[{"id":14671,"web_url":"https://patchwork.libcamera.org/comment/14671/","msgid":"<YAnzthPiMX/uKAtA@pendragon.ideasonboard.com>","date":"2021-01-21T21:35:50","subject":"Re: [libcamera-devel] [PATCH 3/7] android: camera_device: Copy\n\tcamera3 buffers in descriptor","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 Thu, Jan 21, 2021 at 05:53:01PM +0100, Jacopo Mondi wrote:\n> The camera3_stream_buffer_t instances part of a capture request contain\n> information on the stream for which capture has been requested (size,\n> format and fences) and an handle to the stream's memory buffers.\n\ns/an handle/a handle/\n\n> Those information are copied in the descriptor one at the time while\n\ns/Those information are/This information is/\ns/one/one piece/\n\n> processing the camera3 streams to be re-used at request completion time.\n> \n> Simplyify the code by copying the stream information in the descriptor\n> at construction time.\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 | 27 ++++++++-------------------\n>  1 file changed, 8 insertions(+), 19 deletions(-)\n> \n> diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp\n> index f10b572749eb..578fb2271a9e 100644\n> --- a/src/android/camera_device.cpp\n> +++ b/src/android/camera_device.cpp\n> @@ -299,8 +299,11 @@ CameraDevice::Camera3RequestDescriptor::Camera3RequestDescriptor(\n>  {\n>  \tframeNumber_ = camera3Request->frame_number;\n>  \n> +\t/* Copy the camera3 request stream information for later access. */\n>  \tnumBuffers_ = camera3Request->num_output_buffers;\n>  \tbuffers_ = new camera3_stream_buffer_t[numBuffers_];\n> +\tfor (unsigned int i = 0; i < numBuffers_; ++i)\n> +\t\tbuffers_[i] = camera3Request->output_buffers[i];\n>  \n>  \t/*\n>  \t * FrameBuffer instances created by wrapping a camera3 provided dmabuf\n> @@ -1672,13 +1675,6 @@ int CameraDevice::processCaptureRequest(camera3_capture_request_t *camera3Reques\n>  \t\trunning_ = true;\n>  \t}\n>  \n> -\t/*\n> -\t * Queue a request for the Camera with the provided dmabuf file\n> -\t * descriptors.\n> -\t */\n> -\tconst camera3_stream_buffer_t *camera3Buffers =\n> -\t\t\t\t\tcamera3Request->output_buffers;\n> -\n>  \t/*\n>  \t * Save the request descriptors for use at completion time.\n>  \t * The descriptor and the associated memory reserved here are freed\n> @@ -1690,16 +1686,9 @@ int CameraDevice::processCaptureRequest(camera3_capture_request_t *camera3Reques\n>  \tLOG(HAL, Debug) << \"Queueing Request to libcamera with \"\n>  \t\t\t<< descriptor->numBuffers_ << \" HAL streams\";\n>  \tfor (unsigned int i = 0; i < descriptor->numBuffers_; ++i) {\n> -\t\tcamera3_stream *camera3Stream = camera3Buffers[i].stream;\n> -\t\tCameraStream *cameraStream =\n> -\t\t\tstatic_cast<CameraStream *>(camera3Buffers[i].stream->priv);\n> -\n> -\t\t/*\n> -\t\t * Keep track of which stream the request belongs to and store\n> -\t\t * the native buffer handles.\n> -\t\t */\n> -\t\tdescriptor->buffers_[i].stream = camera3Buffers[i].stream;\n> -\t\tdescriptor->buffers_[i].buffer = camera3Buffers[i].buffer;\n> +\t\tconst camera3_stream_buffer_t *camera3Buffer = &descriptor->buffers_[i];\n> +\t\tcamera3_stream *camera3Stream = camera3Buffer->stream;\n> +\t\tCameraStream *cameraStream = static_cast<CameraStream *>(camera3Stream->priv);\n>  \n>  \t\tstd::stringstream ss;\n>  \t\tss << i << \" - (\" << camera3Stream->width << \"x\"\n> @@ -1729,7 +1718,7 @@ int CameraDevice::processCaptureRequest(camera3_capture_request_t *camera3Reques\n>  \t\t\t * associate it with the Camera3RequestDescriptor for\n>  \t\t\t * lifetime management only.\n>  \t\t\t */\n> -\t\t\tbuffer = createFrameBuffer(*camera3Buffers[i].buffer);\n> +\t\t\tbuffer = createFrameBuffer(*camera3Buffer->buffer);\n>  \t\t\tdescriptor->frameBuffers_.emplace_back(buffer);\n>  \t\t\tLOG(HAL, Debug) << ss.str() << \" (direct)\";\n>  \t\t\tbreak;\n> @@ -1754,7 +1743,7 @@ int CameraDevice::processCaptureRequest(camera3_capture_request_t *camera3Reques\n>  \t\t}\n>  \n>  \t\tdescriptor->request_->addBuffer(cameraStream->stream(), buffer,\n> -\t\t\t\t\t\tcamera3Buffers[i].acquire_fence);\n> +\t\t\t\t\t\tcamera3Buffer->acquire_fence);\n>  \t}\n>  \n>  \t/*","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 E1349BD808\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 21 Jan 2021 21:36:10 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 66BCC68221;\n\tThu, 21 Jan 2021 22:36:10 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 40D9968212\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 21 Jan 2021 22:36:09 +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 AAD8250E;\n\tThu, 21 Jan 2021 22:36:08 +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=\"hz9uHYS5\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1611264968;\n\tbh=20kRu+VKIVZKWM7n3bILFbxYPY65Agn/Y6HKDf0ZTno=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=hz9uHYS5ytJWErdhlonUNLjINqPDeHdbozvBEZug/3J1dzlxtVF1V1JbS6+rJYAcL\n\tuf2ZFuHAroBoZ8g48NrIjLAXMvxJQlYacbE3glxtF1i/3bnVsgWNHTr6lNEv/2d+tY\n\tS5lRm8B4VSMzgf2JX61yOXPBA5RGPbiW0cvesKS4=","Date":"Thu, 21 Jan 2021 23:35:50 +0200","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Jacopo Mondi <jacopo@jmondi.org>","Message-ID":"<YAnzthPiMX/uKAtA@pendragon.ideasonboard.com>","References":"<20210121165305.367801-1-jacopo@jmondi.org>\n\t<20210121165305.367801-4-jacopo@jmondi.org>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<20210121165305.367801-4-jacopo@jmondi.org>","Subject":"Re: [libcamera-devel] [PATCH 3/7] android: camera_device: Copy\n\tcamera3 buffers in descriptor","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>"}}]