From 735f0ffeaac736f91c35774e575b1280ba868d69 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Tue, 26 Jul 2022 02:36:38 +0300 Subject: ipa: raspberrypi: Replace Fatal log by error propagation Replace the Fatal log messages that cause an abort during tuning data read with Error messages and proper error propagation to the caller. Signed-off-by: Laurent Pinchart Reviewed-by: Naushir Patuck Tested-by: Naushir Patuck --- src/ipa/raspberrypi/controller/rpi/agc.cpp | 36 +++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 10 deletions(-) (limited to 'src/ipa/raspberrypi/controller/rpi/agc.cpp') diff --git a/src/ipa/raspberrypi/controller/rpi/agc.cpp b/src/ipa/raspberrypi/controller/rpi/agc.cpp index cf03fb10..7fd5d18b 100644 --- a/src/ipa/raspberrypi/controller/rpi/agc.cpp +++ b/src/ipa/raspberrypi/controller/rpi/agc.cpp @@ -34,13 +34,20 @@ static constexpr unsigned int PipelineBits = 13; /* seems to be a 13-bit pipelin int AgcMeteringMode::read(boost::property_tree::ptree const ¶ms) { int num = 0; + for (auto &p : params.get_child("weights")) { - if (num == AgcStatsSize) - LOG(RPiAgc, Fatal) << "AgcMeteringMode: too many weights"; + if (num == AgcStatsSize) { + LOG(RPiAgc, Error) << "AgcMeteringMode: too many weights"; + return -EINVAL; + } weights[num++] = p.second.get_value(); } - if (num != AgcStatsSize) - LOG(RPiAgc, Fatal) << "AgcMeteringMode: insufficient weights"; + + if (num != AgcStatsSize) { + LOG(RPiAgc, Error) << "AgcMeteringMode: insufficient weights"; + return -EINVAL; + } + return 0; } @@ -85,12 +92,19 @@ int AgcExposureMode::read(boost::property_tree::ptree const ¶ms) { int numShutters = readList(shutter, params.get_child("shutter")); int numAgs = readList(gain, params.get_child("gain")); - if (numShutters < 2 || numAgs < 2) - LOG(RPiAgc, Fatal) + + if (numShutters < 2 || numAgs < 2) { + LOG(RPiAgc, Error) << "AgcExposureMode: must have at least two entries in exposure profile"; - if (numShutters != numAgs) - LOG(RPiAgc, Fatal) + return -EINVAL; + } + + if (numShutters != numAgs) { + LOG(RPiAgc, Error) << "AgcExposureMode: expect same number of exposure and gain entries in exposure profile"; + return -EINVAL; + } + return 0; } @@ -120,8 +134,10 @@ int AgcConstraint::read(boost::property_tree::ptree const ¶ms) std::string boundString = params.get("bound", ""); transform(boundString.begin(), boundString.end(), boundString.begin(), ::toupper); - if (boundString != "UPPER" && boundString != "LOWER") - LOG(RPiAgc, Fatal) << "AGC constraint type should be UPPER or LOWER"; + if (boundString != "UPPER" && boundString != "LOWER") { + LOG(RPiAgc, Error) << "AGC constraint type should be UPPER or LOWER"; + return -EINVAL; + } bound = boundString == "UPPER" ? Bound::UPPER : Bound::LOWER; qLo = params.get("q_lo"); qHi = params.get("q_hi"); -- cgit v1.2.1