Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1325347
| From | Robert Baldyga <r.baldyga@samsung.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH v4 06/43] usb: gadget: composite: introduce new descriptors format |
| Date | 2016-02-03 13:50 +0100 |
| Message-ID | <qY52G-212-23@gated-at.bofh.it> (permalink) |
| References | <qY52F-212-5@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
Introduce new structures designed to contain information about
descriptors. It splits descriptors in two categories:
1. Entity descs - interface and endpoint descriptors
2. Vendor descs - all other vendor and class specific descriptors
Entity descriptors are embedded in hierarchy of structures while vendor
descriptors are contained in linked lists. This distinction is caused
by fact, that entity descriptors are needed during gadget bind procedure,
while vendor descriptors can be supplied later, which is usually desired,
as these descriptors may need to be filled with interface numbers and
endpoint addresses which are assigned during gadget bind.
In result we can split descriptors creation process in two steps - first
collecs entity descriptors, perform the bind and then update and attach
all other descriptors. This process can be done this way not only for
each function separately, but also for entire gadget at once, which means
we can first gather descriptors from all functions in gadget, next perform
bind procedure, and then allow functions to supply additional descriptors.
It allows us to have autoconfig solver capable to better distibute ep
resources, and additionally, because we now store information about
endpoints, allows us to handle endpoint state inside composite framework,
and in result remove lots of boilerplate code from USB functions.
Signed-off-by: Robert Baldyga <r.baldyga@samsung.com>
---
include/linux/usb/composite.h | 126 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 126 insertions(+)
diff --git a/include/linux/usb/composite.h b/include/linux/usb/composite.h
index 9911c29..8bb5c35 100644
--- a/include/linux/usb/composite.h
+++ b/include/linux/usb/composite.h
@@ -57,6 +57,128 @@
struct usb_configuration;
/**
+ * struct usb_composite_vendor_desc - vendor specific descriptor
+ * @desc: pointer to vendor specific descriptor
+ * @list: descriptor list element
+ *
+ * It's designed to be element of vendor specific descriptor list,
+ * which can be attached to function, interface (per altsetting) or
+ * endpoint.
+ */
+struct usb_composite_vendor_desc {
+ struct usb_descriptor_header *desc;
+ struct list_head list;
+};
+
+/**
+ * struct usb_composite_ep - representation of USB endpoint
+ * @fs.desc: FullSpeed descriptor
+ * @hs.desc: HighSpeed descriptor
+ * @ss.desc: SuperSpeed descriptor
+ * @ss_comp.desc: SuperSpeed Companion descriptor
+ * @vendor_descs: list of vendor specific descriptors
+ * @vendor_descs_num: count of vendor specific descriptors
+ * @ep: pointer to endpoint obtained during bind process
+ *
+ * We have pointer to each descriptor in union with pointer to descriptor
+ * header in order to avoid casting in many places in code, because in
+ * some situations we want to have access to fields of particular type
+ * of descriptor, while in other situations we want to treat all types
+ * of descriptors in the same way.
+ */
+struct usb_composite_ep {
+ union {
+ struct usb_descriptor_header *header;
+ struct usb_endpoint_descriptor *desc;
+ } fs;
+
+ union {
+ struct usb_descriptor_header *header;
+ struct usb_endpoint_descriptor *desc;
+ } hs;
+
+ union {
+ struct usb_descriptor_header *header;
+ struct usb_endpoint_descriptor *desc;
+ } ss;
+
+ union {
+ struct usb_descriptor_header *header;
+ struct usb_ss_ep_comp_descriptor *desc;
+ } ss_comp;
+
+ struct list_head vendor_descs;
+ int vendor_descs_num;
+
+ struct usb_ep *ep;
+};
+
+/**
+ * struct usb_composite_altset - representation of USB altsetting
+ * @alt.desc: interface (altsetting) descriptor
+ * @eps: array of endpoints in altsetting
+ * @eps_num: number of endpoints
+ * @vendor_descs: list of vendor specific descriptors
+ * @vendor_descs_num: count of vendor specific descriptors
+ *
+ * We have pointer to alt descriptor in union with pointer to descriptor
+ * header in order to avoid casting in many places in code, because in
+ * some situations we want to have access to fields of particular type
+ * of descriptor, while in other situations we want to treat all types
+ * of descriptors in the same way.
+ */
+struct usb_composite_altset {
+ union {
+ struct usb_descriptor_header *header;
+ struct usb_interface_descriptor *desc;
+ } alt;
+
+ struct usb_composite_ep **eps;
+ int eps_num;
+
+ struct list_head vendor_descs;
+ int vendor_descs_num;
+};
+
+/**
+ * struct usb_composite_intf - representation of USB interface
+ * @altsets: array of altsettings in interface
+ * @altsets_num: number of altsettings
+ * @cur_altset: number of currently selected altsetting
+ * @id: id number of interface in configuraion (value of
+ * bInterfaceNumber in interface descriptor)
+ */
+struct usb_composite_intf {
+ struct usb_composite_altset **altsets;
+ int altsets_num;
+
+ int cur_altset;
+ u8 id;
+};
+
+/**
+ * struct usb_composite_descs - representation of USB descriptors
+ * @intfs: array of interfaces in function
+ * @intfs_num: number of interfaces
+ * @vendor_descs: list of vendor specific descriptors
+ * @vendor_descs_num: count of vendor specific descriptors
+ * @fullspeed: descriptors support FullSpeed
+ * @highspeed: descriptors support HighSpeed
+ * @superspeed: descriptors support SuperSpeed
+ */
+struct usb_composite_descs {
+ struct usb_composite_intf **intfs;
+ int intfs_num;
+
+ struct list_head vendor_descs;
+ int vendor_descs_num;
+
+ unsigned fullspeed:1;
+ unsigned highspeed:1;
+ unsigned superspeed:1;
+};
+
+/**
* struct usb_os_desc_ext_prop - describes one "Extended Property"
* @entry: used to keep a list of extended properties
* @type: Extended Property type
@@ -126,6 +248,8 @@ struct usb_os_desc_table {
* string identifiers assigned during @bind(). If this
* pointer is null after initiation, the function will not
* be available at super speed.
+ * @descs: structure containing information about descriptors and endpoints
+ * assigned during gadget bind.
* @config: assigned when @usb_add_function() is called; this is the
* configuration with which this function is associated.
* @os_desc_table: Table of (interface id, os descriptors) pairs. The function
@@ -187,6 +311,8 @@ struct usb_function {
struct usb_descriptor_header **hs_descriptors;
struct usb_descriptor_header **ss_descriptors;
+ struct usb_composite_descs *descs;
+
struct usb_configuration *config;
struct usb_os_desc_table *os_desc_table;
--
1.9.1
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH v4 00/43] usb: gadget: composite: introduce new function API Robert Baldyga <r.baldyga@samsung.com> - 2016-02-03 13:50 +0100
[PATCH v4 10/43] usb: gadget: composite: handle vendor descs Robert Baldyga <r.baldyga@samsung.com> - 2016-02-03 13:50 +0100
[PATCH v4 16/43] usb: gadget: composite: add usb_function_get_ep() function Robert Baldyga <r.baldyga@samsung.com> - 2016-02-03 13:50 +0100
[PATCH v4 24/43] usb: gadget: f_rndis: conversion to new API Robert Baldyga <r.baldyga@samsung.com> - 2016-02-03 13:50 +0100
[PATCH v4 18/43] usb: gadget: composite: usb_get_endpoint_address() function Robert Baldyga <r.baldyga@samsung.com> - 2016-02-03 13:50 +0100
[PATCH v4 06/43] usb: gadget: composite: introduce new descriptors format Robert Baldyga <r.baldyga@samsung.com> - 2016-02-03 13:50 +0100
Re: [PATCH v4 06/43] usb: gadget: composite: introduce new descriptors format kbuild test robot <lkp@intel.com> - 2016-02-04 06:20 +0100
[PATCH v4 15/43] usb: gadget: composite: handle get_alt() automatically Robert Baldyga <r.baldyga@samsung.com> - 2016-02-03 13:50 +0100
[PATCH v4 04/43] usb: gadget: configfs: fix error path Robert Baldyga <r.baldyga@samsung.com> - 2016-02-03 13:50 +0100
[PATCH v4 37/43] usb: gadget: f_mass_storage: conversion to new API Robert Baldyga <r.baldyga@samsung.com> - 2016-02-03 13:50 +0100
[PATCH v4 23/43] usb: gadget: f_ecm: conversion to new API Robert Baldyga <r.baldyga@samsung.com> - 2016-02-03 13:50 +0100
[PATCH v4 02/43] usb: gadget: f_sourcesink: free requests in sourcesink_disable() Robert Baldyga <r.baldyga@samsung.com> - 2016-02-03 13:50 +0100
[PATCH v4 13/43] usb: gadget: composite: enable eps before calling set_alt() callback Robert Baldyga <r.baldyga@samsung.com> - 2016-02-03 13:50 +0100
[PATCH v4 32/43] usb: gadget: f_obex: conversion to new API Robert Baldyga <r.baldyga@samsung.com> - 2016-02-03 13:50 +0100
[PATCH v4 20/43] usb: gadget: configfs: add new composite API support Robert Baldyga <r.baldyga@samsung.com> - 2016-02-03 13:50 +0100
[PATCH v4 27/43] usb: gadget: f_acm: conversion to new API Robert Baldyga <r.baldyga@samsung.com> - 2016-02-03 13:50 +0100
[PATCH v4 26/43] usb: gadget: f_hid: conversion to new API Robert Baldyga <r.baldyga@samsung.com> - 2016-02-03 13:50 +0100
[PATCH v4 30/43] usb: gadget: f_printer: conversion to new API Robert Baldyga <r.baldyga@samsung.com> - 2016-02-03 13:50 +0100
[PATCH v4 08/43] usb: gadget: composite: introduce new USB function ops Robert Baldyga <r.baldyga@samsung.com> - 2016-02-03 13:50 +0100
[PATCH v4 35/43] usb: gadget: f_uac1: conversion to new API Robert Baldyga <r.baldyga@samsung.com> - 2016-02-03 13:50 +0100
[PATCH v4 31/43] usb: gadget: f_serial: conversion to new API Robert Baldyga <r.baldyga@samsung.com> - 2016-02-03 13:50 +0100
[PATCH v4 42/43] Documentation: update uvc configfs interface description Robert Baldyga <r.baldyga@samsung.com> - 2016-02-03 13:50 +0100
[PATCH v4 43/43] usb: gadget: f_uvc: conversion to new API Robert Baldyga <r.baldyga@samsung.com> - 2016-02-03 13:50 +0100
[PATCH v4 25/43] usb: gadget: f_hid: handle requests lifetime properly Robert Baldyga <r.baldyga@samsung.com> - 2016-02-03 13:50 +0100
[PATCH v4 03/43] usb: gadget: f_loopback: free requests in loopback_disable() Robert Baldyga <r.baldyga@samsung.com> - 2016-02-03 13:50 +0100
[PATCH v4 38/43] usb: gadget: u_serial: remove usb_ep_enable()/usb_ep_disable() Robert Baldyga <r.baldyga@samsung.com> - 2016-02-03 13:50 +0100
[PATCH v4 34/43] usb: gadget: f_subset: conversion to new API Robert Baldyga <r.baldyga@samsung.com> - 2016-02-03 13:50 +0100
[PATCH v4 29/43] usb: gadget: f_ncm: conversion to new API Robert Baldyga <r.baldyga@samsung.com> - 2016-02-03 13:50 +0100
[PATCH v4 22/43] usb: gadget: f_sourcesink: convert to new API Robert Baldyga <r.baldyga@samsung.com> - 2016-02-03 13:50 +0100
[PATCH v4 39/43] usb: gadget: u_ether: remove usb_ep_enable()/usb_ep_disable() Robert Baldyga <r.baldyga@samsung.com> - 2016-02-03 13:50 +0100
[PATCH v4 40/43] usb: gadget: uvc: fix typo in UVCG_OPTS_ATTR() macro Robert Baldyga <r.baldyga@samsung.com> - 2016-02-03 13:50 +0100
[PATCH v4 36/43] usb: gadget: f_uac2: conversion to new API Robert Baldyga <r.baldyga@samsung.com> - 2016-02-03 13:50 +0100
[PATCH v4 41/43] usb: gadget: uvc: simplify descriptors generation Robert Baldyga <r.baldyga@samsung.com> - 2016-02-03 13:50 +0100
[PATCH v4 09/43] usb: gadget: composite: handle function bind Robert Baldyga <r.baldyga@samsung.com> - 2016-02-03 14:00 +0100
Re: [PATCH v4 09/43] usb: gadget: composite: handle function bind kbuild test robot <lkp@intel.com> - 2016-02-04 06:50 +0100
[PATCH v4 01/43] usb: gadget: f_sourcesink: make ISO altset user-selectable Robert Baldyga <r.baldyga@samsung.com> - 2016-02-03 14:00 +0100
[PATCH v4 12/43] usb: gadget: composite: disable eps before calling disable() callback Robert Baldyga <r.baldyga@samsung.com> - 2016-02-03 14:00 +0100
[PATCH v4 17/43] usb: gadget: composite: add usb_get_interface_id() function Robert Baldyga <r.baldyga@samsung.com> - 2016-02-03 14:00 +0100
[PATCH v4 19/43] usb: gadget: composite: enable adding USB functions using new API Robert Baldyga <r.baldyga@samsung.com> - 2016-02-03 14:00 +0100
[PATCH v4 05/43] usb: gadget: composite: fix recursive spinlock locking Robert Baldyga <r.baldyga@samsung.com> - 2016-02-03 14:00 +0100
[PATCH v4 21/43] usb: gadget: f_loopback: convert to new API Robert Baldyga <r.baldyga@samsung.com> - 2016-02-03 14:00 +0100
[PATCH v4 14/43] usb: gadget: composite: introduce clear_alt() operation Robert Baldyga <r.baldyga@samsung.com> - 2016-02-03 14:00 +0100
[PATCH v4 11/43] usb: gadget: composite: generate old descs for compatibility Robert Baldyga <r.baldyga@samsung.com> - 2016-02-03 14:00 +0100
[PATCH v4 07/43] usb: gadget: composite: add functions for descriptors handling Robert Baldyga <r.baldyga@samsung.com> - 2016-02-03 14:00 +0100
csiph-web