linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] usb: gadget: uvc: add bInterval checking for HS mode
@ 2021-03-08 12:53 Pawel Laszczak
  2021-03-14  2:29 ` Peter Chen
  2021-03-14  2:40 ` Laurent Pinchart
  0 siblings, 2 replies; 3+ messages in thread
From: Pawel Laszczak @ 2021-03-08 12:53 UTC (permalink / raw)
  To: balbi
  Cc: laurent.pinchart, gregkh, linux-usb, linux-kernel, peter.chen,
	kurahul, Pawel Laszczak

From: Pawel Laszczak <pawell@cadence.com>

Patch adds extra checking for bInterval passed by configfs.
The 5.6.4 chapter of USB Specification (rev. 2.0) say:
"A high-bandwidth endpoint must specify a period of 1x125 µs
(i.e., a bInterval value of 1)."

The issue was observed during testing UVC class on CV.
I treat this change as improvement because we can control
bInterval by configfs.

Signed-off-by: Pawel Laszczak <pawell@cadence.com>

---
Changlog:
v2:
- removed duplicated assignment

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

diff --git a/drivers/usb/gadget/function/f_uvc.c b/drivers/usb/gadget/function/f_uvc.c
index 44b4352a2676..ed77a126a74f 100644
--- a/drivers/usb/gadget/function/f_uvc.c
+++ b/drivers/usb/gadget/function/f_uvc.c
@@ -633,7 +633,12 @@ uvc_function_bind(struct usb_configuration *c, struct usb_function *f)
 
 	uvc_hs_streaming_ep.wMaxPacketSize =
 		cpu_to_le16(max_packet_size | ((max_packet_mult - 1) << 11));
-	uvc_hs_streaming_ep.bInterval = opts->streaming_interval;
+
+	/* A high-bandwidth endpoint must specify a bInterval value of 1 */
+	if (max_packet_mult > 1)
+		uvc_hs_streaming_ep.bInterval = 1;
+	else
+		uvc_hs_streaming_ep.bInterval = opts->streaming_interval;
 
 	uvc_ss_streaming_ep.wMaxPacketSize = cpu_to_le16(max_packet_size);
 	uvc_ss_streaming_ep.bInterval = opts->streaming_interval;
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] usb: gadget: uvc: add bInterval checking for HS mode
  2021-03-08 12:53 [PATCH v2] usb: gadget: uvc: add bInterval checking for HS mode Pawel Laszczak
@ 2021-03-14  2:29 ` Peter Chen
  2021-03-14  2:40 ` Laurent Pinchart
  1 sibling, 0 replies; 3+ messages in thread
From: Peter Chen @ 2021-03-14  2:29 UTC (permalink / raw)
  To: Pawel Laszczak
  Cc: balbi, laurent.pinchart, gregkh, linux-usb, linux-kernel, kurahul

On 21-03-08 13:53:38, Pawel Laszczak wrote:
> From: Pawel Laszczak <pawell@cadence.com>
> 
> Patch adds extra checking for bInterval passed by configfs.
> The 5.6.4 chapter of USB Specification (rev. 2.0) say:
> "A high-bandwidth endpoint must specify a period of 1x125 µs
> (i.e., a bInterval value of 1)."
> 
> The issue was observed during testing UVC class on CV.
> I treat this change as improvement because we can control
> bInterval by configfs.
> 
> Signed-off-by: Pawel Laszczak <pawell@cadence.com>
> 
> ---
> Changlog:
> v2:
> - removed duplicated assignment
> 
>  drivers/usb/gadget/function/f_uvc.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/gadget/function/f_uvc.c b/drivers/usb/gadget/function/f_uvc.c
> index 44b4352a2676..ed77a126a74f 100644
> --- a/drivers/usb/gadget/function/f_uvc.c
> +++ b/drivers/usb/gadget/function/f_uvc.c
> @@ -633,7 +633,12 @@ uvc_function_bind(struct usb_configuration *c, struct usb_function *f)
>  
>  	uvc_hs_streaming_ep.wMaxPacketSize =
>  		cpu_to_le16(max_packet_size | ((max_packet_mult - 1) << 11));
> -	uvc_hs_streaming_ep.bInterval = opts->streaming_interval;
> +
> +	/* A high-bandwidth endpoint must specify a bInterval value of 1 */
> +	if (max_packet_mult > 1)
> +		uvc_hs_streaming_ep.bInterval = 1;
> +	else
> +		uvc_hs_streaming_ep.bInterval = opts->streaming_interval;
>  
>  	uvc_ss_streaming_ep.wMaxPacketSize = cpu_to_le16(max_packet_size);
>  	uvc_ss_streaming_ep.bInterval = opts->streaming_interval;
> -- 
> 2.25.1
> 

