Show a patch.

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

{
    "id": 20504,
    "url": "https://patchwork.libcamera.org/api/patches/20504/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/20504/",
    "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": "<20240703104004.184783-5-stefan.klug@ideasonboard.com>",
    "date": "2024-07-03T10:39:51",
    "name": "[v2,4/6] ipa: rkisp1: blc: Report sensor black levels in metadata",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "a47dcabac244a258d7835f59612d68709d08a1b7",
    "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/20504/mbox/",
    "series": [
        {
            "id": 4435,
            "url": "https://patchwork.libcamera.org/api/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/20504/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/20504/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 215A2BEFBE\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  3 Jul 2024 10:40:28 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 711DE63334;\n\tWed,  3 Jul 2024 12:40:27 +0200 (CEST)",
            "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 36E8462E25\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  3 Jul 2024 12:40:23 +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 27C116D6;\n\tWed,  3 Jul 2024 12:39:55 +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=\"DhBqgwJe\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1720003195;\n\tbh=XVpE0gqzyfuvdVCeycPDg3ZtgWWWa1emzt9Ylz3TJzI=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=DhBqgwJetlX9noUaUW5P/xPySApepe/PZjK9USJUif0JS+8RmE3GY381PqhdIiBN1\n\t8GXsbIqCO/20tNYZY9CHJOBf2sDjr9vDCBQndgFrcl/i3Xhq7OJmkJQa/IbI/bkJJq\n\tOr75p8nUOEWjW73JkF9yAui459tklgKJAV+SVnWI=",
        "From": "Stefan Klug <stefan.klug@ideasonboard.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Cc": "Stefan Klug <stefan.klug@ideasonboard.com>",
        "Subject": "[PATCH v2 4/6] ipa: rkisp1: blc: Report sensor black levels in\n\tmetadata",
        "Date": "Wed,  3 Jul 2024 12:39:51 +0200",
        "Message-ID": "<20240703104004.184783-5-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": "Add sensor black levels to the metadata of the rkisp1 pipeline.\n\nAdditionally enable raw support for this algorithm and add it to\nuncalibrated.yaml, so that black levels get reported when capturing\ntuning images. This is a bit of a hack, because no actual black level\ncorrection is taking place in raw mode, but it is the easiest way to get\nblacklevel reported for raw streams.\n\nSigned-off-by: Stefan Klug <stefan.klug@ideasonboard.com>\n---\n src/ipa/rkisp1/algorithms/blc.cpp     | 28 +++++++++++++++++++++++++++\n src/ipa/rkisp1/algorithms/blc.h       |  5 ++++-\n src/ipa/rkisp1/data/uncalibrated.yaml |  1 +\n 3 files changed, 33 insertions(+), 1 deletion(-)",
    "diff": "diff --git a/src/ipa/rkisp1/algorithms/blc.cpp b/src/ipa/rkisp1/algorithms/blc.cpp\nindex 87025e4f8c72..71c62b009707 100644\n--- a/src/ipa/rkisp1/algorithms/blc.cpp\n+++ b/src/ipa/rkisp1/algorithms/blc.cpp\n@@ -9,6 +9,8 @@\n \n #include <libcamera/base/log.h>\n \n+#include <libcamera/control_ids.h>\n+\n #include \"libcamera/internal/yaml_parser.h\"\n \n /**\n@@ -38,6 +40,13 @@ LOG_DEFINE_CATEGORY(RkISP1Blc)\n BlackLevelCorrection::BlackLevelCorrection()\n \t: tuningParameters_(false)\n {\n+\t/*\n+\t * This is a bit of a hack. In raw mode no black level correction\n+\t * happens. This flag is used to ensure the metadata gets populated with\n+\t * the black level which is needed to capture proper raw images for\n+\t * tuning.\n+\t */\n+\tsupportsRaw_ = true;\n }\n \n /**\n@@ -107,6 +116,9 @@ void BlackLevelCorrection::prepare([[maybe_unused]] IPAContext &context,\n \t\t\t\t   [[maybe_unused]] IPAFrameContext &frameContext,\n \t\t\t\t   rkisp1_params_cfg *params)\n {\n+\tif (context.configuration.raw)\n+\t\treturn;\n+\n \tif (frame > 0)\n \t\treturn;\n \n@@ -125,6 +137,22 @@ void BlackLevelCorrection::prepare([[maybe_unused]] IPAContext &context,\n \tparams->module_cfg_update |= RKISP1_CIF_ISP_MODULE_BLS;\n }\n \n+/**\n+ * \\copydoc libcamera::ipa::Algorithm::process\n+ */\n+void BlackLevelCorrection::process([[maybe_unused]] IPAContext &context,\n+\t\t\t\t   [[maybe_unused]] const uint32_t frame,\n+\t\t\t\t   [[maybe_unused]] IPAFrameContext &frameContext,\n+\t\t\t\t   [[maybe_unused]] const rkisp1_stat_buffer *stats,\n+\t\t\t\t   [[maybe_unused]] ControlList &metadata)\n+{\n+\tmetadata.set(controls::SensorBlackLevels,\n+\t\t     { static_cast<int32_t>(blackLevelRed_),\n+\t\t       static_cast<int32_t>(blackLevelGreenR_),\n+\t\t       static_cast<int32_t>(blackLevelGreenB_),\n+\t\t       static_cast<int32_t>(blackLevelBlue_) });\n+}\n+\n REGISTER_IPA_ALGORITHM(BlackLevelCorrection, \"BlackLevelCorrection\")\n \n } /* namespace ipa::rkisp1::algorithms */\ndiff --git a/src/ipa/rkisp1/algorithms/blc.h b/src/ipa/rkisp1/algorithms/blc.h\nindex 460ebcc15739..4ecac233f88b 100644\n--- a/src/ipa/rkisp1/algorithms/blc.h\n+++ b/src/ipa/rkisp1/algorithms/blc.h\n@@ -23,7 +23,10 @@ public:\n \tvoid prepare(IPAContext &context, const uint32_t frame,\n \t\t     IPAFrameContext &frameContext,\n \t\t     rkisp1_params_cfg *params) override;\n-\n+\tvoid process(IPAContext &context, const uint32_t frame,\n+\t\t     IPAFrameContext &frameContext,\n+\t\t     const rkisp1_stat_buffer *stats,\n+\t\t     ControlList &metadata) override;\n private:\n \tbool tuningParameters_;\n \tint16_t blackLevelRed_;\ndiff --git a/src/ipa/rkisp1/data/uncalibrated.yaml b/src/ipa/rkisp1/data/uncalibrated.yaml\nindex a7bbd8d84263..609012967e02 100644\n--- a/src/ipa/rkisp1/data/uncalibrated.yaml\n+++ b/src/ipa/rkisp1/data/uncalibrated.yaml\n@@ -5,4 +5,5 @@ version: 1\n algorithms:\n   - Agc:\n   - Awb:\n+  - BlackLevelCorrection:\n ...\n",
    "prefixes": [
        "v2",
        "4/6"
    ]
}