From: "Niklas Söderlund" <niklas.soderlund@ragnatech.se>
To: Tomi Valkeinen <tomi.valkeinen+renesas@ideasonboard.com>
Cc: Mauro Carvalho Chehab <mchehab@kernel.org>,
Sakari Ailus <sakari.ailus@linux.intel.com>,
linux-media@vger.kernel.org, linux-renesas-soc@vger.kernel.org,
linux-kernel@vger.kernel.org,
Mauro Carvalho Chehab <mchehab+huawei@kernel.org>,
Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Subject: Re: [PATCH v6 09/11] media: rcar-csi2: Call get_frame_desc to find out VC & DT (Gen3)
Date: Mon, 7 Sep 2026 14:46:52 +0200 [thread overview]
Message-ID: <20260907124652.GH3497753@ragnatech.se> (raw)
In-Reply-To: <20260617-rcar-streams-v6-9-1260eb72dff7@ideasonboard.com>
Hi Tomi,
Thanks for your work.
On 2026-06-17 14:55:02 +0300, Tomi Valkeinen wrote:
> Call get_frame_desc to find out VC & DT, for Gen3 platforms, instead of
> hardcoding the VC routing and deducing the DT based on the mbus format.
>
> If the source subdevice doesn't implement .get_frame_desc, we use a
> fallback case where we assume there's a single stream with VC = 0 and DT
> based on the mbus format.
>
> Signed-off-by: Tomi Valkeinen <tomi.valkeinen+renesas@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
> ---
> drivers/media/platform/renesas/rcar-csi2.c | 111 ++++++++++++++++++-----------
> 1 file changed, 71 insertions(+), 40 deletions(-)
>
> diff --git a/drivers/media/platform/renesas/rcar-csi2.c b/drivers/media/platform/renesas/rcar-csi2.c
> index 0d9e730fa677..8cd38b4cbc7f 100644
> --- a/drivers/media/platform/renesas/rcar-csi2.c
> +++ b/drivers/media/platform/renesas/rcar-csi2.c
> @@ -1069,62 +1069,93 @@ static int rcsi2_calc_mbps(struct rcar_csi2 *priv,
> static int rcsi2_start_receiver_gen3(struct rcar_csi2 *priv,
> struct v4l2_subdev_state *state)
> {
> - const struct v4l2_subdev_route *route;
> - const struct rcar_csi2_format *format;
> - u32 phycnt, vcdt = 0, vcdt2 = 0, fld = 0;
> - const struct v4l2_mbus_framefmt *fmt;
> + u32 phycnt, vcdt = 0, vcdt2 = 0;
> + u32 fld = FLD_DET_SEL(1);
> + struct v4l2_mbus_frame_desc source_fd;
> + struct v4l2_subdev_route *route;
> unsigned int lanes;
> - unsigned int i;
> int mbps, ret;
> + u8 ch = 0;
>
> - /* Use the format on the sink pad to compute the receiver config. */
> + ret = v4l2_subdev_call(priv->remote, pad, get_frame_desc,
> + priv->remote_pad, &source_fd);
> + if (ret && ret != -ENOIOCTLCMD)
> + return ret;
>
> - if (state->routing.num_routes != 1)
> - return -EINVAL;
> + if (ret == -ENOIOCTLCMD) {
> + /* Create a fallback source_fd */
> + struct v4l2_mbus_frame_desc *fd = &source_fd;
> + const struct v4l2_subdev_route *route;
> + const struct rcar_csi2_format *format;
> + struct v4l2_mbus_framefmt *fmt;
>
> - route = &state->routing.routes[0];
> + if (state->routing.num_routes != 1)
> + return -EINVAL;
>
> - fmt = v4l2_subdev_state_get_format(state, route->sink_pad,
> - route->sink_stream);
> - if (!fmt)
> - return -EINVAL;
> + route = &state->routing.routes[0];
>
> - dev_dbg(priv->dev, "Input size (%ux%u%c)\n",
> - fmt->width, fmt->height,
> - fmt->field == V4L2_FIELD_NONE ? 'p' : 'i');
> + fmt = v4l2_subdev_state_get_format(state, route->sink_pad,
> + route->sink_stream);
> + if (!fmt)
> + return -EINVAL;
>
> - /* Code is validated in set_fmt. */
> - format = rcsi2_code_to_fmt(fmt->code);
> - if (!format)
> - return -EINVAL;
> + format = rcsi2_code_to_fmt(fmt->code);
> + if (!format)
> + return -EINVAL;
>
> - /*
> - * Enable all supported CSI-2 channels with virtual channel and
> - * data type matching.
> - *
> - * NOTE: It's not possible to get individual datatype for each
> - * source virtual channel. Once this is possible in V4L2
> - * it should be used here.
> - */
> - for (i = 0; i < priv->info->num_channels; i++) {
> + memset(fd, 0, sizeof(*fd));
> +
> + fd->num_entries = 1;
> + fd->type = V4L2_MBUS_FRAME_DESC_TYPE_CSI2;
> + fd->entry[0].stream = 0;
> + fd->entry[0].pixelcode = fmt->code;
> + fd->entry[0].bus.csi2.vc = 0;
> + fd->entry[0].bus.csi2.dt = format->datatype;
> + }
> +
> + for_each_active_route(&state->routing, route) {
> + const struct v4l2_mbus_frame_desc_entry *source_entry = NULL;
> + const struct v4l2_mbus_framefmt *fmt;
> + unsigned int i;
> u32 vcdt_part;
>
> - if (priv->channel_vc[i] < 0)
> - continue;
> + for (i = 0; i < source_fd.num_entries; i++) {
> + if (source_fd.entry[i].stream == route->sink_stream) {
> + source_entry = &source_fd.entry[i];
> + break;
> + }
> + }
>
> - vcdt_part = VCDT_SEL_VC(priv->channel_vc[i]) | VCDT_VCDTN_EN |
> - VCDT_SEL_DTN_ON | VCDT_SEL_DT(format->datatype);
> + if (!source_entry) {
> + dev_err(priv->dev,
> + "Failed to find stream from source frame desc\n");
> + return -EPIPE;
> + }
> +
> + vcdt_part = VCDT_SEL_VC(source_entry->bus.csi2.vc) |
> + VCDT_VCDTN_EN | VCDT_SEL_DTN_ON |
> + VCDT_SEL_DT(source_entry->bus.csi2.dt);
>
> /* Store in correct reg and offset. */
> - if (i < 2)
> - vcdt |= vcdt_part << ((i % 2) * 16);
> + if (ch < 2)
> + vcdt |= vcdt_part << ((ch % 2) * 16);
> else
> - vcdt2 |= vcdt_part << ((i % 2) * 16);
> - }
> + vcdt2 |= vcdt_part << ((ch % 2) * 16);
> +
> + fmt = v4l2_subdev_state_get_format(state, RCAR_CSI2_SINK,
> + route->sink_stream);
> + if (!fmt)
> + return -EINVAL;
> +
> + dev_dbg(priv->dev, "Input size (%ux%u%c)\n",
> + fmt->width, fmt->height,
> + fmt->field == V4L2_FIELD_NONE ? 'p' : 'i');
>
> - if (fmt->field == V4L2_FIELD_ALTERNATE)
> - fld = FLD_DET_SEL(1) | FLD_FLD_EN(3) | FLD_FLD_EN(2) |
> - FLD_FLD_EN(1) | FLD_FLD_EN(0);
> + if (fmt->field == V4L2_FIELD_ALTERNATE)
> + fld |= FLD_FLD_EN(ch);
> +
> + ch++;
> + }
>
> /*
> * Get the number of active data lanes inspecting the remote mbus
>
> --
> 2.43.0
>
--
Kind Regards,
Niklas Söderlund
next prev parent reply other threads:[~2026-09-07 12:46 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-17 11:54 [PATCH v6 00/11] media: rcar: Streams support Tomi Valkeinen
2026-06-17 11:54 ` [PATCH v6 01/11] media: rcar-vin: Fix comment related to stride handling Tomi Valkeinen
2026-09-07 10:37 ` Niklas Söderlund
2026-06-17 11:54 ` [PATCH v6 02/11] media: rcar-vin: Link VINs on Gen3 to a single channel on each CSI-2 Tomi Valkeinen
2026-06-17 11:54 ` [PATCH v6 03/11] media: rcar-isp: Move {enable|disable}_streams() calls Tomi Valkeinen
2026-09-07 11:30 ` Niklas Söderlund
2026-06-17 11:54 ` [PATCH v6 04/11] media: rcar-csi2: " Tomi Valkeinen
2026-09-07 11:33 ` Niklas Söderlund
2026-06-17 11:54 ` [PATCH v6 05/11] media: rcar-csi2: Switch to Streams API Tomi Valkeinen
2026-09-07 12:39 ` Niklas Söderlund
2026-06-17 11:54 ` [PATCH v6 06/11] media: rcar-isp: " Tomi Valkeinen
2026-09-07 13:29 ` Niklas Söderlund
2026-06-17 11:55 ` [PATCH v6 07/11] media: rcar-csi2: Add .get_frame_desc op Tomi Valkeinen
2026-09-07 12:45 ` Niklas Söderlund
2026-06-17 11:55 ` [PATCH v6 08/11] media: rcar-isp: Call get_frame_desc to find out VC & DT Tomi Valkeinen
2026-09-07 14:45 ` Niklas Söderlund
2026-06-17 11:55 ` [PATCH v6 09/11] media: rcar-csi2: Call get_frame_desc to find out VC & DT (Gen3) Tomi Valkeinen
2026-09-07 12:46 ` Niklas Söderlund [this message]
2026-06-17 11:55 ` [PATCH v6 10/11] media: rcar-csi2: Add full streams support Tomi Valkeinen
2026-09-07 12:48 ` Niklas Söderlund
2026-06-17 11:55 ` [PATCH v6 11/11] media: rcar-isp: " Tomi Valkeinen
2026-09-07 19:21 ` Niklas Söderlund
2026-09-07 19:25 ` [PATCH v6 00/11] media: rcar: Streams support Niklas Söderlund
2026-09-08 6:28 ` Tomi Valkeinen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260907124652.GH3497753@ragnatech.se \
--to=niklas.soderlund@ragnatech.se \
--cc=jacopo.mondi@ideasonboard.com \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=linux-renesas-soc@vger.kernel.org \
--cc=mchehab+huawei@kernel.org \
--cc=mchehab@kernel.org \
--cc=sakari.ailus@linux.intel.com \
--cc=tomi.valkeinen+renesas@ideasonboard.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®