Andy Gross | 6169a148 | 2011-12-15 21:05:17 -0600 | [diff] [blame] | 1 | /* |
Rob Clark | 8bb0daf | 2013-02-11 12:43:09 -0500 | [diff] [blame] | 2 | * drivers/gpu/drm/omapdrm/omap_debugfs.c |
Andy Gross | 6169a148 | 2011-12-15 21:05:17 -0600 | [diff] [blame] | 3 | * |
| 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 | |
Laurent Pinchart | 2d278f5 | 2015-03-05 21:31:37 +0200 | [diff] [blame^] | 20 | #include <drm/drm_crtc.h> |
| 21 | #include <drm/drm_fb_helper.h> |
| 22 | |
Andy Gross | 6169a148 | 2011-12-15 21:05:17 -0600 | [diff] [blame] | 23 | #include "omap_drv.h" |
| 24 | #include "omap_dmm_tiler.h" |
| 25 | |
| 26 | #ifdef CONFIG_DEBUG_FS |
| 27 | |
Rob Clark | f6b6036 | 2012-03-05 10:48:36 -0600 | [diff] [blame] | 28 | static 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 | |
| 47 | static 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 Vetter | b04a590 | 2013-12-11 14:24:46 +0100 | [diff] [blame] | 51 | return drm_mm_dump_table(m, &dev->vma_offset_manager->vm_addr_space_mm); |
Rob Clark | f6b6036 | 2012-03-05 10:48:36 -0600 | [diff] [blame] | 52 | } |
| 53 | |
| 54 | static 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; |
Rob Clark | f6b6036 | 2012-03-05 10:48:36 -0600 | [diff] [blame] | 60 | |
| 61 | seq_printf(m, "fbcon "); |
| 62 | omap_framebuffer_describe(priv->fbdev->fb, m); |
| 63 | |
Daniel Vetter | 4b096ac | 2012-12-10 21:19:18 +0100 | [diff] [blame] | 64 | mutex_lock(&dev->mode_config.fb_lock); |
Rob Clark | f6b6036 | 2012-03-05 10:48:36 -0600 | [diff] [blame] | 65 | list_for_each_entry(fb, &dev->mode_config.fb_list, head) { |
| 66 | if (fb == priv->fbdev->fb) |
| 67 | continue; |
| 68 | |
| 69 | seq_printf(m, "user "); |
| 70 | omap_framebuffer_describe(fb, m); |
| 71 | } |
Daniel Vetter | 4b096ac | 2012-12-10 21:19:18 +0100 | [diff] [blame] | 72 | mutex_unlock(&dev->mode_config.fb_lock); |
Rob Clark | f6b6036 | 2012-03-05 10:48:36 -0600 | [diff] [blame] | 73 | |
Rob Clark | f6b6036 | 2012-03-05 10:48:36 -0600 | [diff] [blame] | 74 | return 0; |
| 75 | } |
| 76 | |
| 77 | /* list of debufs files that are applicable to all devices */ |
Andy Gross | 6169a148 | 2011-12-15 21:05:17 -0600 | [diff] [blame] | 78 | static struct drm_info_list omap_debugfs_list[] = { |
Rob Clark | f6b6036 | 2012-03-05 10:48:36 -0600 | [diff] [blame] | 79 | {"gem", gem_show, 0}, |
| 80 | {"mm", mm_show, 0}, |
| 81 | {"fb", fb_show, 0}, |
| 82 | }; |
| 83 | |
| 84 | /* list of debugfs files that are specific to devices with dmm/tiler */ |
| 85 | static struct drm_info_list omap_dmm_debugfs_list[] = { |
Andy Gross | 6169a148 | 2011-12-15 21:05:17 -0600 | [diff] [blame] | 86 | {"tiler_map", tiler_map_show, 0}, |
| 87 | }; |
| 88 | |
| 89 | int omap_debugfs_init(struct drm_minor *minor) |
| 90 | { |
Rob Clark | f6b6036 | 2012-03-05 10:48:36 -0600 | [diff] [blame] | 91 | struct drm_device *dev = minor->dev; |
| 92 | int ret; |
| 93 | |
| 94 | ret = drm_debugfs_create_files(omap_debugfs_list, |
Andy Gross | 6169a148 | 2011-12-15 21:05:17 -0600 | [diff] [blame] | 95 | ARRAY_SIZE(omap_debugfs_list), |
| 96 | minor->debugfs_root, minor); |
Rob Clark | f6b6036 | 2012-03-05 10:48:36 -0600 | [diff] [blame] | 97 | |
| 98 | if (ret) { |
| 99 | dev_err(dev->dev, "could not install omap_debugfs_list\n"); |
| 100 | return ret; |
| 101 | } |
| 102 | |
Andy Gross | 132390c | 2012-03-05 10:48:37 -0600 | [diff] [blame] | 103 | if (dmm_is_available()) |
| 104 | ret = drm_debugfs_create_files(omap_dmm_debugfs_list, |
| 105 | ARRAY_SIZE(omap_dmm_debugfs_list), |
| 106 | minor->debugfs_root, minor); |
Rob Clark | f6b6036 | 2012-03-05 10:48:36 -0600 | [diff] [blame] | 107 | |
| 108 | if (ret) { |
| 109 | dev_err(dev->dev, "could not install omap_dmm_debugfs_list\n"); |
| 110 | return ret; |
| 111 | } |
| 112 | |
| 113 | return ret; |
Andy Gross | 6169a148 | 2011-12-15 21:05:17 -0600 | [diff] [blame] | 114 | } |
| 115 | |
| 116 | void omap_debugfs_cleanup(struct drm_minor *minor) |
| 117 | { |
| 118 | drm_debugfs_remove_files(omap_debugfs_list, |
| 119 | ARRAY_SIZE(omap_debugfs_list), minor); |
Andy Gross | 132390c | 2012-03-05 10:48:37 -0600 | [diff] [blame] | 120 | if (dmm_is_available()) |
| 121 | drm_debugfs_remove_files(omap_dmm_debugfs_list, |
| 122 | ARRAY_SIZE(omap_dmm_debugfs_list), minor); |
Andy Gross | 6169a148 | 2011-12-15 21:05:17 -0600 | [diff] [blame] | 123 | } |
| 124 | |
| 125 | #endif |