Linux-Media Archive mirror
 help / color / mirror / Atom feed
From: "Niklas Söderlund" <niklas.soderlund+renesas@ragnatech.se>
To: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
	Sakari Ailus <sakari.ailus@linux.intel.com>,
	Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>,
	Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>,
	linux-media@vger.kernel.org, linux-renesas-soc@vger.kernel.org
Subject: Re: [PATCH 15/19] media: rcar-csi2: Add support for multiplexed streams
Date: Thu, 2 May 2024 16:23:16 +0200	[thread overview]
Message-ID: <20240502142316.GA3927860@ragnatech.se> (raw)
In-Reply-To: <20240430103956.60190-16-jacopo.mondi@ideasonboard.com>

Hi Jacopo,

Thanks for your work.

On 2024-04-30 12:39:51 +0200, Jacopo Mondi wrote:
> Create and initialize the v4l2_subdev_state for the R-Car CSI-2 receiver
> in order to prepare to support multiplexed transmitters.
> 
> Create the subdevice state with v4l2_subdev_init_finalize() and
> implement the init_state() operation to guarantee the state is initialized.
> 
> The routing table within the R-Car CSI-2 receiver is fixed, streams
> received on source_stream X will be directed to pad (X + 1) by default.
> Initialize a static routing table with such routes set as active.
> 
> While at it, disable runtime_pm() in the probe() function error path.

Can we break this out in a separate patch? As the multiplexed stream 
work will not be ready for v6.10 if I understood the tendencies 
correctly (?), we can at least fix this issue before that.

