[mutter/gnome-3-38] output/kms: Add back common modes on non-single mode outputs



commit d76c2e75bc893812f49a57e105157bac8b4392dd
Author: Robert Mader <robert mader posteo de>
Date:   Sat May 1 00:22:41 2021 +0200

    output/kms: Add back common modes on non-single mode outputs
    
    But this time, filter out modes that exceed a roughly calculated maximum
    bandwidth. This should avoid e.g. setting a 60 Hz 4K mode, when 4K is
    limited to 30 Hz, but lower resolutions supporting 60 Hz.
    
    Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1834>
    
    (backport of commit efd9af11830dc652509fee964f5ed4dc742516f0)

 src/backends/native/meta-output-kms.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)
---
diff --git a/src/backends/native/meta-output-kms.c b/src/backends/native/meta-output-kms.c
index c4cd4d4ab0..58c191b072 100644
--- a/src/backends/native/meta-output-kms.c
+++ b/src/backends/native/meta-output-kms.c
@@ -147,10 +147,12 @@ add_common_modes (MetaOutputInfo *output_info,
   MetaCrtcMode *crtc_mode;
   GPtrArray *array;
   float refresh_rate;
+  float bandwidth;
   unsigned i;
   unsigned max_hdisplay = 0;
   unsigned max_vdisplay = 0;
   float max_refresh_rate = 0.0;
+  float max_bandwidth = 0.0;
 
   for (i = 0; i < output_info->n_modes; i++)
     {
@@ -159,9 +161,11 @@ add_common_modes (MetaOutputInfo *output_info,
 
       drm_mode = meta_crtc_mode_kms_get_drm_mode (crtc_mode_kms);
       refresh_rate = meta_calculate_drm_mode_refresh_rate (drm_mode);
+      bandwidth = refresh_rate * drm_mode->hdisplay * drm_mode->vdisplay;
       max_hdisplay = MAX (max_hdisplay, drm_mode->hdisplay);
       max_vdisplay = MAX (max_vdisplay, drm_mode->vdisplay);
       max_refresh_rate = MAX (max_refresh_rate, refresh_rate);
+      max_bandwidth = MAX (max_bandwidth, bandwidth);
     }
 
   max_refresh_rate = MAX (max_refresh_rate, 60.0);
@@ -174,9 +178,11 @@ add_common_modes (MetaOutputInfo *output_info,
         {
           drm_mode = &meta_default_landscape_drm_mode_infos[i];
           refresh_rate = meta_calculate_drm_mode_refresh_rate (drm_mode);
+          bandwidth = refresh_rate * drm_mode->hdisplay * drm_mode->vdisplay;
           if (drm_mode->hdisplay > max_hdisplay ||
               drm_mode->vdisplay > max_vdisplay ||
-              refresh_rate > max_refresh_rate)
+              refresh_rate > max_refresh_rate ||
+              bandwidth > max_bandwidth)
             continue;
 
           crtc_mode = meta_gpu_kms_get_mode_from_drm_mode (gpu_kms,
@@ -190,9 +196,11 @@ add_common_modes (MetaOutputInfo *output_info,
         {
           drm_mode = &meta_default_portrait_drm_mode_infos[i];
           refresh_rate = meta_calculate_drm_mode_refresh_rate (drm_mode);
+          bandwidth = refresh_rate * drm_mode->hdisplay * drm_mode->vdisplay;
           if (drm_mode->hdisplay > max_hdisplay ||
               drm_mode->vdisplay > max_vdisplay ||
-              refresh_rate > max_refresh_rate)
+              refresh_rate > max_refresh_rate ||
+              bandwidth > max_bandwidth)
             continue;
 
           crtc_mode = meta_gpu_kms_get_mode_from_drm_mode (gpu_kms,
@@ -259,7 +267,7 @@ init_output_modes (MetaOutputInfo    *output_info,
         output_info->preferred_mode = output_info->modes[i];
     }
 
-  if (connector_state->has_scaling && connector_state->n_modes == 1)
+  if (connector_state->has_scaling)
     add_common_modes (output_info, gpu_kms);
 
   if (!output_info->modes)


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