Linux Media Controller development
 help / color / mirror / Atom feed
From: Jai Luthra <jai.luthra@ideasonboard.com>
To: Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
	Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Cc: Sakari Ailus <sakari.ailus@linux.intel.com>,
	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,
	hverkuil-cisco@xs4all.nl, 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, jai.luthra@linux.dev,
	mripard@kernel.org, Rishikesh Donadkar <r-donadkar@ti.com>
Subject: Re: [PATCH v9 06/19] media: ti: j721e-csi2rx: add a subdev for the core device
Date: Thu, 22 Jan 2026 12:23:50 +0530	[thread overview]
Message-ID: <176906483058.9154.2619844247504630480@freya> (raw)
In-Reply-To: <20260121105232.GD382676@killaraus>

Hi Laurent,

Quoting Laurent Pinchart (2026-01-21 16:22:32)
> On Wed, Jan 21, 2026 at 09:38:29AM +0200, Tomi Valkeinen wrote:
> > On 21/01/2026 01:25, Laurent Pinchart wrote:
> > > On Thu, Jan 15, 2026 at 02:56:21PM +0200, Tomi Valkeinen wrote:
> > >> On 15/01/2026 08:36, Jai Luthra wrote:
> > >>> Quoting Tomi Valkeinen (2026-01-14 20:51:49)
> > >>>> On 30/12/2025 10:32, Rishikesh Donadkar wrote:
> > >>>>> From: Jai Luthra <j-luthra@ti.com>
> > >>>>>
> > >>>>> With single stream capture, it was simpler to use the video device as
> > >>>>> the media entity representing the main TI CSI2RX device. Now with multi
> > >>>>> stream capture coming into the picture, the model has shifted to each
> > >>>>> video device having a link to the main device's subdev. The routing
> > >>>>> would then be set on this subdev.
> > >>>>>
> > >>>>> Add this subdev, link each context to this subdev's entity and link the
> > >>>>> subdev's entity to the source. Also add an array of media pads. It will
> > >>>>> have one sink pad and source pads equal to the number of contexts.
> > >>>>>
> > >>>>> Support the new enable_stream()/disable_stream() APIs in the subdev
> > >>>>> instead of s_stream() hook.
> > >>>>>
> > >>>>> Reviewed-by: Yemike Abhilash Chandra <y-abhilashchandra@ti.com>
> > >>>>> Co-developed-by: Pratyush Yadav <p.yadav@ti.com>
> > >>>>> Signed-off-by: Pratyush Yadav <p.yadav@ti.com>
> > >>>>> Signed-off-by: Jai Luthra <j-luthra@ti.com>
> > >>>>> Signed-off-by: Rishikesh Donadkar <r-donadkar@ti.com>
> > >>>>> ---
> > >>>
> > >>> [...]
> > >>>
> > >>>>> @@ -981,48 +1138,52 @@ static int ti_csi2rx_link_validate(struct media_link *link)
> > >>>>>       struct ti_csi2rx_ctx *ctx = container_of(vdev, struct ti_csi2rx_ctx, vdev);
> > >>>>>       struct ti_csi2rx_dev *csi = ctx->csi;
> > >>>>>       struct v4l2_pix_format *csi_fmt = &ctx->v_fmt.fmt.pix;
> > >>>>> -     struct v4l2_subdev_format source_fmt = {
> > >>>>> -             .which  = V4L2_SUBDEV_FORMAT_ACTIVE,
> > >>>>> -             .pad    = link->source->index,
> > >>>>> -     };
> > >>>>> +     struct v4l2_mbus_framefmt *format;
> > >>>>> +     struct v4l2_subdev_state *state;
> > >>>>>       const struct ti_csi2rx_fmt *ti_fmt;
> > >>>>> -     int ret;
> > >>>>>  
> > >>>>> -     ret = v4l2_subdev_call_state_active(csi->source, pad,
> > >>>>> -                                         get_fmt, &source_fmt);
> > >>>>> -     if (ret)
> > >>>>> -             return ret;
> > >>>>> +     state = v4l2_subdev_lock_and_get_active_state(&csi->subdev);
> > >>>>> +     format = v4l2_subdev_state_get_format(state, link->source->index, 0);
> > >>>>> +     v4l2_subdev_unlock_state(state);
> > >>>>>  
> > >>>>> -     if (source_fmt.format.width != csi_fmt->width) {
> > >>>>> +     if (!format) {
> > >>>>> +             dev_dbg(csi->dev,
> > >>>>> +                     "Skipping validation as no format present on \"%s\":%u:0\n",
> > >>>>> +                     link->source->entity->name, link->source->index);
> > >>>>> +             return 0;
> > >>>>
> > >>>> Isn't this an error?
> > >>>
> > >>> Well, the j7 shim subdev introduced here has immutable and active links to
> > >>> all the video nodes, for each DMA channel (taken from DT), many of which
> > >>> may be unused for certain setups, and thus there might not be any valid
> > >>> format on the subdev source pad corresponding to an unused video node.
> > >>>
> > >>> Jacopo had a similar comment on v2, see this discussion (grep for Mali):
> > >>> https://lore.kernel.org/linux-media/4mnlnsj4co3agvln4qsasmgvgwiyoo7yu2h5wyh4rmzzafhm5u@avhnbw7iknms/
> > >>>
> > >>> I know other drivers use a different approach with mutable links, so it
> > >>> would be good if you/Laurent/Sakari can give your opinions on if only one
> > >>> of these two approaches should be taken for multi-stream pipelines.
> > >>
> > >> I see.
> > >>
> > >> Well, I don't have a definite answer. With some thinking both options
> > >> make certain sense. It makes sense to keep the links immutable and
> > >> always enabled, as there's no configuration that can be done. On the
> > >> other hand, it makes sense to require the unused links to be disabled,
> > >> as, well, they are not used.
> > > 
> > > I'm not familiar with the implications this would have on this driver,
> > > but generally speaking, if a stream is added to the media pipeline by
> > > the pipeline build algorithm, then it is expected that applications
> > > would have configured it correctly. Streams that are not used are
> > > expected to be disabled if they would otherwise be added to the
> > > pipeline.
> > 
> > I think the thing here is that the driver creates immutable
> > always-enabled media links between the videodevs and the first subdev.
> > Then, say, if only one stream is being used, only one of those links is
> > actually used, and for every other link the above check fails as there's
> > no stream, so no format.
> > 
> > In TI CAL driver the links were mutable, and unused links had to be
> > disabled. There it made sense as the links had to be configurable (there
> > were two PHYs). Here, there's no configuration needed, so immutable
> > links make sense, but then they're enabled even when actually not used.
> 
> If the routing table in the subdev does not contain any route that goes
> towards a video node, then that video node should not be added to the
> pipeline by the validation code, and no validation will be attempted. At
> least that's the theory.

Okay that sounds reasonable. I can take a look into the media pipeline
validation code next week. @Rishikesh, given you already have a working
setup, feel free to test if the link_validate callback is triggered on
video nodes that don't have any streams/routes pointing to them.

> 
> I see that this driver implements .link_validate() as a
> media_entity_operations, not a subdev operation. I wonder if that could
> explain the issue.
> 

Well earlier I was partially confused, now I'm fully confused :-)

How is v4l2_subdev_pad_ops.link_validate different from
media_entity_operations.link_validate?

I see mc-core.rst and v4l2-subdev.rst both talk about their own variant,
without making it clear which should be used for a subdev.

Anyway, I'll try to dig through the framework code to understand what's
going wrong.

> -- 
> Regards,
> 
> Laurent Pinchart

Thanks,
Jai

  reply	other threads:[~2026-01-22  6:53 UTC|newest]

Thread overview: 54+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-30  8:32 [PATCH v9 00/19] media: cadence,ti: CSI2RX Multistream Support Rishikesh Donadkar
2025-12-30  8:32 ` [PATCH v9 01/19] media: ti: j721e-csi2rx: Remove word size alignment on frame width Rishikesh Donadkar
2025-12-30  8:32 ` [PATCH v9 02/19] dt-bindings: media: ti,j721e-csi2rx-shim: Support 32 dma chans Rishikesh Donadkar
2025-12-30  8:32 ` [PATCH v9 03/19] media: ti: j721e-csi2rx: separate out device and context Rishikesh Donadkar
2025-12-30  8:32 ` [PATCH v9 04/19] media: ti: j721e-csi2rx: prepare SHIM code for multiple contexts Rishikesh Donadkar
2025-12-30  8:32 ` [PATCH v9 05/19] media: ti: j721e-csi2rx: allocate DMA channel based on context index Rishikesh Donadkar
2025-12-30  8:32 ` [PATCH v9 06/19] media: ti: j721e-csi2rx: add a subdev for the core device Rishikesh Donadkar
2026-01-14 15:21   ` Tomi Valkeinen
2026-01-15  6:36     ` Jai Luthra
2026-01-15 12:56       ` Tomi Valkeinen
2026-01-20 23:25         ` Laurent Pinchart
2026-01-21  7:38           ` Tomi Valkeinen
2026-01-21 10:52             ` Laurent Pinchart
2026-01-22  6:53               ` Jai Luthra [this message]
2026-01-22  9:53                 ` Laurent Pinchart
2026-02-28 17:49                   ` Jai Luthra
2026-01-21  9:10     ` Rishikesh Donadkar
2025-12-30  8:32 ` [PATCH v9 07/19] media: cadence: csi2rx: Move to .enable/disable_streams API Rishikesh Donadkar
2026-01-14 15:25   ` Tomi Valkeinen
2025-12-30  8:32 ` [PATCH v9 08/19] media: staging: starfive: Move to enabel-disable streams in starfive drivers Rishikesh Donadkar
2026-01-14 12:51   ` Jai Luthra
2026-01-14 13:05     ` Laurent Pinchart
2025-12-30  8:32 ` [PATCH v9 09/19] media: ti: j721e-csi2rx: get number of contexts from device tree Rishikesh Donadkar
2025-12-30  8:32 ` [PATCH v9 10/19] media: cadence: csi2rx: add get_frame_desc wrapper Rishikesh Donadkar
2025-12-30  8:32 ` [PATCH v9 11/19] media: ti: j721e-csi2rx: add support for processing virtual channels Rishikesh Donadkar
2026-01-14 15:31   ` Tomi Valkeinen
2026-01-16 10:28     ` Rishikesh Donadkar
2025-12-30  8:32 ` [PATCH v9 12/19] media: cadence: csi2rx: add multistream support Rishikesh Donadkar
2026-01-15 12:01   ` Tomi Valkeinen
2026-01-16 11:04     ` Rishikesh Donadkar
2025-12-30  8:32 ` [PATCH v9 13/19] media: ti: j721e-csi2rx: " Rishikesh Donadkar
2026-01-15 12:27   ` Tomi Valkeinen
2026-01-20  8:48     ` Rishikesh Donadkar
2026-01-15 12:28   ` Tomi Valkeinen
2026-01-20  8:52     ` Rishikesh Donadkar
2025-12-30  8:32 ` [PATCH v9 14/19] media: ti: j721e-csi2rx: Submit all available buffers Rishikesh Donadkar
2025-12-30  8:32 ` [PATCH v9 15/19] media: ti: j721e-csi2rx: Change the drain architecture for multistream Rishikesh Donadkar
2026-01-15 12:37   ` Tomi Valkeinen
2026-01-15 16:02     ` Jai Luthra
2026-01-16 10:11       ` Vignesh Raghavendra
2026-01-19  5:08       ` Rishikesh Donadkar
2026-01-19  5:04     ` Rishikesh Donadkar
2025-12-30  8:32 ` [PATCH v9 16/19] media: ti: j721e-csi2rx: Return the partial frame as error Rishikesh Donadkar
2026-01-06 11:15   ` Jai Luthra
2026-01-08  5:37     ` Rishikesh Donadkar
2026-01-15 12:39   ` Tomi Valkeinen
2025-12-30  8:32 ` [PATCH v9 17/19] media: cadence: csi2rx: Support runtime PM Rishikesh Donadkar
2026-01-14 17:04   ` Tomi Valkeinen
2025-12-30  8:32 ` [PATCH v9 18/19] media: ti: j721e-csi2rx: Support runtime suspend Rishikesh Donadkar
2026-01-15 12:46   ` Tomi Valkeinen
2026-01-19  6:04     ` Jai Luthra
2025-12-30  8:32 ` [PATCH v9 19/19] media: ti: j721e-csi2rx: Support system suspend using pm_notifier Rishikesh Donadkar
2026-01-15 12:50   ` Tomi Valkeinen
2026-01-19  5:25     ` Rishikesh Donadkar

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=176906483058.9154.2619844247504630480@freya \
    --to=jai.luthra@ideasonboard.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@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=r-donadkar@ti.com \
    --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