From patchwork Mon Mar 1 13:31:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 11416 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 3D8A7BD1F1 for ; Mon, 1 Mar 2021 13:32:12 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 0DBD568A9C; Mon, 1 Mar 2021 14:32:12 +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="SsH17KWR"; 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 D3F2960521 for ; Mon, 1 Mar 2021 14:32:09 +0100 (CET) Received: by mail-wm1-x330.google.com with SMTP id u11so8358619wmq.5 for ; Mon, 01 Mar 2021 05:32:09 -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=SsH17KWR1VrOrWpagONYmtdauE4n0jIkU2e9jynDEl8lGyR62MsP2m1RP+tH+tJbsW PKHA9BDdLEqpslKZ8hQQ2vqH8v+GYuGD5OK5Z0oGMlGvLCuU32++YNrX1K8gNKnMZsrd FDA+dAmzekUQ3MkONn1DPx056Cm84AStH7IDCP2+xd7bVoKioh1M55SxjE1X4PY+tYRe Iagt0rjJLAU4oN9uratvDQcHrJWiP589/k17LbSrWwJcQv/KafcnyrfThnoCYilsoZlC 5IZa+vYQkEuV7zVv+sG3DHiDwCRAJPv2jxE9oGjWGNBRyYbjYafWQNcCCiKW4CDW5kJ1 J2FA== 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=rqKdPaLyCr5dVW7O3VLaZcurbLGXFZKQ22uAzgxXvXrSDTb6G0iGrdm3bJK/bLPUoD naGfXG/AmWPOKcaC5nhCZpLMBPdetgJD9/0qoHElyKcakadZ6jGVZR/9LbFRphxHn4Ef g86pqctzz+zubAfNMD8Z+g2IcoRVJxHNueBqAa1wwueiwVByBE0mNPWfba+rFLmtBwpK A3lfT5mwEZ+b8Hp6Ux3wznB5mbaBN7G8MYZKvQjBggznzmazQLAsmsBFe6Jn9XVKrdIE B+sVpFLwH33khezpKlYKCxpoE8UnSgRGNMykwlg2HwRP+x9Uv6QoOs7dj7iM9RtnI5/c hkag== X-Gm-Message-State: AOAM531CvK83NPnehpTJ4P4wpNtzcnbx/G2bm3pUtROzzKqWNhiJkCwK dvewYF8FF2eaw2FTgXs63I/x8oN62SoIn8EC X-Google-Smtp-Source: ABdhPJxcc31Nf/BE2WVwLzIrRib0FO+kZ3ooZjWEl+0fg6l1vMed8WFhPthSL3YqAVgRIp4E2tUwGQ== X-Received: by 2002:a7b:c92d:: with SMTP id h13mr11028042wml.96.1614605528613; Mon, 01 Mar 2021 05:32:08 -0800 (PST) Received: from naush-laptop.patuck.local ([88.97.76.4]) by smtp.gmail.com with ESMTPSA id a75sm11263630wme.10.2021.03.01.05.32.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Mar 2021 05:32:07 -0800 (PST) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Mon, 1 Mar 2021 13:31:58 +0000 Message-Id: <20210301133159.4179129-5-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210301133159.4179129-1-naush@raspberrypi.com> References: <20210301133159.4179129-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 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") Tested-by: David Plowman 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 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({});