{"id":19040,"url":"https://patchwork.libcamera.org/api/patches/19040/?format=json","web_url":"https://patchwork.libcamera.org/patch/19040/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20230916121930.29490-3-jacopo.mondi@ideasonboard.com>","date":"2023-09-16T12:19:20","name":"[libcamera-devel,v4,02/12] libcamera: camera: Introduce SensorConfiguration","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"f424f5b67ef96d3002a64b68c0a3f5b6c864cf54","submitter":{"id":143,"url":"https://patchwork.libcamera.org/api/people/143/?format=json","name":"Jacopo Mondi","email":"jacopo.mondi@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/19040/mbox/","series":[{"id":4027,"url":"https://patchwork.libcamera.org/api/series/4027/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=4027","date":"2023-09-16T12:19:18","name":"libcamera: Introduce SensorConfiguration","version":4,"mbox":"https://patchwork.libcamera.org/series/4027/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/19040/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/19040/checks/","tags":{},"headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 34CFBC3260\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSat, 16 Sep 2023 12:19:41 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 4003362922;\n\tSat, 16 Sep 2023 14:19:40 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 51E1A628E9\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 16 Sep 2023 14:19:38 +0200 (CEST)","from uno.LocalDomain (93-61-96-190.ip145.fastwebnet.it\n\t[93.61.96.190])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 3069210FE;\n\tSat, 16 Sep 2023 14:18:04 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1694866780;\n\tbh=fCrwnYOzbDNE3v4d/Tv6LJHPfte+QYIu6jJXBrOwKTg=;\n\th=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=Hg3tZP7eY714sm6IGPX0Kfw5mU0YdojkMW3FqEG5po6sOxZmelwGXUTcqbPyi0QsJ\n\tUaHkl6PseBRMwfY2X1XWXr58bdezKB+flgULdAJvfVjTh3lGXDWiYtlnStEjgO0I9/\n\tFYMuhLGa6AvNxbA3SDiU0A6xwz+lPdoeKmEzyKaSYjioMHLJ73n2g/kXmLtg+Kaby6\n\tUJWIp+Irdc5m+4jcdj+t8MWyMQj9/M4K4i2gMwFRXTqjcD8bIlilUYzab3i84KDIuk\n\t1u8E3rkyfERLG5VG3rdzw6dJebF5MRo5v+1JKiATJsXj53x3SdKlSgTmd4TqcxaD3R\n\tWYLDdXUYPdfhw==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1694866684;\n\tbh=fCrwnYOzbDNE3v4d/Tv6LJHPfte+QYIu6jJXBrOwKTg=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=Z6bYot7wD235f4NsnpxgP4arAIYA3D0vw5qBb05T1DNhDIx7J6tTMc6cZ8YbkVD9E\n\tsiGVWu0xbSQwkcgMLvHZiePptVEth/b8gr/k6TUj3m4TjnckPZJ8NxKJrZu5uF51rz\n\tYEWi0w3PvhUtnhQ9LhbaPEWin8So7k6G0JRAqe9M="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"Z6bYot7w\"; dkim-atps=neutral","To":"libcamera-devel@lists.libcamera.org","Date":"Sat, 16 Sep 2023 14:19:20 +0200","Message-ID":"<20230916121930.29490-3-jacopo.mondi@ideasonboard.com>","X-Mailer":"git-send-email 2.42.0","In-Reply-To":"<20230916121930.29490-1-jacopo.mondi@ideasonboard.com>","References":"<20230916121930.29490-1-jacopo.mondi@ideasonboard.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v4 02/12] libcamera: camera: Introduce\n\tSensorConfiguration","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","From":"Jacopo Mondi via libcamera-devel <libcamera-devel@lists.libcamera.org>","Reply-To":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>","Cc":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"Introduce SensorConfiguration in the libcamera API.\n\nThe SensorConfiguration is part of the CameraConfiguration class\nand allows applications to control the sensor settings.\n\nSigned-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\nReviewed-by: Naushir Patuck <naush@raspberrypi.com>\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n---\n include/libcamera/camera.h |  43 +++++++++\n src/libcamera/camera.cpp   | 183 +++++++++++++++++++++++++++++++++++++\n 2 files changed, 226 insertions(+)","diff":"diff --git a/include/libcamera/camera.h b/include/libcamera/camera.h\nindex 004bc89455f5..c4f9aa869489 100644\n--- a/include/libcamera/camera.h\n+++ b/include/libcamera/camera.h\n@@ -19,6 +19,7 @@\n #include <libcamera/base/signal.h>\n \n #include <libcamera/controls.h>\n+#include <libcamera/geometry.h>\n #include <libcamera/request.h>\n #include <libcamera/stream.h>\n #include <libcamera/transform.h>\n@@ -30,6 +31,47 @@ class FrameBufferAllocator;\n class PipelineHandler;\n class Request;\n \n+class SensorConfiguration\n+{\n+public:\n+\tunsigned int bitDepth = 0;\n+\n+\tRectangle analogCrop;\n+\n+\tstruct {\n+\t\tunsigned int binX = 1;\n+\t\tunsigned int binY = 1;\n+\t} binning;\n+\n+\tstruct {\n+\t\tunsigned int xOddInc = 1;\n+\t\tunsigned int xEvenInc = 1;\n+\t\tunsigned int yOddInc = 1;\n+\t\tunsigned int yEvenInc = 1;\n+\t} skipping;\n+\n+\tSize outputSize;\n+\n+\tbool valid() const\n+\t{\n+\t\treturn validate() != Invalid;\n+\t}\n+\n+\tbool populated() const\n+\t{\n+\t\treturn validate() == Populated;\n+\t}\n+\n+private:\n+\tenum Status {\n+\t\tUnpopulated,\n+\t\tPopulated,\n+\t\tInvalid,\n+\t};\n+\n+\tStatus validate() const;\n+};\n+\n class CameraConfiguration\n {\n public:\n@@ -66,6 +108,7 @@ public:\n \tbool empty() const;\n \tstd::size_t size() const;\n \n+\tSensorConfiguration sensorConfig;\n \tTransform transform;\n \n protected:\ndiff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp\nindex 0eecee766f00..3d8098239a7f 100644\n--- a/src/libcamera/camera.cpp\n+++ b/src/libcamera/camera.cpp\n@@ -97,6 +97,16 @@\n  * implemented in the above order at the hardware level. The libcamera pipeline\n  * handlers translate the pipeline model to the real hardware configuration.\n  *\n+ * \\subsection camera-sensor-model Camera Sensor Model\n+ *\n+ * By default, libcamera configures the camera sensor automatically based on the\n+ * configuration of the streams. Applications may instead specify a manual\n+ * configuration for the camera sensor. This allows precise control of the frame\n+ * geometry and frame rate delivered by the sensor.\n+ *\n+ * More details about the camera sensor model implemented by libcamera are\n+ * available in the libcamera camera-sensor-model documentation page.\n+ *\n  * \\subsection digital-zoom Digital Zoom\n  *\n  * Digital zoom is implemented as a combination of the cropping and scaling\n@@ -111,6 +121,166 @@ namespace libcamera {\n \n LOG_DECLARE_CATEGORY(Camera)\n \n+/**\n+ * \\class SensorConfiguration\n+ * \\brief Camera sensor configuration\n+ *\n+ * The SensorConfiguration class collects parameters to control the operations\n+ * of the camera sensor, accordingly to the abstract camera sensor model\n+ * implemented by libcamera.\n+ *\n+ * \\todo Applications shall fully populate all fields of the\n+ * CameraConfiguration::sensorConfig class members before validating the\n+ * CameraConfiguration. If the SensorConfiguration is not fully populated, or if\n+ * any of its parameters cannot be applied to the sensor in use, the\n+ * CameraConfiguration validation process will fail and return\n+ * CameraConfiguration::Status::Invalid.\n+ *\n+ * Applications that populate the SensorConfiguration class members are\n+ * expected to be highly-specialized applications that know what sensor\n+ * they are operating with and what parameters are valid for the sensor in use.\n+ *\n+ * A detailed description of the abstract camera sensor model implemented by\n+ * libcamera and the description of its configuration parameters is available\n+ * in the libcamera documentation camera-sensor-model file.\n+ */\n+\n+/**\n+ * \\enum SensorConfiguration::Status\n+ * \\brief The sensor configuration validation status\n+ */\n+\n+/**\n+ * \\var SensorConfiguration::bitDepth\n+ * \\brief The sensor image format bit depth\n+ *\n+ * The number of bits (resolution) used to represent a pixel sample.\n+ */\n+\n+/**\n+ * \\var SensorConfiguration::analogCrop\n+ * \\brief The analog crop rectangle\n+ *\n+ * The selected portion of the active pixel array used to produce the image\n+ * frame.\n+ */\n+\n+/**\n+ * \\var SensorConfiguration::binning\n+ * \\brief Sensor binning configuration\n+ *\n+ * Refer to the camera-sensor-model documentation for an accurate description\n+ * of the binning operations. Disabled by default.\n+ */\n+\n+/**\n+ * \\var SensorConfiguration::binX\n+ * \\brief Horizontal binning factor\n+ *\n+ * The horizontal binning factor. Default to 1.\n+ */\n+\n+/**\n+ * \\var SensorConfiguration::binY\n+ * \\brief Vertical binning factor\n+ *\n+ * The vertical binning factor. Default to 1.\n+ */\n+\n+/**\n+ * \\var SensorConfiguration::skipping\n+ * \\brief The sensor skipping configuration\n+ *\n+ * Refer to the camera-sensor-model documentation for an accurate description\n+ * of the skipping operations.\n+ *\n+ * If no skipping is performed, all the structure fields should be\n+ * set to 1. Disabled by default.\n+ */\n+\n+/**\n+ * \\var SensorConfiguration::xOddInc\n+ * \\brief Horizontal increment for odd rows. Default to 1.\n+ */\n+\n+/**\n+ * \\var SensorConfiguration::xEvenInc\n+ * \\brief Horizontal increment for even rows. Default to 1.\n+ */\n+\n+/**\n+ * \\var SensorConfiguration::yOddInc\n+ * \\brief Vertical increment for odd columns. Default to 1.\n+ */\n+\n+/**\n+ * \\var SensorConfiguration::yEvenInc\n+ * \\brief Vertical increment for even columns. Default to 1.\n+ */\n+\n+/**\n+ * \\var SensorConfiguration::outputSize\n+ * \\brief The frame output (visible) size\n+ *\n+ * The size of the data frame as received by the host processor.\n+ */\n+\n+/**\n+ * \\fn SensorConfiguration::valid() const\n+ * \\brief Validate the SensorConfiguration\n+ *\n+ * Validate the sensor configuration.\n+ *\n+ * \\todo A sensor configuration is valid (or well-formed) if it's either\n+ * completely un-populated or fully populated. For now allow applications to\n+ * populate the bitDepth and the outputSize only.\n+ *\n+ * \\return True if the SensorConfiguration is either fully populated or\n+ * un-populated, false otherwise\n+ */\n+\n+/**\n+ * \\fn SensorConfiguration::populated() const\n+ * \\brief Test if a SensorConfiguration is fully populated\n+ * \\return True if the SensorConfiguration is fully populated\n+ */\n+\n+/**\n+ * \\brief Validate the sensor configuration\n+ *\n+ * \\todo A sensor configuration is valid (or well-formed) if it's either\n+ * completely un-populated or fully populated. For now allow applications to\n+ * populate the bitDepth and the outputSize only.\n+ *\n+ * \\return The sensor configuration status\n+ * \\retval Unpopulated The sensor configuration is fully unpopulated\n+ * \\retval Populated The sensor configuration is fully populated\n+ * \\retval Invalid The sensor configuration is invalid (not fully populated\n+ * and not fully unpopulated)\n+ */\n+SensorConfiguration::Status SensorConfiguration::validate() const\n+{\n+\tif (bitDepth && binning.binX && binning.binY &&\n+\t    skipping.xOddInc && skipping.yOddInc &&\n+\t    skipping.xEvenInc && skipping.yEvenInc &&\n+\t    !outputSize.isNull())\n+\t\treturn Populated;\n+\n+\t/*\n+\t * By default the binning and skipping factors are initialized to 1, but\n+\t * a zero-initialized SensorConfiguration is considered unpopulated\n+\t * as well.\n+\t */\n+\tif (!bitDepth &&\n+\t    binning.binX <= 1 && binning.binY <= 1 &&\n+\t    skipping.xOddInc <= 1 && skipping.yOddInc <= 1 &&\n+\t    skipping.xEvenInc <= 1 && skipping.yEvenInc <= 1 &&\n+\t    outputSize.isNull())\n+\t\treturn Unpopulated;\n+\n+\treturn Invalid;\n+}\n+\n /**\n  * \\class CameraConfiguration\n  * \\brief Hold configuration for streams of the camera\n@@ -391,6 +561,19 @@ CameraConfiguration::Status CameraConfiguration::validateColorSpaces(ColorSpaceF\n \treturn status;\n }\n \n+/**\n+ * \\var CameraConfiguration::sensorConfig\n+ * \\brief The camera sensor configuration\n+ *\n+ * The sensorConfig field allows control of the configuration of the camera\n+ * sensor. Refer to the camera-sensor-model documentation and to the\n+ * SensorConfiguration class documentation for details about the sensor\n+ * configuration process.\n+ *\n+ * The camera sensor configuration applies to all streams produced by a camera\n+ * from the same image source.\n+ */\n+\n /**\n  * \\var CameraConfiguration::transform\n  * \\brief User-specified transform to be applied to the image\n","prefixes":["libcamera-devel","v4","02/12"]}