blob: 34adb0e90ce90e383a179c524fdb01664095d968 [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
Junzhe Zou263a87d2017-06-08 16:06:25 -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)
Jigarkumar Zaladdcb9d32017-06-23 16:21:33 -070028#define CAM_FLASH (1 << 12)
Junzhe Zou263a87d2017-06-08 16:06:25 -070029
Jigarkumar Zaladdcb9d32017-06-23 16:21:33 -070030#define STR_BUFFER_MAX_LENGTH 1024
31#define GROUP 0x0000
Junzhe Zou263a87d2017-06-08 16:06:25 -070032
Jigarkumar Zaladdcb9d32017-06-23 16:21:33 -070033enum cam_debug_level {
34 CAM_LEVEL_INFO,
35 CAM_LEVEL_WARN,
36 CAM_LEVEL_ERR,
37 CAM_LEVEL_DBG,
38};
Junzhe Zou263a87d2017-06-08 16:06:25 -070039
Jigarkumar Zaladdcb9d32017-06-23 16:21:33 -070040/*
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 */
54void cam_debug_log(unsigned int module_id, enum cam_debug_level dbg_level,
55 const char *func, const int line, const char *fmt, ...);
Junzhe Zou263a87d2017-06-08 16:06:25 -070056
Jigarkumar Zaladdcb9d32017-06-23 16:21:33 -070057/*
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 Zou263a87d2017-06-08 16:06:25 -0700114
115#endif /* _CAM_DEBUG_UTIL_H_ */