From patchwork Fri Jun 17 23:56:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 582700 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EAF23C433EF for ; Fri, 17 Jun 2022 23:56:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1383150AbiFQX4U (ORCPT ); Fri, 17 Jun 2022 19:56:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50986 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232294AbiFQX4P (ORCPT ); Fri, 17 Jun 2022 19:56:15 -0400 Received: from mail-ed1-x52b.google.com (mail-ed1-x52b.google.com [IPv6:2a00:1450:4864:20::52b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 68B1656C13 for ; Fri, 17 Jun 2022 16:56:14 -0700 (PDT) Received: by mail-ed1-x52b.google.com with SMTP id ej4so4094229edb.7 for ; Fri, 17 Jun 2022 16:56:14 -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=XGyvgzMv/o67vUhjuadDgOPqP6bhpgbwlijxZc2E+uw=; b=LP7WqlQcTCQrr6X3k4GSlkNW2hhRAOd5wxFafKA1jUlJdUy1jJq6cRySyriytN2jpJ 0eT2HeQYXGlDjosKyRxec2chetVVzCU0czgjx9jhEHPmbwOAVsEnVgVk2DW/3jaYrxoZ epT1EqBf7K2r4ZiLv3bVKwg6u+Lz5KiEhb2w4= 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=XGyvgzMv/o67vUhjuadDgOPqP6bhpgbwlijxZc2E+uw=; b=zIiRF7I7be4fYVgoDqiO7sbnjnZjSv9H2bkZODuc3+vr8eQR5jQntb2PZ5ItPoOkPa tdOKJ0iP+PrPQ4NSsHHML+ALIQ2BSU4kxFBPc24a/6FOjpdgX1XM5gK0ij2ZAvBq2yvZ HyZ911QtKB/Ly5mp16aFij/y96m4l64PikFUadIJ9E2TmNuJMEPCyihOkM5u8/o66r/B NZ5BoL06HFuJZvbsgC6fEMMC/a31hreebm7cFMORD1l1bzYyKHL1uIWKt0yS7X5K+FMX mDeQzxoqRvrNRUl37Iynmw4MjAJTO3sMR2tCV/uH+3Hq+PbSZff0bAHxjAiEaZePyx+A F+pg== X-Gm-Message-State: AJIora9+wgqAm57PMA+i7REh+KXjPcMnwnRBVYtokAMwSXq0tHqZQ9qu vyZ1bx6gY8+Jdt5LSElsGo4vLQ== X-Google-Smtp-Source: AGRyM1tJGH6oMZrjLMSMpk5XR2asvL1lPSg4xxY9zB68xl7XOrnUIZwfRaIBY/JEhCXSiXdH4cDbEw== X-Received: by 2002:a05:6402:2211:b0:42d:cb9e:cbf with SMTP id cq17-20020a056402221100b0042dcb9e0cbfmr15566816edb.76.1655510172931; Fri, 17 Jun 2022 16:56:12 -0700 (PDT) Received: from alco.lan (80.71.134.83.ipv4.parknet.dk. [80.71.134.83]) by smtp.gmail.com with ESMTPSA id z21-20020aa7d415000000b0043566884333sm1452538edq.63.2022.06.17.16.56.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Jun 2022 16:56:12 -0700 (PDT) From: Ricardo Ribalda To: Laurent Pinchart , Mauro Carvalho Chehab , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, tfiga@chromium.org, senozhatsky@chromium.org, yunkec@google.com Cc: Ricardo Ribalda Subject: [PATCH v8 1/9] media: uvcvideo: Add missing value for power_line_frequency Date: Sat, 18 Jun 2022 01:56:02 +0200 Message-Id: <20220617235610.321917-2-ribalda@chromium.org> X-Mailer: git-send-email 2.37.0.rc0.104.g0611611a94-goog In-Reply-To: <20220617235610.321917-1-ribalda@chromium.org> References: <20220617235610.321917-1-ribalda@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@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 Signed-off-by: Laurent Pinchart --- drivers/media/usb/uvc/uvc_ctrl.c | 56 +++++++++++++++++++++++++------- 1 file changed, 45 insertions(+), 11 deletions(-) diff --git a/drivers/media/usb/uvc/uvc_ctrl.c b/drivers/media/usb/uvc/uvc_ctrl.c index 0e78233fc8a0..a709ebbb4d69 100644 --- a/drivers/media/usb/uvc/uvc_ctrl.c +++ b/drivers/media/usb/uvc/uvc_ctrl.c @@ -366,6 +366,7 @@ static const struct uvc_menu_info power_line_frequency_controls[] = { { 0, "Disabled" }, { 1, "50 Hz" }, { 2, "60 Hz" }, + { 3, "Auto" }, }; static const struct uvc_menu_info exposure_auto_controls[] = { @@ -504,17 +505,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 +720,34 @@ 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_count = ARRAY_SIZE(power_line_frequency_controls) - 1, + }, +}; + +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_count = ARRAY_SIZE(power_line_frequency_controls), + }, +}; + /* ------------------------------------------------------------------------ * Utility functions */ @@ -2415,6 +2433,22 @@ static void uvc_ctrl_init_ctrl(struct uvc_video_chain *chain, if (!ctrl->initialized) return; + /* Process common mappings first. */ + for (; mapping < mend; ++mapping) { + if (uvc_entity_match_guid(ctrl->entity, mapping->entity) && + ctrl->info.selector == mapping->selector) + __uvc_ctrl_add_mapping(chain, ctrl, mapping); + } + + /* And then version-specific mappings. */ + if (chain->dev->uvc_version < 0x0150) { + mapping = uvc_ctrl_mappings_uvc11; + mend = mapping + ARRAY_SIZE(uvc_ctrl_mappings_uvc11); + } else { + mapping = uvc_ctrl_mappings_uvc15; + mend = mapping + ARRAY_SIZE(uvc_ctrl_mappings_uvc15); + } + for (; mapping < mend; ++mapping) { if (uvc_entity_match_guid(ctrl->entity, mapping->entity) && ctrl->info.selector == mapping->selector)