From c13f86704b129636bb6d84f8b8ca37826ded3238 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Tue, 26 Jul 2022 05:46:40 +0300 Subject: ipa: raspberrypi: agc: Use YamlObject::getList() Replace the manual implementation of the readList() functions with YamlObject::getList(). Signed-off-by: Laurent Pinchart Reviewed-by: Naushir Patuck Tested-by: Naushir Patuck --- src/ipa/raspberrypi/controller/rpi/agc.cpp | 43 +++++++++--------------------- 1 file changed, 13 insertions(+), 30 deletions(-) diff --git a/src/ipa/raspberrypi/controller/rpi/agc.cpp b/src/ipa/raspberrypi/controller/rpi/agc.cpp index 5037f900..bd54a639 100644 --- a/src/ipa/raspberrypi/controller/rpi/agc.cpp +++ b/src/ipa/raspberrypi/controller/rpi/agc.cpp @@ -5,6 +5,7 @@ * agc.cpp - AGC/AEC control algorithm */ +#include #include #include @@ -71,44 +72,26 @@ readMeteringModes(std::map &metering_modes, return { 0, first }; } -static int readList(std::vector &list, - const libcamera::YamlObject ¶ms) -{ - for (const auto &p : params.asList()) { - auto value = p.get(); - if (!value) - return -EINVAL; - list.push_back(*value); - } - - return list.size(); -} - -static int readList(std::vector &list, - const libcamera::YamlObject ¶ms) -{ - for (const auto &p : params.asList()) { - auto value = p.get(); - if (!value) - return -EINVAL; - list.push_back(*value * 1us); - } - - return list.size(); -} - int AgcExposureMode::read(const libcamera::YamlObject ¶ms) { - int numShutters = readList(shutter, params["shutter"]); - int numAgs = readList(gain, params["gain"]); + auto value = params["shutter"].getList(); + if (!value) + return -EINVAL; + std::transform(value->begin(), value->end(), std::back_inserter(shutter), + [](double v) { return v * 1us; }); + + value = params["gain"].getList(); + if (!value) + return -EINVAL; + gain = std::move(*value); - if (numShutters < 2 || numAgs < 2) { + if (shutter.size() < 2 || gain.size() < 2) { LOG(RPiAgc, Error) << "AgcExposureMode: must have at least two entries in exposure profile"; return -EINVAL; } - if (numShutters != numAgs) { + if (shutter.size() != gain.size()) { LOG(RPiAgc, Error) << "AgcExposureMode: expect same number of exposure and gain entries in exposure profile"; return -EINVAL; -- cgit v1.2.1