diff options
author | Lars Knoll <lars.knoll@qt.io> | 2019-08-06 12:24:37 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2019-08-07 12:50:28 +0200 |
commit | 05b90be3c5ce4709156178478abb2e7ba125a0be (patch) | |
tree | a7c39b76c99f4887dbc6837be3a41afc7fdb29b4 /src/platformsupport/kmsconvenience/qkmsdevice.cpp | |
parent | 7301e44161d8bb25410219a31405584c9492b83e (diff) | |
parent | 6f357f50b4b72e3c5a6903a09624ade1d72d12c1 (diff) |
Merge "Merge remote-tracking branch 'origin/dev' into wip/qt6"
Diffstat (limited to 'src/platformsupport/kmsconvenience/qkmsdevice.cpp')
-rw-r--r-- | src/platformsupport/kmsconvenience/qkmsdevice.cpp | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/src/platformsupport/kmsconvenience/qkmsdevice.cpp b/src/platformsupport/kmsconvenience/qkmsdevice.cpp index 8cc7a539b5..1ba32895f8 100644 --- a/src/platformsupport/kmsconvenience/qkmsdevice.cpp +++ b/src/platformsupport/kmsconvenience/qkmsdevice.cpp @@ -66,6 +66,8 @@ enum OutputConfiguration { int QKmsDevice::crtcForConnector(drmModeResPtr resources, drmModeConnectorPtr connector) { + int candidate = -1; + for (int i = 0; i < connector->count_encoders; i++) { drmModeEncoderPtr encoder = drmModeGetEncoder(m_dri_fd, connector->encoders[i]); if (!encoder) { @@ -73,19 +75,30 @@ int QKmsDevice::crtcForConnector(drmModeResPtr resources, drmModeConnectorPtr co continue; } + quint32 encoderId = encoder->encoder_id; + quint32 crtcId = encoder->crtc_id; quint32 possibleCrtcs = encoder->possible_crtcs; drmModeFreeEncoder(encoder); for (int j = 0; j < resources->count_crtcs; j++) { bool isPossible = possibleCrtcs & (1 << j); bool isAvailable = !(m_crtc_allocator & (1 << j)); - - if (isPossible && isAvailable) + // Preserve the existing CRTC -> encoder -> connector routing if + // any. It makes the initialization faster, and may be better + // since we have a very dumb picking algorithm. + bool isBestChoice = (!connector->encoder_id || + (connector->encoder_id == encoderId && + resources->crtcs[j] == crtcId)); + + if (isPossible && isAvailable && isBestChoice) { return j; + } else if (isPossible && isAvailable) { + candidate = j; + } } } - return -1; + return candidate; } static const char * const connector_type_names[] = { // must match DRM_MODE_CONNECTOR_* |