From patchwork Thu Dec 19 17:57:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Klug X-Patchwork-Id: 22410 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 6A7C0C3272 for ; Thu, 19 Dec 2024 17:57:43 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id ACCC66847E; Thu, 19 Dec 2024 18:57:41 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="BRD8whS+"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 1B08E61899 for ; Thu, 19 Dec 2024 18:57:39 +0100 (CET) Received: from ideasonboard.com (unknown [IPv6:2a00:6020:448c:6c00:783:85f9:c998:cb11]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 523346D6; Thu, 19 Dec 2024 18:57:00 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1734631020; bh=3kYmJGs6xN+tkPCw4zkGSo7C8b1y2iHIEh4PeJ1uMD8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BRD8whS+j5ycMDqsp1fbIHq4RHO+yD3XePsUb4Lz0Ry43znhfNZ+uM0sIYmHHK0mG j+qFVbH83+YXK/1vKjjRYvD8yttbCZOZhtU1herOxgKzTQ60wYrrAybWW/yEA6L/72 ev5r63lDDbkuglrm77wz/Q6ZXaPUuvfSDceDqxjM= From: Stefan Klug To: libcamera-devel@lists.libcamera.org Cc: Stefan Klug , Kieran Bingham , Paul Elder , Laurent Pinchart Subject: [PATCH v6 2/9] ipa: rkisp1: awb: Load white balance gains from tuning file Date: Thu, 19 Dec 2024 18:57:19 +0100 Message-ID: <20241219175729.293782-3-stefan.klug@ideasonboard.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241219175729.293782-1-stefan.klug@ideasonboard.com> References: <20241219175729.293782-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 Reviewed-by: Paul Elder Reviewed-by: Laurent Pinchart --- Changes in v6: - Rename gains_ to colourGainCurve_ - Rename gains to colourGains in tuning file Changes in v5: - Replace Interpolator with Interpolator --- src/ipa/rkisp1/algorithms/awb.cpp | 18 ++++++++++++++++++ src/ipa/rkisp1/algorithms/awb.h | 7 +++++++ 2 files changed, 25 insertions(+) diff --git a/src/ipa/rkisp1/algorithms/awb.cpp b/src/ipa/rkisp1/algorithms/awb.cpp index 4bb4f5b88375..e23f67a96edf 100644 --- a/src/ipa/rkisp1/algorithms/awb.cpp +++ b/src/ipa/rkisp1/algorithms/awb.cpp @@ -41,6 +41,24 @@ Awb::Awb() { } +/** + * \copydoc libcamera::ipa::Algorithm::init + */ +int Awb::init([[maybe_unused]] IPAContext &context, const YamlObject &tuningData) +{ + Interpolator> gainCurve; + int ret = gainCurve.readYaml(tuningData["colourGains"], "ct", "gains"); + if (ret < 0) + LOG(RkISP1Awb, Warning) + << "Failed to parse 'colourGains' " + << "parameter from tuning file; " + << "manual colour temperature will not work properly"; + else + colourGainCurve_ = gainCurve; + + return 0; +} + /** * \copydoc libcamera::ipa::Algorithm::configure */ diff --git a/src/ipa/rkisp1/algorithms/awb.h b/src/ipa/rkisp1/algorithms/awb.h index 6ac3a5c3838b..e424804861a6 100644 --- a/src/ipa/rkisp1/algorithms/awb.h +++ b/src/ipa/rkisp1/algorithms/awb.h @@ -7,6 +7,11 @@ #pragma once +#include + +#include "libipa/interpolator.h" +#include "libipa/vector.h" + #include "algorithm.h" namespace libcamera { @@ -19,6 +24,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, @@ -32,6 +38,7 @@ public: ControlList &metadata) override; private: + std::optional>> colourGainCurve_; bool rgbMode_; };