{"id":20572,"url":"https://patchwork.libcamera.org/api/patches/20572/?format=json","web_url":"https://patchwork.libcamera.org/patch/20572/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/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":"<20240703225230.3530-12-laurent.pinchart@ideasonboard.com>","date":"2024-07-03T22:52:30","name":"[v1,11/11] ipa: rkisp1: blc: Add support for BLS in compand","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"f7459fc0f9fe392e7d69168ba07c6025c200f68b","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/?format=json","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/20572/mbox/","series":[{"id":4442,"url":"https://patchwork.libcamera.org/api/series/4442/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=4442","date":"2024-07-03T22:52:19","name":"rkisp1: Support BLS on i.MX8MP","version":1,"mbox":"https://patchwork.libcamera.org/series/4442/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/20572/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/20572/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 BE7E8BEFBE\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  3 Jul 2024 22:53:22 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 631406335E;\n\tThu,  4 Jul 2024 00:53:22 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 39D9763352\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu,  4 Jul 2024 00:53:02 +0200 (CEST)","from pendragon.ideasonboard.com\n\t(117.145-247-81.adsl-dyn.isp.belgacom.be [81.247.145.117])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id C9DEF4CC;\n\tThu,  4 Jul 2024 00:52:33 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"SBWvRcu/\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1720047153;\n\tbh=lyWrbqwq8Ee+S0xxKiArFicLOsXddvF5sa+XeZBTBok=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=SBWvRcu/UPuxLA/Dby/9WQeycu+GTVO65/q74VZFWjQeGVOk6AKbcPp3y/wephAqs\n\t2RnpZvZ2gIJhu6gn6u2luMg51DnPKe7R15LHcobB5blWo3BDdHWLwohar06GV80OGB\n\tfmjEQNxjQdrDYDizVbRK0RFPSDr2hrYKqo/D0ztk=","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Cc":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>,\n\tPaul Elder <paul.elder@ideasonboard.com>","Subject":"[PATCH v1 11/11] ipa: rkisp1: blc: Add support for BLS in compand","Date":"Thu,  4 Jul 2024 01:52:30 +0300","Message-ID":"<20240703225230.3530-12-laurent.pinchart@ideasonboard.com>","X-Mailer":"git-send-email 2.44.2","In-Reply-To":"<20240703225230.3530-1-laurent.pinchart@ideasonboard.com>","References":"<20240703225230.3530-1-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","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":"From: Paul Elder <paul.elder@ideasonboard.com>\n\nAdd support for black level subtraction to use the BLS in the compand\nblock, for versions of the ISP (such as the one on the i.MX8MP) that\nlack the dedicated BLS block but have BLS in the companding block.\n\nSigned-off-by: Paul Elder <paul.elder@ideasonboard.com>\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n src/ipa/rkisp1/algorithms/blc.cpp | 30 ++++++++++++++++++++++--------\n 1 file changed, 22 insertions(+), 8 deletions(-)","diff":"diff --git a/src/ipa/rkisp1/algorithms/blc.cpp b/src/ipa/rkisp1/algorithms/blc.cpp\nindex 464a0e066dd4..bc329ea035aa 100644\n--- a/src/ipa/rkisp1/algorithms/blc.cpp\n+++ b/src/ipa/rkisp1/algorithms/blc.cpp\n@@ -110,7 +110,7 @@ int BlackLevelCorrection::init(IPAContext &context, const YamlObject &tuningData\n /**\n  * \\copydoc libcamera::ipa::Algorithm::prepare\n  */\n-void BlackLevelCorrection::prepare([[maybe_unused]] IPAContext &context,\n+void BlackLevelCorrection::prepare(IPAContext &context,\n \t\t\t\t   const uint32_t frame,\n \t\t\t\t   [[maybe_unused]] IPAFrameContext &frameContext,\n \t\t\t\t   RkISP1Params *params)\n@@ -124,14 +124,28 @@ void BlackLevelCorrection::prepare([[maybe_unused]] IPAContext &context,\n \tif (!tuningParameters_)\n \t\treturn;\n \n-\tauto config = params->block<Block::Bls>(RkISP1Params::State::Enable);\n+\tif (context.hw->compand) {\n+\t\tauto config = params->block<Block::CompandBls>(RkISP1Params::State::Enable);\n \n-\tconfig->enable_auto = 0;\n-\t/* The rkisp1 uses 12bit based black levels. Scale down accordingly. */\n-\tconfig->fixed_val.r = blackLevelRed_ >> 4;\n-\tconfig->fixed_val.gr = blackLevelGreenR_ >> 4;\n-\tconfig->fixed_val.gb = blackLevelGreenB_ >> 4;\n-\tconfig->fixed_val.b = blackLevelBlue_ >> 4;\n+\t\t/*\n+\t\t * Scale up to the 20-bit black levels used by the companding\n+\t\t * block.\n+\t\t */\n+\t\tconfig->r = blackLevelRed_ << 4;\n+\t\tconfig->gr = blackLevelGreenR_ << 4;\n+\t\tconfig->gb = blackLevelGreenB_ << 4;\n+\t\tconfig->b = blackLevelBlue_ << 4;\n+\t} else {\n+\t\tauto config = params->block<Block::Bls>(RkISP1Params::State::Enable);\n+\n+\t\tconfig->enable_auto = 0;\n+\n+\t\t/* Scale down to the 12-bit black levels used by the BLS block. */\n+\t\tconfig->fixed_val.r = blackLevelRed_ >> 4;\n+\t\tconfig->fixed_val.gr = blackLevelGreenR_ >> 4;\n+\t\tconfig->fixed_val.gb = blackLevelGreenB_ >> 4;\n+\t\tconfig->fixed_val.b = blackLevelBlue_ >> 4;\n+\t}\n }\n \n /**\n","prefixes":["v1","11/11"]}