[{"id":15357,"web_url":"https://patchwork.libcamera.org/comment/15357/","msgid":"<20210301094823.GE3084@pyrite.rasen.tech>","date":"2021-03-01T09:48:23","subject":"Re: [libcamera-devel] [PATCH v2 4/5] libcamera: delayed_controls:\n\tRemove spurious no-op queued controls","submitter":{"id":17,"url":"https://patchwork.libcamera.org/api/people/17/","name":"Paul Elder","email":"paul.elder@ideasonboard.com"},"content":"Hi Naush,\n\nOn Tue, Feb 16, 2021 at 08:53:41AM +0000, Naushir Patuck wrote:\n> In DelayedControls::applyControls(), the controls queue would be\n> extended via a no-op control push to fill the intermittent slots with\n> unchanged control values. This is needed so that we read back unchanged\n> control values correctly on every frame.\n> \n> However, there was one additional no-op performed on every frame that is\n> not required, meaning that any controls queued by the pipeline handler\n> would have their write delayed by one further frame. The original\n> StaggeredCtrl did not do this, as it only had one index to manage,\n> whereas DelayedControls uses two.\n> \n> Remove this last no-op push so that the pipeline_handler provided\n> controls would be written on the very next frame if possible. As a\n> consequence, we must mark the control update as completed within the\n> DelayedControls::applyControls() loop, otherwise it might get reused\n> when cycling through the ring buffer.\n> \n> Signed-off-by: Naushir Patuck <naush@raspberrypi.com>\n> Reported-by: David Plowman <david.plowman@raspberrypi.com>\n> Fixes: 3d4b7b005911 (\"libcamera: delayed_controls: Add helper for controls that apply with a delay\")\n\nLooks good to me.\n\nReviewed-by: Paul Elder <paul.elder@ideasonboard.com>\n\n> ---\n>  src/libcamera/delayed_controls.cpp | 9 ++++++---\n>  1 file changed, 6 insertions(+), 3 deletions(-)\n> \n> diff --git a/src/libcamera/delayed_controls.cpp b/src/libcamera/delayed_controls.cpp\n> index 21dc3e164fe9..d1b79dc3570e 100644\n> --- a/src/libcamera/delayed_controls.cpp\n> +++ b/src/libcamera/delayed_controls.cpp\n> @@ -225,11 +225,11 @@ void DelayedControls::applyControls(uint32_t sequence)\n>  \t * values are set in time to satisfy the sensor delay.\n>  \t */\n>  \tControlList out(device_->controls());\n> -\tfor (const auto &ctrl : values_) {\n> +\tfor (auto &ctrl : values_) {\n>  \t\tconst ControlId *id = ctrl.first;\n>  \t\tunsigned int delayDiff = maxDelay_ - controlParams_[id].delay;\n>  \t\tunsigned int index = std::max<int>(0, writeCount_ - delayDiff);\n> -\t\tconst Info &info = ctrl.second[index];\n> +\t\tInfo &info = ctrl.second[index];\n>  \n>  \t\tif (info.updated) {\n>  \t\t\tif (controlParams_[id].priorityWrite) {\n> @@ -252,12 +252,15 @@ void DelayedControls::applyControls(uint32_t sequence)\n>  \t\t\t\t<< \"Setting \" << id->name()\n>  \t\t\t\t<< \" to \" << info.toString()\n>  \t\t\t\t<< \" at index \" << index;\n> +\n> +\t\t\t/* Done with this update, so mark as completed. */\n> +\t\t\tinfo.updated = false;\n>  \t\t}\n>  \t}\n>  \n>  \twriteCount_++;\n>  \n> -\twhile (writeCount_ >= queueCount_) {\n> +\twhile (writeCount_ > queueCount_) {\n>  \t\tLOG(DelayedControls, Debug)\n>  \t\t\t<< \"Queue is empty, auto queue no-op.\";\n>  \t\tpush({});\n> -- \n> 2.25.1\n> \n> _______________________________________________\n> libcamera-devel mailing list\n> libcamera-devel@lists.libcamera.org\n> https://lists.libcamera.org/listinfo/libcamera-devel","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 15301BD1F1\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon,  1 Mar 2021 09:48:32 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id D7CE6689DD;\n\tMon,  1 Mar 2021 10:48:31 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 28F9F60521\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  1 Mar 2021 10:48:31 +0100 (CET)","from pyrite.rasen.tech (unknown\n\t[IPv6:2400:4051:61:600:2c71:1b79:d06d:5032])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id A8F8F332;\n\tMon,  1 Mar 2021 10:48:29 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"IjSZH5Vj\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1614592110;\n\tbh=2s7l4STeodDZAjfSgR0Eqebsv7dDnZVvLIR1m4yFY54=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=IjSZH5VjeTzlEzdBhV241BPXg8RCkcZzGU3hySpcFR71VxXxPTfk7SW58JmeEFuzX\n\taR5EcmZ5vFrIN3Bjc3A+3elB6/Nk6j3E8IEViIgZauuLa0TGa0Dc+qaUrgPTMuFozl\n\tm89KCkz5fAlVFfC5uIFuysIqpu/+NjzRfgCwv/EY=","Date":"Mon, 1 Mar 2021 18:48:23 +0900","From":"paul.elder@ideasonboard.com","To":"Naushir Patuck <naush@raspberrypi.com>","Message-ID":"<20210301094823.GE3084@pyrite.rasen.tech>","References":"<20210216085342.1012717-1-naush@raspberrypi.com>\n\t<20210216085342.1012717-5-naush@raspberrypi.com>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<20210216085342.1012717-5-naush@raspberrypi.com>","Subject":"Re: [libcamera-devel] [PATCH v2 4/5] libcamera: delayed_controls:\n\tRemove spurious no-op queued controls","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Cc":"libcamera-devel@lists.libcamera.org","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]