aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/usb/composite.h
diff options
context:
space:
mode:
authorAndrzej Pietrasiewicz <andrzej.p@samsung.com>2014-05-08 08:06:23 -0400
committerFelipe Balbi <balbi@ti.com>2014-05-14 10:38:16 -0400
commit37a3a533429ef9b3cc9f15a656c19623f0e88df7 (patch)
tree93746c1babf3172e5d705b6a72fe19e84f7d3362 /include/linux/usb/composite.h
parent19824d5eeecedfb46639961da1b7a21ba3179930 (diff)
usb: gadget: OS Feature Descriptors support
There is a custom (non-USB IF) extension to the USB standard: http://msdn.microsoft.com/library/windows/hardware/gg463182 They grant permission to use the specification - there is "Microsoft OS Descriptor Specification License Agreement" under the link mentioned above, and its Section 2 "Grant of License", letter (b) reads: "Patent license. Microsoft hereby grants to You a nonexclusive, royalty-free, nontransferable, worldwide license under Microsoft’s patents embodied solely within the Specification and that are owned or licensable by Microsoft to make, use, import, offer to sell, sell and distribute directly or indirectly to Your Licensees Your Implementation. You may sublicense this patent license to Your Licensees under the same terms and conditions." The said extension is maintained by Microsoft for Microsoft. Yet it is fairly common for various devices to use it, and a popular proprietary operating system expects devices to provide "OS descriptors", so Linux-based USB gadgets whishing to be able to talk to a variety of operating systems should be able to provide the "OS descriptors". This patch adds optional support for gadgets whishing to expose the so called "OS Feature Descriptors", that is "Extended Compatibility ID" and "Extended Properties". Hosts which do request "OS descriptors" from gadgets do so during the enumeration phase and before the configuration is set with SET_CONFIGURATION. What is more, those hosts never ask for configurations at indices other than 0. Therefore, gadgets whishing to provide "OS descriptors" must designate one configuration to be used with this kind of hosts - this is what os_desc_config is added for in struct usb_composite_dev. There is an additional advantage to it: if a gadget provides "OS descriptors" and designates one configuration to be used with such non-USB-compliant hosts it can invoke "usb_add_config" in any order because the designated configuration will be reported to be at index 0 anyway. This patch also adds handling vendor-specific requests addressed at device or interface and related to handling "OS descriptors". Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com> Acked-by: Michal Nazarewicz <mina86@mina86.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'include/linux/usb/composite.h')
-rw-r--r--include/linux/usb/composite.h58
1 files changed, 58 insertions, 0 deletions
diff --git a/include/linux/usb/composite.h b/include/linux/usb/composite.h
index 7d29ee9363e8..549f5382b01a 100644
--- a/include/linux/usb/composite.h
+++ b/include/linux/usb/composite.h
@@ -57,6 +57,53 @@
57struct usb_configuration; 57struct usb_configuration;
58 58
59/** 59/**
60 * struct usb_os_desc_ext_prop - describes one "Extended Property"
61 * @entry: used to keep a list of extended properties
62 * @type: Extended Property type
63 * @name_len: Extended Property unicode name length, including terminating '\0'
64 * @name: Extended Property name
65 * @data_len: Length of Extended Property blob (for unicode store double len)
66 * @data: Extended Property blob
67 */
68struct usb_os_desc_ext_prop {
69 struct list_head entry;
70 u8 type;
71 int name_len;
72 char *name;
73 int data_len;
74 char *data;
75};
76
77/**
78 * struct usb_os_desc - describes OS descriptors associated with one interface
79 * @ext_compat_id: 16 bytes of "Compatible ID" and "Subcompatible ID"
80 * @ext_prop: Extended Properties list
81 * @ext_prop_len: Total length of Extended Properties blobs
82 * @ext_prop_count: Number of Extended Properties
83 */
84struct usb_os_desc {
85 char *ext_compat_id;
86 struct list_head ext_prop;
87 int ext_prop_len;
88 int ext_prop_count;
89};
90
91/**
92 * struct usb_os_desc_table - describes OS descriptors associated with one
93 * interface of a usb_function
94 * @if_id: Interface id
95 * @os_desc: "Extended Compatibility ID" and "Extended Properties" of the
96 * interface
97 *
98 * Each interface can have at most one "Extended Compatibility ID" and a
99 * number of "Extended Properties".
100 */
101struct usb_os_desc_table {
102 int if_id;
103 struct usb_os_desc *os_desc;
104};
105
106/**
60 * struct usb_function - describes one function of a configuration 107 * struct usb_function - describes one function of a configuration
61 * @name: For diagnostics, identifies the function. 108 * @name: For diagnostics, identifies the function.
62 * @strings: tables of strings, keyed by identifiers assigned during bind() 109 * @strings: tables of strings, keyed by identifiers assigned during bind()
@@ -73,6 +120,10 @@ struct usb_configuration;
73 * be available at super speed. 120 * be available at super speed.
74 * @config: assigned when @usb_add_function() is called; this is the 121 * @config: assigned when @usb_add_function() is called; this is the
75 * configuration with which this function is associated. 122 * configuration with which this function is associated.
123 * @os_desc_table: Table of (interface id, os descriptors) pairs. The function
124 * can expose more than one interface. If an interface is a member of
125 * an IAD, only the first interface of IAD has its entry in the table.
126 * @os_desc_n: Number of entries in os_desc_table
76 * @bind: Before the gadget can register, all of its functions bind() to the 127 * @bind: Before the gadget can register, all of its functions bind() to the
77 * available resources including string and interface identifiers used 128 * available resources including string and interface identifiers used
78 * in interface or class descriptors; endpoints; I/O buffers; and so on. 129 * in interface or class descriptors; endpoints; I/O buffers; and so on.
@@ -129,6 +180,9 @@ struct usb_function {
129 180
130 struct usb_configuration *config; 181 struct usb_configuration *config;
131 182
183 struct usb_os_desc_table *os_desc_table;
184 unsigned os_desc_n;
185
132 /* REVISIT: bind() functions can be marked __init, which 186 /* REVISIT: bind() functions can be marked __init, which
133 * makes trouble for section mismatch analysis. See if 187 * makes trouble for section mismatch analysis. See if
134 * we can't restructure things to avoid mismatching. 188 * we can't restructure things to avoid mismatching.
@@ -342,10 +396,12 @@ static inline struct usb_composite_driver *to_cdriver(
342 * struct usb_composite_device - represents one composite usb gadget 396 * struct usb_composite_device - represents one composite usb gadget
343 * @gadget: read-only, abstracts the gadget's usb peripheral controller 397 * @gadget: read-only, abstracts the gadget's usb peripheral controller
344 * @req: used for control responses; buffer is pre-allocated 398 * @req: used for control responses; buffer is pre-allocated
399 * @os_desc_req: used for OS descriptors responses; buffer is pre-allocated
345 * @config: the currently active configuration 400 * @config: the currently active configuration
346 * @qw_sign: qwSignature part of the OS string 401 * @qw_sign: qwSignature part of the OS string
347 * @b_vendor_code: bMS_VendorCode part of the OS string 402 * @b_vendor_code: bMS_VendorCode part of the OS string
348 * @use_os_string: false by default, interested gadgets set it 403 * @use_os_string: false by default, interested gadgets set it
404 * @os_desc_config: the configuration to be used with OS descriptors
349 * 405 *
350 * One of these devices is allocated and initialized before the 406 * One of these devices is allocated and initialized before the
351 * associated device driver's bind() is called. 407 * associated device driver's bind() is called.
@@ -375,12 +431,14 @@ static inline struct usb_composite_driver *to_cdriver(
375struct usb_composite_dev { 431struct usb_composite_dev {
376 struct usb_gadget *gadget; 432 struct usb_gadget *gadget;
377 struct usb_request *req; 433 struct usb_request *req;
434 struct usb_request *os_desc_req;
378 435
379 struct usb_configuration *config; 436 struct usb_configuration *config;
380 437
381 /* OS String is a custom (yet popular) extension to the USB standard. */ 438 /* OS String is a custom (yet popular) extension to the USB standard. */
382 u8 qw_sign[OS_STRING_QW_SIGN_LEN]; 439 u8 qw_sign[OS_STRING_QW_SIGN_LEN];
383 u8 b_vendor_code; 440 u8 b_vendor_code;
441 struct usb_configuration *os_desc_config;
384 unsigned int use_os_string:1; 442 unsigned int use_os_string:1;
385 443
386 /* private: */ 444 /* private: */