Patch Detail
Show a patch.
GET /api/patches/16271/?format=api
{ "id": 16271, "url": "https://patchwork.libcamera.org/api/patches/16271/?format=api", "web_url": "https://patchwork.libcamera.org/patch/16271/", "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": "<20220620014305.26778-2-laurent.pinchart@ideasonboard.com>", "date": "2022-06-20T01:42:54", "name": "[libcamera-devel,v4,01/12] ipa: libipa: Introduce a Module class template", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "737a09883e18311adbb976d83270dd17ac8fef00", "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/16271/mbox/", "series": [ { "id": 3191, "url": "https://patchwork.libcamera.org/api/series/3191/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3191", "date": "2022-06-20T01:42:53", "name": "Add tuning file support for the RkISP1 IPA module", "version": 4, "mbox": "https://patchwork.libcamera.org/series/3191/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/16271/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/16271/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 82CE4BE173\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 20 Jun 2022 01:43:29 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 906CC65643;\n\tMon, 20 Jun 2022 03:43:28 +0200 (CEST)", "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 771ED601F1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 20 Jun 2022 03:43:25 +0200 (CEST)", "from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id D31D4883;\n\tMon, 20 Jun 2022 03:43:24 +0200 (CEST)" ], "DKIM-Signature": [ "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1655689408;\n\tbh=Vd+XJWO6S5AqcMr1huCj18B9BE1RIuOG/mFoRE3RFXE=;\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=jrN4UROenJrMc8Yk1Kp7AEXmAC7mmnXZidF44yQ8BHUgdPav7PzoZxY6l7GoQV4zP\n\tB2EZHsq5k2N81q/l/Uv+sEUkn4pIOT1gjzndiAKTyJ2tT1NWdw6idUfpCIkV/EZSOB\n\tBNXqSZu9BccJUwMu363S+zhMoia1ndoKG+BA13VWN+v5WrKM9l94jCVBzukw8oGzVr\n\tTKukD3DyRIfQRkHNxh20yohSybMxNRZ0y6HKo9CReQswDLTXd7jgsfcyYdPk9mYn9G\n\t2KH7h/qUfLkY4JPINyh8f2Sl1VkWAhBX/gKLswXafQ6jPeaW/MzfTU8IQgXAgL9LY3\n\tiUaMYcHV7OhWQ==", "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1655689405;\n\tbh=Vd+XJWO6S5AqcMr1huCj18B9BE1RIuOG/mFoRE3RFXE=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=CTh1xJc3MlmTiuRP6JyJk/KZW/YgDx5mxCdfryUfDa4CCbKyAKV+5Zc3/BqRWhjC2\n\tset2OfjXS6GUyOzFvUyUckNsh4TvzRmf6Faqx6FL2fCnN5Ahn2acqCsW4uFsn5VSqW\n\tKxKX3enzYTrpIRCh/80WUjdd4LnM4vLaINYfvfRo=" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"CTh1xJc3\"; dkim-atps=neutral", "To": "libcamera-devel@lists.libcamera.org", "Date": "Mon, 20 Jun 2022 04:42:54 +0300", "Message-Id": "<20220620014305.26778-2-laurent.pinchart@ideasonboard.com>", "X-Mailer": "git-send-email 2.35.1", "In-Reply-To": "<20220620014305.26778-1-laurent.pinchart@ideasonboard.com>", "References": "<20220620014305.26778-1-laurent.pinchart@ideasonboard.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH v4 01/12] ipa: libipa: Introduce a Module\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>", "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": "libipa defines an abstract Algorithm class template that is specialized\nby IPA modules. IPA modules then instantiate and manage algorithms\ninternally, without help from libipa. With ongoing work on tuning data\nsupport for the RkISP1, and future similar work for the IPU3, more code\nduplication for algorithms management is expected.\n\nTo address this and share code between multiple IPA modules, introduce a\nnew Module class template that will define and manage top-level concepts\nfor the IPA module.\n\nThe Module class template needs to be specialized with the same types as\nthe Algorithm class. To avoid manual specialization of both classes,\nstore the types in the Module class, and replace the template arguments\nof the Algorithm class with a single Module argument from which the\nother types are retrieved.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n src/ipa/ipu3/algorithms/algorithm.h | 8 +--\n src/ipa/ipu3/module.h | 27 ++++++++++\n src/ipa/libipa/algorithm.cpp | 17 ++++---\n src/ipa/libipa/algorithm.h | 17 +++----\n src/ipa/libipa/meson.build | 5 +-\n src/ipa/libipa/module.cpp | 73 +++++++++++++++++++++++++++\n src/ipa/libipa/module.h | 30 +++++++++++\n src/ipa/rkisp1/algorithms/algorithm.h | 10 +---\n src/ipa/rkisp1/module.h | 27 ++++++++++\n 9 files changed, 183 insertions(+), 31 deletions(-)\n create mode 100644 src/ipa/ipu3/module.h\n create mode 100644 src/ipa/libipa/module.cpp\n create mode 100644 src/ipa/libipa/module.h\n create mode 100644 src/ipa/rkisp1/module.h", "diff": "diff --git a/src/ipa/ipu3/algorithms/algorithm.h b/src/ipa/ipu3/algorithms/algorithm.h\nindex 234b2bd77f72..ae134a9404fe 100644\n--- a/src/ipa/ipu3/algorithms/algorithm.h\n+++ b/src/ipa/ipu3/algorithms/algorithm.h\n@@ -7,19 +7,15 @@\n \n #pragma once\n \n-#include <libcamera/ipa/ipu3_ipa_interface.h>\n-\n #include <libipa/algorithm.h>\n \n-#include \"ipa_context.h\"\n+#include \"module.h\"\n \n namespace libcamera {\n \n namespace ipa::ipu3 {\n \n-using Algorithm = libcamera::ipa::Algorithm<IPAContext, IPAFrameContext,\n-\t\t\t\t\t IPAConfigInfo, ipu3_uapi_params,\n-\t\t\t\t\t ipu3_uapi_stats_3a>;\n+using Algorithm = libcamera::ipa::Algorithm<Module>;\n \n } /* namespace ipa::ipu3 */\n \ndiff --git a/src/ipa/ipu3/module.h b/src/ipa/ipu3/module.h\nnew file mode 100644\nindex 000000000000..d94fc4594871\n--- /dev/null\n+++ b/src/ipa/ipu3/module.h\n@@ -0,0 +1,27 @@\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\n+/*\n+ * Copyright (C) 2022, Ideas On Board\n+ *\n+ * module.h - IPU3 IPA Module\n+ */\n+\n+#pragma once\n+\n+#include <linux/intel-ipu3.h>\n+\n+#include <libcamera/ipa/ipu3_ipa_interface.h>\n+\n+#include <libipa/module.h>\n+\n+#include \"ipa_context.h\"\n+\n+namespace libcamera {\n+\n+namespace ipa::ipu3 {\n+\n+using Module = ipa::Module<IPAContext, IPAFrameContext, IPAConfigInfo,\n+\t\t\t ipu3_uapi_params, ipu3_uapi_stats_3a>;\n+\n+} /* namespace ipa::ipu3 */\n+\n+} /* namespace libcamera*/\ndiff --git a/src/ipa/libipa/algorithm.cpp b/src/ipa/libipa/algorithm.cpp\nindex cce2ed62986d..2df91e5d8fed 100644\n--- a/src/ipa/libipa/algorithm.cpp\n+++ b/src/ipa/libipa/algorithm.cpp\n@@ -19,14 +19,17 @@ namespace ipa {\n /**\n * \\class Algorithm\n * \\brief The base class for all IPA algorithms\n- * \\tparam Context The type of shared IPA context\n- * \\tparam Config The type of the IPA configuration data\n- * \\tparam Params The type of the ISP specific parameters\n- * \\tparam Stats The type of the IPA statistics and ISP results\n+ * \\tparam Module The IPA module type for this class of 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- * to manage algorithms regardless of their specific type.\n+ * The Algorithm class defines a standard interface for IPA algorithms\n+ * compatible with the \\a Module. By abstracting algorithms, it makes possible\n+ * the implementation of generic code to manage algorithms regardless of their\n+ * specific type.\n+ *\n+ * To specialize the Algorithm class template, an IPA module shall specialize\n+ * the Module class template with module-specific context and configuration\n+ * types, and pass the specialized Module class as the \\a Module template\n+ * argument.\n */\n \n /**\ndiff --git a/src/ipa/libipa/algorithm.h b/src/ipa/libipa/algorithm.h\nindex 032a05b56635..fd2ffcfbc900 100644\n--- a/src/ipa/libipa/algorithm.h\n+++ b/src/ipa/libipa/algorithm.h\n@@ -10,27 +10,26 @@ namespace libcamera {\n \n namespace ipa {\n \n-template<typename Context, typename FrameContext, typename Config,\n-\t typename Params, typename Stats>\n+template<typename Module>\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 Config &configInfo)\n+\tvirtual int configure([[maybe_unused]] typename Module::Context &context,\n+\t\t\t [[maybe_unused]] const typename Module::Config &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+\tvirtual void prepare([[maybe_unused]] typename Module::Context &context,\n+\t\t\t [[maybe_unused]] typename Module::Params *params)\n \t{\n \t}\n \n-\tvirtual void process([[maybe_unused]] Context &context,\n-\t\t\t [[maybe_unused]] FrameContext *frameContext,\n-\t\t\t [[maybe_unused]] const Stats *stats)\n+\tvirtual void process([[maybe_unused]] typename Module::Context &context,\n+\t\t\t [[maybe_unused]] typename Module::FrameContext *frameContext,\n+\t\t\t [[maybe_unused]] const typename Module::Stats *stats)\n \t{\n \t}\n };\ndiff --git a/src/ipa/libipa/meson.build b/src/ipa/libipa/meson.build\nindex 161cc5a1f0d0..465cf7d6c4a7 100644\n--- a/src/ipa/libipa/meson.build\n+++ b/src/ipa/libipa/meson.build\n@@ -3,13 +3,16 @@\n libipa_headers = files([\n 'algorithm.h',\n 'camera_sensor_helper.h',\n- 'histogram.h'\n+ 'histogram.h',\n+ 'module.h',\n ])\n \n libipa_sources = files([\n+ 'algorithm.cpp',\n 'camera_sensor_helper.cpp',\n 'histogram.cpp',\n 'libipa.cpp',\n+ 'module.cpp',\n ])\n \n libipa_includes = include_directories('..')\ndiff --git a/src/ipa/libipa/module.cpp b/src/ipa/libipa/module.cpp\nnew file mode 100644\nindex 000000000000..5a6f49a80e6d\n--- /dev/null\n+++ b/src/ipa/libipa/module.cpp\n@@ -0,0 +1,73 @@\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\n+/*\n+ * Copyright (C) 2022, Ideas On Board\n+ *\n+ * module.cpp - IPA Module\n+ */\n+\n+#include \"module.h\"\n+\n+/**\n+ * \\file module.h\n+ * \\brief IPA Module common interface\n+ */\n+\n+namespace libcamera {\n+\n+namespace ipa {\n+\n+/**\n+ * \\class Module\n+ * \\brief The base class for all IPA modules\n+ * \\tparam Context The type of the shared IPA context\n+ * \\tparam FrameContext The type of the frame context\n+ * \\tparam Config The type of the IPA configuration data\n+ * \\tparam Params The type of the ISP specific parameters\n+ * \\tparam Stats The type of the IPA statistics and ISP results\n+ *\n+ * The Module class template defines a standard internal interface between IPA\n+ * modules and libipa.\n+ *\n+ * While IPA modules are platform-specific, many of their internal functions are\n+ * conceptually similar, even if they take different types of platform-specifc\n+ * parameters. For instance, IPA modules could share code that instantiates,\n+ * initializes and run algorithms if it wasn't for the fact that the the format\n+ * of ISP parameters or statistics passed to the related functions is\n+ * device-dependent.\n+ *\n+ * To enable a shared implementation of those common tasks in libipa, the Module\n+ * class template defines a standard internal interface between IPA modules and\n+ * libipa. The template parameters specify the types of module-dependent data.\n+ * IPA modules shall create a specialization of the Module class template in\n+ * their namespace, and use it to specialize other classes of libipa, such as\n+ * the Algorithm class.\n+ */\n+\n+/**\n+ * \\typedef Module::Context\n+ * \\brief The type of the shared IPA context\n+ */\n+\n+/**\n+ * \\typedef Module::FrameContext\n+ * \\brief The type of the frame context\n+ */\n+\n+/**\n+ * \\typedef Module::Config\n+ * \\brief The type of the IPA configuration data\n+ */\n+\n+/**\n+ * \\typedef Module::Params\n+ * \\brief The type of the ISP specific parameters\n+ */\n+\n+/**\n+ * \\typedef Module::Stats\n+ * \\brief The type of the IPA statistics and ISP results\n+ */\n+\n+} /* namespace ipa */\n+\n+} /* namespace libcamera */\ndiff --git a/src/ipa/libipa/module.h b/src/ipa/libipa/module.h\nnew file mode 100644\nindex 000000000000..c4d778120408\n--- /dev/null\n+++ b/src/ipa/libipa/module.h\n@@ -0,0 +1,30 @@\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\n+/*\n+ * Copyright (C) 2022, Ideas On Board\n+ *\n+ * module.h - IPA module\n+ */\n+\n+#pragma once\n+\n+namespace libcamera {\n+\n+namespace ipa {\n+\n+template<typename _Context, typename _FrameContext, typename _Config,\n+\t typename _Params, typename _Stats>\n+class Module\n+{\n+public:\n+\tusing Context = _Context;\n+\tusing FrameContext = _FrameContext;\n+\tusing Config = _Config;\n+\tusing Params = _Params;\n+\tusing Stats = _Stats;\n+\n+\tvirtual ~Module() {}\n+};\n+\n+} /* namespace ipa */\n+\n+} /* namespace libcamera */\ndiff --git a/src/ipa/rkisp1/algorithms/algorithm.h b/src/ipa/rkisp1/algorithms/algorithm.h\nindex 68e3a44e19b4..c3212cff76fe 100644\n--- a/src/ipa/rkisp1/algorithms/algorithm.h\n+++ b/src/ipa/rkisp1/algorithms/algorithm.h\n@@ -7,21 +7,15 @@\n \n #pragma once\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+#include \"module.h\"\n \n namespace libcamera {\n \n namespace ipa::rkisp1 {\n \n-using Algorithm = libcamera::ipa::Algorithm<IPAContext, IPAFrameContext,\n-\t\t\t\t\t IPACameraSensorInfo, rkisp1_params_cfg,\n-\t\t\t\t\t rkisp1_stat_buffer>;\n+using Algorithm = libcamera::ipa::Algorithm<Module>;\n \n } /* namespace ipa::rkisp1 */\n \ndiff --git a/src/ipa/rkisp1/module.h b/src/ipa/rkisp1/module.h\nnew file mode 100644\nindex 000000000000..89f83208a75c\n--- /dev/null\n+++ b/src/ipa/rkisp1/module.h\n@@ -0,0 +1,27 @@\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\n+/*\n+ * Copyright (C) 2022, Ideas On Board\n+ *\n+ * module.h - RkISP1 IPA Module\n+ */\n+\n+#pragma once\n+\n+#include <linux/rkisp1-config.h>\n+\n+#include <libcamera/ipa/rkisp1_ipa_interface.h>\n+\n+#include <libipa/module.h>\n+\n+#include \"ipa_context.h\"\n+\n+namespace libcamera {\n+\n+namespace ipa::rkisp1 {\n+\n+using Module = ipa::Module<IPAContext, IPAFrameContext, IPACameraSensorInfo,\n+\t\t\t rkisp1_params_cfg, rkisp1_stat_buffer>;\n+\n+} /* namespace ipa::rkisp1 */\n+\n+} /* namespace libcamera*/\n", "prefixes": [ "libcamera-devel", "v4", "01/12" ] }