{"id":10931,"url":"https://patchwork.libcamera.org/api/1.1/patches/10931/?format=json","web_url":"https://patchwork.libcamera.org/patch/10931/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20210121165305.367801-4-jacopo@jmondi.org>","date":"2021-01-21T16:53:01","name":"[libcamera-devel,3/7] android: camera_device: Copy camera3 buffers in descriptor","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"eee3154c9628628e2c3621f25182ffa0a8c0cc0d","submitter":{"id":3,"url":"https://patchwork.libcamera.org/api/1.1/people/3/?format=json","name":"Jacopo Mondi","email":"jacopo@jmondi.org"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/10931/mbox/","series":[{"id":1593,"url":"https://patchwork.libcamera.org/api/1.1/series/1593/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=1593","date":"2021-01-21T16:52:58","name":"android: camera device and metadata improvements","version":1,"mbox":"https://patchwork.libcamera.org/series/1593/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/10931/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/10931/checks/","tags":{},"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 1CC0DBD808\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 21 Jan 2021 16:53:01 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id E5E1C68216;\n\tThu, 21 Jan 2021 17:53:00 +0100 (CET)","from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net\n\t[217.70.183.197])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 81AA468206\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 21 Jan 2021 17:52:57 +0100 (CET)","from uno.lan (93-34-118-233.ip49.fastwebnet.it [93.34.118.233])\n\t(Authenticated sender: jacopo@jmondi.org)\n\tby relay5-d.mail.gandi.net (Postfix) with ESMTPSA id 225241C0012;\n\tThu, 21 Jan 2021 16:52:56 +0000 (UTC)"],"X-Originating-IP":"93.34.118.233","From":"Jacopo Mondi <jacopo@jmondi.org>","To":"libcamera-devel@lists.libcamera.org,\n\tPaul Elder <paul.elder@ideasonboard.com>","Date":"Thu, 21 Jan 2021 17:53:01 +0100","Message-Id":"<20210121165305.367801-4-jacopo@jmondi.org>","X-Mailer":"git-send-email 2.29.2","In-Reply-To":"<20210121165305.367801-1-jacopo@jmondi.org>","References":"<20210121165305.367801-1-jacopo@jmondi.org>","MIME-Version":"1.0","Subject":"[libcamera-devel] [PATCH 3/7] android: camera_device: Copy camera3\n\tbuffers 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>","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>"},"content":"The camera3_stream_buffer_t instances part of a capture request contain\ninformation on the stream for which capture has been requested (size,\nformat and fences) and an handle to the stream's memory buffers.\n\nThose information are copied in the descriptor one at the time while\nprocessing the camera3 streams to be re-used at request completion time.\n\nSimplyify the code by copying the stream information in the descriptor\nat construction time.\n\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n src/android/camera_device.cpp | 27 ++++++++-------------------\n 1 file changed, 8 insertions(+), 19 deletions(-)","diff":"diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp\nindex 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/*\n","prefixes":["libcamera-devel","3/7"]}