{"id":22892,"url":"https://patchwork.libcamera.org/api/patches/22892/?format=json","web_url":"https://patchwork.libcamera.org/patch/22892/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20250227105733.187611-10-keke.li@amlogic.com>","date":"2025-02-27T10:57:31","name":"[v3,09/11] ipa: c3-isp: Add CSC Algorithm","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"c7f16ccb859e21835cd5cf425f8544e16a038efc","submitter":{"id":217,"url":"https://patchwork.libcamera.org/api/people/217/?format=json","name":"Keke Li","email":"keke.li@amlogic.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/22892/mbox/","series":[{"id":5027,"url":"https://patchwork.libcamera.org/api/series/5027/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=5027","date":"2025-02-27T10:57:22","name":"Add Amlogic C3 ISP pipeline handler and IPA","version":3,"mbox":"https://patchwork.libcamera.org/series/5027/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/22892/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/22892/checks/","tags":{},"headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 0E905C3264\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 27 Feb 2025 10:59:03 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 4D03468763;\n\tThu, 27 Feb 2025 11:59:02 +0100 (CET)","from mail-sh.amlogic.com (unknown [58.32.228.46])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id F218A68763\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 27 Feb 2025 11:58:56 +0100 (CET)","from droid10.amlogic.com (10.18.11.213) by mail-sh.amlogic.com\n\t(10.18.11.5) with Microsoft SMTP Server id 15.1.2507.39;\n\tThu, 27 Feb 2025 18:58:56 +0800"],"From":"Keke Li <keke.li@amlogic.com>","To":"<libcamera-devel@lists.libcamera.org>","CC":"<kieran.bingham@ideasonboard.com>, <laurent.pinchart@ideasonboard.com>, \n\t<dan.scally@ideasonboard.com>, Keke Li <keke.li@amlogic.com>","Subject":"[PATCH v3 09/11] ipa: c3-isp: Add CSC Algorithm","Date":"Thu, 27 Feb 2025 18:57:31 +0800","Message-ID":"<20250227105733.187611-10-keke.li@amlogic.com>","X-Mailer":"git-send-email 2.29.0","In-Reply-To":"<20250227105733.187611-1-keke.li@amlogic.com>","References":"<20250227105733.187611-1-keke.li@amlogic.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Content-Type":"text/plain","X-Originating-IP":"[10.18.11.213]","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"Add a new Colour Space Coversion algorithm.\n\nSigned-off-by: Keke Li <keke.li@amlogic.com>\n---\n src/ipa/c3-isp/algorithms/csc.cpp     | 66 +++++++++++++++++++++++++++\n src/ipa/c3-isp/algorithms/csc.h       | 32 +++++++++++++\n src/ipa/c3-isp/algorithms/meson.build |  1 +\n 3 files changed, 99 insertions(+)\n create mode 100644 src/ipa/c3-isp/algorithms/csc.cpp\n create mode 100644 src/ipa/c3-isp/algorithms/csc.h","diff":"diff --git a/src/ipa/c3-isp/algorithms/csc.cpp b/src/ipa/c3-isp/algorithms/csc.cpp\nnew file mode 100644\nindex 00000000..588b1e19\n--- /dev/null\n+++ b/src/ipa/c3-isp/algorithms/csc.cpp\n@@ -0,0 +1,66 @@\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\n+/*\n+ * Copyright (C) 2024, Amlogic\n+ *\n+ * C3ISP Color Space Conversion control\n+ */\n+\n+#include \"csc.h\"\n+\n+#include <libcamera/base/log.h>\n+\n+/**\n+ * \\file csc.h\n+ */\n+\n+namespace libcamera {\n+\n+namespace ipa::c3isp::algorithms {\n+\n+/**\n+ * \\class Csc\n+ * \\brief Color Space Conversion algorithm\n+ */\n+\n+LOG_DEFINE_CATEGORY(C3ISPCsc)\n+\n+Csc::Csc()\n+{\n+}\n+\n+/**\n+ * \\copydoc libcamera::ipa::Algorithm::init\n+ */\n+int Csc::init([[maybe_unused]] IPAContext &context, const YamlObject &tuningData)\n+{\n+\tcscCoeff_ = tuningData[\"cscCoeff\"].getList<int16_t>().value_or(std::vector<int16_t>{});\n+\tif (cscCoeff_.size() != 9) {\n+\t\tLOG(C3ISPCsc, Error) << \"Invalid CSC coeff size\";\n+\t\treturn -EINVAL;\n+\t}\n+\n+\treturn 0;\n+}\n+\n+/**\n+ * \\copydoc libcamera::ipa::Algorithm::prepare\n+ */\n+void Csc::prepare([[maybe_unused]] IPAContext &context,\n+\t\t  [[maybe_unused]] const uint32_t frame,\n+\t\t  [[maybe_unused]] IPAFrameContext &frameContext,\n+\t\t  C3ISPParams *params)\n+{\n+\tauto CscCfg = params->block<BlockType::Csc>();\n+\tCscCfg.setEnabled(C3_ISP_PARAMS_BLOCK_FL_ENABLE);\n+\n+\tfor (unsigned int i = 0; i < 3; i++) {\n+\t\tfor (unsigned int j = 0; j < 3; j++)\n+\t\t\tCscCfg->matrix[i][j] = cscCoeff_[i * 3 + j];\n+\t}\n+}\n+\n+REGISTER_IPA_ALGORITHM(Csc, \"Csc\")\n+\n+} /* namespace ipa::c3isp::algorithms */\n+\n+} /* namespace libcamera */\ndiff --git a/src/ipa/c3-isp/algorithms/csc.h b/src/ipa/c3-isp/algorithms/csc.h\nnew file mode 100644\nindex 00000000..ec082a41\n--- /dev/null\n+++ b/src/ipa/c3-isp/algorithms/csc.h\n@@ -0,0 +1,32 @@\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\n+/*\n+ * Copyright (C) 2024, Amlogic\n+ *\n+ * C3ISP Color Space Conversion control\n+ */\n+\n+#pragma once\n+\n+#include \"algorithm.h\"\n+\n+namespace libcamera {\n+\n+namespace ipa::c3isp::algorithms {\n+\n+class Csc : public Algorithm\n+{\n+public:\n+\tCsc();\n+\t~Csc() = default;\n+\n+\tint init(IPAContext &context, const YamlObject &tuningData) override;\n+\tvoid prepare(IPAContext &context, const uint32_t frame,\n+\t\t     IPAFrameContext &frameContext,\n+\t\t     C3ISPParams *params) override;\n+private:\n+\tstd::vector<int16_t> cscCoeff_;\n+};\n+\n+} /* namespace ipa::c3isp::algorithms */\n+\n+} /* namespace libcamera */\ndiff --git a/src/ipa/c3-isp/algorithms/meson.build b/src/ipa/c3-isp/algorithms/meson.build\nindex 591c2433..5e7e56db 100644\n--- a/src/ipa/c3-isp/algorithms/meson.build\n+++ b/src/ipa/c3-isp/algorithms/meson.build\n@@ -5,4 +5,5 @@ c3isp_ipa_algorithms = files([\n     'awb.cpp',\n     'blc.cpp',\n     'ccm.cpp',\n+    'csc.cpp',\n ])\n","prefixes":["v3","09/11"]}