[RFC/PATCH] usb: Add streams support to epautoconf.

Previous thread: 2.6.37-rc1+: hibernate regression, claims not enough swap space by Pavel Machek on Saturday, November 13, 2010 - 10:21 pm. (10 messages)

Next thread: Re: a Great Idea - include Kademlia networking protocol in kernel -- REVISITED by Marcos on Saturday, November 13, 2010 - 11:31 pm. (1 message)
From: Maya Erez
Date: Saturday, November 13, 2010 - 11:23 pm

- 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 ...
From: Greg KH
Date: Sunday, November 14, 2010 - 11:29 am

Close, but this isn't the proper format for multi-line comments in the

Ick, no, don't do comparisons like this.  The compiler will let you know
if you acidentally get it wrong with only one '=' character, don't do
things "backward" like this just to work around stupid compilers.

thanks,

greg k-h
--

From: Felipe Balbi
Date: Sunday, November 14, 2010 - 1:15 pm

Hi,


we actually have helpers for this and usb_endpoint_xfer_bulk(desc)
would do it.

-- 
balbi

--

Previous thread: 2.6.37-rc1+: hibernate regression, claims not enough swap space by Pavel Machek on Saturday, November 13, 2010 - 10:21 pm. (10 messages)

Next thread: Re: a Great Idea - include Kademlia networking protocol in kernel -- REVISITED by Marcos on Saturday, November 13, 2010 - 11:31 pm. (1 message)