Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/sujqvwi/ShExBy/shex_roo.../usr/include/linux/usb
File: ch9.h
/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
[0] Fix | Delete
/*
[1] Fix | Delete
* This file holds USB constants and structures that are needed for
[2] Fix | Delete
* USB device APIs. These are used by the USB device model, which is
[3] Fix | Delete
* defined in chapter 9 of the USB 2.0 specification and in the
[4] Fix | Delete
* Wireless USB 1.0 (spread around). Linux has several APIs in C that
[5] Fix | Delete
* need these:
[6] Fix | Delete
*
[7] Fix | Delete
* - the master/host side Linux-USB kernel driver API;
[8] Fix | Delete
* - the "usbfs" user space API; and
[9] Fix | Delete
* - the Linux "gadget" slave/device/peripheral side driver API.
[10] Fix | Delete
*
[11] Fix | Delete
* USB 2.0 adds an additional "On The Go" (OTG) mode, which lets systems
[12] Fix | Delete
* act either as a USB master/host or as a USB slave/device. That means
[13] Fix | Delete
* the master and slave side APIs benefit from working well together.
[14] Fix | Delete
*
[15] Fix | Delete
* There's also "Wireless USB", using low power short range radios for
[16] Fix | Delete
* peripheral interconnection but otherwise building on the USB framework.
[17] Fix | Delete
*
[18] Fix | Delete
* Note all descriptors are declared '__attribute__((packed))' so that:
[19] Fix | Delete
*
[20] Fix | Delete
* [a] they never get padded, either internally (USB spec writers
[21] Fix | Delete
* probably handled that) or externally;
[22] Fix | Delete
*
[23] Fix | Delete
* [b] so that accessing bigger-than-a-bytes fields will never
[24] Fix | Delete
* generate bus errors on any platform, even when the location of
[25] Fix | Delete
* its descriptor inside a bundle isn't "naturally aligned", and
[26] Fix | Delete
*
[27] Fix | Delete
* [c] for consistency, removing all doubt even when it appears to
[28] Fix | Delete
* someone that the two other points are non-issues for that
[29] Fix | Delete
* particular descriptor type.
[30] Fix | Delete
*/
[31] Fix | Delete
[32] Fix | Delete
#ifndef __LINUX_USB_CH9_H
[33] Fix | Delete
#define __LINUX_USB_CH9_H
[34] Fix | Delete
[35] Fix | Delete
#include <linux/types.h> /* __u8 etc */
[36] Fix | Delete
#include <asm/byteorder.h> /* le16_to_cpu */
[37] Fix | Delete
[38] Fix | Delete
/*-------------------------------------------------------------------------*/
[39] Fix | Delete
[40] Fix | Delete
/* CONTROL REQUEST SUPPORT */
[41] Fix | Delete
[42] Fix | Delete
/*
[43] Fix | Delete
* USB directions
[44] Fix | Delete
*
[45] Fix | Delete
* This bit flag is used in endpoint descriptors' bEndpointAddress field.
[46] Fix | Delete
* It's also one of three fields in control requests bRequestType.
[47] Fix | Delete
*/
[48] Fix | Delete
#define USB_DIR_OUT 0 /* to device */
[49] Fix | Delete
#define USB_DIR_IN 0x80 /* to host */
[50] Fix | Delete
[51] Fix | Delete
/*
[52] Fix | Delete
* USB types, the second of three bRequestType fields
[53] Fix | Delete
*/
[54] Fix | Delete
#define USB_TYPE_MASK (0x03 << 5)
[55] Fix | Delete
#define USB_TYPE_STANDARD (0x00 << 5)
[56] Fix | Delete
#define USB_TYPE_CLASS (0x01 << 5)
[57] Fix | Delete
#define USB_TYPE_VENDOR (0x02 << 5)
[58] Fix | Delete
#define USB_TYPE_RESERVED (0x03 << 5)
[59] Fix | Delete
[60] Fix | Delete
/*
[61] Fix | Delete
* USB recipients, the third of three bRequestType fields
[62] Fix | Delete
*/
[63] Fix | Delete
#define USB_RECIP_MASK 0x1f
[64] Fix | Delete
#define USB_RECIP_DEVICE 0x00
[65] Fix | Delete
#define USB_RECIP_INTERFACE 0x01
[66] Fix | Delete
#define USB_RECIP_ENDPOINT 0x02
[67] Fix | Delete
#define USB_RECIP_OTHER 0x03
[68] Fix | Delete
/* From Wireless USB 1.0 */
[69] Fix | Delete
#define USB_RECIP_PORT 0x04
[70] Fix | Delete
#define USB_RECIP_RPIPE 0x05
[71] Fix | Delete
[72] Fix | Delete
/*
[73] Fix | Delete
* Standard requests, for the bRequest field of a SETUP packet.
[74] Fix | Delete
*
[75] Fix | Delete
* These are qualified by the bRequestType field, so that for example
[76] Fix | Delete
* TYPE_CLASS or TYPE_VENDOR specific feature flags could be retrieved
[77] Fix | Delete
* by a GET_STATUS request.
[78] Fix | Delete
*/
[79] Fix | Delete
#define USB_REQ_GET_STATUS 0x00
[80] Fix | Delete
#define USB_REQ_CLEAR_FEATURE 0x01
[81] Fix | Delete
#define USB_REQ_SET_FEATURE 0x03
[82] Fix | Delete
#define USB_REQ_SET_ADDRESS 0x05
[83] Fix | Delete
#define USB_REQ_GET_DESCRIPTOR 0x06
[84] Fix | Delete
#define USB_REQ_SET_DESCRIPTOR 0x07
[85] Fix | Delete
#define USB_REQ_GET_CONFIGURATION 0x08
[86] Fix | Delete
#define USB_REQ_SET_CONFIGURATION 0x09
[87] Fix | Delete
#define USB_REQ_GET_INTERFACE 0x0A
[88] Fix | Delete
#define USB_REQ_SET_INTERFACE 0x0B
[89] Fix | Delete
#define USB_REQ_SYNCH_FRAME 0x0C
[90] Fix | Delete
#define USB_REQ_SET_SEL 0x30
[91] Fix | Delete
#define USB_REQ_SET_ISOCH_DELAY 0x31
[92] Fix | Delete
[93] Fix | Delete
#define USB_REQ_SET_ENCRYPTION 0x0D /* Wireless USB */
[94] Fix | Delete
#define USB_REQ_GET_ENCRYPTION 0x0E
[95] Fix | Delete
#define USB_REQ_RPIPE_ABORT 0x0E
[96] Fix | Delete
#define USB_REQ_SET_HANDSHAKE 0x0F
[97] Fix | Delete
#define USB_REQ_RPIPE_RESET 0x0F
[98] Fix | Delete
#define USB_REQ_GET_HANDSHAKE 0x10
[99] Fix | Delete
#define USB_REQ_SET_CONNECTION 0x11
[100] Fix | Delete
#define USB_REQ_SET_SECURITY_DATA 0x12
[101] Fix | Delete
#define USB_REQ_GET_SECURITY_DATA 0x13
[102] Fix | Delete
#define USB_REQ_SET_WUSB_DATA 0x14
[103] Fix | Delete
#define USB_REQ_LOOPBACK_DATA_WRITE 0x15
[104] Fix | Delete
#define USB_REQ_LOOPBACK_DATA_READ 0x16
[105] Fix | Delete
#define USB_REQ_SET_INTERFACE_DS 0x17
[106] Fix | Delete
[107] Fix | Delete
/* specific requests for USB Power Delivery */
[108] Fix | Delete
#define USB_REQ_GET_PARTNER_PDO 20
[109] Fix | Delete
#define USB_REQ_GET_BATTERY_STATUS 21
[110] Fix | Delete
#define USB_REQ_SET_PDO 22
[111] Fix | Delete
#define USB_REQ_GET_VDM 23
[112] Fix | Delete
#define USB_REQ_SEND_VDM 24
[113] Fix | Delete
[114] Fix | Delete
/* The Link Power Management (LPM) ECN defines USB_REQ_TEST_AND_SET command,
[115] Fix | Delete
* used by hubs to put ports into a new L1 suspend state, except that it
[116] Fix | Delete
* forgot to define its number ...
[117] Fix | Delete
*/
[118] Fix | Delete
[119] Fix | Delete
/*
[120] Fix | Delete
* USB feature flags are written using USB_REQ_{CLEAR,SET}_FEATURE, and
[121] Fix | Delete
* are read as a bit array returned by USB_REQ_GET_STATUS. (So there
[122] Fix | Delete
* are at most sixteen features of each type.) Hubs may also support a
[123] Fix | Delete
* new USB_REQ_TEST_AND_SET_FEATURE to put ports into L1 suspend.
[124] Fix | Delete
*/
[125] Fix | Delete
#define USB_DEVICE_SELF_POWERED 0 /* (read only) */
[126] Fix | Delete
#define USB_DEVICE_REMOTE_WAKEUP 1 /* dev may initiate wakeup */
[127] Fix | Delete
#define USB_DEVICE_TEST_MODE 2 /* (wired high speed only) */
[128] Fix | Delete
#define USB_DEVICE_BATTERY 2 /* (wireless) */
[129] Fix | Delete
#define USB_DEVICE_B_HNP_ENABLE 3 /* (otg) dev may initiate HNP */
[130] Fix | Delete
#define USB_DEVICE_WUSB_DEVICE 3 /* (wireless)*/
[131] Fix | Delete
#define USB_DEVICE_A_HNP_SUPPORT 4 /* (otg) RH port supports HNP */
[132] Fix | Delete
#define USB_DEVICE_A_ALT_HNP_SUPPORT 5 /* (otg) other RH port does */
[133] Fix | Delete
#define USB_DEVICE_DEBUG_MODE 6 /* (special devices only) */
[134] Fix | Delete
[135] Fix | Delete
/*
[136] Fix | Delete
* Test Mode Selectors
[137] Fix | Delete
* See USB 2.0 spec Table 9-7
[138] Fix | Delete
*/
[139] Fix | Delete
#define TEST_J 1
[140] Fix | Delete
#define TEST_K 2
[141] Fix | Delete
#define TEST_SE0_NAK 3
[142] Fix | Delete
#define TEST_PACKET 4
[143] Fix | Delete
#define TEST_FORCE_EN 5
[144] Fix | Delete
[145] Fix | Delete
/* Status Type */
[146] Fix | Delete
#define USB_STATUS_TYPE_STANDARD 0
[147] Fix | Delete
#define USB_STATUS_TYPE_PTM 1
[148] Fix | Delete
[149] Fix | Delete
/*
[150] Fix | Delete
* New Feature Selectors as added by USB 3.0
[151] Fix | Delete
* See USB 3.0 spec Table 9-7
[152] Fix | Delete
*/
[153] Fix | Delete
#define USB_DEVICE_U1_ENABLE 48 /* dev may initiate U1 transition */
[154] Fix | Delete
#define USB_DEVICE_U2_ENABLE 49 /* dev may initiate U2 transition */
[155] Fix | Delete
#define USB_DEVICE_LTM_ENABLE 50 /* dev may send LTM */
[156] Fix | Delete
#define USB_INTRF_FUNC_SUSPEND 0 /* function suspend */
[157] Fix | Delete
[158] Fix | Delete
#define USB_INTR_FUNC_SUSPEND_OPT_MASK 0xFF00
[159] Fix | Delete
/*
[160] Fix | Delete
* Suspend Options, Table 9-8 USB 3.0 spec
[161] Fix | Delete
*/
[162] Fix | Delete
#define USB_INTRF_FUNC_SUSPEND_LP (1 << (8 + 0))
[163] Fix | Delete
#define USB_INTRF_FUNC_SUSPEND_RW (1 << (8 + 1))
[164] Fix | Delete
[165] Fix | Delete
/*
[166] Fix | Delete
* Interface status, Figure 9-5 USB 3.0 spec
[167] Fix | Delete
*/
[168] Fix | Delete
#define USB_INTRF_STAT_FUNC_RW_CAP 1
[169] Fix | Delete
#define USB_INTRF_STAT_FUNC_RW 2
[170] Fix | Delete
[171] Fix | Delete
#define USB_ENDPOINT_HALT 0 /* IN/OUT will STALL */
[172] Fix | Delete
[173] Fix | Delete
/* Bit array elements as returned by the USB_REQ_GET_STATUS request. */
[174] Fix | Delete
#define USB_DEV_STAT_U1_ENABLED 2 /* transition into U1 state */
[175] Fix | Delete
#define USB_DEV_STAT_U2_ENABLED 3 /* transition into U2 state */
[176] Fix | Delete
#define USB_DEV_STAT_LTM_ENABLED 4 /* Latency tolerance messages */
[177] Fix | Delete
[178] Fix | Delete
/*
[179] Fix | Delete
* Feature selectors from Table 9-8 USB Power Delivery spec
[180] Fix | Delete
*/
[181] Fix | Delete
#define USB_DEVICE_BATTERY_WAKE_MASK 40
[182] Fix | Delete
#define USB_DEVICE_OS_IS_PD_AWARE 41
[183] Fix | Delete
#define USB_DEVICE_POLICY_MODE 42
[184] Fix | Delete
#define USB_PORT_PR_SWAP 43
[185] Fix | Delete
#define USB_PORT_GOTO_MIN 44
[186] Fix | Delete
#define USB_PORT_RETURN_POWER 45
[187] Fix | Delete
#define USB_PORT_ACCEPT_PD_REQUEST 46
[188] Fix | Delete
#define USB_PORT_REJECT_PD_REQUEST 47
[189] Fix | Delete
#define USB_PORT_PORT_PD_RESET 48
[190] Fix | Delete
#define USB_PORT_C_PORT_PD_CHANGE 49
[191] Fix | Delete
#define USB_PORT_CABLE_PD_RESET 50
[192] Fix | Delete
#define USB_DEVICE_CHARGING_POLICY 54
[193] Fix | Delete
[194] Fix | Delete
/**
[195] Fix | Delete
* struct usb_ctrlrequest - SETUP data for a USB device control request
[196] Fix | Delete
* @bRequestType: matches the USB bmRequestType field
[197] Fix | Delete
* @bRequest: matches the USB bRequest field
[198] Fix | Delete
* @wValue: matches the USB wValue field (le16 byte order)
[199] Fix | Delete
* @wIndex: matches the USB wIndex field (le16 byte order)
[200] Fix | Delete
* @wLength: matches the USB wLength field (le16 byte order)
[201] Fix | Delete
*
[202] Fix | Delete
* This structure is used to send control requests to a USB device. It matches
[203] Fix | Delete
* the different fields of the USB 2.0 Spec section 9.3, table 9-2. See the
[204] Fix | Delete
* USB spec for a fuller description of the different fields, and what they are
[205] Fix | Delete
* used for.
[206] Fix | Delete
*
[207] Fix | Delete
* Note that the driver for any interface can issue control requests.
[208] Fix | Delete
* For most devices, interfaces don't coordinate with each other, so
[209] Fix | Delete
* such requests may be made at any time.
[210] Fix | Delete
*/
[211] Fix | Delete
struct usb_ctrlrequest {
[212] Fix | Delete
__u8 bRequestType;
[213] Fix | Delete
__u8 bRequest;
[214] Fix | Delete
__le16 wValue;
[215] Fix | Delete
__le16 wIndex;
[216] Fix | Delete
__le16 wLength;
[217] Fix | Delete
} __attribute__ ((packed));
[218] Fix | Delete
[219] Fix | Delete
/*-------------------------------------------------------------------------*/
[220] Fix | Delete
[221] Fix | Delete
/*
[222] Fix | Delete
* STANDARD DESCRIPTORS ... as returned by GET_DESCRIPTOR, or
[223] Fix | Delete
* (rarely) accepted by SET_DESCRIPTOR.
[224] Fix | Delete
*
[225] Fix | Delete
* Note that all multi-byte values here are encoded in little endian
[226] Fix | Delete
* byte order "on the wire". Within the kernel and when exposed
[227] Fix | Delete
* through the Linux-USB APIs, they are not converted to cpu byte
[228] Fix | Delete
* order; it is the responsibility of the client code to do this.
[229] Fix | Delete
* The single exception is when device and configuration descriptors (but
[230] Fix | Delete
* not other descriptors) are read from character devices
[231] Fix | Delete
* (i.e. /dev/bus/usb/BBB/DDD);
[232] Fix | Delete
* in this case the fields are converted to host endianness by the kernel.
[233] Fix | Delete
*/
[234] Fix | Delete
[235] Fix | Delete
/*
[236] Fix | Delete
* Descriptor types ... USB 2.0 spec table 9.5
[237] Fix | Delete
*/
[238] Fix | Delete
#define USB_DT_DEVICE 0x01
[239] Fix | Delete
#define USB_DT_CONFIG 0x02
[240] Fix | Delete
#define USB_DT_STRING 0x03
[241] Fix | Delete
#define USB_DT_INTERFACE 0x04
[242] Fix | Delete
#define USB_DT_ENDPOINT 0x05
[243] Fix | Delete
#define USB_DT_DEVICE_QUALIFIER 0x06
[244] Fix | Delete
#define USB_DT_OTHER_SPEED_CONFIG 0x07
[245] Fix | Delete
#define USB_DT_INTERFACE_POWER 0x08
[246] Fix | Delete
/* these are from a minor usb 2.0 revision (ECN) */
[247] Fix | Delete
#define USB_DT_OTG 0x09
[248] Fix | Delete
#define USB_DT_DEBUG 0x0a
[249] Fix | Delete
#define USB_DT_INTERFACE_ASSOCIATION 0x0b
[250] Fix | Delete
/* these are from the Wireless USB spec */
[251] Fix | Delete
#define USB_DT_SECURITY 0x0c
[252] Fix | Delete
#define USB_DT_KEY 0x0d
[253] Fix | Delete
#define USB_DT_ENCRYPTION_TYPE 0x0e
[254] Fix | Delete
#define USB_DT_BOS 0x0f
[255] Fix | Delete
#define USB_DT_DEVICE_CAPABILITY 0x10
[256] Fix | Delete
#define USB_DT_WIRELESS_ENDPOINT_COMP 0x11
[257] Fix | Delete
#define USB_DT_WIRE_ADAPTER 0x21
[258] Fix | Delete
#define USB_DT_RPIPE 0x22
[259] Fix | Delete
#define USB_DT_CS_RADIO_CONTROL 0x23
[260] Fix | Delete
/* From the T10 UAS specification */
[261] Fix | Delete
#define USB_DT_PIPE_USAGE 0x24
[262] Fix | Delete
/* From the USB 3.0 spec */
[263] Fix | Delete
#define USB_DT_SS_ENDPOINT_COMP 0x30
[264] Fix | Delete
/* From the USB 3.1 spec */
[265] Fix | Delete
#define USB_DT_SSP_ISOC_ENDPOINT_COMP 0x31
[266] Fix | Delete
[267] Fix | Delete
/* Conventional codes for class-specific descriptors. The convention is
[268] Fix | Delete
* defined in the USB "Common Class" Spec (3.11). Individual class specs
[269] Fix | Delete
* are authoritative for their usage, not the "common class" writeup.
[270] Fix | Delete
*/
[271] Fix | Delete
#define USB_DT_CS_DEVICE (USB_TYPE_CLASS | USB_DT_DEVICE)
[272] Fix | Delete
#define USB_DT_CS_CONFIG (USB_TYPE_CLASS | USB_DT_CONFIG)
[273] Fix | Delete
#define USB_DT_CS_STRING (USB_TYPE_CLASS | USB_DT_STRING)
[274] Fix | Delete
#define USB_DT_CS_INTERFACE (USB_TYPE_CLASS | USB_DT_INTERFACE)
[275] Fix | Delete
#define USB_DT_CS_ENDPOINT (USB_TYPE_CLASS | USB_DT_ENDPOINT)
[276] Fix | Delete
[277] Fix | Delete
/* All standard descriptors have these 2 fields at the beginning */
[278] Fix | Delete
struct usb_descriptor_header {
[279] Fix | Delete
__u8 bLength;
[280] Fix | Delete
__u8 bDescriptorType;
[281] Fix | Delete
} __attribute__ ((packed));
[282] Fix | Delete
[283] Fix | Delete
[284] Fix | Delete
/*-------------------------------------------------------------------------*/
[285] Fix | Delete
[286] Fix | Delete
/* USB_DT_DEVICE: Device descriptor */
[287] Fix | Delete
struct usb_device_descriptor {
[288] Fix | Delete
__u8 bLength;
[289] Fix | Delete
__u8 bDescriptorType;
[290] Fix | Delete
[291] Fix | Delete
__le16 bcdUSB;
[292] Fix | Delete
__u8 bDeviceClass;
[293] Fix | Delete
__u8 bDeviceSubClass;
[294] Fix | Delete
__u8 bDeviceProtocol;
[295] Fix | Delete
__u8 bMaxPacketSize0;
[296] Fix | Delete
__le16 idVendor;
[297] Fix | Delete
__le16 idProduct;
[298] Fix | Delete
__le16 bcdDevice;
[299] Fix | Delete
__u8 iManufacturer;
[300] Fix | Delete
__u8 iProduct;
[301] Fix | Delete
__u8 iSerialNumber;
[302] Fix | Delete
__u8 bNumConfigurations;
[303] Fix | Delete
} __attribute__ ((packed));
[304] Fix | Delete
[305] Fix | Delete
#define USB_DT_DEVICE_SIZE 18
[306] Fix | Delete
[307] Fix | Delete
[308] Fix | Delete
/*
[309] Fix | Delete
* Device and/or Interface Class codes
[310] Fix | Delete
* as found in bDeviceClass or bInterfaceClass
[311] Fix | Delete
* and defined by www.usb.org documents
[312] Fix | Delete
*/
[313] Fix | Delete
#define USB_CLASS_PER_INTERFACE 0 /* for DeviceClass */
[314] Fix | Delete
#define USB_CLASS_AUDIO 1
[315] Fix | Delete
#define USB_CLASS_COMM 2
[316] Fix | Delete
#define USB_CLASS_HID 3
[317] Fix | Delete
#define USB_CLASS_PHYSICAL 5
[318] Fix | Delete
#define USB_CLASS_STILL_IMAGE 6
[319] Fix | Delete
#define USB_CLASS_PRINTER 7
[320] Fix | Delete
#define USB_CLASS_MASS_STORAGE 8
[321] Fix | Delete
#define USB_CLASS_HUB 9
[322] Fix | Delete
#define USB_CLASS_CDC_DATA 0x0a
[323] Fix | Delete
#define USB_CLASS_CSCID 0x0b /* chip+ smart card */
[324] Fix | Delete
#define USB_CLASS_CONTENT_SEC 0x0d /* content security */
[325] Fix | Delete
#define USB_CLASS_VIDEO 0x0e
[326] Fix | Delete
#define USB_CLASS_WIRELESS_CONTROLLER 0xe0
[327] Fix | Delete
#define USB_CLASS_PERSONAL_HEALTHCARE 0x0f
[328] Fix | Delete
#define USB_CLASS_AUDIO_VIDEO 0x10
[329] Fix | Delete
#define USB_CLASS_BILLBOARD 0x11
[330] Fix | Delete
#define USB_CLASS_USB_TYPE_C_BRIDGE 0x12
[331] Fix | Delete
#define USB_CLASS_MISC 0xef
[332] Fix | Delete
#define USB_CLASS_APP_SPEC 0xfe
[333] Fix | Delete
#define USB_CLASS_VENDOR_SPEC 0xff
[334] Fix | Delete
[335] Fix | Delete
#define USB_SUBCLASS_VENDOR_SPEC 0xff
[336] Fix | Delete
[337] Fix | Delete
/*-------------------------------------------------------------------------*/
[338] Fix | Delete
[339] Fix | Delete
/* USB_DT_CONFIG: Configuration descriptor information.
[340] Fix | Delete
*
[341] Fix | Delete
* USB_DT_OTHER_SPEED_CONFIG is the same descriptor, except that the
[342] Fix | Delete
* descriptor type is different. Highspeed-capable devices can look
[343] Fix | Delete
* different depending on what speed they're currently running. Only
[344] Fix | Delete
* devices with a USB_DT_DEVICE_QUALIFIER have any OTHER_SPEED_CONFIG
[345] Fix | Delete
* descriptors.
[346] Fix | Delete
*/
[347] Fix | Delete
struct usb_config_descriptor {
[348] Fix | Delete
__u8 bLength;
[349] Fix | Delete
__u8 bDescriptorType;
[350] Fix | Delete
[351] Fix | Delete
__le16 wTotalLength;
[352] Fix | Delete
__u8 bNumInterfaces;
[353] Fix | Delete
__u8 bConfigurationValue;
[354] Fix | Delete
__u8 iConfiguration;
[355] Fix | Delete
__u8 bmAttributes;
[356] Fix | Delete
__u8 bMaxPower;
[357] Fix | Delete
} __attribute__ ((packed));
[358] Fix | Delete
[359] Fix | Delete
#define USB_DT_CONFIG_SIZE 9
[360] Fix | Delete
[361] Fix | Delete
/* from config descriptor bmAttributes */
[362] Fix | Delete
#define USB_CONFIG_ATT_ONE (1 << 7) /* must be set */
[363] Fix | Delete
#define USB_CONFIG_ATT_SELFPOWER (1 << 6) /* self powered */
[364] Fix | Delete
#define USB_CONFIG_ATT_WAKEUP (1 << 5) /* can wakeup */
[365] Fix | Delete
#define USB_CONFIG_ATT_BATTERY (1 << 4) /* battery powered */
[366] Fix | Delete
[367] Fix | Delete
/*-------------------------------------------------------------------------*/
[368] Fix | Delete
[369] Fix | Delete
/* USB String descriptors can contain at most 126 characters. */
[370] Fix | Delete
#define USB_MAX_STRING_LEN 126
[371] Fix | Delete
[372] Fix | Delete
/* USB_DT_STRING: String descriptor */
[373] Fix | Delete
struct usb_string_descriptor {
[374] Fix | Delete
__u8 bLength;
[375] Fix | Delete
__u8 bDescriptorType;
[376] Fix | Delete
[377] Fix | Delete
__le16 wData[1]; /* UTF-16LE encoded */
[378] Fix | Delete
} __attribute__ ((packed));
[379] Fix | Delete
[380] Fix | Delete
/* note that "string" zero is special, it holds language codes that
[381] Fix | Delete
* the device supports, not Unicode characters.
[382] Fix | Delete
*/
[383] Fix | Delete
[384] Fix | Delete
/*-------------------------------------------------------------------------*/
[385] Fix | Delete
[386] Fix | Delete
/* USB_DT_INTERFACE: Interface descriptor */
[387] Fix | Delete
struct usb_interface_descriptor {
[388] Fix | Delete
__u8 bLength;
[389] Fix | Delete
__u8 bDescriptorType;
[390] Fix | Delete
[391] Fix | Delete
__u8 bInterfaceNumber;
[392] Fix | Delete
__u8 bAlternateSetting;
[393] Fix | Delete
__u8 bNumEndpoints;
[394] Fix | Delete
__u8 bInterfaceClass;
[395] Fix | Delete
__u8 bInterfaceSubClass;
[396] Fix | Delete
__u8 bInterfaceProtocol;
[397] Fix | Delete
__u8 iInterface;
[398] Fix | Delete
} __attribute__ ((packed));
[399] Fix | Delete
[400] Fix | Delete
#define USB_DT_INTERFACE_SIZE 9
[401] Fix | Delete
[402] Fix | Delete
/*-------------------------------------------------------------------------*/
[403] Fix | Delete
[404] Fix | Delete
/* USB_DT_ENDPOINT: Endpoint descriptor */
[405] Fix | Delete
struct usb_endpoint_descriptor {
[406] Fix | Delete
__u8 bLength;
[407] Fix | Delete
__u8 bDescriptorType;
[408] Fix | Delete
[409] Fix | Delete
__u8 bEndpointAddress;
[410] Fix | Delete
__u8 bmAttributes;
[411] Fix | Delete
__le16 wMaxPacketSize;
[412] Fix | Delete
__u8 bInterval;
[413] Fix | Delete
[414] Fix | Delete
/* NOTE: these two are _only_ in audio endpoints. */
[415] Fix | Delete
/* use USB_DT_ENDPOINT*_SIZE in bLength, not sizeof. */
[416] Fix | Delete
__u8 bRefresh;
[417] Fix | Delete
__u8 bSynchAddress;
[418] Fix | Delete
} __attribute__ ((packed));
[419] Fix | Delete
[420] Fix | Delete
#define USB_DT_ENDPOINT_SIZE 7
[421] Fix | Delete
#define USB_DT_ENDPOINT_AUDIO_SIZE 9 /* Audio extension */
[422] Fix | Delete
[423] Fix | Delete
[424] Fix | Delete
/*
[425] Fix | Delete
* Endpoints
[426] Fix | Delete
*/
[427] Fix | Delete
#define USB_ENDPOINT_NUMBER_MASK 0x0f /* in bEndpointAddress */
[428] Fix | Delete
#define USB_ENDPOINT_DIR_MASK 0x80
[429] Fix | Delete
[430] Fix | Delete
#define USB_ENDPOINT_XFERTYPE_MASK 0x03 /* in bmAttributes */
[431] Fix | Delete
#define USB_ENDPOINT_XFER_CONTROL 0
[432] Fix | Delete
#define USB_ENDPOINT_XFER_ISOC 1
[433] Fix | Delete
#define USB_ENDPOINT_XFER_BULK 2
[434] Fix | Delete
#define USB_ENDPOINT_XFER_INT 3
[435] Fix | Delete
#define USB_ENDPOINT_MAX_ADJUSTABLE 0x80
[436] Fix | Delete
[437] Fix | Delete
#define USB_ENDPOINT_MAXP_MASK 0x07ff
[438] Fix | Delete
#define USB_EP_MAXP_MULT_SHIFT 11
[439] Fix | Delete
#define USB_EP_MAXP_MULT_MASK (3 << USB_EP_MAXP_MULT_SHIFT)
[440] Fix | Delete
#define USB_EP_MAXP_MULT(m) \
[441] Fix | Delete
(((m) & USB_EP_MAXP_MULT_MASK) >> USB_EP_MAXP_MULT_SHIFT)
[442] Fix | Delete
[443] Fix | Delete
/* The USB 3.0 spec redefines bits 5:4 of bmAttributes as interrupt ep type. */
[444] Fix | Delete
#define USB_ENDPOINT_INTRTYPE 0x30
[445] Fix | Delete
#define USB_ENDPOINT_INTR_PERIODIC (0 << 4)
[446] Fix | Delete
#define USB_ENDPOINT_INTR_NOTIFICATION (1 << 4)
[447] Fix | Delete
[448] Fix | Delete
#define USB_ENDPOINT_SYNCTYPE 0x0c
[449] Fix | Delete
#define USB_ENDPOINT_SYNC_NONE (0 << 2)
[450] Fix | Delete
#define USB_ENDPOINT_SYNC_ASYNC (1 << 2)
[451] Fix | Delete
#define USB_ENDPOINT_SYNC_ADAPTIVE (2 << 2)
[452] Fix | Delete
#define USB_ENDPOINT_SYNC_SYNC (3 << 2)
[453] Fix | Delete
[454] Fix | Delete
#define USB_ENDPOINT_USAGE_MASK 0x30
[455] Fix | Delete
#define USB_ENDPOINT_USAGE_DATA 0x00
[456] Fix | Delete
#define USB_ENDPOINT_USAGE_FEEDBACK 0x10
[457] Fix | Delete
#define USB_ENDPOINT_USAGE_IMPLICIT_FB 0x20 /* Implicit feedback Data endpoint */
[458] Fix | Delete
[459] Fix | Delete
/*-------------------------------------------------------------------------*/
[460] Fix | Delete
[461] Fix | Delete
/**
[462] Fix | Delete
* usb_endpoint_num - get the endpoint's number
[463] Fix | Delete
* @epd: endpoint to be checked
[464] Fix | Delete
*
[465] Fix | Delete
* Returns @epd's number: 0 to 15.
[466] Fix | Delete
*/
[467] Fix | Delete
static __inline__ int usb_endpoint_num(const struct usb_endpoint_descriptor *epd)
[468] Fix | Delete
{
[469] Fix | Delete
return epd->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK;
[470] Fix | Delete
}
[471] Fix | Delete
[472] Fix | Delete
/**
[473] Fix | Delete
* usb_endpoint_type - get the endpoint's transfer type
[474] Fix | Delete
* @epd: endpoint to be checked
[475] Fix | Delete
*
[476] Fix | Delete
* Returns one of USB_ENDPOINT_XFER_{CONTROL, ISOC, BULK, INT} according
[477] Fix | Delete
* to @epd's transfer type.
[478] Fix | Delete
*/
[479] Fix | Delete
static __inline__ int usb_endpoint_type(const struct usb_endpoint_descriptor *epd)
[480] Fix | Delete
{
[481] Fix | Delete
return epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK;
[482] Fix | Delete
}
[483] Fix | Delete
[484] Fix | Delete
/**
[485] Fix | Delete
* usb_endpoint_dir_in - check if the endpoint has IN direction
[486] Fix | Delete
* @epd: endpoint to be checked
[487] Fix | Delete
*
[488] Fix | Delete
* Returns true if the endpoint is of type IN, otherwise it returns false.
[489] Fix | Delete
*/
[490] Fix | Delete
static __inline__ int usb_endpoint_dir_in(const struct usb_endpoint_descriptor *epd)
[491] Fix | Delete
{
[492] Fix | Delete
return ((epd->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_IN);
[493] Fix | Delete
}
[494] Fix | Delete
[495] Fix | Delete
/**
[496] Fix | Delete
* usb_endpoint_dir_out - check if the endpoint has OUT direction
[497] Fix | Delete
* @epd: endpoint to be checked
[498] Fix | Delete
*
[499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function