From: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
To: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Cc: Jai Luthra <jai.luthra@ideasonboard.com>,
Sakari Ailus <sakari.ailus@linux.intel.com>,
Mauro Carvalho Chehab <mchehab@kernel.org>,
Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
Kieran Bingham <kieran.bingham@ideasonboard.com>,
linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
Dave Stevenson <dave.stevenson@raspberrypi.org>
Subject: Re: [PATCH] media: Documentation: Fix frame interval calculation for raw camera sensors
Date: Wed, 25 Feb 2026 09:12:35 +0100 [thread overview]
Message-ID: <aZ6ubqtUwCuVPQtt@zed> (raw)
In-Reply-To: <aZ3qotzgQQeyhnbg@zed>
Sorry, one correction
On Tue, Feb 24, 2026 at 07:22:24PM +0100, Jacopo Mondi wrote:
> Hi Jai
>
> On Tue, Feb 24, 2026 at 10:55:33AM +0530, Jai Luthra wrote:
> > Hi Jacopo,
> >
> > Thanks for the review.
> >
> > Quoting Jacopo Mondi (2026-02-23 14:41:02)
> > > Hi Jai
> > >
> > > On Thu, Feb 19, 2026 at 01:20:50PM +0530, Jai Luthra wrote:
> > > > The previous frame interval formula used analogue crop dimensions. This
> > > > breaks down for some sensors when binning.
> > > >
> > > > For example in imx219 the minimum FLL (frame length in lines) can be
> > > > lower than the analogue crop height when binning, which would require a
> > > > negative VBLANK to represent the actual timing. Similarly, imx283 allows
> > > > a lower minimum HMAX (line length) when doing 2x2 or 3x3 binning than
> > > > the analogue crop width of the full resolution mode.
> > > >
> > > > The CCS specification also describes under section "8.2.6 Line Length
> > > > and Frame Length" how the horizontal and vertical readout minimums can
> > > > be different when binning.
> > > >
> > > > Replace the formula with the underlying hardware concepts of LLP (line
> > > > length in pixels) and FLL (frame length in lines). These terms were
> > > > chosen to match the CCS specification on raw sensors, as it is a cleaner
> > > > reference compared to a typical sensor vendor datasheet.
> > > >
> > > > Finally, define the blanking controls relative to the active pixel
> > > > readout (post-binning) rather than the analogue crop size. This matches
> > > > what most sensor drivers already do, and also what applications like
> > > > libcamera expect. In "Figure 42" of CCS specification too, we see a
> > > > similar definition:
> > > >
> > > > frame interval = (output width + HBLANK) *
> > > > (output height + VBLANK) / pixel rate
> > > >
> > > > Also add a note in the "Writing camera sensor drivers" guide, to ensure
> > > > this formula is followed by new sensor drivers.
> > >
> > > I agree that using the analogue crop rectangle sizes is not correct,
> > > however, with this new formulation the LLP and FLL values might be
> > > smaller than the crop rectangles reported through the selection API,
> > > which I'm not sure it's great from a consistency point of view ?
> >
> > While it takes a while to grok, but most sensors I looked at operate in
> > this way (of reducing the line length or the frame length) when binning,
> > including CCS (implicitly). A counterexample would really help here.
> >
> > >
> > > Also the below suggested formulation:
> > >
> > > LLP = active width + V4L2_CID_HBLANK
> > > FLL = active height + V4L2_CID_VBLANK
> > >
> > > Assumes the combined effect of [binning + subsampling] always directly
> > > affect the readout time of pixels on the pixel array. The CCS specs
> > > and driver seems to suggest that's not always the case ?
> >
> > Why do you think this model can't work for sensors where the readout time is
> > unaffected?
> >
> > Let's say a sensor's pixel array is 1920x1080 with minimum LLP=2000, FLL=1200.
> >
> > so, HBLANK minimum = 80, VBLANK minimum = 120
> >
> > It also supports a 2x2 binned mode of 960x540 with the same minimum LLP and FLL
> > (that is same max framerate, no speed up or change in readout).
> >
> > so, HBLANK minimum = 2000 - 960 = 1040, VBLANK minimum = 1200 - 540 = 660
> >
> > If you match this with the CCS Figure 42 it still makes sense.
> >
>
> Ah well, sure if LLP and FFL remain constant, the usage of the
> "active sizes" doesn't matter.
>
> This means that the min hblank and min vblank have to be doubled to
> compensate for the halved the active sizes.
This is of course not correct. blankings doesn't have to be doubled,
but just enalrged enough to maintain LLP/FFL constant.
Sorry for the oversight.
>
> Speaking in CCS terms, this means the limits reported in Table 86 are
> always populated.
>
> And what I'm struggling with at the moment, is the assumptions that's
> always be the case for all sensors. Unfortunately I don't have enough
> experience across all vendors to tell if that's the case..
>
>
> > >
> > > Do we need to distinguish between binning modes that affect the
> > > timings and binning modes that do not do that?
> > >
> > > As we're going to introduce a control for binning to report the
> > > binning factor in the image dimension domain, should we introduce
> > > a control to specify the binning factor in the image timing domain ?
> > >
> > > LLP = (analog_crop_width + HBLANK) / binning_timing_h
> > > FLL = (analog_crop_height + VBLANK) / binning_timing_v
> > > frame_interval = LLP * FLL / pixel_rate
> > >
> > > I'm not 100% sure this is correct however, as the blankings should be
> > > expressed on a different clock domain that the pixel sampling rate,
> > > but I guess this is a reasonable approximation ?
> >
> > What does these two extra controls really offer us?
> >
> > All sensors we have seen thus far map their LLP/FLL (or equivalent HTOT/VTOT)
> > values with respect to the digital readout, and not the analogue pixel array.
> >
> > If we add these two controls, we will have to support two different models for
> > frame interval calculation in the application layer too. Which I'm fine with if
> > it has a practical benefit, that is, it makes it easier to deal with some
> > particular sensor.
>
> Not sure why you would need two modes to calculate timings in
> userspace.
>
> >
> > And if exposing the LLP/FLL directly offer the same benefit, then that is
> > cleaner, as it leaves the HBLANK/VBLANK as-is in the new model.
> >
>
> As per above, if the consensus is that having the limits updated when
> binning to maintaine the LLP/FFL values will work for all sensors,
> then I'm fine with that.
>
> > Thanks,
> > Jai
> >
> > [...]
next prev parent reply other threads:[~2026-02-25 8:12 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-19 7:50 [PATCH] media: Documentation: Fix frame interval calculation for raw camera sensors Jai Luthra
2026-02-19 9:51 ` Sakari Ailus
2026-02-19 14:56 ` Jai Luthra
2026-02-20 10:11 ` Sakari Ailus
2026-02-23 9:11 ` Jacopo Mondi
2026-02-23 10:06 ` Sakari Ailus
2026-02-23 10:25 ` Jacopo Mondi
2026-02-24 5:25 ` Jai Luthra
2026-02-24 8:39 ` Sakari Ailus
2026-02-25 8:53 ` Jai Luthra
2026-02-24 18:22 ` Jacopo Mondi
2026-02-25 8:12 ` Jacopo Mondi [this message]
2026-02-25 8:58 ` Jai Luthra
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=aZ6ubqtUwCuVPQtt@zed \
--to=jacopo.mondi@ideasonboard.com \
--cc=dave.stevenson@raspberrypi.org \
--cc=jai.luthra@ideasonboard.com \
--cc=kieran.bingham@ideasonboard.com \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=sakari.ailus@linux.intel.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