[libcamera-devel,v2,10/10] ipa: libipa: algorithm: queueRequest(): Pass frame context
diff mbox series

Message ID 20220805135312.47497-11-jacopo@jmondi.org
State Accepted
Headers show
Series
  • libcamera: Align IPU3 and RKISP1 interfaces
Related show

Commit Message

Jacopo Mondi Aug. 5, 2022, 1:53 p.m. UTC
From: Kieran Bingham via libcamera-devel <libcamera-devel@lists.libcamera.org>

Pass the current FrameContext for calls to queueRequest().

Now that both the IPU3 and RkISP1 IPA modules comply with the same
interface, propagate the queueRequest() call to algorithms in the IPU3
IPA module.

Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
---
 src/ipa/ipu3/ipu3.cpp                | 5 ++---
 src/ipa/libipa/algorithm.cpp         | 1 +
 src/ipa/libipa/algorithm.h           | 1 +
 src/ipa/rkisp1/algorithms/cproc.cpp  | 1 +
 src/ipa/rkisp1/algorithms/cproc.h    | 1 +
 src/ipa/rkisp1/algorithms/filter.cpp | 1 +
 src/ipa/rkisp1/algorithms/filter.h   | 1 +
 src/ipa/rkisp1/rkisp1.cpp            | 4 +++-
 8 files changed, 11 insertions(+), 4 deletions(-)

Comments

Umang Jain Aug. 11, 2022, 7:19 a.m. UTC | #1
Hi Jacopo

thank you for the patch.

On 8/5/22 19:23, Jacopo Mondi via libcamera-devel wrote:
> From: Kieran Bingham via libcamera-devel <libcamera-devel@lists.libcamera.org>
>
> Pass the current FrameContext for calls to queueRequest().
>
> Now that both the IPU3 and RkISP1 IPA modules comply with the same
> interface, propagate the queueRequest() call to algorithms in the IPU3
> IPA module.


I feel a bit more expansion of rationale, on why do we need to propagate 
frameContexts to queueRequest() would be nice in the commit message.

Maybe something on the lines:

"""
queueRequest() already has access to incoming Request's controls and 
might decide
to populate frame context at initialization time (during parsing the 
controls).
As each algorithm is expected to have ownership of certain set of 
controls (<some eg.s>),
hence it should have access to the frame context to populate it for 
future usage.
"""


>
> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>


Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>

