From patchwork Thu Oct 3 15:20:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 2077 Return-Path: Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [217.70.183.198]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 7F46060BE9 for ; Thu, 3 Oct 2019 17:19:04 +0200 (CEST) X-Originating-IP: 2.224.242.101 Received: from uno.lan (2-224-242-101.ip172.fastwebnet.it [2.224.242.101]) (Authenticated sender: jacopo@jmondi.org) by relay6-d.mail.gandi.net (Postfix) with ESMTPSA id 1D38CC0004; Thu, 3 Oct 2019 15:19:03 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Thu, 3 Oct 2019 17:20:33 +0200 Message-Id: <20191003152037.74617-2-jacopo@jmondi.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191003152037.74617-1-jacopo@jmondi.org> References: <20191003152037.74617-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 1/5] ipa: vimc: Rename ipa_dummy to ipa_vimc X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 Oct 2019 15:19:04 -0000 The DummyIPA is actually a test IPA module for the virtual media controller driver VIMC. Rename it accordingly to its usage. Signed-off-by: Jacopo Mondi Reviewed-by: Laurent Pinchart Reviewed-by: Niklas Söderlund --- src/ipa/{ipa_dummy.cpp => ipa_vimc.cpp} | 10 +++++----- src/ipa/meson.build | 10 +++++----- test/ipa/ipa_test.cpp | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-) rename src/ipa/{ipa_dummy.cpp => ipa_vimc.cpp} (71%) diff --git a/src/ipa/ipa_dummy.cpp b/src/ipa/ipa_vimc.cpp similarity index 71% rename from src/ipa/ipa_dummy.cpp rename to src/ipa/ipa_vimc.cpp index 9d0cbdc8b1ad..abc06e7f5fd5 100644 --- a/src/ipa/ipa_dummy.cpp +++ b/src/ipa/ipa_vimc.cpp @@ -2,7 +2,7 @@ /* * Copyright (C) 2019, Google Inc. * - * ipa_dummy.cpp - Dummy Image Processing Algorithm module + * ipa_vimc.cpp - Vimc Image Processing Algorithm module */ #include @@ -12,15 +12,15 @@ namespace libcamera { -class IPADummy : public IPAInterface +class IPAVimc : public IPAInterface { public: int init(); }; -int IPADummy::init() +int IPAVimc::init() { - std::cout << "initializing dummy IPA!" << std::endl; + std::cout << "initializing vimc IPA!" << std::endl; return 0; } @@ -39,7 +39,7 @@ const struct IPAModuleInfo ipaModuleInfo = { IPAInterface *ipaCreate() { - return new IPADummy(); + return new IPAVimc(); } }; diff --git a/src/ipa/meson.build b/src/ipa/meson.build index f09915bc1388..b5bcd7b2c3db 100644 --- a/src/ipa/meson.build +++ b/src/ipa/meson.build @@ -1,12 +1,12 @@ -ipa_dummy_sources = [ - ['ipa_dummy', 'LGPL-2.1-or-later'], - ['ipa_dummy_isolate', 'Proprietary'], +ipa_vimc_sources = [ + ['ipa_vimc', 'LGPL-2.1-or-later'], + ['ipa_vimc_isolate', 'Proprietary'], ] ipa_install_dir = join_paths(get_option('libdir'), 'libcamera') -foreach t : ipa_dummy_sources - ipa = shared_module(t[0], 'ipa_dummy.cpp', +foreach t : ipa_vimc_sources + ipa = shared_module(t[0], 'ipa_vimc.cpp', name_prefix : '', include_directories : libcamera_includes, install : true, diff --git a/test/ipa/ipa_test.cpp b/test/ipa/ipa_test.cpp index b9e1bd61c299..8f9b2d8058ec 100644 --- a/test/ipa/ipa_test.cpp +++ b/test/ipa/ipa_test.cpp @@ -62,7 +62,7 @@ protected: "GPL-2.0-or-later", }; - count += runTest("src/ipa/ipa_dummy.so", testInfo); + count += runTest("src/ipa/ipa_vimc.so", testInfo); if (count < 0) return TestFail; From patchwork Thu Oct 3 15:20:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 2078 Return-Path: Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [217.70.183.198]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 15E7A60BE9 for ; Thu, 3 Oct 2019 17:19:05 +0200 (CEST) X-Originating-IP: 2.224.242.101 Received: from uno.lan (2-224-242-101.ip172.fastwebnet.it [2.224.242.101]) (Authenticated sender: jacopo@jmondi.org) by relay6-d.mail.gandi.net (Postfix) with ESMTPSA id A6C9FC0008; Thu, 3 Oct 2019 15:19:04 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Thu, 3 Oct 2019 17:20:34 +0200 Message-Id: <20191003152037.74617-3-jacopo@jmondi.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191003152037.74617-1-jacopo@jmondi.org> References: <20191003152037.74617-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 2/5] test: ipa: Rename the ipa_test to ipa_module_test X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 Oct 2019 15:19:05 -0000 Update the IPA test to match the test class name in prevision of adding more IPA tests. Also update the description comment in the test unit, as the old name for the test was still used. Signed-off-by: Jacopo Mondi Reviewed-by: Laurent Pinchart Reviewed-by: Niklas Söderlund --- test/ipa/{ipa_test.cpp => ipa_module_test.cpp} | 2 +- test/ipa/meson.build | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename test/ipa/{ipa_test.cpp => ipa_module_test.cpp} (95%) diff --git a/test/ipa/ipa_test.cpp b/test/ipa/ipa_module_test.cpp similarity index 95% rename from test/ipa/ipa_test.cpp rename to test/ipa/ipa_module_test.cpp index 8f9b2d8058ec..3a634099a550 100644 --- a/test/ipa/ipa_test.cpp +++ b/test/ipa/ipa_module_test.cpp @@ -2,7 +2,7 @@ /* * Copyright (C) 2019, Google Inc. * - * load-so.cpp - loading .so tests + * ipa_module_test.cpp - Test loading of the VIMC IPA module and verify its info */ #include diff --git a/test/ipa/meson.build b/test/ipa/meson.build index 1749ab7d4338..e174671d05e1 100644 --- a/test/ipa/meson.build +++ b/test/ipa/meson.build @@ -1,5 +1,5 @@ ipa_test = [ - ['ipa_test', 'ipa_test.cpp'], + ['ipa_module_test', 'ipa_module_test.cpp'], ] foreach t : ipa_test From patchwork Thu Oct 3 15:20:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 2079 Return-Path: Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [217.70.183.198]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 9C27D60BE9 for ; Thu, 3 Oct 2019 17:19:05 +0200 (CEST) X-Originating-IP: 2.224.242.101 Received: from uno.lan (2-224-242-101.ip172.fastwebnet.it [2.224.242.101]) (Authenticated sender: jacopo@jmondi.org) by relay6-d.mail.gandi.net (Postfix) with ESMTPSA id 3C9EDC0008; Thu, 3 Oct 2019 15:19:05 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Thu, 3 Oct 2019 17:20:35 +0200 Message-Id: <20191003152037.74617-4-jacopo@jmondi.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191003152037.74617-1-jacopo@jmondi.org> References: <20191003152037.74617-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 3/5] ipa: ipa_manager: Print the loaded IPA modules path X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 Oct 2019 15:19:05 -0000 Add debug message to report which IPA modules have been loaded and in which order. The loading order is particularly relevant for the test VIMC IPA, as the same IPA is compiled with an open source license tag and a proprietary one and they both match() against the VIMC pipeline handler. Being informed about their loading order is helpful to understand which one of the two is actually in use. Signed-off-by: Jacopo Mondi Reviewed-by: Laurent Pinchart Reviewed-by: Niklas Söderlund --- src/libcamera/ipa_manager.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/libcamera/ipa_manager.cpp b/src/libcamera/ipa_manager.cpp index 708233e8a9c7..e990bdcdf84b 100644 --- a/src/libcamera/ipa_manager.cpp +++ b/src/libcamera/ipa_manager.cpp @@ -120,13 +120,16 @@ int IPAManager::addDir(const char *libDir) if (strcmp(&ent->d_name[offset], ".so")) continue; - IPAModule *ipaModule = new IPAModule(std::string(libDir) + - "/" + ent->d_name); + std::string modulePath = std::string(libDir) + "/" + + ent->d_name; + IPAModule *ipaModule = new IPAModule(modulePath); if (!ipaModule->isValid()) { delete ipaModule; continue; } + LOG(IPAManager, Debug) << "Loaded IPA module: " << modulePath; + modules_.push_back(ipaModule); count++; } From patchwork Thu Oct 3 15:20:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 2080 Return-Path: Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [217.70.183.198]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 3766760BE9 for ; Thu, 3 Oct 2019 17:19:06 +0200 (CEST) X-Originating-IP: 2.224.242.101 Received: from uno.lan (2-224-242-101.ip172.fastwebnet.it [2.224.242.101]) (Authenticated sender: jacopo@jmondi.org) by relay6-d.mail.gandi.net (Postfix) with ESMTPSA id C22CFC000B; Thu, 3 Oct 2019 15:19:05 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Thu, 3 Oct 2019 17:20:36 +0200 Message-Id: <20191003152037.74617-5-jacopo@jmondi.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191003152037.74617-1-jacopo@jmondi.org> References: <20191003152037.74617-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 4/5] test: ipa: Add test for the IPA Interface X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 Oct 2019 15:19:06 -0000 Implementing a basic test for IPA Interface using the VIMC dummy IPA module. The test implements a communication channel between the test and the dummy IPA module to verify the success of the IPA interactions. Test the only available operation defined by the IPA interface by receiving a confirmation code on the fifo communication channel. Signed-off-by: Jacopo Mondi --- test/ipa/ipa_interface_test.cpp | 147 ++++++++++++++++++++++++++++++++ test/ipa/meson.build | 3 +- 2 files changed, 149 insertions(+), 1 deletion(-) create mode 100644 test/ipa/ipa_interface_test.cpp diff --git a/test/ipa/ipa_interface_test.cpp b/test/ipa/ipa_interface_test.cpp new file mode 100644 index 000000000000..83eef7440fa4 --- /dev/null +++ b/test/ipa/ipa_interface_test.cpp @@ -0,0 +1,147 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * Copyright (C) 2019, Google Inc. + * + * ipa_interface_test.cpp - Test the IPA interface communication using the VIMC + * dummy IPA module + */ + +#include + +#include +#include +#include +#include +#include + +#include +#include +#include + +#include "ipa_module.h" + +#include "test.h" +#include "thread.h" + +using namespace std; +using namespace libcamera; + +/* Keep with in sync with the VIMC IPA module. */ +static const char *ipaFifoPath = "/tmp/vimc_ipa_fifo"; +#define IPA_INIT_CODE 0x01 + +static const char *vimcModulePath = "src/ipa/ipa_vimc.so"; + +class IPAInterfaceTest : public Test, public Object +{ +public: + IPAInterfaceTest() + : fd_(0), data_(0) + { + } + + ~IPAInterfaceTest() + { + /* + * Delete the IPA Interface instance -before- deleting the + * module used to create it, as the IPAModule destructor closes + * the IPA shared object, resulting in segfault at interface + * deletion time. + */ + IPAInterface *ipa = ipa_.release(); + delete ipa; + + if (ipaModule_) + delete ipaModule_; + + delete notifier_; + } + +protected: + int init() override + { + int ret = mkfifo(ipaFifoPath, S_IRUSR | S_IWUSR); + if (ret) { + cerr << "Failed to create IPA test fifo at: " + << ipaFifoPath << ": " << strerror(errno) << endl; + return TestFail; + } + + ret = open(ipaFifoPath, O_RDONLY | O_NONBLOCK); + if (ret < 0) { + cerr << "Failed to open IPA test fifo at: " + << ipaFifoPath << ": " << strerror(errno) << endl; + unlink(ipaFifoPath); + return TestFail; + } + fd_ = ret; + + notifier_ = new EventNotifier(fd_, EventNotifier::Read, this); + notifier_->activated.connect(this, &IPAInterfaceTest::readFifo); + + return TestPass; + } + + int run() override + { + EventDispatcher *dispatcher = thread()->eventDispatcher(); + Timer timer; + + ipaModule_ = new IPAModule(vimcModulePath); + if (!ipaModule_ || !ipaModule_->isValid()) { + cerr << "Failed to create VIMC IPA module at: " + << vimcModulePath << endl; + return TestFail; + } + + if (!ipaModule_->load()) { + cerr << "Failed to load VIMC IPA module" << endl; + return TestFail; + } + + ipa_ = ipaModule_->createInstance(); + if (!ipa_) { + cerr << "Failed to create VIMC IPA interface" << endl; + return TestFail; + } + + /* Test initialization of IPA module. */ + ipa_->init(); + timer.start(1000); + while (timer.isRunning() && data_ != IPA_INIT_CODE) + dispatcher->processEvents(); + + if (data_ != IPA_INIT_CODE) { + cerr << "Failed to test IPA initialization sequence" + << endl; + return TestFail; + } + + return TestPass; + } + + void cleanup() override + { + close(fd_); + unlink(ipaFifoPath); + } + +private: + void readFifo(EventNotifier *notifier) + { + size_t s = read(notifier->fd(), &data_, 1); + if (s < 0) { + cerr << "Failed to to read from IPA test fifo at: " + << ipaFifoPath << strerror(errno) << endl; + data_ = -1; + } + } + + std::unique_ptr ipa_; + EventNotifier *notifier_; + IPAModule *ipaModule_; + unsigned int fd_; + int8_t data_; +}; + +TEST_REGISTER(IPAInterfaceTest) diff --git a/test/ipa/meson.build b/test/ipa/meson.build index e174671d05e1..c501fcf99aed 100644 --- a/test/ipa/meson.build +++ b/test/ipa/meson.build @@ -1,5 +1,6 @@ ipa_test = [ - ['ipa_module_test', 'ipa_module_test.cpp'], + ['ipa_module_test', 'ipa_module_test.cpp'], + ['ipa_interface_test', 'ipa_interface_test.cpp'], ] foreach t : ipa_test From patchwork Thu Oct 3 15:20:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 2081 Return-Path: Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [217.70.183.198]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id C197561915 for ; Thu, 3 Oct 2019 17:19:06 +0200 (CEST) X-Originating-IP: 2.224.242.101 Received: from uno.lan (2-224-242-101.ip172.fastwebnet.it [2.224.242.101]) (Authenticated sender: jacopo@jmondi.org) by relay6-d.mail.gandi.net (Postfix) with ESMTPSA id 5C52AC0004; Thu, 3 Oct 2019 15:19:06 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Thu, 3 Oct 2019 17:20:37 +0200 Message-Id: <20191003152037.74617-6-jacopo@jmondi.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191003152037.74617-1-jacopo@jmondi.org> References: <20191003152037.74617-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 5/5] ipa: vimc: Add support for test back channel X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 Oct 2019 15:19:07 -0000 Add support to the dummy VIMC IPA for communication with the IPA interface test unit. Use the test channel, if available, to send a confirmation code when the init() operation is called. Signed-off-by: Jacopo Mondi --- src/ipa/ipa_vimc.cpp | 54 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/src/ipa/ipa_vimc.cpp b/src/ipa/ipa_vimc.cpp index abc06e7f5fd5..781f5796b082 100644 --- a/src/ipa/ipa_vimc.cpp +++ b/src/ipa/ipa_vimc.cpp @@ -7,20 +7,74 @@ #include +#include +#include +#include +#include + #include #include namespace libcamera { +/* Keep these in sync with the IPA Interface test unit. */ +static const char *vimcFifoPath = "/tmp/vimc_ipa_fifo"; +#define IPA_INIT_CODE 0x01 + class IPAVimc : public IPAInterface { public: + IPAVimc(); + ~IPAVimc(); + int init(); + +private: + unsigned int fd_; }; +IPAVimc::IPAVimc() + : fd_(0) +{ + /* Set up the test unit back-channel, if available. */ + struct stat fifoStat; + int ret = stat(vimcFifoPath, &fifoStat); + if (ret) + return; + + ret = ::open(vimcFifoPath, O_WRONLY); + if (ret < 0) { + std::cerr << "Failed to open vimc IPA test fifo at: " + << vimcFifoPath << ": " << strerror(errno) + << std::endl; + return; + } + fd_ = ret; +} + +IPAVimc::~IPAVimc() +{ + if (fd_) + ::close(fd_); +} + int IPAVimc::init() { std::cout << "initializing vimc IPA!" << std::endl; + + if (!fd_) + return 0; + + int8_t data = IPA_INIT_CODE; + int ret = ::write(fd_, &data, 1); + if (ret < 0) { + ret = -errno; + std::cerr << "Failed to write to vimc IPA test fifo at: " + << vimcFifoPath << ": " << strerror(-ret) + << std::endl; + return ret; + } + return 0; }