@@ -44,7 +44,7 @@ file structure:
pipelines:
simple:
devices:
- - driver: # driver name, e.g. `mxc-isi`
+ # driver name, e.g. `mxc-isi`:
software_isp: # true/false
software_isp:
copy_input_buffer: # true/false
@@ -77,7 +77,7 @@ Configuration file example
pipelines:
simple:
devices:
- - driver: mxc-isi
+ mxc-isi:
software_isp: true
software_isp:
copy_input_buffer: false
@@ -139,7 +139,7 @@ LIBCAMERA_<NAME>_TUNING_FILE
Example value: ``/usr/local/share/libcamera/ipa/rpi/vc4/custom_sensor.json``
-pipelines.simple.devices.driver, pipelines.simple.devices.software_isp
+pipelines.simple.devices.<driver>.software_isp
Override whether software ISP is enabled for the given driver.
Example `driver` value: ``mxc-isi``
@@ -1879,18 +1879,16 @@ bool SimplePipelineHandler::matchDevice(std::shared_ptr<MediaDevice> media,
}
swIspEnabled_ = info.swIspEnabled;
+
const GlobalConfiguration &configuration = cameraManager()->_d()->configuration();
- for (GlobalConfiguration::Option entry :
- configuration.configuration()["pipelines"]["simple"]["devices"]
- .asList()) {
- auto name = entry["driver"].get<std::string>();
- if (name == info.driver) {
- swIspEnabled_ = entry["software_isp"].get<bool>().value_or(swIspEnabled_);
- LOG(SimplePipeline, Debug)
- << "Configuration file overrides software ISP for "
- << info.driver << " to " << swIspEnabled_;
- break;
- }
+ GlobalConfiguration::Option &cfg =
+ configuration.configuration()["pipelines"]["simple"]["devices"][info.driver];
+
+ if (cfg) {
+ swIspEnabled_ = cfg["software_isp"].get<bool>().value_or(swIspEnabled_);
+ LOG(SimplePipeline, Debug)
+ << "Configuration file overrides software ISP for "
+ << info.driver << " to " << swIspEnabled_;
}
/* Locate the sensors. */
The pipelines.simple.devices configuration option contains a list of devices, each of them being a dictionary with a "driver" element that acts as a unique key to index the list. Turn it into a YAML dictionary to ensure uniqueness of the key, and simplify access in the pipeline handler. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> --- This simplification will preclude indexing the list of devices with a compound key. For instance, if we were to extend the simple pipeline handler to match not only on a driver name but on a (driver, driver version) pair, the current configuration file structure would allow expressing this with pipelines: simple: devices: - driver: mxc-isi driver_version: 1 software_isp: true - driver: mxc-isi driver_version: 2 software_isp: false The new structure would conceptually allow us to write pipelines: simple: devices: ? driver: mxc-isi driver_version: 1 : software_isp: true ? driver: mxc-isi driver_version: 2 : software_isp: false For those not familiar with the explicit syntax for mappings, this would translate to the following Python data if dict objects were hashable in Python: { 'pipelines': { 'simple': { 'devices': { { 'driver': 'mxc-isi', 'driver_version': 1 }: { 'software_isp': True, }, { 'driver': 'mxc-isi', 'driver_version': 2 }: { 'software_isp': False, }, }, }, }, } Yes, YAML can use complex data as keys in mappings. I would really not want to have to support that in libcamera though. Opinions will be appreciated. --- Documentation/runtime_configuration.rst | 6 +++--- src/libcamera/pipeline/simple/simple.cpp | 20 +++++++++----------- 2 files changed, 12 insertions(+), 14 deletions(-)