From patchwork Mon Jun 29 16:29:52 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= X-Patchwork-Id: 27108 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 B8272C3261 for ; Mon, 29 Jun 2026 16:31:20 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 56E1B65F92; Mon, 29 Jun 2026 18:31:20 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="WjqPwSXp"; 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 7B29E65F33 for ; Mon, 29 Jun 2026 18:30:27 +0200 (CEST) Received: from pb-laptop.local (185.221.140.128.nat.pool.zt.hu [185.221.140.128]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 540CAE91 for ; Mon, 29 Jun 2026 18:29:44 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1782750584; bh=4K1DR+Z1s585oyJz9UXE/kiOJs3cKR4OAQuWD9T9NNU=; h=From:To:Subject:Date:In-Reply-To:References:From; b=WjqPwSXpr/cBqP4Yvdkt6fKvb9v9H/x7OhIzGnF6FF9UIp8DpjtdE90koYPODxoFU Yj8I5ZWRO24zj+ex0qKTbUYb3rI0UVUrp6/h7mmnZOpRUGF31SkF/u+7IDSwXgzlZI 9KMcvvBexI/5jB4LyT0vISijiauduHYB8QTVyW84= From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= To: libcamera-devel@lists.libcamera.org Subject: [RFC PATCH v1 29/54] libcamera: request: enableStream(): Add Date: Mon, 29 Jun 2026 18:29:52 +0200 Message-ID: <20260629163017.863145-30-barnabas.pocze@ideasonboard.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260629163017.863145-1-barnabas.pocze@ideasonboard.com> References: <20260629163017.863145-1-barnabas.pocze@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" Add a funtion that can enable/disable streams without adding buffers. Specifically, use a `nullptr` as buffer to mark enabled stream. Adjust `completeBuffer()` to set the buffer pointer in the map. Signed-off-by: Barnabás Pőcze --- include/libcamera/request.h | 1 + src/libcamera/request.cpp | 30 +++++++++++++++++++++++++++++- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/include/libcamera/request.h b/include/libcamera/request.h index 290983f613..c86259c59b 100644 --- a/include/libcamera/request.h +++ b/include/libcamera/request.h @@ -55,6 +55,7 @@ public: int addBuffer(const Stream *stream, FrameBuffer *buffer, std::unique_ptr &&fence = {}); FrameBuffer *findBuffer(const Stream *stream) const; + void enableStream(const Stream *stream, bool enabled); uint32_t sequence() const; uint64_t cookie() const { return cookie_; } diff --git a/src/libcamera/request.cpp b/src/libcamera/request.cpp index 5bb1617b51..d7cf39ae2e 100644 --- a/src/libcamera/request.cpp +++ b/src/libcamera/request.cpp @@ -110,13 +110,16 @@ bool Request::Private::completeBuffer(FrameBuffer *buffer) Request *request = LIBCAMERA_O_PTR(); camera_->bufferCompleted.emit(request, buffer); - ASSERT(request->findBuffer(buffer->_d()->stream_) == buffer); + auto it = request->bufferMap_.find(buffer->_d()->stream_); + ASSERT(it != request->bufferMap_.end()); + ASSERT(it->second == buffer || !it->second); ASSERT(pending_ > 0); pending_ -= 1; buffer->_d()->setRequest(nullptr); buffer->_d()->stream_ = nullptr; + it->second = buffer; if (buffer->metadata().status == FrameMetadata::FrameCancelled) cancelled_ = true; @@ -337,6 +340,31 @@ FrameBuffer *Request::findBuffer(const Stream *stream) const return it->second; } +/** + * \brief Change whether the particular stream should be captured + * \param[in] stream The stream + * \param[in] enabled Whether to enable or disable the stream + */ +void Request::enableStream(const Stream *stream, bool enabled) +{ + ASSERT(stream); + + Request::Private *const d = _d(); + + if (enabled) { + const auto [it, inserted] = bufferMap_.try_emplace(stream); + + it->second = nullptr; + d->pending_ += inserted; + } else { + d->pending_ -= bufferMap_.erase(stream); + } + + LOG(Request, Debug) + << "request:" << this << " stream:" << stream + << ' ' << (enabled ? "en" : "dis") << "abled pending:" << d->pending_; +} + /** * \brief Retrieve the sequence number for the request *