[libcamera-devel,v3,12/17] ipa: ipu3: Compute line duration at configure() time
diff mbox series

Message ID 20220818094410.1671-13-jacopo@jmondi.org
State New
Headers show
Series
  • libcamera: Align IPU3 and RKISP1 interfaces
Related show

Commit Message

Jacopo Mondi Aug. 18, 2022, 9:44 a.m. UTC
The IPU3 IPA module computes the sensor line duration at initialization
time only. As the sensor line duration varies according to the applied
configuration, re-compute it at IPA::configure() time as well.

While at it, remove the initialization of lineDuration_ from IPA::init()
as it only generates confusion to see it there.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
---
 src/ipa/ipu3/ipu3.cpp | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

Patch
diff mbox series

diff --git a/src/ipa/ipu3/ipu3.cpp b/src/ipa/ipu3/ipu3.cpp
index eabf179aaa0a..077cf8050508 100644
--- a/src/ipa/ipu3/ipu3.cpp
+++ b/src/ipa/ipu3/ipu3.cpp
@@ -164,7 +164,7 @@  private:
 	void updateControls(const IPACameraSensorInfo &sensorInfo,
 			    const ControlInfoMap &sensorControls,
 			    ControlInfoMap *ipaControls);
-	void updateSessionConfiguration(const ControlInfoMap &sensorControls);
+	void updateSessionConfiguration(const IPAConfigInfo &configInfo);
 
 	bool validateSensorControls();
 
@@ -194,8 +194,11 @@  std::string IPAIPU3::logPrefix() const
  * \brief Compute IPASessionConfiguration using the sensor information and the
  * sensor V4L2 controls
  */
-void IPAIPU3::updateSessionConfiguration(const ControlInfoMap &sensorControls)
+void IPAIPU3::updateSessionConfiguration(const IPAConfigInfo &configInfo)
 {
+	const IPACameraSensorInfo &sensorInfo = configInfo.sensorInfo;
+	const ControlInfoMap &sensorControls = configInfo.sensorControls;
+
 	const ControlInfo vBlank = sensorControls.find(V4L2_CID_VBLANK)->second;
 	context_.configuration.sensor.defVBlank = vBlank.def().get<int32_t>();
 
@@ -218,6 +221,8 @@  void IPAIPU3::updateSessionConfiguration(const ControlInfoMap &sensorControls)
 	 *
 	 * \todo take VBLANK into account for maximum shutter speed
 	 */
+	context_.configuration.sensor.lineDuration = sensorInfo.lineLength * 1.0s
+						   / sensorInfo.pixelRate;
 	context_.configuration.agc.minShutterSpeed = minExposure * context_.configuration.sensor.lineDuration;
 	context_.configuration.agc.maxShutterSpeed = maxExposure * context_.configuration.sensor.lineDuration;
 	context_.configuration.agc.minAnalogueGain = camHelper_->gain(minGain);
@@ -330,7 +335,6 @@  int IPAIPU3::init(const IPASettings &settings,
 
 	/* Clean context */
 	context_.configuration = {};
-	context_.configuration.sensor.lineDuration = sensorInfo.lineLength * 1.0s / sensorInfo.pixelRate;
 
 	/* Load the tuning data file. */
 	File file(settings.configurationFile.c_str());
@@ -504,7 +508,7 @@  int IPAIPU3::configure(const IPAConfigInfo &configInfo,
 	updateControls(sensorInfo_, sensorCtrls_, ipaControls);
 
 	/* Update the IPASessionConfiguration using the sensor settings. */
-	updateSessionConfiguration(sensorCtrls_);
+	updateSessionConfiguration(configInfo);
 
 	for (auto const &algo : algorithms()) {
 		int ret = algo->configure(context_, configInfo);