From patchwork Wed Feb 5 13:04:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 2772 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 3EEB360443 for ; Wed, 5 Feb 2020 14:04:26 +0100 (CET) Received: from localhost.localdomain (cpc89242-aztw30-2-0-cust488.18-1.cable.virginm.net [86.31.129.233]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id DD08FA3B; Wed, 5 Feb 2020 14:04:25 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1580907866; bh=U2Oldkn9fy3GFixU+eQ9nvu7IcEXlTNY+WEr64ZwhE8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NwGYpDYCnaISU800BaTQVS4mVuPx/9nRoMaesSY93Z3cR8mvhdvs7U+fFvJ2WAIm0 of27DmGmRWsFWEcJcz5aBdfdGFSuLxBmo05jar30ZRyq+3vqBRh+nSYQnr4l6V+O2N IW9shWk1OkGkvJVoV6C4vQmR9wCUQbbWbEnVYn0g= From: Kieran Bingham To: LibCamera Devel Date: Wed, 5 Feb 2020 13:04:17 +0000 Message-Id: <20200205130420.8736-3-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200205130420.8736-1-kieran.bingham@ideasonboard.com> References: <20200205130420.8736-1-kieran.bingham@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 2/5] libcamera: ipa_manager: Split path handling 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: Wed, 05 Feb 2020 13:04:26 -0000 Move the iteration of a colon separated path to it's own function. This prepares for parsing extra path variables. Signed-off-by: Kieran Bingham --- src/libcamera/include/ipa_manager.h | 1 + src/libcamera/ipa_manager.cpp | 52 +++++++++++++++++++---------- 2 files changed, 36 insertions(+), 17 deletions(-) diff --git a/src/libcamera/include/ipa_manager.h b/src/libcamera/include/ipa_manager.h index 126f8babbc8f..94d35d9062e4 100644 --- a/src/libcamera/include/ipa_manager.h +++ b/src/libcamera/include/ipa_manager.h @@ -33,6 +33,7 @@ private: ~IPAManager(); int addDir(const char *libDir); + int addPath(const char *path); }; } /* namespace libcamera */ diff --git a/src/libcamera/ipa_manager.cpp b/src/libcamera/ipa_manager.cpp index 92adc6c45015..048465c37772 100644 --- a/src/libcamera/ipa_manager.cpp +++ b/src/libcamera/ipa_manager.cpp @@ -110,23 +110,7 @@ IPAManager::IPAManager() return; } - const char *paths = modulePaths; - while (1) { - const char *delim = strchrnul(paths, ':'); - size_t count = delim - paths; - - if (count) { - std::string path(paths, count); - ret = addDir(path.c_str()); - if (ret > 0) - ipaCount += ret; - } - - if (*delim == '\0') - break; - - paths += count + 1; - } + ipaCount += addPath(modulePaths); if (!ipaCount) LOG(IPAManager, Warning) @@ -206,6 +190,40 @@ int IPAManager::addDir(const char *libDir) return count; } +/** + * \brief Load IPA modules from a colon separated PATH variable + * \param[in] path string to split to search for IPA modules + * + * This method tries to create an IPAModule instance for every shared object + * found in the directories described by \a paths. + * + * \return Number of modules loaded by this call, or a negative error code + * otherwise + */ +int IPAManager::addPath(const char *paths) +{ + int ipaCount = 0; + + while (1) { + const char *delim = strchrnul(paths, ':'); + size_t count = delim - paths; + + if (count) { + std::string path(paths, count); + int ret = addDir(path.c_str()); + if (ret > 0) + ipaCount += ret; + } + + if (*delim == '\0') + break; + + paths += count + 1; + } + + return ipaCount; +} + /** * \brief Create an IPA interface that matches a given pipeline handler * \param[in] pipe The pipeline handler that wants a matching IPA interface