- Add the capability to search for an EP with a required number of streams.
- Add a gadget_op to allow DCDs to use a proprietary search algorithm
for required and minimum number of streams.
Signed-off-by: Maya Erez <merez@codeaurora.org>
---
drivers/usb/gadget/epautoconf.c | 141 ++++++++++++++++++++++++++++++++-------
include/linux/usb/gadget.h | 14 ++++-
2 files changed, 129 insertions(+), 26 deletions(-)
diff --git a/drivers/usb/gadget/epautoconf.c b/drivers/usb/gadget/epautoconf.c
index 8a83248..bbac2fb 100644
--- a/drivers/usb/gadget/epautoconf.c
+++ b/drivers/usb/gadget/epautoconf.c
@@ -63,13 +63,16 @@ static int
ep_matches (
struct usb_gadget *gadget,
struct usb_ep *ep,
- struct usb_endpoint_descriptor *desc
+ struct usb_endpoint_descriptor *desc,
+ struct usb_ss_ep_comp_descriptor *ep_comp
)
{
u8 type;
const char *tmp;
u16 max;
+ int num_req_streams = 0;
+
/* endpoint already claimed? */
if (NULL != ep->driver_data)
return 0;
@@ -128,6 +131,22 @@ ep_matches (
}
}
+
+ /* Get the number of required streams from the EP companion
+ * descriptor and see if the EP matches it
+ */
+ if (USB_ENDPOINT_XFER_BULK == type) {
+ if (ep_comp) {
+ num_req_streams = ep_comp->bmAttributes & 0x1f;
+ if (num_req_streams > ep->num_supported_strms)
+ return 0;
+ /* Update the ep_comp descriptor if needed */
+ if (num_req_streams != ep->num_supported_strms)
+ ep_comp->bmAttributes = ep->num_supported_strms;
+ }
+
+ }
+
/* endpoint maxpacket size is an input parameter, except for bulk
* where it's an output parameter representing the full speed limit.
* the usb spec fixes high speed bulk maxpacket at 512 bytes.
@@ -200,43 +219,74 @@ find_ep (struct usb_gadget *gadget, const char *name)
}
/**
- * usb_ep_autoconfig - choose an endpoint matching the descriptor
+ * usb_ep_autoconfig_ss() - choose an endpoint matching the ep
+ * descriptor and ep companion descriptor
* @gadget: The device to ...