@@ -237,11 +237,36 @@ int AgcMeanLuminance::parseConstraint(const ValueNode &modeDict, int32_t id)
int AgcMeanLuminance::parseConstraintModes(const ValueNode &tuningData)
{
+ static constexpr std::tuple<std::string_view, std::string_view, controls::AeConstraintModeEnum> compat[] = {
+ { "ConstraintNormal", "Normal", controls::AeConstraintModeNormal },
+ { "ConstraintHighlight", "Highlight", controls::AeConstraintModeHighlight },
+ { "ConstraintShadows", "Shadows", controls::AeConstraintModeShadows },
+ { "ConstraintCustom", "Custom", controls::AeConstraintModeCustom },
+ };
+
const ValueNode &constraintModes = tuningData[controls::AeConstraintMode.name()];
if (constraintModes.isDictionary()) {
for (const auto &[modeName, modeDict] : constraintModes.asDict()) {
+ std::optional<controls::AeConstraintModeEnum> modeValue;
+
auto it = AeConstraintModeNameValueMap.find(modeName);
if (it == AeConstraintModeNameValueMap.end()) {
+ for (const auto &[oldName, newName, v] : compat) {
+ if (modeName != oldName)
+ continue;
+
+ modeValue = v;
+
+ LOG(AgcMeanLuminance, Warning)
+ << "Constraint mode '" << oldName << "' has been renamed to '"
+ << newName << "', please fix the tuning file";
+ break;
+ }
+ } else {
+ modeValue = static_cast<controls::AeConstraintModeEnum>(it->second);
+ }
+
+ if (!modeValue) {
LOG(AgcMeanLuminance, Warning)
<< "Skipping unknown constraint mode '" << modeName << "'";
continue;
@@ -253,7 +278,7 @@ int AgcMeanLuminance::parseConstraintModes(const ValueNode &tuningData)
return -EINVAL;
}
- int ret = parseConstraint(modeDict, it->second);
+ int ret = parseConstraint(modeDict, *modeValue);
if (ret)
return ret;
}
@@ -281,11 +306,36 @@ int AgcMeanLuminance::parseConstraintModes(const ValueNode &tuningData)
int AgcMeanLuminance::parseExposureModes(const ValueNode &tuningData)
{
+ static constexpr std::tuple<std::string_view, std::string_view, controls::AeExposureModeEnum> compat[] = {
+ { "ExposureNormal", "Normal", controls::AeExposureModeNormal },
+ { "ExposureShort", "Short", controls::AeExposureModeShort },
+ { "ExposureLong", "Long", controls::AeExposureModeLong },
+ { "ExposureCustom", "Custom", controls::AeExposureModeCustom },
+ };
+
const ValueNode &exposureModes = tuningData[controls::AeExposureMode.name()];
if (exposureModes.isDictionary()) {
for (const auto &[modeName, modeValues] : exposureModes.asDict()) {
+ std::optional<controls::AeExposureModeEnum> modeValue;
+
auto it = AeExposureModeNameValueMap.find(modeName);
if (it == AeExposureModeNameValueMap.end()) {
+ for (const auto &[oldName, newName, v] : compat) {
+ if (modeName != oldName)
+ continue;
+
+ modeValue = v;
+
+ LOG(AgcMeanLuminance, Warning)
+ << "Exposure mode '" << oldName << "' has been renamed to '"
+ << newName << "', please fix the tuning file";
+ break;
+ }
+ } else {
+ modeValue = static_cast<controls::AeExposureModeEnum>(it->second);
+ }
+
+ if (!modeValue) {
LOG(AgcMeanLuminance, Warning)
<< "Skipping unknown exposure mode '" << modeName << "'";
continue;
@@ -322,7 +372,7 @@ int AgcMeanLuminance::parseExposureModes(const ValueNode &tuningData)
});
}
- exposureModeHelpers_.try_emplace(it->second, stages);
+ exposureModeHelpers_.try_emplace(*modeValue, stages);
}
}
@@ -451,9 +451,38 @@ int AwbAlgorithmBase::parseModeConfigs(const ValueNode &tuningData,
return -EINVAL;
}
+ static constexpr std::tuple<std::string_view, std::string_view, controls::AwbModeEnum> compat[] = {
+ { "AwbAuto", "Auto", controls::AwbModeAuto },
+ { "AwbIncandescent", "Incandescent", controls::AwbModeIncandescent },
+ { "AwbTungsten", "Tungsten", controls::AwbModeTungsten },
+ { "AwbFluorescent", "Fluorescent", controls::AwbModeFluorescent },
+ { "AwbIndoor", "Indoor", controls::AwbModeIndoor },
+ { "AwbDaylight", "Daylight", controls::AwbModeDaylight },
+ { "AwbCloudy", "Cloudy", controls::AwbModeCloudy },
+ { "AwbCustom", "Custom", controls::AwbModeCustom },
+ };
+
for (const auto &[modeName, modeDict] : modes.asDict()) {
- if (controls::AwbModeNameValueMap.find(modeName) ==
- controls::AwbModeNameValueMap.end()) {
+ std::optional<controls::AwbModeEnum> modeValue;
+
+ auto it = controls::AwbModeNameValueMap.find(modeName);
+ if (it == controls::AwbModeNameValueMap.end()) {
+ for (const auto &[oldName, newName, v] : compat) {
+ if (modeName != oldName)
+ continue;
+
+ modeValue = v;
+
+ LOG(Awb, Warning)
+ << "AWB mode '" << oldName << " has been renamed to '"
+ << newName << "', please fix the tuning file";
+ break;
+ }
+ } else {
+ modeValue = static_cast<controls::AwbModeEnum>(it->second);
+ }
+
+ if (!modeValue) {
LOG(Awb, Warning)
<< "Skipping unknown AWB mode '"
<< modeName << "'";
@@ -466,10 +495,7 @@ int AwbAlgorithmBase::parseModeConfigs(const ValueNode &tuningData,
return -EINVAL;
}
- const auto &modeValue = static_cast<controls::AwbModeEnum>(
- controls::AwbModeNameValueMap.at(modeName));
-
- ModeConfig &config = modes_[modeValue];
+ ModeConfig &config = modes_[*modeValue];
auto hi = modeDict["hi"].get<double>();
if (!hi) {
@@ -487,7 +513,7 @@ int AwbAlgorithmBase::parseModeConfigs(const ValueNode &tuningData,
}
config.ctLo = *lo;
- availableModes.push_back(modeValue);
+ availableModes.push_back(*modeValue);
}
if (modes_.empty()) {
It is somewhat unfortunate that the parsing logic uses the enum names directly, and does not have separate key -> value mapping like the rpi ipa has. Commit 974102049a41 ("libcamera: controls: Remove common enum prefix") has changed some enum names, crucially some of those have been used in tuning files. To make the the transition, add support for using the old names and warn about the new names. Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com> --- Another approach in addition to https://patchwork.libcamera.org/project/libcamera/list/?series=6318, this is more code, but keeps the old files working. (Apart from the virtual pipeline handler config file.) Similarly, only compile tested. --- src/ipa/libipa/agc_mean_luminance.cpp | 54 ++++++++++++++++++++++++++- src/ipa/libipa/awb.cpp | 40 ++++++++++++++++---- 2 files changed, 85 insertions(+), 9 deletions(-) -- 2.56.0