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
18 FUNCTIONFS_HAS_FS_DESC = 1,18 FUNCTIONFS_HAS_FS_DESC = 1,
19 FUNCTIONFS_HAS_HS_DESC = 2,19 FUNCTIONFS_HAS_HS_DESC = 2,
20 FUNCTIONFS_HAS_SS_DESC = 4,20 FUNCTIONFS_HAS_SS_DESC = 4,
21 FUNCTIONFS_HAS_MS_OS_DESC = 8,
21};22};
22 23
23#ifndef __KERNEL__
24
25/* Descriptor of an non-audio endpoint */24/* Descriptor of an non-audio endpoint */
26struct usb_endpoint_descriptor_no_audio {25struct usb_endpoint_descriptor_no_audio {
27 __u8 bLength;26 __u8 bLength;
@@ -33,6 +32,36 @@ struct usb_endpoint_descriptor_no_audio { · 5 unmodified lines
33 __u8 bInterval;32 __u8 bInterval;
34} __attribute__((packed));33} __attribute__((packed));
35 34
35/* MS OS Descriptor header */
36struct 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
50struct usb_ext_compat_desc {
51 __u8 bFirstInterfaceNumber;
52 __u8 Reserved1;
53 __u8 CompatibleID[8];
54 __u8 SubCompatibleID[8];
55 __u8 Reserved2[6];
56};
57
58struct 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 * Descriptors format:67 * Descriptors format:
@@ -45,9 +74,11 @@ struct usb_endpoint_descriptor_no_audio { · 6 unmodified lines
45 * | | fs_count | LE32 | number of full-speed descriptors |74 * | | fs_count | LE32 | number of full-speed descriptors |
46 * | | hs_count | LE32 | number of high-speed descriptors |75 * | | hs_count | LE32 | number of high-speed descriptors |
47 * | | ss_count | LE32 | number of super-speed descriptors |76 * | | ss_count | LE32 | number of super-speed descriptors |
77 * | | os_count | LE32 | number of MS OS descriptors |
48 * | | fs_descrs | Descriptor[] | list of full-speed descriptors |78 * | | fs_descrs | Descriptor[] | list of full-speed descriptors |
49 * | | hs_descrs | Descriptor[] | list of high-speed descriptors |79 * | | hs_descrs | Descriptor[] | list of high-speed descriptors |
50 * | | ss_descrs | Descriptor[] | list of super-speed descriptors |80 * | | ss_descrs | Descriptor[] | list of super-speed descriptors |
81 * | | os_descrs | OSDesc[] | list of MS OS descriptors |
51 *82 *
52 * Depending on which flags are set, various fields may be missing in the83 * Depending on which flags are set, various fields may be missing in the
53 * structure. Any flags that are not recognised cause the whole block to be84 * 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 * | 0 | bLength | U8 | length of the descriptor |105 * | 0 | bLength | U8 | length of the descriptor |
75 * | 1 | bDescriptorType | U8 | descriptor type |106 * | 1 | bDescriptorType | U8 | descriptor type |
76 * | 2 | payload | | descriptor's payload |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
79struct usb_functionfs_strings_head {156struct usb_functionfs_strings_head {