Patch Detail
Show a patch.
GET /api/1.1/patches/3941/?format=api
{ "id": 3941, "url": "https://patchwork.libcamera.org/api/1.1/patches/3941/?format=api", "web_url": "https://patchwork.libcamera.org/patch/3941/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/1.1/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": "<20200605090106.15424-7-paul.elder@ideasonboard.com>", "date": "2020-06-05T09:01:05", "name": "[libcamera-devel,v2,6/7] v4l2: v4l2_compat: Add eventfd signaling to support polling", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "3a41f03d09730b7338e40e818eff916fdc03e50d", "submitter": { "id": 17, "url": "https://patchwork.libcamera.org/api/1.1/people/17/?format=api", "name": "Paul Elder", "email": "paul.elder@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/3941/mbox/", "series": [ { "id": 956, "url": "https://patchwork.libcamera.org/api/1.1/series/956/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=956", "date": "2020-06-05T09:00:59", "name": "Support qv4l2 with v4l2-compat", "version": 2, "mbox": "https://patchwork.libcamera.org/series/956/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/3941/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/3941/checks/", "tags": {}, "headers": { "Return-Path": "<paul.elder@ideasonboard.com>", "Received": [ "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 74C7E61368\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 5 Jun 2020 11:01:25 +0200 (CEST)", "from emerald.amanokami.net (fs76eef344.knge213.ap.nuro.jp\n\t[118.238.243.68])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 5169D27C;\n\tFri, 5 Jun 2020 11:01:24 +0200 (CEST)" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"mCJ23lnb\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1591347685;\n\tbh=8ue+lVlQb2TeMNQ6WnLK9Xnp+aHKtMRPuaD3Yl8Q8jU=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=mCJ23lnblxDiua68mcvhqH5iIMygOrlFBJlO6+vW9pYu44Qct+vgARCrIrPb4eroO\n\tm1yHWmN+uItP0WhGavSeAL7YZeDt4HhKx4tcqZP6pEIrUwQZXQlxVO0t4TvRerFaod\n\tipPBXMMDATbanqQ03YYdNQZkmUhpoFlKmJt8LZPM=", "From": "Paul Elder <paul.elder@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Fri, 5 Jun 2020 18:01:05 +0900", "Message-Id": "<20200605090106.15424-7-paul.elder@ideasonboard.com>", "X-Mailer": "git-send-email 2.20.1", "In-Reply-To": "<20200605090106.15424-1-paul.elder@ideasonboard.com>", "References": "<20200605090106.15424-1-paul.elder@ideasonboard.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH v2 6/7] v4l2: v4l2_compat: Add eventfd\n\tsignaling to support polling", "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, 05 Jun 2020 09:01:25 -0000" }, "content": "To support polling, we need to be able to signal when data is\navailable to be read (POLLIN), as well as events (POLLPRI). Add the\nnecessary calls to eventfd to allow signaling POLLIN. We signal POLLIN\nby writing writing to the eventfd, and clear it by reading from the\neventfd, upon VIDIOC_DQBUF.\n\nNote that eventfd does not support signaling POLLPRI, so we don't yet\nsupport V4L2 events.\n\nSigned-off-by: Paul Elder <paul.elder@ideasonboard.com>\n\n---\nChanges in v2: use eventfd instead of socket\n---\n src/v4l2/v4l2_camera.cpp | 9 +++++++++\n src/v4l2/v4l2_camera.h | 3 +++\n src/v4l2/v4l2_camera_proxy.cpp | 10 ++++++++++\n src/v4l2/v4l2_camera_proxy.h | 4 ++++\n src/v4l2/v4l2_compat_manager.cpp | 7 ++++++-\n 5 files changed, 32 insertions(+), 1 deletion(-)", "diff": "diff --git a/src/v4l2/v4l2_camera.cpp b/src/v4l2/v4l2_camera.cpp\nindex 4da01a45..3c369328 100644\n--- a/src/v4l2/v4l2_camera.cpp\n+++ b/src/v4l2/v4l2_camera.cpp\n@@ -8,6 +8,7 @@\n #include \"v4l2_camera.h\"\n \n #include <errno.h>\n+#include <unistd.h>\n \n #include \"libcamera/internal/log.h\"\n \n@@ -53,6 +54,11 @@ void V4L2Camera::close()\n \tcamera_->release();\n }\n \n+void V4L2Camera::bind(int efd)\n+{\n+\tefd_ = efd;\n+}\n+\n void V4L2Camera::getStreamConfig(StreamConfiguration *streamConfig)\n {\n \t*streamConfig = config_->at(0);\n@@ -84,6 +90,9 @@ void V4L2Camera::requestComplete(Request *request)\n \tcompletedBuffers_.push_back(std::move(metadata));\n \tbufferLock_.unlock();\n \n+\tuint64_t data = 1;\n+\t::write(efd_, &data, sizeof(data));\n+\n \tbufferSema_.release();\n }\n \ndiff --git a/src/v4l2/v4l2_camera.h b/src/v4l2/v4l2_camera.h\nindex 303eda44..33f5eb02 100644\n--- a/src/v4l2/v4l2_camera.h\n+++ b/src/v4l2/v4l2_camera.h\n@@ -39,6 +39,7 @@ public:\n \n \tint open();\n \tvoid close();\n+\tvoid bind(int efd);\n \tvoid getStreamConfig(StreamConfiguration *streamConfig);\n \tstd::vector<Buffer> completedBuffers();\n \n@@ -70,6 +71,8 @@ private:\n \n \tstd::deque<std::unique_ptr<Request>> pendingRequests_;\n \tstd::deque<std::unique_ptr<Buffer>> completedBuffers_;\n+\n+\tint efd_;\n };\n \n #endif /* __V4L2_CAMERA_H__ */\ndiff --git a/src/v4l2/v4l2_camera_proxy.cpp b/src/v4l2/v4l2_camera_proxy.cpp\nindex cbe9e026..7ee4c0cb 100644\n--- a/src/v4l2/v4l2_camera_proxy.cpp\n+++ b/src/v4l2/v4l2_camera_proxy.cpp\n@@ -13,6 +13,7 @@\n #include <linux/videodev2.h>\n #include <string.h>\n #include <sys/mman.h>\n+#include <unistd.h>\n \n #include <libcamera/camera.h>\n #include <libcamera/object.h>\n@@ -451,6 +452,9 @@ int V4L2CameraProxy::vidioc_dqbuf(struct v4l2_buffer *arg)\n \n \tcurrentBuf_ = (currentBuf_ + 1) % bufferCount_;\n \n+\tuint64_t data;\n+\t::read(efd_, &data, sizeof(data));\n+\n \treturn 0;\n }\n \n@@ -529,6 +533,12 @@ int V4L2CameraProxy::ioctl(unsigned long request, void *arg)\n \treturn ret;\n }\n \n+void V4L2CameraProxy::bind(int fd)\n+{\n+\tefd_ = fd;\n+\tvcam_->bind(fd);\n+}\n+\n struct PixelFormatPlaneInfo {\n \tunsigned int bitsPerPixel;\n \tunsigned int hSubSampling;\ndiff --git a/src/v4l2/v4l2_camera_proxy.h b/src/v4l2/v4l2_camera_proxy.h\nindex af9f9bbe..7c65c886 100644\n--- a/src/v4l2/v4l2_camera_proxy.h\n+++ b/src/v4l2/v4l2_camera_proxy.h\n@@ -33,6 +33,8 @@ public:\n \n \tint ioctl(unsigned long request, void *arg);\n \n+\tvoid bind(int fd);\n+\n private:\n \tbool validateBufferType(uint32_t type);\n \tbool validateMemoryType(uint32_t memory);\n@@ -77,6 +79,8 @@ private:\n \tstd::map<void *, unsigned int> mmaps_;\n \n \tstd::unique_ptr<V4L2Camera> vcam_;\n+\n+\tint efd_;\n };\n \n #endif /* __V4L2_CAMERA_PROXY_H__ */\ndiff --git a/src/v4l2/v4l2_compat_manager.cpp b/src/v4l2/v4l2_compat_manager.cpp\nindex 2338a0ee..56533c4f 100644\n--- a/src/v4l2/v4l2_compat_manager.cpp\n+++ b/src/v4l2/v4l2_compat_manager.cpp\n@@ -155,12 +155,17 @@ int V4L2CompatManager::openat(int dirfd, const char *path, int oflag, mode_t mod\n \tif (ret < 0)\n \t\treturn ret;\n \n-\tint efd = eventfd(0, oflag & (O_CLOEXEC | O_NONBLOCK));\n+\tint efd = eventfd(0, EFD_SEMAPHORE |\n+\t\t\t ((oflag & O_CLOEXEC) ? EFD_CLOEXEC : 0) |\n+\t\t\t ((oflag & O_NONBLOCK) ? EFD_NONBLOCK : 0));\n \tif (efd < 0) {\n+\t\tint err = errno;\n \t\tproxy->close();\n+\t\terrno = err;\n \t\treturn efd;\n \t}\n \n+\tproxy->bind(efd);\n \tdevices_.emplace(efd, proxy);\n \n \treturn efd;\n", "prefixes": [ "libcamera-devel", "v2", "6/7" ] }