xref: /utopia/UTPA2-700.0.x/modules/vdec_v1/api/vdec/apiMJPEG.h (revision 53ee8cc121a030b8d368113ac3e966b4705770ef)
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 //-------------------------------------------------------------------------------------------------
180 //  Type and Structure
181 //-------------------------------------------------------------------------------------------------
182 typedef struct
183 {
184     MS_PHYADDR u32FwBinAddr;        // Address of firmware binary
185     MS_U32 u32FwBinSize;            // Size of firmware binary
186     MS_PHYADDR u32FwAddr;           // Address to load firmware
187     MS_U32 u32FwSize;               // Firmware size
188     MS_PHYADDR u32MRCBufAddr;       // MRC buffer address
189     MS_U32 u32MRCBufSize;           // MRC buffer size
190     MS_PHYADDR u32MWCBufAddr;       // MWC buffer address
191     MS_U32 u32MWCBufSize;           // MWC buffer size
192     MS_PHYADDR u32InternalBufAddr;  // internal buffer address
193     MS_U32 u32InternalBufSize;      // internal buffer size
194     //MS_U32 u32FrameTime;            // frame time
195     MS_U32 u32FrameRate;
196     MS_U32 u32FrameRateBase;
197     MJPEG_FWSourceType eFwSrcType;  // the input FW source type.
198     MS_U32 u32Width;
199     MS_U32 u32Height;
200 } MJPEG_INIT_PARAM;
201 
202 typedef struct
203 {
204     MS_U16 u16Width;
205     MS_U16 u16Height;
206     MS_U32 u32FrameRate;
207     MS_U16 u16CropRight;
208     MS_U16 u16CropLeft;
209     MS_U16 u16CropBottom;
210     MS_U16 u16CropTop;
211     MS_U16 u16Pitch;
212 } MJPEG_DISP_INFO;
213 
214 typedef enum
215 {
216     E_MJPEG_STAGE_STOP = 0,
217     E_MJPEG_STAGE_INIT,
218     E_MJPEG_STAGE_PLAY,
219     E_MJPEG_STAGE_PAUSE,
220 } MJPEG_Stage;
221 
222 typedef struct
223 {
224     MS_BOOL bInit;
225     MS_BOOL bIdle;
226     MJPEG_Stage  eStage;
227 } MJPEG_Status;
228 
229 typedef enum
230 {
231     E_MJPEG_FRM_TYPE_I      = 0,
232     //E_MJPEG_FRM_TYPE_P,
233     //E_MJPEG_FRM_TYPE_B,
234     E_MJPEG_FRM_TYPE_OTHER  = 3,
235 } MJPEG_FrameType;
236 
237 /// frame information
238 typedef struct
239 {
240     /// frame buffer base + the start offset of current displayed luma data. Unit: byte.
241     MS_PHYADDR u32LumaAddr;
242     /// frame buffer base + the start offset of current displayed chroma data. Unit: byte.
243     MS_PHYADDR u32ChromaAddr;
244     /// Time stamp(DTS, PTS) of current displayed frame. Unit: ms (todo: 90khz)
245     MS_U32 u32TimeStamp;
246     /// low part of ID number
247     MS_U32 u32ID_L;
248     /// high part of ID number
249     MS_U32 u32ID_H;
250     /// pitch
251     MS_U16 u16Pitch;
252     /// width
253     MS_U16 u16Width;
254     /// hight
255     MS_U16 u16Height;
256     ///< Frame type: I, P, B frame
257     MJPEG_FrameType eFrameType;
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 
270 //-------------------------------------------------------------------------------------------------
271 //  Function and Variable
272 //-------------------------------------------------------------------------------------------------
273 // Init
274 DLL_PUBLIC MJPEG_Result MApi_MJPEG_Init(MJPEG_INIT_PARAM *pInitParam);
275 DLL_PUBLIC MJPEG_Result MApi_MJPEG_Rst(void);
276 DLL_PUBLIC MJPEG_Result MApi_MJPEG_Stop(void);
277 DLL_PUBLIC MJPEG_Result MApi_MJPEG_CheckDispInfoRdy(void);
278 // Decode control
279 DLL_PUBLIC MJPEG_Result MApi_MJPEG_Play(void);
280 DLL_PUBLIC MJPEG_Result MApi_MJPEG_Pause(void);
281 DLL_PUBLIC MJPEG_Result MApi_MJPEG_Resume(void);
282 DLL_PUBLIC MJPEG_Result MApi_MJPEG_StepPlay(void);
283 DLL_PUBLIC MS_BOOL MApi_MJPEG_IsStepPlayDone(void);
284 DLL_PUBLIC MJPEG_Result MApi_MJPEG_StepDecode(void);
285 DLL_PUBLIC MS_BOOL MApi_MJPEG_IsStepDecodeDone(void);
286 // Data control
287 //MJPEG_Result MApi_MJPEG_PushQueue(MS_PHYADDR u32StAddr, MS_U32 u32Size, MS_U32 u32TimeStamp);
288 DLL_PUBLIC MJPEG_Result MApi_MJPEG_PushQueue(MJPEG_Packet_Info *pInfo);
289 DLL_PUBLIC MS_U32 MApi_MJPEG_GetQueueVacancy(void);
290 DLL_PUBLIC MJPEG_Result MApi_MJPEG_FlushQueue(void);
291 DLL_PUBLIC MS_U32 MApi_MJPEG_GetESWritePtr(void);
292 DLL_PUBLIC MS_U32 MApi_MJPEG_GetESReadPtr(void);
293 // Display control
294 DLL_PUBLIC MJPEG_Result MApi_MJPEG_EnableLastFrameShow(MS_BOOL bEnable);
295 DLL_PUBLIC MS_BOOL MApi_MJPEG_IsDispFinish(void);
296 DLL_PUBLIC MJPEG_Result MApi_MJPEG_SetSpeed(MJPEG_SpeedType eSpeedType, MJPEG_DispSpeed eDispSpeed);
297 DLL_PUBLIC MJPEG_Result MApi_MJPEG_SetFreezeDisp(MS_BOOL bEnable);
298 DLL_PUBLIC MJPEG_Result MApi_MJPEG_SetBlueScreen(MS_BOOL bOn);
299 // AV Sync
300 DLL_PUBLIC MJPEG_Result MApi_MJPEG_ResetPTS(MS_U32 u32PtsBase);
301 DLL_PUBLIC MS_U32 MApi_MJPEG_GetPTS(void);
302 DLL_PUBLIC MJPEG_Result MApi_MJPEG_AVSyncOn(MS_BOOL bOn, MS_U32 u32SyncDelay, MS_U16 u16SyncTolerance);
303 DLL_PUBLIC MS_BOOL MApi_MJPEG_IsAVSyncOn(void);
304 DLL_PUBLIC MS_BOOL MApi_MJPEG_IsReachSync(void);
305 // Get Info
306 DLL_PUBLIC MS_BOOL MApi_MJPEG_GetStatus(MJPEG_Status *pStatus);
307 DLL_PUBLIC MS_U32 MApi_MJPEG_GetErrCode(void);
308 DLL_PUBLIC MS_U32 MApi_MJPEG_GetErrCnt(void);
309 DLL_PUBLIC MS_U32 MApi_MJPEG_GetFrameCnt(void);
310 DLL_PUBLIC MJPEG_Result MApi_MJPEG_GetDispInfo(MJPEG_DISP_INFO *pInfo);
311 DLL_PUBLIC MS_BOOL MApi_MJPEG_IsPlaying(void);
312 DLL_PUBLIC MS_BOOL MApi_MJPEG_IsIdle(void);
313 DLL_PUBLIC MS_BOOL MApi_MJPEG_IsIFrameFound(void);
314 DLL_PUBLIC MS_BOOL MApi_MJPEG_IsWithLowDelay(void);
315 DLL_PUBLIC MJPEG_Result MApi_MJPEG_GetDecFrameInfo(MJPEG_FrameInfo *pFrmInfo);
316 DLL_PUBLIC MJPEG_Result MApi_MJPEG_GetDispFrameInfo(MJPEG_FrameInfo *pFrmInfo);
317 // Debug
318 DLL_PUBLIC void MApi_MJPEG_DbgSetMsgLevel(MJPEG_DbgLevel eDbgLevel);
319 DLL_PUBLIC MJPEG_Result MApi_MJPEG_DbgSetData(MS_PHYADDR u32Addr, MS_U32 u32Data);
320 DLL_PUBLIC MJPEG_Result MApi_MJPEG_DbgGetData(MS_PHYADDR u32Addr, MS_U32* u32Data);
321 
322 // Display Control
323 DLL_PUBLIC MJPEG_Result MApi_MJPEG_EnableDispCmdQ(MS_BOOL bEnable);
324 DLL_PUBLIC MJPEG_Result MApi_MJPEG_PushDispCmdQ(void);
325 DLL_PUBLIC MS_U32 MApi_MJPEG_GetDispCmdQVacancy(void);
326 
327 DLL_PUBLIC MJPEG_Result MApi_MJPEG_DispFrame(MS_U32 u32DispIdx);
328 DLL_PUBLIC MJPEG_Result MApi_MJPEG_FreeFrame(MS_U32 u32DispIdx);
329 DLL_PUBLIC MJPEG_Result MApi_MJPEG_GetNextDispFrame(MJPEG_FrameInfo *pFrmInfo);
330 DLL_PUBLIC MS_U32 MApi_MJPEG_GetNextDispQPtr(void);
331 
332 //
333 DLL_PUBLIC MJPEG_Result MApi_MJPEG_SeekToPTS(MS_U32 u32PTS);
334 DLL_PUBLIC MJPEG_Result MApi_MJPEG_SkipToPTS(MS_U32 u32PTS);
335 
336 DLL_PUBLIC void MApi_MJPEG_EnableTurboFWMode(MS_BOOL bEnable);
337 
338 #ifdef __cplusplus
339 }
340 #endif
341 
342 #endif // _API_MJPEG_H_
343 
344