From patchwork Mon Jun 20 01:43:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 16282 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 B337EBE173 for ; Mon, 20 Jun 2022 01:43:41 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 6D88D65657; Mon, 20 Jun 2022 03:43:41 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1655689421; bh=bVO1xzyMqTUKvU/3ZETsERx9YLdNjt3hyUWoPxtLoz4=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=EGef8Qvga9RFhGzVOCygVeIWSRniX93w3IUD4hDDwsAnG8K3oUpEyqnlyfPe3NJYj D5VNlkgJ5rm8MznCzgihpUG6Idgbepmu66D6DUtpypPGy8eEuUDcTfWp6gM0bD818F f30HqMBzDqHffy3AnwkaiHTYxYQ89zmiFEZzzUFOuKMHnHSzhxHvUSXhoL1hOqp6cH W+sI0dGIQE+ne5sqZLAii34NNLw/pqsXj9gEhT6D4XXHXbRfdfAp8J4YwFSQtjLhoC NtHID/yucCR3l9xkc0JtbBXCLle/rQNAQ8Wi+a66qwM6wj5ch5tKr8Z7rbsdhWFOH+ gX2jObIbL3xlA== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id B65ED6564B for ; Mon, 20 Jun 2022 03:43:30 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="XMDw4RLW"; dkim-atps=neutral Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 3ED3225E; Mon, 20 Jun 2022 03:43:30 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1655689410; bh=bVO1xzyMqTUKvU/3ZETsERx9YLdNjt3hyUWoPxtLoz4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XMDw4RLWjNcVWF0Xq9nsA72b38vgtIgBMlKaN5ncXs+pMqpESDQukrJWae6KAODs2 2jABJel57UvufewKVyk2sBAJT8UcndpD5HowTcE4WyBnRklw48thaAb0t8F0oBvVoC 6gKSjlesR3TiWn3uxR7MmNc7mAV1CscKixE/OhrM= To: libcamera-devel@lists.libcamera.org Date: Mon, 20 Jun 2022 04:43:05 +0300 Message-Id: <20220620014305.26778-13-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220620014305.26778-1-laurent.pinchart@ideasonboard.com> References: <20220620014305.26778-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 12/12] ipa: rkisp1: Add support of Black Level Correction tuning 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: , X-Patchwork-Original-From: Laurent Pinchart via libcamera-devel From: Laurent Pinchart Reply-To: Laurent Pinchart Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" From: Florian Sylvestre Get the Black Level Correction algorithm parameters from YAML tuning data. Signed-off-by: Florian Sylvestre Reviewed-by: Laurent Pinchart Reviewed-by: Paul Elder Signed-off-by: Laurent Pinchart --- Changes since v3: - Adapt to new init() API --- src/ipa/rkisp1/algorithms/blc.cpp | 49 ++++++++++++++++++++++++++----- src/ipa/rkisp1/algorithms/blc.h | 10 ++++++- 2 files changed, 50 insertions(+), 9 deletions(-) diff --git a/src/ipa/rkisp1/algorithms/blc.cpp b/src/ipa/rkisp1/algorithms/blc.cpp index ea9611bd712e..56c2b047df72 100644 --- a/src/ipa/rkisp1/algorithms/blc.cpp +++ b/src/ipa/rkisp1/algorithms/blc.cpp @@ -7,6 +7,10 @@ #include "blc.h" +#include + +#include "libcamera/internal/yaml_parser.h" + /** * \file blc.h */ @@ -29,6 +33,35 @@ namespace ipa::rkisp1::algorithms { * isn't currently supported. */ +LOG_DEFINE_CATEGORY(RkISP1Blc) + +BlackLevelCorrection::BlackLevelCorrection() + : tuningParameters_(false) +{ +} + +/** + * \copydoc libcamera::ipa::Algorithm::init + */ +int BlackLevelCorrection::init([[maybe_unused]] IPAContext &context, + const YamlObject &tuningData) +{ + blackLevelRed_ = tuningData["R"].get(256); + blackLevelGreenR_ = tuningData["Gr"].get(256); + blackLevelGreenB_ = tuningData["Gb"].get(256); + blackLevelBlue_ = tuningData["B"].get(256); + + tuningParameters_ = true; + + LOG(RkISP1Blc, Debug) + << "Black levels: red " << blackLevelRed_ + << ", green (red) " << blackLevelGreenR_ + << ", green (blue) " << blackLevelGreenB_ + << ", blue " << blackLevelBlue_; + + return 0; +} + /** * \copydoc libcamera::ipa::Algorithm::prepare */ @@ -37,15 +70,15 @@ void BlackLevelCorrection::prepare(IPAContext &context, { if (context.frameContext.frameCount > 0) return; - /* - * Substract fixed values taken from imx219 tuning file. - * \todo Use a configuration file for it ? - */ + + if (!tuningParameters_) + return; + params->others.bls_config.enable_auto = 0; - params->others.bls_config.fixed_val.r = 256; - params->others.bls_config.fixed_val.gr = 256; - params->others.bls_config.fixed_val.gb = 256; - params->others.bls_config.fixed_val.b = 256; + params->others.bls_config.fixed_val.r = blackLevelRed_; + params->others.bls_config.fixed_val.gr = blackLevelGreenR_; + params->others.bls_config.fixed_val.gb = blackLevelGreenB_; + params->others.bls_config.fixed_val.b = blackLevelBlue_; params->module_en_update |= RKISP1_CIF_ISP_MODULE_BLS; params->module_ens |= RKISP1_CIF_ISP_MODULE_BLS; diff --git a/src/ipa/rkisp1/algorithms/blc.h b/src/ipa/rkisp1/algorithms/blc.h index 69874d8f5e18..c2649dd7736e 100644 --- a/src/ipa/rkisp1/algorithms/blc.h +++ b/src/ipa/rkisp1/algorithms/blc.h @@ -20,10 +20,18 @@ namespace ipa::rkisp1::algorithms { class BlackLevelCorrection : public Algorithm { public: - BlackLevelCorrection() = default; + BlackLevelCorrection(); ~BlackLevelCorrection() = default; + int init(IPAContext &context, const YamlObject &tuningData) override; void prepare(IPAContext &context, rkisp1_params_cfg *params) override; + +private: + bool tuningParameters_; + int16_t blackLevelRed_; + int16_t blackLevelGreenR_; + int16_t blackLevelGreenB_; + int16_t blackLevelBlue_; }; } /* namespace ipa::rkisp1::algorithms */