From patchwork Mon Aug 5 12:05:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Klug X-Patchwork-Id: 20772 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 22B68C323E for ; Mon, 5 Aug 2024 12:05:58 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 7BFC26337E; Mon, 5 Aug 2024 14:05:56 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="kmz14V2x"; 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 E461D63369 for ; Mon, 5 Aug 2024 14:05:54 +0200 (CEST) Received: from ideasonboard.com (unknown [IPv6:2a00:6020:448c:6c00:30ff:e7b4:349c:44ce]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 8D1E4AB5; Mon, 5 Aug 2024 14:05:03 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1722859503; bh=CSJ1LfBzo/4SQKazTF2Sb4F+6RnatDuscp4MOkWhoGc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kmz14V2x6633sOls2ePeUhCxPLULXlStMM4YPgLAwrvFj45OrjmCLVxBNq1hBWLFb qGNm+Mi2Qb+OczOlCPq0BAbdPUn1IdvX1jVnNgUFICx8n1u1Rmm5Ojb6KZXUj7JZly OShx7U30KSn0ga1zvrwz+8kW+pQiWM1TaSU4Ei4k= From: Stefan Klug To: libcamera-devel@lists.libcamera.org Cc: David Plowman , Stefan Klug Subject: [PATCH v1 2/6] ipa: rkisp1: awb: Load white balance gains from tuning file Date: Mon, 5 Aug 2024 14:05:03 +0200 Message-ID: <20240805120522.1613342-3-stefan.klug@ideasonboard.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240805120522.1613342-1-stefan.klug@ideasonboard.com> References: <20240805120522.1613342-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" For the implementation of a manual colour temperature setting, it is necessary to read predefined colour gains per colour temperature from the tuning file. Implement this in a backwards compatible way. If no gains are contained in the tuning file, loading just continues as before. Signed-off-by: Stefan Klug Reviewed-by: Kieran Bingham --- src/ipa/rkisp1/algorithms/awb.cpp | 18 ++++++++++++++++++ src/ipa/rkisp1/algorithms/awb.h | 6 ++++++ 2 files changed, 24 insertions(+) diff --git a/src/ipa/rkisp1/algorithms/awb.cpp b/src/ipa/rkisp1/algorithms/awb.cpp index 4ccafd48dedd..957d24fe3425 100644 --- a/src/ipa/rkisp1/algorithms/awb.cpp +++ b/src/ipa/rkisp1/algorithms/awb.cpp @@ -39,6 +39,24 @@ Awb::Awb() { } +/** + * \copydoc libcamera::ipa::Algorithm::init + */ +int Awb::init(IPAContext &context, const YamlObject &tuningData) +{ + MatrixInterpolator gains; + int ret = gains.readYaml(tuningData["gains"], "ct", "gains"); + if (ret < 0) + LOG(RkISP1Awb, Warning) + << "Failed to parse 'gains' " + << "parameter from tuning file; " + << "rgb gains will not be set based on colour temperature"; + else + gains_ = gains; + + return 0; +} + /** * \copydoc libcamera::ipa::Algorithm::configure */ diff --git a/src/ipa/rkisp1/algorithms/awb.h b/src/ipa/rkisp1/algorithms/awb.h index 06c92896e2dc..a010e6d1cb3c 100644 --- a/src/ipa/rkisp1/algorithms/awb.h +++ b/src/ipa/rkisp1/algorithms/awb.h @@ -7,6 +7,10 @@ #pragma once +#include + +#include "libipa/matrix_interpolator.h" + #include "algorithm.h" namespace libcamera { @@ -19,6 +23,7 @@ public: Awb(); ~Awb() = default; + int init(IPAContext &context, const YamlObject &tuningData) override; int configure(IPAContext &context, const IPACameraSensorInfo &configInfo) override; void queueRequest(IPAContext &context, const uint32_t frame, IPAFrameContext &frameContext, @@ -34,6 +39,7 @@ public: private: uint32_t estimateCCT(double red, double green, double blue); + std::optional> gains_; bool rgbMode_; };