@@ -388,25 +388,6 @@ int AgcAlgorithm::configure(agc::Session &session, agc::ActiveState &state,
<< "line-duration: " << session.lineDuration << ", "
<< "sensor-output: " << session.sensor.outputSize;
- /*
- * Compute the frame duration limits.
- *
- * The frame length is computed assuming a fixed line length combined
- * with the vertical frame sizes.
- */
-
- const ControlInfo &v4l2VBlank = config.sensorControls.find(V4L2_CID_VBLANK)->second;
- std::array<uint32_t, 3> frameHeights{
- v4l2VBlank.min().get<int32_t>() + config.sensorInfo.outputSize.height,
- v4l2VBlank.max().get<int32_t>() + config.sensorInfo.outputSize.height,
- v4l2VBlank.def().get<int32_t>() + config.sensorInfo.outputSize.height,
- };
-
- std::array<int64_t, 3> frameDurations;
- for (unsigned int i = 0; i < frameHeights.size(); ++i) {
- uint64_t frameSize = static_cast<uint64_t>(lineLength) * frameHeights[i];
- frameDurations[i] = frameSize * 1000000U / config.sensorInfo.pixelRate;
- }
/*
* When the AGC computes the new exposure values for a frame, it needs
@@ -420,8 +401,8 @@ int AgcAlgorithm::configure(agc::Session &session, agc::ActiveState &state,
session.minAnalogueGain = minGain;
session.maxAnalogueGain = maxGain;
session.defAnalogueGain = defGain;
- session.minFrameDuration = std::chrono::microseconds(frameDurations[0]);
- session.maxFrameDuration = std::chrono::microseconds(frameDurations[1]);
+ session.minFrameDuration = config.sensorInfo.minFrameLength * session.lineDuration;
+ session.maxFrameDuration = config.sensorInfo.maxFrameLength * session.lineDuration;
/* Configure the default exposure and gain. */
state = {};
@@ -460,8 +441,12 @@ int AgcAlgorithm::configure(agc::Session &session, agc::ActiveState &state,
static_cast<int32_t>(defExposure * lineDurationUs),
};
config.ctrlMap[&controls::FrameDurationLimits] = ControlInfo{
- frameDurations[0], frameDurations[1],
- std::span<const int64_t, 2>{ { frameDurations[0], frameDurations[1] } },
+ static_cast<int64_t>(session.minFrameDuration.get<std::micro>()),
+ static_cast<int64_t>(session.maxFrameDuration.get<std::micro>()),
+ std::span<const int64_t, 2>{ {
+ static_cast<int64_t>(state.minFrameDuration.get<std::micro>()),
+ static_cast<int64_t>(state.maxFrameDuration.get<std::micro>()),
+ } },
};
const auto add = [&](const ControlId &cid, const auto &automatic, const auto &manual) {
The frame duration is calculated as `frameHeight * lineDuration`, but it was effectively repeating the line duration calculation, but with microsecond precision. Instead, simply reuse the already calculated line duration, and use the already calculated min/max values in the provided in `IPACameraSensorInfo`. Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com> --- src/ipa/libipa/agc.cpp | 31 ++++++++----------------------- 1 file changed, 8 insertions(+), 23 deletions(-)