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 | |
Junzhe Zou | 263a87d | 2017-06-08 16:06:25 -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) |
Jigarkumar Zala | ddcb9d3 | 2017-06-23 16:21:33 -0700 | [diff] [blame^] | 28 | #define CAM_FLASH (1 << 12) |
Junzhe Zou | 263a87d | 2017-06-08 16:06:25 -0700 | [diff] [blame] | 29 | |
Jigarkumar Zala | ddcb9d3 | 2017-06-23 16:21:33 -0700 | [diff] [blame^] | 30 | #define STR_BUFFER_MAX_LENGTH 1024 |
| 31 | #define GROUP 0x0000 |
Junzhe Zou | 263a87d | 2017-06-08 16:06:25 -0700 | [diff] [blame] | 32 | |
Jigarkumar Zala | ddcb9d3 | 2017-06-23 16:21:33 -0700 | [diff] [blame^] | 33 | enum cam_debug_level { |
| 34 | CAM_LEVEL_INFO, |
| 35 | CAM_LEVEL_WARN, |
| 36 | CAM_LEVEL_ERR, |
| 37 | CAM_LEVEL_DBG, |
| 38 | }; |
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 | /* |
| 41 | * cam_debug_log() |
| 42 | * |
| 43 | * @brief: Get the Module name form module ID and print |
| 44 | * respective debug logs |
| 45 | * |
| 46 | * @module_id : Respective Module ID which is calling this function |
| 47 | * @dbg_level : Debug level from cam_module_debug_level enum entries |
| 48 | * @func : Function which is calling to print logs |
| 49 | * @line : Line number associated with the function which is calling |
| 50 | * to print log |
| 51 | * @fmt : Formatted string which needs to be print in the log |
| 52 | * |
| 53 | */ |
| 54 | void cam_debug_log(unsigned int module_id, enum cam_debug_level dbg_level, |
| 55 | const char *func, const int line, const char *fmt, ...); |
Junzhe Zou | 263a87d | 2017-06-08 16:06:25 -0700 | [diff] [blame] | 56 | |
Jigarkumar Zala | ddcb9d3 | 2017-06-23 16:21:33 -0700 | [diff] [blame^] | 57 | /* |
| 58 | * CAM_ERR |
| 59 | * @brief : This Macro will print error logs |
| 60 | * |
| 61 | * @__module : Respective module id which is been calling this Macro |
| 62 | * @fmt : Formatted string which needs to be print in log |
| 63 | * @args: Arguments which needs to be print in log |
| 64 | */ |
| 65 | #define CAM_ERR(__module, fmt, args...) \ |
| 66 | { \ |
| 67 | cam_debug_log(__module, CAM_LEVEL_ERR, \ |
| 68 | __func__, __LINE__, fmt, ##args); \ |
| 69 | } |
| 70 | |
| 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 | { \ |
| 81 | cam_debug_log(__module, CAM_LEVEL_WARN, \ |
| 82 | __func__, __LINE__, fmt, ##args); \ |
| 83 | } |
| 84 | |
| 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 | { \ |
| 95 | cam_debug_log(__module, CAM_LEVEL_INFO, \ |
| 96 | __func__, __LINE__, fmt, ##args); \ |
| 97 | } |
| 98 | |
| 99 | /* |
| 100 | * CAM_DBG |
| 101 | * @brief : This Macro will print debug logs when enabled using GROUP |
| 102 | * |
| 103 | * @__module : Respective module id which is been calling this Macro |
| 104 | * @fmt : Formatted string which needs to be print in log |
| 105 | * @args : Arguments which needs to be print in log |
| 106 | */ |
| 107 | #define CAM_DBG(__module, fmt, args...) \ |
| 108 | do { \ |
| 109 | if (GROUP & __module) { \ |
| 110 | cam_debug_log(__module, CAM_LEVEL_DBG, \ |
| 111 | __func__, __LINE__, fmt, ##args); \ |
| 112 | } \ |
| 113 | } while (0) |
Junzhe Zou | 263a87d | 2017-06-08 16:06:25 -0700 | [diff] [blame] | 114 | |
| 115 | #endif /* _CAM_DEBUG_UTIL_H_ */ |