From patchwork Mon Jun 29 16:29:54 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: 27109 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 A04AEC3261 for ; Mon, 29 Jun 2026 16:31:21 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 2FF2C65FB4; Mon, 29 Jun 2026 18:31:21 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="Xbl3pHIz"; 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 E2A6565F55 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 BDB9EE91 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=IJi/icnrKqaZDiI5CZq7vFXpwDQxSQPkURvjTG1Vu1g=; h=From:To:Subject:Date:In-Reply-To:References:From; b=Xbl3pHIzShpeGuo6cJe7FH79Zvnp+MB1kZVYhDKN01uYWbmyesEJgnNUSV5TYmqog rdO0VoFSrhfD8rhhrgYkBQOe4g3J/tFRwB8mopTBoRpdObMGkpx/25jlhMy3axwgUJ stvmPcxKxyDVWcUZ10raNmD3Mpf9g2dlJg0vf78M= From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= To: libcamera-devel@lists.libcamera.org Subject: [RFC PATCH v1 31/54] libcamera: camera: rejectBuffer(): Add Date: Mon, 29 Jun 2026 18:29:54 +0200 Message-ID: <20260629163017.863145-32-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 function that can be used to signal that a queued buffer is not acceptable and no data has been stored into it. Signed-off-by: Barnabás Pőcze --- include/libcamera/internal/camera.h | 6 ++++++ src/libcamera/camera.cpp | 32 +++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/include/libcamera/internal/camera.h b/include/libcamera/internal/camera.h index 31914075f0..13b72258ff 100644 --- a/include/libcamera/internal/camera.h +++ b/include/libcamera/internal/camera.h @@ -59,6 +59,12 @@ public: using PooledFrameBuffer = std::unique_ptr; [[nodiscard]] PooledFrameBuffer acquireBuffer(const Stream *stream); + void rejectBuffer(FrameBuffer *buffer); + + void rejectBuffer(PooledFrameBuffer buffer) + { + return rejectBuffer(buffer.release()); + } private: enum State { diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp index 016f36e796..be55ed72c4 100644 --- a/src/libcamera/camera.cpp +++ b/src/libcamera/camera.cpp @@ -790,6 +790,38 @@ Camera::Private::acquireBuffer(const Stream *stream) it->second.buffers.pop_back(); return { buffer, { &it->second.buffers } }; } + +/** + * \brief Return a buffer to the application + * \param[in] buffer The buffer + * + * \note \a buffer must not be in the camera's buffer pool + * \todo return fence on timeout? + */ +void Camera::Private::rejectBuffer(FrameBuffer *buffer) +{ + ASSERT(!buffer->_d()->request()); + ASSERT(buffer->_d()->stream_); + + LOG(Camera, Debug) + << "Camera:" << LIBCAMERA_O_PTR() << " rejects buffer:" + << buffer << " for stream:" << buffer->_d()->stream_; + + /* + * \todo Not `FrameError` because that requires `timestamp` and + * `sequence` to be valid. + */ + buffer->_d()->cancel(); + buffer->_d()->stream_ = nullptr; + + // \todo separate event (with stream) ? + LIBCAMERA_O_PTR()->bufferCompleted.emit(nullptr, buffer); +} + +/** + * \fn Camera::Private::rejectBuffer(PooledFrameBuffer buffer) + * \copydoc Camera::Private::rejectBuffer(FrameBuffer *buffer) + */ #endif /* __DOXYGEN_PUBLIC__ */ /**