Backport KMS: Survive missing GAMMA_LUT property

Resolves: #2083091
This commit is contained in:
Jocelyn Falempe 2022-06-13 11:33:44 +02:00
parent 442af5b884
commit ac2035fa06
4 changed files with 136 additions and 1 deletions

View File

@ -0,0 +1,46 @@
From de3188fcc6863b8a6e3d2443a00cf3b00f6f26ff Mon Sep 17 00:00:00 2001
From: Daniel van Vugt <daniel.van.vugt@canonical.com>
Date: Tue, 12 Apr 2022 18:34:58 +0800
Subject: [PATCH 1/2] kms/crtc: Add function meta_kms_crtc_has_gamma
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2360>
---
src/backends/native/meta-kms-crtc.c | 7 +++++++
src/backends/native/meta-kms-crtc.h | 3 +++
2 files changed, 10 insertions(+)
diff --git a/src/backends/native/meta-kms-crtc.c b/src/backends/native/meta-kms-crtc.c
index 51d040b44..24f5a2d74 100644
--- a/src/backends/native/meta-kms-crtc.c
+++ b/src/backends/native/meta-kms-crtc.c
@@ -92,6 +92,13 @@ meta_kms_crtc_is_active (MetaKmsCrtc *crtc)
return crtc->current_state.is_active;
}
+
+gboolean
+meta_kms_crtc_has_gamma (MetaKmsCrtc *crtc)
+{
+ return !!meta_kms_crtc_get_prop_id (crtc, META_KMS_CRTC_PROP_GAMMA_LUT);
+}
+
static void
read_gamma_state (MetaKmsCrtc *crtc,
MetaKmsImplDevice *impl_device,
diff --git a/src/backends/native/meta-kms-crtc.h b/src/backends/native/meta-kms-crtc.h
index 406ca3ac1..cbaeaa280 100644
--- a/src/backends/native/meta-kms-crtc.h
+++ b/src/backends/native/meta-kms-crtc.h
@@ -66,6 +66,9 @@ uint32_t meta_kms_crtc_get_id (MetaKmsCrtc *crtc);
int meta_kms_crtc_get_idx (MetaKmsCrtc *crtc);
+
+gboolean meta_kms_crtc_has_gamma (MetaKmsCrtc *crtc);
+
gboolean meta_kms_crtc_is_active (MetaKmsCrtc *crtc);
void meta_kms_crtc_gamma_free (MetaKmsCrtcGamma *gamma);
--
2.35.1

View File

@ -0,0 +1,43 @@
From 69c40c6d126a5c804db54ce0afe581362e4fd33b Mon Sep 17 00:00:00 2001
From: Daniel van Vugt <daniel.van.vugt@canonical.com>
Date: Tue, 12 Apr 2022 18:37:29 +0800
Subject: [PATCH 2/2] crtc/kms: Don't add gamma to the update if unsupported by
the CRTC
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2197
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2360>
---
src/backends/native/meta-crtc-kms.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/src/backends/native/meta-crtc-kms.c b/src/backends/native/meta-crtc-kms.c
index f1bc79146..953f023ce 100644
--- a/src/backends/native/meta-crtc-kms.c
+++ b/src/backends/native/meta-crtc-kms.c
@@ -201,10 +201,14 @@ meta_crtc_kms_maybe_set_gamma (MetaCrtcKms *crtc_kms,
MetaKms *kms = meta_kms_device_get_kms (kms_device);
MetaKmsUpdate *kms_update;
MetaKmsCrtcGamma *gamma;
+ MetaKmsCrtc *kms_crtc = meta_crtc_kms_get_kms_crtc (crtc_kms);
if (crtc_kms->is_gamma_valid)
return;
+ if (!meta_kms_crtc_has_gamma (kms_crtc))
+ return;
+
gamma = meta_monitor_manager_native_get_cached_crtc_gamma (monitor_manager_native,
crtc_kms);
if (!gamma)
@@ -212,7 +216,7 @@ meta_crtc_kms_maybe_set_gamma (MetaCrtcKms *crtc_kms,
kms_update = meta_kms_ensure_pending_update (kms, kms_device);
meta_kms_update_set_crtc_gamma (kms_update,
- meta_crtc_kms_get_kms_crtc (crtc_kms),
+ kms_crtc,
gamma->size,
gamma->red,
gamma->green,
--
2.35.1

View File

@ -0,0 +1,37 @@
From 8d6e41fc9b5194fb24523c939de54a2af46b5d07 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jonas=20=C3=85dahl?= <jadahl@gmail.com>
Date: Fri, 27 May 2022 18:19:27 +0200
Subject: [PATCH] kms/crtc: Determine gamma support given the gamma length
The property doesn't necessarily exist when using drivers that doesn't
support atomic mode setting, and the way it worked will break night
light and other gamma related features. This makes things use the gamma
length; if it is higher than 0, it definitely supports it one way or the
other, i.e. GAMMA_LUT with the atomic backend, and drmModeCrtcSetGamma()
with the legacy/simple backend.
Fixes: 364572b95c8354ac66674064a8058aa98bc0bbef
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2287
(cherry picked from commit a2ebd10f049d888e451938e23a035ed97e0c8eff)
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2452>
---
src/backends/native/meta-kms-crtc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/backends/native/meta-kms-crtc.c b/src/backends/native/meta-kms-crtc.c
index 24f5a2d7400..0513af947c9 100644
--- a/src/backends/native/meta-kms-crtc.c
+++ b/src/backends/native/meta-kms-crtc.c
@@ -96,7 +96,7 @@ meta_kms_crtc_is_active (MetaKmsCrtc *crtc)
gboolean
meta_kms_crtc_has_gamma (MetaKmsCrtc *crtc)
{
- return !!meta_kms_crtc_get_prop_id (crtc, META_KMS_CRTC_PROP_GAMMA_LUT);
+ return crtc->current_state.gamma.size > 0;
}
static void
--
2.36.1

View File

@ -10,7 +10,7 @@
Name: mutter
Version: 40.9
Release: 3%{?dist}
Release: 4%{?dist}
Summary: Window and compositing manager based on Clutter
License: GPLv2+
@ -71,6 +71,11 @@ Patch15: eglstream-overview-fixes.patch
Patch16: 0001-clutter-Make-ClutterClickAction-independent-of-click.patch
Patch17: add-unsafe-mode-property.patch
# Backport KMS: Survive missing GAMMA_LUT property (#2083091)
Patch18: 0001-kms-crtc-Add-function-meta_kms_crtc_has_gamma.patch
Patch19: 0002-crtc-kms-Don-t-add-gamma-to-the-update-if-unsupporte.patch
Patch20: 0003-kms-crtc-Determine-gamma-support-given-the-gamma-len.patch
BuildRequires: chrpath
BuildRequires: pango-devel
BuildRequires: startup-notification-devel
@ -217,6 +222,10 @@ desktop-file-validate %{buildroot}/%{_datadir}/applications/%{name}.desktop
%{_datadir}/mutter-%{mutter_api_version}/tests
%changelog
* Mon Jun 13 2022 Jocelyn Falempe <jfalempe@redhat.com - 40.9-4
- Backport KMS: Survive missing GAMMA_LUT property
Resolves: #2083091
* Fri Apr 01 2022 Florian Müllner <fmuellner@redhat.com> - 40.9-3
- Add MetaBackend:unsafe-mode property
Related: #2055366