new file mode 100644
@@ -0,0 +1,66 @@
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+/*
+ * Copyright (C) 2024, Amlogic
+ *
+ * C3ISP Color Space Conversion control
+ */
+
+#include "csc.h"
+
+#include <libcamera/base/log.h>
+
+/**
+ * \file csc.h
+ */
+
+namespace libcamera {
+
+namespace ipa::c3isp::algorithms {
+
+/**
+ * \class Csc
+ * \brief Color Space Conversion algorithm
+ */
+
+LOG_DEFINE_CATEGORY(C3ISPCsc)
+
+Csc::Csc()
+{
+}
+
+/**
+ * \copydoc libcamera::ipa::Algorithm::init
+ */
+int Csc::init([[maybe_unused]] IPAContext &context, const YamlObject &tuningData)
+{
+ cscCoeff_ = tuningData["cscCoeff"].getList<int16_t>().value_or(std::vector<int16_t>{});
+ if (cscCoeff_.size() != 9) {
+ LOG(C3ISPCsc, Error) << "Invalid CSC coeff size";
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
+/**
+ * \copydoc libcamera::ipa::Algorithm::prepare
+ */
+void Csc::prepare([[maybe_unused]] IPAContext &context,
+ [[maybe_unused]] const uint32_t frame,
+ [[maybe_unused]] IPAFrameContext &frameContext,
+ C3ISPParams *params)
+{
+ auto CscCfg = params->block<BlockType::Csc>();
+ CscCfg.setEnabled(C3_ISP_PARAMS_BLOCK_FL_ENABLE);
+
+ for (unsigned int i = 0; i < 3; i++) {
+ for (unsigned int j = 0; j < 3; j++)
+ CscCfg->matrix[i][j] = cscCoeff_[i * 3 + j];
+ }
+}
+
+REGISTER_IPA_ALGORITHM(Csc, "Csc")
+
+} /* namespace ipa::c3isp::algorithms */
+
+} /* namespace libcamera */
new file mode 100644
@@ -0,0 +1,32 @@
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+/*
+ * Copyright (C) 2024, Amlogic
+ *
+ * C3ISP Color Space Conversion control
+ */
+
+#pragma once
+
+#include "algorithm.h"
+
+namespace libcamera {
+
+namespace ipa::c3isp::algorithms {
+
+class Csc : public Algorithm
+{
+public:
+ Csc();
+ ~Csc() = 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<int16_t> cscCoeff_;
+};
+
+} /* namespace ipa::c3isp::algorithms */
+
+} /* namespace libcamera */
@@ -5,4 +5,5 @@ c3isp_ipa_algorithms = files([
'awb.cpp',
'blc.cpp',
'ccm.cpp',
+ 'csc.cpp',
])
Add a new Colour Space Coversion algorithm. Signed-off-by: Keke Li <keke.li@amlogic.com> --- src/ipa/c3-isp/algorithms/csc.cpp | 66 +++++++++++++++++++++++++++ src/ipa/c3-isp/algorithms/csc.h | 32 +++++++++++++ src/ipa/c3-isp/algorithms/meson.build | 1 + 3 files changed, 99 insertions(+) create mode 100644 src/ipa/c3-isp/algorithms/csc.cpp create mode 100644 src/ipa/c3-isp/algorithms/csc.h