[libcamera-devel,RFC,07/12] ipa: rkisp1: Convert to use the FCQueue
diff mbox series

Message ID 20220721121310.1286862-8-kieran.bingham@ideasonboard.com
State Superseded
Delegated to: Kieran Bingham
Headers show
Series
  • libcamera: Align IPU3 and RKISP1 interfaces
Related show

Commit Message

Kieran Bingham July 21, 2022, 12:13 p.m. UTC
Establish a queue of FrameContexts using the new FCQueue and use it to
supply the FrameContext to the algorithms.

The algorithms on the RKISP1 do not use this yet themselves, but are
able to do so after the introduction of this patch.

Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
---
 src/ipa/rkisp1/ipa_context.h | 2 ++
 src/ipa/rkisp1/rkisp1.cpp    | 9 +++++----
 2 files changed, 7 insertions(+), 4 deletions(-)

Comments

Umang Jain July 22, 2022, 9:06 p.m. UTC | #1
Hi Kieran,

On 7/21/22 17:43, Kieran Bingham via libcamera-devel wrote:
> Establish a queue of FrameContexts using the new FCQueue and use it to
> supply the FrameContext to the algorithms.
>
> The algorithms on the RKISP1 do not use this yet themselves, but are
> able to do so after the introduction of this patch.
>
> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
> ---
>   src/ipa/rkisp1/ipa_context.h | 2 ++
>   src/ipa/rkisp1/rkisp1.cpp    | 9 +++++----
>   2 files changed, 7 insertions(+), 4 deletions(-)
>
> diff --git a/src/ipa/rkisp1/ipa_context.h b/src/ipa/rkisp1/ipa_context.h
> index a64dbc75fdd2..dc4fa5d1ddba 100644
> --- a/src/ipa/rkisp1/ipa_context.h
> +++ b/src/ipa/rkisp1/ipa_context.h
> @@ -72,6 +72,8 @@ struct RKISP1FrameContext : public IPAFrameContext {
>   struct IPAContext {
>   	IPASessionConfiguration configuration;
>   	IPAActiveState activeState;
> +
> +	FCQueue<RKISP1FrameContext> frameContexts;
>   };
>   
>   } /* namespace ipa::rkisp1 */
> diff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp
> index 7481e67e70f6..a2b7b25a53e5 100644
> --- a/src/ipa/rkisp1/rkisp1.cpp
> +++ b/src/ipa/rkisp1/rkisp1.cpp
> @@ -205,7 +205,9 @@ int IPARkISP1::configure([[maybe_unused]] const IPACameraSensorInfo &info,
>   		<< " Gain: " << minGain << "-" << maxGain;
>   
>   	/* Clean context at configuration */
> -	context_ = {};
> +	context_.configuration = {};
> +	context_.activeState = {};
> +	context_.frameContexts.clear();


  stop() too needs this

>   
>   	/* Set the hardware revision for the algorithms. */
>   	context_.configuration.hw.revision = hwRevision_;
> @@ -290,6 +292,8 @@ void IPARkISP1::fillParamsBuffer(const uint32_t frame, const uint32_t bufferId)
>   void IPARkISP1::processStatsBuffer(const uint32_t frame, const uint32_t bufferId,
>   				   const ControlList &sensorControls)
>   {
> +	RKISP1FrameContext &frameContext = context_.frameContexts.get(frame);
> +
>   	const rkisp1_stat_buffer *stats =
>   		reinterpret_cast<rkisp1_stat_buffer *>(
>   			mappedBuffers_.at(bufferId).planes()[0].data());
> @@ -301,9 +305,6 @@ void IPARkISP1::processStatsBuffer(const uint32_t frame, const uint32_t bufferId
>   
>   	unsigned int aeState = 0;
>   
> -	/* \todo Obtain the frame context to pass to process from the FCQueue */
> -	RKISP1FrameContext frameContext;
> -
>   	for (auto const &algo : algorithms())
>   		algo->process(context_, frameContext, stats);
>

Patch
diff mbox series

diff --git a/src/ipa/rkisp1/ipa_context.h b/src/ipa/rkisp1/ipa_context.h
index a64dbc75fdd2..dc4fa5d1ddba 100644
--- a/src/ipa/rkisp1/ipa_context.h
+++ b/src/ipa/rkisp1/ipa_context.h
@@ -72,6 +72,8 @@  struct RKISP1FrameContext : public IPAFrameContext {
 struct IPAContext {
 	IPASessionConfiguration configuration;
 	IPAActiveState activeState;
+
+	FCQueue<RKISP1FrameContext> frameContexts;
 };
 
 } /* namespace ipa::rkisp1 */
diff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp
index 7481e67e70f6..a2b7b25a53e5 100644
--- a/src/ipa/rkisp1/rkisp1.cpp
+++ b/src/ipa/rkisp1/rkisp1.cpp
@@ -205,7 +205,9 @@  int IPARkISP1::configure([[maybe_unused]] const IPACameraSensorInfo &info,
 		<< " Gain: " << minGain << "-" << maxGain;
 
 	/* Clean context at configuration */
-	context_ = {};
+	context_.configuration = {};
+	context_.activeState = {};
+	context_.frameContexts.clear();
 
 	/* Set the hardware revision for the algorithms. */
 	context_.configuration.hw.revision = hwRevision_;
@@ -290,6 +292,8 @@  void IPARkISP1::fillParamsBuffer(const uint32_t frame, const uint32_t bufferId)
 void IPARkISP1::processStatsBuffer(const uint32_t frame, const uint32_t bufferId,
 				   const ControlList &sensorControls)
 {
+	RKISP1FrameContext &frameContext = context_.frameContexts.get(frame);
+
 	const rkisp1_stat_buffer *stats =
 		reinterpret_cast<rkisp1_stat_buffer *>(
 			mappedBuffers_.at(bufferId).planes()[0].data());
@@ -301,9 +305,6 @@  void IPARkISP1::processStatsBuffer(const uint32_t frame, const uint32_t bufferId
 
 	unsigned int aeState = 0;
 
-	/* \todo Obtain the frame context to pass to process from the FCQueue */
-	RKISP1FrameContext frameContext;
-
 	for (auto const &algo : algorithms())
 		algo->process(context_, frameContext, stats);