Show a patch.

GET /api/patches/496/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 496,
    "url": "https://patchwork.libcamera.org/api/patches/496/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/496/",
    "project": {
        "id": 1,
        "url": "https://patchwork.libcamera.org/api/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": "<20190203110102.5663-10-kieran.bingham@ideasonboard.com>",
    "date": "2019-02-03T11:01:00",
    "name": "[libcamera-devel,09/11] libcamera: v4l2_device: Add event driven buffer passing",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "9fb2d9cb2f3541f8e8388c57264694a1567510e0",
    "submitter": {
        "id": 4,
        "url": "https://patchwork.libcamera.org/api/people/4/?format=api",
        "name": "Kieran Bingham",
        "email": "kieran.bingham@ideasonboard.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/496/mbox/",
    "series": [
        {
            "id": 165,
            "url": "https://patchwork.libcamera.org/api/series/165/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=165",
            "date": "2019-02-03T11:00:51",
            "name": "libcamera: V4L2 Streams",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/165/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/496/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/496/checks/",
    "tags": {},
    "headers": {
        "Return-Path": "<kieran.bingham@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 CD40F60DB8\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun,  3 Feb 2019 12:01:08 +0100 (CET)",
            "from localhost.localdomain\n\t(218.182-78-194.adsl-static.isp.belgacom.be [194.78.182.218])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 7B524D4B;\n\tSun,  3 Feb 2019 12:01:08 +0100 (CET)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1549191668;\n\tbh=Cmht+l0P+IHzGRpfCwRuAbBlWTJUaMyLBGZrKGZuKPs=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=LKxXvCbw/OgrFSvbVATRlSaLoTe87uf1BcBn3V90D09g/gexrDM06bdUzR2D7Fjv2\n\tacO48N9nth93uSFqNiStcLft/Z8hV7zwGq4J0ycEhdL9Fn0gcZBF18q5pugsL4qNrf\n\t/Rno+u7p0Ndb/0KHuTWryYoFAVM0sjsTsvPKdsAQ=",
        "From": "Kieran Bingham <kieran.bingham@ideasonboard.com>",
        "To": "LibCamera Devel <libcamera-devel@lists.libcamera.org>",
        "Date": "Sun,  3 Feb 2019 12:01:00 +0100",
        "Message-Id": "<20190203110102.5663-10-kieran.bingham@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.19.1",
        "In-Reply-To": "<20190203110102.5663-1-kieran.bingham@ideasonboard.com>",
        "References": "<20190203110102.5663-1-kieran.bingham@ideasonboard.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH 09/11] libcamera: v4l2_device: Add event\n\tdriven buffer passing",
        "X-BeenThere": "libcamera-devel@lists.libcamera.org",
        "X-Mailman-Version": "2.1.23",
        "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": "Sun, 03 Feb 2019 11:01:10 -0000"
    },
    "content": "Register an EventNotifier on our device file descriptor to be notified of\nEventNotifier::Read events. These signal that a buffer is ready for dequeing\non the V4L2Device.\n\nA Buffer is dequeued, and passed through the bufferReady Signal.\n\nSigned-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n---\n src/libcamera/include/v4l2_device.h |  7 ++++++\n src/libcamera/v4l2_device.cpp       | 39 +++++++++++++++++++++++++++--\n 2 files changed, 44 insertions(+), 2 deletions(-)",
    "diff": "diff --git a/src/libcamera/include/v4l2_device.h b/src/libcamera/include/v4l2_device.h\nindex d3dad355be58..fbbddad68082 100644\n--- a/src/libcamera/include/v4l2_device.h\n+++ b/src/libcamera/include/v4l2_device.h\n@@ -13,6 +13,7 @@\n #include <linux/videodev2.h>\n \n #include <libcamera/buffer.h>\n+#include <libcamera/event_notifier.h>\n \n namespace libcamera {\n \n@@ -107,6 +108,8 @@ public:\n \tint streamOn();\n \tint streamOff();\n \n+\tSignal<Buffer *> bufferReady;\n+\n private:\n \tint getFormatSingleplane(V4L2DeviceFormat *fmt);\n \tint setFormatSingleplane(V4L2DeviceFormat *fmt);\n@@ -118,6 +121,8 @@ private:\n \tint exportBuffer(Buffer *buffer);\n \tint exportBuffers(BufferPool *pool);\n \n+\tvoid bufferAvailable(EventNotifier *notifier);\n+\n \tstd::string deviceNode_;\n \tint fd_;\n \tV4L2Capability caps_;\n@@ -126,6 +131,8 @@ private:\n \tenum v4l2_memory memoryType_;\n \n \tBufferPool *bufferPool_;\n+\n+\tEventNotifier *fdEvent_;\n };\n \n } /* namespace libcamera */\ndiff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp\nindex 1fd289137b36..630b43532c3e 100644\n--- a/src/libcamera/v4l2_device.cpp\n+++ b/src/libcamera/v4l2_device.cpp\n@@ -13,6 +13,7 @@\n #include <vector>\n \n #include <libcamera/buffer.h>\n+#include <libcamera/event_notifier.h>\n \n #include \"log.h\"\n #include \"media_object.h\"\n@@ -190,7 +191,8 @@ V4L2Buffer::V4L2Buffer(struct v4l2_buffer &vb)\n  * \\param deviceNode The file-system path to the video device node\n  */\n V4L2Device::V4L2Device(const std::string &deviceNode)\n-\t: deviceNode_(deviceNode), fd_(-1), bufferPool_(nullptr)\n+\t: deviceNode_(deviceNode), fd_(-1), bufferPool_(nullptr),\n+\t  fdEvent_(nullptr)\n {\n \t/*\n \t * We default to an MMAP based CAPTURE device, however this will be\n@@ -674,6 +676,28 @@ Buffer *V4L2Device::dequeueBuffer()\n \treturn bufferPool_->buffers()[buf.index];\n }\n \n+/**\n+ * \\brief Slot to handle completed buffer events from the V4L2 device\n+ *\n+ * When this Slot is called, a Buffer has become available from the device, and\n+ * will be emitted through the bufferReady Signal.\n+ *\n+ * For Capture devices the Buffer will be contain valid data.\n+ * For Output devices the Buffer can be considered empty.\n+ */\n+void V4L2Device::bufferAvailable(EventNotifier *notifier)\n+{\n+\tBuffer *buffer;\n+\n+\tLOG(V4L2, Debug) << \"A buffer is available\";\n+\n+\tbuffer = dequeueBuffer();\n+\n+\tbufferReady.emit(buffer);\n+\n+\tqueueBuffer(buffer);\n+}\n+\n /**\n  * \\brief Request that the V4L2Device commences streaming\n  *\n@@ -702,13 +726,17 @@ int V4L2Device::streamOn()\n \t\treturn ret;\n \t}\n \n+\tfdEvent_ = new EventNotifier(fd_, EventNotifier::Read);\n+\tfdEvent_->activated.connect(this, &V4L2Device::bufferAvailable);\n+\n \treturn 0;\n }\n \n /**\n  * \\brief Request that the V4L2Device stops streaming\n  *\n- * Asks the device to halt any current streaming operations.\n+ * Asks the device to halt any current streaming operations and remove the event\n+ * notifier registered against the device file descriptor.\n  *\n  * \\return 0 if the operation completes or a negative error number otherwise\n  */\n@@ -723,7 +751,14 @@ int V4L2Device::streamOff()\n \t\treturn ret;\n \t}\n \n+\tdelete fdEvent_;\n+\n \treturn 0;\n }\n \n+/**\n+ * \\var V4L2Device::bufferReady\n+ * \\brief A Signal handler which emits completed buffers.\n+ */\n+\n } /* namespace libcamera */\n",
    "prefixes": [
        "libcamera-devel",
        "09/11"
    ]
}