Show a patch.

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

{
    "id": 18928,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/18928/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/18928/",
    "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": "<20230808125228.29043-2-jacopo.mondi@ideasonboard.com>",
    "date": "2023-08-08T12:52:20",
    "name": "[libcamera-devel,RFC,1/9] libcamera: Break-out DeviceMatch",
    "commit_ref": null,
    "pull_url": null,
    "state": "new",
    "archived": false,
    "hash": "b5102ea3f65283953ef675fbe2b9f194b574c226",
    "submitter": {
        "id": 143,
        "url": "https://patchwork.libcamera.org/api/1.1/people/143/?format=api",
        "name": "Jacopo Mondi",
        "email": "jacopo.mondi@ideasonboard.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/18928/mbox/",
    "series": [
        {
            "id": 4002,
            "url": "https://patchwork.libcamera.org/api/1.1/series/4002/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=4002",
            "date": "2023-08-08T12:52:19",
            "name": "libcamera: Generalize device match and support USB devices",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/4002/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/18928/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/18928/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 C28E6C32A9\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue,  8 Aug 2023 12:52:49 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id EF049627F0;\n\tTue,  8 Aug 2023 14:52:48 +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 ED43C60562\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  8 Aug 2023 14:52:46 +0200 (CEST)",
            "from uno.localdomain (mob-5-90-60-22.net.vodafone.it [5.90.60.22])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 0449138B3; \n\tTue,  8 Aug 2023 14:51:38 +0200 (CEST)"
        ],
        "DKIM-Signature": [
            "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1691499169;\n\tbh=u/+aVEYmwldsZIs13/MxapmxB2C5bS5FSopQsWJA0vI=;\n\th=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=dlrpOgskQWJSaGK6xOGFTyjfCeoSVEOzKhPZQZCSTZlrEZFybLTZaUWVqk32KWzT3\n\thrP2Yl4KzJIgPZuac+sFfy/UnuiJvMFLhH+YO5fV0h2JEENCfKsSM4Qhi4qo/V1CgJ\n\t69K3zzn/YUpafbVTnDeuprM8FuHHbILpouRgfY8D0v1j77NshWFLp65FKW8FL4Vo8w\n\tFfo1niyK1m+hbT9rtCjINp29KNJ/yiGVeusJ/l+aJNAr2FC0fohLXTxUFlKlmNokVU\n\t4z8jxCWIKUnDsGXFdxGX0e1dE5yvvLiWGtdrj29Q6CY037ENa+QCMdB1yZGO3SMEMU\n\tYlTkoxX44Qsnw==",
            "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1691499099;\n\tbh=u/+aVEYmwldsZIs13/MxapmxB2C5bS5FSopQsWJA0vI=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=BKAal0EPG7HCbobfixm499uHdRWaglLnpMejXEyZnKbIEtwhGBanPww9O4LniPvOA\n\t9++eAbW0zTYil/sIFGAQcrdmz4SM4Zg+Sx4ZW3hCMrzlWbVrwyjAsTaD5kWz7nJfII\n\tgDxceWGA9fqRHgY0J6KOZy/fl4LRApxvcaJpLr2w="
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"BKAal0EP\"; dkim-atps=neutral",
        "To": "libcamera-devel@lists.libcamera.org, Sophie Friedrich <dev@flowerpot.me>",
        "Date": "Tue,  8 Aug 2023 14:52:20 +0200",
        "Message-Id": "<20230808125228.29043-2-jacopo.mondi@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.40.1",
        "In-Reply-To": "<20230808125228.29043-1-jacopo.mondi@ideasonboard.com>",
        "References": "<20230808125228.29043-1-jacopo.mondi@ideasonboard.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [RFC 1/9] libcamera: Break-out DeviceMatch",
        "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>",
        "From": "Jacopo Mondi via libcamera-devel <libcamera-devel@lists.libcamera.org>",
        "Reply-To": "Jacopo Mondi <jacopo.mondi@ideasonboard.com>",
        "Cc": "Jacopo Mondi <jacopo.mondi@ideasonboard.com>",
        "Errors-To": "libcamera-devel-bounces@lists.libcamera.org",
        "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"
    },
    "content": "The DeviceMatch class is defined inside the 'device_enumerator'\nfile. Break it out to a dedicated file and header in order to expand\nit to support multiple matching criteria.\n\nSigned-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\n---\n .../libcamera/internal/device_enumerator.h    | 16 +---\n include/libcamera/internal/device_match.h     | 31 +++++++\n include/libcamera/internal/meson.build        |  1 +\n src/libcamera/device_enumerator.cpp           | 73 ---------------\n src/libcamera/device_match.cpp                | 92 +++++++++++++++++++\n src/libcamera/meson.build                     |  1 +\n 6 files changed, 127 insertions(+), 87 deletions(-)\n create mode 100644 include/libcamera/internal/device_match.h\n create mode 100644 src/libcamera/device_match.cpp",
    "diff": "diff --git a/include/libcamera/internal/device_enumerator.h b/include/libcamera/internal/device_enumerator.h\nindex 72ec9a60b19a..259a9e4621ea 100644\n--- a/include/libcamera/internal/device_enumerator.h\n+++ b/include/libcamera/internal/device_enumerator.h\n@@ -13,24 +13,12 @@\n \n #include <libcamera/base/signal.h>\n \n+#include \"libcamera/internal/device_match.h\"\n+\n namespace libcamera {\n \n class MediaDevice;\n \n-class DeviceMatch\n-{\n-public:\n-\tDeviceMatch(const std::string &driver);\n-\n-\tvoid add(const std::string &entity);\n-\n-\tbool match(const MediaDevice *device) const;\n-\n-private:\n-\tstd::string driver_;\n-\tstd::vector<std::string> entities_;\n-};\n-\n class DeviceEnumerator\n {\n public:\ndiff --git a/include/libcamera/internal/device_match.h b/include/libcamera/internal/device_match.h\nnew file mode 100644\nindex 000000000000..9f190f0c8a84\n--- /dev/null\n+++ b/include/libcamera/internal/device_match.h\n@@ -0,0 +1,31 @@\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\n+/*\n+ * Copyright (C) 2023, Ideas On Board Oy\n+ *\n+ * device_match.h - Match and identify devices to create cameras with\n+ */\n+\n+#pragma once\n+\n+#include <string>\n+#include <vector>\n+\n+namespace libcamera {\n+\n+class MediaDevice;\n+\n+class DeviceMatch\n+{\n+public:\n+\tDeviceMatch(const std::string &driver);\n+\n+\tvoid add(const std::string &entity);\n+\n+\tbool match(const MediaDevice *device) const;\n+\n+private:\n+\tstd::string driver_;\n+\tstd::vector<std::string> entities_;\n+};\n+\n+}; /* namespace libcamera */\ndiff --git a/include/libcamera/internal/meson.build b/include/libcamera/internal/meson.build\nindex 7f1f344014c4..169e06557106 100644\n--- a/include/libcamera/internal/meson.build\n+++ b/include/libcamera/internal/meson.build\n@@ -25,6 +25,7 @@ libcamera_internal_headers = files([\n     'device_enumerator.h',\n     'device_enumerator_sysfs.h',\n     'device_enumerator_udev.h',\n+    'device_match.h',\n     'formats.h',\n     'framebuffer.h',\n     'ipa_manager.h',\ndiff --git a/src/libcamera/device_enumerator.cpp b/src/libcamera/device_enumerator.cpp\nindex f2e055de6477..49afd7834db2 100644\n--- a/src/libcamera/device_enumerator.cpp\n+++ b/src/libcamera/device_enumerator.cpp\n@@ -40,79 +40,6 @@ namespace libcamera {\n \n LOG_DEFINE_CATEGORY(DeviceEnumerator)\n \n-/**\n- * \\class DeviceMatch\n- * \\brief Description of a media device search pattern\n- *\n- * The DeviceMatch class describes a media device using properties from the\n- * Media Controller struct media_device_info, entity names in the media graph\n- * or other properties that can be used to identify a media device.\n- *\n- * The description is meant to be filled by pipeline managers and passed to a\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- *\n- * Pipeline handlers are recommended to add entities to DeviceMatch as\n- * appropriare 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- */\n-\n-/**\n- * \\brief Construct a media device search pattern\n- * \\param[in] driver The Linux device driver name that created the media device\n- */\n-DeviceMatch::DeviceMatch(const std::string &driver)\n-\t: driver_(driver)\n-{\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- */\n-void DeviceMatch::add(const std::string &entity)\n-{\n-\tentities_.push_back(entity);\n-}\n-\n-/**\n- * \\brief Compare a search pattern with a media device\n- * \\param[in] device The media device\n- *\n- * Matching is performed on the Linux device driver name and entity names from\n- * the media graph. A match is found if both the driver name matches and the\n- * media device contains all the entities listed in the search pattern.\n- *\n- * \\return true if the media device matches the search pattern, false otherwise\n- */\n-bool DeviceMatch::match(const MediaDevice *device) const\n-{\n-\tif (driver_ != device->driver())\n-\t\treturn false;\n-\n-\tfor (const std::string &name : 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\t\tfound = true;\n-\t\t\t\tbreak;\n-\t\t\t}\n-\t\t}\n-\n-\t\tif (!found)\n-\t\t\treturn false;\n-\t}\n-\n-\treturn true;\n-}\n-\n /**\n  * \\class DeviceEnumerator\n  * \\brief Enumerate, store and search media devices\ndiff --git a/src/libcamera/device_match.cpp b/src/libcamera/device_match.cpp\nnew file mode 100644\nindex 000000000000..a51b9081d398\n--- /dev/null\n+++ b/src/libcamera/device_match.cpp\n@@ -0,0 +1,92 @@\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\n+/*\n+ * Copyright (C) 2023, Ideas On Board Oy\n+ *\n+ * device_match.cpp - Match and identify devices to create cameras with\n+ */\n+\n+#include \"libcamera/internal/device_match.h\"\n+\n+#include \"libcamera/internal/media_device.h\"\n+\n+/**\n+ * \\file device_match.h\n+ * \\brief Define types and functions to identify devices used to create cameras\n+ */\n+\n+namespace libcamera {\n+\n+/**\n+ * \\class DeviceMatch\n+ * \\brief Description of a media device search pattern\n+ *\n+ * The DeviceMatch class describes a media device using properties from the\n+ * Media Controller struct media_device_info, entity names in the media graph\n+ * or other properties that can be used to identify a media device.\n+ *\n+ * The description is meant to be filled by pipeline managers and passed to a\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+ *\n+ * Pipeline handlers are recommended to add entities to DeviceMatch as\n+ * appropriare 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+ */\n+\n+/**\n+ * \\brief Construct a media device search pattern\n+ * \\param[in] driver The Linux device driver name that created the media device\n+ */\n+DeviceMatch::DeviceMatch(const std::string &driver)\n+\t: driver_(driver)\n+{\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+ */\n+void DeviceMatch::add(const std::string &entity)\n+{\n+\tentities_.push_back(entity);\n+}\n+\n+/**\n+ * \\brief Compare a search pattern with a media device\n+ * \\param[in] device The media device\n+ *\n+ * Matching is performed on the Linux device driver name and entity names from\n+ * the media graph. A match is found if both the driver name matches and the\n+ * media device contains all the entities listed in the search pattern.\n+ *\n+ * \\return True if the media device matches the search pattern, false otherwise\n+ */\n+bool DeviceMatch::match(const MediaDevice *device) const\n+{\n+\tif (driver_ != device->driver())\n+\t\treturn false;\n+\n+\tfor (const std::string &name : 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\t\tfound = true;\n+\t\t\t\tbreak;\n+\t\t\t}\n+\t\t}\n+\n+\t\tif (!found)\n+\t\t\treturn false;\n+\t}\n+\n+\treturn true;\n+}\n+\n+} /* namespace libcamera */\ndiff --git a/src/libcamera/meson.build b/src/libcamera/meson.build\nindex b24f82965764..d5562afc50c7 100644\n--- a/src/libcamera/meson.build\n+++ b/src/libcamera/meson.build\n@@ -17,6 +17,7 @@ libcamera_sources = files([\n     'delayed_controls.cpp',\n     'device_enumerator.cpp',\n     'device_enumerator_sysfs.cpp',\n+    'device_match.cpp',\n     'fence.cpp',\n     'formats.cpp',\n     'framebuffer.cpp',\n",
    "prefixes": [
        "libcamera-devel",
        "RFC",
        "1/9"
    ]
}