Show a patch.

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

{
    "id": 14690,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/14690/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/14690/",
    "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": "<20211123091451.67404-7-jeanmichel.hautbois@ideasonboard.com>",
    "date": "2021-11-23T09:14:46",
    "name": "[libcamera-devel,v2,06/11] ipa: libipa: Introduce Algorithm class template",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "ae1bd1a6472681aa53c552046109747acb65f2de",
    "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/14690/mbox/",
    "series": [
        {
            "id": 2741,
            "url": "https://patchwork.libcamera.org/api/1.1/series/2741/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=2741",
            "date": "2021-11-23T09:14:40",
            "name": "Introduce AGC for RkISP1",
            "version": 2,
            "mbox": "https://patchwork.libcamera.org/series/2741/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/14690/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/14690/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 9B715BDB13\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 23 Nov 2021 09:15:07 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 24AB0603CB;\n\tTue, 23 Nov 2021 10:15:05 +0100 (CET)",
            "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 05F226038C\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 23 Nov 2021 10:14:58 +0100 (CET)",
            "from tatooine.ideasonboard.com (unknown\n\t[IPv6:2a01:e0a:169:7140:3c3b:9149:b:8aa9])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id B7729F95;\n\tTue, 23 Nov 2021 10:14:57 +0100 (CET)"
        ],
        "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=\"KwuPH8lN\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1637658897;\n\tbh=p13rWa+3iqUgkFarjy07FZEvynT03pE9wGITsSUA6oI=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=KwuPH8lNGsBTB1TRCU2moOf9WgHYZ0Qf/nMQCujWw8wsTRinewaEbyjogwWvs6jEY\n\tgr+G0rGDIWctqUXx5ZPXpwNAYz1H35t74gcEDKHkMbK+9ngYlhIJRHwGSDvV/cLdac\n\t89jb0oTJ2spvot4XgvsgqTE/xcFDGUaTN1X1lA4w=",
        "From": "Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Tue, 23 Nov 2021 10:14:46 +0100",
        "Message-Id": "<20211123091451.67404-7-jeanmichel.hautbois@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.32.0",
        "In-Reply-To": "<20211123091451.67404-1-jeanmichel.hautbois@ideasonboard.com>",
        "References": "<20211123091451.67404-1-jeanmichel.hautbois@ideasonboard.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH v2 06/11] ipa: libipa: Introduce Algorithm\n\tclass template",
        "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": "The algorithms are using the same function names with specialized\nparameters. Instead of duplicating code, introduce a libipa Algorithm\nclass which implements a base class with template parameters in libipa,\nand use it in each IPA.\n\nAs we now won't need an algorithm class for each IPA, move the\ndocumentation to libipa, and make it agnostic of the IPA used.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nSigned-off-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>\n---\n src/ipa/ipu3/algorithms/algorithm.h           | 12 ++----\n src/ipa/ipu3/algorithms/meson.build           |  1 -\n .../{ipu3/algorithms => libipa}/algorithm.cpp | 35 ++++++----------\n src/ipa/libipa/algorithm.h                    | 41 +++++++++++++++++++\n src/ipa/libipa/meson.build                    |  1 +\n src/ipa/rkisp1/algorithms/algorithm.h         | 28 +++++++++++++\n src/ipa/rkisp1/algorithms/meson.build         |  4 ++\n src/ipa/rkisp1/meson.build                    |  4 ++\n src/ipa/rkisp1/rkisp1.cpp                     |  5 ++-\n 9 files changed, 97 insertions(+), 34 deletions(-)\n rename src/ipa/{ipu3/algorithms => libipa}/algorithm.cpp (74%)\n create mode 100644 src/ipa/libipa/algorithm.h\n create mode 100644 src/ipa/rkisp1/algorithms/algorithm.h\n create mode 100644 src/ipa/rkisp1/algorithms/meson.build",
    "diff": "diff --git a/src/ipa/ipu3/algorithms/algorithm.h b/src/ipa/ipu3/algorithms/algorithm.h\nindex 43f5d8b0..3c0ce461 100644\n--- a/src/ipa/ipu3/algorithms/algorithm.h\n+++ b/src/ipa/ipu3/algorithms/algorithm.h\n@@ -9,21 +9,15 @@\n \n #include <libcamera/ipa/ipu3_ipa_interface.h>\n \n+#include <libipa/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 configure(IPAContext &context, const IPAConfigInfo &configInfo);\n-\tvirtual void prepare(IPAContext &context, ipu3_uapi_params *params);\n-\tvirtual void process(IPAContext &context, const ipu3_uapi_stats_3a *stats);\n-};\n+using Algorithm = libcamera::ipa::Algorithm<IPAContext, IPAConfigInfo, ipu3_uapi_params, ipu3_uapi_stats_3a>;\n \n } /* namespace ipa::ipu3 */\n \ndiff --git a/src/ipa/ipu3/algorithms/meson.build b/src/ipa/ipu3/algorithms/meson.build\nindex 3ec42f72..4db6ae1d 100644\n--- a/src/ipa/ipu3/algorithms/meson.build\n+++ b/src/ipa/ipu3/algorithms/meson.build\n@@ -2,7 +2,6 @@\n \n ipu3_ipa_algorithms = files([\n     'agc.cpp',\n-    'algorithm.cpp',\n     'awb.cpp',\n     'blc.cpp',\n     'tone_mapping.cpp',\ndiff --git a/src/ipa/ipu3/algorithms/algorithm.cpp b/src/ipa/libipa/algorithm.cpp\nsimilarity index 74%\nrename from src/ipa/ipu3/algorithms/algorithm.cpp\nrename to src/ipa/libipa/algorithm.cpp\nindex 3e7e3018..888ffb57 100644\n--- a/src/ipa/ipu3/algorithms/algorithm.cpp\n+++ b/src/ipa/libipa/algorithm.cpp\n@@ -2,7 +2,7 @@\n /*\n  * Copyright (C) 2021, Ideas On Board\n  *\n- * algorithm.cpp - IPU3 control algorithm interface\n+ * algorithm.cpp - IPA control algorithm interface\n  */\n \n #include \"algorithm.h\"\n@@ -14,11 +14,11 @@\n \n namespace libcamera {\n \n-namespace ipa::ipu3 {\n+namespace ipa {\n \n /**\n  * \\class Algorithm\n- * \\brief The base class for all IPU3 algorithms\n+ * \\brief The base class for all IPA algorithms\n  *\n  * The Algorithm class defines a standard interface for IPA algorithms. By\n  * abstracting algorithms, it makes possible the implementation of generic code\n@@ -26,6 +26,7 @@ namespace ipa::ipu3 {\n  */\n \n /**\n+ * \\fn Algorithm::configure()\n  * \\brief Configure the Algorithm given an IPAConfigInfo\n  * \\param[in] context The shared IPA context\n  * \\param[in] configInfo The IPA configuration data, received from the pipeline\n@@ -39,37 +40,29 @@ namespace ipa::ipu3 {\n  *\n  * \\return 0 if successful, an error code otherwise\n  */\n-int Algorithm::configure([[maybe_unused]] IPAContext &context,\n-\t\t\t [[maybe_unused]] const IPAConfigInfo &configInfo)\n-{\n-\treturn 0;\n-}\n \n /**\n+ * \\fn Algorithm::prepare()\n  * \\brief Fill the \\a params buffer with ISP processing parameters for a frame\n  * \\param[in] context The shared IPA context\n- * \\param[out] params The IPU3 specific parameters.\n+ * \\param[out] params The ISP specific parameters.\n  *\n  * This function is called for every frame when the camera is running before it\n- * is processed by the ImgU to prepare the ImgU processing parameters for that\n- * frame.\n+ * is processed by the ISP.\n  *\n  * Algorithms shall fill in the parameter structure fields appropriately to\n- * configure the ImgU processing blocks that they are responsible for. This\n+ * configure the ISP processing blocks that they are responsible for. This\n  * includes setting fields and flags that enable those processing blocks.\n  */\n-void Algorithm::prepare([[maybe_unused]] IPAContext &context,\n-\t\t\t[[maybe_unused]] ipu3_uapi_params *params)\n-{\n-}\n \n /**\n+ * \\fn Algorithm::process()\n  * \\brief Process ISP statistics, and run algorithm operations\n  * \\param[in] context The shared IPA context\n- * \\param[in] stats The IPU3 statistics and ISP results\n+ * \\param[in] stats The IPA statistics and ISP results\n  *\n  * This function is called while camera is running for every frame processed by\n- * the ImgU, to process statistics generated from that frame by the ImgU.\n+ * the ISP, to process statistics generated from that frame by the ISP.\n  * Algorithms shall use this data to run calculations and update their state\n  * accordingly.\n  *\n@@ -91,11 +84,7 @@ void Algorithm::prepare([[maybe_unused]] IPAContext &context,\n  * Care shall be taken to ensure the ordering of access to the information\n  * such that the algorithms use up to date state as required.\n  */\n-void Algorithm::process([[maybe_unused]] IPAContext &context,\n-\t\t\t[[maybe_unused]] const ipu3_uapi_stats_3a *stats)\n-{\n-}\n \n-} /* namespace ipa::ipu3 */\n+} /* namespace ipa */\n \n } /* namespace libcamera */\ndiff --git a/src/ipa/libipa/algorithm.h b/src/ipa/libipa/algorithm.h\nnew file mode 100644\nindex 00000000..74dc49c4\n--- /dev/null\n+++ b/src/ipa/libipa/algorithm.h\n@@ -0,0 +1,41 @@\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\n+/*\n+ * Copyright (C) 2021, Ideas On Board\n+ *\n+ * algorithm.h - ISP control algorithm interface\n+ */\n+#ifndef __LIBCAMERA_IPA_LIBIPA_ALGORITHM_H__\n+#define __LIBCAMERA_IPA_LIBIPA_ALGORITHM_H__\n+\n+namespace libcamera {\n+\n+namespace ipa {\n+\n+template<typename Context, typename IPAConfigInfo, typename Params, typename Stats>\n+class Algorithm\n+{\n+public:\n+\tvirtual ~Algorithm() {}\n+\n+\tvirtual int configure([[maybe_unused]] Context &context,\n+\t\t\t      [[maybe_unused]] const IPAConfigInfo &configInfo)\n+\t{\n+\t\treturn 0;\n+\t}\n+\n+\tvirtual void prepare([[maybe_unused]] Context &context,\n+\t\t\t     [[maybe_unused]] Params *params)\n+\t{\n+\t}\n+\n+\tvirtual void process([[maybe_unused]] Context &context,\n+\t\t\t     [[maybe_unused]] const Stats *stats)\n+\t{\n+\t}\n+};\n+\n+} /* namespace ipa */\n+\n+} /* namespace libcamera */\n+\n+#endif /* __LIBCAMERA_IPA_LIBIPA_ALGORITHM_H__ */\ndiff --git a/src/ipa/libipa/meson.build b/src/ipa/libipa/meson.build\nindex 4d073a03..161cc5a1 100644\n--- a/src/ipa/libipa/meson.build\n+++ b/src/ipa/libipa/meson.build\n@@ -1,6 +1,7 @@\n # SPDX-License-Identifier: CC0-1.0\n \n libipa_headers = files([\n+    'algorithm.h',\n     'camera_sensor_helper.h',\n     'histogram.h'\n ])\ndiff --git a/src/ipa/rkisp1/algorithms/algorithm.h b/src/ipa/rkisp1/algorithms/algorithm.h\nnew file mode 100644\nindex 00000000..dfa58727\n--- /dev/null\n+++ b/src/ipa/rkisp1/algorithms/algorithm.h\n@@ -0,0 +1,28 @@\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\n+/*\n+ * Copyright (C) 2021, Ideas On Board\n+ *\n+ * algorithm.h - RkISP1 control algorithm interface\n+ */\n+#ifndef __LIBCAMERA_IPA_RKISP1_ALGORITHM_H__\n+#define __LIBCAMERA_IPA_RKISP1_ALGORITHM_H__\n+\n+#include <linux/rkisp1-config.h>\n+\n+#include <libcamera/ipa/rkisp1_ipa_interface.h>\n+\n+#include <libipa/algorithm.h>\n+\n+#include \"ipa_context.h\"\n+\n+namespace libcamera {\n+\n+namespace ipa::rkisp1 {\n+\n+using Algorithm = libcamera::ipa::Algorithm<IPAContext, IPACameraSensorInfo, rkisp1_params_cfg, rkisp1_stat_buffer>;\n+\n+} /* namespace ipa::rkisp1 */\n+\n+} /* namespace libcamera */\n+\n+#endif /* __LIBCAMERA_IPA_RKISP1_ALGORITHM_H__ */\ndiff --git a/src/ipa/rkisp1/algorithms/meson.build b/src/ipa/rkisp1/algorithms/meson.build\nnew file mode 100644\nindex 00000000..1c6c59cf\n--- /dev/null\n+++ b/src/ipa/rkisp1/algorithms/meson.build\n@@ -0,0 +1,4 @@\n+# SPDX-License-Identifier: CC0-1.0\n+\n+rkisp1_ipa_algorithms = files([\n+])\ndiff --git a/src/ipa/rkisp1/meson.build b/src/ipa/rkisp1/meson.build\nindex 3683c922..8c822fbb 100644\n--- a/src/ipa/rkisp1/meson.build\n+++ b/src/ipa/rkisp1/meson.build\n@@ -1,5 +1,7 @@\n # SPDX-License-Identifier: CC0-1.0\n \n+subdir('algorithms')\n+\n ipa_name = 'ipa_rkisp1'\n \n rkisp1_ipa_sources = files([\n@@ -7,6 +9,8 @@ rkisp1_ipa_sources = files([\n     'rkisp1.cpp',\n ])\n \n+rkisp1_ipa_sources += rkisp1_ipa_algorithms\n+\n mod = shared_module(ipa_name,\n                     [rkisp1_ipa_sources, libcamera_generated_ipa_headers],\n                     name_prefix : '',\ndiff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp\nindex 34c3f9a2..0c54d8ec 100644\n--- a/src/ipa/rkisp1/rkisp1.cpp\n+++ b/src/ipa/rkisp1/rkisp1.cpp\n@@ -25,7 +25,7 @@\n \n #include <libcamera/internal/mapped_framebuffer.h>\n \n-#include \"ipa_context.h\"\n+#include \"algorithms/algorithm.h\"\n #include \"libipa/camera_sensor_helper.h\"\n \n namespace libcamera {\n@@ -82,6 +82,9 @@ private:\n \n \t/* Local parameter storage */\n \tstruct IPAContext context_;\n+\n+\t/* Maintain the algorithms used by the IPA */\n+\tstd::list<std::unique_ptr<ipa::rkisp1::Algorithm>> algorithms_;\n };\n \n int IPARkISP1::init(const IPASettings &settings, unsigned int hwRevision)\n",
    "prefixes": [
        "libcamera-devel",
        "v2",
        "06/11"
    ]
}