Skip to contentSkip to conversation

media: uvcvideo: Fix bandwidth issue for Alcor camera.

PATCH Superseded chenchangcheng 3 participants 4 messages May 10, 2025 – May 15, 2025

Subsystems (2)

v10 of 11 Superseded Latest is v11 →

lore
Share & tools
lore
#0 lore raw

PATCH v10 1/1 media: uvcvideo: Fix bandwidth issue for Alcor camera.

From: chenchangcheng <[email protected]>

Some broken device return wrong dwMaxPayloadTransferSize fields as follows:

    [  218.632537] [pid:20427,cpu6,guvcview,8]uvcvideo: Device requested 2752512 B/frame bandwidth.
    [  218.632598] [pid:20427,cpu6,guvcview,9]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.

---
 drivers/media/usb/uvc/uvc_video.c | 9 +++++++++
 1 file changed, 9 insertions(+)
drivers/media/usb/uvc/uvc_video.c +9 -0
index e3567aeb0007..a74cf89852d1 100644
@@ -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,
+				     "the max payload transmission size (%d) exceededs the size of the ep max packet (%d). Using the max size.\n",
+				     ctrl->dwMaxPayloadTransferSize,
+				     stream->maxpsize);
+		ctrl->dwMaxPayloadTransferSize = stream->maxpsize;
+	}
 }
 
 static size_t uvc_video_ctrl_size(struct uvc_streaming *stream)

base-commit: d76bb1ebb5587f66b0f8b8099bfbb44722bc08b3

Signature · 1 line
2.25.1
Reviewed-by on v10 1/1
#1 lore raw

Hi chenchangcheng

Thanks for your patience fixing the warnings from media-ci :)

Regards

Quoted 5 lines · chenchangcheng

From: chenchangcheng <[email protected]>

Some broken device return wrong dwMaxPayloadTransferSize fields as follows:

Quoted 8 lines
    [  218.632537] [pid:20427,cpu6,guvcview,8]uvcvideo: Device requested 2752512 B/frame bandwidth.
    [  218.632598] [pid:20427,cpu6,guvcview,9]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.

Quoted 9 lines
---
 drivers/media/usb/uvc/uvc_video.c | 9 +++++++++
 1 file changed, 9 insertions(+)
drivers/media/usb/uvc/uvc_video.c +0 -0
index e3567aeb0007..a74cf89852d1 100644

drivers/media/usb/uvc/uvc_video.c static void uvc_fixup_video_ctrl(struct uvc_streaming *stream, · line 270

Quoted 9 lines
drivers/media/usb/uvc/uvc_video.c +6 -0
@@ -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,
+                                    "the max payload transmission size (%d) exceededs the size of the ep max packet (%d). Using the max size.\n",
+                                    ctrl->dwMaxPayloadTransferSize,

Minor nitpick. I am trying to standarize "UVC non compliance" header in the logs for this kind of things.

"UVC non compliance: the max payload transmission size (%d) exceededs the size of the ep max packet (%d). Using the max size.\n"

Quoted 11 lines
drivers/media/usb/uvc/uvc_video.c +3 -0
+                                    stream->maxpsize);
+               ctrl->dwMaxPayloadTransferSize = stream->maxpsize;
+       }
 }
 
 static size_t uvc_video_ctrl_size(struct uvc_streaming *stream)

base-commit: d76bb1ebb5587f66b0f8b8099bfbb44722bc08b3 --
2.25.1

Signature · 1 line
Ricardo Ribalda
maintainer Reviewed-by
#2 lore raw
Quoted 45 lines · Ricardo Ribalda

Hi chenchangcheng

Thanks for your patience fixing the warnings from media-ci :)

Regards

Quoted 5 lines · chenchangcheng

From: chenchangcheng <[email protected]>

Some broken device return wrong dwMaxPayloadTransferSize fields as follows:

Quoted 8 lines
    [  218.632537] [pid:20427,cpu6,guvcview,8]uvcvideo: Device requested 2752512 B/frame bandwidth.
    [  218.632598] [pid:20427,cpu6,guvcview,9]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.

