[v3,1/4] ipa: rkisp1: algorithms: agc: Check for correct stats type
diff mbox series

Message ID 20241018153116.925892-2-stefan.klug@ideasonboard.com
State Superseded
Headers show
Series
  • A few small fixes
Related show

Commit Message

Stefan Klug Oct. 18, 2024, 3:30 p.m. UTC
Sometimes the ISP produces statistics only with a subset of statistic
types being valid. It doesn't happen normally, but was observed in the
wild. Check for the RKISP1_CIF_ISP_STAT_AUTOEXP bit to prevent using
invalid or outdated data. As it doesn't happen regularly add an error
message to get notified when it happens.

Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>

---
Changes in v3:
- Split check for stats and type, to silence messages in raw mode

Changes in v2:
- Added error message
- Made condition more readable
- Collected tags
---
 src/ipa/rkisp1/algorithms/agc.cpp | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Comments

Laurent Pinchart Oct. 18, 2024, 3:50 p.m. UTC | #1
On Fri, Oct 18, 2024 at 05:30:57PM +0200, Stefan Klug wrote:
> Sometimes the ISP produces statistics only with a subset of statistic
> types being valid. It doesn't happen normally, but was observed in the
> wild. Check for the RKISP1_CIF_ISP_STAT_AUTOEXP bit to prevent using
> invalid or outdated data. As it doesn't happen regularly add an error
> message to get notified when it happens.
> 
> Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>
> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
> 
> ---
> Changes in v3:
> - Split check for stats and type, to silence messages in raw mode
> 
> Changes in v2:
> - Added error message
> - Made condition more readable
> - Collected tags
> ---
>  src/ipa/rkisp1/algorithms/agc.cpp | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/src/ipa/rkisp1/algorithms/agc.cpp b/src/ipa/rkisp1/algorithms/agc.cpp
> index 17d074d9c03e..281c404902a0 100644
> --- a/src/ipa/rkisp1/algorithms/agc.cpp
> +++ b/src/ipa/rkisp1/algorithms/agc.cpp
> @@ -402,6 +402,11 @@ void Agc::process(IPAContext &context, [[maybe_unused]] const uint32_t frame,
>  		fillMetadata(context, frameContext, metadata);
>  		return;
>  	}
> +	
> +	if (!(stats->meas_type & RKISP1_CIF_ISP_STAT_AUTOEXP)) {
> +		LOG(RkISP1Agc, Error) << "AUTOEXP data is missing in statistics";

No need to call fillMetadata() here ?

> +		return;
> +	}
>  
>  	/*
>  	 * \todo Verify that the exposure and gain applied by the sensor for
> @@ -412,7 +417,6 @@ void Agc::process(IPAContext &context, [[maybe_unused]] const uint32_t frame,
>  	 */
>  
>  	const rkisp1_cif_isp_stat *params = &stats->params;
> -	ASSERT(stats->meas_type & RKISP1_CIF_ISP_STAT_AUTOEXP);
>  
>  	/* The lower 4 bits are fractional and meant to be discarded. */
>  	Histogram hist({ params->hist.hist_bins, context.hw->numHistogramBins },

Patch
diff mbox series

diff --git a/src/ipa/rkisp1/algorithms/agc.cpp b/src/ipa/rkisp1/algorithms/agc.cpp
index 17d074d9c03e..281c404902a0 100644
--- a/src/ipa/rkisp1/algorithms/agc.cpp
+++ b/src/ipa/rkisp1/algorithms/agc.cpp
@@ -402,6 +402,11 @@  void Agc::process(IPAContext &context, [[maybe_unused]] const uint32_t frame,
 		fillMetadata(context, frameContext, metadata);
 		return;
 	}
+	
+	if (!(stats->meas_type & RKISP1_CIF_ISP_STAT_AUTOEXP)) {
+		LOG(RkISP1Agc, Error) << "AUTOEXP data is missing in statistics";
+		return;
+	}
 
 	/*
 	 * \todo Verify that the exposure and gain applied by the sensor for
@@ -412,7 +417,6 @@  void Agc::process(IPAContext &context, [[maybe_unused]] const uint32_t frame,
 	 */
 
 	const rkisp1_cif_isp_stat *params = &stats->params;
-	ASSERT(stats->meas_type & RKISP1_CIF_ISP_STAT_AUTOEXP);
 
 	/* The lower 4 bits are fractional and meant to be discarded. */
 	Histogram hist({ params->hist.hist_bins, context.hw->numHistogramBins },