Reviewed-by: Peter Chen <peter.chen@kernel.org>

-- 

Thanks,
Peter Chen


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] usb: gadget: uvc: add bInterval checking for HS mode
  2021-03-08 12:53 [PATCH v2] usb: gadget: uvc: add bInterval checking for HS mode Pawel Laszczak
  2021-03-14  2:29 ` Peter Chen
@ 2021-03-14  2:40 ` Laurent Pinchart
  1 sibling, 0 replies; 3+ messages in thread
From: Laurent Pinchart @ 2021-03-14  2:40 UTC (permalink / raw)
  To: Pawel Laszczak
  Cc: balbi, gregkh, linux-usb, linux-kernel, peter.chen, kurahul

Hi Pawel,

Thank you for the patch.

On Mon, Mar 08, 2021 at 01:53:38PM +0100, Pawel Laszczak wrote:
> From: Pawel Laszczak <pawell@cadence.com>
> 
> Patch adds extra checking for bInterval passed by configfs.
> The 5.6.4 chapter of USB Specification (rev. 2.0) say:
> "A high-bandwidth endpoint must specify a period of 1x125 µs
> (i.e., a bInterval value of 1)."
> 
> The issue was observed during testing UVC class on CV.
> I treat this change as improvement because we can control
> bInterval by configfs.
> 
> Signed-off-by: Pawel Laszczak <pawell@cadence.com>

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

Felipe, could you take this patch in your tree ?

> ---
> Changlog:
> v2:
> - removed duplicated assignment
> 
>  drivers/usb/gadget/function/f_uvc.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/gadget/function/f_uvc.c b/drivers/usb/gadget/function/f_uvc.c
> index 44b4352a2676..ed77a126a74f 100644
> --- a/drivers/usb/gadget/function/f_uvc.c
> +++ b/drivers/usb/gadget/function/f_uvc.c
> @@ -633,7 +633,12 @@ uvc_function_bind(struct usb_configuration *c, struct usb_function *f)
>  
>  	uvc_hs_streaming_ep.wMaxPacketSize =
>  		cpu_to_le16(max_packet_size | ((max_packet_mult - 1) << 11));
> -	uvc_hs_streaming_ep.bInterval = opts->streaming_interval;
> +
> +	/* A high-bandwidth endpoint must specify a bInterval value of 1 */
> +	if (max_packet_mult > 1)
> +		uvc_hs_streaming_ep.bInterval = 1;
> +	else
> +		uvc_hs_streaming_ep.bInterval = opts->streaming_interval;
>  
>  	uvc_ss_streaming_ep.wMaxPacketSize = cpu_to_le16(max_packet_size);
>  	uvc_ss_streaming_ep.bInterval = opts->streaming_interval;

-- 
Regards,

Laurent Pinchart

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-03-14  2:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-03-08 12:53 [PATCH v2] usb: gadget: uvc: add bInterval checking for HS mode Pawel Laszczak
2021-03-14  2:29 ` Peter Chen
2021-03-14  2:40 ` Laurent Pinchart

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).