xref: /utopia/UTPA2-700.0.x/mxlib/include/apiVDEC.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   apiVDEC.h
98 /// @brief  VDEC API
99 /// @author MStar Semiconductor Inc.
100 ///////////////////////////////////////////////////////////////////////////////////////////////////
101 
102 #ifndef _API_VDEC_H_
103 #define _API_VDEC_H_
104 
105 #include "MsDevice.h"
106 #include "MsTypes.h"
107 #ifdef __cplusplus
108 extern "C"
109 {
110 #endif
111 //-------------------------------------------------------------------------------------------------
112 //  Macro and Define
113 //-------------------------------------------------------------------------------------------------
114 #define MSIF_VDEC_LIB_CODE      {'V','D','E','C'}
115 #define MSIF_VDEC_LIBVER        {'0','E'}
116 #define MSIF_VDEC_BUILDNUM      {'0','2'}
117 #define MSIF_VDEC_CHANGELIST    {'0','0','6','8','9','1','8','8'}
118 
119 /// Version string.
120 #define VDEC_API_VERSION                /* Character String for DRV/API version             */  \
121     MSIF_TAG,                           /* 'MSIF'                                           */  \
122     MSIF_CLASS,                         /* '00'                                             */  \
123     MSIF_CUS,                           /* 0x0000                                           */  \
124     MSIF_MOD,                           /* 0x0000                                           */  \
125     MSIF_CHIP,                                                                                  \
126     MSIF_CPU,                                                                                   \
127     MSIF_VDEC_LIB_CODE,                 /* IP__                                             */  \
128     MSIF_VDEC_LIBVER,                   /* 0.0 ~ Z.Z                                        */  \
129     MSIF_VDEC_BUILDNUM,                 /* 00 ~ 99                                          */  \
130     MSIF_VDEC_CHANGELIST,               /* CL#                                              */  \
131     MSIF_OS
132 
133 #define VDEC_DEFAULT_DBG_MSG_LEVEL  E_VDEC_DBG_LEVEL_DBG
134 #define VDEC_RVD_BROKEN_BY_US   0x80000000
135 #define VDEC_MVD_PIC_START_FLAG 0x40000000
136 #define VDEC_BIT(_bit_)                  (1 << (_bit_))
137 #ifndef VDEC_CAP_SYSTEM_PREGET_FB_MEM_USAGE_SIZE
138 #define VDEC_CAP_SYSTEM_PREGET_FB_MEM_USAGE_SIZE
139 #endif
140 //-------------------------------------------------------------------------------------------------
141 //  Type and Structure
142 //-------------------------------------------------------------------------------------------------
143 
144 #define VDEC_FPA_TYPE_CHECKERBOARD_INTERLEAVING  0
145 #define VDEC_FPA_TYPE_COLUMN_INTERLEAVEING       1
146 #define VDEC_FPA_TYPE_ROW_INTERLEAVEING          2
147 #define VDEC_FPA_TYPE_SIDE_BY_SIDE_PACKING       3
148 #define VDEC_FPA_TYPE_TOP_BOTTOM_PACKING         4
149 #define VDEC_FPA_TYPE_TEMPORAL_INTERLEAVING_FRM  5
150 
151 /// Decoder event enumerator.
152 typedef enum
153 {
154     /// turn off all event
155     E_VDEC_EVENT_OFF                = 0x00,
156     /// display one frame/field
157     E_VDEC_EVENT_DISP_ONE           = VDEC_BIT(0),
158     /// repeat one frame/field
159     E_VDEC_EVENT_DISP_REPEAT        = VDEC_BIT(1),
160     /// one CC data should be displayed
161     E_VDEC_EVENT_DISP_WITH_CC       = VDEC_BIT(2),
162     /// decode one frame
163     E_VDEC_EVENT_DEC_ONE            = VDEC_BIT(3),
164     /// decode one I frame
165     E_VDEC_EVENT_DEC_I              = VDEC_BIT(4),
166     /// decode error
167     E_VDEC_EVENT_DEC_ERR            = VDEC_BIT(5),
168     /// display information is changed
169     E_VDEC_EVENT_DISP_INFO_CHG      = VDEC_BIT(6),
170     /// find user data
171     E_VDEC_EVENT_USER_DATA_FOUND    = VDEC_BIT(7),
172     /// display information ready after be changed
173     E_VDEC_EVENT_DISP_INFO_RDY      = VDEC_BIT(8),
174     /// first frame decoded
175     E_VDEC_EVENT_FIRST_FRAME        = VDEC_BIT(9),
176     /// first picture found
177     E_VDEC_EVENT_PIC_FOUND          = VDEC_BIT(10),
178     /// video is ready to display (no garbage and avsync done)
179     E_VDEC_EVENT_VIDEO_UNMUTE       = VDEC_BIT(11),
180     /// new sequence header found
181     E_VDEC_EVENT_SEQ_HDR_FOUND      = VDEC_BIT(12),
182     /// active format description found
183     E_VDEC_EVENT_AFD_FOUND          = VDEC_BIT(13),
184     // ES data invalid
185     E_VDEC_EVENT_ES_DATA_ERR        = VDEC_BIT(14),
186     /// speed up the un-mute screen on XC.
187     E_VDEC_EVENT_XC_LOW_DEALY       = VDEC_BIT(16)
188 } VDEC_EventFlag;
189 
190 //define VDEC CB type
191 typedef enum
192 {
193     E_VDEC_CB_MAIN  = 0,
194     E_VDEC_CB_SUB,
195 } VDEC_CB_TYPE;
196 
197 /// Codec type enumerator
198 typedef enum
199 {
200     ///Unsupported codec type
201     E_VDEC_CODEC_TYPE_NONE = 0,
202     ///MPEG-1 / MPEG-2
203     E_VDEC_CODEC_TYPE_MPEG2,
204     ///H263 (short video header)
205     E_VDEC_CODEC_TYPE_H263,
206     ///MPEG4 (default)
207     E_VDEC_CODEC_TYPE_MPEG4,
208     ///MPEG4 (Divx311)
209     E_VDEC_CODEC_TYPE_DIVX311,
210     ///MPEG4 (Divx412)
211     E_VDEC_CODEC_TYPE_DIVX412,
212     ///FLV
213     E_VDEC_CODEC_TYPE_FLV,
214     ///VC1 advanced profile (VC1)
215     E_VDEC_CODEC_TYPE_VC1_ADV,
216     ///VC1 main profile (RCV)
217     E_VDEC_CODEC_TYPE_VC1_MAIN,
218     ///Real Video version 8
219     E_VDEC_CODEC_TYPE_RV8,
220     ///Real Video version 9 and 10
221     E_VDEC_CODEC_TYPE_RV9,
222     ///H264
223     E_VDEC_CODEC_TYPE_H264,
224     ///AVS
225     E_VDEC_CODEC_TYPE_AVS,
226     ///MJPEG
227     E_VDEC_CODEC_TYPE_MJPEG,
228     ///MVC
229     E_VDEC_CODEC_TYPE_MVC,
230     ///VP8
231     E_VDEC_CODEC_TYPE_VP8,
232     ///HEVC
233     E_VDEC_CODEC_TYPE_HEVC,
234     ///VP9
235     E_VDEC_CODEC_TYPE_VP9,
236     ///HEVC_DV
237     E_VDEC_CODEC_TYPE_HEVC_DV
238 } VDEC_CodecType;
239 
240 /// Input source select enumerator
241 typedef enum
242 {
243     ///DTV mode
244     E_VDEC_SRC_MODE_DTV = 0,
245     ///TS file mode
246     E_VDEC_SRC_MODE_TS_FILE,
247     ///generic file mode
248     E_VDEC_SRC_MODE_FILE,
249     /// TS file and dual ES buffer mode
250     E_VDEC_SRC_MODE_TS_FILE_DUAL_ES,
251     ///generic file and dual ES buffer mode
252     E_VDEC_SRC_MODE_FILE_DUAL_ES,
253 } VDEC_SrcMode;
254 
255 /// Function return enumerator
256 typedef enum
257 {
258     ///failed
259     E_VDEC_FAIL = 0,
260     ///success
261     E_VDEC_OK,
262     ///invalid parameter
263     E_VDEC_RET_INVALID_PARAM,
264     ///access not allow
265     E_VDEC_RET_ILLEGAL_ACCESS,
266     ///hardware abnormal
267     E_VDEC_RET_HARDWARE_BREAKDOWN,
268      ///unsupported
269     E_VDEC_RET_UNSUPPORTED,
270      ///timeout
271     E_VDEC_RET_TIMEOUT,
272     ///not ready
273     E_VDEC_RET_NOT_READY,
274     ///not initial
275     E_VDEC_RET_NOT_INIT,
276     ///not exit after last initialization
277     E_VDEC_RET_NOT_EXIT,
278     ///not running, counter does not change
279     E_VDEC_RET_NOT_RUNNING,
280 } VDEC_Result;
281 
282 /// Action enumerator of display commands
283 typedef enum
284 {
285     /// Action- display frame
286     E_VDEC_DISP_ACTION_DISPLAY   = 1,
287     /// Action - release frame
288     E_VDEC_DISP_ACTION_RELEASE,
289 } VDEC_DispCmdAction;
290 
291 /// Freeze picture select after flush decoder
292 typedef enum
293 {
294     /// Freeze at current display picture
295     E_VDEC_FREEZE_AT_CUR_PIC = 1,
296     /// Freeze at the latest decode picture
297     E_VDEC_FREEZE_AT_LAST_PIC,
298 } VDEC_FreezePicSelect;
299 
300 /// Error code enumerator
301 typedef enum
302 {
303     E_VDEC_ERR_CODE_BASE = 0x01000000,
304     E_VDEC_ERR_CODE_NOT_SUPPORT,
305     E_VDEC_ERR_CODE_ILLEGAL_ACCESS,
306     E_VDEC_ERR_CODE_FRMRATE_NOT_SUPPORT,
307     E_VDEC_ERR_CODE_DIVX_PLUS_UNSUPPORTED,
308     E_VDEC_ERR_CODE_EXCEED_HW_CAP, ///over hw capability ex : avc 4k + avc 4k
309     E_VDEC_ERR_CODE_CODEC_COMPARE_CASE1, ///Hash key error
310     E_VDEC_ERR_CODE_CODEC_COMPARE_CASE2, ///Hash key error
311 
312     E_VDEC_MVD_ERR_CODE_BASE = 0x02000000,
313         E_VDEC_MVD_ERR_CODE_SHAPE              ,
314         E_VDEC_MVD_ERR_CODE_USED_SPRITE        ,
315         E_VDEC_MVD_ERR_CODE_NOT_8_BIT          ,   ///< error_status : bits per pixel
316         E_VDEC_MVD_ERR_CODE_NERPRED_ENABLE     ,
317         E_VDEC_MVD_ERR_CODE_REDUCED_RES_ENABLE ,
318         E_VDEC_MVD_ERR_CODE_SCALABILITY        ,
319         E_VDEC_MVD_ERR_CODE_OTHER              ,
320         E_VDEC_MVD_ERR_CODE_H263_ERROR         ,
321         E_VDEC_MVD_ERR_CODE_RES_NOT_SUPPORT    ,   ///< error_status : none
322         E_VDEC_MVD_ERR_CODE_MPEG4_NOT_SUPPORT  ,   ///< error_status : none
323         E_VDEC_MVD_ERR_CODE_PROFILE_NOT_SUPPORT  , ///< error_status : none
324         E_VDEC_MVD_ERR_CODE_RCV_ERROR_OCCUR    ,   ///< error_status : none
325         E_VDEC_MVD_ERR_CODE_VC1_NOT_SUPPORT    ,   ///< error_status : none
326         E_VDEC_MVD_ERR_CODE_UNKNOW_CODEC_NOT_SUPPORT  ,   ///< error_status : none
327         E_VDEC_MVD_ERR_CODE_SLQ_TBL_NOT_SUPPORT  , ///< error_status : none
328         E_VDEC_MVD_ERR_CODE_FRAME_BUF_NOT_ENOUGH , ///< error_status : none
329 
330     E_VDEC_HVD_ERR_CODE_BASE = 0x03000000,
331         E_VDEC_HVD_ERR_CODE_GENERAL_BASE = (0x0000|E_VDEC_HVD_ERR_CODE_BASE),
332         E_VDEC_HVD_ERR_CODE_OUT_OF_SPEC ,
333         E_VDEC_HVD_ERR_CODE_UNKNOW_ERR,
334         E_VDEC_HVD_ERR_CODE_HW_BREAK_DOWN,
335         E_VDEC_HVD_ERR_CODE_HW_DEC_TIMEOUT,
336         E_VDEC_HVD_ERR_CODE_OUT_OF_MEMORY,
337         E_VDEC_HVD_ERR_CODE_UNKNOWN_CODEC,
338         // AVC
339         E_VDEC_HVD_ERR_CODE_AVC_BASE = (0x1000|E_VDEC_HVD_ERR_CODE_BASE),
340         E_VDEC_HVD_ERR_CODE_AVC_SPS_BROKEN,
341         E_VDEC_HVD_ERR_CODE_AVC_SPS_NOT_IN_SPEC,
342         E_VDEC_HVD_ERR_CODE_AVC_SPS_NOT_ENOUGH_FRM,   ///< DPB size at specified level is smaller than the specified number of reference frames. This is not allowed
343         E_VDEC_HVD_ERR_CODE_AVC_PPS_BROKEN,           ///< PPS is not valid
344         E_VDEC_HVD_ERR_CODE_AVC_REF_LIST,
345         E_VDEC_HVD_ERR_CODE_AVC_NO_REF,
346         E_VDEC_HVD_ERR_CODE_AVC_RES,
347         // AVS
348         E_VDEC_HVD_ERR_CODE_AVS_BASE = (0x2000|E_VDEC_HVD_ERR_CODE_BASE),
349         E_VDEC_HVD_ERR_CODE_AVS_RES,
350         // RM
351         E_VDEC_HVD_ERR_CODE_RM_BASE = (0x3000|E_VDEC_HVD_ERR_CODE_BASE),
352         E_VDEC_HVD_ERR_CODE_RM_PACKET_HEADER,
353         E_VDEC_HVD_ERR_CODE_RM_FRAME_HEADER,
354         E_VDEC_HVD_ERR_CODE_RM_SLICE_HEADER,
355         E_VDEC_HVD_ERR_CODE_RM_BYTE_CNT,
356         E_VDEC_HVD_ERR_CODE_RM_DISP_TIMEOUT,
357         E_VDEC_HVD_ERR_CODE_RM_NO_REF,
358         E_VDEC_HVD_ERR_CODE_RM_VLC,
359         E_VDEC_HVD_ERR_CODE_RM_SIZE,
360         E_VDEC_HVD_ERR_CODE_RM_RES,
361 
362     E_VDEC_RVD_ERR_CODE_BASE = 0x04000000,
363         E_VDEC_RVD_ERR_CODE_PACKET_HEADER,  ///< packet header version error
364         E_VDEC_RVD_ERR_CODE_FRAME_HEADER,   ///< frame type error
365         E_VDEC_RVD_ERR_CODE_SLICE_HEADER,   ///< slice header error
366         E_VDEC_RVD_ERR_CODE_DECODE_TIMEOUT, ///< decode MB timeout
367         E_VDEC_RVD_ERR_CODE_OUT_OF_MEMORY,  ///< frame buffer is out of memory
368         E_VDEC_RVD_ERR_CODE_BYTE_POS,       ///< can not find in ID table
369         E_VDEC_RVD_ERR_CODE_DISPLAY_TIMEOUT,///
370 
371     E_VDEC_MJPEG_ERR_CODE_BASE = 0x05000000,
372         E_VDEC_HVD_ERR_CODE_MJPEG_RES,
373 } VDEC_ErrCode;
374 
375 /// Frame rate conversion mode enumerator
376 typedef enum
377 {
378     /// Disable FRC mode.
379     E_VDEC_FRC_NORMAL = 0,
380     /// Output rate is twice of input rate (ex. 30p to 60p)
381     E_VDEC_FRC_DISP_TWICE,
382     /// 3:2 pulldown mode (ex. 24p to 60i or 60p)
383     E_VDEC_FRC_3_2_PULLDOWN,
384     /// PAL to NTSC conversion (50i to 60i)
385     E_VDEC_FRC_PAL_TO_NTSC,
386     /// NTSC to PAL conversion (60i to 50i)
387     E_VDEC_FRC_NTSC_TO_PAL,
388     /// Output rate 50P ->60P
389     E_VDEC_FRC_MODE_50P_60P,
390     /// Output rate 60P ->50P
391     E_VDEC_FRC_MODE_60P_50P,
392 } VDEC_FrcMode;
393 
394 /// Trick decode mode enumerator
395 typedef enum
396 {
397     /// decode all frame
398     E_VDEC_TRICK_DEC_ALL = 0,
399     /// decode all except of non-reference frame
400     E_VDEC_TRICK_DEC_IP,
401     /// only decode I frame
402     E_VDEC_TRICK_DEC_I,
403 } VDEC_TrickDec;
404 
405 /// Display speed setting enumerator
406 typedef enum
407 {
408     /// default speed type
409     E_VDEC_SPEED_DEFAULT = 0,
410     /// fast display
411     E_VDEC_SPEED_FAST,
412     /// slow display
413     E_VDEC_SPEED_SLOW,
414 } VDEC_SpeedType;
415 
416 /// The display speed enumerator
417 typedef enum
418 {
419     /// Normal display speed.
420     E_VDEC_DISP_SPEED_1X = 1,
421     /// 2X
422     E_VDEC_DISP_SPEED_2X = 2,
423     /// 4X
424     E_VDEC_DISP_SPEED_4X = 4,
425     /// 8X
426     E_VDEC_DISP_SPEED_8X = 8,
427     /// 16X
428     E_VDEC_DISP_SPEED_16X = 16,
429     /// 32X
430     E_VDEC_DISP_SPEED_32X = 32,
431 } VDEC_DispSpeed;
432 
433 /// Motion JPEG down scale factor enumerator
434 typedef enum
435 {
436     ///Original size
437     E_VDEC_MJPEG_SCALE_1to1 = 0,
438     ///Down scale to 1/2
439     E_VDEC_MJPEG_SCALE_2to1,
440     ///Down scale to 1/4
441     E_VDEC_MJPEG_SCALE_4to1,
442     ///Down scale to 1/8
443     E_VDEC_MJPEG_SCALE_8to1,
444 } VDEC_MJpegScaleFactor;
445 
446 /// Timestamp type of command queue
447 typedef enum
448 {
449     ///without timestamp information
450     E_VDEC_TIME_STAMP_NONE = 0,
451     ///PTS (Presentation Time Stamp)
452     E_VDEC_TIME_STAMP_PTS,
453     ///DTS (Decode Time Stamp)
454     E_VDEC_TIME_STAMP_DTS,
455     ///STS (Sorted Time Stamp)
456     E_VDEC_TIME_STAMP_STS,
457     ///PTS_RVU (Presentation Time Stamp)
458     E_VDEC_TIME_STAMP_PTS_MPEG_DIRECTV_SD,
459     ///DTS_RVU (Decode Time Stamp)
460     E_VDEC_TIME_STAMP_DTS_MPEG_DIRECTV_SD,
461 
462 } VDEC_TimeStampType;
463 
464 /// Debug level of VDEC
465 typedef enum
466 {
467     /// Disable all uart messages.
468     E_VDEC_DBG_LEVEL_NONE = 0,
469     /// Only output error messages
470     E_VDEC_DBG_LEVEL_ERR,
471     /// Output general messages, and above.
472     E_VDEC_DBG_LEVEL_INFO,
473     /// Output debug messages, and above.
474     E_VDEC_DBG_LEVEL_DBG,
475     /// Output function tracing messages, and above.
476     E_VDEC_DBG_LEVEL_TRACE,
477     /// Output FW messages.
478     E_VDEC_DBG_LEVEL_FW,
479 } VDEC_DbgLevel;
480 
481 /// Type of FW source
482 typedef enum
483 {
484     E_VDEC_FW_SOURCE_NONE,
485     E_VDEC_FW_SOURCE_DRAM,
486     E_VDEC_FW_SOURCE_FLASH,
487 }VDEC_FWSourceType;
488 
489 /// Format of CC (Closed Caption)
490 typedef enum
491 {
492     E_VDEC_CC_NONE       = 0x00,
493     E_VDEC_CC_608        = 0x01, //For CC608 or 157
494     E_VDEC_CC_708        = 0x02, //For CC708
495     E_VDEC_CC_UNPACKED   = 0x03,
496 } VDEC_CCFormat;
497 
498 /// Type of CC
499 typedef enum
500 {
501     E_VDEC_CC_TYPE_NONE = 0,
502     E_VDEC_CC_TYPE_NTSC_FIELD1 = 1,
503     E_VDEC_CC_TYPE_NTSC_FIELD2 = 2,
504     E_VDEC_CC_TYPE_DTVCC = 3,
505     E_VDEC_CC_TYPE_NTSC_TWOFIELD = 4,
506 } VDEC_CCType;
507 
508 typedef enum
509 {
510     E_VDEC_CC_GET_BUFF_START = 0x1,
511     E_VDEC_CC_GET_BUFF_SIZE,
512     E_VDEC_CC_GET_708_ENABLE
513 } VDEC_CCInfoCmd;
514 
515 typedef enum
516 {
517     E_VDEC_STAGE_STOP = 0,
518     E_VDEC_STAGE_INIT,
519     E_VDEC_STAGE_PLAY,
520     E_VDEC_STAGE_PAUSE,
521 } VDEC_Stage;
522 
523 
524 typedef enum
525 {
526     /// Used before MApi_VDEC_Flush().
527     E_VDEC_PATTERN_FLUSH = 0,
528     /// Used after MApi_VDEC_EnableLastFrameShow().
529     E_VDEC_PATTERN_FILEEND,
530 }VDEC_PatternType;
531 
532 typedef enum
533 {
534     E_VDEC_FW_STATUS_FLAG_NONE       = 0,
535     E_VDEC_FW_STATUS_FLAG_SEEK_TO_I  = VDEC_BIT(0),
536 }VDEC_FW_STATUS_FLAG;
537 
538 typedef struct
539 {
540     MS_BOOL bInit;
541     MS_BOOL bIdle;
542     VDEC_Stage  eStage;
543 } VDEC_Status;
544 
545 typedef struct
546 {
547     MS_U32 u32Tmp;
548 } VDEC_Info;
549 
550 typedef enum
551 {
552     E_VDEC_FRM_TYPE_I = 0,
553     E_VDEC_FRM_TYPE_P,
554     E_VDEC_FRM_TYPE_B,
555     E_VDEC_FRM_TYPE_OTHER,
556 } VDEC_FrameType;
557 
558 typedef enum
559 {
560     E_VDEC_FIELDTYPE_NONE,  ///< No field.
561     E_VDEC_FIELDTYPE_TOP,   ///< Top field only.
562     E_VDEC_FIELDTYPE_BOTTOM,///< Bottom field only.
563     E_VDEC_FIELDTYPE_BOTH,  ///< Both fields.
564 } VDEC_FieldType;
565 
566 typedef enum
567 {
568     E_VDEC_PATTERN_BEFORE_FRM = 0,
569     E_VDEC_PATTERN_AFTER_FRM,
570     E_VDEC_PATTERN_SKIP_DATA,
571 } VDEC_PatchPattern;
572 
573 typedef enum
574 {
575     E_VDEC_PIC_STRUCTURE_RSV = 0, //reserved
576     E_VDEC_PIC_STRUCTURE_TOP,
577     E_VDEC_PIC_STRUCTURE_BOT,
578     E_VDEC_PIC_STRCUTURE_FRM,
579 } VDEC_PicStructure;
580 
581 //VDEC set clock speed
582 typedef enum
583 {
584     E_VDEC_CLOCK_SPEED_NONE = 0,
585     E_VDEC_CLOCK_SPEED_HIGHEST,
586     E_VDEC_CLOCK_SPEED_HIGH,
587     E_VDEC_CLOCK_SPEED_MEDIUM,
588     E_VDEC_CLOCK_SPEED_LOW,
589     E_VDEC_CLOCK_SPEED_LOWEST,
590     E_VDEC_CLOCK_SPEED_DEFAULT,
591 } VDEC_ClockSpeed;
592 
593 //VDEC user command id
594 typedef enum
595 {
596     //Group1:Set Control command
597     VDEC_USER_CMD_SET_CONTROL_BASE = 0x0000,
598     VDEC_USER_CMD_REPEAT_LAST_FIELD,                // Param: 1(ON), 0(OFF)
599     VDEC_USER_CMD_AVSYNC_REPEAT_TH,                 // Param:0x01 ~ 0xFF(repeat times), 0xFF:always repeat when av is not sync
600     VDEC_USER_CMD_DISP_ONE_FIELD,                   // Param: 1(ON), 0(OFF)
601     VDEC_USER_CMD_FD_MASK_DELAY_COUNT,              // Param: unit is in vsync base for mute the fd_mask
602     VDEC_USER_CMD_FRC_OUTPUT,                       // Param: the address of VDEC_FRC_OutputParam
603     VDEC_USER_CMD_FRC_DROP_TYPE,                    // Param: 1(FRC_DROP_FIELD), 0(FRC_DROP_FRAME), default:0
604     VDEC_USER_CMD_FAST_DISPLAY,                     // Param: TRUE(Fast display), FALSE(Display until synced)
605     VDEC_USER_CMD_IGNORE_ERR_REF,                   // Param: TRUE(Ignore error reference), FALSE(Enable error reference handle)
606     VDEC_USER_CMD_FORCE_FOLLOW_DTV_SPEC,            // Param: 1(ON), 0(OFF)
607     VDEC_USER_CMD_AVC_MIN_FRM_GAP,                  // Param: Set the theshold of H264 frame gap, 0xFFFFFFFF don't care frame gap
608     VDEC_USER_CMD_DISABLE_SEQ_CHG,                  // Param: 1(Disable), 0(Enable)
609     VDEC_USER_CMD_AVC_DISABLE_ANTI_VDEAD,           // Param: 1(Disable), 0(Enable)
610     VDEC_USER_CMD_DTV_RESET_MVD_PARSER,             //
611     VDEC_USER_CMD_PVR_FLUSH_FRAME_BUFFER,           //
612     VDEC_USER_CMD_SET_DTV_USER_DATA_MODE,           // Param: 0(Support normal DVB CC, default case), 1(Support ATSC DirectTV CC), 2,3,4(Reserved)
613     VDEC_USER_CMD_SET_SINGLE_TASK_MODE,             // Param: 0(default case), 1(single task mode) for dual decoder
614     VDEC_USER_CMD_FORCE_INTERLACE_MODE,             // Param: 0(Disable), 1(Enable) DTV, TS-File mode force into interlace mode when framerate is 25 or 30
615     VDEC_USER_CMD_RELEASE_FD_MASK,
616     VDEC_USER_CMD_SET_DECODE_MODE,
617     VDEC_USER_CMD_SHOW_DECODE_ORDER,                // Param: 1(Disable), 0(Enable)
618     VDEC_USER_CMD_SUPPORT_AVC_TO_MVC,               // Param: 0(Do not support), 1(Support AVC to MVC)
619     VDEC_USER_CMD_3DLR_VIEW_EXCHANGE,               // Param: 0(Disable), 1(View L/R exhange)
620     VDEC_USER_CMD_FORCE_AUTO_MUTE,                  // param: 0(default case), 1(Enable)
621     VDEC_USER_CMD_SET_VSIZE_ALIGN,                  // Param: 0(Disable), 1(Enable)
622     VDEC_USER_CMD_AVC_DISP_IGNORE_CROP,             // Param: 0(Disable), 1(Enable)
623     VDEC_USER_CMD_SET_DISP_FINISH_MODE,             // Param: 0(Original), 1(Strict)
624     VDEC_USER_CMD_SET_AVSYNC_MODE,                  // Param: 0(Original), 1(Strict)
625     VDEC_USER_CMD_SET_CC608_INFO_ENHANCE_MODE,      // Param: 0(Disable), 1(Enable)
626     VDEC_USER_CMD_PUSH_DISPQ_WITH_REF_NUM,          // Param: 0(Disable), 1(Enable)
627     VDEC_USER_CMD_SET_IDCT_MODE,                    //Param: 0(Original), 1(new IDCT)
628     VDEC_USER_CMD_DROP_ERR_FRAME,                   // Param: 0(Disable), 1(Enable)
629     VDEC_USER_CMD_SHOW_FIRST_FRAME_DIRECT,          // Param: 0(Disable), 1(Enable), Push first frame to display queue directly..
630     VDEC_USER_CMD_SET_XC_LOW_DELAY_PARA,            // Param: arg0 for diff_field_number...
631     VDEC_USER_CMD_AUTO_EXHAUST_ES_MODE,             // Param: set the upper bound (arg[31:16]), and lower bound (arg[15:0])of ES level, Unit = 1KBytes, Auto drop display to consume ES data as soon as possible when ES level is higher than upper bound
632     VDEC_USER_CMD_SET_MIN_TSP_DATA_SIZE,            // Param: Resize HVD_FW_AVC_ES_MIN_TSP_DATA_SIZE
633     VDEC_USER_CMD_AVC_SUPPORT_REF_NUM_OVER_MAX_DPB_SIZE, // Param: 0(Disable), 1(Enable)
634     VDEC_USER_CMD_FRAMEBUFFER_AUTO_MODE,            // Param: 0(Disable), 1(Enable)
635 #if defined(UFO_PUBLIC_HEADER_700)||defined(UFO_PUBLIC_HEADER_500_3)||defined(UFO_PUBLIC_HEADER_500)||defined(UFO_PUBLIC_HEADER_300)
636     VDEC_USER_CMD_AUTO_DROP_DISPLAY_QUEUE,          // Param: 0(Disable), N = 1~16: Drop display queue when display queue above than N frames.
637     VDEC_USER_CMD_SET_PTS_US_MODE,                   //Param: 1(enable), 0(disable ) PTS output by micro second level,
638     VDEC_USER_CMD_FORCE_PROGRESSIVE_MODE,            // Param: 0(Disable), 1(Enable)
639     VDEC_USER_CMD_AVC_NEW_SLOW_MOTION,                 // Param: 0(Disable), 1(Enable)
640     VDEC_USER_CMD_USE_CPB_REMOVAL_DEALY,			// Param: 0(Disable), 1(Enable)
641     VDEC_USER_CMD_RETURN_INVALID_AFD,               // Param: 0(Disable), 1(Enable)
642     VDEC_USER_CMD_SET_DV_XC_SHM_ADDR,              // Param: PHY Addr for communicating with XC Dolby Vision DM/Comp
643     VDEC_USER_CMD_SET_ENABLE_HDR,                  // Param: 0(Disable), 1(Enable)
644     VDEC_USER_CMD_DISABLE_PBFRAME_MODE,            // Param: 1(Disable), 0(Enable)
645     VDEC_USER_CMD_SET_SLOW_SYNC,                    //Param: VDEC_EX_Slow_Sync, u8RepeatPeriod: 0(disable), 1~0xFF(Repeat Period, repeat one every u8RepeatPeriod display),  u8DropPeriod: 0(disable), 1~0xFF(Drop Period, Drop one every u8DropPeriod display)
646     VDEC_USER_CMD_SET_FRAMEBUFF2,                   // Param[0]=Addr and Param[1]=size for the second frame buffer
647     VDEC_USER_CMD_SET_TRICKPLAY_2X_MODE,           //Param:0(vsync),1(avsync)
648     VDEC_USER_CMD_FRC_ONLY_SHOW_TOP_FIELD,         // Param: 0(Disable), 1(Enable) only show top filed for FRC mode
649     VDEC_USER_CMD_DISABLE_ES_FULL_STOP,             // Param: 0(Enable), 1(Disable) ES FULL STOP mode
650     VDEC_USER_CMD_DIRECT_STC_MODE,                  // Param: stc in ms; 0x0~0x1FFFFFFFF/90, vdec fw use this value as stc; 0xFFFFFFFF, disable ths feature
651 #endif
652 #if defined(UFO_PUBLIC_HEADER_212)
653     VDEC_USER_CMD_AUTO_DROP_DISPLAY_QUEUE,          // Param: 0(Disable), N = 1~16: Drop display queue when display queue above than N frames.
654     VDEC_USER_CMD_USE_CPB_REMOVAL_DEALY,           // Param: 0(Disable), 1(Enable)
655     VDEC_USER_CMD_SET_PTS_US_MODE,                   //Param: 1(enable), 0(disable ) PTS output by micro second level,
656     VDEC_USER_CMD_FORCE_PROGRESSIVE_MODE,            // Param: 0(Disable), 1(Enable)
657     VDEC_USER_CMD_SET_TRICKPLAY_2X_MODE,           //Param:0(vsync),1(avsync)
658     VDEC_USER_CMD_FRC_ONLY_SHOW_TOP_FIELD,         // Param: 0(Disable), 1(Enable) only show top filed for FRC mode
659     VDEC_USER_CMD_DISABLE_ES_FULL_STOP,             // Param: 0(Enable), 1(Disable) ES FULL STOP mode
660     VDEC_USER_CMD_DIRECT_STC_MODE,                  // Param: stc in ms; 0x0~0x1FFFFFFFF/90, vdec fw use this value as stc; 0xFFFFFFFF, disable ths feature
661     VDEC_USER_CMD_AVC_NEW_SLOW_MOTION,                 // Param: 0(Disable), 1(Enable)
662     VDEC_USER_CMD_RETURN_INVALID_AFD,               // Param: 0(Disable), 1(Enable)
663     VDEC_USER_CMD_SET_SLOW_SYNC,                    //Param: VDEC_EX_Slow_Sync, u8RepeatPeriod: 0(disable), 1~0xFF(Repeat Period, repeat one every u8RepeatPeriod display),  u8DropPeriod: 0(disable), 1~0xFF(Drop Period, Drop one every u8DropPeriod display)
664     VDEC_USER_CMD_SET_FRAMEBUFF2,                   // Param[0]=Addr and Param[1]=size for the second frame buffer
665     VDEC_USER_CMD_DISABLE_PBFRAME_MODE,            // Param: 1(Disable), 0(Enable)
666     VDEC_USER_CMD_SET_DV_XC_SHM_ADDR,              // Param: PHY Addr for communicating with XC Dolby Vision DM/Comp
667     VDEC_USER_CMD_SET_ENABLE_HDR,                  // Param: 0(Disable), 1(Enable)
668 #endif
669     VDEC_USER_CMD_SET_BUFFER_INFO,                 //Param: VDEC_EX_BufferInfo
670     VDEC_USER_CMD_HDR10_UPDATE_PERFRAME,
671     VDEC_USER_CMD_SET_CODEC_CONFIG,
672     VDEC_USER_CMD_SET_VP94K2KCHECK,
673     VDEC_USER_CMD_PUSI_CONTROL,
674 
675 
676     VDEC_USER_CMD_MVC_SET_CMD_BASE = 0x0800,
677     VDEC_USER_CMD_MVC_BBU2_PUSH_PACKET,             // Param: Packet Info.
678     VDEC_USER_CMD_MVC_BBU2_FIRE_DECCMD,             // Param: Non
679 
680     //Group2:Get Control command
681     VDEC_USER_CMD_GET_CONTROL_BASE = 0x1000,
682     VDEC_USER_CMD_GET_CHROMA_TYPE,
683     VDEC_USER_CMD_GET_REAL_FRAMERATE,               // Get Real FrameRate reported by decoder
684     VDEC_USER_CMD_GET_COLOR_MATRIX,                 // Get color matrix coefficients reported by decoder
685     VDEC_USER_CMD_GET_DYNSCALE_ENABLED,             // Get if DynamicScaling is enabled by firmware
686     VDEC_USER_CMD_GET_ORI_INTERLACE_MODE,
687     VDEC_USER_CMD_GET_FPA_SEI,                      // Get Frame Packing Arrangment information
688     VDEC_USER_CMD_GET_U64PTS,
689     VDEC_USER_CMD_GET_FB_USAGE_MEM,                 // Get FrameBuufer Size needed by decoder
690     VDEC_USER_CMD_GET_XC_LOW_DELAY_INT_STATE,       // Get xc_low_delay int state...
691     VDEC_USER_CMD_GET_FLUSH_PATTEN_ENTRY_NUM,		// Get Flush patten push based (unit : times)
692     VDEC_USER_CMD_GET_FW_STATUS_FLAG,
693     VDEC_USER_CMD_GET_DS_BUF_MIU_SEL,
694 #if defined(UFO_PUBLIC_HEADER_700)||defined(UFO_PUBLIC_HEADER_300)
695     VDEC_USER_CMD_GET_PVRSEAMLESS_INFO,
696     VDEC_USER_CMD_GET_PRE_PAS_U64PTS,               // Get Pre-parsing PTS
697     VDEC_USER_CMD_GET_SEQ_CHANGE_INFO,              // Get the reason why seq changes, parameter is MS_U32, definition is VDEC_SeqChangeInfo
698     VDEC_USER_CMD_GET_MIN_TSP_DATA_SIZE,
699     VDEC_USER_CMD_GET_CLLI_SEI,
700     VDEC_USER_CMD_GET_DISP_QUEUE_EMPTY,
701     VDEC_USER_CMD_GET_BUFFER_INFO,
702     VDEC_USER_CMD_GET_NEXT_DISP_FRAME_QOS_INFO,
703     VDEC_USER_CMD_GET_NOT_SUPPORT_INFO,
704 #endif
705 #if defined(UFO_PUBLIC_HEADER_500)||defined(UFO_PUBLIC_HEADER_500_3)
706     VDEC_USER_CMD_GET_PRE_PAS_U64PTS,               // Get Pre-parsing PTS
707     VDEC_USER_CMD_GET_SEQ_CHANGE_INFO,              // Get the reason why seq changes, parameter is MS_U32, definition is VDEC_SeqChangeInfo
708     VDEC_USER_CMD_GET_DISP_QUEUE_EMPTY,
709     VDEC_USER_CMD_GET_NOT_SUPPORT_INFO,
710     VDEC_USER_CMD_GET_PVRSEAMLESS_INFO,
711     VDEC_USER_CMD_GET_MIN_TSP_DATA_SIZE,
712     VDEC_USER_CMD_GET_CLLI_SEI,
713     VDEC_USER_CMD_GET_BUFFER_INFO,
714     VDEC_USER_CMD_GET_NEXT_DISP_FRAME_QOS_INFO,
715 #endif
716 #if defined(UFO_PUBLIC_HEADER_212)
717     VDEC_USER_CMD_GET_PVRSEAMLESS_INFO,
718     VDEC_USER_CMD_GET_PRE_PAS_U64PTS,               // Get Pre-parsing PTS
719     VDEC_USER_CMD_GET_SEQ_CHANGE_INFO,              // Get the reason why seq changes, parameter is MS_U32, definition is VDEC_SeqChangeInfo
720     VDEC_USER_CMD_GET_MIN_TSP_DATA_SIZE,
721     VDEC_USER_CMD_GET_CLLI_SEI,
722     VDEC_USER_CMD_GET_DISP_QUEUE_EMPTY,
723     VDEC_USER_CMD_GET_BUFFER_INFO,
724     VDEC_USER_CMD_GET_NEXT_DISP_FRAME_QOS_INFO,
725     VDEC_USER_CMD_GET_NOT_SUPPORT_INFO,
726 #endif
727 
728     VDEC_USER_CMD_MVC_GET_CMD_BASE = 0x1800,
729     VDEC_USER_CMD_GET_MVC_SUB_FRAME_DISP_INFO,     // Param: VDEC_FrameInfo pointer.
730     VDEC_USER_CMD_GET_MVC_BBU2_DECQ_VACANCY,       // Param: BBU2 Dec Q Vacancy.
731     VDEC_USER_CMD_GET_MVC_ES2_READ_PTR,            // Param: ES2 read pointer.
732     VDEC_USER_CMD_GET_MVC_ES2_WRITE_PTR,           // Param: ES2 Write pointer.
733     VDEC_USER_CMD_GET_ES_QUANTITY,                 // Param: Get ES buffer Level.
734     VDEC_USER_CMD_GET_ES2_QUANTITY,                // Param: Get ES2 buffer Level.
735     VDEC_USER_CMD_GET_MAIN_STREAM_ID,              // Param: Get main stream ID.
736 
737     //Group3:System Preset Control command======================
738     //Group3-1:Common system Preset Control command
739     VDEC_USER_CMD_SYSTEM_PRESET_CONTROL_BASE    = 0x2000,
740     VDEC_USER_CMD_SYSTEM_PRESET_VPU_CLOCK,          //Param: VDEC_EX_ClockSpeed
741 
742     //Group3-2:HVD System Preset Control command
743     VDEC_USER_CMD_SYSTEM_PRESET_HVD_BASE        = 0x2100,
744     VDEC_USER_CMD_SYSTEM_PRESET_HVD_CLOCK,          //Param: VDEC_EX_ClockSpeed
745 
746     //Group3-3:MVD System Preset Control command
747     VDEC_USER_CMD_SYSTEM_PRESET_MVD_BASE        = 0x2200,
748     VDEC_USER_CMD_SYSTEM_PRESET_MVD_CLOCK,          //Param: VDEC_EX_ClockSpeed
749     VDEC_USER_CMD_VPU_SECURITY_MODE,               //Param: 0:disable,1:enable
750 
751     //Group4:Preset Control command=============================
752     VDEC_USER_CMD_PRESET_CONTROL_BASE           = 0x2300,
753     VDEC_USER_CMD_HVD_ONE_PENDING_BUFFER_MODE,  //Param: 0(Disable), 1(Enable), use only one pending buffer instead of two for HVD
754     VDEC_USER_CMD_MVD_HWBUFFER_REMAPPING_MODE,  //Param: 0(Disable), 1(Enable), Allcate HW buffer to start of frame buffer
755     VDEC_USER_CMD_FRAMERATE_HANDLING,           //Param: 1000~60000, Set frame rate when the sequence did not have frame rate info. The unit is (param/1000)fps, Ex: 30000 = 30.000 fps
756                                                     //Param: 0xFFFFFFFF, use default frame rate when no frame rate info in header
757     VDEC_USER_CMD_SET_SHAREMEMORY_BASE,
758     VDEC_USER_CMD_HVD_COL_BBU_MODE,                //Param: HVD use colocated BBU mode, 0: disable, 1: enable /*johnny.ko*/
759     VDEC_USER_CMD_HVD_IAPGN_BUF_SHARE_BW_MODE,   //Param: HVD IAP GN Buffer address,
760     VDEC_USER_CMD_DTV_DEBUG_MODE,
761     VDEC_USER_CMD_HVD_TS_IN_BBU_MODE,
762     VDEC_USER_CMD_AUTO_ARRANGE_FRAMEBUFFER_USAGE,
763     VDEC_USER_CMD_THUMBNAIL_MODE,
764     VDEC_USER_CMD_FORCE_8BIT_DEC_MODE,
765     VDEC_USER_CMD_MFCODEC_MODE,                    //Param: VDEC_EX_MFCodec_mode
766     VDEC_USER_CMD_VDEC_FEATURE,                 //AP control VDEC features
767     VDEC_USER_CMD_SET_DISPLAY_MODE,
768     VDEC_USER_CMD_CAL_FRAMERATE,
769     VDEC_USER_CMD_SETPOWERSTATE,
770 
771     //Group5:System PreGet Control command======================
772     //Group5-1:Common system Preget Control command
773     VDEC_USER_CMD_SYSTEM_PREGET_CONTROL_BASE  = 0x4000,
774     VDEC_USER_CMD_SYSTEM_PREGET_FB_MEMORY_USAGE_SIZE,
775 
776 } VDEC_User_Cmd;
777 
778 //VDEC FW TYPE
779 typedef enum
780 {
781     VDEC_FW_TYPE_MVD = 0,
782     VDEC_FW_TYPE_HVD,
783 } VDEC_FwType;
784 
785 //VDEC FB reduction type
786 typedef enum
787 {
788     VDEC_FB_REDUCTION_NONE = 0,
789     VDEC_FB_REDUCTION_1_2,
790     VDEC_FB_REDUCTION_1_4
791 } VDEC_FBReductionType;
792 
793 //VDEC XC_LOW_DELAY
794 typedef enum
795 {
796     // no any XC_LOW_DELAY event happened.
797     VDEC_XC_LOW_DELAY_NONE              = 0x00,
798     // XC_LOW_DELAY event for disable black screen.
799     VDEC_XC_DISABLE_BLACK_SCREEN        = VDEC_BIT(0),
800     // XC_LOW_DELAY event for release force_read_bank.
801     VDEC_XC_RELEASE_FORCE_READ_BANK     = VDEC_BIT(1),
802     // XC_LOW_DELAY event for release bob_mode.
803     VDEC_XC_RELEASE_BOB_MODE            = VDEC_BIT(2),
804 } VDEC_XcLowDelayType;
805 
806 // VDEC SEQ change info
807 typedef enum
808 {
809     // seq change due to first sequence
810     VDEC_SEQ_CHANGE_FIRST_TIME        = VDEC_BIT(0),
811     // seq chagne due to resolution
812     VDEC_SEQ_CHANGE_RESOLUTION        = VDEC_BIT(1),
813     // seq chagne due to picture type
814     VDEC_SEQ_CHANGE_PICTURE_TYPE      = VDEC_BIT(2),
815     // seq chagne due to aspect ratio
816     VDEC_SEQ_CHANGE_ASPECT_RATIO      = VDEC_BIT(3),
817     // seq chagne due to frame rate
818     VDEC_SEQ_CHANGE_FRAME_RATE        = VDEC_BIT(4),
819     // seq chagne due to HDR info
820     VDEC_SEQ_CHANGE_HDR_INFO          = VDEC_BIT(5),
821 } VDEC_SeqChangeInfo;
822 
823 
824 /// Data structure of CC Configuration
825 typedef struct
826 {
827     /// 608 / 708
828     VDEC_CCFormat   eFormat;
829     /// CC type
830     VDEC_CCType     eType;
831     /// CC data start address
832     MS_VIRT          u32BufStAdd;
833     /// CC data size
834     MS_U32          u32BufSize;
835 } VDEC_CCCfg;
836 
837 /// Information for display setting
838 typedef struct
839 {
840     ///Bitstream horizontal size
841     MS_U16 u16HorSize;
842     ///Bitstream vertical size
843     MS_U16 u16VerSize;
844     ///Frame rate
845     MS_U32 u32FrameRate;
846     ///Interlace flag
847     MS_U8 u8Interlace;
848     ///Active format description
849     MS_U8 u8AFD;
850     ///Sample aspect rate width
851     MS_U16 u16SarWidth;
852     ///Sample aspect rate height
853     MS_U16 u16SarHeight;
854     ///Right cropping
855     MS_U16 u16CropRight;
856     ///Left cropping
857     MS_U16 u16CropLeft;
858     ///Bottom cropping
859     MS_U16 u16CropBottom;
860     ///Top cropping
861     MS_U16 u16CropTop;
862     ///Pitch
863     MS_U16 u16Pitch;
864     ///Interval of PTS
865     MS_U16 u16PTSInterval;
866     ///MPEG1 flag
867     MS_U8 u8MPEG1;
868     ///Play mode (fixme)
869     MS_U8 u8PlayMode;
870     ///FRC mode
871     MS_U8 u8FrcMode;
872     ///Aspect ratio code
873     MS_U8 u8AspectRate;
874     ///if FALSE, set VOP as mono mode (only for H264)
875     MS_BOOL bWithChroma;
876     /// if true, color space is xvYCC (Y from 16 to 235 and Cb , Cr from 16 to 240).
877     /// if false, color space is BT.601/709 (Y from  0 to 255 and Cb , Cr from  0 to 255).
878     /// only MPEG might be with BT.601/709
879     MS_BOOL bColorInXVYCC;
880     ///Dynamic scaling buffer address
881     MS_VIRT u32DynScalingAddr;
882     ///Dynamic scaling buffer size
883     MS_U32 u32DynScalingSize;
884     ///Dynamic scaling depth
885     MS_U8 u8DynScalingDepth;
886     ///Dynamic scaling DS buffer on miu1 or miu0
887     MS_BOOL bEnableMIUSel;
888     ///Display width
889     MS_U32 u32AspectWidth;
890     ///Display height
891     MS_U32 u32AspectHeight;
892 } VDEC_DispInfo;
893 
894 /// System configuration
895 typedef struct
896 {
897     ///FW binary start address
898     MS_PHY u32FWBinaryAddr;
899     ///FW binary size
900     MS_U32 u32FWBinarySize;
901     ///FW code buffer start address
902     MS_PHY u32CodeBufAddr;
903     ///FW code buffer size
904     MS_U32 u32CodeBufSize;
905     ///Frame buffer start address
906     MS_PHY u32FrameBufAddr;
907     ///Frame buffer size
908     MS_U32 u32FrameBufSize;
909     ///Bitstream buffer start address
910     MS_PHY u32BitstreamBufAddr;
911     ///Bitstream buffer size
912     MS_U32 u32BitstreamBufSize;
913     ///Driver process buffer start address
914     MS_PHY u32DrvProcBufAddr;
915     ///Driver process buffer size
916     MS_U32 u32DrvProcBufSize;
917     ///VLC table Binary address (RM only)
918     MS_PHY u32VlcBinarySrcAddr;
919     ///VLC table Binary size
920     MS_U32 u32VlcTabBinarySize;
921     ///Debug level setting
922     VDEC_DbgLevel eDbgMsgLevel;
923     ///FW source type seeting
924     VDEC_FWSourceType eFWSourceType;
925 } VDEC_SysCfg;
926 
927 /// Video information
928 typedef struct
929 {
930     ///input source mode
931     VDEC_SrcMode   eSrcMode;
932     /// timestamp type of command queue
933     VDEC_TimeStampType      eTimeStampType;
934     /// MJPEG scale factor
935     VDEC_MJpegScaleFactor   eMJpegScaleFactor;
936     /// should be TRUE when codec type is H264 and container is MKV and MP4(MOV)
937     MS_BOOL bWithoutNalStCode;
938     /// needless when CodecType is MJPEG and divx311
939     MS_U32 u32FrameRate;
940     MS_U32 u32FrameRateBase;
941     /// if divx311; use u16Width[0]; only need other elements when RV8
942     MS_U16  u16Width[8];
943     /// if divx311; use u16Height[0]; only need other elements when RV8
944     MS_U16  u16Height[8];
945     /// video number sizes (for RM)
946     MS_U16  u16NumSizes;
947 } VDEC_VideoInfo;
948 
949 /// Frame information
950 typedef struct
951 {
952     /// frame buffer base + the start offset of current displayed luma data. Unit: byte.
953     MS_PHY u32LumaAddr;
954     /// frame buffer base + the start offset of current displayed chroma data. Unit: byte.
955     MS_PHY u32ChromaAddr;
956     /// Time stamp(DTS, PTS) of current displayed frame. Unit: ms (todo: 90khz)
957     MS_U32 u32TimeStamp;
958     /// low part of ID number
959     MS_U32 u32ID_L;
960     /// high part of ID number or timestamp
961     MS_U32 u32ID_H;
962     /// pitch
963     MS_U16 u16Pitch;
964     /// width
965     MS_U16 u16Width;
966     /// height
967     MS_U16 u16Height;
968     ///< Frame type: I, P, B frame
969     VDEC_FrameType eFrameType;
970     ///< Field type: Top, Bottom, Both
971     VDEC_FieldType eFieldType;
972 } VDEC_FrameInfo;
973 
974 /// Extension display information
975 typedef struct
976 {
977     /// vertical size from sequene_display_extension
978     MS_U16 u16VSize;
979     /// horizontal size from sequene_display_extension
980     MS_U16 u16HSize;
981     /// vertical offset from picture_display_extension
982     MS_S16 s16VOffset;
983     /// horizontal offset from picture_display_extension
984     MS_S16 s16HOffset;
985 } VDEC_ExtDispInfo;
986 
987 /// Display frame information
988 typedef struct
989 {
990     ///< frame information
991     VDEC_FrameInfo stFrmInfo;
992     ///< firmware private data
993     MS_U32 u32PriData;
994     ///< index used by apiVDEC to manage VDEC_DispQ[][]
995     MS_U32 u32Idx;
996     ///< display information
997     VDEC_DispInfo stDispInfo;
998 } VDEC_DispFrame;
999 
1000 /// Time code structure
1001 typedef struct
1002 {
1003     ///  time_code_hours
1004     MS_U8   u8TimeCodeHr;
1005     ///  time_code_minutes
1006     MS_U8   u8TimeCodeMin;
1007     ///  time_code_seconds
1008     MS_U8   u8TimeCodeSec;
1009     ///  time_code_pictures
1010     MS_U8   u8TimeCodePic;
1011     ///  drop_frame_flag
1012     MS_U8   u8DropFrmFlag;
1013     ///  reserved fields for 4-byte alignment
1014     MS_U8   u8Reserved[3];
1015 } VDEC_TimeCode;
1016 
1017 /// VDEC frame buffer reduction
1018 typedef struct
1019 {
1020     VDEC_FBReductionType eLumaFBReduction;
1021     VDEC_FBReductionType eChromaFBReduction;
1022     MS_BOOL              bEnableAutoMode;      /// 0: Disable, 1: Enable
1023 } VDEC_FBReduction;
1024 
1025 /// Initial parameter
1026 typedef struct
1027 {
1028     /// codec type
1029     VDEC_CodecType  eCodecType;
1030     /// system configuration
1031     VDEC_SysCfg     SysConfig;
1032     /// video information from container
1033     VDEC_VideoInfo  VideoInfo;
1034     /// dynamic scaling control bit
1035     MS_BOOL         EnableDynaScale;
1036     /// switch for display decode error frame or not
1037     MS_BOOL         bDisableDropErrFrame;
1038     /// switch for error concealment
1039     MS_BOOL         bDisableErrConceal;
1040     /// enable repeat last field when repeat happened at interlace stream
1041     MS_BOOL         bRepeatLastField;
1042     /// threshold to judge error frame
1043     MS_U8           u8ErrThreshold;
1044     /// dynamic scaling virtual box Width
1045     MS_U32          u32DSVirtualBoxWidth;
1046     /// dynamic scaling virtual box Height
1047     MS_U32          u32DSVirtualBoxHeight;
1048 } VDEC_InitParam;
1049 
1050 /// Initial parameter, version = 1
1051 typedef struct
1052 {
1053     /// init param version : 1
1054     MS_U32          u32Version;
1055     /// codec type
1056     VDEC_CodecType  eCodecType;
1057     /// system configuration
1058     VDEC_SysCfg     SysConfig;
1059     /// video information from container
1060     VDEC_VideoInfo  VideoInfo;
1061     /// dynamic scaling control bit
1062     MS_BOOL         EnableDynaScale;
1063     /// switch for display decode error frame or not
1064     MS_BOOL         bDisableDropErrFrame;
1065     /// switch for error concealment
1066     MS_BOOL         bDisableErrConceal;
1067     /// enable repeat last field when repeat happened at interlace stream
1068     MS_BOOL         bRepeatLastField;
1069     /// threshold to judge error frame
1070     MS_U8           u8ErrThreshold;
1071     /// dynamic scaling virtual box Width
1072     MS_U32          u32DSVirtualBoxWidth;
1073     /// dynamic scaling virtual box Height
1074     MS_U32          u32DSVirtualBoxHeight;
1075     /// vdec frame buffer reduction setting
1076     VDEC_FBReduction    stFBReduction;
1077 } VDEC_InitParam_EX1;
1078 
1079 /// Decode Command
1080 typedef struct
1081 {
1082     /// ID (high 4-bytes) or timestamp of payload (high byte)
1083     MS_U32  u32ID_H;
1084     /// ID (low 4-bytes)
1085     MS_U32  u32ID_L;
1086     /// start address of payload
1087     MS_U32  u32StAddr;
1088     /// size of payload
1089     MS_U32  u32Size;
1090     /// timestamp of payload
1091     MS_U32  u32Timestamp;
1092 } VDEC_DecCmd;
1093 
1094 /// Display Command
1095 typedef struct
1096 {
1097     /// ID (high 4-bytes)
1098     MS_U32  u32ID_H;
1099     /// ID (low 4-bytes)
1100     MS_U32  u32ID_L;
1101     /// action of command
1102     VDEC_DispCmdAction  eAction;
1103 } VDEC_DispCmd;
1104 
1105 typedef struct
1106 {
1107     MS_BOOL bEnable;
1108     MS_U32  u32Delay;
1109     MS_U16  u16Tolerance;
1110 } VDEC_AVSyncCfg;
1111 
1112 
1113 typedef void (*VDEC_EventCb)(MS_U32 eFlag, void *param);
1114 
1115 typedef struct
1116 {
1117     MS_U32              u32Version;
1118     /// top, bottom or frame
1119     VDEC_PicStructure   u8PicStructure;
1120     MS_U8               u8TopFieldFirst;
1121     MS_U16              u16TempRef;
1122     MS_U32              u32Pts;
1123     /// address of cc data
1124     MS_U32              u32UserDataBuf;
1125     /// size of cc data
1126     MS_U32              u32UserDataSize;
1127 } VDEC_CC_Info;
1128 
1129 ///CC input parameters for mstar proprietary CC library
1130 typedef struct
1131 {
1132     MS_U32 u32Ver;      ///version of this structure
1133     MS_U32 u32Val;
1134 } VDEC_CC_InputPara;
1135 
1136 typedef struct
1137 {
1138     MS_U32      u32OutputFrameRate; ///< output frame rate, unit:vsync count
1139     MS_U8       u8Interlace;        ///< output scan:0:progress, 1:interlace
1140 } VDEC_FRC_OutputParam;
1141 
1142 typedef struct
1143 {
1144     MS_U8   u8Frm_packing_arr_cnl_flag;
1145     MS_U8   u8Frm_packing_arr_type;
1146     MS_U8   u8content_interpretation_type;
1147     MS_U8   u1Quincunx_sampling_flag;
1148 
1149     MS_U8   u1Spatial_flipping_flag;
1150     MS_U8   u1Frame0_flipping_flag;
1151     MS_U8   u1Field_views_flag;
1152     MS_U8   u1Current_frame_is_frame0_flag;
1153 
1154     MS_U8   u1Frame0_self_contained_flag;
1155     MS_U8   u1Frame1_self_contained_flag;
1156     MS_U8   u4Frame0_grid_position_x;
1157     MS_U8   u4Frame0_grid_position_y;
1158 
1159     MS_U8   u4Frame1_grid_position_x;
1160     MS_U8   u4Frame1_grid_position_y;
1161     MS_U8   u8Reserved01;
1162     MS_U8   u8Reserved02;
1163 }VDEC_Frame_packing_SEI;
1164 
1165 typedef enum
1166 {
1167     E_VDEC_TRICKPLAY2X_COUNTVSYNC = 0,
1168     E_VDEC_TRICKPLAY2X_AVSYNC
1169 }VDEC_TrickPlay2xMode;
1170 
1171 
1172 typedef struct
1173 {
1174     VDEC_CodecType eCodecType;
1175     MS_PHY  u32DataAddr;
1176     MS_U32  u32MemUsageSize;
1177     MS_U16  u16DataSize;
1178 } VDEC_FbMemUsage_Param;
1179 
1180 typedef struct
1181 {
1182     MS_U8   u8RepeatPeriod;
1183     MS_U8   u8DropPeriod;
1184 }VDEC_Slow_Sync;
1185 
1186 
1187 
1188 //-------------------------------------------------------------------------------------------------
1189 //  Function and Variable
1190 //-------------------------------------------------------------------------------------------------
1191 VDEC_Result MApi_VDEC_GetLibVer(const MSIF_Version **ppVersion);
1192 VDEC_Result MApi_VDEC_GetInfo(const VDEC_Info **ppInfo);
1193 MS_BOOL     MApi_VDEC_GetStatus(VDEC_Status *pStatus);
1194 MS_BOOL     MApi_VDEC_CheckCaps(VDEC_CodecType eCodecType);
1195 VDEC_Result MApi_VDEC_EnableTurboMode(MS_BOOL bEnable);
1196 VDEC_Result MApi_VDEC_Init(VDEC_InitParam *pInitParam);
1197 VDEC_Result MApi_VDEC_Init_EX(void *pInfo, MS_U32 u32Size);
1198 VDEC_Result MApi_VDEC_Rst(void);
1199 VDEC_Result MApi_VDEC_Exit(void);
1200 VDEC_Result MApi_VDEC_CheckDispInfoRdy(void);
1201 VDEC_Result MApi_VDEC_SetFrcMode(VDEC_FrcMode eFrcMode);
1202 VDEC_Result MApi_VDEC_SetDynScalingParams( MS_PHY u32Addr , MS_U32 u32Size);
1203 VDEC_Result MApi_VDEC_SetDbgLevel(VDEC_DbgLevel eDbgLevel);
1204 
1205 
1206 VDEC_Result MApi_VDEC_Play(void);
1207 VDEC_Result MApi_VDEC_Pause(void);
1208 VDEC_Result MApi_VDEC_Resume(void);
1209 VDEC_Result MApi_VDEC_StepDisp(void);
1210 VDEC_Result MApi_VDEC_IsStepDispDone(void);
1211 VDEC_Result MApi_VDEC_StepDecode(void);
1212 VDEC_Result MApi_VDEC_IsStepDecodeDone(void);
1213 VDEC_Result MApi_VDEC_SetTrickMode(VDEC_TrickDec eTrickDec);
1214 VDEC_Result MApi_VDEC_SetBlockDisplay(MS_BOOL bEnable);
1215 
1216 VDEC_Result MApi_VDEC_EnableESBuffMalloc(MS_BOOL bEnable);
1217 MS_U32 MApi_VDEC_GetESBuffVacancy(void* pData);
1218 VDEC_Result MApi_VDEC_GetESBuff(MS_U32 u32ReqSize, MS_U32* u32AvailSize, MS_PHY* u32Addr);
1219 
1220 /*
1221 VDEC_Result MApi_VDEC_PushQueue(MS_U32 u32StAddr,
1222                                 MS_U32 u32Size,
1223                                 MS_U32 u32Timestamp,
1224                                 MS_U32 u32ID_H,
1225                                 MS_U32 u32ID_L);
1226 MS_U32      MApi_VDEC_GetQueueVacancy(void);
1227 VDEC_Result MApi_VDEC_FlushQueue(void);
1228 */
1229 
1230 VDEC_Result MApi_VDEC_PushDecQ(VDEC_DecCmd *pCmd);
1231 VDEC_Result MApi_VDEC_PushDispQ(VDEC_DispCmd *pCmd);
1232 VDEC_Result MApi_VDEC_Flush(VDEC_FreezePicSelect eFreezePic);
1233 VDEC_Result MApi_VDEC_EnableLastFrameShow(MS_BOOL bEnable);
1234 VDEC_Result MApi_VDEC_SetSpeed(VDEC_SpeedType eSpeedType, VDEC_DispSpeed eSpeed);
1235 VDEC_Result MApi_VDEC_SetFreezeDisp(MS_BOOL bEnable);
1236 VDEC_Result MApi_VDEC_SetBlueScreen(MS_BOOL bOn);
1237 VDEC_Result MApi_VDEC_ResetPTS(MS_U32 u32PtsBase);
1238 VDEC_Result MApi_VDEC_AVSyncOn(MS_BOOL bOn, MS_U32 u32SyncDelay, MS_U16 u16SyncTolerance);
1239 VDEC_Result MApi_VDEC_SetAVSyncFreerunThreshold(MS_U32 u32Threshold );
1240 
1241 VDEC_Result MApi_VDEC_GetDispInfo(VDEC_DispInfo *pDispinfo);
1242 VDEC_Result MApi_VDEC_IsAVSyncOn(void);
1243 VDEC_Result MApi_VDEC_IsWithValidStream(void);
1244 VDEC_Result MApi_VDEC_IsDispFinish(void);
1245 VDEC_Result MApi_VDEC_IsFrameRdy(void);
1246 VDEC_Result MApi_VDEC_IsIFrameFound(void);
1247 VDEC_Result MApi_VDEC_IsSeqChg(void);
1248 VDEC_Result MApi_VDEC_IsReachSync(void);
1249 VDEC_Result MApi_VDEC_IsFreerun(void);
1250 VDEC_Result MApi_VDEC_IsStartSync(void);
1251 VDEC_Result MApi_VDEC_IsWithLowDelay(void);
1252 VDEC_Result MApi_VDEC_IsAllBufferEmpty(void);
1253 VDEC_Result MApi_VDEC_GetExtDispInfo(VDEC_ExtDispInfo *pExtDispinfo);
1254 VDEC_Result MApi_VDEC_GetDecFrameInfo(VDEC_FrameInfo *pFrmInfo);
1255 VDEC_Result MApi_VDEC_GetDispFrameInfo(VDEC_FrameInfo *pFrmInfo);
1256 VDEC_Result MApi_VDEC_GetNextDispFrame(VDEC_DispFrame** ppDispFrm);
1257 VDEC_Result MApi_VDEC_DisplayFrame(VDEC_DispFrame *pDispFrm);
1258 VDEC_Result MApi_VDEC_ReleaseFrame(VDEC_DispFrame *pDispFrm);
1259 
1260 VDEC_Result MApi_VDEC_GetDecTimeCode(VDEC_TimeCode* pTimeCode);
1261 VDEC_Result MApi_VDEC_GetDispTimeCode(VDEC_TimeCode* pTimeCode);
1262 VDEC_Result MApi_VDEC_SetEvent(MS_U32 u32EnableEvent, VDEC_EventCb pfn, void* param);
1263 VDEC_Result MApi_VDEC_UnsetEvent(MS_U32 u32EnableEvent);
1264 VDEC_Result MApi_VDEC_SetEvent_EX(VDEC_CB_TYPE cb_type, MS_U32 u32EnableEvent, VDEC_EventCb pfn, void* param);
1265 VDEC_Result MApi_VDEC_UnsetEvent_EX(VDEC_CB_TYPE cb_type, MS_U32 u32EnableEvent);
1266 VDEC_Result MApi_VDEC_GetEventInfo(MS_U32* u32EventFlag);
1267 VDEC_Result MApi_VDEC_GetPatchPattern(VDEC_PatchPattern ePatternType, MS_U32 *pu32Staddr, MS_U32 *pu32Len);
1268 VDEC_Result MApi_VDEC_FireDecCmd(void);
1269 VDEC_Result MApi_VDEC_SeekToPTS(MS_U32 u32PTS);
1270 VDEC_Result MApi_VDEC_SkipToPTS(MS_U32 u32PTS);
1271 
1272 // Advanced Settings / Mode
1273 VDEC_Result MApi_VDEC_DisableDeblocking(MS_BOOL bDisable);
1274 VDEC_Result MApi_VDEC_DisableQuarterPixel(MS_BOOL bDisable);
1275 VDEC_Result MApi_VDEC_SetAutoRmLstZeroByte(MS_BOOL bOn);
1276 VDEC_Result MApi_VDEC_SetBalanceBW(MS_U8 u8QuarPixelTH, MS_U8 u8DeBlockingTH, MS_U8 u8UpperBound, MS_U8 u8SafeCoef);
1277 
1278 MS_U8       MApi_VDEC_GetActiveFormat(void);
1279 MS_U8       MApi_VDEC_GetColourPrimaries(void);
1280 MS_U8       MApi_VDEC_GetGOPCnt(void);
1281 MS_U32      MApi_VDEC_GetESWritePtr(void);
1282 MS_U32      MApi_VDEC_GetESReadPtr(void);
1283 MS_U32      MApi_VDEC_GetPTS(void);
1284 MS_U32      MApi_VDEC_GetNextPTS(void);
1285 MS_U32      MApi_VDEC_GetErrCode(void);
1286 MS_U32      MApi_VDEC_GetErrCnt(void);
1287 MS_U32      MApi_VDEC_GetBitsRate(void);
1288 MS_U32      MApi_VDEC_GetFrameCnt(void);
1289 MS_U32      MApi_VDEC_GetSkipCnt(void);
1290 MS_U32      MApi_VDEC_GetDropCnt(void);
1291 MS_U32      MApi_VDEC_GetDecQVacancy(void);
1292 MS_U32      MApi_VDEC_GetDispQVacancy(void);
1293 MS_BOOL     MApi_VDEC_Is32PullDown(void);
1294 VDEC_Result MApi_VDEC_IsAlive(void);
1295 MS_S64      MApi_VDEC_GetVideoPtsStcDelta(void);
1296 MS_BOOL     MApi_VDEC_IsCCAvailable(void);
1297 VDEC_Result MApi_VDEC_GetCCInfo(void *pInfo, MS_U32 u32Size);
1298 
1299 VDEC_TrickDec MApi_VDEC_GetTrickMode(void);
1300 VDEC_CodecType MApi_VDEC_GetActiveCodecType(void);
1301 
1302 VDEC_Result MDrv_VDEC_GenPattern(VDEC_PatternType ePatternType ,  MS_PHY u32Addr , MS_U32* u32Size);
1303 VDEC_Result MApi_VDEC_GenPattern(VDEC_PatternType ePatternType, MS_PHY u32Addr, MS_U32 *pu32Size);
1304 MS_U32 MApi_VDEC_GetPatternLeastLength(VDEC_PatternType ePatternType );
1305 
1306 VDEC_Result MApi_VDEC_MHEG_DecodeIFrame(MS_PHY u32FrameBufAddr,
1307                                         MS_PHY u32SrcSt,
1308                                         MS_PHY u32SrcEnd);
1309 VDEC_Result MApi_VDEC_MHEG_IsIFrameDecoding(void);
1310 VDEC_Result MApi_VDEC_MHEG_RstIFrameDec(void);
1311 
1312 //ATSC Closed Caption control
1313 VDEC_Result MApi_VDEC_CC_StartParsing(VDEC_CCCfg *pCCParam);
1314 VDEC_Result MApi_VDEC_CC_StopParsing(void);
1315 VDEC_Result MApi_VDEC_CC_GetWritePtr(MS_U32 *pWrite);
1316 VDEC_Result MApi_VDEC_CC_GetReadPtr(MS_U32 *pRead);
1317 VDEC_Result MApi_VDEC_CC_UpdateReadPtr(MS_U32 u32EachPacketSize);
1318 VDEC_Result MApi_VDEC_CC_GetIsOverflow(MS_BOOL *pbOverflow);
1319 
1320 VDEC_Result MApi_VDEC_CC_Init(MS_U32 *pIn);
1321 VDEC_Result MApi_VDEC_CC_SetCfg(VDEC_CCFormat eFmt, VDEC_CCType eType, MS_U32 *pIn);
1322 VDEC_Result MApi_VDEC_CC_SetBuffStartAdd(VDEC_CCFormat eFmt, MS_U32 *pIn);
1323 VDEC_Result MApi_VDEC_CC_UpdateWriteAdd(VDEC_CCFormat eFmt, MS_U32 *pIn);
1324 VDEC_Result MApi_VDEC_CC_UpdateReadAdd(VDEC_CCFormat eFmt, MS_U32 *pIn);
1325 VDEC_Result MApi_VDEC_CC_DisableParsing(VDEC_CCFormat eFmt);
1326 VDEC_Result MApi_VDEC_CC_GetIsRstDone(VDEC_CCFormat eFmt);
1327 VDEC_Result MApi_VDEC_CC_GetIsBuffOverflow(VDEC_CCFormat eFmt);
1328 MS_PHY MApi_VDEC_CC_GetWriteAdd(VDEC_CCFormat eFmt);
1329 MS_PHY MApi_VDEC_CC_GetReadAdd(VDEC_CCFormat eFmt);
1330 
1331 VDEC_Result MApi_VDEC_DbgCmd(MS_U32 u8Cmd, MS_U32 u32CmdArg);
1332 VDEC_Result MApi_VDEC_DbgSetData(MS_VIRT u32Addr, MS_U32 u32Data);
1333 VDEC_Result MApi_VDEC_DbgGetData(MS_VIRT u32Addr, MS_U32 *u32Data);
1334 
1335 VDEC_Result MApi_VDEC_SetControl(VDEC_User_Cmd cmd_id, MS_VIRT param);
1336 VDEC_Result MApi_VDEC_PreSetControl(VDEC_User_Cmd cmd_id, MS_U32 param);
1337 
1338 MS_U32      MApi_VDEC_GetFwVersion(VDEC_FwType eFwType);
1339 
1340 MS_U32 MApi_VDEC_GetDispCnt(void);
1341 
1342 VDEC_Result MApi_VDEC_GetControl(VDEC_User_Cmd cmd_id, MS_U32 *param);
1343 VDEC_Result MApi_VDEC_FlushPTSBuf(void);
1344 
1345 //System preseting function, it should be called when system init.
1346 VDEC_Result MApi_VDEC_SystemPreSetControl(VDEC_User_Cmd cmd_id, void *pParam);
1347 
1348 
1349 VDEC_Result MApi_VDEC_V2_SetPowerState(EN_POWER_MODE u16PowerState);
1350 
1351 VDEC_Result MApi_VDEC_V2_GetLibVer(const MSIF_Version **ppVersion);
1352 VDEC_Result MApi_VDEC_V2_GetInfo(const VDEC_Info **ppInfo);
1353 MS_BOOL MApi_VDEC_V2_GetStatus(VDEC_Status *pStatus);
1354 MS_BOOL MApi_VDEC_V2_CheckCaps(VDEC_CodecType eCodecType);
1355 VDEC_Result MApi_VDEC_V2_EnableTurboMode(MS_BOOL bEnable);
1356 VDEC_Result MApi_VDEC_V2_Init(VDEC_InitParam *pInitParam);
1357 VDEC_Result MApi_VDEC_V2_Init_EX(void *pInfo, MS_U32 u32Size);
1358 VDEC_Result MApi_VDEC_V2_Rst(void);
1359 VDEC_Result MApi_VDEC_V2_Exit(MS_BOOL);
1360 VDEC_Result MApi_VDEC_V2_CheckDispInfoRdy(void);
1361 VDEC_Result MApi_VDEC_V2_SetFrcMode(VDEC_FrcMode eFrcMode);
1362 VDEC_Result MApi_VDEC_V2_SetDynScalingParams( MS_PHY u32Addr , MS_U32 u32Size);
1363 VDEC_Result MApi_VDEC_V2_Play(void);
1364 VDEC_Result MApi_VDEC_V2_Pause(void);
1365 VDEC_Result MApi_VDEC_V2_Resume(void);
1366 VDEC_Result MApi_VDEC_V2_StepDisp(void);
1367 VDEC_Result MApi_VDEC_V2_IsStepDispDone(void);
1368 VDEC_Result MApi_VDEC_V2_SeekToPTS(MS_U32 u32PTS);
1369 VDEC_Result MApi_VDEC_V2_SkipToPTS(MS_U32 u32PTS);
1370 VDEC_Result MApi_VDEC_V2_StepDecode(void);
1371 VDEC_Result MApi_VDEC_V2_IsStepDecodeDone(void);
1372 VDEC_Result MApi_VDEC_V2_SetTrickMode(VDEC_TrickDec eTrickDec);
1373 VDEC_Result MApi_VDEC_V2_PushDecQ(VDEC_DecCmd *pCmd);
1374 VDEC_Result MApi_VDEC_V2_FireDecCmd(void);
1375 MS_U32 MApi_VDEC_V2_GetDecQVacancy(void);
1376 MS_BOOL MApi_VDEC_V2_IsCCAvailable(void);
1377 VDEC_Result MApi_VDEC_V2_GetCCInfo(void *pInfo, MS_U32 u32Size);
1378 VDEC_Result MApi_VDEC_V2_Flush(VDEC_FreezePicSelect eFreezePic);
1379 MS_U32 MApi_VDEC_V2_GetESWritePtr(void);
1380 MS_U32 MApi_VDEC_V2_GetESReadPtr(void);
1381 VDEC_Result MApi_VDEC_V2_EnableLastFrameShow(MS_BOOL bEnable);
1382 VDEC_Result MApi_VDEC_V2_IsDispFinish(void);
1383 VDEC_Result MApi_VDEC_V2_SetSpeed(VDEC_SpeedType eSpeedType, VDEC_DispSpeed eSpeed);
1384 VDEC_Result MApi_VDEC_V2_IsFrameRdy(void);
1385 VDEC_Result MApi_VDEC_V2_SetFreezeDisp(MS_BOOL bEnable);
1386 VDEC_Result MApi_VDEC_V2_SetBlueScreen(MS_BOOL bOn);
1387 VDEC_Result MApi_VDEC_V2_ResetPTS(MS_U32 u32PtsBase);
1388 VDEC_Result MApi_VDEC_V2_AVSyncOn(MS_BOOL bOn, MS_U32 u32SyncDelay, MS_U16 u16SyncTolerance);
1389 VDEC_Result MApi_VDEC_V2_SetAVSyncFreerunThreshold(MS_U32 u32Threshold );
1390 VDEC_Result MApi_VDEC_V2_IsAVSyncOn(void);
1391 MS_U32 MApi_VDEC_V2_GetPTS(void);
1392 MS_U32 MApi_VDEC_V2_GetNextPTS(void);
1393 VDEC_Result MApi_VDEC_V2_IsStartSync(void);
1394 VDEC_Result MApi_VDEC_V2_IsReachSync(void);
1395 VDEC_Result MApi_VDEC_V2_IsFreerun(void);
1396 VDEC_Result MApi_VDEC_V2_MHEG_DecodeIFrame(MS_PHY u32FrameBufAddr,
1397                                         MS_PHY u32SrcSt,
1398                                         MS_PHY u32SrcEnd);
1399 VDEC_Result MApi_VDEC_V2_MHEG_IsIFrameDecoding(void);
1400 VDEC_Result MApi_VDEC_V2_MHEG_RstIFrameDec(void);
1401 MS_U32 MApi_VDEC_V2_GetErrCode(void);
1402 MS_U32 MApi_VDEC_V2_GetErrCnt(void);
1403 VDEC_CodecType MApi_VDEC_V2_GetActiveCodecType(void);
1404 MS_U32 MApi_VDEC_V2_GetBitsRate(void);
1405 MS_BOOL MApi_VDEC_V2_Is32PullDown(void);
1406 VDEC_Result MApi_VDEC_V2_IsAlive(void);
1407 MS_S64 MApi_VDEC_V2_GetVideoPtsStcDelta(void);
1408 VDEC_Result MApi_VDEC_V2_IsWithValidStream(void);
1409 VDEC_Result MApi_VDEC_V2_IsIFrameFound(void);
1410 VDEC_Result MApi_VDEC_V2_IsWithLowDelay(void);
1411 VDEC_Result MApi_VDEC_V2_IsAllBufferEmpty(void);
1412 MS_U8 MApi_VDEC_V2_GetGOPCnt(void);
1413 MS_U32 MApi_VDEC_V2_GetFrameCnt(void);
1414 MS_U32 MApi_VDEC_V2_GetSkipCnt(void);
1415 MS_U32 MApi_VDEC_V2_GetDropCnt(void);
1416 VDEC_Result MApi_VDEC_V2_GetDispInfo(VDEC_DispInfo *pDispinfo);
1417 VDEC_TrickDec MApi_VDEC_V2_GetTrickMode(void);
1418 MS_U8 MApi_VDEC_V2_GetActiveFormat(void);
1419 MS_U8 MApi_VDEC_V2_GetColourPrimaries(void);
1420 VDEC_Result MApi_VDEC_V2_GetHWKey(MS_U8 *pu8Key);
1421 VDEC_Result MApi_VDEC_V2_IsSeqChg(void);
1422 VDEC_Result MApi_VDEC_V2_SetDbgLevel(VDEC_DbgLevel eDbgLevel);
1423 VDEC_Result MApi_VDEC_V2_GetDecFrameInfo(VDEC_FrameInfo* pFrmInfo);
1424 VDEC_Result MApi_VDEC_V2_GetDispFrameInfo(VDEC_FrameInfo *pFrmInfo);
1425 VDEC_Result MApi_VDEC_V2_GetExtDispInfo(VDEC_ExtDispInfo *pExtDispinfo);
1426 VDEC_Result MApi_VDEC_V2_GetDecTimeCode(VDEC_TimeCode* pTimeCode);
1427 VDEC_Result MApi_VDEC_V2_GetDispTimeCode(VDEC_TimeCode* pTimeCode);
1428 VDEC_Result MApi_VDEC_V2_CC_StartParsing(VDEC_CCCfg* pCCParam);
1429 VDEC_Result MApi_VDEC_V2_CC_StopParsing(void);
1430 VDEC_Result MApi_VDEC_V2_CC_GetWritePtr(MS_U32* pu32Write);
1431 VDEC_Result MApi_VDEC_V2_CC_GetReadPtr(MS_U32* pu32Write);
1432 VDEC_Result MApi_VDEC_V2_CC_UpdateReadPtr(MS_U32 u32EachPacketSize);
1433 VDEC_Result MApi_VDEC_V2_CC_GetIsOverflow(MS_BOOL* pbOverflow);
1434 VDEC_Result MApi_VDEC_V2_SetEvent(MS_U32 u32EnableEvent, VDEC_EventCb pfn, void* param);
1435 VDEC_Result MApi_VDEC_V2_UnsetEvent(MS_U32 u32EnableEvent);
1436 VDEC_Result MApi_VDEC_V2_SetEvent_EX(VDEC_CB_TYPE cb_type, MS_U32 u32EnableEvent, VDEC_EventCb pfn, void* param);
1437 VDEC_Result MApi_VDEC_V2_UnsetEvent_EX(VDEC_CB_TYPE cb_type, MS_U32 u32EnableEvent);
1438 VDEC_Result MApi_VDEC_V2_GetEventInfo(MS_U32* u32EventFlag);
1439 VDEC_Result MApi_VDEC_V2_GenPattern(VDEC_PatternType ePatternType,	MS_PHY u32Addr, MS_U32 *pu32Size);
1440 MS_U32 MApi_VDEC_V2_GetPatternLeastLength(VDEC_PatternType ePatternType );
1441 VDEC_Result MApi_VDEC_V2_DisableDeblocking(MS_BOOL bDisable);
1442 VDEC_Result MApi_VDEC_V2_DisableQuarterPixel(MS_BOOL bDisable);
1443 VDEC_Result MApi_VDEC_V2_SetAutoRmLstZeroByte(MS_BOOL bOn);
1444 VDEC_Result MApi_VDEC_V2_SetBalanceBW(MS_U8 u8QuarPixelTH, MS_U8 u8DeBlockingTH, MS_U8 u8UpperBound, MS_U8 u8SafeCoef);
1445 VDEC_Result MApi_VDEC_V2_DbgDumpStatus(void);
1446 VDEC_Result MApi_VDEC_V2_SetControl(VDEC_User_Cmd cmd_id, MS_U32 param);
1447 VDEC_Result MApi_VDEC_V2_GetControl(VDEC_User_Cmd cmd_id, MS_U32 *param);
1448 MS_U32 MApi_VDEC_V2_GetDispCnt(void);
1449 MS_U32 MApi_VDEC_V2_GetFwVersion(VDEC_FwType eFwType);
1450 VDEC_Result MApi_VDEC_V2_SetBlockDisplay(MS_BOOL bEnable);
1451 VDEC_Result MApi_VDEC_V2_EnableESBuffMalloc(MS_BOOL bEnable);
1452 MS_U32 MApi_VDEC_V2_GetESBuffVacancy(void* pData);
1453 VDEC_Result MApi_VDEC_V2_GetESBuff(MS_U32 u32ReqSize, MS_U32* u32AvailSize, MS_PHY* u32Addr);
1454 VDEC_Result MApi_VDEC_V2_GetNextDispFrame(VDEC_DispFrame** ppDispFrm);
1455 VDEC_Result MApi_VDEC_V2_DisplayFrame(VDEC_DispFrame *pDispFrm);
1456 VDEC_Result MApi_VDEC_V2_DisplayFrame(VDEC_DispFrame *pDispFrm);
1457 VDEC_Result MApi_VDEC_V2_FlushPTSBuf(void);
1458 VDEC_Result MApi_VDEC_V2_CaptureFrame(MS_U32 u32FrmPriData, MS_BOOL bEnable);
1459 VDEC_Result MApi_VDEC_V2_CC_Init(MS_U32 *pIn);
1460 VDEC_Result MApi_VDEC_V2_CC_SetCfg(VDEC_CCFormat eFmt, VDEC_CCType eType, MS_U32 *pIn);
1461 VDEC_Result MApi_VDEC_V2_CC_SetBuffStartAdd(VDEC_CCFormat eFmt, MS_U32 *pIn);
1462 VDEC_Result MApi_VDEC_V2_CC_UpdateWriteAdd(VDEC_CCFormat eFmt, MS_U32 *pIn);
1463 VDEC_Result MApi_VDEC_V2_CC_UpdateReadAdd(VDEC_CCFormat eFmt, MS_U32 *pIn);
1464 VDEC_Result MApi_VDEC_V2_CC_DisableParsing(VDEC_CCFormat eFmt);
1465 VDEC_Result MApi_VDEC_V2_CC_GetInfo(VDEC_CCFormat eFmt, VDEC_CCInfoCmd eCmd, MS_U32 *pOut);
1466 VDEC_Result MApi_VDEC_V2_CC_GetIsRstDone(VDEC_CCFormat eFmt);
1467 VDEC_Result MApi_VDEC_V2_CC_GetIsBuffOverflow(VDEC_CCFormat eFmt);
1468 MS_PHY MApi_VDEC_V2_CC_GetWriteAdd(VDEC_CCFormat eFmt);
1469 MS_PHY MApi_VDEC_V2_CC_GetReadAdd(VDEC_CCFormat eFmt);
1470 VDEC_Result MApi_VDEC_V2_CC_SystemPreSetControl(VDEC_User_Cmd cmd_id, void *pParam);
1471 VDEC_Result MApi_VDEC_V2_CC_PreSetControl(VDEC_User_Cmd cmd_id, MS_U32 param);
1472 
1473 
1474 
1475 
1476 
1477 
1478 #ifdef __cplusplus
1479 }
1480 #endif
1481 
1482 #endif // _API_VDEC_H_
1483