linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jacopo Mondi <jacopo@jmondi.org>
To: Hans Verkuil <hverkuil@xs4all.nl>,
	Sakari Ailus <sakari.ailus@linux.intel.com>,
	Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: Jacopo Mondi <jacopo@jmondi.org>,
	Linux Media Mailing List <linux-media@vger.kernel.org>,
	Sowjanya Komatineni <skomatineni@nvidia.com>,
	Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>,
	libcamera-devel@lists.libcamera.org
Subject: [PATCH 1/4] media: docs: Describe pixel array properties
Date: Wed,  5 Aug 2020 12:57:18 +0200	[thread overview]
Message-ID: <20200805105721.15445-2-jacopo@jmondi.org> (raw)
In-Reply-To: <20200805105721.15445-1-jacopo@jmondi.org>

The V4L2 selection API are also used to access the pixel array
properties of an image sensor, such as the size and position of active
pixels and the cropped area of the pixel matrix used to produce images.

Currently no clear definition of the different areas that compose an
image sensor pixel array matrix is provided in the specification, and
the actual meaning of each selection target when applied to an image
sensor was not provided.

Provide in the sub-device documentation the definition of the pixel
matrix properties and the selection target associated to each of them.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
---
 .../userspace-api/media/v4l/dev-subdev.rst    | 81 +++++++++++++++++++
 1 file changed, 81 insertions(+)

diff --git a/Documentation/userspace-api/media/v4l/dev-subdev.rst b/Documentation/userspace-api/media/v4l/dev-subdev.rst
index 134d2fb909fa4..c47861dff9b9b 100644
--- a/Documentation/userspace-api/media/v4l/dev-subdev.rst
+++ b/Documentation/userspace-api/media/v4l/dev-subdev.rst
@@ -386,6 +386,87 @@ requests on all selection targets, unless specifically told otherwise.
 ``V4L2_SEL_FLAG_GE`` and ``V4L2_SEL_FLAG_LE`` flags may be used to round
 the image size either up or down. :ref:`v4l2-selection-flags`
 
+.. _v4l2-subdev-pixel-array-properties:
+
+Selection targets for image sensors properties
+----------------------------------------------
+
+The V4L2 selection API can be used on sub-devices that represent an image
+sensor to retrieve the sensor's pixel array matrix properties by using the
+:ref:`selection <VIDIOC_SUBDEV_G_SELECTION>` ioctls.
+
+Sub-device drivers for image sensor usually register a single source pad, but in
+the case they expose more, the pixel array properties can be accessed from
+any of them.
+
+The ``V4L2_SEL_TGT_NATIVE``, ``V4L2_SEL_TGT_CROP_BOUNDS``,
+``V4L2_SEL_TGT_CROP_DEFAULT`` and ``V4L2_TGT_CROP`` targets are used to retrieve
+the immutable properties of the several different areas that compose the sensor
+pixel array matrix. Each area describes a rectangle of logically adjacent pixel
+units. The logical disposition of pixels is defined by the sensor read-out
+starting point and direction, and may differ from the physical disposition of
+the pixel units in the pixel array matrix.
+
+Each pixel matrix portion is contained in a larger rectangle, with the most
+largest being the one that describes the pixel matrix physical size. This
+defines a hierarchical positional system, where each rectangle is defined
+relatively to the largest available one among the ones exposed by the
+sub-device driver. Each selection target and the associated pixel array portion
+it represents are below presented in order from the largest to the smallest one.
+
+Pixel array physical size
+^^^^^^^^^^^^^^^^^^^^^^^^^
+
+The image sensor chip is composed by a number of physical pixels, not all of
+them readable by the application processor. Invalid or unreadable lines might
+not be transmitted on the data bus at all, or in case on CSI-2 capable sensors
+they might be tagged with an invalid data type (DT) so that the receiver
+automatically discard them. The size of the whole pixel matrix area is
+retrieved using the V4L2_SEL_TGT_NATIVE target, which has its top-left corner
+defined as position (0, 0). All the other selection targets are defined
+relatively to this, larger, rectangle. The rectangle returned by
+V4L2_SEL_TGT_NATIVE describes an immutable property of the image sensor, it
+does not change at run-time and cannot be modified from userspace.
+
+Pixel array readable area
+^^^^^^^^^^^^^^^^^^^^^^^^^
+
+The V4L2_SEL_TGT_CROP_BOUNDS targets returns size and position of the readable
+area of the pixel array matrix, including pixels with valid image data and pixel
+used for calibration purposes, such as optical black pixels. It is not unlikely
+that valid pixels and optical black pixels are surrounded by non-readable rows
+and columns of pixels. Those does not concur in the definition of the
+V4L2_SEL_TGT_CROP_BOUNDS rectangle. The rectangle returned by
+V4L2_SEL_TGT_CROP_BOUNDS describes an immutable property of the image sensor, it
+does not change at run-time and cannot be modified from userspace.
+
+Pixel array active area
+^^^^^^^^^^^^^^^^^^^^^^^
+
+The portion of the pixel array which contains valid image data is defined as the
+active area of the pixel matrix. The active pixel array is is accessed by mean
+of the V4L2_SEL_TGT_CROP_DEFAULT target, and is contained in the larger
+V4L2_SEL_TGT_CROP_BOUNDS rectangle. It represents the largest possible frame
+resolution the sensor can produce and defines the dimension of the full
+field-of-view. The rectangle returned by V4L2_SEL_TGT_CROP_BOUNDS describes an
+immutable property of the image sensor, it does not change at run-time and
+cannot be modified from userspace.
+
+Analog crop rectangle
+^^^^^^^^^^^^^^^^^^^^^
+
+The sensor driver might decide, in order to adjust the image resolution to best
+match the one requested by applications, to only process a part of the active
+pixel array matrix. The selected area is read-out and processed by the image
+sensor on-board ISP in order to produce images of the desired size and
+resolution while possible maintaing the largest possible field-of-view. The
+cropped portion of the pixel array which is used to produce images is returned
+by the V4L2_SEL_TGT_CROP target and represent the only information that can
+change at runtime as it depends on the currently configured sensor mode and
+desired image resolution. If the sub-device driver supports that, userspace
+can set the analog crop rectangle to select which portion of the pixel array
+to read out.
+
 
 Types of selection targets
 --------------------------
