Show a patch.

GET /api/1.1/patches/20501/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 20501,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/20501/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/20501/",
    "project": {
        "id": 1,
        "url": "https://patchwork.libcamera.org/api/1.1/projects/1/?format=api",
        "name": "libcamera",
        "link_name": "libcamera",
        "list_id": "libcamera_core",
        "list_email": "libcamera-devel@lists.libcamera.org",
        "web_url": "",
        "scm_url": "",
        "webscm_url": ""
    },
    "msgid": "<20240703104004.184783-2-stefan.klug@ideasonboard.com>",
    "date": "2024-07-03T10:39:48",
    "name": "[v2,1/6] ipa: libipa: Add black levels to camera sensor helper",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "a55fb8ea6e5f86ad823e8740b6e70b4a3ef81e1d",
    "submitter": {
        "id": 184,
        "url": "https://patchwork.libcamera.org/api/1.1/people/184/?format=api",
        "name": "Stefan Klug",
        "email": "stefan.klug@ideasonboard.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/20501/mbox/",
    "series": [
        {
            "id": 4435,
            "url": "https://patchwork.libcamera.org/api/1.1/series/4435/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=4435",
            "date": "2024-07-03T10:39:47",
            "name": "ipa: Add black level to camera sensor helpers",
            "version": 2,
            "mbox": "https://patchwork.libcamera.org/series/4435/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/20501/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/20501/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 3F83ABEFBE\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  3 Jul 2024 10:40:17 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id DE92862E25;\n\tWed,  3 Jul 2024 12:40:16 +0200 (CEST)",
            "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 2246C62C95\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  3 Jul 2024 12:40:15 +0200 (CEST)",
            "from ideasonboard.com (unknown\n\t[IPv6:2a00:6020:448c:6c00:9263:c199:9587:576])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 125046D6;\n\tWed,  3 Jul 2024 12:39:47 +0200 (CEST)"
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"GMH3gIv1\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1720003187;\n\tbh=dBTzKx/UVMGyiAOzeu1YD+O1cwsF+xeLRK6elxGwmXo=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=GMH3gIv13mGr9tTo4qNV8n0Y1uhTKB5tyr3YqJDLQDCAOqJcOJe/vaXMiSKL1dma4\n\t2o3FlTq2u7ZTDy6TbVuB3Eshou38jfSKO7t//p0cA1+cK1PS52Z/LlGDTtp+9FUOrx\n\tDHSB7DSWjTuA5Sn5Mr7DjV3PgI/IZgd1iGNzlUxY=",
        "From": "Stefan Klug <stefan.klug@ideasonboard.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Cc": "Stefan Klug <stefan.klug@ideasonboard.com>",
        "Subject": "[PATCH v2 1/6] ipa: libipa: Add black levels to camera sensor helper",
        "Date": "Wed,  3 Jul 2024 12:39:48 +0200",
        "Message-ID": "<20240703104004.184783-2-stefan.klug@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.43.0",
        "In-Reply-To": "<20240703104004.184783-1-stefan.klug@ideasonboard.com>",
        "References": "<20240703104004.184783-1-stefan.klug@ideasonboard.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "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>",
        "Errors-To": "libcamera-devel-bounces@lists.libcamera.org",
        "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"
    },
    "content": "For a proper tuning process we need to know the sensor black levels. In\nmost cases these are fixed and not reported by the kernel driver. Store\nthem inside the sensor helpers for later retrieval by the algorithms.\n\nAdd black level value corresponding to the data pedestal for three\ninitial sensors as documented in the datasheets. More should be added,\neventually filling the gaps for all supported sensors.\n\nSigned-off-by: Stefan Klug <stefan.klug@ideasonboard.com>\n---\n src/ipa/libipa/camera_sensor_helper.cpp | 27 +++++++++++++++++++++++++\n src/ipa/libipa/camera_sensor_helper.h   |  3 +++\n 2 files changed, 30 insertions(+)",
    "diff": "diff --git a/src/ipa/libipa/camera_sensor_helper.cpp b/src/ipa/libipa/camera_sensor_helper.cpp\nindex 782ff9904e81..3d0e756927f0 100644\n--- a/src/ipa/libipa/camera_sensor_helper.cpp\n+++ b/src/ipa/libipa/camera_sensor_helper.cpp\n@@ -47,6 +47,30 @@ namespace ipa {\n  * function.\n  */\n \n+/**\n+ * \\fn CameraSensorHelper::blackLevel()\n+ * \\brief Fetch the black level of the sensor\n+ *\n+ * This function returns the black level of the sensor scaled to a 16bit pixel\n+ * width. If it is unknown an empty optional is returned.\n+ *\n+ * Black levels are typically the result of the following phenomena:\n+ * - Pedestal added by the sensor to pixel values. They are typically fixed,\n+ *   sometimes programmable and should be reported in datasheets (but\n+ *   documentation is not always available).\n+ * - Dark currents and other physical effects that add charge to pixels in the\n+ *   absence of light. Those can depend on the integration time and the sensor\n+ *   die temperature, and their contribution to pixel values depend on the\n+ *   sensor gains.\n+ *\n+ * The pedestal is usually the value with the biggest contribution to the\n+ * overall black level. In most cases it is either known before or in rare cases\n+ * (There is not a single driver with such a control in the linux kernel) can be\n+ * queried from the sensor. This function shall provide that fixed, known value.\n+ *\n+ * \\return The black level of the sensor, or std::nullopt if not known\n+ */\n+\n /**\n  * \\brief Compute gain code from the analogue gain absolute value\n  * \\param[in] gain The real gain to pass\n@@ -396,6 +420,7 @@ class CameraSensorHelperImx219 : public CameraSensorHelper\n public:\n \tCameraSensorHelperImx219()\n \t{\n+\t\tblackLevel_ = 4096;\n \t\tgainType_ = AnalogueGainLinear;\n \t\tgainConstants_.linear = { 0, 256, -1, 256 };\n \t}\n@@ -407,6 +432,7 @@ class CameraSensorHelperImx258 : public CameraSensorHelper\n public:\n \tCameraSensorHelperImx258()\n \t{\n+\t\tblackLevel_ = 4096;\n \t\tgainType_ = AnalogueGainLinear;\n \t\tgainConstants_.linear = { 0, 512, -1, 512 };\n \t}\n@@ -456,6 +482,7 @@ class CameraSensorHelperImx335 : public CameraSensorHelper\n public:\n \tCameraSensorHelperImx335()\n \t{\n+\t\tblackLevel_ = 3200;\n \t\tgainType_ = AnalogueGainExponential;\n \t\tgainConstants_.exp = { 1.0, expGainDb(0.3) };\n \t}\ndiff --git a/src/ipa/libipa/camera_sensor_helper.h b/src/ipa/libipa/camera_sensor_helper.h\nindex 0d99073bea82..ac276e27f523 100644\n--- a/src/ipa/libipa/camera_sensor_helper.h\n+++ b/src/ipa/libipa/camera_sensor_helper.h\n@@ -10,6 +10,7 @@\n #include <stdint.h>\n \n #include <memory>\n+#include <optional>\n #include <string>\n #include <vector>\n \n@@ -25,6 +26,7 @@ public:\n \tCameraSensorHelper() = default;\n \tvirtual ~CameraSensorHelper() = default;\n \n+\tstd::optional<int16_t> blackLevel() const { return blackLevel_; }\n \tvirtual uint32_t gainCode(double gain) const;\n \tvirtual double gain(uint32_t gainCode) const;\n \n@@ -51,6 +53,7 @@ protected:\n \t\tAnalogueGainExpConstants exp;\n \t};\n \n+\tstd::optional<int16_t> blackLevel_;\n \tAnalogueGainType gainType_;\n \tAnalogueGainConstants gainConstants_;\n \n",
    "prefixes": [
        "v2",
        "1/6"
    ]
}