xref: /utopia/UTPA2-700.0.x/modules/dmx/drv/mmfi/drvMMFilein.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    drvMMFilein.h
98 /// @brief  Multimedia File In (MMFILEIN) Driver Interface
99 /// @author MStar Semiconductor,Inc.
100 /// @attention
101 /// All MMFILEIN DDI are not allowed to use in any interrupt context other than MMFILEIN ISR and Callback
102 ///////////////////////////////////////////////////////////////////////////////////////////////////
103 
104 #ifndef _DRV_MMFILEIN_H_
105 #define _DRV_MMFILEIN_H_
106 
107 #include "MsTypes.h"
108 
109 #ifdef __cplusplus
110 extern "C"
111 {
112 #endif
113 
114 
115 //-------------------------------------------------------------------------------------------------
116 //  Driver Capability
117 //-------------------------------------------------------------------------------------------------
118 
119 /// TSP byte address alignment unit
120 #define DRVMMFI_ALIGN_UNIT           16UL
121 
122 /// TSP byte address alignment macro
123 #define DRVMMFI_ALIGN(_x)            ALIGN_16((MS_U32)_x)
124 
125 
126 //-------------------------------------------------------------------------------------------------
127 //  Macro and Define
128 //-------------------------------------------------------------------------------------------------
129 /// Transport stream null PID
130 #define DRVMMFI_PID_NULL             0x1FFFUL
131 #define MSIF_MMFI_LIB_CODE           {'M','M','F','I'}                                               // Lib code
132 #define MSIF_MMFI_LIBVER             {'0','3'}                                                       // LIB version
133 #define MSIF_MMFI_BUILDNUM           {'0','0'}                                                       // Build Number
134 #define MSIF_MMFI_CHANGELIST         {'0','0','6','0','7','2','6','6'}                               // P4 ChangeList Number
135 
136 #define MMFI_DRV_VERSION             /* Character String for DRV/API version             */  \
137     MSIF_TAG,                       /* 'MSIF'                                           */  \
138     MSIF_CLASS,                     /* '00'                                             */  \
139     MSIF_CUS,                       /* 0x0000                                           */  \
140     MSIF_MOD,                       /* 0x0000                                           */  \
141     MSIF_CHIP,                                                                              \
142     MSIF_CPU,                                                                               \
143     MSIF_MMFI_LIB_CODE,              /* IP__                                             */  \
144     MSIF_MMFI_LIBVER,                /* 0.0 ~ Z.Z                                        */  \
145     MSIF_MMFI_BUILDNUM,              /* 00 ~ 99                                          */  \
146     MSIF_MMFI_CHANGELIST,            /* CL#                                              */  \
147     MSIF_OS
148 
149 
150 //-------------------------------------------------------------------------------------------------
151 //  Type and Structure
152 //-------------------------------------------------------------------------------------------------
153 /// MMFILEIN DDI return value
154 
155 /// @name MMFI_Result
156 /// @ref MMFI_Result
157 /// return value
158 /// @{
159 typedef enum
160 {
161     DRVMMFI_FAIL                     = 0UL,
162     DRVMMFI_OK                       = 1UL,
163     DRVMMFI_INVALID_PARAM            = 2UL,
164     DRVMMFI_FUNC_ERROR               = 3UL,
165 } MMFI_Result;
166 /// @}
167 
168 typedef enum
169 {
170     E_DRVMMFI_PTH_AUDIO   = 0x00UL,
171     E_DRVMMFI_PATH_VD3D   = 0x01UL,
172 
173 }DrvMMFI_Path;
174 
175 typedef enum
176 {
177     E_DRVMMFI_MODE_NO_BYPASS_AU     = 0x0000UL,
178 
179     E_DRVMMFI_MODE_PS_AU            = 0x0001UL,
180 
181     E_DRVMMFI_MODE_PS_AUB           = 0x0002UL,
182 
183     E_DRVMMFI_MODE_APID_BYPASS      = 0x0004UL,
184 
185     E_DRVMMFI_MODE_APIDB_BYPASS     = 0x0008UL,
186 
187     E_DRVMMFI_MODE_NO_BYPASS_V3D    = 0x0010UL,
188     E_DRVMMFI_MODE_PS_V3D           = 0x0020UL,
189     E_DRVMMFI_MODE_V3DPID_BYPASS    = 0x0040UL,
190 
191     E_DRVMMFI_MODE_NO_BYPASS_VD     = 0x0080UL,
192     E_DRVMMFI_MODE_VPID_BYPASS      = 0x0100UL,
193     E_DRVMMFI_MODE_NO_BYPASS_TS     = 0x0200UL,
194 
195     E_DRVMMFI_MODE_APIDC_BYPASS     = 0x2000UL,
196     E_DRVMMFI_MODE_APIDD_BYPASS     = 0x4000UL,
197 
198     E_DRVMMFI_MODE_MMFI1_MASK       = 0x8000UL,   //must set, when using MMFI1 path
199 } DrvMMFI_FileinMode;
200 
201 typedef enum
202 {
203     /// Command Queue is Idle
204     E_DRVMMFI_STATE_IDLE        = 0x00UL,
205     /// Command Queue is Busy
206     E_DRVMMFI_STATE_BUSY        = 0x01UL,
207 
208     E_DRVMMFI_STATE_UNKNOWN     = 0xFFUL,
209 } DrvMMFI_FileinState;
210 
211 typedef enum
212 {
213     E_DRVMMFI_STATUS_UNKNOWN            = 0UL,
214     E_DRVMMFI_STATUS_AU_FILEINDONE      = 0x01UL,    //bit 0
215     E_DRVMMFI_STATUS_AU_PKTERR          = 0x02UL,    //bit 1
216     E_DRVMMFI_STATUS_VD_FILEINDONE      = 0x04UL,    //bit 2
217     E_DRVMMFI_STATUS_VD_PKTERR          = 0x08UL,    //bit 3
218 } DrvMMFI_Status;
219 
220 
221 /// MMFI file in Packet mode
222 typedef enum //_DrvMMFI_PacketMode
223 {
224     E_DRVMMFI_PKTMODE_188              = 0x0000UL,
225     E_DRVMMFI_PKTMODE_192              = 0x0001UL,
226     E_DRVMMFI_PKTMODE_204              = 0x0002UL,
227 } DrvMMFI_PacketMode;
228 
229 /// TSP TS Input Source
230 typedef enum
231 {
232     E_DRVMMFI_FLTTYPE_NONE = 0UL,
233     E_DRVMMFI_FLTTYPE_AUD  = 1UL,
234     E_DRVMMFI_FLTTYPE_AUDB = 2UL,
235     E_DRVMMFI_FLTTYPE_VD3D = 3UL,
236 } DrvMMFI_FltType;
237 
238 typedef enum //_DrvMMFI_DbgLevel
239 {
240     E_DRVMMFI_DBG_Release = 0UL,
241     E_DRVMMFI_DBG_ERR, // display error msg
242     E_DRVMMFI_DBG_INFO,
243 } DrvMMFI_DbgLevel;
244 
245 typedef enum
246 {
247     E_DRVMMFI_CAP_FILTER_AU_NUM = 0UL,                // Get filter number
248     E_DRVMMFI_CAP_FILTER_VD_NUM,                    // Get pvr filter number
249     E_DRVMMFI_CAP_FILTER_ALL_NUM,
250 
251     E_DRVMMFI_CAP_RESOURCE_SIZE,                    // Get the data structure size of private resource (share resource)
252 
253     E_DRVMMFI_CAP_NULL,
254 } DrvMMFI_Cap;
255 
256 
257 typedef struct _DrvPIDFLT_HEADER
258 {
259     MS_U32      CCounter        : 4;
260     MS_U32      Adp_Ctrl        : 2;
261     MS_U32      Scramble        : 2;
262     MS_U32      PID             : 13;
263     MS_U32      TS_Priority     : 1;
264     MS_U32      Payload_Start   : 1;
265     MS_U32      Err_Flag        : 1;
266     MS_U32      reserved        : 8;
267 }DrvPIDFLT_HEADER;
268 
269 //-------------------------------------------------------------------------------------------------
270 //  Function and Variable
271 //-------------------------------------------------------------------------------------------------
272 MMFI_Result MDrv_MMFI_InitLibResource(void* pResMemAddr);
273 MMFI_Result MDrv_MMFI_Init(void);
274 MMFI_Result MDrv_MMFI_Exit(void);
275 MMFI_Result MDrv_MMFI_Get_HWIntStatus(MS_U32* pu32status);
276 MMFI_Result MDrv_MMFI_SetDbgLevel(DrvMMFI_DbgLevel DbgLevel);
277 MMFI_Result MDrv_MMFI_AudPath_Enable(MS_BOOL bEnable);
278 MMFI_Result MDrv_MMFI_File_SetTimer(DrvMMFI_Path epath, MS_U8 u8timer);
279 MMFI_Result MDrv_MMFI_File_ByteTimer_En(DrvMMFI_Path epath, MS_BOOL bEnable);
280 
281 // PIDFlt API
282 MMFI_Result MDrv_MMFI_PidFlt_Alloc(DrvMMFI_FltType eFilterType, MS_U8 *pu8PidFltId);
283 MMFI_Result MDrv_MMFI_PidFlt_Free(MS_U8 u8PidFltId);
284 MMFI_Result MDrv_MMFI_PidFlt_Enable(MS_U8 u8PidFltId, MS_BOOL bEnable);
285 MMFI_Result MDrv_MMFI_PidFlt_SetPid(MS_U8 u8PidFltId, MS_U16 u16Pid);
286 
287 MMFI_Result MDrv_MMFI_File_CmdQ_Reset(DrvMMFI_Path epath);
288 MMFI_Result MDrv_MMFI_File_CmdQFifo_Status(DrvMMFI_Path epath, MS_U8 *pu8FifoLevel);
289 MMFI_Result MDrv_MMFI_File_CmdQ_GetSlot(DrvMMFI_Path epath, MS_U32 *pu32EmptySlot);
290 
291 MMFI_Result MDrv_MMFI_SetPlaybackTimeStamp(DrvMMFI_Path epath, MS_U32 u32lpcr2);
292 MMFI_Result MDrv_MMFI_GetPlaybackTimeStamp(DrvMMFI_Path epath, MS_U32 *pu32lpcr2);
293 MMFI_Result MDrv_MMFI_GetFileInTimeStamp(DrvMMFI_Path epath, MS_U32* pu32TSLen);
294 
295 MMFI_Result MDrv_MMFI_File_SetAddr(DrvMMFI_Path epath, MS_PHY phyStreamAddr);
296 MMFI_Result MDrv_MMFI_File_SetSize(DrvMMFI_Path epath, MS_U32 u32StreamSize);
297 MMFI_Result MDrv_MMFI_File_SetPacketMode(DrvMMFI_Path epath, DrvMMFI_PacketMode PacketMode);
298 MMFI_Result MDrv_MMFI_File_192Mode_En(DrvMMFI_Path epath, MS_BOOL bEnable);
299 MMFI_Result MDrv_MMFI_File_192BlockScheme_En(DrvMMFI_Path epath, MS_BOOL bEnable);
300 MMFI_Result MDrv_MMFI_File_SetPacketMode(DrvMMFI_Path epath, DrvMMFI_PacketMode PacketMode);
301 MMFI_Result MDrv_MMFI_File_SetTimeStampClk(DrvMMFI_Path ePath, MS_U32 u32ClkSrc);
302 
303 MMFI_Result MDrv_MMFI_DupPktSkip(DrvMMFI_Path epath, MS_BOOL bEnable);
304 MMFI_Result MDrv_MMFI_TEI_SkipPktf(DrvMMFI_Path epath, MS_BOOL bEnable);
305 MMFI_Result MDrv_MMFI_Clr_Pidflt_ByteCnt(DrvMMFI_Path epath);
306 MMFI_Result MDrv_MMFI_TSDataEndian_Swap(DrvMMFI_Path epath, MS_BOOL bEnable);
307 MMFI_Result MDrv_MMFI_TSOrder_Swap(DrvMMFI_Path epath, MS_BOOL bEnable);
308 
309 MMFI_Result MDrv_MMFI_File_GetState(DrvMMFI_Path epath, DrvMMFI_FileinState *peFileinState);
310 MMFI_Result MDrv_MMFI_File_ChkStatus(DrvMMFI_Status* pStatus);
311 MMFI_Result MDrv_MMFI_File_ClearHWInt(MS_U32 u32int);
312 MMFI_Result MDrv_MMFI_Get_TsHeader(DrvMMFI_Path epath, DrvPIDFLT_HEADER *pheader);
313 
314 MMFI_Result MDrv_MMFI_File_Start(DrvMMFI_Path epath);
315 MMFI_Result MDrv_MMFI_File_Abort(DrvMMFI_Path epath);
316 MMFI_Result MDrv_MMFI_File_ModeEnable(DrvMMFI_FileinMode fileinmode, MS_BOOL bEnable);
317 
318 MMFI_Result MDrv_MMFI_ResetAll(void);
319 MMFI_Result MDrv_MMFI_GetCap(DrvMMFI_Cap eCap, void* pOutput);
320 MMFI_Result MDrv_MMFI_RemoveDupAVPkt(MS_BOOL bEnable);
321 
322 MMFI_Result MDrv_MMFI_VD3DPath_Enable(MS_BOOL bEnable);
323 
324 MMFI_Result MDrv_MMFI_Set_MOBF_FileinKey(DrvMMFI_Path epath, MS_U32 u32Key);
325 MMFI_Result MDrv_MMFI_MOBF_FileIn_Enable(DrvMMFI_Path epath, MS_BOOL benable);
326 MMFI_Result MDrv_MMFI_MOBF_FileIn_SetLevel(DrvMMFI_Path epath, MS_U8 u8level);
327 
328 
329 #ifdef __cplusplus
330 } // closing brace for extern "C"
331 #endif
332 
333 #endif // _DRV_MMFILEIN_H_
334