From patchwork Thu Dec 2 18:04:05 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: 14995 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 431B3BDB13 for ; Thu, 2 Dec 2021 18:04:20 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E49B66084B; Thu, 2 Dec 2021 19:04:19 +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="ayDZiJ5r"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id D5F7060592 for ; Thu, 2 Dec 2021 19:04:15 +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 7BF1AB7E; Thu, 2 Dec 2021 19:04:15 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1638468255; bh=TWRUo73KAeS8Br40wdAGYHlWvicaxPYZSA9tHc1RSMA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ayDZiJ5ruRA8+XZ2pSYKSNqiAKQvClvhpCzJw9pqTMdOWTTPLC+rM4T5VIuI6K/lg wCKe1eezEnuSttu+AugnFq6gS1rOvSBbmLN4dyvv6G/qswh3T3bKS0BZNGtTUMoreR JBNF+JR7vz/hT3yTO8EusxdE8labnErgJVb/QNbI= From: Jean-Michel Hautbois To: libcamera-devel@lists.libcamera.org Date: Thu, 2 Dec 2021 19:04:05 +0100 Message-Id: <20211202180410.518232-2-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 1/6] ipa: rkisp1: Introduce sensor degamma 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" The RkISP1 has a sensor degamma control. Introduce the algorithm, but only implement the prepare function as it is a static table to be set. The table used is the one found in the imx219 tuning data in RPi as this is the only sensor I have right now and it looks like a decent default table. Signed-off-by: Jean-Michel Hautbois --- src/ipa/rkisp1/algorithms/meson.build | 1 + src/ipa/rkisp1/algorithms/sdg.cpp | 49 +++++++++++++++++++++++++++ src/ipa/rkisp1/algorithms/sdg.h | 30 ++++++++++++++++ src/ipa/rkisp1/rkisp1.cpp | 2 ++ 4 files changed, 82 insertions(+) create mode 100644 src/ipa/rkisp1/algorithms/sdg.cpp create mode 100644 src/ipa/rkisp1/algorithms/sdg.h diff --git a/src/ipa/rkisp1/algorithms/meson.build b/src/ipa/rkisp1/algorithms/meson.build index a19c1a4fa..0678518d8 100644 --- a/src/ipa/rkisp1/algorithms/meson.build +++ b/src/ipa/rkisp1/algorithms/meson.build @@ -2,4 +2,5 @@ rkisp1_ipa_algorithms = files([ 'agc.cpp', + 'sdg.cpp', ]) diff --git a/src/ipa/rkisp1/algorithms/sdg.cpp b/src/ipa/rkisp1/algorithms/sdg.cpp new file mode 100644 index 000000000..3f6b3e205 --- /dev/null +++ b/src/ipa/rkisp1/algorithms/sdg.cpp @@ -0,0 +1,49 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2021, Ideas On Board + * + * sdg.cpp - Sensor degamma control algorithm + */ + +#include "sdg.h" + +/** + * \file sdg.h + */ + +namespace libcamera { + +namespace ipa::rkisp1::algorithms { + +/** + * \class SensorDeGamma + * \brief A sensor degamma algorithm + */ + +static const uint16_t imx219DeGammaCurve[] = { 0, 583, 957, 1299, 1609, 1877, + 2123, 2350, 2540, 2859, 3101, 3293, + 3429, 3666, 3823, 3963, 4095 }; + +/** + * \copydoc libcamera::ipa::Algorithm::prepare + */ +void SensorDeGamma::prepare([[maybe_unused]] IPAContext &context, + rkisp1_params_cfg *params) +{ + for (uint32_t i = 0; i < RKISP1_CIF_ISP_DEGAMMA_CURVE_SIZE; i++) { + params->others.sdg_config.curve_r.gamma_y[i] = imx219DeGammaCurve[i]; + params->others.sdg_config.curve_b.gamma_y[i] = imx219DeGammaCurve[i]; + params->others.sdg_config.curve_g.gamma_y[i] = imx219DeGammaCurve[i]; + } + + params->others.sdg_config.xa_pnts.gamma_dx0 = 0x44444444; + params->others.sdg_config.xa_pnts.gamma_dx1 = 0x44444444; + + params->module_en_update |= RKISP1_CIF_ISP_MODULE_SDG; + params->module_ens |= RKISP1_CIF_ISP_MODULE_SDG; + params->module_cfg_update |= RKISP1_CIF_ISP_MODULE_SDG; +} + +} /* namespace ipa::rkisp1::algorithms */ + +} /* namespace libcamera */ diff --git a/src/ipa/rkisp1/algorithms/sdg.h b/src/ipa/rkisp1/algorithms/sdg.h new file mode 100644 index 000000000..24c41627a --- /dev/null +++ b/src/ipa/rkisp1/algorithms/sdg.h @@ -0,0 +1,30 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2021, Ideas On Board + * + * sdg.h - Sensor degamma control algorithm + */ + +#pragma once + +#include + +#include "algorithm.h" + +namespace libcamera { + +struct IPACameraSensorInfo; + +namespace ipa::rkisp1::algorithms { + +class SensorDeGamma : public Algorithm +{ +public: + SensorDeGamma() = default; + ~SensorDeGamma() = default; + + void prepare(IPAContext &context, rkisp1_params_cfg *params) override; +}; + +} /* namespace ipa::rkisp1::algorithms */ +} /* namespace libcamera */ diff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp index 2d79f15fe..07f1f1c87 100644 --- a/src/ipa/rkisp1/rkisp1.cpp +++ b/src/ipa/rkisp1/rkisp1.cpp @@ -27,6 +27,7 @@ #include "algorithms/agc.h" #include "algorithms/algorithm.h" +#include "algorithms/sdg.h" #include "libipa/camera_sensor_helper.h" #include "ipa_context.h" @@ -126,6 +127,7 @@ int IPARkISP1::init(const IPASettings &settings, unsigned int hwRevision) /* Construct our Algorithms */ algorithms_.push_back(std::make_unique()); + algorithms_.push_back(std::make_unique()); return 0; }