From 9e1bd62de3c61bf6771f656fc1ed7ccdde4f2bba Mon Sep 17 00:00:00 2001 From: Jean-Michel Hautbois Date: Thu, 22 Apr 2021 06:57:23 +0200 Subject: ipa: ipu3: Add support for IPU3 AEC/AGC algorithm Implement basic auto-exposure (AE) and auto-gain (AG) correction functions. The functions computeTargetExposure() and computeGain() are adapted from the Raspberry Pi AGC implementation to suit the IPU3 structures, and filtering is added to reduce visible stepsize when there are large exposure changes. Signed-off-by: Jean-Michel Hautbois Reviewed-by: Kieran Bingham Tested-by: Jacopo Mondi Signed-off-by: Kieran Bingham --- src/ipa/ipu3/ipu3.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'src/ipa/ipu3/ipu3.cpp') diff --git a/src/ipa/ipu3/ipu3.cpp b/src/ipa/ipu3/ipu3.cpp index a4d327ab..f5343547 100644 --- a/src/ipa/ipu3/ipu3.cpp +++ b/src/ipa/ipu3/ipu3.cpp @@ -21,6 +21,7 @@ #include "libcamera/internal/buffer.h" #include "libcamera/internal/log.h" +#include "ipu3_agc.h" #include "ipu3_awb.h" static constexpr uint32_t kMaxCellWidthPerSet = 160; @@ -72,6 +73,8 @@ private: /* Interface to the AWB algorithm */ std::unique_ptr awbAlgo_; + /* Interface to the AEC/AGC algorithm */ + std::unique_ptr agcAlgo_; /* Local parameter storage */ struct ipu3_uapi_params params_; @@ -170,6 +173,9 @@ void IPAIPU3::configure(const std::map &entityControls awbAlgo_ = std::make_unique(); awbAlgo_->initialise(params_, bdsOutputSize, bdsGrid_); + + agcAlgo_ = std::make_unique(); + agcAlgo_->initialise(bdsGrid_); } void IPAIPU3::mapBuffers(const std::vector &buffers) @@ -241,8 +247,8 @@ void IPAIPU3::processControls([[maybe_unused]] unsigned int frame, void IPAIPU3::fillParams(unsigned int frame, ipu3_uapi_params *params) { - /* Pass a default gamma of 1.0 (default linear correction) */ - awbAlgo_->updateWbParameters(params_, 1.0); + if (agcAlgo_->updateControls()) + awbAlgo_->updateWbParameters(params_, agcAlgo_->gamma()); *params = params_; @@ -257,8 +263,12 @@ void IPAIPU3::parseStatistics(unsigned int frame, { ControlList ctrls(controls::controls); + agcAlgo_->process(stats, exposure_, gain_); awbAlgo_->calculateWBGains(stats); + if (agcAlgo_->updateControls()) + setControls(frame); + IPU3Action op; op.op = ActionMetadataReady; op.controls = ctrls; -- cgit v1.2.1