[RFC,v4,15/23] ipa: libipa: agc: Better respect frame duration limits
diff mbox series

Message ID 20261026132045.269007-16-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 Oct. 26, 2026, 1:20 p.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>
---
 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 40cc4e26d0..af5c179db6 100644
--- a/src/ipa/libipa/agc.cpp
+++ b/src/ipa/libipa/agc.cpp
@@ -1107,7 +1107,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;