drm/rockchip: add drm summary debugfs node
authorMark Yao <mark.yao@rock-chips.com>
Fri, 30 Dec 2016 09:03:51 +0000 (17:03 +0800)
committerHuang, Tao <huangtao@rock-chips.com>
Tue, 3 Jan 2017 06:26:07 +0000 (14:26 +0800)
With the summary debug node, show current display status would be easier.

Using step:
shell# cat /sys/kernel/debug/dri/0/summary

vop name: ff900000.vop status=active
Display mode: 1200x1920 fps[60] clk[160000] type[8] flag[a]
        H: 1200 1320 1340 1361
        V: 1920 1941 1944 1962
win0-0: status=active
        format: AB24 little-endian (0x34324241)
        zpos: 0
        src: pos[0x0] rect[1200x1920]
        dst: pos[0x0] rect[1200x1920]
        buf[0]: addr: 0x9e19000 pitch: 4800 offset: 0
win1-0: status=disabled
win2-0: status=disabled
win2-0: status=disabled
win2-1: status=disabled
win2-2: status=disabled
win3-0: status=disabled
win3-0: status=disabled
win3-1: status=disabled
win3-2: status=disabled
vop name: ff8f0000.vop status=disabled

Change-Id: I386398b0617f0c18902c4cadad5906be343cc4de
Signed-off-by: Mark Yao <mark.yao@rock-chips.com>
drivers/gpu/drm/rockchip/rockchip_drm_drv.c
drivers/gpu/drm/rockchip/rockchip_drm_drv.h
drivers/gpu/drm/rockchip/rockchip_drm_vop.c

index f3d954d01201812951de1abaa545706992976818..ce0b385a5f611750cf69be51dc06484b2ba74ec1 100644 (file)
@@ -771,6 +771,54 @@ static void rockchip_iommu_cleanup(struct drm_device *drm_dev)
        iommu_domain_free(private->domain);
 }
 
