2017-03-08 14:08:38

by Roger Quadros

[permalink] [raw]
Subject: [PATCH 0/2] usb: gadget: f_uvc: SuperSpeed fixes

Hi Laurent & Felipe,

These are some fixes for SuperSpeed case.

--
cheers,
-roger

Roger Quadros (2):
usb: gadget: f_uvc: Fix SuperSpeed companion descriptor's
wBytesPerInterval
usb: gadget: f_uvc: Sanity check wMaxPacketSize for SuperSpeed

drivers/usb/gadget/function/f_uvc.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)

--
2.7.4


2017-03-08 14:28:42

by Roger Quadros

[permalink] [raw]
Subject: [PATCH 1/2] usb: gadget: f_uvc: Fix SuperSpeed companion descriptor's wBytesPerInterval

The streaming_maxburst module parameter is 0 offset (0..15)
so we must add 1 while using it for wBytesPerInterval
calculation for the SuperSpeed companion descriptor.

Without this host uvcvideo driver will always see the wrong
wBytesPerInterval for SuperSpeed uvc gadget and may not find
a suitable video interface endpoint.
e.g. for streaming_maxburst = 0 case it will always
fail as wBytePerInterval was evaluating to 0.

Cc: [email protected]
Signed-off-by: Roger Quadros <[email protected]>
---
drivers/usb/gadget/function/f_uvc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/function/f_uvc.c b/drivers/usb/gadget/function/f_uvc.c
index 29b41b5..c7689d0 100644
--- a/drivers/usb/gadget/function/f_uvc.c
+++ b/drivers/usb/gadget/function/f_uvc.c
@@ -625,7 +625,7 @@ uvc_function_bind(struct usb_configuration *c, struct usb_function *f)
uvc_ss_streaming_comp.bMaxBurst = opts->streaming_maxburst;
uvc_ss_streaming_comp.wBytesPerInterval =
cpu_to_le16(max_packet_size * max_packet_mult *
- opts->streaming_maxburst);
+ (opts->streaming_maxburst + 1));

/* Allocate endpoints. */
ep = usb_ep_autoconfig(cdev->gadget, &uvc_control_ep);
--
2.7.4

2017-03-08 14:08:39

by Roger Quadros

[permalink] [raw]
Subject: [PATCH 2/2] usb: gadget: f_uvc: Sanity check wMaxPacketSize for SuperSpeed

As per USB3.0 Specification "Table 9-20. Standard Endpoint Descriptor",
for interrupt and isochronous endpoints, wMaxPacketSize must be set to
1024 if the endpoint defines bMaxBurst to be greater than zero.

Signed-off-by: Roger Quadros <[email protected]>
---
drivers/usb/gadget/function/f_uvc.c | 8 ++++++++
1 file changed, 8 insertions(+)

diff --git a/drivers/usb/gadget/function/f_uvc.c b/drivers/usb/gadget/function/f_uvc.c
index c7689d0..f8a1881 100644
--- a/drivers/usb/gadget/function/f_uvc.c
+++ b/drivers/usb/gadget/function/f_uvc.c
@@ -594,6 +594,14 @@ uvc_function_bind(struct usb_configuration *c, struct usb_function *f)
opts->streaming_maxpacket = clamp(opts->streaming_maxpacket, 1U, 3072U);
opts->streaming_maxburst = min(opts->streaming_maxburst, 15U);

+ /* For SS, wMaxPacketSize has to be 1024 if bMaxBurst is not 0 */
+ if (opts->streaming_maxburst &&
+ (opts->streaming_maxpacket % 1024) != 0) {
+ opts->streaming_maxpacket = roundup(opts->streaming_maxpacket, 1024);
+ INFO(cdev, "overriding streaming_maxpacket to %d\n",
+ opts->streaming_maxpacket);
+ }
+
/* Fill in the FS/HS/SS Video Streaming specific descriptors from the
* module parameters.
*
--
2.7.4

2017-03-08 15:48:10

by Laurent Pinchart

[permalink] [raw]
Subject: Re: [PATCH 0/2] usb: gadget: f_uvc: SuperSpeed fixes

Hi Roger,

Thank you for the patches.

On Wednesday 08 Mar 2017 16:05:42 Roger Quadros wrote:
> Hi Laurent & Felipe,
>
> These are some fixes for SuperSpeed case.

For both patches,

Reviewed-by: Laurent Pinchart <[email protected]>

> --
> cheers,
> -roger
>
> Roger Quadros (2):
> usb: gadget: f_uvc: Fix SuperSpeed companion descriptor's
> wBytesPerInterval
> usb: gadget: f_uvc: Sanity check wMaxPacketSize for SuperSpeed
>
> drivers/usb/gadget/function/f_uvc.c | 10 +++++++++-
> 1 file changed, 9 insertions(+), 1 deletion(-)

--
Regards,

Laurent Pinchart

2017-03-09 09:37:16

by Roger Quadros

[permalink] [raw]
Subject: Re: [PATCH 1/2] usb: gadget: f_uvc: Fix SuperSpeed companion descriptor's wBytesPerInterval

Felipe,

On 08/03/17 16:05, Roger Quadros wrote:
> The streaming_maxburst module parameter is 0 offset (0..15)
> so we must add 1 while using it for wBytesPerInterval
> calculation for the SuperSpeed companion descriptor.
>
> Without this host uvcvideo driver will always see the wrong
> wBytesPerInterval for SuperSpeed uvc gadget and may not find
> a suitable video interface endpoint.
> e.g. for streaming_maxburst = 0 case it will always
> fail as wBytePerInterval was evaluating to 0.
>
> Cc: [email protected]
> Signed-off-by: Roger Quadros <[email protected]>

Please pick this one for v4.11-rc with Laurent's Reviewed-by. Thanks.

> ---
> drivers/usb/gadget/function/f_uvc.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/usb/gadget/function/f_uvc.c b/drivers/usb/gadget/function/f_uvc.c
> index 29b41b5..c7689d0 100644
> --- a/drivers/usb/gadget/function/f_uvc.c
> +++ b/drivers/usb/gadget/function/f_uvc.c
> @@ -625,7 +625,7 @@ uvc_function_bind(struct usb_configuration *c, struct usb_function *f)
> uvc_ss_streaming_comp.bMaxBurst = opts->streaming_maxburst;
> uvc_ss_streaming_comp.wBytesPerInterval =
> cpu_to_le16(max_packet_size * max_packet_mult *
> - opts->streaming_maxburst);
> + (opts->streaming_maxburst + 1));
>
> /* Allocate endpoints. */
> ep = usb_ep_autoconfig(cdev->gadget, &uvc_control_ep);
>

--
cheers,
-roger