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 | |
Arnd Bergmann | 2d80245 | 2016-05-11 18:01:45 +0200 | [diff] [blame] | 20 | #include <linux/seq_file.h> |
| 21 | |
Laurent Pinchart | 2d278f5 | 2015-03-05 21:31:37 +0200 | [diff] [blame] | 22 | #include <drm/drm_crtc.h> |
| 23 | #include <drm/drm_fb_helper.h> |
| 24 | |
Andy Gross | 6169a148 | 2011-12-15 21:05:17 -0600 | [diff] [blame] | 25 | #include "omap_drv.h" |
| 26 | #include "omap_dmm_tiler.h" |
| 27 | |
| 28 | #ifdef CONFIG_DEBUG_FS |
| 29 | |
Rob Clark | f6b6036 | 2012-03-05 10:48:36 -0600 | [diff] [blame] | 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 | int ret; |
| 36 | |
| 37 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 38 | if (ret) |
| 39 | return ret; |
| 40 | |
| 41 | seq_printf(m, "All Objects:\n"); |
| 42 | omap_gem_describe_objects(&priv->obj_list, m); |
| 43 | |
| 44 | mutex_unlock(&dev->struct_mutex); |
| 45 | |
| 46 | return 0; |
| 47 | } |
| 48 | |
| 49 | static int mm_show(struct seq_file *m, void *arg) |
| 50 | { |
| 51 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 52 | struct drm_device *dev = node->minor->dev; |
Daniel Vetter | b5c3714 | 2016-12-29 12:09:24 +0100 | [diff] [blame] | 53 | struct drm_printer p = drm_seq_file_printer(m); |
| 54 | |
| 55 | drm_mm_print(&dev->vma_offset_manager->vm_addr_space_mm, &p); |
| 56 | |
| 57 | return 0; |
Rob Clark | f6b6036 | 2012-03-05 10:48:36 -0600 | [diff] [blame] | 58 | } |
| 59 | |
Laurent Pinchart | e1c1174 | 2015-12-14 22:39:30 +0200 | [diff] [blame] | 60 | #ifdef CONFIG_DRM_FBDEV_EMULATION |
Rob Clark | f6b6036 | 2012-03-05 10:48:36 -0600 | [diff] [blame] | 61 | static int fb_show(struct seq_file *m, void *arg) |
| 62 | { |
| 63 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 64 | struct drm_device *dev = node->minor->dev; |
| 65 | struct omap_drm_private *priv = dev->dev_private; |
| 66 | struct drm_framebuffer *fb; |
Rob Clark | f6b6036 | 2012-03-05 10:48:36 -0600 | [diff] [blame] | 67 | |
| 68 | seq_printf(m, "fbcon "); |
| 69 | omap_framebuffer_describe(priv->fbdev->fb, m); |
| 70 | |
Daniel Vetter | 4b096ac | 2012-12-10 21:19:18 +0100 | [diff] [blame] | 71 | mutex_lock(&dev->mode_config.fb_lock); |
Rob Clark | f6b6036 | 2012-03-05 10:48:36 -0600 | [diff] [blame] | 72 | list_for_each_entry(fb, &dev->mode_config.fb_list, head) { |
| 73 | if (fb == priv->fbdev->fb) |
| 74 | continue; |
| 75 | |
| 76 | seq_printf(m, "user "); |
| 77 | omap_framebuffer_describe(fb, m); |
| 78 | } |
Daniel Vetter | 4b096ac | 2012-12-10 21:19:18 +0100 | [diff] [blame] | 79 | mutex_unlock(&dev->mode_config.fb_lock); |
Rob Clark | f6b6036 | 2012-03-05 10:48:36 -0600 | [diff] [blame] | 80 | |
Rob Clark | f6b6036 | 2012-03-05 10:48:36 -0600 | [diff] [blame] | 81 | return 0; |
| 82 | } |
Laurent Pinchart | e1c1174 | 2015-12-14 22:39:30 +0200 | [diff] [blame] | 83 | #endif |
Rob Clark | f6b6036 | 2012-03-05 10:48:36 -0600 | [diff] [blame] | 84 | |
| 85 | /* list of debufs files that are applicable to all devices */ |
Andy Gross | 6169a148 | 2011-12-15 21:05:17 -0600 | [diff] [blame] | 86 | static struct drm_info_list omap_debugfs_list[] = { |
Rob Clark | f6b6036 | 2012-03-05 10:48:36 -0600 | [diff] [blame] | 87 | {"gem", gem_show, 0}, |
| 88 | {"mm", mm_show, 0}, |
Laurent Pinchart | e1c1174 | 2015-12-14 22:39:30 +0200 | [diff] [blame] | 89 | #ifdef CONFIG_DRM_FBDEV_EMULATION |
Rob Clark | f6b6036 | 2012-03-05 10:48:36 -0600 | [diff] [blame] | 90 | {"fb", fb_show, 0}, |
Laurent Pinchart | e1c1174 | 2015-12-14 22:39:30 +0200 | [diff] [blame] | 91 | #endif |
Rob Clark | f6b6036 | 2012-03-05 10:48:36 -0600 | [diff] [blame] | 92 | }; |
| 93 | |
| 94 | /* list of debugfs files that are specific to devices with dmm/tiler */ |
| 95 | static struct drm_info_list omap_dmm_debugfs_list[] = { |
Andy Gross | 6169a148 | 2011-12-15 21:05:17 -0600 | [diff] [blame] | 96 | {"tiler_map", tiler_map_show, 0}, |
| 97 | }; |
| 98 | |
| 99 | int omap_debugfs_init(struct drm_minor *minor) |
| 100 | { |
Rob Clark | f6b6036 | 2012-03-05 10:48:36 -0600 | [diff] [blame] | 101 | struct drm_device *dev = minor->dev; |
| 102 | int ret; |
| 103 | |
| 104 | ret = drm_debugfs_create_files(omap_debugfs_list, |
Andy Gross | 6169a148 | 2011-12-15 21:05:17 -0600 | [diff] [blame] | 105 | ARRAY_SIZE(omap_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_debugfs_list\n"); |
| 110 | return ret; |
| 111 | } |
| 112 | |
Andy Gross | 132390c | 2012-03-05 10:48:37 -0600 | [diff] [blame] | 113 | if (dmm_is_available()) |
| 114 | ret = drm_debugfs_create_files(omap_dmm_debugfs_list, |
| 115 | ARRAY_SIZE(omap_dmm_debugfs_list), |
| 116 | minor->debugfs_root, minor); |
Rob Clark | f6b6036 | 2012-03-05 10:48:36 -0600 | [diff] [blame] | 117 | |
| 118 | if (ret) { |
| 119 | dev_err(dev->dev, "could not install omap_dmm_debugfs_list\n"); |
| 120 | return ret; |
| 121 | } |
| 122 | |
| 123 | return ret; |
Andy Gross | 6169a148 | 2011-12-15 21:05:17 -0600 | [diff] [blame] | 124 | } |
| 125 | |
Andy Gross | 6169a148 | 2011-12-15 21:05:17 -0600 | [diff] [blame] | 126 | #endif |