[v3] ipa: rkisp1: agc: Fix histogram construction
diff mbox series

Message ID 20240509114448.3685285-1-paul.elder@ideasonboard.com
State Accepted
Commit f1522e94dfaedcde26280eb6387f2c6f2de66fd7
Headers show
Series
  • [v3] ipa: rkisp1: agc: Fix histogram construction
Related show

Commit Message

Paul Elder May 9, 2024, 11:44 a.m. UTC
This histogram reported by the rkisp1 hardware is 20 bits, where the
upper 16 bits are meaningful integer data and the lower 4 bits are
fractional and meant to be discarded. Remove these 4 bits when
construction the histogram.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

---
Changes in v3:
- fix typo in commit message
- add comment explaining the shift

Changes in v2:
- use a lambda function instead of the rshift parameter
---
 src/ipa/rkisp1/algorithms/agc.cpp | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Patch
diff mbox series

diff --git a/src/ipa/rkisp1/algorithms/agc.cpp b/src/ipa/rkisp1/algorithms/agc.cpp
index 3e98496b..5aad5c7c 100644
--- a/src/ipa/rkisp1/algorithms/agc.cpp
+++ b/src/ipa/rkisp1/algorithms/agc.cpp
@@ -277,7 +277,9 @@  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);
 
-	Histogram hist({ params->hist.hist_bins, context.hw->numHistogramBins });
+	/* The lower 4 bits are fractional and meant to be discarded. */
+	Histogram hist({ params->hist.hist_bins, context.hw->numHistogramBins },
+		       [](uint32_t x) { return x >> 4; });
 	expMeans_ = { params->ae.exp_mean, context.hw->numAeCells };
 
 	/*