From patchwork Mon Sep 14 14:02:17 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Klug X-Patchwork-Id: 28248 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 62150C3272 for ; Mon, 14 Sep 2026 14:03:40 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E5B75686A0; Mon, 14 Sep 2026 16:03:39 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="C14LY+Lk"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id B1234686A0 for ; Mon, 14 Sep 2026 16:03:37 +0200 (CEST) Received: from ideasonboard.com (unknown [IPv6:2a00:6020:448c:6c00:a279:75fa:1f6c:7f40]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id B6EF09A4; Mon, 14 Sep 2026 16:01:57 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1789394517; bh=dP2/sEDvMmG2rcB4M3932K3yUA6MxTPHJZiiIAuQRCA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=C14LY+LkSpQxXKa0q/rtBT3iKKWaQ3x63Q5gn42tK2Dy4OZx/+ewZfKi9MEv/MhWh FWwEUtS9ltZTAEPVgLg9Q1DZ7OL/9tPNLy/ANwUwu2vTarNE+MfMBvw7yZt6pfae/E xwBBNODBUsFV4FaWbBSJrPPQPjq5TdFBxNTajGcs= From: Stefan Klug To: libcamera-devel@lists.libcamera.org Cc: Stefan Klug Subject: [PATCH v3 04/41] libcamera: delayed_controls: Queue noop when needed, not before Date: Mon, 14 Sep 2026 16:02:17 +0200 Message-ID: <20260914140309.3354666-5-stefan.klug@ideasonboard.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260914140309.3354666-1-stefan.klug@ideasonboard.com> References: <20260914140309.3354666-1-stefan.klug@ideasonboard.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" A no-op is queued when DelayedControls runs out of controls at the end of applyControls(). But these controls are only needed on the next call to applyControls(), so there is still time for a proper push. To fix that, move the no-op push to the beginning of applyContols(). Signed-off-by: Stefan Klug --- Changes in v3: - Refrained dropping the writeCount_ member. It will be reused later Changes in v2: - Improved a log message - Improved commit message - dropped writeCount_ member --- src/libcamera/delayed_controls.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/libcamera/delayed_controls.cpp b/src/libcamera/delayed_controls.cpp index 87d4c48425c6..7e3a72e2cb1d 100644 --- a/src/libcamera/delayed_controls.cpp +++ b/src/libcamera/delayed_controls.cpp @@ -270,6 +270,13 @@ void DelayedControls::applyControls(uint32_t sequence) { LOG(DelayedControls, Debug) << "frame " << sequence << " started"; + while (queueCount_ - 1 < sequence) { + LOG(DelayedControls, Warning) + << "Queue is empty, auto queue no-op for sequence " + << queueCount_; + push(queueCount_, {}); + } + /* * Create control list peeking ahead in the value queue to ensure * values are set in time to satisfy the sensor delay. @@ -278,7 +285,7 @@ void DelayedControls::applyControls(uint32_t sequence) for (auto &ctrl : values_) { const ControlId *id = ctrl.first; unsigned int delayDiff = maxDelay_ - controlParams_[id].delay; - unsigned int index = std::max(0, writeCount_ - delayDiff); + unsigned int index = std::max(0, sequence - delayDiff); Info &info = ctrl.second[index]; if (info.updated) { @@ -308,15 +315,8 @@ void DelayedControls::applyControls(uint32_t sequence) } } - writeCount_ = sequence + 1; - - while (writeCount_ > queueCount_) { - LOG(DelayedControls, Warning) - << "Queue is empty, auto queue no-op."; - push(queueCount_, {}); - } - device_->setControls(&out); + writeCount_ = sequence; } } /* namespace libcamera */