{"id":2575,"url":"https://patchwork.libcamera.org/api/1.1/patches/2575/?format=json","web_url":"https://patchwork.libcamera.org/patch/2575/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20200110193808.2266294-29-niklas.soderlund@ragnatech.se>","date":"2020-01-10T19:38:03","name":"[libcamera-devel,v3,28/33] libcamera: v4l2_videodevice: Use FileDescriptor where appropriate","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"e6b689e6ee0666172e82be4fa52461117d8ad5d0","submitter":{"id":5,"url":"https://patchwork.libcamera.org/api/1.1/people/5/?format=json","name":"Niklas Söderlund","email":"niklas.soderlund@ragnatech.se"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/2575/mbox/","series":[{"id":615,"url":"https://patchwork.libcamera.org/api/1.1/series/615/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=615","date":"2020-01-10T19:37:35","name":"libcamera: Rework buffer API","version":3,"mbox":"https://patchwork.libcamera.org/series/615/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/2575/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/2575/checks/","tags":{},"headers":{"Return-Path":"<niklas.soderlund@ragnatech.se>","Received":["from bin-mail-out-06.binero.net (bin-mail-out-06.binero.net\n\t[195.74.38.229])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 636C66069A\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 10 Jan 2020 20:39:07 +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 daa4d8a3-33e0-11ea-b6d8-005056917f90;\n\tFri, 10 Jan 2020 20:39:03 +0100 (CET)"],"X-Halon-ID":"daa4d8a3-33e0-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":"Fri, 10 Jan 2020 20:38:03 +0100","Message-Id":"<20200110193808.2266294-29-niklas.soderlund@ragnatech.se>","X-Mailer":"git-send-email 2.24.1","In-Reply-To":"<20200110193808.2266294-1-niklas.soderlund@ragnatech.se>","References":"<20200110193808.2266294-1-niklas.soderlund@ragnatech.se>","MIME-Version":"1.0","Content-Type":"text/plain; charset=UTF-8","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v3 28/33] libcamera: v4l2_videodevice: Use\n\tFileDescriptor where appropriate","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":"Fri, 10 Jan 2020 19:39:07 -0000"},"content":"From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\nReturn a FileDescriptor instead of a numerical fd from exportDmabufFd().\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nReviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n---\n src/libcamera/include/v4l2_videodevice.h |  2 +-\n src/libcamera/v4l2_videodevice.cpp       | 14 ++++++--------\n 2 files changed, 7 insertions(+), 9 deletions(-)","diff":"diff --git a/src/libcamera/include/v4l2_videodevice.h b/src/libcamera/include/v4l2_videodevice.h\nindex 6959b87a35496b9a..172d670c328b2345 100644\n--- a/src/libcamera/include/v4l2_videodevice.h\n+++ b/src/libcamera/include/v4l2_videodevice.h\n@@ -217,7 +217,7 @@ private:\n \n \tint requestBuffers(unsigned int count);\n \tstd::unique_ptr<FrameBuffer> createBuffer(const struct v4l2_buffer &buf);\n-\tint exportDmabufFd(unsigned int index, unsigned int plane);\n+\tFileDescriptor exportDmabufFd(unsigned int index, unsigned int plane);\n \n \tvoid bufferAvailable(EventNotifier *notifier);\n \tFrameBuffer *dequeueBuffer();\ndiff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp\nindex 59a6d1b5537d776f..c0381d3980063799 100644\n--- a/src/libcamera/v4l2_videodevice.cpp\n+++ b/src/libcamera/v4l2_videodevice.cpp\n@@ -1041,24 +1041,22 @@ V4L2VideoDevice::createBuffer(const struct v4l2_buffer &buf)\n \n \tstd::vector<FrameBuffer::Plane> planes;\n \tfor (unsigned int nplane = 0; nplane < numPlanes; nplane++) {\n-\t\tint fd = exportDmabufFd(buf.index, nplane);\n-\t\tif (fd < 0)\n+\t\tFileDescriptor fd = exportDmabufFd(buf.index, nplane);\n+\t\tif (fd.fd() < 0)\n \t\t\treturn nullptr;\n \n \t\tFrameBuffer::Plane plane;\n-\t\tplane.fd = FileDescriptor(fd);\n+\t\tplane.fd = std::move(fd);\n \t\tplane.length = multiPlanar ?\n \t\t\tbuf.m.planes[nplane].length : buf.length;\n \n \t\tplanes.push_back(std::move(plane));\n-\n-\t\t::close(fd);\n \t}\n \n \treturn utils::make_unique<FrameBuffer>(std::move(planes));\n }\n \n-int V4L2VideoDevice::exportDmabufFd(unsigned int index, unsigned int plane)\n+FileDescriptor V4L2VideoDevice::exportDmabufFd(unsigned int index, unsigned int plane)\n {\n \tstruct v4l2_exportbuffer expbuf = {};\n \tint ret;\n@@ -1072,10 +1070,10 @@ int V4L2VideoDevice::exportDmabufFd(unsigned int index, unsigned int plane)\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\treturn FileDescriptor();\n \t}\n \n-\treturn expbuf.fd;\n+\treturn FileDescriptor(expbuf.fd);\n }\n \n /**\n","prefixes":["libcamera-devel","v3","28/33"]}