From patchwork Thu Mar 4 08:17:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 11490 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 61FA7BD1F1 for ; Thu, 4 Mar 2021 08:17:43 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 12CE868AA9; Thu, 4 Mar 2021 09:17:43 +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="gICNlRk7"; dkim-atps=neutral Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 5B0AA68AA1 for ; Thu, 4 Mar 2021 09:17:40 +0100 (CET) Received: by mail-wr1-x433.google.com with SMTP id j2so13737988wrx.9 for ; Thu, 04 Mar 2021 00:17:40 -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=JVxr9wPhqpMPUC/muNAswAu0GDAhUwE5M/mXi2ElBc4=; b=gICNlRk7Gq2vLTaRJzcIifYAxrBbWKHG2bDhKOmf25b+tuqgETzHpZxXE6kaTltzkB USagNj8M+ErfBP9gQG+ttU4uFtOtZy3oEmGGNNMwWBQGU4ZQXdTeBZj+YwemN+YStQ5r QtxjrmE3sYlBbu2jX6wFZ43pPJeNwE/k4xY1Tj9SiUucBneoLp7EIfuW5hm0t3r+mGOF XkppOW1C7X2AOp9n6QjkP6/hggaLMr7E2NODmoD5wXs17xjmTvSLNEIY93uxx83eM0Ju 9mMf8ISntqRikZ3s4pjYrUga+B93WOCglWQCk+oUEYUcRT+q0KunfvKLM5CiBpIRx3K/ 2ZIA== 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=JVxr9wPhqpMPUC/muNAswAu0GDAhUwE5M/mXi2ElBc4=; b=Hpc9o0cVwUuXHWQhwqdpoF91L98GuqH29W2YO7qmqW4yxtmnAU9Y2u0cJrWQXpVPbU 62Ii28x1iLJAI4APFjYzJnctn4PMZgJOq9tTrnHphlhqNHcwWSPYUE6Bbdn+nLeIsdUj 7qHmLknT9IARxBeDBpiB8WSljbVJ/3R38PKbpBWlOqQfzlRcbz/TTTTJ6kkZfYWvYBeK DNbdXpXO+z0Wn7B3apbRNNI+DRQ7rF/3NM52zMPGRFBgiN77nQwqMIvHeLtnMEfD1UvZ I8LcCMcvnt32svyaCZSTsSwKQFPmqULvJ7rcyFk9hMRPmOMfiHMzf8BCzNqaqUiQWbH3 IQOg== X-Gm-Message-State: AOAM533qLPFaUxFRxHFuVh2lRL3ZrlCpheuvxw5/GOzLSI61KiaOgiYL B9Zd4yalZBUU/UeoKu5SdkkWwMzANRnv/VDk X-Google-Smtp-Source: ABdhPJykL6rMb79yFZbObpGv6EltQtOhu5+3NFOsIfkCMS3lhKJzba+r97uKj19qkXVNVpz2cN1i9A== X-Received: by 2002:adf:b611:: with SMTP id f17mr2677206wre.8.1614845859868; Thu, 04 Mar 2021 00:17:39 -0800 (PST) Received: from naush-laptop.patuck.local ([88.97.76.4]) by smtp.gmail.com with ESMTPSA id b186sm6997926wmc.44.2021.03.04.00.17.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Mar 2021 00:17:39 -0800 (PST) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Thu, 4 Mar 2021 08:17:25 +0000 Message-Id: <20210304081728.1058394-5-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210304081728.1058394-1-naush@raspberrypi.com> References: <20210304081728.1058394-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 4/7] 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") Tested-by: David Plowman Reviewed-by: Paul Elder Tested-by: Jean-Michel Hautbois Reviewed-by: Kieran Bingham --- 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 f6d761d1cc41..5a05741c0285 100644 --- a/src/libcamera/delayed_controls.cpp +++ b/src/libcamera/delayed_controls.cpp @@ -226,11 +226,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) { @@ -253,12 +253,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({});