From 8738d539f4a350d51bc1f6b780cc1fdfd62cf4ec Mon Sep 17 00:00:00 2001 From: Jean-Michel Hautbois Date: Thu, 10 Jun 2021 12:09:13 +0200 Subject: ipa: ipu3: Initialize CameraSensorHelper at IPU3 init stage In order for the CameraSensorHelper to be instantiated, we need to find its factory using the camera sensor model name stored in IPASettings::sensorModel. As we don't need to do it at each configure call (the sensor is not changing in-between), implement the init call in IPAIPU3 to do that. Signed-off-by: Jean-Michel Hautbois Reviewed-by: Umang Jain Reviewed-by: Jacopo Mondi Reviewed-by: Kieran Bingham --- src/ipa/ipu3/ipu3.cpp | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) (limited to 'src/ipa/ipu3/ipu3.cpp') diff --git a/src/ipa/ipu3/ipu3.cpp b/src/ipa/ipu3/ipu3.cpp index 31a3c006..f43f8620 100644 --- a/src/ipa/ipu3/ipu3.cpp +++ b/src/ipa/ipu3/ipu3.cpp @@ -24,6 +24,7 @@ #include "ipu3_agc.h" #include "ipu3_awb.h" +#include "libipa/camera_sensor_helper.h" static constexpr uint32_t kMaxCellWidthPerSet = 160; static constexpr uint32_t kMaxCellHeightPerSet = 56; @@ -37,10 +38,7 @@ namespace ipa::ipu3 { class IPAIPU3 : public IPAIPU3Interface { public: - int init([[maybe_unused]] const IPASettings &settings) override - { - return 0; - } + int init(const IPASettings &settings) override; int start() override; void stop() override {} @@ -79,6 +77,8 @@ private: std::unique_ptr awbAlgo_; /* Interface to the AEC/AGC algorithm */ std::unique_ptr agcAlgo_; + /* Interface to the Camera Helper */ + std::unique_ptr camHelper_; /* Local parameter storage */ struct ipu3_uapi_params params_; @@ -86,6 +86,17 @@ private: struct ipu3_uapi_grid_config bdsGrid_; }; +int IPAIPU3::init(const IPASettings &settings) +{ + camHelper_ = CameraSensorHelperFactory::create(settings.sensorModel); + if (camHelper_ == nullptr) { + LOG(IPAIPU3, Error) << "Failed to create camera sensor helper for " << settings.sensorModel; + return -ENODEV; + } + + return 0; +} + int IPAIPU3::start() { setControls(0); @@ -281,7 +292,10 @@ void IPAIPU3::parseStatistics(unsigned int frame, { ControlList ctrls(controls::controls); - agcAlgo_->process(stats, exposure_, gain_); + double gain = camHelper_->gain(gain_); + agcAlgo_->process(stats, exposure_, gain); + gain_ = camHelper_->gainCode(gain); + awbAlgo_->calculateWBGains(stats); if (agcAlgo_->updateControls()) -- cgit v1.2.1