diff mbox series

[04/19] media: adv748x: Propagate format to opposite stream

Message ID 20240430103956.60190-5-jacopo.mondi@ideasonboard.com
State New
Headers show
Series [01/19] media: adv748x: Add support for active state | expand

Commit Message

Jacopo Mondi April 30, 2024, 10:39 a.m. UTC
Now that the adv748x-csi2 driver supports streams and routing, when a
format is set on the sink pad, it gets propagated to the connected stream
on the source pad.

Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
---
 drivers/media/i2c/adv748x/adv748x-csi2.c | 23 ++++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)

Comments

Laurent Pinchart May 2, 2024, 5:41 p.m. UTC | #1
Hi Jacopo,

Thank you for the patch.

On Tue, Apr 30, 2024 at 12:39:40PM +0200, Jacopo Mondi wrote:
> Now that the adv748x-csi2 driver supports streams and routing, when a
> format is set on the sink pad, it gets propagated to the connected stream
> on the source pad.

As commented in the review of 01/19, this change belongs to that patch.

> Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
> ---
>  drivers/media/i2c/adv748x/adv748x-csi2.c | 23 ++++++++++++-----------
>  1 file changed, 12 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/media/i2c/adv748x/adv748x-csi2.c b/drivers/media/i2c/adv748x/adv748x-csi2.c
> index d929db7e8ef2..ace4e1d904d9 100644
> --- a/drivers/media/i2c/adv748x/adv748x-csi2.c
> +++ b/drivers/media/i2c/adv748x/adv748x-csi2.c
> @@ -167,20 +167,21 @@ static int adv748x_csi2_set_format(struct v4l2_subdev *sd,
>  				   struct v4l2_subdev_state *sd_state,
>  				   struct v4l2_subdev_format *sdformat)
>  {
> -	struct v4l2_mbus_framefmt *mbusformat;
> +	struct v4l2_mbus_framefmt *fmt;
>  
> -	mbusformat = v4l2_subdev_state_get_format(sd_state, sdformat->pad);
> -
> -	/* Format on the source pad is always copied from the sink one. */
> -	if (sdformat->pad == ADV748X_CSI2_SOURCE) {
> -		const struct v4l2_mbus_framefmt *sink_fmt;
> +	/*
> +	 * The format set on the sink pad is propagated to the other end
> +	 * of the active route.
> +	 */
> +	if (sdformat->pad == ADV748X_CSI2_SOURCE)
> +		return -EINVAL;
>  
> -		sink_fmt = v4l2_subdev_state_get_format(sd_state,
> -							ADV748X_CSI2_SINK);
> -		sdformat->format = *sink_fmt;
> -	}
> +	fmt = v4l2_subdev_state_get_format(sd_state, sdformat->pad);
> +	*fmt = sdformat->format;
>  
> -	*mbusformat = sdformat->format;
> +	fmt = v4l2_subdev_state_get_opposite_stream_format(sd_state,
> +							   sdformat->pad, 0);
> +	*fmt = sdformat->format;
>  
>  	return 0;
>  }
diff mbox series

Patch

diff --git a/drivers/media/i2c/adv748x/adv748x-csi2.c b/drivers/media/i2c/adv748x/adv748x-csi2.c
index d929db7e8ef2..ace4e1d904d9 100644
--- a/drivers/media/i2c/adv748x/adv748x-csi2.c
+++ b/drivers/media/i2c/adv748x/adv748x-csi2.c
@@ -167,20 +167,21 @@  static int adv748x_csi2_set_format(struct v4l2_subdev *sd,
 				   struct v4l2_subdev_state *sd_state,
 				   struct v4l2_subdev_format *sdformat)
 {
-	struct v4l2_mbus_framefmt *mbusformat;
+	struct v4l2_mbus_framefmt *fmt;
 
-	mbusformat = v4l2_subdev_state_get_format(sd_state, sdformat->pad);
-
-	/* Format on the source pad is always copied from the sink one. */
-	if (sdformat->pad == ADV748X_CSI2_SOURCE) {
-		const struct v4l2_mbus_framefmt *sink_fmt;
+	/*
+	 * The format set on the sink pad is propagated to the other end
+	 * of the active route.
+	 */
+	if (sdformat->pad == ADV748X_CSI2_SOURCE)
+		return -EINVAL;
 
-		sink_fmt = v4l2_subdev_state_get_format(sd_state,
-							ADV748X_CSI2_SINK);
-		sdformat->format = *sink_fmt;
-	}
+	fmt = v4l2_subdev_state_get_format(sd_state, sdformat->pad);
+	*fmt = sdformat->format;
 
-	*mbusformat = sdformat->format;
+	fmt = v4l2_subdev_state_get_opposite_stream_format(sd_state,
+							   sdformat->pad, 0);
+	*fmt = sdformat->format;
 
 	return 0;
 }