media: staging: imx-csi: move media_pipeline to video device

The imx-media driver has a single imx_media_device. Attaching the
media_pipeline to the imx_media_device prevents the execution of multiple
media pipelines on the device. This should be possible as long as the
media_pipelines don't use the same pads or pads that be configured while
the other media pipeline is streaming.

Move the media_pipeline to the imx_media_video_dev to be able to construct
media pipelines per imx capture device.

If different media pipelines in the media device conflict, the validation
will fail. Thus, the pipeline will fail to start and signal an error to
user space.

Reviewed-by: Frank Li <Frank.Li@nxp.com>
Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
Signed-off-by: Frank Li <Frank.Li@nxp.com>
Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
This commit is contained in:
Michael Tretter 2025-12-18 10:23:49 +01:00 committed by Hans Verkuil
parent a947fc3ba8
commit e52b90b827
3 changed files with 10 additions and 8 deletions

View File

@ -722,8 +722,8 @@ static int capture_start_streaming(struct vb2_queue *vq, unsigned int count)
goto return_bufs;
}
ret = imx_media_pipeline_set_stream(priv->md, &priv->src_sd->entity,
true);
ret = imx_media_pipeline_set_stream(priv->md, &priv->vdev,
&priv->src_sd->entity, true);
if (ret) {
dev_err(priv->dev, "pipeline start failed with %d\n", ret);
goto return_bufs;
@ -749,8 +749,8 @@ static void capture_stop_streaming(struct vb2_queue *vq)
unsigned long flags;
int ret;
ret = imx_media_pipeline_set_stream(priv->md, &priv->src_sd->entity,
false);
ret = imx_media_pipeline_set_stream(priv->md, &priv->vdev,
&priv->src_sd->entity, false);
if (ret)
dev_warn(priv->dev, "pipeline stop failed with %d\n", ret);

View File

@ -749,6 +749,7 @@ EXPORT_SYMBOL_GPL(imx_media_pipeline_subdev);
* Turn current pipeline streaming on/off starting from entity.
*/
int imx_media_pipeline_set_stream(struct imx_media_dev *imxmd,
struct imx_media_video_dev *vdev,
struct media_entity *entity,
bool on)
{
@ -762,7 +763,7 @@ int imx_media_pipeline_set_stream(struct imx_media_dev *imxmd,
mutex_lock(&imxmd->md.graph_mutex);
if (on) {
ret = __media_pipeline_start(entity->pads, &imxmd->pipe);
ret = __media_pipeline_start(entity->pads, &vdev->pipe);
if (ret)
goto out;
ret = v4l2_subdev_call(sd, video, s_stream, 1);

View File

@ -104,6 +104,9 @@ struct imx_media_buffer {
struct imx_media_video_dev {
struct video_device *vfd;
/* the pipeline object */
struct media_pipeline pipe;
/* the user format */
struct v4l2_pix_format fmt;
/* the compose rectangle */
@ -145,9 +148,6 @@ struct imx_media_dev {
struct media_device md;
struct v4l2_device v4l2_dev;
/* the pipeline object */
struct media_pipeline pipe;
struct mutex mutex; /* protect elements below */
/* master video device list */
@ -223,6 +223,7 @@ int imx_media_alloc_dma_buf(struct device *dev,
int size);
int imx_media_pipeline_set_stream(struct imx_media_dev *imxmd,
struct imx_media_video_dev *vdev,
struct media_entity *entity,
bool on);