[PATCH 2/2] media: staging: imx: configure src_mux in csi_start

Frank Li Frank.li at nxp.com
Wed Nov 5 08:53:22 PST 2025


On Wed, Nov 05, 2025 at 04:18:50PM +0100, Michael Tretter wrote:
> After media_pipeline_start() was called, the media graph is assumed to
> be validated. It won't be validated again if a second stream starts.
>
> The imx-media-csi driver, however, changes hardware configuration in the
> link_validate() callback. This can result in started streams with
> misconfigured hardware.
>
> In the concrete example, the ipu2_csi1_mux is driven by a parallel video
> input. After the media pipeline has been started with this
> configuration, a second stream is configured to use ipu1_csi0 with
> MIPI-CSI input from imx6-mipi-csi2. This may require the reconfiguration
> of ipu1_csi0 with ipu_set_csi_src_mux(). Since the media pipeline is
> already running, link_validate won't be called, and the ipu1_csi0 won't
> be reconfigured. The resulting video is broken, because the
> ipu1_csi0_mux is misconfigured, but no error is reported.
>
> Move ipu_set_csi_src_mux from csi_link_validate to csi_start to ensure
> that input to ipu1_csi0 is configured correctly when starting the
> stream. This is a local reconfiguration in ipu1_csi0 and is possible
> while the media pipeline is running.
>
> Signed-off-by: Michael Tretter <m.tretter at pengutronix.de>
> Fixes: 4a34ec8e470c ("[media] media: imx: Add CSI subdev driver")
> Cc: stable at vger.kernel.org
> ---
>  drivers/staging/media/imx/imx-media-csi.c | 44 +++++++++++++++++--------------
>  1 file changed, 24 insertions(+), 20 deletions(-)
>
...
>
>  	ret = v4l2_subdev_link_validate_default(sd, link,
> @@ -1145,25 +1168,6 @@ static int csi_link_validate(struct v4l2_subdev *sd,
>  		return ret;
>  	}
>
> -	mutex_lock(&priv->lock);

Is it safe to remove lock? I think put justification in commit message
about removing lock.

Frank
> -
> -	is_csi2 = !is_parallel_bus(&mbus_cfg);
> -	if (is_csi2) {
> -		/*
> -		 * NOTE! It seems the virtual channels from the mipi csi-2
> -		 * receiver are used only for routing by the video mux's,
> -		 * or for hard-wired routing to the CSI's. Once the stream
> -		 * enters the CSI's however, they are treated internally
> -		 * in the IPU as virtual channel 0.
> -		 */
> -		ipu_csi_set_mipi_datatype(priv->csi, 0,
> -					  &priv->format_mbus[CSI_SINK_PAD]);
> -	}
> -
> -	/* select either parallel or MIPI-CSI2 as input to CSI */
> -	ipu_set_csi_src_mux(priv->ipu, priv->csi_id, is_csi2);
> -
> -	mutex_unlock(&priv->lock);
>  	return ret;
>  }
>
>
> --
> 2.47.3
>



More information about the linux-arm-kernel mailing list