From patchwork Tue Jan 3 11:01:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 38380 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp4553046wrt; Tue, 3 Jan 2023 03:05:43 -0800 (PST) X-Google-Smtp-Source: AMrXdXssunvHZtQYKoAcMLSYWXGRATdWbC29QQotryAqbcf0/tMMpOkputYY+QSoqVDpbIUhHbec X-Received: by 2002:a17:902:bd42:b0:192:4d3e:a573 with SMTP id b2-20020a170902bd4200b001924d3ea573mr41559147plx.24.1672743943334; Tue, 03 Jan 2023 03:05:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672743943; cv=none; d=google.com; s=arc-20160816; b=XxhJLNs8CFxC+rcY45CTPzaZ8dGdFBrWXRR4cBhLJITtRKdGqaGQnwkU6sU7ZOmNys 80RFZIF2q1m4QJqCh0I1cLwmFpM7bPJF7KJOKiPcxG4DmuCmOHaNwGMPcsFlO0i/teaS fc+dS2YT/matxV9MgVs2bPpwePBsNJx2H2ar4vuwtE6TozaXyz4QQmY4vdut1lOjBE/6 /h8tv90mDBRibmvOWBqNbT9yCbQms99p3FLE4k4BUsVTgZ2/1eGxxB5IwfatDYeyiI32 dQkPb3Kr311WUm/6rRrZD38i0AyFTfQMKn6K+JAoDHnHMQjoFIX8V0dipV77iE9JAn3r Cliw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=00bD41CpohMBMgWN2aRl98+MG1NWyw9aXdRxmbyLX7k=; b=H3uN8FsI213FqAp0Lp1ehDLP8oAOi9327hxidMEUjnKBZWe3JlJYmdQtMSrdqWO+nx GNXpaMSk3lxOMllBmLbWtah/bpqli7/P7307afGBLT9dNC6Du35jEPbCkfv+yX0G/XdU Zu0DzakG4i8/NJvTloXXoY5silUOIT4eUGjO3q3gm9WTy+KZdr17OLCzfdEGCupOHjA2 aCTCdtxqLjM7EPagZuYJT8HGPfxaRDVReC+X9cIOGCAt24fG5wxOTFxVj0+dFYuyO4Ig u49LPnnrnD/IP5YzwtwLXGQd43U0o6uAAe0VqCfiv1vXVObV+NfSc9k9Zj3CZrxvB8eK BVSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=lkh5HCyh; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s23-20020a170902b19700b001929aeb0d60si14469505plr.180.2023.01.03.03.05.29; Tue, 03 Jan 2023 03:05:43 -0800 (PST) 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=lkh5HCyh; 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 S237465AbjACLCP (ORCPT + 99 others); Tue, 3 Jan 2023 06:02:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45608 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237285AbjACLB6 (ORCPT ); Tue, 3 Jan 2023 06:01:58 -0500 Received: from mail-ej1-x631.google.com (mail-ej1-x631.google.com [IPv6:2a00:1450:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8FF9110D9 for ; Tue, 3 Jan 2023 03:01:57 -0800 (PST) Received: by mail-ej1-x631.google.com with SMTP id fy8so8771344ejc.13 for ; Tue, 03 Jan 2023 03:01:57 -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=00bD41CpohMBMgWN2aRl98+MG1NWyw9aXdRxmbyLX7k=; b=lkh5HCyhJ0VSthqIJhVg7LcOAC5++DcCafGeW+njz7gDkKybj2yDo9MQKVo5UXRT6G MILYofG4/Z6AMJSCIsZToHVaDBomPh1H6siahu7wUBPJpaihWnRtYYNnsM20RVRiDtUW n2CZfMi+KUMjSk8bwX2x5599R1zGl7KIARf58= 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=00bD41CpohMBMgWN2aRl98+MG1NWyw9aXdRxmbyLX7k=; b=NbLm5U2VH1E+4C/4yUnxXmr7bPBQtsOgKyYqGsAtP5/8ylvkV0IUOjQT5Qj0RDRpVW hQl2z//lnrnEziWeiOohiXuT4lecXIdL/qwT1smYvOhqg7oOPvOv0mbBowBQJrK/L5Bk KVzbejllbh+L3nkiXChccXERTW7LraJk2Hd5GyPRLrIgNPROhMX/rqsWi7x96PG/RMzH nqEzr8ezE1v2wFquUSFlfhy20TnnOifMVxLvgU20ApssnJQs1uul8A9bm3pGXsHKN3y0 ZcXjIcpq2s7MxBxbf8ROHRCmxRtbve0WsAOACe5OkiNRAteJOn789Lw4nKwJ1jNPSwRY ORug== X-Gm-Message-State: AFqh2kpTxWdtBZ4FlTiHoMSNxfHIReCK2DZdnnexVKpSg2ue5RxdYy5N D7B/cuEt2VT3onS+YinqsMJ4pNalgf8j8LBP9Vk= X-Received: by 2002:a17:907:8e93:b0:7ae:bfec:74c7 with SMTP id tx19-20020a1709078e9300b007aebfec74c7mr39110590ejc.72.1672743715986; Tue, 03 Jan 2023 03:01:55 -0800 (PST) Received: from alco.roam.corp.google.com ([2620:0:1059:10:ef23:1430:9acc:b68]) by smtp.gmail.com with ESMTPSA id l12-20020a17090615cc00b007c0cd272a06sm13944331ejd.225.2023.01.03.03.01.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Jan 2023 03:01:55 -0800 (PST) From: Ricardo Ribalda Date: Tue, 03 Jan 2023 12:01:23 +0100 Subject: [PATCH v3 3/3] media: uvcvideo: Refactor power_line_frequency_controls_limited MIME-Version: 1.0 Message-Id: <20221101-easycam-v3-3-2c9881a7a4f7@chromium.org> References: <20221101-easycam-v3-0-2c9881a7a4f7@chromium.org> In-Reply-To: <20221101-easycam-v3-0-2c9881a7a4f7@chromium.org> To: Laurent Pinchart , Mauro Carvalho Chehab Cc: linux-media@vger.kernel.org, Ricardo Ribalda , linux-kernel@vger.kernel.org, Sergey Senozhatsky X-Mailer: b4 0.11.0-dev-696ae X-Developer-Signature: v=1; a=openpgp-sha256; l=3328; i=ribalda@chromium.org; h=from:subject:message-id; bh=U6+fv6Oz+oBYLUlCti95XpzN5zRXjjLpaYFVN2dc0HI=; b=owEBbQKS/ZANAwAKAdE30T7POsSIAcsmYgBjtAsep6BRBKmLrGo7Jh0JjciKXjPQr18hFu57TlyO Go95FN+JAjMEAAEKAB0WIQREDzjr+/4oCDLSsx7RN9E+zzrEiAUCY7QLHgAKCRDRN9E+zzrEiDfTD/ sED2E32h08CttZhf7ECpbeysdAs4/o8+xOE0p0bCSKi5Tjk2X2z7qHE6CGs1mKFD6sXh4bArM/yatP 2eBzUH3JooZyZI0ZKYqrm8ZPsvYEDrLYYeErHU1D1McJsSoOUeKFLrLU+/VjfRthUB5Jd2mERmJkmv FONN68J9MWdIJO5P9rZk6qYWpxBBG+FULClMaf6xc3PkpM9CXMeBeInUC1uCveQ39M/rjjaA9zSrud gkhBFDxf8qBPZZ0v6u3l652X8k+++DLdW2Hu4J+i9iod7zaTHMesogtkzYXktqNEXE1oLM2Eb8aVxx n3KohB6dLJO4hVHryA/Ls3ML9zmQjBi/snepflN5/LTFbH0afItxxc4mEqMzGrr6C63Jfc9A7R9TAQ QJY5nSUiq/58UfWCbB6qdR9D2SKhxUAxK0ix4AUpvZgQw1BImKLtV/g4ix+O7i71hd0oJXVGa2dmXo OHGaHnTqnllCnUAT5FHVVeTB+KeF2UtdCUdlECRn7sqGTInQxqD785P17/IE3uquCIg4w1FWRxXmLO 63Ofnn8KevPELj3tOXP3H/a5gYXVR+Q9W91eIIh7P1GHnhHO9y9DcoSDgqVjDG06iINKWHARnY7+iw v8eoVUMyQ3sf4YqcAHBAW0xD0Rtldqn91Jm1pv3C6NLexP2bckaidYSwAXWQ== X-Developer-Key: i=ribalda@chromium.org; a=openpgp; fpr=9EC3BB66E2FC129A6F90B39556A0D81F9F782DA9 X-Spam-Status: No, score=-2.1 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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1753999153160288541?= X-GMAIL-MSGID: =?utf-8?q?1753999153160288541?= 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 | 17 +++++++++++++++++ drivers/media/usb/uvc/uvc_driver.c | 17 ----------------- drivers/media/usb/uvc/uvcvideo.h | 1 + 3 files changed, 18 insertions(+), 17 deletions(-) diff --git a/drivers/media/usb/uvc/uvc_ctrl.c b/drivers/media/usb/uvc/uvc_ctrl.c index d8283d71bc96..4ff0415d8bf4 100644 --- a/drivers/media/usb/uvc/uvc_ctrl.c +++ b/drivers/media/usb/uvc/uvc_ctrl.c @@ -370,6 +370,11 @@ static const struct uvc_menu_info power_line_frequency_controls[] = { { 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" }, @@ -751,6 +756,18 @@ static const struct uvc_control_mapping uvc_ctrl_mappings_uvc15[] = { }, }; +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_count = ARRAY_SIZE(power_line_frequency_controls_limited), +}; + /* ------------------------------------------------------------------------ * Utility functions */ diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c index 9c09bc988278..6531aed5d642 100644 --- a/drivers/media/usb/uvc/uvc_driver.c +++ b/drivers/media/usb/uvc/uvc_driver.c @@ -2377,23 +2377,6 @@ static const struct uvc_device_info uvc_ctrl_power_line_uvc11 = { }, }; -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_count = ARRAY_SIZE(power_line_frequency_controls_limited), -}; - 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 bcb0b0c101c8..818ae7a6f9b9 100644 --- a/drivers/media/usb/uvc/uvcvideo.h +++ b/drivers/media/usb/uvc/uvcvideo.h @@ -728,6 +728,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 uvc_control_mapping uvc_ctrl_power_line_mapping_uvc11; extern const struct v4l2_subscribed_event_ops uvc_ctrl_sub_ev_ops;