From patchwork Thu Dec 2 18:04:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean-Michel Hautbois X-Patchwork-Id: 14999 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id D7723C3252 for ; Thu, 2 Dec 2021 18:04:22 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 32F1460889; Thu, 2 Dec 2021 19:04:22 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="fh+IJ/JM"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 770976082A for ; Thu, 2 Dec 2021 19:04:16 +0100 (CET) Received: from tatooine.ideasonboard.com (unknown [IPv6:2a01:e0a:169:7140:7fc3:78ca:aeee:c4f2]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 3814FD8B; Thu, 2 Dec 2021 19:04:16 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1638468256; bh=LWB/MXD2m8tPjM6kJ+KIyhHMtYTA/gN4QeY56DOPul4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fh+IJ/JMw05gZF5FdsJnYS/gxEQ8+Aj90p32B3uMCoh8oRMGVLKfqE7kTcaSgOMjS gn3hHrht104dMYX2lCHmKeZr00Hwhl1sYw13DduTeyzqsLcGw7drLo87EthtYrWgTL eYhilnzvunBH88cjHpUAQ0ZsOGXr3F3kIxNvJUXE= From: Jean-Michel Hautbois 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 Subject: [libcamera-devel] [PATCH v1 5/6] ipa: rkisp1: Introduce crosstalk correction X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Introduce the color correction matrix for the RkISP1 based on a simple assumptions on the gains until we can tune the sensor properly. Signed-off-by: Jean-Michel Hautbois --- src/ipa/rkisp1/algorithms/ctk.cpp | 59 +++++++++++++++++++++++++++ src/ipa/rkisp1/algorithms/ctk.h | 30 ++++++++++++++ src/ipa/rkisp1/algorithms/meson.build | 1 + src/ipa/rkisp1/rkisp1.cpp | 2 + 4 files changed, 92 insertions(+) create mode 100644 src/ipa/rkisp1/algorithms/ctk.cpp create mode 100644 src/ipa/rkisp1/algorithms/ctk.h diff --git a/src/ipa/rkisp1/algorithms/ctk.cpp b/src/ipa/rkisp1/algorithms/ctk.cpp new file mode 100644 index 000000000..81600e776 --- /dev/null +++ b/src/ipa/rkisp1/algorithms/ctk.cpp @@ -0,0 +1,59 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2021, Ideas On Board + * + * ctk.cpp - RkISP1 Cross-Talk Correction control + */ + +#include "ctk.h" + +/** + * \file ctk.h + */ + +namespace libcamera { + +namespace ipa::rkisp1::algorithms { + +/** + * \class CrossTalkCorrection + * \brief RkISP1 Cross-Talk Correction control (color correction matrix) + * + * The crosstalk in image sensor is an effect when signal from a specific pixel + * is affected by its adjacent pixels. An image sensor can be considered as a + * linear system, with linear crosstalk existing only between horizontal and + * vertical neighboring pixels. This matrix should be calculated based on tuning + * but a first approximation can be obtained by using the grey-world gains and + * applying them to their respective channel. + */ + +/** + * \copydoc libcamera::ipa::Algorithm::prepare + */ +void CrossTalkCorrection::prepare([[maybe_unused]] IPAContext &context, + rkisp1_params_cfg *params) +{ + params->others.ctk_config.coeff[0][0] = 128 * context.frameContext.awb.gains.red; + params->others.ctk_config.coeff[0][1] = 0; + params->others.ctk_config.coeff[0][2] = 0; + + params->others.ctk_config.coeff[1][0] = 0; + params->others.ctk_config.coeff[1][1] = 128 * context.frameContext.awb.gains.green; + params->others.ctk_config.coeff[1][2] = 0; + + params->others.ctk_config.coeff[2][0] = 0; + params->others.ctk_config.coeff[2][1] = 0; + params->others.ctk_config.coeff[2][2] = 128 * context.frameContext.awb.gains.blue; + + params->others.ctk_config.ct_offset[0] = 0; + params->others.ctk_config.ct_offset[1] = 0; + params->others.ctk_config.ct_offset[2] = 0; + + params->module_en_update |= RKISP1_CIF_ISP_MODULE_CTK; + params->module_ens |= RKISP1_CIF_ISP_MODULE_CTK; + params->module_cfg_update |= RKISP1_CIF_ISP_MODULE_CTK; +} + +} /* namespace ipa::rkisp1::algorithms */ + +} /* namespace libcamera */ diff --git a/src/ipa/rkisp1/algorithms/ctk.h b/src/ipa/rkisp1/algorithms/ctk.h new file mode 100644 index 000000000..c4d240e2d --- /dev/null +++ b/src/ipa/rkisp1/algorithms/ctk.h @@ -0,0 +1,30 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2021, Ideas On Board + * + * blc.h - RkISP1 Cross-Talk Correction control + */ + +#pragma once + +#include + +#include "algorithm.h" + +namespace libcamera { + +struct IPACameraSensorInfo; + +namespace ipa::rkisp1::algorithms { + +class CrossTalkCorrection : public Algorithm +{ +public: + CrossTalkCorrection() = default; + ~CrossTalkCorrection() = default; + + void prepare(IPAContext &context, rkisp1_params_cfg *params) override; +}; + +} /* namespace ipa::rkisp1::algorithms */ +} /* namespace libcamera */ diff --git a/src/ipa/rkisp1/algorithms/meson.build b/src/ipa/rkisp1/algorithms/meson.build index faec0eb3e..482e88474 100644 --- a/src/ipa/rkisp1/algorithms/meson.build +++ b/src/ipa/rkisp1/algorithms/meson.build @@ -4,5 +4,6 @@ rkisp1_ipa_algorithms = files([ 'agc.cpp', 'awb.cpp', 'blc.cpp', + 'ctk.cpp', 'sdg.cpp', ]) diff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp index 979f28420..21a9d15b9 100644 --- a/src/ipa/rkisp1/rkisp1.cpp +++ b/src/ipa/rkisp1/rkisp1.cpp @@ -29,6 +29,7 @@ #include "algorithms/algorithm.h" #include "algorithms/awb.h" #include "algorithms/blc.h" +#include "algorithms/ctk.h" #include "algorithms/sdg.h" #include "libipa/camera_sensor_helper.h" @@ -130,6 +131,7 @@ int IPARkISP1::init(const IPASettings &settings, unsigned int hwRevision) algorithms_.push_back(std::make_unique()); algorithms_.push_back(std::make_unique()); algorithms_.push_back(std::make_unique()); + algorithms_.push_back(std::make_unique()); algorithms_.push_back(std::make_unique()); return 0;