Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755120AbbLKLZx (ORCPT ); Fri, 11 Dec 2015 06:25:53 -0500 Received: from mailout2.samsung.com ([203.254.224.25]:36271 "EHLO mailout2.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755061AbbLKLZt (ORCPT ); Fri, 11 Dec 2015 06:25:49 -0500 X-AuditID: cbfee61b-f793c6d00000236c-8e-566ab2bcad76 From: Robert Baldyga To: balbi@ti.com Cc: gregkh@linuxfoundation.org, andrzej.p@samsung.com, m.szyprowski@samsung.com, b.zolnierkie@samsung.com, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Robert Baldyga Subject: [PATCH v3 06/36] usb: gadget: composite: introduce new descriptors format Date: Fri, 11 Dec 2015 12:24:45 +0100 Message-id: <1449833115-24065-7-git-send-email-r.baldyga@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1449833115-24065-1-git-send-email-r.baldyga@samsung.com> References: <1449833115-24065-1-git-send-email-r.baldyga@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprKLMWRmVeSWpSXmKPExsVy+t9jQd09m7LCDPYv5baY9bKdxWLjjPWs Fgfv11s0L17PZnF51xw2i0XLWpkt1h65y27x4PBOdgcOj/1z17B79G1Zxehx/MZ2Jo/Pm+QC WKK4bFJSczLLUov07RK4MpZP3MhScNKwYt4pwwbGcxpdjJwcEgImEr82r2eDsMUkLtwDsbk4 hARmMUr0zn4LlhAS+Mko8W+DM4jNJqAjseX7BEYQW0RAQGL9i0vsIA3MAucYJR7eaQNLCAuE SNzY1skMYrMIqEr0/14KFucVcJXY/2kHI8Q2OYmTxyazgticAm4Sk09eYoZY5irx5vU6xgmM vAsYGVYxSqQWJBcUJ6XnGuWllusVJ+YWl+al6yXn525iBAfWM+kdjId3uR9iFOBgVOLhXcCR FSbEmlhWXJl7iFGCg1lJhPfXBqAQb0piZVVqUX58UWlOavEhRmkOFiVx3n2XIsOEBNITS1Kz U1MLUotgskwcnFINjL6JTp1uqc+eh6czsmYv62dzEfauMtl5V/QvVyGfTnO85kfnmT5+1iGX FzarBBi84qlXbjjspXHpQAyPXM/uY7aOj+18tuyujVh66qnfjC2Xe9Jy7nVO2ZyxL2/NT+YF 59ZOY1rleaXzUrxS03PBXvF3XEvXti86bLfP62nLyePPMk5u//ZujRJLcUaioRZzUXEiAHUH SQ8oAgAA Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 6414 Lines: 181 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 --- include/linux/usb/composite.h | 119 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 119 insertions(+) diff --git a/include/linux/usb/composite.h b/include/linux/usb/composite.h index 1074b89..686c5f7 100644 --- a/include/linux/usb/composite.h +++ b/include/linux/usb/composite.h @@ -57,6 +57,121 @@ 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 + */ +struct usb_composite_descs { + struct usb_composite_intf **intfs; + int intfs_num; + + struct list_head vendor_descs; + int vendor_descs_num; +}; + +/** * 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 +241,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 +304,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 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/