public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
From: Rishikesh Donadkar <r-donadkar@ti.com>
To: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>,
	<jai.luthra@linux.dev>, <laurent.pinchart@ideasonboard.com>,
	<mripard@kernel.org>
Cc: <y-abhilashchandra@ti.com>, <devarsht@ti.com>, <s-jain1@ti.com>,
	<vigneshr@ti.com>, <mchehab@kernel.org>, <robh@kernel.org>,
	<krzk+dt@kernel.org>, <p.zabel@pengutronix.de>,
	<conor+dt@kernel.org>, <sakari.ailus@linux.intel.com>,
	<hverkuil-cisco@xs4all.nl>, <jai.luthra@ideasonboard.com>,
	<changhuang.liang@starfivetech.com>, <jack.zhu@starfivetech.com>,
	<sjoerd@collabora.com>, <dan.carpenter@linaro.org>,
	<hverkuil+cisco@kernel.org>, <linux-kernel@vger.kernel.org>,
	<linux-media@vger.kernel.org>, <devicetree@vger.kernel.org>
Subject: Re: [PATCH v10 12/18] media: cadence: csi2rx: Use the stream from route to get format
Date: Fri, 30 Jan 2026 09:37:47 +0530	[thread overview]
Message-ID: <d19d1cd1-b7fa-43ab-9ef9-ade414efc508@ti.com> (raw)
In-Reply-To: <55b08e0e-1921-4d37-a716-ff60852ec51b@ideasonboard.com>


On 23/01/26 13:23, Tomi Valkeinen wrote:
> Hi,
Hi Tomi,
>
> On 21/01/2026 15:54, Rishikesh Donadkar wrote:
>> In multistream configurations, different streams can have different
>> formats. Update the driver to use the stream number from the routing
>> configuration when retrieving formats instead of hardcoding stream 0
>> or ignoring streams.
>>
>> In csi2rx_configure_ext_dphy(), use the sink_stream from the first
>> route instead of always using stream 0.
>>
>> In cdns_csi2rx_negotiate_ppc(), iterate through all active routes
>> for the requested pad and retrieve the format using both pad and
>> stream information.
>>
>> Signed-off-by: Rishikesh Donadkar <r-donadkar@ti.com>
>> ---
>>   drivers/media/platform/cadence/cdns-csi2rx.c | 34 ++++++++++++++++----
>>   1 file changed, 28 insertions(+), 6 deletions(-)
> So if I understand this right, v9 was working by luck, as it was always
> using stream 0 format (and expected stream 0 to be there)?


Yes, when I tested using IMX219 connected to the port 1 of the fpd-link 
board, I faced an issue where the v4l2_subdev_state_get_format() 
returned NULL when no stream was passed to it, here the default 0 was 
considered but the fpd-link driver which assigns stream number wrt ports 
assigned it as 1.

>
> Two thoughts here:
> - This should be merged to the previous patch, shouldn't it?


Yes, will do that

> - Are you now testing with different resolutions, fps, etc on the
> fpd-link ports?


I will test the v11 with multiple resolutions and formats. I will 
mention the tested ones in the cover letter


Rishikesh

