From patchwork Mon Jun 29 16:30:14 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: 27129 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 111CEC3303 for ; Mon, 29 Jun 2026 16:31:42 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id CDE6A65FC3; Mon, 29 Jun 2026 18:31:41 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="X2SGzmWb"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id D483A65F75 for ; Mon, 29 Jun 2026 18:30:33 +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 ACF3E1044 for ; Mon, 29 Jun 2026 18:29:50 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1782750590; bh=XKl2eO1QWEXdNrfLES9PG0IyEzsv415hXcC0a7vSego=; h=From:To:Subject:Date:In-Reply-To:References:From; b=X2SGzmWberaZBNnyg+iQhlIQPEADpozfybXnn0qFXaW1W/kkFsc+SnH3cDeaChgca E2PEus6OKn36N9iLhGH6SJFVtSf4y4RQ3jpJdcW3C5//cT08tWedkt2tFi2Z3H4dW4 YDr7ArLZZQslK2tffdV8bSwMht+8M/SomsLDyATE= From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= To: libcamera-devel@lists.libcamera.org Subject: [RFC PATCH v1 51/54] android: camera_device: Move fence restoration into `prepareToReturn()` Date: Mon, 29 Jun 2026 18:30:14 +0200 Message-ID: <20260629163017.863145-52-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" It is sufficient to restore the fence for returning it to the camera framework just before the returned `camera3_stream_buffer_t` is constructed, so do that. Signed-off-by: Barnabás Pőcze --- src/android/camera_device.cpp | 19 +------------------ src/android/camera_request.cpp | 13 +++++++++++++ 2 files changed, 14 insertions(+), 18 deletions(-) diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp index 0d5b5b97eb..09aa129e0a 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -1146,25 +1146,8 @@ void CameraDevice::requestComplete(Request *request) * The buffer status is set to Success and later changed to Error if * post-processing/compression fails. */ - for (auto &buffer : descriptor->buffers_) { - CameraStream *stream = buffer.stream; - - /* - * Streams of type Direct have been queued to the - * libcamera::Camera and their acquire fences have - * already been waited on by the library. - * - * Acquire fences of streams of type Internal and Mapped - * will be handled during post-processing. - */ - if (stream->type() == CameraStream::Type::Direct) { - /* If handling of the fence has failed restore buffer.fence. */ - std::unique_ptr fence = buffer.frameBuffer->releaseFence(); - if (fence) - buffer.fence = fence->release(); - } + for (auto &buffer : descriptor->buffers_) buffer.status = Camera3RequestDescriptor::Status::Success; - } /* * If the Request has failed, abort the request by notifying the error diff --git a/src/android/camera_request.cpp b/src/android/camera_request.cpp index feac7a3e19..6dfe692f09 100644 --- a/src/android/camera_request.cpp +++ b/src/android/camera_request.cpp @@ -10,6 +10,7 @@ #include #include "camera_buffer.h" +#include "camera_stream.h" using namespace libcamera; @@ -195,6 +196,18 @@ Camera3RequestDescriptor::StreamBuffer::operator=(Camera3RequestDescriptor::Stre camera3_stream_buffer_t Camera3RequestDescriptor::StreamBuffer::prepareToReturn() { + /* + * Streams of type Direct have a non-nullptr `frameBuffer` and + * have been queued to the libcamera::Camera and their acquire + * fences have already been waited on by the library. + */ + if (frameBuffer) { + /* If handling of the fence has failed restore buffer.fence. */ + auto f = frameBuffer->releaseFence(); + if (f) + fence = f->release(); + } + /* * Pass the buffer fence back to the camera framework as * a release fence. This instructs the framework to wait