output/kms: Use meta_kms_connector_get_preferred_mode in init_output_modes

I have a monitor which can report two preferred modes: 5120x1440@240
and 3840x1080@60. Since they are enumerated in this order by KMS,
init_output_modes would end up using 3840x1080@60 (and it was impossible
to select any 5120x1440 mode in the GNOME display settings).

Fix this by using meta_kms_connector_get_preferred_mode, which returns
the first KMS mode with DRM_MODE_TYPE_PREFERRED.

v2:
* Use meta_kms_connector_get_preferred_mode. (Jonas Ådahl)

Signed-off-by: Michel Dänzer <mdaenzer@redhat.com>
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3055>
This commit is contained in:
Michel Dänzer 2023-06-06 12:18:02 +02:00 committed by Marge Bot
parent 49e6ce459c
commit 4d664fd797

View File

@ -361,10 +361,12 @@ init_output_modes (MetaOutputInfo *output_info,
GError **error)
{
const MetaKmsConnectorState *connector_state;
MetaKmsMode *kms_preferred_mode;
GList *l;
int i;
connector_state = meta_kms_connector_get_current_state (kms_connector);
kms_preferred_mode = meta_kms_connector_get_preferred_mode (kms_connector);
output_info->preferred_mode = NULL;
@ -373,12 +375,11 @@ init_output_modes (MetaOutputInfo *output_info,
for (l = connector_state->modes, i = 0; l; l = l->next, i++)
{
MetaKmsMode *kms_mode = l->data;
const drmModeModeInfo *drm_mode = meta_kms_mode_get_drm_mode (kms_mode);
MetaCrtcMode *crtc_mode;
crtc_mode = meta_gpu_kms_get_mode_from_kms_mode (gpu_kms, kms_mode);
output_info->modes[i] = crtc_mode;
if (drm_mode->type & DRM_MODE_TYPE_PREFERRED)
if (kms_mode == kms_preferred_mode)
output_info->preferred_mode = output_info->modes[i];
}