From: Jacopo Mondi <jacopo@jmondi.org>
To: Sakari Ailus <sakari.ailus@iki.fi>
Cc: "Krzysztof Hałasa" <khalasa@piap.pl>,
"Mauro Carvalho Chehab" <mchehab@kernel.org>,
"Laurent Pinchart" <laurent.pinchart@ideasonboard.com>,
linux-media@vger.kernel.org
Subject: Re: [PATCH 06/10] media: ar0521: Configure pixel rate using LINK_FREQ
Date: Fri, 7 Oct 2022 09:25:20 +0200 [thread overview]
Message-ID: <20221007072520.6eongavhw3pbtxim@uno.localdomain> (raw)
In-Reply-To: <Yz73Z/Tes6k196pz@valkosipuli.retiisi.eu>
Hi Sakari
On Thu, Oct 06, 2022 at 06:42:31PM +0300, Sakari Ailus wrote:
> Hi Jacopo,
>
> On Wed, Oct 05, 2022 at 09:06:09PM +0200, Jacopo Mondi wrote:
> > Now that the V4L2_LINK_FREQUENCY control is available, use it to
> > configure the sensor pixel rate.
> >
> > Adjust the default pixel rate to match the first listed link_frequency.
> >
> > Validated with:
> >
> > $ v4l2-ctl -l -d /dev/v4l-subdev3
> > link_frequency 0x009f0901 (intmenu): min=0 max=1 default=0 value=0
> > pixel_rate 0x009f0902 (int64) : min=168000000 max=414000000 step=1 default=414000000 value=207000000 flags=read-only
> >
> > 26.493166 (30.78 fps) cam0-stream0 seq: 000008 bytesused: 1843200
> > 26.525629 (30.80 fps) cam0-stream0 seq: 000009 bytesused: 1843200
> >
> > $ yavta -w "0x009f0901 1" /dev/v4l-subdev3
> > $ v4l2-ctl -l -d /dev/v4l-subdev3
> > link_frequency 0x009f0901 (intmenu): min=0 max=1 default=0 value=1
> > pixel_rate 0x009f0902 (int64) : min=168000000 max=414000000 step=1 default=414000000 value=414000000 flags=read-only
> >
> > 54.700859 (61.37 fps) cam0-stream0 seq: 000039 bytesused: 1843200
> > 54.717192 (61.23 fps) cam0-stream0 seq: 000040 bytesused: 1843200
> >
> > Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
> > ---
> > drivers/media/i2c/ar0521.c | 21 +++++++++++++++++----
> > 1 file changed, 17 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/media/i2c/ar0521.c b/drivers/media/i2c/ar0521.c
> > index c5410b091654..b1580c99f5e3 100644
> > --- a/drivers/media/i2c/ar0521.c
> > +++ b/drivers/media/i2c/ar0521.c
> > @@ -24,7 +24,7 @@
> > #define AR0521_PLL_MAX (1280 * 1000 * 1000)
> >
> > /* Effective pixel sample rate on the pixel array. */
> > -#define AR0521_PIXEL_CLOCK_RATE (184 * 1000 * 1000)
> > +#define AR0521_PIXEL_CLOCK_RATE (207 * 1000 * 1000)
> > #define AR0521_PIXEL_CLOCK_MIN (168 * 1000 * 1000)
> > #define AR0521_PIXEL_CLOCK_MAX (414 * 1000 * 1000)
> >
> > @@ -91,7 +91,10 @@ static const char * const ar0521_supply_names[] = {
> > };
> >
> > static const s64 ar0521_link_frequencies[] = {
> > - 184000000,
> > + /* 30 FPS at full resolution */
> > + 207000000,
> > + /* 60 FPS at full resolution */
> > + 414000000,
> > };
> >
> > struct ar0521_ctrls {
> > @@ -330,10 +333,21 @@ static u32 calc_pll(struct ar0521_dev *sensor, u32 freq, u16 *pre_ptr, u16 *mult
> > static void ar0521_calc_mode(struct ar0521_dev *sensor)
> > {
> > unsigned int pixel_clock;
> > + unsigned int link_freq;
> > + s64 frequency;
> > + u32 pixel_rate;
> > u16 pre, mult;
> > u32 vco;
> > int bpp;
> >
> > + /* Update the PIXEL_RATE value using the desired link_frequency. */
> > + bpp = ar0521_code_to_bpp(sensor);
> > + link_freq = sensor->ctrls.link_freq->val;
> > + frequency = ar0521_link_frequencies[link_freq];
> > + pixel_rate = frequency * sensor->lane_count * 2 / bpp;
> > +
> > + __v4l2_ctrl_s_ctrl_int64(sensor->ctrls.pixrate, pixel_rate);
> > +
> > /*
> > * PLL1 and PLL2 are computed equally even if the application note
> > * suggests a slower PLL1 clock. Maintain pll1 and pll2 divider and
> > @@ -380,8 +394,7 @@ static void ar0521_calc_mode(struct ar0521_dev *sensor)
> > * VCO not to exceed the limits specified by the datasheet and
> > * consequentially reduce the obtained pixel clock.
> > */
> > - pixel_clock = AR0521_PIXEL_CLOCK_RATE * 2 / sensor->lane_count;
> > - bpp = ar0521_code_to_bpp(sensor);
> > + pixel_clock = pixel_rate * 2 / sensor->lane_count;
> > sensor->pll.vt_pix = bpp / 2;
> > vco = pixel_clock * sensor->pll.vt_pix;
> >
>
> I checked how the driver validates the link frequencies and it seems this
> one doesn't. It's also missing from DT bindings.
As Dave noted, I don't have an handler for LINK_FREQ in s_ctrl.
I will add one
>
> Would you be kind enough to add it?
And add the property to bindings..
>
> Thanks.
>
> --
> Kind regards,
>
> Sakari Ailus
next prev parent reply other threads:[~2022-10-07 7:25 UTC|newest]
Thread overview: 71+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-05 19:06 [PATCH 00/10] media: ar0521: Add analog gain, rework clock tree Jacopo Mondi
2022-10-05 19:06 ` [PATCH 01/10] media: ar0521: Implement enum_frame_sizes Jacopo Mondi
2022-10-06 14:37 ` Dave Stevenson
2022-10-06 16:33 ` Laurent Pinchart
2022-10-07 4:57 ` Krzysztof Hałasa
2022-10-07 8:08 ` Laurent Pinchart
2022-10-07 7:29 ` Jacopo Mondi
2022-10-07 8:11 ` Laurent Pinchart
2022-10-07 10:32 ` Dave Stevenson
2022-10-07 12:05 ` Sakari Ailus
2022-10-07 12:12 ` Laurent Pinchart
2022-10-05 19:06 ` [PATCH 02/10] media: ar0521: Add V4L2_CID_ANALOG_GAIN Jacopo Mondi
2022-10-06 14:44 ` Dave Stevenson
2022-10-06 15:00 ` Jacopo Mondi
2022-10-06 15:05 ` Laurent Pinchart
2022-10-07 5:28 ` Krzysztof Hałasa
2022-10-07 8:20 ` Laurent Pinchart
2022-10-12 18:54 ` Sakari Ailus
2022-10-13 9:30 ` Laurent Pinchart
2022-10-07 5:20 ` Krzysztof Hałasa
2022-10-07 7:17 ` Jacopo Mondi
2022-10-07 8:30 ` Laurent Pinchart
2022-10-07 12:01 ` Krzysztof Hałasa
2022-10-07 12:07 ` Laurent Pinchart
2022-10-07 14:02 ` Krzysztof Hałasa
2022-10-17 15:10 ` Jacopo Mondi
2022-10-17 15:57 ` Sakari Ailus
2022-10-17 16:31 ` Jacopo Mondi
2022-10-17 16:37 ` Sakari Ailus
2022-10-17 16:42 ` Dave Stevenson
2022-10-07 11:56 ` Krzysztof Hałasa
2022-10-07 12:11 ` Laurent Pinchart
2022-10-07 14:00 ` Krzysztof Hałasa
2022-10-05 19:06 ` [PATCH 03/10] media: ar0521: Set maximum resolution to 2592x1944 Jacopo Mondi
2022-10-06 14:57 ` Dave Stevenson
2022-10-07 13:06 ` Laurent Pinchart
2022-10-20 11:23 ` Jacopo Mondi
2022-10-07 5:33 ` Krzysztof Hałasa
2022-10-07 12:42 ` Jacopo Mondi
2022-10-07 14:07 ` Krzysztof Hałasa
2022-10-05 19:06 ` [PATCH 04/10] media: ar0521: Rework PLL computation Jacopo Mondi
2022-10-07 13:56 ` Laurent Pinchart
2022-10-12 19:02 ` Sakari Ailus
2022-10-13 9:31 ` Laurent Pinchart
2022-10-05 19:06 ` [PATCH 05/10] media: ar0521: Add LINK_FREQ control Jacopo Mondi
2022-10-06 15:10 ` Dave Stevenson
2022-10-07 14:01 ` Laurent Pinchart
2022-10-07 14:26 ` Dave Stevenson
2022-10-16 1:53 ` Laurent Pinchart
2022-10-17 11:21 ` Dave Stevenson
2022-10-17 9:24 ` Jacopo Mondi
2022-10-17 11:00 ` Dave Stevenson
2022-10-17 12:00 ` Jacopo Mondi
2022-10-05 19:06 ` [PATCH 06/10] media: ar0521: Configure pixel rate using LINK_FREQ Jacopo Mondi
2022-10-06 5:51 ` kernel test robot
2022-10-06 15:42 ` Sakari Ailus
2022-10-07 7:25 ` Jacopo Mondi [this message]
2022-10-07 5:52 ` Krzysztof Hałasa
2022-10-05 19:06 ` [PATCH 07/10] media: ar0521: Adjust exposure and blankings limits Jacopo Mondi
2022-10-06 2:08 ` kernel test robot
2022-10-06 4:17 ` kernel test robot
2022-10-06 15:41 ` Dave Stevenson
2022-10-05 19:06 ` [PATCH 08/10] media: ar0521: Setup controls at s_stream time Jacopo Mondi
2022-10-06 15:43 ` Dave Stevenson
2022-10-07 7:23 ` Jacopo Mondi
2022-10-05 19:06 ` [PATCH 09/10] media: ar0521: Rework startup sequence Jacopo Mondi
2022-10-06 15:45 ` Dave Stevenson
2022-10-05 19:06 ` [PATCH 10/10] media: ar0521: Tab-align definitions Jacopo Mondi
2022-10-06 15:48 ` Dave Stevenson
2022-10-06 16:11 ` Laurent Pinchart
2022-10-07 5:42 ` Krzysztof Hałasa
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=20221007072520.6eongavhw3pbtxim@uno.localdomain \
--to=jacopo@jmondi.org \
--cc=khalasa@piap.pl \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=sakari.ailus@iki.fi \
/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 NNTP newsgroup(s).