Blame SOURCES/0001-output-kms-Add-more-heuristics-to-decide-when-to-off.patch

98e88a
From cf16c0d16b42215f35dcede6163235ad5ec1734b Mon Sep 17 00:00:00 2001
98e88a
From: Mario Limonciello <mario.limonciello@amd.com>
98e88a
Date: Thu, 18 Aug 2022 13:36:20 -0500
98e88a
Subject: [PATCH] output/kms: Add more heuristics to decide when to offer
98e88a
 fallback modes
98e88a
98e88a
If the panel is connected via eDP and supports more than one mode
98e88a
at different resolutions don't try to add more.
98e88a
98e88a
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2586>
98e88a
(cherry picked from commit 96aa0fb8536eca579ceb1b17d83e19cf9e3e9e81)
98e88a
---
98e88a
 src/backends/native/meta-output-kms.c | 45 ++++++++++++++++++++++-----
98e88a
 1 file changed, 38 insertions(+), 7 deletions(-)
98e88a
98e88a
diff --git a/src/backends/native/meta-output-kms.c b/src/backends/native/meta-output-kms.c
98e88a
index f3cc543c4d..44c25c5648 100644
98e88a
--- a/src/backends/native/meta-output-kms.c
98e88a
+++ b/src/backends/native/meta-output-kms.c
98e88a
@@ -505,6 +505,43 @@ compare_modes (const void *one,
98e88a
   return g_strcmp0 (b->name, a->name);
98e88a
 }
98e88a
 
98e88a
+static gboolean
98e88a
+are_all_modes_equally_sized (MetaOutput *output)
98e88a
+{
98e88a
+  MetaCrtcMode *base = output->modes[0];
98e88a
+  int i;
98e88a
+
98e88a
+  for (i = 1; i < output->n_modes; i++)
98e88a
+    {
98e88a
+      MetaCrtcMode *crtc_mode = output->modes[i];
98e88a
+
98e88a
+      if (base->width != crtc_mode->width ||
98e88a
+          base->height != crtc_mode->height)
98e88a
+        return FALSE;
98e88a
+    }
98e88a
+
98e88a
+  return TRUE;
98e88a
+}
98e88a
+
98e88a
+static void
98e88a
+maybe_add_fallback_modes (MetaOutput *output,
98e88a
+                          MetaGpuKms *gpu_kms)
98e88a
+{
98e88a
+  MetaOutputKms *output_kms = output->driver_private;
98e88a
+
98e88a
+  if (!output_kms->has_scaling)
98e88a
+    return;
98e88a
+
98e88a
+  if (output->n_modes == 0)
98e88a
+    return;
98e88a
+
98e88a
+  if (output_kms->connector->connector_type == DRM_MODE_CONNECTOR_eDP &&
98e88a
+      !are_all_modes_equally_sized (output))
98e88a
+    return;
98e88a
+
98e88a
+  add_common_modes (output, gpu_kms);
98e88a
+}
98e88a
+
98e88a
 static gboolean
98e88a
 init_output_modes (MetaOutput  *output,
98e88a
                    MetaGpuKms  *gpu_kms,
98e88a
@@ -528,13 +565,7 @@ init_output_modes (MetaOutput  *output,
98e88a
         output->preferred_mode = output->modes[i];
98e88a
     }
98e88a
 
98e88a
-  /* FIXME: MSC feature bit? */
98e88a
-  /* Presume that if the output supports scaling, then we have
98e88a
-   * a panel fitter capable of adjusting any mode to suit.
98e88a
-   */
98e88a
-  if (output_kms->has_scaling)
98e88a
-    add_common_modes (output, gpu_kms);
98e88a
-
98e88a
+  maybe_add_fallback_modes (output, gpu_kms);
98e88a
   if (!output->modes)
98e88a
     {
98e88a
       g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
98e88a
-- 
98e88a
2.37.1
98e88a