extd_debug.c 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. #if defined(CONFIG_MTK_HDMI_SUPPORT)
  2. #include <linux/string.h>
  3. #include <linux/time.h>
  4. #include <linux/uaccess.h>
  5. #include <linux/debugfs.h>
  6. /*#include <mach/mt_typedefs.h>*/
  7. #include <linux/types.h>
  8. /*#include <mach/mt_gpio.h>*/
  9. #include <mt-plat/mt_gpio.h>
  10. /* #include <cust_gpio_usage.h> */
  11. #include "ddp_hal.h"
  12. #include "ddp_reg.h"
  13. #include "ddp_info.h"
  14. #include "extd_hdmi.h"
  15. #include "external_display.h"
  16. /*extern DDP_MODULE_DRIVER *ddp_modules_driver[DISP_MODULE_NUM];*/
  17. /* --------------------------------------------------------------------------- */
  18. /* External variable declarations */
  19. /* --------------------------------------------------------------------------- */
  20. /* extern LCM_DRIVER *lcm_drv; */
  21. /* --------------------------------------------------------------------------- */
  22. /* Debug Options */
  23. /* --------------------------------------------------------------------------- */
  24. static const char STR_HELP[] = "\n" "USAGE\n" " echo [ACTION]... > hdmi\n" "\n" "ACTION\n"
  25. " hdmitx:[on|off]\n" " enable hdmi video output\n" "\n";
  26. /* TODO: this is a temp debug solution */
  27. /* extern void hdmi_cable_fake_plug_in(void); */
  28. /* extern int hdmi_drv_init(void); */
  29. static void process_dbg_opt(const char *opt)
  30. {
  31. if (0 == strncmp(opt, "on", 2))
  32. hdmi_power_on();
  33. else if (0 == strncmp(opt, "off", 3))
  34. hdmi_power_off();
  35. else if (0 == strncmp(opt, "suspend", 7))
  36. hdmi_suspend();
  37. else if (0 == strncmp(opt, "resume", 6))
  38. hdmi_resume();
  39. else if (0 == strncmp(opt, "fakecablein:", 12)) {
  40. if (0 == strncmp(opt + 12, "enable", 6))
  41. hdmi_cable_fake_plug_in();
  42. else if (0 == strncmp(opt + 12, "disable", 7))
  43. hdmi_cable_fake_plug_out();
  44. else
  45. goto Error;
  46. } else if (0 == strncmp(opt, "hdmireg", 7))
  47. ext_disp_diagnose();
  48. else if (0 == strncmp(opt, "I2S1:", 5)) {
  49. #ifdef GPIO_MHL_I2S_OUT_WS_PIN
  50. if (0 == strncmp(opt + 5, "on", 2)) {
  51. pr_debug("[hdmi][Debug] Enable I2S1\n");
  52. mt_set_gpio_mode(GPIO_MHL_I2S_OUT_WS_PIN, GPIO_MODE_01);
  53. mt_set_gpio_mode(GPIO_MHL_I2S_OUT_CK_PIN, GPIO_MODE_01);
  54. mt_set_gpio_mode(GPIO_MHL_I2S_OUT_DAT_PIN, GPIO_MODE_01);
  55. } else if (0 == strncmp(opt + 5, "off", 3)) {
  56. pr_debug("[hdmi][Debug] Disable I2S1\n");
  57. mt_set_gpio_mode(GPIO_MHL_I2S_OUT_WS_PIN, GPIO_MODE_02);
  58. mt_set_gpio_mode(GPIO_MHL_I2S_OUT_CK_PIN, GPIO_MODE_01);
  59. mt_set_gpio_mode(GPIO_MHL_I2S_OUT_DAT_PIN, GPIO_MODE_02);
  60. }
  61. #endif
  62. } else if (0 == strncmp(opt, "forceon", 7))
  63. hdmi_force_on(false);
  64. else if (0 == strncmp(opt, "extd_vsync:", 11)) {
  65. if (0 == strncmp(opt + 11, "on", 2))
  66. hdmi_wait_vsync_debug(1);
  67. else if (0 == strncmp(opt + 11, "off", 3))
  68. hdmi_wait_vsync_debug(0);
  69. } else
  70. goto Error;
  71. return;
  72. Error:
  73. pr_debug("[extd] parse command error!\n\n%s", STR_HELP);
  74. }
  75. static void process_dbg_cmd(char *cmd)
  76. {
  77. char *tok;
  78. pr_debug("[extd] %s\n", cmd);
  79. while ((tok = strsep(&cmd, " ")) != NULL)
  80. process_dbg_opt(tok);
  81. }
  82. /* --------------------------------------------------------------------------- */
  83. /* Debug FileSystem Routines */
  84. /* --------------------------------------------------------------------------- */
  85. struct dentry *extd_dbgfs = NULL;
  86. static int debug_open(struct inode *inode, struct file *file)
  87. {
  88. file->private_data = inode->i_private;
  89. return 0;
  90. }
  91. static char debug_buffer[2048];
  92. static ssize_t debug_read(struct file *file, char __user *ubuf, size_t count, loff_t *ppos)
  93. {
  94. const int debug_bufmax = sizeof(debug_buffer) - 1;
  95. int n = 0;
  96. n += scnprintf(debug_buffer + n, debug_bufmax - n, STR_HELP);
  97. debug_buffer[n++] = 0;
  98. return simple_read_from_buffer(ubuf, count, ppos, debug_buffer, n);
  99. }
  100. static ssize_t debug_write(struct file *file, const char __user *ubuf, size_t count, loff_t *ppos)
  101. {
  102. const int debug_bufmax = sizeof(debug_buffer) - 1;
  103. size_t ret;
  104. ret = count;
  105. if (count > debug_bufmax)
  106. count = debug_bufmax;
  107. if (copy_from_user(&debug_buffer, ubuf, count))
  108. return -EFAULT;
  109. debug_buffer[count] = 0;
  110. process_dbg_cmd(debug_buffer);
  111. return ret;
  112. }
  113. static const struct file_operations debug_fops = {
  114. .read = debug_read,
  115. .write = debug_write,
  116. .open = debug_open,
  117. };
  118. void Extd_DBG_Init(void)
  119. {
  120. extd_dbgfs = debugfs_create_file("extd", S_IFREG | S_IRUGO, NULL, (void *)0, &debug_fops);
  121. }
  122. void Extd_DBG_Deinit(void)
  123. {
  124. debugfs_remove(extd_dbgfs);
  125. }
  126. #endif