diff options
author | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2022-07-26 02:36:38 +0300 |
---|---|---|
committer | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2022-07-28 13:47:49 +0300 |
commit | f357b1bf6ea39d8118e90f8a371974d29bd054e3 (patch) | |
tree | 2511c1b5e729844680a04239fb0a61df94a31f7f /src/ipa/raspberrypi/controller/rpi/ccm.cpp | |
parent | 0c84c67e39e40db43605af0ee0a65b91114f6315 (diff) |
ipa: raspberrypi: Return an error code from Algorithm::read()
When encountering errors, the Algorithm::read() function either uses
LOG(Fatal) or throws exceptions from the boost property_tree functions.
To prepare for replacing boost JSON parse with the YamlParser class,
give the Algorithm::read() function the ability to return an error code,
and propagate it all the way to the IPA module init() function.
All algorithm classes return a hardcoded 0 value for now, subsequent
commits will change that.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Naushir Patuck <naush@raspberrypi.com>
Tested-by: Naushir Patuck <naush@raspberrypi.com>
Diffstat (limited to 'src/ipa/raspberrypi/controller/rpi/ccm.cpp')
-rw-r--r-- | src/ipa/raspberrypi/controller/rpi/ccm.cpp | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/src/ipa/raspberrypi/controller/rpi/ccm.cpp b/src/ipa/raspberrypi/controller/rpi/ccm.cpp index cf0c85d2..f0110d38 100644 --- a/src/ipa/raspberrypi/controller/rpi/ccm.cpp +++ b/src/ipa/raspberrypi/controller/rpi/ccm.cpp @@ -39,7 +39,7 @@ Matrix::Matrix(double m0, double m1, double m2, double m3, double m4, double m5, m[0][0] = m0, m[0][1] = m1, m[0][2] = m2, m[1][0] = m3, m[1][1] = m4, m[1][2] = m5, m[2][0] = m6, m[2][1] = m7, m[2][2] = m8; } -void Matrix::read(boost::property_tree::ptree const ¶ms) +int Matrix::read(boost::property_tree::ptree const ¶ms) { double *ptr = (double *)m; int n = 0; @@ -50,6 +50,7 @@ void Matrix::read(boost::property_tree::ptree const ¶ms) } if (n < 9) LOG(RPiCcm, Fatal) << "Ccm: too few values in CCM"; + return 0; } Ccm::Ccm(Controller *controller) @@ -60,21 +61,32 @@ char const *Ccm::name() const return NAME; } -void Ccm::read(boost::property_tree::ptree const ¶ms) +int Ccm::read(boost::property_tree::ptree const ¶ms) { - if (params.get_child_optional("saturation")) - config_.saturation.read(params.get_child("saturation")); + int ret; + + if (params.get_child_optional("saturation")) { + ret = config_.saturation.read(params.get_child("saturation")); + if (ret) + return ret; + } + for (auto &p : params.get_child("ccms")) { CtCcm ctCcm; ctCcm.ct = p.second.get<double>("ct"); - ctCcm.ccm.read(p.second.get_child("ccm")); + ret = ctCcm.ccm.read(p.second.get_child("ccm")); + if (ret) + return ret; if (!config_.ccms.empty() && ctCcm.ct <= config_.ccms.back().ct) LOG(RPiCcm, Fatal) << "Ccm: CCM not in increasing colour temperature order"; config_.ccms.push_back(std::move(ctCcm)); } + if (config_.ccms.empty()) LOG(RPiCcm, Fatal) << "Ccm: no CCMs specified"; + + return 0; } void Ccm::setSaturation(double saturation) |