omap_debugfs.c 3.5 KB

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