-- 
2.27.0


  reply	other threads:[~2020-08-05 17:22 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-05 10:57 Jacopo Mondi
2020-08-05 10:57 ` Jacopo Mondi [this message]
2020-08-05 22:24   ` [PATCH 1/4] media: docs: Describe pixel array properties Sakari Ailus
2020-08-10  8:12     ` Jacopo Mondi
2020-08-06  8:05   ` Hans Verkuil
2020-08-06  9:50     ` Jacopo Mondi
2020-08-06  9:58       ` Hans Verkuil
2020-08-06 12:54         ` Sakari Ailus
2020-08-06 13:22           ` Hans Verkuil
2020-08-18  8:14             ` Sakari Ailus
2020-08-09 17:17         ` Laurent Pinchart
2020-08-10  8:14           ` Jacopo Mondi
2020-08-19  1:15             ` Laurent Pinchart
2020-08-09 17:58   ` Laurent Pinchart
2020-08-10  8:17     ` Jacopo Mondi
2020-08-18  8:17       ` Sakari Ailus
2020-08-19  1:06         ` Laurent Pinchart
2020-08-19 10:20           ` Sakari Ailus
2020-08-19 12:38             ` Laurent Pinchart
2020-08-20 15:16               ` Sakari Ailus
2020-11-26 13:09                 ` Laurent Pinchart
2020-11-27 13:22                   ` Sakari Ailus
2020-08-05 10:57 ` [PATCH 2/4] media: docs: Describe targets for sensor properties Jacopo Mondi
2020-08-06  8:45   ` Hans Verkuil
2020-08-06 10:08     ` Jacopo Mondi
2020-08-06 10:15       ` Hans Verkuil
2020-08-06 12:45         ` Jacopo Mondi
2020-08-06 13:15           ` Hans Verkuil
2020-08-06 13:36             ` Jacopo Mondi
2020-08-06 15:32               ` Hans Verkuil
2020-08-06 16:11                 ` Jacopo Mondi
2020-08-09 17:54                   ` Laurent Pinchart
2020-08-09 17:32     ` Laurent Pinchart
2020-08-05 10:57 ` [PATCH 3/4] media: docs: USe SUBDEV_G_SELECTION " Jacopo Mondi
2020-08-06  8:45   ` Hans Verkuil
2020-08-05 10:57 ` [PATCH 4/4] media: i2c: imx219: Selection compliance fixes Jacopo Mondi
2020-11-06 12:33   ` Jacopo Mondi
2020-11-26  7:28     ` [libcamera-devel] " Jacopo Mondi
2020-08-09 15:53 ` your mail Laurent Pinchart
2020-08-10  7:28   ` Jacopo Mondi
2020-08-19  0:36     ` Laurent Pinchart

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=20200805105721.15445-2-jacopo@jmondi.org \
    --to=jacopo@jmondi.org \
    --cc=hverkuil@xs4all.nl \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=libcamera-devel@lists.libcamera.org \
    --cc=linux-media@vger.kernel.org \
    --cc=ricardo.ribalda@gmail.com \
    --cc=sakari.ailus@linux.intel.com \
    --cc=skomatineni@nvidia.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).