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 <andy.nichols@qt.io>
bb10
Laszlo Agocs 2017-09-07 17:44:59 +02:00
parent d6c828c65a
commit 9273044567
2 changed files with 6 additions and 3 deletions

View File

@ -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<drmModeModeInfo> 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;

View File

@ -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