[PATCH v4 4/4] media: imx-mipi-csis: Get number of active lanes via mbus_config

Isaac Scott posted 4 patches 6 days, 9 hours ago
[PATCH v4 4/4] media: imx-mipi-csis: Get number of active lanes via mbus_config
Posted by Isaac Scott 6 days, 9 hours ago
The number of lanes actively used by a MIPI CSI transmitter may differ
from that which is defined in device tree, due to the source device not
using all of the connected data lanes on the board. As such, call on
v4l2_get_active_data_lanes() to check if the driver reports a differing
number of lanes to the maximum, and use that number of active lanes.

If the number of active data lanes is invalid, or the op is not
supported, use the maximum number of allowed data lanes.

Signed-off-by: Isaac Scott <isaac.scott@ideasonboard.com>
---
 drivers/media/platform/nxp/imx-mipi-csis.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/media/platform/nxp/imx-mipi-csis.c b/drivers/media/platform/nxp/imx-mipi-csis.c
index 838a1ad123b5..637ef6e614fa 100644
--- a/drivers/media/platform/nxp/imx-mipi-csis.c
+++ b/drivers/media/platform/nxp/imx-mipi-csis.c
@@ -1034,6 +1034,10 @@ static int mipi_csis_s_stream(struct v4l2_subdev *sd, int enable)
 	format = v4l2_subdev_state_get_format(state, CSIS_PAD_SINK);
 	csis_fmt = find_csis_format(format->code);
 
+	ret = v4l2_get_active_data_lanes(csis->source.pad,
+					 csis->bus.num_data_lanes);
+	csis->num_data_lanes = ret < 0 ? csis->bus.num_data_lanes : ret;
+
 	ret = mipi_csis_calculate_params(csis, csis_fmt);
 	if (ret < 0)
 		goto err_unlock;

-- 
2.43.0
Re: [PATCH v4 4/4] media: imx-mipi-csis: Get number of active lanes via mbus_config
Posted by Frank Li 6 days, 3 hours ago
On Thu, Sep 25, 2025 at 04:54:29PM +0100, Isaac Scott wrote:
> The number of lanes actively used by a MIPI CSI transmitter may differ
> from that which is defined in device tree, due to the source device not
> using all of the connected data lanes on the board. As such, call on
> v4l2_get_active_data_lanes() to check if the driver reports a differing
> number of lanes to the maximum, and use that number of active lanes.
>
> If the number of active data lanes is invalid, or the op is not
> supported, use the maximum number of allowed data lanes.

Is below message better?

media: mipi-csis: Support active data lanes differing from maximum

Call v4l2_get_active_data_lanes() to get the number of lanes actively used
by the MIPI CSI transmitter, which may differs from the maximum defined in
the device tree.

If the driver reports an invalid number of active lanes, or the
operation is not supported, fall back to the maximum number of allowed
data lanes

Frank
>
> Signed-off-by: Isaac Scott <isaac.scott@ideasonboard.com>
> ---
>  drivers/media/platform/nxp/imx-mipi-csis.c | 4 ++++
>  1 file changed, 4 insertions(+)
>
> diff --git a/drivers/media/platform/nxp/imx-mipi-csis.c b/drivers/media/platform/nxp/imx-mipi-csis.c
> index 838a1ad123b5..637ef6e614fa 100644
> --- a/drivers/media/platform/nxp/imx-mipi-csis.c
> +++ b/drivers/media/platform/nxp/imx-mipi-csis.c
> @@ -1034,6 +1034,10 @@ static int mipi_csis_s_stream(struct v4l2_subdev *sd, int enable)
>  	format = v4l2_subdev_state_get_format(state, CSIS_PAD_SINK);
>  	csis_fmt = find_csis_format(format->code);
>
> +	ret = v4l2_get_active_data_lanes(csis->source.pad,
> +					 csis->bus.num_data_lanes);
> +	csis->num_data_lanes = ret < 0 ? csis->bus.num_data_lanes : ret;
> +
>  	ret = mipi_csis_calculate_params(csis, csis_fmt);
>  	if (ret < 0)
>  		goto err_unlock;
>
> --
> 2.43.0
>