[{"id":28844,"web_url":"https://patchwork.libcamera.org/comment/28844/","msgid":"<170962164952.566498.15718576350844938762@ping.linuxembedded.co.uk>","date":"2024-03-05T06:54:09","subject":"Re: [PATCH v1 1/1] libcamera: camera_manager: Add environment\n\tvariable to order pipelines match","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Julien Vuillaumier (2024-03-04 18:18:16)\n> To match the enumerated media devices, each pipeline handler registered\n> is used in no specific order. It is a limitation when several pipelines\n> can match the devices, and user has to select a specific pipeline.\n> \n> For this purpose, environment variable LIBCAMERA_PIPELINES_MATCH_LIST is\n> created that gives the option to define an ordered list of pipelines\n> to invoke during the match process.\n> \n> LIBCAMERA_PIPELINES_MATCH_LIST=\"<name1>[,<name2>[,<name3>...]]]\"\n> \n> Example:\n> LIBCAMERA_PIPELINES_MATCH_LIST=\"PipelineHandlerRkISP1,SimplePipelineHandler\"\n> \n> Signed-off-by: Julien Vuillaumier <julien.vuillaumier@nxp.com>\n> ---\n>  Documentation/environment_variables.rst |  5 +++\n>  src/libcamera/camera_manager.cpp        | 51 +++++++++++++++++++++----\n>  2 files changed, 48 insertions(+), 8 deletions(-)\n> \n> diff --git a/Documentation/environment_variables.rst b/Documentation/environment_variables.rst\n> index a9b230bc..f3a0d431 100644\n> --- a/Documentation/environment_variables.rst\n> +++ b/Documentation/environment_variables.rst\n> @@ -37,6 +37,11 @@ LIBCAMERA_IPA_MODULE_PATH\n>  \n>     Example value: ``${HOME}/.libcamera/lib:/opt/libcamera/vendor/lib``\n>  \n> +LIBCAMERA_PIPELINES_MATCH_LIST\n> +   Define ordered list of pipelines to be used to match the media devices.\n> +\n> +   Example value: ``PipelineHandlerRkISP1,SimplePipelineHandler``\n> +\n>  LIBCAMERA_RPI_CONFIG_FILE\n>     Define a custom configuration file to use in the Raspberry Pi pipeline handler.\n>  \n> diff --git a/src/libcamera/camera_manager.cpp b/src/libcamera/camera_manager.cpp\n> index 355f3ada..9568801e 100644\n> --- a/src/libcamera/camera_manager.cpp\n> +++ b/src/libcamera/camera_manager.cpp\n> @@ -109,14 +109,7 @@ void CameraManager::Private::createPipelineHandlers()\n>         const std::vector<PipelineHandlerFactoryBase *> &factories =\n>                 PipelineHandlerFactoryBase::factories();\n>  \n> -       for (const PipelineHandlerFactoryBase *factory : factories) {\n> -               LOG(Camera, Debug)\n> -                       << \"Found registered pipeline handler '\"\n> -                       << factory->name() << \"'\";\n> -               /*\n> -                * Try each pipeline handler until it exhaust\n> -                * all pipelines it can provide.\n> -                */\n> +       auto pipeMatch = [&](const PipelineHandlerFactoryBase *factory) {\n\nDoes this need to be a lambda? is there a specific benefit, or can it be\na function? I find lambda's hard to parse :-( but perhaps that's just\nme, so lets see what others say.\n\n\n>                 while (1) {\n>                         std::shared_ptr<PipelineHandler> pipe = factory->create(o);\n>                         if (!pipe->match(enumerator_.get()))\n> @@ -126,6 +119,48 @@ void CameraManager::Private::createPipelineHandlers()\n>                                 << \"Pipeline handler \\\"\" << factory->name()\n>                                 << \"\\\" matched\";\n>                 }\n> +       };\n> +\n> +       /*\n> +        * When a list of preferred pipelines is defined, iterate through the\n> +        * ordered list to match the devices enumerated.\n> +        * Otherwise, devices matching is done in no specific order with each\n\ns/devices/device/\n\n> +        * pipeline handler registered.\n> +        */\n> +       const char *pipesLists =\n> +               utils::secure_getenv(\"LIBCAMERA_PIPELINES_MATCH_LIST\");\n> +       if (pipesLists) {\n> +               for (const auto &pipeName : utils::split(pipesLists, \",\")) {\n> +                       if (pipeName.empty())\n> +                               continue;\n> +\n> +                       auto nameMatch = [pipeName](const PipelineHandlerFactoryBase *f) {\n> +                               return (f->name() == pipeName);\n> +                       };\n> +\n> +                       auto iter = std::find_if(factories.begin(),\n> +                                                factories.end(),\n> +                                                nameMatch);\n\nIf we do this - I'd probably add support to the PipelineHandlerFactory\nto support getting by name as a preceeding patch.\n\n> +\n> +                       if (iter != factories.end()) {\n> +                               LOG(Camera, Debug)\n> +                                       << \"Found pipeline handler from list '\"\n> +                                       << (*iter)->name() << \"'\";\n> +                               pipeMatch(*iter);\n> +                       }\n> +               }\n> +               return;\n> +       }\n> +\n> +       for (const PipelineHandlerFactoryBase *factory : factories) {\n> +               LOG(Camera, Debug)\n> +                       << \"Found registered pipeline handler '\"\n> +                       << factory->name() << \"'\";\n> +               /*\n> +                * Try each pipeline handler until it exhausts\n> +                * all pipelines it can provide.\n> +                */\n> +               pipeMatch(factory);\n>         }\n>  }\n>  \n> -- \n> 2.34.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 8C73BC326B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue,  5 Mar 2024 06:54:13 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 0544B6286C;\n\tTue,  5 Mar 2024 07:54:13 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id BC00861C83\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  5 Mar 2024 07:54:11 +0100 (CET)","from pendragon.ideasonboard.com\n\t(aztw-30-b2-v4wan-166917-cust845.vm26.cable.virginm.net\n\t[82.37.23.78])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id D7874CC8;\n\tTue,  5 Mar 2024 07:53:54 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"vW4Tlbjx\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1709621634;\n\tbh=GQK0c86GYjScM3LH6F9Ka6H1UbS8CBOmI8yA48y1lZw=;\n\th=In-Reply-To:References:Subject:From:To:Date:From;\n\tb=vW4TlbjxsXcXP5mNr9W5KaEULApsswzLyUeU+G0+Jn47NuGrIZdf/2u6mINb1CxyL\n\t6TSjsnJUb+IbLDzC/gAda4TCiqIZ8LxmO2MKrqesNkN8qO8xmMxPbHG3EUBKrC5oEO\n\tS/6RAb8TlJkZFImw4gMaQKwis8LvWIS+yCLM9Dig=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20240304181816.2361334-2-julien.vuillaumier@nxp.com>","References":"<20240304181816.2361334-1-julien.vuillaumier@nxp.com>\n\t<20240304181816.2361334-2-julien.vuillaumier@nxp.com>","Subject":"Re: [PATCH v1 1/1] libcamera: camera_manager: Add environment\n\tvariable to order pipelines match","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","To":"Julien Vuillaumier <julien.vuillaumier@nxp.com>,\n\tlibcamera-devel@lists.libcamera.org","Date":"Tue, 05 Mar 2024 06:54:09 +0000","Message-ID":"<170962164952.566498.15718576350844938762@ping.linuxembedded.co.uk>","User-Agent":"alot/0.10","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>"}},{"id":28873,"web_url":"https://patchwork.libcamera.org/comment/28873/","msgid":"<LEP8PRrwLiUDciR4NdEdXlznpxZrLA6u7IRay3X_1om0nUcC-FIsBVWpEk1ZrI0DQRh4-YXqC3M6kM1KPWM8pDtga6smGgje8YUuxRZwAg0=@protonmail.com>","date":"2024-03-05T16:42:22","subject":"Re: [PATCH v1 1/1] libcamera: camera_manager: Add environment\n\tvariable to order pipelines match","submitter":{"id":133,"url":"https://patchwork.libcamera.org/api/people/133/","name":"Pőcze Barnabás","email":"pobrn@protonmail.com"},"content":"Hi\n\n\n2024. március 4., hétfő 19:18 keltezéssel, Julien Vuillaumier <julien.vuillaumier@nxp.com> írta:\n\n> To match the enumerated media devices, each pipeline handler registered\n> is used in no specific order. It is a limitation when several pipelines\n> can match the devices, and user has to select a specific pipeline.\n> \n> For this purpose, environment variable LIBCAMERA_PIPELINES_MATCH_LIST is\n> created that gives the option to define an ordered list of pipelines\n> to invoke during the match process.\n> \n> LIBCAMERA_PIPELINES_MATCH_LIST=\"<name1>[,<name2>[,<name3>...]]]\"\n> \n> Example:\n> LIBCAMERA_PIPELINES_MATCH_LIST=\"PipelineHandlerRkISP1,SimplePipelineHandler\"\n> \n> Signed-off-by: Julien Vuillaumier <julien.vuillaumier@nxp.com>\n> ---\n> [...]\n> +\n> +\t/*\n> +\t * When a list of preferred pipelines is defined, iterate through the\n> +\t * ordered list to match the devices enumerated.\n> +\t * Otherwise, devices matching is done in no specific order with each\n> +\t * pipeline handler registered.\n> +\t */\n> +\tconst char *pipesLists =\n> +\t\tutils::secure_getenv(\"LIBCAMERA_PIPELINES_MATCH_LIST\");\n> +\tif (pipesLists) {\n> +\t\tfor (const auto &pipeName : utils::split(pipesLists, \",\")) {\n> +\t\t\tif (pipeName.empty())\n> +\t\t\t\tcontinue;\n> +\n> +\t\t\tauto nameMatch = [pipeName](const PipelineHandlerFactoryBase *f) {\n\n`[&pipeName]` to avoid the copy.\n\n\n> +\t\t\t\treturn (f->name() == pipeName);\n> +\t\t\t};\n> +\n> +\t\t\tauto iter = std::find_if(factories.begin(),\n> +\t\t\t\t\t\t factories.end(),\n> +\t\t\t\t\t\t nameMatch);\n> +\n> +\t\t\tif (iter != factories.end()) {\n> +\t\t\t\tLOG(Camera, Debug)\n> +\t\t\t\t\t<< \"Found pipeline handler from list '\"\n> +\t\t\t\t\t<< (*iter)->name() << \"'\";\n> +\t\t\t\tpipeMatch(*iter);\n> +\t\t\t}\n> +\t\t}\n> +\t\treturn;\n> +\t}\n> +\n> +\tfor (const PipelineHandlerFactoryBase *factory : factories) {\n> +\t\tLOG(Camera, Debug)\n> +\t\t\t<< \"Found registered pipeline handler '\"\n> +\t\t\t<< factory->name() << \"'\";\n> +\t\t/*\n> +\t\t * Try each pipeline handler until it exhausts\n> +\t\t * all pipelines it can provide.\n> +\t\t */\n> +\t\tpipeMatch(factory);\n>  \t}\n>  }\n> \n> --\n> 2.34.1\n> \n\n\nRegards,\nBarnabás Pőcze","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 6D9F2C0F2A\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue,  5 Mar 2024 16:42:54 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id D63C261C92;\n\tTue,  5 Mar 2024 17:42:53 +0100 (CET)","from mail-4316.protonmail.ch (mail-4316.protonmail.ch\n\t[185.70.43.16])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 53A4961C8D\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  5 Mar 2024 17:42:52 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key;\n\tunprotected) header.d=protonmail.com header.i=@protonmail.com\n\theader.b=\"OMifTYFx\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com;\n\ts=protonmail3; t=1709656971; x=1709916171;\n\tbh=NS3Qj3w2EuUYJeMK+bKMrIhMTT6E7Miyfdh/mGtPtgo=;\n\th=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References:\n\tFeedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID:\n\tMessage-ID:BIMI-Selector;\n\tb=OMifTYFx4ryp/FCZGL3wTWkcYFlwUi2SiYlVbWS+Bk7AXBbMyw2DAEQQHeJD0u0u/\n\t9ERKkK9Uv/4Ghl3XiHxDkDgj7jomK7fWWyqZVdAzJ9O6NW25cdWvf/iWCul0W43JSS\n\tCcsgPGex2X3yLBNGshWPwReyG5n03nE3nPUZIx186NwK4giNGFZZwFo7o+fxK5z8DU\n\ts5R7iUS3cCEhGHyeusCs9DhVVeeSspGu3xZnpuf39QRxEX/4w/ZVIRG+xw0EZkNbeQ\n\tx26bbCBw+jjJrPiIfFJ82ZK8kwRi1pmP4Q7H6YlH1syfOfWH22Z+UmytQnHeH6z5F7\n\tUlIiUMqeMbseg==","Date":"Tue, 05 Mar 2024 16:42:22 +0000","To":"Julien Vuillaumier <julien.vuillaumier@nxp.com>","From":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <pobrn@protonmail.com>","Subject":"Re: [PATCH v1 1/1] libcamera: camera_manager: Add environment\n\tvariable to order pipelines match","Message-ID":"<LEP8PRrwLiUDciR4NdEdXlznpxZrLA6u7IRay3X_1om0nUcC-FIsBVWpEk1ZrI0DQRh4-YXqC3M6kM1KPWM8pDtga6smGgje8YUuxRZwAg0=@protonmail.com>","In-Reply-To":"<20240304181816.2361334-2-julien.vuillaumier@nxp.com>","References":"<20240304181816.2361334-1-julien.vuillaumier@nxp.com>\n\t<20240304181816.2361334-2-julien.vuillaumier@nxp.com>","Feedback-ID":"20568564:user:proton","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Transfer-Encoding":"quoted-printable","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>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":28874,"web_url":"https://patchwork.libcamera.org/comment/28874/","msgid":"<4vhi4vseqwbpylxmv5quoe7mucvis7cj6drrsuopg3ksvzz24b@namxemz3bsfv>","date":"2024-03-05T17:38:26","subject":"Re: [PATCH v1 1/1] libcamera: camera_manager: Add environment\n\tvariable to order pipelines match","submitter":{"id":143,"url":"https://patchwork.libcamera.org/api/people/143/","name":"Jacopo Mondi","email":"jacopo.mondi@ideasonboard.com"},"content":"Hi Julien\n\nOn Mon, Mar 04, 2024 at 07:18:16PM +0100, Julien Vuillaumier wrote:\n> To match the enumerated media devices, each pipeline handler registered\n> is used in no specific order. It is a limitation when several pipelines\n> can match the devices, and user has to select a specific pipeline.\n>\n> For this purpose, environment variable LIBCAMERA_PIPELINES_MATCH_LIST is\n> created that gives the option to define an ordered list of pipelines\n> to invoke during the match process.\n>\n> LIBCAMERA_PIPELINES_MATCH_LIST=\"<name1>[,<name2>[,<name3>...]]]\"\n>\n> Example:\n> LIBCAMERA_PIPELINES_MATCH_LIST=\"PipelineHandlerRkISP1,SimplePipelineHandler\"\n\nI think that's a good idea. I expect some bikeshedding on the env\nvariable name :)\n\n>\n> Signed-off-by: Julien Vuillaumier <julien.vuillaumier@nxp.com>\n> ---\n>  Documentation/environment_variables.rst |  5 +++\n>  src/libcamera/camera_manager.cpp        | 51 +++++++++++++++++++++----\n>  2 files changed, 48 insertions(+), 8 deletions(-)\n>\n> diff --git a/Documentation/environment_variables.rst b/Documentation/environment_variables.rst\n> index a9b230bc..f3a0d431 100644\n> --- a/Documentation/environment_variables.rst\n> +++ b/Documentation/environment_variables.rst\n> @@ -37,6 +37,11 @@ LIBCAMERA_IPA_MODULE_PATH\n>\n>     Example value: ``${HOME}/.libcamera/lib:/opt/libcamera/vendor/lib``\n>\n> +LIBCAMERA_PIPELINES_MATCH_LIST\n> +   Define ordered list of pipelines to be used to match the media devices.\n\nnit:\n\n'an ordered list of pipeline names'\n'the media devices in the system'\n\n?\n\n> +\n> +   Example value: ``PipelineHandlerRkISP1,SimplePipelineHandler``\n> +\n>  LIBCAMERA_RPI_CONFIG_FILE\n>     Define a custom configuration file to use in the Raspberry Pi pipeline handler.\n>\n> diff --git a/src/libcamera/camera_manager.cpp b/src/libcamera/camera_manager.cpp\n> index 355f3ada..9568801e 100644\n> --- a/src/libcamera/camera_manager.cpp\n> +++ b/src/libcamera/camera_manager.cpp\n> @@ -109,14 +109,7 @@ void CameraManager::Private::createPipelineHandlers()\n>  \tconst std::vector<PipelineHandlerFactoryBase *> &factories =\n>  \t\tPipelineHandlerFactoryBase::factories();\n>\n> -\tfor (const PipelineHandlerFactoryBase *factory : factories) {\n> -\t\tLOG(Camera, Debug)\n> -\t\t\t<< \"Found registered pipeline handler '\"\n> -\t\t\t<< factory->name() << \"'\";\n> -\t\t/*\n> -\t\t * Try each pipeline handler until it exhaust\n> -\t\t * all pipelines it can provide.\n> -\t\t */\n> +\tauto pipeMatch = [&](const PipelineHandlerFactoryBase *factory) {\n>  \t\twhile (1) {\n>  \t\t\tstd::shared_ptr<PipelineHandler> pipe = factory->create(o);\n>  \t\t\tif (!pipe->match(enumerator_.get()))\n> @@ -126,6 +119,48 @@ void CameraManager::Private::createPipelineHandlers()\n>  \t\t\t\t<< \"Pipeline handler \\\"\" << factory->name()\n>  \t\t\t\t<< \"\\\" matched\";\n>  \t\t}\n> +\t};\n> +\n> +\t/*\n> +\t * When a list of preferred pipelines is defined, iterate through the\n> +\t * ordered list to match the devices enumerated.\n> +\t * Otherwise, devices matching is done in no specific order with each\n> +\t * pipeline handler registered.\n\nnit: 'registered pipeline handler'\n\n> +\t */\n> +\tconst char *pipesLists =\n\nnit: pipesList\n\n> +\t\tutils::secure_getenv(\"LIBCAMERA_PIPELINES_MATCH_LIST\");\n> +\tif (pipesLists) {\n> +\t\tfor (const auto &pipeName : utils::split(pipesLists, \",\")) {\n> +\t\t\tif (pipeName.empty())\n> +\t\t\t\tcontinue;\n\nNot sure if this can be empty, but better safe than sorry\n\n> +\n> +\t\t\tauto nameMatch = [pipeName](const PipelineHandlerFactoryBase *f) {\n> +\t\t\t\treturn (f->name() == pipeName);\n\nno need for ()\n\n> +\t\t\t};\n> +\n> +\t\t\tauto iter = std::find_if(factories.begin(),\n> +\t\t\t\t\t\t factories.end(),\n> +\t\t\t\t\t\t nameMatch);\n\nYou could also inline the above here\n\n\t\t\tauto iter = std::find_if(factories.begin(),\n\t\t\t\t\t\t factories.end(),\n\t\t\t\t\t\t [&pipeName](const PipelineHandlerFactoryBase *f)\n                                                 {\n                                                        return f->name() == pipeName;\n                                                 });\n\nUp to you\n\n> +\n> +\t\t\tif (iter != factories.end()) {\n> +\t\t\t\tLOG(Camera, Debug)\n> +\t\t\t\t\t<< \"Found pipeline handler from list '\"\n> +\t\t\t\t\t<< (*iter)->name() << \"'\";\n> +\t\t\t\tpipeMatch(*iter);\n> +\t\t\t}\n> +\t\t}\n> +\t\treturn;\n> +\t}\n> +\n> +\tfor (const PipelineHandlerFactoryBase *factory : factories) {\n> +\t\tLOG(Camera, Debug)\n> +\t\t\t<< \"Found registered pipeline handler '\"\n> +\t\t\t<< factory->name() << \"'\";\n\nIf order was not relevant, you could have simply searched\nfactory->name() in pipesLists here, but I presume the order in which\npipelines are specified in the env variable and matched is relevant,\nright ?\n\n> +\t\t/*\n> +\t\t * Try each pipeline handler until it exhausts\n> +\t\t * all pipelines it can provide.\n> +\t\t */\n> +\t\tpipeMatch(factory);\n>  \t}\n>  }\n>\n> --\n> 2.34.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 AA24AC0F2A\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue,  5 Mar 2024 17:38:31 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 031B261C92;\n\tTue,  5 Mar 2024 18:38:31 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 3614361C8D\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  5 Mar 2024 18:38:29 +0100 (CET)","from ideasonboard.com (unknown\n\t[IPv6:2001:b07:5d2e:52c9:cc1e:e404:491f:e6ea])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 0C9818D0;\n\tTue,  5 Mar 2024 18:38:12 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"UyPVdmMj\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1709660292;\n\tbh=tptT0V51Z8oEKtg50KIFv8/YsjRLiQILJg5nJGRD7nU=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=UyPVdmMjQSxArGypDgrKQ+vFEP2TUS52Lt1BXLpsM2Z5bTbnYAMSPmwhjp1jWOSmp\n\tlqzqPVdIYuVaAFVEPH9ZyM7UimgKgLLHWAy3PLrjHzAr+WJLuX1OR0cyPc6a5wyH7k\n\tgixIk+sqz9scdzr+8wISo5A8n0sX+Xia+mg03FDg=","Date":"Tue, 5 Mar 2024 18:38:26 +0100","From":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>","To":"Julien Vuillaumier <julien.vuillaumier@nxp.com>","Subject":"Re: [PATCH v1 1/1] libcamera: camera_manager: Add environment\n\tvariable to order pipelines match","Message-ID":"<4vhi4vseqwbpylxmv5quoe7mucvis7cj6drrsuopg3ksvzz24b@namxemz3bsfv>","References":"<20240304181816.2361334-1-julien.vuillaumier@nxp.com>\n\t<20240304181816.2361334-2-julien.vuillaumier@nxp.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20240304181816.2361334-2-julien.vuillaumier@nxp.com>","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>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":28892,"web_url":"https://patchwork.libcamera.org/comment/28892/","msgid":"<3131d544-ecf1-4e1b-a902-11015a4c6e16@nxp.com>","date":"2024-03-06T17:57:58","subject":"Re: [EXT] Re: [PATCH v1 1/1] libcamera: camera_manager: Add\n\tenvironment variable to order pipelines match","submitter":{"id":190,"url":"https://patchwork.libcamera.org/api/people/190/","name":"Julien Vuillaumier","email":"julien.vuillaumier@nxp.com"},"content":"Hi Kieran,\n\nOn 05/03/2024 07:54, Kieran Bingham wrote:\n> Caution: This is an external email. Please take care when clicking links or opening attachments. When in doubt, report the message using the 'Report this email' button\n> \n> \n> Quoting Julien Vuillaumier (2024-03-04 18:18:16)\n>> To match the enumerated media devices, each pipeline handler registered\n>> is used in no specific order. It is a limitation when several pipelines\n>> can match the devices, and user has to select a specific pipeline.\n>>\n>> For this purpose, environment variable LIBCAMERA_PIPELINES_MATCH_LIST is\n>> created that gives the option to define an ordered list of pipelines\n>> to invoke during the match process.\n>>\n>> LIBCAMERA_PIPELINES_MATCH_LIST=\"<name1>[,<name2>[,<name3>...]]]\"\n>>\n>> Example:\n>> LIBCAMERA_PIPELINES_MATCH_LIST=\"PipelineHandlerRkISP1,SimplePipelineHandler\"\n>>\n>> Signed-off-by: Julien Vuillaumier <julien.vuillaumier@nxp.com>\n>> ---\n>>   Documentation/environment_variables.rst |  5 +++\n>>   src/libcamera/camera_manager.cpp        | 51 +++++++++++++++++++++----\n>>   2 files changed, 48 insertions(+), 8 deletions(-)\n>>\n>> diff --git a/Documentation/environment_variables.rst b/Documentation/environment_variables.rst\n>> index a9b230bc..f3a0d431 100644\n>> --- a/Documentation/environment_variables.rst\n>> +++ b/Documentation/environment_variables.rst\n>> @@ -37,6 +37,11 @@ LIBCAMERA_IPA_MODULE_PATH\n>>\n>>      Example value: ``${HOME}/.libcamera/lib:/opt/libcamera/vendor/lib``\n>>\n>> +LIBCAMERA_PIPELINES_MATCH_LIST\n>> +   Define ordered list of pipelines to be used to match the media devices.\n>> +\n>> +   Example value: ``PipelineHandlerRkISP1,SimplePipelineHandler``\n>> +\n>>   LIBCAMERA_RPI_CONFIG_FILE\n>>      Define a custom configuration file to use in the Raspberry Pi pipeline handler.\n>>\n>> diff --git a/src/libcamera/camera_manager.cpp b/src/libcamera/camera_manager.cpp\n>> index 355f3ada..9568801e 100644\n>> --- a/src/libcamera/camera_manager.cpp\n>> +++ b/src/libcamera/camera_manager.cpp\n>> @@ -109,14 +109,7 @@ void CameraManager::Private::createPipelineHandlers()\n>>          const std::vector<PipelineHandlerFactoryBase *> &factories =\n>>                  PipelineHandlerFactoryBase::factories();\n>>\n>> -       for (const PipelineHandlerFactoryBase *factory : factories) {\n>> -               LOG(Camera, Debug)\n>> -                       << \"Found registered pipeline handler '\"\n>> -                       << factory->name() << \"'\";\n>> -               /*\n>> -                * Try each pipeline handler until it exhaust\n>> -                * all pipelines it can provide.\n>> -                */\n>> +       auto pipeMatch = [&](const PipelineHandlerFactoryBase *factory) {\n> \n> Does this need to be a lambda? is there a specific benefit, or can it be\n> a function? I find lambda's hard to parse :-( but perhaps that's just\n> me, so lets see what others say.\n\nThis lambda can be moved to a function, but this function would probably \nnever be used from anywhere else - for that reason it was made local as \na lambda. But if consensus is to limit usage of lambda, a function can \nbe used instead.\n\n> \n>>                  while (1) {\n>>                          std::shared_ptr<PipelineHandler> pipe = factory->create(o);\n>>                          if (!pipe->match(enumerator_.get()))\n>> @@ -126,6 +119,48 @@ void CameraManager::Private::createPipelineHandlers()\n>>                                  << \"Pipeline handler \\\"\" << factory->name()\n>>                                  << \"\\\" matched\";\n>>                  }\n>> +       };\n>> +\n>> +       /*\n>> +        * When a list of preferred pipelines is defined, iterate through the\n>> +        * ordered list to match the devices enumerated.\n>> +        * Otherwise, devices matching is done in no specific order with each\n> \n> s/devices/device/\n> \n\nI will update in v2 - thanks.\n\n>> +        * pipeline handler registered.\n>> +        */\n>> +       const char *pipesLists =\n>> +               utils::secure_getenv(\"LIBCAMERA_PIPELINES_MATCH_LIST\");\n>> +       if (pipesLists) {\n>> +               for (const auto &pipeName : utils::split(pipesLists, \",\")) {\n>> +                       if (pipeName.empty())\n>> +                               continue;\n>> +\n>> +                       auto nameMatch = [pipeName](const PipelineHandlerFactoryBase *f) {\n>> +                               return (f->name() == pipeName);\n>> +                       };\n>> +\n>> +                       auto iter = std::find_if(factories.begin(),\n>> +                                                factories.end(),\n>> +                                                nameMatch);\n> \n> If we do this - I'd probably add support to the PipelineHandlerFactory\n> to support getting by name as a preceeding patch.\n> \n\nSure, I can do - will update in v2.\n\n>> +\n>> +                       if (iter != factories.end()) {\n>> +                               LOG(Camera, Debug)\n>> +                                       << \"Found pipeline handler from list '\"\n>> +                                       << (*iter)->name() << \"'\";\n>> +                               pipeMatch(*iter);\n>> +                       }\n>> +               }\n>> +               return;\n>> +       }\n>> +\n>> +       for (const PipelineHandlerFactoryBase *factory : factories) {\n>> +               LOG(Camera, Debug)\n>> +                       << \"Found registered pipeline handler '\"\n>> +                       << factory->name() << \"'\";\n>> +               /*\n>> +                * Try each pipeline handler until it exhausts\n>> +                * all pipelines it can provide.\n>> +                */\n>> +               pipeMatch(factory);\n>>          }\n>>   }\n>>\n>> --\n>> 2.34.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 C2197C0F2A\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  6 Mar 2024 17:57:54 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 808F662867;\n\tWed,  6 Mar 2024 18:57:54 +0100 (CET)","from EUR02-AM0-obe.outbound.protection.outlook.com\n\t(mail-am0eur02on20601.outbound.protection.outlook.com\n\t[IPv6:2a01:111:f403:2606::601])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id D142861C8F\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  6 Mar 2024 18:57:52 +0100 (CET)","from AM9PR04MB8147.eurprd04.prod.outlook.com\n\t(2603:10a6:20b:3e0::22)\n\tby AM9PR04MB8907.eurprd04.prod.outlook.com (2603:10a6:20b:40a::22)\n\twith Microsoft SMTP Server (version=TLS1_2,\n\tcipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7339.39;\n\tWed, 6 Mar 2024 17:57:51 +0000","from AM9PR04MB8147.eurprd04.prod.outlook.com\n\t([fe80::3fdf:4cf8:d542:1b49]) by\n\tAM9PR04MB8147.eurprd04.prod.outlook.com\n\t([fe80::3fdf:4cf8:d542:1b49%4]) with mapi id 15.20.7362.019;\n\tWed, 6 Mar 2024 17:57:51 +0000"],"Authentication-Results":["lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=nxp.com header.i=@nxp.com header.b=\"J5PQgwGk\";\n\tdkim-atps=neutral","dkim=none (message not signed)\n\theader.d=none;dmarc=none action=none header.from=nxp.com;"],"ARC-Seal":"i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none;\n\tb=AUWwgxVyaauHiW+5NWgFTDLc9gW/5Mfzvsu1J8poWdLR2YzvHCq30Q2mI0s5KBaJqNub1foFpf8E9BCbye8OHsRLzfd8WUp+wKNP4Qw3vHhHc24LLFflr/NhMqjcCfwawlcipOrB61hJebt/GkiLyjKEau4d6HEgw8bZfpOsd97y7RJOTwuph/jBkY/NljK90jpuSbkJxDD26BHP7bJLndpst0Ta4mVs4maeqqPlzB/8GygAIeoDEqlRo15vkP9bsh5qfHJEME9f9+m7HxcAhSWIKiXPYyB9GgyjeZXNiF01VsOPbESSeP0PJBbTRDD+/KmQMtncxrFRVNx11mZyUg==","ARC-Message-Signature":"i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com;\n\ts=arcselector9901;\n\th=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1;\n\tbh=ADEW6JqQodAUMgg86vgy7yWw9S3XqZVsiXugxKhvNlc=;\n\tb=FinaPSbo9uyW633iCWBQ76wDCQdwLIdyGMxeiAfQgQq9j7ACoGp+BT2abn/9zZdEcCDQSCKogJxJD+oWPOihow3DQG9TveiXvlXlO/U6mlFE2gPOoiGRn4nnPot9vQrarjxUJ0fyXh/3N3cRmyTckGLS0GpA6N/71LtWauiHqNWtI9VNwJ2TPtQxU+1CjlQLQwooDEwXoOqpYPi1XDAG0YkC1EoOQUuItFEXr39kM8FQXWjLxBSPR91YoCIzDJS5nLGQuR4JPpI7IKD2L3JmXHnJ4aDiaEXP9eJyJBgDu7LVuTG9XnmeFAcYDXFpxMqEJH/bn/xI87j2zQvzQzJ2Zg==","ARC-Authentication-Results":"i=1; mx.microsoft.com 1; spf=pass\n\tsmtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com;\n\tdkim=pass header.d=nxp.com; arc=none","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2;\n\th=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck;\n\tbh=ADEW6JqQodAUMgg86vgy7yWw9S3XqZVsiXugxKhvNlc=;\n\tb=J5PQgwGkNoqVy3zGw6mGbU5jC3dBQcbwA6xx9+3IovlHzcYl+SSZOtvmSJm29aoZYNLacM/1Z21jBjzkQtZnBJLFV1dX0dgz8QRsp6sj5XZHbymA2IzwM3141ngk1RUd16O8yoUp0HsrKUnt/j3w7MqJI7MHIJh5x3HP73hTt3I=","Message-ID":"<3131d544-ecf1-4e1b-a902-11015a4c6e16@nxp.com>","Date":"Wed, 6 Mar 2024 18:57:58 +0100","User-Agent":"Mozilla Thunderbird","Subject":"Re: [EXT] Re: [PATCH v1 1/1] libcamera: camera_manager: Add\n\tenvironment variable to order pipelines match","Content-Language":"en-US","To":"Kieran Bingham <kieran.bingham@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","References":"<20240304181816.2361334-1-julien.vuillaumier@nxp.com>\n\t<20240304181816.2361334-2-julien.vuillaumier@nxp.com>\n\t<170962164952.566498.15718576350844938762@ping.linuxembedded.co.uk>","From":"Julien Vuillaumier <julien.vuillaumier@nxp.com>","In-Reply-To":"<170962164952.566498.15718576350844938762@ping.linuxembedded.co.uk>","Content-Type":"text/plain; charset=UTF-8; format=flowed","Content-Transfer-Encoding":"7bit","X-ClientProxiedBy":"AS4P190CA0069.EURP190.PROD.OUTLOOK.COM\n\t(2603:10a6:20b:656::15) To AM9PR04MB8147.eurprd04.prod.outlook.com\n\t(2603:10a6:20b:3e0::22)","MIME-Version":"1.0","X-MS-PublicTrafficType":"Email","X-MS-TrafficTypeDiagnostic":"AM9PR04MB8147:EE_|AM9PR04MB8907:EE_","X-MS-Office365-Filtering-Correlation-Id":"139279b4-3e97-4d9f-cb60-08dc3e06f135","X-MS-Exchange-SenderADCheck":"1","X-MS-Exchange-AntiSpam-Relay":"0","X-Microsoft-Antispam":"BCL:0;","X-Microsoft-Antispam-Message-Info":"vOI1xFXzDKG0QWCVEoCeVarur3vmnj92UMIJFlwOfciGe0IXnWhkSr48qbpPruHaVO4AGd9FhsRZSGdB4VsPHfWaV0lzOSnUmMAw89pQZf4F8JTxEyYXB8PLdQ48hfBlb2vRevwCKos6q7Rcxa8OELv2q8MhKYsLC16rAMmHzWO72XODLahAYHiy4zausnaoKCli30o4kSvwLxXqWoMxIdUhVrozTGI3r1YMsfORUkB5F+TybQu3wt8PdzwljR00+iUSPq9NvYAL4qo1qaZ02bqOAe6alvbT6yZ2DzuBaIp1PG05YNtrw+otcjg5BZ+3pUuK174DmORpAlN4hgNsGu9E0k3DWrkbnixPPK98MeZhVymihL1NzyAAbdBW21JJSisW2qsh+aWiSRBlhYOgpgcGFrrCCBzWrs6KCRrP3pFInoV9bSyyjI13xceYRCIykjeZL91YElwEthuKyiNpIsNO2kd0jNqNWAITi5xs1Uiy+PWqp336cK6EJtL12XPTdBxk77nGB7+5MM+bSKKz279ZdT5w5QjJk52kk4w/23gC4cTofbtk3SIov8RW5E2BKlb+3RLv3W5n2sFO3GIZwcX92LMCasLWElN6HdUk01nyrcBMrVCQxQFnNSvMyJ4kdfJ1n+3ju7jJbwB3Ow4eSEhxTylILIZgeGcHW1hdkeg=","X-Forefront-Antispam-Report":"CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:;\n\tIPV:NLI; SFV:NSPM; H:AM9PR04MB8147.eurprd04.prod.outlook.com; PTR:;\n\tCAT:NONE; \n\tSFS:(13230031)(376005); DIR:OUT; SFP:1101; ","X-MS-Exchange-AntiSpam-MessageData-ChunkCount":"1","X-MS-Exchange-AntiSpam-MessageData-0":"=?utf-8?q?fZtfSX+zToU/EHs25wZK7gBPh?=\n\t=?utf-8?q?n2MhcimjuRBjVMjN0FZ3IuhNxP4rqP2nAlK38x3HMOyrIVX2zmqK2erW?=\n\t=?utf-8?q?NU3mkUligsrJuWrPEseBAgCtclMojvlz3eDogBU8LsY6Fyzlwk3TNMnf?=\n\t=?utf-8?q?Y2fLMg0jKOwS1HUNzanlo6RRPuu2lwKPcddfZbmi4xYt3t8J7M0jmOWQ?=\n\t=?utf-8?q?ijkR6bQNem8iIYGKc3pMuWit7cs/MQOvIbpyi+Qtny43gPxvpZbsIb+K?=\n\t=?utf-8?q?GryBDcnX9hnPxMxTSxOkm7cCrbli2lyDbbIuNkEXulR40eDijOiLzC/z?=\n\t=?utf-8?q?NRXzRAKLLCTNU+O3EaI/iqjx7T8PYH6Lthwf27m0psxb9qDZ5jOiDXrf?=\n\t=?utf-8?q?7lhpHvDz4h8jTToT1nUhMoVLxf24uNkxV8rwrgETieCLPpjqcL/yhkV9?=\n\t=?utf-8?q?aICjlCnj2pA28tSvte4ovnMfOvbr1iNY9IZOCFtt+Pi2B/+lxxbGprFx?=\n\t=?utf-8?q?CXXmpfMvXgGTFbDFiye8tx8AmEs2CuVPbEoon4PWuwGR74AZYfEbNOpN?=\n\t=?utf-8?q?ersjaYPrBNk6cPqbPLcZVzROo/P678GB6JEfrRgyhXfE8W44YDLxxmNE?=\n\t=?utf-8?q?4JdP0LdF8o7gJC2rVm794sAWa06f5sLONNxaSoLKoDUelfmiKoS3EB3f?=\n\t=?utf-8?q?esGST5xWW4hXg9C8CZ2lmEzx0wtdNdHcxA7DkpkPVUawJTHF22isThHY?=\n\t=?utf-8?q?1EeYkshDF3ZEeGTf6wt4h+0ZFFfMDCevS4olpMcA7Pe89cwImtL7hJj7?=\n\t=?utf-8?q?Ej8m+pb+ESV81vsQLet+3FbWfVTRIF6w1oQuS863Qhv83MzhmjbdxuoI?=\n\t=?utf-8?q?U2GydWLS8Rz2W9Vnf6WVL0nKk391SR3lgeSBfM9sSqIdeUCF/AeONEey?=\n\t=?utf-8?q?QyBk3sfhONpjpOTNSIddJsMKLlxGoRjZaozi0lcM37Edt8EaOFv9VlpE?=\n\t=?utf-8?q?TbzTdYhW++jK4TXJ5qiogDanl+MnBCqCaJ1N8JfxqmHh52evmNYc9fGJ?=\n\t=?utf-8?q?SAsYJfQDER12XUw7ARPwHBQvzXYgAFsJQzUuFB+44kesUSgxVT/Qj6nc?=\n\t=?utf-8?q?BpLVbQL5WPWg3h9E3weLBefNmwhV4fSGw+9oHtaRHu4EVZQS3IFf9TEU?=\n\t=?utf-8?q?5LHZS+al83QtERRuz3mRDW+/SsMdFA8WS6qlK1cEO/v4p2BiXgaldPCz?=\n\t=?utf-8?q?Qs9Qp4TucYULGWHRRsELJmdWp1Rb1jdo30NVqFZxqMaCfnpPkRqA1zwE?=\n\t=?utf-8?q?Z66XRP8fTEoBzdUWoEkOpK4eVFtCz9cUuqJ5zq26gXt73duTrtz2RTmq?=\n\t=?utf-8?q?+iL7XYXPdcy+tzaH34Q6nHsI/wpuaxohxo+dE1u37PlEAsRF0PLWzt6a?=\n\t=?utf-8?q?qR9G0xO5585uUqEB5oLU9TGRg+F515na08R77ACp96lBTtW+XrXugTJ8?=\n\t=?utf-8?q?EZ6y5aUaV3VZPbtNSFDONz4V2KkqT4emhB+fJl4weMwr/behg9ggyrrW?=\n\t=?utf-8?q?NMBbiVsdcOLSpEVjG52esMdCRuR+HE9hADcrw6j7QvB+ecrwJEUJdVuw?=\n\t=?utf-8?q?1A2/NZaOYwm5HTr5xpumn0+AxjhpxQ2mxzRpF2I70hgB81H5otP84RYj?=\n\t=?utf-8?q?W8GYYCGFeBIyhI9kWwkXJ/AyiUiyg2kXo8l1IrcmeSyj3cfmlN0GaGx1?=\n\t=?utf-8?q?14n73PwSXyx9T0wYGTsOnsrdFuJ8g=3D=3D?=","X-OriginatorOrg":"nxp.com","X-MS-Exchange-CrossTenant-Network-Message-Id":"139279b4-3e97-4d9f-cb60-08dc3e06f135","X-MS-Exchange-CrossTenant-AuthSource":"AM9PR04MB8147.eurprd04.prod.outlook.com","X-MS-Exchange-CrossTenant-AuthAs":"Internal","X-MS-Exchange-CrossTenant-OriginalArrivalTime":"06 Mar 2024 17:57:51.8011\n\t(UTC)","X-MS-Exchange-CrossTenant-FromEntityHeader":"Hosted","X-MS-Exchange-CrossTenant-Id":"686ea1d3-bc2b-4c6f-a92c-d99c5c301635","X-MS-Exchange-CrossTenant-MailboxType":"HOSTED","X-MS-Exchange-CrossTenant-UserPrincipalName":"PnrL+OlhF4t5nrbUdMbha9wRYq8U0jMbI1Oh83lltJY8qmd4dUQ3GTbZT7MPGmiZTNOVRNyaogk6cWCPrbFYl3qrz4ATj9arZscCw/B5HZg=","X-MS-Exchange-Transport-CrossTenantHeadersStamped":"AM9PR04MB8907","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>"}},{"id":28893,"web_url":"https://patchwork.libcamera.org/comment/28893/","msgid":"<63570c46-bd3e-4e54-a44b-7f07d0b18e61@nxp.com>","date":"2024-03-06T18:04:26","subject":"[PATCH v1 1/1] libcamera: camera_manager: Add environment variable\n\tto order pipelines match","submitter":{"id":190,"url":"https://patchwork.libcamera.org/api/people/190/","name":"Julien Vuillaumier","email":"julien.vuillaumier@nxp.com"},"content":"Hi Barnabás,\n\nOn 05/03/2024 17:42, Barnabás Pőcze wrote:\n> Caution: This is an external email. Please take care when clicking links or opening attachments. When in doubt, report the message using the 'Report this email' button\n> \n> \n> Hi\n> \n> \n> 2024. március 4., hétfő 19:18 keltezéssel, Julien Vuillaumier <julien.vuillaumier@nxp.com> írta:\n> \n>> To match the enumerated media devices, each pipeline handler registered\n>> is used in no specific order. It is a limitation when several pipelines\n>> can match the devices, and user has to select a specific pipeline.\n>>\n>> For this purpose, environment variable LIBCAMERA_PIPELINES_MATCH_LIST is\n>> created that gives the option to define an ordered list of pipelines\n>> to invoke during the match process.\n>>\n>> LIBCAMERA_PIPELINES_MATCH_LIST=\"<name1>[,<name2>[,<name3>...]]]\"\n>>\n>> Example:\n>> LIBCAMERA_PIPELINES_MATCH_LIST=\"PipelineHandlerRkISP1,SimplePipelineHandler\"\n>>\n>> Signed-off-by: Julien Vuillaumier <julien.vuillaumier@nxp.com>\n>> ---\n>> [...]\n>> +\n>> +     /*\n>> +      * When a list of preferred pipelines is defined, iterate through the\n>> +      * ordered list to match the devices enumerated.\n>> +      * Otherwise, devices matching is done in no specific order with each\n>> +      * pipeline handler registered.\n>> +      */\n>> +     const char *pipesLists =\n>> +             utils::secure_getenv(\"LIBCAMERA_PIPELINES_MATCH_LIST\");\n>> +     if (pipesLists) {\n>> +             for (const auto &pipeName : utils::split(pipesLists, \",\")) {\n>> +                     if (pipeName.empty())\n>> +                             continue;\n>> +\n>> +                     auto nameMatch = [pipeName](const PipelineHandlerFactoryBase *f) {\n> \n> `[&pipeName]` to avoid the copy.\n\nI will update in v2 - thanks\n\n> \n>> +                             return (f->name() == pipeName);\n>> +                     };\n>> +\n>> +                     auto iter = std::find_if(factories.begin(),\n>> +                                              factories.end(),\n>> +                                              nameMatch);\n>> +\n>> +                     if (iter != factories.end()) {\n>> +                             LOG(Camera, Debug)\n>> +                                     << \"Found pipeline handler from list '\"\n>> +                                     << (*iter)->name() << \"'\";\n>> +                             pipeMatch(*iter);\n>> +                     }\n>> +             }\n>> +             return;\n>> +     }\n>> +\n>> +     for (const PipelineHandlerFactoryBase *factory : factories) {\n>> +             LOG(Camera, Debug)\n>> +                     << \"Found registered pipeline handler '\"\n>> +                     << factory->name() << \"'\";\n>> +             /*\n>> +              * Try each pipeline handler until it exhausts\n>> +              * all pipelines it can provide.\n>> +              */\n>> +             pipeMatch(factory);\n>>        }\n>>   }\n>>\n>> --\n>> 2.34.1\n>>\n> \n> \n> Regards,\n> Barnabás Pőcze","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 3CFBBBD160\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  6 Mar 2024 18:04:27 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 7812462867;\n\tWed,  6 Mar 2024 19:04:26 +0100 (CET)","from EUR04-VI1-obe.outbound.protection.outlook.com\n\t(mail-vi1eur04on20600.outbound.protection.outlook.com\n\t[IPv6:2a01:111:f403:2611::600])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 2261262867\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  6 Mar 2024 19:04:25 +0100 (CET)","from AM9PR04MB8147.eurprd04.prod.outlook.com\n\t(2603:10a6:20b:3e0::22)\n\tby AM9PR04MB8761.eurprd04.prod.outlook.com (2603:10a6:20b:408::17)\n\twith Microsoft SMTP Server (version=TLS1_2,\n\tcipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7339.39;\n\tWed, 6 Mar 2024 18:04:23 +0000","from AM9PR04MB8147.eurprd04.prod.outlook.com\n\t([fe80::3fdf:4cf8:d542:1b49]) by\n\tAM9PR04MB8147.eurprd04.prod.outlook.com\n\t([fe80::3fdf:4cf8:d542:1b49%4]) with mapi id 15.20.7362.019;\n\tWed, 6 Mar 2024 18:04:21 +0000"],"Authentication-Results":["lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=nxp.com header.i=@nxp.com header.b=\"UA9qGMTq\";\n\tdkim-atps=neutral","dkim=none (message not signed)\n\theader.d=none;dmarc=none action=none header.from=nxp.com;"],"ARC-Seal":"i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none;\n\tb=aI70NuHDQIEoPdIyXp1oRDFndanCqy+KFWRzGQ9kA/oEdb9N33YX8V0ZNG3raSj+x7fwc04EjBZHWMNncoHxAGzSC2KO48k8hmTSbgbjFZNJds62lyQ/ENe7jupXprLQiYQ3ks2y/4YdXqCyPOyU/MgAvLFZznLzpFnzuRcfrM7LOx94KFOJ6FbHUaFef31i2GT1qrPCa67Ph5PCc+daXJBDafZd7FXC6hvTY4Sfo+KDOt1Shv2tedVwFnerlSM6QMXVC0WpeIpvBxr8KHyzHNjU0Gumexr1/MptlMwMGwj//urzi3ng680lBUSSOTNzz9qCG532fiUKACkZ+0MjqQ==","ARC-Message-Signature":"i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com;\n\ts=arcselector9901;\n\th=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1;\n\tbh=zuP9XWuKOisrRX7HgBKUIRJPaCj7hXB1SrNUXympt6g=;\n\tb=ViB7yT5VzTSI55yXKehm5WmJOsGDNYuwGEmCOiNVPKmnQDtwfXhwYhOO4/7wpcYJqt2c+TVGLvqFlGV6psj67ujBLpreReExHMwMn/uYuYSNMqYIq9ja/zdR2S7TJ5vxJS61S0GTP8v+5Mc64fXwB45bEeCZJdUjioMC+ngGWPMn5lECc5A8oFNvvtxSgLPxPf9Nhj3Xl/MlYAT5z7KZu5BwEsQhtk8Kk3l0Pa7pF+uj2yLQSrBdYWHWdMcV85S2b7ycnsgjTTCOVBbrHoq1qqO9YmxHklEd+D+AUhOOHaoOYOig/nQvRsGqlHs7OLlBUSpcfrDW+IlIZL8U8K5VBA==","ARC-Authentication-Results":"i=1; mx.microsoft.com 1; spf=pass\n\tsmtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com;\n\tdkim=pass header.d=nxp.com; arc=none","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2;\n\th=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck;\n\tbh=zuP9XWuKOisrRX7HgBKUIRJPaCj7hXB1SrNUXympt6g=;\n\tb=UA9qGMTqXENP9knyBvVoch8OlNpzdzjcccO35SzUYJfMpXgU4N1JaULXWiSM7Ff9dvJGUVFODND2iBZr+G1CnTY0fSdIW/HzUNNRmME6SwzgqT6DLmdo3DISIaPLuZDg0FOcyO2JJ3SsN9CXZmNT7JJPushUmjBB1c0JMMnfx9c=","Message-ID":"<63570c46-bd3e-4e54-a44b-7f07d0b18e61@nxp.com>","Date":"Wed, 6 Mar 2024 19:04:26 +0100","User-Agent":"Mozilla Thunderbird","Subject":"[PATCH v1 1/1] libcamera: camera_manager: Add environment variable\n\tto order pipelines match","Content-Language":"en-US","To":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <pobrn@protonmail.com>","References":"<20240304181816.2361334-1-julien.vuillaumier@nxp.com>\n\t<20240304181816.2361334-2-julien.vuillaumier@nxp.com>\n\t<LEP8PRrwLiUDciR4NdEdXlznpxZrLA6u7IRay3X_1om0nUcC-FIsBVWpEk1ZrI0DQRh4-YXqC3M6kM1KPWM8pDtga6smGgje8YUuxRZwAg0=@protonmail.com>","From":"Julien Vuillaumier <julien.vuillaumier@nxp.com>","In-Reply-To":"<LEP8PRrwLiUDciR4NdEdXlznpxZrLA6u7IRay3X_1om0nUcC-FIsBVWpEk1ZrI0DQRh4-YXqC3M6kM1KPWM8pDtga6smGgje8YUuxRZwAg0=@protonmail.com>","Content-Type":"text/plain; charset=UTF-8; format=flowed","Content-Transfer-Encoding":"8bit","X-ClientProxiedBy":"AM0PR02CA0111.eurprd02.prod.outlook.com\n\t(2603:10a6:20b:28c::8) To AM9PR04MB8147.eurprd04.prod.outlook.com\n\t(2603:10a6:20b:3e0::22)","MIME-Version":"1.0","X-MS-PublicTrafficType":"Email","X-MS-TrafficTypeDiagnostic":"AM9PR04MB8147:EE_|AM9PR04MB8761:EE_","X-MS-Office365-Filtering-Correlation-Id":"82ef4eea-7cb2-4281-d792-08dc3e07d964","X-MS-Exchange-SenderADCheck":"1","X-MS-Exchange-AntiSpam-Relay":"0","X-Microsoft-Antispam":"BCL:0;","X-Microsoft-Antispam-Message-Info":"AslyKUCxMQPQKo4WcN4dpx0gxBG/j0eNZ+c9wgVyc0jNlRl1+TaWqukhtIKF8KKuYCHpyUSZcQZBpu2s8hfmMU0r69ixEiQMKDoKDp5iDv1B9en7FluhWXY1jTbNFLdS9w+bGi52n6qz7+pFsFmEYl1bCfvpBrn1FB0bYQNtWIQ+mlLqQS0IyRT0JQfFHO6fNUpB04DDWLwuWrmPoKKShrWsokjWr2KUCJtd3hqtJLRJ2piYHwciWgt+8cYUKC6uDB5nQgWgJbjR4ETPbRpUcUuPn2+0LIGQJ+qeQn/Ju1O4LXNmiHuzuN/DoQo9D7SyyJHfmyFNbB364nCoVdymQS7gzzdGIaPKPskrk1nBj36802gPr4aJZNoAJ4Q2S5h+Rmi/rXO7QxKkwz9Y0Qa59u3lJUzrC3ODCokDDC2U9eooRKyJBLRkzofy3pAkf0wv8rK49aqMQyiKO8QZ7m6bz5WMSx+0H7n8mxju1pKUo73vViOlcCmqZbuyjQS7VcbXH1y7kZwwE1JSP7yhxi6jwU+C5H2/QnzuRmYMv69jeqnIgjzbm7zsMwOd7vaZAQFQiBlwyYITp5lcazmNTuj18YhRPcYuX8gOBXU43ort9ZcBmNC3f7GX6JTATl1jvhr1XH5j3oCUBO89gr5/GZrfgL7qXUqyrGzN6DxPYn84DXw=","X-Forefront-Antispam-Report":"CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:;\n\tIPV:NLI; SFV:NSPM; H:AM9PR04MB8147.eurprd04.prod.outlook.com; PTR:;\n\tCAT:NONE; \n\tSFS:(13230031)(376005); DIR:OUT; SFP:1101; ","X-MS-Exchange-AntiSpam-MessageData-ChunkCount":"1","X-MS-Exchange-AntiSpam-MessageData-0":"=?utf-8?q?/Olv7i8mHFJUXfHxlsTzW/YFN?=\n\t=?utf-8?q?ZdQ9+pIan8z/eTbdQEQ8DKd3hd6k1sF3IkT4TXaFN4dKK5463lZSnFW6?=\n\t=?utf-8?q?Q17hWNEfY9XR4h0V74+MTtFYV6qFHuWe+uPQefV5bX2d0d8ipZpx4fAA?=\n\t=?utf-8?q?JO0JbSZSOi6SGvzBqbOA0rydQUn/rpzrtTl+mb/l8BkVgVwcB+dUlSuB?=\n\t=?utf-8?q?8dIxeRSxEU7YeW5x5bazpVLoirCUAU82uyi6gP+ZdC5qnXeDnr2DgRHh?=\n\t=?utf-8?q?2RA6kuzkM85VB7v4OD3IgPz8rO9o1QyZbW2TCL85H9n0kDV7nfE4RDwA?=\n\t=?utf-8?q?kqgECvbvtfT8IkyugPQ+WKnbAb7L9DvUZIfke9BcI9Dp3fmMwT6QmDtd?=\n\t=?utf-8?q?Wg0u3YzEMSqtQnblnKNJ1brXbZIPP+WMQGUpNJN7CKKYJ/lwo5XZ9+v7?=\n\t=?utf-8?q?XmbMTn3B/QDoIp1j8BJ3fPni1GAExcLwFsBMFe5cmxKfJAZi0OOx1bZJ?=\n\t=?utf-8?q?LN9xNxNAcOgk2suAiAxHp1d0IxpG5NQH1f6IG4DQ8i+1f2i8ZpwNG4pE?=\n\t=?utf-8?q?ubfVLOdQbRKpvgbxbX6+oOAkk6AqnYze0QQim6DF4t8zF+7IZ6jf2TtJ?=\n\t=?utf-8?q?6QVfz+dW0dnzIQZybxX6Anc/IggKchqGM90C571gMX4DNFV9QsSqydlr?=\n\t=?utf-8?q?cOSs8ssSQdg555MIoAgINA2/kgO0SUevP6fw8FrQfirkHWZcrVF5D1zO?=\n\t=?utf-8?q?z0VaT+j2xJCmzLWdf0x7a9P0lXMu/nS5S9AVr+z8Eb4oz6zmCmdXlNSW?=\n\t=?utf-8?q?MnQy6/88zOxSOB2jqIcz/Yuc07hyo7bOXZ8I3Sc2u8VBUFIeiGGuNBYV?=\n\t=?utf-8?q?F9CQPY9esxcv+0ZV9rnDk8uBXggiiyCcYHfFCxpN2tSeyweNJ7U6ZZPz?=\n\t=?utf-8?q?P8F75c1UM45XLVLEEFSfTG4+CykDdDnhCxlExxrcFFI2QT3yMjBbX+It?=\n\t=?utf-8?q?192jiJQgi7zjfFfDEUiQE3hUlaXTeV0vMSVjkw2SGdhBW1S8dXvqjwB+?=\n\t=?utf-8?q?ZTHoP3j3gdy2OKKDx6PUzMz7j98dGDVj+fqU+yVr2Snss53qp2mjoUqd?=\n\t=?utf-8?q?I98rggyuotWa/yIAYHQlXXJoxqQ1LgkCKOuVDPKWO6+VSvRGMF7j3UEh?=\n\t=?utf-8?q?lnLEDy8ugGISG49SPFveUjXZOnUVlpipLp5HEFGOjXMZFcBD0iHkwxz+?=\n\t=?utf-8?q?ZHAinqp1q/maQULab1TokfpGU5jXqbGbKKKqcK7kqBsM4yjdcP/qUB8A?=\n\t=?utf-8?q?uHAneGkJDmWd0NZrPfRzEJyhkhzOSmRXa7e1VNz+z1/Zbnyiii48hAR1?=\n\t=?utf-8?q?Ygaox9AnXqI0I2JaOdtUGLc0CODEjGgiBaPHTA4LVGdFt0BjCEOC5InA?=\n\t=?utf-8?q?DtzfkSAaESy1kOEKZc9TeNFZoPi4ro5Rjr/BZzT0sZmoQFdbzZL3yrkQ?=\n\t=?utf-8?q?2t1SRWk9SIz7Ymal0XMDvPtjEdLLLMFuxK1pNJe8Qu2c3Az3Km2yU/VN?=\n\t=?utf-8?q?gBGLTFuFBG9xtbOm24FoPwCEq/COxthzf+U77qVaHhVUXJVqQ1r6gMyd?=\n\t=?utf-8?q?XmjindYx4h/H+KuqmXAZdyJVfvBMBVx1vXiBsVJUqK17T+bcWEwWNUzO?=\n\t=?utf-8?q?LFkVMUUJMxg6J1dur+Jc/CG2PM5GHF18CBlo8cUQlKa/VbkLl8aWHY5y?=\n\t=?utf-8?q?TslHwsP24ZOrQhkQ2Y3b+IzFMFVOA=3D=3D?=","X-OriginatorOrg":"nxp.com","X-MS-Exchange-CrossTenant-Network-Message-Id":"82ef4eea-7cb2-4281-d792-08dc3e07d964","X-MS-Exchange-CrossTenant-AuthSource":"AM9PR04MB8147.eurprd04.prod.outlook.com","X-MS-Exchange-CrossTenant-AuthAs":"Internal","X-MS-Exchange-CrossTenant-OriginalArrivalTime":"06 Mar 2024 18:04:21.4035\n\t(UTC)","X-MS-Exchange-CrossTenant-FromEntityHeader":"Hosted","X-MS-Exchange-CrossTenant-Id":"686ea1d3-bc2b-4c6f-a92c-d99c5c301635","X-MS-Exchange-CrossTenant-MailboxType":"HOSTED","X-MS-Exchange-CrossTenant-UserPrincipalName":"GlhhDjJXKFgHtvCHgHJ1LrsiULuT1MUunecfYvKhuPHGO9TWgZFSqwInpw5o67+9E1VTsUaWBAQpEhX4toLe980EoaumS3hE0Q/7KlgnZvc=","X-MS-Exchange-Transport-CrossTenantHeadersStamped":"AM9PR04MB8761","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>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":28894,"web_url":"https://patchwork.libcamera.org/comment/28894/","msgid":"<9889c608-11be-488d-9abf-9ffdbe9161ac@nxp.com>","date":"2024-03-06T18:45:12","subject":"[PATCH v1 1/1] libcamera: camera_manager: Add environment variable\n\tto order pipelines match","submitter":{"id":190,"url":"https://patchwork.libcamera.org/api/people/190/","name":"Julien Vuillaumier","email":"julien.vuillaumier@nxp.com"},"content":"Hi Jacopo,\n\n\nOn 05/03/2024 18:38, Jacopo Mondi wrote:\n> Caution: This is an external email. Please take care when clicking links or opening attachments. When in doubt, report the message using the 'Report this email' button\n> \n> \n> Hi Julien\n> \n> On Mon, Mar 04, 2024 at 07:18:16PM +0100, Julien Vuillaumier wrote:\n>> To match the enumerated media devices, each pipeline handler registered\n>> is used in no specific order. It is a limitation when several pipelines\n>> can match the devices, and user has to select a specific pipeline.\n>>\n>> For this purpose, environment variable LIBCAMERA_PIPELINES_MATCH_LIST is\n>> created that gives the option to define an ordered list of pipelines\n>> to invoke during the match process.\n>>\n>> LIBCAMERA_PIPELINES_MATCH_LIST=\"<name1>[,<name2>[,<name3>...]]]\"\n>>\n>> Example:\n>> LIBCAMERA_PIPELINES_MATCH_LIST=\"PipelineHandlerRkISP1,SimplePipelineHandler\"\n> \n> I think that's a good idea. I expect some bikeshedding on the env\n> variable name :)\n> \n\nNo worries, env variable name can be changed if needed :)\n\n>>\n>> Signed-off-by: Julien Vuillaumier <julien.vuillaumier@nxp.com>\n>> ---\n>>   Documentation/environment_variables.rst |  5 +++\n>>   src/libcamera/camera_manager.cpp        | 51 +++++++++++++++++++++----\n>>   2 files changed, 48 insertions(+), 8 deletions(-)\n>>\n>> diff --git a/Documentation/environment_variables.rst b/Documentation/environment_variables.rst\n>> index a9b230bc..f3a0d431 100644\n>> --- a/Documentation/environment_variables.rst\n>> +++ b/Documentation/environment_variables.rst\n>> @@ -37,6 +37,11 @@ LIBCAMERA_IPA_MODULE_PATH\n>>\n>>      Example value: ``${HOME}/.libcamera/lib:/opt/libcamera/vendor/lib``\n>>\n>> +LIBCAMERA_PIPELINES_MATCH_LIST\n>> +   Define ordered list of pipelines to be used to match the media devices.\n> \n> nit:\n> \n> 'an ordered list of pipeline names'\n> 'the media devices in the system'\n> \n> ?\n\nSure, I will update for the v2 with:\n'Define an ordered list of pipeline names to be used to match the media \ndevices in the system.'\n\n> \n>> +\n>> +   Example value: ``PipelineHandlerRkISP1,SimplePipelineHandler``\n>> +\n>>   LIBCAMERA_RPI_CONFIG_FILE\n>>      Define a custom configuration file to use in the Raspberry Pi pipeline handler.\n>>\n>> diff --git a/src/libcamera/camera_manager.cpp b/src/libcamera/camera_manager.cpp\n>> index 355f3ada..9568801e 100644\n>> --- a/src/libcamera/camera_manager.cpp\n>> +++ b/src/libcamera/camera_manager.cpp\n>> @@ -109,14 +109,7 @@ void CameraManager::Private::createPipelineHandlers()\n>>        const std::vector<PipelineHandlerFactoryBase *> &factories =\n>>                PipelineHandlerFactoryBase::factories();\n>>\n>> -     for (const PipelineHandlerFactoryBase *factory : factories) {\n>> -             LOG(Camera, Debug)\n>> -                     << \"Found registered pipeline handler '\"\n>> -                     << factory->name() << \"'\";\n>> -             /*\n>> -              * Try each pipeline handler until it exhaust\n>> -              * all pipelines it can provide.\n>> -              */\n>> +     auto pipeMatch = [&](const PipelineHandlerFactoryBase *factory) {\n>>                while (1) {\n>>                        std::shared_ptr<PipelineHandler> pipe = factory->create(o);\n>>                        if (!pipe->match(enumerator_.get()))\n>> @@ -126,6 +119,48 @@ void CameraManager::Private::createPipelineHandlers()\n>>                                << \"Pipeline handler \\\"\" << factory->name()\n>>                                << \"\\\" matched\";\n>>                }\n>> +     };\n>> +\n>> +     /*\n>> +      * When a list of preferred pipelines is defined, iterate through the\n>> +      * ordered list to match the devices enumerated.\n>> +      * Otherwise, devices matching is done in no specific order with each\n>> +      * pipeline handler registered.\n> \n> nit: 'registered pipeline handler'\n> \n\nI will update the comment in v2\n\n>> +      */\n>> +     const char *pipesLists =\n> \n> nit: pipesList >\n\nI will update the variable name in v2\n\n\n>> +             utils::secure_getenv(\"LIBCAMERA_PIPELINES_MATCH_LIST\");\n>> +     if (pipesLists) {\n>> +             for (const auto &pipeName : utils::split(pipesLists, \",\")) {\n>> +                     if (pipeName.empty())\n>> +                             continue;\n> \n> Not sure if this can be empty, but better safe than sorry\n> \n\nAgreed, not sure empty() test is strictly necessary. Intent was \npresumably to catch early (odd) definitions like:\nvar='pipe1,,pipe2'\nBut things should work without. I will double check and remove in v2 if \nnot needed.\n\n>> +\n>> +                     auto nameMatch = [pipeName](const PipelineHandlerFactoryBase *f) {\n>> +                             return (f->name() == pipeName);\n> \n> no need for ()\n> \n\nI will remove the extra () in v2\n\n>> +                     };\n>> +\n>> +                     auto iter = std::find_if(factories.begin(),\n>> +                                              factories.end(),\n>> +                                              nameMatch);\n> \n> You could also inline the above here\n> \n>                          auto iter = std::find_if(factories.begin(),\n>                                                   factories.end(),\n>                                                   [&pipeName](const PipelineHandlerFactoryBase *f)\n>                                                   {\n>                                                          return f->name() == pipeName;\n>                                                   });\n> \n> Up to you\n> \n\nThat was an attempt to adhere to coding style and stay within the 80 \ncolumns - but the lambda declaration failed to do so anyway...\nThank you for the suggestion - I will see how that fits after moving \nthis block to a getting by name method of the PipelineHandlerFactory, as \nKieran suggested.\n\n>> +\n>> +                     if (iter != factories.end()) {\n>> +                             LOG(Camera, Debug)\n>> +                                     << \"Found pipeline handler from list '\"\n>> +                                     << (*iter)->name() << \"'\";\n>> +                             pipeMatch(*iter);\n>> +                     }\n>> +             }\n>> +             return;\n>> +     }\n>> +\n>> +     for (const PipelineHandlerFactoryBase *factory : factories) {\n>> +             LOG(Camera, Debug)\n>> +                     << \"Found registered pipeline handler '\"\n>> +                     << factory->name() << \"'\";\n> \n> If order was not relevant, you could have simply searched\n> factory->name() in pipesLists here, but I presume the order in which\n> pipelines are specified in the env variable and matched is relevant,\n> right ?\n> \n\nThe order of the pipelines listed in the env variable is relevant as it \ndefines their respective priorities for the match.\nFor that reason, if a list exists, the preceding 'for' block iterates in \norder through every pipeline name and attempts match with relevant pipeline.\n\nThat second 'for' block is the default case when there is no list \ndefined. It corresponds to the current implementation where match is \nattempted with every pipeline registered in PipelineHandlerFactoryBase, \nbut without specific order.\n\n>> +             /*\n>> +              * Try each pipeline handler until it exhausts\n>> +              * all pipelines it can provide.\n>> +              */\n>> +             pipeMatch(factory);\n>>        }\n>>   }\n>>\n>> --\n>> 2.34.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 EA3FEC0F2A\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  6 Mar 2024 18:45:10 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id CEEC86286F;\n\tWed,  6 Mar 2024 19:45:09 +0100 (CET)","from EUR05-DB8-obe.outbound.protection.outlook.com\n\t(mail-db8eur05on20607.outbound.protection.outlook.com\n\t[IPv6:2a01:111:f400:7e1a::607])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id EA3A961C8F\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  6 Mar 2024 19:45:08 +0100 (CET)","from AM9PR04MB8147.eurprd04.prod.outlook.com\n\t(2603:10a6:20b:3e0::22)\n\tby VI1PR04MB6912.eurprd04.prod.outlook.com (2603:10a6:803:134::12)\n\twith Microsoft SMTP Server (version=TLS1_2,\n\tcipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7362.24;\n\tWed, 6 Mar 2024 18:45:07 +0000","from AM9PR04MB8147.eurprd04.prod.outlook.com\n\t([fe80::3fdf:4cf8:d542:1b49]) by\n\tAM9PR04MB8147.eurprd04.prod.outlook.com\n\t([fe80::3fdf:4cf8:d542:1b49%4]) with mapi id 15.20.7362.019;\n\tWed, 6 Mar 2024 18:45:07 +0000"],"Authentication-Results":["lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=nxp.com header.i=@nxp.com header.b=\"D8FXHeXn\";\n\tdkim-atps=neutral","dkim=none (message not signed)\n\theader.d=none;dmarc=none action=none header.from=nxp.com;"],"ARC-Seal":"i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none;\n\tb=DgQhb9Ry5ii7MhmypHA7Pdi7axmxdiHooW+X55nL0hkD0Pjk4xG1LL41o8pkFXR/K9OBY42px3qGNMVzSyNPhQohSfoAzdgYsXIpa6nYHxcH8fffdTNMvpOXBJeSSWmnWOz5FXdKgsFNFIIHZ+V+oes+OvCkhWzu9k/a9ee/rq9bxG0cTY8np+fj/RHGbTe8gtRpoQ5vvqisAafmHlBb2xC49Urv6kU9STm0z+0wkDX8NLb2o54DWreXqnAPHNf+iF+jYbuuJL8eHNq+BW6KA9qlJ1k7jvY6okgk7ZQvFm8NXyFnJ+CuVffu5J1KU8U/oy4zW6CoLhfY08DLqUlB1w==","ARC-Message-Signature":"i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com;\n\ts=arcselector9901;\n\th=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1;\n\tbh=oQ8Fur1Y+Dn9leRAwhqnqqYIhVKj0QOzN0R6K2K5xyQ=;\n\tb=FIRenPW9H2V3ERJUJzQWSJUZeNTVYue3JU+v6WPrwtahl+6xw7T1RmGAGXVyWpk9XPekiDkafDibD++aaPhI6448Bo5pTJ/8pjcP19HtirF7wQ0EMg6J3gw6vsusVy9sV01TAWNzkz5qJM+oNzy7ydPfNG+QmcIGmPaITQUNRnzFLK6UglBfXAs89R0iGTIZdNy0fdeH4leE2h0gOinPAtfKND7YyMTPmVRP7uB5zoQkegAgZk0V13SrW9SbmLMa5iHRgXDJan2dd81DN6QbftnRM4C3Pa/Zkuvh8CXQzg2m9tIUoCOPj/lVJbwyIEqhf6FwOm8O0hm148uQ0B+0uA==","ARC-Authentication-Results":"i=1; mx.microsoft.com 1; spf=pass\n\tsmtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com;\n\tdkim=pass header.d=nxp.com; arc=none","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2;\n\th=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck;\n\tbh=oQ8Fur1Y+Dn9leRAwhqnqqYIhVKj0QOzN0R6K2K5xyQ=;\n\tb=D8FXHeXnyP08mqfWm1AnQalCgAfEzhAmG/5KRPLxJVKwDoLaU+nOaFwT8XoZ3ClIYOpy14oZX6Q4T0+pwGuJNBcE3rX2gqFrhARpEq+zqhDvDrxx+RkNjHG3uEdOFZCp33nBeqUT98cWNArau4M9Iy+Yg7pxZ6wY00u6ANP+oW4=","Message-ID":"<9889c608-11be-488d-9abf-9ffdbe9161ac@nxp.com>","Date":"Wed, 6 Mar 2024 19:45:12 +0100","User-Agent":"Mozilla Thunderbird","Subject":"[PATCH v1 1/1] libcamera: camera_manager: Add environment variable\n\tto order pipelines match","Content-Language":"en-US","To":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>","References":"<20240304181816.2361334-1-julien.vuillaumier@nxp.com>\n\t<20240304181816.2361334-2-julien.vuillaumier@nxp.com>\n\t<4vhi4vseqwbpylxmv5quoe7mucvis7cj6drrsuopg3ksvzz24b@namxemz3bsfv>","From":"Julien Vuillaumier <julien.vuillaumier@nxp.com>","In-Reply-To":"<4vhi4vseqwbpylxmv5quoe7mucvis7cj6drrsuopg3ksvzz24b@namxemz3bsfv>","Content-Type":"text/plain; charset=UTF-8; format=flowed","Content-Transfer-Encoding":"7bit","X-ClientProxiedBy":"AM0PR04CA0049.eurprd04.prod.outlook.com\n\t(2603:10a6:208:1::26) To AM9PR04MB8147.eurprd04.prod.outlook.com\n\t(2603:10a6:20b:3e0::22)","MIME-Version":"1.0","X-MS-PublicTrafficType":"Email","X-MS-TrafficTypeDiagnostic":"AM9PR04MB8147:EE_|VI1PR04MB6912:EE_","X-MS-Office365-Filtering-Correlation-Id":"43f7c6ca-8218-4e31-7c08-08dc3e0d8b2b","X-MS-Exchange-SenderADCheck":"1","X-MS-Exchange-AntiSpam-Relay":"0","X-Microsoft-Antispam":"BCL:0;","X-Microsoft-Antispam-Message-Info":"RcnU+0YmDdAAJwQJeRmXnJeuuYclMiAhxmAgEKdZtoDK8zvI1zk38PVBWBHuHmH46QKjuvG4Ls5yRrf221R8VX8+DQ/qrT263XHmX6wFRzSXXERLjTUYgHIfeOsuM3QHiBQ+d5X12MStXT+lmDuCA6IgBh30egnOqJqF2jfbFuet3tKf2evSw76QGc0CsXtsiqjRdN2lvNQW9Wixa4HuEme0RBx/PNCC3NfG3U1aUdgJvusBzWEqz4Mzrsz80olz1lgLdHdX3zPr4e85z9SdjXarDwTduww8y2kQWjCy+nRkPzgQoGQd32VO/8KN8RoW6gXxYnR04AfecpuCmaMZq1EA5VDtAQodGLHPZPFtadBfxdvIm2/g7EB1qcbnp7nBkljYe1s3ceNT9wog6sXF/5DEoEGJ8TWAqfKWpG1tMoJFb4agTszk91tVvGNP9Vv5+A8nKpHMVJ+awwwlzaut3B9f+fw2SyiL7wrNymW1zXvStwnO/8qgGh3CVIwBKkpJmQtljg1DwmcdBAhM1KdGNyJz+Yr6Gs6adewD15QMOE9i3M8SxxpawK7F9G2v4z56VTz5iUDyZmF7K52NlXQQyKir4WFMKIsonBBrAU8cTxxkJ5X0u2Mp4sMq+bVGDXXUN0QFEZBPIWfAQi9MY1YykQw1vl4RpvA8RoD2/33IaOE=","X-Forefront-Antispam-Report":"CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:;\n\tIPV:NLI; SFV:NSPM; H:AM9PR04MB8147.eurprd04.prod.outlook.com; PTR:;\n\tCAT:NONE; \n\tSFS:(13230031)(376005); DIR:OUT; SFP:1101; ","X-MS-Exchange-AntiSpam-MessageData-ChunkCount":"1","X-MS-Exchange-AntiSpam-MessageData-0":"=?utf-8?q?ziKx/jdjYfizv0/gx9b4g/s7Z?=\n\t=?utf-8?q?dt19MeeJBw1cBxg4V7TrJSLFHqk9usftcNzK1qW5GvNVfoG+0Nvp14iL?=\n\t=?utf-8?q?PVaLEyuROzVDsCHJGocbrrPgugqoXO4Wl2hU95c7V6BhX22p6pj37gxZ?=\n\t=?utf-8?q?HwzCnEpWfTzsjBP0rQH9wCbgUK1bsQVVU7HQK5dGiv/pypqoVOI5jRhE?=\n\t=?utf-8?q?0oThNG/1fmJfja4qaBpkvA9mfuT9m24jIcBi5/j42xvBYdryjMUmfkok?=\n\t=?utf-8?q?KqOgNSAg7IE8gP4erWbAuQl/qRN9imEuEbPyILLDc8iL2+lYw3Lk2pnh?=\n\t=?utf-8?q?xOWbeZ3U1BU0Vhsz54dkouhE5TDJ/NfY5149x2VT2DUpKCnjJzXV/l4n?=\n\t=?utf-8?q?B+dI8U2hccbL+QJ/EoZZDdQCXzJv5wzRZJGwRj5GTYuOR6Hvdky1krKE?=\n\t=?utf-8?q?0X5iBR1iJeDTgXCKcwFYnixOJ6h2cO9Mq9+9EPJGKp1RQXEsQcqzLooY?=\n\t=?utf-8?q?wqQ5Mc9nMPvNGq/pFkmlVpFWBZ2C46S21CQIb663FHJPrygBdOdys0/1?=\n\t=?utf-8?q?97sgsxt4LGbmg+W9M0SwXs47C7YSZl7aVL9v5gbVyoWqT6v+OMC2GjXB?=\n\t=?utf-8?q?IydrLQ1BWUFo+en+z+Wn3VRk6v1K99S2mGGiliie6MBPMdKm8g7+vT5r?=\n\t=?utf-8?q?Mns9Z0FWZ5ZmvPK2Z7gy5+jFEJfrlhc1g4bJKw1pWUk3PSMNDsqXrLR1?=\n\t=?utf-8?q?bVo7qhITyYL7mYPTrOHdd3z8p1bKDRdgaEHJC6cr90gukgZ41yuM6XzC?=\n\t=?utf-8?q?ld6/1kWul9wtLipVhXhmOPVSI5IlFn8a5+7kE4v/gKQ+cX5mmAHLBJ8X?=\n\t=?utf-8?q?cKA7dWb3VYa10lDti4XZnQJudszbEq2PYjdrbD3PPX+Hj1Y+dAjhhSwe?=\n\t=?utf-8?q?FK1wr8pwrBdmUFtiyY0CisH7hXuydKjaLaYKlkrUJfVzU6PS5+lz6FVa?=\n\t=?utf-8?q?L6+ZNyMaKOb5bUOVLVAf5hW/Rinn9ceGArIKUrqrvn+5yf0i8gW6YNQ9?=\n\t=?utf-8?q?a0WY3H4LbcSU1kuUw32I6+THkgtFC0vSqG9AoG+Hx+pSbwPdAqKdVYwx?=\n\t=?utf-8?q?7Qf7qEfZ03OpPdg/M4nXGyyJdQoYtn/q9nP6lUee3DWVkgCjaaYGU2eP?=\n\t=?utf-8?q?p6VThKC+EQzZ+72e9RrTo9qnLbgOBLiKUny/EytxVQFT1uNcvAQ+vJUF?=\n\t=?utf-8?q?5y+HtxI8zAQdKdYVHq3gVqYdOwRmSSAm35eawnRKzQ8rz2ftBhn5gIp2?=\n\t=?utf-8?q?nxKv625eAy6mF/ZDkn1/+jgx+JcKEyEki80DDUc7hyBeRWx2gmEqdxXS?=\n\t=?utf-8?q?V3uWJ9t8QMU5QEJQDhqolASG0GY6XTQJq/0QFNpOZv4lM7vvhovRcejF?=\n\t=?utf-8?q?/PW8Dl4H/BIHgq0f8QWxcvsAx/8Y/I/U081lT2K5RLMXfmcUhu9gOfWl?=\n\t=?utf-8?q?9wZfXCtSA2OMrOy6b13CEeVIbiJzS8xnrcHsI3OWFPrBEFFefypNTg19?=\n\t=?utf-8?q?HZUmlV8mEOxV7FtpmC7TxUDqGsI4Be1H3Ax8spdH9PtLH1aJErmIEfwB?=\n\t=?utf-8?q?R4w62nircyd9fvLsFR7KIHknyW8GCdE5gfbBVBbFqBvEjYMIhBz89g6Z?=\n\t=?utf-8?q?Etvgb3GE7NDIQMn5hDQGLNL4OjbwEfE+rdLCg2RyIfgEP7IMELGu9waD?=\n\t=?utf-8?q?qEmZRyp6UjbhkW546ox2yxKwpjFIQ=3D=3D?=","X-OriginatorOrg":"nxp.com","X-MS-Exchange-CrossTenant-Network-Message-Id":"43f7c6ca-8218-4e31-7c08-08dc3e0d8b2b","X-MS-Exchange-CrossTenant-AuthSource":"AM9PR04MB8147.eurprd04.prod.outlook.com","X-MS-Exchange-CrossTenant-AuthAs":"Internal","X-MS-Exchange-CrossTenant-OriginalArrivalTime":"06 Mar 2024 18:45:07.2141\n\t(UTC)","X-MS-Exchange-CrossTenant-FromEntityHeader":"Hosted","X-MS-Exchange-CrossTenant-Id":"686ea1d3-bc2b-4c6f-a92c-d99c5c301635","X-MS-Exchange-CrossTenant-MailboxType":"HOSTED","X-MS-Exchange-CrossTenant-UserPrincipalName":"sPVKzj7M8NXcf+BiGeRrt4HARxsc4AWGyxbH+a6HLJpMNDnTFS0KrWME+lerMivrsec3fr8O6ffjH6mQeHaAHRv+h9W2Xbin6/c6zV0sIjc=","X-MS-Exchange-Transport-CrossTenantHeadersStamped":"VI1PR04MB6912","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>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":28895,"web_url":"https://patchwork.libcamera.org/comment/28895/","msgid":"<170980498893.252503.3642068520929429163@ping.linuxembedded.co.uk>","date":"2024-03-07T09:49:48","subject":"Re: [EXT] Re: [PATCH v1 1/1] libcamera: camera_manager: Add\n\tenvironment variable to order pipelines match","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Julien Vuillaumier (2024-03-06 17:57:58)\n> Hi Kieran,\n> \n> On 05/03/2024 07:54, Kieran Bingham wrote:\n> > Caution: This is an external email. Please take care when clicking links or opening attachments. When in doubt, report the message using the 'Report this email' button\n> > \n> > \n> > Quoting Julien Vuillaumier (2024-03-04 18:18:16)\n> >> To match the enumerated media devices, each pipeline handler registered\n> >> is used in no specific order. It is a limitation when several pipelines\n> >> can match the devices, and user has to select a specific pipeline.\n> >>\n> >> For this purpose, environment variable LIBCAMERA_PIPELINES_MATCH_LIST is\n> >> created that gives the option to define an ordered list of pipelines\n> >> to invoke during the match process.\n> >>\n> >> LIBCAMERA_PIPELINES_MATCH_LIST=\"<name1>[,<name2>[,<name3>...]]]\"\n> >>\n> >> Example:\n> >> LIBCAMERA_PIPELINES_MATCH_LIST=\"PipelineHandlerRkISP1,SimplePipelineHandler\"\n> >>\n> >> Signed-off-by: Julien Vuillaumier <julien.vuillaumier@nxp.com>\n> >> ---\n> >>   Documentation/environment_variables.rst |  5 +++\n> >>   src/libcamera/camera_manager.cpp        | 51 +++++++++++++++++++++----\n> >>   2 files changed, 48 insertions(+), 8 deletions(-)\n> >>\n> >> diff --git a/Documentation/environment_variables.rst b/Documentation/environment_variables.rst\n> >> index a9b230bc..f3a0d431 100644\n> >> --- a/Documentation/environment_variables.rst\n> >> +++ b/Documentation/environment_variables.rst\n> >> @@ -37,6 +37,11 @@ LIBCAMERA_IPA_MODULE_PATH\n> >>\n> >>      Example value: ``${HOME}/.libcamera/lib:/opt/libcamera/vendor/lib``\n> >>\n> >> +LIBCAMERA_PIPELINES_MATCH_LIST\n> >> +   Define ordered list of pipelines to be used to match the media devices.\n> >> +\n> >> +   Example value: ``PipelineHandlerRkISP1,SimplePipelineHandler``\n> >> +\n> >>   LIBCAMERA_RPI_CONFIG_FILE\n> >>      Define a custom configuration file to use in the Raspberry Pi pipeline handler.\n> >>\n> >> diff --git a/src/libcamera/camera_manager.cpp b/src/libcamera/camera_manager.cpp\n> >> index 355f3ada..9568801e 100644\n> >> --- a/src/libcamera/camera_manager.cpp\n> >> +++ b/src/libcamera/camera_manager.cpp\n> >> @@ -109,14 +109,7 @@ void CameraManager::Private::createPipelineHandlers()\n> >>          const std::vector<PipelineHandlerFactoryBase *> &factories =\n> >>                  PipelineHandlerFactoryBase::factories();\n> >>\n> >> -       for (const PipelineHandlerFactoryBase *factory : factories) {\n> >> -               LOG(Camera, Debug)\n> >> -                       << \"Found registered pipeline handler '\"\n> >> -                       << factory->name() << \"'\";\n> >> -               /*\n> >> -                * Try each pipeline handler until it exhaust\n> >> -                * all pipelines it can provide.\n> >> -                */\n> >> +       auto pipeMatch = [&](const PipelineHandlerFactoryBase *factory) {\n> > \n> > Does this need to be a lambda? is there a specific benefit, or can it be\n> > a function? I find lambda's hard to parse :-( but perhaps that's just\n> > me, so lets see what others say.\n> \n> This lambda can be moved to a function, but this function would probably \n> never be used from anywhere else - for that reason it was made local as \n> a lambda. But if consensus is to limit usage of lambda, a function can \n> be used instead.\n\nIndeed, that makes sense. We've often used private class functions where\nneeded though. I don't think what you've done is wrong, just not what\nI'm used to ;-) so I don't specifically mind if it stays, but just to\nease readibility a block comment above the lambda might help.\n\n--\nKieran\n\n> \n> > \n> >>                  while (1) {\n> >>                          std::shared_ptr<PipelineHandler> pipe = factory->create(o);\n> >>                          if (!pipe->match(enumerator_.get()))\n> >> @@ -126,6 +119,48 @@ void CameraManager::Private::createPipelineHandlers()\n> >>                                  << \"Pipeline handler \\\"\" << factory->name()\n> >>                                  << \"\\\" matched\";\n> >>                  }\n> >> +       };\n> >> +\n> >> +       /*\n> >> +        * When a list of preferred pipelines is defined, iterate through the\n> >> +        * ordered list to match the devices enumerated.\n> >> +        * Otherwise, devices matching is done in no specific order with each\n> > \n> > s/devices/device/\n> > \n> \n> I will update in v2 - thanks.\n> \n> >> +        * pipeline handler registered.\n> >> +        */\n> >> +       const char *pipesLists =\n> >> +               utils::secure_getenv(\"LIBCAMERA_PIPELINES_MATCH_LIST\");\n> >> +       if (pipesLists) {\n> >> +               for (const auto &pipeName : utils::split(pipesLists, \",\")) {\n> >> +                       if (pipeName.empty())\n> >> +                               continue;\n> >> +\n> >> +                       auto nameMatch = [pipeName](const PipelineHandlerFactoryBase *f) {\n> >> +                               return (f->name() == pipeName);\n> >> +                       };\n> >> +\n> >> +                       auto iter = std::find_if(factories.begin(),\n> >> +                                                factories.end(),\n> >> +                                                nameMatch);\n> > \n> > If we do this - I'd probably add support to the PipelineHandlerFactory\n> > to support getting by name as a preceeding patch.\n> > \n> \n> Sure, I can do - will update in v2.\n> \n> >> +\n> >> +                       if (iter != factories.end()) {\n> >> +                               LOG(Camera, Debug)\n> >> +                                       << \"Found pipeline handler from list '\"\n> >> +                                       << (*iter)->name() << \"'\";\n> >> +                               pipeMatch(*iter);\n> >> +                       }\n> >> +               }\n> >> +               return;\n> >> +       }\n> >> +\n> >> +       for (const PipelineHandlerFactoryBase *factory : factories) {\n> >> +               LOG(Camera, Debug)\n> >> +                       << \"Found registered pipeline handler '\"\n> >> +                       << factory->name() << \"'\";\n> >> +               /*\n> >> +                * Try each pipeline handler until it exhausts\n> >> +                * all pipelines it can provide.\n> >> +                */\n> >> +               pipeMatch(factory);\n> >>          }\n> >>   }\n> >>\n> >> --\n> >> 2.34.1\n> >>\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 A187EBD160\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu,  7 Mar 2024 09:49:54 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id C821E6286F;\n\tThu,  7 Mar 2024 10:49:53 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id E618D61C87\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu,  7 Mar 2024 10:49:51 +0100 (CET)","from pendragon.ideasonboard.com\n\t(aztw-30-b2-v4wan-166917-cust845.vm26.cable.virginm.net\n\t[82.37.23.78])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 8CA5482A;\n\tThu,  7 Mar 2024 10:49:33 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"mg0n0x1r\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1709804973;\n\tbh=bA2qTeyU6VLYumVIEXf+EfK8YLam6rGyGTTk8tNq6Hk=;\n\th=In-Reply-To:References:Subject:From:To:Date:From;\n\tb=mg0n0x1rYGQ/B9JLwmaVPX75r5JYiZdQrxjVT3JroW6LcF2LTuUj/w3/lLvr/5ZmO\n\tEo5F4Euu02YuYfHiUM0TTTjoanVb8hJ80cDM+3tIGWNN43eng6yFT0zoN5I/UOqgVj\n\t3xyS1ZzzKAKamUpNG1wlcqokyEY3z2hNjmayls8o=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<3131d544-ecf1-4e1b-a902-11015a4c6e16@nxp.com>","References":"<20240304181816.2361334-1-julien.vuillaumier@nxp.com>\n\t<20240304181816.2361334-2-julien.vuillaumier@nxp.com>\n\t<170962164952.566498.15718576350844938762@ping.linuxembedded.co.uk>\n\t<3131d544-ecf1-4e1b-a902-11015a4c6e16@nxp.com>","Subject":"Re: [EXT] Re: [PATCH v1 1/1] libcamera: camera_manager: Add\n\tenvironment variable to order pipelines match","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","To":"Julien Vuillaumier <julien.vuillaumier@nxp.com>,\n\tlibcamera-devel@lists.libcamera.org","Date":"Thu, 07 Mar 2024 09:49:48 +0000","Message-ID":"<170980498893.252503.3642068520929429163@ping.linuxembedded.co.uk>","User-Agent":"alot/0.10","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>"}}]