> 
> Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
> ---
>  drivers/media/platform/renesas/rcar-csi2.c | 74 +++++++++++++++++++++-
>  1 file changed, 72 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/media/platform/renesas/rcar-csi2.c b/drivers/media/platform/renesas/rcar-csi2.c
> index 582d5e35db0e..82dc0b92b8d3 100644
> --- a/drivers/media/platform/renesas/rcar-csi2.c
> +++ b/drivers/media/platform/renesas/rcar-csi2.c
> @@ -1226,6 +1226,65 @@ static const struct v4l2_subdev_ops rcar_csi2_subdev_ops = {
>  	.pad	= &rcar_csi2_pad_ops,
>  };
>  
> +static int rcsi2_init_state(struct v4l2_subdev *sd,
> +			    struct v4l2_subdev_state *state)
> +{
> +	/*
> +	 * Routing is fixed for this device: streams sent on sink_stream X
> +	 * are directed to pad (X + 1). Which streams goes to the next
> +	 * processing block (VIN) is controlled by link enablement between the
> +	 * CSI-2 and the VIN itself and not by the CSI-2 routing table.
> +	 *
> +	 * The routing table is then fixed, as stream X will be directed to
> +	 * csi:(X + 1)/0 and will be transmitted to VINs the on media link
> +	 * csi2:(x + 1)->vin:0.
> +	 *
> +	 * For example, to route stream #3 to VIN #1 : "csi2:4/0 -> vin1:0" and
> +	 * to route stream #2 to VIN #4 : "csi2:3/0 -> vin4:0".
> +	 */
> +	struct v4l2_subdev_route routes[] = {
> +		{
> +			.sink_pad = RCAR_CSI2_SINK,
> +			.sink_stream = 0,
> +			.source_pad = RCAR_CSI2_SOURCE_VC0,
> +			.source_stream = 0,
> +			.flags = V4L2_SUBDEV_ROUTE_FL_ACTIVE,
> +		},
> +		{
> +			.sink_pad = RCAR_CSI2_SINK,
> +			.sink_stream = 1,
> +			.source_pad = RCAR_CSI2_SOURCE_VC1,
> +			.source_stream = 0,
> +			.flags = V4L2_SUBDEV_ROUTE_FL_ACTIVE,
> +		},
> +		{
> +			.sink_pad = RCAR_CSI2_SINK,
> +			.sink_stream = 2,
> +			.source_pad = RCAR_CSI2_SOURCE_VC2,
> +			.source_stream = 0,
> +			.flags = V4L2_SUBDEV_ROUTE_FL_ACTIVE,
> +		},
> +		{
> +			.sink_pad = RCAR_CSI2_SINK,
> +			.sink_stream = 3,
> +			.source_pad = RCAR_CSI2_SOURCE_VC3,
> +			.source_stream = 0,
> +			.flags = V4L2_SUBDEV_ROUTE_FL_ACTIVE,
> +		},
> +	};
> +
> +	struct v4l2_subdev_krouting routing = {
> +		.num_routes = ARRAY_SIZE(routes),
> +		.routes = routes,
> +	};

Should not the two structs above be static const as you return a pointer 
to them?

> +
> +	return v4l2_subdev_set_routing(sd, state, &routing);
> +}
> +
> +static const struct v4l2_subdev_internal_ops rcar_csi2_internal_ops = {
> +	.init_state = rcsi2_init_state,
> +};
> +
>  static irqreturn_t rcsi2_irq(int irq, void *data)
>  {
>  	struct rcar_csi2 *priv = data;
> @@ -1887,11 +1946,13 @@ static int rcsi2_probe(struct platform_device *pdev)
>  
>  	priv->subdev.owner = THIS_MODULE;
>  	priv->subdev.dev = &pdev->dev;
> +	priv->subdev.internal_ops = &rcar_csi2_internal_ops;
>  	v4l2_subdev_init(&priv->subdev, &rcar_csi2_subdev_ops);
>  	v4l2_set_subdevdata(&priv->subdev, &pdev->dev);
>  	snprintf(priv->subdev.name, sizeof(priv->subdev.name), "%s %s",
>  		 KBUILD_MODNAME, dev_name(&pdev->dev));
> -	priv->subdev.flags = V4L2_SUBDEV_FL_HAS_DEVNODE;
> +	priv->subdev.flags = V4L2_SUBDEV_FL_HAS_DEVNODE |
> +			     V4L2_SUBDEV_FL_STREAMS;
>  
>  	priv->subdev.entity.function = MEDIA_ENT_F_PROC_VIDEO_PIXEL_FORMATTER;
>  	priv->subdev.entity.ops = &rcar_csi2_entity_ops;
> @@ -1912,14 +1973,22 @@ static int rcsi2_probe(struct platform_device *pdev)
>  
>  	pm_runtime_enable(&pdev->dev);
>  
> +	ret = v4l2_subdev_init_finalize(&priv->subdev);
> +	if (ret)
> +		goto error_pm_runtime;
> +
>  	ret = v4l2_async_register_subdev(&priv->subdev);
>  	if (ret < 0)
> -		goto error_async;
> +		goto error_subdev;
>  
>  	dev_info(priv->dev, "%d lanes found\n", priv->lanes);
>  
>  	return 0;
>  
> +error_subdev:
> +	v4l2_subdev_cleanup(&priv->subdev);
> +error_pm_runtime:
> +	pm_runtime_disable(&pdev->dev);
>  error_async:
>  	v4l2_async_nf_unregister(&priv->notifier);
>  	v4l2_async_nf_cleanup(&priv->notifier);
> @@ -1936,6 +2005,7 @@ static void rcsi2_remove(struct platform_device *pdev)
>  	v4l2_async_nf_unregister(&priv->notifier);
>  	v4l2_async_nf_cleanup(&priv->notifier);
>  	v4l2_async_unregister_subdev(&priv->subdev);
> +	v4l2_subdev_cleanup(&priv->subdev);
>  
>  	pm_runtime_disable(&pdev->dev);
>  
> -- 
> 2.44.0
> 

-- 
Kind Regards,
Niklas Söderlund

  reply	other threads:[~2024-05-02 14:23 UTC|newest]

Thread overview: 56+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-30 10:39 [PATCH 00/19] media: renesas: rcar-csi2: Support multiple streams Jacopo Mondi
2024-04-30 10:39 ` [PATCH 01/19] media: adv748x: Add support for active state Jacopo Mondi
2024-05-02 17:34   ` Laurent Pinchart
2024-05-03  7:55     ` Jacopo Mondi
2024-05-03  8:24       ` Laurent Pinchart
2024-04-30 10:39 ` [PATCH 02/19] media: adv748x: Add flags to adv748x_subdev_init() Jacopo Mondi
2024-05-02 17:37   ` Laurent Pinchart
2024-04-30 10:39 ` [PATCH 03/19] media: adv748x: Use V4L2 streams Jacopo Mondi
2024-05-02 17:40   ` Laurent Pinchart
2024-05-03  7:59     ` Jacopo Mondi
2024-05-03  8:31       ` Laurent Pinchart
2024-05-03  8:46         ` Tomi Valkeinen
2024-04-30 10:39 ` [PATCH 04/19] media: adv748x: Propagate format to opposite stream Jacopo Mondi
2024-05-02 17:41   ` Laurent Pinchart
2024-04-30 10:39 ` [PATCH 05/19] media: adv748x: Implement set_routing() Jacopo Mondi
2024-05-02 17:49   ` Laurent Pinchart
2024-05-03  8:02     ` Jacopo Mondi
2024-04-30 10:39 ` [PATCH 06/19] media: adv748x: Use routes to configure VC Jacopo Mondi
2024-05-02 17:51   ` Laurent Pinchart
2024-05-02 17:52     ` Laurent Pinchart
2024-05-03  8:05       ` Jacopo Mondi
2024-04-30 10:39 ` [PATCH 07/19] media: adv748x: Implement .get_frame_desc() Jacopo Mondi
2024-05-02 17:57   ` Laurent Pinchart
2024-04-30 10:39 ` [PATCH 08/19] media: max9286: Add support for subdev active state Jacopo Mondi
2024-05-02 18:10   ` Laurent Pinchart
2024-04-30 10:39 ` [PATCH 09/19] media: max9286: Fix enum_mbus_code Jacopo Mondi
2024-05-02 18:14   ` Laurent Pinchart
2024-04-30 10:39 ` [PATCH 10/19] media: max9286: Use frame interval from subdev state Jacopo Mondi
2024-05-02 18:23   ` Laurent Pinchart
2024-04-30 10:39 ` [PATCH 11/19] media: max9286: Use V4L2 Streams Jacopo Mondi
2024-05-02 18:25   ` Laurent Pinchart
2024-04-30 10:39 ` [PATCH 12/19] media: max9286: Implement .get_frame_desc() Jacopo Mondi
2024-05-02 18:32   ` Laurent Pinchart
2024-04-30 10:39 ` [PATCH 13/19] media: max9286: Implement support for LINK_FREQ Jacopo Mondi
2024-05-02 18:36   ` Laurent Pinchart
2024-04-30 10:39 ` [PATCH 14/19] media: max9286: Implement .get_mbus_config() Jacopo Mondi
2024-05-02 18:37   ` Laurent Pinchart
2024-04-30 10:39 ` [PATCH 15/19] media: rcar-csi2: Add support for multiplexed streams Jacopo Mondi
2024-05-02 14:23   ` Niklas Söderlund [this message]
2024-05-02 18:41     ` Laurent Pinchart
2024-05-03  8:05       ` Jacopo Mondi
2024-04-30 10:39 ` [PATCH 16/19] media: rcar-csi2: Support multiplexed transmitters Jacopo Mondi
2024-05-02 14:30   ` Niklas Söderlund
2024-05-02 21:56     ` Laurent Pinchart
2024-05-03  8:07       ` Jacopo Mondi
2024-04-30 10:39 ` [PATCH 17/19] media: rcar-csi2: Store format in the subdev state Jacopo Mondi
2024-05-02 14:32   ` Niklas Söderlund
2024-05-02 22:00     ` Laurent Pinchart
2024-04-30 10:39 ` [PATCH 18/19] media: rcar-csi2: Implement set_routing Jacopo Mondi
2024-05-02 22:16   ` Laurent Pinchart
2024-04-30 10:39 ` [PATCH 19/19] media: rcar-vin: Fix YUYV8_1X16 handling for CSI-2 Jacopo Mondi
2024-05-02 14:33   ` Niklas Söderlund
2024-05-02 22:16     ` Laurent Pinchart
2024-04-30 11:17 ` [PATCH 00/19] media: renesas: rcar-csi2: Support multiple streams Niklas Söderlund
2024-04-30 11:51   ` Jacopo Mondi
2024-05-02 17:35     ` Laurent Pinchart

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=20240502142316.GA3927860@ragnatech.se \
    --to=niklas.soderlund+renesas@ragnatech.se \
    --cc=jacopo.mondi@ideasonboard.com \
    --cc=kieran.bingham+renesas@ideasonboard.com \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=sakari.ailus@linux.intel.com \
    --cc=tomi.valkeinen@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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).