From patchwork Tue Feb 16 08:53:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 11303 X-Patchwork-Delegate: niklas.soderlund@ragnatech.se 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 02A14BD1EF for ; Tue, 16 Feb 2021 08:53:54 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 7983D637DC; Tue, 16 Feb 2021 09:53:53 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="UjaFdmGg"; dkim-atps=neutral Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id C0F13637C9 for ; Tue, 16 Feb 2021 09:53:50 +0100 (CET) Received: by mail-wm1-x330.google.com with SMTP id n10so13671985wmq.0 for ; Tue, 16 Feb 2021 00:53:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=X83bfbi6hYD9/lgpvD3X6XcqhNR4s9wHCFQad4teq1A=; b=UjaFdmGg7PnL8TXTWuOWhrDQBnMdWdWnrFjEmQIcKPtJO2WPumqeOaSX1ratZjj4ZW jIJQJ7D461dgHrHDVEL0vXng6u5pkrOJ/C97YB8yP9L7jF99vprs2WW52TiLtNHajDez ceQraCUwDeB1lPN5u6GRpcmLitdaPc/tqvT0xMnqhG8p1Kc6wxHTb2p6yl1IMq5ZczKb jsRISSSjWIpOTNsFGsiwWYBRLKfK60IKRR/wCFZ9wnAJiLJX/VJcdnn3k1V66MB2ayKl hy40o0M34vbWiOZAKxgXP2b16dvlwAtpqPPE8hJ/UlKiO3Otyy9hyR4oAzwXij3t9C8z oy5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=X83bfbi6hYD9/lgpvD3X6XcqhNR4s9wHCFQad4teq1A=; b=Kn3xJ57WBkCK0+TVRq4PXj0A9pRd+T7bTHeZ9aUWvj47wTIn0hpI7fYgCO3Ub6PXJ3 Xkj8q9w8UGnA/EPYS30JtjL9KGAxDuwuVlyiMUzqsXzZELPc/aBF8/FvEwK2OLJZTyuD KSEJXjm73Bf1sLtvy7h0K/TUvAjJ4gxX5yCt7purwR0r8A8zn8g1iEWVHGaF94haA492 1kmJZv3lWWyBVYlb8dTFu3uF5JyYfnrOP1YTyTOVI2Ts5/KJnRRZkMrWdz+p+uu2bS7R L4jpVI7pwrpht0zW5HoyrbcjOxf4+96ETytOUyDqHS6C80Y9bGbQ4PVsO1yca8zfd1Oa 5reg== X-Gm-Message-State: AOAM531RxhGc4wbLmoPm7Wl+9J257Ejac+0R8fPLhGPScO0NOMuu5ZzT kdQsSnJNdftMm7mDABjFIiZkxtibK78JV6XB X-Google-Smtp-Source: ABdhPJxJAWo4ugi121NZgQccpaEIlItxALapeLqAhiE3DiABhmJ2CmiS5JdgfT6Hnv15j4qxkOsrKQ== X-Received: by 2002:a1c:5a54:: with SMTP id o81mr2352219wmb.50.1613465630243; Tue, 16 Feb 2021 00:53:50 -0800 (PST) Received: from naush-laptop.patuck.local ([88.97.76.4]) by smtp.gmail.com with ESMTPSA id e1sm9300369wrd.44.2021.02.16.00.53.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Feb 2021 00:53:49 -0800 (PST) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Tue, 16 Feb 2021 08:53:41 +0000 Message-Id: <20210216085342.1012717-5-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210216085342.1012717-1-naush@raspberrypi.com> References: <20210216085342.1012717-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 4/5] libcamera: delayed_controls: Remove spurious no-op queued controls 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" In DelayedControls::applyControls(), the controls queue would be extended via a no-op control push to fill the intermittent slots with unchanged control values. This is needed so that we read back unchanged control values correctly on every frame. However, there was one additional no-op performed on every frame that is not required, meaning that any controls queued by the pipeline handler would have their write delayed by one further frame. The original StaggeredCtrl did not do this, as it only had one index to manage, whereas DelayedControls uses two. Remove this last no-op push so that the pipeline_handler provided controls would be written on the very next frame if possible. As a consequence, we must mark the control update as completed within the DelayedControls::applyControls() loop, otherwise it might get reused when cycling through the ring buffer. Signed-off-by: Naushir Patuck Reported-by: David Plowman Fixes: 3d4b7b005911 ("libcamera: delayed_controls: Add helper for controls that apply with a delay") Reviewed-by: Paul Elder --- src/libcamera/delayed_controls.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/libcamera/delayed_controls.cpp b/src/libcamera/delayed_controls.cpp index 21dc3e164fe9..d1b79dc3570e 100644 --- a/src/libcamera/delayed_controls.cpp +++ b/src/libcamera/delayed_controls.cpp @@ -225,11 +225,11 @@ void DelayedControls::applyControls(uint32_t sequence) * values are set in time to satisfy the sensor delay. */ ControlList out(device_->controls()); - for (const auto &ctrl : values_) { + for (auto &ctrl : values_) { const ControlId *id = ctrl.first; unsigned int delayDiff = maxDelay_ - controlParams_[id].delay; unsigned int index = std::max(0, writeCount_ - delayDiff); - const Info &info = ctrl.second[index]; + Info &info = ctrl.second[index]; if (info.updated) { if (controlParams_[id].priorityWrite) { @@ -252,12 +252,15 @@ void DelayedControls::applyControls(uint32_t sequence) << "Setting " << id->name() << " to " << info.toString() << " at index " << index; + + /* Done with this update, so mark as completed. */ + info.updated = false; } } writeCount_++; - while (writeCount_ >= queueCount_) { + while (writeCount_ > queueCount_) { LOG(DelayedControls, Debug) << "Queue is empty, auto queue no-op."; push({});