Patch Detail
Show a patch.
GET /api/1.1/patches/16275/?format=api
{ "id": 16275, "url": "https://patchwork.libcamera.org/api/1.1/patches/16275/?format=api", "web_url": "https://patchwork.libcamera.org/patch/16275/", "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": "<20220620014305.26778-6-laurent.pinchart@ideasonboard.com>", "date": "2022-06-20T01:42:58", "name": "[libcamera-devel,v4,05/12] ipa: libipa: module: Add support for instantiation from YAML", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "769dd24b14810d7c073001ae22d857abcbe47b50", "submitter": { "id": 2, "url": "https://patchwork.libcamera.org/api/1.1/people/2/?format=api", "name": "Laurent Pinchart", "email": "laurent.pinchart@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/16275/mbox/", "series": [ { "id": 3191, "url": "https://patchwork.libcamera.org/api/1.1/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/16275/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/16275/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 2A215BE173\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 20 Jun 2022 01:43:35 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 7B6776564D;\n\tMon, 20 Jun 2022 03:43:33 +0200 (CEST)", "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 4529E6563B\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 20 Jun 2022 03:43:27 +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 C530A25E;\n\tMon, 20 Jun 2022 03:43:26 +0200 (CEST)" ], "DKIM-Signature": [ "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1655689413;\n\tbh=iiTYs60suiRgZIa1iHO3GmUnotFsLAIBsnwonLylSjA=;\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=czDUGEv2lNsOQzyzpiMoqDjDgeC5vvX3o8QMYY7HMlkB4xZTv5dwJZ0Jcaw1OHAJm\n\thb5QDgVx0RXeHrGQMJqJ8N8MyF1//78lbzMAdDzoSq4bT+MmoSOeyG6Paxu8LZ5BzW\n\t2dyAbLzYTA1zGY9WF9fk/rT8tal9F5rQF6Qr4+Du3GOyaMXdvLceNbp3n8INTc7gvs\n\t47Bo6bGt6k9UJ1S32yFx9munO7uvPHmJGe1Mfn38jG/ljtGwuU27/4OY7avVJGmIWF\n\thwBPvRaTKv/eNv11NrBV7Rn3HcQwababUTN2QL6YnS7f0v7j6kVVIaXMfOE85wVs8H\n\t3aJcxgWuCkdCQ==", "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1655689407;\n\tbh=iiTYs60suiRgZIa1iHO3GmUnotFsLAIBsnwonLylSjA=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=lB6NE2jwKOgKqjigca1uug5aCUL2yFTHT9eWYqNRcf2A3yqaefY7K6or9kwi3zfjC\n\tLsViq6/8kbBuh1HNaJ7XYV026nZw9J+Fassfm7BTK9T+HZtKk0lykZKMAtXbDhWCM6\n\tQuHJULMVoupO6LnClD4+dvXlkUqROvkgTpPHVFic=" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"lB6NE2jw\"; dkim-atps=neutral", "To": "libcamera-devel@lists.libcamera.org", "Date": "Mon, 20 Jun 2022 04:42:58 +0300", "Message-Id": "<20220620014305.26778-6-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 05/12] ipa: libipa: module: Add support\n\tfor instantiation from YAML", "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": "Add a Module::createAlgorithms() function to instantiate algorithms from\na YamlObject. The instantiated algorithms are stored in a private member\nvariable list, exposed through the Module::algorithms() function.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n src/ipa/libipa/module.cpp | 42 ++++++++++++++++------\n src/ipa/libipa/module.h | 73 +++++++++++++++++++++++++++++++++++----\n 2 files changed, 99 insertions(+), 16 deletions(-)", "diff": "diff --git a/src/ipa/libipa/module.cpp b/src/ipa/libipa/module.cpp\nindex 451614fd04da..7735210444b6 100644\n--- a/src/ipa/libipa/module.cpp\n+++ b/src/ipa/libipa/module.cpp\n@@ -14,6 +14,8 @@\n \n namespace libcamera {\n \n+LOG_DEFINE_CATEGORY(IPAModuleAlgo)\n+\n /**\n * \\brief The IPA namespace\n *\n@@ -76,7 +78,36 @@ namespace ipa {\n */\n \n /**\n- * \\fn Module::createAlgorithm()\n+ * \\fn Module::algorithms()\n+ * \\brief Retrieve the list of instantiated algorithms\n+ * \\return The list of instantiated algorithms\n+ */\n+\n+/**\n+ * \\fn Module::createAlgorithms()\n+ * \\brief Create algorithms from YAML configuration data\n+ * \\param[in] context The IPA context\n+ * \\param[in] algorithms Algorithms configuration data as a parsed YamlObject\n+ *\n+ * This function iterates over the list of \\a algorithms parsed from the YAML\n+ * configuration file, and instantiates and initializes the corresponding\n+ * algorithms. The configuration data is expected to be correct, any error\n+ * causes the function to fail and return immediately.\n+ *\n+ * \\return 0 on success, or a negative error code on failure\n+ */\n+\n+/**\n+ * \\fn Module::registerAlgorithm()\n+ * \\brief Add an algorithm factory class to the list of available algorithms\n+ * \\param[in] factory Factory to use to construct the algorithm\n+ *\n+ * This function registers an algorithm factory. It is meant to be called by the\n+ * AlgorithmFactory constructor only.\n+ */\n+\n+/**\n+ * \\fn Module::createAlgorithm(const std::string &name)\n * \\brief Create an instance of an Algorithm by name\n * \\param[in] name The algorithm name\n *\n@@ -90,15 +121,6 @@ namespace ipa {\n * \\return A new instance of the Algorithm subclass corresponding to the \\a name\n */\n \n-/**\n- * \\fn Module::registerAlgorithm()\n- * \\brief Add an algorithm factory class to the list of available algorithms\n- * \\param[in] factory Factory to use to construct the algorithm\n- *\n- * This function registers an algorithm factory. It is meant to be called by the\n- * AlgorithmFactory constructor only.\n- */\n-\n } /* namespace ipa */\n \n } /* namespace libcamera */\ndiff --git a/src/ipa/libipa/module.h b/src/ipa/libipa/module.h\nindex f30fc33711bb..00d5785e1aa0 100644\n--- a/src/ipa/libipa/module.h\n+++ b/src/ipa/libipa/module.h\n@@ -7,14 +7,22 @@\n \n #pragma once\n \n+#include <list>\n #include <memory>\n #include <string>\n #include <vector>\n \n+#include <libcamera/base/log.h>\n+#include <libcamera/base/utils.h>\n+\n+#include \"libcamera/internal/yaml_parser.h\"\n+\n #include \"algorithm.h\"\n \n namespace libcamera {\n \n+LOG_DECLARE_CATEGORY(IPAModuleAlgo)\n+\n namespace ipa {\n \n template<typename _Context, typename _FrameContext, typename _Config,\n@@ -30,6 +38,63 @@ public:\n \n \tvirtual ~Module() {}\n \n+\tconst std::list<std::unique_ptr<Algorithm<Module>>> &algorithms() const\n+\t{\n+\t\treturn algorithms_;\n+\t}\n+\n+\tint createAlgorithms(Context &context, const YamlObject &algorithms)\n+\t{\n+\t\tconst auto &list = algorithms.asList();\n+\n+\t\tfor (const auto &[i, algo] : utils::enumerate(list)) {\n+\t\t\tif (!algo.isDictionary()) {\n+\t\t\t\tLOG(IPAModuleAlgo, Error)\n+\t\t\t\t\t<< \"Invalid YAML syntax for algorithm \" << i;\n+\t\t\t\talgorithms_.clear();\n+\t\t\t\treturn -EINVAL;\n+\t\t\t}\n+\n+\t\t\tint ret = createAlgorithm(context, algo);\n+\t\t\tif (ret) {\n+\t\t\t\talgorithms_.clear();\n+\t\t\t\treturn ret;\n+\t\t\t}\n+\t\t}\n+\n+\t\treturn 0;\n+\t}\n+\n+\tstatic void registerAlgorithm(AlgorithmFactory<Module> *factory)\n+\t{\n+\t\tfactories().push_back(factory);\n+\t}\n+\n+private:\n+\tint createAlgorithm(Context &context, const YamlObject &data)\n+\t{\n+\t\tconst auto &[name, algoData] = *data.asDict().begin();\n+\t\tstd::unique_ptr<Algorithm<Module>> algo = createAlgorithm(name);\n+\t\tif (!algo) {\n+\t\t\tLOG(IPAModuleAlgo, Error)\n+\t\t\t\t<< \"Algorithm '\" << name << \"' not found\";\n+\t\t\treturn -EINVAL;\n+\t\t}\n+\n+\t\tint ret = algo->init(context, algoData);\n+\t\tif (ret) {\n+\t\t\tLOG(IPAModuleAlgo, Error)\n+\t\t\t\t<< \"Algorithm '\" << name << \"' failed to initialize\";\n+\t\t\treturn ret;\n+\t\t}\n+\n+\t\tLOG(IPAModuleAlgo, Debug)\n+\t\t\t<< \"Instantiated algorithm '\" << name << \"'\";\n+\n+\t\talgorithms_.push_back(std::move(algo));\n+\t\treturn 0;\n+\t}\n+\n \tstatic std::unique_ptr<Algorithm<Module>> createAlgorithm(const std::string &name)\n \t{\n \t\tfor (const AlgorithmFactory<Module> *factory : factories()) {\n@@ -40,12 +105,6 @@ public:\n \t\treturn nullptr;\n \t}\n \n-\tstatic void registerAlgorithm(AlgorithmFactory<Module> *factory)\n-\t{\n-\t\tfactories().push_back(factory);\n-\t}\n-\n-private:\n \tstatic std::vector<AlgorithmFactory<Module> *> &factories()\n \t{\n \t\t/*\n@@ -56,6 +115,8 @@ private:\n \t\tstatic std::vector<AlgorithmFactory<Module> *> factories;\n \t\treturn factories;\n \t}\n+\n+\tstd::list<std::unique_ptr<Algorithm<Module>>> algorithms_;\n };\n \n } /* namespace ipa */\n", "prefixes": [ "libcamera-devel", "v4", "05/12" ] }