Patch Detail
Show a patch.
GET /api/1.1/patches/546/?format=api
{ "id": 546, "url": "https://patchwork.libcamera.org/api/1.1/patches/546/?format=api", "web_url": "https://patchwork.libcamera.org/patch/546/", "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": "<20190207212119.30299-4-kieran.bingham@ideasonboard.com>", "date": "2019-02-07T21:21:17", "name": "[libcamera-devel,3/5] test: v4l2_device: Provide buffer sharing test", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "7d66e4d1984f3c89b5852f7a33ec8140544de02c", "submitter": { "id": 4, "url": "https://patchwork.libcamera.org/api/1.1/people/4/?format=api", "name": "Kieran Bingham", "email": "kieran.bingham@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/546/mbox/", "series": [ { "id": 171, "url": "https://patchwork.libcamera.org/api/1.1/series/171/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=171", "date": "2019-02-07T21:21:14", "name": "libcamera: Buffer Sharing", "version": 1, "mbox": "https://patchwork.libcamera.org/series/171/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/546/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/546/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 8130E610B2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 7 Feb 2019 22:21:30 +0100 (CET)", "from localhost.localdomain (unknown [149.254.234.206])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 72FDB567;\n\tThu, 7 Feb 2019 22:21:29 +0100 (CET)" ], "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1549574490;\n\tbh=uM0dtpORdwrd7i/94nuuDpNb15N8o0D51ie8gmna0pg=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=oTBKr4f4A/gckaIgSUPxKjDThoxkeUv0sflqOjdgmZgava+cn13o4wfpfdXvJX6jI\n\t7Avnoo7cFXp0YV0j4pmTnAgOqT/33zyPGFnrY0m7vLJSp2/tFZZ6IBwXRVFNMNJrw6\n\tkjMeqUMYy1HU5sTNqYY5456SEEMubVDdv8USlwPY=", "From": "Kieran Bingham <kieran.bingham@ideasonboard.com>", "To": "LibCamera Devel <libcamera-devel@lists.libcamera.org>", "Date": "Thu, 7 Feb 2019 21:21:17 +0000", "Message-Id": "<20190207212119.30299-4-kieran.bingham@ideasonboard.com>", "X-Mailer": "git-send-email 2.19.1", "In-Reply-To": "<20190207212119.30299-1-kieran.bingham@ideasonboard.com>", "References": "<20190207212119.30299-1-kieran.bingham@ideasonboard.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH 3/5] 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": "Thu, 07 Feb 2019 21:21:30 -0000" }, "content": "Obtain two V4L2Devices and use one to obtain a BufferPool.\n\nPropogate 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 | 178 ++++++++++++++++++++++++++++\n test/v4l2_device/meson.build | 1 +\n 2 files changed, 179 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..0e96f7b894bd\n--- /dev/null\n+++ b/test/v4l2_device/buffer_sharing.cpp\n@@ -0,0 +1,178 @@\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 <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\tDeviceMatch uvcvideo(\"uvcvideo\");\n+\t\tuvcvideo.add(\"Logitech BRIO\");\n+\n+\t\tsecondMedia_ = std::move(enumerator_->search(uvcvideo));\n+\t\tif (!secondMedia_) {\n+\t\t\tLOG(Test, Info) << \"No Brio found\";\n+\t\t\treturn TestSkip;\n+\t\t}\n+\n+\t\tsecondMedia_->acquire();\n+\n+\t\tMediaEntity *entity = secondMedia_->defaultEntity();\n+\t\tif (!entity)\n+\t\t\treturn TestFail;\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(bufferCount, &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(5000);\n+\t\twhile (timeout.isRunning())\n+\t\t\tdispatcher->processEvents();\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\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\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\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", "3/5" ] }