Patch Detail
Show a patch.
GET /api/1.1/patches/23653/?format=api
{ "id": 23653, "url": "https://patchwork.libcamera.org/api/1.1/patches/23653/?format=api", "web_url": "https://patchwork.libcamera.org/patch/23653/", "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": "<20250625155308.2325438-2-dan.scally@ideasonboard.com>", "date": "2025-06-25T15:53:07", "name": "[v1,1/2] libcamera: device_enumerator: Use regex to match entity names", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "ff3bd97411ba3a0fabbbcc5ab0fecc29d0837ab1", "submitter": { "id": 156, "url": "https://patchwork.libcamera.org/api/1.1/people/156/?format=api", "name": "Dan Scally", "email": "dan.scally@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/23653/mbox/", "series": [ { "id": 5247, "url": "https://patchwork.libcamera.org/api/1.1/series/5247/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=5247", "date": "2025-06-25T15:53:06", "name": "Use regular expressions for entity name matching", "version": 1, "mbox": "https://patchwork.libcamera.org/series/5247/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/23653/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/23653/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 19990C3237\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 25 Jun 2025 15:53:33 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 0E29268DD0;\n\tWed, 25 Jun 2025 17:53:31 +0200 (CEST)", "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 1E7A968DD0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 25 Jun 2025 17:53:27 +0200 (CEST)", "from mail.ideasonboard.com\n\t(cpc141996-chfd3-2-0-cust928.12-3.cable.virginm.net [86.13.91.161])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id C879F982;\n\tWed, 25 Jun 2025 17:53:08 +0200 (CEST)" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"j9/RUtbq\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1750866788;\n\tbh=EMQQg7VR7g0025K3LsIPdudZTjOd6jQRXSK9BFGVgN8=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=j9/RUtbqxhkz0WlzD1+sEhPIxLss2OEBEBkq65K5CUDoAJftQkDB5k8mKhP1a+5cE\n\tgqn7tEeuU9o5G6OzapDXYrhiU23C3bHLUeS4w1TlZsRIxSVd1gMlCsX9M6O8t+AbVL\n\tuIqJyAIrfJNINGiYlQWVAH8bM1FyfRdn1/zV+heo=", "From": "Daniel Scally <dan.scally@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Cc": "Daniel Scally <dan.scally@ideasonboard.com>", "Subject": "[PATCH v1 1/2] libcamera: device_enumerator: Use regex to match\n\tentity names", "Date": "Wed, 25 Jun 2025 16:53:07 +0100", "Message-Id": "<20250625155308.2325438-2-dan.scally@ideasonboard.com>", "X-Mailer": "git-send-email 2.34.1", "In-Reply-To": "<20250625155308.2325438-1-dan.scally@ideasonboard.com>", "References": "<20250625155308.2325438-1-dan.scally@ideasonboard.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "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": "Some entities in a media graph have names that might differ from\nimplementation to implementation; for example the Camera Receiver\nUnit and CSI-2 receiver on the KakiP board have entities with names\nthat include their address, in the form \"csi-16000400.csi2\". Passing\nthat entity name to DeviceMatch is too inflexible given it would only\nwork if that specific CSI-2 receiver were the one being used.\n\nUpdate DeviceMatch.add() such that the string passed to it is used to\ncreate a std::basic_regex, and use std::regex_search() instead of a\ndirect string comparison in DeviceMatch::match(). This allows us to\npass a string that will form a regex expression to match to the entity\ninstead, for example \"csi-[0-9]{8}.csi2\".\n\nSigned-off-by: Daniel Scally <dan.scally@ideasonboard.com>\n---\n .../libcamera/internal/device_enumerator.h | 3 ++-\n src/libcamera/device_enumerator.cpp | 27 ++++++++++---------\n 2 files changed, 16 insertions(+), 14 deletions(-)", "diff": "diff --git a/include/libcamera/internal/device_enumerator.h b/include/libcamera/internal/device_enumerator.h\nindex db3532a9..fce7f0ea 100644\n--- a/include/libcamera/internal/device_enumerator.h\n+++ b/include/libcamera/internal/device_enumerator.h\n@@ -8,6 +8,7 @@\n #pragma once\n \n #include <memory>\n+#include <regex>\n #include <string>\n #include <vector>\n \n@@ -28,7 +29,7 @@ public:\n \n private:\n \tstd::string driver_;\n-\tstd::vector<std::string> entities_;\n+\tstd::vector<std::regex> entities_;\n };\n \n class DeviceEnumerator\ndiff --git a/src/libcamera/device_enumerator.cpp b/src/libcamera/device_enumerator.cpp\nindex ae17862f..e22d2822 100644\n--- a/src/libcamera/device_enumerator.cpp\n+++ b/src/libcamera/device_enumerator.cpp\n@@ -52,15 +52,15 @@ LOG_DEFINE_CATEGORY(DeviceEnumerator)\n * device enumerator to find matching media devices.\n *\n * A DeviceMatch is created with a specific Linux device driver in mind,\n- * therefore the name of the driver is a required property. One or more Entity\n- * names can be added as match criteria.\n+ * therefore the name of the driver is a required property. Regex expressions to\n+ * match one or more Entity names can be added as match criteria.\n *\n- * Pipeline handlers are recommended to add entities to DeviceMatch as\n- * appropriate to ensure that the media device they need can be uniquely\n- * identified. This is useful when the corresponding kernel driver can produce\n- * different graphs, for instance as a result of different driver versions or\n- * hardware configurations, and not all those graphs are suitable for a pipeline\n- * handler.\n+ * Pipeline handlers are recommended to add regex expressions for entities to\n+ * DeviceMatch as appropriate to ensure that the media device they need can be\n+ * uniquely identified. This is useful when the corresponding kernel driver can\n+ * produce different graphs, for instance as a result of different driver\n+ * versions or hardware configurations, and not all those graphs are suitable\n+ * for a pipeline handler.\n */\n \n /**\n@@ -73,12 +73,13 @@ DeviceMatch::DeviceMatch(const std::string &driver)\n }\n \n /**\n- * \\brief Add a media entity name to the search pattern\n- * \\param[in] entity The name of the entity in the media graph\n+ * \\brief Add a media entity regex string to the search pattern\n+ * \\param[in] entity A regex string to match the entity in the media graph\n */\n void DeviceMatch::add(const std::string &entity)\n {\n-\tentities_.push_back(entity);\n+\tstd::regex entity_regex(entity);\n+\tentities_.push_back(entity_regex);\n }\n \n /**\n@@ -96,11 +97,11 @@ bool DeviceMatch::match(const MediaDevice *device) const\n \tif (driver_ != device->driver())\n \t\treturn false;\n \n-\tfor (const std::string &name : entities_) {\n+\tfor (const std::regex &name_regex : entities_) {\n \t\tbool found = false;\n \n \t\tfor (const MediaEntity *entity : device->entities()) {\n-\t\t\tif (name == entity->name()) {\n+\t\t\tif (std::regex_search(entity->name(), name_regex)) {\n \t\t\t\tif (!entity->deviceNode().empty()) {\n \t\t\t\t\tfound = true;\n \t\t\t\t\tbreak;\n", "prefixes": [ "v1", "1/2" ] }