Show a patch.

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

{
    "id": 25516,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/25516/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/25516/",
    "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": "<20251212002937.3118-2-bryan.odonoghue@linaro.org>",
    "date": "2025-12-12T00:29:12",
    "name": "[v8,01/26] libcamera: software_isp: gbm: Add a GBM helper class for GPU surface access",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "d1455df461b8c16ab1beb4b1acef7dddeaf6c78f",
    "submitter": {
        "id": 175,
        "url": "https://patchwork.libcamera.org/api/1.1/people/175/?format=api",
        "name": "Bryan O'Donoghue",
        "email": "bryan.odonoghue@linaro.org"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/25516/mbox/",
    "series": [
        {
            "id": 5657,
            "url": "https://patchwork.libcamera.org/api/1.1/series/5657/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=5657",
            "date": "2025-12-12T00:29:11",
            "name": "Add GLES 2.0 GPUISP to libcamera",
            "version": 8,
            "mbox": "https://patchwork.libcamera.org/series/5657/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/25516/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/25516/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 14497BD1F1\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 12 Dec 2025 00:33:28 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id BB3B161623;\n\tFri, 12 Dec 2025 01:33:27 +0100 (CET)",
            "from mail-pf1-x432.google.com (mail-pf1-x432.google.com\n\t[IPv6:2607:f8b0:4864:20::432])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 3ED7E61613\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 12 Dec 2025 01:33:25 +0100 (CET)",
            "by mail-pf1-x432.google.com with SMTP id\n\td2e1a72fcca58-7b7828bf7bcso718235b3a.2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 11 Dec 2025 16:33:25 -0800 (PST)",
            "from inspiron14p-linux (p99250-ipoefx.ipoe.ocn.ne.jp.\n\t[153.246.134.249]) by smtp.gmail.com with ESMTPSA id\n\t41be03b00d2f7-c0c26eb0f6bsm3317282a12.14.2025.12.11.16.33.20\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tThu, 11 Dec 2025 16:33:22 -0800 (PST)"
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (2048-bit key;\n\tunprotected) header.d=linaro.org header.i=@linaro.org\n\theader.b=\"oHdE+QPo\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=linaro.org; s=google; t=1765499604; x=1766104404;\n\tdarn=lists.libcamera.org; \n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:from:to:cc:subject:date\n\t:message-id:reply-to;\n\tbh=Q4G+/DobTRCRFFgGje+jTAlgyU0g2iZaIgwaHTHs6zc=;\n\tb=oHdE+QPohMRukKQ9QVleMVLI/fvNGYttp3dOAUpiS0iljeWf5u/QfxRP2rRPWhxHnv\n\tOnpjdi7yC/CKSTg3E2j3uRJcfxG3tG2yUqmCo6sghBomtIcg8lfkmbqyjk2nIQAanFR5\n\tCkMCZ6HUOzb4NxoLNfqzA9IMcTXAM4kLAzG8rKAjh4On+ju+s9fDecohFz9Pk8TdvIeT\n\tC4VqxbLlEGAVd1MRB69gJkJwHpYDSx21HL+Z27wW2CCzTNFcWF5cVLC0gJv9HMru1l/c\n\t0Af25IHFhbxWz3jPFZhray+KNg+kHC5e2ArLD6Y0i6Vp0I3Cuv+TV7WQP5iaI7163Inh\n\tsHfg==",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20230601; t=1765499604; x=1766104404;\n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from\n\t:to:cc:subject:date:message-id:reply-to;\n\tbh=Q4G+/DobTRCRFFgGje+jTAlgyU0g2iZaIgwaHTHs6zc=;\n\tb=nu7Vdy28S1EEmPrkEnq+9MA5ckSa4tU0lbdzv/jVH0onNSFNksa/sqGH3gnHtXEIEp\n\tBGpr9XRF2prx/nvD3Hev/J0pWzknIMDcZJFVkxH6QGColZlGFU5hEYUicM12OMZ+wiCR\n\trOYFPA6XorAM4cYlw9xQKQmhXiiom2WU6F6axN/Kit5j1hDGKbO1Y6U2Uxu9vamFluCv\n\tPZBukaAXoJY2zL4wtJsnRtcBikNQZwY+ihMr2aZRlydit1Hi01zyyMRoCdp8mREljVbl\n\t7tQh9ioMxdq0H/9pdi7Kz5UQCE16IyTgc5uBQh05FdehAp0LoKv8/C1D0Tg3WZAoGqDO\n\tXwZA==",
        "X-Gm-Message-State": "AOJu0Yx0yoCO4tJSlON+bSJyX4MV/81oQXlYVaw5gzWatrA3iz/4JSat\n\thdt1KmKnISLAWBDniSonMUChyJsJUiX17IzYZXohWb2sehHuFLqOs054RjvUj2tbz7uLOqjv1T5\n\t6keg3",
        "X-Gm-Gg": "AY/fxX78tScipSSFux7YECT7p69wWWcwJ2CqBDyrJ/myVhrqZyCpTe4WSgH8fYxDJaP\n\tiZy6XAH/wdiKIdTjd/usT+4s7f+th6wm2ffzgZmf9SLWAQyAYvRiPCBFpYq8KjHJg9O9KYLBMI5\n\tZsSJ6pnXJs0YJ4rp4zn9bRTprVCDtHH3deD58+JBRi1oT8VtnhOGqpjRw4A21xup2To5ergdyV0\n\tKwrb6W/EU+75ZAhnamOFVqDCQHdEMkfn+C/SNuWXuWcIWdskpr9p2bg/puXw37lZ/81uO4mJ8JJ\n\tSy9UIXHiUbtPXdAhRmo2/YMSMV7grNXbKyXtPH+JtxYJ+li2CpHmTMuUfEj5mARChuqHYh248xg\n\t+XtQXuWzj3hdo8nkV1hRcpT9ntywvTGUmJLCENN8rOgfoBy04nr0dscTNS/1WWrd4Uq1lXceSB/\n\td5vjaOwbAazpPGohevAq0hjfeS0vVrgH9YXy8Ybu6V8+RJ8hnEh1GZNfn8Bsua74qChR5GQA==",
        "X-Google-Smtp-Source": "AGHT+IEJt/wRmmkrWUJlbUTkbwoxANdfIpff0nUJuUngpEjMtYZnf00gnXF0y+f+N9lnzorGtB80Mw==",
        "X-Received": "by 2002:a05:6a20:914e:b0:35d:d477:a7d8 with SMTP id\n\tadf61e73a8af0-369ae4901dcmr337317637.36.1765499603507; \n\tThu, 11 Dec 2025 16:33:23 -0800 (PST)",
        "From": "Bryan O'Donoghue <bryan.odonoghue@linaro.org>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Cc": "pavel@ucw.cz, Bryan O'Donoghue <bryan.odonoghue@linaro.org>,\n\tKieran Bingham <kieran.bingham@ideasonboard.com>",
        "Subject": "[PATCH v8 01/26] libcamera: software_isp: gbm: Add a GBM helper\n\tclass for GPU surface access",
        "Date": "Fri, 12 Dec 2025 00:29:12 +0000",
        "Message-ID": "<20251212002937.3118-2-bryan.odonoghue@linaro.org>",
        "X-Mailer": "git-send-email 2.52.0",
        "In-Reply-To": "<20251212002937.3118-1-bryan.odonoghue@linaro.org>",
        "References": "<20251212002937.3118-1-bryan.odonoghue@linaro.org>",
        "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": "A helper class to interact with GBM. This will allow us to specify the\ninternal storage format of the GPU when making a texture for the Debayer\nvertex/fragment shaders and thus ensure we receive an uncompressed and\nuntiled output buffer.\n\nAcked-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\nSigned-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>\n---\n include/libcamera/internal/gbm.h       |  39 ++++++++\n include/libcamera/internal/meson.build |   1 +\n src/libcamera/gbm.cpp                  | 130 +++++++++++++++++++++++++\n src/libcamera/meson.build              |  10 ++\n 4 files changed, 180 insertions(+)\n create mode 100644 include/libcamera/internal/gbm.h\n create mode 100644 src/libcamera/gbm.cpp",
    "diff": "diff --git a/include/libcamera/internal/gbm.h b/include/libcamera/internal/gbm.h\nnew file mode 100644\nindex 000000000..09811d1ef\n--- /dev/null\n+++ b/include/libcamera/internal/gbm.h\n@@ -0,0 +1,39 @@\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\n+/*\n+ * Copyright (C) 2024, Linaro Ltd.\n+ *\n+ * Authors:\n+ * Bryan O'Donoghue <bryan.odonoghue@linaro.org>\n+ *\n+ * Helper class for managing GBM interactions\n+ */\n+\n+#pragma once\n+\n+#include <gbm.h>\n+\n+#include <libcamera/base/log.h>\n+\n+#include <libcamera/formats.h>\n+\n+namespace libcamera {\n+\n+LOG_DECLARE_CATEGORY(GBM)\n+\n+class GBM\n+{\n+public:\n+\tGBM();\n+\t~GBM();\n+\n+\tint createDevice();\n+\tstruct gbm_device *getDevice();\n+\tPixelFormat getPixelFormat();\n+\n+private:\n+\tint fd_;\n+\tstruct gbm_device *gbmDevice_;\n+\tPixelFormat format_;\n+};\n+\n+} /* namespace libcamera */\ndiff --git a/include/libcamera/internal/meson.build b/include/libcamera/internal/meson.build\nindex e9540a2f7..b8324996b 100644\n--- a/include/libcamera/internal/meson.build\n+++ b/include/libcamera/internal/meson.build\n@@ -23,6 +23,7 @@ libcamera_internal_headers = files([\n     'dma_buf_allocator.h',\n     'formats.h',\n     'framebuffer.h',\n+    'gbm.h',\n     'global_configuration.h',\n     'ipa_data_serializer.h',\n     'ipa_manager.h',\ndiff --git a/src/libcamera/gbm.cpp b/src/libcamera/gbm.cpp\nnew file mode 100644\nindex 000000000..a2e4c7076\n--- /dev/null\n+++ b/src/libcamera/gbm.cpp\n@@ -0,0 +1,130 @@\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\n+/*\n+ * Copyright (C) 2024, Linaro Ltd.\n+ *\n+ * Authors:\n+ * Bryan O'Donoghue <bryan.odonoghue@linaro.org>\n+ *\n+ * Helper class for managing GBM interactions\n+ */\n+\n+#include \"libcamera/internal/gbm.h\"\n+\n+#include <errno.h>\n+#include <fcntl.h>\n+#include <sys/ioctl.h>\n+#include <sys/mman.h>\n+#include <unistd.h>\n+\n+#include <linux/dma-buf.h>\n+#include <linux/dma-heap.h>\n+\n+namespace libcamera {\n+\n+LOG_DEFINE_CATEGORY(GBM)\n+\n+/**\n+ * \\class GBM\n+ * \\brief Helper class for managing GBM interactions\n+ *\n+ * The GBM class provides a simplified interface for creating and managing\n+ * GBM devices. It handles the initialization and teardown of GBM devices\n+ * used for buffer allocation in graphics and camera pipelines.\n+ *\n+ * This class is responsible for opening a DRI render node, creating a GBM\n+ * device, and providing access to the device and its associated pixel format.\n+ */\n+\n+/**\n+ *\\var GBM::fd_\n+ *\\brief file descriptor to DRI device\n+ */\n+\n+/**\n+ *\\var GBM::gbmDevice_\n+ *\\brief Pointer to GBM device structure derived from fd_\n+ */\n+\n+/**\n+ *\\var GBM::format_\n+ *\\brief Pixel format the GBM surface was created in\n+ */\n+\n+/**\n+ *\\brief GBM constructor.\n+ *\n+ * Creates a GBM instance with unitialised state.\n+ */\n+GBM::GBM()\n+{\n+\tfd_ = 0;\n+\tgbmDevice_ = nullptr;\n+}\n+\n+/**\n+ *\\brief GBM destructor\n+ *\n+ * Cleans up the GBM device if it was successfully created, and closes\n+ * the associated file descriptor.\n+ */\n+GBM::~GBM()\n+{\n+\tif (gbmDevice_)\n+\t\tgbm_device_destroy(gbmDevice_);\n+}\n+\n+/**\n+ * \\brief Create and initialize a GBM device\n+ *\n+ * \\todo Get dri device name from envOption setting\n+ *\n+ * Opens the DRI render node (/dev/dri/renderD128) and creates a GBM\n+ * device using the libgbm library. Sets the default pixel format to\n+ * ARGB8888.\n+ *\n+ * \\return 0 on success, or a negative error code on failure\n+ */\n+int GBM::createDevice()\n+{\n+\tconst char *dri_node = \"/dev/dri/renderD128\";\n+\n+\tfd_ = open(dri_node, O_RDWR | O_CLOEXEC);\n+\tif (fd_ < 0) {\n+\t\tLOG(GBM, Error) << \"Open \" << dri_node << \" fail \" << fd_;\n+\t\treturn fd_;\n+\t}\n+\n+\tgbmDevice_ = gbm_create_device(fd_);\n+\tif (!gbmDevice_) {\n+\t\tLOG(GBM, Error) << \"gbm_create_device fail\";\n+\t\tclose(fd_);\n+\t\treturn -errno;\n+\t}\n+\n+\tformat_ = libcamera::formats::ARGB8888;\n+\n+\treturn 0;\n+}\n+\n+/**\n+ * \\brief Retrieve the GBM device handle\n+ *\n+ * \\return Pointer to the gbm_device structure, or nullptr if the device\n+ * has not been created\n+ */\n+struct gbm_device * GBM::getDevice()\n+{\n+\treturn gbmDevice_;\n+}\n+\n+/**\n+ * \\brief Retrieve the pixel format\n+ *\n+ * \\return The PixelFormat used by this GBM instance (ARGB8888)\n+ */\n+\n+PixelFormat GBM::getPixelFormat()\n+{\n+\treturn format_;\n+}\n+} /* namespace libcamera */\ndiff --git a/src/libcamera/meson.build b/src/libcamera/meson.build\nindex 90d434a5a..685213c78 100644\n--- a/src/libcamera/meson.build\n+++ b/src/libcamera/meson.build\n@@ -70,6 +70,15 @@ libcamera_deps = []\n libatomic = cc.find_library('atomic', required : false)\n libthreads = dependency('threads')\n \n+libgbm = cc.find_library('gbm', required: false)\n+gbm_works = cc.check_header('gbm.h', required: false)\n+\n+if libgbm.found() and gbm_works\n+    libcamera_internal_sources += files([\n+        'gbm.cpp',\n+    ])\n+endif\n+\n subdir('base')\n subdir('converter')\n subdir('ipa')\n@@ -178,6 +187,7 @@ libcamera_deps += [\n     libcamera_base_private,\n     libcrypto,\n     libdl,\n+    libgbm,\n     liblttng,\n     libudev,\n     libyaml,\n",
    "prefixes": [
        "v8",
        "01/26"
    ]
}