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 /////////////////////////////////////////////////////////////////////////////////////////////////// 96 /// 97 /// @file drvMJPEG.h 98 /// @brief MJPEG Driver Interface 99 /// @author MStar Semiconductor Inc. 100 /////////////////////////////////////////////////////////////////////////////////////////////////// 101 102 #ifndef _DRV_MJPEG_H_ 103 #define _DRV_MJPEG_H_ 104 105 //#include "njpeg_def.h" 106 107 108 #ifdef __cplusplus 109 extern "C" 110 { 111 #endif 112 113 typedef enum 114 { 115 E_HVD_FW_INPUT_SOURCE_NONE, ///< No input fw. 116 E_HVD_FW_INPUT_SOURCE_DRAM, ///< input source from DRAM. 117 E_HVD_FW_INPUT_SOURCE_FLASH, ///< input source from FLASH. 118 } HVD_FWInputSourceType; 119 120 // Chip Define 121 typedef enum 122 { 123 E_MJPEG_MSTAR_CHIP_NONE = 0, 124 E_MJPEG_MSTAR_CHIP_U3, 125 E_MJPEG_MSTAR_CHIP_T3, 126 E_MJPEG_MSTAR_CHIP_T4, 127 E_MJPEG_MSTAR_CHIP_JANUS, 128 E_MJPEG_MSTAR_CHIP_U4, 129 E_MJPEG_MSTAR_CHIP_T8, 130 E_MJPEG_MSTAR_CHIP_T9, 131 E_MJPEG_MSTAR_CHIP_T13, 132 E_MJPEG_MSTAR_CHIP_A1, 133 E_MJPEG_MSTAR_CHIP_A6, 134 E_MJPEG_MSTAR_CHIP_A7, 135 E_MJPEG_MSTAR_CHIP_AMETHYST, 136 E_MJPEG_MSTAR_CHIP_EAGLE, 137 E_MJPEG_MSTAR_CHIP_J2, 138 E_MJPEG_MSTAR_CHIP_EMERALD, 139 E_MJPEG_MSTAR_CHIP_NUGGET, 140 E_MJPEG_MSTAR_CHIP_NIKON, 141 } MJPEG_MSTAR_CHIP_ID; 142 143 // Mimic fwNJPD_if.h 144 typedef enum 145 { 146 // Invalid cmd 147 E_MJPEG_CMD_INVALID = 0xffffffffUL, 148 149 E_MJPEG_CMD_GO = 0x00, // Start to show 150 E_MJPEG_CMD_SET_FRAME_BUFF_START_ADDR = 0x01, // Set frame buffer address 151 E_MJPEG_CMD_SET_FRAME_BUFF_UNIT_SIZE = 0x02, // Set frame buffer size 152 E_MJPEG_CMD_SET_FRAME_BUFF_TOTAL_NUM = 0x03, // Set total number of frame buffer 153 E_MJPEG_CMD_SET_FRAME_BUFF_IDX = 0x04, // Set frame buffer index 154 E_MJPEG_CMD_SET_FRAME_BUFF_IDX_READY = 0x05, // Set frame buffer index ready for display 155 E_MJPEG_CMD_SET_WIDTH = 0x06, // Set frame width 156 E_MJPEG_CMD_SET_HEIGHT = 0x07, // Set frame height 157 E_MJPEG_CMD_SET_PITCH = 0x08, // Set pitch 158 E_MJPEG_CMD_SET_FRAME_ID_L = 0x09, // Set frame ID_L 159 E_MJPEG_CMD_SET_FRAME_ID_H = 0x0A, // Set frame ID_H 160 E_MJPEG_CMD_SET_TIMESTAMP = 0x0B, // Set Time Stamp 161 E_MJPEG_CMD_SET_FRAMERATE = 0x0C, // Set FrameRate 162 E_MJPEG_CMD_SET_FRAMERATE_BASE = 0x0D, // Set FrameRate Base 163 E_MJPEG_CMD_SET_FRAME_BUFF_IDX_VALID = 0x0E, // Set frame buffer index available 164 E_MJPEG_CMD_SET_CHIP_ID = 0x0F, // Set frame buffer index available 165 166 E_MJPEG_CMD_PLAY = 0x20, // Play 167 E_MJPEG_CMD_PAUSE = 0x21, // Pause 168 E_MJPEG_CMD_RESUME = 0x22, // Resume 169 E_MJPEG_CMD_STEP_PLAY = 0x23, // Step play 170 E_MJPEG_CMD_SET_SPEED_TYPE = 0x24, // Set play speed type: default, fast, slow 171 E_MJPEG_CMD_SET_SPEED = 0x25, // Set play speed 172 E_MJPEG_CMD_FLUSH_DISP_QUEUE = 0X26, // Flush display queue 173 E_MJPEG_CMD_FREEZE_DISP = 0x27, // Freeze display 174 E_MJPEG_CMD_ENABLE_AVSYNC = 0x28, // Enable AV sync 175 E_MJPEG_CMD_SET_AVSYNC_DELAY = 0x29, // Set AV sync delay 176 E_MJPEG_CMD_SET_AVSYNC_TOLERENCE = 0x2A, // Set AV sync tolerence 177 E_MJPEG_CMD_SET_PTS_BASE = 0x2B, // Set PTS base 178 E_MJPEG_CMD_SET_STC_BASE = 0x2C, // Set STC base 179 E_MJPEG_CMD_SET_BLUE_SCREEN = 0x2D, // Set Blue Screen 180 E_MJPEG_CMD_PUSH_QUEUE_PARA_SETTING = 0x2E, 181 E_MJPEG_CMD_SET_DISPLAY_OUTSIDE_MODE = 0x2F, 182 183 E_MJPEG_CMD_GET_NEXT_FREE_FRAME_BUFF_IDX = 0x40, // Get next free frame buffer index 184 E_MJPEG_CMD_COMPENSATE_PTS = 0x41, // Ask firmware to compensate PTS 185 186 #ifdef VDEC3 187 E_MJPEG_CMD_GET_FRAME_BUFFER = 0x50, // Ask firmware to get frame buffer 188 E_MJPEG_CMD_FREE_FRAME_BUFFER = 0x51, // Ask firmware to free frame buffer 189 #endif 190 191 // Display Command Queue 192 E_MJPEG_CMD_ENABLE_DISP_CMD_QUEUE = 0x80, // Enable Display Command Queue 193 E_MJPEG_CMD_PUSH_DISP_CMD = 0x81, // Push Display Command 194 E_MJPEG_CMD_GET_DISP_CMD_Q_VACANCY = 0x82, // Check if the display command queue full or not 195 196 E_MJPEG_CMD_IS_STEP_PLAY_DONE = 0xFF, // 197 E_MJPEG_CMD_IS_DISP_FINISH = 0xFE, // 198 E_MJPEG_CMD_IS_PLAYING = 0xFC, // 199 E_MJPEG_CMD_IS_DISPLAY_QUEUE_FULL = 0xFB, // 200 E_MJPEG_CMD_IS_AVSYNC_ON = 0xFA, // 201 E_MJPEG_CMD_IS_REACH_AVSYNC = 0xF9, // 202 E_MJPEG_CMD_IS_FLUSH_DONE = 0xF8, // Check if flush done 203 204 } MJPEG_User_Cmd; 205 206 // MJPEG debug level enum 207 typedef enum 208 { 209 E_MJPEG_DEBUG_DRV_NONE = 0x0 210 , E_MJPEG_DEBUG_DRV_MSG = 0x02 211 , E_MJPEG_DEBUG_DRV_ERR = 0x08 212 } MJPEG_DrvDbgLevel; 213 214 typedef enum 215 { 216 E_MJPEG_FAILED = 0 217 , E_MJPEG_OK = 1 218 , E_MJPEG_INVALID_PARAM = 2 219 } MJPEG_Return; 220 221 /// frame information 222 typedef struct 223 { 224 MS_PHYADDR u32LumaAddr; /// frame buffer base + the start offset of current displayed luma data. Unit: byte. 225 MS_PHYADDR u32ChromaAddr; /// frame buffer base + the start offset of current displayed chroma data. Unit: byte. 226 MS_U32 u32TimeStamp; /// Time stamp(DTS, PTS) of current displayed frame. Unit: ms (todo: 90khz) 227 MS_U32 u32ID_L; /// low part of ID number 228 MS_U32 u32ID_H; /// high part of ID number 229 MS_U16 u16Pitch; /// pitch 230 MS_U16 u16Width; /// width 231 MS_U16 u16Height; /// hight 232 MS_U32 eFrameType;///< Frame type: I, P, B frame 233 } MJPEG_DRV_FrameInfo; 234 235 typedef struct 236 { 237 MS_U32 u32Size; 238 MS_PHY u32Addr; 239 MS_U32 u32BinSize; 240 MS_PHY u32BinAddr; 241 MS_U8 u8FwSrcType; 242 MS_PHY u32MWCAddr; 243 MS_U32 u32MWCSize; 244 #ifdef VDEC3 245 MS_BOOL bFWdecideFB; 246 #endif 247 } MJPEG_FW_Info; 248 249 typedef enum 250 { 251 E_MJPEG_DRV_STREAM_NONE = 0, 252 E_MJPEG_DRV_MAIN_STREAM, 253 E_MJPEG_DRV_SUB_STREAM, 254 #ifdef VDEC3 255 E_MJPEG_DRV_N_STREAM, 256 #endif 257 } MJPEG_DRV_StreamType; 258 259 typedef enum 260 { 261 E_MJPEG_MJPEG1, 262 E_MJPEG_MJPEG2, 263 E_MJPEG_MJPEG3, 264 E_MJPEG_MJPEG4, 265 E_MJPEG_MJPEG_TOTAL // Do not remove this one 266 } JPD_Number; 267 268 void MDrv_MJPEG_SetFrameBuffStAddr(MS_U8 u8DrvId, MS_VIRT u32Value); 269 MS_VIRT MDrv_MJPEG_GetFrameBuffStAddr(MS_U8 u8DrvId); 270 void MDrv_MJPEG_SetFrameBuffTotalSize(MS_U8 u8DrvId, MS_U32 u32Value); 271 MS_U32 MDrv_MJPEG_GetFrameBuffTotalSize(MS_U8 u8DrvId); 272 void MDrv_MJPEG_SetFrameBuffUnitSize(MS_U8 u8DrvId, MS_U32 u32Value); 273 MS_U32 MDrv_MJPEG_GetFrameBuffUnitSize(MS_U8 u8DrvId); 274 void MDrv_MJPEG_SetFrameBuffTotalNum(MS_U8 u8DrvId, MS_U32 u32Value); 275 MS_U32 MDrv_MJPEG_GetFrameBuffTotalNum(MS_U8 u8DrvId); 276 void MDrv_MJPEG_SetWidth(MS_U8 u8DrvId, MS_U16 u16Value); 277 MS_U16 MDrv_MJPEG_GetWidth(MS_U8 u8DrvId); 278 void MDrv_MJPEG_SetHeight(MS_U8 u8DrvId, MS_U16 u16Value); 279 MS_U16 MDrv_MJPEG_GetHeight(MS_U8 u8DrvId); 280 void MDrv_MJPEG_SetPitch(MS_U8 u8DrvId, MS_U16 u16Value); 281 MS_U16 MDrv_MJPEG_GetPitch(MS_U8 u8DrvId); 282 void MDrv_MJPEG_SetFrameCnt(MS_U8 u8DrvId, MS_U32 u32Value); 283 MS_U32 MDrv_MJPEG_GetFrameCnt(MS_U8 u8DrvId); 284 void MDrv_MJPEG_SetFrameRate(MS_U8 u8DrvId, MS_U32 u32Value); 285 MS_U32 MDrv_MJPEG_GetFrameRate(MS_U8 u8DrvId); 286 void MDrv_MJPEG_SetFrameRateBase(MS_U8 u8DrvId, MS_U32 u32Value); 287 MS_U32 MDrv_MJPEG_GetFrameRateBase(MS_U8 u8DrvId); 288 void MDrv_MJPEG_SetFrameTime(MS_U8 u8DrvId, MS_U32 u32Value); 289 MS_U32 MDrv_MJPEG_GetFrameTime(MS_U8 u8DrvId); 290 291 void MDrv_MJPEG_SetDbgLevel(MS_U8 u8DbgLevel); 292 293 /* =============================== MJPEG =====================================*/ 294 MS_U8 MDrv_MJPEG_GetDrvId(MS_U32 u32Id); 295 void MDrv_MJPEG_StopVPU(MS_U32 u32Id); 296 //MS_BOOL MDrv_MJPEG_RstVPU(void); 297 void MDrv_MJPEG_ReleaseVPU(MS_U32 u32Id); 298 //void MDrv_MJPEG_ConfigVPU(MS_PHYADDR u32StAddr, MS_U8 u8dlend_en); 299 MS_BOOL MDrv_MJPEG_IsFirmwareReady(MS_U32 u32Id); 300 301 #if 0 302 MS_BOOL MDrv_MJPEG_SetVPUCmd(MS_U32 u32Cmd); 303 MS_BOOL MDrv_MJPEG_SetVPUCmdArg(MS_U32 u32Arg); 304 MS_U32 MDrv_MJPEG_CheckVPUStatus(MS_U32 u32Cmd); 305 MS_U32 MDrv_MJPEG_GetNextFreeFrameBuffIdx(void); 306 #endif 307 MS_U32 MDrv_MJPEG_SendVPUCommand(MS_U32 u32Id, MJPEG_User_Cmd eCmd, MS_VIRT u32Arg); 308 309 //MS_BOOL MDrv_MJPEG_IsVPUOnMiu1(void); 310 //MS_U32 MDrv_MJPEG_GetMiuBase(void); 311 MS_VIRT MDrv_MJPEG_GetShareMemAddr(MS_U32 u32Id); 312 void MDrv_MJPEG_ClearShareMemory(MS_U32 u32Id); 313 MS_VIRT MDrv_MJPEG_GetPtsTableAddr(MS_U32 u32Id); 314 315 MS_BOOL MDrv_MJPEG_ResetPTS(MS_U32 u32Id, MS_U32 u32PtsBase); 316 MS_U32 MDrv_MJPEG_GetPTS(MS_U32 u32Id); 317 void MDrv_MJPEG_GetDispFrameInfo(MS_U32 u32Id, void *pInfo); 318 319 void MDrv_MJPEG_DispFrame(MS_U32 u32Id, MS_U32 u32DispIdx); 320 void MDrv_MJPEG_FreeFrame(MS_U32 u32Id, MS_U32 u32DispIdx); 321 void* MDrv_MJPEG_GetNextDispFrame(MS_U32 u32Id); 322 MS_U32 MDrv_MJPEG_GetDispFrameNum(MS_U32 u32Id); 323 MS_U32 MDrv_MJPEG_GetNextDispQPtr(MS_U32 u32Id); 324 325 void MDrv_MJPEG_EnableTurboFWMode(MS_U32 u32Id, MS_BOOL bEnable); 326 327 MJPEG_Return MDrv_MJPEG_InitFw(MS_U32 u32Id, MJPEG_FW_Info FWInfo); 328 MJPEG_MSTAR_CHIP_ID MDrv_MJPEG_Get_Chip_ID(void); 329 330 // for Dual Decode 331 MJPEG_Return MDrv_MJPEG_GetFreeStream(MS_U32 *pu32Id, MJPEG_DRV_StreamType eStreamType); 332 MJPEG_Return MDrv_MJPEG_DeInit(MS_U32 u32Id); 333 void MDrv_MJPEG_InitRegBase(MS_VIRT u32RegBase); 334 void MDrv_MJPEG_SetPushQPara(MS_U32 u32Id, MS_U32 u32TimeStamp, MS_U32 u32ID_L, MS_U32 u32ID_H, MS_U32 u32NextFrameBuffIdx); 335 void MDrv_MJPEG_SetStepDispPara(MS_U32 u32Id); 336 void MDrv_MJPEG_SetMIUInfo(MS_U32 u32Id, MS_U8 u8MIU); 337 void MDrv_MJPEG_PrintShareInfo(MS_U32 u32Id); 338 MS_U32 MDrv_MJPEG_GetNextFrameBufferIdx(MS_U32 u32Id); 339 MS_BOOL MDrv_MJPEG_IsStepPlayDone(MS_U32 u32Id); 340 MS_BOOL MDrv_MJPEG_IsPlaying(MS_U32 u32Id); 341 MS_BOOL MDrv_MJPEG_IsAVSyncOn(MS_U32 u32Id); 342 MS_BOOL MDrv_MJPEG_IsReachAVSync(MS_U32 u32Id); 343 MS_BOOL MDrv_MJPEG_IsFlushDone(MS_U32 u32Id); 344 void MDrv_MJPEG_InitFlush(MS_U32 u32Id); 345 void MDrv_MJPEG_Init_IsDispFinish(MS_U32 u32Id); 346 MS_BOOL MDrv_MJPEG_IsDispFinish(MS_U32 u32Id); 347 void MDrv_MJPEG_Init_IsQueueFull(MS_U32 u32Id); 348 MS_BOOL MDrv_MJPEG_IsQueueFull(MS_U32 u32Id); 349 #ifdef VDEC3 350 void MDrv_MJPEG_Init_GetFrameBuffer(MS_U32 u32Id); 351 MS_BOOL MDrv_MJPEG_GetFrameBuffer(MS_U32 u32Id); 352 MS_BOOL MDrv_MJPEG_IsFreeFinish(MS_U32 u32Id); 353 #if defined(MSOS_TYPE_LINUX) && defined(SUPPORT_CMA) 354 void MDrv_MJPEG_GetCMAInformation(MS_U32 u32Id, MS_PHY* u32Addr,MS_U32* u32Size,MS_BOOL* bAllocDone); 355 #endif 356 #endif 357 358 #ifdef __cplusplus 359 } 360 #endif 361 362 #endif // _DRV_MJPEG_H_ 363 364