You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

Qt 5.15.2 can run on various backends. The EGLFS and Wayland backends are widely used. Here, we will talk about how to build and integrate Qt 5.15.2 with EGLFS and Wayland backends support based on VLP 3.0.6.


Firstly, the SDK or toolchain must be prepared. The default Yocto SDK of VLP 3.0.6 can only support the Qt with Wayland backend building. So the patch for the Qt 5.6.3(Qt version of VLP 3.0.6) recipe must be applied.

1) Modify meta-qt5/recipes-qt/qt5/qtbase_git.bb:

     file://0008-configure-paths-for-target-qmake-properly.patch \
+    file://0001-dynamic-layers-qt5-qtbase-Add-DRM-KMS-support-for-EG.patch \
"

...

- PACKAGECONFIG_GL ?= "${@bb.utils.contains('DISTRO_FEATURES', 'opengl', 'gl', '', d)}"
+ PACKAGECONFIG_GL ?= "${@bb.utils.contains('DISTRO_FEATURES', 'opengl', 'gles2', '', d)}"

...

PACKAGECONFIG_DEFAULT ?= "dbus udev evdev widgets tools libs"
+ PACKAGECONFIG_EGLFS ?= "kms gbm"

...

  ${PACKAGECONFIG_DISTRO} \
+    ${PACKAGECONFIG_EGLFS} \
"

...

- PACKAGECONFIG[kms] = "-kms,-no-kms,virtual/mesa virtual/egl"
+ PACKAGECONFIG[kms] = "-kms,-no-kms,drm virtual/egl"
+ PACKAGECONFIG[gbm] = "-gbm,-no-gbm,virtual/libgbm"

...

QT_CONFIG_FLAGS += " \
+    -kms -gbm \


2) Add a patch file meta-qt5/recipes-qt/qt5/qtbase/0001-dynamic-layers-qt5-qtbase-Add-DRM-KMS-support-for-EG.patch:

From e9f4221e052c005593f4a5188e4293882edb4468 Mon Sep 17 00:00:00 2001
From: Cuong Doan <cuong.doan.ra@renesas.com>
Date: Wed, 23 Mar 2022 09:43:33 +0700
Subject: [PATCH] dynamic-layers: qt5: qtbase: Add DRM/KMS support for EGLFS.

This patch is for adding drm/kms support for eglfs.

Signed-off-by: Cuong Doan <cuong.doan.ra@renesas.com>
---
 .../eglfs_kms/qeglfskmsintegration.cpp             | 14 +++++++++++++-
 .../eglfs_kms/qeglfskmsintegration.h               |  7 ++++++-
 .../eglfs_kms/qeglfskmsscreen.cpp                  |  2 +-
 src/plugins/platforms/eglfs/qeglfsintegration.cpp  |  6 +++---
 4 files changed, 23 insertions(+), 6 deletions(-)

diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsintegration.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsintegration.cpp
index d1814fb85d..7703b75207 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsintegration.cpp
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsintegration.cpp
@@ -62,7 +62,10 @@ QEglFSKmsIntegration::QEglFSKmsIntegration()
     , m_hwCursor(true)
     , m_pbuffers(false)
     , m_separateScreens(false)
-{}
+{
+    get_platform_display = (PFNEGLGETPLATFORMDISPLAYEXTPROC)
+                           eglGetProcAddress("eglGetPlatformDisplayEXT");
+}
 
 void QEglFSKmsIntegration::platformInit()
 {
@@ -102,6 +105,15 @@ EGLNativeDisplayType QEglFSKmsIntegration::platformDisplay() const
     return reinterpret_cast<EGLNativeDisplayType>(m_device->device());
 }
 
