{"id":26346,"url":"https://patchwork.libcamera.org/api/patches/26346/?format=json","web_url":"https://patchwork.libcamera.org/patch/26346/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/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":"<20260325151416.2114564-5-stefan.klug@ideasonboard.com>","date":"2026-03-25T15:13:36","name":"[v2,04/32] libcamera: delayed_controls: Queue noop when needed, not before","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"917c22e6467a40bb3238965f2a1c8d57894a6c2e","submitter":{"id":184,"url":"https://patchwork.libcamera.org/api/people/184/?format=json","name":"Stefan Klug","email":"stefan.klug@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/26346/mbox/","series":[{"id":5849,"url":"https://patchwork.libcamera.org/api/series/5849/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=5849","date":"2026-03-25T15:13:32","name":"rkisp1: pipeline rework for PFC","version":2,"mbox":"https://patchwork.libcamera.org/series/5849/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/26346/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/26346/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 417EFC32F6\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 25 Mar 2026 15:14:55 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 80C7F627D7;\n\tWed, 25 Mar 2026 16:14:54 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 96724627D7\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 25 Mar 2026 16:14:52 +0100 (CET)","from ideasonboard.com (unknown\n\t[IPv6:2a00:6020:448c:6c00:b16a:5ed9:4ada:a95a])\n\tby perceval.ideasonboard.com (Postfix) with UTF8SMTPSA id 954E51992; \n\tWed, 25 Mar 2026 16:13:34 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"j43NuIxs\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1774451614;\n\tbh=EbhtE94aXfZc4txsZOEuCZh+VEJl4RDHgjpWhMcla5Y=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=j43NuIxsyCbrc+yWLvf6DAZEzXAPI8R6NsQMUeakTz8t//6e8QdOuHRlI3Rgoq927\n\tWpJPFgSoifRblUlMa/yRB75kroE7HoUynaBIBvtN7JdTUlkzkt0mYL1NNs7XpdO3MH\n\tXOaj7kapWgjif5/s9rs6g1syzA/Hh9Y4tWeqNgXc=","From":"Stefan Klug <stefan.klug@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Cc":"Stefan Klug <stefan.klug@ideasonboard.com>","Subject":"[PATCH v2 04/32] libcamera: delayed_controls: Queue noop when\n\tneeded, not before","Date":"Wed, 25 Mar 2026 16:13:36 +0100","Message-ID":"<20260325151416.2114564-5-stefan.klug@ideasonboard.com>","X-Mailer":"git-send-email 2.51.0","In-Reply-To":"<20260325151416.2114564-1-stefan.klug@ideasonboard.com>","References":"<20260325151416.2114564-1-stefan.klug@ideasonboard.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":"A no-op is queued when DelayedControls runs out of controls at the end\nof applyControls(). But these controls are only needed on the next call\nto applyControls(), so there is still time for a proper push. To fix\nthat, move the no-op push to the beginning of applyContols().\n\nDrop writeCount_ as it is no longer needed.\n\nSigned-off-by: Stefan Klug <stefan.klug@ideasonboard.com>\n\n---\n\nChanges in v2:\n- Improved a log message\n- Improved commit message\n- dropped writeCount_ member\n---\n include/libcamera/internal/delayed_controls.h |  1 -\n src/libcamera/delayed_controls.cpp            | 18 ++++++++----------\n 2 files changed, 8 insertions(+), 11 deletions(-)","diff":"diff --git a/include/libcamera/internal/delayed_controls.h b/include/libcamera/internal/delayed_controls.h\nindex c650e672d964..2af572606d0f 100644\n--- a/include/libcamera/internal/delayed_controls.h\n+++ b/include/libcamera/internal/delayed_controls.h\n@@ -76,7 +76,6 @@ private:\n \tunsigned int maxDelay_;\n \n \tuint32_t queueCount_;\n-\tuint32_t writeCount_;\n \t/* \\todo Evaluate if we should index on ControlId * or unsigned int */\n \tstd::unordered_map<const ControlId *, ControlRingBuffer> values_;\n };\ndiff --git a/src/libcamera/delayed_controls.cpp b/src/libcamera/delayed_controls.cpp\nindex 2854016c6170..123a37bdc887 100644\n--- a/src/libcamera/delayed_controls.cpp\n+++ b/src/libcamera/delayed_controls.cpp\n@@ -116,7 +116,6 @@ DelayedControls::DelayedControls(V4L2Device *device,\n void DelayedControls::reset()\n {\n \tqueueCount_ = 1;\n-\twriteCount_ = 0;\n \n \t/* Retrieve control as reported by the device. */\n \tstd::vector<uint32_t> ids;\n@@ -272,6 +271,13 @@ void DelayedControls::applyControls(uint32_t sequence)\n {\n \tLOG(DelayedControls, Debug) << \"frame \" << sequence << \" started\";\n \n+\twhile (queueCount_ - 1 < sequence) {\n+\t\tLOG(DelayedControls, Warning)\n+\t\t\t<< \"Queue is empty, auto queue no-op for sequence \"\n+\t\t\t<< queueCount_;\n+\t\tpush(queueCount_, {});\n+\t}\n+\n \t/*\n \t * Create control list peeking ahead in the value queue to ensure\n \t * values are set in time to satisfy the sensor delay.\n@@ -280,7 +286,7 @@ void DelayedControls::applyControls(uint32_t sequence)\n \tfor (auto &ctrl : values_) {\n \t\tconst ControlId *id = ctrl.first;\n \t\tunsigned int delayDiff = maxDelay_ - controlParams_[id].delay;\n-\t\tunsigned int index = std::max<int>(0, writeCount_ - delayDiff);\n+\t\tunsigned int index = std::max<int>(0, sequence - delayDiff);\n \t\tInfo &info = ctrl.second[index];\n \n \t\tif (info.updated) {\n@@ -310,14 +316,6 @@ void DelayedControls::applyControls(uint32_t sequence)\n \t\t}\n \t}\n \n-\twriteCount_ = sequence + 1;\n-\n-\twhile (writeCount_ > queueCount_) {\n-\t\tLOG(DelayedControls, Warning)\n-\t\t\t<< \"Queue is empty, auto queue no-op.\";\n-\t\tpush(queueCount_, {});\n-\t}\n-\n \tdevice_->setControls(&out);\n }\n \n","prefixes":["v2","04/32"]}