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