summaryrefslogtreecommitdiff
path: root/src/ipa/ipu3/algorithms/contrast.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/ipa/ipu3/algorithms/contrast.cpp')
-rw-r--r--src/ipa/ipu3/algorithms/contrast.cpp46
1 files changed, 46 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 */