From 9f030ecd40c4d519d3cc6f349c27c17b4ff5d5fd Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Wed, 28 Apr 2021 23:18:28 +0300 Subject: [PATCH] platforms/drm: Enable atomic modesetting in hot plugged gpus At the moment, if a gpu is hot plugged, it won't have atomic modesetting enabled. --- src/plugins/platforms/drm/drm_backend.cpp | 6 ------ src/plugins/platforms/drm/drm_gpu.cpp | 6 ++++++ src/plugins/platforms/drm/drm_gpu.h | 3 +-- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/plugins/platforms/drm/drm_backend.cpp b/src/plugins/platforms/drm/drm_backend.cpp index 321171365e..d3fde7fa8e 100644 --- a/src/plugins/platforms/drm/drm_backend.cpp +++ b/src/plugins/platforms/drm/drm_backend.cpp @@ -202,12 +202,6 @@ bool DrmBackend::initialize() addGpu(std::move(devices.at(gpu_index))); } - // trying to activate Atomic Mode Setting (this means also Universal Planes) - if (!qEnvironmentVariableIsSet("KWIN_DRM_NO_AMS")) { - for (auto gpu : m_gpus) - gpu->tryAMS(); - } - initCursor(); if (!updateOutputs()) return false; diff --git a/src/plugins/platforms/drm/drm_gpu.cpp b/src/plugins/platforms/drm/drm_gpu.cpp index a180ff194a..2f491d014d 100644 --- a/src/plugins/platforms/drm/drm_gpu.cpp +++ b/src/plugins/platforms/drm/drm_gpu.cpp @@ -76,6 +76,12 @@ DrmGpu::DrmGpu(DrmBackend *backend, QByteArray devNode, int fd, dev_t deviceId) m_socketNotifier = new QSocketNotifier(fd, QSocketNotifier::Read, this); connect(m_socketNotifier, &QSocketNotifier::activated, this, &DrmGpu::dispatchEvents); + + // trying to activate Atomic Mode Setting (this means also Universal Planes) + static const bool atomicModesetting = !qEnvironmentVariableIsSet("KWIN_DRM_NO_AMS"); + if (atomicModesetting) { + tryAMS(); + } } DrmGpu::~DrmGpu() diff --git a/src/plugins/platforms/drm/drm_gpu.h b/src/plugins/platforms/drm/drm_gpu.h index 5c9efa5e9e..0dfabdbff5 100644 --- a/src/plugins/platforms/drm/drm_gpu.h +++ b/src/plugins/platforms/drm/drm_gpu.h @@ -105,9 +105,7 @@ Q_SIGNALS: void outputDisabled(DrmOutput *output); protected: - friend class DrmBackend; - void tryAMS(); bool updateOutputs(); private: @@ -115,6 +113,7 @@ private: DrmPlane *getCompatiblePlane(DrmPlane::TypeIndex typeIndex, DrmCrtc *crtc); DrmOutput *findOutput(quint32 connector); void removeOutput(DrmOutput *output); + void tryAMS(); DrmBackend* const m_backend; AbstractEglBackend *m_eglBackend;