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



commit 93f9c99cc5e9ccf278d4b33dbab5bc2fdb0c3346
Author: Jonas Ã…dahl <jadahl gmail com>
Date:   Sun Apr 11 12:15:23 2021 +0200

    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>

 src/backends/native/meta-kms-impl-device-atomic.c | 13 +++++++++++--
 src/backends/native/meta-kms-impl-device-simple.c | 21 ++++++++++++++++++---
 src/backends/native/meta-kms-impl-device.c        | 10 ----------
 3 files changed, 29 insertions(+), 15 deletions(-)
---
diff --git a/src/backends/native/meta-kms-impl-device-atomic.c 
b/src/backends/native/meta-kms-impl-device-atomic.c
index cda9133559..85897e3304 100644
--- a/src/backends/native/meta-kms-impl-device-atomic.c
+++ b/src/backends/native/meta-kms-impl-device-atomic.c
@@ -1055,6 +1055,7 @@ meta_kms_impl_device_atomic_open_device_file (MetaKmsImplDevice  *impl_device,
   MetaDevicePool *device_pool =
     meta_backend_native_get_device_pool (META_BACKEND_NATIVE (backend));
   g_autoptr (MetaDeviceFile) device_file = NULL;
+  int fd;
 
   device_file = meta_device_pool_open (device_pool, path,
                                        META_DEVICE_FILE_FLAG_TAKE_CONTROL,
@@ -1062,8 +1063,16 @@ meta_kms_impl_device_atomic_open_device_file (MetaKmsImplDevice  *impl_device,
   if (!device_file)
     return NULL;
 
-  if (drmSetClientCap (meta_device_file_get_fd (device_file),
-                       DRM_CLIENT_CAP_ATOMIC, 1) != 0)
+  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;
+    }
+
+  if (drmSetClientCap (fd, DRM_CLIENT_CAP_ATOMIC, 1) != 0)
     {
       g_set_error (error, META_KMS_ERROR, META_KMS_ERROR_NOT_SUPPORTED,
                    "DRM_CLIENT_CAP_ATOMIC not supported");
diff --git a/src/backends/native/meta-kms-impl-device-simple.c 
b/src/backends/native/meta-kms-impl-device-simple.c
index 02f87b62c7..eabafa096d 100644
--- a/src/backends/native/meta-kms-impl-device-simple.c
+++ b/src/backends/native/meta-kms-impl-device-simple.c
@@ -1547,10 +1547,25 @@ meta_kms_impl_device_simple_open_device_file (MetaKmsImplDevice  *impl_device,
   MetaBackend *backend = meta_kms_get_backend (kms);
   MetaDevicePool *device_pool =
     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,
-                                META_DEVICE_FILE_FLAG_TAKE_CONTROL,
-                                error);
+  device_file = meta_device_pool_open (device_pool, path,
+                                       META_DEVICE_FILE_FLAG_TAKE_CONTROL,
+                                       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
diff --git a/src/backends/native/meta-kms-impl-device.c b/src/backends/native/meta-kms-impl-device.c
index 40cf8c41f2..f43eaa5c65 100644
--- a/src/backends/native/meta-kms-impl-device.c
+++ b/src/backends/native/meta-kms-impl-device.c
@@ -786,20 +786,10 @@ meta_kms_impl_device_init_mode_setting (MetaKmsImplDevice  *impl_device,
   MetaKmsImplDevicePrivate *priv =
     meta_kms_impl_device_get_instance_private (impl_device);
   int fd;
-  int ret;
   drmModeRes *drm_resources;
 
   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);
   if (!drm_resources)
     {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]