xref: /utopia/UTPA2-700.0.x/mxlib/include/apiDMX_tsio.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   apiDMX_tsio.h
98 /// @brief  TSIO API
99 /// @author MStar Semiconductor,Inc.
100 ////////////////////////////////////////////////////////////////////////////////////////////////////
101 
102 #ifndef __API_DMX_TSIO_H__
103 #define __API_DMX_TSIO_H__
104 
105 #include "MsCommon.h"
106 
107 #ifdef __cplusplus
108 extern "C"
109 {
110 #endif
111 
112 
113 typedef enum
114 {
115     TSIO_CC_RESULT_OK,
116     TSIO_CC_RESULT_NORESULT,
117     TSIO_CC_RESULT_TXCMD_TOOSMALL,
118     TSIO_CC_RESULT_TXCMD_TOOBIG,
119     TSIO_CC_RESULT_TXCMD_TIMEOUT,
120     TSIO_CC_RESULT_RXCMD_TOOSMALL,
121     TSIO_CC_RESULT_RXCMD_TOOBIG,
122     TSIO_CC_RESULT_RXCMD_TIMEOUT,
123     TSIO_CC_RESULT_ERR_FLAG,
124     TSIO_CC_RESULT_ERROR,
125 }TSIO_CC_RESULT;
126 
127 typedef enum
128 {
129     TSIO_CLK_200M = 0,
130     TSIO_CLK_100M,
131     TSIO_CLK_50M,
132     TSIO_CLK_25M,
133 }TSIO_CLK;
134 
135 typedef enum
136 {
137     TSIO_CMD_BYPASSSMC,         //bypass SMC setting, 0: disable, 1: direct8, 2: direct 16, 3: loopback.
138     TSIO_CMD_STUFFINGSID,       //stuffing id (from 0 ~ 0x3F)
139     TSIO_CMD_LOCDECRYPT,        //1: enable loc decrypt, 0: disable
140     TSIO_CMD_SYNCTHRESHOLD,     //sync threshold (3 ~ 8)
141     TSIO_CMD_DBGLEVEL,          //3: trace, 2: info, 1: error, 0: release
142 
143 
144     TSIO_CMD_PHASE_ADJUST,      //kastor U01 use
145     TSIO_CMD_BITTRAINING_ADJUST,//kastor U01 use
146 }TSIO_CMD;
147 
148 typedef enum
149 {
150     TSIO_INT_TYPE_NONE = 0,
151     TSIO_INT_TYPE_SGDMAOUT_LASTNODE,
152     TSIO_INT_TYPE_SGDMAOUT_NODEINT,
153     TSIO_INT_TYPE_SGDMAOUT_DROP,
154     TSIO_INT_TYPE_SGDMAOUT_DMAEND,
155     TSIO_INT_TYPE_SGDMAIN_DONE,
156     TSIO_INT_TYPE_CC_TX_DONE,
157     TSIO_INT_TYPE_CC_RX_DONE,
158     TSIO_INT_TYPE_LIVE_TSO_OVERFLOW,
159     TSIO_INT_TYPE_OPERATION_START,
160 }TSIO_INT_TYPE;
161 
162 typedef enum
163 {
164     TSIO_INFO_LOSELOCKCNT = 0,      //lose locked count
165     TSIO_INFO_USEBUFLEN = 1,        //get use buffer size, arg is service handleid from 0 to 63
166 }TSIO_INFO;
167 
168 typedef struct
169 {
170     MS_PHY phyLastpktBufAddr; // 192 bytes (pkt size) x 64 (service num)
171     MS_U32 u32LastpktBufSize;
172     MS_PHY phyDMAVQBufAddr;
173     MS_U32 u32DMAVQBufSize;
174     MS_PHY phyDMAinNodeAddr; // 1 node need 16 bytes.
175     MS_U32 u32DMAinNodeSize;
176     MS_PHY phyDMAoutNodeAddr; // 1 node need 16 bytes.
177     MS_U32 u32DMAoutNodeSize;
178 }TSIO_Init_Set;
179 
180 typedef struct
181 {
182     MS_U8* pIn;
183     MS_U16 u16InLen;
184     MS_U8* pOut;
185     MS_U16* pOutLen;
186     MS_U32 u32Timeout;
187 }TSIO_CC_Set;
188 
189 typedef enum
190 {
191     E_TSIO_SERVICEDEST_LIVE = 0,
192     E_TSIO_SERVICEDEST_DMA,
193 }TSIO_SERVICEDEST;
194 
195 typedef struct
196 {
197     MS_PHY phyBufAddr;
198     MS_U32 u32BufSize;
199     MS_BOOL bTSmode;
200     MS_BOOL bMidPriority;
201     MS_BOOL bLastNodeFlush;
202     MS_BOOL bNewPkt;
203     MS_BOOL bBypassAll;
204 }TSIO_DMAIN_SET;
205 
206 typedef struct
207 {
208     MS_PHY phyBufAddr;
209     MS_U32 u32BufSize;
210     MS_BOOL bSecurity;
211 }TSIO_DMAOUT_SET;
212 
213 typedef struct
214 {
215     MS_BOOL bEnable;
216     MS_BOOL bEvenkeyenable;
217     MS_U8 *u8Evenkey;
218     MS_U16 u16Evenkeylen;
219     MS_BOOL bOddkeyenable;
220     MS_U8 *u8Oddkey;
221     MS_U16 u16Oddkeylen;
222 }TSIO_LOCKEY_SET;
223 
224 typedef void(*TSIOIntTypeCB)(TSIO_INT_TYPE eType, MS_U32 u32Info, void *ext1, void *ext2);
225 
226 ////////////////////////////////////////////////////////////////////////////////
227 // include utopia v2  header files here
228 ////////////////////////////////////////////////////////////////////////////////
229 #ifdef DMX_UTOPIA_20
230 #include "apiDMX_tsio_v2.h"
231 #endif
232 
233 //-------------------------------------------------------------------------------------------------
234 /// Register TSIO callback function
235 /// @param TSIOIntTypeCB                                  \b IN: Callback function pointer
236 /// @return DMX_FILTER_STATUS
237 /// @note
238 //-------------------------------------------------------------------------------------------------
239 DMX_FILTER_STATUS SYMBOL_WEAK MApi_DMX_TSIO_RegisterIntCb(TSIOIntTypeCB efn);
240 
241 //-------------------------------------------------------------------------------------------------
242 /// Init TSIO
243 /// @param eParm                         \b IN: init param
244 /// @return DMX_FILTER_STATUS
245 /// @note
246 /// It should be called before calling any TSIO API.
247 //-------------------------------------------------------------------------------------------------
248 DMX_FILTER_STATUS SYMBOL_WEAK MApi_DMX_TSIO_Init(TSIO_Init_Set *eParm);
249 
250 //-------------------------------------------------------------------------------------------------
251 /// Open TSIO
252 /// @param eClk                         \b IN: smc clk speed
253 /// @return DMX_FILTER_STATUS
254 /// @note
255 //-------------------------------------------------------------------------------------------------
256 DMX_FILTER_STATUS SYMBOL_WEAK MApi_DMX_TSIO_Open(TSIO_CLK eClk);
257 
258 //-------------------------------------------------------------------------------------------------
259 /// Exit TSIO
260 /// @return DMX_FILTER_STATUS
261 /// @note
262 //-------------------------------------------------------------------------------------------------
263 DMX_FILTER_STATUS SYMBOL_WEAK MApi_DMX_TSIO_Exit(void);
264 
265 //-------------------------------------------------------------------------------------------------
266 /// Close TSIO
267 /// @return DMX_FILTER_STATUS
268 /// @note
269 //-------------------------------------------------------------------------------------------------
270 DMX_FILTER_STATUS SYMBOL_WEAK MApi_DMX_TSIO_Close(void);
271 
272 //-------------------------------------------------------------------------------------------------
273 /// Send ctrl command to TSIO
274 /// @param eCmd                                     \b IN: Command
275 /// @param u32Value                                \b IN: Commnad's param
276 /// @return DMX_FILTER_STATUS
277 /// @note
278 //-------------------------------------------------------------------------------------------------
279 DMX_FILTER_STATUS SYMBOL_WEAK MApi_DMX_TSIO_Cmd(TSIO_CMD eCmd, MS_U32 u32Value);
280 
281 //-------------------------------------------------------------------------------------------------
282 /// Send and Recv C&C haed-based cmd
283 /// @param Parm                                        \b IN: Pointer to store C&C cmd address
284 /// @param pResult                                     \b IN: Pointer to store result status
285 /// @return DMX_FILTER_STATUS
286 /// @note
287 //-------------------------------------------------------------------------------------------------
288 DMX_FILTER_STATUS SYMBOL_WEAK MApi_DMX_TSIO_CC(TSIO_CC_Set *Parm, TSIO_CC_RESULT* pResult);
289 
290 //-------------------------------------------------------------------------------------------------
291 /// Get TSIO informaiton
292 /// @param eInfo                                        \b IN: Info type
293 /// @param u32Arg                                      \b IN: detail value
294 /// @param u32Retinfo                                 \b OUT: Pointer to store Info address
295 /// @return DMX_FILTER_STATUS
296 /// @note
297 //-------------------------------------------------------------------------------------------------
298 DMX_FILTER_STATUS SYMBOL_WEAK MApi_DMX_TSIO_GetInfo(TSIO_INFO eInfo , MS_U32 u32Arg, MS_U32 *u32Retinfo);
299 
300 //-------------------------------------------------------------------------------------------------
301 /// Set DMAOUT Virture channel to TSIO service
302 /// @param u16Handle                                    \b IN: Service handle ID
303 /// @param eSet                                            \b IN: Sgdma out param setting
304 /// @return DMX_FILTER_STATUS
305 /// @note
306 //-------------------------------------------------------------------------------------------------
307 DMX_FILTER_STATUS SYMBOL_WEAK MApi_DMX_TSIO_Service_SetDMAoutVC(MS_U16 u16Handle, TSIO_DMAOUT_SET *eSet);
308 
309 //-------------------------------------------------------------------------------------------------
310 /// Get DMAOUT VC  write address
311 /// @param u16Handle                                    \b IN: Service handle ID
312 /// @param pphyWrite                                    \b OUT: dma out write address
313 /// @return DMX_FILTER_STATUS
314 /// @note
315 //-------------------------------------------------------------------------------------------------
316 DMX_FILTER_STATUS SYMBOL_WEAK MApi_DMX_TSIO_Service_DMAout_WriteGet(MS_U16 u16Handle, MS_PHY* pphyWrite);
317 
318 //-------------------------------------------------------------------------------------------------
319 /// Set destination to TSIO service
320 /// @param u16Handle                                    \b IN: Service handle ID
321 /// @param eSet                                             \b IN: Sgdma out param setting
322 /// @return DMX_FILTER_STATUS
323 /// @note
324 //-------------------------------------------------------------------------------------------------
325 DMX_FILTER_STATUS SYMBOL_WEAK MApi_DMX_TSIO_Service_SetDestination(MS_U16 u16Handle, TSIO_SERVICEDEST eDest);
326 
327 //-------------------------------------------------------------------------------------------------
328 /// open DMAIN pid filter for TSIO service
329 /// @param u16Handle                                    \b IN:  Service handle ID
330 /// @param u16Pid                                       \b IN:  PID value of DMAIN PID filter
331 /// @param pu16FltId                                    \b OUT: Pointer to DMAIN PID filter ID
332 /// @return DMX_FILTER_STATUS
333 /// @note
334 //-------------------------------------------------------------------------------------------------
335 DMX_FILTER_STATUS SYMBOL_WEAK MApi_DMX_TSIO_Service_DMAin_PidOpen(MS_U16 u16Handle, MS_U16 u16Pid, MS_U16 *pu16FltId);
336 
337 //-------------------------------------------------------------------------------------------------
338 /// close DMAIN pid filter for TSIO service
339 /// @param u16Handle                                    \b IN:  Service handle ID
340 /// @param u16FltId                                     \b IN:  DMAIN PID filter ID
341 /// @return DMX_FILTER_STATUS
342 /// @note
343 //-------------------------------------------------------------------------------------------------
344 DMX_FILTER_STATUS SYMBOL_WEAK MApi_DMX_TSIO_Service_DMAin_PidClose(MS_U16 u16Handle, MS_U16 u16FltId);
345 
346 //-------------------------------------------------------------------------------------------------
347 /// Set DMAIN Virture channel to TSIO service
348 /// @param u16Handle                                    \b IN: Service handle ID
349 /// @param eSet                                             \b IN: Sgdma in param setting
350 /// @return DMX_FILTER_STATUS
351 /// @note
352 //-------------------------------------------------------------------------------------------------
353 DMX_FILTER_STATUS SYMBOL_WEAK MApi_DMX_TSIO_Service_SetDMAinVC(MS_U16 u16Handle, TSIO_DMAIN_SET *eSet);
354 
355 //-------------------------------------------------------------------------------------------------
356 /// start DMAIN Virture channel
357 /// @param u16Handle                                    \b IN: Service handle ID
358 /// @param u32Pacing                                     \b IN: Sgdma in pacing rate
359 /// @return TSIO_Result
360 /// @note
361 //-------------------------------------------------------------------------------------------------
362 DMX_FILTER_STATUS SYMBOL_WEAK MApi_DMX_TSIO_Service_DMAinVC_Start(MS_U16 u16Handle, MS_U32 u32Pacing);
363 
364 //-------------------------------------------------------------------------------------------------
365 /// Set Locdecrypt key to TSIO service
366 /// @param u16Handle                                    \b IN: Service handle ID
367 /// @param eSet                                            \b IN: Pointer to store loc decrypt key address
368 /// @return DMX_FILTER_STATUS
369 /// @note
370 //-------------------------------------------------------------------------------------------------
371 DMX_FILTER_STATUS SYMBOL_WEAK MApi_DMX_TSIO_Service_SetLocdecKey(MS_U16 u16Handle, TSIO_LOCKEY_SET *eSet);
372 
373 //-------------------------------------------------------------------------------------------------
374 /// Enable/disable locdec key
375 /// @param u16Handle                                    \b IN: Service handle ID
376 /// @param bEnable                                        \b IN: Enable locdec key
377 /// @return TSIO_Result
378 /// @note
379 //-------------------------------------------------------------------------------------------------
380 DMX_FILTER_STATUS SYMBOL_WEAK MApi_DMX_TSIO_Service_LocdecKeyEnable(MS_U16 u16Handle, MS_BOOL bEnable);
381 
382 //-------------------------------------------------------------------------------------------------
383 /// Allocate TSIO service
384 /// @param u8Sid                                            \b IN: Service ID
385 /// @param u16Handle                                    \b OUT: pointer of service handle for return
386 /// @return DMX_FILTER_STATUS
387 /// @note
388 //-------------------------------------------------------------------------------------------------
389 DMX_FILTER_STATUS SYMBOL_WEAK MApi_DMX_TSIO_Service_Alloc(MS_U8 u8Sid, MS_U16 *u16Handle);
390 
391 //-------------------------------------------------------------------------------------------------
392 /// Free TSIO service
393 /// @param u16Handle                                    \b IN: Service handle ID
394 /// @return DMX_FILTER_STATUS
395 /// @note
396 //-------------------------------------------------------------------------------------------------
397 DMX_FILTER_STATUS SYMBOL_WEAK MApi_DMX_TSIO_Service_Free(MS_U16 u16Handle);
398 
399 //-------------------------------------------------------------------------------------------------
400 /// open input pid filter for TSIO service
401 /// @param u16Handle                                    \b IN:  Service handle ID
402 /// @param eTSOInSrc                                    \b IN: TSIO PID filter source
403 /// @param u16Pid                                          \b IN: PID value of TSO PID filter
404 /// @param pu16DmxId                                    \b OUT: Pointer to store PID filter ID
405 /// @return DMX_FILTER_STATUS
406 /// @note
407 //-------------------------------------------------------------------------------------------------
408 DMX_FILTER_STATUS SYMBOL_WEAK MApi_DMX_TSIO_Service_PidOpen(MS_U16 u16Handle, DMX_TSIF eTSOInSrc, MS_U16 u16Pid, MS_U16* pu16DmxId);
409 
410 //-------------------------------------------------------------------------------------------------
411 /// close input pid filter for TSIO service
412 /// @param u16Handle                                    \b IN:  Service handle ID
413 /// @param u16DmxId                                     \b IN: TSO PID filter source
414 /// @return DMX_FILTER_STATUS
415 /// @note
416 //-------------------------------------------------------------------------------------------------
417 DMX_FILTER_STATUS SYMBOL_WEAK MApi_DMX_TSIO_Service_PidClose(MS_U16 u16Handle, MS_U16 u16DmxId);
418 
419 
420 #ifdef __cplusplus
421 }
422 #endif
423 
424 #endif // #ifndef __API_DMX_H__
425