Patch Detail
Show a patch.
GET /api/patches/23837/?format=api
{ "id": 23837, "url": "https://patchwork.libcamera.org/api/patches/23837/?format=api", "web_url": "https://patchwork.libcamera.org/patch/23837/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/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-5-dan.scally@ideasonboard.com>", "date": "2025-07-17T12:48:53", "name": "[v2,4/4] libcamera: V4L2Subdevice: Allow for a regex to match entity name", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "59c5f21b41e9a3b575e4e98a8a1d1180988674e5", "submitter": { "id": 156, "url": "https://patchwork.libcamera.org/api/people/156/?format=api", "name": "Dan Scally", "email": "dan.scally@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/23837/mbox/", "series": [ { "id": 5293, "url": "https://patchwork.libcamera.org/api/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/23837/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/23837/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 6696CC3324\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 17 Jul 2025 12:49:10 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id ADEFB68F91;\n\tThu, 17 Jul 2025 14:49:07 +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 E322E68F7A\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 E85331AE2;\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=\"taoerm3l\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1752756509;\n\tbh=rnk40mK7wmRbsHbj3DM31FOCqnJVNInWCrJmlSaVjtE=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=taoerm3lVpni/dubokTYxtwXaOVOwqKAkRkGOXvIjYv/n61hDRBAZKeQpcgSfrBHp\n\t9wmwxMB/kzitFFkZnNnBX2A7vjGg7/EZ4q4sv7m9Jt47Fe3VV4cbiWmHG68w64xnuc\n\tzy9ecLt1Y3068wjZrBuDIoCfJXGrCSz89z0bmrDs=", "From": "Daniel Scally <dan.scally@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Cc": "Daniel Scally <dan.scally@ideasonboard.com>", "Subject": "[PATCH v2 4/4] libcamera: V4L2Subdevice: Allow for a regex to match\n\tentity name", "Date": "Thu, 17 Jul 2025 13:48:53 +0100", "Message-Id": "<20250717124853.2317191-5-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\nV4L2Subdevice::fromEntityName() 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 V4L2Subdevice::fromEntityName() to instead allow\nusers to pass a std::basic_regex, and use std::regex_search() instead\nof a direct string comparison to find a matching entity. Ths allows\nus to form regular expressions like \"csi-[0-9a-f]{8}.csi2\" to find\nthe entities.\n\nSigned-off-by: Daniel Scally <dan.scally@ideasonboard.com>\n---\nChanges in v2:\n\n\t- New patch\n\n include/libcamera/internal/v4l2_subdevice.h | 3 +++\n src/libcamera/v4l2_subdevice.cpp | 19 +++++++++++++++++++\n 2 files changed, 22 insertions(+)", "diff": "diff --git a/include/libcamera/internal/v4l2_subdevice.h b/include/libcamera/internal/v4l2_subdevice.h\nindex fa2a4a21..192141be 100644\n--- a/include/libcamera/internal/v4l2_subdevice.h\n+++ b/include/libcamera/internal/v4l2_subdevice.h\n@@ -18,6 +18,7 @@\n \n #include <libcamera/base/class.h>\n #include <libcamera/base/log.h>\n+#include <libcamera/base/regex.h>\n \n #include <libcamera/color_space.h>\n #include <libcamera/geometry.h>\n@@ -163,6 +164,8 @@ public:\n \n \tstatic std::unique_ptr<V4L2Subdevice>\n \tfromEntityName(const MediaDevice *media, const std::string &entity);\n+\tstatic std::unique_ptr<V4L2Subdevice>\n+\tfromEntityName(const MediaDevice *media, const std::regex &entity);\n \n protected:\n \tstd::string logPrefix() const override;\ndiff --git a/src/libcamera/v4l2_subdevice.cpp b/src/libcamera/v4l2_subdevice.cpp\nindex fd3b18c2..72fcf0d5 100644\n--- a/src/libcamera/v4l2_subdevice.cpp\n+++ b/src/libcamera/v4l2_subdevice.cpp\n@@ -1760,6 +1760,25 @@ V4L2Subdevice::fromEntityName(const MediaDevice *media,\n \treturn std::make_unique<V4L2Subdevice>(mediaEntity);\n }\n \n+/**\n+ * \\brief Create a new video subdevice instance from an entity in media device\n+ * \\a media\n+ * \\param[in] media The media device where the entity is registered\n+ * \\param[in] entity A regex that will match the media entity's name\n+ *\n+ * \\return A newly created V4L2Subdevice on success, nullptr otherwise\n+ */\n+std::unique_ptr<V4L2Subdevice>\n+V4L2Subdevice::fromEntityName(const MediaDevice *media,\n+\t\t\t const std::regex &entity)\n+{\n+\tMediaEntity *mediaEntity = media->getEntityByName(entity);\n+\tif (!mediaEntity)\n+\t\treturn nullptr;\n+\n+\treturn std::make_unique<V4L2Subdevice>(mediaEntity);\n+}\n+\n std::string V4L2Subdevice::logPrefix() const\n {\n \treturn \"'\" + entity_->name() + \"'\";\n", "prefixes": [ "v2", "4/4" ] }