Re: [PATCH v5 01/10] media: rcar-vin: Link VINs on Gen3 to a single channel on each CSI-2
From: Niklas Söderlund
Date: Sat Apr 04 2026 - 08:10:02 EST
Hi Tomi,
Thanks for your work.
On 2026-03-11 15:53:14 +0200, Tomi Valkeinen wrote:
> The stream routing will be fully configurable when we add full streams
> support to the rcar pipeline. Thus there is no need for the user to be
> able to link VINs to different CSI-2 channels. In fact, allowing e.g.
> VIN0 to be connected to CSI-2 channel 3 would be wrong, as the hardware
> doesn't allow that.
>
> Change rvin_csi2_create_link() so that it creates media links only
> between matching VINs and CSI-2 channels (VIN0 - channel 0, VIN1 -
> channel 1, etc.).
>
> Signed-off-by: Tomi Valkeinen <tomi.valkeinen+renesas@xxxxxxxxxxxxxxxx>
Reviewed-by: Niklas Söderlund <niklas.soderlund+renesas@xxxxxxxxxxxx>
I think you should break this out of the streams series so we can merge
it before streams are enabled by default in the API.
> ---
> .../media/platform/renesas/rcar-vin/rcar-core.c | 27 ++++++++++++----------
> 1 file changed, 15 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/media/platform/renesas/rcar-vin/rcar-core.c b/drivers/media/platform/renesas/rcar-vin/rcar-core.c
> index c8d564aa1eba..2fcea715101c 100644
> --- a/drivers/media/platform/renesas/rcar-vin/rcar-core.c
> +++ b/drivers/media/platform/renesas/rcar-vin/rcar-core.c
> @@ -673,23 +673,26 @@ static int rvin_csi2_create_link(struct rvin_group *group, unsigned int id,
> struct media_entity *source = &group->remotes[route->csi].subdev->entity;
> struct media_entity *sink = &group->vin[id]->vdev.entity;
> struct media_pad *sink_pad = &sink->pads[0];
> + struct media_pad *source_pad;
> + unsigned int source_idx;
> unsigned int channel;
> - int ret;
>
> - for (channel = 0; channel < 4; channel++) {
> - unsigned int source_idx = rvin_group_csi_channel_to_pad(channel);
> - struct media_pad *source_pad = &source->pads[source_idx];
> + /*
> + * The channels from CSI-2 blocks and the VIN groups have a set of
> + * hardcoded routing options to choose from. We only support the routing
> + * where all VINs in a group are connected to the same CSI-2 block,
> + * and the Nth VIN in the group is connected to the Nth CSI-2 channel.
> + */
>
> - /* Skip if link already exists. */
> - if (media_entity_find_link(source_pad, sink_pad))
> - continue;
> + channel = id % 4;
> + source_idx = rvin_group_csi_channel_to_pad(channel);
> + source_pad = &source->pads[source_idx];
>
> - ret = media_create_pad_link(source, source_idx, sink, 0, 0);
> - if (ret)
> - return ret;
> - }
> + /* Skip if link already exists. */
> + if (media_entity_find_link(source_pad, sink_pad))
> + return 0;
>
> - return 0;
> + return media_create_pad_link(source, source_idx, sink, 0, 0);
> }
>
> static int rvin_parallel_setup_links(struct rvin_group *group)
>
> --
> 2.43.0
>
--
Kind Regards,
Niklas Söderlund