summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonas Ã…dahl <jadahl@gmail.com>2021-04-21 10:09:06 +0200
committerMarge Bot <marge-bot@gnome.org>2021-04-27 16:12:18 +0000
commitefd9af11830dc652509fee964f5ed4dc742516f0 (patch)
tree36f383b028f8796269a93f7dad0935aa6f828c26
parentb4a7f35146a32cdcd8638eb97b8a84d236cd4e75 (diff)
downloadmutter-efd9af11830dc652509fee964f5ed4dc742516f0.tar.gz
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. Closes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/4155 Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1834>
-rw-r--r--src/backends/native/meta-output-kms.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/backends/native/meta-output-kms.c b/src/backends/native/meta-output-kms.c
index fa265bcad..f35cdf04e 100644
--- a/src/backends/native/meta-output-kms.c
+++ b/src/backends/native/meta-output-kms.c
@@ -137,6 +137,7 @@ add_common_modes (MetaOutputInfo *output_info,
unsigned max_hdisplay = 0;
unsigned max_vdisplay = 0;
float max_refresh_rate = 0.0;
+ float max_bandwidth = 0.0;
MetaKmsDevice *kms_device;
MetaKmsModeFlag flag_filter;
GList *l;
@@ -147,11 +148,14 @@ add_common_modes (MetaOutputInfo *output_info,
MetaCrtcModeKms *crtc_mode_kms = META_CRTC_MODE_KMS (crtc_mode);
MetaKmsMode *kms_mode = meta_crtc_mode_kms_get_kms_mode (crtc_mode_kms);
const drmModeModeInfo *drm_mode = meta_kms_mode_get_drm_mode (kms_mode);
+ float bandwidth;
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);
@@ -170,15 +174,18 @@ add_common_modes (MetaOutputInfo *output_info,
{
MetaKmsMode *fallback_mode = l->data;
const drmModeModeInfo *drm_mode;
+ float bandwidth;
if (!(meta_kms_mode_get_flags (fallback_mode) & flag_filter))
continue;
drm_mode = meta_kms_mode_get_drm_mode (fallback_mode);
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_kms_mode (gpu_kms, fallback_mode);
@@ -245,8 +252,7 @@ init_output_modes (MetaOutputInfo *output_info,
output_info->preferred_mode = output_info->modes[i];
}
- if (connector_state->has_scaling &&
- g_list_length (connector_state->modes) == 1)
+ if (connector_state->has_scaling)
{
meta_topic (META_DEBUG_KMS, "Adding common modes to connector %u on %s",
meta_kms_connector_get_id (kms_connector),