blob: 7275d5641c0e8beb4cc390af8e467394103b4e77 [file] [log] [blame]
Junzhe Zou26abf772017-07-05 10:36:43 -07001/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
Junzhe Zou263a87d2017-06-08 16:06:25 -07002 *
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 Zalacbb5a382017-07-17 19:06:42 -070016#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 Chilamkurthieb8833c2017-07-15 19:44:13 -070033#define CAM_UTIL (1 << 17)
Lakshmi Narayana Kalavalaadc6ce32017-07-17 17:19:11 -070034#define CAM_HFI (1 << 18)
35#define CAM_CTXT (1 << 19)
Junzhe Zou263a87d2017-06-08 16:06:25 -070036
Jigarkumar Zaladdcb9d32017-06-23 16:21:33 -070037#define STR_BUFFER_MAX_LENGTH 1024
Junzhe Zou263a87d2017-06-08 16:06:25 -070038
Jigarkumar Zaladdcb9d32017-06-23 16:21:33 -070039enum cam_debug_level {
40 CAM_LEVEL_INFO,
41 CAM_LEVEL_WARN,
42 CAM_LEVEL_ERR,
43 CAM_LEVEL_DBG,
44};
Junzhe Zou263a87d2017-06-08 16:06:25 -070045
Jigarkumar Zaladdcb9d32017-06-23 16:21:33 -070046/*
47 * cam_debug_log()
48 *
Jigarkumar Zala0fbb1d92017-07-11 18:55:58 -070049 * @brief : Get the Module name from module ID and print
50 * respective debug logs
Jigarkumar Zaladdcb9d32017-06-23 16:21:33 -070051 *
52 * @module_id : Respective Module ID which is calling this function
53 * @dbg_level : Debug level from cam_module_debug_level enum entries
Jigarkumar Zala0fbb1d92017-07-11 18:55:58 -070054 * @func : Function which is calling to print logs
55 * @line : Line number associated with the function which is calling
Jigarkumar Zaladdcb9d32017-06-23 16:21:33 -070056 * to print log
Jigarkumar Zala0fbb1d92017-07-11 18:55:58 -070057 * @fmt : Formatted string which needs to be print in the log
Jigarkumar Zaladdcb9d32017-06-23 16:21:33 -070058 *
59 */
60void cam_debug_log(unsigned int module_id, enum cam_debug_level dbg_level,
61 const char *func, const int line, const char *fmt, ...);
Junzhe Zou263a87d2017-06-08 16:06:25 -070062
Jigarkumar Zaladdcb9d32017-06-23 16:21:33 -070063/*
Jigarkumar Zala0fbb1d92017-07-11 18:55:58 -070064 * cam_get_module_name()
65 *
66 * @brief : Get the module name from module ID
67 *
68 * @module_id : Module ID which is using this function
69 */
70const char *cam_get_module_name(unsigned int module_id);
71
72/*
Jigarkumar Zaladdcb9d32017-06-23 16:21:33 -070073 * CAM_ERR
Jigarkumar Zala0fbb1d92017-07-11 18:55:58 -070074 * @brief : This Macro will print error logs
Jigarkumar Zaladdcb9d32017-06-23 16:21:33 -070075 *
76 * @__module : Respective module id which is been calling this Macro
Jigarkumar Zala0fbb1d92017-07-11 18:55:58 -070077 * @fmt : Formatted string which needs to be print in log
78 * @args : Arguments which needs to be print in log
Jigarkumar Zaladdcb9d32017-06-23 16:21:33 -070079 */
80#define CAM_ERR(__module, fmt, args...) \
Jigarkumar Zala0fbb1d92017-07-11 18:55:58 -070081 cam_debug_log(__module, CAM_LEVEL_ERR, __func__, __LINE__, fmt, ##args)
Jigarkumar Zaladdcb9d32017-06-23 16:21:33 -070082
83/*
84 * CAM_WARN
Jigarkumar Zala0fbb1d92017-07-11 18:55:58 -070085 * @brief : This Macro will print warning logs
Jigarkumar Zaladdcb9d32017-06-23 16:21:33 -070086 *
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_WARN(__module, fmt, args...) \
Jigarkumar Zala0fbb1d92017-07-11 18:55:58 -070092 cam_debug_log(__module, CAM_LEVEL_WARN, __func__, __LINE__, fmt, ##args)
Jigarkumar Zaladdcb9d32017-06-23 16:21:33 -070093
94/*
95 * CAM_INFO
Jigarkumar Zala0fbb1d92017-07-11 18:55:58 -070096 * @brief : This Macro will print Information logs
Jigarkumar Zaladdcb9d32017-06-23 16:21:33 -070097 *
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(__module, fmt, args...) \
Jigarkumar Zala0fbb1d92017-07-11 18:55:58 -0700103 cam_debug_log(__module, CAM_LEVEL_INFO, __func__, __LINE__, fmt, ##args)
Jigarkumar Zaladdcb9d32017-06-23 16:21:33 -0700104
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...) \
Jigarkumar Zala0fbb1d92017-07-11 18:55:58 -0700114 cam_debug_log(__module, CAM_LEVEL_DBG, __func__, __LINE__, fmt, ##args)
115
116/*
117 * CAM_ERR_RATE_LIMIT
118 * @brief : This Macro will prevent error print logs with ratelimit
119 */
120#define CAM_ERR_RATE_LIMIT(__module, fmt, args...) \
121 pr_err_ratelimited("CAM_ERR: %s: %s: %d\n" fmt, \
122 cam_get_module_name(__module), __func__, __LINE__, ##args)
Junzhe Zou263a87d2017-06-08 16:06:25 -0700123
124#endif /* _CAM_DEBUG_UTIL_H_ */