Skip to content
Permalink
Browse files
drm: fourcc: add drm_get_format_name
  • Loading branch information
frank-w committed Oct 15, 2021
1 parent f028bc2 commit a958b73296c6541778093db348b18f9e3fe047bf
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
@@ -90,6 +90,26 @@ uint32_t drm_mode_legacy_fb_format(uint32_t bpp, uint32_t depth)
}
EXPORT_SYMBOL(drm_mode_legacy_fb_format);

/**
* drm_get_format_name - fill a string with a drm fourcc format's name
* @format: format to compute name of
* @buf: caller-supplied buffer
*/
const char *drm_get_format_name(uint32_t format, struct drm_format_name_buf *buf)
{
snprintf(buf->str, sizeof(buf->str),
"%c%c%c%c %s-endian (0x%08x)",
printable_char(format & 0xff),
printable_char((format >> 8) & 0xff),
printable_char((format >> 16) & 0xff),
printable_char((format >> 24) & 0x7f),
format & DRM_FORMAT_BIG_ENDIAN ? "big" : "little",
format);

return buf->str;
}
EXPORT_SYMBOL(drm_get_format_name);

/**
* drm_driver_legacy_fb_format - compute drm fourcc code from legacy description
* @dev: DRM device
@@ -30,6 +30,14 @@
*/
#define DRM_FORMAT_MAX_PLANES 4u

/**
* struct drm_format_name_buf - name of a DRM format
* @str: string buffer containing the format name
*/
struct drm_format_name_buf {
char str[32];
};

/*
* DRM formats are little endian. Define host endian variants for the
* most common formats here, to reduce the #ifdefs needed in drivers.
@@ -315,5 +323,5 @@ unsigned int drm_format_info_block_height(const struct drm_format_info *info,
int plane);
uint64_t drm_format_info_min_pitch(const struct drm_format_info *info,
int plane, unsigned int buffer_width);

const char *drm_get_format_name(uint32_t format, struct drm_format_name_buf *buf);
#endif /* __DRM_FOURCC_H__ */

0 comments on commit a958b73

Please sign in to comment.