msm_vidc_debug.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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_INST VIDC_DBG_LABEL ": %4s: %s: "
  17. #define VIDC_DBG_TAG_CORE VIDC_DBG_LABEL ": %4s: %08x: %s: "
  18. #define FW_DBG_TAG VIDC_DBG_LABEL ": %6s: "
  19. #define DEFAULT_SID ((u32)-1)
  20. extern int msm_vidc_debug;
  21. extern bool msm_vidc_lossless_encode;
  22. extern bool msm_vidc_syscache_disable;
  23. extern int msm_vidc_clock_voting;
  24. /* To enable messages OR these values and
  25. * echo the result to debugfs file.
  26. *
  27. * To enable all messages set debug_level = 0x101F
  28. */
  29. enum vidc_msg_prio {
  30. VIDC_ERR = 0x00000001,
  31. VIDC_HIGH = 0x00000002,
  32. VIDC_LOW = 0x00000004,
  33. VIDC_PERF = 0x00000008,
  34. VIDC_PKT = 0x00000010,
  35. VIDC_BUS = 0x00000020,
  36. VIDC_ENCODER = 0x00000100,
  37. VIDC_DECODER = 0x00000200,
  38. VIDC_PRINTK = 0x00001000,
  39. VIDC_FTRACE = 0x00002000,
  40. FW_LOW = 0x00010000,
  41. FW_MED = 0x00020000,
  42. FW_HIGH = 0x00040000,
  43. FW_ERROR = 0x00080000,
  44. FW_FATAL = 0x00100000,
  45. FW_PERF = 0x00200000,
  46. FW_PRINTK = 0x10000000,
  47. FW_FTRACE = 0x20000000,
  48. };
  49. #define FW_LOGSHIFT 16
  50. #define FW_LOGMASK 0x0FFF0000
  51. #define dprintk_inst(__level, __level_str, inst, __fmt, ...) \
  52. do { \
  53. if (inst && (msm_vidc_debug & __level)) { \
  54. pr_info(VIDC_DBG_TAG_INST __fmt, \
  55. __level_str, \
  56. inst->debug_str, \
  57. ##__VA_ARGS__); \
  58. } \
  59. } while (0)
  60. #define i_vpr_e(inst, __fmt, ...) dprintk_inst(VIDC_ERR, "err ", inst, __fmt, ##__VA_ARGS__)
  61. #define i_vpr_i(inst, __fmt, ...) dprintk_inst(VIDC_HIGH, "high", inst, __fmt, ##__VA_ARGS__)
  62. #define i_vpr_h(inst, __fmt, ...) dprintk_inst(VIDC_HIGH, "high", inst, __fmt, ##__VA_ARGS__)
  63. #define i_vpr_l(inst, __fmt, ...) dprintk_inst(VIDC_LOW, "low ", inst, __fmt, ##__VA_ARGS__)
  64. #define i_vpr_p(inst, __fmt, ...) dprintk_inst(VIDC_PERF, "perf", inst, __fmt, ##__VA_ARGS__)
  65. #define i_vpr_t(inst, __fmt, ...) dprintk_inst(VIDC_PKT, "pkt ", inst, __fmt, ##__VA_ARGS__)
  66. #define i_vpr_b(inst, __fmt, ...) dprintk_inst(VIDC_BUS, "bus ", inst, __fmt, ##__VA_ARGS__)
  67. #define dprintk_core(__level, __level_str, __fmt, ...) \
  68. do { \
  69. if (msm_vidc_debug & __level) { \
  70. pr_info(VIDC_DBG_TAG_CORE __fmt, \
  71. __level_str, \
  72. DEFAULT_SID, \
  73. "codec", \
  74. ##__VA_ARGS__); \
  75. } \
  76. } while (0)
  77. #define d_vpr_e(__fmt, ...) dprintk_core(VIDC_ERR, "err ", __fmt, ##__VA_ARGS__)
  78. #define d_vpr_h(__fmt, ...) dprintk_core(VIDC_HIGH, "high", __fmt, ##__VA_ARGS__)
  79. #define d_vpr_l(__fmt, ...) dprintk_core(VIDC_LOW, "low ", __fmt, ##__VA_ARGS__)
  80. #define d_vpr_p(__fmt, ...) dprintk_core(VIDC_PERF, "perf", __fmt, ##__VA_ARGS__)
  81. #define d_vpr_t(__fmt, ...) dprintk_core(VIDC_PKT, "pkt ", __fmt, ##__VA_ARGS__)
  82. #define d_vpr_b(__fmt, ...) dprintk_core(VIDC_BUS, "bus ", __fmt, ##__VA_ARGS__)
  83. #define dprintk_ratelimit(__level, __level_str, __fmt, ...) \
  84. do { \
  85. if (msm_vidc_check_ratelimit()) { \
  86. dprintk_core(__level, __level_str, __fmt, ##__VA_ARGS__); \
  87. } \
  88. } while (0)
  89. #define dprintk_firmware(__level, __fmt, ...) \
  90. do { \
  91. if (__level & FW_PRINTK) { \
  92. pr_info(FW_DBG_TAG __fmt, \
  93. "fw", \
  94. ##__VA_ARGS__); \
  95. } \
  96. } while (0)
  97. #define MSM_VIDC_ERROR(value) \
  98. do { if (value) \
  99. d_vpr_e("BugOn"); \
  100. } while (0)
  101. enum msm_vidc_debugfs_event {
  102. MSM_VIDC_DEBUGFS_EVENT_ETB,
  103. MSM_VIDC_DEBUGFS_EVENT_EBD,
  104. MSM_VIDC_DEBUGFS_EVENT_FTB,
  105. MSM_VIDC_DEBUGFS_EVENT_FBD,
  106. };
  107. struct dentry *msm_vidc_debugfs_init_drv(void);
  108. struct dentry *msm_vidc_debugfs_init_core(void *core);
  109. struct dentry *msm_vidc_debugfs_init_inst(void *inst,
  110. struct dentry *parent);
  111. void msm_vidc_debugfs_deinit_inst(void *inst);
  112. void msm_vidc_debugfs_update(void *inst,
  113. enum msm_vidc_debugfs_event e);
  114. int msm_vidc_check_ratelimit(void);
  115. #endif