{"id":14873,"url":"https://patchwork.libcamera.org/api/patches/14873/?format=json","web_url":"https://patchwork.libcamera.org/patch/14873/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/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":"<20211130033820.18235-19-laurent.pinchart@ideasonboard.com>","date":"2021-11-30T03:38:16","name":"[libcamera-devel,v4,18/22] v4l2: v4l2_camera: Return int in getBufferFd()","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"fbbf9d57c2e92c2a17e8ad248ae865413e2b6d2b","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/?format=json","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/14873/mbox/","series":[{"id":2776,"url":"https://patchwork.libcamera.org/api/series/2776/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=2776","date":"2021-11-30T03:37:58","name":"libcamera: Introduce UniqueFD","version":4,"mbox":"https://patchwork.libcamera.org/series/2776/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/14873/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/14873/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 96EC4C3253\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 30 Nov 2021 03:39:14 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 3FB57605CA;\n\tTue, 30 Nov 2021 04:39:14 +0100 (CET)","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 0B518605BC\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 30 Nov 2021 04:38:57 +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 8A48111C5; \n\tTue, 30 Nov 2021 04:38:56 +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=\"CFRLrV07\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1638243536;\n\tbh=lPfrrY2+CW6tNC+uPjP/b4CBUIae3kP/El/iB512rdU=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=CFRLrV07tt/qMYIuniPW0CbNtScwrDuQTRv4wcB5zM31tVo3Foi7bL2QVZxenfAIo\n\tvGHhUxQDQTgbUpsdh44HAfzoyDIBKjN2WCclRSzqB7UQqG3TkSv4dUmSnj8qHKJtbl\n\tSCLeO3EGj7wJt0q5h4sUyAPccAQorrLzPGW5y3dE=","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Tue, 30 Nov 2021 05:38:16 +0200","Message-Id":"<20211130033820.18235-19-laurent.pinchart@ideasonboard.com>","X-Mailer":"git-send-email 2.32.0","In-Reply-To":"<20211130033820.18235-1-laurent.pinchart@ideasonboard.com>","References":"<20211130033820.18235-1-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v4 18/22] v4l2: v4l2_camera: Return int in\n\tgetBufferFd()","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\nV4L2Camera::getBufferFd() returns FileDescriptor. However, the\nfile descriptor is still owned by V4L2Camera. It should rather\nreturn an integer to represent V4L2Camera doesn't have the\nownership of the file descriptor.\n\nSigned-off-by: Hirokazu Honda <hiroh@chromium.org>\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nReviewed-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n src/v4l2/v4l2_camera.cpp       | 6 +++---\n src/v4l2/v4l2_camera.h         | 2 +-\n src/v4l2/v4l2_camera_proxy.cpp | 6 +++---\n 3 files changed, 7 insertions(+), 7 deletions(-)","diff":"diff --git a/src/v4l2/v4l2_camera.cpp b/src/v4l2/v4l2_camera.cpp\nindex 157ab94e0544..464507505c79 100644\n--- a/src/v4l2/v4l2_camera.cpp\n+++ b/src/v4l2/v4l2_camera.cpp\n@@ -186,16 +186,16 @@ void V4L2Camera::freeBuffers()\n \tbufferAllocator_->free(stream);\n }\n \n-FileDescriptor V4L2Camera::getBufferFd(unsigned int index)\n+int V4L2Camera::getBufferFd(unsigned int index)\n {\n \tStream *stream = config_->at(0).stream();\n \tconst std::vector<std::unique_ptr<FrameBuffer>> &buffers =\n \t\tbufferAllocator_->buffers(stream);\n \n \tif (buffers.size() <= index)\n-\t\treturn FileDescriptor();\n+\t\treturn -1;\n \n-\treturn buffers[index]->planes()[0].fd;\n+\treturn buffers[index]->planes()[0].fd.fd();\n }\n \n int V4L2Camera::streamOn()\ndiff --git a/src/v4l2/v4l2_camera.h b/src/v4l2/v4l2_camera.h\nindex 0cea111561dd..9817fd393d59 100644\n--- a/src/v4l2/v4l2_camera.h\n+++ b/src/v4l2/v4l2_camera.h\n@@ -51,7 +51,7 @@ public:\n \n \tint allocBuffers(unsigned int count);\n \tvoid freeBuffers();\n-\tlibcamera::FileDescriptor getBufferFd(unsigned int index);\n+\tint getBufferFd(unsigned int index);\n \n \tint streamOn();\n \tint streamOff();\ndiff --git a/src/v4l2/v4l2_camera_proxy.cpp b/src/v4l2/v4l2_camera_proxy.cpp\nindex 3610e63cade3..627e38d90f5b 100644\n--- a/src/v4l2/v4l2_camera_proxy.cpp\n+++ b/src/v4l2/v4l2_camera_proxy.cpp\n@@ -114,14 +114,14 @@ void *V4L2CameraProxy::mmap(void *addr, size_t length, int prot, int flags,\n \t\treturn MAP_FAILED;\n \t}\n \n-\tFileDescriptor fd = vcam_->getBufferFd(index);\n-\tif (!fd.isValid()) {\n+\tint fd = vcam_->getBufferFd(index);\n+\tif (fd < 0) {\n \t\terrno = EINVAL;\n \t\treturn MAP_FAILED;\n \t}\n \n \tvoid *map = V4L2CompatManager::instance()->fops().mmap(addr, length, prot,\n-\t\t\t\t\t\t\t       flags, fd.fd(), 0);\n+\t\t\t\t\t\t\t       flags, fd, 0);\n \tif (map == MAP_FAILED)\n \t\treturn map;\n \n","prefixes":["libcamera-devel","v4","18/22"]}