diff options
Diffstat (limited to 'include/linux/usb/composite.h')
| -rw-r--r-- | include/linux/usb/composite.h | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/include/linux/usb/composite.h b/include/linux/usb/composite.h index d3ca3b53837c..7373203140e7 100644 --- a/include/linux/usb/composite.h +++ b/include/linux/usb/composite.h | |||
| @@ -57,6 +57,61 @@ | |||
| 57 | struct usb_configuration; | 57 | struct 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 | * @item: Represents this Extended Property in configfs | ||
| 68 | */ | ||
| 69 | struct usb_os_desc_ext_prop { | ||
| 70 | struct list_head entry; | ||
| 71 | u8 type; | ||
| 72 | int name_len; | ||
| 73 | char *name; | ||
| 74 | int data_len; | ||
| 75 | char *data; | ||
| 76 | struct config_item item; | ||
| 77 | }; | ||
| 78 | |||
| 79 | /** | ||
| 80 | * struct usb_os_desc - describes OS descriptors associated with one interface | ||
| 81 | * @ext_compat_id: 16 bytes of "Compatible ID" and "Subcompatible ID" | ||
| 82 | * @ext_prop: Extended Properties list | ||
| 83 | * @ext_prop_len: Total length of Extended Properties blobs | ||
| 84 | * @ext_prop_count: Number of Extended Properties | ||
| 85 | * @opts_mutex: Optional mutex protecting config data of a usb_function_instance | ||
| 86 | * @group: Represents OS descriptors associated with an interface in configfs | ||
| 87 | * @owner: Module associated with this OS descriptor | ||
| 88 | */ | ||
| 89 | struct usb_os_desc { | ||
| 90 | char *ext_compat_id; | ||
| 91 | struct list_head ext_prop; | ||
| 92 | int ext_prop_len; | ||
| 93 | int ext_prop_count; | ||
| 94 | struct mutex *opts_mutex; | ||
| 95 | struct config_group group; | ||
| 96 | struct module *owner; | ||
| 97 | }; | ||
| 98 | |||
| 99 | /** | ||
| 100 | * struct usb_os_desc_table - describes OS descriptors associated with one | ||
| 101 | * interface of a usb_function | ||
| 102 | * @if_id: Interface id | ||
| 103 | * @os_desc: "Extended Compatibility ID" and "Extended Properties" of the | ||
| 104 | * interface | ||
| 105 | * | ||
| 106 | * Each interface can have at most one "Extended Compatibility ID" and a | ||
| 107 | * number of "Extended Properties". | ||
| 108 | */ | ||
| 109 | struct usb_os_desc_table { | ||
| 110 | int if_id; | ||
| 111 | struct usb_os_desc *os_desc; | ||
| 112 | }; | ||
| 113 | |||
| 114 | /** | ||
| 60 | * struct usb_function - describes one function of a configuration | 115 | * struct usb_function - describes one function of a configuration |
| 61 | * @name: For diagnostics, identifies the function. | 116 | * @name: For diagnostics, identifies the function. |
| 62 | * @strings: tables of strings, keyed by identifiers assigned during bind() | 117 | * @strings: tables of strings, keyed by identifiers assigned during bind() |
| @@ -73,6 +128,10 @@ struct usb_configuration; | |||
| 73 | * be available at super speed. | 128 | * be available at super speed. |
| 74 | * @config: assigned when @usb_add_function() is called; this is the | 129 | * @config: assigned when @usb_add_function() is called; this is the |
| 75 | * configuration with which this function is associated. | 130 | * configuration with which this function is associated. |
| 131 | * @os_desc_table: Table of (interface id, os descriptors) pairs. The function | ||
| 132 | * can expose more than one interface. If an interface is a member of | ||
| 133 | * an IAD, only the first interface of IAD has its entry in the table. | ||
| 134 | * @os_desc_n: Number of entries in os_desc_table | ||
| 76 | * @bind: Before the gadget can register, all of its functions bind() to the | 135 | * @bind: Before the gadget can register, all of its functions bind() to the |
| 77 | * available resources including string and interface identifiers used | 136 | * available resources including string and interface identifiers used |
| 78 | * in interface or class descriptors; endpoints; I/O buffers; and so on. | 137 | * in interface or class descriptors; endpoints; I/O buffers; and so on. |
| @@ -129,6 +188,9 @@ struct usb_function { | |||
| 129 | 188 | ||
| 130 | struct usb_configuration *config; | 189 | struct usb_configuration *config; |
| 131 | 190 | ||
| 191 | struct usb_os_desc_table *os_desc_table; | ||
| 192 | unsigned os_desc_n; | ||
| 193 | |||
| 132 | /* REVISIT: bind() functions can be marked __init, which | 194 | /* REVISIT: bind() functions can be marked __init, which |
| 133 | * makes trouble for section mismatch analysis. See if | 195 | * makes trouble for section mismatch analysis. See if |
| 134 | * we can't restructure things to avoid mismatching. | 196 | * we can't restructure things to avoid mismatching. |
| @@ -327,6 +389,8 @@ extern void usb_composite_unregister(struct usb_composite_driver *driver); | |||
| 327 | extern void usb_composite_setup_continue(struct usb_composite_dev *cdev); | 389 | extern void usb_composite_setup_continue(struct usb_composite_dev *cdev); |
| 328 | extern int composite_dev_prepare(struct usb_composite_driver *composite, | 390 | extern int composite_dev_prepare(struct usb_composite_driver *composite, |
| 329 | struct usb_composite_dev *cdev); | 391 | struct usb_composite_dev *cdev); |
| 392 | extern int composite_os_desc_req_prepare(struct usb_composite_dev *cdev, | ||
| 393 | struct usb_ep *ep0); | ||
| 330 | void composite_dev_cleanup(struct usb_composite_dev *cdev); | 394 | void composite_dev_cleanup(struct usb_composite_dev *cdev); |
| 331 | 395 | ||
| 332 | static inline struct usb_composite_driver *to_cdriver( | 396 | static inline struct usb_composite_driver *to_cdriver( |
| @@ -335,11 +399,19 @@ static inline struct usb_composite_driver *to_cdriver( | |||
| 335 | return container_of(gdrv, struct usb_composite_driver, gadget_driver); | 399 | return container_of(gdrv, struct usb_composite_driver, gadget_driver); |
| 336 | } | 400 | } |
| 337 | 401 | ||
| 402 | #define OS_STRING_QW_SIGN_LEN 14 | ||
| 403 | #define OS_STRING_IDX 0xEE | ||
| 404 | |||
| 338 | /** | 405 | /** |
| 339 | * struct usb_composite_device - represents one composite usb gadget | 406 | * struct usb_composite_device - represents one composite usb gadget |
| 340 | * @gadget: read-only, abstracts the gadget's usb peripheral controller | 407 | * @gadget: read-only, abstracts the gadget's usb peripheral controller |
| 341 | * @req: used for control responses; buffer is pre-allocated | 408 | * @req: used for control responses; buffer is pre-allocated |
| 409 | * @os_desc_req: used for OS descriptors responses; buffer is pre-allocated | ||
| 342 | * @config: the currently active configuration | 410 | * @config: the currently active configuration |
| 411 | * @qw_sign: qwSignature part of the OS string | ||
| 412 | * @b_vendor_code: bMS_VendorCode part of the OS string | ||
| 413 | * @use_os_string: false by default, interested gadgets set it | ||
| 414 | * @os_desc_config: the configuration to be used with OS descriptors | ||
| 343 | * | 415 | * |
| 344 | * One of these devices is allocated and initialized before the | 416 | * One of these devices is allocated and initialized before the |
| 345 | * associated device driver's bind() is called. | 417 | * associated device driver's bind() is called. |
| @@ -369,9 +441,16 @@ static inline struct usb_composite_driver *to_cdriver( | |||
| 369 | struct usb_composite_dev { | 441 | struct usb_composite_dev { |
| 370 | struct usb_gadget *gadget; | 442 | struct usb_gadget *gadget; |
| 371 | struct usb_request *req; | 443 | struct usb_request *req; |
| 444 | struct usb_request *os_desc_req; | ||
| 372 | 445 | ||
| 373 | struct usb_configuration *config; | 446 | struct usb_configuration *config; |
| 374 | 447 | ||
| 448 | /* OS String is a custom (yet popular) extension to the USB standard. */ | ||
| 449 | u8 qw_sign[OS_STRING_QW_SIGN_LEN]; | ||
| 450 | u8 b_vendor_code; | ||
| 451 | struct usb_configuration *os_desc_config; | ||
| 452 | unsigned int use_os_string:1; | ||
| 453 | |||
| 375 | /* private: */ | 454 | /* private: */ |
| 376 | /* internals */ | 455 | /* internals */ |
| 377 | unsigned int suspended:1; | 456 | unsigned int suspended:1; |
