From 3b4414ccaaa44f220d58f9e01781ec1962e762bb Mon Sep 17 00:00:00 2001 From: Stefan Klug Date: Wed, 19 Nov 2025 14:22:10 +0100 Subject: [PATCH] ipa: libipa: pwl: Allow to parse a plain yaml value as single point PWL In the tuning files, it is useful to specify some values as PWL that produces a different output value depending on an input value. For example it is useful to specify the relativeLuminanceTarget depending on the lux level, so that the regulation regulates a bit darker in low light scenes. For simple setups this is not necessary and a single value is sufficient. This patch extends the yaml loading code, so that a single point PWL can also be specified as a plain value. This way the following yaml expressions are all valid: yTarget: [ 1000, 0.15, 2000, 0.17 ] # Regular PWL yTarget: [ 0, 0.17 ] # Single point PWL yTarget: 0.17 # Same as above For cases (I'm not aware of any) where a single point Pwl is not allowed there is no change as that must be checked externally anyways. Signed-off-by: Stefan Klug Reviewed-by: Kieran Bingham Reviewed-by: Daniel Scally --- src/ipa/libipa/pwl.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/ipa/libipa/pwl.cpp b/src/ipa/libipa/pwl.cpp index 69a93341..72b63c4d 100644 --- a/src/ipa/libipa/pwl.cpp +++ b/src/ipa/libipa/pwl.cpp @@ -437,6 +437,15 @@ template<> std::optional YamlObject::Getter::get(const YamlObject &obj) const { + /* Treat a single value as single point PWL. */ + if (obj.isValue()) { + auto v = obj.get(); + if (!v) + return std::nullopt; + + return ipa::Pwl({ { { 0.0, *v } } }); + } + if (!obj.size() || obj.size() % 2) return std::nullopt;