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




commit a4355a82d71f8a847d621e9a12d4199e771597e9
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 the gamma cruves 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.
    
    loses: https://gitlab.gnome.org/GNOME/mutter/-/issues/1392

 src/backends/native/meta-renderer-native.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
---
diff --git a/src/backends/native/meta-renderer-native.c b/src/backends/native/meta-renderer-native.c
index ac25a828a7..f9900ed38c 100644
--- a/src/backends/native/meta-renderer-native.c
+++ b/src/backends/native/meta-renderer-native.c
@@ -1317,6 +1317,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)");
@@ -1341,6 +1342,17 @@ 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);
+
+  /* This is a hack to work around
+   * https://gitlab.freedesktop.org/drm/intel/-/issues/2362
+   */
+  current_state = meta_kms_crtc_get_current_state (meta_crtc_kms_get_kms_crtc (onscreen_native->crtc));
+  meta_kms_crtc_set_gamma (meta_crtc_kms_get_kms_crtc (onscreen_native->crtc),
+                           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]