omap_debugfs.c 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. /*
  2. * drivers/gpu/drm/omapdrm/omap_debugfs.c
  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. #include <drm/drm_crtc.h>
  20. #include <drm/drm_fb_helper.h>
  21. #include "omap_drv.h"
  22. #include "omap_dmm_tiler.h"
  23. #ifdef CONFIG_DEBUG_FS
  24. static int gem_show(struct seq_file *m, void *arg)
  25. {
  26. struct drm_info_node *node = (struct drm_info_node *) m->private;
  27. struct drm_device *dev = node->minor->dev;
  28. struct omap_drm_private *priv = dev->dev_private;
  29. int ret;
  30. ret = mutex_lock_interruptible(&dev->struct_mutex);
  31. if (ret)
  32. return ret;
  33. seq_printf(m, "All Objects:\n");
  34. omap_gem_describe_objects(&priv->obj_list, m);
  35. mutex_unlock(&dev->struct_mutex);
  36. return 0;
  37. }
  38. static int mm_show(struct seq_file *m, void *arg)
  39. {
  40. struct drm_info_node *node = (struct drm_info_node *) m->private;
  41. struct drm_device *dev = node->minor->dev;
  42. return drm_mm_dump_table(m, &dev->vma_offset_manager->vm_addr_space_mm);
  43. }
  44. static int fb_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 omap_drm_private *priv = dev->dev_private;
  49. struct drm_framebuffer *fb;
  50. seq_printf(m, "fbcon ");
  51. omap_framebuffer_describe(priv->fbdev->fb, m);
  52. mutex_lock(&dev->mode_config.fb_lock);
  53. list_for_each_entry(fb, &dev->mode_config.fb_list, head) {
  54. if (fb == priv->fbdev->fb)
  55. continue;
  56. seq_printf(m, "user ");
  57. omap_framebuffer_describe(fb, m);
  58. }
  59. mutex_unlock(&dev->mode_config.fb_lock);
  60. return 0;
  61. }
  62. /* list of debufs files that are applicable to all devices */
  63. static struct drm_info_list omap_debugfs_list[] = {
  64. {"gem", gem_show, 0},
  65. {"mm", mm_show, 0},
  66. {"fb", fb_show, 0},
  67. };
  68. /* list of debugfs files that are specific to devices with dmm/tiler */
  69. static struct drm_info_list omap_dmm_debugfs_list[] = {
  70. {"tiler_map", tiler_map_show, 0},
  71. };
  72. int omap_debugfs_init(struct drm_minor *minor)
  73. {
  74. struct drm_device *dev = minor->dev;
  75. int ret;
  76. ret = drm_debugfs_create_files(omap_debugfs_list,
  77. ARRAY_SIZE(omap_debugfs_list),
  78. minor->debugfs_root, minor);
  79. if (ret) {
  80. dev_err(dev->dev, "could not install omap_debugfs_list\n");
  81. return ret;
  82. }
  83. if (dmm_is_available())
  84. ret = drm_debugfs_create_files(omap_dmm_debugfs_list,
  85. ARRAY_SIZE(omap_dmm_debugfs_list),
  86. minor->debugfs_root, minor);
  87. if (ret) {
  88. dev_err(dev->dev, "could not install omap_dmm_debugfs_list\n");
  89. return ret;
  90. }
  91. return ret;
  92. }
  93. void omap_debugfs_cleanup(struct drm_minor *minor)
  94. {
  95. drm_debugfs_remove_files(omap_debugfs_list,
  96. ARRAY_SIZE(omap_debugfs_list), minor);
  97. if (dmm_is_available())
  98. drm_debugfs_remove_files(omap_dmm_debugfs_list,
  99. ARRAY_SIZE(omap_dmm_debugfs_list), minor);
  100. }
  101. #endif