From patchwork Thu May 23 16:42:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 1277 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 E0DA160E9A for ; Thu, 23 May 2019 18:42:24 +0200 (CEST) Received: from localhost.localdomain (unknown [96.44.9.117]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 3B7575A9; Thu, 23 May 2019 18:42:24 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1558629744; bh=tZVdugPfCLgYTJZz8CDhpV+BH1Fq5lIgcxRqgB5iNuk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=L06JEYi2ISrRET39YasxB1teWMs/4SsSPn/V8sWnp0Q40gkFW3i+2EfNTOIzPqfV3 Y8v3MUIwXkOIxATEBLyn2OWNsovS0fiYbgoJCgc6A/Or0DCgYB12LEFcgPhqLFV71O FDiKWH6H6kEw74jLaZs5pN0CnCizt3CqVUmpjerE= From: Paul Elder To: libcamera-devel@lists.libcamera.org Date: Thu, 23 May 2019 12:42:06 -0400 Message-Id: <20190523164210.2105-2-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190523164210.2105-1-paul.elder@ideasonboard.com> References: <20190523164210.2105-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [RFC PATCH v2 1/5] 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: Thu, 23 May 2019 16:42:25 -0000 We need a way to match pipelines with IPA modules, so add fields in IPAModuleInfo to hold the IPA API version number and the pipeline matching string. Also update IPA module tests and Doxygen accordingly. Signed-off-by: Paul Elder --- Changes in v2: - make Doxygen stop complaining about undocumented __attribute__((packed)) Documentation/Doxyfile.in | 7 +++-- include/libcamera/ipa/ipa_module_info.h | 8 ++++-- test/ipa/ipa_test.cpp | 37 +++++++++++++++++-------- test/ipa/shared_test.c | 4 ++- test/ipa/shared_test.cpp | 6 ++-- 5 files changed, 43 insertions(+), 19 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..f3ae97d 100644 --- a/include/libcamera/ipa/ipa_module_info.h +++ b/include/libcamera/ipa/ipa_module_info.h @@ -7,14 +7,18 @@ #ifndef __LIBCAMERA_IPA_MODULE_INFO_H__ #define __LIBCAMERA_IPA_MODULE_INFO_H__ +#include + #ifdef __cplusplus namespace libcamera { #endif struct IPAModuleInfo { + uint32_t ipaAPIVersion; + uint32_t pipelineVersion; + char pipelineName[256]; char name[256]; - unsigned int version; -}; +} __attribute__((packed)); #ifdef __cplusplus extern "C" { diff --git a/test/ipa/ipa_test.cpp b/test/ipa/ipa_test.cpp index 9861ee2..ca15fbd 100644 --- a/test/ipa/ipa_test.cpp +++ b/test/ipa/ipa_test.cpp @@ -33,6 +33,19 @@ protected: const struct IPAModuleInfo &info = ll->info(); + if (info.ipaAPIVersion != testInfo.ipaAPIVersion) { + cerr << "test IPA module has incorrect ipaAPIVersion" << endl; + cerr << "expected \"" << testInfo.ipaAPIVersion << "\", got \"" + << info.ipaAPIVersion << "\"" << endl; + ret = -1; + } + if (info.pipelineVersion != testInfo.pipelineVersion) { + cerr << "test IPA module has incorrect pipelineVersion" << endl; + cerr << "expected \"" << testInfo.pipelineVersion << "\", got \"" + << info.pipelineVersion << "\"" << endl; + ret = -1; + } + if (strcmp(info.name, testInfo.name)) { cerr << "test IPA module has incorrect name" << endl; cerr << "expected \"" << testInfo.name << "\", got \"" @@ -40,13 +53,6 @@ protected: 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; - } - delete ll; return ret; } @@ -55,14 +61,23 @@ protected: { int count = 0; - const struct IPAModuleInfo testInfo = { - "It's over nine thousand!", + const struct IPAModuleInfo testInfo1 = { + 1, 9001, + "bloop", + "It's over nine thousand!", + }; + + const struct IPAModuleInfo testInfo2 = { + 1, + 8999, + "bleep", + "It's under nine thousand!", }; - count += runTest("test/ipa/ipa-dummy-c.so", testInfo); + count += runTest("test/ipa/ipa-dummy-c.so", testInfo1); - count += runTest("test/ipa/ipa-dummy-cpp.so", testInfo); + count += runTest("test/ipa/ipa-dummy-cpp.so", testInfo2); if (count < 0) return TestFail; diff --git a/test/ipa/shared_test.c b/test/ipa/shared_test.c index 87d182b..0046ace 100644 --- a/test/ipa/shared_test.c +++ b/test/ipa/shared_test.c @@ -1,6 +1,8 @@ #include const struct IPAModuleInfo ipaModuleInfo = { + .ipaAPIVersion = 1, + .pipelineVersion = 9001, + .pipelineName = "bloop", .name = "It's over nine thousand!", - .version = 9001, }; diff --git a/test/ipa/shared_test.cpp b/test/ipa/shared_test.cpp index 4e5c976..78405b1 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!", - 9001, + 1, + 8999, + "bleep", + "It's under nine thousand!", }; }; From patchwork Thu May 23 16:42: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: 1278 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 9C207618CD for ; Thu, 23 May 2019 18:42:25 +0200 (CEST) Received: from localhost.localdomain (unknown [96.44.9.117]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id E638D334; Thu, 23 May 2019 18:42:24 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1558629745; bh=8eP52V31XgW1dzUtthrgIyG4Di7EublzgjColo/Txwc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Q8BTNfP1Qo2Hd4mvLboVlvz02KSTJ3UqEv84TwNlFU6zL+m+zqK+pxVa8JgKq4E3W dv+SHqXWDcvCUsZBlWH2BcuXjoSkoTQqIy5DCwrhDl14aka7uxygsTr1eHEhk+IS5J Gp47eHpZAvboiBqMlfl4QO8X0sIptoqNFx7ndcUs= From: Paul Elder To: libcamera-devel@lists.libcamera.org Date: Thu, 23 May 2019 12:42:07 -0400 Message-Id: <20190523164210.2105-3-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190523164210.2105-1-paul.elder@ideasonboard.com> References: <20190523164210.2105-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [RFC PATCH v2 2/5] libcamera: ipa_module: add aquired attribute 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: Thu, 23 May 2019 16:42:26 -0000 The IPAManager will be designed like an enumerator, and IPA modules cannot be used by multiple pipelines at once. Add an aquired attribute to IPAModule, and corresponding getter and setters. Signed-off-by: Paul Elder --- Changes in v2: - renamed acquired() to isAcquired(), to match isValid() - added documentation src/libcamera/include/ipa_module.h | 5 +++ src/libcamera/ipa_module.cpp | 62 ++++++++++++++++++++++++++---- 2 files changed, 60 insertions(+), 7 deletions(-) diff --git a/src/libcamera/include/ipa_module.h b/src/libcamera/include/ipa_module.h index a4c6dbd..58faeca 100644 --- a/src/libcamera/include/ipa_module.h +++ b/src/libcamera/include/ipa_module.h @@ -22,11 +22,16 @@ public: const struct IPAModuleInfo &info() const; + bool isAcquired() const; + bool acquire(); + void release(); + private: struct IPAModuleInfo info_; std::string libPath_; bool valid_; + bool acquired_; int loadIPAModuleInfo(); }; diff --git a/src/libcamera/ipa_module.cpp b/src/libcamera/ipa_module.cpp index 86cbe71..4922e3e 100644 --- a/src/libcamera/ipa_module.cpp +++ b/src/libcamera/ipa_module.cpp @@ -176,14 +176,17 @@ 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::ipaAPIVersion + * \brief The IPA API version that the IPA module was made with * - * \var IPAModuleInfo::version - * \brief The version of the IPA module + * \var IPAModuleInfo::pipelineVersion + * \brief The pipeline version that the IPA module is for * - * \todo abi compatability version - * \todo pipeline compatability matcher + * \var IPAModuleInfo::pipelineName + * \brief The name of the pipeline that the IPA module is for + * + * \var IPAModuleInfo::name + * \brief The name of the IPA module */ /** @@ -212,7 +215,7 @@ int elfLoadSymbol(void *dst, size_t size, void *map, size_t soSize, * IPAModule instance to verify the validity of the IPAModule. */ IPAModule::IPAModule(const std::string &libPath) - : libPath_(libPath), valid_(false) + : libPath_(libPath), valid_(false), acquired_(false) { if (loadIPAModuleInfo() < 0) return; @@ -289,4 +292,49 @@ const struct IPAModuleInfo &IPAModule::info() const return info_; } +/** + * \brief Check if IPA module is in use + * + * \return true if the IPA module has been claimed for exclusive use, or + * false if it is available + * \sa acquire(), release() + */ +bool IPAModule::isAcquired() const +{ + return acquired_; +} + +/** + * \brief Claim an IPA module for exclusive use + * + * Each IPA module is meant to be used by only one pipeline handler. + * IPA modules will be acquired through the IPAManager, which will + * use this method to claim an IPA module before returning it, and will + * skip over already claimed IPA modules. + * + * When the IPA module is not needed anymore, the release() method should + * be called. + * + * \return true if the IPA module was successfully claimed, or false if + * was already claimed + * \sa isAcquired(), release() + */ +bool IPAModule::acquire() +{ + if (acquired_) + return false; + + acquired_ = true; + return true; +} + +/** + * \brief Release an IPA module previously claimed for exclusive use + * \sa acquire(), isAcquired() + */ +void IPAModule::release() +{ + acquired_ = false; +} + } /* namespace libcamera */ From patchwork Thu May 23 16:42: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: 1279 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 64E8F61865 for ; Thu, 23 May 2019 18:42:26 +0200 (CEST) Received: from localhost.localdomain (unknown [96.44.9.117]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id B42355A9; Thu, 23 May 2019 18:42:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1558629746; bh=Qd7YX0RbMCUS16XBJVooMOxEgPKyJXALh4GFJ8PrCjI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EjhgCncKLCcfPuU55mihfUcNK4qJGvQRiYeBVBOE+cbgaet1NtULrH7X+hSdrRg3C D38fTj/TpIh2g2h2t/2CZzQORwN/Wulf92e2qZ+RompXKY4EB2eyrSEy2PfJDIdqHO ys4LWD5icqK6q8qqT8uxBxBpIOWcmfXLTmycaFEM= From: Paul Elder To: libcamera-devel@lists.libcamera.org Date: Thu, 23 May 2019 12:42:08 -0400 Message-Id: <20190523164210.2105-4-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190523164210.2105-1-paul.elder@ideasonboard.com> References: <20190523164210.2105-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [RFC PATCH v2 3/5] 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: Thu, 23 May 2019 16:42:26 -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 pipelines to aquire an IPA. Signed-off-by: Paul Elder --- Changes in v2: - made IPAManager into a real singleton (as opposed to my misunderstood version) - return non-const IPAModule from IPAManager::acquireIPA() - made return value of addDir return the total number of modules loaded - that way the caller can know if any modules were loaded at all (since zero modules loaded doesn't really constitute as an error) src/libcamera/include/ipa_manager.h | 39 +++++++++ src/libcamera/ipa_manager.cpp | 122 ++++++++++++++++++++++++++++ src/libcamera/meson.build | 2 + 3 files changed, 163 insertions(+) create mode 100644 src/libcamera/include/ipa_manager.h create mode 100644 src/libcamera/ipa_manager.cpp diff --git a/src/libcamera/include/ipa_manager.h b/src/libcamera/include/ipa_manager.h new file mode 100644 index 0000000..333fec0 --- /dev/null +++ b/src/libcamera/include/ipa_manager.h @@ -0,0 +1,39 @@ +/* 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(); + + int addDir(const std::string &libDir); + + IPAModule *acquireIPA(const struct IPAModuleInfo &info) const; + +private: + std::list modules_; + + IPAManager(); + ~IPAManager(); + + bool match(const IPAModule *ipa, const struct IPAModuleInfo &info) const; +}; + +} /* 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..3d65786 --- /dev/null +++ b/src/libcamera/ipa_manager.cpp @@ -0,0 +1,122 @@ +/* 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 "ipa_module.h" +#include "pipeline_handler.h" +#include "utils.h" + +#include +#include +#include + +#include "log.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() +{ +} + +IPAManager::~IPAManager() +{ +} + +/** + * \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 + * + * Goes through \a libDir and tries to create an IPAModule instance for every + * found shared object. Skips invalid IPA modules. + * + * \return total number of modules loaded (including modules loaded in + * previous calls of this function), or negative error code + */ +int IPAManager::addDir(const std::string &libDir) +{ + struct dirent *ent; + DIR *dir; + + dir = opendir(libDir.c_str()); + if (!dir) { + int ret = -errno; + LOG(IPAManager, Error) << "Invalid path for IPA modules: " + << strerror(ret); + return ret; + } + + while ((ent = readdir(dir)) != nullptr) { + int offset = strlen(ent->d_name) - 3; + if (strncmp(&ent->d_name[offset], ".so", 3)) + continue; + + IPAModule *ipaModule = new IPAModule(libDir + "/" + ent->d_name); + if (ipaModule->isValid()) + modules_.push_back(ipaModule); + } + + closedir(dir); + return modules_.size(); +} + +/** + * \brief Retrieve an IPA module that matches a desired IPA module info + * + * \return IPA module + */ +IPAModule *IPAManager::acquireIPA(const struct IPAModuleInfo &info) const +{ + IPAModule *m = nullptr; + + for (IPAModule *module : modules_) { + if (module->isAcquired()) + continue; + + if (match(module, info) && module->acquire()) { + m = module; + break; + } + } + + return m; +} + +bool IPAManager::match(const IPAModule *ipa, const struct IPAModuleInfo &info) const +{ + return ipa->info().ipaAPIVersion == info.ipaAPIVersion && + ipa->info().pipelineVersion >= info.pipelineVersion && + !strcmp(ipa->info().pipelineName, info.pipelineName); +} + +} /* namespace libcamera */ diff --git a/src/libcamera/meson.build b/src/libcamera/meson.build index e5b48f2..ee1b658 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_manager.cpp', 'ipa_module.cpp', 'log.cpp', 'media_device.cpp', @@ -32,6 +33,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', From patchwork Thu May 23 16:42: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: 1280 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 5602F6187B for ; Thu, 23 May 2019 18:42:27 +0200 (CEST) Received: from localhost.localdomain (unknown [96.44.9.117]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 7F6A95A9; Thu, 23 May 2019 18:42:26 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1558629746; bh=ZA39u2vMJRmJyNJ/+WvXrdvTuH98X/EM9slz4nuJxAk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=no9M43pkpLFb9fOxaG/4aXxL+75nNKFX/vE9TzYCL40mNZClgIZnzRMw1tSNLoTGR GKaVJutQK1/EMq4XdDPxEnWd7WiYvVu7GR2F4S4uvkmkvJ7vXvXEREh8GU4HzYW4p/ o0ppkMWPnON2bvlZRyCQnTLNHNbrx25l5U9tKVZ8= From: Paul Elder To: libcamera-devel@lists.libcamera.org Date: Thu, 23 May 2019 12:42:09 -0400 Message-Id: <20190523164210.2105-5-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190523164210.2105-1-paul.elder@ideasonboard.com> References: <20190523164210.2105-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [RFC PATCH v2 4/5] test: ipa_manager: add test for IPAManager 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: Thu, 23 May 2019 16:42:27 -0000 Add simple test to test IPA module acquiring through IPAManager. Signed-off-by: Paul Elder --- Changes in v2: - release the IPA module after the test - also use the new IPAManager singleton instead of instantiation test/ipa/ipa_manager_test.cpp | 45 +++++++++++++++++++++++++++++++++++ test/ipa/meson.build | 3 ++- 2 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 test/ipa/ipa_manager_test.cpp diff --git a/test/ipa/ipa_manager_test.cpp b/test/ipa/ipa_manager_test.cpp new file mode 100644 index 0000000..af2e87f --- /dev/null +++ b/test/ipa/ipa_manager_test.cpp @@ -0,0 +1,45 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * Copyright (C) 2019, Google Inc. + * + * load-so.cpp - loading .so tests + */ + +#include +#include + +#include "ipa_module.h" +#include "ipa_manager.h" + +#include "test.h" + +using namespace std; +using namespace libcamera; + +class IPAManagerTest : public Test +{ +protected: + int run() override + { + IPAManager *ipam = IPAManager::instance(); + + ipam->addDir("test/ipa"); + + struct IPAModuleInfo info; + info.ipaAPIVersion = 1; + info.pipelineVersion = 8999; + strcpy(info.pipelineName, "bleep"); + IPAModule *ipa = ipam->acquireIPA(info); + + if (!ipa || strcmp(ipa->info().name, "It's under nine thousand!")) { + cerr << "failed to acquire IPA" << endl; + return TestFail; + } + + ipa->release(); + + return TestPass; + } +}; + +TEST_REGISTER(IPAManagerTest) diff --git a/test/ipa/meson.build b/test/ipa/meson.build index 6df0671..a489ed4 100644 --- a/test/ipa/meson.build +++ b/test/ipa/meson.build @@ -9,7 +9,8 @@ foreach m : ipa_modules_sources endforeach ipa_test = [ - ['ipa_test', 'ipa_test.cpp'], + ['ipa_test', 'ipa_test.cpp'], + ['ipa_manager_test', 'ipa_manager_test.cpp'], ] foreach t : ipa_test From patchwork Thu May 23 16:42: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: 1281 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 21DBA618DC for ; Thu, 23 May 2019 18:42:28 +0200 (CEST) Received: from localhost.localdomain (unknown [96.44.9.117]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 5BB66B7C; Thu, 23 May 2019 18:42:27 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1558629747; bh=M1kfpUtCh75E1PdZNKsWvaC6MhKxCknC/QpWO1NRT+k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SvWRYPf/2GedpaqZ0AfN5VRt/f3dLivaaAZae14kY9euyQcyEtbCHlneOgY9XSbpF Is7Oj8j34WbIl6C7zhdGsyDsDHaJnJjNArjIum9mwrI+MK+2w7ISkMIhF6nDzpdQ+R xxlwakhBpKI+OPPMVzs1blP9YoXcDDBMQxN2hmeU= From: Paul Elder To: libcamera-devel@lists.libcamera.org Date: Thu, 23 May 2019 12:42:10 -0400 Message-Id: <20190523164210.2105-6-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190523164210.2105-1-paul.elder@ideasonboard.com> References: <20190523164210.2105-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [RFC PATCH v2 5/5] libcamera: pipelines: uvcvideo: add IPAManager 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: Thu, 23 May 2019 16:42:28 -0000 Make the UVC pipeline query for one of the test IPA modules. Signed-off-by: Paul Elder --- Changes in v2: - remove IPAManager from PipelineHandler::match parameter This is a sample of how a IPAManager would be used. src/libcamera/pipeline/uvcvideo.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/libcamera/pipeline/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo.cpp index 351712c..8275f5a 100644 --- a/src/libcamera/pipeline/uvcvideo.cpp +++ b/src/libcamera/pipeline/uvcvideo.cpp @@ -6,16 +6,20 @@ */ #include +#include #include #include #include "device_enumerator.h" +#include "ipa_manager.h" #include "log.h" #include "media_device.h" #include "pipeline_handler.h" #include "utils.h" #include "v4l2_device.h" +#include + namespace libcamera { LOG_DEFINE_CATEGORY(UVC) @@ -175,6 +179,16 @@ bool PipelineHandlerUVC::match(DeviceEnumerator *enumerator) if (!media) return false; + IPAManager *ipaManager = IPAManager::instance(); + ipaManager->addDir("test/ipa"); + struct IPAModuleInfo info; + info.ipaAPIVersion = 1; + info.pipelineVersion = 8999; + strcpy(info.pipelineName, "bleep"); + IPAModule *ipa = ipaManager->acquireIPA(info); + if (ipa == nullptr) + LOG(UVC, Warning) << "no matching IPA found"; + std::unique_ptr data = utils::make_unique(this); /* Locate and open the default video node. */ @@ -197,7 +211,7 @@ bool PipelineHandlerUVC::match(DeviceEnumerator *enumerator) /* Create and register the camera. */ std::set streams{ &data->stream_ }; - std::shared_ptr camera = Camera::create(this, media->model(), streams); + std::shared_ptr camera = Camera::create(this, media->model() + " " + (ipa == nullptr ? "" : ipa->info().name), streams); registerCamera(std::move(camera), std::move(data)); /* Enable hot-unplug notifications. */