From patchwork Tue Mar 19 12:05:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Klug X-Patchwork-Id: 19748 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 86653BD160 for ; Tue, 19 Mar 2024 12:05:42 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 12CDB62D3C; Tue, 19 Mar 2024 13:05:39 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="wkrwpne/"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 75D0262D27 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 BBACAF02; Tue, 19 Mar 2024 13:05:02 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1710849902; bh=kyRJ45pWGO4NCh/fbdEU9zKRDng0jLzHN++IvImihv8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wkrwpne/dFq1nmvWoek1KSwQWRW7nNfwnZUaHE8/eXR9Om4TYQ9ODLOrlOzsBh+o4 POJ81MskCLbXWTROuduTaaM/zBf+j2T85oSs3h07RDYsp9aZdiKLXE9ySgPrUsHjDB PPj50bMFDiBr8xXXnrLc14drLgaIcb7wEYQaCG68= From: Stefan Klug To: libcamera-devel@lists.libcamera.org Cc: Stefan Klug Subject: [PATCH v3 08/16] libcamera: delayed_controls: Add ctrls list parameter to reset() function Date: Tue, 19 Mar 2024 13:05:09 +0100 Message-Id: <20240319120517.362082-9-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" 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 Reviewed-by: Jacopo Mondi --- include/libcamera/internal/delayed_controls.h | 2 +- src/libcamera/delayed_controls.cpp | 22 +++++++++++++++---- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/include/libcamera/internal/delayed_controls.h b/include/libcamera/internal/delayed_controls.h index ccbe7239..224c1f7e 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); ControlList get(uint32_t sequence); diff --git a/src/libcamera/delayed_controls.cpp b/src/libcamera/delayed_controls.cpp index 6c766ede..6f06950e 100644 --- a/src/libcamera/delayed_controls.cpp +++ b/src/libcamera/delayed_controls.cpp @@ -109,11 +109,13 @@ DelayedControls::DelayedControls(V4L2Device *device, /** * \brief Reset state machine + * \param[in,out] controls The controls to apply to the device * * Resets the state machine to a starting position based on control values - * retrieved from the device. + * retrieved from the device. If \a controls is given, these controls are set + * on the device before retrieving the reset values. */ -void DelayedControls::reset() +void DelayedControls::reset(ControlList *controls) { queueIndex_ = 1; writeIndex_ = 0; @@ -123,11 +125,23 @@ void DelayedControls::reset() for (auto const ¶m : controlParams_) ids.push_back(param.first->id()); - ControlList controls = device_->getControls(ids); + if (controls) { + device_->setControls(controls); + + LOG(DelayedControls, Debug) << "reset:"; + auto idMap = controls->idMap(); + if (idMap) { + for (const auto &[id, value] : *controls) + LOG(DelayedControls, Debug) << " " << idMap->at(id)->name() + << " : " << value.toString(); + } + } + + ControlList ctrls = device_->getControls(ids); /* Seed the control queue with the controls reported by the device. */ values_.clear(); - for (const auto &ctrl : controls) { + for (const auto &ctrl : ctrls) { const ControlId *id = device_->controls().idmap().at(ctrl.first); /* * Do not mark this control value as updated, it does not need