Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2152271iof; Tue, 7 Jun 2022 21:30:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxSOLivr7MqNMU0cy0p8OPwYEopj9L2vUFbc1vcPpMb5IMvYZU7XF7gKwAawa1c7e8OT90l X-Received: by 2002:a17:90b:1c0d:b0:1e8:7596:f20 with SMTP id oc13-20020a17090b1c0d00b001e875960f20mr17885247pjb.35.1654662628610; Tue, 07 Jun 2022 21:30:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654662628; cv=none; d=google.com; s=arc-20160816; b=OUuyFO5cT4BWDx25JLWAEOISgHJ2xJfBI3Gkr9Jni2RGmwmRlvC3pLpi4FpbdFlc0p 9ZOMwniVQXeAHsNkA50QF69+jpP74T4wUvqBcVeygkAwtLyMynmNZA3dFvZSmHclaLZR eorCxeMbjWxpdUp9f/PKpQavHerNEiBlJAicAgvkrY9hosDY0dJlOJiC53T3JiRNhTmm kFFseF0wnLRgklV1u1eHLH87GIAzC8DN0jJxcyaEEYCdgjJnVABaUvBY3GONp6bDwvAh 9cbZOZ0oj4NuJVI638sXeLccvSeIbJhFEKl4uAPup98KozgYuXYBs5kEnN2FukNS6459 /EnA== 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=81mSmxn15JtVkPz978aR9cpRDrkI+JcjBbyBqhiZujI=; b=f0ZRIOBXEu2DgVqv2AHgNghXS3V5G38RyXseDjnzPhptfG2jl1dOoXot8ZEtzOc75d ewDbRz9yAWbqv8QT07oBeXx5JyfZsr6+iUgfr4BtIk7s8Gyhh/BNsgV0hp5fpkaaPFXf eIqUzVmiKOxn2WUIHrShap6N4gdEYQ6zOYnU1mkzKhQYOzwbmr36rMOQvRmVWoure7RK hv4BJdmhHlUVtj1O/QfLJmveYUDfu+jGZznhrhBlHMLyF3PP9oJmzaXd1IROCmD8Uert 9VFf3BLeG0e5BzYT3SvXonEuyGolqr27EsEnmzUv7+7C2lN3oyQHcxoaNtxCmlsxmPN/ LMew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=JgKwyycO; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id b9-20020a170903228900b00158d1f2d451si29058273plh.45.2022.06.07.21.30.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 21:30:28 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=JgKwyycO; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 934FB251965; Tue, 7 Jun 2022 20:59:06 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244924AbiFGNog (ORCPT + 99 others); Tue, 7 Jun 2022 09:44:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47694 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244896AbiFGNo1 (ORCPT ); Tue, 7 Jun 2022 09:44:27 -0400 Received: from mail-ej1-x62a.google.com (mail-ej1-x62a.google.com [IPv6:2a00:1450:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BE7FDB0400 for ; Tue, 7 Jun 2022 06:44:11 -0700 (PDT) Received: by mail-ej1-x62a.google.com with SMTP id o7so2007094eja.1 for ; Tue, 07 Jun 2022 06:44: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=81mSmxn15JtVkPz978aR9cpRDrkI+JcjBbyBqhiZujI=; b=JgKwyycO6K1nAZG5gXllWbL5lodh9u9YaRM+BOe9H5U9nQazybhFS8p5DbJMKHEsA7 WrWQEd0liSXRb9uOiSEyOWtL1QsFh4UsNSC+vX3dW2J4KvUgfJe5NcrU1TFEHaW6iBVO hc+k523x57hBMog3+jOEI3i31MJYCWNnfjkiw= 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=81mSmxn15JtVkPz978aR9cpRDrkI+JcjBbyBqhiZujI=; b=RdSBMeQY9R7SPRYRDPA3vMsxTJtORraaaC537IzcWn/VLNh2DYuIHQEdfYdGtgq0Fs ViC6fvDpZ5xdk/RpwXushK7NqqmqLa4VAW+KTeDdE2AtsfbB11UKS9hZqev+WWRwE3FP Ve9HXa1cQQhahdCPI7ITbZ4xkC9jOOZisPxRZ7wu+vjzuqDESzZb9s3dZ7eSUP2/z41z 7miOYtbeEquU5IsQBS6a1sCS6zd3knjASLlEeLPkG5I5koIdosicF1ROV8sM4EeMayWP 8syPGEb3Tf4j507wXeowbGgpp/R88T4U7nm9KaYLwUeDY3K+BSsEj7fTBkJQSsOxmaur ctgw== X-Gm-Message-State: AOAM532ZHBtKJbPBGE0gU5OM7zWNjrfC1xcjEL4sVU6MbW0Bj0cSATYE r1r0sNC3yxrcRl70+fpO6nTfcA== X-Received: by 2002:a17:906:99c1:b0:6fe:b01d:134 with SMTP id s1-20020a17090699c100b006feb01d0134mr26619200ejn.598.1654609450293; Tue, 07 Jun 2022 06:44:10 -0700 (PDT) Received: from alco.corp.google.com ([2620:0:1059:10:d185:5aaa:c33d:f136]) by smtp.gmail.com with ESMTPSA id c10-20020a170906528a00b0070a80f03a44sm6621347ejm.119.2022.06.07.06.44.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 06:44: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 v3 1/7] media: uvcvideo: Add missing value for power_line_frequency Date: Tue, 7 Jun 2022 15:43:58 +0200 Message-Id: <20220607134405.166704-2-ribalda@chromium.org> X-Mailer: git-send-email 2.36.1.255.ge46751e96f-goog In-Reply-To: <20220607134405.166704-1-ribalda@chromium.org> References: <20220607134405.166704-1-ribalda@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE 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 UVC 1.5 class defines 4 values for this control on: 4.2.2.3.6 Power Line Frequency Control Add the missing value when the uvc version is 1.5. Signed-off-by: Ricardo Ribalda --- drivers/media/usb/uvc/uvc_ctrl.c | 67 ++++++++++++++++++++++++++------ 1 file changed, 55 insertions(+), 12 deletions(-) diff --git a/drivers/media/usb/uvc/uvc_ctrl.c b/drivers/media/usb/uvc/uvc_ctrl.c index 0e78233fc8a0..f9d4ac81e62f 100644 --- a/drivers/media/usb/uvc/uvc_ctrl.c +++ b/drivers/media/usb/uvc/uvc_ctrl.c @@ -362,12 +362,19 @@ static const u32 uvc_control_classes[] = { V4L2_CID_USER_CLASS, }; -static const struct uvc_menu_info power_line_frequency_controls[] = { +static const struct uvc_menu_info power_line_frequency_controls_uvc11[] = { { 0, "Disabled" }, { 1, "50 Hz" }, { 2, "60 Hz" }, }; +static const struct uvc_menu_info power_line_frequency_controls_uvc15[] = { + { 0, "Disabled" }, + { 1, "50 Hz" }, + { 2, "60 Hz" }, + { 3, "Auto" }, +}; + static const struct uvc_menu_info exposure_auto_controls[] = { { 2, "Auto Mode" }, { 1, "Manual Mode" }, @@ -504,17 +511,6 @@ static const struct uvc_control_mapping uvc_ctrl_mappings[] = { .v4l2_type = V4L2_CTRL_TYPE_INTEGER, .data_type = UVC_CTRL_DATA_TYPE_UNSIGNED, }, - { - .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_count = ARRAY_SIZE(power_line_frequency_controls), - }, { .id = V4L2_CID_HUE_AUTO, .entity = UVC_GUID_UVC_PROCESSING, @@ -730,6 +726,32 @@ static const struct uvc_control_mapping uvc_ctrl_mappings[] = { }, }; +static const +struct uvc_control_mapping 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_uvc11, + .menu_count = ARRAY_SIZE(power_line_frequency_controls_uvc11), +}; + +static const +struct uvc_control_mapping 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_uvc15, + .menu_count = ARRAY_SIZE(power_line_frequency_controls_uvc15), +}; + /* ------------------------------------------------------------------------ * Utility functions */ @@ -2376,6 +2398,22 @@ static void uvc_ctrl_prune_entity(struct uvc_device *dev, } } +/* + * The powerline control has different valid values depending on the + * uvc version. + */ +static void uvc_ctrl_init_powerline(struct uvc_video_chain *chain, + struct uvc_control *ctrl) +{ + if (chain->dev->uvc_version < 0x0150) { + __uvc_ctrl_add_mapping(chain, ctrl, + &power_line_mapping_uvc11); + return; + } + + __uvc_ctrl_add_mapping(chain, ctrl, &power_line_mapping_uvc15); +} + /* * Add control information and hardcoded stock control mappings to the given * device. @@ -2385,6 +2423,7 @@ static void uvc_ctrl_init_ctrl(struct uvc_video_chain *chain, { const struct uvc_control_info *info = uvc_ctrls; const struct uvc_control_info *iend = info + ARRAY_SIZE(uvc_ctrls); + static const u8 uvc_processing_guid[16] = UVC_GUID_UVC_PROCESSING; const struct uvc_control_mapping *mapping = uvc_ctrl_mappings; const struct uvc_control_mapping *mend = mapping + ARRAY_SIZE(uvc_ctrl_mappings); @@ -2415,6 +2454,10 @@ static void uvc_ctrl_init_ctrl(struct uvc_video_chain *chain, if (!ctrl->initialized) return; + if (uvc_entity_match_guid(ctrl->entity, uvc_processing_guid) && + ctrl->info.selector == UVC_PU_POWER_LINE_FREQUENCY_CONTROL) + return uvc_ctrl_init_powerline(chain, ctrl); + for (; mapping < mend; ++mapping) { if (uvc_entity_match_guid(ctrl->entity, mapping->entity) && ctrl->info.selector == mapping->selector) -- 2.36.1.255.ge46751e96f-goog