{"id":15625,"url":"https://patchwork.libcamera.org/api/1.1/patches/15625/?format=json","web_url":"https://patchwork.libcamera.org/patch/15625/","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":"<20220406075859.3857121-4-naush@raspberrypi.com>","date":"2022-04-06T07:58:59","name":"[libcamera-devel,v4,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/1.1/people/34/?format=json","name":"Naushir Patuck","email":"naush@raspberrypi.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/15625/mbox/","series":[{"id":3031,"url":"https://patchwork.libcamera.org/api/1.1/series/3031/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=3031","date":"2022-04-06T07:58:56","name":"Dequeue timeout","version":4,"mbox":"https://patchwork.libcamera.org/series/3031/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/15625/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/15625/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 DAB69C0F1B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  6 Apr 2022 07:59:10 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 67B3565644;\n\tWed,  6 Apr 2022 09:59:10 +0200 (CEST)","from mail-wr1-x432.google.com (mail-wr1-x432.google.com\n\t[IPv6:2a00:1450:4864:20::432])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id A857965645\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  6 Apr 2022 09:59:07 +0200 (CEST)","by mail-wr1-x432.google.com with SMTP id z1so1934607wrg.4\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 06 Apr 2022 00:59:07 -0700 (PDT)","from naush-laptop.pitowers.org\n\t([2a00:1098:3142:14:eedb:32e2:e3d4:3bfa])\n\tby smtp.gmail.com with ESMTPSA id\n\t14-20020a056000154e00b00203f8adde0csm17235503wry.32.2022.04.06.00.59.06\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tWed, 06 Apr 2022 00:59:06 -0700 (PDT)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1649231950;\n\tbh=8Ewq6FpKQZHfDJbvneE/YsIROH3JjdaudrsCD96DizA=;\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=Vqjk0wECMkoMwlJVR8jh5GzmLhfNW3slASjy2P+nJRaXACh91MGMQxnFTWnijQilK\n\tpO5OCRh52rGJtOcfORiSbE4RFShejZrEQY1d4EGKoKSfcKyCKsuOwarkq0HGhiId+N\n\tanDyhG7pzzjer8zNyDlSYCqPq7uHF3uVr4GEk2geprh+Dk0q5qA+sx+gTUg3FboCIX\n\tw8qHsXTyqJhesnvwKTCvSeZBsCKinI6foy2ZKrdSchGBcYJ6fmsxBytF6+8huNObbA\n\tLMsw+Pz6HOPauCDPFIv27UIjS7Gr91DNhydH/rxw1CQkFMn5F05mPvMqLvV8crvmOh\n\tEOYBDl5yGvpTQ==","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=w2V02RKBfRqnzfen6tsvXrw2no3e3coAJ3zggKTkg3E=;\n\tb=Gf3s6X9bXF0k0h57ByXdC2oQe1Ek1ZsHSywtL5jKZtwzT/8SwlCZHTFPJXWRJTizCl\n\tqjyoB4YOxFi0k1hBYMbixYNrjTlbNOCtPrFC8VMtz1HxW//oqNEYL1i/jW5I/Blwo5qP\n\tiCbZyWDA7UFPCDd/gFs/Uikhsgjf5JfcwXaz4xAL14Sz09iJclRDj4f0dSjWEKqNqlYp\n\tArUNtoZu2NXD987JFi2+jPvZvoL06b5lhOkNmZPZhRDslg2j7DGzDlZb+YoSLk0fJLK+\n\t7OWsnQnfEYEbIvWHFPqZT6dGIDPuqokkEN2qXObEZX80miWTGIF5mvYiWI0Th1O3vV6n\n\t66eg=="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"Gf3s6X9b\"; 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=w2V02RKBfRqnzfen6tsvXrw2no3e3coAJ3zggKTkg3E=;\n\tb=eclsEh1MLI8xNuLciE69hmNAl4pjCNa4/aP8Wq7SzHyw+GJHpdJ5DYnV3EVkrvw1KY\n\t+aBOslWsNlU3nCWQGYAQkKx4DioRO78xsfZCmS6xYhg7cXkCSgNeeVclGfE+4lhy7T7D\n\tT6jaJVNSS0JtMpU2dvZIHzfhhISQj1VCjTWAoZ4aiHOhOQSQuHbSg4J0FPWXW6KGPM1D\n\tqZQEYmKgGDbtMC6MdK1ZGORBTtM2ojucTZnKmLMOsZMS6hAyKZWndddY9lBMxMtkeRVq\n\tE/90/E0pZWY+ZqZOjVu9fpiZDhRRxFCNQjeOOK541truVIil5W8QSMXW0cNhvpAqGaDB\n\tDgBw==","X-Gm-Message-State":"AOAM530Ksf+BmUgmQwkt1FtgxcLxICg1jgqE0GVHdnPBHieSFS+w5UJh\n\tvcKSWhciornU1AOAC7pu5+4ZgcyyUx/XrA==","X-Google-Smtp-Source":"ABdhPJx1cGm/eb36D5y+DJsP7WoF8VJav4jlYZYXLI1bbpmWgdwI3vPqoT4zpFnYEeshegmzxM2oPA==","X-Received":"by 2002:a5d:6d8b:0:b0:203:f9b4:be1d with SMTP id\n\tl11-20020a5d6d8b000000b00203f9b4be1dmr5669066wrs.298.1649231947058; \n\tWed, 06 Apr 2022 00:59:07 -0700 (PDT)","To":"libcamera-devel@lists.libcamera.org","Date":"Wed,  6 Apr 2022 08:58:59 +0100","Message-Id":"<20220406075859.3857121-4-naush@raspberrypi.com>","X-Mailer":"git-send-email 2.25.1","In-Reply-To":"<20220406075859.3857121-1-naush@raspberrypi.com>","References":"<20220406075859.3857121-1-naush@raspberrypi.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v4 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>\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.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","v4","3/3"]}