xf86drm: add drmGetFormatName()
Same as drmGetFormatModifierName() but for formats. Signed-off-by: Simon Ser <contact@emersion.fr> Reviewed-by: Marius Vlad <marius.vlad@collabora.com> Reviewed-by: Eric Engestrom <eric@igalia.com>main
parent
03e0ab4d88
commit
baa4b8cafc
|
@ -203,3 +203,4 @@ drmUpdateDrawableInfo
|
||||||
drmWaitVBlank
|
drmWaitVBlank
|
||||||
drmGetFormatModifierName
|
drmGetFormatModifierName
|
||||||
drmGetFormatModifierVendor
|
drmGetFormatModifierVendor
|
||||||
|
drmGetFormatName
|
||||||
|
|
35
xf86drm.c
35
xf86drm.c
|
@ -5106,3 +5106,38 @@ drmGetFormatModifierName(uint64_t modifier)
|
||||||
|
|
||||||
return modifier_found;
|
return modifier_found;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a human-readable name for a DRM FourCC format.
|
||||||
|
*
|
||||||
|
* \param format The format.
|
||||||
|
* \return A malloc'ed string containing the format name. Caller is responsible
|
||||||
|
* for freeing it.
|
||||||
|
*/
|
||||||
|
drm_public char *
|
||||||
|
drmGetFormatName(uint32_t format)
|
||||||
|
{
|
||||||
|
char *str;
|
||||||
|
size_t str_size, i;
|
||||||
|
char a, b, c, d;
|
||||||
|
|
||||||
|
if (format == DRM_FORMAT_INVALID)
|
||||||
|
return strdup("INVALID");
|
||||||
|
|
||||||
|
str_size = 5;
|
||||||
|
str = malloc(str_size);
|
||||||
|
if (!str)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
a = (char) ((format >> 0) & 0xFF);
|
||||||
|
b = (char) ((format >> 8) & 0xFF);
|
||||||
|
c = (char) ((format >> 16) & 0xFF);
|
||||||
|
d = (char) ((format >> 24) & 0xFF);
|
||||||
|
snprintf(str, str_size, "%c%c%c%c", a, b, c, d);
|
||||||
|
|
||||||
|
/* Trim spaces at the end */
|
||||||
|
for (i = 3; i > 0 && str[i] == ' '; i--)
|
||||||
|
str[i] = '\0';
|
||||||
|
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
|
@ -954,6 +954,9 @@ drmGetFormatModifierVendor(uint64_t modifier);
|
||||||
extern char *
|
extern char *
|
||||||
drmGetFormatModifierName(uint64_t modifier);
|
drmGetFormatModifierName(uint64_t modifier);
|
||||||
|
|
||||||
|
extern char *
|
||||||
|
drmGetFormatName(uint32_t format);
|
||||||
|
|
||||||
#ifndef fourcc_mod_get_vendor
|
#ifndef fourcc_mod_get_vendor
|
||||||
#define fourcc_mod_get_vendor(modifier) \
|
#define fourcc_mod_get_vendor(modifier) \
|
||||||
(((modifier) >> 56) & 0xff)
|
(((modifier) >> 56) & 0xff)
|
||||||
|
|
Loading…
Reference in New Issue