cam_debug_util.h 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
  4. */
  5. #ifndef _CAM_DEBUG_UTIL_H_
  6. #define _CAM_DEBUG_UTIL_H_
  7. #define CAM_CDM (1 << 0)
  8. #define CAM_CORE (1 << 1)
  9. #define CAM_CPAS (1 << 2)
  10. #define CAM_ISP (1 << 3)
  11. #define CAM_CRM (1 << 4)
  12. #define CAM_SENSOR (1 << 5)
  13. #define CAM_SMMU (1 << 6)
  14. #define CAM_SYNC (1 << 7)
  15. #define CAM_ICP (1 << 8)
  16. #define CAM_JPEG (1 << 9)
  17. #define CAM_FD (1 << 10)
  18. #define CAM_LRME (1 << 11)
  19. #define CAM_FLASH (1 << 12)
  20. #define CAM_ACTUATOR (1 << 13)
  21. #define CAM_CCI (1 << 14)
  22. #define CAM_CSIPHY (1 << 15)
  23. #define CAM_EEPROM (1 << 16)
  24. #define CAM_UTIL (1 << 17)
  25. #define CAM_HFI (1 << 18)
  26. #define CAM_CTXT (1 << 19)
  27. #define CAM_OIS (1 << 20)
  28. #define CAM_RES (1 << 21)
  29. #define CAM_MEM (1 << 22)
  30. /* CAM_IRQ_CTRL: For events in irq controller */
  31. #define CAM_IRQ_CTRL (1 << 23)
  32. /* CAM_REQ: Tracks a request submitted to KMD */
  33. #define CAM_REQ (1 << 24)
  34. /* CAM_PERF: Used for performance (clock, BW etc) logs */
  35. #define CAM_PERF (1 << 25)
  36. #define STR_BUFFER_MAX_LENGTH 1024
  37. /*
  38. * cam_debug_log()
  39. *
  40. * @brief : Get the Module name from module ID and print
  41. * respective debug logs
  42. *
  43. * @module_id : Respective Module ID which is calling this function
  44. * @func : Function which is calling to print logs
  45. * @line : Line number associated with the function which is calling
  46. * to print log
  47. * @fmt : Formatted string which needs to be print in the log
  48. *
  49. */
  50. void cam_debug_log(unsigned int module_id, const char *func, const int line,
  51. const char *fmt, ...);
  52. /*
  53. * cam_get_module_name()
  54. *
  55. * @brief : Get the module name from module ID
  56. *
  57. * @module_id : Module ID which is using this function
  58. */
  59. const char *cam_get_module_name(unsigned int module_id);
  60. /*
  61. * CAM_ERR
  62. * @brief : This Macro will print error logs
  63. *
  64. * @__module : Respective module id which is been calling this Macro
  65. * @fmt : Formatted string which needs to be print in log
  66. * @args : Arguments which needs to be print in log
  67. */
  68. #define CAM_ERR(__module, fmt, args...) \
  69. pr_err("CAM_ERR: %s: %s: %d " fmt "\n", \
  70. cam_get_module_name(__module), __func__, __LINE__, ##args)
  71. /*
  72. * CAM_WARN
  73. * @brief : This Macro will print warning logs
  74. *
  75. * @__module : Respective module id which is been calling this Macro
  76. * @fmt : Formatted string which needs to be print in log
  77. * @args : Arguments which needs to be print in log
  78. */
  79. #define CAM_WARN(__module, fmt, args...) \
  80. pr_warn("CAM_WARN: %s: %s: %d " fmt "\n", \
  81. cam_get_module_name(__module), __func__, __LINE__, ##args)
  82. /*
  83. * CAM_INFO
  84. * @brief : This Macro will print Information logs
  85. *
  86. * @__module : Respective module id which is been calling this Macro
  87. * @fmt : Formatted string which needs to be print in log
  88. * @args : Arguments which needs to be print in log
  89. */
  90. #define CAM_INFO(__module, fmt, args...) \
  91. pr_info("CAM_INFO: %s: %s: %d " fmt "\n", \
  92. cam_get_module_name(__module), __func__, __LINE__, ##args)
  93. /*
  94. * CAM_INFO_RATE_LIMIT
  95. * @brief : This Macro will print info logs with ratelimit
  96. *
  97. * @__module : Respective module id which is been calling this Macro
  98. * @fmt : Formatted string which needs to be print in log
  99. * @args : Arguments which needs to be print in log
  100. */
  101. #define CAM_INFO_RATE_LIMIT(__module, fmt, args...) \
  102. pr_info_ratelimited("CAM_INFO: %s: %s: %d " fmt "\n", \
  103. cam_get_module_name(__module), __func__, __LINE__, ##args)
  104. /*
  105. * CAM_DBG
  106. * @brief : This Macro will print debug logs when enabled using GROUP
  107. *
  108. * @__module : Respective module id which is been calling this Macro
  109. * @fmt : Formatted string which needs to be print in log
  110. * @args : Arguments which needs to be print in log
  111. */
  112. #define CAM_DBG(__module, fmt, args...) \
  113. cam_debug_log(__module, __func__, __LINE__, fmt, ##args)
  114. /*
  115. * CAM_ERR_RATE_LIMIT
  116. * @brief : This Macro will print error print logs with ratelimit
  117. */
  118. #define CAM_ERR_RATE_LIMIT(__module, fmt, args...) \
  119. pr_err_ratelimited("CAM_ERR: %s: %s: %d " fmt "\n", \
  120. cam_get_module_name(__module), __func__, __LINE__, ##args)
  121. /*
  122. * CAM_WARN_RATE_LIMIT
  123. * @brief : This Macro will print warning logs with ratelimit
  124. *
  125. * @__module : Respective module id which is been calling this Macro
  126. * @fmt : Formatted string which needs to be print in log
  127. * @args : Arguments which needs to be print in log
  128. */
  129. #define CAM_WARN_RATE_LIMIT(__module, fmt, args...) \
  130. pr_warn_ratelimited("CAM_WARN: %s: %s: %d " fmt "\n", \
  131. cam_get_module_name(__module), __func__, __LINE__, ##args)
  132. /*
  133. * CAM_WARN_RATE_LIMIT_CUSTOM
  134. * @brief : This Macro will print warn logs with custom ratelimit
  135. *
  136. * @__module : Respective module id which is been calling this Macro
  137. * @interval : Time interval in seconds
  138. * @burst : No of logs to print in interval time
  139. * @fmt : Formatted string which needs to be print in log
  140. * @args : Arguments which needs to be print in log
  141. */
  142. #define CAM_WARN_RATE_LIMIT_CUSTOM(__module, interval, burst, fmt, args...) \
  143. ({ \
  144. static DEFINE_RATELIMIT_STATE(_rs, \
  145. (interval * HZ), \
  146. burst); \
  147. if (__ratelimit(&_rs)) \
  148. pr_warn( \
  149. "CAM_WARN: %s: %s: %d " fmt "\n", \
  150. cam_get_module_name(__module), __func__, \
  151. __LINE__, ##args); \
  152. })
  153. /*
  154. * CAM_INFO_RATE_LIMIT_CUSTOM
  155. * @brief : This Macro will print info logs with custom ratelimit
  156. *
  157. * @__module : Respective module id which is been calling this Macro
  158. * @interval : Time interval in seconds
  159. * @burst : No of logs to print in interval time
  160. * @fmt : Formatted string which needs to be print in log
  161. * @args : Arguments which needs to be print in log
  162. */
  163. #define CAM_INFO_RATE_LIMIT_CUSTOM(__module, interval, burst, fmt, args...) \
  164. ({ \
  165. static DEFINE_RATELIMIT_STATE(_rs, \
  166. (interval * HZ), \
  167. burst); \
  168. if (__ratelimit(&_rs)) \
  169. pr_info( \
  170. "CAM_INFO: %s: %s: %d " fmt "\n", \
  171. cam_get_module_name(__module), __func__, \
  172. __LINE__, ##args); \
  173. })
  174. /*
  175. * CAM_ERR_RATE_LIMIT_CUSTOM
  176. * @brief : This Macro will print error logs with custom ratelimit
  177. *
  178. * @__module : Respective module id which is been calling this Macro
  179. * @interval : Time interval in seconds
  180. * @burst : No of logs to print in interval time
  181. * @fmt : Formatted string which needs to be print in log
  182. * @args : Arguments which needs to be print in log
  183. */
  184. #define CAM_ERR_RATE_LIMIT_CUSTOM(__module, interval, burst, fmt, args...) \
  185. ({ \
  186. static DEFINE_RATELIMIT_STATE(_rs, \
  187. (interval * HZ), \
  188. burst); \
  189. if (__ratelimit(&_rs)) \
  190. pr_err( \
  191. "CAM_ERR: %s: %s: %d " fmt "\n", \
  192. cam_get_module_name(__module), __func__, \
  193. __LINE__, ##args); \
  194. })
  195. #endif /* _CAM_DEBUG_UTIL_H_ */