Patch Detail
Show a patch.
GET /api/patches/25310/?format=api
{ "id": 25310, "url": "https://patchwork.libcamera.org/api/patches/25310/?format=api", "web_url": "https://patchwork.libcamera.org/patch/25310/", "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": "<20251202134544.662446-2-bryan.odonoghue@linaro.org>", "date": "2025-12-02T13:45:21", "name": "[v6,01/24] libcamera: software_isp: gbm: Add a GBM helper class for GPU surface access", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "bdcb1d415ff25794e7490f22e130997f3221f734", "submitter": { "id": 175, "url": "https://patchwork.libcamera.org/api/people/175/?format=api", "name": "Bryan O'Donoghue", "email": "bryan.odonoghue@linaro.org" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/25310/mbox/", "series": [ { "id": 5631, "url": "https://patchwork.libcamera.org/api/series/5631/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=5631", "date": "2025-12-02T13:45:20", "name": "Add GLES 2.0 GPUISP to libcamera", "version": 6, "mbox": "https://patchwork.libcamera.org/series/5631/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/25310/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/25310/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 605AEC3260\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 2 Dec 2025 13:45:56 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 977A860C88;\n\tTue, 2 Dec 2025 14:45:55 +0100 (CET)", "from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com\n\t[IPv6:2a00:1450:4864:20::32f])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 7190E60C77\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 2 Dec 2025 14:45:53 +0100 (CET)", "by mail-wm1-x32f.google.com with SMTP id\n\t5b1f17b1804b1-4779adb38d3so41021105e9.2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 02 Dec 2025 05:45:53 -0800 (PST)", "from inspiron14p-linux.ht.home (188-141-3-146.dynamic.upc.ie.\n\t[188.141.3.146]) by smtp.gmail.com with ESMTPSA id\n\t5b1f17b1804b1-47926f0ec69sm19383375e9.1.2025.12.02.05.45.51\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tTue, 02 Dec 2025 05:45:51 -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=\"AhyndsQq\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=linaro.org; s=google; t=1764683152; x=1765287952;\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=n/Dr3v1jgs2rQ+R/y4XCcTtZPdFoLGM7Zc7OE3xBNt0=;\n\tb=AhyndsQqpCs9FbJlPxS8yb2eJ3NQDtSqyFUDxpODH9kqcG18kxen3hp67JV61zFKkP\n\t3am1VNEvXVNj9X3tuUb5cuqYdCpNmvdrwA26pYze/CV5+LwZ/yMLyTQ9JhKw/4wKGgw6\n\tMj0utGZtt2sBB7JNknxfzhHZJxniCLkbDkUQk3777J8cWwoVongnkR9bZuxRDu5g21cL\n\t7lRobMawP3NLdSvmgO8DXyAdDW7bMeym8NpIJJWV9871+B+jTluQAsi9zMDfkgScop7T\n\tavXQNRUPg0qevSRPHXFpNJCexyjvPtb8WhbgveR6Oe/lyzisbDLtxVdkgkIE/fUcV4Yz\n\tf+1Q==", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20230601; t=1764683152; x=1765287952;\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=n/Dr3v1jgs2rQ+R/y4XCcTtZPdFoLGM7Zc7OE3xBNt0=;\n\tb=dJ++ohvwofHFNbvHAMaecKQYrSCabDh6YogDlpIJp7EJbz4Sl3JKo1ArDTGBFbUC3O\n\tkmNHqgZApFo2CBAkvlRKUVVcaK3IcXlOJM6bDM0mGAGVN26JG4YoxcAWYKsaKvBCEDBI\n\tRIt3oWu+xMnRtslEe/CtKH+r7NW7jctYXppNO4t9/YjW0RRT7KihMz75id0p8Sgn55RF\n\taYbmE9oGWHjuczMwyDgu/ytFS8WIPWDBTCFdUGbFGOVY78crPdaknZAsFMVb4zruXJlZ\n\tE6ad/F0PkRNU1saJzj74rG0zajwikz1lqLhfp8zS8vxzGWqBL0oQX1XpjocEDTydul6Z\n\tPwMg==", "X-Gm-Message-State": "AOJu0Yy8NUL7LSPTNqL+SE0SxYWYyNz3ouwiBLPMz3Pe7UkD3nXeQbJn\n\tUvtZUaHm6xKZHz7OIPzQouOrtd3+bnJ5sMMagOVp7q122c52ygAAzdpkDF0zqBHOvrSBOTGCeAT\n\tuCL3S", "X-Gm-Gg": "ASbGncvEbxEWhhBWzO6L/CuoEYyh3grXmt+yw/ZkJWHgt0ElPT7tzWgg9m3n/1nb1/w\n\tx4tXsZUSZ7LHNU/iCUjFYFGX2x7TCrKiH+DLP+vD03Nuoqz+qRr5Lpwi9PNJgBUtCsdypHAA5g3\n\tZ3TSYq4x4T37xRpd5yYw7DdYzrthiQgZbKMM5up1BmqZzsxhVrn8/SXG2QJP9WRBa9/FaYfxHen\n\tVe1hOPJe9CQVsV4LPKAmHAjIr95tzaOU5f3f1GWnNIDY8Kjfvzrl97LoGsGp1lJzovLDQ/gQTVG\n\tnuz2mQSUilD9FvDuoOtWEyQ2NmJS5URs/F3HfR9VGL1dVCOSrmn9VJsjddC5FcbfZN1vhwfV4kp\n\tfl/wxCw7sHVEX/BM+sIgGL2EaGsqjoH7QSB4+QeRIhwHgC2mFfLB6P/K2r0TfMnOq1SjbhiMoQT\n\tWNvC/XH9E/zixIuKWPWHQJecjYkdq2K+Rrg9qmlxBC2PB1U1c1fn/JpyD+oz1l5XD8+LM=", "X-Google-Smtp-Source": "AGHT+IEBsZK4czuOzq1ubBK5Kfa39erknNowrvyEPdkj74mAjIaCEACEykbwuweQOPhjiMD1KmkRsg==", "X-Received": "by 2002:a05:600c:c8c:b0:471:d2f:7987 with SMTP id\n\t5b1f17b1804b1-47904b23c04mr275801315e9.26.1764683152429; \n\tTue, 02 Dec 2025 05:45:52 -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 v6 01/24] libcamera: software_isp: gbm: Add a GBM helper\n\tclass for GPU surface access", "Date": "Tue, 2 Dec 2025 13:45:21 +0000", "Message-ID": "<20251202134544.662446-2-bryan.odonoghue@linaro.org>", "X-Mailer": "git-send-email 2.52.0", "In-Reply-To": "<20251202134544.662446-1-bryan.odonoghue@linaro.org>", "References": "<20251202134544.662446-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 | 11 +++\n 4 files changed, 181 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..6852def58\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+ * gbm.h - 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 *gbm_device_;\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..7d53cd43e\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+ * egl.cpp - 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::gbm_device_\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+\tgbm_device_ = NULL;\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 (gbm_device_)\n+\t\tgbm_device_destroy(gbm_device_);\n+}\n+\n+/**\n+ * \\brief Create and initialize a GBM device\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\"; //TODO: get from an env or config setting\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+\tgbm_device_ = gbm_create_device(fd_);\n+\tif (!gbm_device_) {\n+\t\tLOG(GBM, Error) << \"gbm_crate_device fail\";\n+\t\tgoto fail;\n+\t}\n+\n+\tformat_ = libcamera::formats::ARGB8888;\n+\n+\treturn 0;\n+fail:\n+\tclose(fd_);\n+\treturn -errno;\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 gbm_device_;\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..4eaa42062 100644\n--- a/src/libcamera/meson.build\n+++ b/src/libcamera/meson.build\n@@ -70,6 +70,16 @@ 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+ config_h.set('HAVE_GBM', 1)\n+ libcamera_internal_sources += files([\n+ 'gbm.cpp',\n+ ])\n+endif\n+\n subdir('base')\n subdir('converter')\n subdir('ipa')\n@@ -178,6 +188,7 @@ libcamera_deps += [\n libcamera_base_private,\n libcrypto,\n libdl,\n+ libgbm,\n liblttng,\n libudev,\n libyaml,\n", "prefixes": [ "v6", "01/24" ] }