* [PATCH v4] media: uvcvideo: Fix bandwidth error for Alcor camera
@ 2022-11-22 8:48 Ai Chao
2022-11-23 8:19 ` Ricardo Ribalda
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Ai Chao @ 2022-11-22 8:48 UTC (permalink / raw)
To: laurent.pinchart, mchehab, ribalda; +Cc: linux-media, linux-kernel, Ai Chao
For Alcor Corp. Slave camera(1b17:6684/2017:0011), it support to output
compressed video data, and it return a wrong dwMaxPayloadTransferSize
fields. This is a fireware issue, but the manufacturer cannot provide
a const return fieldsby the fireware. For some device, it requested
2752512 B/frame bandwidth. For normally device, it requested 3072 or 1024
B/frame bandwidth. so we check the dwMaxPayloadTransferSize fields,if it
large than 0x1000, reset dwMaxPayloadTransferSize to 1024, and the camera
preview normally.
Signed-off-by: Ai Chao <aichao@kylinos.cn>
---
change for v4
- Change usb_match_one_id to usb_match_id
- Modify the discription
change for v3
- Add VID/PID 2017:0011
change for v2
- Used usb_match_one_id to check VID and PID
---
---
drivers/media/usb/uvc/uvc_video.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/drivers/media/usb/uvc/uvc_video.c b/drivers/media/usb/uvc/uvc_video.c
index d2eb9066e4dc..75bdd71d0e5a 100644
--- a/drivers/media/usb/uvc/uvc_video.c
+++ b/drivers/media/usb/uvc/uvc_video.c
@@ -135,6 +135,11 @@ static void uvc_fixup_video_ctrl(struct uvc_streaming *stream,
static const struct usb_device_id elgato_cam_link_4k = {
USB_DEVICE(0x0fd9, 0x0066)
};
+ static const struct usb_device_id alcor_corp_slave_cam[] = {
+ { USB_DEVICE(0x2017, 0x0011) },
+ { USB_DEVICE(0x1b17, 0x6684) },
+ { }
+ };
struct uvc_format *format = NULL;
struct uvc_frame *frame = NULL;
unsigned int i;
@@ -234,6 +239,13 @@ static void uvc_fixup_video_ctrl(struct uvc_streaming *stream,
ctrl->dwMaxPayloadTransferSize = bandwidth;
}
+
+ /* Alcor Corp. Slave camera return wrong dwMaxPayloadTransferSize */
+ if ((format->flags & UVC_FMT_FLAG_COMPRESSED) &&
+ (ctrl->dwMaxPayloadTransferSize > 0x1000) &&
+ usb_match_id(stream->dev->intf, alcor_corp_slave_cam)) {
+ ctrl->dwMaxPayloadTransferSize = 1024;
+ }
}
static size_t uvc_video_ctrl_size(struct uvc_streaming *stream)
--
2.25.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v4] media: uvcvideo: Fix bandwidth error for Alcor camera
2022-11-22 8:48 [PATCH v4] media: uvcvideo: Fix bandwidth error for Alcor camera Ai Chao
@ 2022-11-23 8:19 ` Ricardo Ribalda
2022-11-23 8:56 ` Jackie Liu
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Ricardo Ribalda @ 2022-11-23 8:19 UTC (permalink / raw)
To: Ai Chao; +Cc: laurent.pinchart, mchehab, linux-media, linux-kernel
Hi Ai
On Tue, 22 Nov 2022 at 09:49, Ai Chao <aichao@kylinos.cn> wrote:
>
> For Alcor Corp. Slave camera(1b17:6684/2017:0011), it support to output
> compressed video data, and it return a wrong dwMaxPayloadTransferSize
> fields. This is a fireware issue, but the manufacturer cannot provide
> a const return fieldsby the fireware. For some device, it requested
nit:s/fireware/firmware/
> 2752512 B/frame bandwidth. For normally device, it requested 3072 or 1024
> B/frame bandwidth. so we check the dwMaxPayloadTransferSize fields,if it
> large than 0x1000, reset dwMaxPayloadTransferSize to 1024, and the camera
> preview normally.
>
> Signed-off-by: Ai Chao <aichao@kylinos.cn>
Reviewed-by: Ricardo Ribalda <ribalda@chromium.org>
>
> ---
> change for v4
> - Change usb_match_one_id to usb_match_id
> - Modify the discription
>
> change for v3
> - Add VID/PID 2017:0011
>
> change for v2
> - Used usb_match_one_id to check VID and PID
> ---
> ---
> drivers/media/usb/uvc/uvc_video.c | 12 ++++++++++++
> 1 file changed, 12 insertions(+)
>
> diff --git a/drivers/media/usb/uvc/uvc_video.c b/drivers/media/usb/uvc/uvc_video.c
> index d2eb9066e4dc..75bdd71d0e5a 100644
> --- a/drivers/media/usb/uvc/uvc_video.c
> +++ b/drivers/media/usb/uvc/uvc_video.c
> @@ -135,6 +135,11 @@ static void uvc_fixup_video_ctrl(struct uvc_streaming *stream,
> static const struct usb_device_id elgato_cam_link_4k = {
> USB_DEVICE(0x0fd9, 0x0066)
> };
> + static const struct usb_device_id alcor_corp_slave_cam[] = {
> + { USB_DEVICE(0x2017, 0x0011) },
> + { USB_DEVICE(0x1b17, 0x6684) },
> + { }
> + };
> struct uvc_format *format = NULL;
> struct uvc_frame *frame = NULL;
> unsigned int i;
> @@ -234,6 +239,13 @@ static void uvc_fixup_video_ctrl(struct uvc_streaming *stream,
>
> ctrl->dwMaxPayloadTransferSize = bandwidth;
> }
> +
> + /* Alcor Corp. Slave camera return wrong dwMaxPayloadTransferSize */
> + if ((format->flags & UVC_FMT_FLAG_COMPRESSED) &&
> + (ctrl->dwMaxPayloadTransferSize > 0x1000) &&
> + usb_match_id(stream->dev->intf, alcor_corp_slave_cam)) {
> + ctrl->dwMaxPayloadTransferSize = 1024;
> + }
> }
>
> static size_t uvc_video_ctrl_size(struct uvc_streaming *stream)
> --
> 2.25.1
>
--
Ricardo Ribalda
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v4] media: uvcvideo: Fix bandwidth error for Alcor camera
2022-11-22 8:48 [PATCH v4] media: uvcvideo: Fix bandwidth error for Alcor camera Ai Chao
2022-11-23 8:19 ` Ricardo Ribalda
@ 2022-11-23 8:56 ` Jackie Liu
2022-12-30 17:47 ` Laurent Pinchart
2023-01-07 0:11 ` Laurent Pinchart
3 siblings, 0 replies; 5+ messages in thread
From: Jackie Liu @ 2022-11-23 8:56 UTC (permalink / raw)
To: Ai Chao, laurent.pinchart, mchehab, ribalda; +Cc: linux-media, linux-kernel
Hi, Chao.
在 2022/11/22 16:48, Ai Chao 写道:
> For Alcor Corp. Slave camera(1b17:6684/2017:0011), it support to output
> compressed video data, and it return a wrong dwMaxPayloadTransferSize
Instead of starting with a space, please start with a letter.
> fields. This is a fireware issue, but the manufacturer cannot provide
> a const return fieldsby the fireware. For some device, it requested
s/fireware/firmware/ ???
> 2752512 B/frame bandwidth. For normally device, it requested 3072 or 1024
> B/frame bandwidth. so we check the dwMaxPayloadTransferSize fields,if it
> large than 0x1000, reset dwMaxPayloadTransferSize to 1024, and the camera
> preview normally.
Until here.
>
> Signed-off-by: Ai Chao <aichao@kylinos.cn>
>
> ---
> change for v4
> - Change usb_match_one_id to usb_match_id
> - Modify the discription
>
> change for v3
> - Add VID/PID 2017:0011
>
> change for v2
> - Used usb_match_one_id to check VID and PID
> ---
> ---
> drivers/media/usb/uvc/uvc_video.c | 12 ++++++++++++
> 1 file changed, 12 insertions(+)
>
> diff --git a/drivers/media/usb/uvc/uvc_video.c b/drivers/media/usb/uvc/uvc_video.c
> index d2eb9066e4dc..75bdd71d0e5a 100644
> --- a/drivers/media/usb/uvc/uvc_video.c
> +++ b/drivers/media/usb/uvc/uvc_video.c
> @@ -135,6 +135,11 @@ static void uvc_fixup_video_ctrl(struct uvc_streaming *stream,
> static const struct usb_device_id elgato_cam_link_4k = {
> USB_DEVICE(0x0fd9, 0x0066)
> };
> + static const struct usb_device_id alcor_corp_slave_cam[] = {
> + { USB_DEVICE(0x2017, 0x0011) },
> + { USB_DEVICE(0x1b17, 0x6684) },
> + { }
> + };
> struct uvc_format *format = NULL;
> struct uvc_frame *frame = NULL;
> unsigned int i;
> @@ -234,6 +239,13 @@ static void uvc_fixup_video_ctrl(struct uvc_streaming *stream,
>
> ctrl->dwMaxPayloadTransferSize = bandwidth;
> }
> +
> + /* Alcor Corp. Slave camera return wrong dwMaxPayloadTransferSize */
> + if ((format->flags & UVC_FMT_FLAG_COMPRESSED) &&
> + (ctrl->dwMaxPayloadTransferSize > 0x1000) &&
> + usb_match_id(stream->dev->intf, alcor_corp_slave_cam)) {
> + ctrl->dwMaxPayloadTransferSize = 1024;
> + }
> }
>
> static size_t uvc_video_ctrl_size(struct uvc_streaming *stream)
Others, LGTM.
Reviewed-by: Jackie Liu <liuyun01@kylinos.cn>
--
Jackie Liu
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v4] media: uvcvideo: Fix bandwidth error for Alcor camera
2022-11-22 8:48 [PATCH v4] media: uvcvideo: Fix bandwidth error for Alcor camera Ai Chao
2022-11-23 8:19 ` Ricardo Ribalda
2022-11-23 8:56 ` Jackie Liu
@ 2022-12-30 17:47 ` Laurent Pinchart
2023-01-07 0:11 ` Laurent Pinchart
3 siblings, 0 replies; 5+ messages in thread
From: Laurent Pinchart @ 2022-12-30 17:47 UTC (permalink / raw)
To: Ai Chao; +Cc: mchehab, ribalda, linux-media, linux-kernel
Hi Ai,
Thank you for the patch.
On Tue, Nov 22, 2022 at 04:48:33PM +0800, Ai Chao wrote:
> For Alcor Corp. Slave camera(1b17:6684/2017:0011), it support to output
Could you please send me the USB descriptors for the 2017:0011 device
(lsusb -v -d 2017:0011) ?
> compressed video data, and it return a wrong dwMaxPayloadTransferSize
> fields. This is a fireware issue, but the manufacturer cannot provide
> a const return fieldsby the fireware. For some device, it requested
> 2752512 B/frame bandwidth. For normally device, it requested 3072 or 1024
> B/frame bandwidth. so we check the dwMaxPayloadTransferSize fields,if it
> large than 0x1000, reset dwMaxPayloadTransferSize to 1024, and the camera
> preview normally.
>
> Signed-off-by: Ai Chao <aichao@kylinos.cn>
>
> ---
> change for v4
> - Change usb_match_one_id to usb_match_id
> - Modify the discription
>
> change for v3
> - Add VID/PID 2017:0011
>
> change for v2
> - Used usb_match_one_id to check VID and PID
> ---
> ---
> drivers/media/usb/uvc/uvc_video.c | 12 ++++++++++++
> 1 file changed, 12 insertions(+)
>
> diff --git a/drivers/media/usb/uvc/uvc_video.c b/drivers/media/usb/uvc/uvc_video.c
> index d2eb9066e4dc..75bdd71d0e5a 100644
> --- a/drivers/media/usb/uvc/uvc_video.c
> +++ b/drivers/media/usb/uvc/uvc_video.c
> @@ -135,6 +135,11 @@ static void uvc_fixup_video_ctrl(struct uvc_streaming *stream,
> static const struct usb_device_id elgato_cam_link_4k = {
> USB_DEVICE(0x0fd9, 0x0066)
> };
> + static const struct usb_device_id alcor_corp_slave_cam[] = {
> + { USB_DEVICE(0x2017, 0x0011) },
> + { USB_DEVICE(0x1b17, 0x6684) },
> + { }
> + };
> struct uvc_format *format = NULL;
> struct uvc_frame *frame = NULL;
> unsigned int i;
> @@ -234,6 +239,13 @@ static void uvc_fixup_video_ctrl(struct uvc_streaming *stream,
>
> ctrl->dwMaxPayloadTransferSize = bandwidth;
> }
> +
> + /* Alcor Corp. Slave camera return wrong dwMaxPayloadTransferSize */
> + if ((format->flags & UVC_FMT_FLAG_COMPRESSED) &&
Is the issue limited to MJPEG ? The device also supports YUYV, does it
provide a correct dwMaxPayloadTransferSize in that case ?
> + (ctrl->dwMaxPayloadTransferSize > 0x1000) &&
> + usb_match_id(stream->dev->intf, alcor_corp_slave_cam)) {
> + ctrl->dwMaxPayloadTransferSize = 1024;
> + }
> }
>
> static size_t uvc_video_ctrl_size(struct uvc_streaming *stream)
--
Regards,
Laurent Pinchart
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v4] media: uvcvideo: Fix bandwidth error for Alcor camera
2022-11-22 8:48 [PATCH v4] media: uvcvideo: Fix bandwidth error for Alcor camera Ai Chao
` (2 preceding siblings ...)
2022-12-30 17:47 ` Laurent Pinchart
@ 2023-01-07 0:11 ` Laurent Pinchart
3 siblings, 0 replies; 5+ messages in thread
From: Laurent Pinchart @ 2023-01-07 0:11 UTC (permalink / raw)
To: Ai Chao; +Cc: mchehab, ribalda, linux-media, linux-kernel
Hi again,
On Tue, Nov 22, 2022 at 04:48:33PM +0800, Ai Chao wrote:
> For Alcor Corp. Slave camera(1b17:6684/2017:0011), it support to output
> compressed video data, and it return a wrong dwMaxPayloadTransferSize
> fields. This is a fireware issue, but the manufacturer cannot provide
> a const return fieldsby the fireware. For some device, it requested
> 2752512 B/frame bandwidth. For normally device, it requested 3072 or 1024
> B/frame bandwidth. so we check the dwMaxPayloadTransferSize fields,if it
> large than 0x1000, reset dwMaxPayloadTransferSize to 1024, and the camera
> preview normally.
>
> Signed-off-by: Ai Chao <aichao@kylinos.cn>
>
> ---
> change for v4
> - Change usb_match_one_id to usb_match_id
> - Modify the discription
>
> change for v3
> - Add VID/PID 2017:0011
>
> change for v2
> - Used usb_match_one_id to check VID and PID
> ---
> ---
> drivers/media/usb/uvc/uvc_video.c | 12 ++++++++++++
> 1 file changed, 12 insertions(+)
>
> diff --git a/drivers/media/usb/uvc/uvc_video.c b/drivers/media/usb/uvc/uvc_video.c
> index d2eb9066e4dc..75bdd71d0e5a 100644
> --- a/drivers/media/usb/uvc/uvc_video.c
> +++ b/drivers/media/usb/uvc/uvc_video.c
> @@ -135,6 +135,11 @@ static void uvc_fixup_video_ctrl(struct uvc_streaming *stream,
> static const struct usb_device_id elgato_cam_link_4k = {
> USB_DEVICE(0x0fd9, 0x0066)
> };
> + static const struct usb_device_id alcor_corp_slave_cam[] = {
> + { USB_DEVICE(0x2017, 0x0011) },
> + { USB_DEVICE(0x1b17, 0x6684) },
> + { }
> + };
> struct uvc_format *format = NULL;
> struct uvc_frame *frame = NULL;
> unsigned int i;
> @@ -234,6 +239,13 @@ static void uvc_fixup_video_ctrl(struct uvc_streaming *stream,
>
> ctrl->dwMaxPayloadTransferSize = bandwidth;
> }
> +
> + /* Alcor Corp. Slave camera return wrong dwMaxPayloadTransferSize */
Let's add a bit more documentation:
/*
* Another issue is with devices that report a transfer size that
* greatly exceeds the maximum supported by any existing USB version.
* For instance, the "Slave camera" devices from Alcor Corp. (2017:0011
* and 1b17:66B8) request 2752512 bytes per interval.
*/
I would also take this as an opportunity to document the previous fixup,
just above the UVC_QUIRK_FIX_BANDWIDTH check, with
/*
* Many devices report an incorrect dwMaxPayloadTransferSize value. The
* most common issue is devices requesting the maximum possible USB
* bandwidth (3072 bytes per interval for high-speed, high-bandwidth
* isochronous endpoints) while they actually require less, preventing
* multiple cameras from being used at the same time due to bandwidth
* overallocation.
*
* For those devices, replace the dwMaxPayloadTransferSize value based
* on an estimation calculated from the frame format and size. This is
* only possible for uncompressed formats, as not enough information is
* available to reliably estimate the bandwidth requirements for
* compressed formats.
*/
> + if ((format->flags & UVC_FMT_FLAG_COMPRESSED) &&
> + (ctrl->dwMaxPayloadTransferSize > 0x1000) &&
Given that the highest bandwidth supported by high-speed, high bandwidth
devices is 3072 bytes per interval, I would check
(ctrl->dwMaxPayloadTransferSize > 3072) &&
here.
> + usb_match_id(stream->dev->intf, alcor_corp_slave_cam)) {
I'm also wondering if we could enable this fixup for all devices using
isochronous endpoints (as for bulk endpoints the transfer size can be
higher), without checking the VID:PID. No isochronous high-speed,
high-bandwidth device should have a swMaxPayloadTransferSize value
higher than 3072. For super-speed devices I'm not entirely sure if the
maximum transfer size covers multiple transfers in a burst. Ricardo, do
you know anything about that ?
I can send a v5 that does all this.
> + ctrl->dwMaxPayloadTransferSize = 1024;
> + }
> }
>
> static size_t uvc_video_ctrl_size(struct uvc_streaming *stream)
--
Regards,
Laurent Pinchart
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-01-07 0:11 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-22 8:48 [PATCH v4] media: uvcvideo: Fix bandwidth error for Alcor camera Ai Chao
2022-11-23 8:19 ` Ricardo Ribalda
2022-11-23 8:56 ` Jackie Liu
2022-12-30 17:47 ` Laurent Pinchart
2023-01-07 0:11 ` Laurent Pinchart
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).