From patchwork Fri Feb 26 13:29:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 11399 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 23224BD1F1 for ; Fri, 26 Feb 2021 13:29:22 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id B405F68A8C; Fri, 26 Feb 2021 14:29:21 +0100 (CET) Received: from relay12.mail.gandi.net (relay12.mail.gandi.net [217.70.178.232]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id A1D5868A61 for ; Fri, 26 Feb 2021 14:29:15 +0100 (CET) Received: from uno.LocalDomain (93-61-96-190.ip145.fastwebnet.it [93.61.96.190]) (Authenticated sender: jacopo@jmondi.org) by relay12.mail.gandi.net (Postfix) with ESMTPSA id 6690E200013 for ; Fri, 26 Feb 2021 13:29:15 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Fri, 26 Feb 2021 14:29:26 +0100 Message-Id: <20210226132932.165484-7-jacopo@jmondi.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210226132932.165484-1-jacopo@jmondi.org> References: <20210226132932.165484-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 06/12] android: Move buffer mapping to CameraStream 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" The destination buffer for the post-processing component is currently first mapped in the CameraDevice class and then passed to CameraStream which simply calls the post-processor interface. Move the mapping to CameraStream::process() to tie the buffer mapping to the lifetime of the CameraBuffer instance. Signed-off-by: Jacopo Mondi Reviewed-by: Laurent Pinchart --- src/android/camera_device.cpp | 15 ++------------- src/android/camera_device.h | 1 - src/android/camera_stream.cpp | 16 +++++++++++++--- src/android/camera_stream.h | 2 +- 4 files changed, 16 insertions(+), 18 deletions(-) diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp index 1c3b0f56ed28..ae01c362559e 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -1857,19 +1857,8 @@ void CameraDevice::requestComplete(Request *request) continue; } - /* - * \todo Buffer mapping and compression should be moved to a - * separate thread. - */ - - CameraBuffer dest(*descriptor->buffers_[i].buffer, - PROT_READ | PROT_WRITE); - if (!dest.isValid()) { - LOG(HAL, Error) << "Failed to map android blob buffer"; - continue; - } - - int ret = cameraStream->process(*src, &dest, + int ret = cameraStream->process(*src, + *descriptor->buffers_[i].buffer, descriptor->settings_, resultMetadata.get()); if (ret) { diff --git a/src/android/camera_device.h b/src/android/camera_device.h index e6c192c2100b..4905958e63c6 100644 --- a/src/android/camera_device.h +++ b/src/android/camera_device.h @@ -24,7 +24,6 @@ #include "libcamera/internal/log.h" #include "libcamera/internal/message.h" -#include "camera_buffer.h" #include "camera_metadata.h" #include "camera_stream.h" #include "camera_worker.h" diff --git a/src/android/camera_stream.cpp b/src/android/camera_stream.cpp index 611ec0d1c42e..61b5bbf429ae 100644 --- a/src/android/camera_stream.cpp +++ b/src/android/camera_stream.cpp @@ -7,6 +7,7 @@ #include "camera_stream.h" +#include "camera_buffer.h" #include "camera_device.h" #include "camera_metadata.h" #include "jpeg/post_processor_jpeg.h" @@ -96,15 +97,24 @@ int CameraStream::configure() } int CameraStream::process(const libcamera::FrameBuffer &source, - libcamera::MappedBuffer *destination, + const buffer_handle_t camera3Dest, const CameraMetadata &requestMetadata, CameraMetadata *resultMetadata) { if (!postProcessor_) return 0; - return postProcessor_->process(source, destination, - requestMetadata, resultMetadata); + /* + * \todo Buffer mapping and compression should be moved to a + * separate thread. + */ + CameraBuffer dest(camera3Dest, PROT_READ | PROT_WRITE); + if (!dest.isValid()) { + LOG(HAL, Error) << "Failed to map android blob buffer"; + return -EINVAL; + } + + return postProcessor_->process(source, &dest, requestMetadata, resultMetadata); } FrameBuffer *CameraStream::getBuffer() diff --git a/src/android/camera_stream.h b/src/android/camera_stream.h index fc242b2aadf1..8673cacf15b0 100644 --- a/src/android/camera_stream.h +++ b/src/android/camera_stream.h @@ -120,7 +120,7 @@ public: int configure(); int process(const libcamera::FrameBuffer &source, - libcamera::MappedBuffer *destination, + const buffer_handle_t camera3Dest, const CameraMetadata &requestMetadata, CameraMetadata *resultMetadata); libcamera::FrameBuffer *getBuffer();