From patchwork Wed Mar 13 10:56:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Klug X-Patchwork-Id: 19698 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 AAFDFC32C5 for ; Wed, 13 Mar 2024 10:57:13 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 8830C62CA6; Wed, 13 Mar 2024 11:57:08 +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="XfpRMsV5"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id A064A62C91 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 2ED4B899; Wed, 13 Mar 2024 11:56:32 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1710327392; bh=3FfanLJUApKs1WDW9CpWtnIIjK3Qjfh5LEQCWvo9zTo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XfpRMsV5IyxB7RyAsOVM/oNhOkCPhTxMUf1ABNS6gS56RCiLbTpMmQcJILGUUg/fO 7gfd+j6loTxN1t8uo3/3beCqrgPwQEkK/6Imxip9+wxIP/f3A4KVfT5/eNXd9wJMg6 z2a7LziEpP2rroxVyZ9axhiqo89TtougQ6cvOvhs= From: Stefan Klug To: libcamera-devel@lists.libcamera.org Subject: [PATCH 08/12] libcamera: delayed_controls: add ctrls list to reset function Date: Wed, 13 Mar 2024 11:56:41 +0100 Message-Id: <20240313105645.120317-10-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); --- 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. */