From patchwork Wed Jan 11 08:52:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yunke Cao X-Patchwork-Id: 41829 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp3205992wrt; Wed, 11 Jan 2023 00:58:19 -0800 (PST) X-Google-Smtp-Source: AMrXdXufkXUgq+4uMuFNedApOo/bE86N0Ffy0Y/bWFF9vS4nPfq1do8Gmz+BnkHFOktUuUlv0YQR X-Received: by 2002:a17:906:cd1a:b0:801:d0bc:f616 with SMTP id oz26-20020a170906cd1a00b00801d0bcf616mr80588511ejb.62.1673427499211; Wed, 11 Jan 2023 00:58:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673427499; cv=none; d=google.com; s=arc-20160816; b=TMNpRDvH84xw6++trcAn51lqyKP0ZQN6DhlVsZ6EPSOt/REq2NLEAeB6GGWnao7f9/ fnulvuYQFMzYG+h5RRC7QJKCNMcGup7za5cVUGGDU1jnbHyXzrKbG7IgPxRp5VTaepfi KZcD9JGH+EPk7J/dKNo7/UBRFvNh+eJIBXR680EGonTBOO10x+jbDZzf9aWczSw5trTF 1OPr518L0bH25yluqbYrAKaW1sQahgJDz3IlPv7lPSAOppdt/OSDWth1SyNwMMftPI7t Lz2SGTc7V7FpElXFPG1Lt2QKBrRWsrVrsh56fJsznn7zKpumj0P9vspU0wx+WTDWLvu5 H2Wg== 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=flIhO45h+mwJLw1XX1p4rJpdGUR0h1OEp/Ako5axtJg=; b=hXEEY5rEFOz1S03HEOOfzHujFklSKrTrlWhffnEGpDJlv5DLPd6QrQ6Hh9BCFWNKR8 /WEdE2Sk7hgTu4u6ZMNN4EsoHDJVLpPSuWdKdUKD6QP+2gE3TWoM+lIFIzlunD8ju+RT eFBrnhLWLfBy5kWI3iA1B9wQZvcMf3G4iRtlb88IxsiBLKUTF+AZdcbpPxCn/VC1dJUX fARqaLv/kkzOhIwBcZtW5Fm/IKlIngCDG0nn1jV8NTqLuSBY6z5keBFVPmSerhlu0n74 A3fSYBxmiqrf561bdxAhfx4PBmU24InfytPJcwR5G2Gjq/7NTkWVOad0lLrmqq6Gz76c 9r4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=hMc8jI1K; 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 wu1-20020a170906eec100b007a1d4f0e7fcsi14119345ejb.655.2023.01.11.00.57.55; Wed, 11 Jan 2023 00:58:19 -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=hMc8jI1K; 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 S236212AbjAKIxH (ORCPT + 99 others); Wed, 11 Jan 2023 03:53:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60064 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232027AbjAKIwu (ORCPT ); Wed, 11 Jan 2023 03:52:50 -0500 Received: from mail-pl1-x62d.google.com (mail-pl1-x62d.google.com [IPv6:2607:f8b0:4864:20::62d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AB938F024 for ; Wed, 11 Jan 2023 00:52:44 -0800 (PST) Received: by mail-pl1-x62d.google.com with SMTP id p24so16057353plw.11 for ; Wed, 11 Jan 2023 00:52:44 -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=flIhO45h+mwJLw1XX1p4rJpdGUR0h1OEp/Ako5axtJg=; b=hMc8jI1K1VoA2Oz/6g/H4SgZ1M+wv0nts25v+cfYIGnHub05Thjt5mZMJ90mo149iW LLkjWYL96OFBEcEJKZzjLgT/K6OiHl7YZp1KJvSucokcRDcjLglyIbXvugeBDtVBo+oK YPEmj+RMakWFOlG9w7WSSQqnB1r9NivNnuoMo= 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=flIhO45h+mwJLw1XX1p4rJpdGUR0h1OEp/Ako5axtJg=; b=YDHZ1I6s5UUMlwZP+C5cf5a9YTdio2CnSmEAmS4rZnwJCzjPY6DHxOFt9kThM3zzk1 KqfkI/w/sM6gx2EmF6ngei23lGrAP3IJdDzl9tMGmbSQA+ag1xfOSaaypuOAjq4chp8G p9wNQJ5y/ULMSKh7tEW4EQjUSlYMS0SpOv9QKIENGkOw1KhUu0KgWiqcW/VUvTDSxPx9 Q1JTSHE9EsXT9b/XcWAJK8bkH7N2KLs+khQpJsN2zIlcHQJmMpGvvFYpdKdqkJn5KwoV vZ3HY4hBXRbRMiY+U89HI5Z6Ee3ABxxp5NjqCd4VffnqlNBsVqe/rvKfQGu5VALTLLEg 3cLg== X-Gm-Message-State: AFqh2kp4o1XQ69o0Id36nbYNyiDKjA2tiwoZdZKsfM8jdj1fY0akLiDL 7fyc/sHv+SDompffDKY++U/qpw== X-Received: by 2002:a17:902:ebc3:b0:189:361f:89ac with SMTP id p3-20020a170902ebc300b00189361f89acmr86973770plg.64.1673427164224; Wed, 11 Jan 2023 00:52:44 -0800 (PST) Received: from yunkec1.tok.corp.google.com ([2401:fa00:8f:203:c84:581:fd3a:b32b]) by smtp.gmail.com with ESMTPSA id ik9-20020a170902ab0900b00183c67844aesm9566612plb.22.2023.01.11.00.52.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Jan 2023 00:52:43 -0800 (PST) From: Yunke Cao Date: Wed, 11 Jan 2023 17:52:38 +0900 Subject: [PATCH RFC 1/3] media: v4l2-ctrls: Expose v4l2_ctrl_fill_event() MIME-Version: 1.0 Message-Id: <20230111-uvc_privacy_subdev-v1-1-f859ac9a01e3@chromium.org> References: <20230111-uvc_privacy_subdev-v1-0-f859ac9a01e3@chromium.org> In-Reply-To: <20230111-uvc_privacy_subdev-v1-0-f859ac9a01e3@chromium.org> To: Laurent Pinchart , Mauro Carvalho Chehab , Ricardo Ribalda , Hans Verkuil Cc: Yunke Cao , linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, Sakari Ailus , Ricardo Ribalda X-Mailer: b4 0.11.0-dev-4d321 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=ham 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?1754715913489422001?= X-GMAIL-MSGID: =?utf-8?q?1754715913489422001?= Rename fill_event() to v4l2_ctrl_fill_event() and expose it to drivers. Signed-off-by: Yunke Cao --- drivers/media/v4l2-core/v4l2-ctrls-core.c | 9 +++++---- include/media/v4l2-ctrls.h | 12 ++++++++++++ 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/drivers/media/v4l2-core/v4l2-ctrls-core.c b/drivers/media/v4l2-core/v4l2-ctrls-core.c index 29169170880a..184e03d032d9 100644 --- a/drivers/media/v4l2-core/v4l2-ctrls-core.c +++ b/drivers/media/v4l2-core/v4l2-ctrls-core.c @@ -16,8 +16,8 @@ static const union v4l2_ctrl_ptr ptr_null; -static void fill_event(struct v4l2_event *ev, struct v4l2_ctrl *ctrl, - u32 changes) +void v4l2_ctrl_fill_event(struct v4l2_event *ev, struct v4l2_ctrl *ctrl, + u32 changes) { memset(ev, 0, sizeof(*ev)); ev->type = V4L2_EVENT_CTRL; @@ -38,6 +38,7 @@ static void fill_event(struct v4l2_event *ev, struct v4l2_ctrl *ctrl, ev->u.ctrl.step = ctrl->step; ev->u.ctrl.default_value = ctrl->default_value; } +EXPORT_SYMBOL(v4l2_ctrl_fill_event); void send_initial_event(struct v4l2_fh *fh, struct v4l2_ctrl *ctrl) { @@ -46,7 +47,7 @@ void send_initial_event(struct v4l2_fh *fh, struct v4l2_ctrl *ctrl) if (!(ctrl->flags & V4L2_CTRL_FLAG_WRITE_ONLY)) changes |= V4L2_EVENT_CTRL_CH_VALUE; - fill_event(&ev, ctrl, changes); + v4l2_ctrl_fill_event(&ev, ctrl, changes); v4l2_event_queue_fh(fh, &ev); } @@ -57,7 +58,7 @@ void send_event(struct v4l2_fh *fh, struct v4l2_ctrl *ctrl, u32 changes) if (list_empty(&ctrl->ev_subs)) return; - fill_event(&ev, ctrl, changes); + v4l2_ctrl_fill_event(&ev, ctrl, changes); list_for_each_entry(sev, &ctrl->ev_subs, node) if (sev->fh != fh || diff --git a/include/media/v4l2-ctrls.h b/include/media/v4l2-ctrls.h index e59d9a234631..52b2f366cdb6 100644 --- a/include/media/v4l2-ctrls.h +++ b/include/media/v4l2-ctrls.h @@ -847,6 +847,18 @@ void v4l2_ctrl_auto_cluster(unsigned int ncontrols, */ struct v4l2_ctrl *v4l2_ctrl_find(struct v4l2_ctrl_handler *hdl, u32 id); +/** + * v4l2_ctrl_fill_event() - Fill the v4l2 event for a control. + * + * @ev: The event to fill. + * @ctrl: The struct v4l2_ctrl for the control event. + * @changes: A bitmask that tells what has changed. + * + * This function assumes that the control handler is locked. + */ +void v4l2_ctrl_fill_event(struct v4l2_event *ev, struct v4l2_ctrl *ctrl, + u32 changes); + /** * v4l2_ctrl_activate() - Make the control active or inactive. * @ctrl: The control to (de)activate. From patchwork Wed Jan 11 08:52:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yunke Cao X-Patchwork-Id: 41828 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp3205991wrt; Wed, 11 Jan 2023 00:58:19 -0800 (PST) X-Google-Smtp-Source: AMrXdXsw9hZQ37IVD+torQK9mizgTuT+2yeFV7ETawodVHuf/1cNCnKrtsPDj4yWvyrtxUueHUNJ X-Received: by 2002:a05:6402:a56:b0:499:1ed2:6461 with SMTP id bt22-20020a0564020a5600b004991ed26461mr10814224edb.17.1673427499155; Wed, 11 Jan 2023 00:58:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673427499; cv=none; d=google.com; s=arc-20160816; b=DYyLU8GlzXXJMZBGa0tAx4qvNzj9KbrAZnj3h49Ple75Ck8XOCKQ+ggsOepKokAmF9 XmGriIB5I1ArgRnQ3jd/oOyV3q4cB0gBQX723vmHi19L5fq6Vwfh8OJpKkKsFj9FeK/D 1vMwyezZGkQ8qd5T+sK58c4Oi0iJf6ig6cRwQwfEaOit2hJm8FHsM+9FXSG0zgLU8PnM IR9YQVHsdyA0K6iXO1ZJfMjBacQLWDpv7cT6aXtXMth1DKM1jvM77HICtT1aTfM+rLt7 +5OrYdOmEIRm153MUto57mbWX6tsITRMAJ8c/RLXXAiQBjcvcx13myS5hzJGIDPuAndp pc1w== 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=ymU4BRjSxrJhQL9DkjeeGrHUVG3DM8ZWjHKpQC1Y2Y0=; b=tKyCcI5SWhb3g8Yd8mEwJEylpQNXcijikNtwUumD79J48OGowFu4uEx2wGIMMNl+K9 kmDlUpAAAhAg07W4HpkdVZMwuzXNhyp3hGMfFoufeRiN1wXAPkKib6DfC3USjqJK38U/ GAk4NJsFgC2US5jjpJcEGaH8bZ5E2v7oUzSpabj1hddoHmo+9SZRr0nJPjdMrznnfuD0 rWv1GldkTl/1zFlhRzXcj+V13AQOsOJ4ehjvkDFNShSeq+gDS8ovzAZ16SrP+p0uwHum hW/8+PTcXX0RH8kBV6C0hlHpuMGawchjZD2qVqAye5/67axG/RSsXuHaMX0R9NMb6Kh+ fhoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=bFcukNq+; 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 eq13-20020a056402298d00b00497d974880dsi11533698edb.338.2023.01.11.00.57.56; Wed, 11 Jan 2023 00:58:19 -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=bFcukNq+; 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 S232033AbjAKIxR (ORCPT + 99 others); Wed, 11 Jan 2023 03:53:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60212 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235879AbjAKIwu (ORCPT ); Wed, 11 Jan 2023 03:52:50 -0500 Received: from mail-pl1-x633.google.com (mail-pl1-x633.google.com [IPv6:2607:f8b0:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C2C371054A for ; Wed, 11 Jan 2023 00:52:46 -0800 (PST) Received: by mail-pl1-x633.google.com with SMTP id v23so11171509plo.1 for ; Wed, 11 Jan 2023 00:52:46 -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=ymU4BRjSxrJhQL9DkjeeGrHUVG3DM8ZWjHKpQC1Y2Y0=; b=bFcukNq+D/b3ltetYdCgFtoSvKiJroUkbRgkIw6ahhoIUwyeqiIpCEPsBLopzwgmkf 0sD9QkBsFBrRFK7O637OjsIkdD34SrPuukjHJ1d0WtulZHAparow0YX+6Zi9GkvzvxPU mq7h8rpMSHOHEJmaI6xG4uqx4JIRnwaQSEKuY= 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=ymU4BRjSxrJhQL9DkjeeGrHUVG3DM8ZWjHKpQC1Y2Y0=; b=yzvzX7m6ILONddpvoiBfBeJax4M27TvBJIv1OaaR1vAVUCeh4D9p+fOKEfE44dPjrS 48+eole849KVIJHKck4Oxa8vnc7mQ7EHgrWcNhnVyRC7+d2Am0gJxrmGe4dbvWZZKgnx Xfiq8upZIs+4FgN8x7WuFjXwadb/QKkGEMCi22PjlLPUIJNZHw8ZWPqjCBotYkV/R3ya C5UnKi3nxCrcmyRR/+jVRvoCK1H8dXOFlnGS1l2VT23URT04O/Efw8bDZJ7siNGUq/Gf SC/tlRIu7c1pN+byeaX4e3Qs48PhTLWn8YDMGoD7UMNDcr24vdsOqplulZSaV2drkJ2R KV5w== X-Gm-Message-State: AFqh2krSnkyaN0P5nTi/Up4+mMFJ4gIIVuZINAX8ArcKjYX2h6VL1H7I Ch7Xyr/N6EksUNCS713wsGcYMQ== X-Received: by 2002:a17:902:ba93:b0:191:282:5d72 with SMTP id k19-20020a170902ba9300b0019102825d72mr1496801pls.51.1673427166313; Wed, 11 Jan 2023 00:52:46 -0800 (PST) Received: from yunkec1.tok.corp.google.com ([2401:fa00:8f:203:c84:581:fd3a:b32b]) by smtp.gmail.com with ESMTPSA id ik9-20020a170902ab0900b00183c67844aesm9566612plb.22.2023.01.11.00.52.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Jan 2023 00:52:46 -0800 (PST) From: Yunke Cao Date: Wed, 11 Jan 2023 17:52:39 +0900 Subject: [PATCH RFC 2/3] media: uvcvideo: remove entity privacy control in the uvc video node MIME-Version: 1.0 Message-Id: <20230111-uvc_privacy_subdev-v1-2-f859ac9a01e3@chromium.org> References: <20230111-uvc_privacy_subdev-v1-0-f859ac9a01e3@chromium.org> In-Reply-To: <20230111-uvc_privacy_subdev-v1-0-f859ac9a01e3@chromium.org> To: Laurent Pinchart , Mauro Carvalho Chehab , Ricardo Ribalda , Hans Verkuil Cc: Yunke Cao , linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, Sakari Ailus , Ricardo Ribalda X-Mailer: b4 0.11.0-dev-4d321 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?1754715913217073333?= X-GMAIL-MSGID: =?utf-8?q?1754715913217073333?= For privacy_gpio, do not expose V4L2_CID_PRIVACY to userspace as a control of the video node. Signed-off-by: Yunke Cao --- drivers/media/usb/uvc/uvc_ctrl.c | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/drivers/media/usb/uvc/uvc_ctrl.c b/drivers/media/usb/uvc/uvc_ctrl.c index c95a2229f4fa..77c5ff19add8 100644 --- a/drivers/media/usb/uvc/uvc_ctrl.c +++ b/drivers/media/usb/uvc/uvc_ctrl.c @@ -348,14 +348,6 @@ static const struct uvc_control_info uvc_ctrls[] = { | UVC_CTRL_FLAG_RESTORE | UVC_CTRL_FLAG_AUTO_UPDATE, }, - { - .entity = UVC_GUID_EXT_GPIO_CONTROLLER, - .selector = UVC_CT_PRIVACY_CONTROL, - .index = 0, - .size = 1, - .flags = UVC_CTRL_FLAG_GET_CUR - | UVC_CTRL_FLAG_AUTO_UPDATE, - }, }; static const u32 uvc_control_classes[] = { @@ -710,15 +702,6 @@ static const struct uvc_control_mapping uvc_ctrl_mappings[] = { .v4l2_type = V4L2_CTRL_TYPE_BOOLEAN, .data_type = UVC_CTRL_DATA_TYPE_BOOLEAN, }, - { - .id = V4L2_CID_PRIVACY, - .entity = UVC_GUID_EXT_GPIO_CONTROLLER, - .selector = UVC_CT_PRIVACY_CONTROL, - .size = 1, - .offset = 0, - .v4l2_type = V4L2_CTRL_TYPE_BOOLEAN, - .data_type = UVC_CTRL_DATA_TYPE_BOOLEAN, - }, }; static const struct uvc_control_mapping uvc_ctrl_mappings_uvc11[] = { From patchwork Wed Jan 11 08:52:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yunke Cao X-Patchwork-Id: 41830 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp3206233wrt; Wed, 11 Jan 2023 00:59:19 -0800 (PST) X-Google-Smtp-Source: AMrXdXu3tHveXHJllXmHlgqLNVaZqPnL21r/UsCrr33T/AAW6m46IELHYtDXAiTHm1/B5gk9IBAb X-Received: by 2002:a05:6402:2:b0:483:5e56:7bc5 with SMTP id d2-20020a056402000200b004835e567bc5mr49697333edu.40.1673427559197; Wed, 11 Jan 2023 00:59:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673427559; cv=none; d=google.com; s=arc-20160816; b=plD7j99pt07EYzO6JTRx3q2PextIg75jDWDxVUt1H69+VBhUXqU8Indc2xVC2mSApT nC/zlmgFhPsNHWb1Dvj5wxeHjoqDf5oA83THQ++KZNWiq5iqIGVVAxfegBUgUl0GOL62 CCDddwlY59pubEXHMFchpb6hZs7qoiozOub907r2IbZb2Xv48/ygZsIsnWiD5CDAdUow RqbygwDh69AplzNqQXRDdM+5AAmLwMMJyXZe8kOX9o6mCYtm6d7nqvQ2cl6rujI86stq FmPzc4AMgceADPzPhbk/oTY+mAY+tPvjHoKaByzIjVJn9lAzjIuBvszdG9yzt9k2qkkY UZ0g== 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=GTHdzY+haQl3YSErVpjNiQcb5OOOoU8CyxSOtErrOF4=; b=T1SzoM7xQxyNssgXQOBIvoja6V9amUqSt5oyb/KoZ911bj59mH94f1qZabxZ8Mnyyv pNL1GDB3z02bHubawFu2BQlG6trkI7tOnGpaIS4UtOBuaCEBvkDBF7mS8gEv4u3Afddx r2VoaqJ9e+qoyUPbrMZhdGKLw/vGnkFC/JTMeBezJ3al5V8UwCVjb0ZUnD4UAyYqwUfi iHY8XOqJZIt8wFTcbwe65fyikfMeREWa6q7PSYP/A9FYYJHDMX8nVYIgxHNvsvpsJImq yHv/HidaSS+7T/+LI7dRGTUffzHS48pa7/g6aQZ/pnHpdLArnXWJMrgG629sFVxuVUNF 6IUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=WkzbApP1; 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 bb7-20020a1709070a0700b00856320b1294si4085342ejc.95.2023.01.11.00.58.56; Wed, 11 Jan 2023 00:59:19 -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=WkzbApP1; 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 S236334AbjAKIxV (ORCPT + 99 others); Wed, 11 Jan 2023 03:53:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60044 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232582AbjAKIwu (ORCPT ); Wed, 11 Jan 2023 03:52:50 -0500 Received: from mail-pj1-x102d.google.com (mail-pj1-x102d.google.com [IPv6:2607:f8b0:4864:20::102d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EE2A7101E3 for ; Wed, 11 Jan 2023 00:52:48 -0800 (PST) Received: by mail-pj1-x102d.google.com with SMTP id m7-20020a17090a730700b00225ebb9cd01so19267724pjk.3 for ; Wed, 11 Jan 2023 00:52:48 -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=GTHdzY+haQl3YSErVpjNiQcb5OOOoU8CyxSOtErrOF4=; b=WkzbApP16X3bCYi53z4UGsBOhusmco9/jYDdOFjVdHdImlUXPFTyBqHGZpM1Fh9u7l ioU6f5BrEdVz/5HtCGmbSc7e9cHXg5QcSYckOvFuTopjca3B/0sv/nhbCknnVWAY1NaD VT9bIsjw4T0b7OA211xXUQhUQ+EX84TyW7KWo= 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=GTHdzY+haQl3YSErVpjNiQcb5OOOoU8CyxSOtErrOF4=; b=ePe9p3x01mIECyoyIluPnJ2sjba1Et386A7MvOwUsx9qpAicIq5mpzbJ1m7D4afrw8 YvfZU+rqrjudBpQPhhUQtonRtfZndB3cov+SS0d2OszaaaRPXi8euEYADL6oJSc5siXW 8TwgEitmFylaFm+vhRZYHsq3bgYflr7zHTS/59zLQhiFme9zrAXnx6SUihfafTA/ueIc CW2EotY5axy2AHdUgzfIUEvAJdDvyYRP2VQEvKNTxZeFsHNyfK3pWZJHEtFgm/+5qlid VGpsvutiRzCnZTvZYSqPUCDEJ7ZNcVtWl3zGnkyDxvDSbGVvY47R+9xDg+e1GMrpB0LW Wa4A== X-Gm-Message-State: AFqh2koqzZzsva7PzWLARoc8ztawmmX8b+w0zJ90hDc+uEO0RVv7EuNf JbokPSchssTw9pnuClgqfTIyFw== X-Received: by 2002:a17:902:c2d4:b0:193:d12:f892 with SMTP id c20-20020a170902c2d400b001930d12f892mr2314171pla.0.1673427168406; Wed, 11 Jan 2023 00:52:48 -0800 (PST) Received: from yunkec1.tok.corp.google.com ([2401:fa00:8f:203:c84:581:fd3a:b32b]) by smtp.gmail.com with ESMTPSA id ik9-20020a170902ab0900b00183c67844aesm9566612plb.22.2023.01.11.00.52.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Jan 2023 00:52:48 -0800 (PST) From: Yunke Cao Date: Wed, 11 Jan 2023 17:52:40 +0900 Subject: [PATCH RFC 3/3] media: uvcvideo: reimplement privacy GPIO as a separate subdevice MIME-Version: 1.0 Message-Id: <20230111-uvc_privacy_subdev-v1-3-f859ac9a01e3@chromium.org> References: <20230111-uvc_privacy_subdev-v1-0-f859ac9a01e3@chromium.org> In-Reply-To: <20230111-uvc_privacy_subdev-v1-0-f859ac9a01e3@chromium.org> To: Laurent Pinchart , Mauro Carvalho Chehab , Ricardo Ribalda , Hans Verkuil Cc: Yunke Cao , linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, Sakari Ailus , Ricardo Ribalda X-Mailer: b4 0.11.0-dev-4d321 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?1754715976081855975?= X-GMAIL-MSGID: =?utf-8?q?1754715976081855975?= Reimplement privacy GPIO as a v4l2 subdev with a volatile privacy control. A v4l2 control event is sent in irq when privacy control value changes. The behavior matches the original implementation, except that the control is of a separate subdevice. V4L2 control kAPI is used for simplicity. Signed-off-by: Yunke Cao --- drivers/media/usb/uvc/uvc_driver.c | 44 +++------------------- drivers/media/usb/uvc/uvc_entity.c | 76 ++++++++++++++++++++++++++++++++++++++ drivers/media/usb/uvc/uvcvideo.h | 19 +++++++--- 3 files changed, 94 insertions(+), 45 deletions(-) diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c index e4bcb5011360..25848f4dbce0 100644 --- a/drivers/media/usb/uvc/uvc_driver.c +++ b/drivers/media/usb/uvc/uvc_driver.c @@ -1209,43 +1209,6 @@ static int uvc_parse_control(struct uvc_device *dev) * Privacy GPIO */ -static void uvc_gpio_event(struct uvc_device *dev) -{ - struct uvc_entity *unit = dev->gpio_unit; - struct uvc_video_chain *chain; - u8 new_val; - - if (!unit) - return; - - new_val = gpiod_get_value_cansleep(unit->gpio.gpio_privacy); - - /* GPIO entities are always on the first chain. */ - chain = list_first_entry(&dev->chains, struct uvc_video_chain, list); - uvc_ctrl_status_event(chain, unit->controls, &new_val); -} - -static int uvc_gpio_get_cur(struct uvc_device *dev, struct uvc_entity *entity, - u8 cs, void *data, u16 size) -{ - if (cs != UVC_CT_PRIVACY_CONTROL || size < 1) - return -EINVAL; - - *(u8 *)data = gpiod_get_value_cansleep(entity->gpio.gpio_privacy); - - return 0; -} - -static int uvc_gpio_get_info(struct uvc_device *dev, struct uvc_entity *entity, - u8 cs, u8 *caps) -{ - if (cs != UVC_CT_PRIVACY_CONTROL) - return -EINVAL; - - *caps = UVC_CONTROL_CAP_GET | UVC_CONTROL_CAP_AUTOUPDATE; - return 0; -} - static irqreturn_t uvc_gpio_irq(int irq, void *data) { struct uvc_device *dev = data; @@ -1279,8 +1242,6 @@ static int uvc_gpio_parse(struct uvc_device *dev) unit->gpio.bControlSize = 1; unit->gpio.bmControls = (u8 *)unit + sizeof(*unit); unit->gpio.bmControls[0] = 1; - unit->get_cur = uvc_gpio_get_cur; - unit->get_info = uvc_gpio_get_info; strscpy(unit->name, "GPIO", sizeof(unit->name)); list_add_tail(&unit->list, &dev->entities); @@ -2202,6 +2163,11 @@ static int uvc_probe(struct usb_interface *intf, if (media_device_register(&dev->mdev) < 0) goto error; #endif + + /* Expose all subdev's nodes*/ + if (v4l2_device_register_subdev_nodes(&dev->vdev) < 0) + goto error; + /* Save our data pointer in the interface data. */ usb_set_intfdata(intf, dev); diff --git a/drivers/media/usb/uvc/uvc_entity.c b/drivers/media/usb/uvc/uvc_entity.c index 7c4d2f93d351..c8e41b42ffd8 100644 --- a/drivers/media/usb/uvc/uvc_entity.c +++ b/drivers/media/usb/uvc/uvc_entity.c @@ -56,17 +56,90 @@ static int uvc_mc_create_links(struct uvc_video_chain *chain, return 0; } +static const struct v4l2_subdev_core_ops uvc_subdev_core_ops = { + .subscribe_event = v4l2_ctrl_subdev_subscribe_event, + .unsubscribe_event = v4l2_event_subdev_unsubscribe, +}; + static const struct v4l2_subdev_ops uvc_subdev_ops = { + .core = &uvc_subdev_core_ops, }; void uvc_mc_cleanup_entity(struct uvc_entity *entity) { + if (UVC_ENTITY_TYPE(entity) == UVC_EXT_GPIO_UNIT) + v4l2_ctrl_handler_free(&entity->gpio.hdl); + if (UVC_ENTITY_TYPE(entity) != UVC_TT_STREAMING) media_entity_cleanup(&entity->subdev.entity); else if (entity->vdev != NULL) media_entity_cleanup(&entity->vdev->entity); } +static int uvc_gpio_g_volatile_ctrl(struct v4l2_ctrl *ctrl) +{ + struct uvc_gpio *gpio = + container_of(ctrl->handler, struct uvc_gpio, hdl); + + ctrl->cur.val = gpiod_get_value_cansleep(gpio->gpio_privacy); + + return 0; +} + +static const struct v4l2_ctrl_ops uvc_gpio_ctrl_ops = { + .g_volatile_ctrl = uvc_gpio_g_volatile_ctrl, +}; + +void uvc_gpio_event(struct uvc_device *dev) +{ + struct uvc_entity *unit = dev->gpio_unit; + struct v4l2_ctrl *ctrl; + struct v4l2_event ev; + s32 old_val; + int ret; + + if (!unit) + return; + + ctrl = unit->gpio.privacy_ctrl; + old_val = ctrl->cur.val; + + v4l2_ctrl_lock(ctrl); + + ret = uvc_gpio_g_volatile_ctrl(ctrl); + if (ret < 0 || old_val == ctrl->cur.val) { + v4l2_ctrl_unlock(ctrl); + return; + } + + v4l2_ctrl_fill_event(&ev, ctrl, V4L2_EVENT_CTRL_CH_VALUE); + v4l2_ctrl_unlock(ctrl); + + v4l2_event_queue(unit->subdev.devnode, &ev); +} + +static void uvc_gpio_init_ctrl(struct uvc_entity *entity) +{ + struct v4l2_ctrl *ctrl; + struct v4l2_ctrl_handler *hdl = &entity->gpio.hdl; + + entity->subdev.flags = V4L2_SUBDEV_FL_HAS_DEVNODE | + V4L2_SUBDEV_FL_HAS_EVENTS; + + v4l2_ctrl_handler_init(hdl, 1); + entity->subdev.ctrl_handler = hdl; + ctrl = v4l2_ctrl_new_std(hdl, &uvc_gpio_ctrl_ops, V4L2_CID_PRIVACY, + 0, 1, 1, 0); + if (ctrl) + ctrl->flags |= V4L2_CTRL_FLAG_VOLATILE | + V4L2_CTRL_FLAG_READ_ONLY; + + /* Read GPIO value to initialize the control. */ + uvc_gpio_g_volatile_ctrl(ctrl); + + entity->gpio.privacy_ctrl = ctrl; +} + static int uvc_mc_init_entity(struct uvc_video_chain *chain, struct uvc_entity *entity) { @@ -113,6 +186,9 @@ static int uvc_mc_init_entity(struct uvc_video_chain *chain, entity->subdev.entity.function = function; + if (UVC_ENTITY_TYPE(entity) == UVC_EXT_GPIO_UNIT) + uvc_gpio_init_ctrl(entity); + ret = media_entity_pads_init(&entity->subdev.entity, entity->num_pads, entity->pads); diff --git a/drivers/media/usb/uvc/uvcvideo.h b/drivers/media/usb/uvc/uvcvideo.h index df93db259312..19ca2896c398 100644 --- a/drivers/media/usb/uvc/uvcvideo.h +++ b/drivers/media/usb/uvc/uvcvideo.h @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -163,6 +164,15 @@ struct uvc_control { #define UVC_ENTITY_FLAG_DEFAULT (1 << 0) +struct uvc_gpio { + u8 bControlSize; + u8 *bmControls; + struct gpio_desc *gpio_privacy; + int irq; + struct v4l2_ctrl_handler hdl; + struct v4l2_ctrl *privacy_ctrl; +}; + struct uvc_entity { struct list_head list; /* Entity as part of a UVC device. */ struct list_head chain; /* Entity as part of a video device chain. */ @@ -221,12 +231,7 @@ struct uvc_entity { u8 *bmControlsType; } extension; - struct { - u8 bControlSize; - u8 *bmControls; - struct gpio_desc *gpio_privacy; - int irq; - } gpio; + struct uvc_gpio gpio; }; u8 bNrInPins; @@ -766,6 +771,8 @@ int uvc_ctrl_is_accessible(struct uvc_video_chain *chain, u32 v4l2_id, int uvc_xu_ctrl_query(struct uvc_video_chain *chain, struct uvc_xu_control_query *xqry); +void uvc_gpio_event(struct uvc_device *dev); + /* Utility functions */ struct usb_host_endpoint *uvc_find_endpoint(struct usb_host_interface *alts, u8 epaddr);