Show a patch.

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

{
    "id": 20494,
    "url": "https://patchwork.libcamera.org/api/patches/20494/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/20494/",
    "project": {
        "id": 1,
        "url": "https://patchwork.libcamera.org/api/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": "<20240701144122.3418955-2-stefan.klug@ideasonboard.com>",
    "date": "2024-07-01T14:38:24",
    "name": "[1/5] ipa: libipa: Add black levels to camera sensor helper",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "4fa88bc1d0db4ce1f3ede16fcd92646721ad3a6f",
    "submitter": {
        "id": 184,
        "url": "https://patchwork.libcamera.org/api/people/184/?format=api",
        "name": "Stefan Klug",
        "email": "stefan.klug@ideasonboard.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/20494/mbox/",
    "series": [
        {
            "id": 4433,
            "url": "https://patchwork.libcamera.org/api/series/4433/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=4433",
            "date": "2024-07-01T14:38:23",
            "name": "ipa: Add black level to camera sensor helpers",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/4433/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/20494/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/20494/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 85B77BEFBE\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon,  1 Jul 2024 14:41:42 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 4318C62E17;\n\tMon,  1 Jul 2024 16:41:42 +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 5E6EA62E01\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  1 Jul 2024 16:41:39 +0200 (CEST)",
            "from ideasonboard.com (unknown\n\t[IPv6:2a00:6020:448c:6c00:89b2:f6c7:b29b:4e5c])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 9B133289;\n\tMon,  1 Jul 2024 16:41:12 +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=\"N8mbrIJ7\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1719844872;\n\tbh=9OfEPJgunPUuDfUjcEI6VFfSww4n4UtaKQheV72OlXk=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=N8mbrIJ7RuHrKJWTkR1pTt5wNme1Pm8yFDyXloZ8QaXoGHu4hX4hk5EZaXNjZzIBr\n\tLzbH5o4KjKf0OqwjzyyTYgjZXBhwWYj+iY1lWJX+dgnX2w5GK2Y00A0NzR+/98oTTp\n\tJDS+M+ltukVwaIulmrYGynlXi2vq97aO1Ltseoao=",
        "From": "Stefan Klug <stefan.klug@ideasonboard.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Cc": "Stefan Klug <stefan.klug@ideasonboard.com>",
        "Subject": "[PATCH 1/5] ipa: libipa: Add black levels to camera sensor helper",
        "Date": "Mon,  1 Jul 2024 16:38:24 +0200",
        "Message-ID": "<20240701144122.3418955-2-stefan.klug@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.43.0",
        "In-Reply-To": "<20240701144122.3418955-1-stefan.klug@ideasonboard.com>",
        "References": "<20240701144122.3418955-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\nSigned-off-by: Stefan Klug <stefan.klug@ideasonboard.com>\n---\n src/ipa/libipa/camera_sensor_helper.cpp | 18 ++++++++++++++++++\n src/ipa/libipa/camera_sensor_helper.h   |  6 ++++++\n 2 files changed, 24 insertions(+)",
    "diff": "diff --git a/src/ipa/libipa/camera_sensor_helper.cpp b/src/ipa/libipa/camera_sensor_helper.cpp\nindex 782ff9904e81..6d8850eb25a5 100644\n--- a/src/ipa/libipa/camera_sensor_helper.cpp\n+++ b/src/ipa/libipa/camera_sensor_helper.cpp\n@@ -47,6 +47,21 @@ namespace ipa {\n  * function.\n  */\n \n+/**\n+ * \\brief Fetch the black levels of the sensor\n+ *\n+ * This function returns the black levels of the sensor with respect to a 16bit\n+ * pixel width in R, Gr, Gb, B order. If these are unknown an empty optional is\n+ * returned.\n+ *\n+ * \\return The black levels of the sensor\n+ */\n+std::optional<CameraSensorHelper::BlackLevels>\n+CameraSensorHelper::blackLevels() const\n+{\n+\treturn blackLevels_;\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 +411,7 @@ class CameraSensorHelperImx219 : public CameraSensorHelper\n public:\n \tCameraSensorHelperImx219()\n \t{\n+\t\tblackLevels_ = { 4096, 4096, 4096, 4096 };\n \t\tgainType_ = AnalogueGainLinear;\n \t\tgainConstants_.linear = { 0, 256, -1, 256 };\n \t}\n@@ -407,6 +423,7 @@ class CameraSensorHelperImx258 : public CameraSensorHelper\n public:\n \tCameraSensorHelperImx258()\n \t{\n+\t\tblackLevels_ = { 4096, 4096, 4096, 4096 };\n \t\tgainType_ = AnalogueGainLinear;\n \t\tgainConstants_.linear = { 0, 512, -1, 512 };\n \t}\n@@ -456,6 +473,7 @@ class CameraSensorHelperImx335 : public CameraSensorHelper\n public:\n \tCameraSensorHelperImx335()\n \t{\n+\t\tblackLevels_ = { 3200, 3200, 3200, 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..f025727c06ee 100644\n--- a/src/ipa/libipa/camera_sensor_helper.h\n+++ b/src/ipa/libipa/camera_sensor_helper.h\n@@ -9,7 +9,9 @@\n \n #include <stdint.h>\n \n+#include <array>\n #include <memory>\n+#include <optional>\n #include <string>\n #include <vector>\n \n@@ -22,9 +24,12 @@ namespace ipa {\n class CameraSensorHelper\n {\n public:\n+\ttypedef std::array<int32_t, 4> BlackLevels;\n+\n \tCameraSensorHelper() = default;\n \tvirtual ~CameraSensorHelper() = default;\n \n+\tvirtual std::optional<BlackLevels> blackLevels() const;\n \tvirtual uint32_t gainCode(double gain) const;\n \tvirtual double gain(uint32_t gainCode) const;\n \n@@ -51,6 +56,7 @@ protected:\n \t\tAnalogueGainExpConstants exp;\n \t};\n \n+\tstd::optional<BlackLevels> blackLevels_;\n \tAnalogueGainType gainType_;\n \tAnalogueGainConstants gainConstants_;\n \n",
    "prefixes": [
        "1/5"
    ]
}