[libcamera-devel] [PATCH 15/22] ipa: ipu3: Mark the beginning and and of a frame

Jean-Michel Hautbois jeanmichel.hautbois at ideasonboard.com
Mon Nov 8 14:13:43 CET 2021


Introduce the skeleton for two functions which will be used to
instantiate a frame context, and do everything needed when a frame is
received. Do the same for the other end, once the algorithms have run
and updated the frame context to later deallocate the corresponding
frame context.

Signed-off-by: Jean-Michel Hautbois <jeanmichel.hautbois at ideasonboard.com>
---
 src/ipa/ipu3/ipu3.cpp | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)

diff --git a/src/ipa/ipu3/ipu3.cpp b/src/ipa/ipu3/ipu3.cpp
index 62df7819..dcf4da65 100644
--- a/src/ipa/ipu3/ipu3.cpp
+++ b/src/ipa/ipu3/ipu3.cpp
@@ -160,6 +160,14 @@ private:
 	void setControls(unsigned int frame);
 	void calculateBdsGrid(const Size &bdsOutputSize);
 
+	/*
+	 * Internal events that mark the beginning of processing a new frame
+	 * to the point that it has successfully completed processing its
+	 * statistics.
+	 */
+	void frameStarted(unsigned int frame);
+	void frameCompleted(unsigned int frame);
+
 	std::map<unsigned int, MappedFrameBuffer> buffers_;
 
 	ControlInfoMap ctrls_;
@@ -510,6 +518,14 @@ void IPAIPU3::unmapBuffers(const std::vector<unsigned int> &ids)
 	}
 }
 
+void IPAIPU3::frameStarted([[maybe_unused]] unsigned int frame)
+{
+}
+
+void IPAIPU3::frameCompleted([[maybe_unused]] unsigned int frame)
+{
+}
+
 /**
  * \brief Process an event generated by the pipeline handler
  * \param[in] event The event sent from pipeline handler
@@ -525,6 +541,14 @@ void IPAIPU3::processEvent(const IPU3Event &event)
 {
 	switch (event.op) {
 	case EventProcessControls: {
+		/*
+		 * To save incurring extra IPC calls, we do not send explicit events
+		 * when a new request is started or completed.
+		 * ProcessControls is the first event handled upon receipt of a new
+		 * request, so we can handle all actions required to start processing
+		 * a new frame.
+		 */
+		frameStarted(event.frame);
 		processControls(event.frame, event.controls);
 		break;
 	}
@@ -558,6 +582,13 @@ void IPAIPU3::processEvent(const IPU3Event &event)
 		context_.frameContext.agc.gain = camHelper_->gain(event.sensorControls.get(V4L2_CID_ANALOGUE_GAIN).get<int32_t>());
 
 		parseStatistics(event.frame, event.frameTimestamp, stats);
+		/*
+		* To save incurring extra IPC calls, we do not send explicit events
+		* when we have completed all handling of a request.
+		* Once the statistics are fully processed, we will no longer handle this
+		* frame.
+		*/
+		frameCompleted(event.frame);
 		break;
 	}
 	default:
-- 
2.32.0



More information about the libcamera-devel mailing list