Linux Media Controller development
 help / color / mirror / Atom feed
From: Sakari Ailus <sakari.ailus@linux.intel.com>
To: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Cc: linux-media@vger.kernel.org,
	Jacopo Mondi <jacopo.mondi@ideasonboard.com>,
	hverkuil@xs4all.nl, laurent.pinchart@ideasonboard.com,
	bingbu.cao@intel.com
Subject: Re: [PATCH v8 2/9] media: v4l: Support obtaining link frequency via get_mbus_config
Date: Wed, 8 Jan 2025 13:53:17 +0000	[thread overview]
Message-ID: <Z36DTYxNxs9-7DYT@kekkonen.localdomain> (raw)
In-Reply-To: <079e6b31-ee12-4d83-9dce-61f4d4c1cc99@ideasonboard.com>

Moi,

On Fri, Dec 20, 2024 at 02:59:39PM +0200, Tomi Valkeinen wrote:
> Hi,
> 
> On 17/12/2024 23:54, Sakari Ailus wrote:
> > Add link_freq field to struct v4l2_mbus_config in order to pass the link
> > frequency to the receiving sub-device.
> > 
> > Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
> > ---
> >   drivers/media/v4l2-core/v4l2-common.c | 15 +++++++++++++--
> >   include/media/v4l2-mediabus.h         |  2 ++
> >   2 files changed, 15 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/media/v4l2-core/v4l2-common.c b/drivers/media/v4l2-core/v4l2-common.c
> > index 9fe74c7e064f..e4b2de3833ee 100644
> > --- a/drivers/media/v4l2-core/v4l2-common.c
> > +++ b/drivers/media/v4l2-core/v4l2-common.c
> > @@ -508,12 +508,23 @@ EXPORT_SYMBOL_GPL(__v4l2_get_link_freq_ctrl);
> >   s64 __v4l2_get_link_freq_pad(struct media_pad *pad, unsigned int mul,
> >   			     unsigned int div)
> >   {
> > +	struct v4l2_mbus_config mbus_config = {};
> >   	struct v4l2_subdev *sd;
> > +	int ret;
> >   	sd = media_entity_to_v4l2_subdev(pad->entity);
> > -	if (!sd)
> > -		return -ENODEV;
> > +	ret = v4l2_subdev_call(sd, pad, get_mbus_config, pad->index,
> > +			       &mbus_config);
> > +	if (ret < 0 && ret != -ENOIOCTLCMD)
> > +		return ret;
> > +
> > +	if (mbus_config.link_freq)
> > +		return mbus_config.link_freq;
> > +	/*
> > +	 * Fall back to using the link frequency control if the media bus config
> > +	 * doesn't provide a link frequency.
> > +	 */
> >   	return __v4l2_get_link_freq_ctrl(sd->ctrl_handler, mul, div);
> >   }
> >   EXPORT_SYMBOL_GPL(__v4l2_get_link_freq_pad);
> > diff --git a/include/media/v4l2-mediabus.h b/include/media/v4l2-mediabus.h
> > index e7f019f68c8d..24c738cd7894 100644
> > --- a/include/media/v4l2-mediabus.h
> > +++ b/include/media/v4l2-mediabus.h
> > @@ -169,6 +169,7 @@ enum v4l2_mbus_type {
> >   /**
> >    * struct v4l2_mbus_config - media bus configuration
> >    * @type: interface type
> > + * @link_freq: The link frequency. See also V4L2_CID_LINK_FREQ control.
> >    * @bus: bus configuration data structure
> >    * @bus.parallel: embedded &struct v4l2_mbus_config_parallel.
> >    *		  Used if the bus is parallel or BT.656.
> > @@ -183,6 +184,7 @@ enum v4l2_mbus_type {
> >    */
> >   struct v4l2_mbus_config {
> >   	enum v4l2_mbus_type type;
> > +	u64 link_freq;
> >   	union {
> >   		struct v4l2_mbus_config_parallel parallel;
> >   		struct v4l2_mbus_config_mipi_csi1 mipi_csi1;
> 
> Maybe the docs (V4L2_CID_LINK_FREQ and/or struct v4l2_mbus_config?) should
> mention that only if v4l2_mbus_config.link_freq is == 0, V4L2_CID_LINK_FREQ
> is used. Or, in other words, the driver must only use one of those methods.

Such documentation is added by the 3rd patch ("media: Documentation: Update link frequency driver
documentation"):

diff --git a/Documentation/driver-api/media/tx-rx.rst b/Documentation/driver-api/media/tx-rx.rst
index c71003f74b1c..6f9eba189a9f 100644
--- a/Documentation/driver-api/media/tx-rx.rst
+++ b/Documentation/driver-api/media/tx-rx.rst
@@ -49,6 +49,10 @@ Link frequency
 The :ref:`V4L2_CID_LINK_FREQ <v4l2-cid-link-freq>` control is used to tell the
 receiver the frequency of the bus (i.e. it is not the same as the symbol rate).
 
+Drivers that do not have user-configurable link frequency should report it
+through the ``.get_mbus_config()`` subdev pad operation, in the ``link_freq``
+field of struct v4l2_mbus_config, instead of through controls.
+
 ``.enable_streams()`` and ``.disable_streams()`` callbacks
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 

-- 
Sakari Ailus

  reply	other threads:[~2025-01-08 13:53 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-17 21:54 [PATCH v8 0/9] Use V4L2 mbus config for conveying link frequency Sakari Ailus
2024-12-17 21:54 ` [PATCH v8 1/9] media: v4l: Support passing media pad argument to v4l2_get_link_freq() Sakari Ailus
2024-12-20 13:09   ` Tomi Valkeinen
2025-01-08 13:14     ` Sakari Ailus
2024-12-17 21:54 ` [PATCH v8 2/9] media: v4l: Support obtaining link frequency via get_mbus_config Sakari Ailus
2024-12-20 12:59   ` Tomi Valkeinen
2025-01-08 13:53     ` Sakari Ailus [this message]
2024-12-17 21:54 ` [PATCH v8 3/9] media: Documentation: Update link frequency driver documentation Sakari Ailus
2024-12-17 21:54 ` [PATCH v8 4/9] media: Documentation: tx-rx: Move transmitter control out of CSI-2 part Sakari Ailus
2024-12-20 13:21   ` Tomi Valkeinen
2024-12-17 21:54 ` [PATCH v8 5/9] media: Documentation: Receiver drivers should call v4l2_get_link_freq() Sakari Ailus
2024-12-20 13:22   ` Tomi Valkeinen
2024-12-17 21:54 ` [PATCH v8 6/9] media: Documentation: Add a note to set all fields in get_mbus_config op Sakari Ailus
2024-12-20 13:29   ` Tomi Valkeinen
2025-01-08 13:42     ` Sakari Ailus
2024-12-17 21:54 ` [PATCH v8 7/9] media: intel/ipu6: Obtain link frequency from the remote subdev pad Sakari Ailus
2024-12-17 21:54 ` [PATCH v8 8/9] media: ivsc: csi: Obtain link frequency from the media pad Sakari Ailus
2024-12-17 21:54 ` [PATCH v8 9/9] media: v4l: Convert the users of v4l2_get_link_freq to call it on a pad Sakari Ailus
2024-12-19 11:03   ` [RESEND PATCH " Sakari Ailus
2024-12-19 12:44     ` Naushir Patuck
2025-01-02 10:49     ` Benjamin Mugnier
2024-12-20 13:19   ` [PATCH " Tomi Valkeinen
2025-01-08 12:50     ` 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=Z36DTYxNxs9-7DYT@kekkonen.localdomain \
    --to=sakari.ailus@linux.intel.com \
    --cc=bingbu.cao@intel.com \
    --cc=hverkuil@xs4all.nl \
    --cc=jacopo.mondi@ideasonboard.com \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-media@vger.kernel.org \
    --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