From 92730445675d4cd71bf5589bd9add8da121de6d4 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Thu, 7 Sep 2017 17:44:59 +0200 Subject: kms: Fix crtc allocation logic The intention of choosing a different CRTC for each connector is fine, but the code is flawed: the bitmask thas marks used crtc must be based on the crtc index, not the id. In practice the fix makes a difference only when multiple connectors are in use and there are crtc ids above 31. Task-number: QTBUG-63058 Change-Id: I74e01add72df9c6e0b8fbddab978c102573a282c Reviewed-by: Andy Nichols --- src/platformsupport/kmsconvenience/qkmsdevice.cpp | 8 +++++--- src/platformsupport/kmsconvenience/qkmsdevice_p.h | 1 + 2 files changed, 6 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/platformsupport/kmsconvenience/qkmsdevice.cpp b/src/platformsupport/kmsconvenience/qkmsdevice.cpp index 494640b858..e1f2459bc0 100644 --- a/src/platformsupport/kmsconvenience/qkmsdevice.cpp +++ b/src/platformsupport/kmsconvenience/qkmsdevice.cpp @@ -75,7 +75,7 @@ int QKmsDevice::crtcForConnector(drmModeResPtr resources, drmModeConnectorPtr co for (int j = 0; j < resources->count_crtcs; j++) { bool isPossible = possibleCrtcs & (1 << j); - bool isAvailable = !(m_crtc_allocator & 1 << resources->crtcs[j]); + bool isAvailable = !(m_crtc_allocator & (1 << j)); if (isPossible && isAvailable) return j; @@ -245,7 +245,8 @@ QPlatformScreen *QKmsDevice::createScreenForConnector(drmModeResPtr resources, QList modes; modes.reserve(connector->count_modes); - qCDebug(qLcKmsDebug) << connectorName << "mode count:" << connector->count_modes; + qCDebug(qLcKmsDebug) << connectorName << "mode count:" << connector->count_modes + << "crtc index:" << crtc << "crtc id:" << crtc_id; for (int i = 0; i < connector->count_modes; i++) { const drmModeModeInfo &mode = connector->modes[i]; qCDebug(qLcKmsDebug) << "mode" << i << mode.hdisplay << "x" << mode.vdisplay @@ -366,6 +367,7 @@ QPlatformScreen *QKmsDevice::createScreenForConnector(drmModeResPtr resources, QKmsOutput output; output.name = QString::fromUtf8(connectorName); output.connector_id = connector->connector_id; + output.crtc_index = crtc; output.crtc_id = crtc_id; output.physical_size = physSize; output.preferred_mode = preferred >= 0 ? preferred : selected_mode; @@ -402,7 +404,7 @@ QPlatformScreen *QKmsDevice::createScreenForConnector(drmModeResPtr resources, } } - m_crtc_allocator |= (1 << output.crtc_id); + m_crtc_allocator |= (1 << output.crtc_index); vinfo->output = output; diff --git a/src/platformsupport/kmsconvenience/qkmsdevice_p.h b/src/platformsupport/kmsconvenience/qkmsdevice_p.h index b253cced3c..872104e49d 100644 --- a/src/platformsupport/kmsconvenience/qkmsdevice_p.h +++ b/src/platformsupport/kmsconvenience/qkmsdevice_p.h @@ -103,6 +103,7 @@ struct QKmsOutput { QString name; uint32_t connector_id = 0; + uint32_t crtc_index = 0; uint32_t crtc_id = 0; QSizeF physical_size; int preferred_mode = -1; // index of preferred mode in list below -- cgit v1.2.3