cam_debug_util.h 7.9 KB

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