summaryrefslogtreecommitdiffstats
path: root/patches/qt-everywhere-src-5.12.1/0004-eglfs_kms-device-ordering-robustness.patch
blob: d466e32b33b6145cc6220256fffb305a79c2d12f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
From: Lucas Stach <l.stach@pengutronix.de>
Date: Mon, 29 Jan 2018 14:02:03 +0100
Subject: [PATCH] eglfs_kms: device ordering robustness

Check the DRM device for available mode resources before deciding to
use it as the KMS device. This way we are robust against changes in
DRM device ordering, where some of the devices are render only.

Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
---
 .../eglfs_kms/qeglfskmsgbmintegration.cpp            | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/qtbase/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmintegration.cpp b/qtbase/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmintegration.cpp
index 402338197d0f..227f6fe3e9fb 100644
--- a/qtbase/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmintegration.cpp
+++ b/qtbase/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmintegration.cpp
@@ -47,6 +47,7 @@
 #include "private/qeglfscursor_p.h"
 
 #include <QtCore/QLoggingCategory>
+#include <QtCore/private/qcore_unix_p.h>
 #include <QtGui/QScreen>
 #include <QtDeviceDiscoverySupport/private/qdevicediscovery_p.h>
 
@@ -129,6 +130,20 @@ void QEglFSKmsGbmIntegration::presentBuffer(QPlatformSurface *surface)
     screen->flip();
 }
 
+static bool check_modesetting(QString devpath)
+{
+    bool moderes = false;
+    struct drm_mode_card_res res = { };
+    int fd = qt_safe_open(devpath.toLocal8Bit().constData(), O_RDWR | O_CLOEXEC);
+
+    if (!drmIoctl(fd, DRM_IOCTL_MODE_GETRESOURCES, &res))
+        moderes = true;
+
+    qt_safe_close(fd);
+
+    return moderes;
+}
+
 QKmsDevice *QEglFSKmsGbmIntegration::createDevice()
 {
     QString path = screenConfig()->devicePath();
@@ -144,6 +159,11 @@ QKmsDevice *QEglFSKmsGbmIntegration::createDevice()
             qFatal("Could not find DRM device!");
 
         path = devices.first();
+        for (int i = 0; i < devices.count(); i++) {
+            path = devices.at(i);
+            if (check_modesetting(path))
+                break;
+        }
         qCDebug(qLcEglfsKmsDebug) << "Using" << path;
     }