+EGLDisplay QEglFSKmsIntegration::createDisplay(EGLNativeDisplayType nativeDisplay)
+{
+    if (get_platform_display)
+        m_display = get_platform_display(EGL_PLATFORM_GBM_KHR, nativeDisplay, NULL);
+    else
+        m_display = eglGetDisplay(nativeDisplay);
+    return m_display;
+}
+
 bool QEglFSKmsIntegration::usesDefaultScreen()
 {
     return false;
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsintegration.h b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsintegration.h
index edb6906a4b..808f19c4d5 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsintegration.h
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsintegration.h
@@ -38,6 +38,7 @@
 #include "qeglfsdeviceintegration.h"
 #include <QtCore/QMap>
 #include <QtCore/QVariant>
+#include <EGL/eglext.h>
 
 QT_BEGIN_NAMESPACE
 
@@ -50,6 +51,7 @@ public:
 
     void platformInit() Q_DECL_OVERRIDE;
     void platformDestroy() Q_DECL_OVERRIDE;
+    EGLDisplay createDisplay(EGLNativeDisplayType nativeDisplay) Q_DECL_OVERRIDE;
     EGLNativeDisplayType platformDisplay() const Q_DECL_OVERRIDE;
     bool usesDefaultScreen() Q_DECL_OVERRIDE;
     void screenInit() Q_DECL_OVERRIDE;
@@ -68,16 +70,19 @@ public:
     bool hwCursor() const;
     bool separateScreens() const;
     QMap<QString, QVariantMap> outputSettings() const;
+    EGLDisplay display() { return m_display; };
 
 private:
     void loadConfig();
-
     QEglFSKmsDevice *m_device;
     bool m_hwCursor;
     bool m_pbuffers;
     bool m_separateScreens;
     QString m_devicePath;
     QMap<QString, QVariantMap> m_outputSettings;
+
+    PFNEGLGETPLATFORMDISPLAYEXTPROC get_platform_display;
+    EGLDisplay m_display;
 };
 
 QT_END_NAMESPACE
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsscreen.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsscreen.cpp
index 048f5433dc..99bdba7142 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsscreen.cpp
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsscreen.cpp
@@ -106,7 +106,7 @@ QEglFSKmsScreen::QEglFSKmsScreen(QEglFSKmsIntegration *integration,
                                  QEglFSKmsDevice *device,
                                  QEglFSKmsOutput output,
                                  QPoint position)
-    : QEglFSScreen(eglGetDisplay(reinterpret_cast<EGLNativeDisplayType>(device->device())))
+    : QEglFSScreen(integration->display())
     , m_integration(integration)
     , m_device(device)
     , m_gbm_surface(Q_NULLPTR)
diff --git a/src/plugins/platforms/eglfs/qeglfsintegration.cpp b/src/plugins/platforms/eglfs/qeglfsintegration.cpp
index 2a6f3aa7cf..4a39d55b66 100644
--- a/src/plugins/platforms/eglfs/qeglfsintegration.cpp
+++ b/src/plugins/platforms/eglfs/qeglfsintegration.cpp
@@ -115,13 +115,13 @@ void QEglFSIntegration::initialize()
 {
     qt_egl_device_integration()->platformInit();
 
-    m_display = qt_egl_device_integration()->createDisplay(nativeDisplay());
+    m_display = qt_egl_device_integration()->createDisplay(qt_egl_device_integration()->platformDisplay());
     if (m_display == EGL_NO_DISPLAY)
-        qFatal("Could not open egl display");
+        qFatal("Could not open egl display. Err:%x", eglGetError());
 
     EGLint major, minor;
     if (!eglInitialize(m_display, &major, &minor))
-        qFatal("Could not initialize egl display");
+        qFatal("Could not initialize egl display. Err:%x", eglGetError());
 
     m_inputContext = QPlatformInputContextFactory::create();
 


3) Build out the Yocto core-image-qt image, and then populate and install the SDK. Assume the SDK default install location is used(/opt/poky/3.1.31).

MACHINE=smarc-rzg2l bitbake core-image-qt

MACHINE=smarc-rzg2l bitbake core-image-qt -c populate_sdk

sudo sh poky-glibc-x86_64-core-image-weston-aarch64-smarc-rzg2l-toolchain-3.1.31.sh

Note: The Qt 5.6.3 with EGLFS backend support is ready. If you only need Qt 5.6.3, you can skip the following steps.


Secondly, we can download, configure and build the Qt 5.15.2 source code.




  • No labels