summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2020-04-27 04:09:42 +0300
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2020-04-28 01:54:29 +0300
commit6e1cd1394e5d73dfd4c4334cbf8beee79072de21 (patch)
treeafb711809804c8c0cde434ca0655f98b04ad1a19 /src
parent256d0a4098aa4c4e9f87db46cecbd66f693dd9bf (diff)
ipa: Name IPA modules after their source directory
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 <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Diffstat (limited to 'src')
-rw-r--r--src/ipa/rkisp1/rkisp1.cpp2
-rw-r--r--src/ipa/vimc/vimc.cpp2
-rw-r--r--src/libcamera/ipa_module.cpp20
3 files changed, 22 insertions, 2 deletions
diff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp
index acbbe58c..7f0ffb0a 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 d2267e11..cfdbd6f9 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 958ede74..52823e88 100644
--- a/src/libcamera/ipa_module.cpp
+++ b/src/libcamera/ipa_module.cpp
@@ -9,6 +9,7 @@
#include <algorithm>
#include <array>
+#include <ctype.h>
#include <dlfcn.h>
#include <elf.h>
#include <errno.h>
@@ -216,6 +217,11 @@ Span<uint8_t> elfLoadSymbol(Span<uint8_t> 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)) {