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
This commit is contained in:
Pekka Paalanen 2018-11-21 15:15:27 +02:00 committed by Jonas Ådahl
parent 7f2dbb6c44
commit 23e7a0a099
2 changed files with 59 additions and 0 deletions

View File

@ -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)
{

View File

@ -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);