History

usb: gadget: f_fs: OS descriptors support

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.

Andrzej Pietrasiewicz committed 12 years ago

Commit f0175ab1 parent 7ea4f083 files · +419 −10Browse files

Showing the changes to include/uapi/linux (1 of 3 files). Show all

Unified · Split

include/uapi/linux/usb/functionfs.h+79−2
@@ -18,10 +18,9 @@ enum functionfs_flags { · 17 unmodified lines
1818 FUNCTIONFS_HAS_FS_DESC = 1,
1919 FUNCTIONFS_HAS_HS_DESC = 2,
2020 FUNCTIONFS_HAS_SS_DESC = 4,
21+ FUNCTIONFS_HAS_MS_OS_DESC = 8,
2122 };
2223
23−#ifndef __KERNEL__
24−
2524 /* Descriptor of an non-audio endpoint */
2625 struct usb_endpoint_descriptor_no_audio {
2726 __u8 bLength;
@@ -33,6 +32,36 @@ struct usb_endpoint_descriptor_no_audio { · 5 unmodified lines
3332 __u8 bInterval;
3433 } __attribute__((packed));
3534
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__
3665
3766 /*
3867 * Descriptors format:
@@ -45,9 +74,11 @@ struct usb_endpoint_descriptor_no_audio { · 6 unmodified lines
4574 * | | fs_count | LE32 | number of full-speed descriptors |
4675 * | | hs_count | LE32 | number of high-speed descriptors |
4776 * | | ss_count | LE32 | number of super-speed descriptors |
77+ * | | os_count | LE32 | number of MS OS descriptors |
4878 * | | fs_descrs | Descriptor[] | list of full-speed descriptors |
4979 * | | hs_descrs | Descriptor[] | list of high-speed descriptors |
5080 * | | ss_descrs | Descriptor[] | list of super-speed descriptors |
81+ * | | os_descrs | OSDesc[] | list of MS OS descriptors |
5182 *
5283 * Depending on which flags are set, various fields may be missing in the
5384 * 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
74105 * | 0 | bLength | U8 | length of the descriptor |
75106 * | 1 | bDescriptorType | U8 | descriptor type |
76107 * | 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 |
77154 */
78155
79156 struct usb_functionfs_strings_head {