msm_vidc_debug.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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(__level, sid, __fmt, ...) \
  48. do { \
  49. if (msm_vidc_debug & __level) { \
  50. pr_err(VIDC_DBG_TAG __fmt, \
  51. level_str(__level), \
  52. sid, \
  53. "codec", \
  54. ##__VA_ARGS__); \
  55. } \
  56. } while (0)
  57. #define s_vpr_e(sid, __fmt, ...) dprintk(VIDC_ERR, sid, __fmt, ##__VA_ARGS__)
  58. #define s_vpr_i(sid, __fmt, ...) dprintk(VIDC_INFO, sid, __fmt, ##__VA_ARGS__)
  59. #define s_vpr_h(sid, __fmt, ...) dprintk(VIDC_HIGH, sid, __fmt, ##__VA_ARGS__)
  60. #define s_vpr_l(sid, __fmt, ...) dprintk(VIDC_LOW, sid, __fmt, ##__VA_ARGS__)
  61. #define s_vpr_p(sid, __fmt, ...) dprintk(VIDC_PERF, sid, __fmt, ##__VA_ARGS__)
  62. #define s_vpr_t(sid, __fmt, ...) dprintk(VIDC_PKT, sid, __fmt, ##__VA_ARGS__)
  63. #define s_vpr_b(sid, __fmt, ...) dprintk(VIDC_BUS, sid, __fmt, ##__VA_ARGS__)
  64. #define s_vpr_hp(sid, __fmt, ...) \
  65. dprintk(VIDC_HIGH|VIDC_PERF, sid, __fmt, ##__VA_ARGS__)
  66. #define d_vpr_e(__fmt, ...) \
  67. dprintk(VIDC_ERR, DEFAULT_SID, __fmt, ##__VA_ARGS__)
  68. #define d_vpr_i(__fmt, ...) \
  69. dprintk(VIDC_INFO, DEFAULT_SID, __fmt, ##__VA_ARGS__)
  70. #define d_vpr_h(__fmt, ...) \
  71. dprintk(VIDC_HIGH, DEFAULT_SID, __fmt, ##__VA_ARGS__)
  72. #define d_vpr_l(__fmt, ...) \
  73. dprintk(VIDC_LOW, DEFAULT_SID, __fmt, ##__VA_ARGS__)
  74. #define d_vpr_p(__fmt, ...) \
  75. dprintk(VIDC_PERF, DEFAULT_SID, __fmt, ##__VA_ARGS__)
  76. #define d_vpr_t(__fmt, ...) \
  77. dprintk(VIDC_PKT, DEFAULT_SID, __fmt, ##__VA_ARGS__)
  78. #define d_vpr_b(__fmt, ...) \
  79. dprintk(VIDC_BUS, DEFAULT_SID, __fmt, ##__VA_ARGS__)
  80. #define dprintk_firmware(__level, __fmt, ...) \
  81. do { \
  82. pr_err(FW_DBG_TAG __fmt, \
  83. "fw", \
  84. ##__VA_ARGS__); \
  85. } while (0)
  86. #define MSM_VIDC_ERROR(value) \
  87. do { if (value) \
  88. d_vpr_e("BugOn"); \
  89. } while (0)
  90. const char *level_str(u32 level);
  91. enum msm_vidc_debugfs_event {
  92. MSM_VIDC_DEBUGFS_EVENT_ETB,
  93. MSM_VIDC_DEBUGFS_EVENT_EBD,
  94. MSM_VIDC_DEBUGFS_EVENT_FTB,
  95. MSM_VIDC_DEBUGFS_EVENT_FBD,
  96. };
  97. struct dentry *msm_vidc_debugfs_init_drv(void);
  98. struct dentry *msm_vidc_debugfs_init_core(void *core);
  99. struct dentry *msm_vidc_debugfs_init_inst(void *inst,
  100. struct dentry *parent);
  101. void msm_vidc_debugfs_deinit_inst(void *inst);
  102. void msm_vidc_debugfs_update(void *inst,
  103. enum msm_vidc_debugfs_event e);
  104. #endif