[mutter] kms/device: Handle tracking capabilities



commit f3cdc9906c6db9584f1cd6a8f09b6bc7883d29ee
Author: Jonas Ådahl <jadahl gmail com>
Date:   Mon Nov 11 18:05:32 2019 +0100

    kms/device: Handle tracking capabilities
    
    Devices have capabilities that other parts need to know about. Instead
    of having them probe using drmMode* API, outsource this to
    MetaKmsDevice. Currently the only capability tracked is HW cursor size.
    
    https://gitlab.gnome.org/GNOME/mutter/merge_requests/930

 src/backends/native/meta-kms-device.c      | 22 ++++++++++++++++++++++
 src/backends/native/meta-kms-device.h      |  4 ++++
 src/backends/native/meta-kms-impl-device.c | 25 +++++++++++++++++++++++++
 src/backends/native/meta-kms-impl-device.h |  9 +++++++++
 4 files changed, 60 insertions(+)
---
diff --git a/src/backends/native/meta-kms-device.c b/src/backends/native/meta-kms-device.c
index beca37c64..c9a54952b 100644
--- a/src/backends/native/meta-kms-device.c
+++ b/src/backends/native/meta-kms-device.c
@@ -43,6 +43,8 @@ struct _MetaKmsDevice
   GList *crtcs;
   GList *connectors;
   GList *planes;
+
+  MetaKmsDeviceCaps caps;
 };
 
 G_DEFINE_TYPE (MetaKmsDevice, meta_kms_device, G_TYPE_OBJECT);
@@ -71,6 +73,23 @@ meta_kms_device_get_flags (MetaKmsDevice *device)
   return device->flags;
 }
 
+gboolean
+meta_kms_device_get_cursor_size (MetaKmsDevice *device,
+                                 uint64_t      *out_cursor_width,
+                                 uint64_t      *out_cursor_height)
+{
+  if (device->caps.has_cursor_size)
+    {
+      *out_cursor_width = device->caps.cursor_width;
+      *out_cursor_height = device->caps.cursor_height;
+      return TRUE;
+    }
+  else
+    {
+      return FALSE;
+    }
+}
+
 GList *
 meta_kms_device_get_connectors (MetaKmsDevice *device)
 {
@@ -211,6 +230,7 @@ typedef struct _CreateImplDeviceData
   GList *out_crtcs;
   GList *out_connectors;
   GList *out_planes;
+  MetaKmsDeviceCaps out_caps;
 } CreateImplDeviceData;
 
 static gpointer
@@ -229,6 +249,7 @@ create_impl_device_in_impl (MetaKmsImpl  *impl,
   data->out_crtcs = meta_kms_impl_device_copy_crtcs (impl_device);
   data->out_connectors = meta_kms_impl_device_copy_connectors (impl_device);
   data->out_planes = meta_kms_impl_device_copy_planes (impl_device);
+  data->out_caps = *meta_kms_impl_device_get_caps (impl_device);
 
   return GINT_TO_POINTER (TRUE);
 }
@@ -271,6 +292,7 @@ meta_kms_device_new (MetaKms            *kms,
   device->crtcs = data.out_crtcs;
   device->connectors = data.out_connectors;
   device->planes = data.out_planes;
+  device->caps = data.out_caps;
 
   return device;
 }
diff --git a/src/backends/native/meta-kms-device.h b/src/backends/native/meta-kms-device.h
index d3d655fec..9f83d3855 100644
--- a/src/backends/native/meta-kms-device.h
+++ b/src/backends/native/meta-kms-device.h
@@ -35,6 +35,10 @@ const char * meta_kms_device_get_path (MetaKmsDevice *device);
 
 MetaKmsDeviceFlag meta_kms_device_get_flags (MetaKmsDevice *device);
 
