From 97f8bfac5c21e730a381a63d371c159eabc45daf Mon Sep 17 00:00:00 2001 From: Xaver Hugl Date: Fri, 16 Jul 2021 17:17:19 +0200 Subject: [PATCH] platforms/drm: where necessary, disconnect CRTCs after VT switch --- src/plugins/platforms/drm/drm_backend.cpp | 6 ++++++ src/plugins/platforms/drm/drm_pipeline.cpp | 10 ++++++++++ src/plugins/platforms/drm/drm_pipeline.h | 6 ++++++ 3 files changed, 22 insertions(+) diff --git a/src/plugins/platforms/drm/drm_backend.cpp b/src/plugins/platforms/drm/drm_backend.cpp index bf77a5cfa2..b37e973477 100644 --- a/src/plugins/platforms/drm/drm_backend.cpp +++ b/src/plugins/platforms/drm/drm_backend.cpp @@ -144,12 +144,18 @@ void DrmBackend::reactivate() for (const auto &output : qAsConst(m_outputs)) { output->pipeline()->updateProperties(); if (output->isEnabled()) { + if (output->gpu()->atomicModeSetting() && !output->pipeline()->isConnected()) { + output->pipeline()->setActive(false); + } output->renderLoop()->uninhibit(); output->showCursor(); } else { output->pipeline()->setActive(false); } } + for (const auto &output : qAsConst(m_outputs)) { + output->pipeline()->setActive(output->isEnabled()); + } if (Compositor *compositor = Compositor::self()) { compositor->addRepaintFull(); diff --git a/src/plugins/platforms/drm/drm_pipeline.cpp b/src/plugins/platforms/drm/drm_pipeline.cpp index 5ce6f9f04b..45903b9c42 100644 --- a/src/plugins/platforms/drm/drm_pipeline.cpp +++ b/src/plugins/platforms/drm/drm_pipeline.cpp @@ -530,6 +530,16 @@ void DrmPipeline::updateProperties() m_cursor.dirty = true; } +bool DrmPipeline::isConnected() const +{ + if (m_primaryPlane) { + return m_connector->getProp(DrmConnector::PropertyIndex::CrtcId)->current() == m_crtc->id() + && m_primaryPlane->getProp(DrmPlane::PropertyIndex::CrtcId)->current() == m_crtc->id(); + } else { + return false; + } +} + static void printProps(DrmObject *object) { auto list = object->properties(); diff --git a/src/plugins/platforms/drm/drm_pipeline.h b/src/plugins/platforms/drm/drm_pipeline.h index 03bcdd4f26..d49695a561 100644 --- a/src/plugins/platforms/drm/drm_pipeline.h +++ b/src/plugins/platforms/drm/drm_pipeline.h @@ -35,6 +35,12 @@ public: DrmPipeline(DrmGpu *gpu, DrmConnector *conn, DrmCrtc *crtc, DrmPlane *primaryPlane); ~DrmPipeline(); + /** + * checks if the connector(s) and plane(s) are set to the CRTC(s) + * always returns false in legacy mode + */ + bool isConnected() const; + /** * tests the pending commit first and commits it if the test passes * if the test fails, there is a guarantee for no lasting changes