From patchwork Fri Mar 27 14:42:34 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Plowman X-Patchwork-Id: 26380 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 02517BDCBD for ; Fri, 27 Mar 2026 14:47:34 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 9043B62CDF; Fri, 27 Mar 2026 15:47:31 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="fxLw7lfb"; dkim-atps=neutral Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 2C9E162CB8 for ; Fri, 27 Mar 2026 15:47:30 +0100 (CET) Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-4852b81c73aso19933605e9.3 for ; Fri, 27 Mar 2026 07:47:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1774622849; x=1775227649; darn=lists.libcamera.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Lm7l35CSskeivQUnTFWAF53eNFVZFpCwOiWtZWKFWzo=; b=fxLw7lfb1tPZ2jVu3asQ6Dmm37oW/uBtvTjPThqU9THs8pNg4gIDq0bP24lPNFoV9O 6SDrWsqqPmGVMhivlUP4nWsuzvGg9yWs7d8c1V+J75g7ojtqh3MvxnyfJ2oiGoKlt+q+ AxyPiMplMq9hz/MMxEuSiLRSGfCnA+yLZPNgabyekKOtP7u3xaZFHNKThqtjNV9wzVrc U5PfFJMkusOHJvdCdKEuJsfYFD8wxmi3xyA4DJ/X6Sb82PpOU5A1L4XTtxI/+C2VhtOW ybh/qAOI50oVjTvXUQcix8JwwlcP9RS7d6K4QOi06ATpm2ha1YkRAgzOMD7eUr/zTwM0 JLoA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774622849; x=1775227649; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=Lm7l35CSskeivQUnTFWAF53eNFVZFpCwOiWtZWKFWzo=; b=AOaV6tyMy5rxgJP04ReuHI4AFbFrQQ87/zK5o/rHxs6rAexN6frBsUpJOX65g0FjhY bEh3PDDUeeifqtH7fy6tdc9Ovd9ftHoCzU9psKQ8B//+hDjyzvO1uTL5oPobPwgTI5RJ lnZcwLbRUzpQr281QfIYPaJpC8K37AcDLwfdVHO5vm4XMck07z4ZSMrIqdHtXwvcXL09 xh3q3RWmpw+y9JpsZe6j0yB+aON7621Vh576mwMGncMrkaa1gsKGzGitAY+DkoDqC+kL L52EZDoeNrdBpE/wcCXX4CSzJdtFTvI7edf9GNozvwlbcfZZ3Hf8tNQEBT6lLWFOHyR8 uElg== X-Gm-Message-State: AOJu0YyIPwhzBd5apx6Ih9aAKZJKEwHbabunt8pt24wd7zq1GnDfaLPs Csgl4SB77mzxNMG7N8NJz3LN5JShoDtRJs0cd6IHBSoX/VsQKuzEO6kYQlfLtf1ZgeMsl+TW2JX U4Pm1 X-Gm-Gg: ATEYQzzXYFN28maM3oE8Kw+Big3/ec4qeQBCo4sTOWWyM4o54slwUIuIi8L2Tc1ASdZ Te7YxRn/9Yrr3XeENCIaHem53Vr0I0V8IWNLy5s9P2uSv8k04DQoq8f3iVbHG5FZuKFnBQTEJbU KqpRzbXqhWLtunVUHIH4eMWUOjMVPrrHmTeHJC1Ji4etZPcuZblh07LAIuW9KwDfCk6JN7pEfUG BxytHLeeKOnn5JzI+4fPb9UFwxU3+p0URuu2ZqG4w8KnKSL61v4CV6k7hpdRg6ntA2kSkM5s0Qv bCBisJpRCLvRzfte7epJBVan3hCqPAL8JfWrd89EMrXx1snBEc+dv8QPWkeMX69RJkIZt0eKifc Vg4JUgifMbG87oG/rfhDFp+w3lSKn/8GO0zOtkf/GfImNcGB7bZeIYv0+h+I1nmyluwMU8Egqd1 4NB1ytzCUQUGhxMU8PYQYmEL4KcPGi4df8ebXw6FEoJkJiKfwDZDEUx/AvNguU9hpeuCynBF6RO F2MlCcsMQ2ErUdNThxzuiDrRlOVF9binMKdVTL4jMxOG1h9 X-Received: by 2002:a05:600c:3e88:b0:487:1108:48b8 with SMTP id 5b1f17b1804b1-48727ee9897mr43406925e9.2.1774622849400; Fri, 27 Mar 2026 07:47:29 -0700 (PDT) Received: from localhost.localdomain ([2a06:61c0:f337:0:9c1f:b517:931a:3b19]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48722be608bsm125858545e9.0.2026.03.27.07.47.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Mar 2026 07:47:28 -0700 (PDT) From: David Plowman To: libcamera-devel@lists.libcamera.org Cc: David Plowman 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 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" The queueCount field in the DelayedControls is actually redundant. Remove it. Signed-off-by: David Plowman --- .../pipeline/rpi/common/delayed_controls.cpp | 32 +++++++++++-------- .../pipeline/rpi/common/delayed_controls.h | 1 - 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/src/libcamera/pipeline/rpi/common/delayed_controls.cpp b/src/libcamera/pipeline/rpi/common/delayed_controls.cpp index 19c71946..93145d30 100644 --- a/src/libcamera/pipeline/rpi/common/delayed_controls.cpp +++ b/src/libcamera/pipeline/rpi/common/delayed_controls.cpp @@ -119,7 +119,6 @@ DelayedControls::DelayedControls(V4L2Device *device, */ void DelayedControls::reset(unsigned int cookie) { - queueCount_ = 1; writeCount_ = 0; cookies_[0] = cookie; @@ -154,10 +153,16 @@ void DelayedControls::reset(unsigned int cookie) bool DelayedControls::push(const ControlList &controls, const unsigned int cookie) { /* Copy state from previous frame. */ - for (auto &ctrl : values_) { - Info &info = ctrl.second[queueCount_]; - info = values_[ctrl.first][queueCount_ - 1]; - info.updated = false; + if (writeCount_ > 0) { + for (auto &ctrl : values_) { + Info &info = ctrl.second[writeCount_]; + info = values_[ctrl.first][writeCount_ - 1]; + info.updated = false; + } + } else { + /* Although it works, we don't expect this. */ + LOG(RPiDelayedControls, Warning) + << "push called before applyControls"; } /* Update with new controls. */ @@ -175,18 +180,17 @@ bool DelayedControls::push(const ControlList &controls, const unsigned int cooki if (controlParams_.find(id) == controlParams_.end()) return false; - Info &info = values_[id][queueCount_]; + Info &info = values_[id][writeCount_]; info = Info(control.second); LOG(RPiDelayedControls, Debug) << "Queuing " << id->name() << " to " << info.toString() - << " at index " << queueCount_; + << " at index " << writeCount_; } - cookies_[queueCount_] = cookie; - queueCount_++; + cookies_[writeCount_] = cookie; return true; } @@ -277,12 +281,12 @@ void DelayedControls::applyControls(uint32_t sequence) } } - writeCount_ = sequence + 1; - - while (writeCount_ > queueCount_) { + while (writeCount_ < sequence + 1) { + writeCount_++; LOG(RPiDelayedControls, Debug) - << "Queue is empty, auto queue no-op."; - push({}, cookies_[queueCount_ - 1]); + << "Pushing noop with for index " << writeCount_ + << " with cookie " << cookies_[writeCount_ - 1]; + push({}, cookies_[writeCount_ - 1]); } device_->setControls(&out); diff --git a/src/libcamera/pipeline/rpi/common/delayed_controls.h b/src/libcamera/pipeline/rpi/common/delayed_controls.h index 487b0057..48ad5a0f 100644 --- a/src/libcamera/pipeline/rpi/common/delayed_controls.h +++ b/src/libcamera/pipeline/rpi/common/delayed_controls.h @@ -76,7 +76,6 @@ private: std::unordered_map controlParams_; unsigned int maxDelay_; - uint32_t queueCount_; uint32_t writeCount_; std::unordered_map> values_; RingBuffer cookies_;