From patchwork Thu May 23 16:42:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 1278 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 9C207618CD for ; Thu, 23 May 2019 18:42:25 +0200 (CEST) Received: from localhost.localdomain (unknown [96.44.9.117]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id E638D334; Thu, 23 May 2019 18:42:24 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1558629745; bh=8eP52V31XgW1dzUtthrgIyG4Di7EublzgjColo/Txwc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Q8BTNfP1Qo2Hd4mvLboVlvz02KSTJ3UqEv84TwNlFU6zL+m+zqK+pxVa8JgKq4E3W dv+SHqXWDcvCUsZBlWH2BcuXjoSkoTQqIy5DCwrhDl14aka7uxygsTr1eHEhk+IS5J Gp47eHpZAvboiBqMlfl4QO8X0sIptoqNFx7ndcUs= From: Paul Elder To: libcamera-devel@lists.libcamera.org Date: Thu, 23 May 2019 12:42:07 -0400 Message-Id: <20190523164210.2105-3-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190523164210.2105-1-paul.elder@ideasonboard.com> References: <20190523164210.2105-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [RFC PATCH v2 2/5] libcamera: ipa_module: add aquired attribute 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, 23 May 2019 16:42:26 -0000 The IPAManager will be designed like an enumerator, and IPA modules cannot be used by multiple pipelines at once. Add an aquired attribute to IPAModule, and corresponding getter and setters. Signed-off-by: Paul Elder --- Changes in v2: - renamed acquired() to isAcquired(), to match isValid() - added documentation src/libcamera/include/ipa_module.h | 5 +++ src/libcamera/ipa_module.cpp | 62 ++++++++++++++++++++++++++---- 2 files changed, 60 insertions(+), 7 deletions(-) diff --git a/src/libcamera/include/ipa_module.h b/src/libcamera/include/ipa_module.h index a4c6dbd..58faeca 100644 --- a/src/libcamera/include/ipa_module.h +++ b/src/libcamera/include/ipa_module.h @@ -22,11 +22,16 @@ public: const struct IPAModuleInfo &info() const; + bool isAcquired() const; + bool acquire(); + void release(); + private: struct IPAModuleInfo info_; std::string libPath_; bool valid_; + bool acquired_; int loadIPAModuleInfo(); }; diff --git a/src/libcamera/ipa_module.cpp b/src/libcamera/ipa_module.cpp index 86cbe71..4922e3e 100644 --- a/src/libcamera/ipa_module.cpp +++ b/src/libcamera/ipa_module.cpp @@ -176,14 +176,17 @@ int elfLoadSymbol(void *dst, size_t size, void *map, size_t soSize, * This structure contains the information of an IPA module. It is loaded, * read, and validated before anything else is loaded from the shared object. * - * \var IPAModuleInfo::name - * \brief The name of the IPA module + * \var IPAModuleInfo::ipaAPIVersion + * \brief The IPA API version that the IPA module was made with * - * \var IPAModuleInfo::version - * \brief The version of the IPA module + * \var IPAModuleInfo::pipelineVersion + * \brief The pipeline version that the IPA module is for * - * \todo abi compatability version - * \todo pipeline compatability matcher + * \var IPAModuleInfo::pipelineName + * \brief The name of the pipeline that the IPA module is for + * + * \var IPAModuleInfo::name + * \brief The name of the IPA module */ /** @@ -212,7 +215,7 @@ int elfLoadSymbol(void *dst, size_t size, void *map, size_t soSize, * IPAModule instance to verify the validity of the IPAModule. */ IPAModule::IPAModule(const std::string &libPath) - : libPath_(libPath), valid_(false) + : libPath_(libPath), valid_(false), acquired_(false) { if (loadIPAModuleInfo() < 0) return; @@ -289,4 +292,49 @@ const struct IPAModuleInfo &IPAModule::info() const return info_; } +/** + * \brief Check if IPA module is in use + * + * \return true if the IPA module has been claimed for exclusive use, or + * false if it is available + * \sa acquire(), release() + */ +bool IPAModule::isAcquired() const +{ + return acquired_; +} + +/** + * \brief Claim an IPA module for exclusive use + * + * Each IPA module is meant to be used by only one pipeline handler. + * IPA modules will be acquired through the IPAManager, which will + * use this method to claim an IPA module before returning it, and will + * skip over already claimed IPA modules. + * + * When the IPA module is not needed anymore, the release() method should + * be called. + * + * \return true if the IPA module was successfully claimed, or false if + * was already claimed + * \sa isAcquired(), release() + */ +bool IPAModule::acquire() +{ + if (acquired_) + return false; + + acquired_ = true; + return true; +} + +/** + * \brief Release an IPA module previously claimed for exclusive use + * \sa acquire(), isAcquired() + */ +void IPAModule::release() +{ + acquired_ = false; +} + } /* namespace libcamera */