[{"id":38447,"web_url":"https://patchwork.libcamera.org/comment/38447/","msgid":"<CAEmqJPq6aDSFGy=qFvK3YJFNgp3MJQAHBS4R08b4cakQUC-WEg@mail.gmail.com>","date":"2026-03-30T07:38:21","subject":"Re: [PATCH v2 1/3] pipeline: rpi: Simplify delayed controls","submitter":{"id":34,"url":"https://patchwork.libcamera.org/api/people/34/","name":"Naushir Patuck","email":"naush@raspberrypi.com"},"content":"Hi David,\n\nThank you for the update.\n\nOn Fri, 27 Mar 2026 at 14:47, David Plowman\n<david.plowman@raspberrypi.com> wrote:\n>\n> The queueCount field in the DelayedControls is actually\n> redundant. Remove it.\n>\n> Signed-off-by: David Plowman <david.plowman@raspberrypi.com>\n\nReviewed-by: Naushir Patuck <naush@raspberrypi.com>\n\n> ---\n>  .../pipeline/rpi/common/delayed_controls.cpp  | 32 +++++++++++--------\n>  .../pipeline/rpi/common/delayed_controls.h    |  1 -\n>  2 files changed, 18 insertions(+), 15 deletions(-)\n>\n> diff --git a/src/libcamera/pipeline/rpi/common/delayed_controls.cpp b/src/libcamera/pipeline/rpi/common/delayed_controls.cpp\n> index 19c71946..93145d30 100644\n> --- a/src/libcamera/pipeline/rpi/common/delayed_controls.cpp\n> +++ b/src/libcamera/pipeline/rpi/common/delayed_controls.cpp\n> @@ -119,7 +119,6 @@ DelayedControls::DelayedControls(V4L2Device *device,\n>   */\n>  void DelayedControls::reset(unsigned int cookie)\n>  {\n> -       queueCount_ = 1;\n>         writeCount_ = 0;\n>         cookies_[0] = cookie;\n>\n> @@ -154,10 +153,16 @@ void DelayedControls::reset(unsigned int cookie)\n>  bool DelayedControls::push(const ControlList &controls, const unsigned int cookie)\n>  {\n>         /* Copy state from previous frame. */\n> -       for (auto &ctrl : values_) {\n> -               Info &info = ctrl.second[queueCount_];\n> -               info = values_[ctrl.first][queueCount_ - 1];\n> -               info.updated = false;\n> +       if (writeCount_ > 0) {\n> +               for (auto &ctrl : values_) {\n> +                       Info &info = ctrl.second[writeCount_];\n> +                       info = values_[ctrl.first][writeCount_ - 1];\n> +                       info.updated = false;\n> +               }\n> +       } else {\n> +               /* Although it works, we don't expect this. */\n> +               LOG(RPiDelayedControls, Warning)\n> +                       << \"push called before applyControls\";\n>         }\n>\n>         /* Update with new controls. */\n> @@ -175,18 +180,17 @@ bool DelayedControls::push(const ControlList &controls, const unsigned int cooki\n>                 if (controlParams_.find(id) == controlParams_.end())\n>                         return false;\n>\n> -               Info &info = values_[id][queueCount_];\n> +               Info &info = values_[id][writeCount_];\n>\n>                 info = Info(control.second);\n>\n>                 LOG(RPiDelayedControls, Debug)\n>                         << \"Queuing \" << id->name()\n>                         << \" to \" << info.toString()\n> -                       << \" at index \" << queueCount_;\n> +                       << \" at index \" << writeCount_;\n>         }\n>\n> -       cookies_[queueCount_] = cookie;\n> -       queueCount_++;\n> +       cookies_[writeCount_] = cookie;\n>\n>         return true;\n>  }\n> @@ -277,12 +281,12 @@ void DelayedControls::applyControls(uint32_t sequence)\n>                 }\n>         }\n>\n> -       writeCount_ = sequence + 1;\n> -\n> -       while (writeCount_ > queueCount_) {\n> +       while (writeCount_ < sequence + 1) {\n> +               writeCount_++;\n>                 LOG(RPiDelayedControls, Debug)\n> -                       << \"Queue is empty, auto queue no-op.\";\n> -               push({}, cookies_[queueCount_ - 1]);\n> +                       << \"Pushing noop with for index \" << writeCount_\n> +                       << \" with cookie \" << cookies_[writeCount_ - 1];\n> +               push({}, cookies_[writeCount_ - 1]);\n>         }\n>\n>         device_->setControls(&out);\n> diff --git a/src/libcamera/pipeline/rpi/common/delayed_controls.h b/src/libcamera/pipeline/rpi/common/delayed_controls.h\n> index 487b0057..48ad5a0f 100644\n> --- a/src/libcamera/pipeline/rpi/common/delayed_controls.h\n> +++ b/src/libcamera/pipeline/rpi/common/delayed_controls.h\n> @@ -76,7 +76,6 @@ private:\n>         std::unordered_map<const ControlId *, ControlParams> controlParams_;\n>         unsigned int maxDelay_;\n>\n> -       uint32_t queueCount_;\n>         uint32_t writeCount_;\n>         std::unordered_map<const ControlId *, RingBuffer<Info>> values_;\n>         RingBuffer<unsigned int> cookies_;\n> --\n> 2.47.3\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 0CD3CBE086\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 30 Mar 2026 07:39:03 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 9661862CF7;\n\tMon, 30 Mar 2026 09:39:01 +0200 (CEST)","from mail-ua1-x936.google.com (mail-ua1-x936.google.com\n\t[IPv6:2607:f8b0:4864:20::936])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 3A18862CC7\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 30 Mar 2026 09:38:59 +0200 (CEST)","by mail-ua1-x936.google.com with SMTP id\n\ta1e0cc1a2514c-9519b2e681dso82250241.3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 30 Mar 2026 00:38:59 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key;\n\tunprotected) header.d=raspberrypi.com header.i=@raspberrypi.com\n\theader.b=\"LyIwjh/Y\"; dkim-atps=neutral","ARC-Seal":"i=1; a=rsa-sha256; t=1774856338; cv=none;\n\td=google.com; s=arc-20240605;\n\tb=Uq5vyJPS0RHjwyVtFnRdS4etYsx8qPgrq5bwqBWDsMrqAW29jOwXMuP6LawgkX/i8v\n\tnP+qnbB7rajE+JSnTtV+5mhQIpOC7rPUK5FJ3KgcjrdOm1463UlUocLO4Sr64Vin7nvp\n\tX33TwYJDk8jRr2af29TZjfMJ3dwb6aag8hBdZWjq+Z4+5PHzdMjz2gwuM1KJIVg+6ASi\n\ttruUGIE5HU4rQB8/rzWAlEQXWJurvAXtssE80AR2wCwvNghM0MWjgBq/JqlDGq4LLX0+\n\ttZo7wcVQiMvJh8dRpB81gq5Fu1gbv3DRzdjkaBrHx/0JvPjh7jKLOuLV79Ej7OsAVKCz\n\tMKaQ==","ARC-Message-Signature":"i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com;\n\ts=arc-20240605; \n\th=cc:to:subject:message-id:date:from:in-reply-to:references\n\t:mime-version:dkim-signature;\n\tbh=eKqCm+hsvY3J6zvo9NDrfJuonpmCBGgVGVJ0guLt6jM=;\n\tfh=raf7gMhxwhTsDETG3li6wpOfdJf6YyDg/c7aYJ8coN8=;\n\tb=fQomDFKWzypIv/3aUbjWhtSVQbRMXKF0oxRph0Qmdu41pAqPlNEfWlp1q06cw1UDOx\n\tXj7kr7RC0VdazERURp4qhESHYQglWw2dxiEaEviZOPOlAaVkDqQHfilZWdwm7+jpjYxz\n\t66kRfSFOWT4k35riR3LnEVGyqYrSwE+5Cz/bXGk28Geje0LmqHuQsGyWbq3uyiV53azj\n\ts5HVvH0ryb6GS8mrQIa8eGGSGe4Zgz20vQlZwokHNU+j9rxqjcgBaszFjjZXeuanDX5C\n\tHn2jPFhKngAftuQtCaaxv2cssYrPlz89gwRdsLjugKFiT0Vu2wfW6vmwI0LwBb1DnJqi\n\tvEkQ==; darn=lists.libcamera.org","ARC-Authentication-Results":"i=1; mx.google.com; arc=none","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google; t=1774856338; x=1775461138;\n\tdarn=lists.libcamera.org; \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=eKqCm+hsvY3J6zvo9NDrfJuonpmCBGgVGVJ0guLt6jM=;\n\tb=LyIwjh/Y1Dkof50LTbpbF//y452MD+y3xUUUEKToQkVTeRfZOuAsyFrfmMgqD3xRCt\n\tQ/5wSMhM9Vz2sqh3IZOf7KfaZ+yJihS3B/PfRCWIldz+7cGAzQTbcgeVfkZiRXZZ30CB\n\t4cZq9CvNVVSvcf9cOEhjnd5aesxWTIvRm6uc49yC90t1HFHjO5TXv5zZd6/fgwc92Nny\n\tlXIabH2rqi6MeE1EFfm3Uifc/Va+6sP9uynSXKU2ouDM/TrC1UFDFMTu7bSF9/LpGzec\n\tTnEVjY/vRRwEgrC0LnK8QdpQ6wgCPc9W4z+1r/SOBDf5AoSH0mMdmg9HPumBly5q1XFC\n\t/+Og==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20251104; t=1774856338; x=1775461138;\n\th=cc:to:subject:message-id:date:from:in-reply-to:references\n\t:mime-version:x-gm-gg:x-gm-message-state:from:to:cc:subject:date\n\t:message-id:reply-to;\n\tbh=eKqCm+hsvY3J6zvo9NDrfJuonpmCBGgVGVJ0guLt6jM=;\n\tb=nsy0aHjtSOtD2hBaVNfxZ9nwRQ8U3qH+XkXDEQCTjQerOMldZSX/wpJjmLbDvMh0XL\n\treiVhIYsDZgMvk7moj6YTMIiZ2u90QGZE94VSJE/W5pElmHx2od5XdJG9xCCVJBQ+LHx\n\t6h8IoLL96bpALpdgIRsEyKf7dfo1rSMnM38lOA2/BZRei9SupKuKbjeAV0+1IM8aSKpQ\n\tl1gqLwJni+mTZH6xjwZM69aFX+96DnrKPEsYZesVYJsQPpdgXd9LoigCe9nfgGR395AH\n\t1ywkvVRvIb2SaQGAhpeHLwnj+jObkBx78XCtMX10jpklZ0s/AtYNiCrw0ze7mqHgj7Nn\n\ts4GA==","X-Gm-Message-State":"AOJu0Yy5JPYXM6Dt7aWZZYzq27E9R4Iop2EUS1hJVTLX3ZSaSeDkb2+6\n\t7HjF8Wd4CtJUOsiHrq0maRBFlrCV+tktDAuYQXKlCwIv1TS8Mw1+WE5Xk4jFp7KNcoOuRECHbl6\n\t0pnmPdB5x+p250rN37KIR0vfufT/wqF+I+jXhIPDI5ucPBelF3Cgl","X-Gm-Gg":"ATEYQzzJyyZMQQDnDV3fweQ8EzcwRb8gxRyFtxK1LCJFkCdreOxNCZ+/3lHkM14puUC\n\tQov4aMJXZsM07QNkBvDHy5w/KQYQ19MVgyGQrBi3XiYFbN6wChgEHKHNH+nhSVn/UFpgeWOKBLg\n\tH5czDl80S/PhDxrSFRhnTFzHJ1+oyNVY8s6qtRp5OiY7mycYnj80HzPLduqAi1V7Rr/sAvQkiUA\n\t2KXnuPy/pgw5qbgy7cbk0M0Z9V4d+7gW72IlYSg7DTUJctWs6RYTIUTvbhPXdx0y04iJhAHBckh\n\tygDSygBUBLBL4lA8P7CDTrO8ia4nLa3my1A3O/anjeRlmOe+nZ13H/6wy+0Vf1W+e8TsQFfQJWk\n\tYbTg/EuRXiIeoRa3LzMdM1oMy","X-Received":"by 2002:a67:e88b:0:b0:5ff:1d91:a4bd with SMTP id\n\tada2fe7eead31-604f932f2e6mr1299218137.8.1774856337777;\n\tMon, 30 Mar 2026 00:38:57 -0700 (PDT)","MIME-Version":"1.0","References":"<20260327144726.7983-1-david.plowman@raspberrypi.com>\n\t<20260327144726.7983-2-david.plowman@raspberrypi.com>","In-Reply-To":"<20260327144726.7983-2-david.plowman@raspberrypi.com>","From":"Naushir Patuck <naush@raspberrypi.com>","Date":"Mon, 30 Mar 2026 08:38:21 +0100","X-Gm-Features":"AQROBzA6755UrWp6sTZJbj1O4zlMh_2Ka6zk3OR7yrfOh-RQkQJfCXqYadVmFeA","Message-ID":"<CAEmqJPq6aDSFGy=qFvK3YJFNgp3MJQAHBS4R08b4cakQUC-WEg@mail.gmail.com>","Subject":"Re: [PATCH v2 1/3] pipeline: rpi: Simplify delayed controls","To":"David Plowman <david.plowman@raspberrypi.com>","Cc":"libcamera-devel@lists.libcamera.org","Content-Type":"text/plain; charset=\"UTF-8\"","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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]