From patchwork Wed Mar 13 10:56:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Klug X-Patchwork-Id: 19694 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 0F1E3C32A3 for ; Wed, 13 Mar 2024 10:57:10 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 4772162CA5; Wed, 13 Mar 2024 11:57:03 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="tVwHY1hv"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id A182D62C8B for ; Wed, 13 Mar 2024 11:56:53 +0100 (CET) Received: from jasper.fritz.box (unknown [IPv6:2a00:6020:448c:6c00:9b07:31b5:38e1:e957]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 38B74899; Wed, 13 Mar 2024 11:56:31 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1710327391; bh=0fdCqsmsRjGgHyqD2+KCaAkGapqqFfm+kwHb3gyTHbo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tVwHY1hv8WTgJoLPL9veER7FHSlLMqE4DA+VL9RWTNHiqNpy2j54WU6cQ8NAkL1Hl C5iWzIGdqPl460rc7UlJVw1uTOFU3eJGcx9tXLyEJ/8WLBn1fWQpE3bN+WlLD/y3rq RGnhxm+OpLtCClyQUFQKmPrhvRpnpRolInC4bLzE= From: Stefan Klug To: libcamera-devel@lists.libcamera.org Subject: [PATCH 05/12] libcamera: delayed_controls: Rename class members Date: Wed, 13 Mar 2024 11:56:37 +0100 Message-Id: <20240313105645.120317-6-stefan.klug@ideasonboard.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240313105645.120317-1-stefan.klug@ideasonboard.com> References: <20240313105645.120317-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" In preperation for the following patch, the class members are renamed to better express their intent. This might be a little picky, but my head is just more used to thinking of an index than a count. Signed-off-by: Stefan Klug --- include/libcamera/internal/delayed_controls.h | 6 ++++-- src/libcamera/delayed_controls.cpp | 20 +++++++++---------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/include/libcamera/internal/delayed_controls.h b/include/libcamera/internal/delayed_controls.h index aef37077..4f8d2424 100644 --- a/include/libcamera/internal/delayed_controls.h +++ b/include/libcamera/internal/delayed_controls.h @@ -72,8 +72,10 @@ private: std::unordered_map controlParams_; unsigned int maxDelay_; - uint32_t queueCount_; - uint32_t writeCount_; + /* Index of the next request to queue */ + uint32_t queueIndex_; + /* Index of the next request that gets written and is guaranteed to be fully applied */ + uint32_t writeIndex_; /* \todo Evaluate if we should index on ControlId * or unsigned int */ std::unordered_map values_; }; diff --git a/src/libcamera/delayed_controls.cpp b/src/libcamera/delayed_controls.cpp index 777441e8..86571cd4 100644 --- a/src/libcamera/delayed_controls.cpp +++ b/src/libcamera/delayed_controls.cpp @@ -115,8 +115,8 @@ DelayedControls::DelayedControls(V4L2Device *device, */ void DelayedControls::reset() { - queueCount_ = 1; - writeCount_ = 0; + queueIndex_ = 1; + writeIndex_ = 0; /* Retrieve control as reported by the device. */ std::vector ids; @@ -150,8 +150,8 @@ bool DelayedControls::push(const ControlList &controls) { /* Copy state from previous frame. */ for (auto &ctrl : values_) { - Info &info = ctrl.second[queueCount_]; - info = values_[ctrl.first][queueCount_ - 1]; + Info &info = ctrl.second[queueIndex_]; + info = values_[ctrl.first][queueIndex_ - 1]; info.updated = false; } @@ -170,17 +170,17 @@ bool DelayedControls::push(const ControlList &controls) if (controlParams_.find(id) == controlParams_.end()) return false; - Info &info = values_[id][queueCount_]; + Info &info = values_[id][queueIndex_]; info = Info(control.second); LOG(DelayedControls, Debug) << "Queuing " << id->name() << " to " << info.toString() - << " at index " << queueCount_; + << " at index " << queueIndex_; } - queueCount_++; + queueIndex_++; return true; } @@ -241,7 +241,7 @@ void DelayedControls::applyControls(uint32_t sequence) for (auto &ctrl : values_) { const ControlId *id = ctrl.first; unsigned int delayDiff = maxDelay_ - controlParams_[id].delay; - unsigned int index = std::max(0, writeCount_ - delayDiff); + unsigned int index = std::max(0, writeIndex_ - delayDiff); Info &info = ctrl.second[index]; if (info.updated) { @@ -271,9 +271,9 @@ void DelayedControls::applyControls(uint32_t sequence) } } - writeCount_ = sequence + 1; + writeIndex_ = sequence + 1; - while (writeCount_ > queueCount_) { + while (writeIndex_ > queueIndex_) { LOG(DelayedControls, Debug) << "Queue is empty, auto queue no-op."; push({});