1 /* 2 * Copyright (C) 2010 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package android.hardware.usb; 18 19 import android.service.ServiceProtoEnums; 20 21 /** 22 * Contains constants for the USB protocol. 23 * These constants correspond to definitions in linux/usb/ch9.h in the linux kernel. 24 */ 25 public final class UsbConstants { 26 27 /** 28 * Bitmask used for extracting the {@link UsbEndpoint} direction from its address field. 29 * @see UsbEndpoint#getAddress 30 * @see UsbEndpoint#getDirection 31 * @see #USB_DIR_OUT 32 * @see #USB_DIR_IN 33 * 34 */ 35 public static final int USB_ENDPOINT_DIR_MASK = 0x80; 36 /** 37 * Used to signify direction of data for a {@link UsbEndpoint} is OUT (host to device) 38 * @see UsbEndpoint#getDirection 39 */ 40 public static final int USB_DIR_OUT = ServiceProtoEnums.USB_ENDPOINT_DIR_OUT; // 0 41 /** 42 * Used to signify direction of data for a {@link UsbEndpoint} is IN (device to host) 43 * @see UsbEndpoint#getDirection 44 */ 45 public static final int USB_DIR_IN = ServiceProtoEnums.USB_ENDPOINT_DIR_IN; // 0x80 46 47 /** 48 * Bitmask used for extracting the {@link UsbEndpoint} number its address field. 49 * @see UsbEndpoint#getAddress 50 * @see UsbEndpoint#getEndpointNumber 51 */ 52 public static final int USB_ENDPOINT_NUMBER_MASK = 0x0f; 53 54 /** 55 * Bitmask used for extracting the {@link UsbEndpoint} type from its address field. 56 * @see UsbEndpoint#getAddress 57 * @see UsbEndpoint#getType 58 * @see #USB_ENDPOINT_XFER_CONTROL 59 * @see #USB_ENDPOINT_XFER_ISOC 60 * @see #USB_ENDPOINT_XFER_BULK 61 * @see #USB_ENDPOINT_XFER_INT 62 */ 63 public static final int USB_ENDPOINT_XFERTYPE_MASK = 0x03; 64 /** 65 * Control endpoint type (endpoint zero) 66 * @see UsbEndpoint#getType 67 */ 68 public static final int USB_ENDPOINT_XFER_CONTROL = 69 ServiceProtoEnums.USB_ENDPOINT_TYPE_XFER_CONTROL; // 0 70 /** 71 * Isochronous endpoint type (currently not supported) 72 * @see UsbEndpoint#getType 73 */ 74 public static final int USB_ENDPOINT_XFER_ISOC = 75 ServiceProtoEnums.USB_ENDPOINT_TYPE_XFER_ISOC; // 1 76 /** 77 * Bulk endpoint type 78 * @see UsbEndpoint#getType 79 */ 80 public static final int USB_ENDPOINT_XFER_BULK = 81 ServiceProtoEnums.USB_ENDPOINT_TYPE_XFER_BULK; // 2 82 /** 83 * Interrupt endpoint type 84 * @see UsbEndpoint#getType 85 */ 86 public static final int USB_ENDPOINT_XFER_INT = 87 ServiceProtoEnums.USB_ENDPOINT_TYPE_XFER_INT; // 3 88 89 90 /** 91 * Bitmask used for encoding the request type for a control request on endpoint zero. 92 */ 93 public static final int USB_TYPE_MASK = (0x03 << 5); 94 /** 95 * Used to specify that an endpoint zero control request is a standard request. 96 */ 97 public static final int USB_TYPE_STANDARD = (0x00 << 5); 98 /** 99 * Used to specify that an endpoint zero control request is a class specific request. 100 */ 101 public static final int USB_TYPE_CLASS = (0x01 << 5); 102 /** 103 * Used to specify that an endpoint zero control request is a vendor specific request. 104 */ 105 public static final int USB_TYPE_VENDOR = (0x02 << 5); 106 /** 107 * Reserved endpoint zero control request type (currently unused). 108 */ 109 public static final int USB_TYPE_RESERVED = (0x03 << 5); 110 111 112 /** 113 * USB class indicating that the class is determined on a per-interface basis. 114 */ 115 public static final int USB_CLASS_PER_INTERFACE = 0; 116 /** 117 * USB class for audio devices. 118 */ 119 public static final int USB_CLASS_AUDIO = 1; 120 /** 121 * USB class for communication devices. 122 */ 123 public static final int USB_CLASS_COMM = 2; 124 /** 125 * USB class for human interface devices (for example, mice and keyboards). 126 */ 127 public static final int USB_CLASS_HID = 3; 128 /** 129 * USB class for physical devices. 130 */ 131 public static final int USB_CLASS_PHYSICA = 5; 132 /** 133 * USB class for still image devices (digital cameras). 134 */ 135 public static final int USB_CLASS_STILL_IMAGE = 6; 136 /** 137 * USB class for printers. 138 */ 139 public static final int USB_CLASS_PRINTER = 7; 140 /** 141 * USB class for mass storage devices. 142 */ 143 public static final int USB_CLASS_MASS_STORAGE = 8; 144 /** 145 * USB class for USB hubs. 146 */ 147 public static final int USB_CLASS_HUB = 9; 148 /** 149 * USB class for CDC devices (communications device class). 150 */ 151 public static final int USB_CLASS_CDC_DATA = 0x0a; 152 /** 153 * USB class for content smart card devices. 154 */ 155 public static final int USB_CLASS_CSCID = 0x0b; 156 /** 157 * USB class for content security devices. 158 */ 159 public static final int USB_CLASS_CONTENT_SEC = 0x0d; 160 /** 161 * USB class for video devices. 162 */ 163 public static final int USB_CLASS_VIDEO = 0x0e; 164 /** 165 * USB class for wireless controller devices. 166 */ 167 public static final int USB_CLASS_WIRELESS_CONTROLLER = 0xe0; 168 /** 169 * USB class for wireless miscellaneous devices. 170 */ 171 public static final int USB_CLASS_MISC = 0xef; 172 /** 173 * Application specific USB class. 174 */ 175 public static final int USB_CLASS_APP_SPEC = 0xfe; 176 /** 177 * Vendor specific USB class. 178 */ 179 public static final int USB_CLASS_VENDOR_SPEC = 0xff; 180 181 /** 182 * Boot subclass for HID devices. 183 */ 184 public static final int USB_INTERFACE_SUBCLASS_BOOT = 1; 185 /** 186 * Vendor specific USB subclass. 187 */ 188 public static final int USB_SUBCLASS_VENDOR_SPEC = 0xff; 189 } 190