From patchwork Mon Jul 1 14:38:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Klug X-Patchwork-Id: 20496 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 55346BEFBE for ; Mon, 1 Jul 2024 14:41:48 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 1736463334; Mon, 1 Jul 2024 16:41:48 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="J4CltYvU"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 5C56162E24 for ; Mon, 1 Jul 2024 16:41:45 +0200 (CEST) Received: from ideasonboard.com (unknown [IPv6:2a00:6020:448c:6c00:89b2:f6c7:b29b:4e5c]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 7B1C1289; Mon, 1 Jul 2024 16:41:18 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1719844878; bh=KPb4J19/zYBrN1CUguZ5WOA3gCeNPSb7o/hh2n8nF08=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=J4CltYvUKvGyFDa4HWEbP/0ld/kd3KrRc/U7Cr5w8U1MrE8GXLcsFLBs7zbRWMDkJ AwbJboDbsEjgY6j05jT6irqUyMhuPFvFCZ0VGV/ZlT53lA7dYwB6Z1BFkn12P7MhOx Yb9OMxxWc4NyaBzYEQNeIiLXlFOcj6UF7aO/fCmE= From: Stefan Klug To: libcamera-devel@lists.libcamera.org Cc: Stefan Klug Subject: [PATCH 3/5] ipa: rkisp1: blc: Query black levels from camera sensor helper Date: Mon, 1 Jul 2024 16:38:26 +0200 Message-ID: <20240701144122.3418955-4-stefan.klug@ideasonboard.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240701144122.3418955-1-stefan.klug@ideasonboard.com> References: <20240701144122.3418955-1-stefan.klug@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" The black levels from the camera sensor helper are then used to do the black level correction. Black levels can still be overwritten by the tuning file. Signed-off-by: Stefan Klug --- src/ipa/rkisp1/algorithms/blc.cpp | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/src/ipa/rkisp1/algorithms/blc.cpp b/src/ipa/rkisp1/algorithms/blc.cpp index d2e743541c99..0c39c3b47da5 100644 --- a/src/ipa/rkisp1/algorithms/blc.cpp +++ b/src/ipa/rkisp1/algorithms/blc.cpp @@ -46,10 +46,30 @@ BlackLevelCorrection::BlackLevelCorrection() 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); + auto blackLevels = context.camHelper->blackLevels(); + if (blackLevels) { + Span levels = *blackLevels; + blackLevelRed_ = levels[0]; + blackLevelGreenR_ = levels[1]; + blackLevelGreenB_ = levels[2]; + blackLevelBlue_ = levels[3]; + } else + LOG(RkISP1Blc, Warning) + << "No black levels provided by camera sensor helper"; + + if (!blackLevels || (tuningData.contains("R") && + tuningData.contains("Gr") && + tuningData.contains("Gb") && + tuningData.contains("B"))) { + blackLevelRed_ = tuningData["R"].get(256); + blackLevelGreenR_ = tuningData["Gr"].get(256); + blackLevelGreenB_ = tuningData["Gb"].get(256); + blackLevelBlue_ = tuningData["B"].get(256); + + if (blackLevels) + LOG(RkISP1Blc, Warning) + << "Black levels overwritten by tuning file"; + } tuningParameters_ = true;