Show a patch.

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

{
    "id": 13253,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/13253/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/13253/",
    "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": "<20210809092007.79067-3-jeanmichel.hautbois@ideasonboard.com>",
    "date": "2021-08-09T09:20:04",
    "name": "[libcamera-devel,RFC,2/5] ipa: ipu3: Introduce modular algorithms",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "c43dbc4d00d01786cd6e079d0f9284d5dfd39383",
    "submitter": {
        "id": 75,
        "url": "https://patchwork.libcamera.org/api/1.1/people/75/?format=api",
        "name": "Jean-Michel Hautbois",
        "email": "jeanmichel.hautbois@ideasonboard.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/13253/mbox/",
    "series": [
        {
            "id": 2320,
            "url": "https://patchwork.libcamera.org/api/1.1/series/2320/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=2320",
            "date": "2021-08-09T09:20:02",
            "name": "IPU3: Introduce modularity for algorithms",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/2320/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/13253/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/13253/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 81230BD87D\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon,  9 Aug 2021 09:20:20 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 3FE1E68864;\n\tMon,  9 Aug 2021 11:20:20 +0200 (CEST)",
            "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 3770A68826\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  9 Aug 2021 11:20:16 +0200 (CEST)",
            "from tatooine.ideasonboard.com (unknown\n\t[IPv6:2a01:e0a:169:7140:14c5:c0eb:b1fb:db22])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id D74B94A1;\n\tMon,  9 Aug 2021 11:20:15 +0200 (CEST)"
        ],
        "Authentication-Results": "lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"CaWiKM0b\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1628500815;\n\tbh=A3Lt+YMe0FeKiiDBhL7+1hPAh1k7tHbw8GSzNrytY5c=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=CaWiKM0bC+JMvISK4KZZJEVIylBsVLmltRO0ZDWs/V4SKuS4moBPEeWqoPnSR2V1i\n\tqVqz8SMJkJCmk32Ls5kvRAlctJiIxW1yE+uVDPJSP/r+bt42cyMzD0D8angMhv9aNz\n\tE9ko74O96oe3VIgv/uEF2A7cpE4wD60MHf0C2PcY=",
        "From": "Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Mon,  9 Aug 2021 11:20:04 +0200",
        "Message-Id": "<20210809092007.79067-3-jeanmichel.hautbois@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.30.2",
        "In-Reply-To": "<20210809092007.79067-1-jeanmichel.hautbois@ideasonboard.com>",
        "References": "<20210809092007.79067-1-jeanmichel.hautbois@ideasonboard.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [RFC PATCH 2/5] ipa: ipu3: Introduce modular\n\talgorithms",
        "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": "Provide a modular IPU3 specific algorithm, and frame context\nstructure so that algorithms can be built for the IPU3 in a\ncomponent based structure.\n\nSigned-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\nSigned-off-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>\n---\n src/ipa/ipu3/algorithms/algorithm.h | 30 ++++++++++++++++++\n src/ipa/ipu3/algorithms/meson.build |  4 +++\n src/ipa/ipu3/ipu3.cpp               | 47 +++++++++++++++++++++++++++++\n src/ipa/ipu3/ipu3_agc.h             |  3 +-\n src/ipa/ipu3/ipu3_awb.h             |  3 +-\n src/ipa/ipu3/meson.build            |  4 +++\n 6 files changed, 89 insertions(+), 2 deletions(-)\n create mode 100644 src/ipa/ipu3/algorithms/algorithm.h\n create mode 100644 src/ipa/ipu3/algorithms/meson.build",
    "diff": "diff --git a/src/ipa/ipu3/algorithms/algorithm.h b/src/ipa/ipu3/algorithms/algorithm.h\nnew file mode 100644\nindex 00000000..bac82b7c\n--- /dev/null\n+++ b/src/ipa/ipu3/algorithms/algorithm.h\n@@ -0,0 +1,30 @@\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\n+/*\n+ * Copyright (C) 2021, Ideas On Board\n+ *\n+ * algorithm.h - IPU3 control algorithm interface\n+ */\n+#ifndef __LIBCAMERA_IPA_IPU3_ALGORITHM_H__\n+#define __LIBCAMERA_IPA_IPU3_ALGORITHM_H__\n+\n+#include <ipa_context.h>\n+\n+namespace libcamera {\n+\n+namespace ipa::ipu3 {\n+\n+class Algorithm\n+{\n+public:\n+\tvirtual ~Algorithm() {}\n+\n+\tvirtual int initialise([[maybe_unused]] IPAContext &context) { return 0; }\n+\tvirtual int configure([[maybe_unused]] IPAContext &context) { return 0; }\n+\tvirtual void process([[maybe_unused]] IPAContext &context) {}\n+};\n+\n+} /* namespace ipa::ipu3 */\n+\n+} /* namespace libcamera */\n+\n+#endif /* __LIBCAMERA_IPA_IPU3_ALGORITHM_H__ */\ndiff --git a/src/ipa/ipu3/algorithms/meson.build b/src/ipa/ipu3/algorithms/meson.build\nnew file mode 100644\nindex 00000000..67148333\n--- /dev/null\n+++ b/src/ipa/ipu3/algorithms/meson.build\n@@ -0,0 +1,4 @@\n+# SPDX-License-Identifier: CC0-1.0\n+\n+ipu3_ipa_algorithms = files([\n+])\ndiff --git a/src/ipa/ipu3/ipu3.cpp b/src/ipa/ipu3/ipu3.cpp\nindex a714af85..55c4da72 100644\n--- a/src/ipa/ipu3/ipu3.cpp\n+++ b/src/ipa/ipu3/ipu3.cpp\n@@ -22,6 +22,7 @@\n \n #include \"libcamera/internal/framebuffer.h\"\n \n+#include \"algorithms/algorithm.h\"\n #include \"ipa_context.h\"\n \n #include \"ipu3_agc.h\"\n@@ -53,6 +54,10 @@ public:\n private:\n \tvoid processControls(unsigned int frame, const ControlList &controls);\n \tvoid fillParams(unsigned int frame, ipu3_uapi_params *params);\n+\n+\tint initialiseAlgorithms();\n+\tint configureAlgorithms();\n+\tvoid processAlgorithms(const ipu3_uapi_stats_3a *stats);\n \tvoid parseStatistics(unsigned int frame,\n \t\t\t     int64_t frameTimestamp,\n \t\t\t     const ipu3_uapi_stats_3a *stats);\n@@ -82,6 +87,9 @@ private:\n \t/* Interface to the Camera Helper */\n \tstd::unique_ptr<CameraSensorHelper> camHelper_;\n \n+\t/* Maintain the algorithms used by the IPA */\n+\tstd::list<std::unique_ptr<ipa::ipu3::Algorithm>> algorithms_;\n+\n \t/* Local parameter storage */\n \tstruct ipu3_uapi_grid_config bdsGrid_;\n \tstruct IPAContext context_;\n@@ -98,6 +106,8 @@ int IPAIPU3::init(const IPASettings &settings)\n \t/* Reset all the hardware settings */\n \tcontext_.params = {};\n \n+\tinitialiseAlgorithms();\n+\n \treturn 0;\n }\n \n@@ -199,6 +209,8 @@ int IPAIPU3::configure(const IPAConfigInfo &configInfo)\n \n \tcalculateBdsGrid(configInfo.bdsOutputSize);\n \n+\tconfigureAlgorithms();\n+\n \tawbAlgo_ = std::make_unique<IPU3Awb>();\n \tawbAlgo_->initialise(context_.params, configInfo.bdsOutputSize, bdsGrid_);\n \n@@ -288,12 +300,47 @@ void IPAIPU3::fillParams(unsigned int frame, ipu3_uapi_params *params)\n \tqueueFrameAction.emit(frame, op);\n }\n \n+int IPAIPU3::initialiseAlgorithms()\n+{\n+\tfor (auto const &algo : algorithms_) {\n+\t\tint ret = algo->initialise(context_);\n+\t\tif (ret)\n+\t\t\treturn ret;\n+\t}\n+\n+\treturn 0;\n+}\n+\n+int IPAIPU3::configureAlgorithms()\n+{\n+\tfor (auto const &algo : algorithms_) {\n+\t\tint ret = algo->configure(context_);\n+\t\tif (ret)\n+\t\t\treturn ret;\n+\t}\n+\n+\treturn 0;\n+}\n+\n+void IPAIPU3::processAlgorithms(const ipu3_uapi_stats_3a *stats)\n+{\n+\t/* It might be better to pass the stats in as a parameter to process() ? */\n+\tcontext_.stats = stats;\n+\n+\tfor (auto const &algo : algorithms_) {\n+\t\talgo->process(context_);\n+\t}\n+}\n+\n void IPAIPU3::parseStatistics(unsigned int frame,\n \t\t\t      [[maybe_unused]] int64_t frameTimestamp,\n \t\t\t      [[maybe_unused]] const ipu3_uapi_stats_3a *stats)\n {\n \tControlList ctrls(controls::controls);\n \n+\t/* Run the process for each algorithm on the stats */\n+\tprocessAlgorithms(stats);\n+\n \tdouble gain = camHelper_->gain(gain_);\n \tagcAlgo_->process(stats, exposure_, gain);\n \tgain_ = camHelper_->gainCode(gain);\ndiff --git a/src/ipa/ipu3/ipu3_agc.h b/src/ipa/ipu3/ipu3_agc.h\nindex 3deca3ae..e3e1d28b 100644\n--- a/src/ipa/ipu3/ipu3_agc.h\n+++ b/src/ipa/ipu3/ipu3_agc.h\n@@ -16,6 +16,7 @@\n \n #include <libcamera/geometry.h>\n \n+#include \"algorithms/algorithm.h\"\n #include \"libipa/algorithm.h\"\n \n namespace libcamera {\n@@ -26,7 +27,7 @@ namespace ipa::ipu3 {\n \n using utils::Duration;\n \n-class IPU3Agc : public Algorithm\n+class IPU3Agc : public ipa::Algorithm\n {\n public:\n \tIPU3Agc();\ndiff --git a/src/ipa/ipu3/ipu3_awb.h b/src/ipa/ipu3/ipu3_awb.h\nindex 122cf68c..284e3844 100644\n--- a/src/ipa/ipu3/ipu3_awb.h\n+++ b/src/ipa/ipu3/ipu3_awb.h\n@@ -13,6 +13,7 @@\n \n #include <libcamera/geometry.h>\n \n+#include \"algorithms/algorithm.h\"\n #include \"libipa/algorithm.h\"\n \n namespace libcamera {\n@@ -23,7 +24,7 @@ namespace ipa::ipu3 {\n static constexpr uint32_t kAwbStatsSizeX = 16;\n static constexpr uint32_t kAwbStatsSizeY = 12;\n \n-class IPU3Awb : public Algorithm\n+class IPU3Awb : public ipa::Algorithm\n {\n public:\n \tIPU3Awb();\ndiff --git a/src/ipa/ipu3/meson.build b/src/ipa/ipu3/meson.build\nindex b6364190..fcb27d68 100644\n--- a/src/ipa/ipu3/meson.build\n+++ b/src/ipa/ipu3/meson.build\n@@ -1,5 +1,7 @@\n # SPDX-License-Identifier: CC0-1.0\n \n+subdir('algorithms')\n+\n ipa_name = 'ipa_ipu3'\n \n ipu3_ipa_sources = files([\n@@ -8,6 +10,8 @@ ipu3_ipa_sources = files([\n     'ipu3_awb.cpp',\n ])\n \n+ipu3_ipa_sources += ipu3_ipa_algorithms\n+\n mod = shared_module(ipa_name,\n                     [ipu3_ipa_sources, libcamera_generated_ipa_headers],\n                     name_prefix : '',\n",
    "prefixes": [
        "libcamera-devel",
        "RFC",
        "2/5"
    ]
}