[mutter] crtc/kms: Add primary plane format list accessors



commit 23e7a0a0997f90d043efbf119ea87bdaef32a8e7
Author: Pekka Paalanen <pekka paalanen collabora com>
Date:   Wed Nov 21 15:15:27 2018 +0200

    crtc/kms: Add primary plane format list accessors
    
    These functions allow inspecting which pixel formats a CRTC's primary
    plane supports. Future patches will inspect the supported formats and
    pick a framebuffer format accordingly instead of hardcoding a format.
    
    The copy list function will be used to initialize a formats list, and
    the supports format function will be used to intersect that list against
    another CRTC's supported formats.
    
    https://gitlab.gnome.org/GNOME/mutter/merge_requests/341

 src/backends/native/meta-crtc-kms.c | 51 +++++++++++++++++++++++++++++++++++++
 src/backends/native/meta-crtc-kms.h |  8 ++++++
 2 files changed, 59 insertions(+)
---
diff --git a/src/backends/native/meta-crtc-kms.c b/src/backends/native/meta-crtc-kms.c
index b11d2d6b6..803f6320e 100644
--- a/src/backends/native/meta-crtc-kms.c
+++ b/src/backends/native/meta-crtc-kms.c
@@ -203,6 +203,57 @@ meta_crtc_kms_get_modifiers (MetaCrtc *crtc,
                               GUINT_TO_POINTER (format));
 }
 
+/**
+ * meta_crtc_kms_copy_drm_format_list:
+ * @crtc: a #MetaCrtc object that has to be a #MetaCrtcKms
+ *
+ * Returns a new #GArray that the caller must destroy. The array
+ * contains all the DRM pixel formats the CRTC supports on
+ * its primary plane. The array element type is uint32_t.
+ */
+GArray *
+meta_crtc_kms_copy_drm_format_list (MetaCrtc *crtc)
+{
+  MetaCrtcKms *crtc_kms = crtc->driver_private;
+  GArray *formats;
+  GHashTableIter it;
+  gpointer key;
+  unsigned int n_formats_modifiers;
+
+  n_formats_modifiers = g_hash_table_size (crtc_kms->formats_modifiers);
+  formats = g_array_sized_new (FALSE,
+                               FALSE,
+                               sizeof (uint32_t),
+                               n_formats_modifiers);
+  g_hash_table_iter_init (&it, crtc_kms->formats_modifiers);
+  while (g_hash_table_iter_next (&it, &key, NULL))
+    {
+      uint32_t drm_format = GPOINTER_TO_UINT (key);
+      g_array_append_val (formats, drm_format);
+    }
+
+  return formats;
+}
+
+/**
+ * meta_crtc_kms_supports_format:
+ * @crtc: a #MetaCrtc object that has to be a #MetaCrtcKms
+ * @drm_format: a DRM pixel format
+ *
+ * Returns true if the CRTC supports the format on its primary plane.
+ */
+gboolean
+meta_crtc_kms_supports_format (MetaCrtc *crtc,
+                               uint32_t  drm_format)
+{
+  MetaCrtcKms *crtc_kms = crtc->driver_private;
+
+  return g_hash_table_lookup_extended (crtc_kms->formats_modifiers,
+                                       GUINT_TO_POINTER (drm_format),
+                                       NULL,
+                                       NULL);
+}
+
 static inline uint32_t *
 formats_ptr (struct drm_format_modifier_blob *blob)
 {
diff --git a/src/backends/native/meta-crtc-kms.h b/src/backends/native/meta-crtc-kms.h
index 3c03f1ade..e3c3da7cc 100644
--- a/src/backends/native/meta-crtc-kms.h
+++ b/src/backends/native/meta-crtc-kms.h
@@ -2,6 +2,7 @@
 
 /*
  * Copyright (C) 2017 Red Hat
+ * Copyright (C) 2018 DisplayLink (UK) Ltd.
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License as
@@ -40,6 +41,13 @@ void meta_crtc_kms_set_underscan (MetaCrtc *crtc,
 GArray * meta_crtc_kms_get_modifiers (MetaCrtc *crtc,
                                       uint32_t  format);
 
+GArray *
+meta_crtc_kms_copy_drm_format_list (MetaCrtc *crtc);
+
+gboolean
+meta_crtc_kms_supports_format (MetaCrtc *crtc,
+                               uint32_t  drm_format);
+
 MetaCrtc * meta_create_kms_crtc (MetaGpuKms   *gpu_kms,
                                  drmModeCrtc  *drm_crtc,
                                  unsigned int  crtc_index);


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