]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
media: staging: imx-csi: move media_pipeline to video device
authorMichael Tretter <m.tretter@pengutronix.de>
Thu, 18 Dec 2025 09:23:49 +0000 (10:23 +0100)
committerHans Verkuil <hverkuil+cisco@kernel.org>
Wed, 27 May 2026 08:58:27 +0000 (10:58 +0200)
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>
drivers/staging/media/imx/imx-media-capture.c
drivers/staging/media/imx/imx-media-utils.c
drivers/staging/media/imx/imx-media.h

index e9cef7af000a91674aa2cfe750a399cae40ff9d6..bfd71d25facce2b0932d728bf97a91e4ccff3f34 100644 (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);
 
index 1b5af8945e6b8bb9cdf585a12cd71d457f3d5c10..f520529a7cfe9c346f1da4c0ad4713cf1747eb8a 100644 (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);
index 135daca7d55be14b9e8f7983f537815d71b57209..537558a7becedae006f7978249373d9afcb4b7e6 100644 (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);