public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Isaac Scott <isaac.scott@ideasonboard.com>
Cc: Sakari Ailus <sakari.ailus@iki.fi>,
	linux-media@vger.kernel.org, rmfrfs@gmail.com, martink@posteo.de,
	kernel@puri.sm, mchehab@kernel.org, shawnguo@kernel.org,
	s.hauer@pengutronix.de, kernel@pengutronix.de,
	festevam@gmail.com, imx@lists.linux.dev,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] imx-mipi-csis: Get the number of active lanes from mbus_config
Date: Tue, 2 Sep 2025 14:38:05 +0200	[thread overview]
Message-ID: <20250902123805.GL13448@pendragon.ideasonboard.com> (raw)
In-Reply-To: <175681611736.1349241.9877873145029586025@isaac-ThinkPad-T16-Gen-2>

On Tue, Sep 02, 2025 at 01:28:37PM +0100, Isaac Scott wrote:
> Quoting Laurent Pinchart (2025-08-19 03:44:13)
> <snip>
> > > > > > That would need to parse the endpoint every time we start streaming, it
> > > > > > doesn't sound ideal.
> > > > > 
> > > > > Perhaps not, but does that matter in practice? Parsing the endpoint is,
> > > > > after all, fairly trivial. The advantage would be simplifying drivers.
> > > > 
> > > > It's trivial from a code point of view, but it's not a cheap operation.
> > > > I'd like to avoid making starting streaming more expensive.
> > > 
> > > How cheap is "not cheap"? I'd be surprised if parsing an endpoint took more
> > > time than e.g. an I²C register write. Of course it depends on the CPU...
> > 
> > Still, it's not cheap, and I think it can easily be avoided.
> > 
> > > > > Alternatively we could think of caching this information somewhere but I
> > > > > don't think it's worth it.
> > > > 
> > > > Drivers likely need to parse endpoints for other reasons. I'd cache the
> > > > value in drivers, like done today, and pass it to a get_active_lanes
> > > > helper.
> > > 
> > > Then drivers presumably would also validate this against the endpoint
> > > configuration, wouldn't they? That's extra code in every CSI-2 receiver
> > > driver.
> > 
> > Why so ? The number of connected lanes can be passed to the helper
> > function, which can use it to validate the number of lanes reported by
> > the source subdev.
> 
> Apologies if I'm interpreting this wrong, but it seems that the main
> thing I'm reading is that this is not the correct place to implement
> this, and it should be implemented at a higher level (e.g. in v4l2) that
> lets all MIPI CSI reciever drivers use it?
> 
> I have noticed that similar functionality has been implemented as part
> of __v4l2_get_link_freq_pad. Are you suggesting that I take a similar
> approach and resubmit as a new series?

As far as iI understand, Sakari would like a helper function that will
query the remote subdev for the number of data lanes it uses, and
validates that against the number of connected data lanes as described
by DT. I don't like the idea of parsing the endpoint properties every
time we do so, so I think the number of connected data lanes should be
passed by the driver to the helper instead. The helper would still query
the remote subdev, and validate the value.

> > > > > > > The function could take struct media_pad pointer as an argument, or struct
> > > > > > > v4l2_subdev pointer and the pad number.
> > > > > > > 
> > > > > > > I wonder if any other parameters could change dynamically but I can't think
> > > > > > > of that now, so perhaps just the number of lanes is what the function
> > > > > > > should indeed return.
> > > > > > > 
> > > > > > > > +
> > > > > > > > +   return 0;
> > > > > > > > +}
> > > > > > > > +
> > > > > > > >  static int mipi_csis_s_stream(struct v4l2_subdev *sd, int enable)
> > > > > > > >  {
> > > > > > > >     struct mipi_csis_device *csis = sd_to_mipi_csis_device(sd);
> > > > > > > > @@ -965,6 +1002,10 @@ static int mipi_csis_s_stream(struct v4l2_subdev *sd, int enable)
> > > > > > > >     format = v4l2_subdev_state_get_format(state, CSIS_PAD_SINK);
> > > > > > > >     csis_fmt = find_csis_format(format->code);
> > > > > > > >  
> > > > > > > > +   ret = mipi_csis_get_active_lanes(sd);
> > > > > > > > +   if (ret < 0)
> > > > > > > > +           dev_dbg(csis->dev, "Failed to get active lanes: %d", ret);
> > > > > > > > +
> > > > > > > >     ret = mipi_csis_calculate_params(csis, csis_fmt);
> > > > > > > >     if (ret < 0)
> > > > > > > >             goto err_unlock;

-- 
Regards,

Laurent Pinchart


  reply	other threads:[~2025-09-02 19:09 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-14 11:37 [PATCH] imx-mipi-csis: Get the number of active lanes from mbus_config Isaac Scott
2025-08-15  9:18 ` Sakari Ailus
2025-08-15 10:32   ` Laurent Pinchart
2025-08-15 11:25     ` Sakari Ailus
2025-08-15 11:36       ` Laurent Pinchart
2025-08-15 12:33         ` Sakari Ailus
2025-08-19  2:44           ` Laurent Pinchart
2025-09-02 12:28             ` Isaac Scott
2025-09-02 12:38               ` Laurent Pinchart [this message]
2025-09-02 12:48                 ` Sakari Ailus

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=20250902123805.GL13448@pendragon.ideasonboard.com \
    --to=laurent.pinchart@ideasonboard.com \
    --cc=festevam@gmail.com \
    --cc=imx@lists.linux.dev \
    --cc=isaac.scott@ideasonboard.com \
    --cc=kernel@pengutronix.de \
    --cc=kernel@puri.sm \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=martink@posteo.de \
    --cc=mchehab@kernel.org \
    --cc=rmfrfs@gmail.com \
    --cc=s.hauer@pengutronix.de \
    --cc=sakari.ailus@iki.fi \
    --cc=shawnguo@kernel.org \
    /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