msm_vidc_debug.h 3.9 KB

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