Show a patch.

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

{
    "id": 2596,
    "url": "https://patchwork.libcamera.org/api/patches/2596/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/2596/",
    "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": "<20200112010212.2609025-15-niklas.soderlund@ragnatech.se>",
    "date": "2020-01-12T01:01:54",
    "name": "[libcamera-devel,v4,14/32] libcamera: v4l2_videodevice: Extract exportDmabufFd()",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "c120b0bee673f3ed476a3dc94568c2049ec1c985",
    "submitter": {
        "id": 5,
        "url": "https://patchwork.libcamera.org/api/people/5/?format=api",
        "name": "Niklas Söderlund",
        "email": "niklas.soderlund@ragnatech.se"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/2596/mbox/",
    "series": [
        {
            "id": 617,
            "url": "https://patchwork.libcamera.org/api/series/617/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=617",
            "date": "2020-01-12T01:01:40",
            "name": "libcamera: Rework buffer API",
            "version": 4,
            "mbox": "https://patchwork.libcamera.org/series/617/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/2596/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/2596/checks/",
    "tags": {},
    "headers": {
        "Return-Path": "<niklas.soderlund@ragnatech.se>",
        "Received": [
            "from vsp-unauthed02.binero.net (vsp-unauthed02.binero.net\n\t[195.74.38.227])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id CEFC7606D6\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 12 Jan 2020 02:03:09 +0100 (CET)",
            "from bismarck.berto.se (p54ac5d7b.dip0.t-ipconnect.de\n\t[84.172.93.123]) by bin-vsp-out-02.atm.binero.net (Halon) with ESMTPA\n\tid 4a600745-34d7-11ea-b6d8-005056917f90;\n\tSun, 12 Jan 2020 02:03:06 +0100 (CET)"
        ],
        "X-Halon-ID": "4a600745-34d7-11ea-b6d8-005056917f90",
        "Authorized-sender": "niklas@soderlund.pp.se",
        "From": "=?utf-8?q?Niklas_S=C3=B6derlund?= <niklas.soderlund@ragnatech.se>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Sun, 12 Jan 2020 02:01:54 +0100",
        "Message-Id": "<20200112010212.2609025-15-niklas.soderlund@ragnatech.se>",
        "X-Mailer": "git-send-email 2.24.1",
        "In-Reply-To": "<20200112010212.2609025-1-niklas.soderlund@ragnatech.se>",
        "References": "<20200112010212.2609025-1-niklas.soderlund@ragnatech.se>",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain; charset=UTF-8",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH v4 14/32] libcamera: v4l2_videodevice:\n\tExtract exportDmabufFd()",
        "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>",
        "X-List-Received-Date": "Sun, 12 Jan 2020 01:03:10 -0000"
    },
    "content": "The part in createPlane() that exports a dma buffer from a video device\nwill be used directly by the FrameBuffer interface. Break it out to a\nseparate function.\n\nSigned-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\nReviewed-by: Jacopo Mondi <jacopo@jmondi.org>\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n* Changes since v3\n- Make exportDmabufFd() return a FileDescriptor\n\n* Changes since v1\n- Rename exportDmaBuffer() to exportDmabufFd()\n---\n src/libcamera/include/v4l2_videodevice.h |  2 ++\n src/libcamera/v4l2_videodevice.cpp       | 42 +++++++++++++++---------\n 2 files changed, 28 insertions(+), 16 deletions(-)",
    "diff": "diff --git a/src/libcamera/include/v4l2_videodevice.h b/src/libcamera/include/v4l2_videodevice.h\nindex fdf11b3a6ec9b702..27ec77cdcc3c07ff 100644\n--- a/src/libcamera/include/v4l2_videodevice.h\n+++ b/src/libcamera/include/v4l2_videodevice.h\n@@ -26,6 +26,7 @@ class Buffer;\n class BufferMemory;\n class BufferPool;\n class EventNotifier;\n+class FileDescriptor;\n class MediaDevice;\n class MediaEntity;\n \n@@ -179,6 +180,7 @@ private:\n \tint requestBuffers(unsigned int count);\n \tint createPlane(BufferMemory *buffer, unsigned int index,\n \t\t\tunsigned int plane, unsigned int length);\n+\tFileDescriptor exportDmabufFd(unsigned int index, unsigned int plane);\n \n \tBuffer *dequeueBuffer();\n \tvoid bufferAvailable(EventNotifier *notifier);\ndiff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp\nindex 81d999e354a16bd0..4551484cfbf8c6ef 100644\n--- a/src/libcamera/v4l2_videodevice.cpp\n+++ b/src/libcamera/v4l2_videodevice.cpp\n@@ -22,6 +22,7 @@\n \n #include <libcamera/buffer.h>\n #include <libcamera/event_notifier.h>\n+#include <libcamera/file_descriptor.h>\n \n #include \"log.h\"\n #include \"media_device.h\"\n@@ -902,31 +903,19 @@ int V4L2VideoDevice::exportBuffers(BufferPool *pool)\n int V4L2VideoDevice::createPlane(BufferMemory *buffer, unsigned int index,\n \t\t\t\t unsigned int planeIndex, unsigned int length)\n {\n-\tstruct v4l2_exportbuffer expbuf = {};\n-\tint ret;\n-\n \tLOG(V4L2, Debug)\n \t\t<< \"Buffer \" << index\n \t\t<< \" plane \" << planeIndex\n \t\t<< \": length=\" << length;\n \n-\texpbuf.type = bufferType_;\n-\texpbuf.index = index;\n-\texpbuf.plane = planeIndex;\n-\texpbuf.flags = O_RDWR;\n-\n-\tret = ioctl(VIDIOC_EXPBUF, &expbuf);\n-\tif (ret < 0) {\n-\t\tLOG(V4L2, Error)\n-\t\t\t<< \"Failed to export buffer: \" << strerror(-ret);\n-\t\treturn ret;\n-\t}\n+\tFileDescriptor fd = exportDmabufFd(index, planeIndex);\n+\tif (!fd.isValid())\n+\t\treturn -EINVAL;\n \n \tFrameBuffer::Plane plane;\n-\tplane.fd = FileDescriptor(expbuf.fd);\n+\tplane.fd = fd;\n \tplane.length = length;\n \tbuffer->planes().push_back(plane);\n-\t::close(expbuf.fd);\n \n \treturn 0;\n }\n@@ -952,6 +941,27 @@ int V4L2VideoDevice::importBuffers(BufferPool *pool)\n \treturn 0;\n }\n \n+FileDescriptor V4L2VideoDevice::exportDmabufFd(unsigned int index,\n+\t\t\t\t\t       unsigned int plane)\n+{\n+\tstruct v4l2_exportbuffer expbuf = {};\n+\tint ret;\n+\n+\texpbuf.type = bufferType_;\n+\texpbuf.index = index;\n+\texpbuf.plane = plane;\n+\texpbuf.flags = O_RDWR;\n+\n+\tret = ioctl(VIDIOC_EXPBUF, &expbuf);\n+\tif (ret < 0) {\n+\t\tLOG(V4L2, Error)\n+\t\t\t<< \"Failed to export buffer: \" << strerror(-ret);\n+\t\treturn FileDescriptor();\n+\t}\n+\n+\treturn FileDescriptor(expbuf.fd);\n+}\n+\n /**\n  * \\brief Release all internally allocated buffers\n  */\n",
    "prefixes": [
        "libcamera-devel",
        "v4",
        "14/32"
    ]
}