[mutter/benzea/gamma-fix-master: 20/20] renderer-native: Re-set gamma curve while configuring CRTCs




commit b6dbe113e4ebdb66de2318c75e8aeef37aa9befa
Author: Benjamin Berg <bberg redhat com>
Date:   Fri Aug 28 19:58:27 2020 +0200

    renderer-native: Re-set gamma curve while configuring CRTCs
    
    Since commit 2e5b767c0 (gpu/kms: Turn off CRTCs as well for DPMS) we
    turn off the CRTCs. This has the undesired side effect that (at least
    currently) updates to the gamma curve are lost. While this can be
    considered a kernel issue, it has the major side effect of breaking
    Night Light in ugly ways.
    
    This fetches the (cached) gamma curve and sets it again when setting the
    CRTC mode. This way we re-apply the gamma curve even if the kernel may
    have lost it due to the CRTC having been turned off at the time.
    
    Note that this may be considered a DRM/driver bug. See
      https://gitlab.freedesktop.org/drm/intel/-/issues/2362
    
    Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1392

 src/backends/native/meta-renderer-native.c | 9 +++++++++
 1 file changed, 9 insertions(+)
---
diff --git a/src/backends/native/meta-renderer-native.c b/src/backends/native/meta-renderer-native.c
index cf29fc9b5b..bd3337af92 100644
--- a/src/backends/native/meta-renderer-native.c
+++ b/src/backends/native/meta-renderer-native.c
@@ -1313,6 +1313,7 @@ meta_onscreen_native_set_crtc_mode (CoglOnscreen              *onscreen,
   CoglOnscreenEGL *onscreen_egl = onscreen->winsys;
   MetaOnscreenNative *onscreen_native = onscreen_egl->platform;
   MetaCrtcKms *crtc_kms = META_CRTC_KMS (onscreen_native->crtc);
+  const MetaKmsCrtcState *current_state;
 
   COGL_TRACE_BEGIN_SCOPED (MetaOnscreenNativeSetCrtcModes,
                            "Onscreen (set CRTC modes)");
@@ -1337,6 +1338,14 @@ meta_onscreen_native_set_crtc_mode (CoglOnscreen              *onscreen,
   meta_crtc_kms_set_mode (crtc_kms, kms_update);
   meta_output_kms_set_underscan (META_OUTPUT_KMS (onscreen_native->output),
                                  kms_update);
+
+  current_state = meta_kms_crtc_get_current_state (meta_crtc_kms_get_kms_crtc (crtc_kms));
+  meta_kms_crtc_set_gamma (meta_crtc_kms_get_kms_crtc (crtc_kms),
+                           kms_update,
+                           current_state->gamma.size,
+                           current_state->gamma.red,
+                           current_state->gamma.green,
+                           current_state->gamma.blue);
 }
 
 static void


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