aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/drm_crtc.c
diff options
context:
space:
mode:
authorVille Syrjälä <ville.syrjala@linux.intel.com>2013-06-10 04:15:10 -0400
committerDave Airlie <airlied@redhat.com>2013-06-10 18:13:54 -0400
commit6ba6d03e69125ef42a63e90d45e49c659ea3c34f (patch)
tree5a1d0fbe6fc7a61e51781ea732ce6ac049dbd1da /drivers/gpu/drm/drm_crtc.c
parentca793f75d91d61fd0009c4179eb88aac54a74239 (diff)
drm: Print pretty names for pixel formats
Rather than just printing the pixel format as a hex number, decode the fourcc into human readable form, and also decode the LE vs. BE flag. Keep printing the raw hex number too in case it contains non-printable characters. Some examples what the new drm_get_format_name() produces: DRM_FORMAT_XRGB8888: "XR24 little-endian (0x34325258)" DRM_FORMAT_YUYV: "YUYV little-endian (0x56595559)" DRM_FORMAT_RGB565|DRM_FORMAT_BIG_ENDIAN: "RG16 big-endian (0xb6314752)" Unprintable characters: "D??? big-endian (0xff7f0244)" v2: Fix patch author Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com> Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'drivers/gpu/drm/drm_crtc.c')
-rw-r--r--drivers/gpu/drm/drm_crtc.c29
1 files changed, 27 insertions, 2 deletions
diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
index e7e92429d10f..079996ad02a7 100644
--- a/drivers/gpu/drm/drm_crtc.c
+++ b/drivers/gpu/drm/drm_crtc.c
@@ -29,6 +29,7 @@
29 * Dave Airlie <airlied@linux.ie> 29 * Dave Airlie <airlied@linux.ie>
30 * Jesse Barnes <jesse.barnes@intel.com> 30 * Jesse Barnes <jesse.barnes@intel.com>
31 */ 31 */
32#include <linux/ctype.h>
32#include <linux/list.h> 33#include <linux/list.h>
33#include <linux/slab.h> 34#include <linux/slab.h>
34#include <linux/export.h> 35#include <linux/export.h>
@@ -252,6 +253,28 @@ char *drm_get_connector_status_name(enum drm_connector_status status)
252} 253}
253EXPORT_SYMBOL(drm_get_connector_status_name); 254EXPORT_SYMBOL(drm_get_connector_status_name);
254 255
256static char printable_char(int c)
257{
258 return isascii(c) && isprint(c) ? c : '?';
259}
260
261char *drm_get_format_name(uint32_t format)
262{
263 static char buf[32];
264
265 snprintf(buf, sizeof(buf),
266 "%c%c%c%c %s-endian (0x%08x)",
267 printable_char(format & 0xff),
268 printable_char((format >> 8) & 0xff),
269 printable_char((format >> 16) & 0xff),
270 printable_char((format >> 24) & 0x7f),
271 format & DRM_FORMAT_BIG_ENDIAN ? "big" : "little",
272 format);
273
274 return buf;
275}
276EXPORT_SYMBOL(drm_get_format_name);
277
255/** 278/**
256 * drm_mode_object_get - allocate a new modeset identifier 279 * drm_mode_object_get - allocate a new modeset identifier
257 * @dev: DRM device 280 * @dev: DRM device
@@ -1834,7 +1857,8 @@ int drm_mode_setplane(struct drm_device *dev, void *data,
1834 if (fb->pixel_format == plane->format_types[i]) 1857 if (fb->pixel_format == plane->format_types[i])
1835 break; 1858 break;
1836 if (i == plane->format_count) { 1859 if (i == plane->format_count) {
1837 DRM_DEBUG_KMS("Invalid pixel format 0x%08x\n", fb->pixel_format); 1860 DRM_DEBUG_KMS("Invalid pixel format %s\n",
1861 drm_get_format_name(fb->pixel_format));
1838 ret = -EINVAL; 1862 ret = -EINVAL;
1839 goto out; 1863 goto out;
1840 } 1864 }
@@ -2312,7 +2336,8 @@ static int framebuffer_check(const struct drm_mode_fb_cmd2 *r)
2312 2336
2313 ret = format_check(r); 2337 ret = format_check(r);
2314 if (ret) { 2338 if (ret) {
2315 DRM_DEBUG_KMS("bad framebuffer format 0x%08x\n", r->pixel_format); 2339 DRM_DEBUG_KMS("bad framebuffer format %s\n",
2340 drm_get_format_name(r->pixel_format));
2316 return ret; 2341 return ret;
2317 } 2342 }
2318 2343