[libcamera-devel,12/15] libcamera: ipa: Use the current VBLANK value
diff mbox series

Message ID 20220627162732.33160-13-jacopo@jmondi.org
State Not Applicable, archived
Headers show
Series
  • Internal controls, sensor delays and IPA init/configure rework
Related show

Commit Message

Jacopo Mondi June 27, 2022, 4:27 p.m. UTC
The IPU3 IPA module uses the default value from the V4L2_CID_VBLANK
control to compute the total frame size in processStatsBuffer().

Most drivers update the VBLANK control limits when a new format is
applied and assign to the default the current control value.

As this is not required by the API specification, and the VBLANK default
value can be different than its current value, use the actual control
value as now available from the IPACameraSensorInfo structure.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
---
 src/ipa/ipu3/ipa_context.cpp |  4 ++--
 src/ipa/ipu3/ipa_context.h   |  2 +-
 src/ipa/ipu3/ipu3.cpp        | 15 ++++++++-------
 3 files changed, 11 insertions(+), 10 deletions(-)

Patch
diff mbox series

diff --git a/src/ipa/ipu3/ipa_context.cpp b/src/ipa/ipu3/ipa_context.cpp
index 13cdb835ef7f..06fdf2a1efc7 100644
--- a/src/ipa/ipu3/ipa_context.cpp
+++ b/src/ipa/ipu3/ipa_context.cpp
@@ -126,8 +126,8 @@  namespace libcamera::ipa::ipu3 {
  * \var IPASessionConfiguration::sensor.lineDuration
  * \brief Line duration in microseconds
  *
- * \var IPASessionConfiguration::sensor.defVBlank
- * \brief The default vblank value of the sensor
+ * \var IPASessionConfiguration::sensor.vBlank
+ * \brief The vertical blanking expressed in number of lines
  */
 
 /**
diff --git a/src/ipa/ipu3/ipa_context.h b/src/ipa/ipu3/ipa_context.h
index 42e11141d3a1..a5b878ab7792 100644
--- a/src/ipa/ipu3/ipa_context.h
+++ b/src/ipa/ipu3/ipa_context.h
@@ -43,7 +43,7 @@  struct IPASessionConfiguration {
 	} agc;
 
 	struct {
-		int32_t defVBlank;
+		int32_t vBlank;
 		utils::Duration lineDuration;
 	} sensor;
 };
diff --git a/src/ipa/ipu3/ipu3.cpp b/src/ipa/ipu3/ipu3.cpp
index 7e8bf0feee8a..3efbc84c4ef1 100644
--- a/src/ipa/ipu3/ipu3.cpp
+++ b/src/ipa/ipu3/ipu3.cpp
@@ -149,7 +149,7 @@  public:
 				const uint32_t bufferId,
 				const ControlList &sensorControls) override;
 private:
-	void updateSessionConfiguration(const ControlInfoMap &sensorControls);
+	void updateSessionConfiguration(const IPAConfigInfo &info);
 
 	bool validateSensorControls();
 
@@ -177,10 +177,12 @@  private:
  * \brief Compute IPASessionConfiguration using the sensor information and the
  * sensor V4L2 controls
  */
-void IPAIPU3::updateSessionConfiguration(const ControlInfoMap &sensorControls)
+void IPAIPU3::updateSessionConfiguration(const IPAConfigInfo &info)
 {
-	const ControlInfo vBlank = sensorControls.find(V4L2_CID_VBLANK)->second;
-	context_.configuration.sensor.defVBlank = vBlank.def().get<int32_t>();
+	const IPACameraSensorInfo &sensorInfo = info.sensorInfo;
+	context_.configuration.sensor.vBlank = sensorInfo.vblank;
+
+	const ControlInfoMap &sensorControls = info.sensorControls;
 
 	const ControlInfo &v4l2Exposure = sensorControls.find(V4L2_CID_EXPOSURE)->second;
 	int32_t minExposure = v4l2Exposure.min().get<int32_t>();
@@ -391,7 +393,7 @@  int IPAIPU3::configure(const IPAConfigInfo &configInfo)
 	}
 
 	/* Update the IPASessionConfiguration using the sensor settings. */
-	updateSessionConfiguration(sensorCtrls_);
+	updateSessionConfiguration(configInfo);
 
 	for (auto const &algo : algorithms_) {
 		int ret = algo->configure(context_, configInfo);
@@ -501,7 +503,7 @@  void IPAIPU3::processStatsBuffer(const uint32_t frame,
 	frameContext.sensor.gain = camHelper_->gain(sensorControls.get(V4L2_CID_ANALOGUE_GAIN).get<int32_t>());
 
 	double lineDuration = context_.configuration.sensor.lineDuration.get<std::micro>();
-	int32_t vBlank = context_.configuration.sensor.defVBlank;
+	int32_t vBlank = context_.configuration.sensor.vBlank;
 	ControlList ctrls(controls::controls);
 
 	for (auto const &algo : algorithms_)
@@ -509,7 +511,6 @@  void IPAIPU3::processStatsBuffer(const uint32_t frame,
 
 	setControls(frame);
 
-	/* \todo Use VBlank value calculated from each frame exposure. */
 	int64_t frameDuration = (vBlank + sensorInfo_.outputSize.height) * lineDuration;
 	ctrls.set(controls::FrameDuration, frameDuration);