From patchwork Thu Jun 13 01:39:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 20282 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 AB459C32D0 for ; Thu, 13 Jun 2024 01:40:32 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id A17A165493; Thu, 13 Jun 2024 03:40:31 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="ucstaAus"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 36C3E6549B for ; Thu, 13 Jun 2024 03:40:18 +0200 (CEST) Received: from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi [81.175.209.231]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 77BBCE39; Thu, 13 Jun 2024 03:40:04 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1718242804; bh=2MXmYmAqW1FhyNWiain1GT8MZZQ8izk1FG0fwfjn7hA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ucstaAusrvwdpCpNxyMjLWtY3gmQxbKGDVjwphBmAUv22tqiova6zmUAy4llR4NYb T0XgsvFtrtFMFQI7AXq1hMGPpfhG4+c6YhEpxV4DcNgAz+j7tCZGlSeR9RaU9zSxF6 7CyC9w5tCN7bMA5qbm+V93IkL6XidfBnomGnvwT0= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Cc: Paul Elder , David Plowman , Naushir Patuck Subject: [PATCH 10/11] ipa: rpi: controller: Replace Pwl::readYaml() with YamlObject::get() Date: Thu, 13 Jun 2024 04:39:43 +0300 Message-ID: <20240613013944.23344-11-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.44.2 In-Reply-To: <20240613013944.23344-1-laurent.pinchart@ideasonboard.com> References: <20240613013944.23344-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" Now that deserializing a Pwl object from YAML data is possible using the YamlObject::get() function, replace all usage of Pwl::readYaml() to prepare for its removal. Signed-off-by: Laurent Pinchart Reviewed-by: Paul Elder Reviewed-by: Kieran Bingham Reviewed-by: David Plowman Tested-by: Laurent Pinchart --- src/ipa/rpi/controller/rpi/af.cpp | 2 +- src/ipa/rpi/controller/rpi/agc_channel.cpp | 9 +++++---- src/ipa/rpi/controller/rpi/awb.cpp | 3 ++- src/ipa/rpi/controller/rpi/ccm.cpp | 6 +++--- src/ipa/rpi/controller/rpi/contrast.cpp | 4 +++- src/ipa/rpi/controller/rpi/geq.cpp | 6 +++--- src/ipa/rpi/controller/rpi/hdr.cpp | 4 ++-- src/ipa/rpi/controller/rpi/tonemap.cpp | 2 +- 8 files changed, 20 insertions(+), 16 deletions(-) diff --git a/src/ipa/rpi/controller/rpi/af.cpp b/src/ipa/rpi/controller/rpi/af.cpp index 304629d6d4e5..5ca76dd98b4b 100644 --- a/src/ipa/rpi/controller/rpi/af.cpp +++ b/src/ipa/rpi/controller/rpi/af.cpp @@ -139,7 +139,7 @@ int Af::CfgParams::read(const libcamera::YamlObject ¶ms) readNumber(skipFrames, params, "skip_frames"); if (params.contains("map")) - map.readYaml(params["map"]); + map = params["map"].get(ipa::Pwl{}); else LOG(RPiAf, Warning) << "No map defined"; diff --git a/src/ipa/rpi/controller/rpi/agc_channel.cpp b/src/ipa/rpi/controller/rpi/agc_channel.cpp index a381dd972215..cf2565a83836 100644 --- a/src/ipa/rpi/controller/rpi/agc_channel.cpp +++ b/src/ipa/rpi/controller/rpi/agc_channel.cpp @@ -130,7 +130,8 @@ int AgcConstraint::read(const libcamera::YamlObject ¶ms) return -EINVAL; qHi = *value; - return yTarget.readYaml(params["y_target"]); + yTarget = params["y_target"].get(ipa::Pwl{}); + return yTarget.empty() ? -EINVAL : 0; } static std::tuple @@ -237,9 +238,9 @@ int AgcConfig::read(const libcamera::YamlObject ¶ms) return ret; } - ret = yTarget.readYaml(params["y_target"]); - if (ret) - return ret; + yTarget = params["y_target"].get(ipa::Pwl{}); + if (yTarget.empty()) + return -EINVAL; speed = params["speed"].get(0.2); startupFrames = params["startup_frames"].get(10); diff --git a/src/ipa/rpi/controller/rpi/awb.cpp b/src/ipa/rpi/controller/rpi/awb.cpp index 603953d7d863..003c8fa137f3 100644 --- a/src/ipa/rpi/controller/rpi/awb.cpp +++ b/src/ipa/rpi/controller/rpi/awb.cpp @@ -49,7 +49,8 @@ int AwbPrior::read(const libcamera::YamlObject ¶ms) return -EINVAL; lux = *value; - return prior.readYaml(params["prior"]); + prior = params["prior"].get(ipa::Pwl{}); + return prior.empty() ? -EINVAL : 0; } static int readCtCurve(ipa::Pwl &ctR, ipa::Pwl &ctB, const libcamera::YamlObject ¶ms) diff --git a/src/ipa/rpi/controller/rpi/ccm.cpp b/src/ipa/rpi/controller/rpi/ccm.cpp index 3272a1416ffa..e673964c1856 100644 --- a/src/ipa/rpi/controller/rpi/ccm.cpp +++ b/src/ipa/rpi/controller/rpi/ccm.cpp @@ -71,9 +71,9 @@ int Ccm::read(const libcamera::YamlObject ¶ms) int ret; if (params.contains("saturation")) { - ret = config_.saturation.readYaml(params["saturation"]); - if (ret) - return ret; + config_.saturation = params["saturation"].get(ipa::Pwl{}); + if (config_.saturation.empty()) + return -EINVAL; } for (auto &p : params["ccms"].asList()) { diff --git a/src/ipa/rpi/controller/rpi/contrast.cpp b/src/ipa/rpi/controller/rpi/contrast.cpp index 66871a61ed28..9b37943ae9c9 100644 --- a/src/ipa/rpi/controller/rpi/contrast.cpp +++ b/src/ipa/rpi/controller/rpi/contrast.cpp @@ -53,7 +53,9 @@ int Contrast::read(const libcamera::YamlObject ¶ms) config_.hiHistogram = params["hi_histogram"].get(0.95); config_.hiLevel = params["hi_level"].get(0.95); config_.hiMax = params["hi_max"].get(2000); - return config_.gammaCurve.readYaml(params["gamma_curve"]); + + config_.gammaCurve = params["gamma_curve"].get(ipa::Pwl{}); + return config_.gammaCurve.empty() ? -EINVAL : 0; } void Contrast::setBrightness(double brightness) diff --git a/src/ipa/rpi/controller/rpi/geq.cpp b/src/ipa/rpi/controller/rpi/geq.cpp index c9c38ebff5ba..40e7191ba16a 100644 --- a/src/ipa/rpi/controller/rpi/geq.cpp +++ b/src/ipa/rpi/controller/rpi/geq.cpp @@ -44,9 +44,9 @@ int Geq::read(const libcamera::YamlObject ¶ms) } if (params.contains("strength")) { - int ret = config_.strength.readYaml(params["strength"]); - if (ret) - return ret; + config_.strength = params["strength"].get(ipa::Pwl{}); + if (config_.strength.empty()) + return -EINVAL; } return 0; diff --git a/src/ipa/rpi/controller/rpi/hdr.cpp b/src/ipa/rpi/controller/rpi/hdr.cpp index d533a4ea4e65..f3da8291bf5d 100644 --- a/src/ipa/rpi/controller/rpi/hdr.cpp +++ b/src/ipa/rpi/controller/rpi/hdr.cpp @@ -42,7 +42,7 @@ void HdrConfig::read(const libcamera::YamlObject ¶ms, const std::string &mod /* Lens shading related parameters. */ if (params.contains("spatial_gain_curve")) { - spatialGainCurve.readYaml(params["spatial_gain_curve"]); + spatialGainCurve = params["spatial_gain_curve"].get(ipa::Pwl{}); } else if (params.contains("spatial_gain")) { double spatialGain = params["spatial_gain"].get(2.0); spatialGainCurve.append(0.0, spatialGain); @@ -66,7 +66,7 @@ void HdrConfig::read(const libcamera::YamlObject ¶ms, const std::string &mod iirStrength = params["iir_strength"].get(8.0); strength = params["strength"].get(1.5); if (tonemapEnable) - tonemap.readYaml(params["tonemap"]); + tonemap = params["tonemap"].get(ipa::Pwl{}); speed = params["speed"].get(1.0); if (params.contains("hi_quantile_targets")) { hiQuantileTargets = params["hi_quantile_targets"].getList().value(); diff --git a/src/ipa/rpi/controller/rpi/tonemap.cpp b/src/ipa/rpi/controller/rpi/tonemap.cpp index 2dc50dfc8d2d..3422adfe7dee 100644 --- a/src/ipa/rpi/controller/rpi/tonemap.cpp +++ b/src/ipa/rpi/controller/rpi/tonemap.cpp @@ -33,7 +33,7 @@ int Tonemap::read(const libcamera::YamlObject ¶ms) config_.detailSlope = params["detail_slope"].get(0.1); config_.iirStrength = params["iir_strength"].get(1.0); config_.strength = params["strength"].get(1.0); - config_.tonemap.readYaml(params["tone_curve"]); + config_.tonemap = params["tone_curve"].get(ipa::Pwl{}); return 0; }