Show a patch.

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

{
    "id": 21262,
    "url": "https://patchwork.libcamera.org/api/patches/21262/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/21262/",
    "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": "<20240913120416.96828-1-robert.mader@collabora.com>",
    "date": "2024-09-13T12:04:16",
    "name": "[v2] libcamera: debayer_cpu: Sync DMABUFs",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "2ed0aa1f310d6cfdca0e22eca331f5e8b57b200d",
    "submitter": {
        "id": 140,
        "url": "https://patchwork.libcamera.org/api/people/140/?format=api",
        "name": "Robert Mader",
        "email": "robert.mader@collabora.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/21262/mbox/",
    "series": [
        {
            "id": 4589,
            "url": "https://patchwork.libcamera.org/api/series/4589/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=4589",
            "date": "2024-09-13T12:04:16",
            "name": "[v2] libcamera: debayer_cpu: Sync DMABUFs",
            "version": 2,
            "mbox": "https://patchwork.libcamera.org/series/4589/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/21262/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/21262/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 88C5DC324C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 13 Sep 2024 12:05:08 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 7C1DD634F8;\n\tFri, 13 Sep 2024 14:05:07 +0200 (CEST)",
            "from sender4-pp-f112.zoho.com (sender4-pp-f112.zoho.com\n\t[136.143.188.112])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 7B150634E3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 13 Sep 2024 14:05:05 +0200 (CEST)",
            "by mx.zohomail.com with SMTPS id 1726229100701785.3377447405329;\n\tFri, 13 Sep 2024 05:05:00 -0700 (PDT)"
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=collabora.com\n\theader.i=robert.mader@collabora.com header.b=\"ZNOnMly9\"; \n\tdkim-atps=neutral",
        "ARC-Seal": "i=1; a=rsa-sha256; t=1726229102; cv=none; \n\td=zohomail.com; s=zohoarc; \n\tb=i4L8Kuwcm+3q/4lacBep/kCEXK8IfvsiDjTchi3aBu2M2QSbKXLwTEegV7riM6WR1P1AJXV0djxs9EXt+Zwfi/itUI6QE6M0BfQiqvf3sAkC7dEqAtSxaUXzo+IeI55MLKyHzFlzL+zu8bGij6VCeSqiG4XFcCdZ4/w7khCxZwI=",
        "ARC-Message-Signature": "i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; \n\ts=zohoarc; t=1726229102;\n\th=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:MIME-Version:Message-ID:Subject:Subject:To:To:Message-Id:Reply-To;\n\tbh=SsobdUwHdkodTXuP5OzAXLzPkRNWNY94VeMZHmts47w=; \n\tb=IUeW9pYZCXq4dCqukjf+4hEmcjAAWadArllD9UH2xIXKJN8U3dEKmhgE0VNhxRAE3DuKCJiKG17ELWOMF/BiEnBMZMSd2EZO6SlT8lcwec2Yfjlfmv3RkqcOU295CTBk8cGBue29+66tZZ5G0IS7ls0o9dD8Ks+z29EuPo4gGDg=",
        "ARC-Authentication-Results": "i=1; mx.zohomail.com;\n\tdkim=pass  header.i=collabora.com;\n\tspf=pass  smtp.mailfrom=robert.mader@collabora.com;\n\tdmarc=pass header.from=<robert.mader@collabora.com>",
        "DKIM-Signature": "v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1726229102;\n\ts=zohomail; d=collabora.com; i=robert.mader@collabora.com;\n\th=From:From:To:To:Cc:Cc:Subject:Subject:Date:Date:Message-ID:MIME-Version:Content-Transfer-Encoding:Message-Id:Reply-To;\n\tbh=SsobdUwHdkodTXuP5OzAXLzPkRNWNY94VeMZHmts47w=;\n\tb=ZNOnMly9SxUDTzJ7rloEUZK7/VXBbD8G8/1ju4zwNBsBTh5/VVoxEkMs10gzFPbT\n\t3wU3YAuVVJoNVx71uYBsnz9eEBA5abi1WvHWL8o23D2FevDwxMgVc0DF78aPUNni4T6\n\t9y5j+QLw/quhXMF2XlvvfppCGocTdyYGOiOxzKdM=",
        "From": "Robert Mader <robert.mader@collabora.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Cc": "Robert Mader <robert.mader@collabora.com>",
        "Subject": "[PATCH v2] libcamera: debayer_cpu: Sync DMABUFs",
        "Date": "Fri, 13 Sep 2024 14:04:16 +0200",
        "Message-ID": "<20240913120416.96828-1-robert.mader@collabora.com>",
        "X-Mailer": "git-send-email 2.46.0",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "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": "Using `DMA_BUF_IOCTL_SYNC` is required for DMABUFs in order to ensure\ncorrect output. Not doing so currently results in occasional tearing\nand/or backlashes in GL/VK clients that use the buffers directly for\nrendering.\n\nAn alternative approach to have the sync code in `MappedFrameBuffer` was\nconsidered but rejected for now, in order to allow clients more\nflexibility.\n\nSigned-off-by: Robert Mader <robert.mader@collabora.com>\n\n---\n\nChanges in v2:\n - sync input buffer as well\n - update commit title accordingly\n - small changes to the commit message\n - linting fixes, should pass now\n---\n src/libcamera/software_isp/debayer_cpu.cpp | 35 ++++++++++++++++++++++\n 1 file changed, 35 insertions(+)",
    "diff": "diff --git a/src/libcamera/software_isp/debayer_cpu.cpp b/src/libcamera/software_isp/debayer_cpu.cpp\nindex 077f7f4b..a3b4851c 100644\n--- a/src/libcamera/software_isp/debayer_cpu.cpp\n+++ b/src/libcamera/software_isp/debayer_cpu.cpp\n@@ -12,8 +12,11 @@\n #include \"debayer_cpu.h\"\n \n #include <stdlib.h>\n+#include <sys/ioctl.h>\n #include <time.h>\n \n+#include <linux/dma-buf.h>\n+\n #include <libcamera/formats.h>\n \n #include \"libcamera/internal/bayer_format.h\"\n@@ -733,6 +736,22 @@ void DebayerCpu::process(FrameBuffer *input, FrameBuffer *output, DebayerParams\n \t\tclock_gettime(CLOCK_MONOTONIC_RAW, &frameStartTime);\n \t}\n \n+\tfor (const FrameBuffer::Plane &plane : input->planes()) {\n+\t\tconst int fd = plane.fd.get();\n+\t\tstruct dma_buf_sync sync = { DMA_BUF_SYNC_START | DMA_BUF_SYNC_READ };\n+\n+\t\tif (ioctl(fd, DMA_BUF_IOCTL_SYNC, &sync) < 0)\n+\t\t\tLOG(Debayer, Error) << \"Syncing buffer FD \" << fd << \"failed: \" << errno;\n+\t}\n+\n+\tfor (const FrameBuffer::Plane &plane : output->planes()) {\n+\t\tconst int fd = plane.fd.get();\n+\t\tstruct dma_buf_sync sync = { DMA_BUF_SYNC_START | DMA_BUF_SYNC_WRITE };\n+\n+\t\tif (ioctl(fd, DMA_BUF_IOCTL_SYNC, &sync) < 0)\n+\t\t\tLOG(Debayer, Error) << \"Syncing buffer FD \" << fd << \"failed: \" << errno;\n+\t}\n+\n \tgreen_ = params.green;\n \tred_ = swapRedBlueGains_ ? params.blue : params.red;\n \tblue_ = swapRedBlueGains_ ? params.red : params.blue;\n@@ -760,6 +779,22 @@ void DebayerCpu::process(FrameBuffer *input, FrameBuffer *output, DebayerParams\n \n \tmetadata.planes()[0].bytesused = out.planes()[0].size();\n \n+\tfor (const FrameBuffer::Plane &plane : output->planes()) {\n+\t\tconst int fd = plane.fd.get();\n+\t\tstruct dma_buf_sync sync = { DMA_BUF_SYNC_END | DMA_BUF_SYNC_WRITE };\n+\n+\t\tif (ioctl(fd, DMA_BUF_IOCTL_SYNC, &sync) < 0)\n+\t\t\tLOG(Debayer, Error) << \"Syncing buffer FD \" << fd << \"failed: \" << errno;\n+\t}\n+\n+\tfor (const FrameBuffer::Plane &plane : input->planes()) {\n+\t\tconst int fd = plane.fd.get();\n+\t\tstruct dma_buf_sync sync = { DMA_BUF_SYNC_END | DMA_BUF_SYNC_READ };\n+\n+\t\tif (ioctl(fd, DMA_BUF_IOCTL_SYNC, &sync) < 0)\n+\t\t\tLOG(Debayer, Error) << \"Syncing buffer FD \" << fd << \"failed: \" << errno;\n+\t}\n+\n \t/* Measure before emitting signals */\n \tif (measuredFrames_ < DebayerCpu::kLastFrameToMeasure &&\n \t    ++measuredFrames_ > DebayerCpu::kFramesToSkip) {\n",
    "prefixes": [
        "v2"
    ]
}