[{"id":15369,"web_url":"https://patchwork.libcamera.org/comment/15369/","msgid":"<YD108DZY4WYxuT61@pendragon.ideasonboard.com>","date":"2021-03-01T23:12:48","subject":"Re: [libcamera-devel] [PATCH 05/10] android: Move buffer mapping to\n\tCameraStream","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Jacopo,\n\nThank you for the patch.\n\nOn Mon, Mar 01, 2021 at 04:01:06PM +0100, Jacopo Mondi wrote:\n> The destination buffer for the post-processing component is\n> currently first mapped in the CameraDevice class and then passed\n> to CameraStream which simply calls the post-processor interface.\n> \n> Move the mapping to CameraStream::process() to tie the buffer\n> mapping to the lifetime of the CameraBuffer instance.\n> \n> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> ---\n>  src/android/camera_device.cpp | 15 ++-------------\n>  src/android/camera_device.h   |  1 -\n>  src/android/camera_stream.cpp | 16 +++++++++++++---\n>  src/android/camera_stream.h   |  2 +-\n>  4 files changed, 16 insertions(+), 18 deletions(-)\n> \n> diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp\n> index 1c3b0f56ed28..ae01c362559e 100644\n> --- a/src/android/camera_device.cpp\n> +++ b/src/android/camera_device.cpp\n> @@ -1857,19 +1857,8 @@ void CameraDevice::requestComplete(Request *request)\n>  \t\t\tcontinue;\n>  \t\t}\n>  \n> -\t\t/*\n> -\t\t * \\todo Buffer mapping and compression should be moved to a\n> -\t\t * separate thread.\n> -\t\t */\n> -\n> -\t\tCameraBuffer dest(*descriptor->buffers_[i].buffer,\n> -\t\t\t\t  PROT_READ | PROT_WRITE);\n> -\t\tif (!dest.isValid()) {\n> -\t\t\tLOG(HAL, Error) << \"Failed to map android blob buffer\";\n> -\t\t\tcontinue;\n> -\t\t}\n> -\n> -\t\tint ret = cameraStream->process(*src, &dest,\n> +\t\tint ret = cameraStream->process(*src,\n> +\t\t\t\t\t\t*descriptor->buffers_[i].buffer,\n>  \t\t\t\t\t\tdescriptor->settings_,\n>  \t\t\t\t\t\tresultMetadata.get());\n>  \t\tif (ret) {\n> diff --git a/src/android/camera_device.h b/src/android/camera_device.h\n> index e6c192c2100b..4905958e63c6 100644\n> --- a/src/android/camera_device.h\n> +++ b/src/android/camera_device.h\n> @@ -24,7 +24,6 @@\n>  #include \"libcamera/internal/log.h\"\n>  #include \"libcamera/internal/message.h\"\n>  \n> -#include \"camera_buffer.h\"\n>  #include \"camera_metadata.h\"\n>  #include \"camera_stream.h\"\n>  #include \"camera_worker.h\"\n> diff --git a/src/android/camera_stream.cpp b/src/android/camera_stream.cpp\n> index 611ec0d1c42e..b2f03b505199 100644\n> --- a/src/android/camera_stream.cpp\n> +++ b/src/android/camera_stream.cpp\n> @@ -7,6 +7,7 @@\n>  \n>  #include \"camera_stream.h\"\n>  \n> +#include \"camera_buffer.h\"\n>  #include \"camera_device.h\"\n>  #include \"camera_metadata.h\"\n>  #include \"jpeg/post_processor_jpeg.h\"\n> @@ -96,15 +97,24 @@ int CameraStream::configure()\n>  }\n>  \n>  int CameraStream::process(const libcamera::FrameBuffer &source,\n> -\t\t\t  libcamera::MappedBuffer *destination,\n> +\t\t\t  buffer_handle_t camera3Dest,\n>  \t\t\t  const CameraMetadata &requestMetadata,\n>  \t\t\t  CameraMetadata *resultMetadata)\n>  {\n>  \tif (!postProcessor_)\n>  \t\treturn 0;\n>  \n> -\treturn postProcessor_->process(source, destination,\n> -\t\t\t\t       requestMetadata, resultMetadata);\n> +\t/*\n> +\t * \\todo Buffer mapping and processing should be moved to a\n> +\t * separate thread.\n> +\t */\n> +\tCameraBuffer dest(camera3Dest, PROT_READ | PROT_WRITE);\n> +\tif (!dest.isValid()) {\n> +\t\tLOG(HAL, Error) << \"Failed to map android blob buffer\";\n> +\t\treturn -EINVAL;\n> +\t}\n> +\n> +\treturn postProcessor_->process(source, &dest, requestMetadata, resultMetadata);\n>  }\n>  \n>  FrameBuffer *CameraStream::getBuffer()\n> diff --git a/src/android/camera_stream.h b/src/android/camera_stream.h\n> index fc242b2aadf1..f68fdd3a17cd 100644\n> --- a/src/android/camera_stream.h\n> +++ b/src/android/camera_stream.h\n> @@ -120,7 +120,7 @@ public:\n>  \n>  \tint configure();\n>  \tint process(const libcamera::FrameBuffer &source,\n> -\t\t    libcamera::MappedBuffer *destination,\n> +\t\t    buffer_handle_t camera3Dest,\n>  \t\t    const CameraMetadata &requestMetadata,\n>  \t\t    CameraMetadata *resultMetadata);\n>  \tlibcamera::FrameBuffer *getBuffer();","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 7E97DBD808\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon,  1 Mar 2021 23:13:18 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 4AFE568A8F;\n\tTue,  2 Mar 2021 00:13:18 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 3223068A45\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  2 Mar 2021 00:13:17 +0100 (CET)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 9C4E945D;\n\tTue,  2 Mar 2021 00:13:16 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"uvxNINYj\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1614640396;\n\tbh=9GwEwNPYLRfdd6CRvduC2f780RKAjTO9qLDgu7s++DM=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=uvxNINYjSYTD0MUdZWEvu+EGhLRKkVhl3sNV3ZQV3IeErRLBz2ZEKqVt8OrCt41L5\n\tpjVCDiqZRPqNRksFyclsgbWjxRP/0cc+qnsx8b+vVQalYYWbF8IdLS/h0GbnRyeaGw\n\tOTEvaab3ar9MjqttkTqoETZ8Xkd3ZVrS2PF4Oinw=","Date":"Tue, 2 Mar 2021 01:12:48 +0200","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Jacopo Mondi <jacopo@jmondi.org>","Message-ID":"<YD108DZY4WYxuT61@pendragon.ideasonboard.com>","References":"<20210301150111.61791-1-jacopo@jmondi.org>\n\t<20210301150111.61791-6-jacopo@jmondi.org>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<20210301150111.61791-6-jacopo@jmondi.org>","Subject":"Re: [libcamera-devel] [PATCH 05/10] android: Move buffer mapping to\n\tCameraStream","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Cc":"Han-lin Chen <hanlinchen@chromium.org>,\n\tlibcamera-devel@lists.libcamera.org, Daniel Hung-yu Wu <hywu@google.com>","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]