summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKieran Bingham <kieran.bingham@ideasonboard.com>2021-08-04 14:29:04 +0100
committerKieran Bingham <kieran.bingham@ideasonboard.com>2021-08-05 08:53:59 +0100
commite5e0ce6573ac91a76954eeaf89cd309a48fd333d (patch)
treebe140b60881e297947da87c282edd31e9ee16b3f /src
parent9f1c38e2609cd8689aab901402188cd223c223b5 (diff)
ipa: ipu3: Introduce a modular contrast algorithmipu3/modules
Implement a new modular framework for algorithms with a common context structure that is passed to each algorithm through a common API. The initial algorithm is chosen to configure the gamma contrast curve which replicates the implementation from AWB for simplicity. Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Diffstat (limited to 'src')
-rw-r--r--src/ipa/ipu3/algorithms/contrast.cpp46
-rw-r--r--src/ipa/ipu3/algorithms/contrast.h32
-rw-r--r--src/ipa/ipu3/algorithms/meson.build1
-rw-r--r--src/ipa/ipu3/ipu3.cpp5
4 files changed, 84 insertions, 0 deletions
diff --git a/src/ipa/ipu3/algorithms/contrast.cpp b/src/ipa/ipu3/algorithms/contrast.cpp
new file mode 100644
index 00000000..890dc3ff
--- /dev/null
+++ b/src/ipa/ipu3/algorithms/contrast.cpp
@@ -0,0 +1,46 @@
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+/*
+ * Copyright (C) 2021, Ideas On Board
+ *
+ * constrast.cpp - IPU3 Contrast and Gamma control
+ */
+
+#include "contrast.h"
+
+#include <cmath>
+
+#include <libcamera/base/log.h>
+
+namespace libcamera {
+
+namespace ipa::ipu3::algorithms {
+
+LOG_DEFINE_CATEGORY(IPU3Contrast)
+
+Contrast::Contrast()
+ : gamma_(1.0)
+{
+}
+
+void Contrast::initialise(IPAContext &context)
+{
+ ipu3_uapi_params &params = context.params;
+
+ /* Limit the gamma effect for now */
+ gamma_ = 1.1;
+
+ /* Plot the gamma curve into the look up table */
+ for (uint32_t i = 0; i < 256; i++) {
+ double j = i / 255.0;
+ double gamma = std::pow(j, 1.0 / gamma_);
+
+ /* The maximum value 255 is represented on 13 bits in the IPU3 */
+ params.acc_param.gamma.gc_lut.lut[i] = gamma * 8191;
+ }
+
+ LOG(IPU3Contrast, Info) << "Processed Gamma Curve";
+}
+
+} /* namespace ipa::ipu3::algorithms */
+
+} /* namespace libcamera */
diff --git a/src/ipa/ipu3/algorithms/contrast.h b/src/ipa/ipu3/algorithms/contrast.h
new file mode 100644
index 00000000..cd1b0060
--- /dev/null
+++ b/src/ipa/ipu3/algorithms/contrast.h
@@ -0,0 +1,32 @@
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+/*
+ * Copyright (C) 2021, Google
+ *
+ * constrast.h - IPU3 Contrast and Gamma control
+ */
+#ifndef __LIBCAMERA_IPU3_ALGORITHMS_CONTRAST_H__
+#define __LIBCAMERA_IPU3_ALGORITHMS_CONTRAST_H__
+
+#include "algorithm.h"
+
+namespace libcamera {
+
+namespace ipa::ipu3::algorithms {
+
+class Contrast : public Algorithm
+{
+public:
+ Contrast();
+ ~Contrast() = default;
+
+ void initialise(IPAContext &context);
+
+private:
+ double gamma_;
+};
+
+} /* namespace ipa::ipu3::algorithms */
+
+} /* namespace libcamera */
+
+#endif /* __LIBCAMERA_IPU3_ALGORITHMS_CONTRAST_H__ */
diff --git a/src/ipa/ipu3/algorithms/meson.build b/src/ipa/ipu3/algorithms/meson.build
index 67148333..f71d1e61 100644
--- a/src/ipa/ipu3/algorithms/meson.build
+++ b/src/ipa/ipu3/algorithms/meson.build
@@ -1,4 +1,5 @@
# SPDX-License-Identifier: CC0-1.0
ipu3_ipa_algorithms = files([
+ 'contrast.cpp',
])
diff --git a/src/ipa/ipu3/ipu3.cpp b/src/ipa/ipu3/ipu3.cpp
index 1d89c28b..0bfb7c49 100644
--- a/src/ipa/ipu3/ipu3.cpp
+++ b/src/ipa/ipu3/ipu3.cpp
@@ -29,6 +29,8 @@
#include "ipu3_awb.h"
#include "libipa/camera_sensor_helper.h"
+#include "algorithms/contrast.h"
+
static constexpr uint32_t kMaxCellWidthPerSet = 160;
static constexpr uint32_t kMaxCellHeightPerSet = 56;
@@ -103,6 +105,9 @@ int IPAIPU3::init(const IPASettings &settings)
return -ENODEV;
}
+ /* Construct our Algorithms */
+ algorithms_.emplace_back(algorithms::Contrast());
+
initialiseAlgorithms();
return 0;