1 /* 2 * Copyright (c) 2022 HiSilicon (Shanghai) Technologies CO., LIMITED. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef __HI_COMM_VB_H__ 17 #define __HI_COMM_VB_H__ 18 19 #include "hi_type.h" 20 #include "hi_errno.h" 21 #include "hi_debug.h" 22 23 #ifdef __cplusplus 24 #if __cplusplus 25 extern "C" { 26 #endif 27 #endif 28 29 #define VB_INVALID_POOLID 0xFFFFFFFF 30 #define VB_INVALID_HANDLE 0xFFFFFFFF 31 32 #define VB_MAX_COMM_POOLS 16 33 #define VB_MAX_MOD_COMM_POOLS 16 34 35 /* user ID for VB */ 36 #define VB_MAX_USER VB_UID_BUTT 37 38 typedef enum hiVB_UID_E { 39 VB_UID_VI = 0, 40 VB_UID_VO = 1, 41 VB_UID_VGS = 2, 42 VB_UID_VENC = 3, 43 VB_UID_VDEC = 4, 44 VB_UID_H265E = 5, 45 VB_UID_H264E = 6, 46 VB_UID_JPEGE = 7, 47 VB_UID_H264D = 8, 48 VB_UID_JPEGD = 9, 49 VB_UID_VPSS = 10, 50 VB_UID_DIS = 11, 51 VB_UID_USER = 12, 52 VB_UID_PCIV = 13, 53 VB_UID_AI = 14, 54 VB_UID_AENC = 15, 55 VB_UID_RC = 16, 56 VB_UID_VFMW = 17, 57 VB_UID_GDC = 18, 58 VB_UID_AVS = 19, 59 VB_UID_DPU_RECT = 20, 60 VB_UID_DPU_MATCH = 21, 61 VB_UID_MCF = 22, 62 VB_UID_BUTT = 23, 63 } VB_UID_E; 64 65 /* Generall common pool use this owner id, module common pool use VB_UID as owner id */ 66 #define POOL_OWNER_COMMON (-1) 67 68 /* Private pool use this owner id */ 69 #define POOL_OWNER_PRIVATE (-2) 70 71 typedef HI_U32 VB_POOL; 72 typedef HI_U32 VB_BLK; 73 74 #define RESERVE_MMZ_NAME "window" 75 76 typedef enum hiVB_REMAP_MODE_E { 77 VB_REMAP_MODE_NONE = 0, /* no remap */ 78 VB_REMAP_MODE_NOCACHE = 1, /* no cache remap */ 79 VB_REMAP_MODE_CACHED = 2, /* cache remap, if you use this mode, you should flush cache by yourself */ 80 VB_REMAP_MODE_BUTT 81 } VB_REMAP_MODE_E; 82 83 typedef struct hiVB_POOL_CONFIG_S { 84 HI_U64 u64BlkSize; 85 HI_U32 u32BlkCnt; 86 VB_REMAP_MODE_E enRemapMode; 87 HI_CHAR acMmzName[MAX_MMZ_NAME_LEN]; 88 } VB_POOL_CONFIG_S; 89 90 typedef struct hiVB_CONFIG_S { 91 HI_U32 u32MaxPoolCnt; 92 VB_POOL_CONFIG_S astCommPool[VB_MAX_COMM_POOLS]; 93 } VB_CONFIG_S; 94 95 typedef struct hiVB_POOL_STATUS_S { 96 HI_U32 bIsCommPool; 97 HI_U32 u32BlkCnt; 98 HI_U32 u32FreeBlkCnt; 99 } VB_POOL_STATUS_S; 100 101 #define VB_SUPPLEMENT_JPEG_MASK 0x1 102 #define VB_SUPPLEMENT_ISPINFO_MASK 0x2 103 #define VB_SUPPLEMENT_MOTION_DATA_MASK 0x4 104 #define VB_SUPPLEMENT_DNG_MASK 0x8 105 106 typedef struct hiVB_SUPPLEMENT_CONFIG_S { 107 HI_U32 u32SupplementConfig; 108 } VB_SUPPLEMENT_CONFIG_S; 109 110 #define HI_ERR_VB_NULL_PTR HI_DEF_ERR(HI_ID_VB, EN_ERR_LEVEL_ERROR, EN_ERR_NULL_PTR) 111 #define HI_ERR_VB_NOMEM HI_DEF_ERR(HI_ID_VB, EN_ERR_LEVEL_ERROR, EN_ERR_NOMEM) 112 #define HI_ERR_VB_NOBUF HI_DEF_ERR(HI_ID_VB, EN_ERR_LEVEL_ERROR, EN_ERR_NOBUF) 113 #define HI_ERR_VB_UNEXIST HI_DEF_ERR(HI_ID_VB, EN_ERR_LEVEL_ERROR, EN_ERR_UNEXIST) 114 #define HI_ERR_VB_ILLEGAL_PARAM HI_DEF_ERR(HI_ID_VB, EN_ERR_LEVEL_ERROR, EN_ERR_ILLEGAL_PARAM) 115 #define HI_ERR_VB_NOTREADY HI_DEF_ERR(HI_ID_VB, EN_ERR_LEVEL_ERROR, EN_ERR_SYS_NOTREADY) 116 #define HI_ERR_VB_BUSY HI_DEF_ERR(HI_ID_VB, EN_ERR_LEVEL_ERROR, EN_ERR_BUSY) 117 #define HI_ERR_VB_NOT_PERM HI_DEF_ERR(HI_ID_VB, EN_ERR_LEVEL_ERROR, EN_ERR_NOT_PERM) 118 #define HI_ERR_VB_SIZE_NOT_ENOUGH HI_DEF_ERR(HI_ID_VB, EN_ERR_LEVEL_ERROR, EN_ERR_SIZE_NOT_ENOUGH) 119 120 #define HI_ERR_VB_2MPOOLS HI_DEF_ERR(HI_ID_VB, EN_ERR_LEVEL_ERROR, EN_ERR_BUTT + 1) 121 122 #define HI_TRACE_VB(level, fmt, ...) \ 123 do { \ 124 HI_TRACE(level, HI_ID_VB, "[Func]:%s [Line]:%d [Info]:" fmt, __FUNCTION__, __LINE__, ##__VA_ARGS__); \ 125 } while (0) 126 127 #ifdef __cplusplus 128 #if __cplusplus 129 } 130 #endif 131 #endif /* __cplusplus */ 132 133 #endif /* __HI_COMM_VB_H_ */ 134 135