Find primary GPU only

Some systems may have multiple DRM devices attached to a single seat and we are
not guaranteed to pick up the primary GPU. With this flag we can control how
DRM devices are detected and consider only the primary GPU.

This is very useful for the kms plugin or QtCompositors running on kms in order
to use the right DRM device.

Change-Id: I8b91e78f148b25aaa4e40724e39e0ed0918ca100
Reviewed-by: Andy Nichols <andy.nichols@digia.com>
bb10
Pier Luigi Fiorini 2013-01-27 09:53:32 +01:00 committed by The Qt Project
parent ea14a63083
commit 888bfb09da
3 changed files with 13 additions and 4 deletions

View File

@ -72,7 +72,8 @@ public:
Device_Touchscreen = 0x04,
Device_Keyboard = 0x08,
Device_DRM = 0x10,
Device_Tablet = 0x20,
Device_DRM_PrimaryGPU = 0x20,
Device_Tablet = 0x40,
Device_InputMask = Device_Mouse | Device_Touchpad | Device_Touchscreen | Device_Keyboard | Device_Tablet,
Device_VideoMask = Device_DRM
};

View File

@ -149,8 +149,16 @@ QStringList QDeviceDiscovery::scanConnectedDevices()
QString candidate = QString::fromUtf8(udev_device_get_devnode(udevice));
if ((m_types & Device_InputMask) && candidate.startsWith(QLatin1String(QT_EVDEV_DEVICE)))
devices << candidate;
if ((m_types & Device_VideoMask) && candidate.startsWith(QLatin1String(QT_DRM_DEVICE)))
devices << candidate;
if ((m_types & Device_VideoMask) && candidate.startsWith(QLatin1String(QT_DRM_DEVICE))) {
if (m_types & Device_DRM_PrimaryGPU) {
udev_device *pci = udev_device_get_parent_with_subsystem_devtype(udevice, "pci", 0);
if (pci) {
if (qstrcmp(udev_device_get_sysattr_value(pci, "boot_vga"), "1") == 0)
devices << candidate;
}
} else
devices << candidate;
}
udev_device_unref(udevice);
}

View File

@ -66,7 +66,7 @@ QKmsIntegration::QKmsIntegration()
setenv("EGL_PLATFORM", "drm",1);
m_vtHandler = new QKmsVTHandler;
m_deviceDiscovery = QDeviceDiscovery::create(QDeviceDiscovery::Device_DRM, 0);
m_deviceDiscovery = QDeviceDiscovery::create(QDeviceDiscovery::Device_DRM | QDeviceDiscovery::Device_DRM_PrimaryGPU, 0);
if (m_deviceDiscovery) {
QStringList devices = m_deviceDiscovery->scanConnectedDevices();
foreach (QString device, devices)