From a4e1afc648c1122ead99265ac352cc909e3d17c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Mon, 9 Oct 2023 16:11:05 +0800 Subject: [PATCH] renderer/native: Fold mode unsetting into renamed unset_modes() We had a function called "reset_modes()" on MetaRendererNative, but what it expected to do was to unset all modes on all CRTCs. Despite this, it had code to unset modes on unconfigured CRTCs, probably because it was used for multiple things in the past. Make this a bit easier to follow by renaming the function "unset_modes()" and fold the function doing the unsetting into the function itself. Part-of: --- .../native/meta-monitor-manager-native.c | 2 +- src/backends/native/meta-renderer-native.c | 63 +++++++++---------- src/backends/native/meta-renderer-native.h | 2 +- 3 files changed, 30 insertions(+), 37 deletions(-) diff --git a/src/backends/native/meta-monitor-manager-native.c b/src/backends/native/meta-monitor-manager-native.c index 8a4d907ae..48c5dac78 100644 --- a/src/backends/native/meta-monitor-manager-native.c +++ b/src/backends/native/meta-monitor-manager-native.c @@ -291,7 +291,7 @@ meta_monitor_manager_native_apply_monitors_config (MetaMonitorManager *ma MetaBackend *backend = meta_monitor_manager_get_backend (manager); MetaRenderer *renderer = meta_backend_get_renderer (backend); - meta_renderer_native_reset_modes (META_RENDERER_NATIVE (renderer)); + meta_renderer_native_unset_modes (META_RENDERER_NATIVE (renderer)); } manager->screen_width = META_MONITOR_MANAGER_MIN_SCREEN_WIDTH; diff --git a/src/backends/native/meta-renderer-native.c b/src/backends/native/meta-renderer-native.c index 57cb20b7e..5acff95fc 100644 --- a/src/backends/native/meta-renderer-native.c +++ b/src/backends/native/meta-renderer-native.c @@ -897,39 +897,6 @@ meta_renderer_native_queue_mode_set_update (MetaRendererNative *renderer_native, meta_kms_update_free (new_kms_update); } -static void -unset_disabled_crtcs (MetaRendererNative *renderer_native) -{ - MetaRenderer *renderer = META_RENDERER (renderer_native); - MetaBackend *backend = meta_renderer_get_backend (renderer); - GList *l; - - meta_topic (META_DEBUG_KMS, "Disabling all disabled CRTCs"); - - for (l = meta_backend_get_gpus (backend); l; l = l->next) - { - MetaGpu *gpu = l->data; - MetaKmsDevice *kms_device = - meta_gpu_kms_get_kms_device (META_GPU_KMS (gpu)); - GList *k; - g_autoptr (MetaKmsFeedback) kms_feedback = NULL; - MetaKmsUpdate *kms_update = NULL; - - for (k = meta_gpu_get_crtcs (gpu); k; k = k->next) - { - MetaCrtc *crtc = k->data; - - if (meta_crtc_get_config (crtc)) - continue; - - kms_update = ensure_mode_set_update (renderer_native, kms_device); - meta_crtc_kms_set_mode (META_CRTC_KMS (crtc), kms_update); - } - } - - post_mode_set_updates (renderer_native); -} - static CoglDmaBufHandle * meta_renderer_native_create_dma_buf (CoglRenderer *cogl_renderer, CoglPixelFormat format, @@ -2032,9 +1999,35 @@ on_power_save_mode_changed (MetaMonitorManager *monitor_manager, } void -meta_renderer_native_reset_modes (MetaRendererNative *renderer_native) +meta_renderer_native_unset_modes (MetaRendererNative *renderer_native) { - unset_disabled_crtcs (renderer_native); + MetaRenderer *renderer = META_RENDERER (renderer_native); + MetaBackend *backend = meta_renderer_get_backend (renderer); + GList *l; + + meta_topic (META_DEBUG_KMS, "Unsetting all CRTC modes"); + + for (l = meta_backend_get_gpus (backend); l; l = l->next) + { + MetaGpu *gpu = l->data; + MetaKmsDevice *kms_device = + meta_gpu_kms_get_kms_device (META_GPU_KMS (gpu)); + GList *k; + g_autoptr (MetaKmsFeedback) kms_feedback = NULL; + MetaKmsUpdate *kms_update = NULL; + + for (k = meta_gpu_get_crtcs (gpu); k; k = k->next) + { + MetaCrtc *crtc = k->data; + + g_warn_if_fail (!meta_crtc_get_config (crtc)); + + kms_update = ensure_mode_set_update (renderer_native, kms_device); + meta_crtc_kms_set_mode (META_CRTC_KMS (crtc), kms_update); + } + } + + post_mode_set_updates (renderer_native); } static MetaGpuKms * diff --git a/src/backends/native/meta-renderer-native.h b/src/backends/native/meta-renderer-native.h index c99d0514c..497b89869 100644 --- a/src/backends/native/meta-renderer-native.h +++ b/src/backends/native/meta-renderer-native.h @@ -66,7 +66,7 @@ void meta_renderer_native_finish_frame (MetaRendererNative *renderer_native, MetaRendererView *view, ClutterFrame *frame); -void meta_renderer_native_reset_modes (MetaRendererNative *renderer_native); +void meta_renderer_native_unset_modes (MetaRendererNative *renderer_native); gboolean meta_renderer_native_send_modifiers (MetaRendererNative *renderer_native);