Received: by 2002:ac2:464d:0:0:0:0:0 with SMTP id s13csp2055136lfo; Fri, 20 May 2022 11:43:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzy+dzqGSOvjug86Uj7IF2aKxmU5XjMMaORsmBp1LU5nKmrCcPmC3LI4kYlbHR7mNkGTy6n X-Received: by 2002:a17:907:1c97:b0:6f5:22ae:7024 with SMTP id nb23-20020a1709071c9700b006f522ae7024mr10022508ejc.570.1653072180924; Fri, 20 May 2022 11:43:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653072180; cv=none; d=google.com; s=arc-20160816; b=0ohA6eImEQCQlSPBhfEt8ZrwycD+RX/QoN8JHvaPXHaEHNO0/oZUWrOAhnSZPAvLp/ g0AtmFoG1gcho5rO5cD14MPT7WZz6+tfmGpVJA6PP13osgfnKA+gS4yJEkfGGV1Kuf+6 peCFt+UJgVmLVTlqEbZOPRZORyQTSlZuTu18k5IiBRvwCMugIgblRUIlfATvQW9ynN32 rKMDm0WCVt5FwG2TtHD+ln1aGfHQG8deiToaFq2AvpJPBjcW/8cd0ery0ixmdkxju2Dp ucwUISQPeJomHfwrkoGTiJoubCjBGl87LFmMneggz/tsY9ENuckyMeOOxZiWLEBmkMEO sl+Q== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=DtTkHYnKGvfKFBtPz8vNVTdKZGvi19TnjUXim2qxDgg=; b=CPCmPZwXZl8eZAoOpXpboouBvYjj2wJ0OiR4wu++D9s1F+TUOqhdUQakQmjbQku4HS I4lC3mmM8+nZwJrtGXdxWARbitWqlfHQzrqR0mlPPsv1J8uhZWCYZQplTaWQHQoUX65V deHLA+uyQM+X09NWZSpU8zitBzxd6NXJGGsRBSNbEwT2SRnEe0Y7S5X3aLfWVW+EPlIK 9hNKmcffu+w6CAJEsRpC0Kdv1kuyHfe+wbxPdsndFSdf3+Toxnyn6wcjMoAw2O1TBOsb 3CJcYOBR0NCmTH35uei8ij+1EZb2TZmpZzO0Zhp/DRaOfKksaNekaDJzlKFE/f4NUaeD z5eg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=f09opcdO; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gt36-20020a1709072da400b006f39f0b8ef6si8525757ejc.449.2022.05.20.11.42.35; Fri, 20 May 2022 11:43:00 -0700 (PDT) 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=f09opcdO; 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 S243718AbiESSN1 (ORCPT + 99 others); Thu, 19 May 2022 14:13:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51002 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243684AbiESSNM (ORCPT ); Thu, 19 May 2022 14:13:12 -0400 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 AD48DE64D2 for ; Thu, 19 May 2022 11:13:11 -0700 (PDT) Received: by mail-ed1-x531.google.com with SMTP id i40so7962063eda.7 for ; Thu, 19 May 2022 11:13:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=DtTkHYnKGvfKFBtPz8vNVTdKZGvi19TnjUXim2qxDgg=; b=f09opcdOAlUEqHlVU0oPsZr8SxaD6LkLiNyxWZGwbd6XOYWSIKIx2gtSg8hp9tJqRO 94SjTrnx31JZ9HIJMM2Cb5opm90u8lj4A36XQ+PhK2JcC8azXJfIaEWG5f3JNPRSRMNo rchXp7EcNXj3zVDkkNMriSMMrpXXA5fwbRPKQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=DtTkHYnKGvfKFBtPz8vNVTdKZGvi19TnjUXim2qxDgg=; b=fd2WdE6lvG8XxiCVEyNTpNNSvNWRXtZUuX/JbM/nr2t5At6Cwfr5DIFhg3UpUzmv0b 3N4wxBsPtodsVVR2oot+jcQ/PuO8KB+adkXb0jNjuq9W5nUHKaHHGjiefhGo13S1Gi3R 6Tn2Ms9qto5COYwtHqI3qNGcI3yk9y3HvWA4ImbiaRTVANn/XTDjROCk9Y3HcGi544au LZfdkJQWysSARvLYXbspQaPM0upYppSAxg6+ZY8zJ+KHGkXbngYu9oYAMSXuA0nerFT2 mSrLc9GmnLPZGdjwPFIrpaja4DC9lol/ddVcG1djs0WtM7jtVHZ6c6mWxZ36eqAUdiyR HMxw== X-Gm-Message-State: AOAM532qMFzix3LGiGcaLwv0eg7C764l1/785WywWPSgNqLsnHUoXghd GjRfXW+ZOunDeygdHJ2U5bTtaA== X-Received: by 2002:aa7:d3c5:0:b0:42a:ab58:1e50 with SMTP id o5-20020aa7d3c5000000b0042aab581e50mr6622591edr.320.1652983990345; Thu, 19 May 2022 11:13:10 -0700 (PDT) Received: from alco.lan (80.71.134.83.ipv4.parknet.dk. [80.71.134.83]) by smtp.gmail.com with ESMTPSA id hw7-20020a170907a0c700b006f3ef214e3csm1225801ejc.162.2022.05.19.11.13.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 May 2022 11:13:09 -0700 (PDT) From: Ricardo Ribalda To: Laurent Pinchart , Mauro Carvalho Chehab , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Tomasz Figa , Sergey Senozhatsky , Yunke Cao Cc: Ricardo Ribalda Subject: [PATCH v2 2/4] media: uvcvideo: Add UVC_QUIRK_LIMITED_POWERLINE Date: Thu, 19 May 2022 20:13:04 +0200 Message-Id: <20220519181306.42136-3-ribalda@chromium.org> X-Mailer: git-send-email 2.36.1.124.g0e6072fb45-goog In-Reply-To: <20220519181306.42136-1-ribalda@chromium.org> References: <20220519181306.42136-1-ribalda@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.6 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,T_SCC_BODY_TEXT_LINE 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 Add a quirk for devices that only support a limited set of Power Line frequencies. Signed-off-by: Ricardo Ribalda --- drivers/media/usb/uvc/uvc_ctrl.c | 24 ++++++++++++++++++++++++ drivers/media/usb/uvc/uvcvideo.h | 1 + 2 files changed, 25 insertions(+) diff --git a/drivers/media/usb/uvc/uvc_ctrl.c b/drivers/media/usb/uvc/uvc_ctrl.c index a942021dfbe1..5027fedc4f39 100644 --- a/drivers/media/usb/uvc/uvc_ctrl.c +++ b/drivers/media/usb/uvc/uvc_ctrl.c @@ -375,6 +375,11 @@ static const struct uvc_menu_info power_line_frequency_controls_uvc15[] = { { 3, "Auto" }, }; +static const struct uvc_menu_info power_line_frequency_controls_limited[] = { + { 1, "50 Hz" }, + { 2, "60 Hz" }, +}; + static const struct uvc_menu_info exposure_auto_controls[] = { { 2, "Auto Mode" }, { 1, "Manual Mode" }, @@ -752,6 +757,19 @@ struct uvc_control_mapping power_line_mapping_uvc15 = { .menu_count = ARRAY_SIZE(power_line_frequency_controls_uvc15), }; +static const +struct uvc_control_mapping 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_count = ARRAY_SIZE(power_line_frequency_controls_limited), +}; + /* ------------------------------------------------------------------------ * Utility functions */ @@ -2395,6 +2413,12 @@ static void uvc_ctrl_prune_entity(struct uvc_device *dev, static void uvc_ctrl_init_powerline(struct uvc_video_chain *chain, struct uvc_control *ctrl) { + if (chain->dev->quirks & UVC_QUIRK_LIMITED_POWERLINE) { + __uvc_ctrl_add_mapping(chain, ctrl, + &power_line_mapping_limited); + return; + } + if (chain->dev->uvc_version < 0x0150) { __uvc_ctrl_add_mapping(chain, ctrl, &power_line_mapping_uvc11); diff --git a/drivers/media/usb/uvc/uvcvideo.h b/drivers/media/usb/uvc/uvcvideo.h index 143230b3275b..06779eb4f5fa 100644 --- a/drivers/media/usb/uvc/uvcvideo.h +++ b/drivers/media/usb/uvc/uvcvideo.h @@ -209,6 +209,7 @@ #define UVC_QUIRK_RESTORE_CTRLS_ON_INIT 0x00000400 #define UVC_QUIRK_FORCE_Y8 0x00000800 #define UVC_QUIRK_FORCE_BPP 0x00001000 +#define UVC_QUIRK_LIMITED_POWERLINE 0x00002000 /* Format flags */ #define UVC_FMT_FLAG_COMPRESSED 0x00000001 -- 2.36.1.124.g0e6072fb45-goog