{"id":521,"url":"https://patchwork.libcamera.org/api/patches/521/?format=json","web_url":"https://patchwork.libcamera.org/patch/521/","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":"<20190206060818.13907-7-laurent.pinchart@ideasonboard.com>","date":"2019-02-06T06:07:57","name":"[libcamera-devel,06/27] libcamera: v4l2_device: Implement stream{On, Off}","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"9bbd327ff60e23f85d95dfedce5bebecd8a39229","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/?format=json","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"delegate":{"id":14,"url":"https://patchwork.libcamera.org/api/users/14/?format=json","username":"pinchartl","first_name":"Laurent","last_name":"Pinchart","email":"laurent.pinchart@ideasonboard.com"},"mbox":"https://patchwork.libcamera.org/patch/521/mbox/","series":[{"id":170,"url":"https://patchwork.libcamera.org/api/series/170/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=170","date":"2019-02-06T06:07:51","name":"Capture frames throught requests","version":1,"mbox":"https://patchwork.libcamera.org/series/170/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/521/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/521/checks/","tags":{},"headers":{"Return-Path":"<laurent.pinchart@ideasonboard.com>","Received":["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 C1BAE61022\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  6 Feb 2019 07:08:24 +0100 (CET)","from pendragon.ideasonboard.com (d51A4137F.access.telenet.be\n\t[81.164.19.127])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 6B0CD2D7\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  6 Feb 2019 07:08:24 +0100 (CET)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1549433304;\n\tbh=vdNnO7uzLhJIZcdswDjBiG1uwUAte5M9V//IYPhHTIE=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=pZP3cOFBe/t/yCDmCbVnDHKaiGPYq7ZKay43xqeCy821XYuomxXLIx4Z+FanZXhHy\n\twdPiesJStn5OL3fABgZfP+z366OR39aQEOV8BY58ICvZHbgD2dzvzv5t/qYDHhWrVs\n\tHqgZdQSGLrZSK8V4+FDyP8dV+E7hHx7j9NbVXrfg=","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Wed,  6 Feb 2019 08:07:57 +0200","Message-Id":"<20190206060818.13907-7-laurent.pinchart@ideasonboard.com>","X-Mailer":"git-send-email 2.19.2","In-Reply-To":"<20190206060818.13907-1-laurent.pinchart@ideasonboard.com>","References":"<20190206060818.13907-1-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=UTF-8","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH 06/27] libcamera: v4l2_device: Implement\n\tstream{On, Off}","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":"Wed, 06 Feb 2019 06:08:25 -0000"},"content":"From: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\nSupport starting and stopping a stream on a V4L2 device. Buffers must be\nqueued before the stream is started.\n\nSigned-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nSigned-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n---\n src/libcamera/include/v4l2_device.h |  3 ++\n src/libcamera/v4l2_device.cpp       | 45 +++++++++++++++++++++++++++++\n 2 files changed, 48 insertions(+)","diff":"diff --git a/src/libcamera/include/v4l2_device.h b/src/libcamera/include/v4l2_device.h\nindex 30a8f77d9772..988e646c5de1 100644\n--- a/src/libcamera/include/v4l2_device.h\n+++ b/src/libcamera/include/v4l2_device.h\n@@ -103,6 +103,9 @@ public:\n \tint queueBuffer(Buffer *buffer);\n \tSignal<Buffer *> bufferReady;\n \n+\tint streamOn();\n+\tint streamOff();\n+\n private:\n \tint getFormatSingleplane(V4L2DeviceFormat *format);\n \tint setFormatSingleplane(V4L2DeviceFormat *format);\ndiff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp\nindex 134a468c4236..f9839fc715f4 100644\n--- a/src/libcamera/v4l2_device.cpp\n+++ b/src/libcamera/v4l2_device.cpp\n@@ -756,4 +756,49 @@ void V4L2Device::bufferAvailable(EventNotifier *notifier)\n  * \\brief A Signal emitted when a buffer completes\n  */\n \n+/**\n+ * \\brief Start the video stream\n+ *\n+ * \\return 0 on success or a negative error code otherwise\n+ */\n+int V4L2Device::streamOn()\n+{\n+\tint ret;\n+\n+\tret = ioctl(fd_, VIDIOC_STREAMON, &bufferType_);\n+\tif (ret < 0) {\n+\t\tret = -errno;\n+\t\tLOG(V4L2, Error)\n+\t\t\t<< \"Failed to start streaming: \" << strerror(-ret);\n+\t\treturn ret;\n+\t}\n+\n+\treturn 0;\n+}\n+\n+/**\n+ * \\brief Stop the video stream\n+ *\n+ * \\todo Ensure completion notifications are sent for all queued buffers\n+ *\n+ * \\return 0 on success or a negative error code otherwise\n+ */\n+int V4L2Device::streamOff()\n+{\n+\tint ret;\n+\n+\tret = ioctl(fd_, VIDIOC_STREAMOFF, &bufferType_);\n+\tif (ret < 0) {\n+\t\tret = -errno;\n+\t\tLOG(V4L2, Error)\n+\t\t\t<< \"Failed to stop streaming: \" << strerror(-ret);\n+\t\treturn ret;\n+\t}\n+\n+\tqueuedBuffersCount_ = 0;\n+\tfdEvent_->setEnabled(false);\n+\n+\treturn 0;\n+}\n+\n } /* namespace libcamera */\n","prefixes":["libcamera-devel","06/27"]}