[v6,16/24] ipa: libipa: agc: Better respect frame duration limits
diff mbox series

Message ID 20261102101610.877390-17-barnabas.pocze@ideasonboard.com
State New
Headers show
Series
  • ipa: libipa: agc: Take exposure margin into account
Related show

Commit Message

Barnabás Pőcze Nov. 2, 2026, 10:16 a.m. UTC
Only frame durations that are multiples of the line duration are possible,
and currently it is possible that a smaller frame duration is selected
even if a frame duration satisfying the requested limits is available.

This is caused by the float -> integer truncation during the calculation. For
(an unrealistic) example, if the exposure time is 24ms, the min frame duration
is 33ms, and the line duration is 2ms, then 32ms will be used as the frame
duration even if e.g. 34 would be allowed by the max frame duration.

So round the result to ensure that if not prevented by the max frame duration
then a value that satisfies the limits is selected.

Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
---
 src/ipa/libipa/agc.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Patch
diff mbox series

diff --git a/src/ipa/libipa/agc.cpp b/src/ipa/libipa/agc.cpp
index 127b4893fd..f40f4b0947 100644
--- a/src/ipa/libipa/agc.cpp
+++ b/src/ipa/libipa/agc.cpp
@@ -1154,7 +1154,8 @@  void AgcAlgorithm::processFrameDuration(const agc::Session &session,
 	 * the minimum frame duration when we have short exposures.
 	 */
 	const auto frameLength = std::max<uint32_t>(
-		frameContext.minFrameDuration / lineDuration,
+		std::min(std::ceil(frameContext.minFrameDuration / lineDuration),
+			 frameContext.maxFrameDuration / lineDuration),
 		frameContext.exposure);
 
 	frameContext.vblank = frameLength - session.sensor.outputSize.height;