From patchwork Thu Jul 4 16:20:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 20587 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 67BD4BD87C for ; Thu, 4 Jul 2024 16:21:23 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E869563334; Thu, 4 Jul 2024 18:21:22 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="Vhmbcnr+"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 2D39F6335E for ; Thu, 4 Jul 2024 18:21:07 +0200 (CEST) Received: from pendragon.ideasonboard.com (117.145-247-81.adsl-dyn.isp.belgacom.be [81.247.145.117]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 383EB502; Thu, 4 Jul 2024 18:20:38 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1720110038; bh=sUGjIC3hICNDnoYck6CjMQTFh86jCNfaYSxefyUteJ0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Vhmbcnr+UFE5ea65tlnEHPzd6+4Xgr9ohCacmkCxAVcmSHFXrOxuKo+47TihLAJSX Pwjr2yx6CbcwPMANg/BeWKwy8k3k1hoFuxrWoLyr2/gfUk6NsE7rl3qdIbYQRaPBUr dNAWsx0s3b90J8ZzA8RL6Sn3TbJ5Gxgs7BL3Y+Sk= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Cc: Jacopo Mondi , Paul Elder Subject: [PATCH v2 11/11] ipa: rkisp1: blc: Add support for BLS in compand Date: Thu, 4 Jul 2024 19:20:35 +0300 Message-ID: <20240704162035.15074-12-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.44.2 In-Reply-To: <20240704162035.15074-1-laurent.pinchart@ideasonboard.com> References: <20240704162035.15074-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 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" From: Paul Elder Extend the RkISP1 BLC algorithm to use the ISP 'companding' block for versions of the ISP (such as the one on the i.MX8MP) that lack the dedicated BLS block but implement BLS as part of the companding block. Signed-off-by: Paul Elder Signed-off-by: Laurent Pinchart Reviewed-by: Jacopo Mondi Reviewed-by: Stefan Klug --- src/ipa/rkisp1/algorithms/blc.cpp | 33 ++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/src/ipa/rkisp1/algorithms/blc.cpp b/src/ipa/rkisp1/algorithms/blc.cpp index df1a91a413db..9bc10f4ad07f 100644 --- a/src/ipa/rkisp1/algorithms/blc.cpp +++ b/src/ipa/rkisp1/algorithms/blc.cpp @@ -110,7 +110,7 @@ int BlackLevelCorrection::init(IPAContext &context, const YamlObject &tuningData /** * \copydoc libcamera::ipa::Algorithm::prepare */ -void BlackLevelCorrection::prepare([[maybe_unused]] IPAContext &context, +void BlackLevelCorrection::prepare(IPAContext &context, const uint32_t frame, [[maybe_unused]] IPAFrameContext &frameContext, RkISP1Params *params) @@ -124,15 +124,30 @@ void BlackLevelCorrection::prepare([[maybe_unused]] IPAContext &context, if (!tuningParameters_) return; - auto config = params->block(); - config.setEnabled(true); + if (context.hw->compand) { + auto config = params->block(); + config.setEnabled(true); - config->enable_auto = 0; - /* The rkisp1 uses 12bit based black levels. Scale down accordingly. */ - config->fixed_val.r = blackLevelRed_ >> 4; - config->fixed_val.gr = blackLevelGreenR_ >> 4; - config->fixed_val.gb = blackLevelGreenB_ >> 4; - config->fixed_val.b = blackLevelBlue_ >> 4; + /* + * Scale up to the 20-bit black levels used by the companding + * block. + */ + config->r = blackLevelRed_ << 4; + config->gr = blackLevelGreenR_ << 4; + config->gb = blackLevelGreenB_ << 4; + config->b = blackLevelBlue_ << 4; + } else { + auto config = params->block(); + config.setEnabled(true); + + config->enable_auto = 0; + + /* Scale down to the 12-bit black levels used by the BLS block. */ + config->fixed_val.r = blackLevelRed_ >> 4; + config->fixed_val.gr = blackLevelGreenR_ >> 4; + config->fixed_val.gb = blackLevelGreenB_ >> 4; + config->fixed_val.b = blackLevelBlue_ >> 4; + } } /**