From patchwork Mon Jan 19 20:28:34 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Robert Mader X-Patchwork-Id: 25852 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 7D210BDCBF for ; Mon, 19 Jan 2026 20:29:15 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 882E461FC6; Mon, 19 Jan 2026 21:29:14 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=collabora.com header.i=robert.mader@collabora.com header.b="HnRItaZp"; dkim-atps=neutral Received: from sender4-pp-f112.zoho.com (sender4-pp-f112.zoho.com [136.143.188.112]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 139EA606D5 for ; Mon, 19 Jan 2026 21:29:12 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; t=1768854548; cv=none; d=zohomail.com; s=zohoarc; b=l+xlhKwTUbfYB7g+yHf90iAJmXbVGFDVXRpIUC/yFDf+LE0yYw6v62dQr277+fxcRRXY85LD2AEIRMz7ddQuMMEdRJ6w0PiLNmjul2G9Sll/TBzbx3731425SD6UGYFBJaJC9oIxbELJqJoi+JUuVlA8dlmFsdL5HYaNA2tC0Q8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1768854548; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:MIME-Version:Message-ID:Subject:Subject:To:To:Message-Id:Reply-To; bh=kLSZVubkmK7IQ02LbqAhOWBarv/lSVzGYVbCM1r9Vgc=; b=Udp5WK1NYLpCKbOY9NM9mx+d0uyxp983iSn5IQmSlE+PQURSic/I0L/hoUQwKg9C/iyh+ryqhCAaMwsBeFb7Ou4bgN+cNuNUxwO8qTIwx+qQlAkRiOq5BDr+WhVazXxodbt1kT35l9Ty8d0K3H4EzKgp+FVxtSDakChHOHVLlpQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=collabora.com; spf=pass smtp.mailfrom=robert.mader@collabora.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1768854548; s=zohomail; d=collabora.com; i=robert.mader@collabora.com; h=From:From:To:To:Cc:Cc:Subject:Subject:Date:Date:Message-ID:MIME-Version:Content-Type:Content-Transfer-Encoding:Message-Id:Reply-To; bh=kLSZVubkmK7IQ02LbqAhOWBarv/lSVzGYVbCM1r9Vgc=; b=HnRItaZpur/xWxDjJ6tLb+RWUriF2BRtfCqTHgAoE+cS4fhjKqkSI1x5dGse8ikF 3/fW6Zjfeyjd9pmEgbpy/wzXmo6VZW9eP1OPICb1tLORrhq377WK5x+VCf+Uym1uoBA cDt2LzEHiWjnqs+aAaTru4JNeckyrJYNx9t8Cu0c= Received: by mx.zohomail.com with SMTPS id 176885454585598.19566847223598; Mon, 19 Jan 2026 12:29:05 -0800 (PST) From: Robert Mader To: libcamera-devel@lists.libcamera.org Cc: Robert Mader , Bryan O'Donoghue , Milan Zamazal , =?utf-8?b?QmFybmFiw6FzIFDFkWN6?= =?utf-8?q?e?= Subject: [PATCH v2 1/2] egl: Use the Mesa surfaceless platform instead of GBM Date: Mon, 19 Jan 2026 21:28:34 +0100 Message-ID: <20260119202835.372125-1-robert.mader@collabora.com> X-Mailer: git-send-email 2.52.0 MIME-Version: 1.0 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Which appears to be a better fit for the use-case at hand: 1. Like GBM it is Mesa specific, so no change in supported setups is expected. If ever required, a fallback to the generic device platform could be added on top. 2. It leaves the complexity of selecting a renderer device to the driver, reducing code and dependencies. 3. It allows to use llvmpipe / software drivers without dri device, which can be useful on CI or debugging (with LIBGL_ALWAYS_SOFTWARE=1). Signed-off-by: Robert Mader Reviewed-by: Bryan O'Donoghue Tested-by: Bryan O'Donoghue # sm8250/rb5, x1e/Dell Insprion14p Reviewed-by: Milan Zamazal Tested-by: Milan Zamazal # TI AM69 Tested-by: Barnabás Pőcze # ThinkPad X1 Yoga Gen 7 + ov2740 Reviewed-by: Laurent Pinchart --- include/libcamera/internal/egl.h | 4 +--- src/libcamera/egl.cpp | 12 +++++------- src/libcamera/software_isp/debayer_egl.cpp | 7 ++----- src/libcamera/software_isp/debayer_egl.h | 1 - 4 files changed, 8 insertions(+), 16 deletions(-) diff --git a/include/libcamera/internal/egl.h b/include/libcamera/internal/egl.h index f007f448a..630345ea7 100644 --- a/include/libcamera/internal/egl.h +++ b/include/libcamera/internal/egl.h @@ -16,8 +16,6 @@ #include #include -#include "libcamera/internal/gbm.h" - #define EGL_EGLEXT_PROTOTYPES #include #include @@ -96,7 +94,7 @@ public: eGL(); ~eGL(); - int initEGLContext(GBM *gbmContext); + int initEGLContext(); int createInputDMABufTexture2D(eGLImage &eglImage, int fd); int createOutputDMABufTexture2D(eGLImage &eglImage, int fd); diff --git a/src/libcamera/egl.cpp b/src/libcamera/egl.cpp index da563ee09..7ff1b5ea2 100644 --- a/src/libcamera/egl.cpp +++ b/src/libcamera/egl.cpp @@ -256,24 +256,22 @@ void eGL::createTexture2D(eGLImage &eglImage, GLint format, uint32_t width, uint /** * \brief Initialise the EGL context - * \param[in] gbmContext Pointer to initialised GBM context * - * Sets up the EGL display from the GBM device, creates an OpenGL ES 2.0 - * context, and retrieves function pointers for required extensions - * including: + * Sets up the EGL display, creates an OpenGL ES 2.0 context, and retrieves + * function pointers for required extensions including: * - eglCreateImageKHR / eglDestroyImageKHR * - glEGLImageTargetTexture2DOES * * \return 0 on success, or -ENODEV on failure */ -int eGL::initEGLContext(GBM *gbmContext) +int eGL::initEGLContext() { EGLint configAttribs[] = { EGL_RED_SIZE, 8, EGL_GREEN_SIZE, 8, EGL_BLUE_SIZE, 8, EGL_ALPHA_SIZE, 8, - EGL_SURFACE_TYPE, EGL_WINDOW_BIT, + EGL_SURFACE_TYPE, EGL_PBUFFER_BIT, EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, EGL_NONE }; @@ -291,7 +289,7 @@ int eGL::initEGLContext(GBM *gbmContext) goto fail; } - display_ = eglGetDisplay(gbmContext->device()); + display_ = eglGetPlatformDisplay(EGL_PLATFORM_SURFACELESS_MESA, nullptr, nullptr); if (display_ == EGL_NO_DISPLAY) { LOG(eGL, Error) << "Unable to get EGL display"; goto fail; diff --git a/src/libcamera/software_isp/debayer_egl.cpp b/src/libcamera/software_isp/debayer_egl.cpp index 9693d7252..c85c7d6cd 100644 --- a/src/libcamera/software_isp/debayer_egl.cpp +++ b/src/libcamera/software_isp/debayer_egl.cpp @@ -142,7 +142,7 @@ int DebayerEGL::initBayerShaders(PixelFormat inputFormat, PixelFormat outputForm /* * Tell shaders how to re-order output taking account of how the - * pixels are actually stored by GBM + * pixels are actually stored by EGL */ switch (outputFormat) { case formats::ARGB8888: @@ -586,10 +586,7 @@ int DebayerEGL::start() { GLint maxTextureImageUnits; - if (gbmSurface_.createDevice()) - return -ENODEV; - - if (egl_.initEGLContext(&gbmSurface_)) + if (egl_.initEGLContext()) return -ENODEV; glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, &maxTextureImageUnits); diff --git a/src/libcamera/software_isp/debayer_egl.h b/src/libcamera/software_isp/debayer_egl.h index a5033bc63..cfbaf8e9d 100644 --- a/src/libcamera/software_isp/debayer_egl.h +++ b/src/libcamera/software_isp/debayer_egl.h @@ -113,7 +113,6 @@ private: Rectangle window_; std::unique_ptr stats_; eGL egl_; - GBM gbmSurface_; uint32_t width_; uint32_t height_; GLint glFormat_;