kms: Add support for filtering based on vrefresh

In addition to "mode": "1280x720", one can now also specify the vrefresh
value: "mode": "1280x720@50".

This way if there is both a 60 and 50 Hz variant, then it is now possible
to choose the 50 Hz one.

Task-number: QTBUG-62262
Change-Id: I9ca21c5a513621c83f2f5348c411d8d7c5492b3d
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
This commit is contained in:
Laszlo Agocs 2017-08-03 12:14:41 +02:00
parent bca297030c
commit 372f5e1fae

View File

@ -174,6 +174,7 @@ QPlatformScreen *QKmsDevice::createScreenForConnector(drmModeResPtr resources,
OutputConfiguration configuration;
QSize configurationSize;
int configurationRefresh = 0;
drmModeModeInfo configurationModeline;
auto userConfig = m_screenConfig->outputSettings();
@ -187,6 +188,10 @@ QPlatformScreen *QKmsDevice::createScreenForConnector(drmModeResPtr resources,
configuration = OutputConfigPreferred;
} else if (mode == "current") {
configuration = OutputConfigCurrent;
} else if (sscanf(mode.constData(), "%dx%d@%d", &configurationSize.rwidth(), &configurationSize.rheight(),
&configurationRefresh) == 3)
{
configuration = OutputConfigMode;
} else if (sscanf(mode.constData(), "%dx%d", &configurationSize.rwidth(), &configurationSize.rheight()) == 2) {
configuration = OutputConfigMode;
} else if (parseModeline(mode, &configurationModeline)) {
@ -256,9 +261,11 @@ QPlatformScreen *QKmsDevice::createScreenForConnector(drmModeResPtr resources,
for (int i = modes.size() - 1; i >= 0; i--) {
const drmModeModeInfo &m = modes.at(i);
if (configuration == OutputConfigMode &&
m.hdisplay == configurationSize.width() &&
m.vdisplay == configurationSize.height()) {
if (configuration == OutputConfigMode
&& m.hdisplay == configurationSize.width()
&& m.vdisplay == configurationSize.height()
&& (!configurationRefresh || m.vrefresh == uint32_t(configurationRefresh)))
{
configured = i;
}