gbm: Introduce a helper function for printing GBM format names.
[mesa.git] / src / gbm / main / gbm.c
index d301661b48ee4330cb965aff3fa105b709df44c3..2e2014205cb82e6cb44a23626defc1f9e4add9fc 100644 (file)
@@ -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;
+}