xref: /utopia/UTPA2-700.0.x/mxlib/include/drvRVD.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 /// @file   drvRVD.h
97 /// @brief  RVD Driver Interface
98 /// @author MStar Semiconductor Inc.
99 ///////////////////////////////////////////////////////////////////////////////////////////////////
100 #ifndef _DRV_RVD_H_
101 #define _DRV_RVD_H_
102 #ifdef __cplusplus
103 extern "C"
104 {
105 #endif
106 
107 //-------------------------------------------------------------------------------------------------
108 //  Driver Capability
109 //-------------------------------------------------------------------------------------------------
110 ////////////////////////////////////////////////////////////////////////////////
111 // Constant & Macro Definition
112 ////////////////////////////////////////////////////////////////////////////////
113 
114 //-------------------------------------------------------------------------------------------------
115 //  Macro and Define
116 //-------------------------------------------------------------------------------------------------
117 #define MSIF_RVD_LIB_CODE    {'R','V','D','_'}    //Lib code
118 #define MSIF_RVD_LIBVER      {'0','1'}            //LIB version
119 #define MSIF_RVD_BUILDNUM    {'0','1'}            //Build Number
120 #define MSIF_RVD_CHANGELIST  {'0','0','1','3','2','9','3','7'} //P4 ChangeList Number
121 
122 
123 //------------------------------------------------------------------------------
124 /// @brief \b RVD_DRV_VERSION : RVD Version
125 //------------------------------------------------------------------------------
126 #define RVD_DRV_VERSION                 /* Character String for DRV/API version             */  \
127     MSIF_TAG,                           /* 'MSIF'                                           */  \
128     MSIF_CLASS,                         /* '00'                                             */  \
129     MSIF_CUS,                           /* 0x0000                                           */  \
130     MSIF_MOD,                           /* 0x0000                                           */  \
131     MSIF_CHIP,                                                                                  \
132     MSIF_CPU,                                                                                   \
133     MSIF_RVD_LIB_CODE,                  /* IP__                                             */  \
134     MSIF_RVD_LIBVER,                    /* 0.0 ~ Z.Z                                        */  \
135     MSIF_RVD_BUILDNUM,                  /* 00 ~ 99                                          */  \
136     MSIF_RVD_CHANGELIST,                /* CL#                                              */  \
137     MSIF_OS
138 
139 //-------------------------------------------------------------------------------------------------
140 //  Type and Structure
141 //-------------------------------------------------------------------------------------------------
142 
143 //-----------------------------------------------------------------------------
144 /// @brief \b Name: RVD_InterruptCb
145 /// @brief \b Description:  RVD Interrupt callback pointer
146 //-----------------------------------------------------------------------------
147 typedef void (*RVD_InterruptCb)(void);
148 
149 //-----------------------------------------------------------------------------
150 /// @brief \b Enum \b Name: E_RVD_DEBUG_LEVEL
151 /// @brief \b Enum \b Description:  SHOW MGS DEBUG LEVEL of RVD
152 //-----------------------------------------------------------------------------
153 typedef enum
154 {
155     E_RVD_DEBUG_NONE = 0x0,  ///< Disable all uart message
156     E_RVD_DEBUG_INF  = 0x01, ///< output general message
157     E_RVD_DEBUG_DRV  = 0x02, ///< output drv layer message
158     E_RVD_DEBUG_HAL  = 0x04, ///< output hal layer message
159     E_RVD_DEBUG_ERR  = 0x08  ///< Only output error message
160 } RVD_DebugLevel;
161 
162 //-----------------------------------------------------------------------------
163 /// @brief \b Enum \b Name: RVD_DisplayMode
164 /// @brief \b Enum \b Description:  RVD Trick(Play)Mode (F/W used)
165 //-----------------------------------------------------------------------------
166 typedef enum
167 {
168     E_RVD_DISPLAYMODE_NULL = 0x7000, ///<Display null
169     E_RVD_DISPLAYMODE_SHOW = 0x7001, ///<Show Display
170     E_RVD_DISPLAYMODE_DONE = 0x7002  ///<Display completed(One frame showed)
171 }  RVD_DisplayMode;
172 
173 //-----------------------------------------------------------------------------
174 /// @brief \b Enum \b Name: RVD_Skip_Decode
175 /// @brief \b Enum \b Description:  The RVD decoding frame types.
176 //-----------------------------------------------------------------------------
177 typedef enum
178 {
179     E_RVD_TRICKMODE_DECODE_ALL = 0, ///<DECODE ALL
180     E_RVD_TRICKMODE_DECODE_I   = 1, ///<DECODE I Frame only
181     E_RVD_TRICKMODE_DECODE_IP  = 2  ///<DECODE I P Frame
182 }  RVD_TrickMode;//FOR PLAYER USED
183 
184 //-----------------------------------------------------------------------------
185 /// @brief \b Enum \b Name: RVD_FWSourceType
186 /// @brief \b Enum \b Description:  The type of fw binary input source
187 //-----------------------------------------------------------------------------
188 typedef enum
189 {
190     E_RVD_FW_SOURCE_NONE,  ///< No input fw.
191     E_RVD_FW_SOURCE_DRAM,  ///< input source from DRAM.
192     E_RVD_FW_SOURCE_FLASH, ///< input source from FLASH.
193 }RVD_FWSourceType;
194 
195 //-----------------------------------------------------------------------------
196 /// @brief \b Struct \b Name: RVD_DrvStatus
197 /// @brief \b Struct \b Description:  Store the RVD driver status
198 //-----------------------------------------------------------------------------
199 typedef struct
200 {
201     MS_BOOL bInit;   ///< - TRUE: Initialization success.  - FALSE: Initialization failed or not initialized yet.
202     MS_BOOL bBusy;   ///< - TRUE: Driver is processing  - FALSE: Driver is Idle.
203 } RVD_DrvStatus;
204 
205 //-----------------------------------------------------------------------------
206 /// @brief \b Enum \b Name: RVD_RVType
207 /// @brief \b Enum \b Description:  The RVD RV Version flag
208 //-----------------------------------------------------------------------------
209 typedef enum
210 {
211     E_RVD_RVTYPE_FLAGRV8 = 0,///<Real Video version 8
212     E_RVD_RVTYPE_FLAGRV9 = 1 ///<Real Video version 9
213 }  RVD_RVType;
214 
215 //-----------------------------------------------------------------------------
216 /// @brief \b Enum \b Name: E_RVD_Result
217 /// @brief \b Enum \b Description:  General result of RVD functions
218 //-----------------------------------------------------------------------------
219 typedef enum
220 {
221     E_RVD_RET_FAIL           = 0, ///< General fail cases.
222     E_RVD_RET_SUCCESS        = 1, ///< Action success.
223     E_RVD_RET_UNSUPPORTED    = 2, ///< Function is not supported by RVD driver.
224     E_RVD_RET_ILLEGAL_ACCESS = 3, ///< Illegal access. like driver not initialized.
225     E_RVD_RET_TIMEOUT        = 4, ///< Action timeout.
226     E_RVD_RET_NOTREADY       = 5, ///< Action not ready. User needs to call it again later.
227     E_RVD_RET_INVALID_PARAM  = 6, ///< Function has invalid input.
228     E_RVD_RET_RE_INIT             ///< RVD driver had initialized.Avoid create new task for RVD
229 }  RVD_Result;
230 
231 //-----------------------------------------------------------------------------
232 /// @brief \b Enum \b Name: RVD_User_Cmd
233 /// @brief \b Enum \b Description:  General command of RVD functions
234 //-----------------------------------------------------------------------------
235 typedef enum
236 {
237     E_RVD_CMD_NULL = 0x0, // Null
238 
239     // Base
240     E_RVD_CMD_NEW_BASE = 0x00010000,//Rvd cmd based
241 
242     //*********************************
243     // Action
244     //*********************************
245     E_RVD_CMD_TYPE_ACTION_MASK = (0x0100|E_RVD_CMD_NEW_BASE),
246     // state machine action
247     E_RVD_CMD_PLAY,            // AVCH264_CMD_GO
248     E_RVD_CMD_PAUSE,           // AVCH264_CMD_PAUSE
249     E_RVD_CMD_STOP,            // AVCH264_CMD_STOP
250     // run-time action
251     E_RVD_CMD_STEP_DECODE,     // AVCH264_CMD_STEP
252     E_RVD_CMD_FLUSH,           // BBU: AVCH264_CMD_DROP ,  DISP: AVCH264_CMD_FLUSH_DISPLAY , AVCH264_CMD_SKIPTOI
253     // internal control action
254     E_RVD_CMD_MIN_FRAME_GAP,   // For file mode only; AVCH264_CMD_MIN_FRAME_GAP
255     E_RVD_CMD_DIS_VDEAD,       // 1: on :For PVR , file mode only ; 0 : off: AVCH264_CMD_DIS_VDEAD
256     E_RVD_CMD_FLUSH_DEC_Q,     // DECODED: AVCH264_CMD_FLUSH_QUEUE
257     E_RVD_CMD_BLUE_SCREEN,
258     E_RVD_CMD_FREEZE_IMG,
259     E_RVD_CMD_JUMP_TO_PTS,     // JUMP TO PTS POSITION
260     E_RVD_CMD_SKIP_TO_PTS,
261     E_RVD_CMD_SYNC_TOLERANCE,
262     E_RVD_CMD_SYNC_VIDEO_DELAY,
263     E_RVD_CMD_FREERUN_THRESHOLD,// 0x1010F
264 
265     //*********************************
266     // FW settings ( only for driver init)
267     //*********************************
268     E_RVD_CMD_SETTINGS_MASK = (0x0200|E_RVD_CMD_NEW_BASE),
269     E_RVD_CMD_DYNAMIC_SCALE,   // 0x10201
270     E_RVD_CMD_SCALER_INFO,     // 0x10202
271 
272     //*********************************
273     // Mode ( for AP run-time)
274     //*********************************
275     E_RVD_CMD_MODE_MASK = (0x0300|E_RVD_CMD_NEW_BASE),
276     E_RVD_CMD_SKIP_DEC,        // E_HVD_DECODE_ALL ;E_HVD_DECODE_I;E_HVD_DECODE_IP; AVCH264_CMD_DEC_I , AVCH264_CMD_SKIP_NONREF
277     E_RVD_CMD_SYNC_ACTIVE,     // 0: sync off; 1: sync on
278     E_RVD_CMD_DISP_SPEED,      // AVCH264_CMD_TRICKY  0,1: normal speed N(>0): show N times, slow motion Nx(2,4...) ; N(<0): FF speed Nx(-2,-4,...) AVCH264_CMD_2X_SPEED
279     E_RVD_CMD_DISP_ERR_FRM,    // True: display and error frame; FALSE: not show error frame ; AVCH264_CMD_ERR_TH
280     E_RVD_CMD_ERR_CONCEAL,     // 1: on ; 0: off ; AVCH264_CMD_PASTE
281     E_RVD_CMD_DROP_DISP_AUTO,  // ??? can we input no arg, 1:on AVCH264_CMD_DISP_DROP, 0:off AVCH264_CMD_DIS_DISP_DROP
282     E_RVD_CMD_DROP_DISP_ONCE,  // AVCH264_CMD_DROP_CNT
283     E_RVD_CMD_DISP_REPEAT_MAX, // Display repeat times
284 
285     //*********************************
286     // test cmd
287     //*********************************
288     E_RVD_CMD_TEST_MASK = (0x0400|E_RVD_CMD_NEW_BASE),
289     E_RVD_CMD_ENABLE_LAST_FRAME_SHOW,
290     E_RVD_CMD_ISR_TYPE
291 } RVD_User_Cmd;
292 
293 //-----------------------------------------------------------------------------
294 /// @brief \b Struct \b Name: RVD_FileInfo
295 /// @brief \b Struct \b Description:  RVD file information
296 //-----------------------------------------------------------------------------
297 typedef struct
298 {
299     MS_U16 RV_Version;      ///< Real Video Bitstream version
300     MS_U16 ulNumSizes;      ///< Real Video Number sizes
301     MS_U16 ulPicSizes_w[8]; ///< Real Video file width
302     MS_U16 ulPicSizes_h[8]; ///< Real Video file height
303     MS_U16 ulBufMode;       ///< Info F/W support HD/SD
304     MS_U32 ulFBAddr;        ///< Frame buffer start addr
305     MS_U32 ulFBSize;        ///< Frame Buffer total size + IAP size (need to be protected)
306     MS_U32 ulVLCAddr;       ///< VLC Table address size :0x20000
307 } RVD_FileInfo;
308 
309 //-----------------------------------------------------------------------------
310 /// @brief \b Struct \b Name: RVD_MiuInfo
311 /// @brief \b Struct \b Description:  Store the RVD driver info
312 //-----------------------------------------------------------------------------
313 typedef struct
314 {
315     MS_BOOL bRVD_MiuSel;       ///<Miu select
316     MS_BOOL bRVD_FWBinInMIU1;  ///<FW Binary source on miu 1
317     MS_BOOL bRVD_VLCBinInMIU1; ///<VLC Binary source on miu 1
318     MS_BOOL bRVD_HWinMIU1;     ///<RVD H/W run on miu 1
319     MS_BOOL bRVD_FWinMIU1;     ///<RVD F/W run on miu 1
320     MS_U32 u32VLC_DstAddr;     ///<VLC Binary source addr
321     MS_U32 u32VLC_DstSize;     ///<VLC Binary source size
322     MS_U32 u32VLC_ScrAddr;     ///<VLC Binary source addr
323     MS_U32 u32VLC_ScrSize;     ///<VLC Binary source size
324     MS_U32 u32FW_ScrAddr;      ///<F/W source addr
325     MS_U32 u32FW_ScrSize;      ///<F/W source size
326     MS_U32 u32FW_DstAddr;      ///<F/W Dst addr
327     MS_U32 u32FW_PhyAddr;      ///<F/W size <remove late>
328     MS_U32 u32BDMAFlag;        ///<BDMA action flag
329 } RVD_MiuInfo;
330 extern RVD_MiuInfo gRVDInfo;
331 
332 //-----------------------------------------------------------------------------
333 /// @brief \b Struct \b Name: RVD_Packet_ID
334 /// @brief \b Struct \b Description:  RVD Packet ID
335 //-----------------------------------------------------------------------------
336 typedef struct
337 {
338     MS_U32 u32PacketID_HI; ///< RVD Packet ID High Addr
339     MS_U32 u32PacketID_LO; ///< RVD Packet ID Low Addr
340 
341 } RVD_Packet_ID;
342 
343 //-----------------------------------------------------------------------------
344 /// @brief \b Struct \b Name: RVD_MEMCfg
345 /// @brief \b Struct \b Description:  RVD Memory Config
346 //-----------------------------------------------------------------------------
347 typedef struct
348 {
349     RVD_FWSourceType eFWSourceType; ///< the input FW source type.
350     MS_U32 u32FWAddr;               ///<RVD Open bin address
351     MS_U32 u32FWSize;               ///<RVD Open bin size
352     MS_U32 u32FBAddr;               ///<RVD Frame buffer start address
353     MS_U32 u32FBSize;               ///<RVD Frame buffer size
354     MS_U32 u32BSAddr;               ///<RVD Bitstream buffer start address
355     MS_U32 u32BSSize;               ///<RVD Bitstream buffer size
356     MS_U32 u32PBAddr;               ///<RVD Dummy data process buffer start address
357     MS_U32 u32PBSize;               ///<RVD Dummy data process buffer size
358     MS_U32 u32FWBinAddr;            ///<RVD open binary data process buffer start address
359     MS_U32 u32FWBinSize;            ///<RVD open binary data process buffer size
360     MS_U32 u32VLCBinAddr;           ///<RVD open binary data process buffer start address
361     MS_U32 u32VLCBinSize;           ///<RVD open binary data process buffer size
362 } RVD_MEMCfg;
363 
364 //-----------------------------------------------------------------------------
365 /// @brief \b Struct \b Name: RVD_FrameInfo
366 /// @brief \b Struct \b Description:  Used for RVD Video Crop
367 //----------------------------------------------------------------------------
368 typedef struct
369 {
370     MS_U16 u16HorSize;        ///<RVD Pic weight
371     MS_U16 u16VerSize;        ///<RVD Pic height
372     MS_U16 u16Sar_width;      ///<RVD Par width ratio
373     MS_U16 u16Sar_height;     ///<RVD Par height ratio
374     MS_U8 u8par_width;        ///<RVD Par width ratio
375     MS_U8 u8par_height;       ///<RVD Par height ratio
376     MS_U16 u16FrameRate;      ///<RVD Frame Rate;
377     MS_U16 u16CropRight;      ///<RVD Crop Right
378     MS_U16 u16CropLeft;       ///<RVD Crop Left
379     MS_U16 u16CropBottom;     ///<RVD Crop Bottom
380     MS_U16 u16CropTop;        ///<RVD Crop Top
381     MS_U32 u32DynScalingAddr; ///<DS Addr
382     MS_U8 u8DynScalingDepth;  ///<DS depth
383     MS_BOOL bEnableMIUSel;    ///<enable  miu select (DS used)
384     MS_U32 u32AspectWidth;    ///Display width
385     MS_U32 u32AspectHeight;   ///Display height
386 } RVD_FrameInfo;
387 
388 //-----------------------------------------------------------------------------
389 /// @brief \b Struct \b Name: RVD_FrameBuff_Info
390 /// @brief \b Struct \b Description:  Get current frame info
391 //----------------------------------------------------------------------------
392 typedef struct
393 {
394     MS_U32 u32LumaAddr;   ///< frame buffer base + the start offset of current displayed luma data. Unit: byte.
395     MS_U32 u32ChromaAddr; ///< frame buffer base + the start offset of current displayed chroma data. Unit: byte.
396     MS_U32 u32TimeStamp;  ///< Time stamp(DTS, PTS) of current displayed frame. Unit: ms (todo: 90khz)
397     MS_U32 u32ID_L;       ///< low part of ID number decided by MDrv_RVD_PushQueue(). (todo)
398     MS_U32 u32ID_H;       ///< high part of ID number decided by MDrv_RVD_PushQueue(). (todo)
399     MS_U16 u16FrmType;    ///< RVD_Picture_Type, picture type: I, P, B frame ---> T_RVPicCodType (temp)
400     MS_U16 u16Pitch;      ///<RVD frame pitch
401     MS_U16 u16Width;      ///<RVD frame width
402     MS_U16 u16Height;     ///<RVD frame hight
403 } RVD_FrameBuff_Info;
404 
405 //-----------------------------------------------------------------------------
406 /// @brief \b Enum \b Name: E_RVD_CMD_SKIP_DEC_ARG
407 /// @brief \b Enum \b Description:  The argument of Skip Decode Mode
408 //-----------------------------------------------------------------------------
409 typedef enum
410 {
411     E_RVD_SKIP_DECB_NONE = 0,
412     E_RVD_SKIP_DECB_ONCE,
413     E_RVD_SKIP_DECB_ALL
414 } RVD_CmdSkipDecArg;
415 
416 //-----------------------------------------------------------------------------
417 /// @brief \b Enum \b Name: E_RVD_CMD_AV_SYNC_ARG
418 /// @brief \b Enum \b Description:  The argument of AV Sync Mode
419 //-----------------------------------------------------------------------------
420 typedef enum
421 {
422     E_RVD_FREERUN = -1,
423     E_RVD_DISABLE = 0,
424     E_RVD_VIDEO_DELAY
425 } RVD_CmdAVSyncArg;
426 
427 //-----------------------------------------------------------------------------
428 /// @brief \b Enum \b Name: E_RVD_CMD_DISP_SPEED_ARG
429 /// @brief \b Enum \b Description:  The argument of Display Speed
430 //-----------------------------------------------------------------------------
431 typedef enum
432 {
433     E_RVD_SPEED_SLOW,
434     E_RVD_SPEED_NORMAL,
435     E_RVD_SPEED_FF
436 } RVD_CmdDispSpeedArg;
437 
438 //-----------------------------------------------------------------------------
439 /// @brief \b Enum \b Name: E_RVD_CMD_DROP_DISP_AUTO_ARG
440 /// @brief \b Enum \b Description:  The argument of DROP DISPLAY
441 //-----------------------------------------------------------------------------
442 typedef enum
443 {
444     E_RVD_DROPDISPAUTO_DISABLE = 0, ///< drop once, drop the number of non-ref frames
445     E_RVD_DROPDISPAUTO_ENABLE       ///< automatic drop mode, drop frame if display queue is more than threshold
446 } RVD_CmdDropDispAutoArg;
447 
448 //-----------------------------------------------------------------------------
449 /// @brief \b Enum \b Name: RVD_Disp_Speed
450 /// @brief \b Enum \b Description:  The current mode type of RVD display speed
451 //-----------------------------------------------------------------------------
452 typedef enum
453 {
454     E_RVD_DISP_SPEED_FF_32X    = -32, ///< Speed fast forward 32x.
455     E_RVD_DISP_SPEED_FF_16X    = -16, ///< Speed fast forward 16x.
456     E_RVD_DISP_SPEED_FF_8X     = -8,  ///< Speed fast forward 8x.
457     E_RVD_DISP_SPEED_FF_4X     = -4,  ///< Speed fast forward 4x.
458     E_RVD_DISP_SPEED_FF_2X     = -2,  ///< Speed fast forward 2x.
459     E_RVD_DISP_SPEED_NORMAL_1X = 1,   ///< Normal display speed.
460     E_RVD_DISP_SPEED_SF_2X     = 2,   ///< Slow forward 2X.
461     E_RVD_DISP_SPEED_SF_4X     = 4,   ///< Slow forward 4X.
462     E_RVD_DISP_SPEED_SF_8X     = 8,   ///< Slow forward 8X.
463     E_RVD_DISP_SPEED_SF_16X    = 16,  ///< Slow forward 16X.
464     E_RVD_DISP_SPEED_SF_32X    = 32,  ///< Slow forward 32X.
465 }RVD_Disp_Speed;
466 
467 //-----------------------------------------------------------------------------
468 /// @brief \b Enum \b Name: RVD_Drop_Disp
469 /// @brief \b Enum \b Description:  The current mode type of RVD dropping decoded frames.
470 //-----------------------------------------------------------------------------
471 typedef enum
472 {
473     E_RVD_DROP_DISPLAY_AUTO = (1<<0),
474     E_RVD_DROP_DISPLAY_ONCE = (1<<1),
475 }RVD_Drop_Disp;
476 
477 //-----------------------------------------------------------------------------
478 /// @brief \b Enum \b Name: RVD_MMAP_Type
479 /// @brief \b Enum \b Description:Memory Config
480 //-----------------------------------------------------------------------------
481 typedef enum
482 {
483     E_RVD_MMAP_FW      = 0, //firmware
484     E_RVD_MMAP_BS      = 1, //bitstream buffer
485     E_RVD_MMAP_FB      = 2, //frame buffer
486     E_RVD_MMAP_PB      = 3, //process buffer
487     E_RVD_MMAP_FW_BIN  = 4, //firmware binary format
488     E_RVD_MMAP_VLC_BIN = 5, //VLC table binary format
489     E_RVD_MMAP_ALL     = 6  //get all memory map
490 } RVD_MMAP_Type;
491 
492 //-----------------------------------------------------------------------------
493 /// @brief \b Enum \b Name: RVD_ActionMode
494 /// @brief \b Enum \b Description:Action Mode
495 //-----------------------------------------------------------------------------
496 typedef enum
497 {
498     E_RVD_ACTIONMODE_IDEL       = 0, //action mode in idel
499     E_RVD_ACTIONMODE_PLAY       = 1, //play mode
500     E_RVD_ACTIONMODE_PAUSE      = 2, //pause mode
501     E_RVD_ACTIONMODE_STOP       = 3, //stop mode
502     E_RVD_ACTIONMODE_STEPDECODE = 4  //step play mode
503 } RVD_ActionMode;
504 
505 //-----------------------------------------------------------------------------
506 /// @brief \b Enum \b Name: RVD_ActionMode
507 /// @brief \b Enum \b Description:Action Mode
508 //-----------------------------------------------------------------------------
509 typedef enum
510 {
511     E_RVD_PICCODTYPE_INTRAPIC,        /* 0 (00) */
512     E_RVD_PICCODTYPE_FORCED_INTRAPIC, /* 1 (01) */
513     E_RVD_PICCODTYPE_INTERPIC,        /* 2 (10) */
514     E_RVD_PICCODTYPE_TRUEBPIC         /* 3 (11) */
515 } RVD_PicCodType;
516 
517 //-----------------------------------------------------------------------------
518 /// @brief \b Enum \b Name: RVD_StatusType
519 /// @brief \b Enum \b Description:Status Type
520 //-----------------------------------------------------------------------------
521 typedef enum
522 {
523     E_RVD_STATUSTYPE_AVSYNCON               = BIT(0), ///AV Sync mode on
524     E_RVD_STATUSTYPE_IFRAMEFOUND            = BIT(1), ///The I frame found
525     E_RVD_STATUSTYPE_PLAYBACK_FINISH        = BIT(2), ///the display finish
526     E_RVD_STATUSTYPE_ENABLE_LAST_FRAME_SHOW = BIT(3), ///the last frame show be enabled
527     E_RVD_STATUSTYPE_BLUE_SCREEN            = BIT(4), ///the blue screen had be enabled
528     E_RVD_STATUSTYPE_FREEZE_IMG             = BIT(5), ///the freeze img had be enabled
529     E_RVD_STATUSTYPE_SKIP_DECODE            = BIT(6),
530     E_RVD_STATUSTYPE_1ST_FRAMERDY           = BIT(7)
531 } RVD_StatusType;
532 
533 //-----------------------------------------------------------------------------
534 /// @brief \b Enum \b Name: RVD_ErrorCode
535 /// @brief \b Enum \b Description:Error code reported by F/W
536 //-----------------------------------------------------------------------------
537 typedef enum
538 {
539     E_ERROR_NONE = 0,       ///no error
540     E_ERROR_PACKET_HEADER,  ///< packet header version error
541     E_ERROR_FRAME_HEADER,   ///< frame type error
542     E_ERROR_SLICE_HEADER,   ///<slice header error
543     E_ERROR_DECODE_TIMEOUT, ///< decode MB timeout
544     E_ERROR_OUT_OF_MEMORY,  ///< frame buffer is out of memory
545     E_ERROR_BYTE_POS,       ///< can not find in ID table
546     E_ERROR_DISPLAY_TIMEOUT
547 } RVD_ErrorCode;
548 
549 //-----------------------------------------------------------------------------
550 /// @brief \b Struct \b Name: RVD_DrvInfo
551 /// @brief \b Struct \b Description:  Store the RVD driver information
552 //-----------------------------------------------------------------------------
553 typedef struct
554 {
555     MS_BOOL bRVD;     ///< - TRUE: HW does support RM.  - FALSE: HW does not support RM.
556     MS_U32 HWversion; ///<- HW version number.
557     MS_U32 FWversion; ///<  FW version number.
558 }RVD_DrvInfo;
559 
560 //-----------------------------------------------------------------------------
561 /// @brief \b Enum \b Name: HVD_ISR_Event
562 /// @brief \b Enum \b Description:  The information type of ISR event.
563 //-----------------------------------------------------------------------------
564 typedef enum
565 {
566     E_RVD_ISR_NONE                 = 0,       ///< disable ISR
567     // DISP
568     E_RVD_ISR_DISP_ONE             = BIT(0),  ///< RVD display one frame on screen.
569     E_RVD_ISR_DISP_REPEAT          = BIT(1),  ///< The current displayed frame is repeated frame.
570     E_RVD_ISR_DISP_WITH_CC         = BIT(2),  ///< Current displayed frame should be displayed with user data.
571     // DEC
572     E_RVD_ISR_DEC_ONE              = BIT(8),  ///< RVD decoded one frame done.
573     E_RVD_ISR_DEC_I                = BIT(9),  ///< RVD decoded one I frame done.
574     E_RVD_ISR_DEC_HW_ERR           = BIT(10), ///< RVD HW found decode error.
575     E_RVD_ISR_DEC_CC_FOUND         = BIT(11), ///< RVD found one user data with decoded frame.
576     E_RVD_ISR_DEC_DISP_INFO_CHANGE = BIT(12), ///< RVD found display information change.
577     E_RVD_ISR_DEC_DATA_ERR         = BIT(13), ///< RVD HW found decode error.
578 } RVD_ISR_Event;
579 
580 /************* RVD debug define *************/
581 #define RVD_MSG_INF(format, args...)  do{if(MDrv_RVD_IsDbgEnable(E_RVD_DEBUG_INF)) printf(format, ##args);}while(0) ///< output general message
582 #define RVD_MSG_DRV(format, args...)  do{if(MDrv_RVD_IsDbgEnable(E_RVD_DEBUG_DRV)) printf(format, ##args);}while(0)///< output drv layer message
583 #define RVD_MSG_HAL(format, args...)  do{if(MDrv_RVD_IsDbgEnable(E_RVD_DEBUG_HAL)) printf(format, ##args);}while(0)///< output hal layer message
584 #define RVD_MSG_ERR(format, args...)  do{if(MDrv_RVD_IsDbgEnable(E_RVD_DEBUG_ERR)) printf(format, ##args);}while(0)///< Only output error message
585 
586 
587 //-------------------------------------------------------------------------------------------------
588 //  Function and Variable
589 //-------------------------------------------------------------------------------------------------
590 extern void MDrv_RVD_SetBBU_OffsetLength(MS_U32 u32Address,MS_U32 u32offset, MS_U32 u32length);
591 extern MS_S16 MDrv_RVD_GetQmemSwBbuVacancy(void);
592 extern void MDrv_RVD_GetFrameSize(MS_U16*  u16Width,MS_U16*  u16Height);
593 extern MS_U32 MDrv_RVD_GetBBUStartAddr(void);
594 extern MS_U32 MDrv_RVD_GetTimeStamp(void);
595 extern MS_U32 MDrv_RVD_GetDecodeCnt(void);
596 extern void MDrv_RVD_SetBBUDepth(MS_U32 u32Rptr);
597 extern void MDrv_RVD_SetBBUReadPtr(MS_U32 u32Rptr);
598 extern void MDrv_RVD_SetBBUWritePtr(MS_U32 u32Wptr);
599 extern MS_U32 MDrv_RVD_GetBBUReadPtr(void);
600 extern MS_U32 MDrv_RVD_GetBBUWritePtr(void);
601 extern MS_U16 MDrv_RVD_GetBBUDepth(void);
602 extern void MDrv_RVD_SetPictureSize(MS_U16 u16Width, MS_U16 u16Height);
603 extern void MDrv_RVD_SetDisplay(RVD_DisplayMode u32PlayMode);
604 extern void MDrv_RVD_PushBBU (MS_U32 u32offset, MS_U32 u32length ,RVD_Packet_ID *rvdPackerInfo);
605 extern void MDrv_RVD_SetFileInfo(RVD_FileInfo *pFileInfo);
606 extern RVD_Result MDrv_RVD_Init(RVD_FileInfo *pFileInfo,RVD_MEMCfg* memCfg);
607 extern RVD_Result MDrv_RVD_EnableDynamicScaling(MS_BOOL bEnable);
608 extern void MDrv_RVD_SetVirtualBox(MS_U16 u16Width, MS_U16 u16Height);
609 extern RVD_Result MDrv_RVD_SetDynScalingParam(MS_U32 u32StAddr, MS_U32 u32Size);
610 extern RVD_Result MDrv_RVD_FlushQueue(void);
611 extern MS_U32 MDrv_RVD_GetESReadPtr(void);
612 extern MS_U32 MDrv_RVD_ReadSVDProgramCounter(void);
613 extern RVD_Result MDrv_RVD_ChkCmdRdy(void);
614 extern RVD_Result MDrv_RVD_SetCmd(RVD_User_Cmd u32Command,MS_U32 u32Argument);
615 extern RVD_Result MDrv_RVD_SetSpeed(RVD_Disp_Speed u32DispSpeed);
616 extern MS_BOOL MDrv_RVD_IsDbgEnable(MS_U8 u8DbgLevel);
617 extern MS_U8 MDrv_RVD_GetDbgLevel(void);
618 extern void MDrv_RVD_SetDbgLevel(MS_U8 u8DbgLevel);
619 extern RVD_Result MDrv_RVD_SetCfg( RVD_MEMCfg* memCfg);
620 extern void MDrv_RVD_SetOSRegBase(MS_U32 u32RegBaseAddr );
621 extern MS_U32 MDrv_RVD_GetFrameCnt(void);
622 extern MS_U32 MDrv_RVD_GetESWritePtr(void);
623 extern MS_BOOL MDrv_RVD_CheckDispInfoRdy(void);
624 extern MS_BOOL MDrv_RVD_CheckCaps(void);
625 extern MS_BOOL MDrv_RVD_IsTSPlaying(void);
626 extern void MDrv_RVD_SetTrickMode(RVD_TrickMode u32TrickMode);
627 extern RVD_Result MDrv_RVD_Play(void);
628 extern RVD_Result MDrv_RVD_AVSyncOn(MS_BOOL  bEnable,MS_U16 u16SyncDelay, MS_U16 u16SyncTolerance);
629 extern MS_BOOL MDrv_RVD_IsAVSyncOn(void);
630 extern RVD_Result MDrv_RVD_Pause(void);
631 extern RVD_Result MDrv_RVD_Exit(void);
632 extern RVD_Result MDrv_RVD_Resume(void);
633 extern RVD_Result MDrv_RVD_EnableLastFrameShowed(MS_BOOL bEnabled);
634 extern RVD_Result MDrv_RVD_StepPlay(void);
635 extern MS_BOOL MDrv_RVD_IsStepPlayDone(void);
636 extern MS_BOOL MDrv_RVD_IsIdle(void);
637 extern MS_BOOL MDrv_RVD_IsDispFinish(void);
638 extern MS_BOOL MDrv_RVD_IsIFrameFound(void);
639 extern MS_U32 MDrv_RVD_GetErrCode(void);
640 extern RVD_Result MDrv_RVD_DbgGetData(MS_U32 u32Addr , MS_U32 *u32Data);
641 extern RVD_Result MDrv_RVD_GetLibVer(const MSIF_Version **ppVersion);
642 extern MS_BOOL MDrv_RVD_DispSetupDone(void);
643 extern RVD_Result  MDrv_RVD_GetDispInfo(RVD_FrameInfo *pinfo);
644 extern MS_BOOL MDrv_RVD_GetStatus( RVD_DrvStatus *pstatus);
645 extern void MDrv_RVD_SetBBU_ID(MS_U32 u32Address,MS_U32 u32Byte_Pos,MS_U32 u32ID_High, MS_U32 u32ID_Low);
646 const RVD_DrvInfo* MDrv_RVD_GetInfo( void );
647 extern MS_U32 MDrv_RVD_GetIDReadPtr(void);
648 extern MS_U32 MDrv_RVD_GetIDWritePtr(void);
649 extern void MDrv_RVD_SetIDWritePtr(MS_U32 u32Wptr);
650 extern void MDrv_RVD_SetIDReadPtr(MS_U32 u32Wptr);
651 extern RVD_Result MDrv_RVD_GetFrameInfo(RVD_FrameBuff_Info *framebuffinfo ,MS_BOOL bGETDISP);
652 extern MS_BOOL MDrv_RVD_SetForceISR(MS_BOOL bEnable);
653 extern MS_BOOL MDrv_RVD_GetISRInfo( RVD_ISR_Event* eType );
654 extern MS_BOOL MDrv_RVD_SetEnableISR(MS_BOOL bEnable);
655 extern RVD_Result MDrv_RVD_SetISREvent(RVD_ISR_Event eEvent ,RVD_InterruptCb fnISRHandler );
656 extern RVD_Result MDrv_RVD_SetDispRepeatCnt(MS_U32 u32Num);
657 //extern void MDrv_RVD_ResetSTCBase(MS_U32 u32time_ms);
658 extern RVD_Result MDrv_RVD_JumpToPTS(MS_U32 u32time_ms);
659 extern RVD_Result MDrv_RVD_SkipToPTS(MS_U32 u32time_ms);
660 extern MS_U32 MDrv_RVD_GetTrickMode(void);
661 extern MS_BOOL MDrv_RVD_IsStepDecodeDone(void);
662 extern RVD_Result MDrv_RVD_StepDecode(void);
663 extern RVD_Result MDrv_RVD_Rst(void );
664 extern RVD_Result MDrv_RVD_SetFreezeImg(MS_BOOL bEnabled);
665 extern RVD_Result MDrv_RVD_SetBlueScreen(MS_BOOL bEnabled);
666 extern RVD_Result MDrv_RVD_FireDecCmd(void);
667 extern MS_BOOL MDrv_RVD_Is1stFrameRdy(void);
668 extern MS_U32 MDrv_RVD_GetDecErrCnt(void);
669 extern MS_U32 MDrv_RVD_GetDataErrCnt(void);
670 extern MS_U32 MDrv_RVD_GetSkipCnt(void);
671 extern MS_U32 MDrv_RVD_GetDropCnt(void);
672 extern MS_U32 MDrv_RVD_GetDispQueNum(void);
673 extern RVD_Result MDrv_RVD_DbgSetCmd(RVD_User_Cmd u32Command,MS_U32 u32Argument);
674 extern void MDrv_RVD_DbgSetData(MS_U32 u32Addr,MS_U32 data);
675 extern void MDrv_RVD_Dump_Status(void);
676 #if 0
677 #if defined(REDLION_LINUX_KERNEL_ENVI)
678 extern MS_S32 _DRV_RVD_ISRHandler(void);
679 #else
680 extern void _DRV_RVD_ISRHandler(void);
681 #endif
682 #endif
683 
684 extern void MDrv_RVD_EnableTurboFWMode(MS_BOOL bEnable);
685 
686 extern RVD_Result MDrv_RVD_SetAVSyncFreerunThreshold(MS_U32 u32Th);
687 
688 #ifdef __cplusplus
689 }
690 #endif
691 
692 #endif // _DRV_RVD_H_
693 
694 
695