kms/impl-device: Set universal plane client cap when opening file

This means it will be set again if the file is reopened.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1828>
This commit is contained in:
Jonas Ådahl 2021-04-11 12:15:23 +02:00
parent 5502f956f5
commit 93f9c99cc5
3 changed files with 29 additions and 15 deletions

View File

@ -1055,6 +1055,7 @@ meta_kms_impl_device_atomic_open_device_file (MetaKmsImplDevice *impl_device,
MetaDevicePool *device_pool = MetaDevicePool *device_pool =
meta_backend_native_get_device_pool (META_BACKEND_NATIVE (backend)); meta_backend_native_get_device_pool (META_BACKEND_NATIVE (backend));
g_autoptr (MetaDeviceFile) device_file = NULL; g_autoptr (MetaDeviceFile) device_file = NULL;
int fd;
device_file = meta_device_pool_open (device_pool, path, device_file = meta_device_pool_open (device_pool, path,
META_DEVICE_FILE_FLAG_TAKE_CONTROL, META_DEVICE_FILE_FLAG_TAKE_CONTROL,
@ -1062,8 +1063,16 @@ meta_kms_impl_device_atomic_open_device_file (MetaKmsImplDevice *impl_device,
if (!device_file) if (!device_file)
return NULL; return NULL;
if (drmSetClientCap (meta_device_file_get_fd (device_file), fd = meta_device_file_get_fd (device_file);
DRM_CLIENT_CAP_ATOMIC, 1) != 0)
if (drmSetClientCap (fd, DRM_CLIENT_CAP_UNIVERSAL_PLANES, 1) != 0)
{
g_set_error (error, META_KMS_ERROR, META_KMS_ERROR_NOT_SUPPORTED,
"DRM_CLIENT_CAP_UNIVERSAL_PLANES not supported");
return NULL;
}
if (drmSetClientCap (fd, DRM_CLIENT_CAP_ATOMIC, 1) != 0)
{ {
g_set_error (error, META_KMS_ERROR, META_KMS_ERROR_NOT_SUPPORTED, g_set_error (error, META_KMS_ERROR, META_KMS_ERROR_NOT_SUPPORTED,
"DRM_CLIENT_CAP_ATOMIC not supported"); "DRM_CLIENT_CAP_ATOMIC not supported");

View File

@ -1547,10 +1547,25 @@ meta_kms_impl_device_simple_open_device_file (MetaKmsImplDevice *impl_device,
MetaBackend *backend = meta_kms_get_backend (kms); MetaBackend *backend = meta_kms_get_backend (kms);
MetaDevicePool *device_pool = MetaDevicePool *device_pool =
meta_backend_native_get_device_pool (META_BACKEND_NATIVE (backend)); meta_backend_native_get_device_pool (META_BACKEND_NATIVE (backend));
g_autoptr (MetaDeviceFile) device_file = NULL;
int fd;
return meta_device_pool_open (device_pool, path, device_file = meta_device_pool_open (device_pool, path,
META_DEVICE_FILE_FLAG_TAKE_CONTROL, META_DEVICE_FILE_FLAG_TAKE_CONTROL,
error); error);
if (!device_file)
return NULL;
fd = meta_device_file_get_fd (device_file);
if (drmSetClientCap (fd, DRM_CLIENT_CAP_UNIVERSAL_PLANES, 1) != 0)
{
g_set_error (error, META_KMS_ERROR, META_KMS_ERROR_NOT_SUPPORTED,
"DRM_CLIENT_CAP_UNIVERSAL_PLANES not supported");
return NULL;
}
return g_steal_pointer (&device_file);
} }
static gboolean static gboolean

View File

@ -786,20 +786,10 @@ meta_kms_impl_device_init_mode_setting (MetaKmsImplDevice *impl_device,
MetaKmsImplDevicePrivate *priv = MetaKmsImplDevicePrivate *priv =
meta_kms_impl_device_get_instance_private (impl_device); meta_kms_impl_device_get_instance_private (impl_device);
int fd; int fd;
int ret;
drmModeRes *drm_resources; drmModeRes *drm_resources;
fd = meta_device_file_get_fd (priv->device_file); fd = meta_device_file_get_fd (priv->device_file);
ret = drmSetClientCap (fd, DRM_CLIENT_CAP_UNIVERSAL_PLANES, 1);
if (ret != 0)
{
g_set_error (error, G_IO_ERROR, g_io_error_from_errno (-ret),
"Failed to activate universal planes: %s",
g_strerror (-ret));
return FALSE;
}
drm_resources = drmModeGetResources (fd); drm_resources = drmModeGetResources (fd);
if (!drm_resources) if (!drm_resources)
{ {