xref: /linux/drivers/gpu/drm/omapdrm/omap_debugfs.c (revision c884d8ac7ffccc094e9674a3eb3be90d3b296c0a)
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3  * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
4  * Author: Rob Clark <rob.clark@linaro.org>
5  */
6 
7 #include <linux/seq_file.h>
8 
9 #include <drm/drm_crtc.h>
10 #include <drm/drm_fb_helper.h>
11 
12 #include "omap_drv.h"
13 #include "omap_dmm_tiler.h"
14 
15 #ifdef CONFIG_DEBUG_FS
16 
17 static int gem_show(struct seq_file *m, void *arg)
18 {
19 	struct drm_info_node *node = (struct drm_info_node *) m->private;
20 	struct drm_device *dev = node->minor->dev;
21 	struct omap_drm_private *priv = dev->dev_private;
22 
23 	seq_printf(m, "All Objects:\n");
24 	mutex_lock(&priv->list_lock);
25 	omap_gem_describe_objects(&priv->obj_list, m);
26 	mutex_unlock(&priv->list_lock);
27 
28 	return 0;
29 }
30 
31 static int mm_show(struct seq_file *m, void *arg)
32 {
33 	struct drm_info_node *node = (struct drm_info_node *) m->private;
34 	struct drm_device *dev = node->minor->dev;
35 	struct drm_printer p = drm_seq_file_printer(m);
36 
37 	drm_mm_print(&dev->vma_offset_manager->vm_addr_space_mm, &p);
38 
39 	return 0;
40 }
41 
42 #ifdef CONFIG_DRM_FBDEV_EMULATION
43 static int fb_show(struct seq_file *m, void *arg)
44 {
45 	struct drm_info_node *node = (struct drm_info_node *) m->private;
46 	struct drm_device *dev = node->minor->dev;
47 	struct omap_drm_private *priv = dev->dev_private;
48 	struct drm_framebuffer *fb;
49 
50 	seq_printf(m, "fbcon ");
51 	omap_framebuffer_describe(priv->fbdev->fb, m);
52 
53 	mutex_lock(&dev->mode_config.fb_lock);
54 	list_for_each_entry(fb, &dev->mode_config.fb_list, head) {
55 		if (fb == priv->fbdev->fb)
56 			continue;
57 
58 		seq_printf(m, "user ");
59 		omap_framebuffer_describe(fb, m);
60 	}
61 	mutex_unlock(&dev->mode_config.fb_lock);
62 
63 	return 0;
64 }
65 #endif
66 
67 /* list of debufs files that are applicable to all devices */
68 static struct drm_info_list omap_debugfs_list[] = {
69 	{"gem", gem_show, 0},
70 	{"mm", mm_show, 0},
71 #ifdef CONFIG_DRM_FBDEV_EMULATION
72 	{"fb", fb_show, 0},
73 #endif
74 };
75 
76 /* list of debugfs files that are specific to devices with dmm/tiler */
77 static struct drm_info_list omap_dmm_debugfs_list[] = {
78 	{"tiler_map", tiler_map_show, 0},
79 };
80 
81 int omap_debugfs_init(struct drm_minor *minor)
82 {
83 	struct drm_device *dev = minor->dev;
84 	int ret;
85 
86 	ret = drm_debugfs_create_files(omap_debugfs_list,
87 			ARRAY_SIZE(omap_debugfs_list),
88 			minor->debugfs_root, minor);
89 
90 	if (ret) {
91 		dev_err(dev->dev, "could not install omap_debugfs_list\n");
92 		return ret;
93 	}
94 
95 	if (dmm_is_available())
96 		ret = drm_debugfs_create_files(omap_dmm_debugfs_list,
97 				ARRAY_SIZE(omap_dmm_debugfs_list),
98 				minor->debugfs_root, minor);
99 
100 	if (ret) {
101 		dev_err(dev->dev, "could not install omap_dmm_debugfs_list\n");
102 		return ret;
103 	}
104 
105 	return ret;
106 }
107 
108 #endif
109