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: 639617 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 A9F3BC3DA7A for ; Thu, 5 Jan 2023 12:33:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232427AbjAEMdx (ORCPT ); Thu, 5 Jan 2023 07:33:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58792 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232736AbjAEMdg (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 C266F4E404 for ; Thu, 5 Jan 2023 04:33:32 -0800 (PST) Received: by mail-ed1-x52c.google.com with SMTP id m21so52550828edc.3 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=TJeu3WIPWeoJO1eLdlBo2JW0BDXXSULPJqs8GOx6HjhBObvzX+ao3CwXXdXhvtwM2n h41HHvDqc7w9Y26opd1SOaRYLZVz1U+869cKlTm2sPDdUgoa0AjW8vBnOCrJfKol+sHN G+grhsb/WxcnOhHu9lUlnBPkA/83Xs0qrsi1fOmJtMkFXwLkJle3qgEpVQacZ2ou+8TR 85zRQv8Sg0/ydCiHjlGHoAVdHJgL9UQQKs3lMzeWE+3iMwZG1Fnet+ZvcVBRDV+cU4zf YrQ2LwhL4K0AFzTSgN/O1b0XY9ysAMuX3Nj817n15gGRyOO+ossUjGg6ZexLDjilQfTf RHNg== X-Gm-Message-State: AFqh2kqLZ0Qh8oj6eIXfgKnaAn6KnJb0VHDMEHOzPlVi3mkZsOBfi7jR Wdg37kliYsQzzZOZVyQ3VvSEy4/DEou5mD5lqvk= X-Google-Smtp-Source: AMrXdXt9PL7j5VffNSgDjkCrb/AVQNmabH7lnN488TdM9yDuH4aycyjM8UB+FxZgQkMNTkKMGvbuww== 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 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,