[PATCH v3 12/15] media: rcar-csi2: Add more stream support to rcsi2_calc_mbps()

Tomi Valkeinen posted 15 patches 6 months, 2 weeks ago
There is a newer version of this series
[PATCH v3 12/15] media: rcar-csi2: Add more stream support to rcsi2_calc_mbps()
Posted by Tomi Valkeinen 6 months, 2 weeks ago
In the case where link-freq is not available, make sure we fail if there
are more than one stream configured, and also use the correct stream
number for that single stream.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen+renesas@ideasonboard.com>
---
 drivers/media/platform/renesas/rcar-csi2.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/media/platform/renesas/rcar-csi2.c b/drivers/media/platform/renesas/rcar-csi2.c
index 65c7f3040696..b9f83aae725a 100644
--- a/drivers/media/platform/renesas/rcar-csi2.c
+++ b/drivers/media/platform/renesas/rcar-csi2.c
@@ -1018,17 +1018,22 @@ static int rcsi2_calc_mbps(struct rcar_csi2 *priv,
 	 */
 	freq = v4l2_get_link_freq(remote_pad, 0, 0);
 	if (freq < 0) {
+		struct v4l2_subdev_route *route = &state->routing.routes[0];
 		const struct rcar_csi2_format *format;
 		struct v4l2_mbus_framefmt *fmt;
 		unsigned int lanes;
 		unsigned int bpp;
 		int ret;
 
+		if (state->routing.num_routes > 1)
+			return -EINVAL;
+
 		ret = rcsi2_get_active_lanes(priv, &lanes);
 		if (ret)
 			return ret;
 
-		fmt = v4l2_subdev_state_get_format(state, RCAR_CSI2_SINK, 0);
+		fmt = v4l2_subdev_state_get_format(state, route->sink_pad,
+						   route->sink_stream);
 		if (!fmt)
 			return -EINVAL;
 

-- 
2.43.0
Re: [PATCH v3 12/15] media: rcar-csi2: Add more stream support to rcsi2_calc_mbps()
Posted by Niklas Söderlund 6 months, 1 week ago
Hi Tomi,

Thanks for your patch.

On 2025-05-30 16:50:41 +0300, Tomi Valkeinen wrote:
> In the case where link-freq is not available, make sure we fail if there
> are more than one stream configured, and also use the correct stream
> number for that single stream.
> 
> Signed-off-by: Tomi Valkeinen <tomi.valkeinen+renesas@ideasonboard.com>

With Laurent's comments addressed,

Reviewed-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>

> ---
>  drivers/media/platform/renesas/rcar-csi2.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/media/platform/renesas/rcar-csi2.c b/drivers/media/platform/renesas/rcar-csi2.c
> index 65c7f3040696..b9f83aae725a 100644
> --- a/drivers/media/platform/renesas/rcar-csi2.c
> +++ b/drivers/media/platform/renesas/rcar-csi2.c
> @@ -1018,17 +1018,22 @@ static int rcsi2_calc_mbps(struct rcar_csi2 *priv,
>  	 */
>  	freq = v4l2_get_link_freq(remote_pad, 0, 0);
>  	if (freq < 0) {
> +		struct v4l2_subdev_route *route = &state->routing.routes[0];
>  		const struct rcar_csi2_format *format;
>  		struct v4l2_mbus_framefmt *fmt;
>  		unsigned int lanes;
>  		unsigned int bpp;
>  		int ret;
>  
> +		if (state->routing.num_routes > 1)
> +			return -EINVAL;
> +
>  		ret = rcsi2_get_active_lanes(priv, &lanes);
>  		if (ret)
>  			return ret;
>  
> -		fmt = v4l2_subdev_state_get_format(state, RCAR_CSI2_SINK, 0);
> +		fmt = v4l2_subdev_state_get_format(state, route->sink_pad,
> +						   route->sink_stream);
>  		if (!fmt)
>  			return -EINVAL;
>  
> 
> -- 
> 2.43.0
> 

-- 
Kind Regards,
Niklas Söderlund
Re: [PATCH v3 12/15] media: rcar-csi2: Add more stream support to rcsi2_calc_mbps()
Posted by Laurent Pinchart 6 months, 2 weeks ago
Hi Tomi,

Thank you for the patch.

On Fri, May 30, 2025 at 04:50:41PM +0300, Tomi Valkeinen wrote:
> In the case where link-freq is not available, make sure we fail if there
> are more than one stream configured, and also use the correct stream
> number for that single stream.
> 
> Signed-off-by: Tomi Valkeinen <tomi.valkeinen+renesas@ideasonboard.com>
> ---
>  drivers/media/platform/renesas/rcar-csi2.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/media/platform/renesas/rcar-csi2.c b/drivers/media/platform/renesas/rcar-csi2.c
> index 65c7f3040696..b9f83aae725a 100644
> --- a/drivers/media/platform/renesas/rcar-csi2.c
> +++ b/drivers/media/platform/renesas/rcar-csi2.c
> @@ -1018,17 +1018,22 @@ static int rcsi2_calc_mbps(struct rcar_csi2 *priv,
>  	 */
>  	freq = v4l2_get_link_freq(remote_pad, 0, 0);
>  	if (freq < 0) {
> +		struct v4l2_subdev_route *route = &state->routing.routes[0];

const

>  		const struct rcar_csi2_format *format;
>  		struct v4l2_mbus_framefmt *fmt;
>  		unsigned int lanes;
>  		unsigned int bpp;
>  		int ret;
>  
> +		if (state->routing.num_routes > 1)
> +			return -EINVAL;

Do we have to guard against the case where there would be no route ?

> +
>  		ret = rcsi2_get_active_lanes(priv, &lanes);
>  		if (ret)
>  			return ret;
>  
> -		fmt = v4l2_subdev_state_get_format(state, RCAR_CSI2_SINK, 0);
> +		fmt = v4l2_subdev_state_get_format(state, route->sink_pad,
> +						   route->sink_stream);
>  		if (!fmt)
>  			return -EINVAL;
>  

-- 
Regards,

Laurent Pinchart
Re: [PATCH v3 12/15] media: rcar-csi2: Add more stream support to rcsi2_calc_mbps()
Posted by Tomi Valkeinen 9 hours ago
Hi,

On 02/06/2025 16:28, Laurent Pinchart wrote:
> Hi Tomi,
> 
> Thank you for the patch.
> 
> On Fri, May 30, 2025 at 04:50:41PM +0300, Tomi Valkeinen wrote:
>> In the case where link-freq is not available, make sure we fail if there
>> are more than one stream configured, and also use the correct stream
>> number for that single stream.
>>
>> Signed-off-by: Tomi Valkeinen <tomi.valkeinen+renesas@ideasonboard.com>
>> ---
>>  drivers/media/platform/renesas/rcar-csi2.c | 7 ++++++-
>>  1 file changed, 6 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/media/platform/renesas/rcar-csi2.c b/drivers/media/platform/renesas/rcar-csi2.c
>> index 65c7f3040696..b9f83aae725a 100644
>> --- a/drivers/media/platform/renesas/rcar-csi2.c
>> +++ b/drivers/media/platform/renesas/rcar-csi2.c
>> @@ -1018,17 +1018,22 @@ static int rcsi2_calc_mbps(struct rcar_csi2 *priv,
>>  	 */
>>  	freq = v4l2_get_link_freq(remote_pad, 0, 0);
>>  	if (freq < 0) {
>> +		struct v4l2_subdev_route *route = &state->routing.routes[0];
> 
> const

Ok.

>>  		const struct rcar_csi2_format *format;
>>  		struct v4l2_mbus_framefmt *fmt;
>>  		unsigned int lanes;
>>  		unsigned int bpp;
>>  		int ret;
>>  
>> +		if (state->routing.num_routes > 1)
>> +			return -EINVAL;
> 
> Do we have to guard against the case where there would be no route ?

No, but I think it still makes sense to use != here (and in other
similar places). Just in case. I'll do that change.

 Tomi

>> +
>>  		ret = rcsi2_get_active_lanes(priv, &lanes);
>>  		if (ret)
>>  			return ret;
>>  
>> -		fmt = v4l2_subdev_state_get_format(state, RCAR_CSI2_SINK, 0);
>> +		fmt = v4l2_subdev_state_get_format(state, route->sink_pad,
>> +						   route->sink_stream);
>>  		if (!fmt)
>>  			return -EINVAL;
>>  
>