Patch Detail
Show a patch.
GET /api/patches/13928/?format=api
{ "id": 13928, "url": "https://patchwork.libcamera.org/api/patches/13928/?format=api", "web_url": "https://patchwork.libcamera.org/patch/13928/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/projects/1/?format=api", "name": "libcamera", "link_name": "libcamera", "list_id": "libcamera_core", "list_email": "libcamera-devel@lists.libcamera.org", "web_url": "", "scm_url": "", "webscm_url": "" }, "msgid": "<20210924170234.152783-3-jacopo@jmondi.org>", "date": "2021-09-24T17:02:34", "name": "[libcamera-devel,2/2] android: Post-pone fences reset in result", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "24ecd63aae28d915614f9cdebbaaded874395fc6", "submitter": { "id": 3, "url": "https://patchwork.libcamera.org/api/people/3/?format=api", "name": "Jacopo Mondi", "email": "jacopo@jmondi.org" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/13928/mbox/", "series": [ { "id": 2566, "url": "https://patchwork.libcamera.org/api/series/2566/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=2566", "date": "2021-09-24T17:02:32", "name": "android: Wait on acquisition fences in CameraStream", "version": 1, "mbox": "https://patchwork.libcamera.org/series/2566/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/13928/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/13928/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 3CA5BBF01C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 24 Sep 2021 17:01:55 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 1685C69191;\n\tFri, 24 Sep 2021 19:01:55 +0200 (CEST)", "from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net\n\t[217.70.183.193])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id CC5996918A\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 24 Sep 2021 19:01:51 +0200 (CEST)", "(Authenticated sender: jacopo@jmondi.org)\n\tby relay1-d.mail.gandi.net (Postfix) with ESMTPSA id 5CA0024000B;\n\tFri, 24 Sep 2021 17:01:51 +0000 (UTC)" ], "From": "Jacopo Mondi <jacopo@jmondi.org>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Fri, 24 Sep 2021 19:02:34 +0200", "Message-Id": "<20210924170234.152783-3-jacopo@jmondi.org>", "X-Mailer": "git-send-email 2.32.0", "In-Reply-To": "<20210924170234.152783-1-jacopo@jmondi.org>", "References": "<20210924170234.152783-1-jacopo@jmondi.org>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH 2/2] android: Post-pone fences reset in\n\tresult", "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>", "Errors-To": "libcamera-devel-bounces@lists.libcamera.org", "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>" }, "content": "When a request has been completed and a new capture_result is created\nto be sent to the framework through the process_capture_result()\ncallback we assumed all fences had been waited on, hence we set both\nthe release and acquisition fences to -1.\n\nNow that the acquisition fence of streams generated through\npost-processing are handled by CameraStream::process(), resetting fences\ntoo early would invalidate them before they get handled.\n\nPost-pone setting fences to -1 for successful capture results, and\ncorrect the release_fence handling for failed captures, as the framework\nrequires the release fences to be set to the acquire fence value if the\nacquire fence has not been waited on.\n\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n src/android/camera_device.cpp | 44 ++++++++++++++++++++++++-----------\n 1 file changed, 31 insertions(+), 13 deletions(-)", "diff": "diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp\nindex db35947afc2f..8ca2353e5f33 100644\n--- a/src/android/camera_device.cpp\n+++ b/src/android/camera_device.cpp\n@@ -1098,22 +1098,10 @@ void CameraDevice::requestComplete(Request *request)\n \t}\n \tCamera3RequestDescriptor &descriptor = node.mapped();\n \n-\t/*\n-\t * Prepare the capture result for the Android camera stack.\n-\t *\n-\t * The buffer status is set to OK and later changed to ERROR if\n-\t * post-processing/compression fails.\n-\t */\n \tcamera3_capture_result_t captureResult = {};\n \tcaptureResult.frame_number = descriptor.frameNumber_;\n \tcaptureResult.num_output_buffers = descriptor.buffers_.size();\n-\tfor (camera3_stream_buffer_t &buffer : descriptor.buffers_) {\n-\t\tbuffer.acquire_fence = -1;\n-\t\tbuffer.release_fence = -1;\n-\t\tbuffer.status = CAMERA3_BUFFER_STATUS_OK;\n-\t}\n \tcaptureResult.output_buffers = descriptor.buffers_.data();\n-\tcaptureResult.partial_result = 1;\n \n \t/*\n \t * If the Request has failed, abort the request by notifying the error\n@@ -1128,8 +1116,27 @@ void CameraDevice::requestComplete(Request *request)\n \t\t\t CAMERA3_MSG_ERROR_REQUEST);\n \n \t\tcaptureResult.partial_result = 0;\n-\t\tfor (camera3_stream_buffer_t &buffer : descriptor.buffers_)\n+\t\tfor (camera3_stream_buffer_t &buffer : descriptor.buffers_) {\n+\t\t\tCameraStream *cameraStream =\n+\t\t\t\tstatic_cast<CameraStream *>(buffer.stream->priv);\n+\n+\t\t\t/*\n+\t\t\t * Streams of type Direct have been queued to the\n+\t\t\t * libcamera::Camera and their acquisition fences has\n+\t\t\t * already been waited on by the CameraWorker.\n+\t\t\t *\n+\t\t\t * For other stream types signal to the framework the\n+\t\t\t * acquisition fence has not been waited on, by setting\n+\t\t\t * the release fence to its value.\n+\t\t\t */\n+\t\t\tif (cameraStream->type() == CameraStream::Type::Direct)\n+\t\t\t\tbuffer.release_fence = -1;\n+\t\t\telse\n+\t\t\t\tbuffer.release_fence = buffer.acquire_fence;\n+\n+\t\t\tbuffer.acquire_fence = -1;\n \t\t\tbuffer.status = CAMERA3_BUFFER_STATUS_ERROR;\n+\t\t}\n \t\tcallbacks_->process_capture_result(callbacks_, &captureResult);\n \n \t\treturn;\n@@ -1196,6 +1203,17 @@ void CameraDevice::requestComplete(Request *request)\n \t\t}\n \t}\n \n+\t/*\n+\t * Finalize the capture result by setting fences and buffer status\n+\t * before executing the callback.\n+\t */\n+\tfor (camera3_stream_buffer_t &buffer : descriptor.buffers_) {\n+\t\tbuffer.acquire_fence = -1;\n+\t\tbuffer.release_fence = -1;\n+\t\tbuffer.status = CAMERA3_BUFFER_STATUS_OK;\n+\t}\n+\tcaptureResult.partial_result = 1;\n+\n \tcaptureResult.result = resultMetadata->get();\n \tcallbacks_->process_capture_result(callbacks_, &captureResult);\n }\n", "prefixes": [ "libcamera-devel", "2/2" ] }