From patchwork Wed Apr 6 12:35:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 15633 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 6887CC0F1B for ; Wed, 6 Apr 2022 12:36:07 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 1A0F46564E; Wed, 6 Apr 2022 14:36:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1649248567; bh=8Ewq6FpKQZHfDJbvneE/YsIROH3JjdaudrsCD96DizA=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=xqZt00pT7ejWTK3I+97oeT68qMK8H/6LVxAJLmxtdivz4H7KtSkYPR0wv6Cpds+k3 sCfiZVC0xIkJ6ji+JS3Q+dCV9oLyeRWlnDC2//IQ+/iwRWAXDrz3UdAfDoInqFpSd2 /Cqtf5RH2mUTnjM1Y/UTckmFlTAXa611ByYdmpC6mfBn5ydIC6O9L/66xIBUURZ9SY SkqpjzbyIUrh/s17NTsL6/t6acYqhstpJXZqukfpbUvhGpAp9I2Em03qIZ2jTz+qrg S63HyMgBoz8GZ1wcu2ukTnOcnqicE/L8Jmu8YYV/j/BFDDPYBCwneQAvO4QODwCi/V tIChoBZ+QHDmw== Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 81B3065651 for ; Wed, 6 Apr 2022 14:36:04 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="M/yRwrFb"; dkim-atps=neutral Received: by mail-wm1-x32c.google.com with SMTP id n38-20020a05600c502600b0038e4a0fc5easo1535121wmr.3 for ; Wed, 06 Apr 2022 05:36:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=w2V02RKBfRqnzfen6tsvXrw2no3e3coAJ3zggKTkg3E=; b=M/yRwrFbX7sjNbJ/SbribQDUohCF4JIJ0kpAH1ZXWqt4jwYdZeEeUpBu4HxqVshRzp Rdnjear8rc0LbIFNvgDavHKgsf3WoH/V5T3kLdIv493DsgkxS3pJK1fcuoPpCG+uPkAE QTAD2i6o/eP1BVFq+WbAFFAUzY6fPRs3uvgMIJUK2hE8XLITRe3cjrWhgJhGqZCujwms Q55tkUd7AFeqvAL9gW25Y5H+ceA6R1ds5oPeq/0DS1uX59zbDEolfHRAXiRRn71MBZHs mAbCUI71DEb9C0hG6EeKNoNf5gBaQxh+hAxDdAXtGxBUxMTWVCbxy8lDrx6srQmfqAc8 Z4JQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=w2V02RKBfRqnzfen6tsvXrw2no3e3coAJ3zggKTkg3E=; b=8Ck8AdwTlDDEotu8YM5lRg9hJjO0waujmWTtogyml7IROsv/1U7P9ProJqM3yCFcHr 0QZl1EHmF/Zr60qthalm/7lIfCQbh7Va8bckKc0I/uwJnWaOfl2Jj9P7N1DHtlYNUsWp Q4Kq/MY1HrJM8yh4+xCxpmmetfZ4JYENXhulKh0kwOMx+IcLkIBqiVk+KuA5THgdx/3V D9NAXQ7hlEPHmBNhGLxJkSouJppkAiCWc8No6fdrJ0cbZ4QwXDk/2c+gFfc/sZ+HYGE3 l2D81vKz/3WB0QgF8gp0b2q0uoOxrhfj1zTJDSFW+SQVcZfP8KT6k40IHK2ZN1c4UJ2l 27Cw== X-Gm-Message-State: AOAM533ovVuYHFpNdb3Fvhw+D/8fLntz/Cc1SU0ffrcDuSLQ4kwQqVJj mdRGapPZWYphzn3Qd4n6Dyl2CyMBMX4bmw== X-Google-Smtp-Source: ABdhPJz5Pg6aOiap8zaQryEZxnbe8xY5AamC7Ilc3b5LU14PUM8Ogc+TCs0QI29jXseiADXG1nyvTA== X-Received: by 2002:a05:600c:4f86:b0:38c:bd13:e074 with SMTP id n6-20020a05600c4f8600b0038cbd13e074mr7411880wmq.97.1649248563839; Wed, 06 Apr 2022 05:36:03 -0700 (PDT) Received: from naush-laptop.pitowers.org ([2a00:1098:3142:14:8464:e7f5:f44c:ee9f]) by smtp.gmail.com with ESMTPSA id p8-20020a5d59a8000000b00204178688d3sm16712490wrr.100.2022.04.06.05.36.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Apr 2022 05:36:03 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Wed, 6 Apr 2022 13:35:54 +0100 Message-Id: <20220406123554.4042163-4-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220406123554.4042163-1-naush@raspberrypi.com> References: <20220406123554.4042163-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v5 3/3] test: v4l2_videodevice: Verify the Dequeue Watchdog X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Naushir Patuck via libcamera-devel From: Naushir Patuck Reply-To: Naushir Patuck Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" From: Kieran Bingham Add a test that captures 5 frames, with a short (5ms) watchdog. The default framerate of the VIMC pipeline should ensure that we never meet this watchdog, and the timeout should activate. Signed-off-by: Kieran Bingham Signed-off-by: Naushir Patuck Reviewed-by: Laurent Pinchart --- test/v4l2_videodevice/dequeue_watchdog.cpp | 96 ++++++++++++++++++++++ test/v4l2_videodevice/meson.build | 1 + 2 files changed, 97 insertions(+) create mode 100644 test/v4l2_videodevice/dequeue_watchdog.cpp diff --git a/test/v4l2_videodevice/dequeue_watchdog.cpp b/test/v4l2_videodevice/dequeue_watchdog.cpp new file mode 100644 index 000000000000..0cb4de6f81a0 --- /dev/null +++ b/test/v4l2_videodevice/dequeue_watchdog.cpp @@ -0,0 +1,96 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * Copyright (C) 2022, Ideas on Board Oy. + * + * libcamera V4L2 dequeue watchdog test + */ + +#include + +#include +#include +#include + +#include + +#include "v4l2_videodevice_test.h" + +using namespace libcamera; +using namespace std::chrono_literals; + +class DequeueWatchdogTest : public V4L2VideoDeviceTest +{ +public: + DequeueWatchdogTest() + : V4L2VideoDeviceTest("vimc", "Raw Capture 0"), frames_(0), barks_(0) {} + +protected: + int run() + { + constexpr unsigned int bufferCount = 8; + + EventDispatcher *dispatcher = Thread::current()->eventDispatcher(); + Timer timeout; + + int ret = capture_->allocateBuffers(bufferCount, &buffers_); + if (ret < 0) + return TestFail; + + capture_->dequeueTimeout.connect(this, &DequeueWatchdogTest::barkCounter); + capture_->setDequeueTimeout(5ms); + + capture_->bufferReady.connect(this, &DequeueWatchdogTest::receiveBuffer); + + for (const std::unique_ptr &buffer : buffers_) { + if (capture_->queueBuffer(buffer.get())) { + std::cout << "Failed to queue buffer" << std::endl; + return TestFail; + } + } + + capture_->streamOn(); + + timeout.start(5s); + while (timeout.isRunning()) { + dispatcher->processEvents(); + if (frames_ > 5) + break; + } + + std::cout << "Processed " << frames_ << " frames_ and heard " + << barks_ << " barks_" << std::endl; + + if (!barks_) { + std::cout << "Failed to hear any barks_." << std::endl; + return TestFail; + } + + capture_->streamOff(); + + return TestPass; + } + +private: + void receiveBuffer(FrameBuffer *buffer) + { + if (buffer->metadata().status == FrameMetadata::FrameCancelled) + return; + + std::cout << "Buffer received" << std::endl; + frames_++; + + /* Requeue the buffer for further use. */ + capture_->queueBuffer(buffer); + } + + void barkCounter() + { + std::cout << "Watchdog is barking" << std::endl; + barks_++; + } + + unsigned int frames_; + unsigned int barks_; +}; + +TEST_REGISTER(DequeueWatchdogTest) diff --git a/test/v4l2_videodevice/meson.build b/test/v4l2_videodevice/meson.build index 643f82edce5e..7a26f53d106a 100644 --- a/test/v4l2_videodevice/meson.build +++ b/test/v4l2_videodevice/meson.build @@ -6,6 +6,7 @@ v4l2_videodevice_tests = [ ['double_open', 'double_open.cpp'], ['controls', 'controls.cpp'], ['formats', 'formats.cpp'], + ['dequeue_watchdog', 'dequeue_watchdog.cpp'], ['request_buffers', 'request_buffers.cpp'], ['buffer_cache', 'buffer_cache.cpp'], ['stream_on_off', 'stream_on_off.cpp'],