ipa: rpi: controller: Ignore algorithms that are not enabled

Algorithms may now contain an "enabled" field which can be set to
false to disable it and prevent it from being loaded. If not present,
algorithms are treated as enabled by default for backwards
compatability.

We additionally prevent duplicate versions of the same algorithm type
(such as AWB) from loading, and flag an error. This will prevent
undefined behaviour if (for example) two distinct AWB algorithms are
trying to run simultaneously.

Signed-off-by: Peter Bailey <peter.bailey@raspberrypi.com>
Reviewed-by: David Plowman <david.plowman@raspberrypi.com>
Reviewed-by: Naushir Patuck <naush@raspberrypi.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
This commit is contained in:
Peter Bailey
2026-01-27 17:13:18 +00:00
committed by Kieran Bingham
parent 045bfb1b8f
commit 7214950ffe
+18
View File
@@ -145,6 +145,14 @@ int Controller::read(char const *filename)
int Controller::createAlgorithm(const std::string &name, const YamlObject &params)
{
/* Any algorithm may be disabled by setting "enabled" to false. */
bool enabled = params["enabled"].get<bool>(true);
LOG(RPiController, Debug)
<< "Algorithm " << name << ": "
<< (enabled ? "enabled" : "disabled");
if (!enabled)
return 0;
auto it = getAlgorithms().find(name);
if (it == getAlgorithms().end()) {
LOG(RPiController, Warning)
@@ -152,6 +160,16 @@ int Controller::createAlgorithm(const std::string &name, const YamlObject &param
return 0;
}
/* Do not allow duplicate versions of algorithms (e.g. AWB) to run. */
size_t pos = name.find_last_of('.');
std::string const &algoType =
pos == std::string::npos ? name : name.substr(pos + 1);
if (getAlgorithm(algoType)) {
LOG(RPiController, Error)
<< "Algorithm type '" << algoType << "' already exists";
return -1;
}
Algorithm *algo = (*it->second)(this);
int ret = algo->read(params);
if (ret)