@@ -115,9 +115,17 @@ int Agc::configure(IPAContext &context,
context.activeState.agc.constraintMode = constraintModes().begin()->first;
context.activeState.agc.exposureMode = exposureModeHelpers().begin()->first;
- /* \todo Run this again when FrameDurationLimits is passed in */
- setLimits(minExposureTime_, maxExposureTime_, minAnalogueGain_,
- maxAnalogueGain_, {});
+ AgcMeanLuminance::SensorConfiguration sensorConfig;
+ sensorConfig.lineDuration = context.configuration.sensor.lineDuration;
+ sensorConfig.minExposureTime = minExposureTime_;
+ sensorConfig.maxExposureTime = maxExposureTime_;
+ sensorConfig.minAnalogueGain = minAnalogueGain_;
+ sensorConfig.maxAnalogueGain = maxAnalogueGain_;
+
+ AgcMeanLuminance::configure(sensorConfig, context.camHelper.get());
+
+ /* \todo Update AGC limits when FrameDurationLimits is passed in */
+
resetFrameCount();
return 0;
@@ -95,6 +95,35 @@ static constexpr double kMaxRelativeLuminanceTarget = 0.95;
* \brief The luminance target for the constraint
*/
+/**
+ * \struct AgcMeanLuminance::SensorConfiguration
+ * \brief The sensor configuration parameters
+ *
+ * This structure collects the sensor configuration parameters which need
+ * to be provided to the AGC algorithm at configure() time.
+ *
+ * Each time configure() is called the sensor configuration need to be updated
+ * with new parameters.
+ *
+ * \todo Remove it once all the information are available from the
+ * CameraSensorHelper.
+ *
+ * \var AgcMeanLuminance::SensorConfiguration::lineDuration
+ * \brief The line duration in microseconds
+ *
+ * \var AgcMeanLuminance::SensorConfiguration::minExposureTime
+ * \brief The sensor minimum exposure time in microseconds
+ *
+ * \var AgcMeanLuminance::SensorConfiguration::maxExposureTime
+ * \brief The sensor maximum exposure time in microseconds
+ *
+ * \var AgcMeanLuminance::SensorConfiguration::minAnalogueGain
+ * \brief The sensor minimum analogue gain absolute value
+ *
+ * \var AgcMeanLuminance::SensorConfiguration::maxAnalogueGain
+ * \brief The sensor maximum analogue gain absolute value
+ */
+
/**
* \class AgcMeanLuminance
* \brief A mean-based auto-exposure algorithm
@@ -314,17 +343,34 @@ int AgcMeanLuminance::parseExposureModes(const YamlObject &tuningData)
/**
* \brief Configure the exposure mode helpers
- * \param[in] lineDuration The sensor line length
+ * \param[in] config The sensor configuration
* \param[in] sensorHelper The sensor helper
*
- * This function configures the exposure mode helpers so they can correctly
+ * This function configures the exposure mode helpers by providing them the
+ * sensor configuration parameters and the sensor helper, so they can correctly
* take quantization effects into account.
*/
-void AgcMeanLuminance::configure(utils::Duration lineDuration,
+void AgcMeanLuminance::configure(const SensorConfiguration &config,
const CameraSensorHelper *sensorHelper)
{
- for (auto &[id, helper] : exposureModeHelpers_)
- helper->configure(lineDuration, sensorHelper);
+ for (auto &[id, helper] : exposureModeHelpers_) {
+ /*
+ * Translate from the SensorConfiguration to the
+ * ExposureModeHelper::SensorConfiguration.
+ *
+ * These are just place holders before all the information are
+ * available from the sensor helper.
+ */
+
+ ExposureModeHelper::SensorConfiguration sensorConfig;
+ sensorConfig.lineDuration_ = config.lineDuration;
+ sensorConfig.minExposureTime_ = config.minExposureTime;
+ sensorConfig.maxExposureTime_ = config.maxExposureTime;
+ sensorConfig.minGain_ = config.minAnalogueGain;
+ sensorConfig.maxGain_ = config.maxAnalogueGain;
+
+ helper->configure(sensorConfig, sensorHelper);
+ }
}
/**
@@ -42,7 +42,16 @@ public:
double yTarget;
};
- void configure(utils::Duration lineDuration, const CameraSensorHelper *sensorHelper);
+ struct SensorConfiguration {
+ utils::Duration lineDuration;
+ utils::Duration minExposureTime;
+ utils::Duration maxExposureTime;
+ double minAnalogueGain;
+ double maxAnalogueGain;
+ };
+
+ void configure(const SensorConfiguration &config,
+ const CameraSensorHelper *sensorHelper);
int parseTuningData(const YamlObject &tuningData);
void setExposureCompensation(double gain)
@@ -111,24 +111,30 @@ ExposureModeHelper::ExposureModeHelper(const Span<std::pair<utils::Duration, dou
/**
* \brief Configure sensor details
- * \param[in] lineDuration The current line length of the sensor
+ * \param[in] sensorConfig The sensor configuration
* \param[in] sensorHelper The sensor helper
*
- * This function sets the line length and sensor helper. These are used in
+ * This function initializes the exposure helper settings using the sensor
+ * configuration parameters.
+ *
+ * The sensor parameters' are used to initialize the min and max limits used in
* splitExposure() to take the quantization of the exposure and gain into
* account.
*
- * When this has not been called, it is assumed that exposure is in micro second
- * granularity and gain has no quantization at all.
- *
* ExposureModeHelper keeps a pointer to the CameraSensorHelper, so the caller
* has to ensure that sensorHelper is valid until the next call to configure().
*/
-void ExposureModeHelper::configure(utils::Duration lineDuration,
+void ExposureModeHelper::configure(const SensorConfiguration &sensorConfig,
const CameraSensorHelper *sensorHelper)
{
- sensor_.lineDuration_ = lineDuration;
+ sensor_ = sensorConfig;
sensorHelper_ = sensorHelper;
+
+ /* Initialize run-time limits with sensor's default. */
+ minExposureTime_ = sensor_.minExposureTime_;
+ maxExposureTime_ = sensor_.maxExposureTime_;
+ minGain_ = sensor_.minGain_;
+ maxGain_ = sensor_.maxGain_;
}
/**
@@ -38,7 +38,8 @@ public:
ExposureModeHelper(const Span<std::pair<utils::Duration, double>> stages);
~ExposureModeHelper() = default;
- void configure(utils::Duration lineLength, const CameraSensorHelper *sensorHelper);
+ void configure(const SensorConfiguration &sensorConfig,
+ const CameraSensorHelper *sensorHelper);
void setLimits(utils::Duration minExposureTime, utils::Duration maxExposureTime,
double minGain, double maxGain);
@@ -169,12 +169,16 @@ int Agc::configure(IPAContext &context,
context.activeState.agc.constraintMode = constraintModes().begin()->first;
context.activeState.agc.exposureMode = exposureModeHelpers().begin()->first;
- /* \todo Run this again when FrameDurationLimits is passed in */
- setLimits(context.configuration.sensor.minShutterSpeed,
- context.configuration.sensor.maxShutterSpeed,
- context.configuration.sensor.minAnalogueGain,
- context.configuration.sensor.maxAnalogueGain,
- {});
+ AgcMeanLuminance::SensorConfiguration sensorConfig;
+ sensorConfig.lineDuration = context.configuration.sensor.lineDuration;
+ sensorConfig.minExposureTime = context.configuration.sensor.minShutterSpeed;
+ sensorConfig.maxExposureTime = context.configuration.sensor.maxShutterSpeed;
+ sensorConfig.minAnalogueGain = context.configuration.sensor.minAnalogueGain;
+ sensorConfig.maxAnalogueGain = context.configuration.sensor.maxAnalogueGain;
+
+ AgcMeanLuminance::configure(sensorConfig, context.camHelper.get());
+
+ /* \todo Update AGC limits when FrameDurationLimits is passed in */
resetFrameCount();
@@ -200,13 +200,14 @@ int Agc::configure(IPAContext &context, const IPACameraSensorInfo &configInfo)
context.configuration.agc.measureWindow.h_size = configInfo.outputSize.width;
context.configuration.agc.measureWindow.v_size = configInfo.outputSize.height;
- AgcMeanLuminance::configure(context.configuration.sensor.lineDuration,
- context.camHelper.get());
-
- setLimits(context.configuration.sensor.minExposureTime,
- context.configuration.sensor.maxExposureTime,
- context.configuration.sensor.minAnalogueGain,
- context.configuration.sensor.maxAnalogueGain, {});
+ AgcMeanLuminance::SensorConfiguration sensorConfig;
+ sensorConfig.lineDuration = context.configuration.sensor.lineDuration;
+ sensorConfig.minExposureTime = context.configuration.sensor.minExposureTime;
+ sensorConfig.maxExposureTime = context.configuration.sensor.maxExposureTime;
+ sensorConfig.minAnalogueGain = context.configuration.sensor.minAnalogueGain;
+ sensorConfig.maxAnalogueGain = context.configuration.sensor.maxAnalogueGain;
+
+ AgcMeanLuminance::configure(sensorConfig, context.camHelper.get());
context.activeState.agc.automatic.yTarget = effectiveYTarget();
The AgcMeanLuminance algorithm interface has a 'configure()' and 'setLimits()' API. configure() doesn't actually do much if not initialzing a few variables, and the Mali and IPU3 IPAs do not even call it. Configuring the AGC requires calling setLimits() at configure() time and at run time. In order to prepare to differentiate between configure-time settings of the Agc and run-time handling of dynamic parameters such as the frame duration limits, make the configure() operation initialize the Agc limits and provide an AgcMeanLuminance::SensorConfiguration type for IPAs to be populated with the sensor's default values. The new type mimics the ExposureModeHelper::SensorConfiguration on introduced in the previous patches and both will be removed once all the information there contained will be made available from the CameraSensorHelper. Update all IPAs Agc implementation deriving from AgcMeanLuminance to populate a AgcMeanLuminance::SensorConfiguration and use it in configure(). Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> --- src/ipa/ipu3/algorithms/agc.cpp | 14 +++++++-- src/ipa/libipa/agc_mean_luminance.cpp | 56 ++++++++++++++++++++++++++++++--- src/ipa/libipa/agc_mean_luminance.h | 11 ++++++- src/ipa/libipa/exposure_mode_helper.cpp | 20 +++++++----- src/ipa/libipa/exposure_mode_helper.h | 3 +- src/ipa/mali-c55/algorithms/agc.cpp | 16 ++++++---- src/ipa/rkisp1/algorithms/agc.cpp | 15 ++++----- 7 files changed, 105 insertions(+), 30 deletions(-)