Received: by 2002:ab2:7407:0:b0:1f4:b336:87c4 with SMTP id e7csp209426lqn; Thu, 11 Apr 2024 21:02:48 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUq0bNm6PvrHEgCd1xNmRWhar65h5epnHVS/Q4WZ4Z50SoFY0scnEmX7u3nFxnFv9ftQD7R103T/j1wUpZ2gL9NtHIW5fBKSL7rJ0oBbA== X-Google-Smtp-Source: AGHT+IGQnlfAM3Yai49wxLPc9UE9WuY6xYLGdnnmysHta/EgpyfTHthyfNQzVGGNQFl5olMVoLdd X-Received: by 2002:a05:6870:b619:b0:22b:5bc1:66f5 with SMTP id cm25-20020a056870b61900b0022b5bc166f5mr1568170oab.16.1712894568324; Thu, 11 Apr 2024 21:02:48 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712894568; cv=pass; d=google.com; s=arc-20160816; b=OM4IxzZW2i+KadM5/0J8RQgk3nvhJf8wxRbO4TizuWGllAoq0Al/NQPJzyNyaZAvs2 mXhApP3FJHW7bb6LrX7O1K7s023mKRAJmSiX2o7GDfIfleu03Wc/V9vCD1SP/wnLyD1k Ro2IYbjCQb+kT4F4xuwZAE8TsT7bTmqRFBOXELz1xyz0FXutyzVz5mSZVC98sCyHYcKl rIo15SPg3uMstkDUrBdidbemJy0a+1E8GlSA9HSrKyNInm4TC7KAWIzMSHUMcTto6oa1 cUQhhLPFPSH1r7LMXHEE1VZN63yHfYcEKT3+jcwnfVRj5aBk+FD1rhTbrPd324CZhUOC +J4Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=AzWF60TWn76BnNkEAivuccYLuZosq+bkmHnV09PIsB8=; fh=Lk00RAwXfEdrvl02y/oikuAjnGx1DnhK+LC4UHSvN80=; b=u25te1947JvggyfAuifXM9vYIL3nmNc0ZtGJel9ynUzkl4n72K6Wubyu9ab8C9hK+8 lF6kVvU+jlaKYlEYehmU88D0hd2XRSxRPhCn7pfcO6IZaWgKauOJjNPW45IZkwZR7I3Y 58miIcYD5snWXjop6qZB9kxUg2q/3sKGOX9fTFMBaHNuMQQWB60lftLZneq9IPdgANzI qOcPOTxzv8U+HPPKDzmK6C7ZIK8fvFDcAsuKbCubbzvZFNh1F/6tFqUojOm2OYrkok7F OJOJNfegUynM+5fhrw1EREsWpO0eCY1zpiY7DwKrnvdIylNdAa5FgO4Xr2AMJ48oHIR7 03IA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=SFaiuDo5; arc=pass (i=1 spf=pass spfdomain=ideasonboard.com dkim=pass dkdomain=ideasonboard.com); spf=pass (google.com: domain of linux-kernel+bounces-141886-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-141886-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id fi1-20020a056a00398100b006ecf5f5c0a0si2622776pfb.41.2024.04.11.21.02.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Apr 2024 21:02:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-141886-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=SFaiuDo5; arc=pass (i=1 spf=pass spfdomain=ideasonboard.com dkim=pass dkdomain=ideasonboard.com); spf=pass (google.com: domain of linux-kernel+bounces-141886-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-141886-linux.lists.archive=gmail.com@vger.kernel.org" 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id E802A2821A9 for ; Fri, 12 Apr 2024 04:02:47 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6F019182C3; Fri, 12 Apr 2024 04:02:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="SFaiuDo5" Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) (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 E0C0117C64; Fri, 12 Apr 2024 04:02:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.167.242.64 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712894559; cv=none; b=UOhErSY8x/TbNnClFUaJZvRAK2GAtmMc/cef30jG/DGZeQjB53dlPjmG9HgCtirT0F6MGfzP/P9hdrPQB/QSUjeQkqsJqX4pNN3c/p3SEzTz1lHVwDlhM2E02ollg1cY6KEiBIOlUrEjm8UUzkMAvgfIjyrbFGirVcfK+L/eSOo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712894559; c=relaxed/simple; bh=+tS0uyXk06urImoDsYh/SXAFdUaHawJMOLbptlv7mN0=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=h/Vlf1Fm1b1hsD4hZdZdrE0QjoxhMtX2660/cB3hkvMMuzj/OT/xiW+q4QFByWZdIS+Ard7KubwjbKtKtHQl/qHctidAEC+46lGffXWr/0RcFwm+tXeUB2CWh8y5wnOHTNEVFj4Iw02zFkycokuxK8uHdAZNjZGrV2OEquSQe7Q= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com; spf=pass smtp.mailfrom=ideasonboard.com; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b=SFaiuDo5; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ideasonboard.com Received: from [192.168.1.105] (unknown [103.251.226.65]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 89A8B9D5; Fri, 12 Apr 2024 06:01:44 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1712894507; bh=+tS0uyXk06urImoDsYh/SXAFdUaHawJMOLbptlv7mN0=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=SFaiuDo5jeeUt9tebvUiWArj2R6ZZWVt78u/C2RSWGAzxf6HS7OQ52x3fwD/Pf7Bo +RN/BHe5fY+q3Mi6tkfEEOM2Fvy6NTWjjK1FEQPB7Ok/YmexHCWngx3UV/5ipPeRQ7 bR108NYPeSHTthtQWsPVqFMUnQz57MGJHuo0lxE0= Message-ID: Date: Fri, 12 Apr 2024 09:32:22 +0530 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3 6/9] media: subdev: Add v4l2_subdev_is_streaming() Content-Language: en-US To: Tomi Valkeinen , Mauro Carvalho Chehab , Hans Verkuil , Laurent Pinchart , Sakari Ailus Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org References: <20240410-enable-streams-impro-v3-0-e5e7a5da7420@ideasonboard.com> <20240410-enable-streams-impro-v3-6-e5e7a5da7420@ideasonboard.com> From: Umang Jain In-Reply-To: <20240410-enable-streams-impro-v3-6-e5e7a5da7420@ideasonboard.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Hi Tomi, Thank you for the patch On 10/04/24 6:05 pm, Tomi Valkeinen wrote: > Add a helper function which returns whether the subdevice is streaming, > i.e. if .s_stream or .enable_streams has been called successfully. > > Signed-off-by: Tomi Valkeinen > --- > drivers/media/v4l2-core/v4l2-subdev.c | 25 +++++++++++++++++++++++++ > include/media/v4l2-subdev.h | 13 +++++++++++++ > 2 files changed, 38 insertions(+) > > diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-core/v4l2-subdev.c > index 3d2c9c224b8f..20b5a00cbeeb 100644 > --- a/drivers/media/v4l2-core/v4l2-subdev.c > +++ b/drivers/media/v4l2-core/v4l2-subdev.c > @@ -2419,6 +2419,31 @@ void v4l2_subdev_notify_event(struct v4l2_subdev *sd, > } > EXPORT_SYMBOL_GPL(v4l2_subdev_notify_event); > > +bool v4l2_subdev_is_streaming(struct v4l2_subdev *sd) > +{ > + struct v4l2_subdev_state *state; > + > + if (!v4l2_subdev_has_op(sd, pad, enable_streams)) > + return sd->streaming_enabled; With this field named s_stream_enabled as per the comment in one of the previous patch, Reviewed-by: Umang Jain > + > + state = v4l2_subdev_get_locked_active_state(sd); > + > + if (!(sd->flags & V4L2_SUBDEV_FL_STREAMS)) > + return !!sd->enabled_pads; > + > + for (unsigned int i = 0; i < state->stream_configs.num_configs; ++i) { > + const struct v4l2_subdev_stream_config *cfg; > + > + cfg = &state->stream_configs.configs[i]; > + > + if (cfg->enabled) > + return true; > + } > + > + return false; > +} > +EXPORT_SYMBOL_GPL(v4l2_subdev_is_streaming); > + > int v4l2_subdev_get_privacy_led(struct v4l2_subdev *sd) > { > #if IS_REACHABLE(CONFIG_LEDS_CLASS) > diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h > index d6867511e9cf..270a4dfa5663 100644 > --- a/include/media/v4l2-subdev.h > +++ b/include/media/v4l2-subdev.h > @@ -1914,4 +1914,17 @@ extern const struct v4l2_subdev_ops v4l2_subdev_call_wrappers; > void v4l2_subdev_notify_event(struct v4l2_subdev *sd, > const struct v4l2_event *ev); > > +/** > + * v4l2_subdev_is_streaming() - Returns if the subdevice is streaming > + * @sd: The subdevice > + * > + * v4l2_subdev_is_streaming() tells if the subdevice is currently streaming. > + * "Streaming" here means whether .s_stream() or .enable_streams() has been > + * successfully called, and the streaming has not yet been disabled. > + * > + * If the subdevice implements .enable_streams() this function must be called > + * while holding the active state lock. > + */ > +bool v4l2_subdev_is_streaming(struct v4l2_subdev *sd); > + > #endif /* _V4L2_SUBDEV_H */ >