[{"id":25611,"web_url":"https://patchwork.libcamera.org/comment/25611/","msgid":"<166680253633.2677993.14524847649738207898@Monstersaurus>","date":"2022-10-26T16:42:16","subject":"Re: [libcamera-devel] [PATCH v4 3/7] tests: delayed_controls: Add\n\tcookie value test","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Naushir Patuck via libcamera-devel (2022-10-19 10:01:03)\n> Add a test for passing and returning cookie values in DelayedControls.\n> \n> Signed-off-by: Naushir Patuck <naush@raspberrypi.com>\n> Reviewed-by: David Plowman <david.plowman@raspberrypi.com>\n> ---\n>  test/delayed_controls.cpp | 44 +++++++++++++++++++++++++++++++++++++++\n>  1 file changed, 44 insertions(+)\n> \n> diff --git a/test/delayed_controls.cpp b/test/delayed_controls.cpp\n> index 322c545998b2..5cc7d3aed4fd 100644\n> --- a/test/delayed_controls.cpp\n> +++ b/test/delayed_controls.cpp\n> @@ -267,6 +267,45 @@ protected:\n>                 return TestPass;\n>         }\n>  \n> +       int cookieValue()\n> +       {\n> +               std::unordered_map<uint32_t, DelayedControls::ControlParams> delays = {\n> +                       { V4L2_CID_BRIGHTNESS, { 1, false } },\n> +               };\n> +               std::unique_ptr<DelayedControls> delayed =\n> +                       std::make_unique<DelayedControls>(dev_.get(), delays);\n> +               ControlList ctrls;\n> +\n> +               /* Set a cookie to the reset value. */\n> +               const unsigned int startCookie = 0x1234;\n> +               ctrls.set(V4L2_CID_BRIGHTNESS, 1);\n> +               dev_->setControls(&ctrls);\n> +               delayed->reset(startCookie);\n> +\n> +               /* Trigger the first frame start event */\n> +               delayed->applyControls(0);\n> +\n> +               for (unsigned int i = 1; i < 100; i++) {\n> +                       ctrls.set(V4L2_CID_BRIGHTNESS, 1);\n> +                       delayed->push(ctrls, startCookie + i);\n> +\n> +                       delayed->applyControls(i);\n\nThe interesting part might be what happens in the event that the pushs\nand the applyControls() get out of sync. I think there's something that\ninternally propogates to push another set of controls on or such ?\n\nDoes that just propogate the cookie forwards from the previous one too?\n\n\n\n> +\n> +                       auto [result, cookie] = delayed->get(i);\n> +                       unsigned int expected = startCookie + i - 1;\n> +                       if (cookie != expected) {\n> +                               cerr << \"Failed cookie value\"\n> +                                    << \" frame \" << i\n> +                                    << \" expected cookie \" << expected\n> +                                    << \" got cookie \" << cookie\n> +                                    << endl;\n> +                               return TestFail;\n> +                       }\n> +               }\n> +\n> +               return TestPass;\n> +       }\n> +\n>         int run() override\n>         {\n>                 int ret;\n> @@ -291,6 +330,11 @@ protected:\n>                 if (ret)\n>                         return ret;\n>  \n> +               /* Test cookie values. */\n> +               ret = cookieValue();\n> +               if (ret)\n> +                       return ret;\n> +\n>                 return TestPass;\n>         }\n>  \n> -- \n> 2.25.1\n>","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 DF9C5BD16B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 26 Oct 2022 16:42:21 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 433C962F62;\n\tWed, 26 Oct 2022 18:42:21 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 1491061F4B\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 26 Oct 2022 18:42:19 +0200 (CEST)","from pendragon.ideasonboard.com\n\t(cpc89244-aztw30-2-0-cust3082.18-1.cable.virginm.net [86.31.172.11])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 928714F8;\n\tWed, 26 Oct 2022 18:42:18 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1666802541;\n\tbh=G16ec0nJxrJjVRM4d1/5SYEg8ZKqAe/5csnt3X2q1N0=;\n\th=In-Reply-To:References:To:Date:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:\n\tFrom;\n\tb=KFbqPIMKN7nDbFzymlemUWtjzVfpHFakLnE+2YEkzxGIel0ADHfE1oIM7ZY25BZk3\n\tOy5aavV4hbqNYQAU6YxcEiKAiIGKjjtYKE0LcuBQXkEZ98nC+ICtywS3U9m7fMbPxZ\n\t1rZv9bolQ9cuzXdzKLpK1kEyYb1N9++5gwQOJvKkelJPlQnnX14ItwMhfWreA2zeH/\n\tiZFwNYSVnKVkFlR/ZwpnA2wTw8eQGGC81Td5tpLCmQKOy7w9wbkJ2GJqcmg9jLEPgA\n\tRu79aq7OzIGD2/zZFBm+N4vsq76QCemyUesBCdCUDlWlKqAAHFRsgweCwl5UHWLUmF\n\tsnNyKmgD1vATw==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1666802538;\n\tbh=G16ec0nJxrJjVRM4d1/5SYEg8ZKqAe/5csnt3X2q1N0=;\n\th=In-Reply-To:References:Subject:From:To:Date:From;\n\tb=WfFqvulO1EWm2wEkGpb7eMQc0WnUb4s6JI/txTrjSWOh3wHMA+0HFa2tMGez1IpY4\n\t9gCUWiWB4YoG7VgEQc0ShesaYlKQ4tfAzjsMP7VygAR/T3fysv6L1zqlWOLSTkyO+t\n\t9GbgoBMHmiAaIRYgppSZP8+KSTOR6ZApBf4r9S88="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"WfFqvulO\"; dkim-atps=neutral","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20221019090107.19975-4-naush@raspberrypi.com>","References":"<20221019090107.19975-1-naush@raspberrypi.com>\n\t<20221019090107.19975-4-naush@raspberrypi.com>","To":"Naushir Patuck <naush@raspberrypi.com>,\n\tlibcamera-devel@lists.libcamera.org","Date":"Wed, 26 Oct 2022 17:42:16 +0100","Message-ID":"<166680253633.2677993.14524847649738207898@Monstersaurus>","User-Agent":"alot/0.10","Subject":"Re: [libcamera-devel] [PATCH v4 3/7] tests: delayed_controls: Add\n\tcookie value test","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":"Kieran Bingham via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":25621,"web_url":"https://patchwork.libcamera.org/comment/25621/","msgid":"<CAEmqJPokDqMWo_iW=2u+hXMq3btQ-ef7tdummJ94=iO4VW+5Eg@mail.gmail.com>","date":"2022-10-27T09:38:36","subject":"Re: [libcamera-devel] [PATCH v4 3/7] tests: delayed_controls: Add\n\tcookie value test","submitter":{"id":34,"url":"https://patchwork.libcamera.org/api/people/34/","name":"Naushir Patuck","email":"naush@raspberrypi.com"},"content":"Hi Kieran,\n\nThanks for your review.\n\nOn Wed, 26 Oct 2022 at 17:42, Kieran Bingham <\nkieran.bingham@ideasonboard.com> wrote:\n\n> Quoting Naushir Patuck via libcamera-devel (2022-10-19 10:01:03)\n> > Add a test for passing and returning cookie values in DelayedControls.\n> >\n> > Signed-off-by: Naushir Patuck <naush@raspberrypi.com>\n> > Reviewed-by: David Plowman <david.plowman@raspberrypi.com>\n> > ---\n> >  test/delayed_controls.cpp | 44 +++++++++++++++++++++++++++++++++++++++\n> >  1 file changed, 44 insertions(+)\n> >\n> > diff --git a/test/delayed_controls.cpp b/test/delayed_controls.cpp\n> > index 322c545998b2..5cc7d3aed4fd 100644\n> > --- a/test/delayed_controls.cpp\n> > +++ b/test/delayed_controls.cpp\n> > @@ -267,6 +267,45 @@ protected:\n> >                 return TestPass;\n> >         }\n> >\n> > +       int cookieValue()\n> > +       {\n> > +               std::unordered_map<uint32_t,\n> DelayedControls::ControlParams> delays = {\n> > +                       { V4L2_CID_BRIGHTNESS, { 1, false } },\n> > +               };\n> > +               std::unique_ptr<DelayedControls> delayed =\n> > +                       std::make_unique<DelayedControls>(dev_.get(),\n> delays);\n> > +               ControlList ctrls;\n> > +\n> > +               /* Set a cookie to the reset value. */\n> > +               const unsigned int startCookie = 0x1234;\n> > +               ctrls.set(V4L2_CID_BRIGHTNESS, 1);\n> > +               dev_->setControls(&ctrls);\n> > +               delayed->reset(startCookie);\n> > +\n> > +               /* Trigger the first frame start event */\n> > +               delayed->applyControls(0);\n> > +\n> > +               for (unsigned int i = 1; i < 100; i++) {\n> > +                       ctrls.set(V4L2_CID_BRIGHTNESS, 1);\n> > +                       delayed->push(ctrls, startCookie + i);\n> > +\n> > +                       delayed->applyControls(i);\n>\n> The interesting part might be what happens in the event that the pushs\n> and the applyControls() get out of sync. I think there's something that\n> internally propogates to push another set of controls on or such ?\n>\n> Does that just propogate the cookie forwards from the previous one too?\n>\n\nYes it does!  The advantage of using DelayedControls to track everything\nmeans\nwe effectively get this sync handling for free.\n\nI'll add another test to this patch that exercises exactly this behavior.\n\nRegards,\nNaush\n\n\n>\n>\n>\n> > +\n> > +                       auto [result, cookie] = delayed->get(i);\n> > +                       unsigned int expected = startCookie + i - 1;\n> > +                       if (cookie != expected) {\n> > +                               cerr << \"Failed cookie value\"\n> > +                                    << \" frame \" << i\n> > +                                    << \" expected cookie \" << expected\n> > +                                    << \" got cookie \" << cookie\n> > +                                    << endl;\n> > +                               return TestFail;\n> > +                       }\n> > +               }\n> > +\n> > +               return TestPass;\n> > +       }\n> > +\n> >         int run() override\n> >         {\n> >                 int ret;\n> > @@ -291,6 +330,11 @@ protected:\n> >                 if (ret)\n> >                         return ret;\n> >\n> > +               /* Test cookie values. */\n> > +               ret = cookieValue();\n> > +               if (ret)\n> > +                       return ret;\n> > +\n> >                 return TestPass;\n> >         }\n> >\n> > --\n> > 2.25.1\n> >\n>","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 21DA7BDB16\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 27 Oct 2022 09:38:55 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 5FCB862F6F;\n\tThu, 27 Oct 2022 11:38:54 +0200 (CEST)","from mail-qk1-x732.google.com (mail-qk1-x732.google.com\n\t[IPv6:2607:f8b0:4864:20::732])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 292ED62F69\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 27 Oct 2022 11:38:53 +0200 (CEST)","by mail-qk1-x732.google.com with SMTP id j21so427030qkk.9\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 27 Oct 2022 02:38:53 -0700 (PDT)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1666863534;\n\tbh=QV4BqUwXiwQq7Hmz30/lExxo3fisR86BhU0/loC/RSY=;\n\th=References:In-Reply-To:Date:To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=qNQkT0kOmqFOkk0el88YFCVTDpVwqhRN/uw/dwbjcTK0yda1LxstyOK09aj5ZsKC7\n\trfAcV7W0CyN8ALZmvgoM1xPn3qvFjI+NzWRMSaHkEXbgFRcPNoKpiPDBkzh6DVFn4K\n\tbo2VDbAsdqT6bpr85bTpP6B2r8PosmnEtxMUNCvbnpQMrsrPlPN5kWWVBp5ktA8tcw\n\tK10LI3ciTI5M38RQkB8RgDacR6IPI8GCO7jr+0lVlgG/nRN7wcu8V96sXVOSYpkSTS\n\tfhtOoNd5MolNnB18/uyEmiafzF7zDcLoFvIUytUcbjOt6TVpEp1wxIafPbuLJpshkV\n\ti/1bU4X/q8xKQ==","v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google;\n\th=cc:to:subject:message-id:date:from:in-reply-to:references\n\t:mime-version:from:to:cc:subject:date:message-id:reply-to;\n\tbh=Cqm3iRaiPxR81QddUmBm4kDL3mtfO5qzPZ5R1wM1T7I=;\n\tb=e+RaHYHRaeeGsRiBtG5JdwX+XDT9cVQGswMhYQMncMd8V+zZLov70pHt+MEBG3Gj5H\n\tR6SnQlKwoycy85EpGgR/CYndAuI5P7ZfuQ752NwSX1Lzs9dpFnX2vSNmH+ASMJI6p6et\n\tPPMqM91u9NI1yKi04xhrm2h+jMS4VFgE1SkRhRIUk15eln+Pq05/NPzg4W+OSHQyJYVE\n\tj6A9U9vjK9d7FZlb3CmsiSCSmFe2nu+UuZHKiUtaVAV08v8Z0O2ZEkf183TNtqxnyHbB\n\tSF9P6pSANOTx8lOxQu/93MG7vDh1PrZtjxD8TDVgH7RciIF8r5hHV0PWxAHacZuQgCpp\n\tL7lw=="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"e+RaHYHR\"; dkim-atps=neutral","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\n\th=cc:to:subject:message-id:date:from:in-reply-to:references\n\t:mime-version:x-gm-message-state:from:to:cc:subject:date:message-id\n\t:reply-to;\n\tbh=Cqm3iRaiPxR81QddUmBm4kDL3mtfO5qzPZ5R1wM1T7I=;\n\tb=qibUmarn1mTzMmSOxT9enJ0KpJJg/llY7G3LpoXtpBJoEt8oc1JTXXUfOIV8PedAoW\n\t95E7UUJUchAhUW1s2llXbZqYIFUcb3byMsR3SZzuAVks4t4sEklNgbgZ4IaoGW1LnTvj\n\t3Fs8KI7nXDgkOundAkwcaRgmdTxtKXVvf7WkPVZAatpes0J3oL4xf/Fjdbe4OG6hM3cI\n\tOtTiUSSCUgW3oRCikjFfnZd1kAqArVlqzta0qVcDV4uwWep9Gydtx5QbERywhUAsXNAB\n\tz5UKp/hmkoGi9yW/fsaZyqRKBzeh0ZPLUtxYxsFNkhERrvpu1eeJdxRr/TgsxQxscEYT\n\tjj7g==","X-Gm-Message-State":"ACrzQf101gCo5C/3rTs1n4b+Ay7xsOJ5yJHQ8r0qWTjtE1ynhwBNlR8H\n\tZ4Zw8rYvZIbaeoeNmhiLxh6ZdWwLGmwX0e69sMgtIuL6TAJsew==","X-Google-Smtp-Source":"AMsMyM7naegvsvLd8HMI6uVY02DTlNtcR1hhPfY5sfy3Iw5bZivD93EvOXRMuM6lWQnVilZ5pevvr/chRL6Q/nGYSAA=","X-Received":"by 2002:a37:f502:0:b0:6f8:c3b2:51b9 with SMTP id\n\tl2-20020a37f502000000b006f8c3b251b9mr6305804qkk.616.1666863532126;\n\tThu, 27 Oct 2022 02:38:52 -0700 (PDT)","MIME-Version":"1.0","References":"<20221019090107.19975-1-naush@raspberrypi.com>\n\t<20221019090107.19975-4-naush@raspberrypi.com>\n\t<166680253633.2677993.14524847649738207898@Monstersaurus>","In-Reply-To":"<166680253633.2677993.14524847649738207898@Monstersaurus>","Date":"Thu, 27 Oct 2022 10:38:36 +0100","Message-ID":"<CAEmqJPokDqMWo_iW=2u+hXMq3btQ-ef7tdummJ94=iO4VW+5Eg@mail.gmail.com>","To":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Content-Type":"multipart/alternative; boundary=\"000000000000b8c2af05ec00e8b5\"","Subject":"Re: [libcamera-devel] [PATCH v4 3/7] tests: delayed_controls: Add\n\tcookie value test","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>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]