Patch Detail
Show a patch.
GET /api/1.1/patches/23836/?format=api
{ "id": 23836, "url": "https://patchwork.libcamera.org/api/1.1/patches/23836/?format=api", "web_url": "https://patchwork.libcamera.org/patch/23836/", "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": "<20250717124853.2317191-4-dan.scally@ideasonboard.com>", "date": "2025-07-17T12:48:52", "name": "[v2,3/4] libcamera: media_device: Allow for a regex to match entity name", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "b548a80809433c025615f50913b79824999e9fc4", "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/23836/mbox/", "series": [ { "id": 5293, "url": "https://patchwork.libcamera.org/api/1.1/series/5293/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=5293", "date": "2025-07-17T12:48:49", "name": "Use regular expressions for entity name matching", "version": 2, "mbox": "https://patchwork.libcamera.org/series/5293/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/23836/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/23836/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 CE92DBE175\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 17 Jul 2025 12:49:09 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id BF7E168F86;\n\tThu, 17 Jul 2025 14:49:06 +0200 (CEST)", "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 A24CE68F78\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 17 Jul 2025 14:49:02 +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 A4DC721F5;\n\tThu, 17 Jul 2025 14:48:28 +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=\"jG/DSCM+\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1752756508;\n\tbh=dyllA6vhOpHDbyQVyysv4Hgk9JcCjOP6QWTZDbX9hW8=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=jG/DSCM+kOm4OaT6kQJpt5A58WcwzJROPUA1L5u3jBTUdwD7LuRxo2ejuhHyaNwWV\n\t+2AM2296th0teqQpYul4f9kat3O80GivELT5gLOxRy/U6fnva3XemnL1D0bRF1q3yN\n\t1gGwTqDCrcIVA6pRG4Z4Y43fFOkjOrjgVcbuGkbA=", "From": "Daniel Scally <dan.scally@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Cc": "Daniel Scally <dan.scally@ideasonboard.com>", "Subject": "[PATCH v2 3/4] libcamera: media_device: Allow for a regex to match\n\tentity name", "Date": "Thu, 17 Jul 2025 13:48:52 +0100", "Message-Id": "<20250717124853.2317191-4-dan.scally@ideasonboard.com>", "X-Mailer": "git-send-email 2.34.1", "In-Reply-To": "<20250717124853.2317191-1-dan.scally@ideasonboard.com>", "References": "<20250717124853.2317191-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 kernel drivers give their entities names that will differ from\nimplementation to implementation; for example the drivers for the\nCamera Receiver Unit and CSI-2 receiver in the RZ/V2H SoC give their\nentities names that include their memory address, in the format\n\"csi-16000400.csi2\". Passing that entity name to\nMediaDevice::getEntityByName() is too inflexible given it would only\nthen work if that specific CSI-2 receiver were the one being used.\n\nAdd an overload for MediaDevice::getEntityByName() that accepts a\nstd::basic_regex instead of a string, and use std::regex_search()\ninstead of a direct string comparison to find a matching entity. This\nallows us to search for entites using regex patterns like\n\"csi-[0-9a-f]{8}.csi2\".\n\nSigned-off-by: Daniel Scally <dan.scally@ideasonboard.com>\n---\nChanges in v2:\n\n\t- Add an overload for ::getEntityByName() instead of\n\treplacing the existing functionality. The new overload\n\ttakes a regex, but will return a nullptr in the event\n\tthat the given regex matches multiple entities.\n\n include/libcamera/internal/media_device.h | 2 ++\n src/libcamera/media_device.cpp | 25 +++++++++++++++++++++++\n 2 files changed, 27 insertions(+)", "diff": "diff --git a/include/libcamera/internal/media_device.h b/include/libcamera/internal/media_device.h\nindex b3a48b98..3f28793f 100644\n--- a/include/libcamera/internal/media_device.h\n+++ b/include/libcamera/internal/media_device.h\n@@ -14,6 +14,7 @@\n #include <linux/media.h>\n \n #include <libcamera/base/log.h>\n+#include <libcamera/base/regex.h>\n #include <libcamera/base/signal.h>\n #include <libcamera/base/unique_fd.h>\n \n@@ -45,6 +46,7 @@ public:\n \n \tconst std::vector<MediaEntity *> &entities() const { return entities_; }\n \tMediaEntity *getEntityByName(const std::string &name) const;\n+\tMediaEntity *getEntityByName(const std::regex &name) const;\n \n \tMediaLink *link(const std::string &sourceName, unsigned int sourceIdx,\n \t\t\tconst std::string &sinkName, unsigned int sinkIdx);\ndiff --git a/src/libcamera/media_device.cpp b/src/libcamera/media_device.cpp\nindex 353f34a8..a0c0df86 100644\n--- a/src/libcamera/media_device.cpp\n+++ b/src/libcamera/media_device.cpp\n@@ -341,6 +341,31 @@ MediaEntity *MediaDevice::getEntityByName(const std::string &name) const\n \treturn nullptr;\n }\n \n+/**\n+ * \\brief Return the MediaEntity with name matching the regex \\a name\n+ * \\param[in] name A regex to match the entity name\n+ * \\return The entity with name matching the regex \\a name, or nullptr if no\n+ * such entity is found\n+ */\n+MediaEntity *MediaDevice::getEntityByName(const std::regex &name) const\n+{\n+\tMediaEntity *entity = nullptr;\n+\n+\tfor (MediaEntity *e : entities_) {\n+\t\tif (std::regex_search(e->name(), name)) {\n+\t\t\tif (entity) {\n+\t\t\t\tLOG(MediaDevice, Error)\n+\t\t\t\t\t<< \"Multiple entities match given regex\";\n+\t\t\t\treturn nullptr;\n+\t\t\t}\n+\n+\t\t\tentity = e;\n+\t\t}\n+\t}\n+\n+\treturn entity;\n+}\n+\n /**\n * \\brief Retrieve the MediaLink connecting two pads, identified by entity\n * names and pad indexes\n", "prefixes": [ "v2", "3/4" ] }