Show a patch.

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

{
    "id": 545,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/545/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/545/",
    "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": "<20190207212119.30299-3-kieran.bingham@ideasonboard.com>",
    "date": "2019-02-07T21:21:16",
    "name": "[libcamera-devel,2/5] libcamera: v4l2_device: importBuffers support",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "50e12381d039f29539bd7dd0a97a34c9eef6a296",
    "submitter": {
        "id": 4,
        "url": "https://patchwork.libcamera.org/api/1.1/people/4/?format=api",
        "name": "Kieran Bingham",
        "email": "kieran.bingham@ideasonboard.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/545/mbox/",
    "series": [
        {
            "id": 171,
            "url": "https://patchwork.libcamera.org/api/1.1/series/171/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=171",
            "date": "2019-02-07T21:21:14",
            "name": "libcamera: Buffer Sharing",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/171/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/545/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/545/checks/",
    "tags": {},
    "headers": {
        "Return-Path": "<kieran.bingham@ideasonboard.com>",
        "Received": [
            "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 8665E610B2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu,  7 Feb 2019 22:21:29 +0100 (CET)",
            "from localhost.localdomain (unknown [149.254.234.206])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 73D7DF9;\n\tThu,  7 Feb 2019 22:21:28 +0100 (CET)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1549574489;\n\tbh=qZWhhbD8CZDP5thj16LSwckC4h6VnN9+WbOXIs/ZKqA=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=lNgrc/UZv539RHyA/lJdrG7NShksWeOM6ZSe7de5GxpPuTBpcrUtzJ5TcdOaA+xPM\n\tsCb87pMzGpYg/jQ7dpTDu4evpVIipzc4wkVlLbml9pscPULRfblW+wnLFa2b82JgLa\n\tKMGXHIlZiyAK61TXxo/X0QgHsdHIpME1ioN6mgd0=",
        "From": "Kieran Bingham <kieran.bingham@ideasonboard.com>",
        "To": "LibCamera Devel <libcamera-devel@lists.libcamera.org>",
        "Date": "Thu,  7 Feb 2019 21:21:16 +0000",
        "Message-Id": "<20190207212119.30299-3-kieran.bingham@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.19.1",
        "In-Reply-To": "<20190207212119.30299-1-kieran.bingham@ideasonboard.com>",
        "References": "<20190207212119.30299-1-kieran.bingham@ideasonboard.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH 2/5] libcamera: v4l2_device: importBuffers\n\tsupport",
        "X-BeenThere": "libcamera-devel@lists.libcamera.org",
        "X-Mailman-Version": "2.1.23",
        "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>",
        "X-List-Received-Date": "Thu, 07 Feb 2019 21:21:29 -0000"
    },
    "content": "Provide the ability to import a BufferPool into the V4L2Device allowing\nexternal dmabuf backed buffers to be queued.\n\nSigned-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n---\n src/libcamera/include/v4l2_device.h |  1 +\n src/libcamera/v4l2_device.cpp       | 45 ++++++++++++++++++++++++++++-\n 2 files changed, 45 insertions(+), 1 deletion(-)",
    "diff": "diff --git a/src/libcamera/include/v4l2_device.h b/src/libcamera/include/v4l2_device.h\nindex 988e646c5de1..3acb5e466d64 100644\n--- a/src/libcamera/include/v4l2_device.h\n+++ b/src/libcamera/include/v4l2_device.h\n@@ -98,6 +98,7 @@ public:\n \tint setFormat(V4L2DeviceFormat *format);\n \n \tint exportBuffers(unsigned int count, BufferPool *pool);\n+\tint importBuffers(BufferPool *pool);\n \tint releaseBuffers();\n \n \tint queueBuffer(Buffer *buffer);\ndiff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp\nindex 64325ff9f5d9..c654e6dd7b8d 100644\n--- a/src/libcamera/v4l2_device.cpp\n+++ b/src/libcamera/v4l2_device.cpp\n@@ -633,6 +633,36 @@ int V4L2Device::createPlane(Buffer *buffer, unsigned int planeIndex,\n \treturn 0;\n }\n \n+/**\n+ * \\brief Import the externally allocated \\a pool of buffers\n+ * \\param[in] pool BufferPool of buffers to import\n+ * \\return 0 on success or a negative error code otherwise\n+ */\n+int V4L2Device::importBuffers(BufferPool *pool)\n+{\n+\tunsigned int allocatedBuffers;\n+\tint ret;\n+\n+\tmemoryType_ = V4L2_MEMORY_DMABUF;\n+\n+\tret = requestBuffers(pool->count());\n+\tif (ret < 0)\n+\t\treturn ret;\n+\n+\tallocatedBuffers = ret;\n+\tif (allocatedBuffers < pool->count()) {\n+\t\tLOG(V4L2, Error)\n+\t\t\t<< \"Not enough buffers provided by V4L2Device\";\n+\t\trequestBuffers(0);\n+\t\treturn -ENOMEM;\n+\t}\n+\n+\tLOG(V4L2, Debug) << \"Device using an externally provided pool\";\n+\tbufferPool_ = pool;\n+\n+\treturn 0;\n+}\n+\n /**\n  * \\brief Release all internally allocated buffers\n  */\n@@ -670,7 +700,20 @@ int V4L2Device::queueBuffer(Buffer *buffer)\n \tbuf.type = bufferType_;\n \tbuf.memory = memoryType_;\n \n-\tif (V4L2_TYPE_IS_MULTIPLANAR(buf.type)) {\n+\tbool multiPlanar = V4L2_TYPE_IS_MULTIPLANAR(buf.type);\n+\n+\tif (buf.memory == V4L2_MEMORY_DMABUF) {\n+\t\tif (multiPlanar) {\n+\t\t\tfor (unsigned int p = 0;\n+\t\t\t     p < buffer->planes().size();\n+\t\t\t     p++)\n+\t\t\t\tplanes[p].m.fd = buffer->planes()[p].dmabuf();\n+\t\t} else {\n+\t\t\tbuf.m.fd = buffer->planes()[0].dmabuf();\n+\t\t}\n+\t}\n+\n+\tif (multiPlanar) {\n \t\tbuf.length = buffer->planes().size();\n \t\tbuf.m.planes = planes;\n \t}\n",
    "prefixes": [
        "libcamera-devel",
        "2/5"
    ]
}