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




commit 8a3dc9ff37dab3e89dd31cd551f982a08e029e7a
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.
    
    Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1392

 src/backends/native/meta-renderer-native.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
---
diff --git a/src/backends/native/meta-renderer-native.c b/src/backends/native/meta-renderer-native.c
index e94562b286..39c5a7f2f6 100644
--- a/src/backends/native/meta-renderer-native.c
+++ b/src/backends/native/meta-renderer-native.c
@@ -1408,6 +1408,7 @@ meta_onscreen_native_set_crtc_mode (CoglOnscreen              *onscreen,
 {
   CoglOnscreenEGL *onscreen_egl = onscreen->winsys;
   MetaOnscreenNative *onscreen_native = onscreen_egl->platform;
+  const MetaKmsCrtcState *current_state;
 
   COGL_TRACE_BEGIN_SCOPED (MetaOnscreenNativeSetCrtcModes,
                            "Onscreen (set CRTC modes)");
@@ -1431,6 +1432,18 @@ meta_onscreen_native_set_crtc_mode (CoglOnscreen              *onscreen,
 
   meta_crtc_kms_set_mode (onscreen_native->crtc, kms_update);
   meta_output_kms_set_underscan (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]