On Sat May 10 14:18:03 2025 +0800, chenchangcheng wrote:
> Some broken device return wrong dwMaxPayloadTransferSize fields as
> follows:
>
> [ 218.632537] uvcvideo: Device requested 2752512 B/frame bandwidth.
> [ 218.632598] uvcvideo: No fast enough alt setting for requested bandwidth.
>
> When dwMaxPayloadTransferSize is greater than maxpsize, it will prevent
> the camera from starting. So use the bandwidth of maxpsize.
>
> Signed-off-by: chenchangcheng <[email protected]>
> Reviewed-by: Ricardo Ribalda <[email protected]>
> Reviewed-by: Laurent Pinchart <[email protected]>
> Link: https://lore.kernel.org/r/[email protected]
> Signed-off-by: Laurent Pinchart <[email protected]>
> Signed-off-by: Hans Verkuil <[email protected]>
Patch committed.
Thanks,
Hans Verkuil
drivers/media/usb/uvc/uvc_video.c | 9 +++++++++
1 file changed, 9 insertions(+)
---
diff --git a/drivers/media/usb/uvc/uvc_video.c
b/drivers/media/usb/uvc/uvc_video.c
index e3567aeb0007..11769a1832d2 100644
--- a/drivers/media/usb/uvc/uvc_video.c
+++ b/drivers/media/usb/uvc/uvc_video.c
@@ -262,6 +262,15 @@ static void uvc_fixup_video_ctrl(struct uvc_streaming
*stream,
ctrl->dwMaxPayloadTransferSize = bandwidth;
}
+
+ if (stream->intf->num_altsetting > 1 &&
+ ctrl->dwMaxPayloadTransferSize > stream->maxpsize) {
+ dev_warn_ratelimited(&stream->intf->dev,
+ "UVC non compliance: the max payload
transmission size (%u) exceeds the size of the ep max packet (%u). Using the
max size.\n",
+ ctrl->dwMaxPayloadTransferSize,
+ stream->maxpsize);
+ ctrl->dwMaxPayloadTransferSize = stream->maxpsize;
+ }
}
static size_t uvc_video_ctrl_size(struct uvc_streaming *stream)