From 299e5278bd7657c785b7adac0c4f02d7e42f22c2 Mon Sep 17 00:00:00 2001
From: Naushir Patuck <naush@raspberrypi.com>
Date: Fri, 26 Apr 2024 12:18:15 +0100
Subject: ipa: rpi: Fix for incorrectly reported max shutter speed

The maximum shutter speed calculation in the cam-helper relied on
the frame duration limits being correctly set in the cam-helper's mode
structure. This was not the case on first startup, so the maximum
shutter speed reported back via the ControlInfo was incorrect.

Fix this by setting up the camera mode in the cam-helper before querying
for the max shutter value.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: David Plowman <david.plowman@raspberrypi.com>
Acked-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
---
 src/ipa/rpi/common/ipa_base.cpp | 6 ++++++
 1 file changed, 6 insertions(+)

(limited to 'src/ipa')

diff --git a/src/ipa/rpi/common/ipa_base.cpp b/src/ipa/rpi/common/ipa_base.cpp
index 293f3f16..31b7985e 100644
--- a/src/ipa/rpi/common/ipa_base.cpp
+++ b/src/ipa/rpi/common/ipa_base.cpp
@@ -586,6 +586,12 @@ void IpaBase::setMode(const IPACameraSensorInfo &sensorInfo)
 	mode_.minAnalogueGain = helper_->gain(gainCtrl.min().get<int32_t>());
 	mode_.maxAnalogueGain = helper_->gain(gainCtrl.max().get<int32_t>());
 
+	/*
+	 * We need to give the helper the min/max frame durations so it can calculate
+	 * the correct exposure limits below.
+	 */
+	helper_->setCameraMode(mode_);
+
 	/* Shutter speed is calculated based on the limits of the frame durations. */
 	mode_.minShutter = helper_->exposure(shutterCtrl.min().get<int32_t>(), mode_.minLineLength);
 	mode_.maxShutter = Duration::max();
-- 
cgit v1.2.1