mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Hugues FRUCHET <hugues.fruchet@foss.st.com>
To: Alain Volmat <alain.volmat@foss.st.com>,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	Maxime Coquelin <mcoquelin.stm32@gmail.com>,
	Alexandre Torgue <alexandre.torgue@foss.st.com>
Cc: <linux-media@vger.kernel.org>,
	<linux-stm32@st-md-mailman.stormreply.com>,
	<linux-arm-kernel@lists.infradead.org>,
	<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2 2/2] media: stm32: dcmi: only call s_stream on the source subdev
Date: Tue, 25 Jul 2023 10:34:37 +0200	[thread overview]
Message-ID: <da0de3ba-28b7-2138-733a-7d12ec0b5206@foss.st.com> (raw)
In-Reply-To: <20230721120316.1172445-3-alain.volmat@foss.st.com>

Reviewed-by: Hugues FRUCHET <hugues.fruchet@foss.st.com>

On 7/21/23 14:03, Alain Volmat wrote:
> Avoid calling s_stream on each subdev until reaching the sensor and
> instead call s_stream on the source subdev only (which will in turn
> do whatever needed to start the stream).
> 
> Signed-off-by: Alain Volmat <alain.volmat@foss.st.com>
> ---
>   drivers/media/platform/st/stm32/stm32-dcmi.c | 63 +++++---------------
>   1 file changed, 14 insertions(+), 49 deletions(-)
> 
> diff --git a/drivers/media/platform/st/stm32/stm32-dcmi.c b/drivers/media/platform/st/stm32/stm32-dcmi.c
> index dad6e22e4ce4..ac8a5031dce6 100644
> --- a/drivers/media/platform/st/stm32/stm32-dcmi.c
> +++ b/drivers/media/platform/st/stm32/stm32-dcmi.c
> @@ -134,6 +134,7 @@ struct stm32_dcmi {
>   	struct video_device		*vdev;
>   	struct v4l2_async_notifier	notifier;
>   	struct v4l2_subdev		*source;
> +	struct v4l2_subdev		*s_subdev;
>   	struct v4l2_format		fmt;
>   	struct v4l2_rect		crop;
>   	bool				do_crop;
> @@ -692,51 +693,6 @@ static int dcmi_pipeline_s_fmt(struct stm32_dcmi *dcmi,
>   	return 0;
>   }
>   
> -static int dcmi_pipeline_s_stream(struct stm32_dcmi *dcmi, int state)
> -{
> -	struct media_entity *entity = &dcmi->vdev->entity;
> -	struct v4l2_subdev *subdev;
> -	struct media_pad *pad;
> -	int ret;
> -
> -	/* Start/stop all entities within pipeline */
> -	while (1) {
> -		pad = &entity->pads[0];
> -		if (!(pad->flags & MEDIA_PAD_FL_SINK))
> -			break;
> -
> -		pad = media_pad_remote_pad_first(pad);
> -		if (!pad || !is_media_entity_v4l2_subdev(pad->entity))
> -			break;
> -
> -		entity = pad->entity;
> -		subdev = media_entity_to_v4l2_subdev(entity);
> -
> -		ret = v4l2_subdev_call(subdev, video, s_stream, state);
> -		if (ret < 0 && ret != -ENOIOCTLCMD) {
> -			dev_err(dcmi->dev, "%s: \"%s\" failed to %s streaming (%d)\n",
> -				__func__, subdev->name,
> -				state ? "start" : "stop", ret);
> -			return ret;
> -		}
> -
> -		dev_dbg(dcmi->dev, "\"%s\" is %s\n",
> -			subdev->name, state ? "started" : "stopped");
> -	}
> -
> -	return 0;
> -}
> -
> -static int dcmi_pipeline_start(struct stm32_dcmi *dcmi)
> -{
> -	return dcmi_pipeline_s_stream(dcmi, 1);
> -}
> -
> -static void dcmi_pipeline_stop(struct stm32_dcmi *dcmi)
> -{
> -	dcmi_pipeline_s_stream(dcmi, 0);
> -}
> -
>   static int dcmi_start_streaming(struct vb2_queue *vq, unsigned int count)
>   {
>   	struct stm32_dcmi *dcmi = vb2_get_drv_priv(vq);
> @@ -758,9 +714,12 @@ static int dcmi_start_streaming(struct vb2_queue *vq, unsigned int count)
>   		goto err_pm_put;
>   	}
>   
> -	ret = dcmi_pipeline_start(dcmi);
> -	if (ret)
> +	ret = v4l2_subdev_call(dcmi->s_subdev, video, s_stream, 1);
> +	if (ret < 0) {
> +		dev_err(dcmi->dev, "%s: Failed to start source subdev, error (%d)\n",
> +			__func__, ret);
>   		goto err_media_pipeline_stop;
> +	}
>   
>   	spin_lock_irq(&dcmi->irqlock);
>   
> @@ -862,7 +821,7 @@ static int dcmi_start_streaming(struct vb2_queue *vq, unsigned int count)
>   	return 0;
>   
>   err_pipeline_stop:
> -	dcmi_pipeline_stop(dcmi);
> +	v4l2_subdev_call(dcmi->s_subdev, video, s_stream, 0);
>   
>   err_media_pipeline_stop:
>   	video_device_pipeline_stop(dcmi->vdev);
> @@ -889,8 +848,12 @@ static void dcmi_stop_streaming(struct vb2_queue *vq)
>   {
>   	struct stm32_dcmi *dcmi = vb2_get_drv_priv(vq);
>   	struct dcmi_buf *buf, *node;
> +	int ret;
>   
> -	dcmi_pipeline_stop(dcmi);
> +	ret = v4l2_subdev_call(dcmi->s_subdev, video, s_stream, 0);
> +	if (ret < 0)
> +		dev_err(dcmi->dev, "%s: Failed to stop source subdev, error (%d)\n",
> +			__func__, ret);
>   
>   	video_device_pipeline_stop(dcmi->vdev);
>   
> @@ -1876,6 +1839,8 @@ static int dcmi_graph_notify_bound(struct v4l2_async_notifier *notifier,
>   		dev_dbg(dcmi->dev, "DCMI is now linked to \"%s\"\n",
>   			subdev->name);
>   
> +	dcmi->s_subdev = subdev;
> +
>   	return ret;
>   }
>   

      reply	other threads:[~2023-07-25  8:35 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-21 12:03 [PATCH v2 0/2] media: stm32: correct s_stream calls in dcmi & st-mipid02 Alain Volmat
2023-07-21 12:03 ` [PATCH v2 1/2] media: i2c: st_mipid02: cascade s_stream call to the source subdev Alain Volmat
2023-07-25  7:56   ` Benjamin Mugnier
2023-07-21 12:03 ` [PATCH v2 2/2] media: stm32: dcmi: only call s_stream on " Alain Volmat
2023-07-25  8:34   ` Hugues FRUCHET [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=da0de3ba-28b7-2138-733a-7d12ec0b5206@foss.st.com \
    --to=hugues.fruchet@foss.st.com \
    --cc=alain.volmat@foss.st.com \
    --cc=alexandre.torgue@foss.st.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-stm32@st-md-mailman.stormreply.com \
    --cc=mchehab@kernel.org \
    --cc=mcoquelin.stm32@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®