Show a patch.

GET /api/1.1/patches/13957/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 13957,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/13957/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/13957/",
    "project": {
        "id": 1,
        "url": "https://patchwork.libcamera.org/api/1.1/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": "<20210927213700.25365-2-jacopo@jmondi.org>",
    "date": "2021-09-27T21:36:59",
    "name": "[libcamera-devel,v2,1/2] android: Post-pone fences reset in capture result",
    "commit_ref": null,
    "pull_url": null,
    "state": "not-applicable",
    "archived": false,
    "hash": "24ecd63aae28d915614f9cdebbaaded874395fc6",
    "submitter": {
        "id": 3,
        "url": "https://patchwork.libcamera.org/api/1.1/people/3/?format=api",
        "name": "Jacopo Mondi",
        "email": "jacopo@jmondi.org"
    },
    "delegate": {
        "id": 15,
        "url": "https://patchwork.libcamera.org/api/1.1/users/15/?format=api",
        "username": "jmondi",
        "first_name": "Jacopo",
        "last_name": "Mondi",
        "email": "jacopo@jmondi.org"
    },
    "mbox": "https://patchwork.libcamera.org/patch/13957/mbox/",
    "series": [
        {
            "id": 2577,
            "url": "https://patchwork.libcamera.org/api/1.1/series/2577/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=2577",
            "date": "2021-09-27T21:36:58",
            "name": "android: Wait on acquisition fences in CameraStream",
            "version": 2,
            "mbox": "https://patchwork.libcamera.org/series/2577/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/13957/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/13957/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 80BBEBDC71\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 27 Sep 2021 21:36:19 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 4E04B6918D;\n\tMon, 27 Sep 2021 23:36:19 +0200 (CEST)",
            "from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net\n\t[217.70.183.198])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 52FDA69189\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 27 Sep 2021 23:36:17 +0200 (CEST)",
            "(Authenticated sender: jacopo@jmondi.org)\n\tby relay6-d.mail.gandi.net (Postfix) with ESMTPSA id A933FC0002;\n\tMon, 27 Sep 2021 21:36:16 +0000 (UTC)"
        ],
        "From": "Jacopo Mondi <jacopo@jmondi.org>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Mon, 27 Sep 2021 23:36:59 +0200",
        "Message-Id": "<20210927213700.25365-2-jacopo@jmondi.org>",
        "X-Mailer": "git-send-email 2.32.0",
        "In-Reply-To": "<20210927213700.25365-1-jacopo@jmondi.org>",
        "References": "<20210927213700.25365-1-jacopo@jmondi.org>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH v2 1/2] android: Post-pone fences reset in\n\tcapture result",
        "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\nwe assumed all fences had been waited on, hence we set both\nthe release and acquisition fences to -1.\n\nAs no buffer is queued to libcamera::Camera for streams of type Mapped,\ntheir acquisition fences went ignored. Prepare to fix that by\nby moving fences resetting after post-processing, that will be\ninstrumented to handle fences in the next patch.\n\nAlso correct the release_fence handling for failed captures, as the\nframework requires the release fences to be set to the acquire fence\nvalue if the acquire fence has not been waited on.\n\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\nReviewed-by: Hirokazu Honda <hiroh@chromium.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 21844e5114a9..3c9609d74402 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",
        "v2",
        "1/2"
    ]
}