From 099a1cc31f3d7eff8c7631ec45ddbf260747f68a Mon Sep 17 00:00:00 2001 From: Xaver Hugl Date: Tue, 16 Jul 2024 23:10:16 +0200 Subject: [PATCH] backends/drm: limit max_bpc to 8 by default with docks There's generally a lot of problems with higher than 8bpc in docking stations, especially when multiple monitors are involved. Until these problems are hopefully eventually fixed on the driver side, limit the bpc to 8 with docks by default --- src/backends/drm/drm_pipeline.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/backends/drm/drm_pipeline.cpp b/src/backends/drm/drm_pipeline.cpp index 34704d1fae..8016069fd3 100644 --- a/src/backends/drm/drm_pipeline.cpp +++ b/src/backends/drm/drm_pipeline.cpp @@ -314,7 +314,13 @@ bool DrmPipeline::prepareAtomicModeset(DrmAtomicCommit *commit) // TODO migrate this env var to a proper setting static bool ok = false; static const int preferred = qEnvironmentVariableIntValue("KWIN_DRM_PREFER_COLOR_DEPTH", &ok); - commit->addProperty(m_connector->maxBpc, ok && preferred == 24 ? 8 : 10); + // docks very often have problems with higher than 8 bits per color + // see https://gitlab.freedesktop.org/drm/amd/-/issues/2598 for example + uint32_t bpc = m_connector->mstPath().isEmpty() ? 10 : 8; + if (ok) { + bpc = preferred / 3; + } + commit->addProperty(m_connector->maxBpc, std::clamp(bpc, m_connector->maxBpc.minValue(), m_connector->maxBpc.maxValue())); } if (m_connector->hdrMetadata.isValid()) { commit->addBlob(m_connector->hdrMetadata, createHdrMetadata(m_pending.colorDescription.transferFunction()));