]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
media: uvcvideo: Fix bandwidth issue for Alcor camera
authorchenchangcheng <chenchangcheng@kylinos.cn>
Sat, 10 May 2025 06:18:03 +0000 (14:18 +0800)
committerHans Verkuil <hverkuil@xs4all.nl>
Mon, 16 Jun 2025 06:43:22 +0000 (08:43 +0200)
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 <chenchangcheng@kylinos.cn>
Reviewed-by: Ricardo Ribalda <ribalda@chromium.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Link: https://lore.kernel.org/r/20250510061803.811433-1-ccc194101@163.com
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
drivers/media/usb/uvc/uvc_video.c

index e3567aeb0007c1f0a766f331e4e744359e95a863..11769a1832d2ba9b3f9a50bcb10b0c4cdff71f09 100644 (file)
@@ -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)