Prefer GPUs with built-in panels connected when selecting a primary GPU

Some laptops don't have the integrated GPU come earlier in the PCI topology
which means that when mutter enumerates the GPUs it may select the dGPU
as the primary.

In a laptop context, this is unlikely to work because the eDP panel can
only be actively connected to a single GPU at a time.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3746
Suggested-by: Jonas Ådahl
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4114>
This commit is contained in:
Mario Limonciello
2024-11-06 13:54:55 -06:00
committed by Marge Bot
parent a280280cff
commit ecbe4a5dad
3 changed files with 41 additions and 0 deletions

View File

@ -2205,6 +2205,21 @@ choose_primary_gpu_unchecked (MetaBackend *backend,
}
}
/* Then prefer a GPU with a builtin panel connected to it. */
for (l = gpus; l; l = l->next)
{
MetaGpuKms *gpu_kms = META_GPU_KMS (l->data);
MetaKmsDevice *kms_device = meta_gpu_kms_get_kms_device (gpu_kms);
if (meta_kms_device_has_connected_builtin_panel (kms_device) &&
(allow_sw == 1 ||
gpu_kms_is_hardware_rendering (renderer_native, gpu_kms)))
{
g_message ("GPU %s selected primary from builtin panel presence",
meta_gpu_kms_get_file_path (gpu_kms));
return gpu_kms;
}
}
/* Prefer a platform device */
for (l = gpus; l; l = l->next)