Patch Detail
Show a patch.
GET /api/patches/26818/?format=api
{ "id": 26818, "url": "https://patchwork.libcamera.org/api/patches/26818/?format=api", "web_url": "https://patchwork.libcamera.org/patch/26818/", "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": "<20260603102534.3059900-1-qi.hou@nxp.com>", "date": "2026-06-03T10:25:34", "name": "libcamera: software_isp: Probe EGL availability before creating DebayerEGL", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "bbf82a105ade178ff427edf4f7c4d54b9253f8e5", "submitter": { "id": 195, "url": "https://patchwork.libcamera.org/api/people/195/?format=api", "name": "Qi Hou", "email": "qi.hou@nxp.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/26818/mbox/", "series": [ { "id": 5973, "url": "https://patchwork.libcamera.org/api/series/5973/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=5973", "date": "2026-06-03T10:25:34", "name": "libcamera: software_isp: Probe EGL availability before creating DebayerEGL", "version": 1, "mbox": "https://patchwork.libcamera.org/series/5973/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/26818/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/26818/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 33830C324C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 3 Jun 2026 10:25:46 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 6F32F630BA;\n\tWed, 3 Jun 2026 12:25:45 +0200 (CEST)", "from inva020.nxp.com (inva020.nxp.com [92.121.34.13])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id A526A62FE1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 3 Jun 2026 12:25:43 +0200 (CEST)", "from inva020.nxp.com (localhost [127.0.0.1])\n\tby inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id 3F1C11A5E97;\n\tWed, 3 Jun 2026 12:25:43 +0200 (CEST)", "from aprdc01srsp001v.ap-rdc01.nxp.com\n\t(aprdc01srsp001v.ap-rdc01.nxp.com [165.114.16.16])\n\tby inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id 08F281A5E72;\n\tWed, 3 Jun 2026 12:25:43 +0200 (CEST)", "from lsvm11u0000124.swis.ap-northeast-2.aws.nxp.com\n\t(lsvm11u0000124.swis.ap-northeast-2.aws.nxp.com [10.52.8.111])\n\tby aprdc01srsp001v.ap-rdc01.nxp.com (Postfix) with ESMTP id\n\tDD6CE180004C; Wed, 3 Jun 2026 18:25:41 +0800 (+08)" ], "From": "Qi Hou <qi.hou@nxp.com>", "To": "libcamera-devel@lists.libcamera.org", "Cc": "jared.hu@nxp.com,\n\tqi.hou@nxp.com,\n\tjulien.vuillaumier@nxp.com", "Subject": "[PATCH] libcamera: software_isp: Probe EGL availability before\n\tcreating DebayerEGL", "Date": "Wed, 3 Jun 2026 19:25:34 +0900", "Message-Id": "<20260603102534.3059900-1-qi.hou@nxp.com>", "X-Mailer": "git-send-email 2.34.1", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "X-Virus-Scanned": "ClamAV using ClamSMTP", "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 HAVE_DEBAYER_EGL is enabled, the SoftwareIsp constructor\nunconditionally creates a DebayerEGL instance. The DebayerEGL\nconstructor always succeeds because it merely stores pointers without\ninitialising the EGL context. The actual EGL initialisation is deferred\nto DebayerEGL::start(), which calls eGL::initEGLContext(). If the\nplatform lacks a surfaceless EGL display (e.g. i.MX8MM without Mesa\nsurfaceless support), eglGetPlatformDisplay(EGL_PLATFORM_SURFACELESS_MESA)\nfails and start() returns -ENODEV. At that point, the SwStatsCpu\nownership has already been moved into the unusable DebayerEGL instance,\nmaking a fallback to DebayerCpu impossible.\n\nFix this by adding a static DebayerEGL::isEGLAvailable() method that\nprobes whether EGL surfaceless rendering can be initialised. It\nattempts eglGetPlatformDisplay() + eglInitialize() and immediately\ncalls eglTerminate() to release resources. The SoftwareIsp constructor\nnow calls this probe before creating DebayerEGL. If EGL is not\navailable, DebayerEGL is not instantiated and the existing fallback\npath naturally creates a DebayerCpu instance instead.\n\nSigned-off-by: Qi Hou <qi.hou@nxp.com>\n---\n src/libcamera/software_isp/debayer_egl.cpp | 28 +++++++++++++++++++++\n src/libcamera/software_isp/debayer_egl.h | 2 ++\n src/libcamera/software_isp/software_isp.cpp | 10 ++++++--\n 3 files changed, 38 insertions(+), 2 deletions(-)", "diff": "diff --git a/src/libcamera/software_isp/debayer_egl.cpp b/src/libcamera/software_isp/debayer_egl.cpp\nindex 7b9e02d9..cfe41447 100644\n--- a/src/libcamera/software_isp/debayer_egl.cpp\n+++ b/src/libcamera/software_isp/debayer_egl.cpp\n@@ -33,6 +33,34 @@ namespace libcamera {\n * Implements an EGL shader based debayering solution.\n */\n \n+/**\n+ * \\brief Probe whether EGL surfaceless rendering is available\n+ *\n+ * Performs a lightweight check by attempting to obtain an EGL display using\n+ * EGL_PLATFORM_SURFACELESS_MESA and initialising it. The display is\n+ * immediately released so that no resources are leaked. This allows the\n+ * caller to decide at construction time whether to instantiate DebayerEGL\n+ * or fall back to DebayerCpu.\n+ *\n+ * \\return true if EGL surfaceless rendering is available, false otherwise\n+ */\n+bool DebayerEGL::isEGLAvailable()\n+{\n+\tif (!eglBindAPI(EGL_OPENGL_ES_API))\n+\t\treturn false;\n+\n+\tEGLDisplay display = eglGetPlatformDisplay(EGL_PLATFORM_SURFACELESS_MESA,\n+\t\t\t\t\t\t EGL_DEFAULT_DISPLAY,\n+\t\t\t\t\t\t nullptr);\n+\tif (display == EGL_NO_DISPLAY)\n+\t\treturn false;\n+\n+\tEGLBoolean ret = eglInitialize(display, nullptr, nullptr);\n+\teglTerminate(display);\n+\n+\treturn ret == EGL_TRUE;\n+}\n+\n /**\n * \\brief Construct a DebayerEGL object\n * \\param[in] stats Statistics processing object\ndiff --git a/src/libcamera/software_isp/debayer_egl.h b/src/libcamera/software_isp/debayer_egl.h\nindex 141fb288..945125cd 100644\n--- a/src/libcamera/software_isp/debayer_egl.h\n+++ b/src/libcamera/software_isp/debayer_egl.h\n@@ -39,6 +39,8 @@ class CameraManager;\n class DebayerEGL : public Debayer\n {\n public:\n+\tstatic bool isEGLAvailable();\n+\n \tDebayerEGL(std::unique_ptr<SwStatsCpu> stats, const CameraManager &cm);\n \t~DebayerEGL();\n \ndiff --git a/src/libcamera/software_isp/software_isp.cpp b/src/libcamera/software_isp/software_isp.cpp\nindex 781cf02f..403efbdb 100644\n--- a/src/libcamera/software_isp/software_isp.cpp\n+++ b/src/libcamera/software_isp/software_isp.cpp\n@@ -119,8 +119,14 @@ SoftwareIsp::SoftwareIsp(PipelineHandler *pipe, const CameraSensor *sensor,\n \t\t}\n \t}\n \n-\tif (!softISPMode || softISPMode == \"gpu\")\n-\t\tdebayer_ = std::make_unique<DebayerEGL>(std::move(stats), cm);\n+\tif (!softISPMode || softISPMode == \"gpu\") {\n+\t\tif (DebayerEGL::isEGLAvailable()) {\n+\t\t\tdebayer_ = std::make_unique<DebayerEGL>(std::move(stats), cm);\n+\t\t} else {\n+\t\t\tLOG(SoftwareIsp, Info)\n+\t\t\t\t<< \"EGL not available, falling back to CPU debayer\";\n+\t\t}\n+\t}\n \n #endif\n \tif (!debayer_)\n", "prefixes": [] }