{"id":26380,"url":"https://patchwork.libcamera.org/api/1.1/patches/26380/?format=json","web_url":"https://patchwork.libcamera.org/patch/26380/","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":"<20260327144726.7983-2-david.plowman@raspberrypi.com>","date":"2026-03-27T14:42:34","name":"[v2,1/3] pipeline: rpi: Simplify delayed controls","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"f11d222b9b22cbeda1bb48efb898e62ace3c0dc9","submitter":{"id":42,"url":"https://patchwork.libcamera.org/api/1.1/people/42/?format=json","name":"David Plowman","email":"david.plowman@raspberrypi.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/26380/mbox/","series":[{"id":5854,"url":"https://patchwork.libcamera.org/api/1.1/series/5854/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=5854","date":"2026-03-27T14:42:33","name":"Atomic control lists on Raspberry Pi","version":2,"mbox":"https://patchwork.libcamera.org/series/5854/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/26380/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/26380/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 02517BDCBD\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 27 Mar 2026 14:47:34 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 9043B62CDF;\n\tFri, 27 Mar 2026 15:47:31 +0100 (CET)","from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com\n\t[IPv6:2a00:1450:4864:20::32d])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 2C9E162CB8\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 27 Mar 2026 15:47:30 +0100 (CET)","by mail-wm1-x32d.google.com with SMTP id\n\t5b1f17b1804b1-4852b81c73aso19933605e9.3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 27 Mar 2026 07:47:30 -0700 (PDT)","from localhost.localdomain ([2a06:61c0:f337:0:9c1f:b517:931a:3b19])\n\tby smtp.gmail.com with ESMTPSA id\n\t5b1f17b1804b1-48722be608bsm125858545e9.0.2026.03.27.07.47.28\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tFri, 27 Mar 2026 07:47:28 -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=\"fxLw7lfb\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google; t=1774622849; x=1775227649;\n\tdarn=lists.libcamera.org; \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=Lm7l35CSskeivQUnTFWAF53eNFVZFpCwOiWtZWKFWzo=;\n\tb=fxLw7lfb1tPZ2jVu3asQ6Dmm37oW/uBtvTjPThqU9THs8pNg4gIDq0bP24lPNFoV9O\n\t6SDrWsqqPmGVMhivlUP4nWsuzvGg9yWs7d8c1V+J75g7ojtqh3MvxnyfJ2oiGoKlt+q+\n\tAxyPiMplMq9hz/MMxEuSiLRSGfCnA+yLZPNgabyekKOtP7u3xaZFHNKThqtjNV9wzVrc\n\tU5PfFJMkusOHJvdCdKEuJsfYFD8wxmi3xyA4DJ/X6Sb82PpOU5A1L4XTtxI/+C2VhtOW\n\tybh/qAOI50oVjTvXUQcix8JwwlcP9RS7d6K4QOi06ATpm2ha1YkRAgzOMD7eUr/zTwM0\n\tJLoA==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20251104; t=1774622849; x=1775227649;\n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from\n\t:to:cc:subject:date:message-id:reply-to;\n\tbh=Lm7l35CSskeivQUnTFWAF53eNFVZFpCwOiWtZWKFWzo=;\n\tb=AOaV6tyMy5rxgJP04ReuHI4AFbFrQQ87/zK5o/rHxs6rAexN6frBsUpJOX65g0FjhY\n\tbEh3PDDUeeifqtH7fy6tdc9Ovd9ftHoCzU9psKQ8B//+hDjyzvO1uTL5oPobPwgTI5RJ\n\tlnZcwLbRUzpQr281QfIYPaJpC8K37AcDLwfdVHO5vm4XMck07z4ZSMrIqdHtXwvcXL09\n\txh3q3RWmpw+y9JpsZe6j0yB+aON7621Vh576mwMGncMrkaa1gsKGzGitAY+DkoDqC+kL\n\tL52EZDoeNrdBpE/wcCXX4CSzJdtFTvI7edf9GNozvwlbcfZZ3Hf8tNQEBT6lLWFOHyR8\n\tuElg==","X-Gm-Message-State":"AOJu0YyIPwhzBd5apx6Ih9aAKZJKEwHbabunt8pt24wd7zq1GnDfaLPs\n\tCsgl4SB77mzxNMG7N8NJz3LN5JShoDtRJs0cd6IHBSoX/VsQKuzEO6kYQlfLtf1ZgeMsl+TW2JX\n\tU4Pm1","X-Gm-Gg":"ATEYQzzXYFN28maM3oE8Kw+Big3/ec4qeQBCo4sTOWWyM4o54slwUIuIi8L2Tc1ASdZ\n\tTe7YxRn/9Yrr3XeENCIaHem53Vr0I0V8IWNLy5s9P2uSv8k04DQoq8f3iVbHG5FZuKFnBQTEJbU\n\tKqpRzbXqhWLtunVUHIH4eMWUOjMVPrrHmTeHJC1Ji4etZPcuZblh07LAIuW9KwDfCk6JN7pEfUG\n\tBxytHLeeKOnn5JzI+4fPb9UFwxU3+p0URuu2ZqG4w8KnKSL61v4CV6k7hpdRg6ntA2kSkM5s0Qv\n\tbCBisJpRCLvRzfte7epJBVan3hCqPAL8JfWrd89EMrXx1snBEc+dv8QPWkeMX69RJkIZt0eKifc\n\tVg4JUgifMbG87oG/rfhDFp+w3lSKn/8GO0zOtkf/GfImNcGB7bZeIYv0+h+I1nmyluwMU8Egqd1\n\t4NB1ytzCUQUGhxMU8PYQYmEL4KcPGi4df8ebXw6FEoJkJiKfwDZDEUx/AvNguU9hpeuCynBF6RO\n\tF2MlCcsMQ2ErUdNThxzuiDrRlOVF9binMKdVTL4jMxOG1h9","X-Received":"by 2002:a05:600c:3e88:b0:487:1108:48b8 with SMTP id\n\t5b1f17b1804b1-48727ee9897mr43406925e9.2.1774622849400; \n\tFri, 27 Mar 2026 07:47:29 -0700 (PDT)","From":"David Plowman <david.plowman@raspberrypi.com>","To":"libcamera-devel@lists.libcamera.org","Cc":"David Plowman <david.plowman@raspberrypi.com>","Subject":"[PATCH v2 1/3] pipeline: rpi: Simplify delayed controls","Date":"Fri, 27 Mar 2026 14:42:34 +0000","Message-ID":"<20260327144726.7983-2-david.plowman@raspberrypi.com>","X-Mailer":"git-send-email 2.47.3","In-Reply-To":"<20260327144726.7983-1-david.plowman@raspberrypi.com>","References":"<20260327144726.7983-1-david.plowman@raspberrypi.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","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>"},"content":"The queueCount field in the DelayedControls is actually\nredundant. Remove it.\n\nSigned-off-by: David Plowman <david.plowman@raspberrypi.com>\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(-)","diff":"diff --git a/src/libcamera/pipeline/rpi/common/delayed_controls.cpp b/src/libcamera/pipeline/rpi/common/delayed_controls.cpp\nindex 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-\tqueueCount_ = 1;\n \twriteCount_ = 0;\n \tcookies_[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 \t/* Copy state from previous frame. */\n-\tfor (auto &ctrl : values_) {\n-\t\tInfo &info = ctrl.second[queueCount_];\n-\t\tinfo = values_[ctrl.first][queueCount_ - 1];\n-\t\tinfo.updated = false;\n+\tif (writeCount_ > 0) {\n+\t\tfor (auto &ctrl : values_) {\n+\t\t\tInfo &info = ctrl.second[writeCount_];\n+\t\t\tinfo = values_[ctrl.first][writeCount_ - 1];\n+\t\t\tinfo.updated = false;\n+\t\t}\n+\t} else {\n+\t\t/* Although it works, we don't expect this. */\n+\t\tLOG(RPiDelayedControls, Warning)\n+\t\t\t<< \"push called before applyControls\";\n \t}\n \n \t/* Update with new controls. */\n@@ -175,18 +180,17 @@ bool DelayedControls::push(const ControlList &controls, const unsigned int cooki\n \t\tif (controlParams_.find(id) == controlParams_.end())\n \t\t\treturn false;\n \n-\t\tInfo &info = values_[id][queueCount_];\n+\t\tInfo &info = values_[id][writeCount_];\n \n \t\tinfo = Info(control.second);\n \n \t\tLOG(RPiDelayedControls, Debug)\n \t\t\t<< \"Queuing \" << id->name()\n \t\t\t<< \" to \" << info.toString()\n-\t\t\t<< \" at index \" << queueCount_;\n+\t\t\t<< \" at index \" << writeCount_;\n \t}\n \n-\tcookies_[queueCount_] = cookie;\n-\tqueueCount_++;\n+\tcookies_[writeCount_] = cookie;\n \n \treturn true;\n }\n@@ -277,12 +281,12 @@ void DelayedControls::applyControls(uint32_t sequence)\n \t\t}\n \t}\n \n-\twriteCount_ = sequence + 1;\n-\n-\twhile (writeCount_ > queueCount_) {\n+\twhile (writeCount_ < sequence + 1) {\n+\t\twriteCount_++;\n \t\tLOG(RPiDelayedControls, Debug)\n-\t\t\t<< \"Queue is empty, auto queue no-op.\";\n-\t\tpush({}, cookies_[queueCount_ - 1]);\n+\t\t\t<< \"Pushing noop with for index \" << writeCount_\n+\t\t\t<< \" with cookie \" << cookies_[writeCount_ - 1];\n+\t\tpush({}, cookies_[writeCount_ - 1]);\n \t}\n \n \tdevice_->setControls(&out);\ndiff --git a/src/libcamera/pipeline/rpi/common/delayed_controls.h b/src/libcamera/pipeline/rpi/common/delayed_controls.h\nindex 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 \tstd::unordered_map<const ControlId *, ControlParams> controlParams_;\n \tunsigned int maxDelay_;\n \n-\tuint32_t queueCount_;\n \tuint32_t writeCount_;\n \tstd::unordered_map<const ControlId *, RingBuffer<Info>> values_;\n \tRingBuffer<unsigned int> cookies_;\n","prefixes":["v2","1/3"]}