> ---
>   src/ipa/ipu3/ipu3.cpp                | 5 ++---
>   src/ipa/libipa/algorithm.cpp         | 1 +
>   src/ipa/libipa/algorithm.h           | 1 +
>   src/ipa/rkisp1/algorithms/cproc.cpp  | 1 +
>   src/ipa/rkisp1/algorithms/cproc.h    | 1 +
>   src/ipa/rkisp1/algorithms/filter.cpp | 1 +
>   src/ipa/rkisp1/algorithms/filter.h   | 1 +
>   src/ipa/rkisp1/rkisp1.cpp            | 4 +++-
>   8 files changed, 11 insertions(+), 4 deletions(-)
>
> diff --git a/src/ipa/ipu3/ipu3.cpp b/src/ipa/ipu3/ipu3.cpp
> index da4d416b6aef..e033891a9341 100644
> --- a/src/ipa/ipu3/ipu3.cpp
> +++ b/src/ipa/ipu3/ipu3.cpp
> @@ -622,9 +622,8 @@ void IPAIPU3::queueRequest(const uint32_t frame, const ControlList &controls)
>   	/* \todo Start processing for 'frame' based on 'controls'. */
>   	IPU3FrameContext &frameContext = context_.frameContexts.initialise(frame);
>   
> -	/* \todo Implement queueRequest to each algorithm. */
> -	(void)frameContext;
> -	(void)controls;
> +	for (auto const &algo : algorithms_)
> +		algo->queueRequest(context_, frame, frameContext, controls);
>   }
>   
>   /**
> diff --git a/src/ipa/libipa/algorithm.cpp b/src/ipa/libipa/algorithm.cpp
> index 30eab67f71fc..c152b885aee1 100644
> --- a/src/ipa/libipa/algorithm.cpp
> +++ b/src/ipa/libipa/algorithm.cpp
> @@ -88,6 +88,7 @@ namespace ipa {
>    * \brief Provide control values to the algorithm
>    * \param[in] context The shared IPA context
>    * \param[in] frame The frame number to apply the control values
> + * \param[in] frameContext The current frame's context
>    * \param[in] controls The list of user controls
>    *
>    * This function is called for each request queued to the camera. It provides
> diff --git a/src/ipa/libipa/algorithm.h b/src/ipa/libipa/algorithm.h
> index c2d990707b25..f92829ad7ac6 100644
> --- a/src/ipa/libipa/algorithm.h
> +++ b/src/ipa/libipa/algorithm.h
> @@ -46,6 +46,7 @@ public:
>   
>   	virtual void queueRequest([[maybe_unused]] typename Module::Context &context,
>   				  [[maybe_unused]] const uint32_t frame,
> +				  [[maybe_unused]] typename Module::FrameContext &frameContext,
>   				  [[maybe_unused]] const ControlList &controls)
>   	{
>   	}
> diff --git a/src/ipa/rkisp1/algorithms/cproc.cpp b/src/ipa/rkisp1/algorithms/cproc.cpp
> index edaf2d10e850..c0792926f9eb 100644
> --- a/src/ipa/rkisp1/algorithms/cproc.cpp
> +++ b/src/ipa/rkisp1/algorithms/cproc.cpp
> @@ -38,6 +38,7 @@ LOG_DEFINE_CATEGORY(RkISP1CProc)
>    */
>   void ColorProcessing::queueRequest(IPAContext &context,
>   				   [[maybe_unused]] const uint32_t frame,
> +				   [[maybe_unused]] RKISP1FrameContext &frameContext,
>   				   const ControlList &controls)
>   {
>   	auto &cproc = context.activeState.cproc;
> diff --git a/src/ipa/rkisp1/algorithms/cproc.h b/src/ipa/rkisp1/algorithms/cproc.h
> index fde83f3c965c..13f8967e70a8 100644
> --- a/src/ipa/rkisp1/algorithms/cproc.h
> +++ b/src/ipa/rkisp1/algorithms/cproc.h
> @@ -22,6 +22,7 @@ public:
>   	~ColorProcessing() = default;
>   
>   	void queueRequest(IPAContext &context, const uint32_t frame,
> +			  RKISP1FrameContext &frameContext,
>   			  const ControlList &controls) override;
>   	void prepare(IPAContext &context, unsigned int frame,
>   		     RKISP1FrameContext &frameContext,
> diff --git a/src/ipa/rkisp1/algorithms/filter.cpp b/src/ipa/rkisp1/algorithms/filter.cpp
> index f6577046442a..8c5af213d6d0 100644
> --- a/src/ipa/rkisp1/algorithms/filter.cpp
> +++ b/src/ipa/rkisp1/algorithms/filter.cpp
> @@ -44,6 +44,7 @@ static constexpr uint32_t kFiltModeDefault = 0x000004f2;
>    */
>   void Filter::queueRequest(IPAContext &context,
>   			  [[maybe_unused]] const uint32_t frame,
> +			  [[maybe_unused]] RKISP1FrameContext &frameContext,
>   			  const ControlList &controls)
>   {
>   	auto &filter = context.activeState.filter;
> diff --git a/src/ipa/rkisp1/algorithms/filter.h b/src/ipa/rkisp1/algorithms/filter.h
> index 1fbe785a3cab..b10efa208a48 100644
> --- a/src/ipa/rkisp1/algorithms/filter.h
> +++ b/src/ipa/rkisp1/algorithms/filter.h
> @@ -22,6 +22,7 @@ public:
>   	~Filter() = default;
>   
>   	void queueRequest(IPAContext &context, const uint32_t frame,
> +			  RKISP1FrameContext &frameContext,
>   			  const ControlList &controls) override;
>   	void prepare(IPAContext &context, unsigned int frame,
>   		     RKISP1FrameContext &frameContext,
> diff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp
> index 9af8217c3b8a..548bbd202cfb 100644
> --- a/src/ipa/rkisp1/rkisp1.cpp
> +++ b/src/ipa/rkisp1/rkisp1.cpp
> @@ -296,8 +296,10 @@ void IPARkISP1::unmapBuffers(const std::vector<unsigned int> &ids)
>   
>   void IPARkISP1::queueRequest(const uint32_t frame, const ControlList &controls)
>   {
> +	RKISP1FrameContext &frameContext = context_.frameContexts.initialise(frame);
> +
>   	for (auto const &algo : algorithms())
> -		algo->queueRequest(context_, frame, controls);
> +		algo->queueRequest(context_, frame, frameContext, controls);
>   }
>   
>   void IPARkISP1::fillParamsBuffer(const uint32_t frame, const uint32_t bufferId)

Patch
diff mbox series

diff --git a/src/ipa/ipu3/ipu3.cpp b/src/ipa/ipu3/ipu3.cpp
index da4d416b6aef..e033891a9341 100644
--- a/src/ipa/ipu3/ipu3.cpp
+++ b/src/ipa/ipu3/ipu3.cpp
@@ -622,9 +622,8 @@  void IPAIPU3::queueRequest(const uint32_t frame, const ControlList &controls)
 	/* \todo Start processing for 'frame' based on 'controls'. */
 	IPU3FrameContext &frameContext = context_.frameContexts.initialise(frame);
 
-	/* \todo Implement queueRequest to each algorithm. */
-	(void)frameContext;
-	(void)controls;
+	for (auto const &algo : algorithms_)
+		algo->queueRequest(context_, frame, frameContext, controls);
 }
 
 /**
diff --git a/src/ipa/libipa/algorithm.cpp b/src/ipa/libipa/algorithm.cpp
index 30eab67f71fc..c152b885aee1 100644
--- a/src/ipa/libipa/algorithm.cpp
+++ b/src/ipa/libipa/algorithm.cpp
@@ -88,6 +88,7 @@  namespace ipa {
  * \brief Provide control values to the algorithm
  * \param[in] context The shared IPA context
  * \param[in] frame The frame number to apply the control values
+ * \param[in] frameContext The current frame's context
  * \param[in] controls The list of user controls
  *
  * This function is called for each request queued to the camera. It provides
diff --git a/src/ipa/libipa/algorithm.h b/src/ipa/libipa/algorithm.h
index c2d990707b25..f92829ad7ac6 100644
--- a/src/ipa/libipa/algorithm.h
+++ b/src/ipa/libipa/algorithm.h
@@ -46,6 +46,7 @@  public:
 
 	virtual void queueRequest([[maybe_unused]] typename Module::Context &context,
 				  [[maybe_unused]] const uint32_t frame,
+				  [[maybe_unused]] typename Module::FrameContext &frameContext,
 				  [[maybe_unused]] const ControlList &controls)
 	{
 	}
diff --git a/src/ipa/rkisp1/algorithms/cproc.cpp b/src/ipa/rkisp1/algorithms/cproc.cpp
index edaf2d10e850..c0792926f9eb 100644
--- a/src/ipa/rkisp1/algorithms/cproc.cpp
+++ b/src/ipa/rkisp1/algorithms/cproc.cpp
@@ -38,6 +38,7 @@  LOG_DEFINE_CATEGORY(RkISP1CProc)
  */
 void ColorProcessing::queueRequest(IPAContext &context,
 				   [[maybe_unused]] const uint32_t frame,
+				   [[maybe_unused]] RKISP1FrameContext &frameContext,
 				   const ControlList &controls)
 {
 	auto &cproc = context.activeState.cproc;
diff --git a/src/ipa/rkisp1/algorithms/cproc.h b/src/ipa/rkisp1/algorithms/cproc.h
index fde83f3c965c..13f8967e70a8 100644
--- a/src/ipa/rkisp1/algorithms/cproc.h
+++ b/src/ipa/rkisp1/algorithms/cproc.h
@@ -22,6 +22,7 @@  public:
 	~ColorProcessing() = default;
 
 	void queueRequest(IPAContext &context, const uint32_t frame,
+			  RKISP1FrameContext &frameContext,
 			  const ControlList &controls) override;
 	void prepare(IPAContext &context, unsigned int frame,
 		     RKISP1FrameContext &frameContext,
diff --git a/src/ipa/rkisp1/algorithms/filter.cpp b/src/ipa/rkisp1/algorithms/filter.cpp
index f6577046442a..8c5af213d6d0 100644
--- a/src/ipa/rkisp1/algorithms/filter.cpp
+++ b/src/ipa/rkisp1/algorithms/filter.cpp
@@ -44,6 +44,7 @@  static constexpr uint32_t kFiltModeDefault = 0x000004f2;
  */
 void Filter::queueRequest(IPAContext &context,
 			  [[maybe_unused]] const uint32_t frame,
+			  [[maybe_unused]] RKISP1FrameContext &frameContext,
 			  const ControlList &controls)
 {
 	auto &filter = context.activeState.filter;
diff --git a/src/ipa/rkisp1/algorithms/filter.h b/src/ipa/rkisp1/algorithms/filter.h
index 1fbe785a3cab..b10efa208a48 100644
--- a/src/ipa/rkisp1/algorithms/filter.h
+++ b/src/ipa/rkisp1/algorithms/filter.h
@@ -22,6 +22,7 @@  public:
 	~Filter() = default;
 
 	void queueRequest(IPAContext &context, const uint32_t frame,
+			  RKISP1FrameContext &frameContext,
 			  const ControlList &controls) override;
 	void prepare(IPAContext &context, unsigned int frame,
 		     RKISP1FrameContext &frameContext,
diff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp
index 9af8217c3b8a..548bbd202cfb 100644
--- a/src/ipa/rkisp1/rkisp1.cpp
+++ b/src/ipa/rkisp1/rkisp1.cpp
@@ -296,8 +296,10 @@  void IPARkISP1::unmapBuffers(const std::vector<unsigned int> &ids)
 
 void IPARkISP1::queueRequest(const uint32_t frame, const ControlList &controls)
 {
+	RKISP1FrameContext &frameContext = context_.frameContexts.initialise(frame);
+
 	for (auto const &algo : algorithms())
-		algo->queueRequest(context_, frame, controls);
+		algo->queueRequest(context_, frame, frameContext, controls);
 }
 
 void IPARkISP1::fillParamsBuffer(const uint32_t frame, const uint32_t bufferId)