From patchwork Wed Jul 3 22:52:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 20572 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 BE7E8BEFBE for ; Wed, 3 Jul 2024 22:53:22 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 631406335E; Thu, 4 Jul 2024 00:53:22 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="SBWvRcu/"; 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 39D9763352 for ; Thu, 4 Jul 2024 00:53:02 +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 C9DEF4CC; Thu, 4 Jul 2024 00:52:33 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1720047153; bh=lyWrbqwq8Ee+S0xxKiArFicLOsXddvF5sa+XeZBTBok=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SBWvRcu/UPuxLA/Dby/9WQeycu+GTVO65/q74VZFWjQeGVOk6AKbcPp3y/wephAqs 2RnpZvZ2gIJhu6gn6u2luMg51DnPKe7R15LHcobB5blWo3BDdHWLwohar06GV80OGB fmjEQNxjQdrDYDizVbRK0RFPSDr2hrYKqo/D0ztk= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Cc: Jacopo Mondi , Paul Elder 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 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 Add support for black level subtraction to use the BLS in the compand block, for versions of the ISP (such as the one on the i.MX8MP) that lack the dedicated BLS block but have BLS in the companding block. Signed-off-by: Paul Elder Signed-off-by: Laurent Pinchart Reviewed-by: Jacopo Mondi --- src/ipa/rkisp1/algorithms/blc.cpp | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/src/ipa/rkisp1/algorithms/blc.cpp b/src/ipa/rkisp1/algorithms/blc.cpp index 464a0e066dd4..bc329ea035aa 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,14 +124,28 @@ void BlackLevelCorrection::prepare([[maybe_unused]] IPAContext &context, if (!tuningParameters_) return; - auto config = params->block(RkISP1Params::State::Enable); + if (context.hw->compand) { + auto config = params->block(RkISP1Params::State::Enable); - 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(RkISP1Params::State::Enable); + + 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; + } } /**