From: Dave Stevenson <dave.stevenson@raspberrypi.com>
To: Sakari Ailus <sakari.ailus@linux.intel.com>
Cc: linux-media@vger.kernel.org, hans@jjverkuil.nl,
laurent.pinchart@ideasonboard.com,
Prabhakar <prabhakar.csengg@gmail.com>,
"Kate Hsuan" <hpa@redhat.com>,
"Tommaso Merciai" <tomm.merciai@gmail.com>,
"Benjamin Mugnier" <benjamin.mugnier@foss.st.com>,
"Sylvain Petinot" <sylvain.petinot@foss.st.com>,
"Christophe JAILLET" <christophe.jaillet@wanadoo.fr>,
"Julien Massot" <julien.massot@collabora.com>,
"Naushir Patuck" <naush@raspberrypi.com>,
"Yan, Dongcheng" <dongcheng.yan@intel.com>,
"Cao, Bingbu" <bingbu.cao@intel.com>,
"Qiu, Tian Shu" <tian.shu.qiu@intel.com>,
"Stefan Klug" <stefan.klug@ideasonboard.com>,
"Mirela Rabulea" <mirela.rabulea@nxp.com>,
"André Apitzsch" <git@apitzsch.eu>,
"Heimir Thor Sverrisson" <heimir.sverrisson@gmail.com>,
"Kieran Bingham" <kieran.bingham@ideasonboard.com>,
"Mehdi Djait" <mehdi.djait@linux.intel.com>,
"Ricardo Ribalda Delgado" <ribalda@kernel.org>,
"Hans de Goede" <hansg@kernel.org>,
"Jacopo Mondi" <jacopo.mondi@ideasonboard.com>,
"Tomi Valkeinen" <tomi.valkeinen@ideasonboard.com>,
"David Plowman" <david.plowman@raspberrypi.com>,
"Yu, Ong Hock" <ong.hock.yu@intel.com>,
"Ng, Khai Wen" <khai.wen.ng@intel.com>,
"Jai Luthra" <jai.luthra@ideasonboard.com>
Subject: Re: [PATCH v3 06/22] media: imx219: Don't update exposure limits while setting format
Date: Wed, 25 Mar 2026 12:37:54 +0000 [thread overview]
Message-ID: <CAPY8ntAmcychf6qCJzpSwPGW8nj116gMjwJk=gGvWMeV0=qEZg@mail.gmail.com> (raw)
In-Reply-To: <20260325105818.1176816-7-sakari.ailus@linux.intel.com>
Hi Sakari
On Wed, 25 Mar 2026 at 10:58, Sakari Ailus <sakari.ailus@linux.intel.com> wrote:
>
> Don't update exposure limits explicitly while setting format. This is
> already done through the s_ctrl() callback.
done through the s_ctrl() callback for V4L2_CID_VBLANK.
I believe this change leaves a potential for future failure if any
modes get added because the ctrl handler framework swallows any s_ctrl
that doesn't change the value.
vblank is an offset on top of height. exposure is absolute in the
number of lines.
As an example, take the current mode of 1920x1080 with fll_def 1763,
therefore a vblank of 1763-1080 = 683, and max exposure of 1080-4 =
1076. Add a new mode of 640x480 with fll_def of 1163, therefore vblank
is 1163-480 = 683, and max exposure is 480-4 = 476. set_pad_format for
either mode will set vblank to 683. As it's the same value,
imx219_set_ctrl will not be called to update vblank, leaving the wrong
max exposure value.
You could add V4L2_CTRL_FLAG_EXECUTE_ON_WRITE to V4L2_CID_VBLANK to
always call s_ctrl, but that would have a larger downside if userspace
repeatedly set it to the same value.
It doesn't affect any of the current modes, but it's going to be a
very ugly one for the unwary. imx219 is often pointed to as a
reference for those writing new drivers, so this would likely
propagate.
Dave
>
> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
> ---
> drivers/media/i2c/imx219.c | 14 --------------
> 1 file changed, 14 deletions(-)
>
> diff --git a/drivers/media/i2c/imx219.c b/drivers/media/i2c/imx219.c
> index a72630ad1561..ca6a5939773d 100644
> --- a/drivers/media/i2c/imx219.c
> +++ b/drivers/media/i2c/imx219.c
> @@ -867,8 +867,6 @@ static int imx219_set_pad_format(struct v4l2_subdev *sd,
> crop->top = (IMX219_NATIVE_HEIGHT - crop->height) / 2;
>
> if (fmt->which == V4L2_SUBDEV_FORMAT_ACTIVE) {
> - int exposure_max;
> - int exposure_def;
> int llp_min;
> int pixel_rate;
>
> @@ -887,18 +885,6 @@ static int imx219_set_pad_format(struct v4l2_subdev *sd,
> if (ret)
> return ret;
>
> - /* Update max exposure while meeting expected vblanking */
> - exposure_max = mode->fll_def - IMX219_EXPOSURE_OFFSET;
> - exposure_def = (exposure_max < IMX219_EXPOSURE_DEFAULT) ?
> - exposure_max : IMX219_EXPOSURE_DEFAULT;
> - ret = __v4l2_ctrl_modify_range(imx219->exposure,
> - imx219->exposure->minimum,
> - exposure_max,
> - imx219->exposure->step,
> - exposure_def);
> - if (ret)
> - return ret;
> -
> /*
> * With analog binning the default minimum line length of 3448
> * can cause artefacts with RAW10 formats, because the ADC
> --
> 2.47.3
>
next prev parent reply other threads:[~2026-03-25 12:38 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-25 10:57 [PATCH v3 00/22] Metadata series preparation Sakari Ailus
2026-03-25 10:57 ` [PATCH v3 01/22] media: imx219: Rename "PIXEL_ARRAY" as "VISIBLE" Sakari Ailus
2026-03-25 10:57 ` [PATCH v3 02/22] media: imx219: Fix maximum frame length in lines Sakari Ailus
2026-03-25 11:36 ` Dave Stevenson
2026-03-25 10:57 ` [PATCH v3 03/22] media: imx219: Set horizontal blanking on mode change Sakari Ailus
2026-03-25 11:48 ` Dave Stevenson
2026-03-25 12:20 ` Sakari Ailus
2026-03-25 10:58 ` [PATCH v3 04/22] media: imx219: Scale the vblank limits according to rate_factor Sakari Ailus
2026-03-25 10:58 ` [PATCH v3 05/22] media: imx219: Fix vertical blanking and exposure for analogue binning Sakari Ailus
2026-03-25 10:58 ` [PATCH v3 06/22] media: imx219: Don't update exposure limits while setting format Sakari Ailus
2026-03-25 12:37 ` Dave Stevenson [this message]
2026-03-25 12:47 ` Sakari Ailus
2026-03-25 10:58 ` [PATCH v3 07/22] media: imx219: Rename "binning" as "bin_hv" in imx219_set_pad_format Sakari Ailus
2026-03-25 10:58 ` [PATCH v3 08/22] media: Documentation: Improve LINK_FREQ documentation Sakari Ailus
2026-03-25 10:58 ` [PATCH v3 09/22] media: Documentation: Improve pixel rate calculation documentation Sakari Ailus
2026-03-25 10:58 ` [PATCH v3 10/22] media: v4l2-subdev: Refactor returning routes Sakari Ailus
2026-03-25 10:58 ` [PATCH v3 11/22] media: v4l2-subdev: Allow accessing routes with STREAMS client capability Sakari Ailus
2026-03-25 10:58 ` [PATCH v3 12/22] media: mc: Simplify link processing in __media_pipeline_start() Sakari Ailus
2026-03-25 10:58 ` [PATCH v3 13/22] media: mc: Separate single link validation into a new function Sakari Ailus
2026-03-25 10:58 ` [PATCH v3 14/14] media: Improve enable_streams and disable_streams documentation Sakari Ailus
2026-03-25 12:34 ` Sakari Ailus
2026-03-25 10:58 ` [PATCH v3 14/22] media: uapi: Bump the STREAMS bit a little Sakari Ailus
2026-03-25 10:58 ` [PATCH v3 15/22] media: mc: Don't care about unsettable flags in MEDIA_IOC_LINK_SETUP Sakari Ailus
2026-03-25 10:58 ` [PATCH v3 16/22] media: mc: Add MEDIA_LNK_FL_VALIDATE_LATE Sakari Ailus
2026-03-25 10:58 ` [PATCH v3 17/22] media: Improve enable_streams and disable_streams documentation Sakari Ailus
2026-03-25 10:58 ` [PATCH v3 18/22] media: v4l2-subdev: Move subdev client capabilities into a new struct Sakari Ailus
2026-03-25 10:58 ` [PATCH v3 19/22] media: v4l2-subdev: Add struct v4l2_subdev_client_info pointer to pad ops Sakari Ailus
2026-03-25 10:58 ` [PATCH v3 20/22] media: v4l2-subdev: Add v4l2_subdev_call_ci_active_state Sakari Ailus
2026-03-25 10:58 ` [PATCH v3 21/22] media: v4l2-subdev: Perform client info changes to i2c drivers 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='CAPY8ntAmcychf6qCJzpSwPGW8nj116gMjwJk=gGvWMeV0=qEZg@mail.gmail.com' \
--to=dave.stevenson@raspberrypi.com \
--cc=benjamin.mugnier@foss.st.com \
--cc=bingbu.cao@intel.com \
--cc=christophe.jaillet@wanadoo.fr \
--cc=david.plowman@raspberrypi.com \
--cc=dongcheng.yan@intel.com \
--cc=git@apitzsch.eu \
--cc=hans@jjverkuil.nl \
--cc=hansg@kernel.org \
--cc=heimir.sverrisson@gmail.com \
--cc=hpa@redhat.com \
--cc=jacopo.mondi@ideasonboard.com \
--cc=jai.luthra@ideasonboard.com \
--cc=julien.massot@collabora.com \
--cc=khai.wen.ng@intel.com \
--cc=kieran.bingham@ideasonboard.com \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linux-media@vger.kernel.org \
--cc=mehdi.djait@linux.intel.com \
--cc=mirela.rabulea@nxp.com \
--cc=naush@raspberrypi.com \
--cc=ong.hock.yu@intel.com \
--cc=prabhakar.csengg@gmail.com \
--cc=ribalda@kernel.org \
--cc=sakari.ailus@linux.intel.com \
--cc=stefan.klug@ideasonboard.com \
--cc=sylvain.petinot@foss.st.com \
--cc=tian.shu.qiu@intel.com \
--cc=tomi.valkeinen@ideasonboard.com \
--cc=tomm.merciai@gmail.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