* [PATCH 0/2] media: stm32: correct s_stream calls in dcmi & st-mipid02 @ 2023-07-11 12:32 Alain Volmat 2023-07-11 12:32 ` [PATCH 1/2] media: i2c: st_mipid02: cascade s_stream call to the source subdev Alain Volmat 2023-07-11 12:32 ` [PATCH 2/2] media: stm32: dcmi: only call s_stream on " Alain Volmat 0 siblings, 2 replies; 6+ messages in thread From: Alain Volmat @ 2023-07-11 12:32 UTC (permalink / raw) To: Benjamin Mugnier, Sylvain Petinot, Mauro Carvalho Chehab, Hugues Fruchet, Maxime Coquelin, Alexandre Torgue Cc: alain.volmat, linux-media, linux-kernel, linux-stm32, linux-arm-kernel Currently the stm32 dcmi driver is calling s_stream to all subdevs until reaching the sensor subdev. This serie corrects this by having a subdev only calling s_stream on its source subdev. Alain Volmat (2): media: i2c: st_mipid02: cascade s_stream call to the source subdev media: stm32: dcmi: only call s_stream on the source subdev drivers/media/i2c/st-mipid02.c | 11 ++++ drivers/media/platform/st/stm32/stm32-dcmi.c | 63 +++++--------------- 2 files changed, 25 insertions(+), 49 deletions(-) -- 2.25.1 ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/2] media: i2c: st_mipid02: cascade s_stream call to the source subdev 2023-07-11 12:32 [PATCH 0/2] media: stm32: correct s_stream calls in dcmi & st-mipid02 Alain Volmat @ 2023-07-11 12:32 ` Alain Volmat 2023-07-11 12:44 ` Benjamin Mugnier 2023-07-19 10:26 ` Hans Verkuil 2023-07-11 12:32 ` [PATCH 2/2] media: stm32: dcmi: only call s_stream on " Alain Volmat 1 sibling, 2 replies; 6+ messages in thread From: Alain Volmat @ 2023-07-11 12:32 UTC (permalink / raw) To: Benjamin Mugnier, Sylvain Petinot, Mauro Carvalho Chehab Cc: alain.volmat, linux-media, linux-kernel Cascade the s_stream call to the source subdev whenever the bridge streaming is enable / disabled. Signed-off-by: Alain Volmat <alain.volmat@foss.st.com> --- drivers/media/i2c/st-mipid02.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/media/i2c/st-mipid02.c b/drivers/media/i2c/st-mipid02.c index 906553a28676..703d2f06f552 100644 --- a/drivers/media/i2c/st-mipid02.c +++ b/drivers/media/i2c/st-mipid02.c @@ -547,6 +547,13 @@ static int mipid02_stream_disable(struct mipid02_dev *bridge) struct i2c_client *client = bridge->i2c_client; int ret; + if (!bridge->s_subdev) + goto error; + + ret = v4l2_subdev_call(bridge->s_subdev, video, s_stream, 0); + if (ret) + goto error; + /* Disable all lanes */ ret = mipid02_write_reg(bridge, MIPID02_CLK_LANE_REG1, 0); if (ret) @@ -633,6 +640,10 @@ static int mipid02_stream_enable(struct mipid02_dev *bridge) if (ret) goto error; + ret = v4l2_subdev_call(bridge->s_subdev, video, s_stream, 1); + if (ret) + goto error; + return 0; error: -- 2.25.1 ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] media: i2c: st_mipid02: cascade s_stream call to the source subdev 2023-07-11 12:32 ` [PATCH 1/2] media: i2c: st_mipid02: cascade s_stream call to the source subdev Alain Volmat @ 2023-07-11 12:44 ` Benjamin Mugnier 2023-07-19 10:26 ` Hans Verkuil 1 sibling, 0 replies; 6+ messages in thread From: Benjamin Mugnier @ 2023-07-11 12:44 UTC (permalink / raw) To: Alain Volmat, Sylvain Petinot, Mauro Carvalho Chehab Cc: linux-media, linux-kernel Hi Alain, Thank you for your patch. LGTM. Reviewed-By: Benjamin Mugnier <benjamin.mugnier@foss.st.com> On 7/11/23 14:32, Alain Volmat wrote: > Cascade the s_stream call to the source subdev whenever the bridge > streaming is enable / disabled. > > Signed-off-by: Alain Volmat <alain.volmat@foss.st.com> > --- > drivers/media/i2c/st-mipid02.c | 11 +++++++++++ > 1 file changed, 11 insertions(+) > > diff --git a/drivers/media/i2c/st-mipid02.c b/drivers/media/i2c/st-mipid02.c > index 906553a28676..703d2f06f552 100644 > --- a/drivers/media/i2c/st-mipid02.c > +++ b/drivers/media/i2c/st-mipid02.c > @@ -547,6 +547,13 @@ static int mipid02_stream_disable(struct mipid02_dev *bridge) > struct i2c_client *client = bridge->i2c_client; > int ret; > > + if (!bridge->s_subdev) > + goto error; > + > + ret = v4l2_subdev_call(bridge->s_subdev, video, s_stream, 0); > + if (ret) > + goto error; > + > /* Disable all lanes */ > ret = mipid02_write_reg(bridge, MIPID02_CLK_LANE_REG1, 0); > if (ret) > @@ -633,6 +640,10 @@ static int mipid02_stream_enable(struct mipid02_dev *bridge) > if (ret) > goto error; > > + ret = v4l2_subdev_call(bridge->s_subdev, video, s_stream, 1); > + if (ret) > + goto error; > + > return 0; > > error: -- Regards, Benjamin ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] media: i2c: st_mipid02: cascade s_stream call to the source subdev 2023-07-11 12:32 ` [PATCH 1/2] media: i2c: st_mipid02: cascade s_stream call to the source subdev Alain Volmat 2023-07-11 12:44 ` Benjamin Mugnier @ 2023-07-19 10:26 ` Hans Verkuil 2023-07-21 12:18 ` Alain Volmat 1 sibling, 1 reply; 6+ messages in thread From: Hans Verkuil @ 2023-07-19 10:26 UTC (permalink / raw) To: Alain Volmat, Benjamin Mugnier, Sylvain Petinot, Mauro Carvalho Chehab Cc: linux-media, linux-kernel On 11/07/2023 14:32, Alain Volmat wrote: > Cascade the s_stream call to the source subdev whenever the bridge > streaming is enable / disabled. > > Signed-off-by: Alain Volmat <alain.volmat@foss.st.com> > --- > drivers/media/i2c/st-mipid02.c | 11 +++++++++++ > 1 file changed, 11 insertions(+) > > diff --git a/drivers/media/i2c/st-mipid02.c b/drivers/media/i2c/st-mipid02.c > index 906553a28676..703d2f06f552 100644 > --- a/drivers/media/i2c/st-mipid02.c > +++ b/drivers/media/i2c/st-mipid02.c > @@ -547,6 +547,13 @@ static int mipid02_stream_disable(struct mipid02_dev *bridge) > struct i2c_client *client = bridge->i2c_client; > int ret; > > + if (!bridge->s_subdev) > + goto error; I'm getting this compiler warning: media-git/drivers/media/i2c/st-mipid02.c: In function 'mipid02_stream_disable': media-git/drivers/media/i2c/st-mipid02.c:568:12: warning: 'ret' may be used uninitialized [-Wmaybe-uninitialized] 568 | if (ret) | ^ media-git/drivers/media/i2c/st-mipid02.c:548:13: note: 'ret' was declared here 548 | int ret; | ^~~ I'm dropping this series, waiting for a v2. Regards, Hans > + > + ret = v4l2_subdev_call(bridge->s_subdev, video, s_stream, 0); > + if (ret) > + goto error; > + > /* Disable all lanes */ > ret = mipid02_write_reg(bridge, MIPID02_CLK_LANE_REG1, 0); > if (ret) > @@ -633,6 +640,10 @@ static int mipid02_stream_enable(struct mipid02_dev *bridge) > if (ret) > goto error; > > + ret = v4l2_subdev_call(bridge->s_subdev, video, s_stream, 1); > + if (ret) > + goto error; > + > return 0; > > error: ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] media: i2c: st_mipid02: cascade s_stream call to the source subdev 2023-07-19 10:26 ` Hans Verkuil @ 2023-07-21 12:18 ` Alain Volmat 0 siblings, 0 replies; 6+ messages in thread From: Alain Volmat @ 2023-07-21 12:18 UTC (permalink / raw) To: Hans Verkuil Cc: Benjamin Mugnier, Sylvain Petinot, Mauro Carvalho Chehab, linux-media, linux-kernel Hi Hans, On Wed, Jul 19, 2023 at 12:26:37PM +0200, Hans Verkuil wrote: > On 11/07/2023 14:32, Alain Volmat wrote: > > Cascade the s_stream call to the source subdev whenever the bridge > > streaming is enable / disabled. > > > > Signed-off-by: Alain Volmat <alain.volmat@foss.st.com> > > --- > > drivers/media/i2c/st-mipid02.c | 11 +++++++++++ > > 1 file changed, 11 insertions(+) > > > > diff --git a/drivers/media/i2c/st-mipid02.c b/drivers/media/i2c/st-mipid02.c > > index 906553a28676..703d2f06f552 100644 > > --- a/drivers/media/i2c/st-mipid02.c > > +++ b/drivers/media/i2c/st-mipid02.c > > @@ -547,6 +547,13 @@ static int mipid02_stream_disable(struct mipid02_dev *bridge) > > struct i2c_client *client = bridge->i2c_client; > > int ret; > > > > + if (!bridge->s_subdev) > > + goto error; > > I'm getting this compiler warning: > > media-git/drivers/media/i2c/st-mipid02.c: In function 'mipid02_stream_disable': > media-git/drivers/media/i2c/st-mipid02.c:568:12: warning: 'ret' may be used uninitialized [-Wmaybe-uninitialized] > 568 | if (ret) > | ^ > media-git/drivers/media/i2c/st-mipid02.c:548:13: note: 'ret' was declared here > 548 | int ret; > | ^~~ > > I'm dropping this series, waiting for a v2. Indeed, this was a real issue. I added KCFLAGS=-Wmaybe-uninitialized in my build command line to spot thoses issues from now on. v2 posted with the fix. > > Regards, > > Hans Regards, Alain > > > + > > + ret = v4l2_subdev_call(bridge->s_subdev, video, s_stream, 0); > > + if (ret) > > + goto error; > > + > > /* Disable all lanes */ > > ret = mipid02_write_reg(bridge, MIPID02_CLK_LANE_REG1, 0); > > if (ret) > > @@ -633,6 +640,10 @@ static int mipid02_stream_enable(struct mipid02_dev *bridge) > > if (ret) > > goto error; > > > > + ret = v4l2_subdev_call(bridge->s_subdev, video, s_stream, 1); > > + if (ret) > > + goto error; > > + > > return 0; > > > > error: > ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 2/2] media: stm32: dcmi: only call s_stream on the source subdev 2023-07-11 12:32 [PATCH 0/2] media: stm32: correct s_stream calls in dcmi & st-mipid02 Alain Volmat 2023-07-11 12:32 ` [PATCH 1/2] media: i2c: st_mipid02: cascade s_stream call to the source subdev Alain Volmat @ 2023-07-11 12:32 ` Alain Volmat 1 sibling, 0 replies; 6+ messages in thread From: Alain Volmat @ 2023-07-11 12:32 UTC (permalink / raw) To: Hugues Fruchet, Mauro Carvalho Chehab, Maxime Coquelin, Alexandre Torgue Cc: alain.volmat, linux-media, linux-stm32, linux-arm-kernel, linux-kernel 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; } -- 2.25.1 ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2023-07-21 12:19 UTC | newest] Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2023-07-11 12:32 [PATCH 0/2] media: stm32: correct s_stream calls in dcmi & st-mipid02 Alain Volmat 2023-07-11 12:32 ` [PATCH 1/2] media: i2c: st_mipid02: cascade s_stream call to the source subdev Alain Volmat 2023-07-11 12:44 ` Benjamin Mugnier 2023-07-19 10:26 ` Hans Verkuil 2023-07-21 12:18 ` Alain Volmat 2023-07-11 12:32 ` [PATCH 2/2] media: stm32: dcmi: only call s_stream on " Alain Volmat
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®