Show a patch.

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

{
    "id": 17154,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/17154/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/17154/",
    "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": "<20220818090108.3004198-1-paul.elder@ideasonboard.com>",
    "date": "2022-08-18T09:01:08",
    "name": "[libcamera-devel,v2] ipa: rkisp1: Add manual color gains",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "c7394f1a9a3660bbe01f61ce04812286a050f82b",
    "submitter": {
        "id": 17,
        "url": "https://patchwork.libcamera.org/api/1.1/people/17/?format=api",
        "name": "Paul Elder",
        "email": "paul.elder@ideasonboard.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/17154/mbox/",
    "series": [
        {
            "id": 3425,
            "url": "https://patchwork.libcamera.org/api/1.1/series/3425/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3425",
            "date": "2022-08-18T09:01:08",
            "name": "[libcamera-devel,v2] ipa: rkisp1: Add manual color gains",
            "version": 2,
            "mbox": "https://patchwork.libcamera.org/series/3425/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/17154/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/17154/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 58BA8BE173\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 18 Aug 2022 09:01:25 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 9DC7A61FC0;\n\tThu, 18 Aug 2022 11:01:24 +0200 (CEST)",
            "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id E2F7261FA5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 18 Aug 2022 11:01:23 +0200 (CEST)",
            "from pyrite.rasen.tech (KD027085204050.au-net.ne.jp [27.85.204.50])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 094A38B;\n\tThu, 18 Aug 2022 11:01:21 +0200 (CEST)"
        ],
        "DKIM-Signature": [
            "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1660813284;\n\tbh=O6gwiW9k23xFMQJL7GGbkhSznu2fqV9SmdKcLDDZ8TU=;\n\th=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post:\n\tList-Help:List-Subscribe:From:Reply-To:From;\n\tb=2zigW3Wv35L3OhNF1M8xx9aP2964XPdyhO02X36xoNReouUX9I2DiKfr5gixw6DLE\n\tZYCercp77/reBBDa2KcaQ4pBVzCDTACxGz61s1HfGF/UJgmIMCTe3IdrXjxFpCDyBK\n\tcjVecOhG9p0w0QdlbkSLTmkPEPwiZIk+cEUtuNzSTa6wXqissGgNLB+t4yDAyDMzWe\n\tlZqyQkW45jn21wgFRf/hxgYKfGzmMkORRMDi1mMhr+0aUXVYYQ22o7TKErR+hVDRaE\n\tZ7kgNW9rDHOL74Rsr6jZbFbyCy4i00ueEakCamlr7SOJkGI/K2evt3BJkRc2IDSOv2\n\tsWgZPBcfoHipQ==",
            "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1660813283;\n\tbh=O6gwiW9k23xFMQJL7GGbkhSznu2fqV9SmdKcLDDZ8TU=;\n\th=From:To:Cc:Subject:Date:From;\n\tb=q6G5IPb6nD7h0DqpAk9BNMo+W9qSg1tiGFgEDE0AnbN99CERGyiMi3mK2lSKcgbXd\n\tUg/HwhAgEmaKGl/Q/rojcZDKIMrq11NWWR5oGmb9nAJy613wdUFrQtepaQx1kzveIQ\n\tqmvc0gdbdhnjB4SeYmnpRJ/n+jgyIef3BJu1vUsE="
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"q6G5IPb6\"; dkim-atps=neutral",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Thu, 18 Aug 2022 18:01:08 +0900",
        "Message-Id": "<20220818090108.3004198-1-paul.elder@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.30.2",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH v2] ipa: rkisp1: Add manual color gains",
        "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": "Paul Elder via libcamera-devel <libcamera-devel@lists.libcamera.org>",
        "Reply-To": "Paul Elder <paul.elder@ideasonboard.com>",
        "Errors-To": "libcamera-devel-bounces@lists.libcamera.org",
        "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"
    },
    "content": "Add support for manually controlling the color gains on the rkisp1 IPA.\nTo that end, add and plumb the AwbEnable and ColourGains controls. As\nper-frame controls aren't supported yet in the rkisp1 IPA, simply apply\nand perform checks on the controls immediately.\n\nSigned-off-by: Paul Elder <paul.elder@ideasonboard.com>\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n---\nChanges in v2:\n- s/enabled/autoEnabled\n  - add documentation\n- fixup construction of the ControlInfo\n---\n src/ipa/rkisp1/algorithms/awb.cpp | 36 +++++++++++++++++++++++++++++--\n src/ipa/rkisp1/algorithms/awb.h   |  3 +++\n src/ipa/rkisp1/ipa_context.cpp    |  3 +++\n src/ipa/rkisp1/ipa_context.h      |  1 +\n src/ipa/rkisp1/rkisp1.cpp         |  2 ++\n 5 files changed, 43 insertions(+), 2 deletions(-)",
    "diff": "diff --git a/src/ipa/rkisp1/algorithms/awb.cpp b/src/ipa/rkisp1/algorithms/awb.cpp\nindex 9f00364d..a3c14a9a 100644\n--- a/src/ipa/rkisp1/algorithms/awb.cpp\n+++ b/src/ipa/rkisp1/algorithms/awb.cpp\n@@ -12,6 +12,7 @@\n \n #include <libcamera/base/log.h>\n \n+#include <libcamera/control_ids.h>\n #include <libcamera/ipa/core_ipa_interface.h>\n \n /**\n@@ -38,6 +39,7 @@ int Awb::configure(IPAContext &context,\n \tcontext.frameContext.awb.gains.red = 1.0;\n \tcontext.frameContext.awb.gains.blue = 1.0;\n \tcontext.frameContext.awb.gains.green = 1.0;\n+\tcontext.frameContext.awb.autoEnabled = true;\n \n \t/*\n \t * Define the measurement window for AWB as a centered rectangle\n@@ -116,6 +118,34 @@ void Awb::prepare(IPAContext &context, rkisp1_params_cfg *params)\n \tparams->module_ens |= RKISP1_CIF_ISP_MODULE_AWB;\n }\n \n+/**\n+ * \\copydoc libcamera::ipa::Algorithm::queueRequest\n+ */\n+void Awb::queueRequest(IPAContext &context,\n+\t\t       [[maybe_unused]] const uint32_t frame,\n+\t\t       const ControlList &controls)\n+{\n+\tauto &awb = context.frameContext.awb;\n+\n+\tconst auto &awbEnable = controls.get(controls::AwbEnable);\n+\tif (awbEnable && *awbEnable != awb.autoEnabled) {\n+\t\tawb.autoEnabled = *awbEnable;\n+\n+\t\tLOG(RkISP1Awb, Debug)\n+\t\t\t<< (*awbEnable ? \"Enabling\" : \"Disabling\") << \" AWB\";\n+\t}\n+\n+\tconst auto &colourGains = controls.get(controls::ColourGains);\n+\tif (colourGains && !awb.autoEnabled) {\n+\t\tawb.gains.red = (*colourGains)[0];\n+\t\tawb.gains.blue = (*colourGains)[1];\n+\n+\t\tLOG(RkISP1Awb, Debug)\n+\t\t\t<< \"Set colour gains to red: \" << awb.gains.red\n+\t\t\t<< \", blue: \" << awb.gains.blue;\n+\t}\n+}\n+\n /**\n  * \\copydoc libcamera::ipa::Algorithm::process\n  */\n@@ -164,8 +194,10 @@ void Awb::process([[maybe_unused]] IPAContext &context,\n \t * Gain values are unsigned integer value, range 0 to 4 with 8 bit\n \t * fractional part.\n \t */\n-\tframeContext.awb.gains.red = std::clamp(redGain, 0.0, 1023.0 / 256);\n-\tframeContext.awb.gains.blue = std::clamp(blueGain, 0.0, 1023.0 / 256);\n+\tif (frameContext.awb.autoEnabled) {\n+\t\tframeContext.awb.gains.red = std::clamp(redGain, 0.0, 1023.0 / 256);\n+\t\tframeContext.awb.gains.blue = std::clamp(blueGain, 0.0, 1023.0 / 256);\n+\t}\n \t/* Hardcode the green gain to 1.0. */\n \tframeContext.awb.gains.green = 1.0;\n \ndiff --git a/src/ipa/rkisp1/algorithms/awb.h b/src/ipa/rkisp1/algorithms/awb.h\nindex 667a8beb..4332fac7 100644\n--- a/src/ipa/rkisp1/algorithms/awb.h\n+++ b/src/ipa/rkisp1/algorithms/awb.h\n@@ -21,6 +21,9 @@ public:\n \n \tint configure(IPAContext &context, const IPACameraSensorInfo &configInfo) override;\n \tvoid prepare(IPAContext &context, rkisp1_params_cfg *params) override;\n+\tvoid queueRequest(IPAContext &context,\n+\t\t\t  const uint32_t frame,\n+\t\t\t  const ControlList &controls);\n \tvoid process(IPAContext &context, IPAFrameContext *frameCtx,\n \t\t     const rkisp1_stat_buffer *stats) override;\n \ndiff --git a/src/ipa/rkisp1/ipa_context.cpp b/src/ipa/rkisp1/ipa_context.cpp\nindex ef8bb8e9..290569d0 100644\n--- a/src/ipa/rkisp1/ipa_context.cpp\n+++ b/src/ipa/rkisp1/ipa_context.cpp\n@@ -134,6 +134,9 @@ namespace libcamera::ipa::rkisp1 {\n  *\n  * \\var IPAFrameContext::awb.temperatureK\n  * \\brief Estimated color temperature\n+ *\n+ * \\var IPAFrameContext::awb.autoEnabled\n+ * \\brief Whether the Auto White Balance algorithm is enabled\n  */\n \n /**\ndiff --git a/src/ipa/rkisp1/ipa_context.h b/src/ipa/rkisp1/ipa_context.h\nindex 2bdb6a81..68f92297 100644\n--- a/src/ipa/rkisp1/ipa_context.h\n+++ b/src/ipa/rkisp1/ipa_context.h\n@@ -55,6 +55,7 @@ struct IPAFrameContext {\n \t\t} gains;\n \n \t\tdouble temperatureK;\n+\t\tbool autoEnabled;\n \t} awb;\n \n \tstruct {\ndiff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp\nindex 17d42d38..27b4212b 100644\n--- a/src/ipa/rkisp1/rkisp1.cpp\n+++ b/src/ipa/rkisp1/rkisp1.cpp\n@@ -92,6 +92,8 @@ namespace {\n /* List of controls handled by the RkISP1 IPA */\n const ControlInfoMap::Map rkisp1Controls{\n \t{ &controls::AeEnable, ControlInfo(false, true) },\n+\t{ &controls::AwbEnable, ControlInfo(false, true) },\n+\t{ &controls::ColourGains, ControlInfo(0.0f, 3.996f, 1.0f) },\n \t{ &controls::Brightness, ControlInfo(-1.0f, 0.993f) },\n \t{ &controls::Contrast, ControlInfo(0.0f, 1.993f) },\n \t{ &controls::Saturation, ControlInfo(0.0f, 1.993f) },\n",
    "prefixes": [
        "libcamera-devel",
        "v2"
    ]
}