mtk_dump.c 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. /*
  2. * Copyright (C) 2019 MediaTek Inc.
  3. *
  4. * This program is free software: you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License version 2 as
  6. * published by the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. */
  13. #include "mtk_drm_ddp_comp.h"
  14. #include "mtk_dump.h"
  15. static const char * const ddp_comp_str[] = {DECLARE_DDP_COMP(DECLARE_STR)};
  16. const char *mtk_dump_comp_str(struct mtk_ddp_comp *comp)
  17. {
  18. if (comp->id < 0) {
  19. DDPPR_ERR("%s: Invalid ddp comp id:%d\n", __func__, comp->id);
  20. comp->id = 0;
  21. }
  22. return ddp_comp_str[comp->id];
  23. }
  24. const char *mtk_dump_comp_str_id(unsigned int id)
  25. {
  26. if (likely(id < DDP_COMPONENT_ID_MAX))
  27. return ddp_comp_str[id];
  28. return "invalid";
  29. }
  30. int mtk_dump_reg(struct mtk_ddp_comp *comp)
  31. {
  32. switch (comp->id) {
  33. case DDP_COMPONENT_OVL0:
  34. case DDP_COMPONENT_OVL0_2L:
  35. case DDP_COMPONENT_OVL1_2L:
  36. case DDP_COMPONENT_OVL2_2L:
  37. case DDP_COMPONENT_OVL3_2L:
  38. mtk_ovl_dump(comp);
  39. break;
  40. case DDP_COMPONENT_RDMA0:
  41. case DDP_COMPONENT_RDMA1:
  42. case DDP_COMPONENT_RDMA4:
  43. case DDP_COMPONENT_RDMA5:
  44. mtk_rdma_dump(comp);
  45. break;
  46. case DDP_COMPONENT_WDMA0:
  47. case DDP_COMPONENT_WDMA1:
  48. mtk_wdma_dump(comp);
  49. break;
  50. case DDP_COMPONENT_RSZ0:
  51. case DDP_COMPONENT_RSZ1:
  52. mtk_rsz_dump(comp);
  53. break;
  54. case DDP_COMPONENT_DSI0:
  55. case DDP_COMPONENT_DSI1:
  56. mtk_dsi_dump(comp);
  57. break;
  58. #ifdef CONFIG_MTK_HDMI_SUPPORT
  59. case DDP_COMPONENT_DP_INTF0:
  60. mtk_dp_intf_dump(comp);
  61. break;
  62. #endif
  63. case DDP_COMPONENT_COLOR0:
  64. case DDP_COMPONENT_COLOR1:
  65. case DDP_COMPONENT_COLOR2:
  66. mtk_color_dump(comp);
  67. break;
  68. case DDP_COMPONENT_CCORR0:
  69. case DDP_COMPONENT_CCORR1:
  70. mtk_ccorr_dump(comp);
  71. break;
  72. case DDP_COMPONENT_AAL0:
  73. case DDP_COMPONENT_AAL1:
  74. mtk_aal_dump(comp);
  75. break;
  76. case DDP_COMPONENT_DMDP_AAL0:
  77. mtk_dmdp_aal_dump(comp);
  78. break;
  79. case DDP_COMPONENT_DITHER0:
  80. case DDP_COMPONENT_DITHER1:
  81. mtk_dither_dump(comp);
  82. break;
  83. case DDP_COMPONENT_GAMMA0:
  84. case DDP_COMPONENT_GAMMA1:
  85. mtk_gamma_dump(comp);
  86. break;
  87. case DDP_COMPONENT_POSTMASK0:
  88. case DDP_COMPONENT_POSTMASK1:
  89. mtk_postmask_dump(comp);
  90. break;
  91. case DDP_COMPONENT_DSC0:
  92. mtk_dsc_dump(comp);
  93. break;
  94. case DDP_COMPONENT_MERGE0:
  95. case DDP_COMPONENT_MERGE1:
  96. mtk_merge_dump(comp);
  97. break;
  98. default:
  99. return 0;
  100. }
  101. return 0;
  102. }
  103. int mtk_dump_analysis(struct mtk_ddp_comp *comp)
  104. {
  105. switch (comp->id) {
  106. case DDP_COMPONENT_OVL0:
  107. case DDP_COMPONENT_OVL1:
  108. case DDP_COMPONENT_OVL0_2L:
  109. case DDP_COMPONENT_OVL1_2L:
  110. case DDP_COMPONENT_OVL2_2L:
  111. case DDP_COMPONENT_OVL3_2L:
  112. mtk_ovl_analysis(comp);
  113. break;
  114. case DDP_COMPONENT_RDMA0:
  115. case DDP_COMPONENT_RDMA1:
  116. case DDP_COMPONENT_RDMA4:
  117. case DDP_COMPONENT_RDMA5:
  118. mtk_rdma_analysis(comp);
  119. break;
  120. case DDP_COMPONENT_WDMA0:
  121. case DDP_COMPONENT_WDMA1:
  122. mtk_wdma_analysis(comp);
  123. break;
  124. case DDP_COMPONENT_RSZ0:
  125. case DDP_COMPONENT_RSZ1:
  126. mtk_rsz_analysis(comp);
  127. break;
  128. case DDP_COMPONENT_DSI0:
  129. case DDP_COMPONENT_DSI1:
  130. mtk_dsi_analysis(comp);
  131. break;
  132. #ifdef CONFIG_MTK_HDMI_SUPPORT
  133. case DDP_COMPONENT_DP_INTF0:
  134. mtk_dp_intf_analysis(comp);
  135. break;
  136. #endif
  137. case DDP_COMPONENT_POSTMASK0:
  138. case DDP_COMPONENT_POSTMASK1:
  139. mtk_postmask_analysis(comp);
  140. break;
  141. case DDP_COMPONENT_DSC0:
  142. mtk_dsc_analysis(comp);
  143. break;
  144. case DDP_COMPONENT_MERGE0:
  145. case DDP_COMPONENT_MERGE1:
  146. mtk_merge_analysis(comp);
  147. default:
  148. return 0;
  149. }
  150. return 0;
  151. }
  152. void mtk_serial_dump_reg(void __iomem *base, unsigned int offset,
  153. unsigned int num)
  154. {
  155. unsigned int max_size = 54, i = 0, s = 0, l = 0;
  156. char buf[max_size];
  157. if (num > 4)
  158. num = 4;
  159. l = snprintf(buf, max_size, "0x%03x:", offset);
  160. for (i = 0; i < num; i++) {
  161. s = snprintf(buf + l, max_size, "0x%08x ",
  162. readl(base + offset + i * 0x4));
  163. l += s;
  164. }
  165. DDPDUMP("%s\n", buf);
  166. }
  167. void mtk_cust_dump_reg(void __iomem *base, int off1, int off2, int off3,
  168. int off4)
  169. {
  170. unsigned int max_size = 84, i = 0, s = 0, l = 0;
  171. int off[] = {off1, off2, off3, off4};
  172. char buf[max_size];
  173. for (i = 0; i < 4; i++) {
  174. if (off[i] < 0)
  175. break;
  176. s = snprintf(buf + l, max_size, "0x%03x:0x%08x ", off[i],
  177. readl(base + off[i]));
  178. if (s < 0) {
  179. /* Handle snprintf() error */
  180. return;
  181. }
  182. l += s;
  183. }
  184. DDPDUMP("%s\n", buf);
  185. }