+#ifdef CONFIG_DEBUG_FS
+static int rockchip_drm_summary_show(struct seq_file *s, void *data)
+{
+       struct drm_info_node *node = s->private;
+       struct drm_minor *minor = node->minor;
+       struct drm_device *drm_dev = minor->dev;
+       struct rockchip_drm_private *priv = drm_dev->dev_private;
+       struct drm_crtc *crtc;
+
+       drm_for_each_crtc(crtc, drm_dev) {
+               int pipe = drm_crtc_index(crtc);
+
+               if (priv->crtc_funcs[pipe] &&
+                   priv->crtc_funcs[pipe]->debugfs_dump)
+                       priv->crtc_funcs[pipe]->debugfs_dump(crtc, s);
+       }
+
+       return 0;
+}
+
+static struct drm_info_list rockchip_debugfs_files[] = {
+       { "summary", rockchip_drm_summary_show, 0, NULL },
+};
+
+static int rockchip_drm_debugfs_init(struct drm_minor *minor)
+{
+       struct drm_device *dev = minor->dev;
+       int ret;
+
+       ret = drm_debugfs_create_files(rockchip_debugfs_files,
+                                      ARRAY_SIZE(rockchip_debugfs_files),
+                                      minor->debugfs_root,
+                                      minor);
+       if (ret) {
+               dev_err(dev->dev, "could not install rockchip_debugfs_list\n");
+               return ret;
+       }
+
+       return 0;
+}
+
+static void rockchip_drm_debugfs_cleanup(struct drm_minor *minor)
+{
+       drm_debugfs_remove_files(rockchip_debugfs_files,
+                                ARRAY_SIZE(rockchip_debugfs_files), minor);
+}
+#endif
+
 static int rockchip_drm_bind(struct device *dev)
 {
        struct drm_device *drm_dev;
@@ -1060,6 +1108,10 @@ static struct drm_driver rockchip_drm_driver = {
        .gem_prime_vmap         = rockchip_gem_prime_vmap,
        .gem_prime_vunmap       = rockchip_gem_prime_vunmap,
        .gem_prime_mmap         = rockchip_gem_mmap_buf,
+#ifdef CONFIG_DEBUG_FS
+       .debugfs_init           = rockchip_drm_debugfs_init,
+       .debugfs_cleanup        = rockchip_drm_debugfs_cleanup,
+#endif
        .ioctls                 = rockchip_ioctls,
        .num_ioctls             = ARRAY_SIZE(rockchip_ioctls),
        .fops                   = &rockchip_drm_driver_fops,
index 172f214d81c98a70a27910b2aadabda1f48059d9..2f80d7d88dfb8fed5fe57f9cf96c9cc55af6f146 100644 (file)
@@ -44,6 +44,7 @@ struct rockchip_crtc_funcs {
        void (*disable_vblank)(struct drm_crtc *crtc);
        void (*wait_for_update)(struct drm_crtc *crtc);
        void (*cancel_pending_vblank)(struct drm_crtc *crtc, struct drm_file *file_priv);
+       int (*debugfs_dump)(struct drm_crtc *crtc, struct seq_file *s);
 };
 
 struct drm_rockchip_subdrv {
index 77980e75de0c088bf1dd67eb5568f43f7aa3ea12..f1485fdc90a86c3da5300115093951cd2ce23399 100644 (file)
@@ -1323,12 +1323,76 @@ static int vop_crtc_loader_protect(struct drm_crtc *crtc, bool on)
        return 0;
 }
 
+static int vop_plane_info_dump(struct seq_file *s, struct drm_plane *plane)
+{
+       struct vop_win *win = to_vop_win(plane);
+       struct drm_plane_state *state = plane->state;
+       struct vop_plane_state *pstate = to_vop_plane_state(state);
+       struct drm_rect *src, *dest;
+       struct drm_framebuffer *fb = state->fb;
+       int i;
+
+       seq_printf(s, "win%d-%d: status=%s\n", win->win_id, win->area_id,
+                  pstate->enable ? "active" : "disabled");
+       if (!fb)
+               return 0;
+
+       src = &pstate->src;
+       dest = &pstate->dest;
+
+       seq_printf(s, "\tformat: %s\n", drm_get_format_name(fb->pixel_format));
+       seq_printf(s, "\tzpos: %d\n", pstate->zpos);
+       seq_printf(s, "\tsrc: pos[%dx%d] rect[%dx%d]\n", src->x1 >> 16,
+                  src->y1 >> 16, drm_rect_width(src) >> 16,
+                  drm_rect_height(src) >> 16);
+       seq_printf(s, "\tdst: pos[%dx%d] rect[%dx%d]\n", dest->x1, dest->y1,
+                  drm_rect_width(dest), drm_rect_height(dest));
+
+       for (i = 0; i < drm_format_num_planes(fb->pixel_format); i++)
+               seq_printf(s, "\tbuf[%d]: addr: 0x%llx pitch: %d offset: %d\n",
+                          i, rockchip_fb_get_dma_addr(fb, i),
+                          fb->pitches[i], fb->offsets[i]);
+
+       return 0;
+}
+
+static int vop_crtc_debugfs_dump(struct drm_crtc *crtc, struct seq_file *s)
+{
+       struct vop *vop = to_vop(crtc);
+       struct drm_crtc_state *crtc_state = crtc->state;
+       struct drm_display_mode *mode = &crtc->state->adjusted_mode;
+       struct drm_plane *plane;
+       int i;
+
+       seq_printf(s, "vop name: %s status=%s\n", dev_name(vop->dev),
+                  crtc_state->active ? "active" : "disabled");
+
+       if (!crtc_state->active)
+               return 0;
+
+       seq_printf(s, "Display mode: %s fps[%d] clk[%d] type[%d] flag[%x]\n",
+                  mode->name, drm_mode_vrefresh(mode), mode->clock,
+                  mode->type, mode->flags);
+       seq_printf(s, "\tH: %d %d %d %d\n", mode->hdisplay, mode->hsync_start,
+                  mode->hsync_end, mode->htotal);
+       seq_printf(s, "\tV: %d %d %d %d\n", mode->vdisplay, mode->vsync_start,
+                  mode->vsync_end, mode->vtotal);
+
+       for (i = 0; i < vop->num_wins; i++) {
+               plane = &vop->win[i].base;
+               vop_plane_info_dump(s, plane);
+       }
+
+       return 0;
+}
+
 static const struct rockchip_crtc_funcs private_crtc_funcs = {
        .loader_protect = vop_crtc_loader_protect,
        .enable_vblank = vop_crtc_enable_vblank,
        .disable_vblank = vop_crtc_disable_vblank,
        .wait_for_update = vop_crtc_wait_for_update,
        .cancel_pending_vblank = vop_crtc_cancel_pending_vblank,
+       .debugfs_dump = vop_crtc_debugfs_dump,
 };
 
 static bool vop_crtc_mode_fixup(struct drm_crtc *crtc,