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