Show a patch.

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

{
    "id": 16885,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/16885/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/16885/",
    "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": "<20220801000543.3501-9-laurent.pinchart@ideasonboard.com>",
    "date": "2022-08-01T00:05:38",
    "name": "[libcamera-devel,08/13] libcamera: v4l2_subdevice: Add support for the V4L2 subdev routing API",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "da53ce209e82e9c31bd6c0d7ccac3c6e69a55cc4",
    "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/16885/mbox/",
    "series": [
        {
            "id": 3352,
            "url": "https://patchwork.libcamera.org/api/1.1/series/3352/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3352",
            "date": "2022-08-01T00:05:30",
            "name": "libcamera: pipeline: simple: Support the NXP i.MX8 ISI",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/3352/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/16885/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/16885/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 611B3BE173\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon,  1 Aug 2022 00:06:02 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 137146332A;\n\tMon,  1 Aug 2022 02:06:02 +0200 (CEST)",
            "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 77D9363312\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  1 Aug 2022 02:06:00 +0200 (CEST)",
            "from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 14110A42;\n\tMon,  1 Aug 2022 02:06:00 +0200 (CEST)"
        ],
        "DKIM-Signature": [
            "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1659312362;\n\tbh=ccCBU6TGpcKxIKorUiUwWP8Ua8AT2WuDW1tPjcXYYfg=;\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:\n\tFrom;\n\tb=xK4K1UnF2IM+FY1eOcRYrH//PpZMJpk81zQsASugW6n4r+FNXwbK5TAmqCUlEhJHj\n\thdk6vR6S2FT+CZwQ9E6XV7bFAcdUn9dtbVxlJvGPoDfFF11ek16Zvuf0vWgka9npr/\n\tjcwDoJVY4f5axy1fiL/bTQJjM+67tzdZcw90i/UZZY/xV4aLosjO0FCVLfMXka4Xer\n\tdvollPRm6QsO+nT8b65Br36BW0n0YzfKsk6Oi4wQ064uD7N62Vp0AhnQtdwy9tUH4M\n\tkS9/dqiedzK4n0djY7OU+sw45vtIHOCOJNVlT8CtDz8icaqeUYN+dOpsLIEG296ZzT\n\twahRmaE5xj4oA==",
            "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1659312360;\n\tbh=ccCBU6TGpcKxIKorUiUwWP8Ua8AT2WuDW1tPjcXYYfg=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=ptBlot2vzPvK8IVzQ+kjDchacoZmJDWc5cAbyruR+r+lx1M3D8gZlLQ7PcaO2vzZ+\n\tHfeNb1l+DJuEBwtXGA9oYbwXrc0CwwAkof1IqbMrFv3ycwV7eH6Ch7gmENuzYvmvIm\n\tbrW1NABSL09Nd4yB5ds4I6wov8hc8r5Hvb9vuikw="
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"ptBlot2v\"; dkim-atps=neutral",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Mon,  1 Aug 2022 03:05:38 +0300",
        "Message-Id": "<20220801000543.3501-9-laurent.pinchart@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.35.1",
        "In-Reply-To": "<20220801000543.3501-1-laurent.pinchart@ideasonboard.com>",
        "References": "<20220801000543.3501-1-laurent.pinchart@ideasonboard.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH 08/13] libcamera: v4l2_subdevice: Add\n\tsupport for the V4L2 subdev routing API",
        "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": "Laurent Pinchart via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>",
        "Reply-To": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>",
        "Errors-To": "libcamera-devel-bounces@lists.libcamera.org",
        "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"
    },
    "content": "From: Jacopo Mondi <jacopo@jmondi.org>\n\nExtend the V4L2Subdevice class to support getting and setting routing\ntables.\n\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\nChanges on top of Jacopo's initial work:\n\n- Turn Routing struct into a class, an inherit from std::vector\n- Drop Routing::numRoutes\n---\n include/libcamera/internal/v4l2_subdevice.h |   9 ++\n src/libcamera/v4l2_subdevice.cpp            | 105 ++++++++++++++++++++\n 2 files changed, 114 insertions(+)",
    "diff": "diff --git a/include/libcamera/internal/v4l2_subdevice.h b/include/libcamera/internal/v4l2_subdevice.h\nindex a1d3144c6a7f..00be17bb1465 100644\n--- a/include/libcamera/internal/v4l2_subdevice.h\n+++ b/include/libcamera/internal/v4l2_subdevice.h\n@@ -61,6 +61,12 @@ public:\n \t\tActiveFormat = V4L2_SUBDEV_FORMAT_ACTIVE,\n \t};\n \n+\tclass Routing : public std::vector<struct v4l2_subdev_route>\n+\t{\n+\tpublic:\n+\t\tstd::string toString() const;\n+\t};\n+\n \texplicit V4L2Subdevice(const MediaEntity *entity);\n \t~V4L2Subdevice();\n \n@@ -80,6 +86,9 @@ public:\n \tint setFormat(unsigned int pad, V4L2SubdeviceFormat *format,\n \t\t      Whence whence = ActiveFormat);\n \n+\tint getRouting(Routing *routing, Whence whence = ActiveFormat);\n+\tint setRouting(Routing *routing, Whence whence = ActiveFormat);\n+\n \tconst std::string &model();\n \tconst V4L2SubdeviceCapability &caps() const { return caps_; }\n \ndiff --git a/src/libcamera/v4l2_subdevice.cpp b/src/libcamera/v4l2_subdevice.cpp\nindex a1672b2365f2..fe8b8e4eae2a 100644\n--- a/src/libcamera/v4l2_subdevice.cpp\n+++ b/src/libcamera/v4l2_subdevice.cpp\n@@ -288,6 +288,32 @@ std::ostream &operator<<(std::ostream &out, const V4L2SubdeviceFormat &f)\n  * \\brief The format operation applies to TRY formats\n  */\n \n+/**\n+ * \\class V4L2Subdevice::Routing\n+ * \\brief V4L2 subdevice routing table\n+ *\n+ * This class stores a subdevice routing table as a vector of routes.\n+ */\n+\n+/**\n+ * \\brief Assemble and return a string describing the routing table\n+ * \\return A string describing the routing table\n+ */\n+std::string V4L2Subdevice::Routing::toString() const\n+{\n+\tstd::stringstream routing;\n+\n+\tfor (const auto &[i, route] : utils::enumerate(*this)) {\n+\t\trouting << \"[\" << i << \"] \"\n+\t\t\t<< route.sink_pad << \"/\" << route.sink_stream << \" -> \"\n+\t\t\t<< route.source_pad << \"/\" << route.source_stream;\n+\t\tif (i != size() - 1)\n+\t\t\trouting << \", \";\n+\t}\n+\n+\treturn routing.str();\n+}\n+\n /**\n  * \\brief Create a V4L2 subdevice from a MediaEntity using its device node\n  * path\n@@ -517,6 +543,85 @@ int V4L2Subdevice::setFormat(unsigned int pad, V4L2SubdeviceFormat *format,\n \treturn 0;\n }\n \n+/**\n+ * \\brief Retrieve the subdevice's internal routing table\n+ * \\param[out] routing The routing table\n+ * \\param[in] whence The routing table to get, \\ref V4L2Subdevice::ActiveFormat\n+ * \"ActiveFormat\" or \\ref V4L2Subdevice::TryFormat \"TryFormat\"\n+ *\n+ * \\return 0 on success or a negative error code otherwise\n+ */\n+int V4L2Subdevice::getRouting(Routing *routing, Whence whence)\n+{\n+\tif (!caps_.hasStreams())\n+\t\treturn 0;\n+\n+\tstruct v4l2_subdev_routing rt = {};\n+\n+\trt.which = whence;\n+\n+\tint ret = ioctl(VIDIOC_SUBDEV_G_ROUTING, &rt);\n+\tif (ret == 0 || ret == -ENOTTY)\n+\t\treturn ret;\n+\n+\tif (ret != -ENOSPC) {\n+\t\tLOG(V4L2, Error)\n+\t\t\t<< \"Failed to retrieve number of routes: \"\n+\t\t\t<< strerror(-ret);\n+\t\treturn ret;\n+\t}\n+\n+\trouting->resize(rt.num_routes);\n+\trt.routes = reinterpret_cast<uintptr_t>(routing->data());\n+\n+\tret = ioctl(VIDIOC_SUBDEV_G_ROUTING, &rt);\n+\tif (ret) {\n+\t\tLOG(V4L2, Error)\n+\t\t\t<< \"Failed to retrieve routes: \" << strerror(-ret);\n+\t\treturn ret;\n+\t}\n+\n+\tif (rt.num_routes != routing->size()) {\n+\t\tLOG(V4L2, Error) << \"Invalid number of routes\";\n+\t\treturn -EINVAL;\n+\t}\n+\n+\treturn 0;\n+}\n+\n+/**\n+ * \\brief Set a routing table on the V4L2 subdevice\n+ * \\param[inout] routing The routing table\n+ * \\param[in] whence The routing table to set, \\ref V4L2Subdevice::ActiveFormat\n+ * \"ActiveFormat\" or \\ref V4L2Subdevice::TryFormat \"TryFormat\"\n+ *\n+ * Apply to the V4L2 subdevice the routing table \\a routing and update its\n+ * content to reflect the actually applied routing table as getRouting() would\n+ * do.\n+ *\n+ * \\return 0 on success or a negative error code otherwise\n+ */\n+int V4L2Subdevice::setRouting(Routing *routing, Whence whence)\n+{\n+\tif (!caps_.hasStreams())\n+\t\treturn 0;\n+\n+\tstruct v4l2_subdev_routing rt = {};\n+\trt.which = whence;\n+\trt.num_routes = routing->size();\n+\trt.routes = reinterpret_cast<uintptr_t>(routing->data());\n+\n+\tint ret = ioctl(VIDIOC_SUBDEV_S_ROUTING, &rt);\n+\tif (ret) {\n+\t\tLOG(V4L2, Error) << \"Failed to set routes: \" << strerror(-ret);\n+\t\treturn ret;\n+\t}\n+\n+\trouting->resize(rt.num_routes);\n+\n+\treturn 0;\n+}\n+\n /**\n  * \\brief Retrieve the model name of the device\n  *\n",
    "prefixes": [
        "libcamera-devel",
        "08/13"
    ]
}