From patchwork Wed Jun 5 22:18:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 1362 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id A75FA63581 for ; Thu, 6 Jun 2019 00:18:28 +0200 (CEST) Received: from localhost.localdomain (unknown [96.44.9.117]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 0305E2D1; Thu, 6 Jun 2019 00:18:27 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1559773108; bh=DivdmcAJO1wAnWb4pm5wgAFaMrvdU91kw1hjFJ2PgTo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ACszzDkGIf/hN6ho76txNuNkBK7ZEsqDAIiUNwt0RQu/SzaKsMKLVSe3gWcFbujdM HlJNMi+akgzCVR/Pb8IBJ6YBNvTqiieF0OtuDQK5BcI2tYmmKKUkS6qkCFR0vgZCBy 4PsS9/G5V8JuG/Kcxkncu+JPNXQIfsPo0/35QToI= From: Paul Elder To: libcamera-devel@lists.libcamera.org Date: Wed, 5 Jun 2019 18:18:08 -0400 Message-Id: <20190605221817.966-2-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190605221817.966-1-paul.elder@ideasonboard.com> References: <20190605221817.966-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [RFC PATCH 01/10] libcamera: ipa_module_info: remove cplusplus guards X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 05 Jun 2019 22:18:28 -0000 IPA modules must be implemented in C++, which means we no longer need __cplusplus guards, so remove them. Signed-off-by: Paul Elder Reviewed-by: Laurent Pinchart --- include/libcamera/ipa/ipa_module_info.h | 8 -------- 1 file changed, 8 deletions(-) diff --git a/include/libcamera/ipa/ipa_module_info.h b/include/libcamera/ipa/ipa_module_info.h index 803b5d3..585f753 100644 --- a/include/libcamera/ipa/ipa_module_info.h +++ b/include/libcamera/ipa/ipa_module_info.h @@ -11,9 +11,7 @@ #define IPA_MODULE_API_VERSION 1 -#ifdef __cplusplus namespace libcamera { -#endif struct IPAModuleInfo { int moduleAPIVersion; @@ -22,16 +20,10 @@ struct IPAModuleInfo { char name[256]; } __attribute__((packed)); -#ifdef __cplusplus extern "C" { -#endif extern const struct IPAModuleInfo ipaModuleInfo; -#ifdef __cplusplus }; -#endif -#ifdef __cplusplus }; /* namespace libcamera */ -#endif #endif /* __LIBCAMERA_IPA_MODULE_INFO_H__ */ From patchwork Wed Jun 5 22:18:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 1363 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 59DCE64608 for ; Thu, 6 Jun 2019 00:18:29 +0200 (CEST) Received: from localhost.localdomain (unknown [96.44.9.117]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id A806984; Thu, 6 Jun 2019 00:18:28 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1559773109; bh=so+lnPNN9ud5ole5bqrKe2TboIM9D+ocCQzrji9VjnU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ONwaOhXRuuMkFbwnC4b9tA5GdCg6DKECT/oXdmVJc+mS0YevEoyNuDFGUncJjdJDV 47r/ijqiaP+v/ZQQvo3kEDFUeW3B1jxsg3hOIktX7J0H6UqHB0gOIbHQKNiLhdn957 JbNMRH+3B6jLlu4qB4tzqY29Ydjmesr/yrgCbLRQ= From: Paul Elder To: libcamera-devel@lists.libcamera.org Date: Wed, 5 Jun 2019 18:18:09 -0400 Message-Id: <20190605221817.966-3-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190605221817.966-1-paul.elder@ideasonboard.com> References: <20190605221817.966-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [RFC PATCH 02/10] libcamera: ipa_module: add path getter X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 05 Jun 2019 22:18:29 -0000 Add a method to IPAModule to get the path of the IPA module shared object that the IPAModule was constructed from. Signed-off-by: Paul Elder Reviewed-by: Laurent Pinchart --- src/libcamera/include/ipa_module.h | 1 + src/libcamera/ipa_module.cpp | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/src/libcamera/include/ipa_module.h b/src/libcamera/include/ipa_module.h index fec4237..f6904fa 100644 --- a/src/libcamera/include/ipa_module.h +++ b/src/libcamera/include/ipa_module.h @@ -26,6 +26,7 @@ public: bool isValid() const; const struct IPAModuleInfo &info() const; + const char *path() const; bool load(); diff --git a/src/libcamera/ipa_module.cpp b/src/libcamera/ipa_module.cpp index 2663b9e..e1d4b27 100644 --- a/src/libcamera/ipa_module.cpp +++ b/src/libcamera/ipa_module.cpp @@ -321,6 +321,19 @@ const struct IPAModuleInfo &IPAModule::info() const return info_; } +/** + * \brief Retrieve the IPA module path + * + * The IPA module path is the file name and path of the IPA module shared + * object from which the IPA module was created. + * + * \return the IPA module path + */ +const char *IPAModule::path() const +{ + return libPath_.c_str(); +} + /** * \brief Load the IPA implementation factory from the shared object * From patchwork Wed Jun 5 22:18:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 1364 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 2A2F763B17 for ; Thu, 6 Jun 2019 00:18:30 +0200 (CEST) Received: from localhost.localdomain (unknown [96.44.9.117]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 5BBE62D1; Thu, 6 Jun 2019 00:18:29 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1559773109; bh=PJPujODM+mZEHea8RunfQ7+YGDTZ/WytjuNJ9SWA8c8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=f1eFeDElaNkD682FjfsGxhdGJcUrwwmkdU/flO23cbw4rgCAZRVgs5KdmjMpjNtPo o+yOoyDM43WsnMpIgMbEKaQfIiCEivyrMwBKKXUCbPFO8O7iOYtttF5zJNC9e1sgv1 J+bXsozQdIMl87/VSM1toZiYHlV+MOiuMeE0MDPk= From: Paul Elder To: libcamera-devel@lists.libcamera.org Date: Wed, 5 Jun 2019 18:18:10 -0400 Message-Id: <20190605221817.966-4-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190605221817.966-1-paul.elder@ideasonboard.com> References: <20190605221817.966-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [RFC PATCH 03/10] libcamera: ipa_module: add loading error messages X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 05 Jun 2019 22:18:30 -0000 Currently, if an IPAModule fails to be constructed due to size mismatch of struct IPAModuleInfo, the error is simply "symbol not found". Add an error message to say that the symbol is found, but not valid. Also add an error message to tell, if an IPA module failed to load, the path to the IPA module shared object that was attempted to be loaded. Signed-off-by: Paul Elder --- src/libcamera/ipa_module.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/libcamera/ipa_module.cpp b/src/libcamera/ipa_module.cpp index e1d4b27..84c77f7 100644 --- a/src/libcamera/ipa_module.cpp +++ b/src/libcamera/ipa_module.cpp @@ -145,6 +145,12 @@ int elfLoadSymbol(void *dst, size_t size, void *map, size_t soSize, targetSymbol = sym; break; } + + if (!strcmp(name, symbol)) { + LOG(IPAModule, Error) + << "Symbol " << symbol + << " found, but not valid. Check module version."; + } } if (targetSymbol == nullptr) { @@ -286,6 +292,12 @@ int IPAModule::loadIPAModuleInfo() ret = -EINVAL; } + if (ret) + LOG(IPAModule, Error) + << "Error loading IPA module at " + << libPath_; + + unmap: munmap(map, soSize); close: From patchwork Wed Jun 5 22:18:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 1365 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 74A1864B8F for ; Thu, 6 Jun 2019 00:18:31 +0200 (CEST) Received: from localhost.localdomain (unknown [96.44.9.117]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 3B1492D1; Thu, 6 Jun 2019 00:18:30 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1559773110; bh=7NmTwFIAJeS3Ymgk6NtzFkRL8N3ccbfAojEQgkv0Hlc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oWDGPXQz9u+esMwIyTTPvxhkfmn0YVaZkD2Co0Dh60bA4FHGPCvBqc4OLwwxWoegU IZkK6X61G7Y7sJx5SPBonGmN10bxTXn3aPYjnhK9K7PStIsTsCXXQXEw9/Wh0TPZmz d+5qQuWHLNKan9FeAmwqYyjvwPNnq3K9LMmS+a18= From: Paul Elder To: libcamera-devel@lists.libcamera.org Date: Wed, 5 Jun 2019 18:18:11 -0400 Message-Id: <20190605221817.966-5-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190605221817.966-1-paul.elder@ideasonboard.com> References: <20190605221817.966-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [RFC PATCH 04/10] libcamera: ipa_interface: add init for shims X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 05 Jun 2019 22:18:32 -0000 Add a function to IPAInterface for shims to use to initialize the IPA module that it will wrap around. Signed-off-by: Paul Elder --- include/libcamera/ipa/ipa_interface.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/libcamera/ipa/ipa_interface.h b/include/libcamera/ipa/ipa_interface.h index 2c5eb1f..fd779d2 100644 --- a/include/libcamera/ipa/ipa_interface.h +++ b/include/libcamera/ipa/ipa_interface.h @@ -15,6 +15,7 @@ public: virtual ~IPAInterface() {} virtual int init() = 0; + virtual int init(const char *path) { return 0; }; }; } /* namespace libcamera */ From patchwork Wed Jun 5 22:18:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 1366 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 2CE2B63B83 for ; Thu, 6 Jun 2019 00:18:32 +0200 (CEST) Received: from localhost.localdomain (unknown [96.44.9.117]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 77BC7566; Thu, 6 Jun 2019 00:18:31 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1559773111; bh=4T0kdIeH0qOe7OtK4s+I90fvGoIWqoGB4QAeW8UnRWw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ukjEm1cO+p6TtZoKsT2y/E2kZYA1zhCmzs2fCIUx461naqI8U0Ie2GgGO4fSd14ZN coskJKBb3+o2iGtvIASIPyCtJ1Bszb2AfllV7QHRzkWpnckD+5yxmdQ0++MUukATWy qQk1rpCalWYE0SlTs2S7psOYvxKMPvrNRN7NqYrw= From: Paul Elder To: libcamera-devel@lists.libcamera.org Date: Wed, 5 Jun 2019 18:18:12 -0400 Message-Id: <20190605221817.966-6-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190605221817.966-1-paul.elder@ideasonboard.com> References: <20190605221817.966-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [RFC PATCH 05/10] libcamera: ipa_module_info: add field for isolation X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 05 Jun 2019 22:18:32 -0000 Add a field to IPAModuleInfo that determines whether or not the IPA module needs to be isolated in a separated process. Also increment the IPA_MODULE_API_VERSION, due to the change to struct IPAModuleInfo. Update the dummy IPA and IPA test to conform to the new struct layout. Signed-off-by: Paul Elder --- include/libcamera/ipa/ipa_module_info.h | 3 ++- src/ipa/ipa_dummy.cpp | 1 + test/ipa/ipa_test.cpp | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/include/libcamera/ipa/ipa_module_info.h b/include/libcamera/ipa/ipa_module_info.h index 585f753..cb112e4 100644 --- a/include/libcamera/ipa/ipa_module_info.h +++ b/include/libcamera/ipa/ipa_module_info.h @@ -9,7 +9,7 @@ #include -#define IPA_MODULE_API_VERSION 1 +#define IPA_MODULE_API_VERSION 2 namespace libcamera { @@ -18,6 +18,7 @@ struct IPAModuleInfo { uint32_t pipelineVersion; char pipelineName[256]; char name[256]; + int isolate; } __attribute__((packed)); extern "C" { diff --git a/src/ipa/ipa_dummy.cpp b/src/ipa/ipa_dummy.cpp index ee7a3a8..a8ff88c 100644 --- a/src/ipa/ipa_dummy.cpp +++ b/src/ipa/ipa_dummy.cpp @@ -34,6 +34,7 @@ const struct IPAModuleInfo ipaModuleInfo = { 0, "PipelineHandlerVimc", "Dummy IPA for Vimc", + 0, }; IPAInterface *ipaCreate() diff --git a/test/ipa/ipa_test.cpp b/test/ipa/ipa_test.cpp index bbef069..2682bae 100644 --- a/test/ipa/ipa_test.cpp +++ b/test/ipa/ipa_test.cpp @@ -59,6 +59,7 @@ protected: 0, "PipelineHandlerVimc", "Dummy IPA for Vimc", + 0, }; count += runTest("src/ipa/ipa_dummy.so", testInfo); From patchwork Wed Jun 5 22:18:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 1367 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id CE50A66C75 for ; Thu, 6 Jun 2019 00:18:32 +0200 (CEST) Received: from localhost.localdomain (unknown [96.44.9.117]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 2AF1C9BC; Thu, 6 Jun 2019 00:18:32 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1559773112; bh=bRpVbdJkCA2p8oENqa8RmSJRj6p0z8NpYLh9vE/vAEU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Zom3/DzNyWtl1ecf8cBxqW5bCGtlEM7WzIFQIvQkDlLbZOxco/nEu4jv9TZwepIbE /GPF13YN8ZNL9is8dZ7g+4685ev4PIiLC2E76p8GxDsJ9yidUAevbWrhovIQnz2tnD 9zDX1Esh6L9QFRPU9T4zISVdWVql6iJrulHRDsDA= From: Paul Elder To: libcamera-devel@lists.libcamera.org Date: Wed, 5 Jun 2019 18:18:13 -0400 Message-Id: <20190605221817.966-7-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190605221817.966-1-paul.elder@ideasonboard.com> References: <20190605221817.966-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [RFC PATCH 06/10] libcamera: ipa_manager: add shims X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 05 Jun 2019 22:18:33 -0000 Make IPAManager load shim shared objects in addition to IPA module shared objects, and keep them in a shims list. When requested for an IPA, if the IPA requires isolation, wrap the IPA in the first shim that is available. Signed-off-by: Paul Elder --- src/libcamera/include/ipa_manager.h | 1 + src/libcamera/ipa_manager.cpp | 34 +++++++++++++++++++++++++++-- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/src/libcamera/include/ipa_manager.h b/src/libcamera/include/ipa_manager.h index 310ce7c..a0fb8ad 100644 --- a/src/libcamera/include/ipa_manager.h +++ b/src/libcamera/include/ipa_manager.h @@ -28,6 +28,7 @@ public: private: std::vector modules_; + std::vector shims_; IPAManager(); ~IPAManager(); diff --git a/src/libcamera/ipa_manager.cpp b/src/libcamera/ipa_manager.cpp index f689aa6..3648ea6 100644 --- a/src/libcamera/ipa_manager.cpp +++ b/src/libcamera/ipa_manager.cpp @@ -110,7 +110,10 @@ int IPAManager::addDir(const char *libDir) continue; } - modules_.push_back(ipaModule); + if (!strncmp(ipaModule->info().pipelineName, "Shim", 4)) + shims_.push_back(ipaModule); + else + modules_.push_back(ipaModule); count++; } @@ -132,6 +135,7 @@ std::unique_ptr IPAManager::createIPA(PipelineHandler *pipe, uint32_t minVersion) { IPAModule *m = nullptr; + IPAModule *shim = nullptr; for (IPAModule *module : modules_) { if (module->match(pipe, minVersion, maxVersion)) { @@ -140,7 +144,33 @@ std::unique_ptr IPAManager::createIPA(PipelineHandler *pipe, } } - if (!m || !m->load()) + if (!m) + return nullptr; + + if (m->info().isolate) { + if (shims_.empty()) { + LOG(IPAManager, Error) << "No shims available"; + return nullptr; + } + + shim = shims_.front(); + if (!shim || !shim->load()) { + LOG(IPAManager, Error) << "Failed to obtain shim"; + return nullptr; + } + + auto shimIPAIntf = shim->createInstance(); + if (!shimIPAIntf) { + LOG(IPAManager, Error) << "Failed to load shim"; + return nullptr; + } + + shimIPAIntf->init(m->path()); + + return shimIPAIntf; + } + + if (!m->load()) return nullptr; return m->createInstance(); From patchwork Wed Jun 5 22:18:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 1368 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 7F07363B83 for ; Thu, 6 Jun 2019 00:18:33 +0200 (CEST) Received: from localhost.localdomain (unknown [96.44.9.117]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id D610884; Thu, 6 Jun 2019 00:18:32 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1559773113; bh=yKtpg1snsBsTQzTFgYEtEQIHceQym7X5mvL/qUGr/Dc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bCND2De/TBdruQPMeFkrcca9RqKxzcTJTXBnnGkhZTHW0MRaZhPnPou1tY1MQqKv6 VfynD2pmERLuxvlCxCOtYltGkQuaap9+T/RqJUzkxOSA67qx/icxsO8Hl+0y5un5kx gurzQUHfSzDl1m11T8oifXzm9uubwI0NR9nlz8jk= From: Paul Elder To: libcamera-devel@lists.libcamera.org Date: Wed, 5 Jun 2019 18:18:14 -0400 Message-Id: <20190605221817.966-8-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190605221817.966-1-paul.elder@ideasonboard.com> References: <20190605221817.966-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [RFC PATCH 07/10] libcamera: ipa: shim: add dummy shim X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 05 Jun 2019 22:18:33 -0000 Add a dummy shim. Signed-off-by: Paul Elder --- src/ipa/shim_dummy.cpp | 53 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 src/ipa/shim_dummy.cpp diff --git a/src/ipa/shim_dummy.cpp b/src/ipa/shim_dummy.cpp new file mode 100644 index 0000000..4d28c2d --- /dev/null +++ b/src/ipa/shim_dummy.cpp @@ -0,0 +1,53 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2019, Google Inc. + * + * ipa_dummy.cpp - Dummy Image Processing Algorithm module + */ + +#include + +#include +#include + +namespace libcamera { + +class ShimDummy : public IPAInterface +{ +public: + int init(); + int init(const char *path); +}; + +int ShimDummy::init() +{ + std::cout << "okay shim init without path" << std::endl; + return 0; +} + +int ShimDummy::init(const char *path) +{ + std::cout << "initializing dummy shim!" << std::endl; + return 0; +} + +/* + * External IPA module interface + */ + +extern "C" { +const struct IPAModuleInfo ipaModuleInfo = { + IPA_MODULE_API_VERSION, + 0, + "Shim", + "Dummy Shim", + 1, +}; + +IPAInterface *ipaCreate() +{ + return new ShimDummy(); +} +}; + +}; /* namespace libcamera */ From patchwork Wed Jun 5 22:18:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 1369 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 2BD136487C for ; Thu, 6 Jun 2019 00:18:34 +0200 (CEST) Received: from localhost.localdomain (unknown [96.44.9.117]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 895342D1; Thu, 6 Jun 2019 00:18:33 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1559773113; bh=r7o75nPLoyZFTFoCq5OL0g7DMsWnDTG6E/VoH0AZ9Lk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CCyUank9AW5EmIz9ug+qlJ8Enc9OpkD4N7lCsiH3l6gpSYQpou+SUJQgB3QzrRlpa jF00+luAKwROQ3CSxbxbNASFA62QXqXg0g8Qw++ZlgenAj8Zyc4R3Ij8B4JNM4xZKp J3nmBKFliWEYW3wEbaCfEzAAuVleG64TzygyqND4= From: Paul Elder To: libcamera-devel@lists.libcamera.org Date: Wed, 5 Jun 2019 18:18:15 -0400 Message-Id: <20190605221817.966-9-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190605221817.966-1-paul.elder@ideasonboard.com> References: <20190605221817.966-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [RFC PATCH 08/10] libcamera: ipa: add dummy IPA that needs to be isolated X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 05 Jun 2019 22:18:34 -0000 Add a dummy IPA that needs to be isolated. Signed-off-by: Paul Elder --- src/ipa/ipa_dummy_isolate.cpp | 46 +++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 src/ipa/ipa_dummy_isolate.cpp diff --git a/src/ipa/ipa_dummy_isolate.cpp b/src/ipa/ipa_dummy_isolate.cpp new file mode 100644 index 0000000..87e5ec8 --- /dev/null +++ b/src/ipa/ipa_dummy_isolate.cpp @@ -0,0 +1,46 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2019, Google Inc. + * + * ipa_dummy.cpp - Dummy Image Processing Algorithm module + */ + +#include + +#include +#include + +namespace libcamera { + +class IPADummyIsolate : public IPAInterface +{ +public: + int init(); +}; + +int IPADummyIsolate::init() +{ + std::cout << "initializing dummy IPA!" << std::endl; + return 0; +} + +/* + * External IPA module interface + */ + +extern "C" { +const struct IPAModuleInfo ipaModuleInfo = { + IPA_MODULE_API_VERSION, + 0, + "PipelineHandlerVimc", + "Dummy IPA for Vimc that needs to be isolated", + 1, +}; + +IPAInterface *ipaCreate() +{ + return new IPADummyIsolate(); +} +}; + +}; /* namespace libcamera */ From patchwork Wed Jun 5 22:18:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 1370 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id DDADE66C8D for ; Thu, 6 Jun 2019 00:18:34 +0200 (CEST) Received: from localhost.localdomain (unknown [96.44.9.117]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 3E8412D1; Thu, 6 Jun 2019 00:18:34 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1559773114; bh=lgztqeJGNuTMw8qjsasEi3cBGnvr2dU+ZkE0bztacrY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NuSvLEjqw6k19Z5066V/PNZ5g0UD+6BsrG+ZyVl53tGuiDEnTTl4tFgqRpm3VQ66z kUHOD2uqVYQ2O3gbYCu0AkyXkOhnBhrdM7yOLOXVliRNg5Yad1VAlK8CG5Rv4ShSwl nDvq54DyUM9P8iZUlOUcoTKF+kut0/Xb0DVk3l1c= From: Paul Elder To: libcamera-devel@lists.libcamera.org Date: Wed, 5 Jun 2019 18:18:16 -0400 Message-Id: <20190605221817.966-10-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190605221817.966-1-paul.elder@ideasonboard.com> References: <20190605221817.966-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [RFC PATCH 09/10] libcamera: ipa: meson: build dummy IPA and shim X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 05 Jun 2019 22:18:35 -0000 Add dummy IPA and dummy shim to meson. At the same time, clean up the IPA meson to facilitate adding more IPAs. Signed-off-by: Paul Elder --- src/ipa/meson.build | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/ipa/meson.build b/src/ipa/meson.build index 3c33a37..f5d539e 100644 --- a/src/ipa/meson.build +++ b/src/ipa/meson.build @@ -1,15 +1,19 @@ -ipa_dummy_sources = files([ - 'ipa_dummy.cpp', -]) +ipa_dummy_sources = [ + ['ipa_dummy', 'ipa_dummy.cpp'], + ['ipa_dummy_isolate', 'ipa_dummy_isolate.cpp'], + ['shim_dummy', 'shim_dummy.cpp'], +] ipa_install_dir = join_paths(get_option('libdir'), 'libcamera') -ipa_dummy = shared_library('ipa_dummy', - ipa_dummy_sources, - name_prefix : '', - include_directories : libcamera_includes, - install : true, - install_dir : ipa_install_dir) +foreach t : ipa_dummy_sources + ipa = shared_module(t[0], + t[1], + name_prefix : '', + include_directories : libcamera_includes, + install : true, + install_dir : ipa_install_dir) +endforeach config_h.set('IPA_MODULE_DIR', '"' + join_paths(get_option('prefix'), ipa_install_dir) + '"') From patchwork Wed Jun 5 22:18:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 1371 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 88C6164772 for ; Thu, 6 Jun 2019 00:18:35 +0200 (CEST) Received: from localhost.localdomain (unknown [96.44.9.117]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id E343C84; Thu, 6 Jun 2019 00:18:34 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1559773115; bh=EUm7WwfdOoEbXjefZzOV8nULKUqO1Bc4JJNcuQDD1Y8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YpQ1iX3gQoGxoHpNhjmpHj5HSySjF53Qw3eexdBAyD6C9SoxeOwDNHlgN7OhWEe5h K+XIFVcfOTTVvcJHNQ9DA6L1kw22IByuZoJRwjbVFVLyNcPPxilYlcW1tZVLo/SLty 71kh/SILzkbvrTpC9BOHrdK8xHl81f2pPgeKDLH4= From: Paul Elder To: libcamera-devel@lists.libcamera.org Date: Wed, 5 Jun 2019 18:18:17 -0400 Message-Id: <20190605221817.966-11-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190605221817.966-1-paul.elder@ideasonboard.com> References: <20190605221817.966-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [RFC PATCH 10/10] libcamera: ipa: shim: load IPA module into an IPAInterface X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 05 Jun 2019 22:18:35 -0000 Implement the dummy shim's init method that takes a path for the IPA module to be loaded. Set up IPC, then fork and load the IPAInterface implementation from the IPA module shared object. Implement a cleanup method along with it. Signed-off-by: Paul Elder --- This is the most draft-y patch of the whole series. I wasn't sure how to put what kind of IPC, so I kind of just did this very skeletal "give you an idea" type of IPC initialization. Privilege dropping will be looked into for the next version. src/ipa/shim_dummy.cpp | 79 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 77 insertions(+), 2 deletions(-) diff --git a/src/ipa/shim_dummy.cpp b/src/ipa/shim_dummy.cpp index 4d28c2d..f2e6961 100644 --- a/src/ipa/shim_dummy.cpp +++ b/src/ipa/shim_dummy.cpp @@ -6,6 +6,14 @@ */ #include +#include + +#include +#include +#include +#include +#include +#include #include #include @@ -17,20 +25,87 @@ class ShimDummy : public IPAInterface public: int init(); int init(const char *path); + + void cleanup(); + +private: + std::unique_ptr ipa_; + + int sockets_[2]; + int childPid_; + void *dlHandle_; + + typedef IPAInterface *(*IPAIntfFactory)(void); }; int ShimDummy::init() { - std::cout << "okay shim init without path" << std::endl; + std::cout << "initializing IPA via dummy shim!" << std::endl; return 0; } int ShimDummy::init(const char *path) { - std::cout << "initializing dummy shim!" << std::endl; + std::cout << "initializing dummy shim! loading IPA from " << path + << std::endl; + + /* We know the IPA module is valid, otherwise IPAManager wouldn't + * even give its path to us. */ + + // setup comm + if (socketpair(AF_UNIX, SOCK_STREAM, 0, sockets_)) { + int err = errno; + std::cerr << "Error opening sockets: " << strerror(errno) + << std::endl; + return err; + } + + // fork + if ((childPid_ = fork()) == -1) { + int err = errno; + std::cerr << "Failed to fork: " << strerror(errno) << std::endl; + return err; + } else if (childPid_) { + // we are parent + // we can read/write sockets_[1] + close(sockets_[0]); + } else { + // we are child + // we can read/write sockets_[0] + close(sockets_[1]); + + dlHandle_ = dlopen(path, RTLD_LAZY); + if (!dlHandle_) { + std::cerr << "Failed to open IPA module: " + << dlerror() << std::endl; + return -1; + } + + void *symbol = dlsym(dlHandle_, "ipaCreate"); + if (!symbol) { + std::cerr + << "Failed to load ipaCreate() from IPA module shared object: " + << dlerror(); + dlclose(dlHandle_); + dlHandle_ = nullptr; + return -1; + } + + IPAIntfFactory ipaCreate = reinterpret_cast(symbol); + ipa_ = std::unique_ptr(ipaCreate()); + exit(0); + } + return 0; } +void ShimDummy::cleanup() +{ + if (dlHandle_) + dlclose(dlHandle_); + dlHandle_ = nullptr; +} + /* * External IPA module interface */