[v3,09/19] ipa: libipa: agc: Store sensor configuration parameters
diff mbox series

Message ID 20251114-exposure-limits-v3-9-b7c07feba026@ideasonboard.com
State New
Headers show
Series
  • libipa: agc: Calculate exposure limits
Related show

Commit Message

Jacopo Mondi Nov. 14, 2025, 2:17 p.m. UTC
To prepare for changing the configure() and setLimits() functions
of the ExposureModeHelper class, introduce the sensor configuration
parameters that will remain valid for a streaming session, and separate
them from the run-time configuration parameters used by the exposure
helper to split shutter time and gains.

Only introduce the type in this patch but do not make use of it yet.

This change also prepares to centralize the sensor configuration
paramters in the CameraHelper.

Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
---
 src/ipa/libipa/exposure_mode_helper.cpp | 43 ++++++++++++++++++++++++++++-----
 src/ipa/libipa/exposure_mode_helper.h   | 18 ++++++++++++--
 2 files changed, 53 insertions(+), 8 deletions(-)

Patch
diff mbox series

diff --git a/src/ipa/libipa/exposure_mode_helper.cpp b/src/ipa/libipa/exposure_mode_helper.cpp
index 962ce1b1b7503e0f86f3857b484b249cb6383fde..c3ed1601939bd28435bbbc540d9b8c9d92b81912 100644
--- a/src/ipa/libipa/exposure_mode_helper.cpp
+++ b/src/ipa/libipa/exposure_mode_helper.cpp
@@ -21,8 +21,6 @@ 
 
 namespace libcamera {
 
-using namespace std::literals::chrono_literals;
-
 LOG_DEFINE_CATEGORY(ExposureModeHelper)
 
 namespace ipa {
@@ -59,6 +57,40 @@  namespace ipa {
  * used.
  */
 
+/**
+ * \struct ExposureModeHelper::SensorConfiguration
+ * \brief The sensor configuration parameters
+ *
+ * This struct represents the sensor configuration paramters. Sensor
+ * configuration parameters are set at configure() time and remain valid for
+ * the duration of the streaming session.
+ *
+ * \todo Remove it once all the information are available from the
+ * CameraSensorHelper.
+ *
+ * \var SensorConfiguration::lineDuration_
+ * \brief The sensor line duration
+ *
+ * \var SensorConfiguration::minExposureTime_
+ * \brief The sensor min exposure time in microseconds
+ *
+ * \var SensorConfiguration::maxExposureTime_
+ * \brief The sensor max exposure time in microseconds
+ * \todo Remove the max exposure time and calculcate it from the frame duration
+ *
+ * \var SensorConfiguration::minFrameDuration_
+ * \brief The sensor min frame duration in microseconds
+ *
+ * \var SensorConfiguration::maxFrameDuration_
+ * \brief The sensor max frame duration in microseconds
+ *
+ * \var SensorConfiguration::minGain_
+ * \brief The sensor minimum analogue gain value
+ *
+ * \var SensorConfiguration::maxGain_
+ * \brief The sensor maximum analogue gain value
+ */
+
 /**
  * \brief Construct an ExposureModeHelper instance
  * \param[in] stages The vector of paired exposure time and gain limits
@@ -70,8 +102,6 @@  namespace ipa {
  * the runtime limits set through setLimits() instead.
  */
 ExposureModeHelper::ExposureModeHelper(const Span<std::pair<utils::Duration, double>> stages)
-	: lineDuration_(1us), minExposureTime_(0us), maxExposureTime_(0us),
-	  minGain_(0), maxGain_(0), sensorHelper_(nullptr)
 {
 	for (const auto &[s, g] : stages) {
 		exposureTimes_.push_back(s);
@@ -97,7 +127,7 @@  ExposureModeHelper::ExposureModeHelper(const Span<std::pair<utils::Duration, dou
 void ExposureModeHelper::configure(utils::Duration lineDuration,
 				   const CameraSensorHelper *sensorHelper)
 {
-	lineDuration_ = lineDuration;
+	sensor_.lineDuration_ = lineDuration;
 	sensorHelper_ = sensorHelper;
 }
 
@@ -134,7 +164,8 @@  utils::Duration ExposureModeHelper::clampExposureTime(utils::Duration exposureTi
 	utils::Duration exp;
 
 	clamped = std::clamp(exposureTime, minExposureTime_, maxExposureTime_);
-	exp = static_cast<long>(clamped / lineDuration_) * lineDuration_;
+	exp = static_cast<long>(clamped / sensor_.lineDuration_)
+	    * sensor_.lineDuration_;
 	if (quantizationGain)
 		*quantizationGain = clamped / exp;
 
diff --git a/src/ipa/libipa/exposure_mode_helper.h b/src/ipa/libipa/exposure_mode_helper.h
index f8b7a4aa4800b59459f8fc80f502b83647547f51..4971cfbf5b2be9ef0e3e95a64b815902833e93a4 100644
--- a/src/ipa/libipa/exposure_mode_helper.h
+++ b/src/ipa/libipa/exposure_mode_helper.h
@@ -20,9 +20,21 @@  namespace libcamera {
 
 namespace ipa {
 
+using namespace std::literals::chrono_literals;
+
 class ExposureModeHelper
 {
 public:
+	struct SensorConfiguration {
+		utils::Duration lineDuration_;
+		utils::Duration minExposureTime_;
+		utils::Duration maxExposureTime_;
+		utils::Duration minFrameDuration_;
+		utils::Duration maxFrameDuration_;
+		double minGain_;
+		double maxGain_;
+	};
+
 	ExposureModeHelper(const Span<std::pair<utils::Duration, double>> stages);
 	~ExposureModeHelper() = default;
 
@@ -41,12 +53,14 @@  private:
 	std::vector<utils::Duration> exposureTimes_;
 	std::vector<double> gains_;
 
-	utils::Duration lineDuration_;
+	SensorConfiguration sensor_;
+	const CameraSensorHelper *sensorHelper_ = nullptr;
+
+	/* Runtime parameters, used to split exposure. */
 	utils::Duration minExposureTime_;
 	utils::Duration maxExposureTime_;
 	double minGain_;
 	double maxGain_;
-	const CameraSensorHelper *sensorHelper_;
 };
 
 } /* namespace ipa */