From patchwork Tue Mar 19 12:05:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Klug X-Patchwork-Id: 19745 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 ECF1AC3274 for ; Tue, 19 Mar 2024 12:05:39 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id C608162D2F; Tue, 19 Mar 2024 13:05:35 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="soxGyqYm"; 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 9DF4162CAD for ; Tue, 19 Mar 2024 13:05:28 +0100 (CET) Received: from jasper.fritz.box (unknown [IPv6:2a00:6020:448c:6c00:1478:344b:8fcb:baf5]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id EBA5F480; Tue, 19 Mar 2024 13:05:01 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1710849902; bh=0fdCqsmsRjGgHyqD2+KCaAkGapqqFfm+kwHb3gyTHbo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=soxGyqYmMaTIVE3GtClGxonkRle2RCUDArDCuGPYWjEH6QAdeHPPW9ZV0Lk7jyuB0 6+/4SsZXNiKCO1Sgt+vDjEHSzxkhPio6Zf6TpGYc2omJ5xYfHGX7MlUkWyUCdXTfGO Bjkccn9tm/IXE4TOovzNb9Df3pG9jutkXJc+zNQQ= From: Stefan Klug To: libcamera-devel@lists.libcamera.org Cc: Stefan Klug Subject: [PATCH v3 05/16] libcamera: delayed_controls: Rename class members Date: Tue, 19 Mar 2024 13:05:06 +0100 Message-Id: <20240319120517.362082-6-stefan.klug@ideasonboard.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240319120517.362082-1-stefan.klug@ideasonboard.com> References: <20240319120517.362082-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({});