From patchwork Wed Jun 5 00:53:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 1349 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 3AA5F64715 for ; Wed, 5 Jun 2019 02:53:28 +0200 (CEST) Received: from localhost.localdomain (unknown [96.44.9.117]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 66E2B321; Wed, 5 Jun 2019 02:53:27 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1559696007; bh=3bqDVGvliX70qUzX3ccl7Np2y/M52gOWDZr00dyTheA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sHCOl9JUcIRN+nr6D2r5zp2YFD/JAJPc1lC1nWsmjIBU3eSpetqOMZEjFG6P9/bdP Z3/tuesOwrm+wew+Qexz3NH1rw2eqQNKK5Zo30CnDR4xBDdckTb7FzzeSfjVeFqf4i WTbvC6C2otH2/A4IlBg9i+sltGl1asApQcCoIWtc= From: Paul Elder To: libcamera-devel@lists.libcamera.org Date: Tue, 4 Jun 2019 20:53:07 -0400 Message-Id: <20190605005316.4835-2-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190605005316.4835-1-paul.elder@ideasonboard.com> References: <20190605005316.4835-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 01/10] libcamera: ipa_interface: add header 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 00:53:28 -0000 Define an IPAInterface class which will contain an IPA implementation. The methods that the IPAInterface exposes form the interface to the IPA implementation, hence the name. IPA module shared objects will implement this class. This also means that IPA module shared objects must be implemented in C++, so remove the C test IPA module. Signed-off-by: Paul Elder Reviewed-by: Laurent Pinchart --- No change in v3 No change in v2 include/libcamera/ipa/ipa_interface.h | 22 ++++++++++++++++++++++ include/libcamera/meson.build | 1 + src/libcamera/ipa_interface.cpp | 27 +++++++++++++++++++++++++++ src/libcamera/meson.build | 1 + test/ipa/ipa_test.cpp | 2 -- test/ipa/meson.build | 1 - test/ipa/shared_test.c | 6 ------ 7 files changed, 51 insertions(+), 9 deletions(-) create mode 100644 include/libcamera/ipa/ipa_interface.h create mode 100644 src/libcamera/ipa_interface.cpp delete mode 100644 test/ipa/shared_test.c diff --git a/include/libcamera/ipa/ipa_interface.h b/include/libcamera/ipa/ipa_interface.h new file mode 100644 index 0000000..2c5eb1f --- /dev/null +++ b/include/libcamera/ipa/ipa_interface.h @@ -0,0 +1,22 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2019, Google Inc. + * + * ipa_interface.h - Image Processing Algorithm interface + */ +#ifndef __LIBCAMERA_IPA_INTERFACE_H__ +#define __LIBCAMERA_IPA_INTERFACE_H__ + +namespace libcamera { + +class IPAInterface +{ +public: + virtual ~IPAInterface() {} + + virtual int init() = 0; +}; + +} /* namespace libcamera */ + +#endif /* __LIBCAMERA_IPA_INTERFACE_H__ */ diff --git a/include/libcamera/meson.build b/include/libcamera/meson.build index 1fcf6b5..1b86fdc 100644 --- a/include/libcamera/meson.build +++ b/include/libcamera/meson.build @@ -5,6 +5,7 @@ libcamera_api = files([ 'event_dispatcher.h', 'event_notifier.h', 'geometry.h', + 'ipa/ipa_interface.h', 'ipa/ipa_module_info.h', 'object.h', 'request.h', diff --git a/src/libcamera/ipa_interface.cpp b/src/libcamera/ipa_interface.cpp new file mode 100644 index 0000000..9d30da2 --- /dev/null +++ b/src/libcamera/ipa_interface.cpp @@ -0,0 +1,27 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2019, Google Inc. + * + * ipa_interface.cpp - Image Processing Algorithm interface + */ + +#include + +/** + * \file ipa_interface.h + * \brief Image Processing Algorithm interface + */ + +namespace libcamera { + +/** + * \class IPAInterface + * \brief Interface for IPA implementation + */ + +/** + * \fn IPAInterface::init() + * \brief Initialise the IPAInterface + */ + +} /* namespace libcamera */ diff --git a/src/libcamera/meson.build b/src/libcamera/meson.build index 6a73580..07335e5 100644 --- a/src/libcamera/meson.build +++ b/src/libcamera/meson.build @@ -10,6 +10,7 @@ libcamera_sources = files([ 'event_notifier.cpp', 'formats.cpp', 'geometry.cpp', + 'ipa_interface.cpp', 'ipa_module.cpp', 'log.cpp', 'media_device.cpp', diff --git a/test/ipa/ipa_test.cpp b/test/ipa/ipa_test.cpp index 9861ee2..2dbc702 100644 --- a/test/ipa/ipa_test.cpp +++ b/test/ipa/ipa_test.cpp @@ -60,8 +60,6 @@ protected: 9001, }; - count += runTest("test/ipa/ipa-dummy-c.so", testInfo); - count += runTest("test/ipa/ipa-dummy-cpp.so", testInfo); if (count < 0) diff --git a/test/ipa/meson.build b/test/ipa/meson.build index ecde313..08ee95c 100644 --- a/test/ipa/meson.build +++ b/test/ipa/meson.build @@ -1,5 +1,4 @@ ipa_modules_sources = [ - ['ipa-dummy-c', 'shared_test.c'], ['ipa-dummy-cpp', 'shared_test.cpp'], ] diff --git a/test/ipa/shared_test.c b/test/ipa/shared_test.c deleted file mode 100644 index 87d182b..0000000 --- a/test/ipa/shared_test.c +++ /dev/null @@ -1,6 +0,0 @@ -#include - -const struct IPAModuleInfo ipaModuleInfo = { - .name = "It's over nine thousand!", - .version = 9001, -}; From patchwork Wed Jun 5 00:53: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: 1350 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id DF4D964715 for ; Wed, 5 Jun 2019 02:53:28 +0200 (CEST) Received: from localhost.localdomain (unknown [96.44.9.117]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 3A4012D1; Wed, 5 Jun 2019 02:53:28 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1559696008; bh=mkRO0aFvSt525vcU6vZxJM/oAHUmGZr2juS9gswQcck=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OxyipHXunKP+98SFhuyARWtEfhUNmyil6ZjbpSqQt9h5TY97gqG6pa3v+cWdtoqjs aryd3BOS4E7fSRiXdT1aXTH66bddL23LG4NW32Bdo8xohDob1k9cE5GlS1lc+MZFZF IC6QveVkUBFYTc+qbPUW9KUcg9UiTpmgZoBgE5e8= From: Paul Elder To: libcamera-devel@lists.libcamera.org Date: Tue, 4 Jun 2019 20:53:08 -0400 Message-Id: <20190605005316.4835-3-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190605005316.4835-1-paul.elder@ideasonboard.com> References: <20190605005316.4835-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 02/10] libcamera: pipeline: add name 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 00:53:29 -0000 In order to match an IPA module with a pipeline handler, the pipeline handler must have a name. Add a name attribute and getter to PipelineHandler such that it can automatically be defined by REGISTER_PIPELINE_HANDLER. Signed-off-by: Paul Elder Reviewed-by: Laurent Pinchart --- Changes in v3: - remove version completely from the pipeline hander's side, as the pipeline handler will now specify its acceptable version range when it asks the IPAManager for an IPAInterface (so IPAModules still need a pipeline version) - nicer, less intrusive way of setting the pipeline names by making the pipeline handler factory a friend class of pipeline handler Changes in v2: - make the name and version getters into methods of the base PipelineHandler class, so that the specialized pipeline handlers no longer have to specify overriding - add PIPELINE_VERSION macro to create one version number from major and minor pair src/libcamera/include/pipeline_handler.h | 14 +++++++++++++- src/libcamera/pipeline_handler.cpp | 17 +++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/src/libcamera/include/pipeline_handler.h b/src/libcamera/include/pipeline_handler.h index 7da6df1..84307e4 100644 --- a/src/libcamera/include/pipeline_handler.h +++ b/src/libcamera/include/pipeline_handler.h @@ -77,6 +77,8 @@ public: bool completeBuffer(Camera *camera, Request *request, Buffer *buffer); void completeRequest(Camera *camera, Request *request); + const char *name() const { return name_; } + protected: void registerCamera(std::shared_ptr camera, std::unique_ptr data); @@ -93,6 +95,10 @@ private: std::vector> mediaDevices_; std::vector> cameras_; std::map> cameraData_; + + const char *name_; + + friend class PipelineHandlerFactory; }; class PipelineHandlerFactory @@ -108,6 +114,9 @@ public: static void registerType(PipelineHandlerFactory *factory); static std::vector &factories(); +protected: + void setInfo(PipelineHandler *handler, const char *name); + private: std::string name_; }; @@ -119,7 +128,10 @@ public: \ handler##Factory() : PipelineHandlerFactory(#handler) {} \ std::shared_ptr create(CameraManager *manager) \ { \ - return std::make_shared(manager); \ + std::shared_ptr h = \ + std::make_shared(manager); \ + setInfo(h.get(), #handler); \ + return h; \ } \ }; \ static handler##Factory global_##handler##Factory; diff --git a/src/libcamera/pipeline_handler.cpp b/src/libcamera/pipeline_handler.cpp index dd56907..800931d 100644 --- a/src/libcamera/pipeline_handler.cpp +++ b/src/libcamera/pipeline_handler.cpp @@ -505,6 +505,12 @@ CameraData *PipelineHandler::cameraData(const Camera *camera) * constant for the whole lifetime of the pipeline handler. */ +/** + * \fn PipelineHandler::name() + * \brief Retrieve the pipeline handler name + * \return The pipeline handler name + */ + /** * \class PipelineHandlerFactory * \brief Registration of PipelineHandler classes and creation of instances @@ -582,6 +588,17 @@ std::vector &PipelineHandlerFactory::factories() return factories; } +/** + * \brief Set the information of a given pipeline handler + * \param[in] handler The handler whose info is to be set + * \param[in] name The name of the pipeline handler + */ +void PipelineHandlerFactory::setInfo(PipelineHandler *handler, + const char *name) +{ + handler->name_ = name; +} + /** * \def REGISTER_PIPELINE_HANDLER * \brief Register a pipeline handler with the pipeline handler factory From patchwork Wed Jun 5 00:53: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: 1351 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 B0F2E64715 for ; Wed, 5 Jun 2019 02:53:29 +0200 (CEST) Received: from localhost.localdomain (unknown [96.44.9.117]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 028672D1; Wed, 5 Jun 2019 02:53:28 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1559696009; bh=uLHP7cKNxNQbJKthygPW0RWsT+atPvzvL1LImshOu1w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lpL1g1t7PyHY2vAtjFJhgWDXGah56/68StB7asAKuH6fGuppdO5NccBjDpIT2Yz+D VghSBA6A503byLvYSy8a+Lu2w8I5l2QuN8Glgyc9e/yR/m/GVgmetpCzthuovJ7+fD dEW1w4SoU8KKqFpGqJ2XCIHE8igZfpb21TtFmmgU= From: Paul Elder To: libcamera-devel@lists.libcamera.org Date: Tue, 4 Jun 2019 20:53:09 -0400 Message-Id: <20190605005316.4835-4-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190605005316.4835-1-paul.elder@ideasonboard.com> References: <20190605005316.4835-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 03/10] libcamera: ipa_module_info: update struct to allow IPA matching 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 00:53:29 -0000 We need a way to match pipelines with IPA modules, so add fields in IPAModuleInfo to hold the IPA module API version number, the pipeline name, and the pipeline version. The module API version is used to determine the layout of struct IPAModuleInfo. Also update IPA module tests and Doxygen accordingly. Doxygen needs to be updated to accomodate __attribute__((packed)). Signed-off-by: Paul Elder Reviewed-by: Laurent Pinchart --- Changes in v3: - remove PIPELINE_VERSION documentation (since the macro was removed, since pipeline versions are now a single number) Changes in v2: - combine pipeline major and minor versions into one using the Documentation/Doxyfile.in | 7 +++--- include/libcamera/ipa/ipa_module_info.h | 10 ++++++-- src/libcamera/ipa_module.cpp | 32 ++++++++++++++++++++----- test/ipa/ipa_test.cpp | 27 +++++++++++---------- test/ipa/shared_test.cpp | 4 +++- 5 files changed, 55 insertions(+), 25 deletions(-) diff --git a/Documentation/Doxyfile.in b/Documentation/Doxyfile.in index 67eaded..ac70efb 100644 --- a/Documentation/Doxyfile.in +++ b/Documentation/Doxyfile.in @@ -2016,7 +2016,7 @@ ENABLE_PREPROCESSING = YES # The default value is: NO. # This tag requires that the tag ENABLE_PREPROCESSING is set to YES. -MACRO_EXPANSION = NO +MACRO_EXPANSION = YES # If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES then # the macro expansion is limited to the macros specified with the PREDEFINED and @@ -2024,7 +2024,7 @@ MACRO_EXPANSION = NO # The default value is: NO. # This tag requires that the tag ENABLE_PREPROCESSING is set to YES. -EXPAND_ONLY_PREDEF = NO +EXPAND_ONLY_PREDEF = YES # If the SEARCH_INCLUDES tag is set to YES, the include files in the # INCLUDE_PATH will be searched if a #include is found. @@ -2057,7 +2057,8 @@ INCLUDE_FILE_PATTERNS = *.h # This tag requires that the tag ENABLE_PREPROCESSING is set to YES. PREDEFINED = __DOXYGEN__ \ - __cplusplus + __cplusplus \ + __attribute__(x)= # If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then this # tag can be used to specify a list of macro names that should be expanded. The diff --git a/include/libcamera/ipa/ipa_module_info.h b/include/libcamera/ipa/ipa_module_info.h index 4e0d668..803b5d3 100644 --- a/include/libcamera/ipa/ipa_module_info.h +++ b/include/libcamera/ipa/ipa_module_info.h @@ -7,14 +7,20 @@ #ifndef __LIBCAMERA_IPA_MODULE_INFO_H__ #define __LIBCAMERA_IPA_MODULE_INFO_H__ +#include + +#define IPA_MODULE_API_VERSION 1 + #ifdef __cplusplus namespace libcamera { #endif struct IPAModuleInfo { + int moduleAPIVersion; + uint32_t pipelineVersion; + char pipelineName[256]; char name[256]; - unsigned int version; -}; +} __attribute__((packed)); #ifdef __cplusplus extern "C" { diff --git a/src/libcamera/ipa_module.cpp b/src/libcamera/ipa_module.cpp index 86cbe71..f79a44e 100644 --- a/src/libcamera/ipa_module.cpp +++ b/src/libcamera/ipa_module.cpp @@ -169,6 +169,17 @@ int elfLoadSymbol(void *dst, size_t size, void *map, size_t soSize, } /* namespace */ +/** + * \def IPA_MODULE_API_VERSION + * \brief The IPA module API version + * + * This version number specifies the version for the layout of + * struct IPAModuleInfo. The IPA module shall use this macro to + * set its moduleAPIVersion field. + * + * \sa IPAModuleInfo::moduleAPIVersion + */ + /** * \struct IPAModuleInfo * \brief Information of an IPA module @@ -176,14 +187,23 @@ int elfLoadSymbol(void *dst, size_t size, void *map, size_t soSize, * This structure contains the information of an IPA module. It is loaded, * read, and validated before anything else is loaded from the shared object. * - * \var IPAModuleInfo::name - * \brief The name of the IPA module + * \var IPAModuleInfo::moduleAPIVersion + * \brief The IPA module API version that the IPA module implements + * + * This version number specifies the version for the layout of + * struct IPAModuleInfo. The IPA module shall report here the version that + * it was built for, using the macro IPA_MODULE_API_VERSION. + * + * \var IPAModuleInfo::pipelineVersion + * \brief The pipeline handler version that the IPA module is for * - * \var IPAModuleInfo::version - * \brief The version of the IPA module + * \var IPAModuleInfo::pipelineName + * \brief The name of the pipeline handler that the IPA module is for * - * \todo abi compatability version - * \todo pipeline compatability matcher + * This name is used to match a pipeline handler with the module. + * + * \var IPAModuleInfo::name + * \brief The name of the IPA module */ /** diff --git a/test/ipa/ipa_test.cpp b/test/ipa/ipa_test.cpp index 2dbc702..63e4243 100644 --- a/test/ipa/ipa_test.cpp +++ b/test/ipa/ipa_test.cpp @@ -33,18 +33,17 @@ protected: const struct IPAModuleInfo &info = ll->info(); - if (strcmp(info.name, testInfo.name)) { - cerr << "test IPA module has incorrect name" << endl; - cerr << "expected \"" << testInfo.name << "\", got \"" - << info.name << "\"" << endl; - ret = -1; - } - - if (info.version != testInfo.version) { - cerr << "test IPA module has incorrect version" << endl; - cerr << "expected \"" << testInfo.version << "\", got \"" - << info.version << "\"" << endl; - ret = -1; + if (memcmp(&info, &testInfo, sizeof(info))) { + cerr << "IPA module information mismatch: expected:" << endl + << "moduleAPIVersion = " << testInfo.moduleAPIVersion << endl + << "pipelineVersion = " << testInfo.pipelineVersion << endl + << "pipelineName = " << testInfo.pipelineName << endl + << "name = " << testInfo.name + << "got: " << endl + << "moduleAPIVersion = " << info.moduleAPIVersion << endl + << "pipelineVersion = " << info.pipelineVersion << endl + << "pipelineName = " << info.pipelineName << endl + << "name = " << info.name << endl; } delete ll; @@ -56,8 +55,10 @@ protected: int count = 0; const struct IPAModuleInfo testInfo = { - "It's over nine thousand!", + IPA_MODULE_API_VERSION, 9001, + "bleep", + "It's over nine thousand!", }; count += runTest("test/ipa/ipa-dummy-cpp.so", testInfo); diff --git a/test/ipa/shared_test.cpp b/test/ipa/shared_test.cpp index 4e5c976..8bac439 100644 --- a/test/ipa/shared_test.cpp +++ b/test/ipa/shared_test.cpp @@ -4,8 +4,10 @@ namespace libcamera { extern "C" { const struct libcamera::IPAModuleInfo ipaModuleInfo = { - "It's over nine thousand!", + IPA_MODULE_API_VERSION, 9001, + "bleep", + "It's over nine thousand!", }; }; From patchwork Wed Jun 5 00:53: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: 1352 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 92A626471C for ; Wed, 5 Jun 2019 02:53:30 +0200 (CEST) Received: from localhost.localdomain (unknown [96.44.9.117]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id C478F2D1; Wed, 5 Jun 2019 02:53:29 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1559696010; bh=YJ3Ev46ZbfSbeeW3ZSix5DgsNlsTwaQV4Z8rW5yyrB8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LqEqTmSN0LWiWDIEQW5B/UEzj/rl3/BUPd/q8rS1r6s0R/VOmbnTyw1v8Ku9xfqry J4SjGGtPEcfcl18/RkCW6KcBdlFXPWSSHZfmy8lH0T9MswY4YjraXp3BuG7xVfPpOx KDNnMtHuL6ZnOuB72UMj4fSTYrLse8Z8U91GH2OM= From: Paul Elder To: libcamera-devel@lists.libcamera.org Date: Tue, 4 Jun 2019 20:53:10 -0400 Message-Id: <20190605005316.4835-5-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190605005316.4835-1-paul.elder@ideasonboard.com> References: <20190605005316.4835-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 04/10] libcamera: ipa_module: verify IPA module API version upon loading 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 00:53:30 -0000 The IPA module API version determines the layout of struct IPAModuleInfo. If this version number does not match, then it means that the IPA module cannot be loaded at all. Validate this version number upon loading the IPA module info from the IPA shared object. Signed-off-by: Paul Elder Reviewed-by: Laurent Pinchart --- New patch src/libcamera/ipa_module.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/libcamera/ipa_module.cpp b/src/libcamera/ipa_module.cpp index f79a44e..2aa508c 100644 --- a/src/libcamera/ipa_module.cpp +++ b/src/libcamera/ipa_module.cpp @@ -274,6 +274,9 @@ int IPAModule::loadIPAModuleInfo() ret = elfLoadSymbol (&info_, sizeof(info_), map, soSize, "ipaModuleInfo"); + if (info_.moduleAPIVersion != IPA_MODULE_API_VERSION) + ret = -EINVAL; + unmap: munmap(map, soSize); close: From patchwork Wed Jun 5 00:53: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: 1353 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 50C1064726 for ; Wed, 5 Jun 2019 02:53:31 +0200 (CEST) Received: from localhost.localdomain (unknown [96.44.9.117]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 8571B321; Wed, 5 Jun 2019 02:53:30 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1559696011; bh=8Yr4JNBZsjBMRxsbY2d5/GBQ69Qf3NKuX8yyhVVS8MQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=H4Hiry5b/U7T2Bx6eUepxc0xvBWBaLo/lnSaYcDoeAKN0su1DU3YR3pnkaELaXHHN rouNgT/eHlkSvMPdrxEpy2wRrqdmJmjBYOXOusIrGIAG0BOpTNGB4Du2dZv2vHrja7 Htrk0z4KdzhpAyNt/KBkzI/l2C7eBE76nzLfygjw= From: Paul Elder To: libcamera-devel@lists.libcamera.org Date: Tue, 4 Jun 2019 20:53:11 -0400 Message-Id: <20190605005316.4835-6-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190605005316.4835-1-paul.elder@ideasonboard.com> References: <20190605005316.4835-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 05/10] libcamera: ipa_module: allow instantiation of 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 00:53:32 -0000 Add functions for loading the IPAInterface factory function from an IPA module shared object, and for creating an instance of an IPAInterface. These functions will be used by IPAManager, from which a PipelineHandler will request an IPAInterface. Also update meson to add the "-ldl" linker argument, to allow loading of the factory function from a shared object. Signed-off-by: Paul Elder Reviewed-by: Laurent Pinchart --- No major change in v3 Changes in v2: - mostly just documentation src/libcamera/include/ipa_module.h | 12 +++++ src/libcamera/ipa_module.cpp | 83 ++++++++++++++++++++++++++++-- src/libcamera/meson.build | 3 +- 3 files changed, 94 insertions(+), 4 deletions(-) diff --git a/src/libcamera/include/ipa_module.h b/src/libcamera/include/ipa_module.h index a4c6dbd..7ac5cad 100644 --- a/src/libcamera/include/ipa_module.h +++ b/src/libcamera/include/ipa_module.h @@ -7,8 +7,10 @@ #ifndef __LIBCAMERA_IPA_MODULE_H__ #define __LIBCAMERA_IPA_MODULE_H__ +#include #include +#include #include namespace libcamera { @@ -17,16 +19,26 @@ class IPAModule { public: explicit IPAModule(const std::string &libPath); + ~IPAModule(); bool isValid() const; const struct IPAModuleInfo &info() const; + bool load(); + + std::unique_ptr createInstance(); + private: struct IPAModuleInfo info_; std::string libPath_; bool valid_; + bool loaded_; + + void *dlHandle_; + typedef IPAInterface *(*IPAIntfFactory)(void); + IPAIntfFactory ipaCreate_; int loadIPAModuleInfo(); }; diff --git a/src/libcamera/ipa_module.cpp b/src/libcamera/ipa_module.cpp index 2aa508c..8ec4e5a 100644 --- a/src/libcamera/ipa_module.cpp +++ b/src/libcamera/ipa_module.cpp @@ -7,6 +7,7 @@ #include "ipa_module.h" +#include #include #include #include @@ -226,13 +227,12 @@ int elfLoadSymbol(void *dst, size_t size, void *map, size_t soSize, * The IPA module shared object file must be of the same endianness and * bitness as libcamera. * - * \todo load funtions from the IPA to be used by pipelines - * * The caller shall call the isValid() method after constructing an * IPAModule instance to verify the validity of the IPAModule. */ IPAModule::IPAModule(const std::string &libPath) - : libPath_(libPath), valid_(false) + : libPath_(libPath), valid_(false), loaded_(false), + dlHandle_(nullptr), ipaCreate_(nullptr) { if (loadIPAModuleInfo() < 0) return; @@ -240,6 +240,12 @@ IPAModule::IPAModule(const std::string &libPath) valid_ = true; } +IPAModule::~IPAModule() +{ + if (dlHandle_) + dlclose(dlHandle_); +} + int IPAModule::loadIPAModuleInfo() { int fd = open(libPath_.c_str(), O_RDONLY); @@ -312,4 +318,75 @@ const struct IPAModuleInfo &IPAModule::info() const return info_; } +/** + * \brief Load the IPA implementation factory from the shared object + * + * The IPA module shared object implements an IPAInterface class to be used + * by pipeline handlers. This method loads the factory function from the + * shared object. Later, createInstance() can be called to instantiate the + * IPAInterface. + * + * This method only needs to be called successfully once, after which + * createInstance() can be called as many times as IPAInterface instances are + * needed. + * + * Calling this function on an invalid module (as returned by isValid()) is + * an error. + * + * \return True if load was successful, or already loaded, and false otherwise + */ +bool IPAModule::load() +{ + if (!valid_) + return false; + + if (loaded_) + return true; + + dlHandle_ = dlopen(libPath_.c_str(), RTLD_LAZY); + if (!dlHandle_) { + LOG(IPAModule, Error) + << "Failed to open IPA module shared object: " + << dlerror(); + return false; + } + + void *symbol = dlsym(dlHandle_, "ipaCreate"); + if (!symbol) { + LOG(IPAModule, Error) + << "Failed to load ipaCreate() from IPA module shared object: " + << dlerror(); + dlclose(dlHandle_); + dlHandle_ = nullptr; + return false; + } + + ipaCreate_ = reinterpret_cast(symbol); + + loaded_ = true; + + return true; +} + +/** + * \brief Instantiate an IPAInterface + * + * After loading the IPA module with load(), this method creates an + * instance of the IPA module interface. + * + * Calling this function on a module that has not yet been loaded, or an + * invalid module (as returned by load() and isValid(), respectively) is + * an error. + * + * \return The IPA implementation as a new IPAInterface instance on success, + * or nullptr on error + */ +std::unique_ptr IPAModule::createInstance() +{ + if (!valid_ || !loaded_) + return nullptr; + + return std::unique_ptr(ipaCreate_()); +} + } /* namespace libcamera */ diff --git a/src/libcamera/meson.build b/src/libcamera/meson.build index 07335e5..32f7da4 100644 --- a/src/libcamera/meson.build +++ b/src/libcamera/meson.build @@ -65,7 +65,8 @@ libcamera = shared_library('camera', libcamera_sources, install : true, include_directories : includes, - dependencies : libudev) + dependencies : libudev, + link_args : '-ldl') libcamera_dep = declare_dependency(sources : [libcamera_api, libcamera_h], include_directories : libcamera_includes, From patchwork Wed Jun 5 00:53: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: 1354 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 32B9D64723 for ; Wed, 5 Jun 2019 02:53:32 +0200 (CEST) Received: from localhost.localdomain (unknown [96.44.9.117]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 57CA62D1; Wed, 5 Jun 2019 02:53:31 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1559696011; bh=d5RStYmQgp2dyUwQv6sD0WwJcVGkJn/hWKI80THwihQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=L4YE9CUieAeggNSWmBW7Mpqnx7VkFnNooaDUEBvz8gNv6zEreF5XIcVnFhtiLlB9J sH+o4nL3zfDvSmgv4t+jgXdDg6ZkhXX1x5DlBV2Rx2oUM/4hw5z+VIC2jQa7vvccfM oECHAJ7mkcMwiP3wBgilZ4a2NHqyZwpllL1fFR5k= From: Paul Elder To: libcamera-devel@lists.libcamera.org Date: Tue, 4 Jun 2019 20:53:12 -0400 Message-Id: <20190605005316.4835-7-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190605005316.4835-1-paul.elder@ideasonboard.com> References: <20190605005316.4835-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 06/10] libcamera: ipa_module: match IPA module with pipeline handler 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 00:53:32 -0000 Add a method to IPAModule to check if it matches with a given pipeline handler and pipeline version range. Signed-off-by: Paul Elder Reviewed-by: Laurent Pinchart --- Changes in v3: - match() now takes a version range from the caller to match against, instead of getting a version number from the pipeline handler input v2: New patch, but this IPAModule::match method used to be IPAManager::match src/libcamera/include/ipa_module.h | 5 +++++ src/libcamera/ipa_module.cpp | 20 ++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/src/libcamera/include/ipa_module.h b/src/libcamera/include/ipa_module.h index 7ac5cad..fec4237 100644 --- a/src/libcamera/include/ipa_module.h +++ b/src/libcamera/include/ipa_module.h @@ -13,6 +13,8 @@ #include #include +#include "pipeline_handler.h" + namespace libcamera { class IPAModule @@ -29,6 +31,9 @@ public: std::unique_ptr createInstance(); + bool match(PipelineHandler *pipe, + uint32_t minVersion, uint32_t maxVersion) const; + private: struct IPAModuleInfo info_; diff --git a/src/libcamera/ipa_module.cpp b/src/libcamera/ipa_module.cpp index 8ec4e5a..09e96b4 100644 --- a/src/libcamera/ipa_module.cpp +++ b/src/libcamera/ipa_module.cpp @@ -18,6 +18,7 @@ #include #include "log.h" +#include "pipeline_handler.h" /** * \file ipa_module.h @@ -389,4 +390,23 @@ std::unique_ptr IPAModule::createInstance() return std::unique_ptr(ipaCreate_()); } +/** + * \brief Verify if the IPA module maches a given pipeline handler + * \param[in] pipe Pipeline handler to match with + * \param[in] minVersion Minimum acceptable version of IPA module + * \param[in] maxVersion Maximum acceptable version of IPA module + * + * This method checks if this IPA module matches the \a pipe pipeline handler, + * and the input version range. + * + * \return True if the pipeline handler matches the IPA module, or false otherwise + */ +bool IPAModule::match(PipelineHandler *pipe, + uint32_t minVersion, uint32_t maxVersion) const +{ + return info_.pipelineVersion >= minVersion && + info_.pipelineVersion <= maxVersion && + !strcmp(info_.pipelineName, pipe->name()); +} + } /* namespace libcamera */ From patchwork Wed Jun 5 00:53: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: 1355 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id DCC226472A for ; Wed, 5 Jun 2019 02:53:32 +0200 (CEST) Received: from localhost.localdomain (unknown [96.44.9.117]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 36358321; Wed, 5 Jun 2019 02:53:32 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1559696012; bh=uKAEFI4mBSLI5wq4nHzo2wU6t3yS0PtFIQyUZY05y8Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fZkTHM0lrPF7jFb39ou39Hup9ioN2ptfCYOUWq7ZOMk6NM98DEbFXEvZY4bs4u8Tu msVRMiVevr4+1Rld2lJeJV0Mj22ahRSBE1v+3+wd+z7E30J+FBmqkoVc9NdJ+t3OlT gg6OUvXOLE1Jg9Yd41/YJjXzp2ba6OVWd/xdN1l4= From: Paul Elder To: libcamera-devel@lists.libcamera.org Date: Tue, 4 Jun 2019 20:53:13 -0400 Message-Id: <20190605005316.4835-8-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190605005316.4835-1-paul.elder@ideasonboard.com> References: <20190605005316.4835-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 07/10] libcamera: ipa_manager: implement class for managing IPA modules 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 00:53:33 -0000 IPAManager is a class that will search in given directories for IPA modules, and will load them into a list. It also provides an interface for pipeline handlers to acquire an IPA. A meson build file for the IPAs is added, which also specifies a hard-coded path for where to load the IPAs from in the installation directory. More paths can be specified with the environment variable LIBCAMERA_IPA_MODULE_PATH, with the same syntax as the regular PATH environment variable. Make the test framework set this environment variable. Signed-off-by: Paul Elder Reviewed-by: Laurent Pinchart --- Changes in v3: - createIPA() now inputs an acceptable version range to find an IPAModule, as opposed to taking the version of the input pipeline handler - fix strtok (and C++ize it) - rename environment variable from IPA_MODULE_PATH to LIBCAMERA_IPA_MODULE_PATH Changes in v2: - make addDir private, and called from constructor - add hard-coded IPA modules path from meson - read environment variable for additional IPA module paths - move match to IPAModule - make addDir return value more sensible - add the build IPA directory to the IPA module path for all tests src/ipa/meson.build | 2 + src/libcamera/include/ipa_manager.h | 40 ++++++++ src/libcamera/ipa_manager.cpp | 149 ++++++++++++++++++++++++++++ src/libcamera/meson.build | 2 + src/meson.build | 1 + test/libtest/test.cpp | 6 ++ 6 files changed, 200 insertions(+) create mode 100644 src/ipa/meson.build create mode 100644 src/libcamera/include/ipa_manager.h create mode 100644 src/libcamera/ipa_manager.cpp diff --git a/src/ipa/meson.build b/src/ipa/meson.build new file mode 100644 index 0000000..be4f954 --- /dev/null +++ b/src/ipa/meson.build @@ -0,0 +1,2 @@ +config_h.set('IPA_MODULE_DIR', + '"' + join_paths(get_option('prefix'), get_option('libdir'), 'libcamera') + '"') diff --git a/src/libcamera/include/ipa_manager.h b/src/libcamera/include/ipa_manager.h new file mode 100644 index 0000000..310ce7c --- /dev/null +++ b/src/libcamera/include/ipa_manager.h @@ -0,0 +1,40 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2019, Google Inc. + * + * ipa_manager.h - Image Processing Algorithm module manager + */ +#ifndef __LIBCAMERA_IPA_MANAGER_H__ +#define __LIBCAMERA_IPA_MANAGER_H__ + +#include + +#include +#include + +#include "ipa_module.h" +#include "pipeline_handler.h" + +namespace libcamera { + +class IPAManager +{ +public: + static IPAManager *instance(); + + std::unique_ptr createIPA(PipelineHandler *pipe, + uint32_t maxVersion, + uint32_t minVersion); + +private: + std::vector modules_; + + IPAManager(); + ~IPAManager(); + + int addDir(const char *libDir); +}; + +} /* namespace libcamera */ + +#endif /* __LIBCAMERA_IPA_MANAGER_H__ */ diff --git a/src/libcamera/ipa_manager.cpp b/src/libcamera/ipa_manager.cpp new file mode 100644 index 0000000..f689aa6 --- /dev/null +++ b/src/libcamera/ipa_manager.cpp @@ -0,0 +1,149 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2019, Google Inc. + * + * ipa_manager.cpp - Image Processing Algorithm module manager + */ + +#include "ipa_manager.h" + +#include +#include +#include + +#include "ipa_module.h" +#include "log.h" +#include "pipeline_handler.h" +#include "utils.h" + +/** + * \file ipa_manager.h + * \brief Image Processing Algorithm module manager + */ + +namespace libcamera { + +LOG_DEFINE_CATEGORY(IPAManager) + +/** + * \class IPAManager + * \brief Manager for IPA modules + */ + +IPAManager::IPAManager() +{ + addDir(IPA_MODULE_DIR); + + std::string modulePaths = utils::secure_getenv("LIBCAMERA_IPA_MODULE_PATH"); + if (modulePaths.empty()) + return; + + for (size_t pos = 0, delim = 0; delim != std::string::npos; + pos = delim + 1) { + delim = modulePaths.find(':', pos); + size_t count = delim == std::string::npos ? delim : delim - pos; + std::string path = modulePaths.substr(pos, count); + if (path.empty()) + continue; + + addDir(path.c_str()); + } +} + +IPAManager::~IPAManager() +{ + for (IPAModule *module : modules_) + delete module; +} + +/** + * \brief Retrieve the IPA manager instance + * + * The IPAManager is a singleton and can't be constructed manually. This + * function shall instead be used to retrieve the single global instance of the + * manager. + * + * \return The IPA manager instance + */ +IPAManager *IPAManager::instance() +{ + static IPAManager ipaManager; + return &ipaManager; +} + +/** + * \brief Load IPA modules from a directory + * \param[in] libDir directory to search for IPA modules + * + * This method tries to create an IPAModule instance for every shared object + * found in \a libDir, and skips invalid IPA modules. + * + * \return Number of modules loaded by this call, or a negative error code + * otherwise + */ +int IPAManager::addDir(const char *libDir) +{ + struct dirent *ent; + DIR *dir; + + dir = opendir(libDir); + if (!dir) { + int ret = -errno; + LOG(IPAManager, Error) + << "Invalid path " << libDir << " for IPA modules: " + << strerror(-ret); + return ret; + } + + unsigned int count = 0; + while ((ent = readdir(dir)) != nullptr) { + int offset = strlen(ent->d_name) - 3; + if (offset < 0) + continue; + if (strcmp(&ent->d_name[offset], ".so")) + continue; + + IPAModule *ipaModule = new IPAModule(std::string(libDir) + + "/" + ent->d_name); + if (!ipaModule->isValid()) { + delete ipaModule; + continue; + } + + modules_.push_back(ipaModule); + count++; + } + + closedir(dir); + return count; +} + +/** + * \brief Create an IPA interface that matches a given pipeline handler + * \param[in] pipe The pipeline handler that wants a matching IPA interface + * \param[in] minVersion Minimum acceptable version of IPA module + * \param[in] maxVersion Maximum acceptable version of IPA module + * + * \return A newly created IPA interface, or nullptr if no matching + * IPA module is found + */ +std::unique_ptr IPAManager::createIPA(PipelineHandler *pipe, + uint32_t maxVersion, + uint32_t minVersion) +{ + IPAModule *m = nullptr; + + for (IPAModule *module : modules_) { + if (module->match(pipe, minVersion, maxVersion)) { + m = module; + break; + } + } + + if (!m || !m->load()) + return nullptr; + + return m->createInstance(); +} + +} /* namespace libcamera */ diff --git a/src/libcamera/meson.build b/src/libcamera/meson.build index 32f7da4..0889b0d 100644 --- a/src/libcamera/meson.build +++ b/src/libcamera/meson.build @@ -11,6 +11,7 @@ libcamera_sources = files([ 'formats.cpp', 'geometry.cpp', 'ipa_interface.cpp', + 'ipa_manager.cpp', 'ipa_module.cpp', 'log.cpp', 'media_device.cpp', @@ -33,6 +34,7 @@ libcamera_headers = files([ 'include/device_enumerator_udev.h', 'include/event_dispatcher_poll.h', 'include/formats.h', + 'include/ipa_manager.h', 'include/ipa_module.h', 'include/log.h', 'include/media_device.h', diff --git a/src/meson.build b/src/meson.build index 4e41fd3..628e7a7 100644 --- a/src/meson.build +++ b/src/meson.build @@ -1,3 +1,4 @@ subdir('libcamera') +subdir('ipa') subdir('cam') subdir('qcam') diff --git a/test/libtest/test.cpp b/test/libtest/test.cpp index 9d537ea..b119cf1 100644 --- a/test/libtest/test.cpp +++ b/test/libtest/test.cpp @@ -5,6 +5,8 @@ * test.cpp - libcamera test base class */ +#include + #include "test.h" Test::Test() @@ -19,6 +21,10 @@ int Test::execute() { int ret; + ret = setenv("LIBCAMERA_IPA_MODULE_PATH", "src/ipa", 1); + if (ret) + return errno; + ret = init(); if (ret) return ret; From patchwork Wed Jun 5 00:53: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: 1356 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id B28D864730 for ; Wed, 5 Jun 2019 02:53:33 +0200 (CEST) Received: from localhost.localdomain (unknown [96.44.9.117]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id EF314321; Wed, 5 Jun 2019 02:53:32 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1559696013; bh=41C6r/N4G+gjwFb2VC/0pi7nHn96f6VJNjYj9cR/5xU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=A/OA+W66KZ89bUvW5L3kzaBdw5aSKR1QAw4ygA+YVK+vu857LqUZAEPLuIcVOb3jQ uHtWyV/BsR8NB/hd+Ew6DNvAILZ/7YuWk+DTpYPe65lPfeZfOfAdnOYQ8gcIyMTD/D QF4DrENXfTMLcRNihIpcr1m4vvhX7VnnzTdQwHQg= From: Paul Elder To: libcamera-devel@lists.libcamera.org Date: Tue, 4 Jun 2019 20:53:14 -0400 Message-Id: <20190605005316.4835-9-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190605005316.4835-1-paul.elder@ideasonboard.com> References: <20190605005316.4835-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 08/10] libcamera: ipa: add dummy IPA implementation 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 00:53:34 -0000 Add a dummy IPA module. Signed-off-by: Paul Elder Reviewed-by: Laurent Pinchart --- Changes in v3: - make meson a bit more DRY Changes in v2: - use macros for defining the version fields in ipaModuleInfo src/ipa/ipa_dummy.cpp | 45 +++++++++++++++++++++++++++++++++++++++++++ src/ipa/meson.build | 15 ++++++++++++++- 2 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 src/ipa/ipa_dummy.cpp diff --git a/src/ipa/ipa_dummy.cpp b/src/ipa/ipa_dummy.cpp new file mode 100644 index 0000000..ee7a3a8 --- /dev/null +++ b/src/ipa/ipa_dummy.cpp @@ -0,0 +1,45 @@ +/* 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 IPADummy : public IPAInterface +{ +public: + int init(); +}; + +int IPADummy::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", +}; + +IPAInterface *ipaCreate() +{ + return new IPADummy(); +} +}; + +}; /* namespace libcamera */ diff --git a/src/ipa/meson.build b/src/ipa/meson.build index be4f954..3c33a37 100644 --- a/src/ipa/meson.build +++ b/src/ipa/meson.build @@ -1,2 +1,15 @@ +ipa_dummy_sources = files([ + 'ipa_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) + config_h.set('IPA_MODULE_DIR', - '"' + join_paths(get_option('prefix'), get_option('libdir'), 'libcamera') + '"') + '"' + join_paths(get_option('prefix'), ipa_install_dir) + '"') From patchwork Wed Jun 5 00:53: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: 1357 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 997AC64720 for ; Wed, 5 Jun 2019 02:53:34 +0200 (CEST) Received: from localhost.localdomain (unknown [96.44.9.117]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id BDFEA2D1; Wed, 5 Jun 2019 02:53:33 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1559696014; bh=t2wkwpSghKHJ8pPXWQvy3esnWgO0patx4uwB6AJY3Ms=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UWUlYnVj3J6segd38cb8Kln0tnu65y2EbaBbXocp8GwiC0ckebXeDq/cEQomXzrab ZPOe3SjaOkj3iSvGioqxnLnMzL9Fg4eUGzlP0fzOOus2g0498fwdU6HzyKJrYC51jH M83a6SZbIrJjNz4S2ZXkjGE05TjDj6zY/mgX/JTg= From: Paul Elder To: libcamera-devel@lists.libcamera.org Date: Tue, 4 Jun 2019 20:53:15 -0400 Message-Id: <20190605005316.4835-10-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190605005316.4835-1-paul.elder@ideasonboard.com> References: <20190605005316.4835-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 09/10] libcamera: test: remove test IPA and use dummy IPA instead 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 00:53:34 -0000 Use the dummy IPA for testing/sample IPA instead of the earlier test IPA. Remove the test IPA, and update tests and meson accordingly. Signed-off-by: Paul Elder Reviewed-by: Laurent Pinchart --- Changes in v3: - delete the unused test IPA shared object source Changes in v2: - use macros for defining the fields in the expected IPA module info test/ipa/ipa_test.cpp | 8 ++++---- test/ipa/meson.build | 10 ---------- test/ipa/shared_test.cpp | 14 -------------- 3 files changed, 4 insertions(+), 28 deletions(-) delete mode 100644 test/ipa/shared_test.cpp diff --git a/test/ipa/ipa_test.cpp b/test/ipa/ipa_test.cpp index 63e4243..bbef069 100644 --- a/test/ipa/ipa_test.cpp +++ b/test/ipa/ipa_test.cpp @@ -56,12 +56,12 @@ protected: const struct IPAModuleInfo testInfo = { IPA_MODULE_API_VERSION, - 9001, - "bleep", - "It's over nine thousand!", + 0, + "PipelineHandlerVimc", + "Dummy IPA for Vimc", }; - count += runTest("test/ipa/ipa-dummy-cpp.so", testInfo); + count += runTest("src/ipa/ipa_dummy.so", testInfo); if (count < 0) return TestFail; diff --git a/test/ipa/meson.build b/test/ipa/meson.build index 08ee95c..bca39fa 100644 --- a/test/ipa/meson.build +++ b/test/ipa/meson.build @@ -1,13 +1,3 @@ -ipa_modules_sources = [ - ['ipa-dummy-cpp', 'shared_test.cpp'], -] - -foreach m : ipa_modules_sources - shared_library(m, name_prefix : '', - dependencies : libcamera_dep, - include_directories : test_includes_public) -endforeach - ipa_test = [ ['ipa_test', 'ipa_test.cpp'], ] diff --git a/test/ipa/shared_test.cpp b/test/ipa/shared_test.cpp deleted file mode 100644 index 8bac439..0000000 --- a/test/ipa/shared_test.cpp +++ /dev/null @@ -1,14 +0,0 @@ -#include - -namespace libcamera { - -extern "C" { -const struct libcamera::IPAModuleInfo ipaModuleInfo = { - IPA_MODULE_API_VERSION, - 9001, - "bleep", - "It's over nine thousand!", -}; -}; - -}; /* namespace libcamera */ From patchwork Wed Jun 5 00:53: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: 1358 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 327E964720 for ; Wed, 5 Jun 2019 02:53:35 +0200 (CEST) Received: from localhost.localdomain (unknown [96.44.9.117]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 8CB1C9BC; Wed, 5 Jun 2019 02:53:34 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1559696015; bh=gK0u0l3VetDjQuopNDzrP+AtpRMLmuagyrlF/GCxfA4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=V8XHYSlD7WoaQbUYElpDlijm2w4qLT5hpbkanNrcYxmd3RMZz4z0WugYM0yDZypGQ jgRQjDzu4uJZi4UtlRiFbx/BJFNzcojZXHlOfpcxbtthseUcsHSgFORd14QJQH2J6c gil8NAe++n/17dzxseGTd+H+Q6/4cMns9ktSCrEc= From: Paul Elder To: libcamera-devel@lists.libcamera.org Date: Tue, 4 Jun 2019 20:53:16 -0400 Message-Id: <20190605005316.4835-11-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190605005316.4835-1-paul.elder@ideasonboard.com> References: <20190605005316.4835-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 10/10] libcamera: pipeline: vimc: add dummy IPA 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 00:53:35 -0000 Make the vimc pipeline handler get the dummy IPA, to show how an IPA can be acquired by a pipeline handler. Signed-off-by: Paul Elder Reviewed-by: Laurent Pinchart --- Changes in v3: - save IPA to VIMC pipeline data - no IPA is non-fatal warning Changes in v2: - save IPA to pipeline data - no IPA is fatal error src/libcamera/pipeline/vimc.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/libcamera/pipeline/vimc.cpp b/src/libcamera/pipeline/vimc.cpp index 0e4eede..ad4577a 100644 --- a/src/libcamera/pipeline/vimc.cpp +++ b/src/libcamera/pipeline/vimc.cpp @@ -9,10 +9,13 @@ #include #include +#include +#include #include #include #include "device_enumerator.h" +#include "ipa_manager.h" #include "log.h" #include "media_device.h" #include "pipeline_handler.h" @@ -77,6 +80,8 @@ private: return static_cast( PipelineHandler::cameraData(camera)); } + + std::unique_ptr ipa_; }; VimcCameraConfiguration::VimcCameraConfiguration() @@ -248,6 +253,12 @@ bool PipelineHandlerVimc::match(DeviceEnumerator *enumerator) if (!media) return false; + ipa_ = IPAManager::instance()->createIPA(this, 0, 0); + if (ipa_ == nullptr) + LOG(VIMC, Warning) << "no matching IPA found"; + else + ipa_->init(); + std::unique_ptr data = utils::make_unique(this); /* Locate and open the capture video node. */