Show a patch.

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

{
    "id": 13232,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/13232/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/13232/",
    "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": "<20210805222436.6263-2-laurent.pinchart@ideasonboard.com>",
    "date": "2021-08-05T22:24:27",
    "name": "[libcamera-devel,01/10] libcamera: media_object: Expose entity type",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "883a224916f367c61b67d2d59544883f95a1dcd2",
    "submitter": {
        "id": 2,
        "url": "https://patchwork.libcamera.org/api/1.1/people/2/?format=api",
        "name": "Laurent Pinchart",
        "email": "laurent.pinchart@ideasonboard.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/13232/mbox/",
    "series": [
        {
            "id": 2314,
            "url": "https://patchwork.libcamera.org/api/1.1/series/2314/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=2314",
            "date": "2021-08-05T22:24:26",
            "name": "Concurrent camera support in simple pipeline handler",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/2314/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/13232/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/13232/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 E25E4C3235\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu,  5 Aug 2021 22:25:00 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id EAAF268823;\n\tFri,  6 Aug 2021 00:24:58 +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 2DD43687CF\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri,  6 Aug 2021 00:24:56 +0200 (CEST)",
            "from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id B6D5AE1A\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri,  6 Aug 2021 00:24:55 +0200 (CEST)"
        ],
        "Authentication-Results": "lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"EO60FyGZ\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1628202295;\n\tbh=QMEiIVBdtXgbvP804wCtcYHU33xqlB3J4uzUIu/Jzqo=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=EO60FyGZHg4ISnEDIP5aYPBZAEnQ9pMlb0yZKgQEQLXYQ83PXDgXj29e0zzUg1Fdv\n\tjzedOiiy70dpfMq1w5tpBW6tWUwQqtcpICA3Z5OmZY9qYrxwBpsgeAJBwXLwUAmiZm\n\t/4m+0sxZXY3xiA737QEqMv0d/ycLo8Pym0cHcEUY=",
        "From": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Fri,  6 Aug 2021 01:24:27 +0300",
        "Message-Id": "<20210805222436.6263-2-laurent.pinchart@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.31.1",
        "In-Reply-To": "<20210805222436.6263-1-laurent.pinchart@ideasonboard.com>",
        "References": "<20210805222436.6263-1-laurent.pinchart@ideasonboard.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH 01/10] libcamera: media_object: Expose\n\tentity type",
        "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": "Add a new field to the MediaEntity class to tell the type of interface\nit exposes to userspace. The MediaEntity constructor is changed to take\na media_v2_interface pointer instead of just the device node major and\nminor to have access to the interface type.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n include/libcamera/internal/media_object.h | 11 ++++-\n src/libcamera/media_device.cpp            |  9 +---\n src/libcamera/media_object.cpp            | 50 +++++++++++++++++++++--\n 3 files changed, 57 insertions(+), 13 deletions(-)",
    "diff": "diff --git a/include/libcamera/internal/media_object.h b/include/libcamera/internal/media_object.h\nindex 2f5d33e1903e..6ae22c679cc5 100644\n--- a/include/libcamera/internal/media_object.h\n+++ b/include/libcamera/internal/media_object.h\n@@ -88,9 +88,17 @@ private:\n class MediaEntity : public MediaObject\n {\n public:\n+\tenum class Type {\n+\t\tInvalid,\n+\t\tMediaEntity,\n+\t\tV4L2Subdevice,\n+\t\tV4L2VideoDevice,\n+\t};\n+\n \tconst std::string &name() const { return name_; }\n \tunsigned int function() const { return function_; }\n \tunsigned int flags() const { return flags_; }\n+\tType type() const { return type_; }\n \tconst std::string &deviceNode() const { return deviceNode_; }\n \tunsigned int deviceMajor() const { return major_; }\n \tunsigned int deviceMinor() const { return minor_; }\n@@ -108,13 +116,14 @@ private:\n \tfriend class MediaDevice;\n \n \tMediaEntity(MediaDevice *dev, const struct media_v2_entity *entity,\n-\t\t    unsigned int major = 0, unsigned int minor = 0);\n+\t\t    const struct media_v2_interface *iface);\n \n \tvoid addPad(MediaPad *pad);\n \n \tstd::string name_;\n \tunsigned int function_;\n \tunsigned int flags_;\n+\tType type_;\n \tstd::string deviceNode_;\n \tunsigned int major_;\n \tunsigned int minor_;\ndiff --git a/src/libcamera/media_device.cpp b/src/libcamera/media_device.cpp\nindex fa50264fa253..4d7cb1f566c4 100644\n--- a/src/libcamera/media_device.cpp\n+++ b/src/libcamera/media_device.cpp\n@@ -652,14 +652,7 @@ bool MediaDevice::populateEntities(const struct media_v2_topology &topology)\n \t\t */\n \t\tstruct media_v2_interface *iface =\n \t\t\tfindInterface(topology, ent->id);\n-\n-\t\tMediaEntity *entity;\n-\t\tif (iface)\n-\t\t\tentity = new MediaEntity(this, ent,\n-\t\t\t\t\t\t iface->devnode.major,\n-\t\t\t\t\t\t iface->devnode.minor);\n-\t\telse\n-\t\t\tentity = new MediaEntity(this, ent);\n+\t\tMediaEntity *entity = new MediaEntity(this, ent, iface);\n \n \t\tif (!addObject(entity)) {\n \t\t\tdelete entity;\ndiff --git a/src/libcamera/media_object.cpp b/src/libcamera/media_object.cpp\nindex 815edc8e3b2d..f425d0447241 100644\n--- a/src/libcamera/media_object.cpp\n+++ b/src/libcamera/media_object.cpp\n@@ -247,6 +247,23 @@ void MediaPad::addLink(MediaLink *link)\n  * may expose a deviceNode().\n  */\n \n+/**\n+ * \\enum MediaEntity::Type\n+ * \\brief The type of the interface exposed by the entity to userspace\n+ *\n+ * \\var MediaEntity::Type::Invalid\n+ * \\brief Invalid or unsupported entity type\n+ *\n+ * \\var MediaEntity::Type::MediaEntity\n+ * \\brief Plain media entity with no userspace interface\n+ *\n+ * \\var MediaEntity::Type::V4L2VideoDevice\n+ * \\brief V4L2 video device with a V4L2 video device node\n+ *\n+ * \\var MediaEntity::Type::V4L2Subdevice\n+ * \\brief V4L2 subdevice with a V4L2 subdev device node\n+ */\n+\n /**\n  * \\fn MediaEntity::name()\n  * \\brief Retrieve the entity name\n@@ -273,6 +290,15 @@ void MediaPad::addLink(MediaLink *link)\n  * \\return The entity's flags\n  */\n \n+/**\n+ * \\fn MediaEntity::type()\n+ * \\brief Retrieve the entity's type\n+ *\n+ * The entity type identifies the type of interface exposed to userspace.\n+ *\n+ * \\return The entity's type\n+ */\n+\n /**\n  * \\fn MediaEntity::deviceNode()\n  * \\brief Retrieve the entity's device node path, if any\n@@ -356,16 +382,32 @@ int MediaEntity::setDeviceNode(const std::string &deviceNode)\n  * \\brief Construct a MediaEntity\n  * \\param[in] dev The media device this entity belongs to\n  * \\param[in] entity The media entity kernel data\n- * \\param[in] major The major number of the entity associated interface\n- * \\param[in] minor The minor number of the entity associated interface\n+ * \\param[in] iface The entity interface data (may be null)\n  */\n MediaEntity::MediaEntity(MediaDevice *dev,\n \t\t\t const struct media_v2_entity *entity,\n-\t\t\t unsigned int major, unsigned int minor)\n+\t\t\t const struct media_v2_interface *iface)\n \t: MediaObject(dev, entity->id), name_(entity->name),\n \t  function_(entity->function), flags_(entity->flags),\n-\t  major_(major), minor_(minor)\n+\t  type_(Type::MediaEntity), major_(0), minor_(0)\n {\n+\tif (!iface)\n+\t\treturn;\n+\n+\tswitch (iface->intf_type) {\n+\tcase MEDIA_INTF_T_V4L_VIDEO:\n+\t\ttype_ = Type::V4L2VideoDevice;\n+\t\tbreak;\n+\tcase MEDIA_INTF_T_V4L_SUBDEV:\n+\t\ttype_ = Type::V4L2Subdevice;\n+\t\tbreak;\n+\tdefault:\n+\t\ttype_ = Type::Invalid;\n+\t\treturn;\n+\t}\n+\n+\tmajor_ = iface->devnode.major;\n+\tminor_ = iface->devnode.minor;\n }\n \n /**\n",
    "prefixes": [
        "libcamera-devel",
        "01/10"
    ]
}