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 107 // MBox type of FW cmd 108 #if (HAL_HVD_ENABLE_VPU_CMD) 109 #define HAL_HVD_CMD_MBOX E_HVD_VPU_HI_0 110 #define HAL_HVD_CMD_ARG_MBOX E_HVD_VPU_HI_1 111 #else 112 #define HAL_HVD_CMD_MBOX E_HVD_HI_0 113 #define HAL_HVD_CMD_ARG_MBOX E_HVD_HI_1 114 #endif 115 // MBox other usages 116 #define HAL_HVD_REG_ISR_VPU E_HVD_VPU_RISC_1 117 #define HAL_HVD_REG_FW_STATE E_HVD_RISC_0 118 #define HAL_HVD_REG_ISR_HVD E_HVD_RISC_1 119 #define HAL_HVD_REG_DISP_INFO_COPYED E_HVD_RISC_1 120 #define HAL_HVD_REG_DISP_INFO_CHANGE E_HVD_RISC_1 121 #define HAL_HVD_REG_DISP_CTL E_HVD_HI_0 122 123 #define PRESET_ONE_PENDING_BUFFER (1 << 0) /// For AVC, one pending buffer mode, reduce from two to one 124 #define PRESET_FRAMERATE_HANDLING (1 << 1) /// For AVC, Handle frame rate by input frame rate when sequence did not have frame rate info. 125 #define PRESET_TSP_IN_BBU_MODE (1 << 2) /// For AVS/AVS+ only. Raw data comes from TSP while HVD HW engine triggers decode according to BBU table 126 127 #if defined(CHIP_T3) 128 // patch for HW bug 129 #define HVD_MIU1_BASE_ADDRESS 0x08000000UL//0x10000000UL 130 #else // CHIP_U3 131 #define HVD_MIU1_BASE_ADDRESS 0x08000000UL 132 #endif 133 134 #define HVD_RV_BROKENBYUS_BIT 29 135 136 //------------------------------------------------------------------------------------------------- 137 // Type and Structure 138 //------------------------------------------------------------------------------------------------- 139 140 typedef enum 141 { 142 E_HVD_HI_0, 143 E_HVD_HI_1, 144 E_HVD_RISC_0, 145 E_HVD_RISC_1, 146 E_HVD_VPU_HI_0, 147 E_HVD_VPU_HI_1, 148 E_HVD_VPU_RISC_0, 149 E_HVD_VPU_RISC_1, 150 } HVD_MBOX_TYPE; 151 152 typedef enum 153 { 154 //Support TSP/TS/File mode 155 E_HAL_HVD_MAIN_STREAM, 156 157 //Only support file mode 158 E_HAL_HVD_SUB_STREAM, 159 160 //Only support MVC mode 161 E_HAL_HVD_MVC_STREAM, 162 } HAL_HVD_StreamType; 163 164 typedef struct 165 { 166 HAL_HVD_StreamId eStreamId; 167 MS_BOOL bUsed; 168 MS_BOOL bDispOutSide; 169 MS_U32 u32PTSPreWptr; 170 MS_U32 u32PTSByteCnt; 171 MS_U32 u32BBUWptr; 172 MS_U32 u32BBUEntryNum; 173 MS_U32 u32BBUEntryNumTH; 174 MS_U32 u32DispQIndex; 175 MS_U32 u32PrivateData; 176 MS_U32 u32FreeData; 177 MS_U32 u32RegBase; 178 } HVD_EX_Stream; 179 180 typedef struct 181 { 182 MS_BOOL bColocateBBUMode; 183 184 }HVD_EX_PreSet; 185 186 //------------------------------------------------------------------------------------------------- 187 // Function and Variable 188 //------------------------------------------------------------------------------------------------- 189 MS_BOOL HAL_HVD_EX_InitHW(MS_U32 u32Id,VPU_EX_DecoderType DecoderType); 190 MS_BOOL HAL_HVD_EX_DeinitHW(void); 191 void HAL_HVD_EX_FlushMemory(void); 192 void HAL_HVD_EX_ReadMemory(void); 193 void HAL_HVD_EX_SetDrvCtrlsBase(HVD_EX_Drv_Ctrl *pHVDCtrlsBase); 194 void HAL_HVD_EX_CheckMIUSel(MS_BOOL bChange); 195 MS_U32 HAL_HVD_EX_GetHWVersionID(void); 196 HAL_HVD_StreamId HAL_HVD_EX_GetFreeStream(HAL_HVD_StreamType eStreamType); 197 void HAL_HVD_EX_PowerCtrl(MS_BOOL bEnable); 198 void HAL_HVD_EX_InitRegBase(MS_U32 u32RegBase); 199 HVD_Return HAL_HVD_EX_InitVariables(MS_U32 u32Id); 200 HVD_Return HAL_HVD_EX_InitShareMem(MS_U32 u32Id); 201 HVD_Return HAL_HVD_EX_InitRegCPU(MS_U32 u32Id); 202 HVD_Return HAL_HVD_EX_SetData(MS_U32 u32Id, HVD_SetData u32type, MS_U32 u32Data); 203 MS_U32 HAL_HVD_EX_GetData(MS_U32 u32Id, HVD_GetData eType); 204 MS_S64 HAL_HVD_EX_GetData_EX(MS_U32 u32Id, HVD_GetData eType); 205 MS_U32 HAL_HVD_EX_GetShmAddr(MS_U32 u32Id); 206 MS_BOOL HAL_HVD_EX_GetFrmRateIsSupported(MS_U32 u32Id, MS_U16 u16HSize, MS_U16 u16VSize, MS_U32 u32FrmRate); 207 HVD_Return HAL_HVD_EX_SetCmd(MS_U32 u32Id, HVD_User_Cmd eUsrCmd, MS_U32 u32CmdArg); 208 HVD_Return HAL_HVD_EX_DeInit(MS_U32 u32Id); 209 HVD_Return HAL_HVD_EX_PushPacket(MS_U32 u32Id, HVD_BBU_Info *pInfo); 210 void HAL_HVD_EX_EnableISR(MS_U32 u32Id, MS_BOOL bEnable); 211 void HAL_HVD_EX_SetForceISR(MS_U32 u32Id, MS_BOOL bEnable); 212 void HAL_HVD_EX_SetClearISR(MS_U32 u32Id); 213 MS_BOOL HAL_HVD_EX_IsISROccured(MS_U32 u32Id); 214 MS_BOOL HAL_HVD_EX_IsEnableISR(MS_U32 u32Id); 215 MS_BOOL HAL_HVD_EX_IsAlive(MS_U32 u32Id); 216 MS_BOOL HAL_HVD_EX_RstPTSCtrlVariable(MS_U32 u32Id); 217 MS_BOOL HAL_HVD_EX_FlushRstShareMem(MS_U32 u32Id); 218 void HAL_HVD_EX_UartSwitch2FW(MS_BOOL bEnable); 219 MS_U32 HAL_HVD_EX_GetData_Dbg(MS_VIRT u32Addr); 220 void HAL_HVD_EX_SetData_Dbg(MS_VIRT u32Addr, MS_U32 u32Data); 221 MS_U16 HAL_HVD_EX_GetCorretClock(MS_U16 u16Clock); 222 void HAL_HVD_EX_UpdateESWptr_Fire(MS_U32 u32Id); 223 void HAL_HVD_EX_MVD_PowerCtrl(MS_BOOL bEnable); 224 void HAL_HVD_EX_Dump_FW_Status(MS_U32 u32Id); 225 void HAL_HVD_EX_Dump_HW_Status(MS_U32 u32Num); 226 void HAL_HVD_EX_SetMiuBurstLevel(HVD_EX_Drv_Ctrl *pDrvCtrl, HVD_MIU_Burst_Cnt_Ctrl eMiuBurstCntCtrl); 227 #ifdef SUPPORT_X_MODEL_FEATURE //We using the common compile option to handle X model 228 void HVD_EX_SetRstFlag(MS_BOOL bRst); 229 #endif 230 MS_BOOL HAL_HVD_EX_DispFrameAllViewed(MS_U32 u32Id); 231 #if HVD_ENABLE_MVC 232 MS_BOOL HAL_HVD_EX_CheckMVCID(MS_U32 u32Id); 233 VDEC_EX_View HAL_HVD_EX_GetView(MS_U32 u32Id); 234 #endif ///HVD_ENABLE_MVC 235 MS_BOOL HAL_HVD_EX_Init_Share_Mem(void); 236 void HAL_HVD_EX_SpareBandwidth(MS_U32 u32Id); 237 MS_U32 HAL_HVD_EX_GetDispFrmNum(MS_U32 u32Id); 238 HVD_Return HAL_HVD_EX_SetHVDColBBUMode(MS_U32 u32Id, MS_BOOL bEnable); 239 void HAL_HVD_EX_SetHwRegBase(MS_U32 u32Id, MS_U32 u32ModeFlag); 240 MS_BOOL HAL_HVD_EX_GetSupport2ndMVOPInterface(void); 241 void HAL_HVD_EX_SetBufferAddr(MS_U32 u32Id); 242 void HAL_HVD_EX_SetPreCtrlVariables(MS_U32 u32Id,MS_U32 drvprectrl); 243 244 typedef enum 245 { 246 E_BBU_FSM_START = 0, 247 E_BBU_FSM_0, 248 E_BBU_FSM_00, 249 E_BBU_FSM_001, 250 } VDEC_EX_BBU_FSM_STATE; 251 252 MS_BOOL _HVD_EX_IS_BBU_TSP_MODE(MS_U32 u32Id); 253 MS_BOOL _HVD_EX_BBU_Get_TaskRunning(MS_U32 u32Id); 254 void _HVD_EX_BBU_Set_TaskRunning(MS_U32 u32Id,MS_BOOL val); 255 MS_U32 _HVD_EX_GetESOffsetIncrease(MS_U32 u32Id, MS_U32 inc, MS_U32 offset); 256 MS_U32 _HVD_EX_GetESOffsetMinus(MS_U32 u32Id, MS_U32 mis, MS_U32 offset); 257 void _HVD_EX_ES_DBG_PRINT(MS_U32 u32Id, MS_U32 offset, MS_U32 length); 258 MS_U32 _HVD_EX_ES_Read(MS_U32 u32Id, MS_U32 offset); 259 260 MS_BOOL _HVD_EX_CheckWaterLevel(MS_U32 u32Id, MS_U32 u32ESRptr, MS_U32 u32ESWptr); 261 MS_BOOL _HVD_EX_BBU_FindStartCode(MS_U32 u32Id,MS_U32* u32Offset, MS_U32 u32ESRptr, MS_U32 u32ESWptr); 262 263 void HAL_HVD_EX_BBU_Proc(MS_U32 u32Id); 264 void HAL_HVD_EX_BBU_StopProc(MS_U32 u32Id); 265 266 #endif 267 268 #endif // _HAL_HVD_H_ 269 270