39EGLDisplay QEglFSKmsGbmIntegration::createDisplay(EGLNativeDisplayType nativeDisplay)
41 qCDebug(qLcEglfsKmsDebug,
"Querying EGLDisplay");
44 PFNEGLGETPLATFORMDISPLAYEXTPROC getPlatformDisplay =
nullptr;
45 const char *extensions = eglQueryString(EGL_NO_DISPLAY, EGL_EXTENSIONS);
46 if (extensions && (strstr(extensions,
"EGL_KHR_platform_gbm") || strstr(extensions,
"EGL_MESA_platform_gbm"))) {
47 getPlatformDisplay =
reinterpret_cast<PFNEGLGETPLATFORMDISPLAYEXTPROC>(
48 eglGetProcAddress(
"eglGetPlatformDisplayEXT"));
51 if (getPlatformDisplay) {
54 qCDebug(qLcEglfsKmsDebug,
"No eglGetPlatformDisplay for GBM, falling back to eglGetDisplay");
55 display = eglGetDisplay(nativeDisplay);
61EGLNativeWindowType QEglFSKmsGbmIntegration::createNativeOffscreenWindow(
const QSurfaceFormat &format)
66 gbm_surface *surface = gbm_surface_create(
static_cast<QEglFSKmsGbmDevice *>(device())->gbmDevice(),
69 GBM_BO_USE_RENDERING);
71 return reinterpret_cast<EGLNativeWindowType>(surface);
100QKmsDevice *QEglFSKmsGbmIntegration::createDevice()
103 m_deviceDiscovery = std::unique_ptr<QDeviceDiscovery>(QDeviceDiscovery::create(QDeviceDiscovery::Device_VideoMask));
104 m_kmsConfigWatcher = std::unique_ptr<QFileSystemWatcher>(
new QFileSystemWatcher());
106 QString path = screenConfig()->devicePath();
107 if (!path.isEmpty()) {
108 qCDebug(qLcEglfsKmsDebug) <<
"GBM: Using DRM device" << path <<
"specified in config file";
110 const QStringList devices = m_deviceDiscovery->scanConnectedDevices();
111 qCDebug(qLcEglfsKmsDebug) <<
"Found the following video devices:" << devices;
113 if (Q_UNLIKELY(devices.isEmpty()))
114 qFatal(
"Could not find DRM device!");
116 path = devices.first();
117 qCDebug(qLcEglfsKmsDebug) <<
"Using" << path;
120 bool hotreload = !qEnvironmentVariable(
"QT_QPA_EGLFS_HOTPLUG_ENABLED").isEmpty();
122 qCWarning(qLcEglfsKmsDebug) <<
"EGLFS/KMS: Hot-Reload on KMS-events enabled, be aware that"
123 <<
"this requires actions in UI code for proper functionallity"
124 <<
"(e.g. close/open windows on screen's disconnect/connect)";
125 QObject::connect(m_deviceDiscovery.get(), &QDeviceDiscovery::deviceChanged,
126 m_deviceDiscovery.get(), [
this](
const QString &deviceNode) {
127 qCDebug(qLcEglfsKmsDebug) <<
"KMS device changed:" << deviceNode;
128 m_device->checkConnectedScreens();
132 QString json = qEnvironmentVariable(
"QT_QPA_EGLFS_KMS_CONFIG");
134 json = qEnvironmentVariable(
"QT_QPA_KMS_CONFIG");
136 if (!json.isEmpty()) {
137 m_kmsConfigWatcher->addPath(json);
138 QObject::connect(m_kmsConfigWatcher.get(), &QFileSystemWatcher::fileChanged,
139 m_kmsConfigWatcher.get(), [
this, json]() {
140 qCDebug(qLcEglfsKmsDebug) <<
"KMS config-file has changed! path:"
142 m_screenConfig->refreshConfig();
143 m_device->updateScreens();
144 m_kmsConfigWatcher->addPath(json);
149 return new QEglFSKmsGbmDevice(screenConfig(), path);