aboutsummaryrefslogtreecommitdiffstats
path: root/src/gbm/main/gbm.c
diff options
context:
space:
mode:
authorEric Anholt <[email protected]>2018-11-02 14:35:06 -0700
committerEric Anholt <[email protected]>2018-11-12 15:20:23 -0800
commit6328536ff28ca26f2ad4e6f2c956c467acebda88 (patch)
tree118c06fa9d1914f808d99a9c7995896df95c8b91 /src/gbm/main/gbm.c
parentee7f848c000112a98e9614f42921b176be473792 (diff)
gbm: Introduce a helper function for printing GBM format names.
This requires that the caller make a little (stack) allocation to store the string. v2: Use gbm_format_canonicalize (suggested by Daniel) Reviewed-by: Eric Engestrom <[email protected]> Reviewed-by: Daniel Stone <[email protected]>
Diffstat (limited to 'src/gbm/main/gbm.c')
-rw-r--r--src/gbm/main/gbm.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/gbm/main/gbm.c b/src/gbm/main/gbm.c
index d301661b48e..2e2014205cb 100644
--- a/src/gbm/main/gbm.c
+++ b/src/gbm/main/gbm.c
@@ -711,3 +711,23 @@ gbm_format_canonicalize(uint32_t gbm_format)
return gbm_format;
}
}
+
+/**
+ * Returns a string representing the fourcc format name.
+ *
+ * \param desc Caller-provided storage for the format name string.
+ * \return String containing the fourcc of the format.
+ */
+GBM_EXPORT char *
+gbm_format_get_name(uint32_t gbm_format, struct gbm_format_name_desc *desc)
+{
+ gbm_format = gbm_format_canonicalize(gbm_format);
+
+ desc->name[0] = gbm_format;
+ desc->name[1] = gbm_format >> 8;
+ desc->name[2] = gbm_format >> 16;
+ desc->name[3] = gbm_format >> 24;
+ desc->name[4] = 0;
+
+ return desc->name;
+}