{"id":523,"url":"https://patchwork.libcamera.org/api/1.1/patches/523/?format=json","web_url":"https://patchwork.libcamera.org/patch/523/","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":"<20190206060818.13907-9-laurent.pinchart@ideasonboard.com>","date":"2019-02-06T06:07:59","name":"[libcamera-devel,08/27] test: v4l2_device: Provide asynchronous capture test","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"74e15e55ea7d45f5a97ad0062f9f7be6a90250bc","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/1.1/people/2/?format=json","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/523/mbox/","series":[{"id":170,"url":"https://patchwork.libcamera.org/api/1.1/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/523/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/523/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 40EFB61031\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  6 Feb 2019 07:08:25 +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 E1B472D7\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=1549433305;\n\tbh=YIvPvFriiZwE+IFaKBq5lVADB1qrbFQm8NRuhv1MsSo=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=vA/z/mLdcvK/MDSRjGe2Pr0H/J8WLM52g56kNauK8rQzF287C7m8kgih7j6FJHsFD\n\tvVHL49cEMDHmxvA9A7CgmzA+bbck1neJI4A71xRHkk5LSCo66OP+Mw9XCdtvz5qIjl\n\t0FBsyJeUfZT4q6vaRmJV5iAtsSf13KvYSNiMVxFQ=","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Wed,  6 Feb 2019 08:07:59 +0200","Message-Id":"<20190206060818.13907-9-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 08/27] test: v4l2_device: Provide\n\tasynchronous capture test","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:26 -0000"},"content":"From: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\nUtilise the event_dispatcher to create a default event loop, and process\nasynchronous buffer receive events.\n\nIf no frames are captured in 5 seconds, the test will fail.\nIt will also fail if less than 30 frames have been captured in the same\ntimeout period.\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 test/v4l2_device/capture_async.cpp | 86 ++++++++++++++++++++++++++++++\n test/v4l2_device/meson.build       |  1 +\n 2 files changed, 87 insertions(+)\n create mode 100644 test/v4l2_device/capture_async.cpp","diff":"diff --git a/test/v4l2_device/capture_async.cpp b/test/v4l2_device/capture_async.cpp\nnew file mode 100644\nindex 000000000000..7a0735f65535\n--- /dev/null\n+++ b/test/v4l2_device/capture_async.cpp\n@@ -0,0 +1,86 @@\n+/* SPDX-License-Identifier: GPL-2.0-or-later */\n+/*\n+ * Copyright (C) 2019, Google Inc.\n+ *\n+ * libcamera V4L2 API tests\n+ */\n+\n+#include <libcamera/buffer.h>\n+#include <libcamera/camera_manager.h>\n+#include <libcamera/event_dispatcher.h>\n+#include <libcamera/timer.h>\n+\n+#include <iostream>\n+\n+#include \"v4l2_device_test.h\"\n+\n+class CaptureAsyncTest : public V4L2DeviceTest\n+{\n+public:\n+\tCaptureAsyncTest()\n+\t\t: frames(0){};\n+\n+\tvoid receiveBuffer(Buffer *buffer)\n+\t{\n+\t\tstd::cout << \"Received buffer \" << buffer->index() << std::endl;\n+\t\tframes++;\n+\n+\t\t/* Requeue the buffer for further use. */\n+\t\tdev_->queueBuffer(buffer);\n+\t}\n+\n+protected:\n+\tint run()\n+\t{\n+\t\tconst unsigned int bufferCount = 8;\n+\n+\t\tEventDispatcher *dispatcher = CameraManager::instance()->eventDispatcher();\n+\t\tTimer timeout;\n+\t\tint ret;\n+\n+\t\tcreateBuffers(bufferCount);\n+\n+\t\tret = dev_->exportBuffers(bufferCount, &pool_);\n+\t\tif (ret)\n+\t\t\treturn TestFail;\n+\n+\t\tdev_->bufferReady.connect(this, &CaptureAsyncTest::receiveBuffer);\n+\n+\t\t/* Queue all the buffers to the device. */\n+\t\tfor (Buffer &b : pool_.buffers()) {\n+\t\t\tif (dev_->queueBuffer(&b))\n+\t\t\t\treturn TestFail;\n+\t\t}\n+\n+\t\tret = dev_->streamOn();\n+\t\tif (ret)\n+\t\t\treturn TestFail;\n+\n+\t\ttimeout.start(5000);\n+\t\twhile (timeout.isRunning())\n+\t\t\tdispatcher->processEvents();\n+\n+\t\tif (frames < 1) {\n+\t\t\tstd::cout << \"Failed to capture any frames within timeout.\" << std::endl;\n+\t\t\treturn TestFail;\n+\t\t}\n+\n+\t\tif (frames < 30) {\n+\t\t\tstd::cout << \"Failed to capture 30 frames within timeout.\" << std::endl;\n+\t\t\treturn TestFail;\n+\t\t}\n+\n+\t\tstd::cout << \"Processed \" << frames << \" frames\" << std::endl;\n+\n+\t\tret = dev_->streamOff();\n+\t\tif (ret)\n+\t\t\treturn TestFail;\n+\n+\t\treturn TestPass;\n+\t}\n+\n+private:\n+\tunsigned int frames;\n+};\n+\n+TEST_REGISTER(CaptureAsyncTest);\ndiff --git a/test/v4l2_device/meson.build b/test/v4l2_device/meson.build\nindex cbaa79da9b81..ec2c7f9f11ff 100644\n--- a/test/v4l2_device/meson.build\n+++ b/test/v4l2_device/meson.build\n@@ -4,6 +4,7 @@ v4l2_device_tests = [\n   [ 'double_open',        'double_open.cpp' ],\n   [ 'request_buffers',    'request_buffers.cpp' ],\n   [ 'stream_on_off',      'stream_on_off.cpp' ],\n+  [ 'capture_async',      'capture_async.cpp' ],\n ]\n \n foreach t : v4l2_device_tests\n","prefixes":["libcamera-devel","08/27"]}