backends/drm: restrict common mode generation to drivers that support scaling

Also set the scaling mode property to "full aspect", which should reduce
the number of cases where the feature can cause issues
remotes/origin/work/zzag/deleted-minor-cleanups
Xaver Hugl 3 years ago
parent cf1d66ef59
commit 67dc0c5c48
  1. 9
      autotests/drm/drmTest.cpp
  2. 7
      src/backends/drm/drm_connector.cpp
  3. 7
      src/backends/drm/drm_connector.h
  4. 3
      src/backends/drm/drm_pipeline.cpp
  5. 3
      src/backends/drm/drm_pipeline_legacy.cpp

@ -266,6 +266,15 @@ void DrmTest::testModeGeneration()
conn->addMode(nativeMode.width(), nativeMode.height(), 60);
QVERIFY(gpu->updateOutputs());
QCOMPARE(gpu->drmOutputs().size(), 1);
// no mode generation without the scaling property
QCOMPARE(gpu->drmOutputs().front()->modes().size(), 1);
mockGpu->connectors.removeAll(conn);
QVERIFY(gpu->updateOutputs());
conn->props.emplace_back(conn.get(), QStringLiteral("scaling mode"), 0, 0, QVector<QByteArray>{"None", "Full", "Center", "Full aspect"});
mockGpu->connectors.push_back(conn);
QVERIFY(gpu->updateOutputs());
DrmOutput *const output = gpu->drmOutputs().front();
QCOMPARE(output->modes().size(), expectedModes.size());

@ -105,7 +105,8 @@ DrmConnector::DrmConnector(DrmGpu *gpu, uint32_t connectorId)
PropertyDefinition(QByteArrayLiteral("content type"), Requirement::Optional,
{QByteArrayLiteral("No Data"), QByteArrayLiteral("Graphics"), QByteArrayLiteral("Photo"), QByteArrayLiteral("Cinema"), QByteArrayLiteral("Game")}),
PropertyDefinition(QByteArrayLiteral("panel orientation"), Requirement::Optional, {QByteArrayLiteral("Normal"), QByteArrayLiteral("Upside Down"), QByteArrayLiteral("Left Side Up"), QByteArrayLiteral("Right Side Up")}),
PropertyDefinition(QByteArrayLiteral("HDR_OUTPUT_METADATA"), Requirement::Optional)},
PropertyDefinition(QByteArrayLiteral("HDR_OUTPUT_METADATA"), Requirement::Optional),
PropertyDefinition(QByteArrayLiteral("scaling mode"), Requirement::Optional, {QByteArrayLiteral("None"), QByteArrayLiteral("Full"), QByteArrayLiteral("Center"), QByteArrayLiteral("Full aspect")})},
DRM_MODE_OBJECT_CONNECTOR)
, m_pipeline(std::make_unique<DrmPipeline>(this))
, m_conn(drmModeGetConnector(gpu->fd(), connectorId))
@ -282,7 +283,9 @@ bool DrmConnector::updateProperties()
}
m_modes.clear();
m_modes.append(m_driverModes);
m_modes.append(generateCommonModes());
if (auto scaling = getProp(PropertyIndex::ScalingMode); scaling && scaling->hasEnum(ScalingMode::Full_Aspect)) {
m_modes.append(generateCommonModes());
}
if (m_pipeline->mode()) {
if (const auto mode = findMode(*m_pipeline->mode()->nativeMode())) {
m_pipeline->setMode(mode);

@ -67,6 +67,7 @@ public:
ContentType = 12,
PanelOrientation = 13,
HdrMetadata = 14,
ScalingMode = 15,
Count
};
@ -92,6 +93,12 @@ public:
LeftUp = 2,
RightUp = 3
};
enum class ScalingMode : uint32_t {
None = 0,
Full = 1,
Center = 2,
Full_Aspect = 3
};
bool init() override;
bool updateProperties() override;

@ -264,6 +264,9 @@ void DrmPipeline::prepareAtomicModeset(DrmAtomicCommit *commit)
if (const auto hdr = m_connector->getProp(DrmConnector::PropertyIndex::HdrMetadata)) {
commit->addProperty(hdr, 0);
}
if (const auto scaling = m_connector->getProp(DrmConnector::PropertyIndex::ScalingMode); scaling && scaling->hasEnum(DrmConnector::ScalingMode::Full_Aspect)) {
commit->addEnum(scaling, DrmConnector::ScalingMode::Full_Aspect);
}
commit->addProperty(m_pending.crtc->getProp(DrmCrtc::PropertyIndex::Active), 1);
commit->addBlob(m_pending.crtc->getProp(DrmCrtc::PropertyIndex::ModeId), m_pending.mode->blob());

@ -112,6 +112,9 @@ DrmPipeline::Error DrmPipeline::applyPendingChangesLegacy()
m_connector->getProp(DrmConnector::PropertyIndex::Underscan_vborder)->setPropertyLegacy(m_pending.overscan);
m_connector->getProp(DrmConnector::PropertyIndex::Underscan_hborder)->setPropertyLegacy(hborder);
}
if (const auto scaling = m_connector->getProp(DrmConnector::PropertyIndex::ScalingMode); scaling && scaling->hasEnum(DrmConnector::ScalingMode::Full_Aspect)) {
scaling->setEnumLegacy(DrmConnector::ScalingMode::Full_Aspect);
}
if (m_pending.crtc != m_current.crtc || m_pending.mode != m_current.mode) {
Error err = legacyModeset();
if (err != Error::None) {

Loading…
Cancel
Save