43EGLDisplay QEglFSKmsGbmIntegration::createDisplay(EGLNativeDisplayType nativeDisplay)
45 qCDebug(qLcEglfsKmsDebug,
"Querying EGLDisplay");
48 PFNEGLGETPLATFORMDISPLAYEXTPROC getPlatformDisplay =
nullptr;
49 const char *extensions = eglQueryString(EGL_NO_DISPLAY, EGL_EXTENSIONS);
50 if (extensions && (strstr(extensions,
"EGL_KHR_platform_gbm") || strstr(extensions,
"EGL_MESA_platform_gbm"))) {
51 getPlatformDisplay =
reinterpret_cast<PFNEGLGETPLATFORMDISPLAYEXTPROC>(
52 eglGetProcAddress(
"eglGetPlatformDisplayEXT"));
55 if (getPlatformDisplay) {
58 qCDebug(qLcEglfsKmsDebug,
"No eglGetPlatformDisplay for GBM, falling back to eglGetDisplay");
59 display = eglGetDisplay(nativeDisplay);
65EGLNativeWindowType QEglFSKmsGbmIntegration::createNativeOffscreenWindow(
const QSurfaceFormat &format)
70 gbm_surface *surface = gbm_surface_create(
static_cast<QEglFSKmsGbmDevice *>(device())->gbmDevice(),
73 GBM_BO_USE_RENDERING);
75 return reinterpret_cast<EGLNativeWindowType>(surface);
104QKmsDevice *QEglFSKmsGbmIntegration::createDevice()
107 m_deviceDiscovery = std::unique_ptr<QDeviceDiscovery>(QDeviceDiscovery::create(QDeviceDiscovery::Device_VideoMask));
108#if QT_CONFIG(filesystemwatcher)
109 m_kmsConfigWatcher = std::unique_ptr<QFileSystemWatcher>(
new QFileSystemWatcher());
112 QString path = screenConfig()->devicePath();
113 if (!path.isEmpty()) {
114 qCDebug(qLcEglfsKmsDebug) <<
"GBM: Using DRM device" << path <<
"specified in config file";
116 const QStringList devices = m_deviceDiscovery->scanConnectedDevices();
117 qCDebug(qLcEglfsKmsDebug) <<
"Found the following video devices:" << devices;
119 if (Q_UNLIKELY(devices.isEmpty()))
120 qFatal(
"Could not find DRM device!");
122 path = devices.first();
123 qCDebug(qLcEglfsKmsDebug) <<
"Using" << path;
126 bool hotreload = !qEnvironmentVariable(
"QT_QPA_EGLFS_HOTPLUG_ENABLED").isEmpty();
128 qCWarning(qLcEglfsKmsDebug) <<
"EGLFS/KMS: Hot-Reload on KMS-events enabled, be aware that"
129 <<
"this requires actions in UI code for proper functionallity"
130 <<
"(e.g. close/open windows on screen's disconnect/connect)";
131 QObject::connect(m_deviceDiscovery.get(), &QDeviceDiscovery::deviceChanged,
132 m_deviceDiscovery.get(), [
this](
const QString &deviceNode) {
133 qCDebug(qLcEglfsKmsDebug) <<
"KMS device changed:" << deviceNode;
134 m_device->checkConnectedScreens();
138 QString json = qEnvironmentVariable(
"QT_QPA_EGLFS_KMS_CONFIG");
140 json = qEnvironmentVariable(
"QT_QPA_KMS_CONFIG");
142 if (!json.isEmpty()) {
143#if QT_CONFIG(filesystemwatcher)
144 m_kmsConfigWatcher->addPath(json);
145 QObject::connect(m_kmsConfigWatcher.get(), &QFileSystemWatcher::fileChanged,
146 m_kmsConfigWatcher.get(), [
this, json]() {
147 qCDebug(qLcEglfsKmsDebug) <<
"KMS config-file has changed! path:"
149 m_screenConfig->refreshConfig();
150 m_device->updateScreens();
151 m_kmsConfigWatcher->addPath(json);
157 return new QEglFSKmsGbmDevice(screenConfig(), path);