xref: /utopia/UTPA2-700.0.x/modules/dmx/drv/tso/drvTSO.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) 2011-2013 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    drvTSO.h
98 /// @brief  TS I/O Driver Interface
99 /// @author MStar Semiconductor,Inc.
100 /// @attention
101 /// All TSO DDI are not allowed to use in any interrupt context other than TSO ISR and Callback
102 ///////////////////////////////////////////////////////////////////////////////////////////////////
103 
104 #ifndef _DRV_TSO_H_
105 #define _DRV_TSO_H_
106 
107 
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 DRVTSO_ALIGN_UNIT           16
121 
122 /// TSP byte address alignment macro
123 #define DRVTSO_ALIGN(_x)            ALIGN_16((MS_U32)_x)
124 
125 //-------------------------------------------------------------------------------------------------
126 //  Macro and Define
127 //-------------------------------------------------------------------------------------------------
128 /// Transport stream null PID
129 #define DRVTSO_PID_NULL             0x1FFF
130 
131 #define MSIF_TSO_LIB_CODE           {'T','S','O'}                                               // Lib code
132 #define MSIF_TSO_LIBVER             {'0','2'}                                                   // LIB version
133 #define MSIF_TSO_BUILDNUM           {'0','0'}                                                   // Build Number
134 #define MSIF_TSO_CHANGELIST         {'0','0','5','1','1','4','7','0'}                           // P4 ChangeList Number
135 
136 #define TSO_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_TSO_LIB_CODE,              /* IP__                                             */  \
144     MSIF_TSO_LIBVER,                /* 0.0 ~ Z.Z                                        */  \
145     MSIF_TSO_BUILDNUM,              /* 00 ~ 99                                          */  \
146     MSIF_TSO_CHANGELIST,            /* CL#                                              */  \
147     MSIF_OS
148 
149 
150 //-------------------------------------------------------------------------------------------------
151 //  Type and Structure
152 //-------------------------------------------------------------------------------------------------
153 /// TSO DDI return value
154 
155 /// @name TSO_Result
156 /// @ref TSO_Result
157 /// return value
158 /// @{
159 typedef enum
160 {
161     DRVTSO_FAIL                      = 0,
162     DRVTSO_OK                        = 1,
163     DRVTSO_INVALID_PARAM             = 2,
164     DRVTSO_FUNC_ERROR                = 3,
165 }TSO_Result;
166 /// @}
167 
168 typedef enum //_DrvTSO_DbgLevel
169 {
170     E_DRVTSO_DBG_Release = 0,
171     E_DRVTSO_DBG_ERR, // display error msg
172     E_DRVTSO_DBG_INFO,
173 } DrvTSO_DbgLevel;
174 
175 typedef enum
176 {
177     E_DRVTSO_CAP_FILTER_NUM = 0,                 // Get filter number
178     E_DRVTSO_CAP_RESOURCE_SIZE          = 1,                     // Get the data structure size of private resource (share resource)
179     E_DRVTSO_CAP_ENGINE_NUM             = 2,                     // Get TSO engine number
180     E_DRVTSO_CAP_ENGINE_TSIF_NUM        = 3,                     // Get TSO interface number of every engine
181 
182     E_DRVTSO_CAP_NULL,
183 } DrvTSO_Cap;
184 
185 typedef enum
186 {
187     /// Command Queue is Idle
188     E_DRVTSO_STATE_IDLE        = 0x00,
189     /// Command Queue is Busy
190     E_DRVTSO_STATE_BUSY        = 0x01,
191 
192     E_DRVTSO_STATE_UNKNOWN     = 0xFF,
193 } DrvTSO_FileinState;
194 
195 typedef enum
196 {
197     E_DRVTSO_STATUS_UNKNOWN         = 0,
198     E_DRVTSO_STATUS_FILEINDONE      = 0x01,    //bit 0
199     E_DRVTSO_STATUS_PKTERR          = 0x02,    //bit 1
200 } DrvTSO_Status;
201 
202 typedef enum
203 {
204     E_DRVTSO_CTRL_MODE_TS0,
205     E_DRVTSO_CTRL_MODE_TS1,
206     E_DRVTSO_CTRL_MODE_TS2,
207     E_DRVTSO_CTRL_MODE_TS3,
208     E_DRVTSO_CTRL_MODE_TSCB,
209     E_DRVTSO_CTRL_MODE_DEMOD0,
210     E_DRVTSO_CTRL_MODE_DEMOD1,
211     E_DRVTSO_CTRL_MODE_MEM,
212     E_DRVTSO_CTRL_MODE_MEM1,
213     E_DRVTSO_CTRL_MODE_INVALID
214 } DrvTSO_CtrlMode;
215 
216 /// TSP file in Packet mode
217 typedef enum //_DrvTSO_PacketMode
218 {
219     E_DRVTSO_PKTMODE_188              = 0x00000000,
220     E_DRVTSO_PKTMODE_192              = 0x00000001,
221     E_DRVTSO_PKTMODE_204              = 0x00000002,
222 } DrvTSO_PacketMode;
223 
224 typedef enum
225 {
226     E_DRVTSO_OUTCLK_DIV2N,
227     E_DRVTSO_OUTCLK_DIVN,
228     E_DRVTSO_OUTCLK_62M,
229     E_DRVTSO_OUTCLK_54M,
230     E_DRVTSO_OUTCLK_PTSOOUT,
231     E_DRVTSO_OUTCLK_PTSOOUT_DIV8,
232     E_DRVTSO_OUTCLK_Dmd,
233 }DrvTSO_OutClk;
234 
235 typedef enum
236 {
237     E_DRVTSO_OUTCLKSRC_172M_2N,
238     E_DRVTSO_OUTCLKSRC_288M_2N,
239     E_DRVTSO_OUTCLKSRC_432M_2N,
240     E_DRVTSO_OUTCLKSRC_216M_N,
241     E_DRVTSO_OUTCLKSRC_P_TS0IN,
242     E_DRVTSO_OUTCLKSRC_P_TS1IN,
243     E_DRVTSO_OUTCLKSRC_P_TS2IN,
244 }DrvTSO_OutClkSrc;
245 
246 /// TSO input pad selection
247 typedef enum
248 {
249     E_DRVTSO_PAD_EXT_INPUT0           = 0x00,
250     E_DRVTSO_PAD_EXT_INPUT1           = 0x01,
251     E_DRVTSO_PAD_EXT_INPUT2           = 0x02,
252     E_DRVTSO_PAD_EXT_INPUT3           = 0x03,
253     E_DRVTSO_PAD_EXT_INPUT4           = 0x04,
254     E_DRVTSO_PAD_EXT_INPUT5           = 0x05,
255     E_DRVTSO_PAD_DEMOD                = 0x07,
256 
257     E_DRVTSO_MEM                      = 0x80,
258 } DrvTSO_PadIn;
259 
260 typedef struct
261 {
262     DrvTSO_PadIn        ePad;
263     MS_BOOL             bClkInv;
264     MS_BOOL             bExtSync;
265     MS_BOOL             bParallel;
266 } DrvTSO_If_Set;
267 
268 TSO_Result MDrv_TSO_InitLibResource(void* pResMemAddr);
269 TSO_Result MDrv_TSO_Init(void);
270 TSO_Result MDrv_TSO_Exit(void);
271 TSO_Result MDrv_TSO_SetDbgLevel(DrvTSO_DbgLevel DbgLevel);
272 TSO_Result MDrv_TSO_Get_HWIntStatus(MS_U8 u8Eng, MS_U16* pu16status);
273 TSO_Result MDrv_TSO_SetOperateMode(MS_U8 u8Eng, DrvTSO_CtrlMode TSOCtrlMode, MS_BOOL bClkInv, MS_BOOL bParallel);
274 TSO_Result MDrv_TSO_Filein_Rate(MS_U8 u8Eng, MS_U16 u16timer);
275 TSO_Result MDrv_TSO_SetOutClk(MS_U8 u8Eng, DrvTSO_OutClk eOutClk, DrvTSO_OutClkSrc eOutClkSrc, MS_U16 u16DivNum, MS_BOOL bClkInv);
276 
277 
278 // PIDFlt API
279 TSO_Result MDrv_TSO_PidFlt_Alloc(MS_U8 u8Eng, MS_U8 *pu8PidFltId);
280 TSO_Result MDrv_TSO_PidFlt_Free(MS_U8 u8Eng, MS_U8 u8PidFltId);
281 TSO_Result MDrv_TSO_PidFlt_SetPid(MS_U8 u8Eng, MS_U8 u8PidFltId, MS_U16 u16Pid);
282 
283 TSO_Result MDrv_TSO_Filein_CmdQ_Reset(MS_U8 u8Eng);
284 TSO_Result MDrv_TSO_Filein_CmdQFifo_Status(MS_U8 u8Eng, MS_U8 *pu8FifoLevel);
285 TSO_Result MDrv_TSO_Filein_CmdQ_GetSlot(MS_U8 u8Eng, MS_U32 *pu32EmptySlot);
286 
287 TSO_Result MDrv_TSO_SetPlaybackTimeStamp(MS_U8 u8Eng, MS_U32 u32timestamp);
288 TSO_Result MDrv_TSO_GetPlaybackTimeStamp(MS_U8 u8Eng, MS_U32 *pu32timestamp);
289 
290 TSO_Result MDrv_TSO_GetFileInTimeStamp(MS_U8 u8Eng, MS_U32* pu32Timestamp);
291 TSO_Result MDrv_TSO_Filein_GetReadAddr(MS_U8 u8Eng, MS_PHY *pu32ReadAddr);
292 TSO_Result MDrv_TSO_Filein_SetAddr(MS_U8 u8Eng, MS_PHY u32StreamAddr);
293 TSO_Result MDrv_TSO_Filein_SetSize(MS_U8 u8Eng, MS_U32 u32StreamSize);
294 TSO_Result MDrv_TSO_SetPacketMode(MS_U8 u8Eng, DrvTSO_PacketMode ePktMode);
295 TSO_Result MDrv_TSO_SetPacketSize(MS_U8 u8Eng, MS_BOOL bFileinMode, MS_U16 u16InPktSize, MS_U16 u16OutPktSize);
296 TSO_Result MDrv_TSO_Filein_192Mode_En(MS_U8 u8Eng, MS_BOOL bEnable);
297 TSO_Result MDrv_TSO_Filein_192BlockScheme_En(MS_U8 u8Eng, MS_BOOL bEnable);
298 
299 TSO_Result MDrv_TSO_TEI_SkipPkt(MS_U8 u8Eng, MS_BOOL bEnable);
300 TSO_Result MDrv_TSO_Clr_Pidflt_ByteCnt(MS_U8 u8Eng);
301 TSO_Result MDrv_TSO_GetCap(DrvTSO_Cap eCap, void* pOutput);
302 TSO_Result MDrv_TSO_Filein_GetState(MS_U8 u8Eng, DrvTSO_FileinState *peFileinState);
303 TSO_Result MDrv_TSO_Filein_ChkStatus(MS_U8 u8Eng, DrvTSO_Status* pStatus);
304 TSO_Result MDrv_TSO_Filein_ClearHWInt(MS_U8 u8Eng, MS_U16 u16int);
305 
306 TSO_Result MDrv_TSO_Filein_Start(MS_U8 u8Eng);
307 TSO_Result MDrv_TSO_Filein_Stop(MS_U8 u8Eng);
308 TSO_Result MDrv_TSO_Filein_Abort(MS_U8 u8Eng);
309 
310 TSO_Result MDrv_TSO_ResetAll(MS_U8 u8Eng);
311 TSO_Result MDrv_TSO_SelPad(MS_U8 u8Eng, DrvTSO_If_Set* pIfSet);
312 
313 TSO_Result MDrv_TSO_OutputEnable(MS_U8 u8Eng, MS_BOOL bEnable);
314 
315 
316 #ifdef __cplusplus
317 } // closing brace for extern "C"
318 #endif
319 
320 #endif // _DRV_TSO_H_
321 
322 
323