From patchwork Fri Oct 24 08:50:28 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Klug X-Patchwork-Id: 24770 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 5FB5BC3259 for ; Fri, 24 Oct 2025 08:51:50 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 2871B6089B; Fri, 24 Oct 2025 10:51:50 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="WlrBGwyc"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id A27CB6086F for ; Fri, 24 Oct 2025 10:51:48 +0200 (CEST) Received: from ideasonboard.com (unknown [IPv6:2a00:6020:448c:6c00:7edc:62f4:c118:1549]) by perceval.ideasonboard.com (Postfix) with UTF8SMTPSA id 2DA331AC5; Fri, 24 Oct 2025 10:50:02 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1761295803; bh=0RNLWOI7Kr+6RucCxL2v52hvZHMXiHYlDf0dDuYyE4s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WlrBGwycuwU1OZI9Z4uHDUerLTkb1wgtrBgV6pWOBr1TLoZmtgj1vA18QLsc1kIph QusVn0fTYN2QkStUIoNBBFizzH5tuo6DmXsZCwDeYUVpRfLmAJWVuo/JFKQ131c8uo Nw2+TriF59zEM8yuYPpNcFxXXbnVApe5hqaJMiEg= From: Stefan Klug To: libcamera-devel@lists.libcamera.org Cc: Stefan Klug Subject: [PATCH v1 04/35] libcamera: delayed_controls: Queue noop when needed, not before Date: Fri, 24 Oct 2025 10:50:28 +0200 Message-ID: <20251024085130.995967-5-stefan.klug@ideasonboard.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20251024085130.995967-1-stefan.klug@ideasonboard.com> References: <20251024085130.995967-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 after a successful applyControls(). But after applyControls() there is still some time left for new controls to be pushed until the next call to applyControls(). To fix that, move the no-op push to the beginning of applyContols(). Signed-off-by: Stefan Klug --- src/libcamera/delayed_controls.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/libcamera/delayed_controls.cpp b/src/libcamera/delayed_controls.cpp index 044c6c7325e7..67213fe87d53 100644 --- a/src/libcamera/delayed_controls.cpp +++ b/src/libcamera/delayed_controls.cpp @@ -272,6 +272,14 @@ 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." << queueCount_; + push(queueCount_, {}); + } + + writeCount_ = sequence; + /* * Create control list peeking ahead in the value queue to ensure * values are set in time to satisfy the sensor delay. @@ -312,12 +320,6 @@ 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); }