]> asedeno.scripts.mit.edu Git - linux.git/blob - drivers/gpu/drm/omapdrm/omap_debugfs.c
drm/omapdrm: drop use of drmP.h
[linux.git] / drivers / gpu / drm / omapdrm / omap_debugfs.c
1 /*
2  * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
3  * 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
18 #include <linux/seq_file.h>
19
20 #include <drm/drm_crtc.h>
21 #include <drm/drm_debugfs.h>
22 #include <drm/drm_file.h>
23 #include <drm/drm_fb_helper.h>
24
25 #include "omap_drv.h"
26 #include "omap_dmm_tiler.h"
27
28 #ifdef CONFIG_DEBUG_FS
29
30 static int gem_show(struct seq_file *m, void *arg)
31 {
32         struct drm_info_node *node = (struct drm_info_node *) m->private;
33         struct drm_device *dev = node->minor->dev;
34         struct omap_drm_private *priv = dev->dev_private;
35
36         seq_printf(m, "All Objects:\n");
37         mutex_lock(&priv->list_lock);
38         omap_gem_describe_objects(&priv->obj_list, m);
39         mutex_unlock(&priv->list_lock);
40
41         return 0;
42 }
43
44 static int mm_show(struct seq_file *m, void *arg)
45 {
46         struct drm_info_node *node = (struct drm_info_node *) m->private;
47         struct drm_device *dev = node->minor->dev;
48         struct drm_printer p = drm_seq_file_printer(m);
49
50         drm_mm_print(&dev->vma_offset_manager->vm_addr_space_mm, &p);
51
52         return 0;
53 }
54
55 #ifdef CONFIG_DRM_FBDEV_EMULATION
56 static int fb_show(struct seq_file *m, void *arg)
57 {
58         struct drm_info_node *node = (struct drm_info_node *) m->private;
59         struct drm_device *dev = node->minor->dev;
60         struct omap_drm_private *priv = dev->dev_private;
61         struct drm_framebuffer *fb;
62
63         seq_printf(m, "fbcon ");
64         omap_framebuffer_describe(priv->fbdev->fb, m);
65
66         mutex_lock(&dev->mode_config.fb_lock);
67         list_for_each_entry(fb, &dev->mode_config.fb_list, head) {
68                 if (fb == priv->fbdev->fb)
69                         continue;
70
71                 seq_printf(m, "user ");
72                 omap_framebuffer_describe(fb, m);
73         }
74         mutex_unlock(&dev->mode_config.fb_lock);
75
76         return 0;
77 }
78 #endif
79
80 /* list of debufs files that are applicable to all devices */
81 static struct drm_info_list omap_debugfs_list[] = {
82         {"gem", gem_show, 0},
83         {"mm", mm_show, 0},
84 #ifdef CONFIG_DRM_FBDEV_EMULATION
85         {"fb", fb_show, 0},
86 #endif
87 };
88
89 /* list of debugfs files that are specific to devices with dmm/tiler */
90 static struct drm_info_list omap_dmm_debugfs_list[] = {
91         {"tiler_map", tiler_map_show, 0},
92 };
93
94 int omap_debugfs_init(struct drm_minor *minor)
95 {
96         struct drm_device *dev = minor->dev;
97         int ret;
98
99         ret = drm_debugfs_create_files(omap_debugfs_list,
100                         ARRAY_SIZE(omap_debugfs_list),
101                         minor->debugfs_root, minor);
102
103         if (ret) {
104                 dev_err(dev->dev, "could not install omap_debugfs_list\n");
105                 return ret;
106         }
107
108         if (dmm_is_available())
109                 ret = drm_debugfs_create_files(omap_dmm_debugfs_list,
110                                 ARRAY_SIZE(omap_dmm_debugfs_list),
111                                 minor->debugfs_root, minor);
112
113         if (ret) {
114                 dev_err(dev->dev, "could not install omap_dmm_debugfs_list\n");
115                 return ret;
116         }
117
118         return ret;
119 }
120
121 #endif