blob: b42e286616b00b894b99e133c06d56b4b24db9be [file] [log] [blame]
Andy Gross6169a1482011-12-15 21:05:17 -06001/*
Andrew F. Davisbb5cdf82017-12-05 14:29:31 -06002 * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
Andy Gross6169a1482011-12-15 21:05:17 -06003 * Author: Rob Clark <rob.clark@linaro.org>
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 as published by
7 * the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along with
15 * this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
Arnd Bergmann2d802452016-05-11 18:01:45 +020018#include <linux/seq_file.h>
19
Laurent Pinchart2d278f52015-03-05 21:31:37 +020020#include <drm/drm_crtc.h>
21#include <drm/drm_fb_helper.h>
22
Andy Gross6169a1482011-12-15 21:05:17 -060023#include "omap_drv.h"
24#include "omap_dmm_tiler.h"
25
26#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;
Daniel Vetterb5c37142016-12-29 12:09:24 +010051 struct drm_printer p = drm_seq_file_printer(m);
52
53 drm_mm_print(&dev->vma_offset_manager->vm_addr_space_mm, &p);
54
55 return 0;
Rob Clarkf6b60362012-03-05 10:48:36 -060056}
57
Laurent Pincharte1c11742015-12-14 22:39:30 +020058#ifdef CONFIG_DRM_FBDEV_EMULATION
Rob Clarkf6b60362012-03-05 10:48:36 -060059static int fb_show(struct seq_file *m, void *arg)
60{
61 struct drm_info_node *node = (struct drm_info_node *) m->private;
62 struct drm_device *dev = node->minor->dev;
63 struct omap_drm_private *priv = dev->dev_private;
64 struct drm_framebuffer *fb;
Rob Clarkf6b60362012-03-05 10:48:36 -060065
66 seq_printf(m, "fbcon ");
67 omap_framebuffer_describe(priv->fbdev->fb, m);
68
Daniel Vetter4b096ac2012-12-10 21:19:18 +010069 mutex_lock(&dev->mode_config.fb_lock);
Rob Clarkf6b60362012-03-05 10:48:36 -060070 list_for_each_entry(fb, &dev->mode_config.fb_list, head) {
71 if (fb == priv->fbdev->fb)
72 continue;
73
74 seq_printf(m, "user ");
75 omap_framebuffer_describe(fb, m);
76 }
Daniel Vetter4b096ac2012-12-10 21:19:18 +010077 mutex_unlock(&dev->mode_config.fb_lock);
Rob Clarkf6b60362012-03-05 10:48:36 -060078
Rob Clarkf6b60362012-03-05 10:48:36 -060079 return 0;
80}
Laurent Pincharte1c11742015-12-14 22:39:30 +020081#endif
Rob Clarkf6b60362012-03-05 10:48:36 -060082
83/* list of debufs files that are applicable to all devices */
Andy Gross6169a1482011-12-15 21:05:17 -060084static struct drm_info_list omap_debugfs_list[] = {
Rob Clarkf6b60362012-03-05 10:48:36 -060085 {"gem", gem_show, 0},
86 {"mm", mm_show, 0},
Laurent Pincharte1c11742015-12-14 22:39:30 +020087#ifdef CONFIG_DRM_FBDEV_EMULATION
Rob Clarkf6b60362012-03-05 10:48:36 -060088 {"fb", fb_show, 0},
Laurent Pincharte1c11742015-12-14 22:39:30 +020089#endif
Rob Clarkf6b60362012-03-05 10:48:36 -060090};
91
92/* list of debugfs files that are specific to devices with dmm/tiler */
93static struct drm_info_list omap_dmm_debugfs_list[] = {
Andy Gross6169a1482011-12-15 21:05:17 -060094 {"tiler_map", tiler_map_show, 0},
95};
96
97int omap_debugfs_init(struct drm_minor *minor)
98{
Rob Clarkf6b60362012-03-05 10:48:36 -060099 struct drm_device *dev = minor->dev;
100 int ret;
101
102 ret = drm_debugfs_create_files(omap_debugfs_list,
Andy Gross6169a1482011-12-15 21:05:17 -0600103 ARRAY_SIZE(omap_debugfs_list),
104 minor->debugfs_root, minor);
Rob Clarkf6b60362012-03-05 10:48:36 -0600105
106 if (ret) {
107 dev_err(dev->dev, "could not install omap_debugfs_list\n");
108 return ret;
109 }
110
Andy Gross132390c2012-03-05 10:48:37 -0600111 if (dmm_is_available())
112 ret = drm_debugfs_create_files(omap_dmm_debugfs_list,
113 ARRAY_SIZE(omap_dmm_debugfs_list),
114 minor->debugfs_root, minor);
Rob Clarkf6b60362012-03-05 10:48:36 -0600115
116 if (ret) {
117 dev_err(dev->dev, "could not install omap_dmm_debugfs_list\n");
118 return ret;
119 }
120
121 return ret;
Andy Gross6169a1482011-12-15 21:05:17 -0600122}
123
Andy Gross6169a1482011-12-15 21:05:17 -0600124#endif