{"id":17738,"url":"https://patchwork.libcamera.org/api/1.1/patches/17738/?format=json","web_url":"https://patchwork.libcamera.org/patch/17738/","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":"<20221031114522.14215-4-naush@raspberrypi.com>","date":"2022-10-31T11:45:18","name":"[libcamera-devel,v5,3/7] tests: delayed_controls: Add cookie tests","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"17b652d9b2371ea8c757c5a704ba453a8ac0c909","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/17738/mbox/","series":[{"id":3590,"url":"https://patchwork.libcamera.org/api/1.1/series/3590/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=3590","date":"2022-10-31T11:45:15","name":"Raspberry Pi AGC digital gain fixes","version":5,"mbox":"https://patchwork.libcamera.org/series/3590/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/17738/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/17738/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 24559C3286\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 31 Oct 2022 11:45:35 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id AF07A6304B;\n\tMon, 31 Oct 2022 12:45:34 +0100 (CET)","from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com\n\t[IPv6:2a00:1450:4864:20::42b])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 892E163041\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 31 Oct 2022 12:45:30 +0100 (CET)","by mail-wr1-x42b.google.com with SMTP id g12so15565478wrs.10\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 31 Oct 2022 04:45:30 -0700 (PDT)","from naush-laptop.localdomain ([93.93.133.154])\n\tby smtp.gmail.com with ESMTPSA id\n\th11-20020adff18b000000b0023677e1157fsm6936354wro.56.2022.10.31.04.45.29\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tMon, 31 Oct 2022 04:45:29 -0700 (PDT)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1667216734;\n\tbh=YgGiKgMXIahXa21Lh6ZR4WbW075cAGL5YbEd7/YWnH0=;\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=XBVUGKoqSBpcp2Dq/xQErvEtFyax82Vc1g/w7jvdALMLdNwmliAl5EWsgLlzdkTy2\n\t39aEM4oibjqTiZfSpRAnRurCGLlk1wx9uDAMGHdEvFtGzleqVO3yokYT+mkc00Zx9R\n\tknJor4xFoCzCWCZEEX5/CqlLWy348WIZAPsCYW9HYPEkViALfjWSLfwAXOG7CA/7xi\n\t8gPH64ZRH72zQSFBBQPcRSGRn+jTDEHIsaWyyXlRQVpCR0oiEB8d9pgoWGyLm0JQRZ\n\teHZV0ZnktMHw6fT5ot0Y5bQORmVACpjHDzYoFa6W0pbvzD800kFTPKNFDSVhIDEF40\n\tSmdsqCnrAl8oQ==","v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google;\n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:from:to:cc:subject:date\n\t:message-id:reply-to;\n\tbh=3Hub9huiA2Fp5q/ldBR20j+lQfHfA0OwAhO+e2na52o=;\n\tb=FelnHXryaept3bVwmE6Ay19SG9LY3VOtLbNxW3F0notR/kOU0o/V4pL51BrYmFgn93\n\tukZC5cVHIddtTM/4Lf/rgiKT4kz+IACMtGOdlJHkyXeECGgv3nxSp9s9RILdY/Z45mdl\n\tZRd4NovKzMwDlWxpSvbyoyOW6jpIMHjjAVcoj3m0hEhzKE2+Pv8yoqjKBAGg5TPtzf8k\n\tAPrrPudEEObINzjqVedB2A7fgltLtPynjfdExRJoHbaLcdwx87pTaVn+dYrXFwlzrsrl\n\tipfvxHZjDri+y2IjqWIY+42DUrHxv7bNZkuj4rpFF3Yy95Hkd/XqYhk9fosLp8UAf7fW\n\tuLMg=="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"FelnHXry\"; dkim-atps=neutral","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc\n\t:subject:date:message-id:reply-to;\n\tbh=3Hub9huiA2Fp5q/ldBR20j+lQfHfA0OwAhO+e2na52o=;\n\tb=J80LSBZq+sVAnI9ZpBU0HPn8+u6kgWjssPgOAMV1GDAUMOmZhsonDyv9fRby+65Ivt\n\tN6tKkVz8McP85uYU7l9je3mNeRTBLCabVlQ1BeRspj9BihIUsTcgau1+fvG2vq3+khm7\n\tSrl5XdW21LAauWe27tB38hHq2I7ElvJLnkcW9LYK2P7jU25idBpK56fEnTieAl7T1rhH\n\t09HfvglJrSjKB0DfEJp/bUwtM/NFJyplSJwWRMVkzkCocf1PP0hSPD2sc9CcF3Vn3Bqs\n\tVn0rIJIWsphgaJDOlD2oe8cl/J2x/xpAk6xAfz1PUlPyhUEiaMdy3LvnuE2BaIY4Z/ax\n\troYQ==","X-Gm-Message-State":"ACrzQf2u2G3RnitGEQIksTaxx7n7/bDdTmf+PDc5zNcQkh+cmSNlc1rb\n\tWVeqWN7N5HJHdLUFSTtilyyr9NApFF1Y7g==","X-Google-Smtp-Source":"AMsMyM4KE1gzZGVWuM/7OpDp9vukE1ea+fqXws1GhH59PAtRkdhkYzeCsvJT5DTtoqgxOg7PitxVDA==","X-Received":"by 2002:a5d:6743:0:b0:236:6301:918 with SMTP id\n\tl3-20020a5d6743000000b0023663010918mr7830577wrw.247.1667216729648; \n\tMon, 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","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v5 3/7] tests: delayed_controls: Add\n\tcookie tests","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":"Add a test for passing and returning cookie values in DelayedControls.\nAdd a test to simulate frame skips ensuring cookie values are returned\ncorrectly.\n\nSigned-off-by: Naushir Patuck <naush@raspberrypi.com>\nReviewed-by: David Plowman <david.plowman@raspberrypi.com>\n---\n test/delayed_controls.cpp | 97 +++++++++++++++++++++++++++++++++++++++\n 1 file changed, 97 insertions(+)","diff":"diff --git a/test/delayed_controls.cpp b/test/delayed_controls.cpp\nindex 26037268f245..387958a339a2 100644\n--- a/test/delayed_controls.cpp\n+++ b/test/delayed_controls.cpp\n@@ -267,6 +267,93 @@ protected:\n \t\treturn TestPass;\n \t}\n \n+\tint cookieValue()\n+\t{\n+\t\tstd::unordered_map<uint32_t, DelayedControls::ControlParams> delays = {\n+\t\t\t{ V4L2_CID_BRIGHTNESS, { 1, false } },\n+\t\t};\n+\t\tstd::unique_ptr<DelayedControls> delayed =\n+\t\t\tstd::make_unique<DelayedControls>(dev_.get(), delays);\n+\t\tControlList ctrls;\n+\n+\t\t/* Set a cookie to the reset value. */\n+\t\tconst unsigned int startCookie = 0x1234;\n+\t\tctrls.set(V4L2_CID_BRIGHTNESS, 1);\n+\t\tdev_->setControls(&ctrls);\n+\t\tdelayed->reset(startCookie);\n+\n+\t\t/* Trigger the first frame start event */\n+\t\tdelayed->applyControls(0);\n+\n+\t\tfor (unsigned int i = 1; i < 100; i++) {\n+\t\t\tctrls.set(V4L2_CID_BRIGHTNESS, 1);\n+\t\t\tdelayed->push(ctrls, startCookie + i);\n+\n+\t\t\tdelayed->applyControls(i);\n+\n+\t\t\tauto [result, cookie] = delayed->get(i);\n+\t\t\tunsigned int expected = startCookie + i - 1;\n+\t\t\tif (cookie != expected) {\n+\t\t\t\tcerr << \"Failed cookie value\"\n+\t\t\t\t     << \" frame \" << i\n+\t\t\t\t     << \" expected cookie \" << expected\n+\t\t\t\t     << \" got cookie \" << cookie\n+\t\t\t\t     << endl;\n+\t\t\t\treturn TestFail;\n+\t\t\t}\n+\t\t}\n+\n+\t\treturn TestPass;\n+\t}\n+\n+\tint cookieSkip()\n+\t{\n+\t\tstd::unordered_map<uint32_t, DelayedControls::ControlParams> delays = {\n+\t\t\t{ V4L2_CID_BRIGHTNESS, { 1, false } },\n+\t\t};\n+\t\tstd::unique_ptr<DelayedControls> delayed =\n+\t\t\tstd::make_unique<DelayedControls>(dev_.get(), delays);\n+\t\tControlList ctrls;\n+\n+\t\t/* Set a cookie to the reset value. */\n+\t\tunsigned int cookie = 0x1234;\n+\t\tctrls.set(V4L2_CID_BRIGHTNESS, 1);\n+\t\tdev_->setControls(&ctrls);\n+\t\tdelayed->reset(cookie);\n+\n+\t\t/* Trigger the first frame start event */\n+\t\tdelayed->applyControls(0);\n+\n+\t\tunsigned int expected = cookie++;\n+\t\tfor (unsigned int i = 1; i < 100; i++) {\n+\t\t\t/*\n+\t\t\t * Send a control for 2 out of every 3 frames, simulating\n+\t\t\t * some frame skips.\n+\t\t\t */\n+\t\t\tif (i % 3) {\n+\t\t\t\tctrls.set(V4L2_CID_BRIGHTNESS, 1);\n+\t\t\t\tdelayed->push(ctrls, cookie);\n+\t\t\t}\n+\n+\t\t\tdelayed->applyControls(i);\n+\n+\t\t\tauto [result, getCookie] = delayed->get(i);\n+\t\t\tif (expected != getCookie) {\n+\t\t\t\tcerr << \"Failed cookie value\"\n+\t\t\t\t     << \" frame \" << i\n+\t\t\t\t     << \" expected cookie \" << expected\n+\t\t\t\t     << \" got cookie \" << getCookie\n+\t\t\t\t     << endl;\n+\t\t\t\treturn TestFail;\n+\t\t\t}\n+\n+\t\t\tif (i % 3)\n+\t\t\t\texpected = cookie++;\n+\t\t}\n+\n+\t\treturn TestPass;\n+\t}\n+\n \tint run() override\n \t{\n \t\tint ret;\n@@ -291,6 +378,16 @@ protected:\n \t\tif (ret)\n \t\t\treturn ret;\n \n+\t\t/* Test cookie values. */\n+\t\tret = cookieValue();\n+\t\tif (ret)\n+\t\t\treturn ret;\n+\n+\t\t/* Test cookie values with frame skips. */\n+\t\tret = cookieSkip();\n+\t\tif (ret)\n+\t\t\treturn ret;\n+\n \t\treturn TestPass;\n \t}\n \n","prefixes":["libcamera-devel","v5","3/7"]}