• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *
3  * Copyright 2013 Rockchip Electronics Co., LTD.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 /*
19  * @file        Rockchip_OSAL_Log.h
20  * @brief
21  * @author      csy(csy@rock-chips.com)
22  * @version     1.0.0
23  * @history
24  *   2013.11.26 : Create
25  */
26 
27 #ifndef ROCKCHIP_OSAL_LOG
28 #define ROCKCHIP_OSAL_LOG
29 
30 #include "OMX_Core.h"
31 #include "OMX_Types.h"
32 
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36 
37 #ifndef ROCKCHIP_LOG_TAG
38 #define ROCKCHIP_LOG_TAG    "omx_log"
39 #endif
40 
41 typedef enum _LOG_LEVEL {
42     ROCKCHIP_LOG_TRACE,
43     ROCKCHIP_LOG_INFO,
44     ROCKCHIP_LOG_WARNING,
45     ROCKCHIP_LOG_ERROR,
46     ROCKCHIP_LOG_DEBUG
47 } ROCKCHIP_LOG_LEVEL;
48 
49 /*
50  * omx_debug bit definition
51  */
52 #define OMX_DBG_UNKNOWN                 0x00000000
53 #define OMX_DBG_FUNCTION                0x80000000
54 #define OMX_DBG_MALLOC                  0x40000000
55 #define OMX_DBG_CAPACITYS               0x00000001
56 
57 void _Rockchip_OSAL_Log(ROCKCHIP_LOG_LEVEL logLevel, OMX_U32 flag, const char *tag, const char *msg, ...);
58 
59 #define omx_info(format, ...) \
60     _Rockchip_OSAL_Log(ROCKCHIP_LOG_INFO, OMX_DBG_UNKNOWN, ROCKCHIP_LOG_TAG, format "\n", ##__VA_ARGS__)
61 #define omx_trace(format, ...) \
62     _Rockchip_OSAL_Log(ROCKCHIP_LOG_TRACE, OMX_DBG_UNKNOWN, ROCKCHIP_LOG_TAG, format "\n", ##__VA_ARGS__)
63 #define omx_err(format, ...)   \
64     _Rockchip_OSAL_Log(ROCKCHIP_LOG_ERROR, OMX_DBG_UNKNOWN, ROCKCHIP_LOG_TAG, format "\n", ##__VA_ARGS__)
65 #define omx_warn(format, ...)  \
66     _Rockchip_OSAL_Log(ROCKCHIP_LOG_WARNING, OMX_DBG_UNKNOWN, ROCKCHIP_LOG_TAG, format "\n", ##__VA_ARGS__)
67 
68 #define omx_info_f(format, ...) \
69     _Rockchip_OSAL_Log(ROCKCHIP_LOG_INFO, OMX_DBG_UNKNOWN, ROCKCHIP_LOG_TAG, \
70         "%s(%d): " format "\n", __FUNCTION__, __LINE__, ##__VA_ARGS__)
71 #define omx_trace_f(format, ...) \
72     _Rockchip_OSAL_Log(ROCKCHIP_LOG_TRACE, OMX_DBG_UNKNOWN, \
73       ROCKCHIP_LOG_TAG, "%s(%d): " format "\n", __FUNCTION__, __LINE__, ##__VA_ARGS__)
74 #define omx_err_f(format, ...)  \
75     _Rockchip_OSAL_Log(ROCKCHIP_LOG_ERROR, OMX_DBG_UNKNOWN, \
76      ROCKCHIP_LOG_TAG, "%s(%d): " format "\n", __FUNCTION__, __LINE__, ##__VA_ARGS__)
77 #define omx_warn_f(format, ...)  \
78     _Rockchip_OSAL_Log(ROCKCHIP_LOG_WARNING, OMX_DBG_UNKNOWN, ROCKCHIP_LOG_TAG, \
79         "%s(%d): " format "\n", __FUNCTION__, __LINE__, ##__VA_ARGS__)
80 
81 #define _omx_dbg(fmt, ...)  \
82     _Rockchip_OSAL_Log(ROCKCHIP_LOG_INFO, OMX_DBG_UNKNOWN, \
83         ROCKCHIP_LOG_TAG, "%s(%d): " fmt "\n", __FUNCTION__, __LINE__, ##__VA_ARGS__)
84 
85 #define omx_dbg_f(flags, fmt, ...) \
86     _Rockchip_OSAL_Log(ROCKCHIP_LOG_DEBUG, flags, ROCKCHIP_LOG_TAG, \
87          "%s(%d): " fmt "\n", __FUNCTION__, __LINE__, ##__VA_ARGS__)
88 
89 #define omx_dbg(debug, flag, fmt, ...) \
90             do { \
91                 if (debug & flag) \
92                     _omx_dbg(fmt, ## __VA_ARGS__); \
93             } while (0)
94 
95 #define FunctionIn() omx_dbg_f(OMX_DBG_FUNCTION, "IN")
96 
97 #define FunctionOut() omx_dbg_f(OMX_DBG_FUNCTION, "OUT")
98 
99 
100 #ifdef __cplusplus
101 }
102 #endif
103 
104 #endif