From patchwork Wed Jul 27 02:38:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 16825 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 17F70C3275 for ; Wed, 27 Jul 2022 02:38:39 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id A30EB6333C; Wed, 27 Jul 2022 04:38:38 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1658889518; bh=l78zBW/LwB1XHylCSimYUBear1h4A4iOs0lqRZY8i80=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=Ydzxteb89tbxEPsII9IxztP6wU/aAlDkGxilzAHCat0I3+3fKY/qWaFO21ngNz/dt uV5qKDn23yeRTaD1cAlGrHDCz2m3fih6me8uZAs39grmpwwP1BdmTgt6Gs5NfjBSSp RUvt1qNVxXyMh7Msfnj2f8znq6ZHg+/QiNH4qc5SjCnjQFEfJRO5I2xB2Zp4QGGq/1 fr5GPwu/2NB+xqnNrD9UFDoNEk2wTQ+VQ4DDr7BPwz5vc1KlmzhsozNioVAOY/iSJQ 1jerXdUnvQ6y+qCzXjJW4a66QBNDZSW0ISMrYoYjnaF4HKtXL44FhFZnYc3yJ4tCMF zBBOu5q0hAb7w== 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 AF23163329 for ; Wed, 27 Jul 2022 04:38:35 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="IN7T4mGD"; dkim-atps=neutral Received: from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 47CAC56D; Wed, 27 Jul 2022 04:38:35 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1658889515; bh=l78zBW/LwB1XHylCSimYUBear1h4A4iOs0lqRZY8i80=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IN7T4mGDXst/UXBMCVeql5pJEQ4TskSP/W3OlM0qzegP3dMX+G5u2UcHeUv7Ycug9 NryNrghEHnlcCh0ZIrg8SuhCe+06PphLiw6n1SmpbRV9mOyqQpeAJHY92hqXxh9Gdl jPmVzqCkLjl7T816j1ZSz3dbSKsoXMHTPyF+WXPI= To: libcamera-devel@lists.libcamera.org Date: Wed, 27 Jul 2022 05:38:16 +0300 Message-Id: <20220727023816.30008-15-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220727023816.30008-1-laurent.pinchart@ideasonboard.com> References: <20220727023816.30008-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v7 14/14] ipa: raspberrypi: agc: Use YamlObject::getList() 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: , X-Patchwork-Original-From: Laurent Pinchart via libcamera-devel From: Laurent Pinchart Reply-To: Laurent Pinchart Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Replace the manual implementation of the readList() functions with YamlObject::getList(). Signed-off-by: Laurent Pinchart Reviewed-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 9fd339c6904e..b8eb5bc605a1 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; }); - if (numShutters < 2 || numAgs < 2) { + value = params["gain"].getList(); + if (!value) + return -EINVAL; + gain = std::move(*value); + + 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;