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

Message ID 20220310205130.336361-3-umang.jain@ideasonboard.com
State Changes Requested
Delegated to: Umang Jain
Headers show
Series
  • ipa: ipu3: IPAFrameContext Queue
Related show

Commit Message

Umang Jain March 10, 2022, 8:51 p.m. UTC
From: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>

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>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
---
 src/ipa/ipu3/ipu3.cpp | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

Comments

Kieran Bingham April 21, 2022, 10:46 a.m. UTC | #1
Quoting Umang Jain (2022-03-10 20:51:29)
> From: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>
> 
> 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>
> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
> Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
> ---
>  src/ipa/ipu3/ipu3.cpp | 20 ++++++++++++++++++++
>  1 file changed, 20 insertions(+)
> 
> diff --git a/src/ipa/ipu3/ipu3.cpp b/src/ipa/ipu3/ipu3.cpp
> index 81788b9a..3d5c5706 100644
> --- a/src/ipa/ipu3/ipu3.cpp
> +++ b/src/ipa/ipu3/ipu3.cpp
> @@ -163,6 +163,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(const uint32_t frame);
> +       void frameCompleted(const uint32_t frame);
> +
>         std::map<unsigned int, MappedFrameBuffer> buffers_;
>  
>         ControlInfoMap ctrls_;
> @@ -491,6 +499,14 @@ void IPAIPU3::unmapBuffers(const std::vector<unsigned int> &ids)
>         }
>  }
>  
> +void IPAIPU3::frameStarted([[maybe_unused]] const uint32_t frame)
> +{
> +}
> +
> +void IPAIPU3::frameCompleted([[maybe_unused]] const uint32_t frame)
> +{
> +}
> +
>  /**
>   * \brief Prepare the ISP to process the Request
>   * \param[in] frame The frame number
> @@ -549,6 +565,8 @@ void IPAIPU3::processControls(const uint32_t frame,
>                               [[maybe_unused]] const ControlList &controls)

Aha, I was a bit confused, but I think this is now called queueRequest()

It will be interesting to see how we tie up a request that is queued to
the frame index that it will capture from. I think it works out in the
end, as long as we ensure that requests are queued before we start the
camera ...

(and now I can't recall, do we support starting the camera without
requests queued?...)


>  {
>         /* \todo Start processing for 'frame' based on 'controls'. */
> +
> +       frameStarted(frame);
>  }
>  
>  /**
> @@ -620,6 +638,8 @@ void IPAIPU3::parseStatistics(unsigned int frame,
>          */
>  
>         statsBufferReady.emit(frame, ctrls);
> +
> +       frameCompleted(frame);
>  }
>  
>  /**
> -- 
> 2.31.0
>
Umang Jain April 25, 2022, 6:14 a.m. UTC | #2
Hi Kieran

On 4/21/22 16:16, Kieran Bingham wrote:
> Quoting Umang Jain (2022-03-10 20:51:29)
>> From: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>
>>
>> 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>
>> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
>> Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
>> ---
>>   src/ipa/ipu3/ipu3.cpp | 20 ++++++++++++++++++++
>>   1 file changed, 20 insertions(+)
>>
>> diff --git a/src/ipa/ipu3/ipu3.cpp b/src/ipa/ipu3/ipu3.cpp
>> index 81788b9a..3d5c5706 100644
>> --- a/src/ipa/ipu3/ipu3.cpp
>> +++ b/src/ipa/ipu3/ipu3.cpp
>> @@ -163,6 +163,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(const uint32_t frame);
>> +       void frameCompleted(const uint32_t frame);
>> +
>>          std::map<unsigned int, MappedFrameBuffer> buffers_;
>>   
>>          ControlInfoMap ctrls_;
>> @@ -491,6 +499,14 @@ void IPAIPU3::unmapBuffers(const std::vector<unsigned int> &ids)
>>          }
>>   }
>>   
>> +void IPAIPU3::frameStarted([[maybe_unused]] const uint32_t frame)
>> +{
>> +}
>> +
>> +void IPAIPU3::frameCompleted([[maybe_unused]] const uint32_t frame)
>> +{
>> +}
>> +
>>   /**
>>    * \brief Prepare the ISP to process the Request
>>    * \param[in] frame The frame number
>> @@ -549,6 +565,8 @@ void IPAIPU3::processControls(const uint32_t frame,
>>                                [[maybe_unused]] const ControlList &controls)
> Aha, I was a bit confused, but I think this is now called queueRequest()


Yep, this will go under a major rebase to adapt to new interface.

>
> It will be interesting to see how we tie up a request that is queued to
> the frame index that it will capture from. I think it works out in the


Discussion is under progress. Either we can tie up Request sequence with 
frame number

OR

for the HAL case, the Camera3RequestDescriptor gets a frame number/id 
from the framework. I am keen to use that too but for non-HAL cases it 
won't suffice (or I need to develop an alternative mechanism)

https://git.libcamera.org/libcamera/libcamera.git/tree/include/android/hardware/libhardware/include/hardware/camera3.h#n2228


> end, as long as we ensure that requests are queued before we start the
> camera ...
>
> (and now I can't recall, do we support starting the camera without
> requests queued?...)


Initially we dont.

But if there is a start/stop sequence, I think on next start, the 
request already queued will get satisfied first?

>
>
>>   {
>>          /* \todo Start processing for 'frame' based on 'controls'. */
>> +
>> +       frameStarted(frame);
>>   }
>>   
>>   /**
>> @@ -620,6 +638,8 @@ void IPAIPU3::parseStatistics(unsigned int frame,
>>           */
>>   
>>          statsBufferReady.emit(frame, ctrls);
>> +
>> +       frameCompleted(frame);
>>   }
>>   
>>   /**
>> -- 
>> 2.31.0
>>

Patch
diff mbox series

diff --git a/src/ipa/ipu3/ipu3.cpp b/src/ipa/ipu3/ipu3.cpp
index 81788b9a..3d5c5706 100644
--- a/src/ipa/ipu3/ipu3.cpp
+++ b/src/ipa/ipu3/ipu3.cpp
@@ -163,6 +163,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(const uint32_t frame);
+	void frameCompleted(const uint32_t frame);
+
 	std::map<unsigned int, MappedFrameBuffer> buffers_;
 
 	ControlInfoMap ctrls_;
@@ -491,6 +499,14 @@  void IPAIPU3::unmapBuffers(const std::vector<unsigned int> &ids)
 	}
 }
 
+void IPAIPU3::frameStarted([[maybe_unused]] const uint32_t frame)
+{
+}
+
+void IPAIPU3::frameCompleted([[maybe_unused]] const uint32_t frame)
+{
+}
+
 /**
  * \brief Prepare the ISP to process the Request
  * \param[in] frame The frame number
@@ -549,6 +565,8 @@  void IPAIPU3::processControls(const uint32_t frame,
 			      [[maybe_unused]] const ControlList &controls)
 {
 	/* \todo Start processing for 'frame' based on 'controls'. */
+
+	frameStarted(frame);
 }
 
 /**
@@ -620,6 +638,8 @@  void IPAIPU3::parseStatistics(unsigned int frame,
 	 */
 
 	statsBufferReady.emit(frame, ctrls);
+
+	frameCompleted(frame);
 }
 
 /**