Commit 58976057 authored by Xaver Hugl's avatar Xaver Hugl
Browse files

backends/drm: fix overscan

Somehow its use got lost in the 5.24 development cycle

(cherry picked from commit 7faa2587)
parent c7988e8c
Pipeline #139237 passed with stage
in 24 minutes and 2 seconds
......@@ -266,24 +266,6 @@ uint32_t DrmConnector::overscan() const
return 0;
}
void DrmConnector::setOverscan(uint32_t overscan, const QSize &modeSize)
{
if (auto prop = m_props[static_cast<uint32_t>(PropertyIndex::Overscan)]) {
prop->setPending(overscan);
} else if (auto prop = m_props[static_cast<uint32_t>(PropertyIndex::Underscan)]) {
float aspectRatio = modeSize.width() / static_cast<float>(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)) {
......
......@@ -106,7 +106,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;
......
......@@ -233,6 +233,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() ? mode->blobId() : 0);
......@@ -244,6 +252,20 @@ void DrmPipeline::prepareAtomicModeset()
}
}
uint32_t DrmPipeline::calculateUnderscan()
{
const auto modes = m_connector->modes();
const auto size = modes[pending.modeIndex]->size();
const float aspectRatio = size.width() / static_cast<float>(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) {
......
......@@ -126,6 +126,7 @@ private:
bool checkTestBuffer();
bool activePending() const;
bool isCursorVisible() const;
uint32_t calculateUnderscan();
// legacy only
bool presentLegacy();
......
......@@ -95,6 +95,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;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment