• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2022 Rockchip Electronics Co. LTD
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef __MPP_DEBUG_H__
18 #define __MPP_DEBUG_H__
19 
20 #include <stdlib.h>
21 
22 #include "rk_type.h"
23 #include "mpp_err.h"
24 #include "mpp_log.h"
25 
26 #define MPP_DBG_TIMING                  (0x00000001)
27 #define MPP_DBG_PTS                     (0x00000002)
28 #define MPP_DBG_INFO                    (0x00000004)
29 #define MPP_DBG_PLATFORM                (0x00000010)
30 
31 #define MPP_DBG_DUMP_LOG                (0x00000100)
32 #define MPP_DBG_DUMP_IN                 (0x00000200)
33 #define MPP_DBG_DUMP_OUT                (0x00000400)
34 #define MPP_DBG_DUMP_CFG                (0x00000800)
35 
36 #define _mpp_dbg(debug, flag, fmt, ...)     mpp_log_c((debug) & (flag), fmt, ## __VA_ARGS__)
37 #define _mpp_dbg_f(debug, flag, fmt, ...)   mpp_log_cf((debug) & (flag), fmt, ## __VA_ARGS__)
38 
39 #define mpp_dbg(flag, fmt, ...)         _mpp_dbg(mpp_debug, flag, fmt, ## __VA_ARGS__)
40 #define mpp_dbg_f(flag, fmt, ...)       _mpp_dbg_f(mpp_debug, flag, fmt, ## __VA_ARGS__)
41 
42 #define mpp_dbg_pts(fmt, ...)           mpp_dbg(MPP_DBG_PTS, fmt, ## __VA_ARGS__)
43 #define mpp_dbg_info(fmt, ...)          mpp_dbg(MPP_DBG_INFO, fmt, ## __VA_ARGS__)
44 #define mpp_dbg_platform(fmt, ...)      mpp_dbg(MPP_DBG_PLATFORM, fmt, ## __VA_ARGS__)
45 
46 #define MPP_ABORT                       (0x10000000)
47 
48 /*
49  * mpp_dbg usage:
50  *
51  * in h264d module define module debug flag variable like: h265d_debug
52  * then define h265d_dbg macro as follow :
53  *
54  * extern RK_U32 h265d_debug;
55  *
56  * #define H265D_DBG_FUNCTION          (0x00000001)
57  * #define H265D_DBG_VPS               (0x00000002)
58  * #define H265D_DBG_SPS               (0x00000004)
59  * #define H265D_DBG_PPS               (0x00000008)
60  * #define H265D_DBG_SLICE_HDR         (0x00000010)
61  *
62  * #define h265d_dbg(flag, fmt, ...) mpp_dbg(h265d_debug, flag, fmt, ## __VA_ARGS__)
63  *
64  * finally use environment control the debug flag
65  *
66  * mpp_get_env_u32("h264d_debug", &h265d_debug, 0)
67  *
68  */
69 /*
70  * sub-module debug flag usage example:
71  * +------+-------------------+
72  * | 8bit |      24bit        |
73  * +------+-------------------+
74  *  0~15 bit: software debug print
75  * 16~23 bit: hardware debug print
76  * 24~31 bit: information print format
77  */
78 
79 #define mpp_abort() do {                \
80     if (mpp_debug & MPP_ABORT) {        \
81         abort();                        \
82     }                                   \
83 } while (0)
84 
85 #define MPP_STRINGS(x)      MPP_TO_STRING(x)
86 #define MPP_TO_STRING(x)    #x
87 
88 #define mpp_assert(cond) do {                                           \
89     if (!(cond)) {                                                      \
90         mpp_err("Assertion %s failed at %s:%d\n",                       \
91                MPP_STRINGS(cond), __FUNCTION__, __LINE__);              \
92         mpp_abort();                                                    \
93     }                                                                   \
94 } while (0)
95 
96 
97 #ifdef __cplusplus
98 extern "C" {
99 #endif
100 
101 extern RK_U32 mpp_debug;
102 
103 #ifdef __cplusplus
104 }
105 #endif
106 
107 #endif /*__MPP_DEBUG_H__*/
108