tpd_debug.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Copyright (C) 2019 MediaTek Inc.
  4. */
  5. #ifndef TPD_DEBUG_H
  6. #define TPD_DEBUG_H
  7. #ifdef TPD_DEBUG_CODE
  8. #include<linux/i2c.h>
  9. extern int tpd_debug_nr;
  10. void tpd_debug_set_time(void);
  11. extern int tpd_debug_time;
  12. extern long tpd_last_2_int_time[2];
  13. extern long tpd_last_down_time;
  14. extern int tpd_start_profiling;
  15. extern int tpd_down_status;
  16. #define TPD_DEBUG_PRINT_INT \
  17. do { \
  18. if (tpd_debug_time) { \
  19. pr_info("tp_int\n"); \
  20. } \
  21. } while (0)
  22. #define TPD_DEBUG_PRINT_UP \
  23. do { \
  24. if (pending == 0 && tpd_debug_time) { \
  25. tpd_down_status = 0; \
  26. pr_debug("up on %ld ms (+%ld ms)\n", \
  27. (tpd_last_2_int_time[1] - tpd_last_down_time) / 1000, \
  28. (tpd_last_2_int_time[1] - tpd_last_2_int_time[0]) / 1000); \
  29. } \
  30. } while (0)
  31. #define TPD_DEBUG_PRINT_DOWN \
  32. do { \
  33. if (tpd_debug_time) { \
  34. if (tpd_down_status == 0)\
  35. pr_debug("down on 0 ms\n"); \
  36. else \
  37. pr_debug("move on %ld ms (+%ld ms)\n", \
  38. (tpd_last_2_int_time[1] - \
  39. tpd_last_down_time) / 1000, \
  40. (tpd_last_2_int_time[1] -\
  41. tpd_last_2_int_time[0]) / 1000); \
  42. tpd_down_status = 1; \
  43. } \
  44. } while (0)
  45. #define TPD_DEBUG_SET_TIME do { tpd_debug_set_time(); } while (0)
  46. extern int tpd_em_log;
  47. extern int tpd_em_log_to_fs;
  48. extern int tpd_type_cap;
  49. void tpd_em_log_output(int raw_x,
  50. int raw_y, int cal_x, int cal_y, int p, int down);
  51. void tpd_em_log_store(int raw_x,
  52. int raw_y, int cal_x, int cal_y, int p, int down);
  53. void tpd_em_log_release(void);
  54. void tpd_enable_em_log(int enable);
  55. #ifndef CREATE_TRACE_POINTS
  56. #define CREATE_TRACE_POINTS
  57. #endif
  58. noinline void MET_touch(int raw_x, int raw_y,
  59. int cal_x, int cal_y, int p, int down);
  60. #define TPD_TYPE_RAW_DATA 2
  61. #define TPD_TYPE_INT_DOWN 3
  62. #define TPD_TYPE_INT_UP 4
  63. #define TPD_TYPE_TIMER 5
  64. #define TPD_TYPE_REJECT1 6
  65. #define TPD_TYPE_REJECT2 7
  66. #define TPD_TYPE_FIST_LATENCY 8
  67. #define TPD_EM_PRINT(raw_x, raw_y, cal_x, cal_y, p, down)\
  68. do { \
  69. if (tpd_em_log) {\
  70. if (!tpd_em_log_to_fs) { \
  71. tpd_em_log_output(raw_x, \
  72. raw_y, cal_x, cal_y, p, down); \
  73. } else { \
  74. tpd_em_log_store(raw_x, \
  75. raw_y, cal_x, cal_y, p, down); \
  76. tpd_em_log_output(raw_x, \
  77. raw_y, cal_x, cal_y, p, down); \
  78. } \
  79. } else { \
  80. if (tpd_em_log_to_fs) { \
  81. tpd_em_log_release(); \
  82. } \
  83. } \
  84. MET_touch(raw_x, raw_y, cal_x, cal_y, p, down); \
  85. } while (0)
  86. #ifdef TPD_DEBUG_TRACK
  87. extern void *dal_fb_addr;
  88. extern int tpd_debug_track;
  89. void tpd_up_debug_track(int x, int y);
  90. void tpd_down_debug_track(int x, int y);
  91. #define TPD_UP_DEBUG_TRACK(x, y) \
  92. do { \
  93. if (tpd_debug_track) \
  94. tpd_up_debug_track(x, y); \
  95. } while (0)
  96. #define TPD_DOWN_DEBUG_TRACK(x, y) \
  97. do { \
  98. if (tpd_debug_track) \
  99. tpd_down_debug_track(x, y); \
  100. } while (0)
  101. #endif /* TPD_DEBUG_TRACK */
  102. #endif /* TPD_DEBUG_CODE */
  103. /* Macros that will be embedded in code */
  104. #ifndef TPD_DEBUG_SET_TIME
  105. #define TPD_DEBUG_SET_TIME
  106. #endif
  107. #ifndef TPD_DEBUG_PRINT_UP
  108. #define TPD_DEBUG_PRINT_UP
  109. #endif
  110. #ifndef TPD_DEBUG_PRINT_DOWN
  111. #define TPD_DEBUG_PRINT_DOWN
  112. #endif
  113. #ifndef TPD_UP_DEBUG_TRACK
  114. #define TPD_UP_DEBUG_TRACK(x, y)
  115. #endif
  116. #ifndef TPD_DOWN_DEBUG_TRACK
  117. #define TPD_DOWN_DEBUG_TRACK(x, y)
  118. #endif
  119. #endif /* TPD_DEBUG_H */