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