[{"id":22575,"web_url":"https://patchwork.libcamera.org/comment/22575/","msgid":"<Ykxnm1G3CVCmkFHe@pendragon.ideasonboard.com>","date":"2022-04-05T16:00:27","subject":"Re: [libcamera-devel] [PATCH v3 3/3] test: v4l2_videodevice: Verify\n\tthe Dequeue Watchdog","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Naush,\n\nThank you for the patch.\n\nOn Tue, Mar 29, 2022 at 12:29:29PM +0100, Naushir Patuck via libcamera-devel wrote:\n> From: Kieran Bingham <kieran.bingham@ideasonboard.com>\n> \n> Add a test that captures 5 frames, with a short (5ms) watchdog.\n> The default framerate of the VIMC pipeline should ensure that\n> we never meet this watchdog, and the timeout should activate.\n> \n> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n> Signed-off-by: Naushir Patuck <naush@raspberrypi.com>\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> ---\n>  test/v4l2_videodevice/dequeue_watchdog.cpp | 96 ++++++++++++++++++++++\n>  test/v4l2_videodevice/meson.build          |  1 +\n>  2 files changed, 97 insertions(+)\n>  create mode 100644 test/v4l2_videodevice/dequeue_watchdog.cpp\n> \n> diff --git a/test/v4l2_videodevice/dequeue_watchdog.cpp b/test/v4l2_videodevice/dequeue_watchdog.cpp\n> new file mode 100644\n> index 000000000000..0cb4de6f81a0\n> --- /dev/null\n> +++ b/test/v4l2_videodevice/dequeue_watchdog.cpp\n> @@ -0,0 +1,96 @@\n> +/* SPDX-License-Identifier: GPL-2.0-or-later */\n> +/*\n> + * Copyright (C) 2022, Ideas on Board Oy.\n> + *\n> + * libcamera V4L2 dequeue watchdog test\n> + */\n> +\n> +#include <iostream>\n> +\n> +#include <libcamera/base/event_dispatcher.h>\n> +#include <libcamera/base/thread.h>\n> +#include <libcamera/base/timer.h>\n> +\n> +#include <libcamera/framebuffer.h>\n> +\n> +#include \"v4l2_videodevice_test.h\"\n> +\n> +using namespace libcamera;\n> +using namespace std::chrono_literals;\n> +\n> +class DequeueWatchdogTest : public V4L2VideoDeviceTest\n> +{\n> +public:\n> +\tDequeueWatchdogTest()\n> +\t\t: V4L2VideoDeviceTest(\"vimc\", \"Raw Capture 0\"), frames_(0), barks_(0) {}\n> +\n> +protected:\n> +\tint run()\n> +\t{\n> +\t\tconstexpr unsigned int bufferCount = 8;\n> +\n> +\t\tEventDispatcher *dispatcher = Thread::current()->eventDispatcher();\n> +\t\tTimer timeout;\n> +\n> +\t\tint ret = capture_->allocateBuffers(bufferCount, &buffers_);\n> +\t\tif (ret < 0)\n> +\t\t\treturn TestFail;\n> +\n> +\t\tcapture_->dequeueTimeout.connect(this, &DequeueWatchdogTest::barkCounter);\n> +\t\tcapture_->setDequeueTimeout(5ms);\n> +\n> +\t\tcapture_->bufferReady.connect(this, &DequeueWatchdogTest::receiveBuffer);\n> +\n> +\t\tfor (const std::unique_ptr<FrameBuffer> &buffer : buffers_) {\n> +\t\t\tif (capture_->queueBuffer(buffer.get())) {\n> +\t\t\t\tstd::cout << \"Failed to queue buffer\" << std::endl;\n> +\t\t\t\treturn TestFail;\n> +\t\t\t}\n> +\t\t}\n> +\n> +\t\tcapture_->streamOn();\n> +\n> +\t\ttimeout.start(5s);\n> +\t\twhile (timeout.isRunning()) {\n> +\t\t\tdispatcher->processEvents();\n> +\t\t\tif (frames_ > 5)\n> +\t\t\t\tbreak;\n> +\t\t}\n> +\n> +\t\tstd::cout << \"Processed \" << frames_ << \" frames_ and heard \"\n> +\t\t\t  << barks_ << \" barks_\" << std::endl;\n> +\n> +\t\tif (!barks_) {\n> +\t\t\tstd::cout << \"Failed to hear any barks_.\" << std::endl;\n> +\t\t\treturn TestFail;\n> +\t\t}\n> +\n> +\t\tcapture_->streamOff();\n> +\n> +\t\treturn TestPass;\n> +\t}\n> +\n> +private:\n> +\tvoid receiveBuffer(FrameBuffer *buffer)\n> +\t{\n> +\t\tif (buffer->metadata().status == FrameMetadata::FrameCancelled)\n> +\t\t\treturn;\n> +\n> +\t\tstd::cout << \"Buffer received\" << std::endl;\n> +\t\tframes_++;\n> +\n> +\t\t/* Requeue the buffer for further use. */\n> +\t\tcapture_->queueBuffer(buffer);\n> +\t}\n> +\n> +\tvoid barkCounter()\n> +\t{\n> +\t\tstd::cout << \"Watchdog is barking\" << std::endl;\n> +\t\tbarks_++;\n> +\t}\n> +\n> +\tunsigned int frames_;\n> +\tunsigned int barks_;\n> +};\n> +\n> +TEST_REGISTER(DequeueWatchdogTest)\n> diff --git a/test/v4l2_videodevice/meson.build b/test/v4l2_videodevice/meson.build\n> index 643f82edce5e..7a26f53d106a 100644\n> --- a/test/v4l2_videodevice/meson.build\n> +++ b/test/v4l2_videodevice/meson.build\n> @@ -6,6 +6,7 @@ v4l2_videodevice_tests = [\n>      ['double_open',         'double_open.cpp'],\n>      ['controls',            'controls.cpp'],\n>      ['formats',             'formats.cpp'],\n> +    ['dequeue_watchdog',    'dequeue_watchdog.cpp'],\n>      ['request_buffers',     'request_buffers.cpp'],\n>      ['buffer_cache',        'buffer_cache.cpp'],\n>      ['stream_on_off',       'stream_on_off.cpp'],","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 85124C3256\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue,  5 Apr 2022 16:00:32 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id E429E65642;\n\tTue,  5 Apr 2022 18:00:31 +0200 (CEST)","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 DD224604BB\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  5 Apr 2022 18:00:30 +0200 (CEST)","from pendragon.ideasonboard.com\n\t(117.145-247-81.adsl-dyn.isp.belgacom.be [81.247.145.117])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 64F7D5D;\n\tTue,  5 Apr 2022 18:00:30 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1649174431;\n\tbh=sim1hOJaMqbolfwyLqzBujxeg4FvhgNdOxL34GdmJ48=;\n\th=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=jAlOpSJzIiaMOxepX4jyUKP8R+8+bv7Mb0aJ5Sib92zkz0Gc1UIP42Wh/4Gsd3PKR\n\t56AaF8o7+P+RqyhzQDt1PIWNsVbiHccYSqcbJZwLbj6KGfBjkXVGBwDtSDayFBTt9A\n\tbfVJcRmuRgxKyxUyE6ZoP0bh3QGQFVFEMzGaJsuNYGPRtziWZbeT3O6W3j+KXhnI6E\n\taq2KOFswmsVqLRwhm5eJ9lYTVRwo/kHTpKmZCBQsOBO9PIjHRx8EHFp9iZj8oDHNof\n\t7uQ8RJTMfWZtQblBuFhGkdDQ/A33494YwvFw3FFGFeOjovNqStgs/8k8tqV18n9ssr\n\tFdv3sRTCcMHXQ==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1649174430;\n\tbh=sim1hOJaMqbolfwyLqzBujxeg4FvhgNdOxL34GdmJ48=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=gm0msimoeLlG7LgHB6dlUoHF9bPUpKW/WlaiaMViCS9bI4FEIEyPku2IjWNj0wcUj\n\t+uMaHYYn6wXUMTmRNweSgGVdQ4Eu5w0NyMwpqBf/iMz1IChIy/zcp9vqQlSK4O5kv5\n\tBSCnc/6+8lERCCsZPGtBP+Rmaa3TWkZROINuQmIY="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"gm0msimo\"; dkim-atps=neutral","Date":"Tue, 5 Apr 2022 19:00:27 +0300","To":"Naushir Patuck <naush@raspberrypi.com>","Message-ID":"<Ykxnm1G3CVCmkFHe@pendragon.ideasonboard.com>","References":"<20220329112929.465434-1-naush@raspberrypi.com>\n\t<20220329112929.465434-3-naush@raspberrypi.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20220329112929.465434-3-naush@raspberrypi.com>","Subject":"Re: [libcamera-devel] [PATCH v3 3/3] test: v4l2_videodevice: Verify\n\tthe Dequeue Watchdog","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","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>","From":"Laurent Pinchart via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]