Add support for OS descriptors. The new format of descriptors is used, because the "flags" field is required for extensions. os_count gives the number of OSDesc[] elements. The format of descriptors is given in include/uapi/linux/usb/functionfs.h. For extended properties descriptor the usb_ext_prop_desc structure covers only a part of a descriptor, because the wPropertyNameLength is unknown up front.
Showing the changes to include/uapi/linux (1 of 3 files). Show all
Unified · Split
| @@ -18,10 +18,9 @@ enum functionfs_flags { · 17 unmodified lines | ||
| 18 | 18 | FUNCTIONFS_HAS_FS_DESC = 1, |
| 19 | 19 | FUNCTIONFS_HAS_HS_DESC = 2, |
| 20 | 20 | FUNCTIONFS_HAS_SS_DESC = 4, |
| 21 | + FUNCTIONFS_HAS_MS_OS_DESC = 8, | |
| 21 | 22 | }; |
| 22 | 23 | |
| 23 | −#ifndef __KERNEL__ | |
| 24 | − | |
| 25 | 24 | /* Descriptor of an non-audio endpoint */ |
| 26 | 25 | struct usb_endpoint_descriptor_no_audio { |
| 27 | 26 | __u8 bLength; |
| @@ -33,6 +32,36 @@ struct usb_endpoint_descriptor_no_audio { · 5 unmodified lines | ||
| 33 | 32 | __u8 bInterval; |
| 34 | 33 | } __attribute__((packed)); |
| 35 | 34 | |
| 35 | +/* MS OS Descriptor header */ | |
| 36 | +struct usb_os_desc_header { | |
| 37 | + __u8 interface; | |
| 38 | + __le32 dwLength; | |
| 39 | + __le16 bcdVersion; | |
| 40 | + __le16 wIndex; | |
| 41 | + union { | |
| 42 | + struct { | |
| 43 | + __u8 bCount; | |
| 44 | + __u8 Reserved; | |
| 45 | + }; | |
| 46 | + __le16 wCount; | |
| 47 | + }; | |
| 48 | +} __attribute__((packed)); | |
| 49 | + | |
| 50 | +struct usb_ext_compat_desc { | |
| 51 | + __u8 bFirstInterfaceNumber; | |
| 52 | + __u8 Reserved1; | |
| 53 | + __u8 CompatibleID[8]; | |
| 54 | + __u8 SubCompatibleID[8]; | |
| 55 | + __u8 Reserved2[6]; | |
| 56 | +}; | |
| 57 | + | |
| 58 | +struct usb_ext_prop_desc { | |
| 59 | + __le32 dwSize; | |
| 60 | + __le32 dwPropertyDataType; | |
| 61 | + __le16 wPropertyNameLength; | |
| 62 | +} __attribute__((packed)); | |
| 63 | + | |
| 64 | +#ifndef __KERNEL__ | |
| 36 | 65 | |
| 37 | 66 | /* |
| 38 | 67 | * Descriptors format: |
| @@ -45,9 +74,11 @@ struct usb_endpoint_descriptor_no_audio { · 6 unmodified lines | ||
| 45 | 74 | * | | fs_count | LE32 | number of full-speed descriptors | |
| 46 | 75 | * | | hs_count | LE32 | number of high-speed descriptors | |
| 47 | 76 | * | | ss_count | LE32 | number of super-speed descriptors | |
| 77 | + * | | os_count | LE32 | number of MS OS descriptors | | |
| 48 | 78 | * | | fs_descrs | Descriptor[] | list of full-speed descriptors | |
| 49 | 79 | * | | hs_descrs | Descriptor[] | list of high-speed descriptors | |
| 50 | 80 | * | | ss_descrs | Descriptor[] | list of super-speed descriptors | |
| 81 | + * | | os_descrs | OSDesc[] | list of MS OS descriptors | | |
| 51 | 82 | * |
| 52 | 83 | * Depending on which flags are set, various fields may be missing in the |
| 53 | 84 | * structure. Any flags that are not recognised cause the whole block to be |
| @@ -74,6 +105,52 @@ struct usb_endpoint_descriptor_no_audio { · 20 unmodified lines | ||
| 74 | 105 | * | 0 | bLength | U8 | length of the descriptor | |
| 75 | 106 | * | 1 | bDescriptorType | U8 | descriptor type | |
| 76 | 107 | * | 2 | payload | | descriptor's payload | |
| 108 | + * | |
| 109 | + * OSDesc[] is an array of valid MS OS Feature Descriptors which have one of | |
| 110 | + * the following formats: | |
| 111 | + * | |
| 112 | + * | off | name | type | description | | |
| 113 | + * |-----+-----------------+------+--------------------------| | |
| 114 | + * | 0 | inteface | U8 | related interface number | | |
| 115 | + * | 1 | dwLength | U32 | length of the descriptor | | |
| 116 | + * | 5 | bcdVersion | U16 | currently supported: 1 | | |
| 117 | + * | 7 | wIndex | U16 | currently supported: 4 | | |
| 118 | + * | 9 | bCount | U8 | number of ext. compat. | | |
| 119 | + * | 10 | Reserved | U8 | 0 | | |
| 120 | + * | 11 | ExtCompat[] | | list of ext. compat. d. | | |
| 121 | + * | |
| 122 | + * | off | name | type | description | | |
| 123 | + * |-----+-----------------+------+--------------------------| | |
| 124 | + * | 0 | inteface | U8 | related interface number | | |
| 125 | + * | 1 | dwLength | U32 | length of the descriptor | | |
| 126 | + * | 5 | bcdVersion | U16 | currently supported: 1 | | |
| 127 | + * | 7 | wIndex | U16 | currently supported: 5 | | |
| 128 | + * | 9 | wCount | U16 | number of ext. compat. | | |
| 129 | + * | 11 | ExtProp[] | | list of ext. prop. d. | | |
| 130 | + * | |
| 131 | + * ExtCompat[] is an array of valid Extended Compatiblity descriptors | |
| 132 | + * which have the following format: | |
| 133 | + * | |
| 134 | + * | off | name | type | description | | |
| 135 | + * |-----+-----------------------+------+-------------------------------------| | |
| 136 | + * | 0 | bFirstInterfaceNumber | U8 | index of the interface or of the 1st| | |
| 137 | + * | | | | interface in an IAD group | | |
| 138 | + * | 1 | Reserved | U8 | 0 | | |
| 139 | + * | 2 | CompatibleID | U8[8]| compatible ID string | | |
| 140 | + * | 10 | SubCompatibleID | U8[8]| subcompatible ID string | | |
| 141 | + * | 18 | Reserved | U8[6]| 0 | | |
| 142 | + * | |
| 143 | + * ExtProp[] is an array of valid Extended Properties descriptors | |
| 144 | + * which have the following format: | |
| 145 | + * | |
| 146 | + * | off | name | type | description | | |
| 147 | + * |-----+-----------------------+------+-------------------------------------| | |
| 148 | + * | 0 | dwSize | U32 | length of the descriptor | | |
| 149 | + * | 4 | dwPropertyDataType | U32 | 1..7 | | |
| 150 | + * | 8 | wPropertyNameLength | U16 | bPropertyName length (NL) | | |
| 151 | + * | 10 | bPropertyName |U8[NL]| name of this property | | |
| 152 | + * |10+NL| dwPropertyDataLength | U32 | bPropertyData length (DL) | | |
| 153 | + * |14+NL| bProperty |U8[DL]| payload of this property | | |
| 77 | 154 | */ |
| 78 | 155 | |
| 79 | 156 | struct usb_functionfs_strings_head { |