From patchwork Wed Jul 27 02:38:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 16818 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 7CBC2BE173 for ; Wed, 27 Jul 2022 02:38:28 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 1455D63321; Wed, 27 Jul 2022 04:38:28 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1658889508; bh=luqq5mg3n/Ocf6RJpP4l9IGSv4THtMeGK/EoW4TKN+I=; 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=vGSio50SYfF9yI025Xk9hQ3Wn03zk2o/5PWWEbX2U7mjw4/2eKQnuEcfLOfGRHUuA IxJmmbORT73tn990nWZW91D2TH+KaJGsTohxAHH1YLLZYzU+4xRXxRRsey5MrWoSLI /EuPt0C+lTkEo23iqh0fpoXqKe2zHXLBtGfovV84uEPHGaYWXtzMg8A6IRUXX1WN4M YotB/QK76GXe5TnzaHDgHPgZGhefphRLomuGj5HssyY8UPufe2otJ/xXJUNgFjgFCp qeKZZivo0suinEph8R9JZQd0cXAaqk95M0fprUpTVh46UfpL5stQmOUpOX23GZAPe0 wzR20zQFbOSEQ== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 2CB566331A for ; Wed, 27 Jul 2022 04:38:25 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="HPQ0xNNm"; 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 B507D56D; Wed, 27 Jul 2022 04:38:24 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1658889504; bh=luqq5mg3n/Ocf6RJpP4l9IGSv4THtMeGK/EoW4TKN+I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HPQ0xNNmZjYY9ILevtJSYS6dGBZTDXS4soB4rZjangZpppwsyMgxG+8Rn0n1ygLEL zt848TljvDhMLXrfglx5Dqrf72XzKviAFEuxEfsQgl+pJv/7zuqMcpiJJr7fXcBiqW /T1oKq3B2GS2OJBC+txnIm1QpsIrofGvhgLkta10= To: libcamera-devel@lists.libcamera.org Date: Wed, 27 Jul 2022 05:38:08 +0300 Message-Id: <20220727023816.30008-7-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 06/14] ipa: raspberrypi: Propagate errors from AGC metering tuning data read 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" Update the AGC metering functions that deal with reading tuning data to propagate errors to the caller, using std::tie and std::tuple to group the error code and return value. Signed-off-by: Laurent Pinchart Reviewed-by: Naushir Patuck --- src/ipa/raspberrypi/controller/rpi/agc.cpp | 71 ++++++++++++++++------ 1 file changed, 54 insertions(+), 17 deletions(-) diff --git a/src/ipa/raspberrypi/controller/rpi/agc.cpp b/src/ipa/raspberrypi/controller/rpi/agc.cpp index 130c606d4136..93f966a1d5ce 100644 --- a/src/ipa/raspberrypi/controller/rpi/agc.cpp +++ b/src/ipa/raspberrypi/controller/rpi/agc.cpp @@ -6,6 +6,7 @@ */ #include +#include #include @@ -43,19 +44,25 @@ int AgcMeteringMode::read(boost::property_tree::ptree const ¶ms) return 0; } -static std::string +static std::tuple readMeteringModes(std::map &meteringModes, boost::property_tree::ptree const ¶ms) { std::string first; + int ret; + for (auto &p : params) { AgcMeteringMode meteringMode; - meteringMode.read(p.second); + ret = meteringMode.read(p.second); + if (ret) + return { ret, {} }; + meteringModes[p.first] = std::move(meteringMode); if (first.empty()) first = p.first; } - return first; + + return { 0, first }; } static int readList(std::vector &list, @@ -87,19 +94,25 @@ int AgcExposureMode::read(boost::property_tree::ptree const ¶ms) return 0; } -static std::string +static std::tuple readExposureModes(std::map &exposureModes, boost::property_tree::ptree const ¶ms) { std::string first; + int ret; + for (auto &p : params) { AgcExposureMode exposureMode; - exposureMode.read(p.second); + ret = exposureMode.read(p.second); + if (ret) + return { ret, {} }; + exposureModes[p.first] = std::move(exposureMode); if (first.empty()) first = p.first; } - return first; + + return { 0, first }; } int AgcConstraint::read(boost::property_tree::ptree const ¶ms) @@ -115,38 +128,62 @@ int AgcConstraint::read(boost::property_tree::ptree const ¶ms) return yTarget.read(params.get_child("y_target")); } -static AgcConstraintMode +static std::tuple readConstraintMode(boost::property_tree::ptree const ¶ms) { AgcConstraintMode mode; + int ret; + for (auto &p : params) { AgcConstraint constraint; - constraint.read(p.second); + ret = constraint.read(p.second); + if (ret) + return { ret, {} }; + mode.push_back(std::move(constraint)); } - return mode; + + return { 0, mode }; } -static std::string readConstraintModes(std::map &constraintModes, - boost::property_tree::ptree const ¶ms) +static std::tuple +readConstraintModes(std::map &constraintModes, + boost::property_tree::ptree const ¶ms) { std::string first; + int ret; + for (auto &p : params) { - constraintModes[p.first] = readConstraintMode(p.second); + std::tie(ret, constraintModes[p.first]) = readConstraintMode(p.second); + if (ret) + return { ret, {} }; + if (first.empty()) first = p.first; } - return first; + + return { 0, first }; } int AgcConfig::read(boost::property_tree::ptree const ¶ms) { LOG(RPiAgc, Debug) << "AgcConfig"; - defaultMeteringMode = readMeteringModes(meteringModes, params.get_child("metering_modes")); - defaultExposureMode = readExposureModes(exposureModes, params.get_child("exposure_modes")); - defaultConstraintMode = readConstraintModes(constraintModes, params.get_child("constraint_modes")); + int ret; - int ret = yTarget.read(params.get_child("y_target")); + std::tie(ret, defaultMeteringMode) = + readMeteringModes(meteringModes, params.get_child("metering_modes")); + if (ret) + return ret; + std::tie(ret, defaultExposureMode) = + readExposureModes(exposureModes, params.get_child("exposure_modes")); + if (ret) + return ret; + std::tie(ret, defaultConstraintMode) = + readConstraintModes(constraintModes, params.get_child("constraint_modes")); + if (ret) + return ret; + + ret = yTarget.read(params.get_child("y_target")); if (ret) return ret;