From patchwork Wed Mar 13 10:56:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Klug X-Patchwork-Id: 19696 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 F2101BD1F1 for ; Wed, 13 Mar 2024 10:57:11 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 9DE0962C9A; Wed, 13 Mar 2024 11:57:05 +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="pJUn/1/x"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 5E2D262C8F for ; Wed, 13 Mar 2024 11:56:54 +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 E8CA0A8F; 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=1710327392; bh=sO0A/gemJARVBZjvuPwdylUf4HYJ/EZt5BDp1fF+NCs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pJUn/1/xqvb6YsdxGXCkkt211+QHSU7lH/Zl6/a41JNa+CwZxkjUrw23RySvwoO8y nH0Lwxszim00JKR02RFjjyyhucHkgCkVsxWUsIXaLF8+wVel0t9gZ6pOEudXUiP/na z4rL8RWyu/C7wUhX9O0PLRmeJjO9ojPJXZ5sGYh0= From: Stefan Klug To: libcamera-devel@lists.libcamera.org Subject: [PATCH 08/12] libcamera: delayed_controls: Add ctrls list parameter to reset() function Date: Wed, 13 Mar 2024 11:56:40 +0100 Message-Id: <20240313105645.120317-9-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" This makes it easier for the caller. There is often this pattern sensor_->setControls(controls); delayedControls_->reset(); which can then be reduced to delayedControls_->reset(controls); Signed-off-by: Stefan Klug --- include/libcamera/internal/delayed_controls.h | 2 +- src/libcamera/delayed_controls.cpp | 14 +++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/include/libcamera/internal/delayed_controls.h b/include/libcamera/internal/delayed_controls.h index 2738e8bf..a3063400 100644 --- a/include/libcamera/internal/delayed_controls.h +++ b/include/libcamera/internal/delayed_controls.h @@ -27,7 +27,7 @@ public: DelayedControls(V4L2Device *device, const std::unordered_map &controlParams); - void reset(); + void reset(ControlList *controls = nullptr); bool push(const ControlList &controls); bool pushForFrame(uint32_t sequence, const ControlList &controls); diff --git a/src/libcamera/delayed_controls.cpp b/src/libcamera/delayed_controls.cpp index c46e54d1..ac38eb64 100644 --- a/src/libcamera/delayed_controls.cpp +++ b/src/libcamera/delayed_controls.cpp @@ -115,7 +115,7 @@ DelayedControls::DelayedControls(V4L2Device *device, * Resets the state machine to a starting position based on control values * retrieved from the device. */ -void DelayedControls::reset() +void DelayedControls::reset(ControlList *ctrls) { queueIndex_ = 0; /* Frames up to maxDelay_ will be based on sensor init values. */ @@ -126,6 +126,18 @@ void DelayedControls::reset() for (auto const ¶m : controlParams_) ids.push_back(param.first->id()); + if (ctrls) { + device_->setControls(ctrls); + + LOG(DelayedControls, Debug) << "reset:"; + auto idMap = ctrls->idMap(); + if (idMap) { + for (const auto &[id, value] : *ctrls) { + LOG(DelayedControls, Debug) << " " << idMap->at(id)->name() << " : " << value.toString(); + } + } + } + ControlList controls = device_->getControls(ids); /* Seed the control queue with the controls reported by the device. */