xref: /utopia/UTPA2-700.0.x/projects/tmplib/include/drvRASP.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   drvRASP.h
98 /// @brief  RASP Driver Interface
99 /// @author MStar Semiconductor,Inc.
100 /// @attention
101 ////////////////////////////////////////////////////////////////////////////////////////////////////
102 
103 #ifndef _DRVRASP_H_
104 #define _DRVRASP_H_
105 
106 #ifdef __cplusplus
107 extern "C"
108 {
109 #endif
110 
111 //--------------------------------------------------------------------------------------------------
112 //  Define
113 //--------------------------------------------------------------------------------------------------
114 #define RASP_PIDFLT_START_NUM        0
115 #define RASP_PIDFLT_END_NUM          24
116 
117 #define RASP_PIDFLT_NUM_ALL          24
118 
119 #ifdef HW_PVR_ENABLE
120     #define PVR_PIDFLT_START_NUM        0
121     #define PVR_PIDFLT_END_NUM          16
122 
123     #define PVR_PIDFLT_NUM_ALL          16
124 #endif //#endif HW_PVR_ENABLE
125 
126 #define CALLBACK_SIZE_MIN               16//due to current MIU alignment's up to 16 bytes
127 
128 #define DRVRASP_PID_NULL             0x1FFF                                                 // Transport stream null PID
129 #define MSIF_RASP_LIB_CODE           {'R','A','S','P'}                                      // Lib code
130 #define MSIF_RASP_LIBVER             {'0','2'}                                              // LIB version
131 #define MSIF_RASP_BUILDNUM           {'0','0'}                                              // Build Number
132 #define MSIF_RASP_CHANGELIST         {'0','0','5','1','1','4','7','0'}                      // P4 ChangeList Number
133 
134 #define RASP_DRV_VERSION                 /* Character String for DRV/API version             */  \
135     MSIF_TAG,                            /* 'MSIF'                                           */  \
136     MSIF_CLASS,                          /* '00'                                             */  \
137     MSIF_CUS,                            /* 0x0000                                           */  \
138     MSIF_MOD,                            /* 0x0000                                           */  \
139     MSIF_CHIP,                                                                                   \
140     MSIF_CPU,                                                                                    \
141     MSIF_RASP_LIB_CODE,                  /* IP__                                             */  \
142     MSIF_RASP_LIBVER,                    /* 0.0 ~ Z.Z                                        */  \
143     MSIF_RASP_BUILDNUM,                  /* 00 ~ 99                                          */  \
144     MSIF_RASP_CHANGELIST,                /* CL#                                              */  \
145     MSIF_OS
146 
147 //--------------------------------------------------------------------------------------------------
148 //  Driver Capability
149 //--------------------------------------------------------------------------------------------------
150 
151 //--------------------------------------------------------------------------------------------------
152 //  Type and Structure
153 //--------------------------------------------------------------------------------------------------
154 
155 /// RASP DDI return value
156 /// @name TSP_Result
157 /// @ref TSP_Result
158 /// return value
159 /// @{
160 typedef enum
161 {
162     DRVRASP_FAIL                   = 0,
163     DRVRASP_OK,
164     DRVRASP_INVALID_PARAM,
165     DRVRASP_FUNC_ERROR,
166 } RASP_Result;
167 
168 #define DrvRASP_Event                    MS_U32
169 #define E_DRVRASP_EVENT_DATA_INIT        0x00000000
170 //PVR buffer callback size met
171 #define E_DRVRASP_EVENT_CALLBACK_SIZE_MET 0x00000040
172 
173 // Payload/Event Mask flag
174 //#define RASP_BYPASS_MASK            0xffffffff
175 #define E_DRVRASP_BYPASS_AFE             0x00000001      // adaptation field extension
176 #define E_DRVRASP_BYPASS_TPD             0x00000002      // transport private data
177 #define E_DRVRASP_BYPASS_SP              0x00000004      // splicing point
178 #define E_DRVRASP_BYPASS_OPCR            0x00000008      // OPCR
179 #define E_DRVRASP_BYPASS_PCR             0x00000010      // PCR
180 #define E_DRVRASP_BYPASS_ESPI            0x00000020      // elementary stream priority indicator
181 #define E_DRVRASP_BYPASS_RAI             0x00000040      // random access indicator
182 #define E_DRVRASP_BYPASS_DI              0x00000080      // discontinue indicator
183 #define E_DRVRASP_BYPASS_ESNS            0x00000100      // elementary stream not scrambled
184 #define E_DRVRASP_BYPASS_ESES            0x00000200      // elementary stream even scrambled
185 #define E_DRVRASP_BYPASS_ESOS            0x00000400      // elementary stream odd scrambled
186 #define E_DRVRASP_BYPASS_PUSI            0x00000800      // payload unit start indicator
187 #define E_DRVRASP_BYPASS_FPR             0x00001000      // first packet recorded
188 #define E_DRVRASP_BYPASS_RASP_Tick       0x80000000      // rasp tick
189 
190 typedef enum
191 {
192     E_DRVRASP_CAP_FILTER_NUM = 0,                   // Get filter number
193     E_DRVRASP_CAP_FILTER_PVR_NUM,                   // Get pvr filter number
194     E_DRVRASP_CAP_PVR_ALIGN,                        // Get pvr buffer minimal alignment
195     E_DRVRASP_CAP_RESOURCE_SIZE,                    // Get the data structure size of private resource (share resource)
196     E_DRVRASP_CAP_RASP_NUM,                    // Get RASP num
197 
198     E_DRVRASP_CAP_NULL,
199 } DrvRASP_Cap;
200 
201 /// RASP channel state bit flags
202 typedef enum //_DrvTSP_FltState
203 {
204     E_DRVRASP_FLT_STATE_FREE         = 0x00000000,                                                   ///<\n
205     E_DRVRASP_FLT_STATE_ALLOC        = 0x00000001,                                                   ///<\n
206     E_DRVRASP_FLT_STATE_ENABLE       = 0x00000002,                                                   ///<\n
207     E_DRVRASP_FLT_STATE_OVERFLOW     = 0x00010000,                                                   //[Reserved]
208     E_DRVRASP_FLT_STATE_NA           = 0xFFFFFFFF,
209 } DrvRASP_FltState;
210 
211 /// TSP record mode
212 typedef enum //_DrvRASP_RecMode
213 {
214     // Record PID
215     E_DRVRASP_REC_MODE_PID  = 0x00000000,
216     // Record ALL
217     E_DRVRASP_REC_MODE_ALL  = 0x00000001,
218 } DrvRASP_RecMode;
219 
220 /// TSP interface
221 typedef enum
222 {
223     E_DRVRASP_IF_PLAYBACK            = 0x0, // TS interface 0
224     E_DRVRASP_IF_PVR0                = 0x1, // TS interface 1, mainly for PVR
225 } DrvRASP_If;
226 
227 typedef struct //_DrvRASP_Msg
228 {/*//why union? by teddy.chen
229     /// Union data type of message
230     union
231     {
232         /// FltInfo message
233         ///   - Byte[0] : Section filter id
234         ///   - Byte[1] : TSP id
235         MS_U32                          FltInfo;
236         /// PvrBufId
237         ///   - Byte[0] : PVR buffer id
238         MS_U32                          PvrBufId;
239     };
240 */
241     MS_U8 u8PVREngNum;
242 } DrvRASP_Msg;
243 
244 typedef enum //_DrvRASP_RecType
245 {
246     STR2MIU          = 0x0,
247     PAYLOAD2MIU      = 0x1,
248     ECM2MIU          = 0x2,
249 } DrvRASP_RecType;
250 
251 /// TSP notification function
252 typedef void (*P_DrvRASP_EvtCallback)(DrvRASP_Event eEvent, DrvRASP_Msg *pMsg);
253 
254 //--------------------------------------------------------------------------------------------------
255 //  Function Prototype
256 //--------------------------------------------------------------------------------------------------
257 
258 // Initialization API
259 RASP_Result MDrv_RASP_InitLibResource(void* pResMemAddr);
260 RASP_Result MDrv_RASP_Init(void);
261 RASP_Result MDrv_RASP_Exit(void);
262 RASP_Result MDrv_RASP_Reset(void);
263 RASP_Result MDrv_RASP_Alive(void);
264 RASP_Result MDrv_RASP_ReplacePackets(void);
265 RASP_Result MDrv_RASP_Confi(void);
266 RASP_Result MDrv_RASP_PVR_SetTSIF(MS_U32 u32RASPEng, MS_BOOL bPara, MS_BOOL bExtSync, MS_BOOL bDataSWP);
267 RASP_Result MDrv_RASP_PVR_GetTSIFStatus(MS_U32 u32RASPEng, MS_BOOL* pbExtSyc, MS_BOOL* pbParl, MS_BOOL *pbDataSWP);
268 RASP_Result MDrv_RASP_PVR_FileinEnable(MS_U32 u32RASPEng, MS_BOOL bEn);
269 RASP_Result MDrv_RASP_PVR_GetFileinEnable(MS_U32 u32RASPEng, MS_BOOL* bEn);
270 
271 // Capacity query
272 RASP_Result MDrv_RASP_GetCap(DrvRASP_Cap eCap, void* pOutput);
273 RASP_Result MDrv_RASP_GetLibVer(const MSIF_Version **ppVersion);
274 RASP_Result MDrv_RASP_GetTimerAndPacketNum(const MSIF_Version **ppVersion);
275 RASP_Result MDrv_RASP_GetTsPayload(const MSIF_Version **ppVersion);
276 RASP_Result MDrv_RASP_GetEventMask(const MSIF_Version **ppVersion);
277 
278 // PVR API
279 RASP_Result MDrv_RASP_PVR_SetBuffer(MS_U32 u32RASPEng, MS_PHYADDR u32BufStart0, MS_PHYADDR u32BufStart1, MS_U32 u32BufSize0, MS_U32 u32BufSize1);
280 RASP_Result MDrv_RASP_PVR_Start(MS_U32 u32RASPEng, DrvRASP_RecMode eRecMode, MS_BOOL bStart);
281 RASP_Result MDrv_RASP_PVR_Pause(MS_U32 u32RASPEng, MS_BOOL bPause);
282 RASP_Result MDrv_RASP_PVR_GetWriteAddr(MS_U32 u32RASPEng, MS_PHYADDR *pu32WriteAddr);
283 RASP_Result MDrv_RASP_PVR_Notify(MS_U32 u32RASPEng, DrvRASP_Event eEvents, P_DrvRASP_EvtCallback pfCallback);
284 RASP_Result MDrv_RASP_PVR_SetPacketMode(MS_U32 u32RASPEng, DrvRASP_RecType eRecType,MS_BOOL bSet);
285 RASP_Result MDrv_RASP_PVR_TimeStampSetRecordStamp(MS_U32 u32RASPEng, MS_U32 u32Stamp);
286 RASP_Result MDrv_RASP_PVR_TimeStampGetRecordStamp(MS_U32 u32RASPEng, MS_U32* u32Stamp);
287 RASP_Result MDrv_RASP_PVR_TimeStampSelRecordStampSrc(MS_U32 u32RASPEng, MS_BOOL bLocal);
288 RASP_Result MDrv_RASP_PVR_AllocFlt(MS_U32 u32RASPEng, MS_U32 *pu32PidFltId);
289 RASP_Result MDrv_RASP_PVR_SetPid(MS_U32 u32RASPEng, MS_U16 u16Fltid, MS_U16 u16Pid);
290 RASP_Result MDrv_RASP_PVR_GetPid(MS_U32 u32RASPEng, MS_U16 u16Fltid, MS_U16 *pu16Pid);
291 RASP_Result MDrv_RASP_PVR_ReleaseFlt(MS_U32 u32RASPEng, MS_U16 u32FltId);
292 RASP_Result MDrv_RASP_PVR_AttachInterrupt(InterruptCb pIntCb);
293 RASP_Result MDrv_RASP_PVR_EnableInterrupt(void);
294 RASP_Result MDrv_RASP_PVR_CallbackSize(MS_U32 u32RASPEng, MS_U32* pu32CallbackSize, MS_BOOL bSet);
295 //RASP_Result MDrv_RASP_PVR_TimeStampSetPlaybackStamp(MS_U32 u32Stamp);
296 //RASP_Result MDrv_RASP_PVR_TimeStampGetPlaybackStamp(MS_U32* u32Stamp);
297 //RASP_Result MDrv_RASP_PVR_TimeStamp(MS_BOOL bEnable);
298 
299 // RASP API
300 RASP_Result MDrv_RASP_SetEvent(MS_U32 u32RASPEng, MS_U16 u16Flt, MS_U32 u32Event);
301 RASP_Result MDrv_RASP_SetPayload(MS_U32 u32RASPEng, MS_U16 u16Flt, MS_U32 u32Payload);
302 RASP_Result MDrv_RASP_SetDataSwap(MS_U32 u32RASPEng, MS_BOOL bEn);
303 
304 RASP_Result MDrv_PROC_RASP_PVR_SizeMet(MS_U32 u32RASPEng);
305 RASP_Result MDrv_RASP_CallbackIntCheck(MS_U32 u32RASPEng, MS_BOOL* bInterrupted);
306 RASP_Result MDrv_RASP_CallbackIntClr(MS_U32 u32RASPEng);
307 
308 #ifdef __cplusplus
309 } // closing brace for extern "C"
310 #endif
311 #endif // _DRVRASP_H_
312