Commit 8a0d0ce9 authored by Pekka Paalanen's avatar Pekka Paalanen Committed by Jonas Ådahl

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.

parent 0789c3fb
......@@ -211,6 +211,19 @@ free_modifier_array (GArray *array)
g_array_free (array, 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 */,
DRM_FORMAT_XBGR8888 /* OpenGL GL_RGBA, GL_UNSIGNED_BYTE format, hopefully supported */
static void
set_formats_from_array (MetaCrtc *crtc,
const uint32_t *formats,
......@@ -407,6 +420,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,
G_N_ELEMENTS (drm_default_formats));
static void
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment