diff --git a/src/backends/drm/drm_object_connector.cpp b/src/backends/drm/drm_object_connector.cpp index ceb372d0e7..d7359c4f14 100644 --- a/src/backends/drm/drm_object_connector.cpp +++ b/src/backends/drm/drm_object_connector.cpp @@ -261,24 +261,6 @@ uint32_t DrmConnector::overscan() const return 0; } -void DrmConnector::setOverscan(uint32_t overscan, const QSize &modeSize) -{ - if (auto prop = m_props[static_cast(PropertyIndex::Overscan)]) { - prop->setPending(overscan); - } else if (auto prop = m_props[static_cast(PropertyIndex::Underscan)]) { - float aspectRatio = modeSize.width() / static_cast(modeSize.height()); - prop->setEnum(overscan > 0 ? UnderscanOptions::On : UnderscanOptions::Off); - uint32_t hborder = overscan * aspectRatio; - if (hborder > 128) { - hborder = 128; - overscan = 128 / aspectRatio; - } - // overscan only goes from 0-100 so we cut off the 101-128 value range of underscan_vborder - setPending(PropertyIndex::Underscan_vborder, overscan); - setPending(PropertyIndex::Underscan_hborder, hborder); - } -} - bool DrmConnector::vrrCapable() const { if (const auto &prop = getProp(PropertyIndex::VrrCapable)) { diff --git a/src/backends/drm/drm_object_connector.h b/src/backends/drm/drm_object_connector.h index 231efbfa8b..e7262d31de 100644 --- a/src/backends/drm/drm_object_connector.h +++ b/src/backends/drm/drm_object_connector.h @@ -105,7 +105,6 @@ public: AbstractWaylandOutput::SubPixel subpixel() const; bool hasOverscan() const; uint32_t overscan() const; - void setOverscan(uint32_t overscan, const QSize &modeSize); bool vrrCapable() const; bool hasRgbRange() const; AbstractWaylandOutput::RgbRange rgbRange() const; diff --git a/src/backends/drm/drm_pipeline.cpp b/src/backends/drm/drm_pipeline.cpp index 5495feceb0..115f424017 100644 --- a/src/backends/drm/drm_pipeline.cpp +++ b/src/backends/drm/drm_pipeline.cpp @@ -237,6 +237,14 @@ void DrmPipeline::prepareAtomicModeset() if (const auto &prop = m_connector->getProp(DrmConnector::PropertyIndex::LinkStatus)) { prop->setEnum(DrmConnector::LinkStatus::Good); } + if (const auto overscan = m_connector->getProp(DrmConnector::PropertyIndex::Overscan)) { + overscan->setPending(pending.overscan); + } else if (const auto underscan = m_connector->getProp(DrmConnector::PropertyIndex::Underscan)) { + const uint32_t hborder = calculateUnderscan(); + underscan->setEnum(pending.overscan != 0 ? DrmConnector::UnderscanOptions::On : DrmConnector::UnderscanOptions::Off); + m_connector->getProp(DrmConnector::PropertyIndex::Underscan_vborder)->setPending(pending.overscan); + m_connector->getProp(DrmConnector::PropertyIndex::Underscan_hborder)->setPending(hborder); + } pending.crtc->setPending(DrmCrtc::PropertyIndex::Active, activePending()); pending.crtc->setPending(DrmCrtc::PropertyIndex::ModeId, activePending() ? pending.mode->blobId() : 0); @@ -248,6 +256,19 @@ void DrmPipeline::prepareAtomicModeset() } } +uint32_t DrmPipeline::calculateUnderscan() +{ + const auto size = pending.mode->size(); + const float aspectRatio = size.width() / static_cast(size.height()); + uint32_t hborder = pending.overscan * aspectRatio; + if (hborder > 128) { + // overscan only goes from 0-100 so we cut off the 101-128 value range of underscan_vborder + hborder = 128; + pending.overscan = 128 / aspectRatio; + } + return hborder; +} + void DrmPipeline::atomicCommitFailed() { if (m_oldTestBuffer) { diff --git a/src/backends/drm/drm_pipeline.h b/src/backends/drm/drm_pipeline.h index 96240da59a..ecc30e8164 100644 --- a/src/backends/drm/drm_pipeline.h +++ b/src/backends/drm/drm_pipeline.h @@ -128,6 +128,7 @@ private: bool activePending() const; bool isCursorVisible() const; bool isBufferForDirectScanout() const; + uint32_t calculateUnderscan(); // legacy only bool presentLegacy(); diff --git a/src/backends/drm/drm_pipeline_legacy.cpp b/src/backends/drm/drm_pipeline_legacy.cpp index 200abaa79a..d77d13ca49 100644 --- a/src/backends/drm/drm_pipeline_legacy.cpp +++ b/src/backends/drm/drm_pipeline_legacy.cpp @@ -94,6 +94,14 @@ bool DrmPipeline::applyPendingChangesLegacy() if (const auto &rgbRange = m_connector->getProp(DrmConnector::PropertyIndex::Broadcast_RGB)) { rgbRange->setEnumLegacy(pending.rgbRange); } + if (const auto overscan = m_connector->getProp(DrmConnector::PropertyIndex::Overscan)) { + overscan->setPropertyLegacy(pending.overscan); + } else if (const auto underscan = m_connector->getProp(DrmConnector::PropertyIndex::Underscan)) { + const uint32_t hborder = calculateUnderscan(); + underscan->setEnumLegacy(pending.overscan != 0 ? DrmConnector::UnderscanOptions::On : DrmConnector::UnderscanOptions::Off); + m_connector->getProp(DrmConnector::PropertyIndex::Underscan_vborder)->setPropertyLegacy(pending.overscan); + m_connector->getProp(DrmConnector::PropertyIndex::Underscan_hborder)->setPropertyLegacy(hborder); + } if (needsModeset() &&!legacyModeset()) { return false; }