From patchwork Fri Nov 18 02:23:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ai Chao X-Patchwork-Id: 22073 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp738854wrr; Thu, 17 Nov 2022 18:29:21 -0800 (PST) X-Google-Smtp-Source: AA0mqf7JIncuQqocUkq/pdNSrWa7aPDbvWNpbszDWodKct53eMQkvWAx7kBjg8Y58yLHdSu7FfHu X-Received: by 2002:a65:694e:0:b0:474:6749:407d with SMTP id w14-20020a65694e000000b004746749407dmr4657809pgq.425.1668738561386; Thu, 17 Nov 2022 18:29:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668738561; cv=none; d=google.com; s=arc-20160816; b=Ui3qtPrr0OZP2fHNN4x7wM6DyhOUXx4ST9cmdHwH6eLN7oGbixIUGQDW73Pfa/Qa4v XX4KGySiubs1Wu2gdHT+n4ZNjG+5lJaFi/M3BVcIdc7PCkXAmX+as5/R5H97PLOuIeHy XB7B+zh0n7DpVobf2raxRG1TKAE2NPxr8FzFVBjO1Q+Eo5e73zQX/NeeI2D0nzo8cQ/m IGG7XRA5hCKH04natlxNzgfQ0W6AQLj3EehYQTo6Q47C+E0xqIXUxML832BrAAzmoE2j EybL/vHiPYcF8qG30BZP29YXQ86WQ97BIDoXjPYWf6+GDl9c83f+ub9lFiXE/UeEtz8z /7RA== 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=jIORvmXONa8FQE2fLTlWDmcsNFcS95sOWBzZjSrnHUU=; b=vZyzM6MCZMsPlOAmLU64yzskp0MR3xzUH5ZWGWkWf69/D32xs61nD3F77LcOPUTE0p o51hu2T5mMj+fT/HzBdqsviGSnPyZ2yWpG9D4PbiaXNNVGh9mLiHbnJX9Mr/DUqetMPa cjgWPY0yiUMUJOu9UXoGVEtYoVF4ni55ETO4CkJTNk8TjQ+yGTZeiHUBHs0ErKO+btsl jlejCcQ4vi8fQ5MUKtKTu3C5pNkxMRsGWkU76lsfxyt+2HwDTPgy5kFPvzR9d0n7NfOJ tnBcDNyvGnlvDvV5cdG8ZaFO9mD8zEgxnhNe7ycK8QFDBbxiOvKlrRZEbc8NLTzJICW5 I6Eg== 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 m21-20020a170902e41500b0017f9db0233fsi1249428ple.448.2022.11.17.18.29.08; Thu, 17 Nov 2022 18:29:21 -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 S234695AbiKRCXZ (ORCPT + 99 others); Thu, 17 Nov 2022 21:23:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47148 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232050AbiKRCXW (ORCPT ); Thu, 17 Nov 2022 21:23:22 -0500 Received: from mailgw.kylinos.cn (unknown [124.126.103.232]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 00E6674AAA; Thu, 17 Nov 2022 18:23:17 -0800 (PST) X-UUID: 01a59f0de35b4581b34eda7dfd5bef7b-20221118 X-CPASD-INFO: 113bc3333ceb49adbfea8f3b96d65fcb@eoFtgpBlYWNfg6eug3ysnoKXlZFoklO xe3CEZmOWj4KVhH5xTV5uYFV9fWtVYV9dYVR6eGxQYmBgZFJ4i3-XblBgXoZgUZB3gHNtgpNhYw== X-CLOUD-ID: 113bc3333ceb49adbfea8f3b96d65fcb 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:189.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:5,DUF:8679,ACD:144,DCD:144,SL:0,EISP:0,AG:0,CFC:0.526,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: 01a59f0de35b4581b34eda7dfd5bef7b-20221118 X-CPASD-BLOCK: 1000 X-CPASD-STAGE: 1 X-UUID: 01a59f0de35b4581b34eda7dfd5bef7b-20221118 X-User: aichao@kylinos.cn Received: from localhost.localdomain [(112.64.161.44)] by mailgw (envelope-from ) (Generic MTA) with ESMTP id 748414521; Fri, 18 Nov 2022 10:23:36 +0800 From: Ai Chao To: laurent.pinchart@ideasonboard.com, mchehab@kernel.org, ribalda@chromium.org Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Ai Chao Subject: [PATCH v3] media: uvcvideo: Fix bandwidth error for Alcor camera Date: Fri, 18 Nov 2022 10:23:02 +0800 Message-Id: <20221118022302.112121-1-aichao@kylinos.cn> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749799205860624542?= X-GMAIL-MSGID: =?utf-8?q?1749799205860624542?= 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 fields by the fireware. For some device, device requested 2752512 B/frame bandwidth. For some device, device requested 3072 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 --- 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 | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/media/usb/uvc/uvc_video.c b/drivers/media/usb/uvc/uvc_video.c index d2eb9066e4dc..1260800ef8bd 100644 --- a/drivers/media/usb/uvc/uvc_video.c +++ b/drivers/media/usb/uvc/uvc_video.c @@ -135,6 +135,10 @@ 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(0x1b17, 0x6684), + USB_DEVICE(0x2017, 0x0011), + }; struct uvc_format *format = NULL; struct uvc_frame *frame = NULL; unsigned int i; @@ -234,6 +238,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_one_id(stream->dev->intf, &alcor_corp_slave_cam)) { + ctrl->dwMaxPayloadTransferSize = 1024; + } } static size_t uvc_video_ctrl_size(struct uvc_streaming *stream)