blob: c0aa40f8ad6a22de5983a4ae9b6c431e3153f67b [file] [log] [blame]
Andy Gross6169a1482011-12-15 21:05:17 -06001/*
Rob Clark8bb0daf2013-02-11 12:43:09 -05002 * drivers/gpu/drm/omapdrm/omap_debugfs.c
Andy Gross6169a1482011-12-15 21:05:17 -06003 *
4 * Copyright (C) 2011 Texas Instruments
5 * Author: Rob Clark <rob.clark@linaro.org>
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License version 2 as published by
9 * the Free Software Foundation.
10 *
11 * This program is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 * more details.
15 *
16 * You should have received a copy of the GNU General Public License along with
17 * this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#include "omap_drv.h"
21#include "omap_dmm_tiler.h"
22
Rob Clarkf6b60362012-03-05 10:48:36 -060023#include "drm_fb_helper.h"
24
25
Andy Gross6169a1482011-12-15 21:05:17 -060026#ifdef CONFIG_DEBUG_FS
27
Rob Clarkf6b60362012-03-05 10:48:36 -060028static int gem_show(struct seq_file *m, void *arg)
29{
30 struct drm_info_node *node = (struct drm_info_node *) m->private;
31 struct drm_device *dev = node->minor->dev;
32 struct omap_drm_private *priv = dev->dev_private;
33 int ret;
34
35 ret = mutex_lock_interruptible(&dev->struct_mutex);
36 if (ret)
37 return ret;
38
39 seq_printf(m, "All Objects:\n");
40 omap_gem_describe_objects(&priv->obj_list, m);
41
42 mutex_unlock(&dev->struct_mutex);
43
44 return 0;
45}
46
47static int mm_show(struct seq_file *m, void *arg)
48{
49 struct drm_info_node *node = (struct drm_info_node *) m->private;
50 struct drm_device *dev = node->minor->dev;
51 return drm_mm_dump_table(m, dev->mm_private);
52}
53
54static int fb_show(struct seq_file *m, void *arg)
55{
56 struct drm_info_node *node = (struct drm_info_node *) m->private;
57 struct drm_device *dev = node->minor->dev;
58 struct omap_drm_private *priv = dev->dev_private;
59 struct drm_framebuffer *fb;
60 int ret;
61
62 ret = mutex_lock_interruptible(&dev->mode_config.mutex);
63 if (ret)
64 return ret;
65
66 ret = mutex_lock_interruptible(&dev->struct_mutex);
67 if (ret) {
68 mutex_unlock(&dev->mode_config.mutex);
69 return ret;
70 }
71
72 seq_printf(m, "fbcon ");
73 omap_framebuffer_describe(priv->fbdev->fb, m);
74
Daniel Vetter4b096ac2012-12-10 21:19:18 +010075 mutex_lock(&dev->mode_config.fb_lock);
Rob Clarkf6b60362012-03-05 10:48:36 -060076 list_for_each_entry(fb, &dev->mode_config.fb_list, head) {
77 if (fb == priv->fbdev->fb)
78 continue;
79
80 seq_printf(m, "user ");
81 omap_framebuffer_describe(fb, m);
82 }
Daniel Vetter4b096ac2012-12-10 21:19:18 +010083 mutex_unlock(&dev->mode_config.fb_lock);
Rob Clarkf6b60362012-03-05 10:48:36 -060084
85 mutex_unlock(&dev->struct_mutex);
86 mutex_unlock(&dev->mode_config.mutex);
87
88 return 0;
89}
90
91/* list of debufs files that are applicable to all devices */
Andy Gross6169a1482011-12-15 21:05:17 -060092static struct drm_info_list omap_debugfs_list[] = {
Rob Clarkf6b60362012-03-05 10:48:36 -060093 {"gem", gem_show, 0},
94 {"mm", mm_show, 0},
95 {"fb", fb_show, 0},
96};
97
98/* list of debugfs files that are specific to devices with dmm/tiler */
99static struct drm_info_list omap_dmm_debugfs_list[] = {
Andy Gross6169a1482011-12-15 21:05:17 -0600100 {"tiler_map", tiler_map_show, 0},
101};
102
103int omap_debugfs_init(struct drm_minor *minor)
104{
Rob Clarkf6b60362012-03-05 10:48:36 -0600105 struct drm_device *dev = minor->dev;
106 int ret;
107
108 ret = drm_debugfs_create_files(omap_debugfs_list,
Andy Gross6169a1482011-12-15 21:05:17 -0600109 ARRAY_SIZE(omap_debugfs_list),
110 minor->debugfs_root, minor);
Rob Clarkf6b60362012-03-05 10:48:36 -0600111
112 if (ret) {
113 dev_err(dev->dev, "could not install omap_debugfs_list\n");
114 return ret;
115 }
116
Andy Gross132390c2012-03-05 10:48:37 -0600117 if (dmm_is_available())
118 ret = drm_debugfs_create_files(omap_dmm_debugfs_list,
119 ARRAY_SIZE(omap_dmm_debugfs_list),
120 minor->debugfs_root, minor);
Rob Clarkf6b60362012-03-05 10:48:36 -0600121
122 if (ret) {
123 dev_err(dev->dev, "could not install omap_dmm_debugfs_list\n");
124 return ret;
125 }
126
127 return ret;
Andy Gross6169a1482011-12-15 21:05:17 -0600128}
129
130void omap_debugfs_cleanup(struct drm_minor *minor)
131{
132 drm_debugfs_remove_files(omap_debugfs_list,
133 ARRAY_SIZE(omap_debugfs_list), minor);
Andy Gross132390c2012-03-05 10:48:37 -0600134 if (dmm_is_available())
135 drm_debugfs_remove_files(omap_dmm_debugfs_list,
136 ARRAY_SIZE(omap_dmm_debugfs_list), minor);
Andy Gross6169a1482011-12-15 21:05:17 -0600137}
138
139#endif