[v11,06/12] config: Look up pipelines match list in configuration file
diff mbox series

Message ID 20250624083612.27230-7-mzamazal@redhat.com
State New
Headers show
Series
  • Add global configuration file
Related show

Commit Message

Milan Zamazal June 24, 2025, 8:36 a.m. UTC
Let's add a configuration file item for the pipelines match list.

The configuration snippet:

  configuration:
    pipelines_match_list: rkisp1,simple

Signed-off-by: Milan Zamazal <mzamazal@redhat.com>
---
 src/libcamera/camera_manager.cpp | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

Comments

Barnabás Pőcze June 27, 2025, 2 p.m. UTC | #1
Hi

2025. 06. 24. 10:36 keltezéssel, Milan Zamazal írta:
> Let's add a configuration file item for the pipelines match list.
> 
> The configuration snippet:
> 
>    configuration:
>      pipelines_match_list: rkisp1,simple
> 
> Signed-off-by: Milan Zamazal <mzamazal@redhat.com>
> ---
>   src/libcamera/camera_manager.cpp | 9 +++++----
>   1 file changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/src/libcamera/camera_manager.cpp b/src/libcamera/camera_manager.cpp
> index c47fd3677..b4d56c3aa 100644
> --- a/src/libcamera/camera_manager.cpp
> +++ b/src/libcamera/camera_manager.cpp
> @@ -111,14 +111,15 @@ void CameraManager::Private::createPipelineHandlers()
>   	 * file and only fallback on environment variable or all handlers, if
>   	 * there is no configuration file.
>   	 */
> -	const char *pipesList =
> -		utils::secure_getenv("LIBCAMERA_PIPELINES_MATCH_LIST");
> -	if (pipesList) {
> +	std::optional<std::string> pipesList =
> +		configuration().envOption("LIBCAMERA_PIPELINES_MATCH_LIST",
> +					  "pipelines_match_list");

Wouldn't it be better to use `envListOption()`? I realize that the separator
is different (':' vs ','), but it still seems better to me. The separator
could be an argument of `envListOption()` I believe.


Regards,
Barnabás Pőcze



> +	if (pipesList.has_value()) {
>   		/*
>   		 * When a list of preferred pipelines is defined, iterate
>   		 * through the ordered list to match the enumerated devices.
>   		 */
> -		for (const auto &pipeName : utils::split(pipesList, ",")) {
> +		for (const auto &pipeName : utils::split(pipesList.value(), ",")) {
>   			const PipelineHandlerFactoryBase *factory;
>   			factory = PipelineHandlerFactoryBase::getFactoryByName(pipeName);
>   			if (!factory)
Milan Zamazal June 27, 2025, 9:11 p.m. UTC | #2
Hi Barnabás,

Barnabás Pőcze <barnabas.pocze@ideasonboard.com> writes:

> Hi
>
> 2025. 06. 24. 10:36 keltezéssel, Milan Zamazal írta:
>> Let's add a configuration file item for the pipelines match list.
>> The configuration snippet:
>>    configuration:
>>      pipelines_match_list: rkisp1,simple
>> Signed-off-by: Milan Zamazal <mzamazal@redhat.com>
>> ---
>>   src/libcamera/camera_manager.cpp | 9 +++++----
>>   1 file changed, 5 insertions(+), 4 deletions(-)
>> diff --git a/src/libcamera/camera_manager.cpp b/src/libcamera/camera_manager.cpp
>> index c47fd3677..b4d56c3aa 100644
>> --- a/src/libcamera/camera_manager.cpp
>> +++ b/src/libcamera/camera_manager.cpp
>> @@ -111,14 +111,15 @@ void CameraManager::Private::createPipelineHandlers()
>>   	 * file and only fallback on environment variable or all handlers, if
>>   	 * there is no configuration file.
>>   	 */
>> -	const char *pipesList =
>> -		utils::secure_getenv("LIBCAMERA_PIPELINES_MATCH_LIST");
>> -	if (pipesList) {
>> +	std::optional<std::string> pipesList =
>> +		configuration().envOption("LIBCAMERA_PIPELINES_MATCH_LIST",
>> +					  "pipelines_match_list");
>
> Wouldn't it be better to use `envListOption()`? I realize that the separator
> is different (':' vs ','), but it still seems better to me. The separator
> could be an argument of `envListOption()` I believe.

Probably.  (Well, new environment variables are introduced more quickly
than these patches merged, which means new creations are handled
afterwards rather than before...)

> Regards,
> Barnabás Pőcze
>
>
>
>> +	if (pipesList.has_value()) {
>>   		/*
>>   		 * When a list of preferred pipelines is defined, iterate
>>   		 * through the ordered list to match the enumerated devices.
>>   		 */
>> -		for (const auto &pipeName : utils::split(pipesList, ",")) {
>> +		for (const auto &pipeName : utils::split(pipesList.value(), ",")) {
>>   			const PipelineHandlerFactoryBase *factory;
>>   			factory = PipelineHandlerFactoryBase::getFactoryByName(pipeName);
>>   			if (!factory)

Patch
diff mbox series

diff --git a/src/libcamera/camera_manager.cpp b/src/libcamera/camera_manager.cpp
index c47fd3677..b4d56c3aa 100644
--- a/src/libcamera/camera_manager.cpp
+++ b/src/libcamera/camera_manager.cpp
@@ -111,14 +111,15 @@  void CameraManager::Private::createPipelineHandlers()
 	 * file and only fallback on environment variable or all handlers, if
 	 * there is no configuration file.
 	 */
-	const char *pipesList =
-		utils::secure_getenv("LIBCAMERA_PIPELINES_MATCH_LIST");
-	if (pipesList) {
+	std::optional<std::string> pipesList =
+		configuration().envOption("LIBCAMERA_PIPELINES_MATCH_LIST",
+					  "pipelines_match_list");
+	if (pipesList.has_value()) {
 		/*
 		 * When a list of preferred pipelines is defined, iterate
 		 * through the ordered list to match the enumerated devices.
 		 */
-		for (const auto &pipeName : utils::split(pipesList, ",")) {
+		for (const auto &pipeName : utils::split(pipesList.value(), ",")) {
 			const PipelineHandlerFactoryBase *factory;
 			factory = PipelineHandlerFactoryBase::getFactoryByName(pipeName);
 			if (!factory)