{"id":11946,"url":"https://patchwork.libcamera.org/api/1.1/patches/11946/?format=json","web_url":"https://patchwork.libcamera.org/patch/11946/","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":"<20210415083843.3399502-10-hiroh@chromium.org>","date":"2021-04-15T08:38:43","name":"[libcamera-devel,RFC,10/10] v4l2: V4L2Camera: Return int in getBufferFd()","commit_ref":null,"pull_url":null,"state":"changes-requested","archived":false,"hash":"16296091459299f41c51c6794863e411f29def97","submitter":{"id":63,"url":"https://patchwork.libcamera.org/api/1.1/people/63/?format=json","name":"Hirokazu Honda","email":"hiroh@chromium.org"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/11946/mbox/","series":[{"id":1933,"url":"https://patchwork.libcamera.org/api/1.1/series/1933/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=1933","date":"2021-04-15T08:38:35","name":null,"version":1,"mbox":"https://patchwork.libcamera.org/series/1933/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/11946/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/11946/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 B013CBD224\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 15 Apr 2021 08:39:04 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 67FD568820;\n\tThu, 15 Apr 2021 10:39:04 +0200 (CEST)","from mail-pg1-x52d.google.com (mail-pg1-x52d.google.com\n\t[IPv6:2607:f8b0:4864:20::52d])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 6C1046881C\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 15 Apr 2021 10:39:03 +0200 (CEST)","by mail-pg1-x52d.google.com with SMTP id w10so16430180pgh.5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 15 Apr 2021 01:39:03 -0700 (PDT)","from hiroh2.tok.corp.google.com\n\t([2401:fa00:8f:2:84f5:7981:dfbe:8f02])\n\tby smtp.gmail.com with ESMTPSA id\n\t205sm1520258pfc.201.2021.04.15.01.39.00\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tThu, 15 Apr 2021 01:39:01 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=chromium.org header.i=@chromium.org\n\theader.b=\"UszF879V\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org;\n\ts=google; \n\th=from:to:cc:subject:date:message-id:in-reply-to:references\n\t:mime-version:content-transfer-encoding;\n\tbh=DSsxcSmsNI9tDWl/QmgciTOfqlHw1LrlygyIrWs5bYw=;\n\tb=UszF879VhFcbEnqHkvQJ34hIscVtI9CHlD0kqhgOmzJoUUMQwUlmuyPDS8HYA1VciJ\n\tKCYxTabv5/fYUlg0il08GzYJ+RQIJvxW0iWTrycYpgAAcDHmIRPO5hML1oc5y2hyOhUs\n\tk/f89NPo4Ng9DfHK3dwq/7PySNr0ufP6dUeqU=","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references:mime-version:content-transfer-encoding;\n\tbh=DSsxcSmsNI9tDWl/QmgciTOfqlHw1LrlygyIrWs5bYw=;\n\tb=C+zXhR4DLRK8W2whysUJtXVd7iYgo/SzIBzM75rbpZYlmaUxo/Fd4kCuQpKe5t2rzH\n\tvcHOFQ6BfZahfMM5bMyNxN/18LQU1rwKztXMJokiSIj4QB4o7e4dgUZtUaogXfCJUrOQ\n\tcuwqGkB2UwMRqibSBHJM07iRRQPxUzSqRqOTqegALNUWKxBFmSLM6G0mojdEp6uX1d7C\n\tZHsGUZkyFsj+GwQ5UB9bJZdOLXPOuSC+JY3G+sQVyz86XOUNHBXlghKcpLJSRWly8WQ1\n\t3mkg1ZMzyrz4LfS6y6MM63hvy4Lskiu/TpJUAn9BszPsdSPsSzSMMxJTZAyNio4REWg2\n\tdioA==","X-Gm-Message-State":"AOAM531j8QXYkLSw/aFNcC3XIYdLXKOqEQSIedXG3O1Kgta8uInvm5I9\n\tGRTeqY79s58wnxIOdvAnjxa2cfF1jXtODA==","X-Google-Smtp-Source":"ABdhPJwYB8ZCYkI41AySZLE23mkwwfUC5gud5+oOglGczMt33plvLktIeG9I1mjK3eUFup/EdC5H9Q==","X-Received":"by 2002:a63:dc03:: with SMTP id s3mr2409558pgg.426.1618475941835;\n\tThu, 15 Apr 2021 01:39:01 -0700 (PDT)","From":"Hirokazu Honda <hiroh@chromium.org>","To":"libcamera-devel@lists.libcamera.org","Date":"Thu, 15 Apr 2021 17:38:43 +0900","Message-Id":"<20210415083843.3399502-10-hiroh@chromium.org>","X-Mailer":"git-send-email 2.31.1.368.gbe11c130af-goog","In-Reply-To":"<20210415083843.3399502-1-hiroh@chromium.org>","References":"<20210415083843.3399502-1-hiroh@chromium.org>","MIME-Version":"1.0","Subject":"[libcamera-devel] [RFC PATCH 10/10] v4l2: V4L2Camera: 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>","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"V4L2Camera::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>\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 97825c71..cccc6749 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 d2380462..8efe1642 100644\n--- a/src/v4l2/v4l2_camera.h\n+++ b/src/v4l2/v4l2_camera.h\n@@ -53,7 +53,7 @@ public:\n \n \tint allocBuffers(unsigned int count);\n \tvoid freeBuffers();\n-\tFileDescriptor 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 f8bfe595..8f417421 100644\n--- a/src/v4l2/v4l2_camera_proxy.cpp\n+++ b/src/v4l2/v4l2_camera_proxy.cpp\n@@ -112,14 +112,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","RFC","10/10"]}