KMS QPA Plugin: use preferred mode when selecting mode

This should select the best mode (likely the currently running mode)
for the display instead of the first one found.

The built-in mode was left as a fallback.

Change-Id: I4e1bc798df6f310b001566ab76cb9def3224a7ed
Reviewed-by: Andy Nichols <andy.nichols@digia.com>
This commit is contained in:
anknight 2013-02-14 14:52:58 +02:00 committed by The Qt Project
parent 936aceb5f2
commit f8fdeb68b6

View File

@ -124,10 +124,14 @@ void QKmsScreen::initializeScreenMode()
drmModeConnector *connector = drmModeGetConnector(m_device->fd(), m_connectorId);
drmModeModeInfo *mode = 0;
if (connector->count_modes > 0)
mode = &connector->modes[0];
else
mode = &builtin_1024x768;
for (int i = 0; i < connector->count_modes; ++i) {
if (connector->modes[i].type & DRM_MODE_TYPE_PREFERRED) {
mode = &connector->modes[i];
break;
}
}
if (!mode)
mode = mode = &builtin_1024x768;
drmModeEncoder *encoder = drmModeGetEncoder(m_device->fd(), connector->encoders[0]);
if (encoder == 0)