+gboolean meta_kms_device_get_cursor_size (MetaKmsDevice *device,
+                                          uint64_t      *out_cursor_width,
+                                          uint64_t      *out_cursor_height);
+
 GList * meta_kms_device_get_connectors (MetaKmsDevice *device);
 
 GList * meta_kms_device_get_crtcs (MetaKmsDevice *device);
diff --git a/src/backends/native/meta-kms-impl-device.c b/src/backends/native/meta-kms-impl-device.c
index cf5aee9d3..b35b19e55 100644
--- a/src/backends/native/meta-kms-impl-device.c
+++ b/src/backends/native/meta-kms-impl-device.c
@@ -48,6 +48,8 @@ struct _MetaKmsImplDevice
   GList *crtcs;
   GList *connectors;
   GList *planes;
+
+  MetaKmsDeviceCaps caps;
 };
 
 G_DEFINE_TYPE (MetaKmsImplDevice, meta_kms_impl_device, G_TYPE_OBJECT)
@@ -76,6 +78,12 @@ meta_kms_impl_device_copy_planes (MetaKmsImplDevice *impl_device)
   return g_list_copy (impl_device->planes);
 }
 
+const MetaKmsDeviceCaps *
+meta_kms_impl_device_get_caps (MetaKmsImplDevice *impl_device)
+{
+  return &impl_device->caps;
+}
+
 static void
 page_flip_handler (int           fd,
                    unsigned int  sequence,
@@ -179,6 +187,21 @@ meta_kms_impl_device_find_property (MetaKmsImplDevice       *impl_device,
   return NULL;
 }
 
+static void
+init_caps (MetaKmsImplDevice *impl_device)
+{
+  int fd = impl_device->fd;
+  uint64_t cursor_width, cursor_height;
+
+  if (drmGetCap (fd, DRM_CAP_CURSOR_WIDTH, &cursor_width) == 0 &&
+      drmGetCap (fd, DRM_CAP_CURSOR_HEIGHT, &cursor_height) == 0)
+    {
+      impl_device->caps.has_cursor_size = TRUE;
+      impl_device->caps.cursor_width = cursor_width;
+      impl_device->caps.cursor_height = cursor_height;
+    }
+}
+
 static void
 init_crtcs (MetaKmsImplDevice *impl_device,
             drmModeRes        *drm_resources)
@@ -385,6 +408,8 @@ meta_kms_impl_device_new (MetaKmsDevice  *device,
   impl_device->impl = impl;
   impl_device->fd = fd;
 
+  init_caps (impl_device);
+
   init_crtcs (impl_device, drm_resources);
   init_planes (impl_device);
 
diff --git a/src/backends/native/meta-kms-impl-device.h b/src/backends/native/meta-kms-impl-device.h
index 5bd0f5f98..fba0fdb69 100644
--- a/src/backends/native/meta-kms-impl-device.h
+++ b/src/backends/native/meta-kms-impl-device.h
@@ -28,6 +28,13 @@
 #include "backends/native/meta-kms-types.h"
 #include "backends/native/meta-kms-update.h"
 
+typedef struct _MetaKmsDeviceCaps
+{
+  gboolean has_cursor_size;
+  uint64_t cursor_width;
+  uint64_t cursor_height;
+} MetaKmsDeviceCaps;
+
 #define META_TYPE_KMS_IMPL_DEVICE (meta_kms_impl_device_get_type ())
 G_DECLARE_FINAL_TYPE (MetaKmsImplDevice, meta_kms_impl_device,
                       META, KMS_IMPL_DEVICE,
@@ -41,6 +48,8 @@ GList * meta_kms_impl_device_copy_crtcs (MetaKmsImplDevice *impl_device);
 
 GList * meta_kms_impl_device_copy_planes (MetaKmsImplDevice *impl_device);
 
+const MetaKmsDeviceCaps * meta_kms_impl_device_get_caps (MetaKmsImplDevice *impl_device);
+
 gboolean meta_kms_impl_device_dispatch (MetaKmsImplDevice  *impl_device,
                                         GError            **error);
 


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