Message ID | 20221122084833.1241078-1-aichao@kylinos.cn |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2085867wrr; Tue, 22 Nov 2022 00:57:45 -0800 (PST) X-Google-Smtp-Source: AA0mqf79+qae59uJeGGp0aacbXzc6/k6EfwfGjMtq7ED5a4c+Z4PTFQRtii76A+UOChFcxaDnqKJ X-Received: by 2002:a17:906:5409:b0:7b2:7b45:848f with SMTP id q9-20020a170906540900b007b27b45848fmr19084304ejo.129.1669107465385; Tue, 22 Nov 2022 00:57:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669107465; cv=none; d=google.com; s=arc-20160816; b=YI2l8+UGW5SXBOgeRdDoSFgOuIhNLSMxjf8ItcSkPEl6sVycfzHzTVN80diPLjqiz1 oehbdnxjRapA7mX7taSFaZUnh5tJ5SCrGeSuZjMw3O2zjiNw0pyihK3SMdZp8XDRQxEX KPjPCIDdkNqD+eUrQk+x9R1VMdOxfxbCphCG3/RzeXG3QJGHlUNSNVl0z4U8zqiLnpo8 UT8UuzX+v4CkkOIBfzLK3FlZkRMwyy9HxmkK1VLAGbHOvlhEOh99zXmjzVsJazUXPwE4 JQ3LL5xgW7aYqze8OCq2K19xFkXYuNmFhIk4FHj/X1qanANyASPbhqwsqOL/14tLuKJU eHvQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=mafJSkdftLtYXUSpIsIdOUm6Cx9oeb8cs2LqFnAQVNY=; b=g+a84A4NL4p6tTQbw5IZ/PsrGqntWghh+WrF8uuMJDdqC867UrmP6W5+nspB4Rs4Aa zL1LU5lCXzn96/kCC+VdX421/RSTVzW+nogAaEmqrpYXGBZXEGjAjVNLlKuqNOoeNa6O occXrUkNrrZByfl40RgeTNjoe2XcXxD6EwynOxrDWoTGyb80iV+ao3ZvH+gfIxTrs/rX +T3KKqtsOS+POLgrS06SyfFFodGbDMxDxD5W3HbV/z5tpso/rKhleMizKbrE+h7mcL/b bq7YjF3Eq2qpdG2SSCNGFtt861iv9hADGndkDVDlW25smb6rT9JMALpgfMuXJ6FWtDcq k/og== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sb21-20020a1709076d9500b0078df1c345dasi12867137ejc.534.2022.11.22.00.57.21; Tue, 22 Nov 2022 00:57:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232933AbiKVIts (ORCPT <rfc822;cjcooper78@gmail.com> + 99 others); Tue, 22 Nov 2022 03:49:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51076 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229459AbiKVItr (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 22 Nov 2022 03:49:47 -0500 Received: from mailgw.kylinos.cn (unknown [124.126.103.232]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ABFFE2EF27; Tue, 22 Nov 2022 00:49:45 -0800 (PST) X-UUID: a4ba9ef470ac43859a62a212c5ff47b9-20221122 X-CPASD-INFO: d934f1414b9e43fb80baa5b3114d7ae4@rYltVJNjYmFggnuxg3axnFhhkpGRYYK Cc2tUlGWRkVSVhH5xTV5nX1V9gnNXZF5dXFV3dnBQYmBhXVJ3i3-XblBgXoZgUZB3s3ttVJZfZA== X-CLOUD-ID: d934f1414b9e43fb80baa5b3114d7ae4 X-CPASD-SUMMARY: SIP:-1,APTIP:-2.0,KEY:0.0,FROMBLOCK:1,OB:0.0,URL:-5,TVAL:161. 0,ESV:0.0,ECOM:-5.0,ML:0.0,FD:0.0,CUTS:197.0,IP:-2.0,MAL:-5.0,PHF:-5.0,PHC:-5 .0,SPF:4.0,EDMS:-5,IPLABEL:4480.0,FROMTO:0,AD:0,FFOB:0.0,CFOB:0.0,SPC:0,SIG:- 5,AUF:7,DUF:8907,ACD:149,DCD:149,SL:0,EISP:0,AG:0,CFC:0.544,CFSR:0.029,UAT:0, RAF:0,IMG:-5.0,DFA:0,DTA:0,IBL:-2.0,ADI:-5,SBL:0,REDM:0,REIP:0,ESB:0,ATTNUM:0 ,EAF:0,CID:-5.0,VERSION:2.3.17 X-CPASD-ID: a4ba9ef470ac43859a62a212c5ff47b9-20221122 X-CPASD-BLOCK: 1000 X-CPASD-STAGE: 1 X-UUID: a4ba9ef470ac43859a62a212c5ff47b9-20221122 X-User: aichao@kylinos.cn Received: from localhost.localdomain [(112.64.161.44)] by mailgw (envelope-from <aichao@kylinos.cn>) (Generic MTA) with ESMTP id 1114180233; Tue, 22 Nov 2022 16:49:37 +0800 From: Ai Chao <aichao@kylinos.cn> To: laurent.pinchart@ideasonboard.com, mchehab@kernel.org, ribalda@chromium.org Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Ai Chao <aichao@kylinos.cn> Subject: [PATCH v4] media: uvcvideo: Fix bandwidth error for Alcor camera Date: Tue, 22 Nov 2022 16:48:33 +0800 Message-Id: <20221122084833.1241078-1-aichao@kylinos.cn> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00,PDS_RDNS_DYNAMIC_FP, RDNS_DYNAMIC,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750186029712351408?= X-GMAIL-MSGID: =?utf-8?q?1750186029712351408?= |
Series |
[v4] media: uvcvideo: Fix bandwidth error for Alcor camera
|
|
Commit Message
Ai Chao
Nov. 22, 2022, 8:48 a.m. UTC
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(+)
Comments
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 >
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>
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)
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)
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)