{"id":14999,"url":"https://patchwork.libcamera.org/api/1.1/patches/14999/?format=json","web_url":"https://patchwork.libcamera.org/patch/14999/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/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":"<20211202180410.518232-6-jeanmichel.hautbois@ideasonboard.com>","date":"2021-12-02T18:04:09","name":"[libcamera-devel,v1,5/6] ipa: rkisp1: Introduce crosstalk correction","commit_ref":null,"pull_url":null,"state":"changes-requested","archived":false,"hash":"5a9bcda8a7e7f3d77cff9b83de1134742579a8bf","submitter":{"id":75,"url":"https://patchwork.libcamera.org/api/1.1/people/75/?format=json","name":"Jean-Michel Hautbois","email":"jeanmichel.hautbois@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/14999/mbox/","series":[{"id":2805,"url":"https://patchwork.libcamera.org/api/1.1/series/2805/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=2805","date":"2021-12-02T18:04:04","name":"IPA RkISP1 awb and misc improvements","version":1,"mbox":"https://patchwork.libcamera.org/series/2805/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/14999/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/14999/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 D7723C3252\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu,  2 Dec 2021 18:04:22 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 32F1460889;\n\tThu,  2 Dec 2021 19:04:22 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 770976082A\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu,  2 Dec 2021 19:04:16 +0100 (CET)","from tatooine.ideasonboard.com (unknown\n\t[IPv6:2a01:e0a:169:7140:7fc3:78ca:aeee:c4f2])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 3814FD8B;\n\tThu,  2 Dec 2021 19:04:16 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"fh+IJ/JM\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1638468256;\n\tbh=LWB/MXD2m8tPjM6kJ+KIyhHMtYTA/gN4QeY56DOPul4=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=fh+IJ/JMw05gZF5FdsJnYS/gxEQ8+Aj90p32B3uMCoh8oRMGVLKfqE7kTcaSgOMjS\n\tgn3hHrht104dMYX2lCHmKeZr00Hwhl1sYw13DduTeyzqsLcGw7drLo87EthtYrWgTL\n\teYhilnzvunBH88cjHpUAQ0ZsOGXr3F3kIxNvJUXE=","From":"Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Thu,  2 Dec 2021 19:04:09 +0100","Message-Id":"<20211202180410.518232-6-jeanmichel.hautbois@ideasonboard.com>","X-Mailer":"git-send-email 2.32.0","In-Reply-To":"<20211202180410.518232-1-jeanmichel.hautbois@ideasonboard.com>","References":"<20211202180410.518232-1-jeanmichel.hautbois@ideasonboard.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v1 5/6] ipa: rkisp1: Introduce crosstalk\n\tcorrection","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":"Introduce the color correction matrix for the RkISP1 based on a simple\nassumptions on the gains until we can tune the sensor properly.\n\nSigned-off-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>\n---\n src/ipa/rkisp1/algorithms/ctk.cpp     | 59 +++++++++++++++++++++++++++\n src/ipa/rkisp1/algorithms/ctk.h       | 30 ++++++++++++++\n src/ipa/rkisp1/algorithms/meson.build |  1 +\n src/ipa/rkisp1/rkisp1.cpp             |  2 +\n 4 files changed, 92 insertions(+)\n create mode 100644 src/ipa/rkisp1/algorithms/ctk.cpp\n create mode 100644 src/ipa/rkisp1/algorithms/ctk.h","diff":"diff --git a/src/ipa/rkisp1/algorithms/ctk.cpp b/src/ipa/rkisp1/algorithms/ctk.cpp\nnew file mode 100644\nindex 000000000..81600e776\n--- /dev/null\n+++ b/src/ipa/rkisp1/algorithms/ctk.cpp\n@@ -0,0 +1,59 @@\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\n+/*\n+ * Copyright (C) 2021, Ideas On Board\n+ *\n+ * ctk.cpp - RkISP1 Cross-Talk Correction control\n+ */\n+\n+#include \"ctk.h\"\n+\n+/**\n+ * \\file ctk.h\n+ */\n+\n+namespace libcamera {\n+\n+namespace ipa::rkisp1::algorithms {\n+\n+/**\n+ * \\class CrossTalkCorrection\n+ * \\brief RkISP1 Cross-Talk Correction control (color correction matrix)\n+ *\n+ * The crosstalk in image sensor is an effect when signal from a specific pixel\n+ * is affected by its adjacent pixels. An image sensor can be considered as a\n+ * linear system, with linear crosstalk existing only between horizontal and\n+ * vertical neighboring pixels. This matrix should be calculated based on tuning\n+ * but a first approximation can be obtained by using the grey-world gains and\n+ * applying them to their respective channel.\n+ */\n+\n+/**\n+ * \\copydoc libcamera::ipa::Algorithm::prepare\n+ */\n+void CrossTalkCorrection::prepare([[maybe_unused]] IPAContext &context,\n+\t\t\t\t  rkisp1_params_cfg *params)\n+{\n+\tparams->others.ctk_config.coeff[0][0] = 128 * context.frameContext.awb.gains.red;\n+\tparams->others.ctk_config.coeff[0][1] = 0;\n+\tparams->others.ctk_config.coeff[0][2] = 0;\n+\n+\tparams->others.ctk_config.coeff[1][0] = 0;\n+\tparams->others.ctk_config.coeff[1][1] = 128 * context.frameContext.awb.gains.green;\n+\tparams->others.ctk_config.coeff[1][2] = 0;\n+\n+\tparams->others.ctk_config.coeff[2][0] = 0;\n+\tparams->others.ctk_config.coeff[2][1] = 0;\n+\tparams->others.ctk_config.coeff[2][2] = 128 * context.frameContext.awb.gains.blue;\n+\n+\tparams->others.ctk_config.ct_offset[0] = 0;\n+\tparams->others.ctk_config.ct_offset[1] = 0;\n+\tparams->others.ctk_config.ct_offset[2] = 0;\n+\n+\tparams->module_en_update |= RKISP1_CIF_ISP_MODULE_CTK;\n+\tparams->module_ens |= RKISP1_CIF_ISP_MODULE_CTK;\n+\tparams->module_cfg_update |= RKISP1_CIF_ISP_MODULE_CTK;\n+}\n+\n+} /* namespace ipa::rkisp1::algorithms */\n+\n+} /* namespace libcamera */\ndiff --git a/src/ipa/rkisp1/algorithms/ctk.h b/src/ipa/rkisp1/algorithms/ctk.h\nnew file mode 100644\nindex 000000000..c4d240e2d\n--- /dev/null\n+++ b/src/ipa/rkisp1/algorithms/ctk.h\n@@ -0,0 +1,30 @@\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\n+/*\n+ * Copyright (C) 2021, Ideas On Board\n+ *\n+ * blc.h - RkISP1 Cross-Talk Correction control\n+ */\n+\n+#pragma once\n+\n+#include <linux/rkisp1-config.h>\n+\n+#include \"algorithm.h\"\n+\n+namespace libcamera {\n+\n+struct IPACameraSensorInfo;\n+\n+namespace ipa::rkisp1::algorithms {\n+\n+class CrossTalkCorrection : public Algorithm\n+{\n+public:\n+\tCrossTalkCorrection() = default;\n+\t~CrossTalkCorrection() = default;\n+\n+\tvoid prepare(IPAContext &context, rkisp1_params_cfg *params) override;\n+};\n+\n+} /* namespace ipa::rkisp1::algorithms */\n+} /* namespace libcamera */\ndiff --git a/src/ipa/rkisp1/algorithms/meson.build b/src/ipa/rkisp1/algorithms/meson.build\nindex faec0eb3e..482e88474 100644\n--- a/src/ipa/rkisp1/algorithms/meson.build\n+++ b/src/ipa/rkisp1/algorithms/meson.build\n@@ -4,5 +4,6 @@ rkisp1_ipa_algorithms = files([\n     'agc.cpp',\n     'awb.cpp',\n     'blc.cpp',\n+    'ctk.cpp',\n     'sdg.cpp',\n ])\ndiff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp\nindex 979f28420..21a9d15b9 100644\n--- a/src/ipa/rkisp1/rkisp1.cpp\n+++ b/src/ipa/rkisp1/rkisp1.cpp\n@@ -29,6 +29,7 @@\n #include \"algorithms/algorithm.h\"\n #include \"algorithms/awb.h\"\n #include \"algorithms/blc.h\"\n+#include \"algorithms/ctk.h\"\n #include \"algorithms/sdg.h\"\n #include \"libipa/camera_sensor_helper.h\"\n \n@@ -130,6 +131,7 @@ int IPARkISP1::init(const IPASettings &settings, unsigned int hwRevision)\n \talgorithms_.push_back(std::make_unique<algorithms::Agc>());\n \talgorithms_.push_back(std::make_unique<algorithms::Awb>());\n \talgorithms_.push_back(std::make_unique<algorithms::BlackLevelCorrection>());\n+\talgorithms_.push_back(std::make_unique<algorithms::CrossTalkCorrection>());\n \talgorithms_.push_back(std::make_unique<algorithms::SensorDeGamma>());\n \n \treturn 0;\n","prefixes":["libcamera-devel","v1","5/6"]}