summaryrefslogtreecommitdiff
path: root/src/ipa/ipu3/ipu3.cpp
diff options
context:
space:
mode:
authorJean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>2022-02-24 16:11:12 +0100
committerUmang Jain <umang.jain@ideasonboard.com>2022-03-11 20:47:32 +0530
commitb5d2adbeabeacdba6e887de2aef39aa320f4abe1 (patch)
treea02b36fb70092db8f5b0743dea243c64ef5669c3 /src/ipa/ipu3/ipu3.cpp
parente3900d1bf9fdb7200cfda7b73e59b5aac03c6f18 (diff)
ipa: ipu3: agc: Introduce lineDuration in IPASessionConfiguration
Instead of having a local cached value for line duration, store it in the IPASessionConfiguration::sensor structure. While at it, configure the default analogue gain and shutter speed to controlled fixed values. The latter is set to be 10ms as it will in most cases be close to the one needed, making the AGC faster to converge. Signed-off-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Umang Jain <umang.jain@ideasonboard.com> Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
Diffstat (limited to 'src/ipa/ipu3/ipu3.cpp')
-rw-r--r--src/ipa/ipu3/ipu3.cpp28
1 files changed, 15 insertions, 13 deletions
diff --git a/src/ipa/ipu3/ipu3.cpp b/src/ipa/ipu3/ipu3.cpp
index c0c29416..17324616 100644
--- a/src/ipa/ipu3/ipu3.cpp
+++ b/src/ipa/ipu3/ipu3.cpp
@@ -173,8 +173,6 @@ private:
uint32_t minGain_;
uint32_t maxGain_;
- utils::Duration lineDuration_;
-
/* Interface to the Camera Helper */
std::unique_ptr<CameraSensorHelper> camHelper_;
@@ -206,8 +204,8 @@ void IPAIPU3::updateSessionConfiguration(const ControlInfoMap &sensorControls)
*
* \todo take VBLANK into account for maximum shutter speed
*/
- context_.configuration.agc.minShutterSpeed = minExposure * lineDuration_;
- context_.configuration.agc.maxShutterSpeed = maxExposure * lineDuration_;
+ 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);
context_.configuration.agc.maxAnalogueGain = camHelper_->gain(maxGain);
}
@@ -229,6 +227,7 @@ void IPAIPU3::updateControls(const IPACameraSensorInfo &sensorInfo,
ControlInfoMap *ipaControls)
{
ControlInfoMap::Map controls{};
+ double lineDuration = context_.configuration.sensor.lineDuration.get<std::micro>();
/*
* Compute exposure time limits by using line length and pixel rate
@@ -237,9 +236,9 @@ void IPAIPU3::updateControls(const IPACameraSensorInfo &sensorInfo,
* microseconds.
*/
const ControlInfo &v4l2Exposure = sensorControls.find(V4L2_CID_EXPOSURE)->second;
- int32_t minExposure = v4l2Exposure.min().get<int32_t>() * lineDuration_.get<std::micro>();
- int32_t maxExposure = v4l2Exposure.max().get<int32_t>() * lineDuration_.get<std::micro>();
- int32_t defExposure = v4l2Exposure.def().get<int32_t>() * lineDuration_.get<std::micro>();
+ int32_t minExposure = v4l2Exposure.min().get<int32_t>() * lineDuration;
+ int32_t maxExposure = v4l2Exposure.max().get<int32_t>() * lineDuration;
+ int32_t defExposure = v4l2Exposure.def().get<int32_t>() * lineDuration;
controls[&controls::ExposureTime] = ControlInfo(minExposure, maxExposure,
defExposure);
@@ -293,6 +292,10 @@ int IPAIPU3::init(const IPASettings &settings,
return -ENODEV;
}
+ /* Clean context */
+ context_ = {};
+ context_.configuration.sensor.lineDuration = sensorInfo.lineLength * 1.0s / sensorInfo.pixelRate;
+
/* Construct our Algorithms */
algorithms_.push_back(std::make_unique<algorithms::Agc>());
algorithms_.push_back(std::make_unique<algorithms::Awb>());
@@ -454,12 +457,10 @@ int IPAIPU3::configure(const IPAConfigInfo &configInfo,
defVBlank_ = itVBlank->second.def().get<int32_t>();
- /* Clean context at configuration */
- context_ = {};
-
calculateBdsGrid(configInfo.bdsOutputSize);
- lineDuration_ = sensorInfo_.lineLength * 1.0s / sensorInfo_.pixelRate;
+ /* Clean frameContext at each reconfiguration. */
+ context_.frameContext = {};
/* Update the camera controls using the new sensor settings. */
updateControls(sensorInfo_, ctrls_, ipaControls);
@@ -620,6 +621,7 @@ void IPAIPU3::parseStatistics(unsigned int frame,
[[maybe_unused]] int64_t frameTimestamp,
const ipu3_uapi_stats_3a *stats)
{
+ double lineDuration = context_.configuration.sensor.lineDuration.get<std::micro>();
ControlList ctrls(controls::controls);
for (auto const &algo : algorithms_)
@@ -628,14 +630,14 @@ void IPAIPU3::parseStatistics(unsigned int frame,
setControls(frame);
/* \todo Use VBlank value calculated from each frame exposure. */
- int64_t frameDuration = (defVBlank_ + sensorInfo_.outputSize.height) * lineDuration_.get<std::micro>();
+ int64_t frameDuration = (defVBlank_ + sensorInfo_.outputSize.height) * lineDuration;
ctrls.set(controls::FrameDuration, frameDuration);
ctrls.set(controls::AnalogueGain, context_.frameContext.sensor.gain);
ctrls.set(controls::ColourTemperature, context_.frameContext.awb.temperatureK);
- ctrls.set(controls::ExposureTime, context_.frameContext.sensor.exposure * lineDuration_.get<std::micro>());
+ ctrls.set(controls::ExposureTime, context_.frameContext.sensor.exposure * lineDuration);
/*
* \todo The Metadata provides a path to getting extended data