@@ -6,4 +6,5 @@ c3isp_ipa_algorithms = files([
'blc.cpp',
'ccm.cpp',
'csc.cpp',
+ 'post_gamma.cpp',
])
new file mode 100644
@@ -0,0 +1,65 @@
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+/*
+ * Copyright (C) 2024, Amlogic
+ *
+ * C3ISP Post Gamma control
+ */
+
+#include "post_gamma.h"
+
+#include <libcamera/base/log.h>
+
+/**
+ * \file post_gamma.h
+ */
+
+namespace libcamera {
+
+namespace ipa::c3isp::algorithms {
+
+/**
+ * \class PostGamma
+ * \brief A post gamma algorithm
+ */
+
+LOG_DEFINE_CATEGORY(C3ISPPostGamma)
+
+PostGamma::PostGamma()
+{
+}
+
+/**
+ * \copydoc libcamera::ipa::Algorithm::init
+ */
+int PostGamma::init([[maybe_unused]] IPAContext &context, const YamlObject &tuningData)
+{
+ gammaLut_ = tuningData["gammaLut"].getList<uint16_t>().value_or(std::vector<uint16_t>{});
+ if (gammaLut_.size() != 129) {
+ LOG(C3ISPPostGamma, Error) << "Invalid gamma Look-up table size";
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
+/**
+ * \copydoc libcamera::ipa::Algorithm::prepare
+ */
+void PostGamma::prepare([[maybe_unused]] IPAContext &context,
+ [[maybe_unused]] const uint32_t frame,
+ [[maybe_unused]] IPAFrameContext &frameContext,
+ C3ISPParams *params)
+{
+ auto PostGammaCfg = params->block<BlockType::PostGamma>();
+ PostGammaCfg.setEnabled(C3_ISP_PARAMS_BLOCK_FL_ENABLE);
+
+ for (unsigned int i = 0; i < 129; i++) {
+ PostGammaCfg->lut[i] = gammaLut_[i];
+ }
+}
+
+REGISTER_IPA_ALGORITHM(PostGamma, "PostGamma")
+
+} /* namespace ipa::c3isp::algorithms */
+
+} /* namespace libcamera */
new file mode 100644
@@ -0,0 +1,33 @@
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+/*
+ * Copyright (C) 2024, Amlogic
+ *
+ * C3ISP Post Gamma control
+ */
+
+#pragma once
+
+#include "algorithm.h"
+
+namespace libcamera {
+
+namespace ipa::c3isp::algorithms {
+
+class PostGamma : public Algorithm
+{
+public:
+ PostGamma();
+ ~PostGamma() = default;
+
+ int init(IPAContext &context, const YamlObject &tuningData) override;
+ void prepare(IPAContext &context, const uint32_t frame,
+ IPAFrameContext &frameContext,
+ C3ISPParams *params) override;
+
+private:
+ std::vector<uint16_t> gammaLut_;
+};
+
+} /* namespace ipa::c3isp::algorithms */
+
+} /* namespace libcamera */
Add a new Post Gamma algorithm. Signed-off-by: Keke Li <keke.li@amlogic.com> --- src/ipa/c3-isp/algorithms/meson.build | 1 + src/ipa/c3-isp/algorithms/post_gamma.cpp | 65 ++++++++++++++++++++++++ src/ipa/c3-isp/algorithms/post_gamma.h | 33 ++++++++++++ 3 files changed, 99 insertions(+) create mode 100644 src/ipa/c3-isp/algorithms/post_gamma.cpp create mode 100644 src/ipa/c3-isp/algorithms/post_gamma.h