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