Re: [PATCH v2 3/6] media: synopsys: csi2rx: implement .get_frame_desc() callback

From: Michael Riesch

Date: Mon Feb 16 2026 - 04:04:03 EST


Hi Frank,

On 2/13/26 21:25, Frank Li wrote:
> Implement the .get_frame_desc() callback to fetch information from the
> remote endpoint.
>
> Signed-off-by: Frank Li <Frank.Li@xxxxxxx>
> ---
> change in v2
> - add csi2rx in subject
> ---
> drivers/media/platform/synopsys/dw-mipi-csi2rx.c | 25 ++++++++++++++++++++++++
> 1 file changed, 25 insertions(+)
>
> diff --git a/drivers/media/platform/synopsys/dw-mipi-csi2rx.c b/drivers/media/platform/synopsys/dw-mipi-csi2rx.c
> index f03fe01280013bf9a832433c6b06dab691bf8f4c..a6d251ca5ad14c5138a6fd0202a970460e64c68f 100644
> --- a/drivers/media/platform/synopsys/dw-mipi-csi2rx.c
> +++ b/drivers/media/platform/synopsys/dw-mipi-csi2rx.c
> @@ -68,6 +68,8 @@ struct dw_mipi_csi2rx_device {
> struct v4l2_async_notifier notifier;
> struct v4l2_subdev sd;
>
> + struct v4l2_subdev *remote_source;
> +
> enum v4l2_mbus_type bus_type;
> u32 lanes_num;
> };
> @@ -429,10 +431,31 @@ static int dw_mipi_csi2rx_disable_streams(struct v4l2_subdev *sd,
> return ret;
> }
>
> +static int
> +dw_mipi_csi2rx_get_frame_desc(struct v4l2_subdev *sd, unsigned int pad,
> + struct v4l2_mbus_frame_desc *fd)
> +{
> + struct dw_mipi_csi2rx_device *csi2 = to_csi2(sd);
> + struct media_pad *remote_pad;
> +
> + if (!csi2->remote_source)
> + return -ENODEV;
> +
> + remote_pad = media_pad_remote_pad_unique(&csi2->pads[DW_MIPI_CSI2RX_PAD_SINK]);
> + if (IS_ERR(remote_pad)) {
> + dev_err(csi2->dev, "can't get source pad of %s (%pe)\n",
> + csi2->remote_source->name, remote_pad);
> + return PTR_ERR(remote_pad);
> + }

You can get the remote subdevice with
remote_sd = media_entity_to_v4l2_subdev(remote_pad->entity);
instead of storing it in the device data.

Best regards,
Michael

> + return v4l2_subdev_call(csi2->remote_source, pad, get_frame_desc,
> + remote_pad->index, fd);
> +}
> +
> static const struct v4l2_subdev_pad_ops dw_mipi_csi2rx_pad_ops = {
> .enum_mbus_code = dw_mipi_csi2rx_enum_mbus_code,
> .get_fmt = v4l2_subdev_get_fmt,
> .set_fmt = dw_mipi_csi2rx_set_fmt,
> + .get_frame_desc = dw_mipi_csi2rx_get_frame_desc,
> .set_routing = dw_mipi_csi2rx_set_routing,
> .enable_streams = dw_mipi_csi2rx_enable_streams,
> .disable_streams = dw_mipi_csi2rx_disable_streams,
> @@ -485,6 +508,8 @@ static int dw_mipi_csi2rx_notifier_bound(struct v4l2_async_notifier *notifier,
> return ret;
> }
>
> + csi2->remote_source = sd;
> +
> return 0;
> }
>
>