[PATCH v5 08/15] config: Look up rpi paths in configuration file

Milan Zamazal mzamazal at redhat.com
Tue Oct 1 12:28:00 CEST 2024


It may be arguable whether pipeline specific configurations belong to
the global configuration file.  But:

- Having a single configuration file is generally easier for the user.
- The original configuration via environment variables can be already
  considered global.
- These options point to other configuration files and it makes little
  sense to add another configuration file to the chain.

The configuration snippet:

  configuration:
    pipeline:
      rpi:
        config_file: FILENAME
        tuning_file: FILENAME

Signed-off-by: Milan Zamazal <mzamazal at redhat.com>
---
 .../pipeline/rpi/common/pipeline_base.cpp      | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/src/libcamera/pipeline/rpi/common/pipeline_base.cpp b/src/libcamera/pipeline/rpi/common/pipeline_base.cpp
index 3041fd1ed..6c9a39725 100644
--- a/src/libcamera/pipeline/rpi/common/pipeline_base.cpp
+++ b/src/libcamera/pipeline/rpi/common/pipeline_base.cpp
@@ -20,6 +20,7 @@
 #include <libcamera/property_ids.h>
 
 #include "libcamera/internal/camera_lens.h"
+#include "libcamera/internal/global_configuration.h"
 #include "libcamera/internal/ipa_manager.h"
 #include "libcamera/internal/v4l2_subdevice.h"
 
@@ -1088,7 +1089,12 @@ int CameraData::loadPipelineConfiguration()
 	/* Initial configuration of the platform, in case no config file is present */
 	platformPipelineConfigure({});
 
-	char const *configFromEnv = utils::secure_getenv("LIBCAMERA_RPI_CONFIG_FILE");
+	std::optional<std::string> configFile =
+		GlobalConfiguration::envOption("LIBCAMERA_RPI_CONFIG_FILE",
+					       "pipelines.rpi.config_file");
+	if (!configFile.has_value())
+		return 0;
+	char const *configFromEnv = configFile.value().c_str();
 	if (!configFromEnv || *configFromEnv == '\0')
 		return 0;
 
@@ -1147,14 +1153,18 @@ int CameraData::loadIPA(ipa::RPi::InitResult *result)
 	 * the environment variable overrides it.
 	 */
 	std::string configurationFile;
-	char const *configFromEnv = utils::secure_getenv("LIBCAMERA_RPI_TUNING_FILE");
-	if (!configFromEnv || *configFromEnv == '\0') {
+	const std::string confPath =
+		std::string("pipelines.rpi.cameras.") + sensor_->id() + std::string(".tuning_file");
+	std::optional<std::string> configFromEnv =
+		GlobalConfiguration::envOption("LIBCAMERA_RPI_TUNING_FILE",
+					       confPath.c_str());
+	if (!configFromEnv.has_value() || configFromEnv.value().empty()) {
 		std::string model = sensor_->model();
 		if (isMonoSensor(sensor_))
 			model += "_mono";
 		configurationFile = ipa_->configurationFile(model + ".json");
 	} else {
-		configurationFile = std::string(configFromEnv);
+		configurationFile = configFromEnv.value();
 	}
 
 	IPASettings settings(configurationFile, sensor_->model());
-- 
2.44.1



More information about the libcamera-devel mailing list