Patch Detail
Show a patch.
GET /api/1.1/patches/13145/?format=api
{ "id": 13145, "url": "https://patchwork.libcamera.org/api/1.1/patches/13145/?format=api", "web_url": "https://patchwork.libcamera.org/patch/13145/", "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": "<20210730010306.19956-2-laurent.pinchart@ideasonboard.com>", "date": "2021-07-30T01:02:59", "name": "[libcamera-devel,v2,1/8] cam: event_loop: Add support for file descriptor events", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "83e3c8309304246c13202581eb82b3c5108c06ff", "submitter": { "id": 2, "url": "https://patchwork.libcamera.org/api/1.1/people/2/?format=api", "name": "Laurent Pinchart", "email": "laurent.pinchart@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/13145/mbox/", "series": [ { "id": 2289, "url": "https://patchwork.libcamera.org/api/1.1/series/2289/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=2289", "date": "2021-07-30T01:02:59", "name": "libcamera: Add DRM/KMS viewfinder display to cam", "version": 2, "mbox": "https://patchwork.libcamera.org/series/2289/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/13145/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/13145/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 29CD5C3230\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 30 Jul 2021 01:03:22 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 222C8687CD;\n\tFri, 30 Jul 2021 03:03:21 +0200 (CEST)", "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 EA7A5687BD\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 30 Jul 2021 03:03:18 +0200 (CEST)", "from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 92AF1101E\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 30 Jul 2021 03:03:18 +0200 (CEST)" ], "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=\"fe8F+sNb\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1627606998;\n\tbh=3kw4e4aKYS0TdKoIEjU2QVbi/0iC9BQA98HJwgjfhtI=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=fe8F+sNbNx0VdSggrnwulrkUgHoPR1pzeCgwsMdXqUHMJyyyOIF85jWFEBn8e7p9e\n\tKxHDFBAH0ENsbQ4fy65lPCPY3lgSl+CRmhEhdd/4U30EK/RH8v+cwjevdQk4wzwYWL\n\t7qnJofLPKWUuyjwJZDruZcOZHVPTwlPGO3NfgoCE=", "From": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Fri, 30 Jul 2021 04:02:59 +0300", "Message-Id": "<20210730010306.19956-2-laurent.pinchart@ideasonboard.com>", "X-Mailer": "git-send-email 2.31.1", "In-Reply-To": "<20210730010306.19956-1-laurent.pinchart@ideasonboard.com>", "References": "<20210730010306.19956-1-laurent.pinchart@ideasonboard.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH v2 1/8] cam: event_loop: Add support for\n\tfile descriptor events", "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": "Extend the EventLoop class to support watching file descriptors for\nread and write events.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n src/cam/event_loop.cpp | 44 ++++++++++++++++++++++++++++++++++++++++++\n src/cam/event_loop.h | 20 +++++++++++++++++++\n 2 files changed, 64 insertions(+)", "diff": "diff --git a/src/cam/event_loop.cpp b/src/cam/event_loop.cpp\nindex 6a4c47f287d0..e25784c083cf 100644\n--- a/src/cam/event_loop.cpp\n+++ b/src/cam/event_loop.cpp\n@@ -10,6 +10,7 @@\n #include <assert.h>\n #include <event2/event.h>\n #include <event2/thread.h>\n+#include <iostream>\n \n EventLoop *EventLoop::instance_ = nullptr;\n \n@@ -26,6 +27,7 @@ EventLoop::~EventLoop()\n {\n \tinstance_ = nullptr;\n \n+\tevents_.clear();\n \tevent_base_free(base_);\n \tlibevent_global_shutdown();\n }\n@@ -58,6 +60,30 @@ void EventLoop::callLater(const std::function<void()> &func)\n \tevent_base_once(base_, -1, EV_TIMEOUT, dispatchCallback, this, nullptr);\n }\n \n+void EventLoop::addEvent(int fd, EventType type,\n+\t\t\t const std::function<void()> &callback)\n+{\n+\tstd::unique_ptr<Event> event = std::make_unique<Event>(callback);\n+\tshort events = (type & Read ? EV_READ : 0)\n+\t\t | (type & Write ? EV_WRITE : 0)\n+\t\t | EV_PERSIST;\n+\n+\tevent->event_ = event_new(base_, fd, events, &EventLoop::Event::dispatch,\n+\t\t\t\t event.get());\n+\tif (!event->event_) {\n+\t\tstd::cerr << \"Failed to create event for fd \" << fd << std::endl;\n+\t\treturn;\n+\t}\n+\n+\tint ret = event_add(event->event_, nullptr);\n+\tif (ret < 0) {\n+\t\tstd::cerr << \"Failed to add event for fd \" << fd << std::endl;\n+\t\treturn;\n+\t}\n+\n+\tevents_.push_back(std::move(event));\n+}\n+\n void EventLoop::dispatchCallback([[maybe_unused]] evutil_socket_t fd,\n \t\t\t\t [[maybe_unused]] short flags, void *param)\n {\n@@ -80,3 +106,21 @@ void EventLoop::dispatchCall()\n \n \tcall();\n }\n+\n+EventLoop::Event::Event(const std::function<void()> &callback)\n+\t: callback_(callback), event_(nullptr)\n+{\n+}\n+\n+EventLoop::Event::~Event()\n+{\n+\tevent_del(event_);\n+\tevent_free(event_);\n+}\n+\n+void EventLoop::Event::dispatch([[maybe_unused]] int fd,\n+\t\t\t\t[[maybe_unused]] short events, void *arg)\n+{\n+\tEvent *event = static_cast<Event *>(arg);\n+\tevent->callback_();\n+}\ndiff --git a/src/cam/event_loop.h b/src/cam/event_loop.h\nindex ba3ba3a4a675..57bb6fb34aa7 100644\n--- a/src/cam/event_loop.h\n+++ b/src/cam/event_loop.h\n@@ -8,6 +8,7 @@\n #define __CAM_EVENT_LOOP_H__\n \n #include <functional>\n+#include <memory>\n #include <list>\n #include <mutex>\n \n@@ -18,6 +19,11 @@ struct event_base;\n class EventLoop\n {\n public:\n+\tenum EventType {\n+\t\tRead = 1,\n+\t\tWrite = 2,\n+\t};\n+\n \tEventLoop();\n \t~EventLoop();\n \n@@ -28,13 +34,27 @@ public:\n \n \tvoid callLater(const std::function<void()> &func);\n \n+\tvoid addEvent(int fd, EventType type,\n+\t\t const std::function<void()> &handler);\n+\n private:\n+\tstruct Event {\n+\t\tEvent(const std::function<void()> &callback);\n+\t\t~Event();\n+\n+\t\tstatic void dispatch(int fd, short events, void *arg);\n+\n+\t\tstd::function<void()> callback_;\n+\t\tstruct event *event_;\n+\t};\n+\n \tstatic EventLoop *instance_;\n \n \tstruct event_base *base_;\n \tint exitCode_;\n \n \tstd::list<std::function<void()>> calls_;\n+\tstd::list<std::unique_ptr<Event>> events_;\n \tstd::mutex lock_;\n \n \tstatic void dispatchCallback(evutil_socket_t fd, short flags,\n", "prefixes": [ "libcamera-devel", "v2", "1/8" ] }