Home | History | Annotate | Download | only in linux
      1 /****************************************************************************
      2  ****************************************************************************
      3  ***
      4  ***   This header was automatically generated from a Linux kernel header
      5  ***   of the same name, to make information necessary for userspace to
      6  ***   call into the kernel available to libc.  It contains only constants,
      7  ***   structures, and macros generated from the original header, and thus,
      8  ***   contains no copyrightable information.
      9  ***
     10  ****************************************************************************
     11  ****************************************************************************/
     12 #ifndef __LINUX_USB_CH9_H
     13 #define __LINUX_USB_CH9_H
     14 
     15 #include <linux/types.h>
     16 
     17 #define USB_DIR_OUT 0
     18 #define USB_DIR_IN 0x80
     19 
     20 #define USB_TYPE_MASK (0x03 << 5)
     21 #define USB_TYPE_STANDARD (0x00 << 5)
     22 #define USB_TYPE_CLASS (0x01 << 5)
     23 #define USB_TYPE_VENDOR (0x02 << 5)
     24 #define USB_TYPE_RESERVED (0x03 << 5)
     25 
     26 #define USB_RECIP_MASK 0x1f
     27 #define USB_RECIP_DEVICE 0x00
     28 #define USB_RECIP_INTERFACE 0x01
     29 #define USB_RECIP_ENDPOINT 0x02
     30 #define USB_RECIP_OTHER 0x03
     31 
     32 #define USB_RECIP_PORT 0x04
     33 #define USB_RECIP_RPIPE 0x05
     34 
     35 #define USB_REQ_GET_STATUS 0x00
     36 #define USB_REQ_CLEAR_FEATURE 0x01
     37 #define USB_REQ_SET_FEATURE 0x03
     38 #define USB_REQ_SET_ADDRESS 0x05
     39 #define USB_REQ_GET_DESCRIPTOR 0x06
     40 #define USB_REQ_SET_DESCRIPTOR 0x07
     41 #define USB_REQ_GET_CONFIGURATION 0x08
     42 #define USB_REQ_SET_CONFIGURATION 0x09
     43 #define USB_REQ_GET_INTERFACE 0x0A
     44 #define USB_REQ_SET_INTERFACE 0x0B
     45 #define USB_REQ_SYNCH_FRAME 0x0C
     46 
     47 #define USB_REQ_SET_ENCRYPTION 0x0D
     48 #define USB_REQ_GET_ENCRYPTION 0x0E
     49 #define USB_REQ_RPIPE_ABORT 0x0E
     50 #define USB_REQ_SET_HANDSHAKE 0x0F
     51 #define USB_REQ_RPIPE_RESET 0x0F
     52 #define USB_REQ_GET_HANDSHAKE 0x10
     53 #define USB_REQ_SET_CONNECTION 0x11
     54 #define USB_REQ_SET_SECURITY_DATA 0x12
     55 #define USB_REQ_GET_SECURITY_DATA 0x13
     56 #define USB_REQ_SET_WUSB_DATA 0x14
     57 #define USB_REQ_LOOPBACK_DATA_WRITE 0x15
     58 #define USB_REQ_LOOPBACK_DATA_READ 0x16
     59 #define USB_REQ_SET_INTERFACE_DS 0x17
     60 
     61 #define USB_DEVICE_SELF_POWERED 0
     62 #define USB_DEVICE_REMOTE_WAKEUP 1
     63 #define USB_DEVICE_TEST_MODE 2
     64 #define USB_DEVICE_BATTERY 2
     65 #define USB_DEVICE_B_HNP_ENABLE 3
     66 #define USB_DEVICE_WUSB_DEVICE 3
     67 #define USB_DEVICE_A_HNP_SUPPORT 4
     68 #define USB_DEVICE_A_ALT_HNP_SUPPORT 5
     69 #define USB_DEVICE_DEBUG_MODE 6
     70 
     71 #define USB_ENDPOINT_HALT 0
     72 
     73 struct usb_ctrlrequest {
     74  __u8 bRequestType;
     75  __u8 bRequest;
     76  __le16 wValue;
     77  __le16 wIndex;
     78  __le16 wLength;
     79 } __attribute__ ((packed));
     80 
     81 #define USB_DT_DEVICE 0x01
     82 #define USB_DT_CONFIG 0x02
     83 #define USB_DT_STRING 0x03
     84 #define USB_DT_INTERFACE 0x04
     85 #define USB_DT_ENDPOINT 0x05
     86 #define USB_DT_DEVICE_QUALIFIER 0x06
     87 #define USB_DT_OTHER_SPEED_CONFIG 0x07
     88 #define USB_DT_INTERFACE_POWER 0x08
     89 
     90 #define USB_DT_OTG 0x09
     91 #define USB_DT_DEBUG 0x0a
     92 #define USB_DT_INTERFACE_ASSOCIATION 0x0b
     93 
     94 #define USB_DT_SECURITY 0x0c
     95 #define USB_DT_KEY 0x0d
     96 #define USB_DT_ENCRYPTION_TYPE 0x0e
     97 #define USB_DT_BOS 0x0f
     98 #define USB_DT_DEVICE_CAPABILITY 0x10
     99 #define USB_DT_WIRELESS_ENDPOINT_COMP 0x11
    100 #define USB_DT_WIRE_ADAPTER 0x21
    101 #define USB_DT_RPIPE 0x22
    102 
    103 #define USB_DT_CS_DEVICE 0x21
    104 #define USB_DT_CS_CONFIG 0x22
    105 #define USB_DT_CS_STRING 0x23
    106 #define USB_DT_CS_INTERFACE 0x24
    107 #define USB_DT_CS_ENDPOINT 0x25
    108 
    109 struct usb_descriptor_header {
    110  __u8 bLength;
    111  __u8 bDescriptorType;
    112 } __attribute__ ((packed));
    113 
    114 struct usb_device_descriptor {
    115  __u8 bLength;
    116  __u8 bDescriptorType;
    117 
    118  __le16 bcdUSB;
    119  __u8 bDeviceClass;
    120  __u8 bDeviceSubClass;
    121  __u8 bDeviceProtocol;
    122  __u8 bMaxPacketSize0;
    123  __le16 idVendor;
    124  __le16 idProduct;
    125  __le16 bcdDevice;
    126  __u8 iManufacturer;
    127  __u8 iProduct;
    128  __u8 iSerialNumber;
    129  __u8 bNumConfigurations;
    130 } __attribute__ ((packed));
    131 
    132 #define USB_DT_DEVICE_SIZE 18
    133 
    134 #define USB_CLASS_PER_INTERFACE 0
    135 #define USB_CLASS_AUDIO 1
    136 #define USB_CLASS_COMM 2
    137 #define USB_CLASS_HID 3
    138 #define USB_CLASS_PHYSICAL 5
    139 #define USB_CLASS_STILL_IMAGE 6
    140 #define USB_CLASS_PRINTER 7
    141 #define USB_CLASS_MASS_STORAGE 8
    142 #define USB_CLASS_HUB 9
    143 #define USB_CLASS_CDC_DATA 0x0a
    144 #define USB_CLASS_CSCID 0x0b
    145 #define USB_CLASS_CONTENT_SEC 0x0d
    146 #define USB_CLASS_VIDEO 0x0e
    147 #define USB_CLASS_WIRELESS_CONTROLLER 0xe0
    148 #define USB_CLASS_APP_SPEC 0xfe
    149 #define USB_CLASS_VENDOR_SPEC 0xff
    150 
    151 struct usb_config_descriptor {
    152  __u8 bLength;
    153  __u8 bDescriptorType;
    154 
    155  __le16 wTotalLength;
    156  __u8 bNumInterfaces;
    157  __u8 bConfigurationValue;
    158  __u8 iConfiguration;
    159  __u8 bmAttributes;
    160  __u8 bMaxPower;
    161 } __attribute__ ((packed));
    162 
    163 #define USB_DT_CONFIG_SIZE 9
    164 
    165 #define USB_CONFIG_ATT_ONE (1 << 7)
    166 #define USB_CONFIG_ATT_SELFPOWER (1 << 6)
    167 #define USB_CONFIG_ATT_WAKEUP (1 << 5)
    168 #define USB_CONFIG_ATT_BATTERY (1 << 4)
    169 
    170 struct usb_string_descriptor {
    171  __u8 bLength;
    172  __u8 bDescriptorType;
    173 
    174  __le16 wData[1];
    175 } __attribute__ ((packed));
    176 
    177 struct usb_interface_descriptor {
    178  __u8 bLength;
    179  __u8 bDescriptorType;
    180 
    181  __u8 bInterfaceNumber;
    182  __u8 bAlternateSetting;
    183  __u8 bNumEndpoints;
    184  __u8 bInterfaceClass;
    185  __u8 bInterfaceSubClass;
    186  __u8 bInterfaceProtocol;
    187  __u8 iInterface;
    188 } __attribute__ ((packed));
    189 
    190 #define USB_DT_INTERFACE_SIZE 9
    191 
    192 struct usb_endpoint_descriptor {
    193  __u8 bLength;
    194  __u8 bDescriptorType;
    195 
    196  __u8 bEndpointAddress;
    197  __u8 bmAttributes;
    198  __le16 wMaxPacketSize;
    199  __u8 bInterval;
    200 
    201  __u8 bRefresh;
    202  __u8 bSynchAddress;
    203 } __attribute__ ((packed));
    204 
    205 #define USB_DT_ENDPOINT_SIZE 7
    206 #define USB_DT_ENDPOINT_AUDIO_SIZE 9
    207 
    208 #define USB_ENDPOINT_NUMBER_MASK 0x0f
    209 #define USB_ENDPOINT_DIR_MASK 0x80
    210 
    211 #define USB_ENDPOINT_XFERTYPE_MASK 0x03
    212 #define USB_ENDPOINT_XFER_CONTROL 0
    213 #define USB_ENDPOINT_XFER_ISOC 1
    214 #define USB_ENDPOINT_XFER_BULK 2
    215 #define USB_ENDPOINT_XFER_INT 3
    216 #define USB_ENDPOINT_MAX_ADJUSTABLE 0x80
    217 
    218 struct usb_qualifier_descriptor {
    219  __u8 bLength;
    220  __u8 bDescriptorType;
    221 
    222  __le16 bcdUSB;
    223  __u8 bDeviceClass;
    224  __u8 bDeviceSubClass;
    225  __u8 bDeviceProtocol;
    226  __u8 bMaxPacketSize0;
    227  __u8 bNumConfigurations;
    228  __u8 bRESERVED;
    229 } __attribute__ ((packed));
    230 
    231 struct usb_otg_descriptor {
    232  __u8 bLength;
    233  __u8 bDescriptorType;
    234 
    235  __u8 bmAttributes;
    236 } __attribute__ ((packed));
    237 
    238 #define USB_OTG_SRP (1 << 0)
    239 #define USB_OTG_HNP (1 << 1)
    240 
    241 struct usb_debug_descriptor {
    242  __u8 bLength;
    243  __u8 bDescriptorType;
    244 
    245  __u8 bDebugInEndpoint;
    246  __u8 bDebugOutEndpoint;
    247 };
    248 
    249 struct usb_interface_assoc_descriptor {
    250  __u8 bLength;
    251  __u8 bDescriptorType;
    252 
    253  __u8 bFirstInterface;
    254  __u8 bInterfaceCount;
    255  __u8 bFunctionClass;
    256  __u8 bFunctionSubClass;
    257  __u8 bFunctionProtocol;
    258  __u8 iFunction;
    259 } __attribute__ ((packed));
    260 
    261 struct usb_security_descriptor {
    262  __u8 bLength;
    263  __u8 bDescriptorType;
    264 
    265  __le16 wTotalLength;
    266  __u8 bNumEncryptionTypes;
    267 };
    268 
    269 struct usb_key_descriptor {
    270  __u8 bLength;
    271  __u8 bDescriptorType;
    272 
    273  __u8 tTKID[3];
    274  __u8 bReserved;
    275  __u8 bKeyData[0];
    276 };
    277 
    278 struct usb_encryption_descriptor {
    279  __u8 bLength;
    280  __u8 bDescriptorType;
    281 
    282  __u8 bEncryptionType;
    283 #define USB_ENC_TYPE_UNSECURE 0
    284 #define USB_ENC_TYPE_WIRED 1
    285 #define USB_ENC_TYPE_CCM_1 2
    286 #define USB_ENC_TYPE_RSA_1 3
    287  __u8 bEncryptionValue;
    288  __u8 bAuthKeyIndex;
    289 };
    290 
    291 struct usb_bos_descriptor {
    292  __u8 bLength;
    293  __u8 bDescriptorType;
    294 
    295  __le16 wTotalLength;
    296  __u8 bNumDeviceCaps;
    297 };
    298 
    299 struct usb_dev_cap_header {
    300  __u8 bLength;
    301  __u8 bDescriptorType;
    302  __u8 bDevCapabilityType;
    303 };
    304 
    305 #define USB_CAP_TYPE_WIRELESS_USB 1
    306 
    307 struct usb_wireless_cap_descriptor {
    308  __u8 bLength;
    309  __u8 bDescriptorType;
    310  __u8 bDevCapabilityType;
    311 
    312  __u8 bmAttributes;
    313 #define USB_WIRELESS_P2P_DRD (1 << 1)
    314 #define USB_WIRELESS_BEACON_MASK (3 << 2)
    315 #define USB_WIRELESS_BEACON_SELF (1 << 2)
    316 #define USB_WIRELESS_BEACON_DIRECTED (2 << 2)
    317 #define USB_WIRELESS_BEACON_NONE (3 << 2)
    318  __le16 wPHYRates;
    319 #define USB_WIRELESS_PHY_53 (1 << 0)
    320 #define USB_WIRELESS_PHY_80 (1 << 1)
    321 #define USB_WIRELESS_PHY_107 (1 << 2)
    322 #define USB_WIRELESS_PHY_160 (1 << 3)
    323 #define USB_WIRELESS_PHY_200 (1 << 4)
    324 #define USB_WIRELESS_PHY_320 (1 << 5)
    325 #define USB_WIRELESS_PHY_400 (1 << 6)
    326 #define USB_WIRELESS_PHY_480 (1 << 7)
    327  __u8 bmTFITXPowerInfo;
    328  __u8 bmFFITXPowerInfo;
    329  __le16 bmBandGroup;
    330  __u8 bReserved;
    331 };
    332 
    333 struct usb_wireless_ep_comp_descriptor {
    334  __u8 bLength;
    335  __u8 bDescriptorType;
    336 
    337  __u8 bMaxBurst;
    338  __u8 bMaxSequence;
    339  __le16 wMaxStreamDelay;
    340  __le16 wOverTheAirPacketSize;
    341  __u8 bOverTheAirInterval;
    342  __u8 bmCompAttributes;
    343 #define USB_ENDPOINT_SWITCH_MASK 0x03
    344 #define USB_ENDPOINT_SWITCH_NO 0
    345 #define USB_ENDPOINT_SWITCH_SWITCH 1
    346 #define USB_ENDPOINT_SWITCH_SCALE 2
    347 };
    348 
    349 struct usb_handshake {
    350  __u8 bMessageNumber;
    351  __u8 bStatus;
    352  __u8 tTKID[3];
    353  __u8 bReserved;
    354  __u8 CDID[16];
    355  __u8 nonce[16];
    356  __u8 MIC[8];
    357 };
    358 
    359 struct usb_connection_context {
    360  __u8 CHID[16];
    361  __u8 CDID[16];
    362  __u8 CK[16];
    363 };
    364 
    365 enum usb_device_speed {
    366  USB_SPEED_UNKNOWN = 0,
    367  USB_SPEED_LOW, USB_SPEED_FULL,
    368  USB_SPEED_HIGH,
    369  USB_SPEED_VARIABLE,
    370 };
    371 
    372 enum usb_device_state {
    373 
    374  USB_STATE_NOTATTACHED = 0,
    375 
    376  USB_STATE_ATTACHED,
    377  USB_STATE_POWERED,
    378  USB_STATE_UNAUTHENTICATED,
    379  USB_STATE_RECONNECTING,
    380  USB_STATE_DEFAULT,
    381  USB_STATE_ADDRESS,
    382  USB_STATE_CONFIGURED,
    383 
    384  USB_STATE_SUSPENDED
    385 
    386 };
    387 
    388 #endif
    389