[v3,17/19] ipa: rkisp1: agc: Calculate frame duration using cam helper
diff mbox series

Message ID 20251114-exposure-limits-v3-17-b7c07feba026@ideasonboard.com
State New
Headers show
Series
  • libipa: agc: Calculate exposure limits
Related show

Commit Message

Jacopo Mondi Nov. 14, 2025, 2:17 p.m. UTC
The RkISP1 IPA is the only IPA that derives from AgcMeanLuminance
that populates the FrameDuration control.

The way frame duration is calculated is by using the shutter time
as returned by the Agc helpers and use that value to populate the
FrameDuration metadata and calculate the vblank.

This is however not correct as the exposure time shall be shorter than
the frame duration by a sensor-specific margin.

Use the camera sensor helper to calculate the minimum frame duration
required to achieve the newly calculated shutter time.

Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
---
 src/ipa/rkisp1/algorithms/agc.cpp | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

Patch
diff mbox series

diff --git a/src/ipa/rkisp1/algorithms/agc.cpp b/src/ipa/rkisp1/algorithms/agc.cpp
index a2ecd5c46a1fbcb728e23ed83b37b89fcdb80d84..10498eb6357d8917e299ac24f6c8ba8c33af4eae 100644
--- a/src/ipa/rkisp1/algorithms/agc.cpp
+++ b/src/ipa/rkisp1/algorithms/agc.cpp
@@ -501,21 +501,26 @@  double Agc::estimateLuminance(double gain) const
  * \brief Process frame duration and compute vblank
  * \param[in] context The shared IPA context
  * \param[in] frameContext The current frame context
- * \param[in] frameDuration The target frame duration
+ * \param[in] shutterTime The target shutter duration
  *
- * Compute and populate vblank from the target frame duration.
+ * Compute and populate vblank from a frame duration that allows to achieve the
+ * desired \a shutterTime
  */
 void Agc::processFrameDuration(IPAContext &context,
 			       IPAFrameContext &frameContext,
-			       utils::Duration frameDuration)
+			       utils::Duration shutterTime)
 {
-	IPACameraSensorInfo &sensorInfo = context.sensorInfo;
 	utils::Duration lineDuration = context.configuration.sensor.lineDuration;
+	utils::Duration frameDuration =
+		std::max(context.camHelper->minFrameDuration(shutterTime, lineDuration),
+			 context.activeState.agc.minFrameDuration);
 
-	frameContext.agc.vblank = (frameDuration / lineDuration) - sensorInfo.outputSize.height;
+	frameContext.agc.vblank = (frameDuration / lineDuration)
+				- context.sensorInfo.outputSize.height;
 
 	/* Update frame duration accounting for line length quantization. */
-	frameContext.agc.frameDuration = (sensorInfo.outputSize.height + frameContext.agc.vblank) * lineDuration;
+	frameContext.agc.frameDuration = (context.sensorInfo.outputSize.height
+				       + frameContext.agc.vblank) * lineDuration;
 }
 
 /**