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

Message ID 20241018160638.936993-2-stefan.klug@ideasonboard.com
State Accepted
Commit 0e0e32b1890c97343ade0f91cb643a1c4da9064f
Headers show
Series
  • A few small fixes
Related show

Commit Message

Stefan Klug Oct. 18, 2024, 4:06 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 v4:
- Fix missing fillMetadata introduced in v3.

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 | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

Patch
diff mbox series

diff --git a/src/ipa/rkisp1/algorithms/agc.cpp b/src/ipa/rkisp1/algorithms/agc.cpp
index 17d074d9c03e..301b7ec26508 100644
--- a/src/ipa/rkisp1/algorithms/agc.cpp
+++ b/src/ipa/rkisp1/algorithms/agc.cpp
@@ -402,6 +402,12 @@  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)) {
+		fillMetadata(context, frameContext, metadata);
+		LOG(RkISP1Agc, Error) << "AUTOEXP data is missing in statistics";
+		return;
+	}
 
 	/*
 	 * \todo Verify that the exposure and gain applied by the sensor for
@@ -412,7 +418,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 },