cam_debug_util.h 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2017-2020, 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 CAM_CUSTOM (1 << 26)
  37. #define CAM_OPE (1 << 28)
  38. #define CAM_PRESIL (1 << 27)
  39. #define STR_BUFFER_MAX_LENGTH 1024
  40. /*
  41. * cam_debug_log()
  42. *
  43. * @brief : Get the Module name from module ID and print
  44. * respective debug logs
  45. *
  46. * @module_id : Respective Module ID which is calling this function
  47. * @func : Function which is calling to print logs
  48. * @line : Line number associated with the function which is calling
  49. * to print log
  50. * @fmt : Formatted string which needs to be print in the log
  51. *
  52. */
  53. void cam_debug_log(unsigned int module_id, const char *func, const int line,
  54. const char *fmt, ...);
  55. /*
  56. * cam_get_module_name()
  57. *
  58. * @brief : Get the module name from module ID
  59. *
  60. * @module_id : Module ID which is using this function
  61. */
  62. const char *cam_get_module_name(unsigned int module_id);
  63. /*
  64. * CAM_ERR
  65. * @brief : This Macro will print error logs
  66. *
  67. * @__module : Respective module id which is been calling this Macro
  68. * @fmt : Formatted string which needs to be print in log
  69. * @args : Arguments which needs to be print in log
  70. */
  71. #define CAM_ERR(__module, fmt, args...) \
  72. pr_info("CAM_ERR: %s: %s: %d " fmt "\n", \
  73. cam_get_module_name(__module), __func__, __LINE__, ##args)
  74. /*
  75. * CAM_WARN
  76. * @brief : This Macro will print warning logs
  77. *
  78. * @__module : Respective module id which is been calling this Macro
  79. * @fmt : Formatted string which needs to be print in log
  80. * @args : Arguments which needs to be print in log
  81. */
  82. #define CAM_WARN(__module, fmt, args...) \
  83. pr_info("CAM_WARN: %s: %s: %d " fmt "\n", \
  84. cam_get_module_name(__module), __func__, __LINE__, ##args)
  85. /*
  86. * CAM_INFO
  87. * @brief : This Macro will print Information logs
  88. *
  89. * @__module : Respective module id which is been calling this Macro
  90. * @fmt : Formatted string which needs to be print in log
  91. * @args : Arguments which needs to be print in log
  92. */
  93. #define CAM_INFO(__module, fmt, args...) \
  94. pr_info("CAM_INFO: %s: %s: %d " fmt "\n", \
  95. cam_get_module_name(__module), __func__, __LINE__, ##args)
  96. /*
  97. * CAM_INFO_RATE_LIMIT
  98. * @brief : This Macro will print info logs with ratelimit
  99. *
  100. * @__module : Respective module id which is been calling this Macro
  101. * @fmt : Formatted string which needs to be print in log
  102. * @args : Arguments which needs to be print in log
  103. */
  104. #define CAM_INFO_RATE_LIMIT(__module, fmt, args...) \
  105. pr_info_ratelimited("CAM_INFO: %s: %s: %d " fmt "\n", \
  106. cam_get_module_name(__module), __func__, __LINE__, ##args)
  107. /*
  108. * CAM_DBG
  109. * @brief : This Macro will print debug logs when enabled using GROUP
  110. *
  111. * @__module : Respective module id which is been calling this Macro
  112. * @fmt : Formatted string which needs to be print in log
  113. * @args : Arguments which needs to be print in log
  114. */
  115. #define CAM_DBG(__module, fmt, args...) \
  116. cam_debug_log(__module, __func__, __LINE__, fmt, ##args)
  117. /*
  118. * CAM_ERR_RATE_LIMIT
  119. * @brief : This Macro will print error print logs with ratelimit
  120. */
  121. #define CAM_ERR_RATE_LIMIT(__module, fmt, args...) \
  122. pr_info_ratelimited("CAM_ERR: %s: %s: %d " fmt "\n", \
  123. cam_get_module_name(__module), __func__, __LINE__, ##args)
  124. /*
  125. * CAM_WARN_RATE_LIMIT
  126. * @brief : This Macro will print warning logs with ratelimit
  127. *
  128. * @__module : Respective module id which is been calling this Macro
  129. * @fmt : Formatted string which needs to be print in log
  130. * @args : Arguments which needs to be print in log
  131. */
  132. #define CAM_WARN_RATE_LIMIT(__module, fmt, args...) \
  133. pr_info_ratelimited("CAM_WARN: %s: %s: %d " fmt "\n", \
  134. cam_get_module_name(__module), __func__, __LINE__, ##args)
  135. /*
  136. * CAM_WARN_RATE_LIMIT_CUSTOM
  137. * @brief : This Macro will print warn logs with custom ratelimit
  138. *
  139. * @__module : Respective module id which is been calling this Macro
  140. * @interval : Time interval in seconds
  141. * @burst : No of logs to print in interval time
  142. * @fmt : Formatted string which needs to be print in log
  143. * @args : Arguments which needs to be print in log
  144. */
  145. #define CAM_WARN_RATE_LIMIT_CUSTOM(__module, interval, burst, fmt, args...) \
  146. ({ \
  147. static DEFINE_RATELIMIT_STATE(_rs, \
  148. (interval * HZ), \
  149. burst); \
  150. if (__ratelimit(&_rs)) \
  151. pr_info( \
  152. "CAM_WARN: %s: %s: %d " fmt "\n", \
  153. cam_get_module_name(__module), __func__, \
  154. __LINE__, ##args); \
  155. })
  156. /*
  157. * CAM_INFO_RATE_LIMIT_CUSTOM
  158. * @brief : This Macro will print info logs with custom ratelimit
  159. *
  160. * @__module : Respective module id which is been calling this Macro
  161. * @interval : Time interval in seconds
  162. * @burst : No of logs to print in interval time
  163. * @fmt : Formatted string which needs to be print in log
  164. * @args : Arguments which needs to be print in log
  165. */
  166. #define CAM_INFO_RATE_LIMIT_CUSTOM(__module, interval, burst, fmt, args...) \
  167. ({ \
  168. static DEFINE_RATELIMIT_STATE(_rs, \
  169. (interval * HZ), \
  170. burst); \
  171. if (__ratelimit(&_rs)) \
  172. pr_info( \
  173. "CAM_INFO: %s: %s: %d " fmt "\n", \
  174. cam_get_module_name(__module), __func__, \
  175. __LINE__, ##args); \
  176. })
  177. /*
  178. * CAM_ERR_RATE_LIMIT_CUSTOM
  179. * @brief : This Macro will print error logs with custom ratelimit
  180. *
  181. * @__module : Respective module id which is been calling this Macro
  182. * @interval : Time interval in seconds
  183. * @burst : No of logs to print in interval time
  184. * @fmt : Formatted string which needs to be print in log
  185. * @args : Arguments which needs to be print in log
  186. */
  187. #define CAM_ERR_RATE_LIMIT_CUSTOM(__module, interval, burst, fmt, args...) \
  188. ({ \
  189. static DEFINE_RATELIMIT_STATE(_rs, \
  190. (interval * HZ), \
  191. burst); \
  192. if (__ratelimit(&_rs)) \
  193. pr_info( \
  194. "CAM_ERR: %s: %s: %d " fmt "\n", \
  195. cam_get_module_name(__module), __func__, \
  196. __LINE__, ##args); \
  197. })
  198. #endif /* _CAM_DEBUG_UTIL_H_ */