Junzhe Zou | 26abf77 | 2017-07-05 10:36:43 -0700 | [diff] [blame] | 1 | /* Copyright (c) 2017, The Linux Foundation. All rights reserved. |
Junzhe Zou | 263a87d | 2017-06-08 16:06:25 -0700 | [diff] [blame] | 2 | * |
| 3 | * This program is free software; you can redistribute it and/or modify |
| 4 | * it under the terms of the GNU General Public License version 2 and |
| 5 | * only version 2 as published by the Free Software Foundation. |
| 6 | * |
| 7 | * This program is distributed in the hope that it will be useful, |
| 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 10 | * GNU General Public License for more details. |
| 11 | */ |
| 12 | |
| 13 | #ifndef _CAM_DEBUG_UTIL_H_ |
| 14 | #define _CAM_DEBUG_UTIL_H_ |
| 15 | |
Jigarkumar Zala | cbb5a38 | 2017-07-17 19:06:42 -0700 | [diff] [blame] | 16 | #define CAM_CDM (1 << 0) |
| 17 | #define CAM_CORE (1 << 1) |
| 18 | #define CAM_CPAS (1 << 2) |
| 19 | #define CAM_ISP (1 << 3) |
| 20 | #define CAM_CRM (1 << 4) |
| 21 | #define CAM_SENSOR (1 << 5) |
| 22 | #define CAM_SMMU (1 << 6) |
| 23 | #define CAM_SYNC (1 << 7) |
| 24 | #define CAM_ICP (1 << 8) |
| 25 | #define CAM_JPEG (1 << 9) |
| 26 | #define CAM_FD (1 << 10) |
| 27 | #define CAM_LRME (1 << 11) |
| 28 | #define CAM_FLASH (1 << 12) |
| 29 | #define CAM_ACTUATOR (1 << 13) |
| 30 | #define CAM_CCI (1 << 14) |
| 31 | #define CAM_CSIPHY (1 << 15) |
| 32 | #define CAM_EEPROM (1 << 16) |
Pavan Kumar Chilamkurthi | eb8833c | 2017-07-15 19:44:13 -0700 | [diff] [blame] | 33 | #define CAM_UTIL (1 << 17) |
Lakshmi Narayana Kalavala | adc6ce3 | 2017-07-17 17:19:11 -0700 | [diff] [blame] | 34 | #define CAM_HFI (1 << 18) |
| 35 | #define CAM_CTXT (1 << 19) |
Vivek Veenam | 281516b | 2017-08-17 17:39:04 +0530 | [diff] [blame^] | 36 | #define CAM_OIS (1 << 20) |
Junzhe Zou | 263a87d | 2017-06-08 16:06:25 -0700 | [diff] [blame] | 37 | |
Jigarkumar Zala | ddcb9d3 | 2017-06-23 16:21:33 -0700 | [diff] [blame] | 38 | #define STR_BUFFER_MAX_LENGTH 1024 |
Junzhe Zou | 263a87d | 2017-06-08 16:06:25 -0700 | [diff] [blame] | 39 | |
Jigarkumar Zala | ddcb9d3 | 2017-06-23 16:21:33 -0700 | [diff] [blame] | 40 | enum cam_debug_level { |
| 41 | CAM_LEVEL_INFO, |
| 42 | CAM_LEVEL_WARN, |
| 43 | CAM_LEVEL_ERR, |
| 44 | CAM_LEVEL_DBG, |
| 45 | }; |
Junzhe Zou | 263a87d | 2017-06-08 16:06:25 -0700 | [diff] [blame] | 46 | |
Jigarkumar Zala | ddcb9d3 | 2017-06-23 16:21:33 -0700 | [diff] [blame] | 47 | /* |
| 48 | * cam_debug_log() |
| 49 | * |
Jigarkumar Zala | 0fbb1d9 | 2017-07-11 18:55:58 -0700 | [diff] [blame] | 50 | * @brief : Get the Module name from module ID and print |
| 51 | * respective debug logs |
Jigarkumar Zala | ddcb9d3 | 2017-06-23 16:21:33 -0700 | [diff] [blame] | 52 | * |
| 53 | * @module_id : Respective Module ID which is calling this function |
| 54 | * @dbg_level : Debug level from cam_module_debug_level enum entries |
Jigarkumar Zala | 0fbb1d9 | 2017-07-11 18:55:58 -0700 | [diff] [blame] | 55 | * @func : Function which is calling to print logs |
| 56 | * @line : Line number associated with the function which is calling |
Jigarkumar Zala | ddcb9d3 | 2017-06-23 16:21:33 -0700 | [diff] [blame] | 57 | * to print log |
Jigarkumar Zala | 0fbb1d9 | 2017-07-11 18:55:58 -0700 | [diff] [blame] | 58 | * @fmt : Formatted string which needs to be print in the log |
Jigarkumar Zala | ddcb9d3 | 2017-06-23 16:21:33 -0700 | [diff] [blame] | 59 | * |
| 60 | */ |
| 61 | void cam_debug_log(unsigned int module_id, enum cam_debug_level dbg_level, |
| 62 | const char *func, const int line, const char *fmt, ...); |
Junzhe Zou | 263a87d | 2017-06-08 16:06:25 -0700 | [diff] [blame] | 63 | |
Jigarkumar Zala | ddcb9d3 | 2017-06-23 16:21:33 -0700 | [diff] [blame] | 64 | /* |
Jigarkumar Zala | 0fbb1d9 | 2017-07-11 18:55:58 -0700 | [diff] [blame] | 65 | * cam_get_module_name() |
| 66 | * |
| 67 | * @brief : Get the module name from module ID |
| 68 | * |
| 69 | * @module_id : Module ID which is using this function |
| 70 | */ |
| 71 | const char *cam_get_module_name(unsigned int module_id); |
| 72 | |
| 73 | /* |
Jigarkumar Zala | ddcb9d3 | 2017-06-23 16:21:33 -0700 | [diff] [blame] | 74 | * CAM_ERR |
Jigarkumar Zala | 0fbb1d9 | 2017-07-11 18:55:58 -0700 | [diff] [blame] | 75 | * @brief : This Macro will print error logs |
Jigarkumar Zala | ddcb9d3 | 2017-06-23 16:21:33 -0700 | [diff] [blame] | 76 | * |
| 77 | * @__module : Respective module id which is been calling this Macro |
Jigarkumar Zala | 0fbb1d9 | 2017-07-11 18:55:58 -0700 | [diff] [blame] | 78 | * @fmt : Formatted string which needs to be print in log |
| 79 | * @args : Arguments which needs to be print in log |
Jigarkumar Zala | ddcb9d3 | 2017-06-23 16:21:33 -0700 | [diff] [blame] | 80 | */ |
| 81 | #define CAM_ERR(__module, fmt, args...) \ |
Jigarkumar Zala | 0fbb1d9 | 2017-07-11 18:55:58 -0700 | [diff] [blame] | 82 | cam_debug_log(__module, CAM_LEVEL_ERR, __func__, __LINE__, fmt, ##args) |
Jigarkumar Zala | ddcb9d3 | 2017-06-23 16:21:33 -0700 | [diff] [blame] | 83 | |
| 84 | /* |
| 85 | * CAM_WARN |
Jigarkumar Zala | 0fbb1d9 | 2017-07-11 18:55:58 -0700 | [diff] [blame] | 86 | * @brief : This Macro will print warning logs |
Jigarkumar Zala | ddcb9d3 | 2017-06-23 16:21:33 -0700 | [diff] [blame] | 87 | * |
| 88 | * @__module : Respective module id which is been calling this Macro |
| 89 | * @fmt : Formatted string which needs to be print in log |
| 90 | * @args : Arguments which needs to be print in log |
| 91 | */ |
| 92 | #define CAM_WARN(__module, fmt, args...) \ |
Jigarkumar Zala | 0fbb1d9 | 2017-07-11 18:55:58 -0700 | [diff] [blame] | 93 | cam_debug_log(__module, CAM_LEVEL_WARN, __func__, __LINE__, fmt, ##args) |
Jigarkumar Zala | ddcb9d3 | 2017-06-23 16:21:33 -0700 | [diff] [blame] | 94 | |
| 95 | /* |
| 96 | * CAM_INFO |
Jigarkumar Zala | 0fbb1d9 | 2017-07-11 18:55:58 -0700 | [diff] [blame] | 97 | * @brief : This Macro will print Information logs |
Jigarkumar Zala | ddcb9d3 | 2017-06-23 16:21:33 -0700 | [diff] [blame] | 98 | * |
| 99 | * @__module : Respective module id which is been calling this Macro |
| 100 | * @fmt : Formatted string which needs to be print in log |
| 101 | * @args : Arguments which needs to be print in log |
| 102 | */ |
| 103 | #define CAM_INFO(__module, fmt, args...) \ |
Jigarkumar Zala | 0fbb1d9 | 2017-07-11 18:55:58 -0700 | [diff] [blame] | 104 | cam_debug_log(__module, CAM_LEVEL_INFO, __func__, __LINE__, fmt, ##args) |
Jigarkumar Zala | ddcb9d3 | 2017-06-23 16:21:33 -0700 | [diff] [blame] | 105 | |
| 106 | /* |
| 107 | * CAM_DBG |
| 108 | * @brief : This Macro will print debug logs when enabled using GROUP |
| 109 | * |
| 110 | * @__module : Respective module id which is been calling this Macro |
| 111 | * @fmt : Formatted string which needs to be print in log |
| 112 | * @args : Arguments which needs to be print in log |
| 113 | */ |
| 114 | #define CAM_DBG(__module, fmt, args...) \ |
Jigarkumar Zala | 0fbb1d9 | 2017-07-11 18:55:58 -0700 | [diff] [blame] | 115 | cam_debug_log(__module, CAM_LEVEL_DBG, __func__, __LINE__, fmt, ##args) |
| 116 | |
| 117 | /* |
| 118 | * CAM_ERR_RATE_LIMIT |
| 119 | * @brief : This Macro will prevent error print logs with ratelimit |
| 120 | */ |
| 121 | #define CAM_ERR_RATE_LIMIT(__module, fmt, args...) \ |
| 122 | pr_err_ratelimited("CAM_ERR: %s: %s: %d\n" fmt, \ |
| 123 | cam_get_module_name(__module), __func__, __LINE__, ##args) |
Junzhe Zou | 263a87d | 2017-06-08 16:06:25 -0700 | [diff] [blame] | 124 | |
| 125 | #endif /* _CAM_DEBUG_UTIL_H_ */ |