native: Invalidate CRTC gamma when resuming or leaving power save

With atomic mode setting, commits don't work when CRTCs aren't enabled,
which they aren't when we're power saving. This means the gamma state
fails to being update. To fix night light and for whatever other reason
gamma ramps was changed during power saving by marking the CRTC gamma
state as invalid when leaving power saving, as well as when resuming.
This means that the next frame will append the CRTC gamma state to the
KMS commit.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1755
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1835>
This commit is contained in:
Jonas Ådahl 2021-04-21 10:44:13 +02:00 committed by Marge Bot
parent a0af52caf0
commit c5e4d7db45
2 changed files with 55 additions and 27 deletions

View File

@ -153,21 +153,24 @@ meta_monitor_manager_native_set_power_save_mode (MetaMonitorManager *manager,
MetaKms *kms = meta_backend_native_get_kms (backend_native); MetaKms *kms = meta_backend_native_get_kms (backend_native);
GList *l; GList *l;
for (l = meta_backend_get_gpus (backend); l; l = l->next)
{
MetaGpuKms *gpu_kms = l->data;
switch (mode) switch (mode)
{ {
case META_POWER_SAVE_ON: case META_POWER_SAVE_ON:
case META_POWER_SAVE_UNSUPPORTED: case META_POWER_SAVE_UNSUPPORTED:
/* This will be handled on mode set. */ {
return; g_list_foreach (meta_gpu_get_crtcs (META_GPU (gpu_kms)),
(GFunc) meta_crtc_kms_invalidate_gamma,
NULL);
break;
}
case META_POWER_SAVE_STANDBY: case META_POWER_SAVE_STANDBY:
case META_POWER_SAVE_SUSPEND: case META_POWER_SAVE_SUSPEND:
case META_POWER_SAVE_OFF: case META_POWER_SAVE_OFF:
break;
}
for (l = meta_backend_get_gpus (backend); l; l = l->next)
{ {
MetaGpuKms *gpu_kms = l->data;
MetaKmsDevice *kms_device = meta_gpu_kms_get_kms_device (gpu_kms); MetaKmsDevice *kms_device = meta_gpu_kms_get_kms_device (gpu_kms);
MetaKmsUpdate *kms_update; MetaKmsUpdate *kms_update;
MetaKmsUpdateFlag flags; MetaKmsUpdateFlag flags;
@ -186,6 +189,9 @@ meta_monitor_manager_native_set_power_save_mode (MetaMonitorManager *manager,
g_warning ("Failed to enter power saving mode: %s", g_warning ("Failed to enter power saving mode: %s",
meta_kms_feedback_get_error (kms_feedback)->message); meta_kms_feedback_get_error (kms_feedback)->message);
} }
break;
}
}
} }
} }
@ -540,7 +546,20 @@ meta_monitor_manager_native_pause (MetaMonitorManagerNative *manager_native)
void void
meta_monitor_manager_native_resume (MetaMonitorManagerNative *manager_native) meta_monitor_manager_native_resume (MetaMonitorManagerNative *manager_native)
{ {
MetaMonitorManager *manager = META_MONITOR_MANAGER (manager_native);
MetaBackend *backend = meta_monitor_manager_get_backend (manager);
GList *l;
meta_monitor_manager_native_connect_hotplug_handler (manager_native); meta_monitor_manager_native_connect_hotplug_handler (manager_native);
for (l = meta_backend_get_gpus (backend); l; l = l->next)
{
MetaGpu *gpu = l->data;
g_list_foreach (meta_gpu_get_crtcs (gpu),
(GFunc) meta_crtc_kms_invalidate_gamma,
NULL);
}
} }
static gboolean static gboolean

View File

@ -1167,7 +1167,12 @@ meta_renderer_native_prepare_frame (MetaRendererNative *renderer_native,
MetaRendererView *view, MetaRendererView *view,
ClutterFrame *frame) ClutterFrame *frame)
{ {
MetaRenderer *renderer = META_RENDERER (renderer_native);
MetaBackend *backend = meta_renderer_get_backend (renderer);
MetaMonitorManager *monitor_manager =
meta_backend_get_monitor_manager (backend);
MetaCrtc *crtc = meta_renderer_view_get_crtc (view); MetaCrtc *crtc = meta_renderer_view_get_crtc (view);
MetaPowerSave power_save_mode;
MetaCrtcKms *crtc_kms; MetaCrtcKms *crtc_kms;
MetaKmsCrtc *kms_crtc; MetaKmsCrtc *kms_crtc;
MetaKmsDevice *kms_device; MetaKmsDevice *kms_device;
@ -1175,6 +1180,10 @@ meta_renderer_native_prepare_frame (MetaRendererNative *renderer_native,
if (!META_IS_CRTC_KMS (crtc)) if (!META_IS_CRTC_KMS (crtc))
return; return;
power_save_mode = meta_monitor_manager_get_power_save_mode (monitor_manager);
if (power_save_mode != META_POWER_SAVE_ON)
return;
crtc_kms = META_CRTC_KMS (crtc); crtc_kms = META_CRTC_KMS (crtc);
kms_crtc = meta_crtc_kms_get_kms_crtc (META_CRTC_KMS (crtc)); kms_crtc = meta_crtc_kms_get_kms_crtc (META_CRTC_KMS (crtc));
kms_device = meta_kms_crtc_get_device (kms_crtc); kms_device = meta_kms_crtc_get_device (kms_crtc);