[PATCH 5/8] drm/gem-fb-helper: Add drm_gem_fb_debugfs_show()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Add drm_gem_fb_debugfs_show() function to provide a debugfs
representation of the framebuffer and GEM object(s).

Signed-off-by: Noralf Trønnes <noralf@xxxxxxxxxxx>
---
 drivers/gpu/drm/drm_gem_framebuffer_helper.c | 45 ++++++++++++++++++++++++++++
 include/drm/drm_gem_framebuffer_helper.h     |  6 ++++
 2 files changed, 51 insertions(+)

diff --git a/drivers/gpu/drm/drm_gem_framebuffer_helper.c b/drivers/gpu/drm/drm_gem_framebuffer_helper.c
index fc7e995..054eee0 100644
--- a/drivers/gpu/drm/drm_gem_framebuffer_helper.c
+++ b/drivers/gpu/drm/drm_gem_framebuffer_helper.c
@@ -245,6 +245,51 @@ int drm_gem_fb_prepare_fb(struct drm_plane *plane,
 }
 EXPORT_SYMBOL_GPL(drm_gem_fb_prepare_fb);
 
+#ifdef CONFIG_DEBUG_FS
+static void drm_gem_fb_describe(struct drm_framebuffer *fb, struct seq_file *m)
+{
+	struct drm_gem_object *obj;
+	unsigned int i;
+
+	seq_printf(m, "[FB:%d] %dx%d@%4.4s\n", fb->base.id, fb->width,
+		   fb->height, (char *)&fb->format->format);
+
+	for (i = 0; i < fb->format->num_planes; i++) {
+		obj = fb->obj[i];
+		seq_printf(m, "\t%u: offset=%d pitch=%d, GEM: name=%d",
+			   i, fb->offsets[i], fb->pitches[i], obj->name);
+		seq_printf(m, " refcount=%d start=%08lx size=%zu%s\n",
+			   kref_read(&obj->refcount),
+			   drm_vma_node_start(&obj->vma_node), obj->size,
+			   obj->import_attach ? " (imported)" : "");
+	}
+}
+
+/**
+ * drm_gem_fb_debugfs_show() - Helper to list GEM backed framebuffer objects
+ *                             in debugfs.
+ * @m: Output file
+ * @arg: Private data for the callback
+ *
+ * This function gives a debugfs representation of the framebuffers with their
+ * backing GEM objects. See drm_debugfs_create_files() for more info.
+ */
+int drm_gem_fb_debugfs_show(struct seq_file *m, void *arg)
+{
+	struct drm_info_node *node = m->private;
+	struct drm_device *dev = node->minor->dev;
+	struct drm_framebuffer *fb;
+
+	mutex_lock(&dev->mode_config.fb_lock);
+	drm_for_each_fb(fb, dev)
+		drm_gem_fb_describe(fb, m);
+	mutex_unlock(&dev->mode_config.fb_lock);
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(drm_gem_fb_debugfs_show);
+#endif
+
 /**
  * drm_gem_fbdev_fb_create - Create a drm_framebuffer for fbdev emulation
  * @dev: DRM device
diff --git a/include/drm/drm_gem_framebuffer_helper.h b/include/drm/drm_gem_framebuffer_helper.h
index 5ca7cdc..1bb73d9 100644
--- a/include/drm/drm_gem_framebuffer_helper.h
+++ b/include/drm/drm_gem_framebuffer_helper.h
@@ -28,6 +28,12 @@ drm_gem_fb_create(struct drm_device *dev, struct drm_file *file,
 int drm_gem_fb_prepare_fb(struct drm_plane *plane,
 			  struct drm_plane_state *state);
 
+#ifdef CONFIG_DEBUG_FS
+struct seq_file;
+
+int drm_gem_fb_debugfs_show(struct seq_file *m, void *arg);
+#endif
+
 struct drm_framebuffer *
 drm_gem_fbdev_fb_create(struct drm_device *dev,
 			struct drm_fb_helper_surface_size *sizes,
-- 
2.7.4

_______________________________________________
dri-devel mailing list
dri-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/dri-devel




[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux