Received: by 2002:ab2:4a89:0:b0:1f4:a8b6:6e69 with SMTP id w9csp217408lqj; Wed, 10 Apr 2024 08:30:03 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVDsN+wCIO5lYQb6z44NLlOu5tUtDWGONeXrsvYirMIn/vMyUgRiuX7b0RnOqgTzCKbmkgTx1NqZDYEmt9goJAeaMOXqbqJo+hdp2uknA== X-Google-Smtp-Source: AGHT+IE88DV7/Irf++k3d0aBl7D5IGssGaSbuy5HnYHWJalT+59JnpX2rI/RtNY4tx3sZ9L/0bmx X-Received: by 2002:a17:906:ce4b:b0:a47:3766:cfec with SMTP id se11-20020a170906ce4b00b00a473766cfecmr5113342ejb.9.1712763003699; Wed, 10 Apr 2024 08:30:03 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712763003; cv=pass; d=google.com; s=arc-20160816; b=jagzpeub1zSQ8kETcrw1JpSOsmYObj5J219pVwZOaGKeK+LdsHk6j5OsYAScYNYPXP 0RtBwaDfjyBu4q/rAJV++NgYHy6NVt1j1rG0qCMCpnYtPKtI2kozPfnE7jSkaECXuKjv abIf9Xt/gt0hIS3Cz/MpPWBaJtbLSsr92y1f2tBpqIdZ6Ytm8yk2v4nMCGwbxtRe0OLi sld+Hi6k7zcw79spUegosjE1S9SKo1PpIsEkwl3YxkGYk/Ru9ZfAKJe58hZ1Q4qxzyTR t68K4gyh9uztjAHYWWlezTW/tZnnBmuL8dtmyyhQ4Bwe5NMfdmBa2ttyKaLctSdoNzMG UUgQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=zD6jefBDR1MgbTHSmCePAW5SSMkUGiZPJ4Kj3W4QYXg=; fh=2Wf5hOZvWUs5NuZCrs0OIcn0xiSh3BXHVMSO9PBr30I=; b=mgWmwwcTBOAt70sti4l+R6Y15tvDtp78bi1yw74HLeH5W5YjDC7bPB5E5UwEYZLZiy pArrd/gOtSXkc4XX1Wiht4hbkQ56RCYwrFStnB+14RYOmalGZMUvFTZR8XI0MhHmxhK1 3lecTa4TmParDUjtYptZpnlDNpGyH8+ArSS17XYh7ugZiDDIrMfCSJiWEIl6B6Yshv2D MX9xWp7BbyVtvd39dHc0pa6y5qwOHfvkfpUqYXiEjHA4417JmzQgxM5Pd9lgJuA34EfH Y70N/zGZ8onMlrf2/nY4+xLWRd+pC5lSUwf4L/wbsyDta/uToIehXYJXujoRLA61nC2m yC2w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=hFx8RxOY; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-138213-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-138213-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id ec20-20020a170906b6d400b00a51d4ef31a7si3236613ejb.5.2024.04.10.08.30.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Apr 2024 08:30:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-138213-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=hFx8RxOY; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-138213-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-138213-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 2AA2E1F2129B for ; Wed, 10 Apr 2024 09:07:56 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9129C1553BF; Wed, 10 Apr 2024 09:07:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="hFx8RxOY" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E078D19BA6; Wed, 10 Apr 2024 09:07:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.17 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712740061; cv=none; b=L+C7hOnreyUsB598ckGys+8mVBkwA5eYFYrU6viyRJtJySa47L0pUAZwyW/x7VYTrjG2fMr5822NnZ7reJHd+AQU7X+I/YA5YLu5nvCDynFbOiCemTqZliq8fVOJyhoz0pLYQ+fsxa2IUHU4frNeZwdMufZuZr/YeXJHaXn56Es= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712740061; c=relaxed/simple; bh=V+liulKAtSoyNMjfM1JBqrUTw3SMU8b19KrXLY09SMo=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=L9q909c6goAq+iB9dE8yoE/7e9HLuRxIDo4pozZjwULDkpF21Gg2Vx4ysyJAIcYo52qpxslnFNw5+RFzhXWC2X2EjKQzBDq59nG8ya/zz5op02RgLOWVy52rK/M060o2fdU6YhGz/e7vGM8g/ed44pT99c/GatojCBIqO4CfQbM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=hFx8RxOY; arc=none smtp.client-ip=192.198.163.17 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1712740060; x=1744276060; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=V+liulKAtSoyNMjfM1JBqrUTw3SMU8b19KrXLY09SMo=; b=hFx8RxOYZeZr7FShUMy2NDGPqBR8j5YHklr2pLXF62aj/jeCZzclYGZP G5FxKn97ZC7gomjpEy9SN/lBG59OHMjn4pxPZ014wF4Tg3yc4jFDGq1fT bWJV+o0WVPsszGiZ4DjN4Z/Q3vdvUFDr8bBJrGH0c/skD/ZhHGv+OBAgM nLVQ/GgriinN8yNIKOUxShcjjFpq3EM4EBubHwCIyTxoD7jnxefrQan7Y gZ8EUoSfDvO56HGDbeVwZxH/m0Yr8lJzNpnp9ssA+a1rRcMI9QDxnl/Vs 2vpaz9iu1EZFTjIm9fe0w7seB96UZCb+aLw4fUqe8T8j57iXYFexsXpvK A==; X-CSE-ConnectionGUID: x10F2hVcSGG5Gw53Ydb84w== X-CSE-MsgGUID: 265CPGygQwuWgykrZgTtxA== X-IronPort-AV: E=McAfee;i="6600,9927,11039"; a="7948567" X-IronPort-AV: E=Sophos;i="6.07,190,1708416000"; d="scan'208";a="7948567" Received: from fmviesa001.fm.intel.com ([10.60.135.141]) by fmvoesa111.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Apr 2024 02:07:39 -0700 X-CSE-ConnectionGUID: UXF2mQdURRiCTuaMhqsM4A== X-CSE-MsgGUID: uA0ST9FTTee0gRBBRInCJw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,190,1708416000"; d="scan'208";a="51720328" Received: from turnipsi.fi.intel.com (HELO kekkonen.fi.intel.com) ([10.237.72.44]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Apr 2024 02:07:37 -0700 Received: from kekkonen.localdomain (localhost [127.0.0.1]) by kekkonen.fi.intel.com (Postfix) with SMTP id EC23E11FC46; Wed, 10 Apr 2024 12:07:34 +0300 (EEST) Date: Wed, 10 Apr 2024 09:07:34 +0000 From: Sakari Ailus To: Tomi Valkeinen Cc: Mauro Carvalho Chehab , Hans Verkuil , Laurent Pinchart , Umang Jain , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, hdegoede@redhat.com Subject: Re: [PATCH v2 1/9] media: subdev: Add privacy led helpers Message-ID: References: <20240405-enable-streams-impro-v2-0-22bca967665d@ideasonboard.com> <20240405-enable-streams-impro-v2-1-22bca967665d@ideasonboard.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240405-enable-streams-impro-v2-1-22bca967665d@ideasonboard.com> Moi, On Fri, Apr 05, 2024 at 12:14:19PM +0300, Tomi Valkeinen wrote: > Add helper functions to enable and disable the privacy led. This moves > the #if from the call site to the privacy led functions, and makes > adding privacy led support to v4l2_subdev_enable/disable_streams() > cleaner. > > Signed-off-by: Tomi Valkeinen > --- > drivers/media/v4l2-core/v4l2-subdev.c | 31 ++++++++++++++++++++++--------- > 1 file changed, 22 insertions(+), 9 deletions(-) > > diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-core/v4l2-subdev.c > index 4c6198c48dd6..942c7a644033 100644 > --- a/drivers/media/v4l2-core/v4l2-subdev.c > +++ b/drivers/media/v4l2-core/v4l2-subdev.c > @@ -148,6 +148,23 @@ static int subdev_close(struct file *file) > } > #endif /* CONFIG_VIDEO_V4L2_SUBDEV_API */ > > +static void v4l2_subdev_enable_privacy_led(struct v4l2_subdev *sd) > +{ > +#if IS_REACHABLE(CONFIG_LEDS_CLASS) > + if (!IS_ERR_OR_NULL(sd->privacy_led)) > + led_set_brightness(sd->privacy_led, > + sd->privacy_led->max_brightness); > +#endif > +} > + > +static void v4l2_subdev_disable_privacy_led(struct v4l2_subdev *sd) > +{ > +#if IS_REACHABLE(CONFIG_LEDS_CLASS) > + if (!IS_ERR_OR_NULL(sd->privacy_led)) > + led_set_brightness(sd->privacy_led, 0); > +#endif > +} > + > static inline int check_which(u32 which) > { > if (which != V4L2_SUBDEV_FORMAT_TRY && > @@ -412,15 +429,11 @@ static int call_s_stream(struct v4l2_subdev *sd, int enable) > if (WARN_ON(!!sd->enabled_streams == !!enable)) > return 0; > > -#if IS_REACHABLE(CONFIG_LEDS_CLASS) > - if (!IS_ERR_OR_NULL(sd->privacy_led)) { > - if (enable) > - led_set_brightness(sd->privacy_led, > - sd->privacy_led->max_brightness); > - else > - led_set_brightness(sd->privacy_led, 0); > - } > -#endif > + if (enable) > + v4l2_subdev_enable_privacy_led(sd); > + else > + v4l2_subdev_disable_privacy_led(sd); > + > ret = sd->ops->video->s_stream(sd, enable); I see that you're only making changes before the s_stream call which also reveals a bug here: if streaming on fails, the LED will remain lit. It should be fixed before this set. I cc'd Hans de Goede. > > if (!enable && ret < 0) { > -- Kind regards, Sakari Ailus