msm_vidc_debug.h 4.3 KB

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