1 /* 2 * Copyright 2015 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_AVSD_BASE_H__ 18 #define __HAL_AVSD_BASE_H__ 19 20 #include "parser_api.h" 21 #include "hal_avsd_api.h" 22 #include "avsd_syntax.h" 23 24 #include "mpp_device.h" 25 26 #define AVSD_HAL_DBG_ERROR (0x00000001) 27 #define AVSD_HAL_DBG_ASSERT (0x00000002) 28 #define AVSD_HAL_DBG_WARNNING (0x00000004) 29 #define AVSD_HAL_DBG_TRACE (0x00000008) 30 31 #define AVSD_HAL_DBG_OFFSET (0x00000010) 32 #define AVSD_HAL_DBG_WAIT (0x00000020) 33 34 #define AVSD_DBG_HARD_MODE (0x00010000) 35 #define AVSD_DBG_PROFILE_ID (0x00020000) 36 37 extern RK_U32 avsd_hal_debug; 38 39 #define AVSD_HAL_DBG(level, fmt, ...)\ 40 do {\ 41 if (level & avsd_hal_debug)\ 42 { mpp_log(fmt, ## __VA_ARGS__); }\ 43 } while (0) 44 45 #define AVSD_HAL_TRACE(fmt, ...)\ 46 do {\ 47 if (AVSD_HAL_DBG_TRACE & avsd_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 AVSD_HAL_DBG(AVSD_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 AVSD_HAL_DBG(AVSD_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 avsd_hal_picture_t { 92 RK_U32 valid; 93 RK_U32 pic_type; 94 RK_U32 pic_code_type; 95 RK_U32 picture_distance; 96 97 RK_S32 slot_idx; 98 } AvsdHalPic_t; 99 100 101 typedef struct avsd_hal_ctx_t { 102 MppHalApi hal_api; 103 MppBufSlots frame_slots; 104 MppBufSlots packet_slots; 105 MppBufferGroup buf_group; 106 107 MppCodingType coding; 108 MppCbCtx *dec_cb; 109 MppDev dev; 110 MppDecCfgSet *dec_cfg; 111 112 AvsdSyntax_t syn; 113 RK_U32 *p_regs; 114 RK_U32 regs_num; 115 MppBuffer mv_buf; 116 MppHalCfg *cfg; 117 118 AvsdHalPic_t pic[3]; 119 //!< add for control 120 RK_U32 first_field; 121 RK_U32 prev_pic_structure; 122 RK_U32 prev_pic_code_type; 123 RK_S32 future2prev_past_dist; 124 RK_S32 work0; 125 RK_S32 work1; 126 RK_S32 work_out; 127 RK_U32 data_offset; 128 129 RK_U32 frame_no; 130 } AvsdHalCtx_t; 131 132 133 #ifdef __cplusplus 134 extern "C" { 135 #endif 136 137 RK_U32 avsd_ver_align(RK_U32 val); 138 RK_U32 avsd_hor_align(RK_U32 val); 139 RK_U32 avsd_len_align(RK_U32 val); 140 RK_S32 get_queue_pic(AvsdHalCtx_t *p_hal); 141 RK_S32 get_packet_fd(AvsdHalCtx_t *p_hal, RK_S32 idx); 142 RK_S32 get_frame_fd(AvsdHalCtx_t *p_hal, RK_S32 idx); 143 144 #ifdef __cplusplus 145 } 146 #endif 147 148 #endif /*__HAL_AVSD_COMMON_H__*/ 149