]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
drm: helper macros to print composite types
authorRob Clark <robdclark@gmail.com>
Sat, 5 Nov 2016 15:08:06 +0000 (11:08 -0400)
committerSean Paul <seanpaul@chromium.org>
Tue, 8 Nov 2016 21:38:03 +0000 (16:38 -0500)
I'll want to print things in a similar way in a later patch.  This will
make it easier.

Signed-off-by: Rob Clark <robdclark@gmail.com>
Reviewed-by: Sean Paul <seanpaul@chromium.org>
Signed-off-by: Sean Paul <seanpaul@chromium.org>
Link: http://patchwork.freedesktop.org/patch/msgid/1478358492-30738-2-git-send-email-robdclark@gmail.com
drivers/gpu/drm/drm_modes.c
drivers/gpu/drm/drm_rect.c
include/drm/drmP.h

index f64ac86deb84aac6a93f8756121bb9d6910bacda..ce6eeda02acfa1bd4e89ce8d4eca3073777684b2 100644 (file)
  */
 void drm_mode_debug_printmodeline(const struct drm_display_mode *mode)
 {
-       DRM_DEBUG_KMS("Modeline %d:\"%s\" %d %d %d %d %d %d %d %d %d %d "
-                       "0x%x 0x%x\n",
-               mode->base.id, mode->name, mode->vrefresh, mode->clock,
-               mode->hdisplay, mode->hsync_start,
-               mode->hsync_end, mode->htotal,
-               mode->vdisplay, mode->vsync_start,
-               mode->vsync_end, mode->vtotal, mode->type, mode->flags);
+       DRM_DEBUG_KMS("Modeline " DRM_MODE_FMT "\n", DRM_MODE_ARG(mode));
 }
 EXPORT_SYMBOL(drm_mode_debug_printmodeline);
 
index 73e53a8d1b37c08a64ea862dacf51739fe85c15a..e6057d8cdcd5d3679f6d4bf1e84bbda057f6c82f 100644 (file)
@@ -281,17 +281,10 @@ EXPORT_SYMBOL(drm_rect_calc_vscale_relaxed);
  */
 void drm_rect_debug_print(const char *prefix, const struct drm_rect *r, bool fixed_point)
 {
-       int w = drm_rect_width(r);
-       int h = drm_rect_height(r);
-
        if (fixed_point)
-               DRM_DEBUG_KMS("%s%d.%06ux%d.%06u%+d.%06u%+d.%06u\n", prefix,
-                             w >> 16, ((w & 0xffff) * 15625) >> 10,
-                             h >> 16, ((h & 0xffff) * 15625) >> 10,
-                             r->x1 >> 16, ((r->x1 & 0xffff) * 15625) >> 10,
-                             r->y1 >> 16, ((r->y1 & 0xffff) * 15625) >> 10);
+               DRM_DEBUG_KMS("%s" DRM_RECT_FP_FMT "\n", prefix, DRM_RECT_FP_ARG(r));
        else
-               DRM_DEBUG_KMS("%s%dx%d%+d%+d\n", prefix, w, h, r->x1, r->y1);
+               DRM_DEBUG_KMS("%s" DRM_RECT_FMT "\n", prefix, DRM_RECT_ARG(r));
 }
 EXPORT_SYMBOL(drm_rect_debug_print);
 
index a3effab98407c06d8c76633d6461f52fa3650493..e92c904fe8cbd96a6e03a3ef42fe6527e9c59044 100644 (file)
@@ -306,6 +306,27 @@ void drm_printk(const char *level, unsigned int category,
 #define DRM_DEBUG_PRIME_RATELIMITED(fmt, args...)                      \
        DRM_DEV_DEBUG_PRIME_RATELIMITED(NULL, fmt, ##args)
 
+/* Format strings and argument splitters to simplify printing
+ * various "complex" objects
+ */
+#define DRM_MODE_FMT    "%d:\"%s\" %d %d %d %d %d %d %d %d %d %d 0x%x 0x%x"
+#define DRM_MODE_ARG(m) \
+       (m)->base.id, (m)->name, (m)->vrefresh, (m)->clock, \
+       (m)->hdisplay, (m)->hsync_start, (m)->hsync_end, (m)->htotal, \
+       (m)->vdisplay, (m)->vsync_start, (m)->vsync_end, (m)->vtotal, \
+       (m)->type, (m)->flags
+
+#define DRM_RECT_FMT    "%dx%d%+d%+d"
+#define DRM_RECT_ARG(r) drm_rect_width(r), drm_rect_height(r), (r)->x1, (r)->y1
+
+/* for rect's in fixed-point format: */
+#define DRM_RECT_FP_FMT "%d.%06ux%d.%06u%+d.%06u%+d.%06u"
+#define DRM_RECT_FP_ARG(r) \
+               drm_rect_width(r) >> 16, ((drm_rect_width(r) & 0xffff) * 15625) >> 10, \
+               drm_rect_height(r) >> 16, ((drm_rect_height(r) & 0xffff) * 15625) >> 10, \
+               (r)->x1 >> 16, (((r)->x1 & 0xffff) * 15625) >> 10, \
+               (r)->y1 >> 16, (((r)->y1 & 0xffff) * 15625) >> 10
+
 /*@}*/
 
 /***********************************************************************/