[v1] ipa: rkisp1: Handle missing histogram
diff mbox series

Message ID 20261124091108.1068218-1-barnabas.pocze@ideasonboard.com
State New
Headers show
Series
  • [v1] ipa: rkisp1: Handle missing histogram
Related show

Commit Message

Barnabás Pőcze Nov. 24, 2026, 9:11 a.m. UTC
Check if a valid histogram is actually contained in the statistics,
and skip processing if not.

Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
---
 src/ipa/rkisp1/algorithms/agc.cpp | 5 +++--
 src/ipa/rkisp1/algorithms/lux.cpp | 2 +-
 2 files changed, 4 insertions(+), 3 deletions(-)

Comments

Laurent Pinchart Nov. 24, 2026, 9:54 a.m. UTC | #1
On Tue, Nov 24, 2026 at 10:11:08AM +0100, Barnabás Pőcze wrote:
> Check if a valid histogram is actually contained in the statistics,
> and skip processing if not.

This is something we should fix in the kernel at some point. The
interrupts handler are racy, that's why we get statistics buffers
without all blocks. I fear it may also cause us to receive statistics
calculated on the previous frame once in a while.

In the meantime, this patch looks reasonable.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
> ---
>  src/ipa/rkisp1/algorithms/agc.cpp | 5 +++--
>  src/ipa/rkisp1/algorithms/lux.cpp | 2 +-
>  2 files changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/src/ipa/rkisp1/algorithms/agc.cpp b/src/ipa/rkisp1/algorithms/agc.cpp
> index 1c323ede87..bdc78a9ff6 100644
> --- a/src/ipa/rkisp1/algorithms/agc.cpp
> +++ b/src/ipa/rkisp1/algorithms/agc.cpp
> @@ -355,10 +355,11 @@ void Agc::process(IPAContext &context, [[maybe_unused]] const uint32_t frame,
>  	const rkisp1_cif_isp_stat *params = nullptr;
>  
>  	if (stats) {
> -		if (stats->meas_type & RKISP1_CIF_ISP_STAT_AUTOEXP)
> +		if ((stats->meas_type & RKISP1_CIF_ISP_STAT_AUTOEXP) &&
> +		    (stats->meas_type & RKISP1_CIF_ISP_STAT_HIST))
>  			params = &stats->params;
>  		else
> -			LOG(RkISP1Agc, Error) << "AUTOEXP data is missing in statistics";
> +			LOG(RkISP1Agc, Error) << "AUTOEXP / HIST data is missing in statistics";
>  	}
>  
>  	if (params) {
> diff --git a/src/ipa/rkisp1/algorithms/lux.cpp b/src/ipa/rkisp1/algorithms/lux.cpp
> index 5f47ce37eb..70062b79ba 100644
> --- a/src/ipa/rkisp1/algorithms/lux.cpp
> +++ b/src/ipa/rkisp1/algorithms/lux.cpp
> @@ -58,7 +58,7 @@ void Lux::process(IPAContext &context,
>  		  const rkisp1_stat_buffer *stats,
>  		  ControlList &metadata)
>  {
> -	if (!stats) {
> +	if (!stats || !(stats->meas_type & RKISP1_CIF_ISP_STAT_HIST)) {
>  		lux_.process(context.activeState.lux, frameContext.lux, metadata, {});
>  		return;
>  	}

Patch
diff mbox series

diff --git a/src/ipa/rkisp1/algorithms/agc.cpp b/src/ipa/rkisp1/algorithms/agc.cpp
index 1c323ede87..bdc78a9ff6 100644
--- a/src/ipa/rkisp1/algorithms/agc.cpp
+++ b/src/ipa/rkisp1/algorithms/agc.cpp
@@ -355,10 +355,11 @@  void Agc::process(IPAContext &context, [[maybe_unused]] const uint32_t frame,
 	const rkisp1_cif_isp_stat *params = nullptr;
 
 	if (stats) {
-		if (stats->meas_type & RKISP1_CIF_ISP_STAT_AUTOEXP)
+		if ((stats->meas_type & RKISP1_CIF_ISP_STAT_AUTOEXP) &&
+		    (stats->meas_type & RKISP1_CIF_ISP_STAT_HIST))
 			params = &stats->params;
 		else
-			LOG(RkISP1Agc, Error) << "AUTOEXP data is missing in statistics";
+			LOG(RkISP1Agc, Error) << "AUTOEXP / HIST data is missing in statistics";
 	}
 
 	if (params) {
diff --git a/src/ipa/rkisp1/algorithms/lux.cpp b/src/ipa/rkisp1/algorithms/lux.cpp
index 5f47ce37eb..70062b79ba 100644
--- a/src/ipa/rkisp1/algorithms/lux.cpp
+++ b/src/ipa/rkisp1/algorithms/lux.cpp
@@ -58,7 +58,7 @@  void Lux::process(IPAContext &context,
 		  const rkisp1_stat_buffer *stats,
 		  ControlList &metadata)
 {
-	if (!stats) {
+	if (!stats || !(stats->meas_type & RKISP1_CIF_ISP_STAT_HIST)) {
 		lux_.process(context.activeState.lux, frameContext.lux, metadata, {});
 		return;
 	}