{"id":9933,"url":"https://patchwork.libcamera.org/api/1.1/patches/9933/?format=json","web_url":"https://patchwork.libcamera.org/patch/9933/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20201002143154.468162-26-paul.elder@ideasonboard.com>","date":"2020-10-02T14:31:41","name":"[libcamera-devel,v3,25/38] libcamera: IPAManager: Make createIPA return proxy directly","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"49d823508a557771c06684843bf42c12f38588db","submitter":{"id":17,"url":"https://patchwork.libcamera.org/api/1.1/people/17/?format=json","name":"Paul Elder","email":"paul.elder@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/9933/mbox/","series":[{"id":1348,"url":"https://patchwork.libcamera.org/api/1.1/series/1348/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=1348","date":"2020-10-02T14:31:16","name":"IPA isolation implementation","version":3,"mbox":"https://patchwork.libcamera.org/series/1348/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/9933/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/9933/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 D3035C3B5C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri,  2 Oct 2020 14:33:08 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 9FC2963B98;\n\tFri,  2 Oct 2020 16:33:08 +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 42C8563B6A\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri,  2 Oct 2020 16:33:07 +0200 (CEST)","from pyrite.rasen.tech (unknown\n\t[IPv6:2400:4051:61:600:2c71:1b79:d06d:5032])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id F2817FD1;\n\tFri,  2 Oct 2020 16:33:04 +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=\"fSyA3pBc\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1601649187;\n\tbh=A988jWffaGguysURX5q6vJmOfC/W8RbtoBtlOGoIIw0=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=fSyA3pBc+w+ymu3HeM63Gn3fKHRbrS0O1n88N37kMfGoQ8rRp7ygZMf/96qNRfPhk\n\tlOC7c+ZmM/ahn/PT4XSEIOkNF0cLSPYTxcW0elPYp/XebAe8EbblCKN2N71qcB6dSq\n\too0YOooYGdNZyw2xWOi5xrw9EiirTFhkInVMC/QI=","From":"Paul Elder <paul.elder@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Fri,  2 Oct 2020 23:31:41 +0900","Message-Id":"<20201002143154.468162-26-paul.elder@ideasonboard.com>","X-Mailer":"git-send-email 2.27.0","In-Reply-To":"<20201002143154.468162-1-paul.elder@ideasonboard.com>","References":"<20201002143154.468162-1-paul.elder@ideasonboard.com>","MIME-Version":"1.0","Subject":"[libcamera-devel] [PATCH v3 25/38] libcamera: IPAManager: Make\n\tcreateIPA return proxy directly","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>","Content-Type":"text/plain; charset=\"utf-8\"","Content-Transfer-Encoding":"base64","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"Since every pipeline knows the type of the proxy that it needs, and\nsince all IPAs are to be wrapped in a proxy, IPAManager no longer needs\nto search in the factory list to fetch the proxy factory to construct a\nfactory. Instead, we define createIPA as a template function, and the\npipeline handler can declare the proxy type when it calls createIPA.\n\nSigned-off-by: Paul Elder <paul.elder@ideasonboard.com>\nReviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n\n---\nNo change in v3\n\nNo change in v2\n---\n include/libcamera/internal/ipa_manager.h | 31 +++++++++++++--\n src/libcamera/ipa_manager.cpp            | 48 +-----------------------\n 2 files changed, 29 insertions(+), 50 deletions(-)","diff":"diff --git a/include/libcamera/internal/ipa_manager.h b/include/libcamera/internal/ipa_manager.h\nindex 4a143b6a..297a8a58 100644\n--- a/include/libcamera/internal/ipa_manager.h\n+++ b/include/libcamera/internal/ipa_manager.h\n@@ -14,20 +14,45 @@\n #include <libcamera/ipa/ipa_module_info.h>\n \n #include \"libcamera/internal/ipa_module.h\"\n+#include \"libcamera/internal/log.h\"\n #include \"libcamera/internal/pipeline_handler.h\"\n #include \"libcamera/internal/pub_key.h\"\n \n namespace libcamera {\n \n+LOG_DECLARE_CATEGORY(IPAManager)\n+\n class IPAManager\n {\n public:\n \tIPAManager();\n \t~IPAManager();\n \n-\tstatic std::unique_ptr<IPAProxy> createIPA(PipelineHandler *pipe,\n-\t\t\t\t\t\t   uint32_t maxVersion,\n-\t\t\t\t\t\t   uint32_t minVersion);\n+\ttemplate<class P>\n+\tstatic std::unique_ptr<P> createIPA(PipelineHandler *pipe,\n+\t\t\t\t\t    uint32_t maxVersion,\n+\t\t\t\t\t    uint32_t minVersion)\n+\t{\n+\t\tIPAModule *m = nullptr;\n+\n+\t\tfor (IPAModule *module : self_->modules_) {\n+\t\t\tif (module->match(pipe, minVersion, maxVersion)) {\n+\t\t\t\tm = module;\n+\t\t\t\tbreak;\n+\t\t\t}\n+\t\t}\n+\n+\t\tif (!m)\n+\t\t\treturn nullptr;\n+\n+\t\tstd::unique_ptr<P> proxy = std::make_unique<P>(m, !self_->isSignatureValid(m));\n+\t\tif (!proxy->isValid()) {\n+\t\t\tLOG(IPAManager, Error) << \"Failed to load proxy\";\n+\t\t\treturn nullptr;\n+\t\t}\n+\n+\t\treturn proxy;\n+\t}\n \n private:\n \tstatic IPAManager *self_;\ndiff --git a/src/libcamera/ipa_manager.cpp b/src/libcamera/ipa_manager.cpp\nindex 26458153..0d518443 100644\n--- a/src/libcamera/ipa_manager.cpp\n+++ b/src/libcamera/ipa_manager.cpp\n@@ -245,6 +245,7 @@ unsigned int IPAManager::addDir(const char *libDir, unsigned int maxDepth)\n }\n \n /**\n+ * \\fn IPAManager::createIPA()\n  * \\brief Create an IPA proxy that matches a given pipeline handler\n  * \\param[in] pipe The pipeline handler that wants a matching IPA proxy\n  * \\param[in] minVersion Minimum acceptable version of IPA module\n@@ -253,53 +254,6 @@ unsigned int IPAManager::addDir(const char *libDir, unsigned int maxDepth)\n  * \\return A newly created IPA proxy, or nullptr if no matching IPA module is\n  * found or if the IPA proxy fails to initialize\n  */\n-std::unique_ptr<IPAProxy> IPAManager::createIPA(PipelineHandler *pipe,\n-\t\t\t\t\t\tuint32_t maxVersion,\n-\t\t\t\t\t\tuint32_t minVersion)\n-{\n-\tIPAModule *m = nullptr;\n-\n-\tfor (IPAModule *module : self_->modules_) {\n-\t\tif (module->match(pipe, minVersion, maxVersion)) {\n-\t\t\tm = module;\n-\t\t\tbreak;\n-\t\t}\n-\t}\n-\n-\tif (!m)\n-\t\treturn nullptr;\n-\n-\t/*\n-\t * Load and run the IPA module in a thread if it has a valid signature,\n-\t * or isolate it in a separate process otherwise.\n-\t *\n-\t * \\todo Implement a better proxy selection\n-\t */\n-\tstd::string pipeName(pipe->name());\n-\tconst char *proxyName = pipeName.replace(0, 15, \"IPAProxy\").c_str();\n-\tIPAProxyFactory *pf = nullptr;\n-\n-\tfor (IPAProxyFactory *factory : IPAProxyFactory::factories()) {\n-\t\tif (!strcmp(factory->name().c_str(), proxyName)) {\n-\t\t\tpf = factory;\n-\t\t\tbreak;\n-\t\t}\n-\t}\n-\n-\tif (!pf) {\n-\t\tLOG(IPAManager, Error) << \"Failed to get proxy factory\";\n-\t\treturn nullptr;\n-\t}\n-\n-\tstd::unique_ptr<IPAProxy> proxy =\n-\t\tpf->create(m, !self_->isSignatureValid(m));\n-\tif (!proxy->isValid()) {\n-\t\tLOG(IPAManager, Error) << \"Failed to load proxy\";\n-\t\treturn nullptr;\n-\t}\n-\n-\treturn proxy;\n-}\n \n bool IPAManager::isSignatureValid([[maybe_unused]] IPAModule *ipa) const\n {\n","prefixes":["libcamera-devel","v3","25/38"]}