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