Received: by 2002:ab2:69cc:0:b0:1f4:be93:e15a with SMTP id n12csp90552lqp; Fri, 12 Apr 2024 11:16:21 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVRMmBc4CJQsByuU1lv2EvcJztABeXbPHRvFe3KNkKeGWGSTVv2f0ccxT1HtaHfqeliDmG8DvFiZK6KjDLhDCgPB4DGLMRTM3/m0/UlrA== X-Google-Smtp-Source: AGHT+IEhVDVseZtspA+6IwTXYXVyNsurLW0niDjTEZgDTrp/Xs4XfqeMQlEfz0+GyS/jeeqLiNu0 X-Received: by 2002:a17:902:e5cd:b0:1e4:952c:fafb with SMTP id u13-20020a170902e5cd00b001e4952cfafbmr4513114plf.2.1712945780694; Fri, 12 Apr 2024 11:16:20 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712945780; cv=pass; d=google.com; s=arc-20160816; b=JNSLKBvxbsZzZQXgFX+euczMpJWjb8Zi7o/uK8wSKu8Ae+2Fo2iGcsYbwVEpt8BJlX T4TyjaSWZVb+kOr1YG2jUO72I7ImBgdNHFIHCqEN9u++PzI+iyzbvZRw9Euwr3EK5FtS xUQhQ/4qju7aJ25SO88LtFtDgGOfU4Rc8tgKllzNXV2D1WYasqaZOHgkS1jSIqlYvTrK F1aIx6Cee5rnFIuLVlj5TUYhaFBQ3qiDMNgTRpoA5lpTU/VYJkp5fxz+kN/F/5A6CIhc N9QZ56KtcZRi9+HFqK7A4CRJfTyGzWzPnlpBzk/ld1p7ZuTUqzmkhJB046SuqNY83IIc Hk+A== 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=YPqSOrNtDJZ3QlWRWWRWp3Wu0wtXdeDlXpZSocSYsX0=; fh=kb24mPs25WqywxJHooszEmv14QS87Sk+hEKpHxhz2LM=; b=bqeiYVFwGKkKOugpE5om985zNEjqbUB4Zs8Etv4ftdczPkP8c659bOhFo6HXdKP14e +1Oq6aoxJSJQi6z4oCrKBdBbyKtnVom6lAWwq2N29xsBdVgs7hb37VXISiuWNRWbnXnl OXf+meTIGD45GUepZQXL3aevAhuDSnQaXmlR2t4ijJE99LCp0MHPgy2PpPYFvpeeoVKx pYs+ydYZX50sDYS0jD78dWdtAqiwTgbHx8TNHndoj5wHygxoEn9uy5Dc2UnbevJLmlJc TWv+AVO8c2KqTJb+aaB0tYRM6+3GyXvl/JZACjrlrR5Kk95rJB3JVeuQhG+TixK4XLye mRTA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=a4qF07Hq; arc=pass (i=1 spf=pass spfdomain=ideasonboard.com dkim=pass dkdomain=ideasonboard.com); spf=pass (google.com: domain of linux-kernel+bounces-143184-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-143184-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id t18-20020a17090340d200b001e3e564577bsi3642676pld.205.2024.04.12.11.16.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Apr 2024 11:16:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-143184-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=a4qF07Hq; arc=pass (i=1 spf=pass spfdomain=ideasonboard.com dkim=pass dkdomain=ideasonboard.com); spf=pass (google.com: domain of linux-kernel+bounces-143184-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-143184-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 5F1A3282498 for ; Fri, 12 Apr 2024 18:16:20 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E02A814EC4F; Fri, 12 Apr 2024 18:16:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="a4qF07Hq" 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 6B43C14E2E1; Fri, 12 Apr 2024 18:16:10 +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=1712945772; cv=none; b=B3fJByjNqXyM9WLFu043dPNsgdlU9HNC6cHAtkU7K15hVU+Txtjc+0s9PH+D+1rVSpg5sLld+uh2VI9eNNxIWwEQHf2PlmjfdnWjT98vsY/gCjxzODw/KiMUYMOkJNTD6hHXuZVKJaMLK2XD1bXKIbwGXvcRS7o0mM9MhyP2alY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712945772; c=relaxed/simple; bh=dZ7DBLOplA06T/PhVO+GGVrNbWcG7Pg5wgdv1SwGr5A=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=l3HeGaH+1BQE3A5CWz22/DbV2GkPTftAOTogZX67XnCUN6wuu3DkN/Mbp2e7cmuZVLxF0tkskzhXzQGkuSGUYWxUk5RNmXndB3Aow1eSfpxg0oGskwM+IYO78RlfxJxsjvffAohegQhfswxt3sQRzrPSTJgCSmsxxogGzXv1MWM= 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=a4qF07Hq; 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 pendragon.ideasonboard.com (85-76-65-73-nat.elisa-mobile.fi [85.76.65.73]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 989029D5; Fri, 12 Apr 2024 20:15:24 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1712945725; bh=dZ7DBLOplA06T/PhVO+GGVrNbWcG7Pg5wgdv1SwGr5A=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=a4qF07Hqp6QbxF+DdKNbg7E7ucc1k7j8PMU8AdrQ8GEeUczRxaDedLhQMG2y08F50 FWldRDtmW6vvKRgbBXSETpbhvAKPXyH/1WW6fVTfaoC8z2Gn6iAJrjueZ0BJVcmNxY WUZ6FCLszKLkFKtJrEfOwLzKrieVVIwpV546YvmA= Date: Fri, 12 Apr 2024 21:15:58 +0300 From: Laurent Pinchart To: Tomi Valkeinen Cc: Mauro Carvalho Chehab , Hans Verkuil , Sakari Ailus , Umang Jain , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 6/9] media: subdev: Add v4l2_subdev_is_streaming() Message-ID: <20240412181558.GI31122@pendragon.ideasonboard.com> References: <20240410-enable-streams-impro-v3-0-e5e7a5da7420@ideasonboard.com> <20240410-enable-streams-impro-v3-6-e5e7a5da7420@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=utf-8 Content-Disposition: inline In-Reply-To: <20240410-enable-streams-impro-v3-6-e5e7a5da7420@ideasonboard.com> Hi Tomi, Thank you for the patch. On Wed, Apr 10, 2024 at 03:35:53PM +0300, 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; > + > + state = v4l2_subdev_get_locked_active_state(sd); > + > + if (!(sd->flags & V4L2_SUBDEV_FL_STREAMS)) > + return !!sd->enabled_pads; I think this can be moved above the v4l2_subdev_get_locked_active_state() call. Reviewed-by: Laurent Pinchart Any plan to convert drivers to this ? > + > + 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 */ > -- Regards, Laurent Pinchart