>
> Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
>
>   Tomi
>
>> diff --git a/drivers/media/platform/cadence/cdns-csi2rx.c b/drivers/media/platform/cadence/cdns-csi2rx.c
>> index 175366f889115..db9871fdbe3a4 100644
>> --- a/drivers/media/platform/cadence/cdns-csi2rx.c
>> +++ b/drivers/media/platform/cadence/cdns-csi2rx.c
>> @@ -279,6 +279,7 @@ static int csi2rx_configure_ext_dphy(struct csi2rx_priv *csi2rx)
>>   	struct v4l2_mbus_framefmt *framefmt;
>>   	struct v4l2_subdev_state *state;
>>   	const struct csi2rx_fmt *fmt;
>> +	struct v4l2_subdev_route *route;
>>   	int source_pad = csi2rx->source_pad;
>>   	struct media_pad *pad = &csi2rx->source_subdev->entity.pads[source_pad];
>>   	s64 link_freq;
>> @@ -296,7 +297,9 @@ static int csi2rx_configure_ext_dphy(struct csi2rx_priv *csi2rx)
>>   	if (state->routing.num_routes > 1) {
>>   		bpp = 0;
>>   	} else {
>> -		framefmt = v4l2_subdev_state_get_format(state, CSI2RX_PAD_SINK, 0);
>> +		route = &state->routing.routes[0];
>> +		framefmt = v4l2_subdev_state_get_format(state, CSI2RX_PAD_SINK,
>> +							route->sink_stream);
>>   		if (!framefmt) {
>>   			dev_err(csi2rx->dev, "Did not find active sink format\n");
>>   			return -EINVAL;
>> @@ -706,25 +709,44 @@ int cdns_csi2rx_negotiate_ppc(struct v4l2_subdev *subdev, unsigned int pad,
>>   {
>>   	struct csi2rx_priv *csi2rx = v4l2_subdev_to_csi2rx(subdev);
>>   	const struct csi2rx_fmt *csi_fmt;
>> +	struct v4l2_subdev_route *route;
>>   	struct v4l2_subdev_state *state;
>>   	struct v4l2_mbus_framefmt *fmt;
>> +	int ret = 0;
>>   
>>   	if (!ppc || pad < CSI2RX_PAD_SOURCE_STREAM0 || pad >= CSI2RX_PAD_MAX)
>>   		return -EINVAL;
>>   
>>   	state = v4l2_subdev_lock_and_get_active_state(subdev);
>> -	fmt = v4l2_subdev_state_get_format(state, pad);
>> -	csi_fmt = csi2rx_get_fmt_by_code(fmt->code);
>> +	/* Check all streams on requested pad */
>> +	for_each_active_route(&state->routing, route) {
>> +		if (route->source_pad != pad)
>> +			continue;
>> +
>> +		fmt = v4l2_subdev_state_get_format(state, route->source_pad,
>> +						   route->source_stream);
>> +		if (!fmt) {
>> +			ret = -EPIPE;
>> +			*ppc = 1;
>> +			break;
>> +		}
>>   
>> -	/* Reduce requested PPC if it is too high */
>> -	*ppc = min(*ppc, csi_fmt->max_pixels);
>> +		csi_fmt = csi2rx_get_fmt_by_code(fmt->code);
>> +		if (!csi_fmt) {
>> +			ret = -EINVAL;
>> +			*ppc = 1;
>> +			break;
>> +		}
>>   
>> +		/* Reduce requested PPC if it is too high for this stream */
>> +		*ppc = min(*ppc, csi_fmt->max_pixels);
>> +	}
>>   	v4l2_subdev_unlock_state(state);
>>   
>>   	csi2rx->num_pixels[pad - CSI2RX_PAD_SOURCE_STREAM0] =
>>   		CSI2RX_STREAM_CFG_NUM_PIXELS(*ppc);
>>   
>> -	return 0;
>> +	return ret;
>>   }
>>   EXPORT_SYMBOL_FOR_MODULES(cdns_csi2rx_negotiate_ppc, "j721e-csi2rx");
>>   

  reply	other threads:[~2026-01-30  4:07 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-21 13:54 [PATCH v10 00/18] media: cadence,ti: CSI2RX Multistream Support Rishikesh Donadkar
2026-01-21 13:54 ` [PATCH v10 01/18] media: ti: j721e-csi2rx: Remove word size alignment on frame width Rishikesh Donadkar
2026-01-21 13:54 ` [PATCH v10 02/18] dt-bindings: media: ti,j721e-csi2rx-shim: Support 32 dma chans Rishikesh Donadkar
2026-01-21 13:54 ` [PATCH v10 03/18] media: ti: j721e-csi2rx: separate out device and context Rishikesh Donadkar
2026-01-21 13:54 ` [PATCH v10 04/18] media: ti: j721e-csi2rx: prepare SHIM code for multiple contexts Rishikesh Donadkar
2026-01-21 13:54 ` [PATCH v10 05/18] media: ti: j721e-csi2rx: allocate DMA channel based on context index Rishikesh Donadkar
2026-01-21 13:54 ` [PATCH v10 06/18] media: ti: j721e-csi2rx: add a subdev for the core device Rishikesh Donadkar
2026-01-23  8:40   ` Tomi Valkeinen
2026-01-21 13:54 ` [PATCH v10 07/18] media: cadence: csi2rx: Move to .enable/disable_streams API Rishikesh Donadkar
2026-01-21 13:54 ` [PATCH v10 08/18] media: ti: j721e-csi2rx: get number of contexts from device tree Rishikesh Donadkar
2026-01-21 13:54 ` [PATCH v10 09/18] media: cadence: csi2rx: add get_frame_desc wrapper Rishikesh Donadkar
2026-01-21 13:54 ` [PATCH v10 10/18] media: ti: j721e-csi2rx: add support for processing virtual channels Rishikesh Donadkar
2026-01-23  8:50   ` Tomi Valkeinen
2026-01-30  4:00     ` Rishikesh Donadkar
2026-01-21 13:54 ` [PATCH v10 11/18] media: cadence: csi2rx: add multistream support Rishikesh Donadkar
2026-01-21 13:54 ` [PATCH v10 12/18] media: cadence: csi2rx: Use the stream from route to get format Rishikesh Donadkar
2026-01-23  7:53   ` Tomi Valkeinen
2026-01-30  4:07     ` Rishikesh Donadkar [this message]
2026-01-21 13:54 ` [PATCH v10 13/18] media: ti: j721e-csi2rx: add multistream support Rishikesh Donadkar
2026-01-23  9:26   ` Tomi Valkeinen
2026-01-30  4:09     ` Rishikesh Donadkar
2026-01-21 13:54 ` [PATCH v10 14/18] media: ti: j721e-csi2rx: Submit all available buffers Rishikesh Donadkar
2026-01-21 13:54 ` [PATCH v10 15/18] media: ti: j721e-csi2rx: Change the drain architecture for multistream Rishikesh Donadkar
2026-01-23  9:29   ` Tomi Valkeinen
2026-01-21 13:54 ` [PATCH v10 16/18] media: cadence: csi2rx: Support runtime PM Rishikesh Donadkar
2026-01-21 13:54 ` [PATCH v10 17/18] media: ti: j721e-csi2rx: Support runtime suspend Rishikesh Donadkar
2026-01-21 13:54 ` [PATCH v10 18/18] media: ti: j721e-csi2rx: Support system suspend using pm_notifier Rishikesh Donadkar
2026-01-23  9:33   ` 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=d19d1cd1-b7fa-43ab-9ef9-ade414efc508@ti.com \
    --to=r-donadkar@ti.com \
    --cc=changhuang.liang@starfivetech.com \
    --cc=conor+dt@kernel.org \
    --cc=dan.carpenter@linaro.org \
    --cc=devarsht@ti.com \
    --cc=devicetree@vger.kernel.org \
    --cc=hverkuil+cisco@kernel.org \
    --cc=hverkuil-cisco@xs4all.nl \
    --cc=jack.zhu@starfivetech.com \
    --cc=jai.luthra@ideasonboard.com \
    --cc=jai.luthra@linux.dev \
    --cc=krzk+dt@kernel.org \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=mripard@kernel.org \
    --cc=p.zabel@pengutronix.de \
    --cc=robh@kernel.org \
    --cc=s-jain1@ti.com \
    --cc=sakari.ailus@linux.intel.com \
    --cc=sjoerd@collabora.com \
    --cc=tomi.valkeinen@ideasonboard.com \
    --cc=vigneshr@ti.com \
    --cc=y-abhilashchandra@ti.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