linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jacopo Mondi <jacopo@jmondi.org>
To: Sakari Ailus <sakari.ailus@linux.intel.com>,
	Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
	Dave Stevenson <dave.stevenson@raspberrypi.com>,
	Hans Verkuil <hverkuil@xs4all.nl>,
	Mauro Carvalho Chehab <mchehab@kernel.org>
Cc: Jacopo Mondi <jacopo@jmondi.org>,
	Linux Media Mailing List <linux-media@vger.kernel.org>
Subject: [PATCH v2 2/2] documentation: media: camera_sensor: Update exposure on blanking change
Date: Mon, 21 Nov 2022 19:15:15 +0100	[thread overview]
Message-ID: <20221121181515.34008-3-jacopo@jmondi.org> (raw)
In-Reply-To: <20221121181515.34008-1-jacopo@jmondi.org>

The maximum achieable exposure time in a camera sensor is usually
bound by the total frame height (visible + blankings) minus a fixed
sensor-speific offset.

When the vertical blanking control value is changed, the exposure
control limits should be updated as well.

Add this to the camera sensor documentation.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
---
 .../driver-api/media/camera-sensor.rst        | 36 +++++++++++++++++++
 1 file changed, 36 insertions(+)

diff --git a/Documentation/driver-api/media/camera-sensor.rst b/Documentation/driver-api/media/camera-sensor.rst
index 382ea4ecebd4..675f55ad54b5 100644
--- a/Documentation/driver-api/media/camera-sensor.rst
+++ b/Documentation/driver-api/media/camera-sensor.rst
@@ -184,3 +184,39 @@ used to obtain device's power state after the power state transition:
 The function returns a non-zero value if it succeeded getting the power count or
 runtime PM was disabled, in either of which cases the driver may proceed to
 access the device.
+
+Resetting exposure limits on vertical blanking update
+"""""""""""""""""""""""""""""""""""""""""""""""""""""
+
+The sensor exposure time, specified by the ``V4L2_CID_EXPOSURE`` control, is
+usually limited to a maximum value related to the frame interval. Frequently it
+is a number of lines less than the frame length that will be specified in the
+sensor documentation.
+
+When a new ``V4L2_CID_VBLANK`` value is applied, regardless of it being actually
+programmed to the hardware or not, the limits of the ``V4L2_CID_EXPOSURE``
+control should be updated as well.
+
+The typical coding pattern that realizes that in the ``.s_ctrl`` callback
+handler is:
+
+.. code-block:: c
+
+	#define SENSOR_EXPOSURE_OFFSET   <see sensor documentation>
+
+	static int s_ctrl(struct v4l2_ctrl *ctrl)
+	{
+		int exp_max;
+
+		switch (ctrl->id) {
+		case V4L2_CID_VBLANK:
+			exp_max = (analogue crop height) + ctrl->val - SENSOR_EXPOSURE_OFFSET;
+			__v4l2_ctrl_modify_range(sensor->ctrls.exposure,
+						 sensor->ctrls.exposure->minimum,
+						 exp_max, sensor->ctrls.exposure->step,
+						 sensor->ctrls.exposure->default_value);
+			break;
+		}
+
+		if (!pm_runtime_get_if_in_use(&sensor->i2c_client->dev))
+			return 0;
--
2.38.1


      parent reply	other threads:[~2022-11-21 18:15 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-21 18:15 [PATCH v2 0/2] Documentation: media: camera_sensor: Document blankings handling Jacopo Mondi
2022-11-21 18:15 ` [PATCH v2 1/2] documentation: " Jacopo Mondi
2022-11-21 18:15 ` Jacopo Mondi [this message]

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=20221121181515.34008-3-jacopo@jmondi.org \
    --to=jacopo@jmondi.org \
    --cc=dave.stevenson@raspberrypi.com \
    --cc=hverkuil@xs4all.nl \
    --cc=laurent.pinchart@ideasonboard.com \
    --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;
as well as URLs for NNTP newsgroup(s).