summaryrefslogtreecommitdiff
path: root/src/ipa/ipu3/ipu3.cpp
diff options
context:
space:
mode:
authorUmang Jain <umang.jain@ideasonboard.com>2022-05-17 23:42:13 +0530
committerKieran Bingham <kieran.bingham@ideasonboard.com>2022-05-18 15:27:33 +0100
commitf4783e689918abf6f470f4bcaaadaf3c2400dff4 (patch)
tree5fefd11654b09050dac8274a70607c7f107ee8af /src/ipa/ipu3/ipu3.cpp
parent8b291bce82f7cc8307e8ef55ff20e3f41462fa3f (diff)
ipa: ipu3: Put IPAFrameContext(s) in a ring buffer
Instead of having one frame context constantly being updated, this patch aims to introduce per-frame IPAFrameContext which are stored in a ring buffer. Whenever a request is queued, a new IPAFrameContext is created and inserted into the ring buffer. The IPAFrameContext structure itself has been slightly extended to store a frame id and a ControlList for incoming frame controls (sent in by the application). The next step would be to read and set these controls whenever the request is actually queued to the hardware. Since now we are working in multiples of IPAFrameContext, the Algorithm::process() will actually take in a IPAFrameContext pointer (as opposed to a nullptr while preparing for this change). Signed-off-by: Umang Jain <umang.jain@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Diffstat (limited to 'src/ipa/ipu3/ipu3.cpp')
-rw-r--r--src/ipa/ipu3/ipu3.cpp24
1 files changed, 15 insertions, 9 deletions
diff --git a/src/ipa/ipu3/ipu3.cpp b/src/ipa/ipu3/ipu3.cpp
index 16e5028f..2f6bb672 100644
--- a/src/ipa/ipu3/ipu3.cpp
+++ b/src/ipa/ipu3/ipu3.cpp
@@ -313,7 +313,7 @@ int IPAIPU3::init(const IPASettings &settings,
}
/* Clean context */
- context_ = {};
+ context_.configuration = {};
context_.configuration.sensor.lineDuration = sensorInfo.lineLength * 1.0s / sensorInfo.pixelRate;
/* Construct our Algorithms */
@@ -456,7 +456,8 @@ int IPAIPU3::configure(const IPAConfigInfo &configInfo,
/* Clean IPAActiveState at each reconfiguration. */
context_.activeState = {};
- context_.frameContext = {};
+ IPAFrameContext initFrameContext;
+ context_.frameContexts.fill(initFrameContext);
if (!validateSensorControls()) {
LOG(IPAIPU3, Error) << "Sensor control validation failed.";
@@ -568,15 +569,20 @@ void IPAIPU3::processStatsBuffer(const uint32_t frame,
const ipu3_uapi_stats_3a *stats =
reinterpret_cast<ipu3_uapi_stats_3a *>(mem.data());
- context_.frameContext.sensor.exposure = sensorControls.get(V4L2_CID_EXPOSURE).get<int32_t>();
- context_.frameContext.sensor.gain = camHelper_->gain(sensorControls.get(V4L2_CID_ANALOGUE_GAIN).get<int32_t>());
+ IPAFrameContext &frameContext = context_.frameContexts[frame % kMaxFrameContexts];
+
+ if (frameContext.frame != frame)
+ LOG(IPAIPU3, Warning) << "Frame " << frame << " does not match its frame context";
+
+ frameContext.sensor.exposure = sensorControls.get(V4L2_CID_EXPOSURE).get<int32_t>();
+ 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;
ControlList ctrls(controls::controls);
for (auto const &algo : algorithms_)
- algo->process(context_, nullptr, stats);
+ algo->process(context_, &frameContext, stats);
setControls(frame);
@@ -584,11 +590,11 @@ void IPAIPU3::processStatsBuffer(const uint32_t frame,
int64_t frameDuration = (vBlank + sensorInfo_.outputSize.height) * lineDuration;
ctrls.set(controls::FrameDuration, frameDuration);
- ctrls.set(controls::AnalogueGain, context_.frameContext.sensor.gain);
+ ctrls.set(controls::AnalogueGain, frameContext.sensor.gain);
ctrls.set(controls::ColourTemperature, context_.activeState.awb.temperatureK);
- ctrls.set(controls::ExposureTime, context_.frameContext.sensor.exposure * lineDuration);
+ ctrls.set(controls::ExposureTime, frameContext.sensor.exposure * lineDuration);
/*
* \todo The Metadata provides a path to getting extended data
@@ -609,10 +615,10 @@ void IPAIPU3::processStatsBuffer(const uint32_t frame,
* Parse the request to handle any IPA-managed controls that were set from the
* application such as manual sensor settings.
*/
-void IPAIPU3::queueRequest([[maybe_unused]] const uint32_t frame,
- [[maybe_unused]] const ControlList &controls)
+void IPAIPU3::queueRequest(const uint32_t frame, const ControlList &controls)
{
/* \todo Start processing for 'frame' based on 'controls'. */
+ context_.frameContexts[frame % kMaxFrameContexts] = { frame, controls };
}
/**