summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/ipa/ipu3/ipu3.cpp24
-rw-r--r--src/ipa/ipu3/ipu3_agc.cpp4
-rw-r--r--src/ipa/ipu3/ipu3_agc.h4
3 files changed, 23 insertions, 9 deletions
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<IPU3Awb> awbAlgo_;
/* Interface to the AEC/AGC algorithm */
std::unique_ptr<IPU3Agc> agcAlgo_;
+ /* Interface to the Camera Helper */
+ std::unique_ptr<CameraSensorHelper> 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())
diff --git a/src/ipa/ipu3/ipu3_agc.cpp b/src/ipa/ipu3/ipu3_agc.cpp
index fd0b70f0..6253ab94 100644
--- a/src/ipa/ipu3/ipu3_agc.cpp
+++ b/src/ipa/ipu3/ipu3_agc.cpp
@@ -145,7 +145,7 @@ void IPU3Agc::filterExposure()
LOG(IPU3Agc, Debug) << "After filtering, total_exposure " << prevExposure_;
}
-void IPU3Agc::lockExposureGain(uint32_t &exposure, uint32_t &gain)
+void IPU3Agc::lockExposureGain(uint32_t &exposure, double &gain)
{
updateControls_ = false;
@@ -193,7 +193,7 @@ void IPU3Agc::lockExposureGain(uint32_t &exposure, uint32_t &gain)
lastFrame_ = frameCount_;
}
-void IPU3Agc::process(const ipu3_uapi_stats_3a *stats, uint32_t &exposure, uint32_t &gain)
+void IPU3Agc::process(const ipu3_uapi_stats_3a *stats, uint32_t &exposure, double &gain)
{
processBrightness(stats);
lockExposureGain(exposure, gain);
diff --git a/src/ipa/ipu3/ipu3_agc.h b/src/ipa/ipu3/ipu3_agc.h
index 60c7a84f..3deca3ae 100644
--- a/src/ipa/ipu3/ipu3_agc.h
+++ b/src/ipa/ipu3/ipu3_agc.h
@@ -33,7 +33,7 @@ public:
~IPU3Agc() = default;
void initialise(struct ipu3_uapi_grid_config &bdsGrid, const IPACameraSensorInfo &sensorInfo);
- void process(const ipu3_uapi_stats_3a *stats, uint32_t &exposure, uint32_t &gain);
+ void process(const ipu3_uapi_stats_3a *stats, uint32_t &exposure, double &gain);
bool converged() { return converged_; }
bool updateControls() { return updateControls_; }
/* \todo Use a metadata exchange between IPAs */
@@ -42,7 +42,7 @@ public:
private:
void processBrightness(const ipu3_uapi_stats_3a *stats);
void filterExposure();
- void lockExposureGain(uint32_t &exposure, uint32_t &gain);
+ void lockExposureGain(uint32_t &exposure, double &gain);
struct ipu3_uapi_grid_config aeGrid_;