* [PATCH] media: uvcvideo: fix the bandwdith quirk on USB 3.x
@ 2024-04-14 17:00 Michal Pecio
2024-04-15 19:46 ` Ricardo Ribalda
2024-06-16 23:26 ` Laurent Pinchart
0 siblings, 2 replies; 3+ messages in thread
From: Michal Pecio @ 2024-04-14 17:00 UTC (permalink / raw)
To: Laurent Pinchart, Mauro Carvalho Chehab; +Cc: linux-media
The bandwidth fixup quirk doesn't know that SuperSpeed exists and has
the same 8 service intervals per millisecond as High Speed, hence its
calculations are wrong.
Assume that all speeds from HS up use 8 intervals per millisecond.
No further changes are needed, updated code has been confirmed to work
with all speeds from FS to SS.
Signed-off-by: Michal Pecio <michal.pecio@gmail.com>
---
drivers/media/usb/uvc/uvc_video.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/media/usb/uvc/uvc_video.c b/drivers/media/usb/uvc/uvc_video.c
index 28dde08ec6c5..4b86bef06a52 100644
--- a/drivers/media/usb/uvc/uvc_video.c
+++ b/drivers/media/usb/uvc/uvc_video.c
@@ -214,13 +214,13 @@ static void uvc_fixup_video_ctrl(struct uvc_streaming *stream,
* Compute a bandwidth estimation by multiplying the frame
* size by the number of video frames per second, divide the
* result by the number of USB frames (or micro-frames for
- * high-speed devices) per second and add the UVC header size
- * (assumed to be 12 bytes long).
+ * high- and super-speed devices) per second and add the UVC
+ * header size (assumed to be 12 bytes long).
*/
bandwidth = frame->wWidth * frame->wHeight / 8 * format->bpp;
bandwidth *= 10000000 / interval + 1;
bandwidth /= 1000;
- if (stream->dev->udev->speed == USB_SPEED_HIGH)
+ if (stream->dev->udev->speed >= USB_SPEED_HIGH)
bandwidth /= 8;
bandwidth += 12;
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] media: uvcvideo: fix the bandwdith quirk on USB 3.x
2024-04-14 17:00 [PATCH] media: uvcvideo: fix the bandwdith quirk on USB 3.x Michal Pecio
@ 2024-04-15 19:46 ` Ricardo Ribalda
2024-06-16 23:26 ` Laurent Pinchart
1 sibling, 0 replies; 3+ messages in thread
From: Ricardo Ribalda @ 2024-04-15 19:46 UTC (permalink / raw)
To: Michal Pecio; +Cc: Laurent Pinchart, Mauro Carvalho Chehab, linux-media
Hi Michal
On Sun, 14 Apr 2024 at 19:00, Michal Pecio <michal.pecio@gmail.com> wrote:
>
> The bandwidth fixup quirk doesn't know that SuperSpeed exists and has
> the same 8 service intervals per millisecond as High Speed, hence its
> calculations are wrong.
>
> Assume that all speeds from HS up use 8 intervals per millisecond.
>
> No further changes are needed, updated code has been confirmed to work
> with all speeds from FS to SS.
>
> Signed-off-by: Michal Pecio <michal.pecio@gmail.com>
Reviewed-by: Ricardo Ribalda <ribalda@chromium.org>
> ---
> drivers/media/usb/uvc/uvc_video.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/media/usb/uvc/uvc_video.c b/drivers/media/usb/uvc/uvc_video.c
> index 28dde08ec6c5..4b86bef06a52 100644
> --- a/drivers/media/usb/uvc/uvc_video.c
> +++ b/drivers/media/usb/uvc/uvc_video.c
> @@ -214,13 +214,13 @@ static void uvc_fixup_video_ctrl(struct uvc_streaming *stream,
> * Compute a bandwidth estimation by multiplying the frame
> * size by the number of video frames per second, divide the
> * result by the number of USB frames (or micro-frames for
> - * high-speed devices) per second and add the UVC header size
> - * (assumed to be 12 bytes long).
> + * high- and super-speed devices) per second and add the UVC
> + * header size (assumed to be 12 bytes long).
> */
> bandwidth = frame->wWidth * frame->wHeight / 8 * format->bpp;
> bandwidth *= 10000000 / interval + 1;
> bandwidth /= 1000;
> - if (stream->dev->udev->speed == USB_SPEED_HIGH)
> + if (stream->dev->udev->speed >= USB_SPEED_HIGH)
> bandwidth /= 8;
> bandwidth += 12;
>
> --
> 2.43.0
>
>
--
Ricardo Ribalda
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] media: uvcvideo: fix the bandwdith quirk on USB 3.x
2024-04-14 17:00 [PATCH] media: uvcvideo: fix the bandwdith quirk on USB 3.x Michal Pecio
2024-04-15 19:46 ` Ricardo Ribalda
@ 2024-06-16 23:26 ` Laurent Pinchart
1 sibling, 0 replies; 3+ messages in thread
From: Laurent Pinchart @ 2024-06-16 23:26 UTC (permalink / raw)
To: Michal Pecio; +Cc: Mauro Carvalho Chehab, linux-media
Hi Michal,
Thank you for the patch.
On Sun, Apr 14, 2024 at 07:00:40PM +0200, Michal Pecio wrote:
> The bandwidth fixup quirk doesn't know that SuperSpeed exists and has
> the same 8 service intervals per millisecond as High Speed, hence its
> calculations are wrong.
>
> Assume that all speeds from HS up use 8 intervals per millisecond.
>
> No further changes are needed, updated code has been confirmed to work
> with all speeds from FS to SS.
>
> Signed-off-by: Michal Pecio <michal.pecio@gmail.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---
> drivers/media/usb/uvc/uvc_video.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/media/usb/uvc/uvc_video.c b/drivers/media/usb/uvc/uvc_video.c
> index 28dde08ec6c5..4b86bef06a52 100644
> --- a/drivers/media/usb/uvc/uvc_video.c
> +++ b/drivers/media/usb/uvc/uvc_video.c
> @@ -214,13 +214,13 @@ static void uvc_fixup_video_ctrl(struct uvc_streaming *stream,
> * Compute a bandwidth estimation by multiplying the frame
> * size by the number of video frames per second, divide the
> * result by the number of USB frames (or micro-frames for
> - * high-speed devices) per second and add the UVC header size
> - * (assumed to be 12 bytes long).
> + * high- and super-speed devices) per second and add the UVC
> + * header size (assumed to be 12 bytes long).
> */
> bandwidth = frame->wWidth * frame->wHeight / 8 * format->bpp;
> bandwidth *= 10000000 / interval + 1;
> bandwidth /= 1000;
> - if (stream->dev->udev->speed == USB_SPEED_HIGH)
> + if (stream->dev->udev->speed >= USB_SPEED_HIGH)
> bandwidth /= 8;
> bandwidth += 12;
>
--
Regards,
Laurent Pinchart
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-06-16 23:26 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-14 17:00 [PATCH] media: uvcvideo: fix the bandwdith quirk on USB 3.x Michal Pecio
2024-04-15 19:46 ` Ricardo Ribalda
2024-06-16 23:26 ` Laurent Pinchart
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.