Show a patch.

GET /api/1.1/patches/19819/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 19819,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/19819/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/19819/",
    "project": {
        "id": 1,
        "url": "https://patchwork.libcamera.org/api/1.1/projects/1/?format=api",
        "name": "libcamera",
        "link_name": "libcamera",
        "list_id": "libcamera_core",
        "list_email": "libcamera-devel@lists.libcamera.org",
        "web_url": "",
        "scm_url": "",
        "webscm_url": ""
    },
    "msgid": "<20240327172731.434048-3-julien.vuillaumier@nxp.com>",
    "date": "2024-03-27T17:27:31",
    "name": "[v3,2/2] libcamera: camera_manager: Add environment variable to order pipelines match",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "51fd3aac3160241ba5ba2c8f19f897524cec2b38",
    "submitter": {
        "id": 190,
        "url": "https://patchwork.libcamera.org/api/1.1/people/190/?format=api",
        "name": "Julien Vuillaumier",
        "email": "julien.vuillaumier@nxp.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/19819/mbox/",
    "series": [
        {
            "id": 4245,
            "url": "https://patchwork.libcamera.org/api/1.1/series/4245/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=4245",
            "date": "2024-03-27T17:27:29",
            "name": "Add environment variable to order pipelines match",
            "version": 3,
            "mbox": "https://patchwork.libcamera.org/series/4245/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/19819/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/19819/checks/",
    "tags": {},
    "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 6709BBD160\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 27 Mar 2024 17:28:12 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 212B763354;\n\tWed, 27 Mar 2024 18:28:12 +0100 (CET)",
            "from EUR04-HE1-obe.outbound.protection.outlook.com\n\t(mail-he1eur04on20601.outbound.protection.outlook.com\n\t[IPv6:2a01:111:f403:260f::601])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id A4D7363331\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 27 Mar 2024 18:28:10 +0100 (CET)",
            "from AM9PR04MB8147.eurprd04.prod.outlook.com\n\t(2603:10a6:20b:3e0::22)\n\tby AM0PR04MB6913.eurprd04.prod.outlook.com (2603:10a6:208:184::24)\n\twith Microsoft SMTP Server (version=TLS1_2,\n\tcipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.31;\n\tWed, 27 Mar 2024 17:28:09 +0000",
            "from AM9PR04MB8147.eurprd04.prod.outlook.com\n\t([fe80::2208:ff47:a8fe:dea6]) by\n\tAM9PR04MB8147.eurprd04.prod.outlook.com\n\t([fe80::2208:ff47:a8fe:dea6%5]) with mapi id 15.20.7409.031;\n\tWed, 27 Mar 2024 17:28:09 +0000"
        ],
        "Authentication-Results": [
            "lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=nxp.com header.i=@nxp.com header.b=\"RK/wXtKH\";\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=Lp2b0Y5DFXfLJItYeUTMPmPcgEEgQnxISNGt99fgPpNa00qzoKFCXVz7MnROOn0oreuRHTbK6iil3XJE44IV9mebG4VeJbtYGMARWT4BIWVgJ0S1gai4j0soexqGGwJrTnv0u+sQgYWvO2UTKfXcOACJ7zZFVhvRGzaznxucx+Fxv0lxbbrC5RO1ITKodpTBxndI8yfopNDQsKfBJtW+QS0saXO4XR/BSiohATUSfA8zmP9FlXD7VFRMw0PexNL1IYpNdk3vVy558KuRAxfTMoZCfAWBIGF8qijSzv/xmej1yQh5PL35xTHHQLTB9T+GYgCD4PzB3dmOJNZTJg3PzA==",
        "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=tJ1iULtkpwCOr84ZAiqsCOjAYc3Zi89uB0Fgsk89Suo=;\n\tb=UYlL6+83xkKazm32iVxoPAhImOj5DBDULBKPa5L9iUUe950gH8mDj0I1w/TpJup4i25DLOddgLSlGRq2YoAlT56FX7Gr7O8/l16+8VkkUCpQKMjEkKaBvVHJruhb5SqWzlvDcshYMpm7g9zqnMxysAj7fMRX7L4I/iCGXQ4hx+yoLgsoT/DcgVYswiskPpdpzgZU1T9R3/BNeCTkRtdgRo9LF/IiZEWExiXVnQ/9TztuNKkLRGTEz7MIRjDOio5vY9dnw+aqf6w7A+O0ssGzsLUNaFpFbUqVSL+4Z4bD7TxB1DED8RySt/h/7N2GqD3JeNUk5CHTwLe9hueWS8Q2Ww==",
        "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=tJ1iULtkpwCOr84ZAiqsCOjAYc3Zi89uB0Fgsk89Suo=;\n\tb=RK/wXtKHygRRGjrQczjQKr5+cXU/VW/P/H6X81tiPEjmwqNbC3icN15I0s0glWJhDSumpILC4uMKdQrxIh1fUECAarZYV/Xzfb3JR3vC1r9H85UwWtL5WB+eLmDyY90rIiIt6w/8ELcApUEOYtmJXvsgND7CmUAKNO30smzAVbk=",
        "From": "Julien Vuillaumier <julien.vuillaumier@nxp.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Cc": "julien.vuillaumier@nxp.com, Jacopo Mondi <jacopo.mondi@ideasonboard.com>",
        "Subject": "[PATCH v3 2/2] libcamera: camera_manager: Add environment variable\n\tto order pipelines match",
        "Date": "Wed, 27 Mar 2024 18:27:31 +0100",
        "Message-Id": "<20240327172731.434048-3-julien.vuillaumier@nxp.com>",
        "X-Mailer": "git-send-email 2.34.1",
        "In-Reply-To": "<20240327172731.434048-1-julien.vuillaumier@nxp.com>",
        "References": "<20240327172731.434048-1-julien.vuillaumier@nxp.com>",
        "Content-Transfer-Encoding": "8bit",
        "Content-Type": "text/plain",
        "X-ClientProxiedBy": "AM0PR02CA0167.eurprd02.prod.outlook.com\n\t(2603:10a6:20b:28d::34) 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_|AM0PR04MB6913:EE_",
        "X-MS-Office365-Filtering-Correlation-Id": "a7f7e37d-fe93-4e46-8878-08dc4e83455e",
        "X-MS-Exchange-SenderADCheck": "1",
        "X-MS-Exchange-AntiSpam-Relay": "0",
        "X-Microsoft-Antispam": "BCL:0;",
        "X-Microsoft-Antispam-Message-Info": "42endNeR+oANSGfrSZdxk01EsPsOGBErKY0sH+B+wKBFaIXbAj1Vcn8FBxN/SoNCgeeJ8ecm5ZSaJZB+BizWT/o76roTxreUQaidKS0qQvuMdmcNPYfu/5R4nECReqR23cO6y5944VloYbl/7G7j762VR8bG0RDdYoHx3LI5Ep5i/XT0UVDAcqubPXGwld8vI+pYYIpS2KmuKkR5T64C6kp4HeaCeLNZwxkEVAMJQS+EUkkj7a6a0swdI+bZRHRkC8G8v9nYl0gt+/Kym7kec5Y21ErK6vwwQeT/bx08f1V6pw5TicVO4CUd7mKttj8ifgUoBqXiNJ0hTQbpzj2eOvmdE2gG9A4w9gnumyKdTce5IeOu4cWTXlfdQzfrpFcP7ylrA83jG5qfAQh5cX62J8XR7KoNnvISl/FY60ohXtw7yUfH2iN/3RFORRTVBVfKTfFIEZA4ZTa76hn7OIqz4N0FraYRRRBw9oFIzSCdRmd71Qx3Og7QU1+ICRGH7Oc/DffQJ1WQBr5aNcns9tWdYruaBjAtuTqUOrbHCdNp5G5wKBEgKemy+l6X9atk3pqdry59ag4otuNDTudssIO9jE0aQZvy7h9qfo47867JNCU5b/FbRHkAXFRK5H6fVBMg1BMcWxVQFuQ665c3BHQ1tcPG8vsNxwpyvp4JGgiku1PvjbGVuqQNVGN7OqfyzpXKOZIUnniRHuKRUlJEcuAHzg==",
        "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)(366007)(1800799015)(52116005)(38350700005);\n\tDIR:OUT; SFP:1101; ",
        "X-MS-Exchange-AntiSpam-MessageData-ChunkCount": "1",
        "X-MS-Exchange-AntiSpam-MessageData-0": "AjQffDnFFQiDP41Aps9D+1TLbhWDhK/n1wYDO0Hv9+52LTaW/J08JWC+4xJiv/osT9HtU+x69uCyY8W8SLFsRL4Igb315hpjBsw+JdfeM7mACbAzj9eUKAlNINh35JV7EILL2rfg8/VGixjtxuEmtncmVpyGXrOOBFuO0aiR5ibcgYc+aVWq/zXOsEIr1XMn6AQoEPUQUS3f3gCD9UcB7kiiZBva+vPrHX858AhLKWCv9hXb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AYt5BfAEEQnwdIcAoz1evpYxzBUndN+8Epd4aRj6wRL3tg7IuIWrEBroEbmIn//brKuOx5UenLXe2vYl1RFRHg+YW79JpS3JjbNErwQEoalcB/noMpS7wTe6wMuED6sd24pToMr9m4i54a0hErsSLNt8RizRdcfFTy+ccrBRlYVQkfHfyJ74pIXZoiPUitTL9J17K4r2QvHYTIAeQGUaK3/B4uNJMm1adG1aRD0ZWDAXcojzAgJbqlEyL5NiWrQBGfXNRQMWR2TLlbaEjuCSYaThICsp9i/4ILj4nXgk9Ws0y1Q==",
        "X-OriginatorOrg": "nxp.com",
        "X-MS-Exchange-CrossTenant-Network-Message-Id": "a7f7e37d-fe93-4e46-8878-08dc4e83455e",
        "X-MS-Exchange-CrossTenant-AuthSource": "AM9PR04MB8147.eurprd04.prod.outlook.com",
        "X-MS-Exchange-CrossTenant-AuthAs": "Internal",
        "X-MS-Exchange-CrossTenant-OriginalArrivalTime": "27 Mar 2024 17:28:09.3275\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": "fG8krlYjefnjCM7OUbdutz+d4TuI/bJ2JjKqEjNz/6WJKU2RAr8LxeILQ/5vD5z/Brh13TblBuISvA+7JsgGA+25GQ/KACH5GkH9NhiHagc=",
        "X-MS-Exchange-Transport-CrossTenantHeadersStamped": "AM0PR04MB6913",
        "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>"
    },
    "content": "To match the enumerated media devices, each registered pipeline handler\nis used in no specific order. It is a limitation when several pipelines\ncan match the devices, and user has to select a specific pipeline.\n\nFor this purpose, environment variable LIBCAMERA_PIPELINES_MATCH_LIST is\ncreated to give the option to define an ordered list of pipelines to\nmatch on.\n\nLIBCAMERA_PIPELINES_MATCH_LIST=\"<name1>[,<name2>[,<name3>...]]]\"\n\nExample:\nLIBCAMERA_PIPELINES_MATCH_LIST=\"PipelineHandlerRkISP1,SimplePipelineHandler\"\n\nSigned-off-by: Julien Vuillaumier <julien.vuillaumier@nxp.com>\nReviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\n---\n Documentation/environment_variables.rst     |  8 ++++\n include/libcamera/internal/camera_manager.h |  1 +\n src/libcamera/camera_manager.cpp            | 53 ++++++++++++++++-----\n 3 files changed, 50 insertions(+), 12 deletions(-)",
    "diff": "diff --git a/Documentation/environment_variables.rst b/Documentation/environment_variables.rst\nindex a9b230bc..c763435c 100644\n--- a/Documentation/environment_variables.rst\n+++ b/Documentation/environment_variables.rst\n@@ -37,6 +37,14 @@ LIBCAMERA_IPA_MODULE_PATH\n \n    Example value: ``${HOME}/.libcamera/lib:/opt/libcamera/vendor/lib``\n \n+LIBCAMERA_PIPELINES_MATCH_LIST\n+   Define an ordered list of pipeline names to be used to match the media\n+   devices in the system. The pipeline handler names used to populate the\n+   variable are the ones passed to the REGISTER_PIPELINE_HANDLER() macro in the\n+   source code.\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 \ndiff --git a/include/libcamera/internal/camera_manager.h b/include/libcamera/internal/camera_manager.h\nindex 33ebe069..5694d40d 100644\n--- a/include/libcamera/internal/camera_manager.h\n+++ b/include/libcamera/internal/camera_manager.h\n@@ -44,6 +44,7 @@ protected:\n private:\n \tint init();\n \tvoid createPipelineHandlers();\n+\tvoid pipelineFactoryMatch(const PipelineHandlerFactoryBase *factory);\n \tvoid cleanup() LIBCAMERA_TSA_EXCLUDES(mutex_);\n \n \t/*\ndiff --git a/src/libcamera/camera_manager.cpp b/src/libcamera/camera_manager.cpp\nindex 355f3ada..ce6607e1 100644\n--- a/src/libcamera/camera_manager.cpp\n+++ b/src/libcamera/camera_manager.cpp\n@@ -99,16 +99,37 @@ int CameraManager::Private::init()\n \n void CameraManager::Private::createPipelineHandlers()\n {\n-\tCameraManager *const o = LIBCAMERA_O_PTR();\n-\n \t/*\n \t * \\todo Try to read handlers and order from configuration\n-\t * file and only fallback on all handlers if there is no\n-\t * configuration file.\n+\t * file and only fallback on environment variable or all handlers, if\n+\t * there is no configuration file.\n \t */\n+\tconst char *pipesList =\n+\t\tutils::secure_getenv(\"LIBCAMERA_PIPELINES_MATCH_LIST\");\n+\tif (pipesList) {\n+\t\t/*\n+\t\t * When a list of preferred pipelines is defined, iterate\n+\t\t * through the ordered list to match the enumerated devices.\n+\t\t */\n+\t\tfor (const auto &pipeName : utils::split(pipesList, \",\")) {\n+\t\t\tconst PipelineHandlerFactoryBase *factory;\n+\t\t\tfactory = PipelineHandlerFactoryBase::getFactoryByName(pipeName);\n+\t\t\tif (!factory)\n+\t\t\t\tcontinue;\n+\n+\t\t\tLOG(Camera, Debug)\n+\t\t\t\t<< \"Found listed pipeline handler '\"\n+\t\t\t\t<< pipeName << \"'\";\n+\t\t\tpipelineFactoryMatch(factory);\n+\t\t}\n+\n+\t\treturn;\n+\t}\n+\n \tconst std::vector<PipelineHandlerFactoryBase *> &factories =\n \t\tPipelineHandlerFactoryBase::factories();\n \n+\t/* Match all the registered pipeline handlers. */\n \tfor (const PipelineHandlerFactoryBase *factory : factories) {\n \t\tLOG(Camera, Debug)\n \t\t\t<< \"Found registered pipeline handler '\"\n@@ -117,15 +138,23 @@ void CameraManager::Private::createPipelineHandlers()\n \t\t * Try each pipeline handler until it exhaust\n \t\t * all pipelines it can provide.\n \t\t */\n-\t\twhile (1) {\n-\t\t\tstd::shared_ptr<PipelineHandler> pipe = factory->create(o);\n-\t\t\tif (!pipe->match(enumerator_.get()))\n-\t\t\t\tbreak;\n+\t\tpipelineFactoryMatch(factory);\n+\t}\n+}\n \n-\t\t\tLOG(Camera, Debug)\n-\t\t\t\t<< \"Pipeline handler \\\"\" << factory->name()\n-\t\t\t\t<< \"\\\" matched\";\n-\t\t}\n+void CameraManager::Private::pipelineFactoryMatch(const PipelineHandlerFactoryBase *factory)\n+{\n+\tCameraManager *const o = LIBCAMERA_O_PTR();\n+\n+\t/* Provide as many matching pipelines as possible. */\n+\twhile (1) {\n+\t\tstd::shared_ptr<PipelineHandler> pipe = factory->create(o);\n+\t\tif (!pipe->match(enumerator_.get()))\n+\t\t\tbreak;\n+\n+\t\tLOG(Camera, Debug)\n+\t\t\t<< \"Pipeline handler \\\"\" << factory->name()\n+\t\t\t<< \"\\\" matched\";\n \t}\n }\n \n",
    "prefixes": [
        "v3",
        "2/2"
    ]
}