<div dir="ltr"><div dir="ltr">Hi Laurent,<div><br></div><div>Thank you for your patch.</div><div><br></div></div><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, 27 Jul 2022 at 03:38, Laurent Pinchart <<a href="mailto:laurent.pinchart@ideasonboard.com">laurent.pinchart@ideasonboard.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Update the AGC metering functions that deal with reading tuning data to<br>
propagate errors to the caller, using std::tie and std::tuple to group<br>
the error code and return value.<br>
<br>
Signed-off-by: Laurent Pinchart <<a href="mailto:laurent.pinchart@ideasonboard.com" target="_blank">laurent.pinchart@ideasonboard.com</a>><br></blockquote><div><br></div><div>Reviewed-by: Naushir Patuck <<a href="mailto:naush@raspberrypi.com">naush@raspberrypi.com</a>></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
---<br>
 src/ipa/raspberrypi/controller/rpi/agc.cpp | 71 ++++++++++++++++------<br>
 1 file changed, 54 insertions(+), 17 deletions(-)<br>
<br>
diff --git a/src/ipa/raspberrypi/controller/rpi/agc.cpp b/src/ipa/raspberrypi/controller/rpi/agc.cpp<br>
index 130c606d4136..93f966a1d5ce 100644<br>
--- a/src/ipa/raspberrypi/controller/rpi/agc.cpp<br>
+++ b/src/ipa/raspberrypi/controller/rpi/agc.cpp<br>
@@ -6,6 +6,7 @@<br>
  */<br>
<br>
 #include <map><br>
+#include <tuple><br>
<br>
 #include <linux/bcm2835-isp.h><br>
<br>
@@ -43,19 +44,25 @@ int AgcMeteringMode::read(boost::property_tree::ptree const &params)<br>
        return 0;<br>
 }<br>
<br>
-static std::string<br>
+static std::tuple<int, std::string><br>
 readMeteringModes(std::map<std::string, AgcMeteringMode> &meteringModes,<br>
                  boost::property_tree::ptree const &params)<br>
 {<br>
        std::string first;<br>
+       int ret;<br>
+<br>
        for (auto &p : params) {<br>
                AgcMeteringMode meteringMode;<br>
-               meteringMode.read(p.second);<br>
+               ret = meteringMode.read(p.second);<br>
+               if (ret)<br>
+                       return { ret, {} };<br>
+<br>
                meteringModes[p.first] = std::move(meteringMode);<br>
                if (first.empty())<br>
                        first = p.first;<br>
        }<br>
-       return first;<br>
+<br>
+       return { 0, first };<br>
 }<br>
<br>
 static int readList(std::vector<double> &list,<br>
@@ -87,19 +94,25 @@ int AgcExposureMode::read(boost::property_tree::ptree const &params)<br>
        return 0;<br>
 }<br>
<br>
-static std::string<br>
+static std::tuple<int, std::string><br>
 readExposureModes(std::map<std::string, AgcExposureMode> &exposureModes,<br>
                  boost::property_tree::ptree const &params)<br>
 {<br>
        std::string first;<br>
+       int ret;<br>
+<br>
        for (auto &p : params) {<br>
                AgcExposureMode exposureMode;<br>
-               exposureMode.read(p.second);<br>
+               ret = exposureMode.read(p.second);<br>
+               if (ret)<br>
+                       return { ret, {} };<br>
+<br>
                exposureModes[p.first] = std::move(exposureMode);<br>
                if (first.empty())<br>
                        first = p.first;<br>
        }<br>
-       return first;<br>
+<br>
+       return { 0, first };<br>
 }<br>
<br>
 int AgcConstraint::read(boost::property_tree::ptree const &params)<br>
@@ -115,38 +128,62 @@ int AgcConstraint::read(boost::property_tree::ptree const &params)<br>
        return yTarget.read(params.get_child("y_target"));<br>
 }<br>
<br>
-static AgcConstraintMode<br>
+static std::tuple<int, AgcConstraintMode><br>
 readConstraintMode(boost::property_tree::ptree const &params)<br>
 {<br>
        AgcConstraintMode mode;<br>
+       int ret;<br>
+<br>
        for (auto &p : params) {<br>
                AgcConstraint constraint;<br>
-               constraint.read(p.second);<br>
+               ret = constraint.read(p.second);<br>
+               if (ret)<br>
+                       return { ret, {} };<br>
+<br>
                mode.push_back(std::move(constraint));<br>
        }<br>
-       return mode;<br>
+<br>
+       return { 0, mode };<br>
 }<br>
<br>
-static std::string readConstraintModes(std::map<std::string, AgcConstraintMode> &constraintModes,<br>
-                                      boost::property_tree::ptree const &params)<br>
+static std::tuple<int, std::string><br>
+readConstraintModes(std::map<std::string, AgcConstraintMode> &constraintModes,<br>
+                   boost::property_tree::ptree const &params)<br>
 {<br>
        std::string first;<br>
+       int ret;<br>
+<br>
        for (auto &p : params) {<br>
-               constraintModes[p.first] = readConstraintMode(p.second);<br>
+               std::tie(ret, constraintModes[p.first]) = readConstraintMode(p.second);<br>
+               if (ret)<br>
+                       return { ret, {} };<br>
+<br>
                if (first.empty())<br>
                        first = p.first;<br>
        }<br>
-       return first;<br>
+<br>
+       return { 0, first };<br>
 }<br>
<br>
 int AgcConfig::read(boost::property_tree::ptree const &params)<br>
 {<br>
        LOG(RPiAgc, Debug) << "AgcConfig";<br>
-       defaultMeteringMode = readMeteringModes(meteringModes, params.get_child("metering_modes"));<br>
-       defaultExposureMode = readExposureModes(exposureModes, params.get_child("exposure_modes"));<br>
-       defaultConstraintMode = readConstraintModes(constraintModes, params.get_child("constraint_modes"));<br>
+       int ret;<br>
<br>
-       int ret = yTarget.read(params.get_child("y_target"));<br>
+       std::tie(ret, defaultMeteringMode) =<br>
+               readMeteringModes(meteringModes, params.get_child("metering_modes"));<br>
+       if (ret)<br>
+               return ret;<br>
+       std::tie(ret, defaultExposureMode) =<br>
+               readExposureModes(exposureModes, params.get_child("exposure_modes"));<br>
+       if (ret)<br>
+               return ret;<br>
+       std::tie(ret, defaultConstraintMode) =<br>
+               readConstraintModes(constraintModes, params.get_child("constraint_modes"));<br>
+       if (ret)<br>
+               return ret;<br>
+<br>
+       ret = yTarget.read(params.get_child("y_target"));<br>
        if (ret)<br>
                return ret;<br>
<br>
-- <br>
Regards,<br>
<br>
Laurent Pinchart<br>
<br>
</blockquote></div></div>