msm_vidc_debug.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2020, The Linux Foundation. All rights reserved.
  4. */
  5. #ifndef __MSM_VIDC_DEBUG__
  6. #define __MSM_VIDC_DEBUG__
  7. #include <linux/debugfs.h>
  8. #include <linux/delay.h>
  9. #include <linux/types.h>
  10. #ifndef VIDC_DBG_LABEL
  11. #define VIDC_DBG_LABEL "msm_vidc"
  12. #endif
  13. /* Allow only 6 prints/sec */
  14. #define VIDC_DBG_SESSION_RATELIMIT_INTERVAL (1 * HZ)
  15. #define VIDC_DBG_SESSION_RATELIMIT_BURST 6
  16. #define VIDC_DBG_TAG VIDC_DBG_LABEL ": %6s: %08x: %5s: "
  17. #define FW_DBG_TAG VIDC_DBG_LABEL ": %6s: "
  18. #define DEFAULT_SID ((u32)-1)
  19. extern int msm_vidc_debug;
  20. extern bool msm_vidc_lossless_encode;
  21. extern bool msm_vidc_syscache_disable;
  22. extern int msm_vidc_clock_voting;
  23. /* To enable messages OR these values and
  24. * echo the result to debugfs file.
  25. *
  26. * To enable all messages set debug_level = 0x101F
  27. */
  28. enum vidc_msg_prio {
  29. VIDC_ERR = 0x00000001,
  30. VIDC_HIGH = 0x00000002,
  31. VIDC_LOW = 0x00000004,
  32. VIDC_PERF = 0x00000008,
  33. VIDC_PKT = 0x00000010,
  34. VIDC_BUS = 0x00000020,
  35. VIDC_ENCODER = 0x00000100,
  36. VIDC_DECODER = 0x00000200,
  37. VIDC_PRINTK = 0x00001000,
  38. VIDC_FTRACE = 0x00002000,
  39. FW_LOW = 0x00010000,
  40. FW_MED = 0x00020000,
  41. FW_HIGH = 0x00040000,
  42. FW_ERROR = 0x00080000,
  43. FW_FATAL = 0x00100000,
  44. FW_PERF = 0x00200000,
  45. FW_PRINTK = 0x10000000,
  46. FW_FTRACE = 0x20000000,
  47. };
  48. #define FW_LOGSHIFT 16
  49. #define FW_LOGMASK 0x0FFF0000
  50. #define dprintk_inst(__level, inst, __fmt, ...) \
  51. do { \
  52. if (inst && (msm_vidc_debug & __level)) { \
  53. pr_err(VIDC_DBG_TAG __fmt, \
  54. level_str(__level), \
  55. get_sid(inst), \
  56. codec_str(inst), \
  57. ##__VA_ARGS__); \
  58. } \
  59. } while (0)
  60. #define i_vpr_e(inst, __fmt, ...) dprintk_inst(VIDC_ERR, inst, __fmt, ##__VA_ARGS__)
  61. #define i_vpr_i(inst, __fmt, ...) dprintk_inst(VIDC_HIGH, inst, __fmt, ##__VA_ARGS__)
  62. #define i_vpr_h(inst, __fmt, ...) dprintk_inst(VIDC_HIGH, inst, __fmt, ##__VA_ARGS__)
  63. #define i_vpr_l(inst, __fmt, ...) dprintk_inst(VIDC_LOW, inst, __fmt, ##__VA_ARGS__)
  64. #define i_vpr_p(inst, __fmt, ...) dprintk_inst(VIDC_PERF, inst, __fmt, ##__VA_ARGS__)
  65. #define i_vpr_t(inst, __fmt, ...) dprintk_inst(VIDC_PKT, inst, __fmt, ##__VA_ARGS__)
  66. #define i_vpr_b(inst, __fmt, ...) dprintk_inst(VIDC_BUS, inst, __fmt, ##__VA_ARGS__)
  67. #define i_vpr_hp(inst, __fmt, ...) \
  68. dprintk_inst(VIDC_HIGH | VIDC_PERF, inst, __fmt, ##__VA_ARGS__)
  69. #define dprintk(__level, sid, __fmt, ...) \
  70. do { \
  71. if (msm_vidc_debug & __level) { \
  72. pr_err(VIDC_DBG_TAG __fmt, \
  73. level_str(__level), \
  74. sid, \
  75. "codec", \
  76. ##__VA_ARGS__); \
  77. } \
  78. } while (0)
  79. #define d_vpr_e(__fmt, ...) \
  80. dprintk(VIDC_ERR, DEFAULT_SID, __fmt, ##__VA_ARGS__)
  81. #define d_vpr_i(__fmt, ...) \
  82. dprintk(VIDC_HIGH, DEFAULT_SID, __fmt, ##__VA_ARGS__)
  83. #define d_vpr_h(__fmt, ...) \
  84. dprintk(VIDC_HIGH, DEFAULT_SID, __fmt, ##__VA_ARGS__)
  85. #define d_vpr_l(__fmt, ...) \
  86. dprintk(VIDC_LOW, DEFAULT_SID, __fmt, ##__VA_ARGS__)
  87. #define d_vpr_p(__fmt, ...) \
  88. dprintk(VIDC_PERF, DEFAULT_SID, __fmt, ##__VA_ARGS__)
  89. #define d_vpr_t(__fmt, ...) \
  90. dprintk(VIDC_PKT, DEFAULT_SID, __fmt, ##__VA_ARGS__)
  91. #define d_vpr_b(__fmt, ...) \
  92. dprintk(VIDC_BUS, DEFAULT_SID, __fmt, ##__VA_ARGS__)
  93. #define dprintk_firmware(__level, __fmt, ...) \
  94. do { \
  95. pr_err(FW_DBG_TAG __fmt, \
  96. "fw", \
  97. ##__VA_ARGS__); \
  98. } while (0)
  99. #define dprintk_ratelimit(__level, __fmt, ...) \
  100. do { \
  101. if (msm_vidc_check_ratelimit()) { \
  102. dprintk(__level, DEFAULT_SID, __fmt, ##__VA_ARGS__); \
  103. } \
  104. } while (0)
  105. #define MSM_VIDC_ERROR(value) \
  106. do { if (value) \
  107. d_vpr_e("BugOn"); \
  108. } while (0)
  109. const char *level_str(u32 level);
  110. const char *codec_str(void *instance);
  111. u32 get_sid(void *instance);
  112. enum msm_vidc_debugfs_event {
  113. MSM_VIDC_DEBUGFS_EVENT_ETB,
  114. MSM_VIDC_DEBUGFS_EVENT_EBD,
  115. MSM_VIDC_DEBUGFS_EVENT_FTB,
  116. MSM_VIDC_DEBUGFS_EVENT_FBD,
  117. };
  118. struct dentry *msm_vidc_debugfs_init_drv(void);
  119. struct dentry *msm_vidc_debugfs_init_core(void *core);
  120. struct dentry *msm_vidc_debugfs_init_inst(void *inst,
  121. struct dentry *parent);
  122. void msm_vidc_debugfs_deinit_inst(void *inst);
  123. void msm_vidc_debugfs_update(void *inst,
  124. enum msm_vidc_debugfs_event e);
  125. int msm_vidc_check_ratelimit(void);
  126. #endif