From patchwork Thu Jul 11 18:50:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 1665 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 CCE8A6157A for ; Thu, 11 Jul 2019 20:51:15 +0200 (CEST) Received: from neptunite.amanokami.net (softbank126163157105.bbtec.net [126.163.157.105]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 701C531C; Thu, 11 Jul 2019 20:51:14 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1562871075; bh=asMxJuYS3eRmMn+bPArvHQyqlmibUefl73Gg935Uxzw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eyRvtw8Az4XNU8j95Lqci5JhReIkrVv+rS5m7qv0jeXXadQanx3DTxrnpdXsY66tf wwnPQTmyEGrx1vqGnkZrJoN742m42fCr1JW6tGYM99R3kjN20gTPGZvSndbCGO4WQX /bayCd/TCEmgU8IsAn2J0FnkEsjYDPXo3PeVu9OU= From: Paul Elder To: libcamera-devel@lists.libcamera.org Date: Fri, 12 Jul 2019 03:50:45 +0900 Message-Id: <20190711185047.11671-7-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190711185047.11671-1-paul.elder@ideasonboard.com> References: <20190711185047.11671-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 6/8] libcamera: ipa_manager: use proxy 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, 11 Jul 2019 18:51:16 -0000 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 Reviewed-by: Laurent Pinchart --- Changes in v4: - move IPAModule open source verification to IPAModule::isOpenSource() Changes in v3: - license checking is done with SPDX license strings, and only LGPL 2.1+ is accepted for now New in v2 - replaces adding shims - since Proxies are not external shared objects like the shims in v1 were, there is no longer a list of shims that is treated like IPAModules - instead the matching is done by searching the list of proxy factories src/libcamera/ipa_manager.cpp | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/src/libcamera/ipa_manager.cpp b/src/libcamera/ipa_manager.cpp index 532b77d..4276d99 100644 --- a/src/libcamera/ipa_manager.cpp +++ b/src/libcamera/ipa_manager.cpp @@ -12,6 +12,7 @@ #include #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 IPAManager::createIPA(PipelineHandler *pipe, uint32_t maxVersion, @@ -144,7 +145,36 @@ std::unique_ptr IPAManager::createIPA(PipelineHandler *pipe, } } - if (!m || !m->load()) + if (!m) + return nullptr; + + if (!m->isOpenSource()) { + IPAProxyFactory *pf = nullptr; + std::vector &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 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();