[libcamera-devel,15/22] ipa: ipu3: Mark the beginning and and of a frame
diff mbox series

Message ID 20211108131350.130665-16-jeanmichel.hautbois@ideasonboard.com
State Superseded
Headers show
Series
  • IPA: IPU3: Introduce per-frame controls
Related show

Commit Message

Jean-Michel Hautbois Nov. 8, 2021, 1:13 p.m. UTC
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@ideasonboard.com>
---
 src/ipa/ipu3/ipu3.cpp | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)

Comments

Kieran Bingham Nov. 8, 2021, 3:45 p.m. UTC | #1
Quoting Jean-Michel Hautbois (2021-11-08 13:13:43)
> 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.
> 

These definitely make sense to me. I'm not sure if they need their own
patch to add as a skeleton yet, but let see later.

Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>

Can stand here, but I wonder if there's anything later that might make
sense to squash in so they all build up together. Perhaps it's fine on
it's own though.


> Signed-off-by: Jean-Michel Hautbois <jeanmichel.hautbois@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

Indentation is wrong in this block

> +               * 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
>

Patch
diff mbox series

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: