From patchwork Thu Jan 5 12:32:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 39502 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp279160wrt; Thu, 5 Jan 2023 04:37:37 -0800 (PST) X-Google-Smtp-Source: AMrXdXskiE6400/0B8r7bCdzzxllJANo/0jKOb8SgWDHX1GR++2D2GhZPPfYsIf6ddTD5FVxFVVD X-Received: by 2002:a17:906:9e23:b0:7aa:7598:128c with SMTP id fp35-20020a1709069e2300b007aa7598128cmr36188734ejc.37.1672922257067; Thu, 05 Jan 2023 04:37:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672922257; cv=none; d=google.com; s=arc-20160816; b=nsYUlagDKfvpG+CFDuUip2DhyyK/I4Pjps2oEByApfZunKep4JIRLu4tEYuJ7DM8Bd 1AP2FSADx4wUHZX0XRMpKzKfh/ozAbR+J0u9/d39+PNpPbXSmkpkmw1ynSoi4tMFVC92 W/v3nCb+/0q+iz7RxG6S2/hPrv5Q5E2mm+/611Bpw/2O1vb9X7KVp4aNg5r8o/lDdy85 aODOc0b/5DMuMdGsVJHgktuGjlSxm3YQBabJyPtot5Asw9tcZhvPACARhCAERiuQauFZ RDPmwOzdCXReCnJU8t0VQZhtiGSB/25iACqi5Z5+lNV0pN+wLh/+sF4PHn6/6aj4ordn Wgvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=wwpb044KqtjBhtl1Bm719/ilzZh9PY8FBAW1s12for8=; b=bkSQE6vHvOmGeI7TGVmZQPi2EPBMEq3cMtReU0gEyhR9b+BtUXWEylafJ1arN0eDT4 RUi1lWD6cYZsFikG7VApINzX7hODRc2uQWvplAFQDJL2Ob/4i6P8NtWs4laOO07K/xyB 4+zkNCIzBICnrNBmTgZ8j9zjAiOTMZpZM5f8pk8o2onHkG87PcLGuMjibYSD6pcYfeeg ISVCY6JLuVBz/AlUyC5nFW/UpQImPiKDkWV2aXumW5izIdAWctsYuBe6jq3H8Whz2P5R +xFAzMb5nxsRkpmMrY7mV2KMAHsHMiEmvoqIoyn/jp6xh+UNmi6p2YJElof0SKheDe1r Ysig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=AHs7dfOX; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dp15-20020a170906c14f00b007c111fc30absi31197208ejc.865.2023.01.05.04.37.13; Thu, 05 Jan 2023 04:37:37 -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; dkim=pass header.i=@chromium.org header.s=google header.b=AHs7dfOX; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233068AbjAEMdw (ORCPT + 99 others); Thu, 5 Jan 2023 07:33:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58778 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232427AbjAEMde (ORCPT ); Thu, 5 Jan 2023 07:33:34 -0500 Received: from mail-ed1-x531.google.com (mail-ed1-x531.google.com [IPv6:2a00:1450:4864:20::531]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3D8EF485A6 for ; Thu, 5 Jan 2023 04:33:29 -0800 (PST) Received: by mail-ed1-x531.google.com with SMTP id m21so52550689edc.3 for ; Thu, 05 Jan 2023 04:33:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=wwpb044KqtjBhtl1Bm719/ilzZh9PY8FBAW1s12for8=; b=AHs7dfOXIB/OKVfu5rgcTlKLDljanF9Ga/d/kCIzE482MT/5uh42FMdMpDvoJyHnvc 213ywA409wYpmz26bnnjy0IVzLLjzO7vIBJO1/1ldLJCWJ6y9I0tINV88GsLfmIVyH31 aypIudFY3fVIUORq8N7/FHE6RKp40yU3bOsYU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=wwpb044KqtjBhtl1Bm719/ilzZh9PY8FBAW1s12for8=; b=GSifRiCgJdKllEjSZvkMkQss1O0UdHKfBOOWUef4Va+O2TjAT+lG1s3TZ5KP3ka8YY 4M2c70zecXZWx5baID+XxH/X6Q+alCmknhcoqvaSGukqFzE4gxliLE9aAnkRIe5HdJaf 87AKu/oCHukQ7srCfY71JOaYmFT/faLr/OKZjvmCMv8X2q++UK5KX8JLFvQZMqwRO8TM pw8ogvM8V52rUstYqILVlI6VucZbhuX6WpLpb40WqOZQMHbc2He4oloiuqE9Ig1QExK0 2Po3UhwFG2qwdTtnsGWjwL41tHrvaIlhayISyO4Ke6nOBbWP6zCPHMy7PVJPzkKSBlhk 6VHg== X-Gm-Message-State: AFqh2kqtdMV+4d3hmZDWrUh6+1S6uU81zICNXmyl5pPhTtJHrOJ5L9Pz 3n4oNmXFkJ42ynPVml45iT6z+A== X-Received: by 2002:a05:6402:150b:b0:493:a6eb:874f with SMTP id f11-20020a056402150b00b00493a6eb874fmr1216850edw.7.1672922007810; Thu, 05 Jan 2023 04:33:27 -0800 (PST) Received: from alco.roam.corp.google.com ([2620:0:1059:10:43c3:8ac4:5d6f:2251]) by smtp.gmail.com with ESMTPSA id r17-20020aa7d591000000b004847513929csm13138909edq.72.2023.01.05.04.33.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Jan 2023 04:33:27 -0800 (PST) From: Ricardo Ribalda Date: Thu, 05 Jan 2023 13:32:12 +0100 Subject: [PATCH 1/6] Revert "media: uvcvideo: Fix power line control for Lenovo Integrated Camera" MIME-Version: 1.0 Message-Id: <20230105-uvc-gcc5-v1-1-8550de720e82@chromium.org> References: <20230105-uvc-gcc5-v1-0-8550de720e82@chromium.org> In-Reply-To: <20230105-uvc-gcc5-v1-0-8550de720e82@chromium.org> To: Laurent Pinchart , Mauro Carvalho Chehab Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Yunke Cao , Sergey Senozhatsky , Ricardo Ribalda X-Mailer: b4 0.11.0-dev-696ae X-Developer-Signature: v=1; a=openpgp-sha256; l=3972; i=ribalda@chromium.org; h=from:subject:message-id; bh=NB7jQ6QoKPyFq1qlyN4fB4I79KDSooYKz0aYGFsDK/0=; b=owEBbQKS/ZANAwAKAdE30T7POsSIAcsmYgBjtsOJIPodmNM8YDX1mxcv+bsBZ0xhN/gnjG1qMcEq OFtGgkSJAjMEAAEKAB0WIQREDzjr+/4oCDLSsx7RN9E+zzrEiAUCY7bDiQAKCRDRN9E+zzrEiGbQD/ 0dquCOEhE2QMVsGXWdJ/8pVQtpSvtCELnj+O/2itym4znaIRsiB1k2abVwYPSfg/R+eRqMnbPkAmXm FSdf1lHx3vYI79+JOKKck9CSIXlZYsgLrkJ4839n7H1AuADUBzLqd34ZPDfTd3LERP+j0lKgSW4Vp3 ZJOWfixEmgjpcf4z9UWX0ehbtDUb72Lno9fGOVBZUa+ZN7AWvLAX9SPOTNjlCioTNcPFgHuOPUme+R Cc14Y0yyUDV3qSSQJVGOgGCGjeVOajhLjrPNFvXZcwHYcf+YKeG7aSnFn9S5vU1OyQKE3Pbp/OO4sr VfWcY2haq8q8MSNCdZLxCUG1yv2kXbwykkVi1opeSlp0zcZ76YBHiA08bYI4AwpyIwd4ReGjoOJO0+ psnJL0go7TVBxgPMKZDnOGSKRmgP+BbczD3tQqTJtBOitpGh91ldQ8ENZiY/0sxw1Sa95HDomSx4TR Ym1RQrudFtutLPO+KeKJOMsyV5yeBDOmA+bUxkxJGBXdLaigEgYonR8QhZFdM+riFjnEPNqKdeq9Ki R0Rfp5zzQqOh1FM018a+qqik5Wvbi+4SUiVfvDb8mjxILmQ3U5C2PvSEN5grNDRdddUop1S8MveGBv VoJjSrmceH2O8U5WTEUMGsglZDi1IghBi7z1SXdUqpkUGFUPuZoAb6ujmKCg== X-Developer-Key: i=ribalda@chromium.org; a=openpgp; fpr=9EC3BB66E2FC129A6F90B39556A0D81F9F782DA9 X-Spam-Status: No, score=-0.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,SUBJECT_DRUG_GAP_L 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?1754186128567202007?= X-GMAIL-MSGID: =?utf-8?q?1754186128567202007?= This reverts commit fb1316b0ff3fc3cd98637040ee17ab7be753aac7. As today, the minimum version of GCC required to build the kernel is 5.1, which does not support static const structure initialization. Error: drivers/media/usb/uvc/uvc_ctrl.c:737:2: error: initializer element is not a compile-time constant Fixes: fb1316b0ff3f ("media: uvcvideo: Fix power line control for Lenovo Integrated Camera") Signed-off-by: Ricardo Ribalda --- drivers/media/usb/uvc/uvc_ctrl.c | 24 +++++++++++------------- drivers/media/usb/uvc/uvc_driver.c | 16 ---------------- drivers/media/usb/uvc/uvcvideo.h | 1 - 3 files changed, 11 insertions(+), 30 deletions(-) diff --git a/drivers/media/usb/uvc/uvc_ctrl.c b/drivers/media/usb/uvc/uvc_ctrl.c index e07b56bbf853..06bb3822c05d 100644 --- a/drivers/media/usb/uvc/uvc_ctrl.c +++ b/drivers/media/usb/uvc/uvc_ctrl.c @@ -722,20 +722,18 @@ static const struct uvc_control_mapping uvc_ctrl_mappings[] = { }, }; -const struct uvc_control_mapping uvc_ctrl_power_line_mapping_uvc11 = { - .id = V4L2_CID_POWER_LINE_FREQUENCY, - .entity = UVC_GUID_UVC_PROCESSING, - .selector = UVC_PU_POWER_LINE_FREQUENCY_CONTROL, - .size = 2, - .offset = 0, - .v4l2_type = V4L2_CTRL_TYPE_MENU, - .data_type = UVC_CTRL_DATA_TYPE_ENUM, - .menu_info = power_line_frequency_controls, - .menu_mask = BIT_MASK(ARRAY_SIZE(power_line_frequency_controls) - 1), -}; - static const struct uvc_control_mapping uvc_ctrl_mappings_uvc11[] = { - uvc_ctrl_power_line_mapping_uvc11, + { + .id = V4L2_CID_POWER_LINE_FREQUENCY, + .entity = UVC_GUID_UVC_PROCESSING, + .selector = UVC_PU_POWER_LINE_FREQUENCY_CONTROL, + .size = 2, + .offset = 0, + .v4l2_type = V4L2_CTRL_TYPE_MENU, + .data_type = UVC_CTRL_DATA_TYPE_ENUM, + .menu_info = power_line_frequency_controls, + .menu_mask = BIT_MASK(ARRAY_SIZE(power_line_frequency_controls) - 1), + }, }; static const struct uvc_control_mapping uvc_ctrl_mappings_uvc15[] = { diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c index 72c025d8e20b..2f59ee80a0af 100644 --- a/drivers/media/usb/uvc/uvc_driver.c +++ b/drivers/media/usb/uvc/uvc_driver.c @@ -2378,13 +2378,6 @@ MODULE_PARM_DESC(timeout, "Streaming control requests timeout"); * Driver initialization and cleanup */ -static const struct uvc_device_info uvc_ctrl_power_line_uvc11 = { - .mappings = (const struct uvc_control_mapping *[]) { - &uvc_ctrl_power_line_mapping_uvc11, - NULL, /* Sentinel */ - }, -}; - static const struct uvc_menu_info power_line_frequency_controls_limited[] = { { 1, "50 Hz" }, { 2, "60 Hz" }, @@ -2988,15 +2981,6 @@ static const struct usb_device_id uvc_ids[] = { .bInterfaceSubClass = 1, .bInterfaceProtocol = 0, .driver_info = UVC_INFO_QUIRK(UVC_QUIRK_FORCE_BPP) }, - /* Lenovo Integrated Camera */ - { .match_flags = USB_DEVICE_ID_MATCH_DEVICE - | USB_DEVICE_ID_MATCH_INT_INFO, - .idVendor = 0x30c9, - .idProduct = 0x0093, - .bInterfaceClass = USB_CLASS_VIDEO, - .bInterfaceSubClass = 1, - .bInterfaceProtocol = UVC_PC_PROTOCOL_15, - .driver_info = (kernel_ulong_t)&uvc_ctrl_power_line_uvc11 }, /* Sonix Technology USB 2.0 Camera */ { .match_flags = USB_DEVICE_ID_MATCH_DEVICE | USB_DEVICE_ID_MATCH_INT_INFO, diff --git a/drivers/media/usb/uvc/uvcvideo.h b/drivers/media/usb/uvc/uvcvideo.h index ae0066eceffd..a8eec43cd860 100644 --- a/drivers/media/usb/uvc/uvcvideo.h +++ b/drivers/media/usb/uvc/uvcvideo.h @@ -747,7 +747,6 @@ int uvc_status_start(struct uvc_device *dev, gfp_t flags); void uvc_status_stop(struct uvc_device *dev); /* Controls */ -extern const struct uvc_control_mapping uvc_ctrl_power_line_mapping_uvc11; extern const struct v4l2_subscribed_event_ops uvc_ctrl_sub_ev_ops; int uvc_query_v4l2_ctrl(struct uvc_video_chain *chain, From patchwork Thu Jan 5 12:32:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 39497 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp278302wrt; Thu, 5 Jan 2023 04:35:20 -0800 (PST) X-Google-Smtp-Source: AMrXdXvPnM6VY7JmUBePIsGi/BNPZ56eC0S7wggJJRRveoieuDhKnSJgjPKjWOcApvv4qrJZlzkg X-Received: by 2002:a17:906:1655:b0:7b5:73aa:9984 with SMTP id n21-20020a170906165500b007b573aa9984mr40613469ejd.14.1672922119686; Thu, 05 Jan 2023 04:35:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672922119; cv=none; d=google.com; s=arc-20160816; b=R3BDJAbHLBFvzmct5cjhlUu2UBVWc5/VO0wGxlgH7J4k0hS4mOsvm8fKzhbCxD36Xw veIN+apDlhaBmzWmgRsMkVDiSTEsUXlVuDJa1atikaY7vDGWFYxpFUbm/5RBjZhCDJV7 AxLaYzKvI4RnI9jdrieVewY0gNUT6eMwq75F7qDh+teVUdnpA9gYeZdSlUpgfowdgmlj YJbY3XgnhewH8+QXkRA1sNNIvAAiSC+k44IxjxHWCoiEtN7g8WAdVRLJH2ajG6iGTA5V RO+ERIoyri3O3DgcnuvXYsW72CBigkYgqpsNq60PHSqNe3mfpx3MN5WolmaKmvoDNlk4 XmWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=KBGZezEaxNT5mYG63q3/p+giIEe5CEbFfULH3PLbvPA=; b=Fb0BDUfA2dGbqXkgMTmIXDI1dj/KmKaedTjmFBeJEaVMLXzEKYFDSJhFtWjk5I9LnQ iFhkJoPs7lW6KoYFnjvIyo3BLOf+UQye+DQH7ytPYQM84uU0hFhInqzhxhkdXx0CiaqE HIMHYJSSkTC4buVdmb0xexOOvRQ+sC6GUvQjPJJ1G521SvVVpFki6WLW0pxbhas/8fc+ 9d17ABojyZSANrT3RKRvK/o2KK0v0XxjahJ1uhMfbmSJWrbBDzc1XaMsFYvB3SUuZkCd sxjUn2s+hewX4VFxlQ6xnJe1C++5EW5htEWavSBLEDY4KuX+D/lZDQYOAZKxrDfwS1tk 2VCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=Df9cDEPn; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ho18-20020a1709070e9200b0084514612c2asi35294132ejc.609.2023.01.05.04.34.55; Thu, 05 Jan 2023 04:35:19 -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; dkim=pass header.i=@chromium.org header.s=google header.b=Df9cDEPn; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232803AbjAEMdh (ORCPT + 99 others); Thu, 5 Jan 2023 07:33:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58746 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231520AbjAEMdb (ORCPT ); Thu, 5 Jan 2023 07:33:31 -0500 Received: from mail-ed1-x52f.google.com (mail-ed1-x52f.google.com [IPv6:2a00:1450:4864:20::52f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3152148CDB for ; Thu, 5 Jan 2023 04:33:30 -0800 (PST) Received: by mail-ed1-x52f.google.com with SMTP id i9so52608012edj.4 for ; Thu, 05 Jan 2023 04:33:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=KBGZezEaxNT5mYG63q3/p+giIEe5CEbFfULH3PLbvPA=; b=Df9cDEPnMrMjAc51R/8C1RBphrS1ZMgbwsQ/zhRmWfUDDsDg3bGg5u6jx6p5hwzFWC GsRGGfNMFgigqf7M77muxgzOUhQDiemPUB4Oo2tcRjkdcrrajkaTkmeG78fuOFPf9/vT KNh6McVPkjPQxadcyYbwu1+l5CBlp7JzbLwSQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=KBGZezEaxNT5mYG63q3/p+giIEe5CEbFfULH3PLbvPA=; b=yAtU7HKBosMQBTjNWmKTBEN8VBwl9V+vMoTHTXGcMf+Pbpv4+091D0GQdTidqQMY6C Bt6Eed814zm6T+asEhqmWjUq/YSZmZcA9dqQcclLMvvAA5YXweGzv9kBwxmjunaAo2WY eilf7FlDlRDJzgpvgw9aRaDPu2K5l5+dYh076jRzZttjihALVQ8/KQ7yai1kLhmsJVul RpcDcdLHAf2/+EIdluyNcXmGrvcg6zt7m2H4Jk4YKwoO6VyN5755y0KGiGXkFsDtgLpL UYgPmv62FmdvZ8iwuGJ3BtS4i+EVQy8fGsiM2+I75E6DwOSpKRniUIGQkGYa769LbmU4 LTjQ== X-Gm-Message-State: AFqh2koCJgGpXjTCBmJ338u3vNipeCGtXwmpzLFc5zv7TMxkxw+CPa0P ZbCnTgp2lxQW5GuqHmKPUcArXg== X-Received: by 2002:a05:6402:2936:b0:48a:269c:9dc8 with SMTP id ee54-20020a056402293600b0048a269c9dc8mr20164724edb.10.1672922008704; Thu, 05 Jan 2023 04:33:28 -0800 (PST) Received: from alco.roam.corp.google.com ([2620:0:1059:10:43c3:8ac4:5d6f:2251]) by smtp.gmail.com with ESMTPSA id r17-20020aa7d591000000b004847513929csm13138909edq.72.2023.01.05.04.33.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Jan 2023 04:33:28 -0800 (PST) From: Ricardo Ribalda Date: Thu, 05 Jan 2023 13:32:13 +0100 Subject: [PATCH 2/6] Revert "media: uvcvideo: Implement mask for V4L2_CTRL_TYPE_MENU" MIME-Version: 1.0 Message-Id: <20230105-uvc-gcc5-v1-2-8550de720e82@chromium.org> References: <20230105-uvc-gcc5-v1-0-8550de720e82@chromium.org> In-Reply-To: <20230105-uvc-gcc5-v1-0-8550de720e82@chromium.org> To: Laurent Pinchart , Mauro Carvalho Chehab Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Yunke Cao , Sergey Senozhatsky , Ricardo Ribalda X-Mailer: b4 0.11.0-dev-696ae X-Developer-Signature: v=1; a=openpgp-sha256; l=6121; i=ribalda@chromium.org; h=from:subject:message-id; bh=Bll6tbezraJ/a0Cf4Y3tLo27i37SeM2dqnIYPB0QUok=; b=owEBbQKS/ZANAwAKAdE30T7POsSIAcsmYgBjtsOLaFre82MreSAJjzDj3FfC9VRnHyn8bhWiL1lA HFCkEkmJAjMEAAEKAB0WIQREDzjr+/4oCDLSsx7RN9E+zzrEiAUCY7bDiwAKCRDRN9E+zzrEiMR4D/ 9YVpFxZSNP0ojhSnacp+OFzjlaqROm+uJyTn9XxVnxj3tnKiYI3La2Aj5BwYRqJaG0lEujMIr7yChf +/Wz65easwt9e5V5TVFj5I5BOlXE91nKMr5MSsxzKnrcT980J38dUWm64i92tb47cP9PpXd6xUvZit aE7OKee0BWJzzAzv5Mgfyz6RyWz0NE3b4FL+vGfiH9TxobQqNh+G+f9khgETQFoJvUKLDwffMNS4aR Orf+UZnsRPeQdltMkYBwqoG//kwtzIzSFZE/P8tUQEEXLfGvs811wRQGUzv7ptJE6O04L+bGRtLYty 0L94obfvsvQsMdL5xvKk5/yT+s5t1WsZD/5HkEo29WpdnR1YABuHuLmiTheq0N6Wv1YJxdnAcQ54dI kmt9M1yWyXyUDfdpaH1uiQDQOMDB3RnBxUjiNghDjpqvLJqf461BbvSq79G4TlscqJeyIzN2Auc+9c aLodDtPTcF3wToXMpDpBK39rBPfmM+a5/vgb5P7QAcN5DggealX2BGOFLenf/4f+yy7W2wWiF4LqRf LpRAY2ukecVjk66Qz0VUMFnYCFesw1aFOdHqbFBrk9GG6Wtvw83/v8z6+nhlWEpVpljVZIsROxJFKw eOKcu1mMiHR9kCD8l2mERoa7gRIV+bs5Mv5W2ZS93l2BcxrTo383bTtO4Sew== X-Developer-Key: i=ribalda@chromium.org; a=openpgp; fpr=9EC3BB66E2FC129A6F90B39556A0D81F9F782DA9 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=ham 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?1754185984290343976?= X-GMAIL-MSGID: =?utf-8?q?1754185984290343976?= This reverts commit 2ada36ecf16dcd32b56554f01ce38f273bc16efc. BIT_MASK is nothing more than BIT(). Fixes: 2ada36ecf16d ("media: uvcvideo: Implement mask for V4L2_CTRL_TYPE_MENU") Signed-off-by: Ricardo Ribalda --- drivers/media/usb/uvc/uvc_ctrl.c | 30 ++++++++++-------------------- drivers/media/usb/uvc/uvc_driver.c | 3 +-- drivers/media/usb/uvc/uvc_v4l2.c | 3 +-- drivers/media/usb/uvc/uvcvideo.h | 2 +- 4 files changed, 13 insertions(+), 25 deletions(-) diff --git a/drivers/media/usb/uvc/uvc_ctrl.c b/drivers/media/usb/uvc/uvc_ctrl.c index 06bb3822c05d..ffa0e2654264 100644 --- a/drivers/media/usb/uvc/uvc_ctrl.c +++ b/drivers/media/usb/uvc/uvc_ctrl.c @@ -6,7 +6,6 @@ * Laurent Pinchart (laurent.pinchart@ideasonboard.com) */ -#include #include #include #include @@ -526,7 +525,7 @@ static const struct uvc_control_mapping uvc_ctrl_mappings[] = { .v4l2_type = V4L2_CTRL_TYPE_MENU, .data_type = UVC_CTRL_DATA_TYPE_BITMASK, .menu_info = exposure_auto_controls, - .menu_mask = BIT_MASK(ARRAY_SIZE(exposure_auto_controls)), + .menu_count = ARRAY_SIZE(exposure_auto_controls), .slave_ids = { V4L2_CID_EXPOSURE_ABSOLUTE, }, }, { @@ -732,7 +731,7 @@ static const struct uvc_control_mapping uvc_ctrl_mappings_uvc11[] = { .v4l2_type = V4L2_CTRL_TYPE_MENU, .data_type = UVC_CTRL_DATA_TYPE_ENUM, .menu_info = power_line_frequency_controls, - .menu_mask = BIT_MASK(ARRAY_SIZE(power_line_frequency_controls) - 1), + .menu_count = ARRAY_SIZE(power_line_frequency_controls) - 1, }, }; @@ -746,7 +745,7 @@ static const struct uvc_control_mapping uvc_ctrl_mappings_uvc15[] = { .v4l2_type = V4L2_CTRL_TYPE_MENU, .data_type = UVC_CTRL_DATA_TYPE_ENUM, .menu_info = power_line_frequency_controls, - .menu_mask = BIT_MASK(ARRAY_SIZE(power_line_frequency_controls)), + .menu_count = ARRAY_SIZE(power_line_frequency_controls), }, }; @@ -976,9 +975,7 @@ static s32 __uvc_ctrl_get_value(struct uvc_control_mapping *mapping, const struct uvc_menu_info *menu = mapping->menu_info; unsigned int i; - for (i = 0; BIT(i) <= mapping->menu_mask; ++i, ++menu) { - if (!test_bit(i, &mapping->menu_mask)) - continue; + for (i = 0; i < mapping->menu_count; ++i, ++menu) { if (menu->value == value) { value = i; break; @@ -1231,14 +1228,12 @@ static int __uvc_query_v4l2_ctrl(struct uvc_video_chain *chain, switch (mapping->v4l2_type) { case V4L2_CTRL_TYPE_MENU: - v4l2_ctrl->minimum = ffs(mapping->menu_mask) - 1; - v4l2_ctrl->maximum = fls(mapping->menu_mask) - 1; + v4l2_ctrl->minimum = 0; + v4l2_ctrl->maximum = mapping->menu_count - 1; v4l2_ctrl->step = 1; menu = mapping->menu_info; - for (i = 0; BIT(i) <= mapping->menu_mask; ++i, ++menu) { - if (!test_bit(i, &mapping->menu_mask)) - continue; + for (i = 0; i < mapping->menu_count; ++i, ++menu) { if (menu->value == v4l2_ctrl->default_value) { v4l2_ctrl->default_value = i; break; @@ -1359,7 +1354,7 @@ int uvc_query_v4l2_menu(struct uvc_video_chain *chain, goto done; } - if (!test_bit(query_menu->index, &mapping->menu_mask)) { + if (query_menu->index >= mapping->menu_count) { ret = -EINVAL; goto done; } @@ -1873,13 +1868,8 @@ int uvc_ctrl_set(struct uvc_fh *handle, break; case V4L2_CTRL_TYPE_MENU: - if (xctrl->value < (ffs(mapping->menu_mask) - 1) || - xctrl->value > (fls(mapping->menu_mask) - 1)) + if (xctrl->value < 0 || xctrl->value >= mapping->menu_count) return -ERANGE; - - if (!test_bit(xctrl->value, &mapping->menu_mask)) - return -EINVAL; - value = mapping->menu_info[xctrl->value].value; /* @@ -2316,7 +2306,7 @@ static int __uvc_ctrl_add_mapping(struct uvc_video_chain *chain, INIT_LIST_HEAD(&map->ev_subs); - size = sizeof(*mapping->menu_info) * fls(mapping->menu_mask); + size = sizeof(*mapping->menu_info) * mapping->menu_count; map->menu_info = kmemdup(mapping->menu_info, size, GFP_KERNEL); if (!map->menu_info) goto err_nomem; diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c index 2f59ee80a0af..6d08457ecb9c 100644 --- a/drivers/media/usb/uvc/uvc_driver.c +++ b/drivers/media/usb/uvc/uvc_driver.c @@ -7,7 +7,6 @@ */ #include -#include #include #include #include @@ -2392,7 +2391,7 @@ static const struct uvc_control_mapping uvc_ctrl_power_line_mapping_limited = { .v4l2_type = V4L2_CTRL_TYPE_MENU, .data_type = UVC_CTRL_DATA_TYPE_ENUM, .menu_info = power_line_frequency_controls_limited, - .menu_mask = BIT_MASK(ARRAY_SIZE(power_line_frequency_controls_limited)), + .menu_count = ARRAY_SIZE(power_line_frequency_controls_limited), }; static const struct uvc_device_info uvc_ctrl_power_line_limited = { diff --git a/drivers/media/usb/uvc/uvc_v4l2.c b/drivers/media/usb/uvc/uvc_v4l2.c index ed2525e7e2a5..3edb54c086b2 100644 --- a/drivers/media/usb/uvc/uvc_v4l2.c +++ b/drivers/media/usb/uvc/uvc_v4l2.c @@ -6,7 +6,6 @@ * Laurent Pinchart (laurent.pinchart@ideasonboard.com) */ -#include #include #include #include @@ -81,7 +80,7 @@ static int uvc_ioctl_ctrl_map(struct uvc_video_chain *chain, goto free_map; } - map->menu_mask = BIT_MASK(xmap->menu_count); + map->menu_count = xmap->menu_count; break; default: diff --git a/drivers/media/usb/uvc/uvcvideo.h b/drivers/media/usb/uvc/uvcvideo.h index a8eec43cd860..41ba0bbd8171 100644 --- a/drivers/media/usb/uvc/uvcvideo.h +++ b/drivers/media/usb/uvc/uvcvideo.h @@ -115,7 +115,7 @@ struct uvc_control_mapping { u32 data_type; const struct uvc_menu_info *menu_info; - unsigned long menu_mask; + u32 menu_count; u32 master_id; s32 master_manual; From patchwork Thu Jan 5 12:32:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 39498 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp278326wrt; Thu, 5 Jan 2023 04:35:22 -0800 (PST) X-Google-Smtp-Source: AMrXdXsUge6Hh1uqw07ulXRNF59lgPSlyJVTDxwvvqkmNMlcmszwS36xKZ7b8odEa5nYXeeumKwm X-Received: by 2002:a17:906:6a91:b0:844:d342:3566 with SMTP id p17-20020a1709066a9100b00844d3423566mr37170772ejr.22.1672922122120; Thu, 05 Jan 2023 04:35:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672922122; cv=none; d=google.com; s=arc-20160816; b=tVrVe3zztcFwsJJUAlQBjNhzhdSppQ6fKRIg0YPfPE544eonM+SRZU6VWws/b0y/TI DVBsU1pFEAMdAVbNJ7UFIkaj1qQXk85JYD595mkMkc2tDXXkI8C48QMi7rExVQHkShWz ZR162b1GomyP9MdRzSbDjdO7rBS0WfKqrRyv1gqPyz52lUiUQ7ROy/SrgckaaOqxdH3s 2aTR9llwvWzv64X2krhayZwRDs7Lir2/qeE7alm4zyXEP930yUi9J0Fge9Pf1neaDgge wKYhgxMT2NSI8yJb1Jwwdb6ulj5dKKtNsDqZwGm9SsPqz++NkNsXJvmtWXrn7SeMv6BU TzkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=i22sBtg5sgJPjmyCPs4YT31o+9MgBiTxsORfyqFHwvE=; b=rZm7rax6CTzUEtAu+imA8ERiWiGP4VniMwrWcWEAaPW2nxw1VfUp1PuryrHkXfD8Gh W9y1bE+rnSPDihjwVTXsnwxi06VdmGl2yxeO78as+MbVOG3QCetBgbRH5o/noD5OnFMh SrNU9/e6DYwQavO4eDNI6Nc6AgCGB4MfBao6opFEOThndxKimBywyGd9g5uG1lwJpqXo V+H7NjF10PE1FTFI2KhVg+X0Dl2GOkOxnE0nWyU40wg2MGECrv+554hyw4r9Vw1G57Ob SHZ4zuK5QLzQ589SZd44xS8XlDLBV5pT8FlYO0Xe/MxGARf5aq0bDgteLvTzJBs33Hqi Ji8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=kUoF+3ps; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q17-20020a056402519100b0047b5ecde3d7si35582465edd.257.2023.01.05.04.34.57; Thu, 05 Jan 2023 04:35:22 -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; dkim=pass header.i=@chromium.org header.s=google header.b=kUoF+3ps; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233220AbjAEMdq (ORCPT + 99 others); Thu, 5 Jan 2023 07:33:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58764 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232027AbjAEMdd (ORCPT ); Thu, 5 Jan 2023 07:33:33 -0500 Received: from mail-ed1-x52d.google.com (mail-ed1-x52d.google.com [IPv6:2a00:1450:4864:20::52d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 10DAC4C71E for ; Thu, 5 Jan 2023 04:33:31 -0800 (PST) Received: by mail-ed1-x52d.google.com with SMTP id v30so1286983edb.9 for ; Thu, 05 Jan 2023 04:33:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=i22sBtg5sgJPjmyCPs4YT31o+9MgBiTxsORfyqFHwvE=; b=kUoF+3psXi6YYHua/fexy8hRbaVw/bjVwDGCyEwL1F8UoKtGOj3WKAWT7O/aeNYixd mME/0Lo2NjAWv2iJ9Wkx1zjw4A8QhN5RkHjYkPmLmAz5VEuehZkrSaiUyrGJrQrmDBQn KeSyPXp0jnu/vvJcgbB+gKHT1VM/dqCSGrHMI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=i22sBtg5sgJPjmyCPs4YT31o+9MgBiTxsORfyqFHwvE=; b=OVEhEWwnrBtJS1FV2U20LMTpzuUFcoT/ALx1J6ZHNOugkEKfg5j4O0UqJhN6/1/FZM DcWfX0NrW4bZrLCtdttKPVyIowa/rTz0D9K8EhGl4fGvaOJT812GbfcmIc8Yapm8xflq /tgxjoCld0esAhhjqdThgZq+shYVnZ0uOk0ePE3Bf745kRouH3A+4uDS2nJi5NkiEPvw OIPmi0GC+FnXQDrk9hsowIy3Pkm7pUvljQf0ldFsP0YeqMx3udwY/ZQrS+Mq1KUsg7GH VhODoTVtYEwcV9GLWXi/G5r9ChIPRowOyMCTTkkTob6zFOQ5UoUI8irUPfPso77HnwVB 2uZg== X-Gm-Message-State: AFqh2kpkqbQ9y+5Fr6OXc6fVuF5Qpr48C4QUA7jVqbXPNEW1JHvKcHzC CjmaMB37P8V0iPbujXdZkCE3XQ== X-Received: by 2002:aa7:d6ce:0:b0:491:6ea2:e883 with SMTP id x14-20020aa7d6ce000000b004916ea2e883mr2569742edr.27.1672922009623; Thu, 05 Jan 2023 04:33:29 -0800 (PST) Received: from alco.roam.corp.google.com ([2620:0:1059:10:43c3:8ac4:5d6f:2251]) by smtp.gmail.com with ESMTPSA id r17-20020aa7d591000000b004847513929csm13138909edq.72.2023.01.05.04.33.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Jan 2023 04:33:29 -0800 (PST) From: Ricardo Ribalda Date: Thu, 05 Jan 2023 13:32:14 +0100 Subject: [PATCH 3/6] media: uvcvideo: Implement mask for V4L2_CTRL_TYPE_MENU MIME-Version: 1.0 Message-Id: <20230105-uvc-gcc5-v1-3-8550de720e82@chromium.org> References: <20230105-uvc-gcc5-v1-0-8550de720e82@chromium.org> In-Reply-To: <20230105-uvc-gcc5-v1-0-8550de720e82@chromium.org> To: Laurent Pinchart , Mauro Carvalho Chehab Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Yunke Cao , Sergey Senozhatsky , Ricardo Ribalda X-Mailer: b4 0.11.0-dev-696ae X-Developer-Signature: v=1; a=openpgp-sha256; l=6328; i=ribalda@chromium.org; h=from:subject:message-id; bh=c0qCW+bmUSyESwPogSJMQMg1NsP7nOLTyNEVHbIZYzQ=; b=owEBbQKS/ZANAwAKAdE30T7POsSIAcsmYgBjtsOMo+1cjRYFlPFKA36T8b+YypA8tCALF83TCx0V agb4fo+JAjMEAAEKAB0WIQREDzjr+/4oCDLSsx7RN9E+zzrEiAUCY7bDjAAKCRDRN9E+zzrEiC9rEA CZarCBtHy/lR8iglZryXmINPspqIFF4SkE7qp2HF7YI0PbqLUF5vANSeytURo/5QN/tdLQ/q8/FKbC wx9R4ZoSqUYAtyn2HER9/Z5NYWuM2JTV3CJz6nbXnqHOLQq5yTcGxmXthyOH4hav0rb+XdfP4qAraH NOO6ClawjB9OZImv4OahccWlu0Olc5CX12CoqLfSdeL6J+1f6CxQFAhKPPOVfJj/Wt1D9vPUnLBjTk +rdTIsGsULelS61hXqaE78oBBpWYk3r0v4PPAL+OUzy37Dd/tTWwhtRRxrOUOcs5RAXYXVXtCjs9Xh A6sb71AsrO355PELeeAW/B96bIggfNYTFeoeGD/Ran5osthiYWkKQHV3f4nAjggLWS9d2St+49ADsa S/3mIj4eqe/W/K8hVG/5ggsUWvV7uVKbIIJyt5omkX56XDHA6arGsw2wWAIrpZCEVdN9ZP3FOz1lkC FHH3AfRWpm9dfpVl6dsC7Nig1IrqvnjK6fKw+oEK+WaICrcjMnCOO04MgIiQfXGj2qs/Ml5Fcdttwa aXm8nX3RA1qfO6tGLXW2lqJnExLCgKXmqliRBu4TowTd4bbmV+xrHrCniapicYd48Cd94cvk9tX3BP NM25oHE4neCGcThuRN1oFVg63Dw/xrgr0QaUdJCbWly1fdR9OUUkhvCyEhHQ== X-Developer-Key: i=ribalda@chromium.org; a=openpgp; fpr=9EC3BB66E2FC129A6F90B39556A0D81F9F782DA9 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=ham 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?1754185987141294753?= X-GMAIL-MSGID: =?utf-8?q?1754185987141294753?= Replace the count with a mask field that lets us choose not only the max value, but also the minimum value and what values are valid in between. Reviewed-by: Laurent Pinchart Signed-off-by: Ricardo Ribalda Suggested-by: Laurent Pinchart --- drivers/media/usb/uvc/uvc_ctrl.c | 33 +++++++++++++++++++++++---------- drivers/media/usb/uvc/uvc_driver.c | 4 +++- drivers/media/usb/uvc/uvc_v4l2.c | 3 ++- drivers/media/usb/uvc/uvcvideo.h | 2 +- 4 files changed, 29 insertions(+), 13 deletions(-) diff --git a/drivers/media/usb/uvc/uvc_ctrl.c b/drivers/media/usb/uvc/uvc_ctrl.c index ffa0e2654264..2ebe5cc18ad9 100644 --- a/drivers/media/usb/uvc/uvc_ctrl.c +++ b/drivers/media/usb/uvc/uvc_ctrl.c @@ -6,6 +6,7 @@ * Laurent Pinchart (laurent.pinchart@ideasonboard.com) */ +#include #include #include #include @@ -525,7 +526,8 @@ static const struct uvc_control_mapping uvc_ctrl_mappings[] = { .v4l2_type = V4L2_CTRL_TYPE_MENU, .data_type = UVC_CTRL_DATA_TYPE_BITMASK, .menu_info = exposure_auto_controls, - .menu_count = ARRAY_SIZE(exposure_auto_controls), + .menu_mask = + GENMASK(ARRAY_SIZE(exposure_auto_controls) - 1, 0), .slave_ids = { V4L2_CID_EXPOSURE_ABSOLUTE, }, }, { @@ -731,7 +733,8 @@ static const struct uvc_control_mapping uvc_ctrl_mappings_uvc11[] = { .v4l2_type = V4L2_CTRL_TYPE_MENU, .data_type = UVC_CTRL_DATA_TYPE_ENUM, .menu_info = power_line_frequency_controls, - .menu_count = ARRAY_SIZE(power_line_frequency_controls) - 1, + .menu_mask = GENMASK(V4L2_CID_POWER_LINE_FREQUENCY_60HZ, + V4L2_CID_POWER_LINE_FREQUENCY_DISABLED), }, }; @@ -745,7 +748,8 @@ static const struct uvc_control_mapping uvc_ctrl_mappings_uvc15[] = { .v4l2_type = V4L2_CTRL_TYPE_MENU, .data_type = UVC_CTRL_DATA_TYPE_ENUM, .menu_info = power_line_frequency_controls, - .menu_count = ARRAY_SIZE(power_line_frequency_controls), + .menu_mask = GENMASK(V4L2_CID_POWER_LINE_FREQUENCY_AUTO, + V4L2_CID_POWER_LINE_FREQUENCY_DISABLED), }, }; @@ -975,7 +979,9 @@ static s32 __uvc_ctrl_get_value(struct uvc_control_mapping *mapping, const struct uvc_menu_info *menu = mapping->menu_info; unsigned int i; - for (i = 0; i < mapping->menu_count; ++i, ++menu) { + for (i = 0; BIT(i) <= mapping->menu_mask; ++i, ++menu) { + if (!test_bit(i, &mapping->menu_mask)) + continue; if (menu->value == value) { value = i; break; @@ -1228,12 +1234,14 @@ static int __uvc_query_v4l2_ctrl(struct uvc_video_chain *chain, switch (mapping->v4l2_type) { case V4L2_CTRL_TYPE_MENU: - v4l2_ctrl->minimum = 0; - v4l2_ctrl->maximum = mapping->menu_count - 1; + v4l2_ctrl->minimum = ffs(mapping->menu_mask) - 1; + v4l2_ctrl->maximum = fls(mapping->menu_mask) - 1; v4l2_ctrl->step = 1; menu = mapping->menu_info; - for (i = 0; i < mapping->menu_count; ++i, ++menu) { + for (i = 0; BIT(i) <= mapping->menu_mask; ++i, ++menu) { + if (!test_bit(i, &mapping->menu_mask)) + continue; if (menu->value == v4l2_ctrl->default_value) { v4l2_ctrl->default_value = i; break; @@ -1354,7 +1362,7 @@ int uvc_query_v4l2_menu(struct uvc_video_chain *chain, goto done; } - if (query_menu->index >= mapping->menu_count) { + if (!test_bit(query_menu->index, &mapping->menu_mask)) { ret = -EINVAL; goto done; } @@ -1868,8 +1876,13 @@ int uvc_ctrl_set(struct uvc_fh *handle, break; case V4L2_CTRL_TYPE_MENU: - if (xctrl->value < 0 || xctrl->value >= mapping->menu_count) + if (xctrl->value < (ffs(mapping->menu_mask) - 1) || + xctrl->value > (fls(mapping->menu_mask) - 1)) return -ERANGE; + + if (!test_bit(xctrl->value, &mapping->menu_mask)) + return -EINVAL; + value = mapping->menu_info[xctrl->value].value; /* @@ -2306,7 +2319,7 @@ static int __uvc_ctrl_add_mapping(struct uvc_video_chain *chain, INIT_LIST_HEAD(&map->ev_subs); - size = sizeof(*mapping->menu_info) * mapping->menu_count; + size = sizeof(*mapping->menu_info) * fls(mapping->menu_mask); map->menu_info = kmemdup(mapping->menu_info, size, GFP_KERNEL); if (!map->menu_info) goto err_nomem; diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c index 6d08457ecb9c..e659670ea2d8 100644 --- a/drivers/media/usb/uvc/uvc_driver.c +++ b/drivers/media/usb/uvc/uvc_driver.c @@ -7,6 +7,7 @@ */ #include +#include #include #include #include @@ -2391,7 +2392,8 @@ static const struct uvc_control_mapping uvc_ctrl_power_line_mapping_limited = { .v4l2_type = V4L2_CTRL_TYPE_MENU, .data_type = UVC_CTRL_DATA_TYPE_ENUM, .menu_info = power_line_frequency_controls_limited, - .menu_count = ARRAY_SIZE(power_line_frequency_controls_limited), + .menu_mask = + GENMASK(ARRAY_SIZE(power_line_frequency_controls_limited) - 1, 0), }; static const struct uvc_device_info uvc_ctrl_power_line_limited = { diff --git a/drivers/media/usb/uvc/uvc_v4l2.c b/drivers/media/usb/uvc/uvc_v4l2.c index 3edb54c086b2..0774a11360c0 100644 --- a/drivers/media/usb/uvc/uvc_v4l2.c +++ b/drivers/media/usb/uvc/uvc_v4l2.c @@ -6,6 +6,7 @@ * Laurent Pinchart (laurent.pinchart@ideasonboard.com) */ +#include #include #include #include @@ -80,7 +81,7 @@ static int uvc_ioctl_ctrl_map(struct uvc_video_chain *chain, goto free_map; } - map->menu_count = xmap->menu_count; + map->menu_mask = GENMASK(xmap->menu_count - 1, 0); break; default: diff --git a/drivers/media/usb/uvc/uvcvideo.h b/drivers/media/usb/uvc/uvcvideo.h index 41ba0bbd8171..a8eec43cd860 100644 --- a/drivers/media/usb/uvc/uvcvideo.h +++ b/drivers/media/usb/uvc/uvcvideo.h @@ -115,7 +115,7 @@ struct uvc_control_mapping { u32 data_type; const struct uvc_menu_info *menu_info; - u32 menu_count; + unsigned long menu_mask; u32 master_id; s32 master_manual; From patchwork Thu Jan 5 12:32:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 39501 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp279162wrt; Thu, 5 Jan 2023 04:37:37 -0800 (PST) X-Google-Smtp-Source: AMrXdXtKIVLleyTF4tZN7aVcY3rOnl/PktYaNtL9eSwzwxxI0KnfhIx1QjChfpc8hKGnHMWj0wRo X-Received: by 2002:a17:907:7f04:b0:7c0:a4e9:615b with SMTP id qf4-20020a1709077f0400b007c0a4e9615bmr55998520ejc.61.1672922257114; Thu, 05 Jan 2023 04:37:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672922257; cv=none; d=google.com; s=arc-20160816; b=Whosf1JjUlL9yXuJmHoT9Fu9MYMV16/n9c1czpEmTIllKrpwn3ApXzA1VBTnovXDHj jF3z09vb/WA6P6odY7PYoLDqBgDXETVYgx2SEm0ITgJK1phE3nMHruXMByNXppiXhFC3 NdUAwaY0NcM/1EH0KKQ6bhlmZY3ml+kBImx7X2JCWTKhg01Rpp1KJQB0iOehLQCrlbO1 pzb1QXM/5jl1o85vUJ/mPYG0JUnzckXW5yjqzYSfnQr8rlQfZ0dnAtYThB3P3/yHrVK6 MQF/nvkP3y3s3em8buJuP77GDTaQjzzaZdXf3+lP/kN7/llNP86LOuU0Dc0SDVk+AzU3 35iw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=T2+QEDBh605/YOw8UIx/peFMX1PrmbZbNImTnYA7xrk=; b=MH4D1hgUde+AZpuaW+xAUQIcljw2EB4jE0B/UqoFq90ZeOeEpNt7YTLe2rrzjnzefp urEhk5f4ujoRqrr7bwxkeyRqh72Mh9PXILyVQlgAkNZEPdM57iB6Vv9x5SbbJanpoG3E d29YoHLJzSVI70g2dWArQsREo3eUJw0L1tmJ3yJnK0kRCp5iG2+osHtU5DvE5xfjgbuN yjXFEB+DPj6trovnRpLlNjfhJluMk6FjXv6r44XuWIyLn6yVImp2DbeiGTt2f3PB84Kj yI9tg7sGc8BowAXHy7opRKhK6sYhjXfrCJOzavCR7yGC3Cf3RwU/GirDvRkgcxshc2q0 0EnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=cNpxdmmy; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sc37-20020a1709078a2500b007c19a5b7697si33700682ejc.233.2023.01.05.04.37.13; Thu, 05 Jan 2023 04:37:37 -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; dkim=pass header.i=@chromium.org header.s=google header.b=cNpxdmmy; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232768AbjAEMdz (ORCPT + 99 others); Thu, 5 Jan 2023 07:33:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58798 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232949AbjAEMdh (ORCPT ); Thu, 5 Jan 2023 07:33:37 -0500 Received: from mail-ej1-x634.google.com (mail-ej1-x634.google.com [IPv6:2a00:1450:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DB6E532EA0 for ; Thu, 5 Jan 2023 04:33:31 -0800 (PST) Received: by mail-ej1-x634.google.com with SMTP id vm8so82788193ejc.2 for ; Thu, 05 Jan 2023 04:33:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=T2+QEDBh605/YOw8UIx/peFMX1PrmbZbNImTnYA7xrk=; b=cNpxdmmypyDiQSrE9C9OKdhB0yaPnURMEJUdX04q27l/cwa+Ay5KqEZL1GR2uqObwR laGHm1XoaahdfyDfWa3/L9bS1O28elavG156hsB5YJgExcczsOdko1WhXpsAoIFBEBNw 7ujPie3uMUWqwZVeESTkkVyllz6vPrQ/rQvHM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=T2+QEDBh605/YOw8UIx/peFMX1PrmbZbNImTnYA7xrk=; b=SZkeGdnovJr3Sa6qCMCFTy3BwTmNck9keDAxMA3wivsy7eWCKX5WVEZ8rf32dIhpYG PpW5qF+CWv6QGJoKGqh0sd4mu4kRG62LOTsJOBmG/eScL+5q6wZ0jyRXqeftXiTyTZd+ uwBQmPfr79iLTe3ocpkH5vBm/+vmKoLp7WduVPUvTYbrr56dxI2tFGfkrQ8V+kJspzfC v57TW4g9XRr2MXQRI8rEELjhgTXLs7ViKlHJyro9xeW3k0au7lYTVHacuv13f1uzgUEO CKOvDJQWDiSaO68rgFd8FtwdG6Fv74VxmWHvRiFwjSXm+zVPX2fmTl3dBgWxJIGUas83 JwuQ== X-Gm-Message-State: AFqh2kr4dfdpkCbLRAc0OLRUaZ5CBeyJJx3DuQfsBnUH3W9FwdazpXFY 0En0sEx5aOQC8+90HLcAtekA8g== X-Received: by 2002:a17:906:1dcd:b0:84c:c121:dc53 with SMTP id v13-20020a1709061dcd00b0084cc121dc53mr13045287ejh.34.1672922010412; Thu, 05 Jan 2023 04:33:30 -0800 (PST) Received: from alco.roam.corp.google.com ([2620:0:1059:10:43c3:8ac4:5d6f:2251]) by smtp.gmail.com with ESMTPSA id r17-20020aa7d591000000b004847513929csm13138909edq.72.2023.01.05.04.33.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Jan 2023 04:33:30 -0800 (PST) From: Ricardo Ribalda Date: Thu, 05 Jan 2023 13:32:15 +0100 Subject: [PATCH 4/6] media: uvcvideo: Refactor uvc_ctrl_mappings_uvcXX MIME-Version: 1.0 Message-Id: <20230105-uvc-gcc5-v1-4-8550de720e82@chromium.org> References: <20230105-uvc-gcc5-v1-0-8550de720e82@chromium.org> In-Reply-To: <20230105-uvc-gcc5-v1-0-8550de720e82@chromium.org> To: Laurent Pinchart , Mauro Carvalho Chehab Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Yunke Cao , Sergey Senozhatsky , Ricardo Ribalda X-Mailer: b4 0.11.0-dev-696ae X-Developer-Signature: v=1; a=openpgp-sha256; l=4328; i=ribalda@chromium.org; h=from:subject:message-id; bh=cN0QwI5lzK55LyNPAeknpt5DPiDQGV+bwKxrSvbPPOE=; b=owEBbQKS/ZANAwAKAdE30T7POsSIAcsmYgBjtsOPXayDHzuGg11H2cDJ7V6FhwEQiGPMiMZnD7Dm F/Wv9RKJAjMEAAEKAB0WIQREDzjr+/4oCDLSsx7RN9E+zzrEiAUCY7bDjwAKCRDRN9E+zzrEiHEWD/ 9QsgQIbF407r81pcqrt3v84B7q/E9Zw2vZstqZpu88tvFsSqqs/Bhr67ZC4E76XA4bOVT38/5Es3Up Prjgq0W5IzATE5sAGpz46/edKiuD11YuRmYwNwSFoP63FAiQv6QZe95TNtk5mFZz4ASOebqToRzBPP T74mUSvcKo+S3T6Glu4d+Dg76jZyDtWNFq1rtuMCbjK5p5bQgy5UUpB/bYfQbgXoZmRvlC4NeKO870 FDdQyy6I/L1BTFWqIy0Pnf66Gqa+1NXHrYAG6GiyYeHJoPXaW0ZsNTgiqAGRwgWWBES6j4YdKppohU tPsN/JgSUjVGWUuNYNB+XXpTtC66J7aaODLve+6A9pjDw9cS73AI/g5X+M1Ginja9+hmCMmHDNBEIu ohm5PKGytdjOFRd6l9k0DRkMBRUKnF94S+7KaXrP1PXcLAqk/US4ErFtEdCTOrjnswsqKRd5gLB++C Da5b7K1gmsVAwJYoC+dUz1bKIAZ54mrVkX5dYabXbSEiYFP1wFZksn74DGvnhPdTby9TMtzTkguo0S E6WaCT+lglgLk6ga5BgHG8eMcXvX4nrOdz6uPRxfhYxYGyw5CHoDnSqvXgjYkjyfoeAoR8rziLzQKb +X5njXwhuTBfcnFGuFRbOaovJsKqrp7uU39Vzq8umUc9VSqDI0PRjHoFVkqg== X-Developer-Key: i=ribalda@chromium.org; a=openpgp; fpr=9EC3BB66E2FC129A6F90B39556A0D81F9F782DA9 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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?1754186128605647900?= X-GMAIL-MSGID: =?utf-8?q?1754186128605647900?= Convert the array of structs into an array of pointers, that way the mappings can be reused. Signed-off-by: Ricardo Ribalda --- drivers/media/usb/uvc/uvc_ctrl.c | 81 +++++++++++++++++++--------------------- 1 file changed, 39 insertions(+), 42 deletions(-) diff --git a/drivers/media/usb/uvc/uvc_ctrl.c b/drivers/media/usb/uvc/uvc_ctrl.c index 2ebe5cc18ad9..9af64f7a23d3 100644 --- a/drivers/media/usb/uvc/uvc_ctrl.c +++ b/drivers/media/usb/uvc/uvc_ctrl.c @@ -723,34 +723,40 @@ static const struct uvc_control_mapping uvc_ctrl_mappings[] = { }, }; -static const struct uvc_control_mapping uvc_ctrl_mappings_uvc11[] = { - { - .id = V4L2_CID_POWER_LINE_FREQUENCY, - .entity = UVC_GUID_UVC_PROCESSING, - .selector = UVC_PU_POWER_LINE_FREQUENCY_CONTROL, - .size = 2, - .offset = 0, - .v4l2_type = V4L2_CTRL_TYPE_MENU, - .data_type = UVC_CTRL_DATA_TYPE_ENUM, - .menu_info = power_line_frequency_controls, - .menu_mask = GENMASK(V4L2_CID_POWER_LINE_FREQUENCY_60HZ, - V4L2_CID_POWER_LINE_FREQUENCY_DISABLED), - }, +static const struct uvc_control_mapping uvc_ctrl_power_line_mapping_uvc11 = { + .id = V4L2_CID_POWER_LINE_FREQUENCY, + .entity = UVC_GUID_UVC_PROCESSING, + .selector = UVC_PU_POWER_LINE_FREQUENCY_CONTROL, + .size = 2, + .offset = 0, + .v4l2_type = V4L2_CTRL_TYPE_MENU, + .data_type = UVC_CTRL_DATA_TYPE_ENUM, + .menu_info = power_line_frequency_controls, + .menu_mask = GENMASK(V4L2_CID_POWER_LINE_FREQUENCY_60HZ, + V4L2_CID_POWER_LINE_FREQUENCY_DISABLED), }; -static const struct uvc_control_mapping uvc_ctrl_mappings_uvc15[] = { - { - .id = V4L2_CID_POWER_LINE_FREQUENCY, - .entity = UVC_GUID_UVC_PROCESSING, - .selector = UVC_PU_POWER_LINE_FREQUENCY_CONTROL, - .size = 2, - .offset = 0, - .v4l2_type = V4L2_CTRL_TYPE_MENU, - .data_type = UVC_CTRL_DATA_TYPE_ENUM, - .menu_info = power_line_frequency_controls, - .menu_mask = GENMASK(V4L2_CID_POWER_LINE_FREQUENCY_AUTO, - V4L2_CID_POWER_LINE_FREQUENCY_DISABLED), - }, +static const struct uvc_control_mapping *uvc_ctrl_mappings_uvc11[] = { + &uvc_ctrl_power_line_mapping_uvc11, + NULL, /* Sentinel */ +}; + +static const struct uvc_control_mapping uvc_ctrl_power_line_mapping_uvc15 = { + .id = V4L2_CID_POWER_LINE_FREQUENCY, + .entity = UVC_GUID_UVC_PROCESSING, + .selector = UVC_PU_POWER_LINE_FREQUENCY_CONTROL, + .size = 2, + .offset = 0, + .v4l2_type = V4L2_CTRL_TYPE_MENU, + .data_type = UVC_CTRL_DATA_TYPE_ENUM, + .menu_info = power_line_frequency_controls, + .menu_mask = GENMASK(V4L2_CID_POWER_LINE_FREQUENCY_AUTO, + V4L2_CID_POWER_LINE_FREQUENCY_DISABLED), +}; + +static const struct uvc_control_mapping *uvc_ctrl_mappings_uvc15[] = { + &uvc_ctrl_power_line_mapping_uvc15, + NULL, /* Sentinel */ }; /* ------------------------------------------------------------------------ @@ -2506,8 +2512,7 @@ static void uvc_ctrl_prune_entity(struct uvc_device *dev, static void uvc_ctrl_init_ctrl(struct uvc_video_chain *chain, struct uvc_control *ctrl) { - const struct uvc_control_mapping *mappings; - unsigned int num_mappings; + const struct uvc_control_mapping **mappings; unsigned int i; /* @@ -2574,21 +2579,13 @@ static void uvc_ctrl_init_ctrl(struct uvc_video_chain *chain, } /* Finally process version-specific mappings. */ - if (chain->dev->uvc_version < 0x0150) { - mappings = uvc_ctrl_mappings_uvc11; - num_mappings = ARRAY_SIZE(uvc_ctrl_mappings_uvc11); - } else { - mappings = uvc_ctrl_mappings_uvc15; - num_mappings = ARRAY_SIZE(uvc_ctrl_mappings_uvc15); - } - - for (i = 0; i < num_mappings; ++i) { - const struct uvc_control_mapping *mapping = &mappings[i]; + mappings = (chain->dev->uvc_version < 0x0150) ? uvc_ctrl_mappings_uvc11 + : uvc_ctrl_mappings_uvc15; - if (uvc_entity_match_guid(ctrl->entity, mapping->entity) && - ctrl->info.selector == mapping->selector) - __uvc_ctrl_add_mapping(chain, ctrl, mapping); - } + for (i = 0; mappings[i]; ++i) + if (uvc_entity_match_guid(ctrl->entity, mappings[i]->entity) && + ctrl->info.selector == mappings[i]->selector) + __uvc_ctrl_add_mapping(chain, ctrl, mappings[i]); } /* From patchwork Thu Jan 5 12:32:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 39499 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp278631wrt; Thu, 5 Jan 2023 04:36:10 -0800 (PST) X-Google-Smtp-Source: AMrXdXt36l7N1yGcjDctnLMyfHwFJOzfCocxc5sJsvmI7oIAnUUJDMnTSbf6bynn34krr4SF/z1a X-Received: by 2002:a17:906:d217:b0:7c1:6fc:6048 with SMTP id w23-20020a170906d21700b007c106fc6048mr42317800ejz.24.1672922170440; Thu, 05 Jan 2023 04:36:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672922170; cv=none; d=google.com; s=arc-20160816; b=QMQR+62isaylOljKbJfeVLre6z6r8hqHzyvVu7b0xN7gSQcGCqU8aSVF364bJs+J3e mUruWu6WoNfmWtpXtbOjhXKSW3zX6uYLtneDfBXP1GHHEO9rbn9Gz/5kUCIAiIKo7q50 MIjyuTnXJZ3ILwCWpdXB5KqW4+1qZ6qbsRkbbGynAHVsfvddw9bvSHrLBt3UBi6m5/W2 1lyhCE03GPOtIhQpFcLRxq7t+Ps3+clulGXEbcY00iud/Z+FeECF3duJ1C4SU0CdhdxE /6taG+Xyc3jVBq9ogZoElxwWiJ9QjuT7KT4iwi6PD2fgpXK/IEe0yPUmOw5gM5iwhCD5 eGig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=2RMA+soBb7ISYDgZGukscenX9Gq6ESDTcYuOQgtCRPU=; b=YrqshhsGpp0iGDpI5gfMNRgTSUcDqIBoLYgFiq2rZO+Uz5BI046iw07fftEScg7gu1 FeNgiGAJPN86AAqkNLxco5LxTOi9BPd4xzDRc0gkRG4L7IXLpqpQYZtQeAz5zfFY60ur gpf+zkNn450ZGmUaN/+NA+BtmB+85dIHOzLtYUdxLsRtFuWqFgGnzIiDZ2TCwrM2LC1o cnPzWtijcQpuX9ec/vsdcozXvZ2lJlTii9gYD+asp4HZMqJjseCv3jumoQJg4XNoqNz4 jBOC42KpW4VRuUxnLEB7QA7iQ4RUWdE2Z6k0G255ve9xBK4Sj6PRS16fFVTQSa22kCSA 88YQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=BmcRlqdB; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z10-20020a05640240ca00b0047ed405b4a7si34328352edb.224.2023.01.05.04.35.46; Thu, 05 Jan 2023 04:36:10 -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; dkim=pass header.i=@chromium.org header.s=google header.b=BmcRlqdB; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232949AbjAEMd7 (ORCPT + 99 others); Thu, 5 Jan 2023 07:33:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58790 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232779AbjAEMdg (ORCPT ); Thu, 5 Jan 2023 07:33:36 -0500 Received: from mail-ed1-x52c.google.com (mail-ed1-x52c.google.com [IPv6:2a00:1450:4864:20::52c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9873A4E402 for ; Thu, 5 Jan 2023 04:33:32 -0800 (PST) Received: by mail-ed1-x52c.google.com with SMTP id z11so36801952ede.1 for ; Thu, 05 Jan 2023 04:33:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=2RMA+soBb7ISYDgZGukscenX9Gq6ESDTcYuOQgtCRPU=; b=BmcRlqdBjxR4r+Jx6xp+/nvK9jMCX2Nt24dLwkBldJgMoXmhStUgW7WhpnZrcwIN3O mfgV/R7ZrwCbzBDvj8rQReJsv+jGA3J8PCp7rM6SHLzGFnUNcrjFaFpu5hB8h76O40w2 n4zdLs/NUwg356wKAxjTYQA2RK8YFmwd7ObbA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2RMA+soBb7ISYDgZGukscenX9Gq6ESDTcYuOQgtCRPU=; b=vzeVgBSW1u31kxuDtUiyZsPMjRDQuN/j+DMwoa+EmpDsUwKjQ7m4gNbOwgU9OIh859 fQbYviCG7dp38j4V097HqjTCPSBTDzJLn3zuMgpOznZ79NzzM0PSlE0XxF0zhGv8lNBx jSbbBVRun7AjsTJm9s9cg8cyKfqrgHrxYn0r3X7n1zM0IgiVZ9Pj4DdWR+xrfMfPrv7g ZU8kUlW+c6Q/JVhywyH1kkH0gAG6+K4Ac2QcEYbRTwE4B8EaspVmXU8NkF5TaTkJJel2 80OM3dOD1ZMEXlhC2Lwk49WtdrEq4O9Ia1dcSsrWtYtlgrxekiBXNR1MGEZwxicG9Vzw 4vtA== X-Gm-Message-State: AFqh2kqK0weM0h+iVrNVfvg7KUD+FuZBekwQE81fsrbBFKmX1R59O2QP 1dBmt1H5wiFf2YUsfGMMyPPAJQ== X-Received: by 2002:a50:a401:0:b0:46d:53d7:d21e with SMTP id u1-20020a50a401000000b0046d53d7d21emr47345364edb.27.1672922011147; Thu, 05 Jan 2023 04:33:31 -0800 (PST) Received: from alco.roam.corp.google.com ([2620:0:1059:10:43c3:8ac4:5d6f:2251]) by smtp.gmail.com with ESMTPSA id r17-20020aa7d591000000b004847513929csm13138909edq.72.2023.01.05.04.33.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Jan 2023 04:33:30 -0800 (PST) From: Ricardo Ribalda Date: Thu, 05 Jan 2023 13:32:16 +0100 Subject: [PATCH 5/6] media: uvcvideo: Refactor power_line_frequency_controls_limited MIME-Version: 1.0 Message-Id: <20230105-uvc-gcc5-v1-5-8550de720e82@chromium.org> References: <20230105-uvc-gcc5-v1-0-8550de720e82@chromium.org> In-Reply-To: <20230105-uvc-gcc5-v1-0-8550de720e82@chromium.org> To: Laurent Pinchart , Mauro Carvalho Chehab Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Yunke Cao , Sergey Senozhatsky , Ricardo Ribalda X-Mailer: b4 0.11.0-dev-696ae X-Developer-Signature: v=1; a=openpgp-sha256; l=3076; i=ribalda@chromium.org; h=from:subject:message-id; bh=DwtzhBtzoWhod5MLtGXm+KQO/xP0T/ezlf1lPZGLRkA=; b=owEBbQKS/ZANAwAKAdE30T7POsSIAcsmYgBjtsOR2N06IYE/A83vfL7O598nnP3a4ihc6he/ANmB SMntxzKJAjMEAAEKAB0WIQREDzjr+/4oCDLSsx7RN9E+zzrEiAUCY7bDkQAKCRDRN9E+zzrEiO19D/ 9tTLGXWPKuxiC2qXJI+Rl0DfvN3WGtNGtkcaPY05H/XTItqwL+G1umO9KW4/H47xCpW6/+TjX/4SzZ 4g5GmtRVvnUBAyoElrdLZ8hWddkY0AetGV8ssxSKEAz1UxqN0EXkvC3x3spEGZVU25w0Ms9X08NQI+ +uh3m3B+QOMl5ektVt7qga58I1zC6uBA4dAcwb0WrCVtfGjr5nwT0AMok+Vtoe+GHw/AdDsApz5691 QCRO9HJn1F60pTjIKPlK86veZcjLg4G2cQysdCZNW58kX2aJP5PZAA53IftSvEQfjDZXX+Dkb5hXVk Zj9KaWOlLkAj3G+TbBlAs2TZmdTk3aManxWynnuVL92tDIYVruL0O6SFsFdLaTMxefmN9LETbs8ild aePeMHWhlhNC4nt0uu3Z+95lWyIbhFCPc3MdydEw8nqFA8Vu34b7suci8oHxvcrWRyiOByGIuZhylM v73q58TJhQnpLP07KMc0OJXa8pmlVhtsQFNTru6DjTunYWuBjn0zIrNqQuVpsmmcUUWG/EHapdbjLW AfeBzfmSEKGVH36hJTO0DUQrLgeWPSyx/GxzyYv5xCth8GQ0Prr6/Tnkf9T1/7iU0HwLwHwwLN3xKv SGGV1oTnpXGjWzQtPEbF0qn1WtOO6QAVRbllZTyV0zBeElja+AjsGLLDodGg== X-Developer-Key: i=ribalda@chromium.org; a=openpgp; fpr=9EC3BB66E2FC129A6F90B39556A0D81F9F782DA9 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=ham 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?1754186037738817509?= X-GMAIL-MSGID: =?utf-8?q?1754186037738817509?= Move the control mapping to uvc_ctrl.c. This way we do not have references to UVC controls or V4L2 controls in uvc_driver.c Signed-off-by: Ricardo Ribalda --- drivers/media/usb/uvc/uvc_ctrl.c | 13 +++++++++++++ drivers/media/usb/uvc/uvc_driver.c | 18 ------------------ drivers/media/usb/uvc/uvcvideo.h | 1 + 3 files changed, 14 insertions(+), 18 deletions(-) diff --git a/drivers/media/usb/uvc/uvc_ctrl.c b/drivers/media/usb/uvc/uvc_ctrl.c index 9af64f7a23d3..f559a1ac6e3c 100644 --- a/drivers/media/usb/uvc/uvc_ctrl.c +++ b/drivers/media/usb/uvc/uvc_ctrl.c @@ -723,6 +723,19 @@ static const struct uvc_control_mapping uvc_ctrl_mappings[] = { }, }; +const struct uvc_control_mapping uvc_ctrl_power_line_mapping_limited = { + .id = V4L2_CID_POWER_LINE_FREQUENCY, + .entity = UVC_GUID_UVC_PROCESSING, + .selector = UVC_PU_POWER_LINE_FREQUENCY_CONTROL, + .size = 2, + .offset = 0, + .v4l2_type = V4L2_CTRL_TYPE_MENU, + .data_type = UVC_CTRL_DATA_TYPE_ENUM, + .menu_info = power_line_frequency_controls, + .menu_mask = GENMASK(V4L2_CID_POWER_LINE_FREQUENCY_60HZ, + V4L2_CID_POWER_LINE_FREQUENCY_50HZ), +}; + static const struct uvc_control_mapping uvc_ctrl_power_line_mapping_uvc11 = { .id = V4L2_CID_POWER_LINE_FREQUENCY, .entity = UVC_GUID_UVC_PROCESSING, diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c index e659670ea2d8..37d2b08bc8b2 100644 --- a/drivers/media/usb/uvc/uvc_driver.c +++ b/drivers/media/usb/uvc/uvc_driver.c @@ -2378,24 +2378,6 @@ MODULE_PARM_DESC(timeout, "Streaming control requests timeout"); * Driver initialization and cleanup */ -static const struct uvc_menu_info power_line_frequency_controls_limited[] = { - { 1, "50 Hz" }, - { 2, "60 Hz" }, -}; - -static const struct uvc_control_mapping uvc_ctrl_power_line_mapping_limited = { - .id = V4L2_CID_POWER_LINE_FREQUENCY, - .entity = UVC_GUID_UVC_PROCESSING, - .selector = UVC_PU_POWER_LINE_FREQUENCY_CONTROL, - .size = 2, - .offset = 0, - .v4l2_type = V4L2_CTRL_TYPE_MENU, - .data_type = UVC_CTRL_DATA_TYPE_ENUM, - .menu_info = power_line_frequency_controls_limited, - .menu_mask = - GENMASK(ARRAY_SIZE(power_line_frequency_controls_limited) - 1, 0), -}; - static const struct uvc_device_info uvc_ctrl_power_line_limited = { .mappings = (const struct uvc_control_mapping *[]) { &uvc_ctrl_power_line_mapping_limited, diff --git a/drivers/media/usb/uvc/uvcvideo.h b/drivers/media/usb/uvc/uvcvideo.h index a8eec43cd860..1b2d9f327583 100644 --- a/drivers/media/usb/uvc/uvcvideo.h +++ b/drivers/media/usb/uvc/uvcvideo.h @@ -747,6 +747,7 @@ int uvc_status_start(struct uvc_device *dev, gfp_t flags); void uvc_status_stop(struct uvc_device *dev); /* Controls */ +extern const struct uvc_control_mapping uvc_ctrl_power_line_mapping_limited; extern const struct v4l2_subscribed_event_ops uvc_ctrl_sub_ev_ops; int uvc_query_v4l2_ctrl(struct uvc_video_chain *chain, From patchwork Thu Jan 5 12:32:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 39503 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp279363wrt; Thu, 5 Jan 2023 04:38:00 -0800 (PST) X-Google-Smtp-Source: AMrXdXsq2somuRKLu83Wknv9J24fJmemJrhqsz1mHRkjnPwoiUYQ9GczIPRKPkSyD9Us6WWQuzsL X-Received: by 2002:a17:907:9a98:b0:7c1:d4c:f08c with SMTP id km24-20020a1709079a9800b007c10d4cf08cmr44392473ejc.4.1672922280510; Thu, 05 Jan 2023 04:38:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672922280; cv=none; d=google.com; s=arc-20160816; b=yZ4F5qWrg61mYfjueyF5UPIJtyxmFApAE+Tko9gsqvPdu9VVHQm/L0dgEV/GbBG6ms L9GbgJIxWZVFd1/JumtKO0aSdoc76zYnR0mpBA9zaXOQ00OIm34j7H11fejIys5CJALR KW5Nv/N6i0+BCuYY9+JSQlMdKF6cqWAfz7zGwnGJIZtVyTShV/AcJax4KwrAJnl436U9 +GOTnuZp78kWeGzcOHEIUnM9hPDTZxEmYKUK4S/pZleQJBCr50KFuAmdg91HtVy58l2w bPMmB/SzmF2EnjBLRnyuKZr3uwhhePEfIMjG6He505lv4S2BAZrbFDePDqvJJlaaZ9Wd PshQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=ppI8aVxw1/6kIrnqudHixv/DEHg5kpLKy5SssbyDECs=; b=CCDKhVbjUy4glWvJYgyDG4Gvxmxx/jLfxHFNkCORTFLZ+gR4CrsHVllnJu2tJkfdD3 H3r+WOg+PKNXFHAKGaUVW1hQgb4Um1XDwtCqc7Q7/ApkxqFoLJQl+gpe03CpnERztA0V n1JsDuOYymL12Ku7fCMrTnaazW2lBCqrwmnlqqYXtC4RcdcwZe959e4/Ih4UKQ7g+eYn TjixMPD1f20LrycOUyCS2HsZ8hGGi+8e/OqDAIT5Aer1nJxsf8azk7K1rfvTXNVVc/BC UvrO8ZqIVZfJUl5YsvwOxcVgZ03lWUmMh0Cze7hOUvlQ/wf0p0nHmLQjOIm8eJO3YOFn HTXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=MSNFhYMU; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id va28-20020a17090711dc00b007ba16fcfefdsi26090985ejb.936.2023.01.05.04.37.36; Thu, 05 Jan 2023 04:38:00 -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; dkim=pass header.i=@chromium.org header.s=google header.b=MSNFhYMU; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233286AbjAEMeD (ORCPT + 99 others); Thu, 5 Jan 2023 07:34:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58798 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233023AbjAEMdj (ORCPT ); Thu, 5 Jan 2023 07:33:39 -0500 Received: from mail-ed1-x52d.google.com (mail-ed1-x52d.google.com [IPv6:2a00:1450:4864:20::52d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 964B74E40A for ; Thu, 5 Jan 2023 04:33:33 -0800 (PST) Received: by mail-ed1-x52d.google.com with SMTP id b88so45345650edf.6 for ; Thu, 05 Jan 2023 04:33:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=ppI8aVxw1/6kIrnqudHixv/DEHg5kpLKy5SssbyDECs=; b=MSNFhYMUJD/0dMQ+7fEV+M3++4Q0TrAbZDRf0HeKCIZuEo8UbWK3wNTuv2Qa4EzTla OVAc2PFCR+nqt2cvcp1VLK1Qexr3WlwtLvEF7UeWq/r7fvWWueGr+1Rb2nInl5cdK/c3 xejetG4i6DlouDmmsbY9flyXHGTUlIDFXNNq0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ppI8aVxw1/6kIrnqudHixv/DEHg5kpLKy5SssbyDECs=; b=h5CBxzAtAvm9cl0AR/kz3MmYFTs04nGLb2lO4w7F9jR2TKYgI22yOdYAhEmNK3wgmV YNN9TwixvD2Wf3JRawoxxmzH3TCXmHAIEd3ONmbHfC3BAFFpmVJulS3Qnbh5ge5z8OFd EgDX+1zgtpdV9KJf/PTSyvcnskpNIvxMdiak2sisRFsu+PDYiu7hT0T7IGcHOWLUP25M l4tlPg2Fp7fFCsF269H5+G044HZFWx2IzVbZvR9q18LN0X6UmfsCAKrIVfIWNHOCGYHi G2V2cbi7KPehPSWoLNtu7m6TRJFsxZpXSYBtrWi6UgdNzV25DfRHWH/MJOWl1RGpZywt 6Axg== X-Gm-Message-State: AFqh2krzjc5eaVSFBkxeBoSqmsWiaWjMQLBZEz5IuXhB2bcp4AcyP49q D5Y0WJX0hKqlVc4NrkW/TcZDUw== X-Received: by 2002:a05:6402:1757:b0:490:d8e1:aac4 with SMTP id v23-20020a056402175700b00490d8e1aac4mr3139524edx.15.1672922012132; Thu, 05 Jan 2023 04:33:32 -0800 (PST) Received: from alco.roam.corp.google.com ([2620:0:1059:10:43c3:8ac4:5d6f:2251]) by smtp.gmail.com with ESMTPSA id r17-20020aa7d591000000b004847513929csm13138909edq.72.2023.01.05.04.33.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Jan 2023 04:33:31 -0800 (PST) From: Ricardo Ribalda Date: Thu, 05 Jan 2023 13:32:17 +0100 Subject: [PATCH 6/6] media: uvcvideo: Fix power line control for Lenovo Integrated Camera MIME-Version: 1.0 Message-Id: <20230105-uvc-gcc5-v1-6-8550de720e82@chromium.org> References: <20230105-uvc-gcc5-v1-0-8550de720e82@chromium.org> In-Reply-To: <20230105-uvc-gcc5-v1-0-8550de720e82@chromium.org> To: Laurent Pinchart , Mauro Carvalho Chehab Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Yunke Cao , Sergey Senozhatsky , Ricardo Ribalda X-Mailer: b4 0.11.0-dev-696ae X-Developer-Signature: v=1; a=openpgp-sha256; l=3620; i=ribalda@chromium.org; h=from:subject:message-id; bh=JBsJXIk7F9TaTHpPg9s+pdonJi4DxHELPycW3O1XV2A=; b=owEBbQKS/ZANAwAKAdE30T7POsSIAcsmYgBjtsOTqxox+ir5TnHf9fIsoisbVBS0umYxbY75kx9T WuNmqFyJAjMEAAEKAB0WIQREDzjr+/4oCDLSsx7RN9E+zzrEiAUCY7bDkwAKCRDRN9E+zzrEiBffD/ 4tJwNJ75vU1WDBwssF1VhoCEZ1WEw3ONnLnakOk3XBgHQgjQuji3g6UHH0H8+NpPj3J9DkwhBPS5em b+eX1fGjgPP5FT8a22yqLEaxPmnSp2QTiUIKGftOi5v/HjhzNtdZqU+wxHLrJTjH5FkjH3kKh2SJO/ 6KvDzVJhZfpmE45lzlx8ImpIf7DU+sx210kdHcL7zfO/j2o6nBp8TjXqsMfjJK5psXP2eCKfSHoKvo cylDOuK9o3ypnkgrj7L7+Sq4JmKotr4ubpD+aUwlNJn87F9ybXuXmO4mOd/NIp8yb/T4NlGrmaiMw9 o2wdE3Kb8jEVs/0Hvysc8G5EiMil8X4FixxIbcBr6x1egqTyeKJ19UB9Ep9qzqjbtTj4WN5UtYuXqF rHUYSI0Dxlm4Aki2OA+PZ5Rh1Q69lzXynY60ScdAyQOYkdCk4K2A/VdJYL9+00PQOA8WmDZAq+Uaha e4B07Km7ujsdiFsCZO//wK8vCNUzLkKMXCl06RRbYYEAJj/1jGgIuTV0aeWmFX5yE4FTrevUNKbYcz fZC571/wiVg4WjBnEKHVfzgyYCml6Wq9tKFwV9W+DuSBWhBhHNdykmehvfmKe2wWgV364uA4zISMEH OspcrDTpyPQcPEaKBcTbzN4RlyE+NRWwoijBhmL76t1OP/brAzyqnVON553A== X-Developer-Key: i=ribalda@chromium.org; a=openpgp; fpr=9EC3BB66E2FC129A6F90B39556A0D81F9F782DA9 X-Spam-Status: No, score=-0.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,SUBJECT_DRUG_GAP_L 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?1754186153670128091?= X-GMAIL-MSGID: =?utf-8?q?1754186153670128091?= The device does not implement the power line control correctly. It is a UVC 1.5 device, but implements the PLC control as a UVC 1.1 device. Add the corresponding control mapping override. Bus 003 Device 002: ID 30c9:0093 Lenovo Integrated Camera Device Descriptor: bLength 18 bDescriptorType 1 bcdUSB 2.01 bDeviceClass 239 Miscellaneous Device bDeviceSubClass 2 bDeviceProtocol 1 Interface Association bMaxPacketSize0 64 idVendor 0x30c9 idProduct 0x0093 bcdDevice 0.07 iManufacturer 3 Lenovo iProduct 1 Integrated Camera iSerial 2 8SSC21J75356V1SR2830069 bNumConfigurations 1 Signed-off-by: Laurent Pinchart Signed-off-by: Ricardo Ribalda --- drivers/media/usb/uvc/uvc_ctrl.c | 2 +- drivers/media/usb/uvc/uvc_driver.c | 16 ++++++++++++++++ drivers/media/usb/uvc/uvcvideo.h | 1 + 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/drivers/media/usb/uvc/uvc_ctrl.c b/drivers/media/usb/uvc/uvc_ctrl.c index f559a1ac6e3c..28ef9b2024a1 100644 --- a/drivers/media/usb/uvc/uvc_ctrl.c +++ b/drivers/media/usb/uvc/uvc_ctrl.c @@ -736,7 +736,7 @@ const struct uvc_control_mapping uvc_ctrl_power_line_mapping_limited = { V4L2_CID_POWER_LINE_FREQUENCY_50HZ), }; -static const struct uvc_control_mapping uvc_ctrl_power_line_mapping_uvc11 = { +const struct uvc_control_mapping uvc_ctrl_power_line_mapping_uvc11 = { .id = V4L2_CID_POWER_LINE_FREQUENCY, .entity = UVC_GUID_UVC_PROCESSING, .selector = UVC_PU_POWER_LINE_FREQUENCY_CONTROL, diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c index 37d2b08bc8b2..57c948d47bbf 100644 --- a/drivers/media/usb/uvc/uvc_driver.c +++ b/drivers/media/usb/uvc/uvc_driver.c @@ -2385,6 +2385,13 @@ static const struct uvc_device_info uvc_ctrl_power_line_limited = { }, }; +static const struct uvc_device_info uvc_ctrl_power_line_uvc11 = { + .mappings = (const struct uvc_control_mapping *[]) { + &uvc_ctrl_power_line_mapping_uvc11, + NULL, /* Sentinel */ + }, +}; + static const struct uvc_device_info uvc_quirk_probe_minmax = { .quirks = UVC_QUIRK_PROBE_MINMAX, }; @@ -2964,6 +2971,15 @@ static const struct usb_device_id uvc_ids[] = { .bInterfaceSubClass = 1, .bInterfaceProtocol = 0, .driver_info = UVC_INFO_QUIRK(UVC_QUIRK_FORCE_BPP) }, + /* Lenovo Integrated Camera */ + { .match_flags = USB_DEVICE_ID_MATCH_DEVICE + | USB_DEVICE_ID_MATCH_INT_INFO, + .idVendor = 0x30c9, + .idProduct = 0x0093, + .bInterfaceClass = USB_CLASS_VIDEO, + .bInterfaceSubClass = 1, + .bInterfaceProtocol = UVC_PC_PROTOCOL_15, + .driver_info = (kernel_ulong_t)&uvc_ctrl_power_line_uvc11 }, /* Sonix Technology USB 2.0 Camera */ { .match_flags = USB_DEVICE_ID_MATCH_DEVICE | USB_DEVICE_ID_MATCH_INT_INFO, diff --git a/drivers/media/usb/uvc/uvcvideo.h b/drivers/media/usb/uvc/uvcvideo.h index 1b2d9f327583..31c33eb0edf5 100644 --- a/drivers/media/usb/uvc/uvcvideo.h +++ b/drivers/media/usb/uvc/uvcvideo.h @@ -748,6 +748,7 @@ void uvc_status_stop(struct uvc_device *dev); /* Controls */ extern const struct uvc_control_mapping uvc_ctrl_power_line_mapping_limited; +extern const struct uvc_control_mapping uvc_ctrl_power_line_mapping_uvc11; extern const struct v4l2_subscribed_event_ops uvc_ctrl_sub_ev_ops; int uvc_query_v4l2_ctrl(struct uvc_video_chain *chain,