[{"id":35735,"web_url":"https://patchwork.libcamera.org/comment/35735/","msgid":"<175740795172.2127323.11034940818765108877@neptunite.rasen.tech>","date":"2025-09-09T08:52:31","subject":"Re: [PATCH v16 06/12] config: Look up pipelines match list in\n\tconfiguration file","submitter":{"id":17,"url":"https://patchwork.libcamera.org/api/people/17/","name":"Paul Elder","email":"paul.elder@ideasonboard.com"},"content":"Quoting Milan Zamazal (2025-07-29 16:31:54)\n> Let's add a configuration file item for the pipelines match list.\n> \n> The configuration snippet:\n> \n>   configuration:\n>     pipelines_match_list: rkisp1,simple\n> \n> Signed-off-by: Milan Zamazal <mzamazal@redhat.com>\n> ---\n>  include/libcamera/internal/global_configuration.h |  3 ++-\n>  src/libcamera/camera_manager.cpp                  | 10 ++++++----\n>  src/libcamera/global_configuration.cpp            |  6 ++++--\n>  3 files changed, 12 insertions(+), 7 deletions(-)\n> \n> diff --git a/include/libcamera/internal/global_configuration.h b/include/libcamera/internal/global_configuration.h\n> index 3b500ee29..8d09517ed 100644\n> --- a/include/libcamera/internal/global_configuration.h\n> +++ b/include/libcamera/internal/global_configuration.h\n> @@ -48,7 +48,8 @@ public:\n>                 const std::initializer_list<std::string_view> confPath) const;\n>         std::optional<std::vector<std::string>> envListOption(\n>                 const char *const envVariable,\n> -               const std::initializer_list<std::string_view> confPath) const;\n> +               const std::initializer_list<std::string_view> confPath,\n> +               const std::string delimiter = \":\") const;\n\nSame comment as 5/12; imo this (and the cpp below) should be added in 3/12,\nthen this patch will just be plubimg CameraManager.\n\n>  \n>  private:\n>         bool loadFile(const std::filesystem::path &fileName);\n> diff --git a/src/libcamera/camera_manager.cpp b/src/libcamera/camera_manager.cpp\n> index 64df62444..c203b08f7 100644\n> --- a/src/libcamera/camera_manager.cpp\n> +++ b/src/libcamera/camera_manager.cpp\n> @@ -111,14 +111,16 @@ void CameraManager::Private::createPipelineHandlers()\n>          * file and only fallback on environment variable or all handlers, if\n>          * there is no configuration file.\n>          */\n> -       const char *pipesList =\n> -               utils::secure_getenv(\"LIBCAMERA_PIPELINES_MATCH_LIST\");\n> -       if (pipesList) {\n> +       const auto pipesList =\n> +               configuration().envListOption(\"LIBCAMERA_PIPELINES_MATCH_LIST\",\n> +                                             { \"pipelines_match_list\" },\n> +                                             \",\");\n\nIt's really neat that it becomes so clean to do this.\n\n\nPaul\n\n> +       if (pipesList.has_value()) {\n>                 /*\n>                  * When a list of preferred pipelines is defined, iterate\n>                  * through the ordered list to match the enumerated devices.\n>                  */\n> -               for (const auto &pipeName : utils::split(pipesList, \",\")) {\n> +               for (const auto &pipeName : pipesList.value()) {\n>                         const PipelineHandlerFactoryBase *factory;\n>                         factory = PipelineHandlerFactoryBase::getFactoryByName(pipeName);\n>                         if (!factory)\n> diff --git a/src/libcamera/global_configuration.cpp b/src/libcamera/global_configuration.cpp\n> index 1371392c5..b9531fdfb 100644\n> --- a/src/libcamera/global_configuration.cpp\n> +++ b/src/libcamera/global_configuration.cpp\n> @@ -174,6 +174,7 @@ std::optional<std::string> GlobalConfiguration::envOption(\n>   * \\brief Return values of the configuration option from a file or environment\n>   * \\param[in] envVariable Environment variable to get the value from\n>   * \\param[in] confPath The same as in GlobalConfiguration::option\n> + * \\param[in] delimiter Items separator in the environment variable\n>   *\n>   * This helper looks first at the given environment variable and if it is\n>   * defined (even if it is empty) then it splits its value by semicolons and\n> @@ -190,11 +191,12 @@ std::optional<std::string> GlobalConfiguration::envOption(\n>   */\n>  std::optional<std::vector<std::string>> GlobalConfiguration::envListOption(\n>         const char *const envVariable,\n> -       const std::initializer_list<std::string_view> confPath) const\n> +       const std::initializer_list<std::string_view> confPath,\n> +       const std::string delimiter) const\n>  {\n>         const char *envValue = utils::secure_getenv(envVariable);\n>         if (envValue) {\n> -               auto items = utils::split(envValue, \":\");\n> +               auto items = utils::split(envValue, delimiter);\n>                 return std::vector<std::string>(items.begin(), items.end());\n>         }\n>         return listOption(confPath);\n> -- \n> 2.50.1\n>","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id CF03BC324E\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue,  9 Sep 2025 08:52:42 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id E96566935F;\n\tTue,  9 Sep 2025 10:52:41 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 9D55369339\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  9 Sep 2025 10:52:39 +0200 (CEST)","from neptunite.rasen.tech (unknown\n\t[IPv6:2404:7a81:160:2100:6f3a:4f34:f1fa:8b3])\n\tby perceval.ideasonboard.com (Postfix) with UTF8SMTPSA id DBA97593;\n\tTue,  9 Sep 2025 10:51:25 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"pSn17w9s\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1757407886;\n\tbh=YnLbVUZoSwL3JR3pnNbD0dOpcS3xbEwMienZtwtWGZ0=;\n\th=In-Reply-To:References:Subject:From:Cc:To:Date:From;\n\tb=pSn17w9sjLhQOluGw2L21oGWKewTMZ9XPJJwAdj3Eh3524YZLH84zpSERwEb+ZYlT\n\tPbkp4q1e4tvRQZEOMKZL5ZtT5W+Kt8PgLsV528j5cMcaO18yxCRPjE0XgYm2iESlYg\n\tLdw+BESyePelT8JW2Sh+qNwYF1warLv6mha3+m/k=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20250729073201.5369-7-mzamazal@redhat.com>","References":"<20250729073201.5369-1-mzamazal@redhat.com>\n\t<20250729073201.5369-7-mzamazal@redhat.com>","Subject":"Re: [PATCH v16 06/12] config: Look up pipelines match list in\n\tconfiguration file","From":"Paul Elder <paul.elder@ideasonboard.com>","Cc":"Milan Zamazal <mzamazal@redhat.com>, Kieran Bingham\n\t<kieran.bingham@ideasonboard.com>, =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?=\n\t<barnabas.pocze@ideasonboard.com>, Laurent Pinchart\n\t<laurent.pinchart@ideasonboard.com>","To":"Milan Zamazal <mzamazal@redhat.com>, libcamera-devel@lists.libcamera.org","Date":"Tue, 09 Sep 2025 17:52:31 +0900","Message-ID":"<175740795172.2127323.11034940818765108877@neptunite.rasen.tech>","User-Agent":"alot/0.0.0","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]