[mutter] monitor-manager-kms: Disable CRTCs if there is no monitor



commit e5b07138f0c8af6ecf5588fafbb61ab97910c379
Author: Kai-Heng Feng <kai heng feng canonical com>
Date:   Mon Dec 21 14:59:32 2020 +0800

    monitor-manager-kms: Disable CRTCs if there is no monitor
    
    After last monitor gets unplugged from the system, hotplug detection may
    no longer work on Intel GFX.
    
    This is because we didn't trigger a modeset to disable CRTCs, and i915
    requires it to make hotplug detection continue to work [1].
    
    Ensure disabled CRTCs are unset and post a modeset to disable them.
    
    [1] https://www.kernel.org/doc/html/latest/gpu/i915.html#hotplug
    
    https://gitlab.freedesktop.org/drm/intel/-/issues/2602
    
    Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1561>

 src/backends/native/meta-monitor-manager-kms.c |  8 ++++++++
 src/backends/native/meta-renderer-native.c     | 15 +++++++++++++++
 src/backends/native/meta-renderer-native.h     |  2 ++
 3 files changed, 25 insertions(+)
---
diff --git a/src/backends/native/meta-monitor-manager-kms.c b/src/backends/native/meta-monitor-manager-kms.c
index cc3c2dc4dc..5f953f1cc9 100644
--- a/src/backends/native/meta-monitor-manager-kms.c
+++ b/src/backends/native/meta-monitor-manager-kms.c
@@ -281,6 +281,14 @@ meta_monitor_manager_kms_apply_monitors_config (MetaMonitorManager      *manager
 
   if (!config)
     {
+      if (!manager->in_init)
+        {
+          MetaBackend *backend = meta_get_backend ();
+          MetaRenderer *renderer = meta_backend_get_renderer (backend);
+
+          meta_renderer_native_reset_modes (META_RENDERER_NATIVE (renderer));
+        }
+
       manager->screen_width = META_MONITOR_MANAGER_MIN_SCREEN_WIDTH;
       manager->screen_height = META_MONITOR_MANAGER_MIN_SCREEN_HEIGHT;
       meta_monitor_manager_rebuild (manager, NULL);
diff --git a/src/backends/native/meta-renderer-native.c b/src/backends/native/meta-renderer-native.c
index 91f213ad85..2de461bc59 100644
--- a/src/backends/native/meta-renderer-native.c
+++ b/src/backends/native/meta-renderer-native.c
@@ -3744,6 +3744,21 @@ on_power_save_mode_changed (MetaMonitorManager *monitor_manager,
     meta_kms_discard_pending_page_flips (kms);
 }
 
+void
+meta_renderer_native_reset_modes (MetaRendererNative *renderer_native)
+{
+  MetaRenderer *renderer = META_RENDERER (renderer_native);
+  MetaBackend *backend = meta_renderer_get_backend (renderer);
+  MetaBackendNative *backend_native = META_BACKEND_NATIVE (backend);
+  MetaKms *kms = meta_backend_native_get_kms (backend_native);
+  MetaKmsUpdate *kms_update;
+
+  kms_update = unset_disabled_crtcs (backend, kms);
+
+  if (kms_update)
+    post_pending_update (kms);
+}
+
 static MetaGpuKms *
 choose_primary_gpu_unchecked (MetaBackend        *backend,
                               MetaRendererNative *renderer_native)
diff --git a/src/backends/native/meta-renderer-native.h b/src/backends/native/meta-renderer-native.h
index c0357a7d86..466d8d3a6a 100644
--- a/src/backends/native/meta-renderer-native.h
+++ b/src/backends/native/meta-renderer-native.h
@@ -55,6 +55,8 @@ MetaGpuKms * meta_renderer_native_get_primary_gpu (MetaRendererNative *renderer_
 
 void meta_renderer_native_finish_frame (MetaRendererNative *renderer_native);
 
+void meta_renderer_native_reset_modes (MetaRendererNative *renderer_native);
+
 gboolean meta_renderer_native_use_modifiers (MetaRendererNative *renderer_native);
 
 gboolean meta_onscreen_native_is_buffer_scanout_compatible (CoglOnscreen *onscreen,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]