Quoted 9 lines
---
 drivers/media/usb/uvc/uvc_video.c | 9 +++++++++
 1 file changed, 9 insertions(+)
drivers/media/usb/uvc/uvc_video.c +0 -0
index e3567aeb0007..a74cf89852d1 100644

drivers/media/usb/uvc/uvc_video.c static void uvc_fixup_video_ctrl(struct uvc_streaming *stream, · line 270

Quoted 9 lines
drivers/media/usb/uvc/uvc_video.c +6 -0
@@ -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,
+                                    "the max payload transmission size (%d) exceededs the size of the ep max packet (%d). Using the max size.\n",
+                                    ctrl->dwMaxPayloadTransferSize,

Minor nitpick. I am trying to standarize "UVC non compliance" header in the logs for this kind of things.

Quoted 2 lines

"UVC non compliance: the max payload transmission size (%d) exceededs the size of the ep max packet (%d). Using the max size.\n"

s/exceededs/exceeds/

I will also replauce %d with %u as both variables are unsigned.

Quoted 8 lines
Quoted 8 lines
drivers/media/usb/uvc/uvc_video.c +3 -0
+                                    stream->maxpsize);
+               ctrl->dwMaxPayloadTransferSize = stream->maxpsize;
+       }
 }
 
 static size_t uvc_video_ctrl_size(struct uvc_streaming *stream)

base-commit: d76bb1ebb5587f66b0f8b8099bfbb44722bc08b3

Signature · 3 lines
Regards,

Laurent Pinchart
author
#3 lore raw

Dear Ricardo Ribalda & Laurent Pinchart:

Quoted 55 lines · Laurent Pinchart
Quoted 45 lines · Ricardo Ribalda

Hi chenchangcheng

Thanks for your patience fixing the warnings from media-ci :)

Regards

Quoted 5 lines · chenchangcheng

From: chenchangcheng <[email protected]>

Some broken device return wrong dwMaxPayloadTransferSize fields as follows:

Quoted 8 lines
    [  218.632537] [pid:20427,cpu6,guvcview,8]uvcvideo: Device requested 2752512 B/frame bandwidth.
    [  218.632598] [pid:20427,cpu6,guvcview,9]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.

Quoted 9 lines
---
 drivers/media/usb/uvc/uvc_video.c | 9 +++++++++
 1 file changed, 9 insertions(+)
drivers/media/usb/uvc/uvc_video.c +0 -0
index e3567aeb0007..a74cf89852d1 100644

drivers/media/usb/uvc/uvc_video.c static void uvc_fixup_video_ctrl(struct uvc_streaming *stream, · line 270

Quoted 9 lines
drivers/media/usb/uvc/uvc_video.c +6 -0
@@ -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,
+                                    "the max payload transmission size (%d) exceededs the size of the ep max packet (%d). Using the max size.\n",
+                                    ctrl->dwMaxPayloadTransferSize,

Minor nitpick. I am trying to standarize "UVC non compliance" header in the logs for this kind of things.

Quoted 2 lines

"UVC non compliance: the max payload transmission size (%d) exceededs the size of the ep max packet (%d). Using the max size.\n"

s/exceededs/exceeds/

I will also replauce %d with %u as both variables are unsigned.

Quoted 13 lines
Quoted 8 lines
Quoted 8 lines
drivers/media/usb/uvc/uvc_video.c +3 -0
+                                    stream->maxpsize);
+               ctrl->dwMaxPayloadTransferSize = stream->maxpsize;
+       }
 }
 
 static size_t uvc_video_ctrl_size(struct uvc_streaming *stream)

base-commit: d76bb1ebb5587f66b0f8b8099bfbb44722bc08b3

Signature · 3 lines
Regards,

Laurent Pinchart

Thank you for your guidance.
I will submit a new version after the modifications.

Signature · 3 lines
Regards,

Changcheng Chen