Patch Detail
Show a patch.
GET /api/patches/25085/?format=api
{ "id": 25085, "url": "https://patchwork.libcamera.org/api/patches/25085/?format=api", "web_url": "https://patchwork.libcamera.org/patch/25085/", "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": "<20251120094919.12138-1-robert.mader@collabora.com>", "date": "2025-11-20T09:49:19", "name": "qcam: Sync buffers before import", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "3e9e433bd19fbadc7d573c64c251413372de5ca4", "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/25085/mbox/", "series": [ { "id": 5596, "url": "https://patchwork.libcamera.org/api/series/5596/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=5596", "date": "2025-11-20T09:49:19", "name": "qcam: Sync buffers before import", "version": 1, "mbox": "https://patchwork.libcamera.org/series/5596/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/25085/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/25085/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 71C18C0F1B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 20 Nov 2025 09:50:00 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id A46C7606E6;\n\tThu, 20 Nov 2025 10:49:59 +0100 (CET)", "from sender3-pp-f112.zoho.com (sender3-pp-f112.zoho.com\n\t[136.143.184.112])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id BA170606E6\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 20 Nov 2025 10:49:57 +0100 (CET)", "by mx.zohomail.com with SMTPS id 1763632190746400.6753210444941;\n\tThu, 20 Nov 2025 01:49:50 -0800 (PST)" ], "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=\"PN+lxRFN\"; \n\tdkim-atps=neutral", "ARC-Seal": "i=1; a=rsa-sha256; t=1763632192; cv=none; \n\td=zohomail.com; s=zohoarc; \n\tb=ejXNiCBIXkRi/VD1GqSFWGCnrKT1BtukHm81d0SR+5kCIvxgTyyt3578e+OsI6K/f+ozgcPYIspAue8U8I52Ps6OOCE4vOLoEzNoWt1uS4N82l/vjXNpKLud2ddP00Qq9QE2lHMdf5TPqlEb//Xbuo5yp3svUn0fE1W0OsQFY9I=", "ARC-Message-Signature": "i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; \n\ts=zohoarc; t=1763632192;\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=+iIAm30aDRC67zfxTSzYYlgjiEwVx4EFyui3p76t5wE=; \n\tb=ZxOLMYp8SlVUsju+8IPBg3IfYKopwhvxi35c0LMRUd0HACCOf/XedTmSMkow4C1+/Rx7IdnUaQoxQGXIg5pAbDJ5GUzUSkbOPsrWV1D92Gi+2b8rwOPI5T90/ojL/Yu0+QsncU2EzMZZbdY7MgBcUH0fXkIc1RfOKen8+g81TGM=", "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=1763632192;\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=+iIAm30aDRC67zfxTSzYYlgjiEwVx4EFyui3p76t5wE=;\n\tb=PN+lxRFN7zipSFR+3Ltbb/mi/HkWJr5pX8OtMtYg//f9rKM0zrkgDMcQxQBw5HzV\n\tdDi6bD/AcymzS4kVp+PzeJ+UkJmqqf1vwth3sv9MQqszWMqpzAFuME+pA8wcELfabzo\n\tzptdbLofAv2KSfoVcz2YgFdJiqNGOxkqJNVROx2M=", "From": "Robert Mader <robert.mader@collabora.com>", "To": "libcamera-devel@lists.libcamera.org", "Cc": "Robert Mader <robert.mader@collabora.com>", "Subject": "[PATCH] qcam: Sync buffers before import", "Date": "Thu, 20 Nov 2025 10:49:19 +0100", "Message-ID": "<20251120094919.12138-1-robert.mader@collabora.com>", "X-Mailer": "git-send-email 2.51.1", "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": "Use the DmaSyncer handler to ensure the data from the buffer is\ncoherent. This is required by the spec - from\nhttps://docs.kernel.org/driver-api/dma-buf.html#c.dma_buf_sync:\n\n> When a DMA buffer is accessed from the CPU via mmap, it is not always\n> possible to guarantee coherency between the CPU-visible map and\n> underlying memory. To manage coherency, DMA_BUF_IOCTL_SYNC must be used\n> to bracket any CPU access to give the kernel the chance to shuffle memory\n> around if needed.\n\nThis was reported to fix glitches with the upcoming GPU-ISP, in which\ncase the accessed data in written by the GPU.\n\nNote that in the GPU-ISP case we are effectively seeing a round-trip of\nthe buffer contents - from GPU synced to CPU, copied to GPU again. We\ncould avoid that in the future by implementing direct dmabuf import in\nqcam.\n\nSigned-off-by: Robert Mader <robert.mader@collabora.com>\n---\n src/apps/qcam/viewfinder_gl.cpp | 10 ++++++++--\n src/apps/qcam/viewfinder_qt.cpp | 11 +++++++++++\n 2 files changed, 19 insertions(+), 2 deletions(-)", "diff": "diff --git a/src/apps/qcam/viewfinder_gl.cpp b/src/apps/qcam/viewfinder_gl.cpp\nindex f31956ff0..0121c97ad 100644\n--- a/src/apps/qcam/viewfinder_gl.cpp\n+++ b/src/apps/qcam/viewfinder_gl.cpp\n@@ -9,14 +9,16 @@\n \n #include <array>\n \n+#include <libcamera/formats.h>\n+\n+#include \"libcamera/internal/dma_buf_allocator.h\"\n+\n #include <QByteArray>\n #include <QFile>\n #include <QImage>\n #include <QMatrix4x4>\n #include <QStringList>\n \n-#include <libcamera/formats.h>\n-\n #include \"../common/image.h\"\n \n static const QList<libcamera::PixelFormat> supportedFormats{\n@@ -542,6 +544,10 @@ void ViewFinderGL::doRender()\n \t/* Stride of the first plane, in pixels. */\n \tunsigned int stridePixels;\n \n+\tstd::vector<libcamera::DmaSyncer> dmaSyncers;\n+\tfor (const libcamera::FrameBuffer::Plane &plane : buffer_->planes())\n+\t\tdmaSyncers.emplace_back(plane.fd, libcamera::DmaSyncer::SyncType::Read);\n+\n \tswitch (format_) {\n \tcase libcamera::formats::NV12:\n \tcase libcamera::formats::NV21:\ndiff --git a/src/apps/qcam/viewfinder_qt.cpp b/src/apps/qcam/viewfinder_qt.cpp\nindex 1a238922b..4d00f154d 100644\n--- a/src/apps/qcam/viewfinder_qt.cpp\n+++ b/src/apps/qcam/viewfinder_qt.cpp\n@@ -11,6 +11,7 @@\n #include <stdint.h>\n #include <utility>\n \n+#include \"libcamera/internal/dma_buf_allocator.h\"\n #include <libcamera/formats.h>\n \n #include <QImage>\n@@ -114,6 +115,10 @@ void ViewFinderQt::render(libcamera::FrameBuffer *buffer, Image *image)\n \t\t\t * Otherwise, convert the format and release the frame\n \t\t\t * buffer immediately.\n \t\t\t */\n+\t\t\tstd::vector<libcamera::DmaSyncer> dmaSyncers;\n+\t\t\tfor (const libcamera::FrameBuffer::Plane &plane : buffer->planes())\n+\t\t\t\tdmaSyncers.emplace_back(plane.fd, libcamera::DmaSyncer::SyncType::Read);\n+\n \t\t\tconverter_.convert(image, size, &image_);\n \t\t}\n \t}\n@@ -161,6 +166,12 @@ void ViewFinderQt::paintEvent(QPaintEvent *)\n \n \t/* If we have an image, draw it, with black letterbox rectangles. */\n \tif (!image_.isNull()) {\n+\t\tif (buffer_) {\n+\t\t\tstd::vector<libcamera::DmaSyncer> dmaSyncers;\n+\t\t\tfor (const libcamera::FrameBuffer::Plane &plane : buffer_->planes())\n+\t\t\t\tdmaSyncers.emplace_back(plane.fd, libcamera::DmaSyncer::SyncType::Read);\n+\t\t}\n+\n \t\tif (place_.width() < width()) {\n \t\t\tQRect rect{ 0, 0, (width() - place_.width()) / 2, height() };\n \t\t\tpainter.drawRect(rect);\n", "prefixes": [] }