[PATCH v10] media: uvcvideo: Fix bandwidth issue for Alcor camera.

chenchangcheng posted 1 patch 7 months, 1 week ago
There is a newer version of this series
drivers/media/usb/uvc/uvc_video.c | 9 +++++++++
1 file changed, 9 insertions(+)
[PATCH v10] media: uvcvideo: Fix bandwidth issue for Alcor camera.
Posted by chenchangcheng 7 months, 1 week ago
From: chenchangcheng <chenchangcheng@kylinos.cn>

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.

Signed-off-by: chenchangcheng <chenchangcheng@kylinos.cn>
---
 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..a74cf89852d1 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,
+				     "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
-- 
2.25.1
Re: [PATCH v10] media: uvcvideo: Fix bandwidth issue for Alcor camera.
Posted by Ricardo Ribalda 7 months ago
Hi chenchangcheng

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

Regards

On Sat, 10 May 2025 at 08:18, chenchangcheng <ccc194101@163.com> wrote:
>
> From: chenchangcheng <chenchangcheng@kylinos.cn>
>
> 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.
>
> Signed-off-by: chenchangcheng <chenchangcheng@kylinos.cn>
Reviewed-by: Ricardo Ribalda <ribalda@chromium.org>
> ---
>  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..a74cf89852d1 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,
> +                                    "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"
> +                                    stream->maxpsize);
> +               ctrl->dwMaxPayloadTransferSize = stream->maxpsize;
> +       }
>  }
>
>  static size_t uvc_video_ctrl_size(struct uvc_streaming *stream)
>
> base-commit: d76bb1ebb5587f66b0f8b8099bfbb44722bc08b3
> --
> 2.25.1
>


-- 
Ricardo Ribalda
Re: [PATCH v10] media: uvcvideo: Fix bandwidth issue for Alcor camera.
Posted by Laurent Pinchart 7 months ago
On Wed, May 14, 2025 at 11:17:06AM +0200, Ricardo Ribalda wrote:
> Hi chenchangcheng
> 
> Thanks for your patience fixing the warnings from media-ci :)
> 
> Regards
> 
> On Sat, 10 May 2025 at 08:18, chenchangcheng <ccc194101@163.com> wrote:
> >
> > From: chenchangcheng <chenchangcheng@kylinos.cn>
> >
> > 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.
> >
> > Signed-off-by: chenchangcheng <chenchangcheng@kylinos.cn>

> Reviewed-by: Ricardo Ribalda <ribalda@chromium.org>
>
> > ---
> >  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..a74cf89852d1 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,
> > +                                    "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"

s/exceededs/exceeds/

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

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

> > +                                    stream->maxpsize);
> > +               ctrl->dwMaxPayloadTransferSize = stream->maxpsize;
> > +       }
> >  }
> >
> >  static size_t uvc_video_ctrl_size(struct uvc_streaming *stream)
> >
> > base-commit: d76bb1ebb5587f66b0f8b8099bfbb44722bc08b3

-- 
Regards,

Laurent Pinchart
Re:Re: [PATCH v10] media: uvcvideo: Fix bandwidth issue for Alcor camera.
Posted by 自己 7 months ago
Dear Ricardo Ribalda & Laurent Pinchart:


At 2025-05-15 16:12:02, "Laurent Pinchart" <laurent.pinchart@ideasonboard.com> wrote:
>On Wed, May 14, 2025 at 11:17:06AM +0200, Ricardo Ribalda wrote:
>> Hi chenchangcheng
>> 
>> Thanks for your patience fixing the warnings from media-ci :)
>> 
>> Regards
>> 
>> On Sat, 10 May 2025 at 08:18, chenchangcheng <ccc194101@163.com> wrote:
>> >
>> > From: chenchangcheng <chenchangcheng@kylinos.cn>
>> >
>> > 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.
>> >
>> > Signed-off-by: chenchangcheng <chenchangcheng@kylinos.cn>
>
>> Reviewed-by: Ricardo Ribalda <ribalda@chromium.org>
>>
>> > ---
>> >  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..a74cf89852d1 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,
>> > +                                    "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"
>
>s/exceededs/exceeds/
>
>I will also replauce %d with %u as both variables are unsigned.
>
>Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
>
>> > +                                    stream->maxpsize);
>> > +               ctrl->dwMaxPayloadTransferSize = stream->maxpsize;
>> > +       }
>> >  }
>> >
>> >  static size_t uvc_video_ctrl_size(struct uvc_streaming *stream)
>> >
>> > base-commit: d76bb1ebb5587f66b0f8b8099bfbb44722bc08b3
>
>-- 
>Regards,
>
>Laurent Pinchart


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

-- 
Regards,

Changcheng Chen