Patch Detail
Show a patch.
GET /api/patches/577/?format=api
{ "id": 577, "url": "https://patchwork.libcamera.org/api/patches/577/?format=api", "web_url": "https://patchwork.libcamera.org/patch/577/", "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": "<20190213151027.6376-9-kieran.bingham@ideasonboard.com>", "date": "2019-02-13T15:10:27", "name": "[libcamera-devel,v2,8/8] test: v4l2_device: Provide buffer sharing test", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "d4919b4777e43ab2ebfe3ef09a0cacba54eb8a88", "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/577/mbox/", "series": [ { "id": 181, "url": "https://patchwork.libcamera.org/api/series/181/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=181", "date": "2019-02-13T15:10:19", "name": "libcamera: v4l2_device buffer sharing", "version": 2, "mbox": "https://patchwork.libcamera.org/series/181/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/577/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/577/checks/", "tags": {}, "headers": { "Return-Path": "<kieran.bingham@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 B601D610D5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 13 Feb 2019 16:10:34 +0100 (CET)", "from localhost.localdomain\n\t(cpc89242-aztw30-2-0-cust488.18-1.cable.virginm.net [86.31.129.233])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 516AC85;\n\tWed, 13 Feb 2019 16:10:34 +0100 (CET)" ], "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1550070634;\n\tbh=DTQoIzW920jrgfR9bqhstO727x6zqMU6XJrGHngA6pU=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=C+LiVdpr4bcVnGUe1jTTGrGLsONO4xnjgMRSj51rOW/tYPcYgQSmRLV2kqT0C5CtM\n\tyz3XKQpE2kjWEWpSrQ4R37sDa6wsHYmZbV8/QOIzZ3zEpf/1hUvf0a5UHW+luGCD/f\n\thyRAOJFk70ElClCzk9uAMrBLX2dF6PGorcQfAdm4=", "From": "Kieran Bingham <kieran.bingham@ideasonboard.com>", "To": "LibCamera Devel <libcamera-devel@lists.libcamera.org>", "Date": "Wed, 13 Feb 2019 15:10:27 +0000", "Message-Id": "<20190213151027.6376-9-kieran.bingham@ideasonboard.com>", "X-Mailer": "git-send-email 2.19.1", "In-Reply-To": "<20190213151027.6376-1-kieran.bingham@ideasonboard.com>", "References": "<20190213151027.6376-1-kieran.bingham@ideasonboard.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH v2 8/8] test: v4l2_device: Provide buffer\n\tsharing 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, 13 Feb 2019 15:10:35 -0000" }, "content": "Obtain two V4L2Devices and use one to obtain a BufferPool.\n\nPropagate the formats from the first to the second device and then commence\nsending buffers between the two devices in a ping-pong fashion.\n\nSigned-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n---\n test/v4l2_device/buffer_sharing.cpp | 179 ++++++++++++++++++++++++++++\n test/v4l2_device/meson.build | 1 +\n 2 files changed, 180 insertions(+)\n create mode 100644 test/v4l2_device/buffer_sharing.cpp", "diff": "diff --git a/test/v4l2_device/buffer_sharing.cpp b/test/v4l2_device/buffer_sharing.cpp\nnew file mode 100644\nindex 000000000000..f03201e82084\n--- /dev/null\n+++ b/test/v4l2_device/buffer_sharing.cpp\n@@ -0,0 +1,179 @@\n+/* SPDX-License-Identifier: GPL-2.0-or-later */\n+/*\n+ * Copyright (C) 2019, Google Inc.\n+ *\n+ * libcamera V4L2 API tests\n+ *\n+ * Validate the function of exporting buffers from a V4L2Device and\n+ * the ability to import them to another V4L2Device instance.\n+ * Ensure that the Buffers can successfully be queued and dequeued\n+ * between both devices.\n+ */\n+\n+#include <iostream>\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 \"v4l2_device_test.h\"\n+\n+#include \"log.h\"\n+\n+LOG_DEFINE_CATEGORY(Test)\n+\n+class BufferSharingTest : public V4L2DeviceTest\n+{\n+public:\n+\tBufferSharingTest()\n+\t\t: output_(nullptr), framesCapture(0), framesOutput(0){};\n+\n+private:\n+\tconst unsigned int bufferCount = 4;\n+\n+\tV4L2Device *output_;\n+\tstd::shared_ptr<MediaDevice> secondMedia_;\n+\n+\tunsigned int framesCapture;\n+\tunsigned int framesOutput;\n+\n+protected:\n+\tint init()\n+\t{\n+\t\tint ret = V4L2DeviceTest::init();\n+\t\tif (ret)\n+\t\t\treturn ret;\n+\n+\t\t/* media_ already represents VIVID */\n+\t\tMediaEntity *entity = media_->getEntityByName(\"vivid-000-vid-out\");\n+\t\tif (!entity)\n+\t\t\treturn TestSkip;\n+\n+\t\toutput_ = new V4L2Device(entity);\n+\t\tif (!output_)\n+\t\t\treturn TestFail;\n+\n+\t\tret = output_->open();\n+\t\tif (ret)\n+\t\t\treturn TestFail;\n+\n+\t\tV4L2DeviceFormat format;\n+\n+\t\tret = dev_->getFormat(&format);\n+\t\tif (ret) {\n+\t\t\treturn TestFail;\n+\t\t}\n+\n+\t\tLOG(Test, Info) << \"Successfully obtained format from source\";\n+\n+\t\tret = output_->setFormat(&format);\n+\t\tif (ret)\n+\t\t\treturn TestFail;\n+\n+\t\tLOG(Test, Info) << \"Successfully set format to output\";\n+\n+\t\tpool_.createBuffers(bufferCount);\n+\n+\t\tret = dev_->exportBuffers(&pool_);\n+\t\tif (ret)\n+\t\t\treturn TestFail;\n+\n+\t\tret = output_->importBuffers(&pool_);\n+\t\tif (ret) {\n+\t\t\tstd::cerr << \"Failed to import buffers\" << std::endl;\n+\t\t\treturn TestFail;\n+\t\t}\n+\n+\t\treturn 0;\n+\t}\n+\n+\tvoid receiveSourceBuffer(Buffer *buffer)\n+\t{\n+\t\tstd::cout << \"Received source buffer: \" << buffer->index()\n+\t\t\t << \" sequence \" << buffer->sequence() << std::endl;\n+\n+\t\toutput_->queueBuffer(buffer);\n+\t\tframesCapture++;\n+\t}\n+\n+\tvoid receiveDestinationBuffer(Buffer *buffer)\n+\t{\n+\t\tstd::cout << \"Received destination buffer: \" << buffer->index()\n+\t\t\t << \" sequence \" << buffer->sequence() << std::endl;\n+\n+\t\tdev_->queueBuffer(buffer);\n+\t\tframesOutput++;\n+\t}\n+\n+\tint run()\n+\t{\n+\t\tEventDispatcher *dispatcher = CameraManager::instance()->eventDispatcher();\n+\t\tTimer timeout;\n+\t\tint ret;\n+\n+\t\tdev_->bufferReady.connect(this, &BufferSharingTest::receiveSourceBuffer);\n+\t\toutput_->bufferReady.connect(this, &BufferSharingTest::receiveDestinationBuffer);\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\tret = output_->streamOn();\n+\t\tif (ret)\n+\t\t\treturn TestFail;\n+\n+\t\ttimeout.start(10000);\n+\t\twhile (timeout.isRunning()) {\n+\t\t\tdispatcher->processEvents();\n+\t\t\tif (framesCapture > 30 && framesOutput > 30)\n+\t\t\t\tbreak;\n+\t\t}\n+\n+\t\tif ((framesCapture < 1) || (framesOutput < 1)) {\n+\t\t\tstd::cout << \"Failed to process any frames within timeout.\" << std::endl;\n+\t\t\treturn TestFail;\n+\t\t}\n+\n+\t\tif ((framesCapture < 30) || (framesOutput < 30)) {\n+\t\t\tstd::cout << \"Failed to process 30 frames within timeout.\" << std::endl;\n+\t\t\treturn TestFail;\n+\t\t}\n+\n+\t\tret = dev_->streamOff();\n+\t\tif (ret)\n+\t\t\treturn TestFail;\n+\n+\t\tret = output_->streamOff();\n+\t\tif (ret)\n+\t\t\treturn TestFail;\n+\n+\t\treturn TestPass;\n+\t}\n+\n+\tvoid cleanup()\n+\t{\n+\t\tstd::cout\n+\t\t\t<< \"Processed \" << framesCapture << \" capture frames\"\n+\t\t\t<< \" and \" << framesOutput << \" output frames\"\n+\t\t\t<< std::endl;\n+\n+\t\tdev_->streamOff();\n+\t\toutput_->streamOff();\n+\n+\t\tif (secondMedia_)\n+\t\t\tsecondMedia_->release();\n+\n+\t\tdelete output_;\n+\n+\t\tV4L2DeviceTest::cleanup();\n+\t}\n+};\n+\n+TEST_REGISTER(BufferSharingTest);\ndiff --git a/test/v4l2_device/meson.build b/test/v4l2_device/meson.build\nindex ec2c7f9f11ff..9f7a7545ac9b 100644\n--- a/test/v4l2_device/meson.build\n+++ b/test/v4l2_device/meson.build\n@@ -5,6 +5,7 @@ v4l2_device_tests = [\n [ 'request_buffers', 'request_buffers.cpp' ],\n [ 'stream_on_off', 'stream_on_off.cpp' ],\n [ 'capture_async', 'capture_async.cpp' ],\n+ [ 'buffer_sharing', 'buffer_sharing.cpp' ],\n ]\n \n foreach t : v4l2_device_tests\n", "prefixes": [ "libcamera-devel", "v2", "8/8" ] }