From patchwork Tue Mar 19 12:05:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Klug X-Patchwork-Id: 19750 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 347C2C32C7 for ; Tue, 19 Mar 2024 12:05:44 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 6775D62D32; Tue, 19 Mar 2024 13:05:42 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="wde0jtBV"; 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 F41E962CA8 for ; Tue, 19 Mar 2024 13:05:29 +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 48304F02; Tue, 19 Mar 2024 13:05:03 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1710849903; bh=7jyWwJWbWc+w2r/bxH6jSapXRfGGacSKdC6GGq/QzNo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wde0jtBVq+Nk423Satk+gDeFhMWrWivGARUt6ViPJXFt3XomtUnpQt3TmOX/ZxPJQ qoaqkD7oCEh9146qoKs+Ls79agPhIwkMa8ipaU41POJciyfl+faEBt1Cu+VgZYTJmQ jCnBLeA1hf0Qk2pISDRKD2WoC0ccs3saQSTRAL0Q= From: Stefan Klug To: libcamera-devel@lists.libcamera.org Cc: Stefan Klug Subject: [PATCH v3 10/16] libcamera: delayed_controls: Add fillValues() helper Date: Tue, 19 Mar 2024 13:05:11 +0100 Message-Id: <20240319120517.362082-11-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 the upcoming patches the function to initialize the value in the ringbuffer is needed at multiple places. So it makes sense to factor it out. Signed-off-by: Stefan Klug --- include/libcamera/internal/delayed_controls.h | 1 + src/libcamera/delayed_controls.cpp | 28 +++++++++++++++---- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/include/libcamera/internal/delayed_controls.h b/include/libcamera/internal/delayed_controls.h index 5a0428e0..db5c29e9 100644 --- a/include/libcamera/internal/delayed_controls.h +++ b/include/libcamera/internal/delayed_controls.h @@ -70,6 +70,7 @@ private: }; bool controlsAreQueued(unsigned int frame, const ControlList &controls); + void fillValues(unsigned int fromIndex, unsigned int toIndex); V4L2Device *device_; /* \todo Evaluate if we should index on ControlId * or unsigned int */ diff --git a/src/libcamera/delayed_controls.cpp b/src/libcamera/delayed_controls.cpp index 8cfa6bbb..e325b6b2 100644 --- a/src/libcamera/delayed_controls.cpp +++ b/src/libcamera/delayed_controls.cpp @@ -185,6 +185,27 @@ bool DelayedControls::controlsAreQueued(unsigned int sequence, return true; } +/** + * @brief Helper function to fill the values with the data from previous entries + * + * @param fromIndex The index to start the copy from + * @param toIndex The last index that gets filled + * + * The updated member of the control values is reset to false. + */ +void DelayedControls::fillValues(unsigned int fromIndex, unsigned int toIndex) +{ + /* Copy state from previous queue. */ + for (auto &ctrl : values_) { + auto &ringBuffer = ctrl.second; + for (auto i = fromIndex; i < toIndex; i++) { + Info &info = ringBuffer[i + 1]; + info = ringBuffer[i]; + info.updated = false; + } + } +} + /** * \brief Push a set of controls on the queue * \param[in] controls List of controls to add to the device queue @@ -196,12 +217,7 @@ bool DelayedControls::controlsAreQueued(unsigned int sequence, */ bool DelayedControls::push(const ControlList &controls) { - /* Copy state from previous frame. */ - for (auto &ctrl : values_) { - Info &info = ctrl.second[queueIndex_]; - info = values_[ctrl.first][queueIndex_ - 1]; - info.updated = false; - } + fillValues(queueIndex_ - 1, queueIndex_); /* Update with new controls. */ const ControlIdMap &idmap = device_->controls().idmap();