{"id":16282,"url":"https://patchwork.libcamera.org/api/1.1/patches/16282/?format=json","web_url":"https://patchwork.libcamera.org/patch/16282/","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":"<20220620014305.26778-13-laurent.pinchart@ideasonboard.com>","date":"2022-06-20T01:43:05","name":"[libcamera-devel,v4,12/12] ipa: rkisp1: Add support of Black Level Correction tuning","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"c569d81aced04a74a4439efc013179b9d046f541","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/1.1/people/2/?format=json","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/16282/mbox/","series":[{"id":3191,"url":"https://patchwork.libcamera.org/api/1.1/series/3191/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=3191","date":"2022-06-20T01:42:53","name":"Add tuning file support for the RkISP1 IPA module","version":4,"mbox":"https://patchwork.libcamera.org/series/3191/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/16282/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/16282/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 B337EBE173\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 20 Jun 2022 01:43:41 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 6D88D65657;\n\tMon, 20 Jun 2022 03:43:41 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id B65ED6564B\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 20 Jun 2022 03:43:30 +0200 (CEST)","from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 3ED3225E;\n\tMon, 20 Jun 2022 03:43:30 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1655689421;\n\tbh=bVO1xzyMqTUKvU/3ZETsERx9YLdNjt3hyUWoPxtLoz4=;\n\th=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:\n\tFrom;\n\tb=EGef8Qvga9RFhGzVOCygVeIWSRniX93w3IUD4hDDwsAnG8K3oUpEyqnlyfPe3NJYj\n\tD5VNlkgJ5rm8MznCzgihpUG6Idgbepmu66D6DUtpypPGy8eEuUDcTfWp6gM0bD818F\n\tf30HqMBzDqHffy3AnwkaiHTYxYQ89zmiFEZzzUFOuKMHnHSzhxHvUSXhoL1hOqp6cH\n\tW+sI0dGIQE+ne5sqZLAii34NNLw/pqsXj9gEhT6D4XXHXbRfdfAp8J4YwFSQtjLhoC\n\tNtHID/yucCR3l9xkc0JtbBXCLle/rQNAQ8Wi+a66qwM6wj5ch5tKr8Z7rbsdhWFOH+\n\tgX2jObIbL3xlA==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1655689410;\n\tbh=bVO1xzyMqTUKvU/3ZETsERx9YLdNjt3hyUWoPxtLoz4=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=XMDw4RLWjNcVWF0Xq9nsA72b38vgtIgBMlKaN5ncXs+pMqpESDQukrJWae6KAODs2\n\t2jABJel57UvufewKVyk2sBAJT8UcndpD5HowTcE4WyBnRklw48thaAb0t8F0oBvVoC\n\t6gKSjlesR3TiWn3uxR7MmNc7mAV1CscKixE/OhrM="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"XMDw4RLW\"; dkim-atps=neutral","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","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v4 12/12] ipa: rkisp1: Add support of\n\tBlack Level Correction tuning","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>","From":"Laurent Pinchart via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"From: Florian Sylvestre <fsylvestre@baylibre.com>\n\nGet the Black Level Correction algorithm parameters from YAML tuning\ndata.\n\nSigned-off-by: Florian Sylvestre <fsylvestre@baylibre.com>\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nReviewed-by: Paul Elder <paul.elder@ideasonboard.com>\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\nChanges since v3:\n\n- Adapt to new init() API\n---\n src/ipa/rkisp1/algorithms/blc.cpp | 49 ++++++++++++++++++++++++++-----\n src/ipa/rkisp1/algorithms/blc.h   | 10 ++++++-\n 2 files changed, 50 insertions(+), 9 deletions(-)","diff":"diff --git a/src/ipa/rkisp1/algorithms/blc.cpp b/src/ipa/rkisp1/algorithms/blc.cpp\nindex ea9611bd712e..56c2b047df72 100644\n--- a/src/ipa/rkisp1/algorithms/blc.cpp\n+++ b/src/ipa/rkisp1/algorithms/blc.cpp\n@@ -7,6 +7,10 @@\n \n #include \"blc.h\"\n \n+#include <libcamera/base/log.h>\n+\n+#include \"libcamera/internal/yaml_parser.h\"\n+\n /**\n  * \\file blc.h\n  */\n@@ -29,6 +33,35 @@ namespace ipa::rkisp1::algorithms {\n  * isn't currently supported.\n  */\n \n+LOG_DEFINE_CATEGORY(RkISP1Blc)\n+\n+BlackLevelCorrection::BlackLevelCorrection()\n+\t: tuningParameters_(false)\n+{\n+}\n+\n+/**\n+ * \\copydoc libcamera::ipa::Algorithm::init\n+ */\n+int BlackLevelCorrection::init([[maybe_unused]] IPAContext &context,\n+\t\t\t       const YamlObject &tuningData)\n+{\n+\tblackLevelRed_ = tuningData[\"R\"].get<int16_t>(256);\n+\tblackLevelGreenR_ = tuningData[\"Gr\"].get<int16_t>(256);\n+\tblackLevelGreenB_ = tuningData[\"Gb\"].get<int16_t>(256);\n+\tblackLevelBlue_ = tuningData[\"B\"].get<int16_t>(256);\n+\n+\ttuningParameters_ = true;\n+\n+\tLOG(RkISP1Blc, Debug)\n+\t\t<< \"Black levels: red \" << blackLevelRed_\n+\t\t<< \", green (red) \" << blackLevelGreenR_\n+\t\t<< \", green (blue) \" << blackLevelGreenB_\n+\t\t<< \", blue \" << blackLevelBlue_;\n+\n+\treturn 0;\n+}\n+\n /**\n  * \\copydoc libcamera::ipa::Algorithm::prepare\n  */\n@@ -37,15 +70,15 @@ void BlackLevelCorrection::prepare(IPAContext &context,\n {\n \tif (context.frameContext.frameCount > 0)\n \t\treturn;\n-\t/*\n-\t * Substract fixed values taken from imx219 tuning file.\n-\t * \\todo Use a configuration file for it ?\n-\t */\n+\n+\tif (!tuningParameters_)\n+\t\treturn;\n+\n \tparams->others.bls_config.enable_auto = 0;\n-\tparams->others.bls_config.fixed_val.r = 256;\n-\tparams->others.bls_config.fixed_val.gr = 256;\n-\tparams->others.bls_config.fixed_val.gb = 256;\n-\tparams->others.bls_config.fixed_val.b = 256;\n+\tparams->others.bls_config.fixed_val.r = blackLevelRed_;\n+\tparams->others.bls_config.fixed_val.gr = blackLevelGreenR_;\n+\tparams->others.bls_config.fixed_val.gb = blackLevelGreenB_;\n+\tparams->others.bls_config.fixed_val.b = blackLevelBlue_;\n \n \tparams->module_en_update |= RKISP1_CIF_ISP_MODULE_BLS;\n \tparams->module_ens |= RKISP1_CIF_ISP_MODULE_BLS;\ndiff --git a/src/ipa/rkisp1/algorithms/blc.h b/src/ipa/rkisp1/algorithms/blc.h\nindex 69874d8f5e18..c2649dd7736e 100644\n--- a/src/ipa/rkisp1/algorithms/blc.h\n+++ b/src/ipa/rkisp1/algorithms/blc.h\n@@ -20,10 +20,18 @@ namespace ipa::rkisp1::algorithms {\n class BlackLevelCorrection : public Algorithm\n {\n public:\n-\tBlackLevelCorrection() = default;\n+\tBlackLevelCorrection();\n \t~BlackLevelCorrection() = default;\n \n+\tint init(IPAContext &context, const YamlObject &tuningData) override;\n \tvoid prepare(IPAContext &context, rkisp1_params_cfg *params) override;\n+\n+private:\n+\tbool tuningParameters_;\n+\tint16_t blackLevelRed_;\n+\tint16_t blackLevelGreenR_;\n+\tint16_t blackLevelGreenB_;\n+\tint16_t blackLevelBlue_;\n };\n \n } /* namespace ipa::rkisp1::algorithms */\n","prefixes":["libcamera-devel","v4","12/12"]}