Show a patch.

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

{
    "id": 14829,
    "url": "https://patchwork.libcamera.org/api/patches/14829/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/14829/",
    "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": "<20211128235752.10836-15-laurent.pinchart@ideasonboard.com>",
    "date": "2021-11-28T23:57:49",
    "name": "[libcamera-devel,v3,14/17] libcamera: v4l2_videodevice: Use fd for a file descriptor",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "e27e5c8d798795b083ac191c232cd485accaec22",
    "submitter": {
        "id": 2,
        "url": "https://patchwork.libcamera.org/api/people/2/?format=api",
        "name": "Laurent Pinchart",
        "email": "laurent.pinchart@ideasonboard.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/14829/mbox/",
    "series": [
        {
            "id": 2768,
            "url": "https://patchwork.libcamera.org/api/series/2768/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=2768",
            "date": "2021-11-28T23:57:35",
            "name": "libcamera: Introduce UniqueFD",
            "version": 3,
            "mbox": "https://patchwork.libcamera.org/series/2768/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/14829/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/14829/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 2E727C3250\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSun, 28 Nov 2021 23:58:40 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id CF2576058C;\n\tMon, 29 Nov 2021 00:58:39 +0100 (CET)",
            "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 7422C6057D\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 29 Nov 2021 00:58:27 +0100 (CET)",
            "from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 0C71BA15;\n\tMon, 29 Nov 2021 00:58:26 +0100 (CET)"
        ],
        "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=\"i67FNUtK\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1638143907;\n\tbh=KBY2NLCMmHFAHDrxRe2w0oriPC6HklA1vo1zPN9Yn4w=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=i67FNUtKOJA/v3b1pe7I3otlBQbwtTjuHGYBrrSZzRZ/RFxJznACG427/Sq+ZCr34\n\tbNz2A9BTeIETVL6ubO2RNwUqPVis9b0TlNpeZKISmd52KOg2vCGMpLVVeyjQSG6rwX\n\tgxM3iipHNEDSdxt+SlzVw5H8RWKyokWovpmYfIaE=",
        "From": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Mon, 29 Nov 2021 01:57:49 +0200",
        "Message-Id": "<20211128235752.10836-15-laurent.pinchart@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.32.0",
        "In-Reply-To": "<20211128235752.10836-1-laurent.pinchart@ideasonboard.com>",
        "References": "<20211128235752.10836-1-laurent.pinchart@ideasonboard.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH v3 14/17] libcamera: v4l2_videodevice: Use\n\tfd for a file descriptor",
        "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": "From: Hirokazu Honda <hiroh@chromium.org>\n\nManages file descriptors owned by V4L2VideoDevice by UniqueFD.\nThis also changes the return type of exportDmabufFd to UniqueFD\nfrom FileDescriptor in order to represent a caller owns the\nreturned file file descriptor.\n\nSigned-off-by: Hirokazu Honda <hiroh@chromium.org>\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\nChanges since v2:\n\n- Use FileDescriptor(UniqueFD &&) constructor\n- Fix errno handling\n- Return {}\n---\n include/libcamera/internal/v4l2_videodevice.h |  4 +--\n src/libcamera/v4l2_videodevice.cpp            | 30 ++++++++-----------\n 2 files changed, 15 insertions(+), 19 deletions(-)",
    "diff": "diff --git a/include/libcamera/internal/v4l2_videodevice.h b/include/libcamera/internal/v4l2_videodevice.h\nindex 4a44b7fd53b1..80b665771782 100644\n--- a/include/libcamera/internal/v4l2_videodevice.h\n+++ b/include/libcamera/internal/v4l2_videodevice.h\n@@ -19,6 +19,7 @@\n #include <libcamera/base/class.h>\n #include <libcamera/base/log.h>\n #include <libcamera/base/signal.h>\n+#include <libcamera/base/unique_fd.h>\n \n #include <libcamera/framebuffer.h>\n #include <libcamera/geometry.h>\n@@ -31,7 +32,6 @@\n namespace libcamera {\n \n class EventNotifier;\n-class FileDescriptor;\n class MediaDevice;\n class MediaEntity;\n \n@@ -238,7 +238,7 @@ private:\n \tint createBuffers(unsigned int count,\n \t\t\t  std::vector<std::unique_ptr<FrameBuffer>> *buffers);\n \tstd::unique_ptr<FrameBuffer> createBuffer(unsigned int index);\n-\tFileDescriptor exportDmabufFd(unsigned int index, unsigned int plane);\n+\tUniqueFD exportDmabufFd(unsigned int index, unsigned int plane);\n \n \tvoid bufferAvailable();\n \tFrameBuffer *dequeueBuffer();\ndiff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp\nindex c95626d33cc3..3966483a365f 100644\n--- a/src/libcamera/v4l2_videodevice.cpp\n+++ b/src/libcamera/v4l2_videodevice.cpp\n@@ -1320,12 +1320,12 @@ std::unique_ptr<FrameBuffer> V4L2VideoDevice::createBuffer(unsigned int index)\n \n \tstd::vector<FrameBuffer::Plane> planes;\n \tfor (unsigned int nplane = 0; nplane < numPlanes; nplane++) {\n-\t\tFileDescriptor fd = exportDmabufFd(buf.index, nplane);\n+\t\tUniqueFD fd = exportDmabufFd(buf.index, nplane);\n \t\tif (!fd.isValid())\n \t\t\treturn nullptr;\n \n \t\tFrameBuffer::Plane plane;\n-\t\tplane.fd = std::move(fd);\n+\t\tplane.fd = FileDescriptor(std::move(fd));\n \t\t/*\n \t\t * V4L2 API doesn't provide dmabuf offset information of plane.\n \t\t * Set 0 as a placeholder offset.\n@@ -1380,8 +1380,8 @@ std::unique_ptr<FrameBuffer> V4L2VideoDevice::createBuffer(unsigned int index)\n \treturn std::make_unique<FrameBuffer>(planes);\n }\n \n-FileDescriptor V4L2VideoDevice::exportDmabufFd(unsigned int index,\n-\t\t\t\t\t       unsigned int plane)\n+UniqueFD V4L2VideoDevice::exportDmabufFd(unsigned int index,\n+\t\t\t\t\t unsigned int plane)\n {\n \tstruct v4l2_exportbuffer expbuf = {};\n \tint ret;\n@@ -1395,10 +1395,10 @@ FileDescriptor V4L2VideoDevice::exportDmabufFd(unsigned int index,\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\treturn {};\n \t}\n \n-\treturn FileDescriptor(std::move(expbuf.fd));\n+\treturn UniqueFD(expbuf.fd);\n }\n \n /**\n@@ -1896,7 +1896,6 @@ V4L2M2MDevice::~V4L2M2MDevice()\n  */\n int V4L2M2MDevice::open()\n {\n-\tint fd;\n \tint ret;\n \n \t/*\n@@ -1905,30 +1904,27 @@ int V4L2M2MDevice::open()\n \t * as the V4L2VideoDevice::open() retains a handle by duplicating the\n \t * fd passed in.\n \t */\n-\tfd = syscall(SYS_openat, AT_FDCWD, deviceNode_.c_str(),\n-\t\t     O_RDWR | O_NONBLOCK);\n-\tif (fd < 0) {\n+\tUniqueFD fd(syscall(SYS_openat, AT_FDCWD, deviceNode_.c_str(),\n+\t\t\t    O_RDWR | O_NONBLOCK));\n+\tif (!fd.isValid()) {\n \t\tret = -errno;\n-\t\tLOG(V4L2, Error)\n-\t\t\t<< \"Failed to open V4L2 M2M device: \" << strerror(-ret);\n+\t\tLOG(V4L2, Error) << \"Failed to open V4L2 M2M device: \"\n+\t\t\t\t << strerror(-ret);\n \t\treturn ret;\n \t}\n \n-\tret = output_->open(fd, V4L2_BUF_TYPE_VIDEO_OUTPUT);\n+\tret = output_->open(fd.get(), V4L2_BUF_TYPE_VIDEO_OUTPUT);\n \tif (ret)\n \t\tgoto err;\n \n-\tret = capture_->open(fd, V4L2_BUF_TYPE_VIDEO_CAPTURE);\n+\tret = capture_->open(fd.get(), V4L2_BUF_TYPE_VIDEO_CAPTURE);\n \tif (ret)\n \t\tgoto err;\n \n-\t::close(fd);\n-\n \treturn 0;\n \n err:\n \tclose();\n-\t::close(fd);\n \n \treturn ret;\n }\n",
    "prefixes": [
        "libcamera-devel",
        "v3",
        "14/17"
    ]
}