Show a patch.

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

{
    "id": 17643,
    "url": "https://patchwork.libcamera.org/api/patches/17643/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/17643/",
    "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": "<20221019205614.25751-4-laurent.pinchart@ideasonboard.com>",
    "date": "2022-10-19T20:56:14",
    "name": "[libcamera-devel,v2,3/3] ipa: ipu3: Fill AGC and AWB metadata in algorithms",
    "commit_ref": "11f5c3ad0561a4e4b1e06f477ab2022c69803ad2",
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "d6421ce8cd166e1cec144952b52c866bd1d1c3e0",
    "submitter": {
        "id": 2,
        "url": "https://patchwork.libcamera.org/api/people/2/?format=api",
        "name": "Laurent Pinchart",
        "email": "laurent.pinchart@ideasonboard.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/17643/mbox/",
    "series": [
        {
            "id": 3570,
            "url": "https://patchwork.libcamera.org/api/series/3570/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3570",
            "date": "2022-10-19T20:56:11",
            "name": "ipa: Fill metadata in individual algorithms",
            "version": 2,
            "mbox": "https://patchwork.libcamera.org/series/3570/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/17643/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/17643/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 5B586C327C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 19 Oct 2022 20:56:46 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 071D762E69;\n\tWed, 19 Oct 2022 22:56:46 +0200 (CEST)",
            "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id CFDF362E61\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 19 Oct 2022 22:56:42 +0200 (CEST)",
            "from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 5FE13903\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 19 Oct 2022 22:56:42 +0200 (CEST)"
        ],
        "DKIM-Signature": [
            "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1666213006;\n\tbh=outIGZNDFhfw+v/f0Xrt5Zk6YNJRbV269r4O/NHohC4=;\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:\n\tFrom;\n\tb=Ev7smDNZkK0Nof8ATP/4N6lf58A5d9/gOqYTAU8bvPokPaZWA4dKxiLZr+TsHjZHg\n\tXWeUON82MWinVhQh9W5CMfqy3RSxykZklK4V95LhnyJ6+nGKXI19Ra1dllU5m5Ma7Z\n\tDF8i3+Djd90fH67PSCdzLwJNCMZKcoYlR1GO2UDTdoxlIZXpHcoXmBbtnTUnH51oyj\n\tpGSD0qJk36LJrBLVMXPpkdBh1v8txR4vPJsfo5xlu9DQ1M4OFVScQp5XmbUsyGv0Bx\n\tjQoIHUuv60OzRCt2y5fl5TN1vJ/q5S/fEtHFR96Kl5hRoQayIJc7dZyv9wBRJ52djK\n\tTOWzUEVb8stDw==",
            "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1666213002;\n\tbh=outIGZNDFhfw+v/f0Xrt5Zk6YNJRbV269r4O/NHohC4=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=YpHCkjFMa1e1JGIC2YxAbH0UswVSRS6y+X8efXZEWhDoRM3JuN8sQ0u0DypvQI4+5\n\tcIs2Ibl3kUwL/KgIABbwne7FAL9O+QoFqkBSNR+msuX93QoBc9zAF3fiaXo+1fGl6w\n\tB7YgRCFx+JUa+fmPxWI4czkNs/6jp33EL8bDlMRY="
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"YpHCkjFM\"; dkim-atps=neutral",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Wed, 19 Oct 2022 23:56:14 +0300",
        "Message-Id": "<20221019205614.25751-4-laurent.pinchart@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.37.3",
        "In-Reply-To": "<20221019205614.25751-1-laurent.pinchart@ideasonboard.com>",
        "References": "<20221019205614.25751-1-laurent.pinchart@ideasonboard.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH v2 3/3] ipa: ipu3: Fill AGC and AWB\n\tmetadata in algorithms",
        "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": "Laurent Pinchart via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>",
        "Reply-To": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>",
        "Errors-To": "libcamera-devel-bounces@lists.libcamera.org",
        "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"
    },
    "content": "Fill the frame metadata in the AGC and AWB algorithm's prepare()\nfunction. This removes the need to fill metadata manually in the IPA\nmodule's processStatsBuffer() function.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n src/ipa/ipu3/algorithms/agc.cpp | 16 +++++++++++++++-\n src/ipa/ipu3/algorithms/awb.cpp | 10 ++++++++++\n src/ipa/ipu3/ipa_context.cpp    |  3 +++\n src/ipa/ipu3/ipa_context.h      |  1 +\n src/ipa/ipu3/ipu3.cpp           | 13 +------------\n 5 files changed, 30 insertions(+), 13 deletions(-)",
    "diff": "diff --git a/src/ipa/ipu3/algorithms/agc.cpp b/src/ipa/ipu3/algorithms/agc.cpp\nindex f4e559bf8b84..b5309bdbea25 100644\n--- a/src/ipa/ipu3/algorithms/agc.cpp\n+++ b/src/ipa/ipu3/algorithms/agc.cpp\n@@ -14,6 +14,7 @@\n #include <libcamera/base/log.h>\n #include <libcamera/base/utils.h>\n \n+#include <libcamera/control_ids.h>\n #include <libcamera/ipa/core_ipa_interface.h>\n \n #include \"libipa/histogram.h\"\n@@ -328,7 +329,7 @@ double Agc::estimateLuminance(IPAActiveState &activeState,\n void Agc::process(IPAContext &context, [[maybe_unused]] const uint32_t frame,\n \t\t  IPAFrameContext &frameContext,\n \t\t  const ipu3_uapi_stats_3a *stats,\n-\t\t  [[maybe_unused]] ControlList &metadata)\n+\t\t  ControlList &metadata)\n {\n \t/*\n \t * Estimate the gain needed to have the proportion of pixels in a given\n@@ -365,6 +366,19 @@ void Agc::process(IPAContext &context, [[maybe_unused]] const uint32_t frame,\n \n \tcomputeExposure(context, frameContext, yGain, iqMeanGain);\n \tframeCount_++;\n+\n+\tutils::Duration exposureTime = context.configuration.sensor.lineDuration\n+\t\t\t\t     * frameContext.sensor.exposure;\n+\tmetadata.set(controls::AnalogueGain, frameContext.sensor.gain);\n+\tmetadata.set(controls::ExposureTime, exposureTime.get<std::micro>());\n+\n+\t/* \\todo Use VBlank value calculated from each frame exposure. */\n+\tuint32_t vTotal = context.configuration.sensor.size.height\n+\t\t\t+ context.configuration.sensor.defVBlank;\n+\tutils::Duration frameDuration = context.configuration.sensor.lineDuration\n+\t\t\t\t      * vTotal;\n+\tmetadata.set(controls::FrameDuration, frameDuration.get<std::micro>());\n+\n }\n \n REGISTER_IPA_ALGORITHM(Agc, \"Agc\")\ndiff --git a/src/ipa/ipu3/algorithms/awb.cpp b/src/ipa/ipu3/algorithms/awb.cpp\nindex 6452b6a1acd2..dd7ebc07c534 100644\n--- a/src/ipa/ipu3/algorithms/awb.cpp\n+++ b/src/ipa/ipu3/algorithms/awb.cpp\n@@ -11,6 +11,8 @@\n \n #include <libcamera/base/log.h>\n \n+#include <libcamera/control_ids.h>\n+\n /**\n  * \\file awb.h\n  */\n@@ -403,6 +405,14 @@ void Awb::process(IPAContext &context, [[maybe_unused]] const uint32_t frame,\n \tcontext.activeState.awb.gains.green = asyncResults_.greenGain;\n \tcontext.activeState.awb.gains.red = asyncResults_.redGain;\n \tcontext.activeState.awb.temperatureK = asyncResults_.temperatureK;\n+\n+\tmetadata.set(controls::AwbEnable, true);\n+\tmetadata.set(controls::ColourGains, {\n+\t\t\tstatic_cast<float>(context.activeState.awb.gains.red),\n+\t\t\tstatic_cast<float>(context.activeState.awb.gains.blue)\n+\t\t});\n+\tmetadata.set(controls::ColourTemperature,\n+\t\t     context.activeState.awb.temperatureK);\n }\n \n constexpr uint16_t Awb::threshold(float value)\ndiff --git a/src/ipa/ipu3/ipa_context.cpp b/src/ipa/ipu3/ipa_context.cpp\nindex 68f017b04751..959f314f5452 100644\n--- a/src/ipa/ipu3/ipa_context.cpp\n+++ b/src/ipa/ipu3/ipa_context.cpp\n@@ -111,6 +111,9 @@ namespace libcamera::ipa::ipu3 {\n  *\n  * \\var IPASessionConfiguration::sensor.defVBlank\n  * \\brief The default vblank value of the sensor\n+ *\n+ * \\var IPASessionConfiguration::sensor.size\n+ * \\brief Sensor output resolution\n  */\n \n /**\ndiff --git a/src/ipa/ipu3/ipa_context.h b/src/ipa/ipu3/ipa_context.h\nindex 36099353e9f2..e9a3863b1693 100644\n--- a/src/ipa/ipu3/ipa_context.h\n+++ b/src/ipa/ipu3/ipa_context.h\n@@ -41,6 +41,7 @@ struct IPASessionConfiguration {\n \tstruct {\n \t\tint32_t defVBlank;\n \t\tutils::Duration lineDuration;\n+\t\tSize size;\n \t} sensor;\n };\n \ndiff --git a/src/ipa/ipu3/ipu3.cpp b/src/ipa/ipu3/ipu3.cpp\nindex bc0f6007baca..a9a2b49ca95b 100644\n--- a/src/ipa/ipu3/ipu3.cpp\n+++ b/src/ipa/ipu3/ipu3.cpp\n@@ -502,6 +502,7 @@ int IPAIPU3::configure(const IPAConfigInfo &configInfo,\n \t/* Initialise the sensor configuration. */\n \tcontext_.configuration.sensor.lineDuration = sensorInfo_.minLineLength\n \t\t\t\t\t\t   * 1.0s / sensorInfo_.pixelRate;\n+\tcontext_.configuration.sensor.size = sensorInfo_.outputSize;\n \n \t/*\n \t * Compute the sensor V4L2 controls to be used by the algorithms and\n@@ -628,8 +629,6 @@ void IPAIPU3::processStatsBuffer(const uint32_t frame,\n \tframeContext.sensor.exposure = sensorControls.get(V4L2_CID_EXPOSURE).get<int32_t>();\n \tframeContext.sensor.gain = camHelper_->gain(sensorControls.get(V4L2_CID_ANALOGUE_GAIN).get<int32_t>());\n \n-\tdouble lineDuration = context_.configuration.sensor.lineDuration.get<std::micro>();\n-\tint32_t vBlank = context_.configuration.sensor.defVBlank;\n \tControlList metadata(controls::controls);\n \n \tfor (auto const &algo : algorithms())\n@@ -637,16 +636,6 @@ void IPAIPU3::processStatsBuffer(const uint32_t frame,\n \n \tsetControls(frame);\n \n-\t/* \\todo Use VBlank value calculated from each frame exposure. */\n-\tint64_t frameDuration = (vBlank + sensorInfo_.outputSize.height) * lineDuration;\n-\tmetadata.set(controls::FrameDuration, frameDuration);\n-\n-\tmetadata.set(controls::AnalogueGain, frameContext.sensor.gain);\n-\n-\tmetadata.set(controls::ColourTemperature, context_.activeState.awb.temperatureK);\n-\n-\tmetadata.set(controls::ExposureTime, frameContext.sensor.exposure * lineDuration);\n-\n \t/*\n \t * \\todo The Metadata provides a path to getting extended data\n \t * out to the application. Further data such as a simplifed Histogram\n",
    "prefixes": [
        "libcamera-devel",
        "v2",
        "3/3"
    ]
}