From patchwork Mon Oct 31 11:45:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 17738 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 24559C3286 for ; Mon, 31 Oct 2022 11:45:35 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id AF07A6304B; Mon, 31 Oct 2022 12:45:34 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1667216734; bh=YgGiKgMXIahXa21Lh6ZR4WbW075cAGL5YbEd7/YWnH0=; 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=XBVUGKoqSBpcp2Dq/xQErvEtFyax82Vc1g/w7jvdALMLdNwmliAl5EWsgLlzdkTy2 39aEM4oibjqTiZfSpRAnRurCGLlk1wx9uDAMGHdEvFtGzleqVO3yokYT+mkc00Zx9R knJor4xFoCzCWCZEEX5/CqlLWy348WIZAPsCYW9HYPEkViALfjWSLfwAXOG7CA/7xi 8gPH64ZRH72zQSFBBQPcRSGRn+jTDEHIsaWyyXlRQVpCR0oiEB8d9pgoWGyLm0JQRZ eHZV0ZnktMHw6fT5ot0Y5bQORmVACpjHDzYoFa6W0pbvzD800kFTPKNFDSVhIDEF40 SmdsqCnrAl8oQ== Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 892E163041 for ; Mon, 31 Oct 2022 12:45:30 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="FelnHXry"; dkim-atps=neutral Received: by mail-wr1-x42b.google.com with SMTP id g12so15565478wrs.10 for ; Mon, 31 Oct 2022 04:45:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=3Hub9huiA2Fp5q/ldBR20j+lQfHfA0OwAhO+e2na52o=; b=FelnHXryaept3bVwmE6Ay19SG9LY3VOtLbNxW3F0notR/kOU0o/V4pL51BrYmFgn93 ukZC5cVHIddtTM/4Lf/rgiKT4kz+IACMtGOdlJHkyXeECGgv3nxSp9s9RILdY/Z45mdl ZRd4NovKzMwDlWxpSvbyoyOW6jpIMHjjAVcoj3m0hEhzKE2+Pv8yoqjKBAGg5TPtzf8k APrrPudEEObINzjqVedB2A7fgltLtPynjfdExRJoHbaLcdwx87pTaVn+dYrXFwlzrsrl ipfvxHZjDri+y2IjqWIY+42DUrHxv7bNZkuj4rpFF3Yy95Hkd/XqYhk9fosLp8UAf7fW uLMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=3Hub9huiA2Fp5q/ldBR20j+lQfHfA0OwAhO+e2na52o=; b=J80LSBZq+sVAnI9ZpBU0HPn8+u6kgWjssPgOAMV1GDAUMOmZhsonDyv9fRby+65Ivt N6tKkVz8McP85uYU7l9je3mNeRTBLCabVlQ1BeRspj9BihIUsTcgau1+fvG2vq3+khm7 Srl5XdW21LAauWe27tB38hHq2I7ElvJLnkcW9LYK2P7jU25idBpK56fEnTieAl7T1rhH 09HfvglJrSjKB0DfEJp/bUwtM/NFJyplSJwWRMVkzkCocf1PP0hSPD2sc9CcF3Vn3Bqs Vn0rIJIWsphgaJDOlD2oe8cl/J2x/xpAk6xAfz1PUlPyhUEiaMdy3LvnuE2BaIY4Z/ax roYQ== X-Gm-Message-State: ACrzQf2u2G3RnitGEQIksTaxx7n7/bDdTmf+PDc5zNcQkh+cmSNlc1rb WVeqWN7N5HJHdLUFSTtilyyr9NApFF1Y7g== X-Google-Smtp-Source: AMsMyM4KE1gzZGVWuM/7OpDp9vukE1ea+fqXws1GhH59PAtRkdhkYzeCsvJT5DTtoqgxOg7PitxVDA== X-Received: by 2002:a5d:6743:0:b0:236:6301:918 with SMTP id l3-20020a5d6743000000b0023663010918mr7830577wrw.247.1667216729648; Mon, 31 Oct 2022 04:45:29 -0700 (PDT) Received: from naush-laptop.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id h11-20020adff18b000000b0023677e1157fsm6936354wro.56.2022.10.31.04.45.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Oct 2022 04:45:29 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Mon, 31 Oct 2022 11:45:18 +0000 Message-Id: <20221031114522.14215-4-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221031114522.14215-1-naush@raspberrypi.com> References: <20221031114522.14215-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v5 3/7] tests: delayed_controls: Add cookie tests 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" Add a test for passing and returning cookie values in DelayedControls. Add a test to simulate frame skips ensuring cookie values are returned correctly. Signed-off-by: Naushir Patuck Reviewed-by: David Plowman --- test/delayed_controls.cpp | 97 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) diff --git a/test/delayed_controls.cpp b/test/delayed_controls.cpp index 26037268f245..387958a339a2 100644 --- a/test/delayed_controls.cpp +++ b/test/delayed_controls.cpp @@ -267,6 +267,93 @@ protected: return TestPass; } + int cookieValue() + { + std::unordered_map delays = { + { V4L2_CID_BRIGHTNESS, { 1, false } }, + }; + std::unique_ptr delayed = + std::make_unique(dev_.get(), delays); + ControlList ctrls; + + /* Set a cookie to the reset value. */ + const unsigned int startCookie = 0x1234; + ctrls.set(V4L2_CID_BRIGHTNESS, 1); + dev_->setControls(&ctrls); + delayed->reset(startCookie); + + /* Trigger the first frame start event */ + delayed->applyControls(0); + + for (unsigned int i = 1; i < 100; i++) { + ctrls.set(V4L2_CID_BRIGHTNESS, 1); + delayed->push(ctrls, startCookie + i); + + delayed->applyControls(i); + + auto [result, cookie] = delayed->get(i); + unsigned int expected = startCookie + i - 1; + if (cookie != expected) { + cerr << "Failed cookie value" + << " frame " << i + << " expected cookie " << expected + << " got cookie " << cookie + << endl; + return TestFail; + } + } + + return TestPass; + } + + int cookieSkip() + { + std::unordered_map delays = { + { V4L2_CID_BRIGHTNESS, { 1, false } }, + }; + std::unique_ptr delayed = + std::make_unique(dev_.get(), delays); + ControlList ctrls; + + /* Set a cookie to the reset value. */ + unsigned int cookie = 0x1234; + ctrls.set(V4L2_CID_BRIGHTNESS, 1); + dev_->setControls(&ctrls); + delayed->reset(cookie); + + /* Trigger the first frame start event */ + delayed->applyControls(0); + + unsigned int expected = cookie++; + for (unsigned int i = 1; i < 100; i++) { + /* + * Send a control for 2 out of every 3 frames, simulating + * some frame skips. + */ + if (i % 3) { + ctrls.set(V4L2_CID_BRIGHTNESS, 1); + delayed->push(ctrls, cookie); + } + + delayed->applyControls(i); + + auto [result, getCookie] = delayed->get(i); + if (expected != getCookie) { + cerr << "Failed cookie value" + << " frame " << i + << " expected cookie " << expected + << " got cookie " << getCookie + << endl; + return TestFail; + } + + if (i % 3) + expected = cookie++; + } + + return TestPass; + } + int run() override { int ret; @@ -291,6 +378,16 @@ protected: if (ret) return ret; + /* Test cookie values. */ + ret = cookieValue(); + if (ret) + return ret; + + /* Test cookie values with frame skips. */ + ret = cookieSkip(); + if (ret) + return ret; + return TestPass; }