From 3bc722b5da0dd32fe848505958a644705a946ae7 Mon Sep 17 00:00:00 2001 From: David Plowman Date: Thu, 23 Oct 2025 12:49:15 +0100 Subject: [PATCH] ipa: rpi: pisp: Use a floating region to get whole image Y statistics Floating regions are currently unused on the PiSP platform, so we can use one of them to get an average Y value for the whole image. If an algorithm (such as the "lux" algorithm) wants a scene-referred estimate of absolute brightness, then this would be a better choice than a value from Y histogram as the latter is not invariant to the metering mode (e.g. centre-weighted, spot etc.). (So note that for the AGC/AEC algorithm, where the metering mode is relevant, the Y histogram is the appropriate choice.) We also fix the loop that copies the hardware's floating region values into our statistics structure; it was using the wrong limit which was causing it not to do anything. A future commit will update the lux algorithm to use this feature. Signed-off-by: David Plowman Reviewed-by: Stefan Klug Reviewed-by: Naushir Patuck Signed-off-by: Kieran Bingham --- src/ipa/rpi/pisp/pisp.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/ipa/rpi/pisp/pisp.cpp b/src/ipa/rpi/pisp/pisp.cpp index 01baebcd..ec7593ff 100644 --- a/src/ipa/rpi/pisp/pisp.cpp +++ b/src/ipa/rpi/pisp/pisp.cpp @@ -533,7 +533,7 @@ RPiController::StatisticsPtr IpaPiSP::platformProcessStats(Span mem) /* AGC region sums only get collected on floating zones. */ statistics->agcRegions.init({ 0, 0 }, PISP_FLOATING_STATS_NUM_ZONES); - for (i = 0; i < statistics->agcRegions.numRegions(); i++) + for (i = 0; i < PISP_FLOATING_STATS_NUM_ZONES; i++) statistics->agcRegions.setFloating(i, { { 0, 0, 0, stats->agc.floating[i].Y_sum }, stats->agc.floating[i].counted, 0 }); @@ -1075,6 +1075,12 @@ void IpaPiSP::setStatsAndDebin() */ setHistogramWeights(); + /* Configure the first AGC floating region to cover the whole image, for the lux algo. */ + pisp_fe_floating_stats_config floatingStatsConfig = {}; + floatingStatsConfig.regions[0].size_x = mode_.width; + floatingStatsConfig.regions[0].size_y = mode_.height; + fe_->SetFloatingStats(floatingStatsConfig); + pisp_be_global_config beGlobal; be_->GetGlobal(beGlobal);