Show a patch.

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

{
    "id": 491,
    "url": "https://patchwork.libcamera.org/api/patches/491/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/491/",
    "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": "<20190203110102.5663-5-kieran.bingham@ideasonboard.com>",
    "date": "2019-02-03T11:00:55",
    "name": "[libcamera-devel,04/11] libcamera: v4l2_device: Support exporting buffers",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "9e2d2bafdf146a699b022b1d3eecd262ca5e2238",
    "submitter": {
        "id": 4,
        "url": "https://patchwork.libcamera.org/api/people/4/?format=api",
        "name": "Kieran Bingham",
        "email": "kieran.bingham@ideasonboard.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/491/mbox/",
    "series": [
        {
            "id": 165,
            "url": "https://patchwork.libcamera.org/api/series/165/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=165",
            "date": "2019-02-03T11:00:51",
            "name": "libcamera: V4L2 Streams",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/165/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/491/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/491/checks/",
    "tags": {},
    "headers": {
        "Return-Path": "<kieran.bingham@ideasonboard.com>",
        "Received": [
            "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 AEF0260B1B\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun,  3 Feb 2019 12:01:07 +0100 (CET)",
            "from localhost.localdomain\n\t(218.182-78-194.adsl-static.isp.belgacom.be [194.78.182.218])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 5B4BFD4B;\n\tSun,  3 Feb 2019 12:01:07 +0100 (CET)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1549191667;\n\tbh=ApbnUKVZtAMnEj3TtinpMY7Bpb+TnV7zi2Y0DX8u63s=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=D39BaXHSADMjrhNtQt/oaCJAsLYGcVq9GQ4Fgty9zCUnBoHonPlrn8bQB9ELWjOk9\n\tA30v9jq4RugIEA36XvRiKELVlykuWcp5jzYSuGJaaYgkLPIml9aiLtkw/Nvo1E11Xy\n\tJbcVYtGaKvCK44EOA5ISDRF465VBfav0XtTpVdNE=",
        "From": "Kieran Bingham <kieran.bingham@ideasonboard.com>",
        "To": "LibCamera Devel <libcamera-devel@lists.libcamera.org>",
        "Date": "Sun,  3 Feb 2019 12:00:55 +0100",
        "Message-Id": "<20190203110102.5663-5-kieran.bingham@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.19.1",
        "In-Reply-To": "<20190203110102.5663-1-kieran.bingham@ideasonboard.com>",
        "References": "<20190203110102.5663-1-kieran.bingham@ideasonboard.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH 04/11] libcamera: v4l2_device: Support\n\texporting buffers",
        "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": "Sun, 03 Feb 2019 11:01:07 -0000"
    },
    "content": "Implement the VIDIOC_EXPBUF functionality allowing our buffers to be exported\nto other V4L2Device objects.\n\nExport buffers when they are allocated during a call to requestBuffers()\n\nSigned-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n---\n src/libcamera/include/v4l2_device.h |  2 +\n src/libcamera/v4l2_device.cpp       | 59 +++++++++++++++++++++++++++++\n 2 files changed, 61 insertions(+)",
    "diff": "diff --git a/src/libcamera/include/v4l2_device.h b/src/libcamera/include/v4l2_device.h\nindex 6599ce2d761c..f445f98f97a4 100644\n--- a/src/libcamera/include/v4l2_device.h\n+++ b/src/libcamera/include/v4l2_device.h\n@@ -109,6 +109,8 @@ private:\n \tint setFormatMultiplane(V4L2DeviceFormat *fmt);\n \n \tint requestBuffers(unsigned int qty, std::vector<Buffer *> &buffers);\n+\tint exportBuffer(Buffer *buffer);\n+\tint exportBuffers(BufferPool *pool);\n \n \tstd::string deviceNode_;\n \tint fd_;\ndiff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp\nindex 8bcd8bbc34f6..728478a1ae8f 100644\n--- a/src/libcamera/v4l2_device.cpp\n+++ b/src/libcamera/v4l2_device.cpp\n@@ -340,6 +340,13 @@ BufferPool *V4L2Device::requestBuffers(unsigned int qty)\n \t\treturn nullptr;\n \t}\n \n+\tret = exportBuffers(bufferPool_);\n+\tif (ret) {\n+\t\tdelete bufferPool_;\n+\t\tbufferPool_ = nullptr;\n+\t\treturn nullptr;\n+\t}\n+\n \treturn bufferPool_;\n }\n \n@@ -414,6 +421,58 @@ int V4L2Device::requestBuffers(unsigned int qty, std::vector<Buffer *> &buffers)\n \treturn 0;\n }\n \n+int V4L2Device::exportBuffer(Buffer *buffer)\n+{\n+\tunsigned int i = 0;\n+\tfor (Plane *plane : buffer->planes()) {\n+\t\tstruct v4l2_exportbuffer expbuf = {};\n+\t\tint ret;\n+\n+\t\texpbuf.type = bufferType_;\n+\t\texpbuf.index = buffer->index();\n+\t\texpbuf.plane = i++;\n+\n+\t\tret = ioctl(fd_, VIDIOC_EXPBUF, &expbuf);\n+\t\tif (ret < 0) {\n+\t\t\tret = -errno;\n+\t\t\tLOG(V4L2, Error)\n+\t\t\t\t<< \"Failed to export buffer: \" << strerror(-ret);\n+\t\t\treturn ret;\n+\t\t}\n+\n+\t\tplane->setDmabuf(expbuf.fd);\n+\t}\n+\n+\treturn 0;\n+}\n+\n+int V4L2Device::exportBuffers(BufferPool *pool)\n+{\n+\tfor (Buffer *buffer : pool->buffers()) {\n+\t\tint ret = exportBuffer(buffer);\n+\t\tif (ret)\n+\t\t\treturn ret;\n+\n+\t\t/**\n+\t\t * \\todo: Remove this mmap\n+\t\t * It is a temporary work around to have all internal buffers\n+\t\t * mapped for early development.\n+\t\t *\n+\t\t * Applications will be expected to map buffers if necessary.\n+\t\t */\n+\t\tret = buffer->mmap();\n+\t\tif (ret) {\n+\t\t\tret = -errno;\n+\t\t\tLOG(V4L2, Error)\n+\t\t\t\t<< \"Failed to mmap a buffer instance: \"\n+\t\t\t\t<< strerror(-ret);\n+\t\t\treturn ret;\n+\t\t}\n+\t}\n+\n+\treturn 0;\n+}\n+\n /**\n  * \\brief Retrieve the image format set on the V4L2 device\n  * \\return 0 for success, a negative error code otherwise\n",
    "prefixes": [
        "libcamera-devel",
        "04/11"
    ]
}