Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/backends/native/meta-backend-native.c
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,9 @@ create_gpu_from_udev_device (MetaBackendNative *native,
if (meta_is_udev_device_requires_modifiers (device))
flags |= META_KMS_DEVICE_FLAG_REQUIRES_MODIFIERS;

if (meta_is_udev_device_preferred_primary (device))
flags |= META_KMS_DEVICE_FLAG_PREFERRED_PRIMARY;

device_path = g_udev_device_get_device_file (device);

kms_device = meta_kms_create_device (native->kms, device_path, flags,
Expand Down
9 changes: 9 additions & 0 deletions src/backends/native/meta-gpu-kms.c
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,15 @@ meta_gpu_kms_requires_modifiers (MetaGpuKms *gpu_kms)
return !!(flags & META_KMS_DEVICE_FLAG_REQUIRES_MODIFIERS);
}

gboolean
meta_gpu_kms_is_preferred_primary (MetaGpuKms *gpu_kms)
{
MetaKmsDeviceFlag flags;

flags = meta_kms_device_get_flags (gpu_kms->kms_device);
return !!(flags & META_KMS_DEVICE_FLAG_PREFERRED_PRIMARY);
}

static int
compare_outputs (gconstpointer one,
gconstpointer two)
Expand Down
1 change: 1 addition & 0 deletions src/backends/native/meta-gpu-kms.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ gboolean meta_gpu_kms_is_crtc_active (MetaGpuKms *gpu_kms,
gboolean meta_gpu_kms_is_boot_vga (MetaGpuKms *gpu_kms);
gboolean meta_gpu_kms_is_platform_device (MetaGpuKms *gpu_kms);
gboolean meta_gpu_kms_requires_modifiers (MetaGpuKms *gpu_kms);
gboolean meta_gpu_kms_is_preferred_primary (MetaGpuKms *gpu_kms);

gboolean meta_gpu_kms_wait_for_flip (MetaGpuKms *gpu_kms,
GError **error);
Expand Down
1 change: 1 addition & 0 deletions src/backends/native/meta-kms-types.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ typedef enum _MetaKmsDeviceFlag
META_KMS_DEVICE_FLAG_BOOT_VGA = 1 << 0,
META_KMS_DEVICE_FLAG_PLATFORM_DEVICE = 1 << 1,
META_KMS_DEVICE_FLAG_REQUIRES_MODIFIERS = 1 << 2,
META_KMS_DEVICE_FLAG_PREFERRED_PRIMARY = 1 << 3,
} MetaKmsDeviceFlag;

typedef enum _MetaKmsPlaneType MetaKmsPlaneType;
Expand Down
11 changes: 11 additions & 0 deletions src/backends/native/meta-renderer-native.c
Original file line number Diff line number Diff line change
Expand Up @@ -3940,6 +3940,17 @@ choose_primary_gpu_unchecked (MetaBackend *backend,
*/
for (allow_sw = 0; allow_sw < 2; allow_sw++)
{
/* Prefer a device tagged as preferred primary via udev */
for (l = gpus; l; l = l->next)
{
MetaGpuKms *gpu_kms = META_GPU_KMS (l->data);

if (meta_gpu_kms_is_preferred_primary (gpu_kms) &&
(allow_sw == 1 ||
gpu_kms_is_hardware_rendering (renderer_native, gpu_kms)))
return gpu_kms;
}

/* Prefer a platform device */
for (l = gpus; l; l = l->next)
{
Expand Down
12 changes: 12 additions & 0 deletions src/backends/native/meta-udev.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,18 @@ meta_is_udev_device_boot_vga (GUdevDevice *device)
return g_udev_device_get_sysfs_attr_as_int (pci_device, "boot_vga") == 1;
}

gboolean
meta_is_udev_device_preferred_primary (GUdevDevice *device)
{
const char * const * tags;

tags = g_udev_device_get_tags (device);
if (!tags)
return FALSE;

return g_strv_contains (tags, "muffin-device-preferred-primary");
}

gboolean
meta_is_udev_device_requires_modifiers (GUdevDevice *device)
{
Expand Down
2 changes: 2 additions & 0 deletions src/backends/native/meta-udev.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ gboolean meta_is_udev_device_platform_device (GUdevDevice *device);

gboolean meta_is_udev_device_boot_vga (GUdevDevice *device);

gboolean meta_is_udev_device_preferred_primary (GUdevDevice *device);

gboolean meta_is_udev_device_requires_modifiers (GUdevDevice *device);

gboolean meta_udev_is_drm_device (MetaUdev *udev,
Expand Down