[mutter/wip/rstrode/rhel-8.0.0: 25/30] crtc/kms: Add fallback primary plane formats



commit e121e5284e6c18823326387b1ca8fbdeb9dfe3f1
Author: Pekka Paalanen <pekka paalanen collabora com>
Date:   Wed Nov 21 14:21:20 2018 +0200

    crtc/kms: Add fallback primary plane formats
    
    This avoids having to hardcode the same fallbacks elsewhere multiple
    times when determining what formats might be suitable for a set of
    CRTCs. The formats_modifiers hash table is now guaranteed to be
    populated with at least something, so future code will not need to
    handle it being empty.
    
    The hardcoded fallback formats are a minimal set probably supported by
    most hardware. XRGB8888 is the format that, according to ancient lore,
    all DRM devices should support, especially if they don't have the
    capability to advertise otherwise. Mutter also hardcodes XRGB8888 as the
    GBM surface format, so it is already required on primary GPUs.
    
    XBGR8888 matches the most common OpenGL format, sans alpha channel since
    scanout hardware has not traditionally supported alpha. XBGR8888 is here
    also because Mutter hardcodes that format for secondary GPU outputs when
    using the CPU copy path.
    
    https://gitlab.gnome.org/GNOME/mutter/merge_requests/341

 src/backends/native/meta-crtc-kms.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
---
diff --git a/src/backends/native/meta-crtc-kms.c b/src/backends/native/meta-crtc-kms.c
index 2cede326e..abcee8f9e 100644
--- a/src/backends/native/meta-crtc-kms.c
+++ b/src/backends/native/meta-crtc-kms.c
@@ -213,6 +213,19 @@ free_modifier_array (GArray *arr)
   g_array_free (arr, TRUE);
 }
 
+/*
+ * In case the DRM driver does not expose a format list for the
+ * primary plane (does not support universal planes nor
+ * IN_FORMATS property), hardcode something that is probably supported.
+ */
+static const uint32_t drm_default_formats[] =
+  {
+    DRM_FORMAT_XRGB8888 /* The format everything should always support by convention */,
+#if G_BYTE_ORDER == G_LITTLE_ENDIAN
+    DRM_FORMAT_XBGR8888 /* OpenGL GL_RGBA, GL_UNSIGNED_BYTE format, hopefully supported */
+#endif
+  };
+
 static void
 set_formats_from_array (MetaCrtc       *crtc,
                         const uint32_t *formats,
@@ -409,6 +422,14 @@ init_crtc_rotations (MetaCrtc *crtc,
   crtc->all_transforms |= crtc_kms->all_hw_transforms;
 
   drmModeFreePlaneResources (planes);
+
+  /* final formats fallback to something hardcoded */
+  if (g_hash_table_size (crtc_kms->formats_modifiers) == 0)
+    {
+      set_formats_from_array (crtc,
+                              drm_default_formats,
+                              G_N_ELEMENTS (drm_default_formats));
+    }
 }
 
 static void


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