[{"id":15334,"web_url":"https://patchwork.libcamera.org/comment/15334/","msgid":"<YDvhk+nsNn5YRvw6@pendragon.ideasonboard.com>","date":"2021-02-28T18:31:47","subject":"Re: [libcamera-devel] [PATCH 06/12] 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 Fri, Feb 26, 2021 at 02:29:26PM +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> ---\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..61b5bbf429ae 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  const buffer_handle_t camera3Dest,\n\nShouldn't you drop const, based on patch 04/12 ?\n\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 compression should be moved to a\n\nWhile at it, s/compression/processing/ as we will have different types\nof post-processing ?\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\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..8673cacf15b0 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    const 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 77067BD1F1\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSun, 28 Feb 2021 18:32:18 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 0EF5C68A76;\n\tSun, 28 Feb 2021 19:32: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 DFC9768A45\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 28 Feb 2021 19:32:16 +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 4F5A680F;\n\tSun, 28 Feb 2021 19:32: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=\"Vuowvxqa\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1614537136;\n\tbh=y4I7iNuUqHyAUZNykIdNlsa9+UZ6shyq8lo3WSGcbEo=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=VuowvxqalaHrMQ0VZf793DtwkFD9lbnBJI+wYx/TlAv7UHV5YSSrahlABmeSQe8U3\n\tAqfsj8hco0c+joOutAGIFi16leL6gsDGiCgDpNA7zyQe4mzqjq6oax1lgQ8EZneWKN\n\ti4Y5k+3TPwEXRETch39DrNVKJodwBDA5MciG256g=","Date":"Sun, 28 Feb 2021 20:31:47 +0200","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Jacopo Mondi <jacopo@jmondi.org>","Message-ID":"<YDvhk+nsNn5YRvw6@pendragon.ideasonboard.com>","References":"<20210226132932.165484-1-jacopo@jmondi.org>\n\t<20210226132932.165484-7-jacopo@jmondi.org>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<20210226132932.165484-7-jacopo@jmondi.org>","Subject":"Re: [libcamera-devel] [PATCH 06/12] 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":"libcamera-devel@lists.libcamera.org","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>"}}]