From patchwork Thu Jan 5 13:52:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 640253 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 78237C54EF1 for ; Thu, 5 Jan 2023 13:56:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234137AbjAEN4F (ORCPT ); Thu, 5 Jan 2023 08:56:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41512 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234511AbjAENzW (ORCPT ); Thu, 5 Jan 2023 08:55:22 -0500 Received: from mail-ej1-x62b.google.com (mail-ej1-x62b.google.com [IPv6:2a00:1450:4864:20::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 44ABD4FCE4 for ; Thu, 5 Jan 2023 05:53:19 -0800 (PST) Received: by mail-ej1-x62b.google.com with SMTP id qk9so90027563ejc.3 for ; Thu, 05 Jan 2023 05:53:19 -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=TAPmw+y/LoYpb8ERNgeVU5ZMhp1Kwg8BHj2s0Y4AnMlt3Bc/0dOXyGT8zINdnQ9j0i NvbW19vYhExGrXXhLMNxY3AUU5G5Bb5Cmpsh8Y7LeALcZIAksx1LKuQkgkYWFwTz2wCf 49Hp+W8zgpRvfHxLCNczX752pmUENDL/H0VfI= 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=idRBjSrCEVzS3hHai5RKJd81qyFvZjiuMgXVAt3NJVCekR3c8eaIHhE9CCj0Md9aEw 69SbBf76LMp+MOdAN6rK86lXAyAgQMeJBZ3RG6YRWTd6HxLLFNyy8v6v+E5/tbQOdIi6 3cB4sv81sqFLq3n2hb6lGJVqPBehpUhNFuCdHWZudZcCj15Tle462GkV3HMd4A9QOJZ6 jUCUM72GlDfuyL7DVPc2c8THvBc3lpfuNtG8SbV3pzOJGfMGYfRiPUiByRjSZ45ewobz SlfHAqfo3oMf+liFUOaXL3foDCcotF1a3/ADYMu+E/JapQGZiC7wR7jTjJitQLFxBKcO kxbw== X-Gm-Message-State: AFqh2kqfSTA6wTR7GcC7wMnW27e1zkFtk7LeWKE8qklCWVKWP8Mfn5KA f9VU0HaZNG3PLM7u+JGpiSQ/Yw== X-Google-Smtp-Source: AMrXdXsyYjuYxWDGZ8yq+j5dtkgQZmpKpDtKSS02rAx1JeeFm46IK193HbeiefW02MvKifEVlWzoMg== X-Received: by 2002:a17:907:cb14:b0:849:ea61:511e with SMTP id um20-20020a170907cb1400b00849ea61511emr43083613ejc.44.1672926798876; Thu, 05 Jan 2023 05:53:18 -0800 (PST) Received: from alco.roam.corp.google.com ([2620:0:1059:10:43c3:8ac4:5d6f:2251]) by smtp.gmail.com with ESMTPSA id x11-20020a170906b08b00b007806c1474e1sm16459084ejy.127.2023.01.05.05.53.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Jan 2023 05:53:18 -0800 (PST) From: Ricardo Ribalda Date: Thu, 05 Jan 2023 14:52:56 +0100 Subject: [PATCH v2 5/7] media: uvcvideo: Refactor power_line_frequency_controls_limited MIME-Version: 1.0 Message-Id: <20230105-uvc-gcc5-v2-5-2ba6c660d6f5@chromium.org> References: <20230105-uvc-gcc5-v2-0-2ba6c660d6f5@chromium.org> In-Reply-To: <20230105-uvc-gcc5-v2-0-2ba6c660d6f5@chromium.org> To: Laurent Pinchart , Mauro Carvalho Chehab Cc: Ricardo Ribalda , linux-media@vger.kernel.org, Yunke Cao , linux-kernel@vger.kernel.org, Sergey Senozhatsky 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/ZANAwAKAdE30T7POsSIAcsmYgBjttZEDva4TTVOKcDo4v43+ndHUK9dLIrDPT8n8aMs sBoKU0yJAjMEAAEKAB0WIQREDzjr+/4oCDLSsx7RN9E+zzrEiAUCY7bWRAAKCRDRN9E+zzrEiFhqEA CNBJb3H3POfgL7x1Njja/ruBSNtRUZ63U4RjdkjqJdnXrhJf9IfvwW04yCfhEGxmJII79tyXeSbQ1k BQbO+u+voKO/yqHqMnPtxCdVI60r59UhgsuXlQO8ABYps2ve3vBXE46k4VAhfKaCyUvVQZOu4S9oRz IBFZJxh3p7zACo1I+/j6eme5T3QzL6j0vrHpOjhMYcCBk3tOBQpaSFkW7N0Aaqw5JKrwM4uctRYCEw wGFHfyMlxt4oqG/bA7Hsz0IB3YRaqSc5NWzAms1NDehNktfJ/gEM1f6TIHjvWQanzCigx5sARqYTzt OW9MLR5PtyMEIfqUrPEu7uP99XJuj1Wg4v0OcDa4burHjvwiO7ZY0uwh5RyAYlwveKnOwj+TXGwKEs XB6tbYJ+rKgN7317tJYMFuLwS02FqBFO/kDapEZXwqfcC43QlOeyAwjUc8BesWEOr7UucejoDpBe9o 3EDb20tonKSP3cohDVPzNfJQZeB/Q8XTh7BK6A/utB7fFQACa6NZDhqsgf7Lf6ZJ0x3bXcigwPg+oA 7JcNx90g58tJ0H12HDG6uyimozdPPPuoUtyKf2g67S10WQffIM9a4XvkDuRa/FNJrfaaZXGvJzmJv4 UwpA3aBhYMazx29R75Nz8nGbOgpzl5hTz80yhnhwuRohHxLJ2mIBfKr6GD4A== X-Developer-Key: i=ribalda@chromium.org; a=openpgp; fpr=9EC3BB66E2FC129A6F90B39556A0D81F9F782DA9 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org 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,