1 /* Copyright (c) 2012, 2014, 2016, The Linux Foundation. All rights reserved. 2 * 3 * Redistribution and use in source and binary forms, with or without 4 * modification, are permitted provided that the following conditions are 5 * met: 6 * * Redistributions of source code must retain the above copyright 7 * notice, this list of conditions and the following disclaimer. 8 * * Redistributions in binary form must reproduce the above 9 * copyright notice, this list of conditions and the following 10 * disclaimer in the documentation and/or other materials provided 11 * with the distribution. 12 * * Neither the name of The Linux Foundation nor the names of its 13 * contributors may be used to endorse or promote products derived 14 * from this software without specific prior written permission. 15 * 16 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT 19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 20 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 23 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 26 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 * 28 */ 29 30 #ifndef __MM_CAMERA_DBG_H__ 31 #define __MM_CAMERA_DBG_H__ 32 33 // System dependencies 34 #include <utils/Log.h> 35 36 #ifdef QCAMERA_REDEFINE_LOG 37 38 // Camera dependencies 39 #include "cam_types.h" 40 41 typedef enum { 42 CAM_NO_MODULE, 43 CAM_HAL_MODULE, 44 CAM_MCI_MODULE, 45 CAM_JPEG_MODULE, 46 CAM_LAST_MODULE 47 } cam_modules_t; 48 49 /* values that persist.camera.global.debug can be set to */ 50 /* all camera modules need to map their internal debug levels to this range */ 51 typedef enum { 52 CAM_GLBL_DBG_NONE = 0, 53 CAM_GLBL_DBG_ERR = 1, 54 CAM_GLBL_DBG_WARN = 2, 55 CAM_GLBL_DBG_HIGH = 3, 56 CAM_GLBL_DBG_DEBUG = 4, 57 CAM_GLBL_DBG_LOW = 5, 58 CAM_GLBL_DBG_INFO = 6 59 } cam_global_debug_level_t; 60 61 extern int g_cam_log[CAM_LAST_MODULE][CAM_GLBL_DBG_INFO + 1]; 62 63 #define FATAL_IF(cond, ...) LOG_ALWAYS_FATAL_IF(cond, ## __VA_ARGS__) 64 65 #undef CLOGx 66 #define CLOGx(module, level, fmt, args...) \ 67 {\ 68 if (g_cam_log[module][level]) { \ 69 mm_camera_debug_log(module, level, __func__, __LINE__, fmt, ##args); \ 70 }\ 71 } 72 73 #undef CLOGI 74 #define CLOGI(module, fmt, args...) \ 75 CLOGx(module, CAM_GLBL_DBG_INFO, fmt, ##args) 76 #undef CLOGD 77 #define CLOGD(module, fmt, args...) \ 78 CLOGx(module, CAM_GLBL_DBG_DEBUG, fmt, ##args) 79 #undef CLOGL 80 #define CLOGL(module, fmt, args...) \ 81 CLOGx(module, CAM_GLBL_DBG_LOW, fmt, ##args) 82 #undef CLOGW 83 #define CLOGW(module, fmt, args...) \ 84 CLOGx(module, CAM_GLBL_DBG_WARN, fmt, ##args) 85 #undef CLOGH 86 #define CLOGH(module, fmt, args...) \ 87 CLOGx(module, CAM_GLBL_DBG_HIGH, fmt, ##args) 88 #undef CLOGE 89 #define CLOGE(module, fmt, args...) \ 90 CLOGx(module, CAM_GLBL_DBG_ERR, fmt, ##args) 91 92 #ifndef CAM_MODULE 93 #define CAM_MODULE CAM_MCI_MODULE 94 #endif 95 96 #undef LOGD 97 #define LOGD(fmt, args...) CLOGD(CAM_MODULE, fmt, ##args) 98 #undef LOGL 99 #define LOGL(fmt, args...) CLOGL(CAM_MODULE, fmt, ##args) 100 #undef LOGW 101 #define LOGW(fmt, args...) CLOGW(CAM_MODULE, fmt, ##args) 102 #undef LOGH 103 #define LOGH(fmt, args...) CLOGH(CAM_MODULE, fmt, ##args) 104 #undef LOGE 105 #define LOGE(fmt, args...) CLOGE(CAM_MODULE, fmt, ##args) 106 #undef LOGI 107 #define LOGI(fmt, args...) CLOGI(CAM_MODULE, fmt, ##args) 108 109 /* reads and updates camera logging properties */ 110 void mm_camera_set_dbg_log_properties(void); 111 112 /* generic logger function */ 113 void mm_camera_debug_log(const cam_modules_t module, 114 const cam_global_debug_level_t level, 115 const char *func, const int line, const char *fmt, ...); 116 117 #else 118 119 #undef LOGD 120 #define LOGD(fmt, args...) ALOGD(fmt, ##args) 121 #undef LOGL 122 #define LOGL(fmt, args...) ALOGD(fmt, ##args) 123 #undef LOGW 124 #define LOGW(fmt, args...) ALOGW(fmt, ##args) 125 #undef LOGH 126 #define LOGH(fmt, args...) ALOGD(fmt, ##args) 127 #undef LOGE 128 #define LOGE(fmt, args...) ALOGE(fmt, ##args) 129 #undef LOGI 130 #define LOGI(fmt, args...) ALOGV(fmt, ##args) 131 132 #endif 133 134 #endif /* __MM_CAMERA_DBG_H__ */ 135