From patchwork Mon Apr 27 03:17:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 3553 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 5B23960AF0 for ; Mon, 27 Apr 2020 05:17:33 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="Gp2XEtbO"; dkim-atps=neutral Received: from pendragon.bb.dnainternet.fi (81-175-216-236.bb.dnainternet.fi [81.175.216.236]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id DCF7C97D for ; Mon, 27 Apr 2020 05:17:32 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1587957453; bh=4K3q3LxITDScf4fk6mopnuQ3dB5mLsL2heWudNvKlRk=; h=From:To:Subject:Date:In-Reply-To:References:From; b=Gp2XEtbOZ3f3RjnupkZYXS3RAm6gp3X4I1cVzIDT+XG62f5lSvhqSP3tLgDPLN5kp Q1sluq2tS22iO/6zhpvgTvxWfSxb9bwRSWvkk/nAYF4OH3T/BGMDb6WTBNib4n5Zxz 0vFH3Xc7KCUMZ8H3ovU04oPdEUkZlEuo0jBBDjWQ= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Mon, 27 Apr 2020 06:17:03 +0300 Message-Id: <20200427031713.14013-2-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.25.3 In-Reply-To: <20200427031713.14013-1-laurent.pinchart@ideasonboard.com> References: <20200427031713.14013-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 01/11] ipa: Name IPA modules after their source directory 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: Mon, 27 Apr 2020 03:17:33 -0000 The IPAModuleInfo::name field is currently a free-formed string that has little use. Tighten its usage rules to make it suitable for building file system paths to IPA-specific resources by matching the directory name of the IPA module. Signed-off-by: Laurent Pinchart Reviewed-by: Kieran Bingham --- src/ipa/rkisp1/rkisp1.cpp | 2 +- src/ipa/vimc/vimc.cpp | 2 +- src/libcamera/ipa_module.cpp | 20 ++++++++++++++++++++ test/ipa/ipa_module_test.cpp | 2 +- 4 files changed, 23 insertions(+), 3 deletions(-) diff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp index acbbe58c7a2e..7f0ffb0a791f 100644 --- a/src/ipa/rkisp1/rkisp1.cpp +++ b/src/ipa/rkisp1/rkisp1.cpp @@ -274,7 +274,7 @@ const struct IPAModuleInfo ipaModuleInfo = { IPA_MODULE_API_VERSION, 1, "PipelineHandlerRkISP1", - "RkISP1 IPA", + "rkisp1", }; struct ipa_context *ipaCreate() diff --git a/src/ipa/vimc/vimc.cpp b/src/ipa/vimc/vimc.cpp index d2267e11737f..cfdbd6f99155 100644 --- a/src/ipa/vimc/vimc.cpp +++ b/src/ipa/vimc/vimc.cpp @@ -126,7 +126,7 @@ const struct IPAModuleInfo ipaModuleInfo = { IPA_MODULE_API_VERSION, 0, "PipelineHandlerVimc", - "Dummy IPA for Vimc", + "vimc", }; struct ipa_context *ipaCreate() diff --git a/src/libcamera/ipa_module.cpp b/src/libcamera/ipa_module.cpp index 958ede74688e..52823e88a508 100644 --- a/src/libcamera/ipa_module.cpp +++ b/src/libcamera/ipa_module.cpp @@ -9,6 +9,7 @@ #include #include +#include #include #include #include @@ -216,6 +217,11 @@ Span elfLoadSymbol(Span elf, const char *symbol) * \var IPAModuleInfo::name * \brief The name of the IPA module * + * The name may be used to build file system paths to IPA-specific resources. + * It shall only contain printable characters, and may not contain '/', '*', + * '?' or '\'. For IPA modules included in libcamera, it shall match the + * directory of the IPA module in the source tree. + * * \todo Allow user to choose to isolate open source IPAs */ @@ -287,6 +293,20 @@ int IPAModule::loadIPAModuleInfo() return -EINVAL; } + /* Validate the IPA module name. */ + std::string ipaName = info_.name; + auto iter = std::find_if_not(ipaName.begin(), ipaName.end(), + [](unsigned char c) -> bool { + return isprint(c) && c != '/' && + c != '?' && c != '*' && + c != '\\'; + }); + if (iter != ipaName.end()) { + LOG(IPAModule, Error) + << "Invalid IPA module name '" << ipaName << "'"; + return -EINVAL; + } + /* Load the signature. Failures are not fatal. */ File sign{ libPath_ + ".sign" }; if (!sign.open(File::ReadOnly)) { diff --git a/test/ipa/ipa_module_test.cpp b/test/ipa/ipa_module_test.cpp index d22c302fa726..e3aee190b410 100644 --- a/test/ipa/ipa_module_test.cpp +++ b/test/ipa/ipa_module_test.cpp @@ -58,7 +58,7 @@ protected: IPA_MODULE_API_VERSION, 0, "PipelineHandlerVimc", - "Dummy IPA for Vimc", + "vimc", }; count += runTest("src/ipa/vimc/ipa_vimc.so", testInfo); From patchwork Mon Apr 27 03:17:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 3554 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id A19FB601B8 for ; Mon, 27 Apr 2020 05:17:33 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="jkmQwApG"; dkim-atps=neutral Received: from pendragon.bb.dnainternet.fi (81-175-216-236.bb.dnainternet.fi [81.175.216.236]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 3E4BF98D for ; Mon, 27 Apr 2020 05:17:33 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1587957453; bh=uYFqjtDHmx0Sd0s9U3QQN1xno33zpkPgGM26TlOWy3I=; h=From:To:Subject:Date:In-Reply-To:References:From; b=jkmQwApGZvCGBSLNiQmOKFsipfBg2xQZ9Ea16hHUoalLogrnpaqygxNahCsRerYvO aZZ7dKsT9KHoCv+NKu+Z8q5uL9dEu2YKTdH61HXlDblkCWzXpMsk3PbpMOasykubrg MUsYuPM8ko/M+K+Q1JF2XbYxHaqtxI3FAS4outFE= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Mon, 27 Apr 2020 06:17:04 +0300 Message-Id: <20200427031713.14013-3-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.25.3 In-Reply-To: <20200427031713.14013-1-laurent.pinchart@ideasonboard.com> References: <20200427031713.14013-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 02/11] libcamera: utils: Add a function to retrieve the libcamera source tree 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: Mon, 27 Apr 2020 03:17:33 -0000 Similarly to libcameraBuildPath(), there's a need to locate resources within the source tree when running libcamera without installing it. Support this use case with a new utils::libcameraSourcePath() function. The implementation currently leaks the path to the source tree in the installed binary. The data is put in a separate section named .zero which will need to be zeroed at installation time to fix this. Signed-off-by: Laurent Pinchart Reviewed-by: Jacopo Mondi Reviewed-by: Kieran Bingham --- meson.build | 2 ++ src/libcamera/include/utils.h | 1 + src/libcamera/utils.cpp | 37 ++++++++++++++++++++++++++++++++--- 3 files changed, 37 insertions(+), 3 deletions(-) diff --git a/meson.build b/meson.build index c6e6a934e54e..2058a6a77ceb 100644 --- a/meson.build +++ b/meson.build @@ -26,6 +26,8 @@ libcamera_version = libcamera_git_version.split('+')[0] cc = meson.get_compiler('c') config_h = configuration_data() +config_h.set('LIBCAMERA_SOURCE_DIR', '"' + meson.current_source_dir() + '"') + if cc.has_header_symbol('execinfo.h', 'backtrace') config_h.set('HAVE_BACKTRACE', 1) endif diff --git a/src/libcamera/include/utils.h b/src/libcamera/include/utils.h index 242eeded9d50..3334ff16613d 100644 --- a/src/libcamera/include/utils.h +++ b/src/libcamera/include/utils.h @@ -188,6 +188,7 @@ private: details::StringSplitter split(const std::string &str, const std::string &delim); std::string libcameraBuildPath(); +std::string libcameraSourcePath(); } /* namespace utils */ diff --git a/src/libcamera/utils.cpp b/src/libcamera/utils.cpp index 97f9b632e45b..056a67e93e0f 100644 --- a/src/libcamera/utils.cpp +++ b/src/libcamera/utils.cpp @@ -360,9 +360,10 @@ bool isLibcameraInstalled() * * During development, it is useful to run libcamera binaries directly from the * build directory without installing them. This function helps components that - * need to locate resources, such as IPA modules or IPA proxy workers, by - * providing them with the path to the root of the build directory. Callers can - * then use it to complement or override searches in system-wide directories. + * need to locate resources in the build tree, such as IPA modules or IPA proxy + * workers, by providing them with the path to the root of the build directory. + * Callers can then use it to complement or override searches in system-wide + * directories. * * If libcamera has been installed, the build directory path is not available * and this function returns an empty string. @@ -385,6 +386,36 @@ std::string libcameraBuildPath() return dirname(info.dli_fname) + "/../../"; } +namespace { +/* \todo Figure out a way to zero this section at install time */ +__attribute__((section(".zero"))) +const char sourceDirectory[] = LIBCAMERA_SOURCE_DIR; +} /* namespace */ + +/** + * \brief Retrieve the path to the source directory + * + * During development, it is useful to run libcamera binaries directly from the + * build directory without installing them. This function helps components that + * need to locate resources in the source tree, such as IPA configuration + * files, by providing them with the path to the root of the source directory. + * Callers can then use it to complement or override searches in system-wide + * directories. + * + * If libcamera has been installed, the source directory path is not available + * and this function returns an empty string. + * + * \return The path to the source directory if running from a build, or an empty + * string otherwise + */ +std::string libcameraSourcePath() +{ + if (isLibcameraInstalled()) + return std::string(); + + return std::string(sourceDirectory) + "/"; +} + } /* namespace utils */ } /* namespace libcamera */ From patchwork Mon Apr 27 03:17:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 3555 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 064C4601B8 for ; Mon, 27 Apr 2020 05:17:34 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="SbMNCNPL"; dkim-atps=neutral Received: from pendragon.bb.dnainternet.fi (81-175-216-236.bb.dnainternet.fi [81.175.216.236]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 914E172C for ; Mon, 27 Apr 2020 05:17:33 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1587957453; bh=X10g9cTC4AaPeazr5PZPuFoyA7YcMFRGtahHVMYJPcM=; h=From:To:Subject:Date:In-Reply-To:References:From; b=SbMNCNPLt3Kv4ar4wh5HU+iFICNhwZgRrKUD3Qyb7l+stj8B2GUg1iV6WCmMoY7YI IhRXJ4aIqflmdJQjl7mzLaZ5R4pL7vEbWt537lUgwO0woE5+paac/lW7zHGnvYvpTv Y0AaWRC5oIs7Kytyu/UrfcXyLEu5unZR+e1g1zXY= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Mon, 27 Apr 2020 06:17:05 +0300 Message-Id: <20200427031713.14013-4-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.25.3 In-Reply-To: <20200427031713.14013-1-laurent.pinchart@ideasonboard.com> References: <20200427031713.14013-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 03/11] libcamera: ipa_proxy: Add missing space in info message 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: Mon, 27 Apr 2020 03:17:34 -0000 The message printed when loading a proxy worker from the build directory is missing a space. Add it. Signed-off-by: Laurent Pinchart Reviewed-by: Jacopo Mondi Reviewed-by: Jacopo Mondi --- src/libcamera/ipa_proxy.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libcamera/ipa_proxy.cpp b/src/libcamera/ipa_proxy.cpp index 5fd88a4ba75e..22b246be5797 100644 --- a/src/libcamera/ipa_proxy.cpp +++ b/src/libcamera/ipa_proxy.cpp @@ -102,7 +102,7 @@ std::string IPAProxy::resolvePath(const std::string &file) const std::string ipaProxyDir = root + "src/libcamera/proxy/worker"; LOG(IPAProxy, Info) - << "libcamera is not installed. Loading proxy workers from'" + << "libcamera is not installed. Loading proxy workers from '" << ipaProxyDir << "'"; std::string proxyPath = ipaProxyDir + proxyFile; From patchwork Mon Apr 27 03:17:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 3556 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 6C273601B8 for ; Mon, 27 Apr 2020 05:17:34 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="rZJ+Vffb"; dkim-atps=neutral Received: from pendragon.bb.dnainternet.fi (81-175-216-236.bb.dnainternet.fi [81.175.216.236]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id F279D97D for ; Mon, 27 Apr 2020 05:17:33 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1587957454; bh=bTjPNruQeanW5+57OlGxytT9uM7WkE3B6ytNRiZSGjo=; h=From:To:Subject:Date:In-Reply-To:References:From; b=rZJ+VffbRYeSv+DWCn7VWgl4CQSkxIR+nRJhHpdM+RtVfMseoX5SDQkgXqZuNQ/ah wDXiagWP4DA5OtvfNINC5//w63D3mYzf8JnsGyMjOBOTWrrE23C9bewOSYLSdSCfJz u/Pwud0ijzzx2dvxepkmfon+3uybzDymM3aRvuYg= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Mon, 27 Apr 2020 06:17:06 +0300 Message-Id: <20200427031713.14013-5-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.25.3 In-Reply-To: <20200427031713.14013-1-laurent.pinchart@ideasonboard.com> References: <20200427031713.14013-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 04/11] libcamera: ipa_proxy: Don't include 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: Mon, 27 Apr 2020 03:17:34 -0000 The iostream header isn't needed. Drop it. Fixes: c2a8217df54c ("libcamera: add IPA proxy") Signed-off-by: Laurent Pinchart Reviewed-by: Jacopo Mondi Reviewed-by: Kieran Bingham --- src/libcamera/ipa_proxy.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/libcamera/ipa_proxy.cpp b/src/libcamera/ipa_proxy.cpp index 22b246be5797..43ac9afc25cb 100644 --- a/src/libcamera/ipa_proxy.cpp +++ b/src/libcamera/ipa_proxy.cpp @@ -13,8 +13,6 @@ #include "log.h" #include "utils.h" -#include - /** * \file ipa_proxy.h * \brief IPA Proxy From patchwork Mon Apr 27 03:17:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 3557 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 B8DBB601B8 for ; Mon, 27 Apr 2020 05:17:34 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="oczknb41"; dkim-atps=neutral Received: from pendragon.bb.dnainternet.fi (81-175-216-236.bb.dnainternet.fi [81.175.216.236]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 5B1F272C for ; Mon, 27 Apr 2020 05:17:34 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1587957454; bh=+bCKeeRKlKKGlXKTgM0sj3xdHdjbiWTrb31gXoU4oec=; h=From:To:Subject:Date:In-Reply-To:References:From; b=oczknb41AkpwEg+nYadkrL+8nR7N7oTlQmK0Ar+9t8suIf9vI6GoyXWI/HTjf2Ahk rB1rKDovBaY4xNA1R+SSMFw3mIpqJrQ8GUwbjOlzq3jN3jU48zcnafgr6bzTzUoZEf fcCkYoQb2ye7eVkeuyCVkbRYoI5xG6zB5NIdqzAM= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Mon, 27 Apr 2020 06:17:07 +0300 Message-Id: <20200427031713.14013-6-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.25.3 In-Reply-To: <20200427031713.14013-1-laurent.pinchart@ideasonboard.com> References: <20200427031713.14013-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 05/11] libcamera: ipa_proxy: Provide suport for IPA configuration files 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: Mon, 27 Apr 2020 03:17:34 -0000 IPA modules may require configuration files, which may be stored in different locations in the file system. To standardize file locations between all IPAs and pipeline handlers, provide a helper function to locate a configuration file by searching in the following directories: - All directories specified in the LIBCAMERA_IPA_CONFIG_PATH environment variable ; or - In the build tree if libcamera is not installed ; otherwise - In standard system locations (etc and share directories). More locations, or extensions to the mechanism, may be implemented later. Signed-off-by: Laurent Pinchart Reviewed-by: Kieran Bingham --- src/ipa/meson.build | 6 ++ src/libcamera/include/ipa_proxy.h | 11 ++- src/libcamera/ipa_proxy.cpp | 91 +++++++++++++++++++++++- src/libcamera/proxy/ipa_proxy_linux.cpp | 2 +- src/libcamera/proxy/ipa_proxy_thread.cpp | 2 +- 5 files changed, 105 insertions(+), 7 deletions(-) diff --git a/src/ipa/meson.build b/src/ipa/meson.build index cb4e3ab3388f..145bf8105af7 100644 --- a/src/ipa/meson.build +++ b/src/ipa/meson.build @@ -1,10 +1,16 @@ ipa_install_dir = join_paths(get_option('libdir'), 'libcamera') +ipa_data_dir = join_paths(get_option('datadir'), 'libcamera', 'ipa') +ipa_sysconf_dir = join_paths(get_option('sysconfdir'), 'libcamera', 'ipa') ipa_includes = [ libcamera_includes, libcamera_internal_includes, ] +config_h.set('IPA_CONFIG_DIR', + '"' + join_paths(get_option('prefix'), ipa_sysconf_dir) + + ':' + join_paths(get_option('prefix'), ipa_data_dir) + '"') + config_h.set('IPA_MODULE_DIR', '"' + join_paths(get_option('prefix'), ipa_install_dir) + '"') diff --git a/src/libcamera/include/ipa_proxy.h b/src/libcamera/include/ipa_proxy.h index e696551af39f..1111065b36a7 100644 --- a/src/libcamera/include/ipa_proxy.h +++ b/src/libcamera/include/ipa_proxy.h @@ -13,22 +13,27 @@ #include -#include "ipa_module.h" - namespace libcamera { +class IPAModule; + class IPAProxy : public IPAInterface { public: - IPAProxy(); + IPAProxy(IPAModule *ipam); ~IPAProxy(); bool isValid() const { return valid_; } + std::string configurationFile(const std::string &file) const; + protected: std::string resolvePath(const std::string &file) const; bool valid_; + +private: + IPAModule *ipam_; }; class IPAProxyFactory diff --git a/src/libcamera/ipa_proxy.cpp b/src/libcamera/ipa_proxy.cpp index 43ac9afc25cb..ea69e63d6bb8 100644 --- a/src/libcamera/ipa_proxy.cpp +++ b/src/libcamera/ipa_proxy.cpp @@ -8,8 +8,11 @@ #include "ipa_proxy.h" #include +#include +#include #include +#include "ipa_module.h" #include "log.h" #include "utils.h" @@ -34,12 +37,13 @@ LOG_DEFINE_CATEGORY(IPAProxy) /** * \brief Construct an IPAProxy instance + * \param[in] ipam The IPA module * * IPAProxy instances shall be constructed through the IPAProxyFactory::create() * method implemented by the respective factories. */ -IPAProxy::IPAProxy() - : valid_(false) +IPAProxy::IPAProxy(IPAModule *ipam) + : valid_(false), ipam_(ipam) { } @@ -57,6 +61,89 @@ IPAProxy::~IPAProxy() * \return True if the IPAProxy is valid, false otherwise */ +/** + * \brief Retrieve the absolute path to an IPA configuration file + * \param[in] name The configuration name + * + * This function locates the configuration file for an IPA and returns its + * absolute path. It searches the following directories, in order: + * + * - All directories specified in the colon-separated LIBCAMERA_IPA_CONFIG_PATH + * environment variable ; or + * - If libcamera is not installed, the src/ipa/ directory within the source + * tree ; otherwise + * - The system sysconf (etc/libcamera/ipa) and the data (share/libcamera/ipa/) + * directories. + * + * The system directories are not searched if libcamera is not installed. + * + * Within each of those directories, the function looks for a subdirectory + * named after the IPA module name, as reported in IPAModuleInfo::name, and for + * a file named \a name within that directory. The \a name is IPA-specific. + * + * \return The full path to the IPA configuration file, or an empty string if + * no configuration file can be found + */ +std::string IPAProxy::configurationFile(const std::string &name) const +{ + struct stat statbuf; + int ret; + + /* + * The IPA module name can be used as-is to build directory names as it + * has been validated when loading the module. + */ + std::string ipaName = ipam_->info().name; + + /* Check the environment variable first. */ + const char *confPaths = utils::secure_getenv("LIBCAMERA_IPA_CONFIG_PATH"); + if (confPaths) { + for (const auto &dir : utils::split(confPaths, ":")) { + if (dir.empty()) + continue; + + std::string confPath = dir + "/" + ipaName + "/" + name; + ret = stat(confPath.c_str(), &statbuf); + if (ret == 0 && (statbuf.st_mode & S_IFMT) == S_IFREG) + return confPath; + } + } + + /* + * When libcamera is used before it is installed, load configuration + * files from the source directory. The configuration files are then + * located in the 'data' subdirectory of the corresponding IPA module. + */ + std::string root = utils::libcameraSourcePath(); + if (!root.empty()) { + std::string ipaConfDir = root + "src/ipa/" + ipaName + "/data"; + + LOG(IPAProxy, Info) + << "libcamera is not installed. Loading IPA configuration from '" + << ipaConfDir << "'"; + + std::string confPath = ipaConfDir + "/" + name; + ret = stat(confPath.c_str(), &statbuf); + if (ret == 0 && (statbuf.st_mode & S_IFMT) == S_IFREG) + return confPath; + + return std::string(); + } + + /* Else look in the system locations. */ + for (const auto &dir : utils::split(IPA_CONFIG_DIR, ":")) { + if (dir.empty()) + continue; + + std::string confPath = dir + "/" + ipaName + "/" + name; + ret = stat(confPath.c_str(), &statbuf); + if (ret == 0 && (statbuf.st_mode & S_IFMT) == S_IFREG) + return confPath; + } + + return std::string(); +} + /** * \brief Find a valid full path for a proxy worker for a given executable name * \param[in] file File name of proxy worker executable diff --git a/src/libcamera/proxy/ipa_proxy_linux.cpp b/src/libcamera/proxy/ipa_proxy_linux.cpp index 2aa80b946704..89f5cb54687b 100644 --- a/src/libcamera/proxy/ipa_proxy_linux.cpp +++ b/src/libcamera/proxy/ipa_proxy_linux.cpp @@ -44,7 +44,7 @@ private: }; IPAProxyLinux::IPAProxyLinux(IPAModule *ipam) - : proc_(nullptr), socket_(nullptr) + : IPAProxy(ipam), proc_(nullptr), socket_(nullptr) { LOG(IPAProxy, Debug) << "initializing dummy proxy: loading IPA from " diff --git a/src/libcamera/proxy/ipa_proxy_thread.cpp b/src/libcamera/proxy/ipa_proxy_thread.cpp index 368ccca1cf60..1ebb9b6a6c9d 100644 --- a/src/libcamera/proxy/ipa_proxy_thread.cpp +++ b/src/libcamera/proxy/ipa_proxy_thread.cpp @@ -73,7 +73,7 @@ private: }; IPAProxyThread::IPAProxyThread(IPAModule *ipam) - : running_(false) + : IPAProxy(ipam), running_(false) { if (!ipam->load()) return; From patchwork Mon Apr 27 03:17:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 3558 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 2496C60AF4 for ; Mon, 27 Apr 2020 05:17:35 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="Q4UAEiQG"; dkim-atps=neutral Received: from pendragon.bb.dnainternet.fi (81-175-216-236.bb.dnainternet.fi [81.175.216.236]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id B185397D for ; Mon, 27 Apr 2020 05:17:34 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1587957454; bh=MjnLqgId78kIcnx1x19FR35PMzeYX8YVfyOVjuYPVFk=; h=From:To:Subject:Date:In-Reply-To:References:From; b=Q4UAEiQG1IcVbchc8g4VJVQpgJxULjGB0kJUj6FJovRxl1hCwQfoPFkPJUhRoR7L7 89YAPRGot13kpZsy9iQBJgXF8jYYUn8eMrssMU10l3VYh0fQBn+BJocaAGm1WulQEf pUSHisPp9bOero+ALetwUXixanRUdTs9/QIcKmX0= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Mon, 27 Apr 2020 06:17:08 +0300 Message-Id: <20200427031713.14013-7-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.25.3 In-Reply-To: <20200427031713.14013-1-laurent.pinchart@ideasonboard.com> References: <20200427031713.14013-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 06/11] libcamera: ipa_manager: Return an IPAProxy from createIPA() 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: Mon, 27 Apr 2020 03:17:36 -0000 In order to provide pipeline handlers with IPA-related helpers on top of IPAInterface, return the IPAProxy instance from IPAManager::createIPA(). No change is required in the pipeline handlers as the IPAInterface that was previously returned is implemented by an IPAProxy instance already. Signed-off-by: Laurent Pinchart Reviewed-by: Jacopo Mondi Reviewed-by: Kieran Bingham --- src/libcamera/include/ipa_manager.h | 6 +++--- src/libcamera/include/pipeline_handler.h | 5 +++-- src/libcamera/ipa_manager.cpp | 14 +++++++------- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/libcamera/include/ipa_manager.h b/src/libcamera/include/ipa_manager.h index 6165efb8b145..aa6b9adb1f87 100644 --- a/src/libcamera/include/ipa_manager.h +++ b/src/libcamera/include/ipa_manager.h @@ -24,9 +24,9 @@ class IPAManager public: static IPAManager *instance(); - std::unique_ptr createIPA(PipelineHandler *pipe, - uint32_t maxVersion, - uint32_t minVersion); + std::unique_ptr createIPA(PipelineHandler *pipe, + uint32_t maxVersion, + uint32_t minVersion); private: std::vector modules_; diff --git a/src/libcamera/include/pipeline_handler.h b/src/libcamera/include/pipeline_handler.h index 3fcfeda4bfee..706413fa6e9f 100644 --- a/src/libcamera/include/pipeline_handler.h +++ b/src/libcamera/include/pipeline_handler.h @@ -15,11 +15,12 @@ #include #include -#include #include #include #include +#include "ipa_proxy.h" + namespace libcamera { class Camera; @@ -46,7 +47,7 @@ public: std::list queuedRequests_; ControlInfoMap controlInfo_; ControlList properties_; - std::unique_ptr ipa_; + std::unique_ptr ipa_; private: CameraData(const CameraData &) = delete; diff --git a/src/libcamera/ipa_manager.cpp b/src/libcamera/ipa_manager.cpp index 50b6792d6cce..df3786797010 100644 --- a/src/libcamera/ipa_manager.cpp +++ b/src/libcamera/ipa_manager.cpp @@ -247,17 +247,17 @@ unsigned int IPAManager::addDir(const char *libDir, unsigned int maxDepth) } /** - * \brief Create an IPA interface that matches a given pipeline handler - * \param[in] pipe The pipeline handler that wants a matching IPA interface + * \brief Create an IPA proxy that matches a given pipeline handler + * \param[in] pipe The pipeline handler that wants a matching IPA proxy * \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 or if the IPA interface fails to initialize + * \return A newly created IPA proxy, or nullptr if no matching IPA module is + * found or if the IPA proxy fails to initialize */ -std::unique_ptr IPAManager::createIPA(PipelineHandler *pipe, - uint32_t maxVersion, - uint32_t minVersion) +std::unique_ptr IPAManager::createIPA(PipelineHandler *pipe, + uint32_t maxVersion, + uint32_t minVersion) { IPAModule *m = nullptr; From patchwork Mon Apr 27 03:17:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 3559 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 7958560B02 for ; Mon, 27 Apr 2020 05:17:35 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="rjBTTwQW"; dkim-atps=neutral Received: from pendragon.bb.dnainternet.fi (81-175-216-236.bb.dnainternet.fi [81.175.216.236]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 1253572C for ; Mon, 27 Apr 2020 05:17:35 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1587957455; bh=yTQIcQx7iiYii1WpyFu45u9ADXFUWy/YU6VYuN22hCc=; h=From:To:Subject:Date:In-Reply-To:References:From; b=rjBTTwQWLg1wZ0nmNqdbXBVxFGwdXOIINXC6hGn05HYkC7B3tupRVnzHvs8cMvYGa dEkGO1u02X7hOQGf1oUGXt3/INGGSY2VvwjN+MQya2BgUXbNModvnf8P4iekXeyRs5 lCasCtcrD+MUbOYh08kyQoLvzFRZ91C9iRe0pbso= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Mon, 27 Apr 2020 06:17:09 +0300 Message-Id: <20200427031713.14013-8-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.25.3 In-Reply-To: <20200427031713.14013-1-laurent.pinchart@ideasonboard.com> References: <20200427031713.14013-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 07/11] ipa: Pass IPA initialization settings to IPAInterface::init() 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: Mon, 27 Apr 2020 03:17:37 -0000 Add a new IPASettings class to pass IPA initialization settings through the IPAInterface::init() method. The settings currently only contain the name of a configuration file, and are expected to be extended later. Signed-off-by: Laurent Pinchart --- include/ipa/ipa_interface.h | 13 +++++++-- src/ipa/libipa/ipa_interface_wrapper.cpp | 8 ++++-- src/ipa/libipa/ipa_interface_wrapper.h | 3 +- src/ipa/rkisp1/rkisp1.cpp | 2 +- src/ipa/vimc/vimc.cpp | 4 +-- src/libcamera/include/ipa_context_wrapper.h | 2 +- src/libcamera/ipa_context_wrapper.cpp | 9 ++++-- src/libcamera/ipa_interface.cpp | 32 +++++++++++++++++++++ src/libcamera/pipeline/rkisp1/rkisp1.cpp | 2 +- src/libcamera/pipeline/vimc/vimc.cpp | 2 +- src/libcamera/proxy/ipa_proxy_linux.cpp | 2 +- src/libcamera/proxy/ipa_proxy_thread.cpp | 6 ++-- test/ipa/ipa_interface_test.cpp | 3 +- test/ipa/ipa_wrappers_test.cpp | 13 +++++++-- 14 files changed, 80 insertions(+), 21 deletions(-) diff --git a/include/ipa/ipa_interface.h b/include/ipa/ipa_interface.h index e65844bc7b34..ef3d6507b692 100644 --- a/include/ipa/ipa_interface.h +++ b/include/ipa/ipa_interface.h @@ -18,6 +18,10 @@ struct ipa_context { const struct ipa_context_ops *ops; }; +struct ipa_settings { + const char *configuration_file; +}; + struct ipa_stream { unsigned int id; unsigned int pixel_format; @@ -63,7 +67,8 @@ struct ipa_callback_ops { struct ipa_context_ops { void (*destroy)(struct ipa_context *ctx); void *(*get_interface)(struct ipa_context *ctx); - void (*init)(struct ipa_context *ctx); + void (*init)(struct ipa_context *ctx, + const struct ipa_settings *settings); int (*start)(struct ipa_context *ctx); void (*stop)(struct ipa_context *ctx); void (*register_callbacks)(struct ipa_context *ctx, @@ -100,6 +105,10 @@ struct ipa_context *ipaCreate(); namespace libcamera { +struct IPASettings { + std::string configurationFile; +}; + struct IPAStream { unsigned int pixelFormat; Size size; @@ -121,7 +130,7 @@ class IPAInterface public: virtual ~IPAInterface() {} - virtual int init() = 0; + virtual int init(const IPASettings &settings) = 0; virtual int start() = 0; virtual void stop() = 0; diff --git a/src/ipa/libipa/ipa_interface_wrapper.cpp b/src/ipa/libipa/ipa_interface_wrapper.cpp index f50f93a0185a..7776d9881575 100644 --- a/src/ipa/libipa/ipa_interface_wrapper.cpp +++ b/src/ipa/libipa/ipa_interface_wrapper.cpp @@ -79,11 +79,15 @@ void *IPAInterfaceWrapper::get_interface(struct ipa_context *_ctx) return ctx->ipa_.get(); } -void IPAInterfaceWrapper::init(struct ipa_context *_ctx) +void IPAInterfaceWrapper::init(struct ipa_context *_ctx, + const struct ipa_settings *settings) { IPAInterfaceWrapper *ctx = static_cast(_ctx); - ctx->ipa_->init(); + IPASettings ipaSettings{ + .configurationFile = std::string{ settings->configuration_file } + }; + ctx->ipa_->init(ipaSettings); } int IPAInterfaceWrapper::start(struct ipa_context *_ctx) diff --git a/src/ipa/libipa/ipa_interface_wrapper.h b/src/ipa/libipa/ipa_interface_wrapper.h index e4bc6dd4535d..78ccf0f59d42 100644 --- a/src/ipa/libipa/ipa_interface_wrapper.h +++ b/src/ipa/libipa/ipa_interface_wrapper.h @@ -23,7 +23,8 @@ public: private: static void destroy(struct ipa_context *ctx); static void *get_interface(struct ipa_context *ctx); - static void init(struct ipa_context *ctx); + static void init(struct ipa_context *ctx, + const struct ipa_settings *settings); static int start(struct ipa_context *ctx); static void stop(struct ipa_context *ctx); static void register_callbacks(struct ipa_context *ctx, diff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp index 7f0ffb0a791f..9a347e527cd2 100644 --- a/src/ipa/rkisp1/rkisp1.cpp +++ b/src/ipa/rkisp1/rkisp1.cpp @@ -32,7 +32,7 @@ LOG_DEFINE_CATEGORY(IPARkISP1) class IPARkISP1 : public IPAInterface { public: - int init() override { return 0; } + int init(const IPASettings &settings) override { return 0; } int start() override { return 0; } void stop() override {} diff --git a/src/ipa/vimc/vimc.cpp b/src/ipa/vimc/vimc.cpp index cfdbd6f99155..e6bda8ec58b0 100644 --- a/src/ipa/vimc/vimc.cpp +++ b/src/ipa/vimc/vimc.cpp @@ -31,7 +31,7 @@ public: IPAVimc(); ~IPAVimc(); - int init() override; + int init(const IPASettings &settings) override; int start() override; void stop() override; @@ -61,7 +61,7 @@ IPAVimc::~IPAVimc() ::close(fd_); } -int IPAVimc::init() +int IPAVimc::init(const IPASettings &settings) { trace(IPAOperationInit); diff --git a/src/libcamera/include/ipa_context_wrapper.h b/src/libcamera/include/ipa_context_wrapper.h index 0a48bfe732c8..64395b4a450b 100644 --- a/src/libcamera/include/ipa_context_wrapper.h +++ b/src/libcamera/include/ipa_context_wrapper.h @@ -19,7 +19,7 @@ public: IPAContextWrapper(struct ipa_context *context); ~IPAContextWrapper(); - int init() override; + int init(const IPASettings &settings) override; int start() override; void stop() override; void configure(const std::map &streamConfig, diff --git a/src/libcamera/ipa_context_wrapper.cpp b/src/libcamera/ipa_context_wrapper.cpp index ab6ce396b88a..5bd5d916ccc0 100644 --- a/src/libcamera/ipa_context_wrapper.cpp +++ b/src/libcamera/ipa_context_wrapper.cpp @@ -69,15 +69,18 @@ IPAContextWrapper::~IPAContextWrapper() ctx_->ops->destroy(ctx_); } -int IPAContextWrapper::init() +int IPAContextWrapper::init(const IPASettings &settings) { if (intf_) - return intf_->init(); + return intf_->init(settings); if (!ctx_) return 0; - ctx_->ops->init(ctx_); + struct ipa_settings c_settings; + c_settings.configuration_file = settings.configurationFile.c_str(); + + ctx_->ops->init(ctx_, &c_settings); return 0; } diff --git a/src/libcamera/ipa_interface.cpp b/src/libcamera/ipa_interface.cpp index 890d4340e4f3..3949b7d6ea5d 100644 --- a/src/libcamera/ipa_interface.cpp +++ b/src/libcamera/ipa_interface.cpp @@ -92,6 +92,16 @@ * \brief The IPA context operations */ +/** + * \struct ipa_settings + * \brief IPA initialization settings for the IPA context operations + * \sa IPASettings + * + * \var ipa_settings::configuration_file + * \brief The name of the IPA configuration file (may be null or point to an + * empty string) + */ + /** * \struct ipa_stream * \brief Stream information for the IPA context operations @@ -231,6 +241,7 @@ * \var ipa_context_ops::init * \brief Initialise the IPA context * \param[in] ctx The IPA context + * \param[in] settings The IPA initialization settings * * \sa libcamera::IPAInterface::init() */ @@ -310,6 +321,22 @@ namespace libcamera { +/** + * \struct IPASettings + * \brief IPA interface initialization settings + * + * The IPASettings structure stores data passed to the IPAInterface::init() + * function. + */ + +/** + * \var IPASettings::configurationFile + * \brief The name of the IPA configuration file + * + * This field may be an empty string if the IPA doesn't require a configuration + * file. + */ + /** * \struct IPAStream * \brief Stream configuration for the IPA interface @@ -424,6 +451,11 @@ namespace libcamera { /** * \fn IPAInterface::init() * \brief Initialise the IPAInterface + * \param[in] settings The IPA initialization settings + * + * This function initializes the IPA interface. It shall be called before any + * other function of the IPAInterface. The \a settings carry initialization + * parameters that will remain valid for the whole life time of the interface. */ /** diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp index f42264361785..fde445b99a46 100644 --- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp +++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp @@ -401,7 +401,7 @@ int RkISP1CameraData::loadIPA() ipa_->queueFrameAction.connect(this, &RkISP1CameraData::queueFrameAction); - ipa_->init(); + ipa_->init(IPASettings{}); return 0; } diff --git a/src/libcamera/pipeline/vimc/vimc.cpp b/src/libcamera/pipeline/vimc/vimc.cpp index c5eea3a01b0e..699f788aa1b8 100644 --- a/src/libcamera/pipeline/vimc/vimc.cpp +++ b/src/libcamera/pipeline/vimc/vimc.cpp @@ -374,7 +374,7 @@ bool PipelineHandlerVimc::match(DeviceEnumerator *enumerator) if (data->ipa_ == nullptr) LOG(VIMC, Warning) << "no matching IPA found"; else - data->ipa_->init(); + data->ipa_->init(IPASettings{}); /* Locate and open the capture video node. */ if (data->init(media)) diff --git a/src/libcamera/proxy/ipa_proxy_linux.cpp b/src/libcamera/proxy/ipa_proxy_linux.cpp index 89f5cb54687b..cd8ac824679d 100644 --- a/src/libcamera/proxy/ipa_proxy_linux.cpp +++ b/src/libcamera/proxy/ipa_proxy_linux.cpp @@ -26,7 +26,7 @@ public: IPAProxyLinux(IPAModule *ipam); ~IPAProxyLinux(); - int init() override { return 0; } + int init(const IPASettings &settings) override { return 0; } int start() override { return 0; } void stop() override {} void configure(const std::map &streamConfig, diff --git a/src/libcamera/proxy/ipa_proxy_thread.cpp b/src/libcamera/proxy/ipa_proxy_thread.cpp index 1ebb9b6a6c9d..be82fde34bd9 100644 --- a/src/libcamera/proxy/ipa_proxy_thread.cpp +++ b/src/libcamera/proxy/ipa_proxy_thread.cpp @@ -25,7 +25,7 @@ class IPAProxyThread : public IPAProxy, public Object public: IPAProxyThread(IPAModule *ipam); - int init() override; + int init(const IPASettings &settings) override; int start() override; void stop() override; @@ -97,9 +97,9 @@ IPAProxyThread::IPAProxyThread(IPAModule *ipam) valid_ = true; } -int IPAProxyThread::init() +int IPAProxyThread::init(const IPASettings &settings) { - int ret = ipa_->init(); + int ret = ipa_->init(settings); if (ret) return ret; diff --git a/test/ipa/ipa_interface_test.cpp b/test/ipa/ipa_interface_test.cpp index 22f9ca41ef37..2e2dfb8d1ebd 100644 --- a/test/ipa/ipa_interface_test.cpp +++ b/test/ipa/ipa_interface_test.cpp @@ -98,7 +98,8 @@ protected: } /* Test initialization of IPA module. */ - ipa_->init(); + IPASettings settings; + ipa_->init(settings); timer.start(1000); while (timer.isRunning() && trace_ != IPAOperationInit) dispatcher->processEvents(); diff --git a/test/ipa/ipa_wrappers_test.cpp b/test/ipa/ipa_wrappers_test.cpp index fae1d56b67c7..21bf51a2e046 100644 --- a/test/ipa/ipa_wrappers_test.cpp +++ b/test/ipa/ipa_wrappers_test.cpp @@ -43,8 +43,14 @@ public: { } - int init() override + int init(const IPASettings &settings) override { + if (settings.configurationFile != "/ipa/configuration/file") { + cerr << "init(): Invalid configuration file" << endl; + report(Op_init, TestFail); + return 0; + } + report(Op_init, TestPass); return 0; } @@ -339,7 +345,10 @@ protected: * Test init(), start() and stop() last to ensure nothing in the * wrappers or serializer depends on them being called first. */ - ret = INVOKE(init); + IPASettings settings{ + .configurationFile = "/ipa/configuration/file" + }; + ret = INVOKE(init, settings); if (ret == TestFail) { cerr << "Failed to run init()"; return TestFail; From patchwork Mon Apr 27 03:17:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 3560 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id D0DA160B06 for ; Mon, 27 Apr 2020 05:17:35 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="k6PooFgX"; dkim-atps=neutral Received: from pendragon.bb.dnainternet.fi (81-175-216-236.bb.dnainternet.fi [81.175.216.236]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 7768B97D for ; Mon, 27 Apr 2020 05:17:35 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1587957455; bh=0CnZ6Jaoh5AxEIMlKRwwcdwzEDpXfU6o5xaLE3LMvsM=; h=From:To:Subject:Date:In-Reply-To:References:From; b=k6PooFgXzHuqGKZubRqCCDGW7WcL6Avup6n5TX/tXkHh0TxSlQ9S/Tquf0K6fbvmO ElfjCtIVvQMDVGyoKauD9ihweI4iwecHpsa6YGhgTm+Z+CiQoaFx0zRSEW8DWxO/xr zQ6N0EbuUl0sYHXQdrr50pm4bFtUAMqFnLhVcnCs= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Mon, 27 Apr 2020 06:17:10 +0300 Message-Id: <20200427031713.14013-9-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.25.3 In-Reply-To: <20200427031713.14013-1-laurent.pinchart@ideasonboard.com> References: <20200427031713.14013-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 08/11] ipa: vimc: Add a dummy configuration file to the vimc IPA 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: Mon, 27 Apr 2020 03:17:39 -0000 The file will be used to test the corresponding APIs. Signed-off-by: Laurent Pinchart Reviewed-by: Jacopo Mondi Reviewed-by: Kieran Bingham --- src/ipa/vimc/data/meson.build | 6 ++++++ src/ipa/vimc/data/vimc.conf | 1 + src/ipa/vimc/meson.build | 2 ++ 3 files changed, 9 insertions(+) create mode 100644 src/ipa/vimc/data/meson.build create mode 100644 src/ipa/vimc/data/vimc.conf diff --git a/src/ipa/vimc/data/meson.build b/src/ipa/vimc/data/meson.build new file mode 100644 index 000000000000..c844926da7f2 --- /dev/null +++ b/src/ipa/vimc/data/meson.build @@ -0,0 +1,6 @@ +conf_files = files([ + 'vimc.conf', +]) + +install_data(conf_files, + install_dir : join_paths(ipa_data_dir, 'vimc')) diff --git a/src/ipa/vimc/data/vimc.conf b/src/ipa/vimc/data/vimc.conf new file mode 100644 index 000000000000..b3cda75801e2 --- /dev/null +++ b/src/ipa/vimc/data/vimc.conf @@ -0,0 +1 @@ +# Dummy configuration file for the vimc IPA. diff --git a/src/ipa/vimc/meson.build b/src/ipa/vimc/meson.build index a354096d8496..f8650ee80461 100644 --- a/src/ipa/vimc/meson.build +++ b/src/ipa/vimc/meson.build @@ -17,3 +17,5 @@ if ipa_sign_module install : true, install_dir : ipa_install_dir) endif + +subdir('data') From patchwork Mon Apr 27 03:17:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 3561 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 3853860AF8 for ; Mon, 27 Apr 2020 05:17:36 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="AdWkkMyM"; dkim-atps=neutral Received: from pendragon.bb.dnainternet.fi (81-175-216-236.bb.dnainternet.fi [81.175.216.236]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id C972272C for ; Mon, 27 Apr 2020 05:17:35 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1587957455; bh=XxIr00FoNnsz5gVRWHpiQJEwQ6zWN3rNCXKODoLdKME=; h=From:To:Subject:Date:In-Reply-To:References:From; b=AdWkkMyMU9zJin7vEIb4DkbR8Sby04GYATvS10Eb1GTzBaAFvrp6gFjmwcB3huP5/ 1OxD4ejHkRk09Al8Q/z0AXIIAi6K+rU1CEaJHttmwC8vVLiRr93aROrjTtQmRMRxLb YUlszIs89gvgddor0zBuYqThSRjVPkc9iFFNwEeI= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Mon, 27 Apr 2020 06:17:11 +0300 Message-Id: <20200427031713.14013-10-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.25.3 In-Reply-To: <20200427031713.14013-1-laurent.pinchart@ideasonboard.com> References: <20200427031713.14013-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 09/11] libcamera: pipeline: vimc: Pass configuration file to IPA init() 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: Mon, 27 Apr 2020 03:17:39 -0000 Pass the vimc IPA dummy configuration file to the IPA init() function. This will be used by the IPA to validate the init() call. Signed-off-by: Laurent Pinchart Reviewed-by: Jacopo Mondi Reviewed-by: Kieran Bingham --- src/libcamera/pipeline/vimc/vimc.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/libcamera/pipeline/vimc/vimc.cpp b/src/libcamera/pipeline/vimc/vimc.cpp index 699f788aa1b8..ec3ee7241cdf 100644 --- a/src/libcamera/pipeline/vimc/vimc.cpp +++ b/src/libcamera/pipeline/vimc/vimc.cpp @@ -371,10 +371,12 @@ bool PipelineHandlerVimc::match(DeviceEnumerator *enumerator) std::unique_ptr data = std::make_unique(this); data->ipa_ = IPAManager::instance()->createIPA(this, 0, 0); - if (data->ipa_ == nullptr) + if (data->ipa_ != nullptr) { + std::string conf = data->ipa_->configurationFile("vimc.conf"); + data->ipa_->init(IPASettings{ conf }); + } else { LOG(VIMC, Warning) << "no matching IPA found"; - else - data->ipa_->init(IPASettings{}); + } /* Locate and open the capture video node. */ if (data->init(media)) From patchwork Mon Apr 27 03:17:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 3562 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 8738B60AFB for ; Mon, 27 Apr 2020 05:17:36 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="OIM4nOYA"; dkim-atps=neutral Received: from pendragon.bb.dnainternet.fi (81-175-216-236.bb.dnainternet.fi [81.175.216.236]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 2C93A98D for ; Mon, 27 Apr 2020 05:17:36 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1587957456; bh=sputzHIH3iwI3MjFrOYYVXcbfQ+IzAxG9ZlE8SM5WrU=; h=From:To:Subject:Date:In-Reply-To:References:From; b=OIM4nOYAPVsJ5DvzdUg0jekQ7/+w79+sKpmce8KjhruUlCienjdEFuatzfyXicXTu qjPbsCBJiyAgyBG5dJQmTB7J0Y8A4xNAqTXgu8l86sP6VMN6HCwaLoxaoRl1CtndhL 1CwJOGnk+AS8/pcX8anNy7k7h55aAagiNRCx8WCA= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Mon, 27 Apr 2020 06:17:12 +0300 Message-Id: <20200427031713.14013-11-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.25.3 In-Reply-To: <20200427031713.14013-1-laurent.pinchart@ideasonboard.com> References: <20200427031713.14013-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 10/11] test: ipa: ipa_interface: Pass configuration file to IPA init() 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: Mon, 27 Apr 2020 03:17:39 -0000 Pass the vimc IPA dummy configuration file to the IPA init() function. This will be used by the IPA to validate the init() call. Signed-off-by: Laurent Pinchart Reviewed-by: Jacopo Mondi Reviewed-by: Kieran Bingham --- test/ipa/ipa_interface_test.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/test/ipa/ipa_interface_test.cpp b/test/ipa/ipa_interface_test.cpp index 2e2dfb8d1ebd..7fa88efee089 100644 --- a/test/ipa/ipa_interface_test.cpp +++ b/test/ipa/ipa_interface_test.cpp @@ -98,8 +98,13 @@ protected: } /* Test initialization of IPA module. */ - IPASettings settings; - ipa_->init(settings); + std::string conf = ipa_->configurationFile("vimc.conf"); + int ret = ipa_->init(IPASettings{ conf }); + if (ret < 0) { + cerr << "IPA interface init() failed" << endl; + return TestFail; + } + timer.start(1000); while (timer.isRunning() && trace_ != IPAOperationInit) dispatcher->processEvents(); @@ -155,7 +160,7 @@ private: } std::shared_ptr pipe_; - std::unique_ptr ipa_; + std::unique_ptr ipa_; enum IPAOperationCode trace_; EventNotifier *notifier_; int fd_; From patchwork Mon Apr 27 03:17:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 3563 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id E04EB61212 for ; Mon, 27 Apr 2020 05:17:36 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="d3MHoxbY"; dkim-atps=neutral Received: from pendragon.bb.dnainternet.fi (81-175-216-236.bb.dnainternet.fi [81.175.216.236]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 7FAF672C for ; Mon, 27 Apr 2020 05:17:36 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1587957456; bh=L/Id3vhye5F7dVlO7V/6uEru7Nw+QzFKHtGenNJ4v/A=; h=From:To:Subject:Date:In-Reply-To:References:From; b=d3MHoxbYWCUUdYbcebOsvdg2vxWiLIRRpOtgu9oUyF93/ZQcX5sAfSbFWWo9gs0Vm M4/F4FmXFaUQAktjwcVK0z9utbR+ULE9SYtr5BLtiYnThiSu8vhBlygf3P416XJom1 gdpWnM6AR/aBlHUE+SNol03QNXWpBmjwRCJVv5qo= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Mon, 27 Apr 2020 06:17:13 +0300 Message-Id: <20200427031713.14013-12-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.25.3 In-Reply-To: <20200427031713.14013-1-laurent.pinchart@ideasonboard.com> References: <20200427031713.14013-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 11/11] ipa: vimc: Validate configuration file in init() 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: Mon, 27 Apr 2020 03:17:39 -0000 Make sure we can open the configuration file passed to the init() function, and return an error otherwise. Signed-off-by: Laurent Pinchart Reviewed-by: Jacopo Mondi Reviewed-by: Kieran Bingham --- src/ipa/vimc/vimc.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/ipa/vimc/vimc.cpp b/src/ipa/vimc/vimc.cpp index e6bda8ec58b0..f29bc504d8c8 100644 --- a/src/ipa/vimc/vimc.cpp +++ b/src/ipa/vimc/vimc.cpp @@ -19,6 +19,7 @@ #include +#include "file.h" #include "log.h" namespace libcamera { @@ -65,7 +66,15 @@ int IPAVimc::init(const IPASettings &settings) { trace(IPAOperationInit); - LOG(IPAVimc, Debug) << "initializing vimc IPA!"; + LOG(IPAVimc, Debug) + << "initializing vimc IPA with configuration file " + << settings.configurationFile; + + File conf(settings.configurationFile); + if (!conf.open(File::ReadOnly)) { + LOG(IPAVimc, Error) << "Failed to open configuration file"; + return -EINVAL; + } return 0; }