[PATCH 1/3] media: imx-csi: move media_pipeline to video device
Frank Li
Frank.li at nxp.com
Fri Nov 7 08:10:41 PST 2025
On Fri, Nov 07, 2025 at 11:16:33AM +0100, Michael Tretter wrote:
> 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.
>
> Signed-off-by: Michael Tretter <m.tretter at pengutronix.de>
> ---
Reviewed-by: Frank Li <Frank.Li at nxp.com>
> drivers/staging/media/imx/imx-media-capture.c | 8 ++++----
> drivers/staging/media/imx/imx-media-utils.c | 3 ++-
> drivers/staging/media/imx/imx-media.h | 7 ++++---
> 3 files changed, 10 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/staging/media/imx/imx-media-capture.c b/drivers/staging/media/imx/imx-media-capture.c
> index e9cef7af000a..bfd71d25facc 100644
> --- a/drivers/staging/media/imx/imx-media-capture.c
> +++ b/drivers/staging/media/imx/imx-media-capture.c
> @@ -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);
>
> diff --git a/drivers/staging/media/imx/imx-media-utils.c b/drivers/staging/media/imx/imx-media-utils.c
> index 1b5af8945e6b..f520529a7cfe 100644
> --- a/drivers/staging/media/imx/imx-media-utils.c
> +++ b/drivers/staging/media/imx/imx-media-utils.c
> @@ -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);
> diff --git a/drivers/staging/media/imx/imx-media.h b/drivers/staging/media/imx/imx-media.h
> index f095d9134fee..8b65f79b125f 100644
> --- a/drivers/staging/media/imx/imx-media.h
> +++ b/drivers/staging/media/imx/imx-media.h
> @@ -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);
>
>
> --
> 2.47.3
>
More information about the linux-arm-kernel
mailing list