[libcamera-devel,1/6] libcamera: request: Add IPAMetaData

Message ID 20190831210220.29819-2-niklas.soderlund@ragnatech.se
State Superseded
Delegated to: Niklas Söderlund
Headers show
Series
  • libcamera: ipa: Add IPA meta data
Related show

Commit Message

Niklas Söderlund Aug. 31, 2019, 9:02 p.m. UTC
Add a new structure to hold meta data coming out of the IPA. The
structure will grow over time but for now only add information about the
auto exposure state as it can be directly used by the rkisp1 IPA, which
is capable of controlling exposure.

Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
---
 include/libcamera/request.h | 13 +++++++++++
 src/libcamera/request.cpp   | 44 +++++++++++++++++++++++++++++++++++--
 2 files changed, 55 insertions(+), 2 deletions(-)

Patch

diff --git a/include/libcamera/request.h b/include/libcamera/request.h
index f5de5257bba3f2bb..6f75a59fb69a43d7 100644
--- a/include/libcamera/request.h
+++ b/include/libcamera/request.h
@@ -21,6 +21,17 @@  class Buffer;
 class Camera;
 class Stream;
 
+enum AeState {
+	Inactive,
+	Searching,
+	Converged,
+};
+
+struct IPAMetaData {
+	AeState aeState;
+	bool ready;
+};
+
 class RequestData
 {
 };
@@ -44,6 +55,7 @@  public:
 	const std::map<Stream *, Buffer *> &buffers() const { return bufferMap_; }
 	int addBuffer(std::unique_ptr<Buffer> buffer);
 	Buffer *findBuffer(Stream *stream) const;
+	const IPAMetaData &metaData() const { return metaData_; };
 
 	uint64_t cookie() const { return cookie_; }
 	Status status() const { return status_; }
@@ -65,6 +77,7 @@  private:
 	ControlList controls_;
 	std::map<Stream *, Buffer *> bufferMap_;
 	std::unordered_set<Buffer *> pending_;
+	IPAMetaData metaData_;
 
 	const uint64_t cookie_;
 	Status status_;
diff --git a/src/libcamera/request.cpp b/src/libcamera/request.cpp
index bdb4f908fb664ccf..f40cf5cac1f029a9 100644
--- a/src/libcamera/request.cpp
+++ b/src/libcamera/request.cpp
@@ -24,6 +24,40 @@  namespace libcamera {
 
 LOG_DEFINE_CATEGORY(Request)
 
+/**
+ * \enum AeState
+ * State of Auto Exposure algorithm
+ * \var AeState::Inactive
+ * AE not running
+ * \var AeState::Searching
+ * AE is not converged to a good value and is adjusting exposure parameters.
+ * \var AeState::Converged
+ * AE has found good exposure values for the current scene.
+ */
+
+/**
+ * \struct IPAMetaData
+ * \brief Meta data describing the state of the IPA
+ *
+ * Container for IPA meta data. The intended creator of this object is an IPA
+ * and the intended consumer is applications. Applications access the object
+ * thru the Request object that corresponds to the specific capture event
+ * that generated the meta data.
+ */
+
+/**
+ * \var IPAMetaData::aeState
+ * \brief Holds the state of the Auto Exposure algorithm
+ */
+
+/**
+ * \var IPAMetaData::ready
+ * \brief Flag to indicate the pipeline have validated the meta data
+ *
+ * The meta data should not be returned to the application by the specific
+ * pipeline handler implementation before this flag is set to true.
+ */
+
 /**
  * \enum Request::Status
  * Request completion status
@@ -55,8 +89,8 @@  LOG_DEFINE_CATEGORY(Request)
  *
  */
 Request::Request(Camera *camera, uint64_t cookie)
-	: data(nullptr), camera_(camera), controls_(camera), cookie_(cookie),
-	  status_(RequestPending), cancelled_(false)
+	: data(nullptr), camera_(camera), controls_(camera), metaData_({}),
+	  cookie_(cookie), status_(RequestPending), cancelled_(false)
 {
 }
 
@@ -156,6 +190,12 @@  Buffer *Request::findBuffer(Stream *stream) const
 	return it->second;
 }
 
+/**
+ * \fn Request::metaData()
+ * \brief Retrieve the request's meta data
+ * \return The meta data associated with the request
+ */
+
 /**
  * \fn Request::cookie()
  * \brief Retrieve the cookie set when the request was created