[libcamera-devel,RFC,2/5] libcamera: ipa_module: add aquired attribute

Message ID 20190522210220.1631-3-paul.elder@ideasonboard.com
State Superseded
Headers show
Series
  • Add IPAManager
Related show

Commit Message

Paul Elder May 22, 2019, 9:02 p.m. UTC
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 <paul.elder@ideasonboard.com>
---
 src/libcamera/include/ipa_module.h |  5 +++++
 src/libcamera/ipa_module.cpp       | 21 ++++++++++++++++++++-
 2 files changed, 25 insertions(+), 1 deletion(-)

Patch

diff --git a/src/libcamera/include/ipa_module.h b/src/libcamera/include/ipa_module.h
index a4c6dbd..dc26037 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 acquired();
+	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..fb294e6 100644
--- a/src/libcamera/ipa_module.cpp
+++ b/src/libcamera/ipa_module.cpp
@@ -212,7 +212,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 +289,23 @@  const struct IPAModuleInfo &IPAModule::info() const
 	return info_;
 }
 
+bool IPAModule::acquired()
+{
+	return acquired_;
+}
+
+bool IPAModule::acquire()
+{
+	if (acquired_)
+		return false;
+
+	acquired_ = true;
+	return true;
+}
+
+void IPAModule::release()
+{
+	acquired_ = false;
+}
+
 } /* namespace libcamera */