diff --git a/src/backends/native/meta-crtc-kms.c b/src/backends/native/meta-crtc-kms.c index 59570e60b..3a72c46d1 100644 --- a/src/backends/native/meta-crtc-kms.c +++ b/src/backends/native/meta-crtc-kms.c @@ -33,6 +33,7 @@ #include "backends/native/meta-kms-mode.h" #include "backends/native/meta-kms-plane.h" #include "backends/native/meta-kms-update.h" +#include "backends/native/meta-monitor-manager-kms.h" #define ALL_TRANSFORMS_MASK ((1 << META_MONITOR_N_TRANSFORMS) - 1) @@ -190,11 +191,30 @@ meta_crtc_kms_set_mode (MetaCrtcKms *crtc_kms, { const MetaCrtcConfig *crtc_config = meta_crtc_get_config (crtc); MetaCrtcModeKms *crtc_mode_kms = META_CRTC_MODE_KMS (crtc_config->mode); + MetaBackend *backend = meta_gpu_get_backend (gpu); + MetaMonitorManager *monitor_manager = + meta_backend_get_monitor_manager (backend); + MetaPowerSave power_save; + uint64_t dpms_state; + GList *l; kms_mode = meta_crtc_mode_kms_get_kms_mode (crtc_mode_kms); g_debug ("Setting CRTC (%" G_GUINT64_FORMAT ") mode to %s", meta_crtc_get_id (crtc), meta_kms_mode_get_name (kms_mode)); + + power_save = meta_monitor_manager_get_power_save_mode (monitor_manager); + g_warn_if_fail (power_save == META_POWER_SAVE_ON); + + dpms_state = meta_power_save_to_dpms_state (power_save); + for (l = connectors; l; l = l->next) + { + MetaKmsConnector *kms_connector = l->data; + + meta_kms_update_set_dpms_state (kms_update, + kms_connector, + dpms_state); + } } else { diff --git a/src/backends/native/meta-gpu-kms.c b/src/backends/native/meta-gpu-kms.c index dbf76abed..3df26ff3e 100644 --- a/src/backends/native/meta-gpu-kms.c +++ b/src/backends/native/meta-gpu-kms.c @@ -151,6 +151,8 @@ meta_gpu_kms_set_power_save_mode (MetaGpuKms *gpu_kms, MetaGpu *gpu = META_GPU (gpu_kms); GList *l; + g_return_if_fail (state != DRM_MODE_DPMS_ON); + for (l = meta_gpu_get_outputs (gpu); l; l = l->next) { MetaOutput *output = l->data; @@ -159,17 +161,14 @@ meta_gpu_kms_set_power_save_mode (MetaGpuKms *gpu_kms, state, kms_update); } - if (state != META_POWER_SAVE_ON) + /* Turn off CRTCs for DPMS */ + for (l = meta_gpu_get_crtcs (gpu); l; l = l->next) { - /* Turn off CRTCs for DPMS */ - for (l = meta_gpu_get_crtcs (gpu); l; l = l->next) - { - MetaCrtcKms *crtc_kms = META_CRTC_KMS (l->data); + MetaCrtcKms *crtc_kms = META_CRTC_KMS (l->data); - meta_kms_update_mode_set (kms_update, - meta_crtc_kms_get_kms_crtc (crtc_kms), - NULL, NULL); - } + meta_kms_update_mode_set (kms_update, + meta_crtc_kms_get_kms_crtc (crtc_kms), + NULL, NULL); } } diff --git a/src/backends/native/meta-monitor-manager-kms.c b/src/backends/native/meta-monitor-manager-kms.c index f3881862f..19b3faaf0 100644 --- a/src/backends/native/meta-monitor-manager-kms.c +++ b/src/backends/native/meta-monitor-manager-kms.c @@ -113,6 +113,27 @@ meta_monitor_manager_kms_read_current_state (MetaMonitorManager *manager) parent_class->read_current_state (manager); } +uint64_t +meta_power_save_to_dpms_state (MetaPowerSave power_save) +{ + switch (power_save) + { + case META_POWER_SAVE_ON: + return DRM_MODE_DPMS_ON; + case META_POWER_SAVE_STANDBY: + return DRM_MODE_DPMS_STANDBY; + case META_POWER_SAVE_SUSPEND: + return DRM_MODE_DPMS_SUSPEND; + case META_POWER_SAVE_OFF: + return DRM_MODE_DPMS_OFF; + case META_POWER_SAVE_UNSUPPORTED: + return DRM_MODE_DPMS_ON; + } + + g_warn_if_reached (); + return DRM_MODE_DPMS_ON; +} + static void meta_monitor_manager_kms_set_power_save_mode (MetaMonitorManager *manager, MetaPowerSave mode) @@ -123,22 +144,19 @@ meta_monitor_manager_kms_set_power_save_mode (MetaMonitorManager *manager, uint64_t state; GList *l; - switch (mode) { - case META_POWER_SAVE_ON: - state = DRM_MODE_DPMS_ON; - break; - case META_POWER_SAVE_STANDBY: - state = DRM_MODE_DPMS_STANDBY; - break; - case META_POWER_SAVE_SUSPEND: - state = DRM_MODE_DPMS_SUSPEND; - break; - case META_POWER_SAVE_OFF: - state = DRM_MODE_DPMS_OFF; - break; - default: - return; - } + switch (mode) + { + case META_POWER_SAVE_ON: + case META_POWER_SAVE_UNSUPPORTED: + /* This will be handled on mode set. */ + return; + case META_POWER_SAVE_STANDBY: + case META_POWER_SAVE_SUSPEND: + case META_POWER_SAVE_OFF: + break; + } + + state = meta_power_save_to_dpms_state (mode); for (l = meta_backend_get_gpus (backend); l; l = l->next) { diff --git a/src/backends/native/meta-monitor-manager-kms.h b/src/backends/native/meta-monitor-manager-kms.h index b7287bc9a..84499397c 100644 --- a/src/backends/native/meta-monitor-manager-kms.h +++ b/src/backends/native/meta-monitor-manager-kms.h @@ -39,4 +39,6 @@ void meta_monitor_manager_kms_pause (MetaMonitorManagerKms *manager_kms); void meta_monitor_manager_kms_resume (MetaMonitorManagerKms *manager_kms); +uint64_t meta_power_save_to_dpms_state (MetaPowerSave power_save); + #endif /* META_MONITOR_MANAGER_KMS_H */