{"id":15583,"url":"https://patchwork.libcamera.org/api/patches/15583/?format=json","web_url":"https://patchwork.libcamera.org/patch/15583/","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":"<20220329112929.465434-3-naush@raspberrypi.com>","date":"2022-03-29T11:29:29","name":"[libcamera-devel,v3,3/3] test: v4l2_videodevice: Verify the Dequeue Watchdog","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"0acd2ab3147c6c9cb29a6b85b68a2873e6f184c2","submitter":{"id":34,"url":"https://patchwork.libcamera.org/api/people/34/?format=json","name":"Naushir Patuck","email":"naush@raspberrypi.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/15583/mbox/","series":[{"id":3012,"url":"https://patchwork.libcamera.org/api/series/3012/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=3012","date":"2022-03-29T11:29:27","name":"[libcamera-devel,v3,1/3] libcamera: v4l2_videodevice: Add a dequeue timer","version":3,"mbox":"https://patchwork.libcamera.org/series/3012/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/15583/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/15583/checks/","tags":{},"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 49FB7C0F1B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 29 Mar 2022 11:29:39 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id E1BDF65635;\n\tTue, 29 Mar 2022 13:29:37 +0200 (CEST)","from mail-wr1-x433.google.com (mail-wr1-x433.google.com\n\t[IPv6:2a00:1450:4864:20::433])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 74B1B604C5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 29 Mar 2022 13:29:36 +0200 (CEST)","by mail-wr1-x433.google.com with SMTP id m30so24360637wrb.1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 29 Mar 2022 04:29:36 -0700 (PDT)","from naush-laptop.pitowers.org\n\t([2a00:1098:3142:14:e34f:94fd:5684:9ead])\n\tby smtp.gmail.com with ESMTPSA id\n\tbi20-20020a05600c3d9400b0038cfe80eeddsm1767436wmb.29.2022.03.29.04.29.34\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tTue, 29 Mar 2022 04:29:35 -0700 (PDT)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1648553377;\n\tbh=uJkdLyKKi1CM7U78WY3/9v8M7LaHmqKbeWqVheZf5rM=;\n\th=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:\n\tFrom;\n\tb=DnDMFZs3e/P/eeYf2NI6mLHH/BuyBue1dqqpWeMxRWoFJ/x3lptVD5hDdNu+Ea6lQ\n\tB/i34hGXG5HC3f2RY9QLpk2wjysYuP5WeFlbdeiQz9OrzAtjrf5Ch24ZZBOyFXsUmU\n\tY+unX9i3GZOj4h1F4E3cMLRjSbuA5+gv9dG4UvmQ2HKIja8MG6UE0k1E0t3QSyhFxe\n\tpz/lT0yR4wArH+5F0ZZUCFbVbVVltk8jg8Yxph9bAWRPAdZBxSPhcrRnKDuO5S+D/+\n\tFdsNF0xab3ZnkDeY9N2ROmpA3AuFFolhNsJ87QsW8yCmTqCeQ4jgYB+VCFC4meKcQ2\n\tvM1N2fHgX+evg==","v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google;\n\th=from:to:cc:subject:date:message-id:in-reply-to:references\n\t:mime-version:content-transfer-encoding;\n\tbh=YymQGyzOkJ/fWIcmhh9T0m5zlCZROtuZjEIX+kkvOFQ=;\n\tb=lBBgkEzBnAqXTMiLdHQCLcO9U/cP3po6VfvxyIO0WrE+wZ2WJpuR3lT5OP9XO7hZlR\n\ty/mpAXdahEFVGFFiIjWo5cXlihUXhKjnG4ooekOhYyUYgwy7A3bnWF+U481vVBdQ/5M1\n\t6fgsPGQZfMB/ylVJ6o+w5kBzu31I3b/G0g/JgaxOKAFpsVRKFOgUBVPtab8zqAsvikd7\n\tr3UnE6iDpVAjHxqp6kZQ68ghEiJWCfLAT1sSboKWXc8u1G0bk43iAz3YPESBtSXKM1tH\n\tk/esSC7WQsLkP3dGRu/EbtlnabiUxjRMuWkdkEIDEvHQW8uzCJWYCaLoxwuQ8zurac7R\n\tLC/Q=="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"lBBgkEzB\"; dkim-atps=neutral","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references:mime-version:content-transfer-encoding;\n\tbh=YymQGyzOkJ/fWIcmhh9T0m5zlCZROtuZjEIX+kkvOFQ=;\n\tb=n8dVKZW6v7QQs2w8j69qvk2OwibvHI+rfuNTntoUrV2wRk7NEhPjpxArK2jsdcFwGW\n\txPyZBgdhkFHIA/tI/eXQPLhp9vaiXuOfs0R2v9Hswa5FhWL7hygEAXYxQIOeGP7YUq/D\n\tjwPHLGipq/Vh2LRF/8QjdcYfruubEYJ4nG1wosdxxCvVph0LAOqa2jYfZ6rTbH2XJgvO\n\t7S4j8/olXpDgOgg60fAk2osxhKJdSAlHN4dSXGmbY0huLstd5OTgo2wnE3CNgRkZmHX3\n\tEGVWnFb0I6BUs1lt/80HAsKEIiS07Y9ZqetW+RepjOUuIGREWzYZitkQfNYj1UOUmth8\n\tmxRw==","X-Gm-Message-State":"AOAM53104gQOjskTtZQtgoOrTkjOtgBMIX3f7W2MQ+tauRpc2xkA2eRe\n\tEhGgRMYwFxjWmDKPq0NRaOxyAPlFHG/Gow==","X-Google-Smtp-Source":"ABdhPJxnGfG5mtchbMFio84bRKIgVL/YZea2a7i9MmUg0Bmc81gkvVPhYyKOJuqhE4sZMbJ7SBhEUQ==","X-Received":"by 2002:adf:cc89:0:b0:203:f654:116a with SMTP id\n\tp9-20020adfcc89000000b00203f654116amr29848750wrj.320.1648553375986; \n\tTue, 29 Mar 2022 04:29:35 -0700 (PDT)","To":"libcamera-devel@lists.libcamera.org","Date":"Tue, 29 Mar 2022 12:29:29 +0100","Message-Id":"<20220329112929.465434-3-naush@raspberrypi.com>","X-Mailer":"git-send-email 2.25.1","In-Reply-To":"<20220329112929.465434-1-naush@raspberrypi.com>","References":"<20220329112929.465434-1-naush@raspberrypi.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v3 3/3] test: v4l2_videodevice: Verify the\n\tDequeue 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":"Naushir Patuck via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Naushir Patuck <naush@raspberrypi.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"From: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\nAdd a test that captures 5 frames, with a short (5ms) watchdog.\nThe default framerate of the VIMC pipeline should ensure that\nwe never meet this watchdog, and the timeout should activate.\n\nSigned-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\nSigned-off-by: Naushir Patuck <naush@raspberrypi.com>\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","diff":"diff --git a/test/v4l2_videodevice/dequeue_watchdog.cpp b/test/v4l2_videodevice/dequeue_watchdog.cpp\nnew file mode 100644\nindex 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)\ndiff --git a/test/v4l2_videodevice/meson.build b/test/v4l2_videodevice/meson.build\nindex 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'],\n","prefixes":["libcamera-devel","v3","3/3"]}