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 apiMJPEG.h 98 /// @brief MJPEG API 99 /// @author MStar Semiconductor Inc. 100 /////////////////////////////////////////////////////////////////////////////////////////////////// 101 102 #ifndef _API_MJPEG_H_ 103 #define _API_MJPEG_H_ 104 105 #include "MsCommon.h" 106 107 108 #ifdef __cplusplus 109 extern "C" 110 { 111 #endif 112 113 //------------------------------------------------------------------------------------------------- 114 // Macro and Define 115 //------------------------------------------------------------------------------------------------- 116 117 typedef enum 118 { 119 E_MJPEG_RET_FAIL = 0, 120 E_MJPEG_RET_SUCCESS, 121 E_MJPEG_RET_INVALID_PARAMETER, 122 E_MJPEG_RET_DECODE_HDR_ERROR, 123 E_MJPEG_RET_DECODE_ERROR, 124 E_MJPEG_RET_DECODING, 125 } MJPEG_Result; 126 127 typedef enum 128 { 129 E_MJPEG_SPEED_DEFAULT = 0, 130 E_MJPEG_SPEED_FAST, 131 E_MJPEG_SPEED_SLOW 132 } MJPEG_SpeedType; 133 134 typedef enum 135 { 136 /// Normal display speed. 137 E_MJPEG_DISP_SPEED_1X = 1, 138 /// 2X 139 E_MJPEG_DISP_SPEED_2X = 2, 140 /// 4X 141 E_MJPEG_DISP_SPEED_4X = 4, 142 /// 8X 143 E_MJPEG_DISP_SPEED_8X = 8, 144 /// 16X 145 E_MJPEG_DISP_SPEED_16X = 16, 146 /// 32X 147 E_MJPEG_DISP_SPEED_32X = 32, 148 } MJPEG_DispSpeed; 149 150 typedef enum 151 { 152 /// disable all uart message. 153 E_MJPEG_DBG_LEVEL_NONE = 0, 154 /// Only output error message 155 E_MJPEG_DBG_LEVEL_ERR, 156 /// output general message, and above. 157 E_MJPEG_DBG_LEVEL_INFO, 158 /// output debug message, and above. 159 E_MJPEG_DBG_LEVEL_DBG, 160 /// output function tracing message, and above. 161 E_MJPEG_DBG_LEVEL_TRACE, 162 /// output FW message. 163 E_MJPEG_DBG_LEVEL_FW, 164 } MJPEG_DbgLevel; 165 166 typedef enum 167 { 168 E_MJPEG_FW_SOURCE_NONE, ///< No input fw. 169 E_MJPEG_FW_SOURCE_DRAM, ///< input source from DRAM. 170 E_MJPEG_FW_SOURCE_FLASH, ///< input source from FLASH. 171 } MJPEG_FWSourceType; 172 173 typedef enum 174 { 175 E_MJPEG_ERROR_CODE_NONE = 0, 176 E_MJPEG_ERR_CODE_RES, 177 } MJPEG_ErrorCode; 178 179 //for Dual Decode 180 typedef enum 181 { 182 E_MJPEG_API_STREAM_NONE = 0, 183 E_MJPEG_API_MAIN_STREAM, 184 E_MJPEG_API_SUB_STREAM 185 } MJPEG_API_StreamType; 186 187 188 //------------------------------------------------------------------------------------------------- 189 // Type and Structure 190 //------------------------------------------------------------------------------------------------- 191 typedef struct 192 { 193 MS_PHY u32FwBinAddr; // Address of firmware binary 194 MS_U32 u32FwBinSize; // Size of firmware binary 195 MS_PHY u32FwAddr; // Address to load firmware 196 MS_U32 u32FwSize; // Firmware size 197 MS_PHY u32MRCBufAddr; // MRC buffer address 198 MS_U32 u32MRCBufSize; // MRC buffer size 199 MS_PHY u32MWCBufAddr; // MWC buffer address 200 MS_U32 u32MWCBufSize; // MWC buffer size 201 MS_PHY u32InternalBufAddr; // internal buffer address 202 MS_U32 u32InternalBufSize; // internal buffer size 203 //MS_U32 u32FrameTime; // frame time 204 MS_U32 u32FrameRate; 205 MS_U32 u32FrameRateBase; 206 MJPEG_FWSourceType eFwSrcType; // the input FW source type. 207 MS_U32 u32Width; 208 MS_U32 u32Height; 209 } MJPEG_INIT_PARAM; 210 211 typedef struct 212 { 213 MS_U16 u16Width; 214 MS_U16 u16Height; 215 MS_U32 u32FrameRate; 216 MS_U16 u16CropRight; 217 MS_U16 u16CropLeft; 218 MS_U16 u16CropBottom; 219 MS_U16 u16CropTop; 220 MS_U16 u16Pitch; 221 } MJPEG_DISP_INFO; 222 223 typedef enum 224 { 225 E_MJPEG_STAGE_STOP = 0, 226 E_MJPEG_STAGE_INIT, 227 E_MJPEG_STAGE_PLAY, 228 E_MJPEG_STAGE_PAUSE, 229 } MJPEG_Stage; 230 231 typedef struct 232 { 233 MS_BOOL bInit; 234 MS_BOOL bIdle; 235 MJPEG_Stage eStage; 236 } MJPEG_Status; 237 238 typedef enum 239 { 240 E_MJPEG_FRM_TYPE_I = 0, 241 //E_MJPEG_FRM_TYPE_P, 242 //E_MJPEG_FRM_TYPE_B, 243 E_MJPEG_FRM_TYPE_OTHER = 3, 244 } MJPEG_FrameType; 245 246 /// frame information 247 typedef struct 248 { 249 MS_PHY u32LumaAddr; /// frame buffer base + the start offset of current displayed luma data. Unit: byte. 250 MS_PHY u32ChromaAddr; /// frame buffer base + the start offset of current displayed chroma data. Unit: byte. 251 MS_U32 u32TimeStamp; /// Time stamp(DTS, PTS) of current displayed frame. Unit: ms (todo: 90khz) 252 MS_U32 u32ID_L; /// low part of ID number 253 MS_U32 u32ID_H; /// high part of ID number 254 MS_U16 u16Pitch; /// pitch 255 MS_U16 u16Width; /// width 256 MS_U16 u16Height; /// hight 257 MJPEG_FrameType eFrameType;///< Frame type: I, P, B frame 258 } MJPEG_FrameInfo; 259 260 typedef struct 261 { 262 MS_U32 u32StAddr; ///< Packet offset from bitstream buffer base address. unit: byte. 263 MS_U32 u32Size; ///< Packet size. unit: byte. 264 MS_U32 u32TimeStamp; ///< Packet time stamp. unit: ms. 265 MS_U32 u32ID_L; ///< Packet ID low part. 266 MS_U32 u32ID_H; ///< Packet ID high part. 267 } MJPEG_Packet_Info; 268 269 typedef enum 270 { 271 E_MJPEG_VDEC_CMD_SET_DISPLAY_OUTSIDE_MODE = 0x0000, 272 }MJPEG_VDEC_Cmd; 273 //------------------------------------------------------------------------------------------------- 274 // Function and Variable 275 //------------------------------------------------------------------------------------------------- 276 // Init 277 DLL_PUBLIC MJPEG_Result MApi_MJPEG_Init(MS_U32 u32Id, MJPEG_INIT_PARAM *pInitParam); 278 DLL_PUBLIC MJPEG_Result MApi_MJPEG_Rst(MS_U32 u32Id); 279 DLL_PUBLIC MJPEG_Result MApi_MJPEG_Stop(MS_U32 u32Id); 280 DLL_PUBLIC MJPEG_Result MApi_MJPEG_CheckDispInfoRdy(MS_U32 u32Id); 281 // Decode control 282 DLL_PUBLIC MJPEG_Result MApi_MJPEG_Play(MS_U32 u32Id); 283 DLL_PUBLIC MJPEG_Result MApi_MJPEG_Pause(MS_U32 u32Id); 284 DLL_PUBLIC MJPEG_Result MApi_MJPEG_Resume(MS_U32 u32Id); 285 DLL_PUBLIC MJPEG_Result MApi_MJPEG_StepPlay(MS_U32 u32Id); 286 DLL_PUBLIC MS_BOOL MApi_MJPEG_IsStepPlayDone(MS_U32 u32Id); 287 DLL_PUBLIC MJPEG_Result MApi_MJPEG_StepDecode(MS_U32 u32Id); 288 DLL_PUBLIC MS_BOOL MApi_MJPEG_IsStepDecodeDone(MS_U32 u32Id); 289 // Data control 290 //MJPEG_Result MApi_MJPEG_PushQueue(MS_PHY u32StAddr, MS_U32 u32Size, MS_U32 u32TimeStamp); 291 DLL_PUBLIC MJPEG_Result MApi_MJPEG_PushQueue(MS_U32 u32Id, MJPEG_Packet_Info *pInfo); 292 DLL_PUBLIC MS_U32 MApi_MJPEG_GetQueueVacancy(MS_U32 u32Id); 293 DLL_PUBLIC MJPEG_Result MApi_MJPEG_FlushQueue(MS_U32 u32Id); 294 DLL_PUBLIC MS_U32 MApi_MJPEG_GetESWritePtr(MS_U32 u32Id); 295 DLL_PUBLIC MS_U32 MApi_MJPEG_GetESReadPtr(MS_U32 u32Id); 296 // Display control 297 DLL_PUBLIC MJPEG_Result MApi_MJPEG_EnableLastFrameShow(MS_U32 u32Id, MS_BOOL bEnable); 298 DLL_PUBLIC MS_BOOL MApi_MJPEG_IsDispFinish(MS_U32 u32Id); 299 DLL_PUBLIC MJPEG_Result MApi_MJPEG_SetSpeed(MS_U32 u32Id, MJPEG_SpeedType eSpeedType, MJPEG_DispSpeed eDispSpeed); 300 DLL_PUBLIC MJPEG_Result MApi_MJPEG_SetFreezeDisp(MS_U32 u32Id, MS_BOOL bEnable); 301 DLL_PUBLIC MJPEG_Result MApi_MJPEG_SetBlueScreen(MS_U32 u32Id, MS_BOOL bOn); 302 // AV Sync 303 DLL_PUBLIC MJPEG_Result MApi_MJPEG_ResetPTS(MS_U32 u32Id, MS_U32 u32PtsBase); 304 DLL_PUBLIC MS_U32 MApi_MJPEG_GetPTS(MS_U32 u32Id); 305 DLL_PUBLIC MJPEG_Result MApi_MJPEG_AVSyncOn(MS_U32 u32Id, MS_BOOL bOn, MS_U32 u32SyncDelay, MS_U16 u16SyncTolerance); 306 DLL_PUBLIC MS_BOOL MApi_MJPEG_IsAVSyncOn(MS_U32 u32Id); 307 DLL_PUBLIC MS_BOOL MApi_MJPEG_IsReachSync(MS_U32 u32Id); 308 // Get Info 309 DLL_PUBLIC MS_BOOL MApi_MJPEG_GetStatus(MS_U32 u32Id, MJPEG_Status *pStatus); 310 DLL_PUBLIC MS_U32 MApi_MJPEG_GetErrCode(MS_U32 u32Id); 311 DLL_PUBLIC MS_U32 MApi_MJPEG_GetErrCnt(MS_U32 u32Id); 312 DLL_PUBLIC MS_U32 MApi_MJPEG_GetSkipCnt(MS_U32 u32Id); 313 DLL_PUBLIC MS_U32 MApi_MJPEG_GetFrameCnt(MS_U32 u32Id); 314 DLL_PUBLIC MJPEG_Result MApi_MJPEG_GetDispInfo(MS_U32 u32Id, MJPEG_DISP_INFO *pInfo); 315 DLL_PUBLIC MS_BOOL MApi_MJPEG_IsPlaying(MS_U32 u32Id); 316 DLL_PUBLIC MS_BOOL MApi_MJPEG_IsIdle(MS_U32 u32Id); 317 DLL_PUBLIC MS_BOOL MApi_MJPEG_IsIFrameFound(MS_U32 u32Id); 318 DLL_PUBLIC MS_BOOL MApi_MJPEG_IsWithLowDelay(MS_U32 u32Id); 319 DLL_PUBLIC MJPEG_Result MApi_MJPEG_GetDecFrameInfo(MS_U32 u32Id, MJPEG_FrameInfo *pFrmInfo); 320 DLL_PUBLIC MJPEG_Result MApi_MJPEG_GetDispFrameInfo(MS_U32 u32Id, MJPEG_FrameInfo *pFrmInfo); 321 // Debug 322 DLL_PUBLIC void MApi_MJPEG_DbgSetMsgLevel(MJPEG_DbgLevel eDbgLevel); 323 DLL_PUBLIC MJPEG_Result MApi_MJPEG_DbgSetData(MS_U32 u32Id, MS_PHY u32Addr, MS_U32 u32Data); 324 DLL_PUBLIC MJPEG_Result MApi_MJPEG_DbgGetData(MS_U32 u32Id, MS_PHY u32Addr, MS_U32* u32Data); 325 326 // Display Control 327 DLL_PUBLIC MJPEG_Result MApi_MJPEG_EnableDispCmdQ(MS_U32 u32Id, MS_BOOL bEnable); 328 DLL_PUBLIC MJPEG_Result MApi_MJPEG_PushDispCmdQ(MS_U32 u32Id); 329 DLL_PUBLIC MS_U32 MApi_MJPEG_GetDispCmdQVacancy(MS_U32 u32Id); 330 331 DLL_PUBLIC MJPEG_Result MApi_MJPEG_DispFrame(MS_U32 u32Id, MS_U32 u32DispIdx); 332 DLL_PUBLIC MJPEG_Result MApi_MJPEG_FreeFrame(MS_U32 u32Id, MS_U32 u32DispIdx); 333 DLL_PUBLIC MJPEG_Result MApi_MJPEG_GetNextDispFrame(MS_U32 u32Id, MJPEG_FrameInfo *pFrmInfo); 334 DLL_PUBLIC MS_U32 MApi_MJPEG_GetDispFrmNum(MS_U32 u32Id); 335 DLL_PUBLIC MS_U32 MApi_MJPEG_GetNextDispQPtr(MS_U32 u32Id); 336 337 // 338 DLL_PUBLIC MJPEG_Result MApi_MJPEG_SeekToPTS(MS_U32 u32Id, MS_U32 u32PTS); 339 DLL_PUBLIC MJPEG_Result MApi_MJPEG_SkipToPTS(MS_U32 u32Id, MS_U32 u32PTS); 340 DLL_PUBLIC MJPEG_Result MApi_MJPEG_SetControl(MS_U32 u32Id, MJPEG_VDEC_Cmd cmd_id, MS_U32 param); 341 342 DLL_PUBLIC void MApi_MJPEG_EnableTurboFWMode(MS_BOOL bEnable); 343 344 //for Dual Decode 345 DLL_PUBLIC MJPEG_Result MApi_MJPEG_GetFreeStream(MS_U32 *pu32Id, MJPEG_API_StreamType eStreamType); 346 347 348 #ifdef __cplusplus 349 } 350 #endif 351 352 #endif // _API_MJPEG_H_ 353 354