diff options
author | Paul Elder <paul.elder@ideasonboard.com> | 2019-06-05 17:09:05 -0400 |
---|---|---|
committer | Paul Elder <paul.elder@ideasonboard.com> | 2019-07-12 16:32:29 +0900 |
commit | 47a81cb9f660495bbde7df7341e74a7f8fff4490 (patch) | |
tree | 34003baab807f288b5b928c57d887b24835afb37 | |
parent | 131a88795ec7424954e23b292399803392dfc85f (diff) |
libcamera: ipa_manager: use proxy
Make IPAManager isolate an IPA in a Proxy if the IPA's license is not
open source, before returning the IPA to the caller. For now, only use
the default Linux IPA proxy, and only LGPL 2.1+ is considered open
source.
Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
-rw-r--r-- | src/libcamera/ipa_manager.cpp | 34 |
1 files changed, 32 insertions, 2 deletions
diff --git a/src/libcamera/ipa_manager.cpp b/src/libcamera/ipa_manager.cpp index 532b77d3..4276d995 100644 --- a/src/libcamera/ipa_manager.cpp +++ b/src/libcamera/ipa_manager.cpp @@ -12,6 +12,7 @@ #include <sys/types.h> #include "ipa_module.h" +#include "ipa_proxy.h" #include "log.h" #include "pipeline_handler.h" #include "utils.h" @@ -129,7 +130,7 @@ int IPAManager::addDir(const char *libDir) * \param[in] maxVersion Maximum acceptable version of IPA module * * \return A newly created IPA interface, or nullptr if no matching - * IPA module is found + * IPA module is found or if the IPA interface fails to initialize */ std::unique_ptr<IPAInterface> IPAManager::createIPA(PipelineHandler *pipe, uint32_t maxVersion, @@ -144,7 +145,36 @@ std::unique_ptr<IPAInterface> IPAManager::createIPA(PipelineHandler *pipe, } } - if (!m || !m->load()) + if (!m) + return nullptr; + + if (!m->isOpenSource()) { + IPAProxyFactory *pf = nullptr; + std::vector<IPAProxyFactory *> &factories = IPAProxyFactory::factories(); + + for (IPAProxyFactory *factory : factories) { + /* TODO: Better matching */ + if (!strcmp(factory->name().c_str(), "IPAProxyLinux")) { + pf = factory; + break; + } + } + + if (!pf) { + LOG(IPAManager, Error) << "Failed to get proxy factory"; + return nullptr; + } + + std::unique_ptr<IPAProxy> proxy = pf->create(m); + if (!proxy->isValid()) { + LOG(IPAManager, Error) << "Failed to load proxy"; + return nullptr; + } + + return proxy; + } + + if (!m->load()) return nullptr; return m->createInstance(); |