eglfs: Add physicalWidth and height overrides to KMS config

Task-number: QTBUG-55188
Change-Id: I751b8c3c4b6f7a33b08ec23fd16cd025a5792ba6
Reviewed-by: Dominik Holland <dominik.holland@pelagicore.com>
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
This commit is contained in:
Laszlo Agocs 2016-08-08 16:54:52 +02:00
parent b305702d1e
commit 7de7f981dc
2 changed files with 20 additions and 10 deletions

View File

@ -159,7 +159,7 @@ static bool parseModeline(const QByteArray &text, drmModeModeInfoPtr mode)
return true; return true;
} }
QEglFSKmsScreen *QEglFSKmsDevice::screenForConnector(drmModeResPtr resources, drmModeConnectorPtr connector, QPoint pos) QEglFSKmsScreen *QEglFSKmsDevice::createScreenForConnector(drmModeResPtr resources, drmModeConnectorPtr connector, QPoint pos)
{ {
const QByteArray connectorName = nameForConnector(connector); const QByteArray connectorName = nameForConnector(connector);
@ -173,8 +173,11 @@ QEglFSKmsScreen *QEglFSKmsDevice::screenForConnector(drmModeResPtr resources, dr
QSize configurationSize; QSize configurationSize;
drmModeModeInfo configurationModeline; drmModeModeInfo configurationModeline;
const QByteArray mode = m_integration->outputSettings().value(QString::fromUtf8(connectorName)) auto userConfig = m_integration->outputSettings();
.value(QStringLiteral("mode"), QStringLiteral("preferred")).toByteArray().toLower(); auto userConnectorConfig = userConfig.value(QString::fromUtf8(connectorName));
// default to the preferred mode unless overridden in the config
const QByteArray mode = userConnectorConfig.value(QStringLiteral("mode"), QStringLiteral("preferred"))
.toByteArray().toLower();
if (mode == "off") { if (mode == "off") {
configuration = OutputConfigOff; configuration = OutputConfigOff;
} else if (mode == "preferred") { } else if (mode == "preferred") {
@ -287,18 +290,25 @@ QEglFSKmsScreen *QEglFSKmsDevice::screenForConnector(drmModeResPtr resources, dr
qCDebug(qLcEglfsKmsDebug) << "Selected mode" << selected_mode << ":" << width << "x" << height qCDebug(qLcEglfsKmsDebug) << "Selected mode" << selected_mode << ":" << width << "x" << height
<< '@' << refresh << "hz for output" << connectorName; << '@' << refresh << "hz for output" << connectorName;
} }
// physical size from connector < config values < env vars
static const int width = qEnvironmentVariableIntValue("QT_QPA_EGLFS_PHYSICAL_WIDTH"); static const int width = qEnvironmentVariableIntValue("QT_QPA_EGLFS_PHYSICAL_WIDTH");
static const int height = qEnvironmentVariableIntValue("QT_QPA_EGLFS_PHYSICAL_HEIGHT"); static const int height = qEnvironmentVariableIntValue("QT_QPA_EGLFS_PHYSICAL_HEIGHT");
QSizeF size(width, height); QSizeF physSize(width, height);
if (size.isEmpty()) { if (physSize.isEmpty()) {
size.setWidth(connector->mmWidth); physSize = QSize(userConnectorConfig.value(QStringLiteral("physicalWidth")).toInt(),
size.setHeight(connector->mmHeight); userConnectorConfig.value(QStringLiteral("physicalHeight")).toInt());
if (physSize.isEmpty()) {
physSize.setWidth(connector->mmWidth);
physSize.setHeight(connector->mmHeight);
} }
}
QEglFSKmsOutput output = { QEglFSKmsOutput output = {
QString::fromUtf8(connectorName), QString::fromUtf8(connectorName),
connector->connector_id, connector->connector_id,
crtc_id, crtc_id,
size, physSize,
selected_mode, selected_mode,
false, false,
drmModeGetCrtc(m_dri_fd, crtc_id), drmModeGetCrtc(m_dri_fd, crtc_id),
@ -360,7 +370,7 @@ void QEglFSKmsDevice::createScreens()
if (!connector) if (!connector)
continue; continue;
QEglFSKmsScreen *screen = screenForConnector(resources, connector, pos); QEglFSKmsScreen *screen = createScreenForConnector(resources, connector, pos);
if (screen) { if (screen) {
integration->addScreen(screen); integration->addScreen(screen);
pos.rx() += screen->geometry().width(); pos.rx() += screen->geometry().width();

View File

@ -80,7 +80,7 @@ protected:
quint32 m_connector_allocator; quint32 m_connector_allocator;
int crtcForConnector(drmModeResPtr resources, drmModeConnectorPtr connector); int crtcForConnector(drmModeResPtr resources, drmModeConnectorPtr connector);
QEglFSKmsScreen *screenForConnector(drmModeResPtr resources, drmModeConnectorPtr connector, QPoint pos); QEglFSKmsScreen *createScreenForConnector(drmModeResPtr resources, drmModeConnectorPtr connector, QPoint pos);
drmModePropertyPtr connectorProperty(drmModeConnectorPtr connector, const QByteArray &name); drmModePropertyPtr connectorProperty(drmModeConnectorPtr connector, const QByteArray &name);
static void pageFlipHandler(int fd, static void pageFlipHandler(int fd,