1 //<MStar Software> 2 //****************************************************************************** 3 // MStar Software 4 // Copyright (c) 2010 - 2012 MStar Semiconductor, Inc. All rights reserved. 5 // All software, firmware and related documentation herein ("MStar Software") are 6 // intellectual property of MStar Semiconductor, Inc. ("MStar") and protected by 7 // law, including, but not limited to, copyright law and international treaties. 8 // Any use, modification, reproduction, retransmission, or republication of all 9 // or part of MStar Software is expressly prohibited, unless prior written 10 // permission has been granted by MStar. 11 // 12 // By accessing, browsing and/or using MStar Software, you acknowledge that you 13 // have read, understood, and agree, to be bound by below terms ("Terms") and to 14 // comply with all applicable laws and regulations: 15 // 16 // 1. MStar shall retain any and all right, ownership and interest to MStar 17 // Software and any modification/derivatives thereof. 18 // No right, ownership, or interest to MStar Software and any 19 // modification/derivatives thereof is transferred to you under Terms. 20 // 21 // 2. You understand that MStar Software might include, incorporate or be 22 // supplied together with third party`s software and the use of MStar 23 // Software may require additional licenses from third parties. 24 // Therefore, you hereby agree it is your sole responsibility to separately 25 // obtain any and all third party right and license necessary for your use of 26 // such third party`s software. 27 // 28 // 3. MStar Software and any modification/derivatives thereof shall be deemed as 29 // MStar`s confidential information and you agree to keep MStar`s 30 // confidential information in strictest confidence and not disclose to any 31 // third party. 32 // 33 // 4. MStar Software is provided on an "AS IS" basis without warranties of any 34 // kind. Any warranties are hereby expressly disclaimed by MStar, including 35 // without limitation, any warranties of merchantability, non-infringement of 36 // intellectual property rights, fitness for a particular purpose, error free 37 // and in conformity with any international standard. You agree to waive any 38 // claim against MStar for any loss, damage, cost or expense that you may 39 // incur related to your use of MStar Software. 40 // In no event shall MStar be liable for any direct, indirect, incidental or 41 // consequential damages, including without limitation, lost of profit or 42 // revenues, lost or damage of data, and unauthorized system use. 43 // You agree that this Section 4 shall still apply without being affected 44 // even if MStar Software has been modified by MStar in accordance with your 45 // request or instruction for your use, except otherwise agreed by both 46 // parties in writing. 47 // 48 // 5. If requested, MStar may from time to time provide technical supports or 49 // services in relation with MStar Software to you for your use of 50 // MStar Software in conjunction with your or your customer`s product 51 // ("Services"). 52 // You understand and agree that, except otherwise agreed by both parties in 53 // writing, Services are provided on an "AS IS" basis and the warranty 54 // disclaimer set forth in Section 4 above shall apply. 55 // 56 // 6. Nothing contained herein shall be construed as by implication, estoppels 57 // or otherwise: 58 // (a) conferring any license or right to use MStar name, trademark, service 59 // mark, symbol or any other identification; 60 // (b) obligating MStar or any of its affiliates to furnish any person, 61 // including without limitation, you and your customers, any assistance 62 // of any kind whatsoever, or any information; or 63 // (c) conferring any license or right under any intellectual property right. 64 // 65 // 7. These terms shall be governed by and construed in accordance with the laws 66 // of Taiwan, R.O.C., excluding its conflict of law rules. 67 // Any and all dispute arising out hereof or related hereto shall be finally 68 // settled by arbitration referred to the Chinese Arbitration Association, 69 // Taipei in accordance with the ROC Arbitration Law and the Arbitration 70 // Rules of the Association by three (3) arbitrators appointed in accordance 71 // with the said Rules. 72 // The place of arbitration shall be in Taipei, Taiwan and the language shall 73 // be English. 74 // The arbitration award shall be final and binding to both parties. 75 // 76 //****************************************************************************** 77 //<MStar Software> 78 //////////////////////////////////////////////////////////////////////////////// 79 // 80 // Copyright (c) 2008-2009 MStar Semiconductor, Inc. 81 // All rights reserved. 82 // 83 // Unless otherwise stipulated in writing, any and all information contained 84 // herein regardless in any format shall remain the sole proprietary of 85 // MStar Semiconductor Inc. and be kept in strict confidence 86 // ("MStar Confidential Information") by the recipient. 87 // Any unauthorized act including without limitation unauthorized disclosure, 88 // copying, use, reproduction, sale, distribution, modification, disassembling, 89 // reverse engineering and compiling of the contents of MStar Confidential 90 // Information is unlawful and strictly prohibited. MStar hereby reserves the 91 // rights to any and all damages, losses, costs and expenses resulting therefrom. 92 // 93 //////////////////////////////////////////////////////////////////////////////// 94 95 #ifndef _HAL_HVD_H_ 96 #define _HAL_HVD_H_ 97 #if !defined(MSOS_TYPE_NUTTX) || defined(SUPPORT_X_MODEL_FEATURE) 98 99 //------------------------------------------------------------------------------------------------- 100 // Macro and Define 101 //------------------------------------------------------------------------------------------------- 102 // Feature 103 #define HAL_HVD_ENABLE_MUTEX_PROTECT HVD_ENABLE_MUTEX_PROTECT 104 #define HAL_HVD_ENABLE_MIU_PROTECT HVD_ENABLE_MIU_RST_PROTECT 105 #define HAL_HVD_ENABLE_VPU_CMD 1 106 #define HAL_CHIP_SUPPORT_EVD 107 108 109 // MBox type of FW cmd 110 #if (HAL_HVD_ENABLE_VPU_CMD) 111 #define HAL_HVD_CMD_MBOX E_HVD_VPU_HI_0 112 #define HAL_HVD_CMD_ARG_MBOX E_HVD_VPU_HI_1 113 #else 114 #define HAL_HVD_CMD_MBOX E_HVD_HI_0 115 #define HAL_HVD_CMD_ARG_MBOX E_HVD_HI_1 116 #endif 117 // MBox other usages 118 #define HAL_HVD_REG_ISR_VPU E_HVD_VPU_RISC_1 119 #define HAL_HVD_REG_FW_STATE E_HVD_RISC_0 120 #define HAL_HVD_REG_ISR_HVD E_HVD_RISC_1 121 #define HAL_HVD_REG_DISP_INFO_COPYED E_HVD_RISC_1 122 #define HAL_HVD_REG_DISP_INFO_CHANGE E_HVD_RISC_1 123 #define HAL_HVD_REG_DISP_CTL E_HVD_HI_0 124 125 #define PRESET_ONE_PENDING_BUFFER (1 << 0) /// For AVC, one pending buffer mode, reduce from two to one 126 #define PRESET_FRAMERATE_HANDLING (1 << 1) /// For AVC, Handle frame rate by input frame rate when sequence did not have frame rate info. 127 128 #if defined(CHIP_T3) 129 // patch for HW bug 130 #define HVD_MIU1_BASE_ADDRESS 0x08000000UL//0x10000000UL 131 #else // CHIP_U3 132 #define HVD_MIU1_BASE_ADDRESS 0x08000000UL 133 #endif 134 135 #define HVD_RV_BROKENBYUS_BIT 29 136 137 #ifdef VDEC3 138 #define HAL_HVD_INVALID_BBU_ID 0xFFFFFFFF 139 #endif 140 141 //------------------------------------------------------------------------------------------------- 142 // Type and Structure 143 //------------------------------------------------------------------------------------------------- 144 145 typedef enum 146 { 147 E_HVD_HI_0, 148 E_HVD_HI_1, 149 E_HVD_RISC_0, 150 E_HVD_RISC_1, 151 E_HVD_VPU_HI_0, 152 E_HVD_VPU_HI_1, 153 E_HVD_VPU_RISC_0, 154 E_HVD_VPU_RISC_1, 155 } HVD_MBOX_TYPE; 156 157 typedef enum 158 { 159 //Support TSP/TS/File mode 160 E_HAL_HVD_MAIN_STREAM, 161 162 //Only support file mode 163 E_HAL_HVD_SUB_STREAM, 164 165 //Only support MVC mode 166 E_HAL_HVD_MVC_STREAM, 167 168 #ifdef VDEC3 169 E_HAL_HVD_N_STREAM, 170 #endif 171 } HAL_HVD_StreamType; 172 173 #ifdef VDEC3 174 typedef enum 175 { 176 E_HAL_HVD_AVC, 177 E_HAL_HVD_AVS, 178 E_HAL_HVD_RM, 179 E_HAL_HVD_MVC, 180 E_HAL_HVD_VP8, 181 E_HAL_HVD_MJPEG, 182 E_HAL_HVD_VP6, 183 E_HAL_HVD_HEVC, 184 E_HAL_HVD_VP9, 185 E_HAL_HVD_NONE, 186 } HAL_HVD_CodecType; 187 188 typedef enum 189 { 190 E_HAL_HVD_STATE_STOP, 191 E_HAL_HVD_STATE_RUNNING, 192 E_HAL_HVD_STATE_PAUSING, 193 E_HAL_HVD_STATE_PAUSE_DONE 194 } HAL_HVD_Task_State; 195 196 #endif 197 198 typedef struct 199 { 200 HAL_HVD_StreamId eStreamId; 201 MS_BOOL bUsed; 202 MS_BOOL bDispOutSide; 203 MS_U32 u32PTSPreWptr; 204 MS_U32 u32PTSByteCnt; 205 MS_U32 u32BBUWptr; 206 MS_U32 u32BBUEntryNum; 207 MS_U32 u32BBUEntryNumTH; 208 MS_U32 u32DispQIndex; 209 MS_U32 u32PrivateData; 210 MS_U32 u32FreeData; 211 MS_U32 u32RegBase; 212 #ifdef VDEC3 213 HAL_HVD_CodecType u32CodecType; 214 HAL_HVD_Task_State ePpTaskState; 215 MS_S32 s32HvdPpTaskId; 216 #endif 217 } HVD_EX_Stream; 218 219 typedef struct 220 { 221 MS_BOOL bColocateBBUMode; 222 223 }HVD_EX_PreSet; 224 225 //------------------------------------------------------------------------------------------------- 226 // Function and Variable 227 //------------------------------------------------------------------------------------------------- 228 MS_BOOL HAL_HVD_EX_InitHW(MS_U32 u32Id,VPU_EX_DecoderType DecoderType); 229 MS_BOOL HAL_HVD_EX_DeinitHW(void); 230 void HAL_HVD_EX_FlushMemory(void); 231 void HAL_HVD_EX_ReadMemory(void); 232 void HAL_HVD_EX_SetDrvCtrlsBase(HVD_EX_Drv_Ctrl *pHVDCtrlsBase); 233 void HAL_HVD_EX_CheckMIUSel(MS_BOOL bChange); 234 MS_U32 HAL_HVD_EX_GetHWVersionID(void); 235 HAL_HVD_StreamId HAL_HVD_EX_GetFreeStream(HAL_HVD_StreamType eStreamType); 236 void HAL_HVD_EX_PowerCtrl(MS_BOOL bEnable); 237 void HAL_HVD_EX_InitRegBase(MS_U32 u32RegBase); 238 HVD_Return HAL_HVD_EX_InitVariables(MS_U32 u32Id); 239 #ifdef VDEC3 240 MS_U32 HAL_HVD_EX_GetBBUId(MS_U32 u32Id); 241 MS_BOOL HAL_HVD_EX_FreeBBUId(MS_U32 u32Id, MS_U32 u32BBUId); 242 HVD_Return HAL_HVD_EX_InitShareMem(MS_U32 u32Id, MS_BOOL bFWdecideFB, MS_BOOL bCMAUsed); 243 HVD_Return HAL_HVD_EX_InitRegCPU(MS_U32 u32Id, MS_BOOL bFWdecideFB); 244 #else 245 HVD_Return HAL_HVD_EX_InitShareMem(MS_U32 u32Id); 246 HVD_Return HAL_HVD_EX_InitRegCPU(MS_U32 u32Id); 247 #endif 248 HVD_Return HAL_HVD_EX_SetData(MS_U32 u32Id, HVD_SetData u32type, MS_U32 u32Data); 249 MS_U32 HAL_HVD_EX_GetData(MS_U32 u32Id, HVD_GetData eType); 250 MS_S64 HAL_HVD_EX_GetData_EX(MS_U32 u32Id, HVD_GetData eType); 251 MS_U32 HAL_HVD_EX_GetShmAddr(MS_U32 u32Id); 252 MS_VIRT HAL_HVD_EX_GetDispQExtShmAddr(MS_U32 u32Id); 253 MS_BOOL HAL_HVD_EX_GetFrmRateIsSupported(MS_U32 u32Id, MS_U16 u16HSize, MS_U16 u16VSize, MS_U32 u32FrmRate); 254 HVD_Return HAL_HVD_EX_SetCmd(MS_U32 u32Id, HVD_User_Cmd eUsrCmd, MS_U32 u32CmdArg); 255 HVD_Return HAL_HVD_EX_DeInit(MS_U32 u32Id); 256 HVD_Return HAL_HVD_EX_PushPacket(MS_U32 u32Id, HVD_BBU_Info *pInfo); 257 void HAL_HVD_EX_EnableISR(MS_U32 u32Id, MS_BOOL bEnable); 258 void HAL_HVD_EX_SetForceISR(MS_U32 u32Id, MS_BOOL bEnable); 259 void HAL_HVD_EX_SetClearISR(HWDEC_ISR_TYPE eISRType); 260 MS_BOOL HAL_HVD_EX_IsISROccured(MS_U32 u32Id); 261 MS_BOOL HAL_HVD_EX_IsEnableISR(MS_U32 u32Id); 262 MS_BOOL HAL_HVD_EX_IsAlive(MS_U32 u32Id); 263 MS_BOOL HAL_HVD_EX_RstPTSCtrlVariable(MS_U32 u32Id); 264 MS_BOOL HAL_HVD_EX_FlushRstShareMem(MS_U32 u32Id); 265 void HAL_HVD_EX_UartSwitch2FW(MS_BOOL bEnable); 266 MS_U32 HAL_HVD_EX_GetData_Dbg(MS_U32 u32Addr); 267 void HAL_HVD_EX_SetData_Dbg(MS_U32 u32Addr, MS_U32 u32Data); 268 MS_U16 HAL_HVD_EX_GetCorretClock(MS_U16 u16Clock); 269 void HAL_HVD_EX_UpdateESWptr_Fire(MS_U32 u32Id); 270 void HAL_HVD_EX_MVD_PowerCtrl(MS_BOOL bEnable); 271 void HAL_HVD_EX_Dump_FW_Status(MS_U32 u32Id); 272 void HAL_HVD_EX_Dump_HW_Status(MS_U32 u32Num); 273 void HAL_HVD_EX_SetMiuBurstLevel(HVD_EX_Drv_Ctrl *pDrvCtrl, HVD_MIU_Burst_Cnt_Ctrl eMiuBurstCntCtrl); 274 void HVD_EX_SetRstFlag(MS_BOOL bRst); 275 MS_BOOL HAL_HVD_EX_DispFrameAllViewed(MS_U32 u32Id); 276 #if HVD_ENABLE_MVC 277 MS_BOOL HAL_HVD_EX_CheckMVCID(MS_U32 u32Id); 278 VDEC_EX_View HAL_HVD_EX_GetView(MS_U32 u32Id); 279 #endif ///HVD_ENABLE_MVC 280 MS_BOOL HAL_HVD_EX_Init_Share_Mem(void); 281 void HAL_HVD_EX_SpareBandwidth(MS_U32 u32Id); 282 void HAL_HVD_EX_PowerSaving(MS_U32 u32Id); 283 MS_U32 HAL_HVD_EX_GetDispFrmNum(MS_U32 u32Id); 284 HVD_Return HAL_HVD_EX_SetHVDColBBUMode(MS_U32 u32Id, MS_BOOL bEnable); 285 void HAL_HVD_EX_SetHwRegBase(MS_U32 u32Id, MS_U32 u32ModeFlag); 286 #if SUPPORT_EVD 287 void HAL_EVD_EX_ClearTSPInput(MS_U32 u32Id); 288 #endif 289 MS_BOOL HAL_HVD_EX_GetSupport2ndMVOPInterface(void); 290 void HAL_HVD_EX_SetBufferAddr(MS_U32 u32Id); 291 void HAL_HVD_EX_SetPreCtrlVariables(MS_U32 u32Id,MS_U32 drvprectrl); 292 MS_BOOL HAL_HVD_EX_Is_RM_Supported(MS_U32 u32Id); 293 void HAL_HVD_MVDMiuClientSel(MS_U8 u8MiuSel); 294 typedef enum 295 { 296 E_BBU_FSM_START = 0, 297 E_BBU_FSM_0, 298 E_BBU_FSM_00, 299 E_BBU_FSM_001, 300 } VDEC_EX_BBU_FSM_STATE; 301 302 MS_BOOL _HVD_EX_IS_BBU_TSP_MODE(MS_U32 u32Id); 303 MS_BOOL _HVD_EX_BBU_Get_TaskRunning(MS_U32 u32Id); 304 void _HVD_EX_BBU_Set_TaskRunning(MS_U32 u32Id,MS_BOOL val); 305 MS_U32 _HVD_EX_GetESOffsetIncrease(MS_U32 u32Id, MS_U32 inc, MS_U32 offset); 306 MS_U32 _HVD_EX_GetESOffsetMinus(MS_U32 u32Id, MS_U32 mis, MS_U32 offset); 307 void _HVD_EX_ES_DBG_PRINT(MS_U32 u32Id, MS_U32 offset, MS_U32 length); 308 309 MS_BOOL _HVD_EX_BBU_FindStartCode(MS_U32 u32Id,MS_U32* u32Offset, MS_U32 u32ESRptr, MS_U32 u32ESWptr); 310 311 void HAL_HVD_EX_BBU_Proc(MS_U32 u32Id); 312 void HAL_HVD_EX_BBU_StopProc(MS_U32 u32Id); 313 314 MS_U32 HAL_HVD_EX_GetEVDHWBuffer(void); 315 316 #endif 317 #endif // _HAL_HVD_H_ 318 319