1 /* 2 * Copyright 2021 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 __HAL_AVS2D_GLOBAL_H__ 18 #define __HAL_AVS2D_GLOBAL_H__ 19 20 #include "mpp_device.h" 21 #include "hal_bufs.h" 22 23 #include "parser_api.h" 24 #include "hal_avs2d_api.h" 25 #include "avs2d_syntax.h" 26 27 #define AVS2D_HAL_DBG_ERROR (0x00000001) 28 #define AVS2D_HAL_DBG_ASSERT (0x00000002) 29 #define AVS2D_HAL_DBG_WARNNING (0x00000004) 30 #define AVS2D_HAL_DBG_TRACE (0x00000100) 31 #define AVS2D_HAL_DBG_REG (0x00000200) 32 #define AVS2D_HAL_DBG_IN (0x00000400) 33 #define AVS2D_HAL_DBG_OUT (0x00000800) 34 35 #define AVS2D_HAL_DBG_OFFSET (0x00010000) 36 37 extern RK_U32 avs2d_hal_debug; 38 39 #define AVS2D_HAL_DBG(level, fmt, ...)\ 40 do {\ 41 if (level & avs2d_hal_debug)\ 42 { mpp_log(fmt, ## __VA_ARGS__); }\ 43 } while (0) 44 45 #define AVS2D_HAL_TRACE(fmt, ...)\ 46 do {\ 47 if (AVS2D_HAL_DBG_TRACE & avs2d_hal_debug)\ 48 { mpp_log_f(fmt, ## __VA_ARGS__); }\ 49 } while (0) 50 51 52 #define INP_CHECK(ret, val, ...)\ 53 do{\ 54 if ((val)) { \ 55 ret = MPP_ERR_INIT; \ 56 AVS2D_HAL_DBG(AVS2D_HAL_DBG_WARNNING, "input empty(%d).\n", __LINE__); \ 57 goto __RETURN; \ 58 }\ 59 } while (0) 60 61 62 #define FUN_CHECK(val)\ 63 do{\ 64 if ((val) < 0) {\ 65 AVS2D_HAL_DBG(AVS2D_HAL_DBG_WARNNING, "Function error(%d).\n", __LINE__); \ 66 goto __FAILED; \ 67 }\ 68 } while (0) 69 70 71 //!< memory malloc check 72 #define MEM_CHECK(ret, val, ...)\ 73 do{\ 74 if (!(val)) {\ 75 ret = MPP_ERR_MALLOC; \ 76 mpp_err_f("malloc buffer error(%d).\n", __LINE__); \ 77 goto __FAILED; \ 78 }\ 79 } while (0) 80 81 82 #define FIELDPICTURE 0 83 #define FRAMEPICTURE 1 84 85 enum { 86 IFRAME = 0, 87 PFRAME = 1, 88 BFRAME = 2 89 }; 90 91 typedef struct avs2d_hal_ctx_t { 92 MppHalApi hal_api; 93 MppDecCfgSet *cfg; 94 MppBufSlots frame_slots; 95 MppBufSlots packet_slots; 96 MppBufferGroup buf_group; 97 HalBufs cmv_bufs; 98 RK_U32 mv_size; 99 RK_U32 mv_count; 100 MppCbCtx *dec_cb; 101 MppDev dev; 102 Avs2dSyntax_t syntax; 103 RK_U32 fast_mode; 104 105 void *reg_ctx; 106 MppBuffer shph_buf; 107 MppBuffer scalist_buf; 108 109 RK_U32 frame_no; 110 const MppDecHwCap *hw_info; 111 } Avs2dHalCtx_t; 112 113 #endif /*__HAL_AVS2D_GLOBAL_H__*/ 114