xref: /utopia/UTPA2-700.0.x/modules/dscmb/hal/k6lite/nsk2/halNDSRASP.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) 2006-2007 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   halRASP.h
97 // @brief  RASP HAL
98 // @author MStar Semiconductor,Inc.
99 ////////////////////////////////////////////////////////////////////////////////////////////////////
100 #ifndef __HAL_NDSRASP_H__
101 #define __HAL_NDSRASP_H__
102 
103 #include "regNDSRASP.h"
104 
105 //--------------------------------------------------------------------------------------------------
106 //  Driver Compiler Option
107 //--------------------------------------------------------------------------------------------------
108 
109 //--------------------------------------------------------------------------------------------------
110 //  RASP Hardware Abstraction Layer
111 //--------------------------------------------------------------------------------------------------
112 
113 // rasp define
114 #define RASP_NUM 2
115 
116 #define RASP_DBGLV_EMERG     0  //Used for emergency messages, usually those that precede a crash.
117 #define RASP_DBGLV_ALERT     1  //A situation requiring immediate action.
118 #define RASP_DBGLV_CRIT      2  //Critical conditions, often related to serious hardware or software failures.
119 #define RASP_DBGLV_ERR       3  //Used to report error conditions; device drivers often use KERN_ERR to report hardware difficulties.
120 #define RASP_DBGLV_WARNING   4  //Warnings about problematic situations that do not, in themselves, create serious problems with the system.
121 #define RASP_DBGLV_NOTICE    5  //Situations that are normal, but still worthy of note. A number of security-related conditions are reported at this level.
122 #define RASP_DBGLV_INFO      6  //Informational messages. Many drivers print information about the hardware they find at startup time at this level.
123 #define RASP_DBGLV_DEBUG     7  //Used for debugging messages.
124 #define RASP_DBGLV_ARRAY     8  //Uesd for array data.
125 
126 // TSP Register
127 #define _TspPid                     ((REG_Pid*)(REG_PIDFLT_BASE))
128 #define _TspSec                     ((REG_Sec*)(REG_SECFLT_BASE))
129 
130 // HW characteristic
131 #define MIU(_addr_)                    ((_addr_)>>4)
132 
133 // HW characteristic
134 #define MIUNDS(_addr_)                 ((_addr_)>>3)
135 
136 //--------------------------------------------------------------------------------------------------
137 //  Macro of bit operations
138 //--------------------------------------------------------------------------------------------------
139 #define HAS_FLAG(flag, bit)        ((flag) & (bit))
140 #define SET_FLAG(flag, bit)        ((flag)|= (bit))
141 #define RESET_FLAG(flag, bit)      ((flag)&= (~(bit)))
142 #define SET_FLAG1(flag, bit)       ((flag)|  (bit))
143 #define RESET_FLAG1(flag, bit)     ((flag)&  (~(bit)))
144 
145 typedef enum
146 {
147     RASP_SRC_TS0,
148     RASP_SRC_TS1,
149     RASP_SRC_TS2,
150     RASP_SRC_TS3,
151     RASP_SRC_TS4,
152     RASP_SRC_TS5,
153     RASP_SRC_TS6,
154     RASP_SRC_DEMOD0,
155     RASP_SRC_DEMOD1,
156 } RASP_LIVEIN_SRC_e;
157 
158 ////////////////////////////////////////////////
159 // HAL API
160 ////////////////////////////////////////////////
161 void HAL_NDSRASP_SetBank(MS_U32 u32BankAddr);
162 void HAL_NDSRASP_Init(MS_U32 u32RASPEng);
163 void HAL_NDSRASP_Exit(MS_U32 u32RASPEng);
164 void HAL_NDSRASP_Ctrl(MS_U32 u32RASPEng, MS_U16 u16FromTo, MS_U16 u16PktSize2);
165 void HAL_NDSRASP_Pvr_Enable(MS_U32 u32RASPEng);
166 void HAL_NDSRASP_Stop(MS_U32 u32RASPEng);
167 void HAL_NDSRASP_Pause(MS_U32 u32RASPEng , MS_BOOL bPause);
168 void HAL_NDSRASP_SWReset(MS_U32 u32RASPEng);
169 void HAL_NDSRASP_SetPidflt(MS_U32 u32RASPEng, MS_U16 u16Fltid, MS_U16 u16Pid);
170 void HAL_NDSRASP_GetPidflt(MS_U32 u32RASPEng , MS_U16 u16Fltid , MS_U16 *u16Pid);
171 void HAL_NDSRASP_SetEcmPidflt(MS_U32 u32RASPEng , MS_U16 u16Fltid , MS_U16 u16Pid);
172 void HAL_NDSRASP_SetECM_Init_1(MS_U32 u32RASPEng);
173 void HAL_NDSRASP_SetECM_Init_2(MS_U32 u32RASPEng);
174 MS_U16 HAL_NDSRASP_SetECM_GetHW(MS_U32 u32RASPEng);
175 void HAL_NDSRASP_SetECM_ResetHW(MS_U32 u32RASPEng, MS_U16 IntStatus);
176 void HAL_NDSRASP_SetEventMask(MS_U32 u32RASPEng, MS_U16 u16Flt, MS_U32 u32Mask);
177 void HAL_NDSRASP_SetPayloadMask(MS_U32 u32RASPEng, MS_U16 u16Flt, MS_U32 u32Mask);
178 void HAL_NDSRASP_SetPayloadPacketMode(MS_U32 u32RASPEng,MS_BOOL bDisable192);
179 void HAL_NDSRASP_SetECMPacketMode(MS_U32 u32RASPEng,MS_BOOL bDisable192);
180 
181 void HAL_NDSRASP_SetCorptData(MS_U32 u32RASPEng, MS_U16 u16From , MS_U16 u16To, MS_U8 u8Data);
182 void HAL_NDSRASP_SetCorptFlt(MS_U32 u32RASPEng , MS_U16 u16Fltid, MS_BOOL Enable);
183 
184 void HAL_NDSRASP_SetStr2Miu_StartAddr(MS_U32 u32RASPEng, MS_U32 u32StartAddr0, MS_U32 u32StartAddr1);
185 void HAL_NDSRASP_SetStr2Miu_MidAddr(MS_U32 u32RASPEng, MS_U32 u32MidAddr0, MS_U32 u32MidAddr1);
186 void HAL_NDSRASP_SetStr2Miu_EndAddr(MS_U32 u32RASPEng, MS_U32 u32EndAddr0, MS_U32 u32EndAddr1);
187 
188 void HAL_NDSRASP_Payload_Enable(MS_U32 u32RASPEng ,MS_BOOL enable );
189 //void HAL_NDSRASP_SetPayload_StartAddr(MS_U32 u32RASPEng, MS_U32 u32StartAddr0, MS_U32 u32StartAddr1);
190 //void HAL_NDSRASP_SetPayload_MidAddr(MS_U32 u32RASPEng, MS_U32 u32MidAddr0, MS_U32 u32MidAddr1);
191 //void HAL_NDSRASP_SetPayload_EndAddr(MS_U32 u32RASPEng, MS_U32 u32EndAddr0, MS_U32 u32EndAddr1);
192 MS_U32 HAL_NDSRASP_GetPayloadWritePtr(MS_U32 u32RASPEng);
193 
194 void HAL_NDSRASP_ECM_Enable(MS_U32 u32RASPEng , MS_BOOL enable );
195 //void HAL_NDSRASP_SetECM_StartAddr(MS_U32 u32RASPEng, MS_U32 u32StartAddr);
196 //void HAL_NDSRASP_SetECM_MidAddr(MS_U32 u32RASPEng, MS_U32 u32MidAddr);
197 //void HAL_NDSRASP_SetECM_EndAddr(MS_U32 u32RASPEng, MS_U32 u32EndAddr);
198 
199 //void HAL_NDSRASP_SetECM_Pidflt(MS_U32 u32RASPEng, MS_U16 u16Fltid, MS_U16 u16Pid);
200 void HAL_NDSRASP_SetStrPacketMode(MS_U32 u32RASPEng, MS_BOOL bSet);
201 void HAL_NDSRASP_PowerCtrl(MS_U32 u32RASPEng, MS_BOOL bSet);
202 
203 void HAL_NDSRASP_SetPVRTimeStamp(MS_U32 u32RASPEng, MS_U32 u32Stamp);
204 void HAL_NDSRASP_SetECMTimeStamp(MS_U32 u32RASPEng, MS_U32 u32Stamp);
205 void HAL_NDSRASP_SetPayloadTimeStamp(MS_U32 u32RASPEng, MS_U32 u32Stamp);
206 //void HAL_NDSRASP_SetTimerWaterMark(MS_U32 u32RASPEng, MS_U16 u16TimerWaterMask);
207 //void HAL_NDSRASP_SetEventWaterMark(MS_U32 u32RASPEng, MS_U16 u16EventWaterMask);
208 
209 void HAL_NDSRASP_Rec_PID(MS_U32 u32RASPEng, MS_BOOL bSet);
210 
211 MS_U32 HAL_NDSRASP_GetPVRTimeStamp(MS_U32 u32RASPEng);
212 MS_U32 HAL_NDSRASP_GetECMTimeStamp(MS_U32 u32RASPEng);
213 MS_U32 HAL_NDSRASP_GetPayloadTimeStamp(MS_U32 u32RASPEng);
214 
215 
216 MS_U32 HAL_NDSRASP_GetWritePtr(MS_U32 u32RASPEng);
217 MS_U32 HAL_NDSRASP_GetECMWritePtr(MS_U32 u32RASPEng);
218 void HAL_NDSRASP_SetFileinStart(MS_U32 u32RASPEng, MS_BOOL bEn);
219 MS_BOOL HAL_NDSRASP_GetFileinStart(MS_U32 u32RASPEng);
220 
221 void HAL_NDSRASP_SetTSIF(MS_U32 u32RASPEng, MS_BOOL bPara, MS_BOOL bExtSync, MS_BOOL bDataSWP);
222 void HAL_NDSRASP_GetTSIF(MS_U32 u32RASPEng , MS_BOOL* pbPara, MS_BOOL* pbExtSync, MS_BOOL* pbDataSWP);
223 
224 
225 
226 MS_U16  HAL_NDSRASP_INT_GetHW(MS_U32 u32RASPEng);
227 void    HAL_NDSRASP_INT_ClrHW(MS_U32 u32RASPEng, MS_U16 u16Mask);
228 void    HAL_NDSRASP_INT_Enable(MS_U32 u32RASPEng, MS_U16 u16Mask);
229 void    HAL_NDSRASP_INT_Disable(MS_U32 u32RASPEng, MS_U16 u16Mask);
230 void    HAL_NDSRASP_EVENT_EventWM_Enable(MS_U32 u32RASPEng, MS_BOOL enable);
231 void    HAL_NDSRASP_EVENT_TimeWM_Enable(MS_U32 u32RASPEng, MS_BOOL enable);
232 void    HAL_NDSRASP_SetDataSwap(MS_U32 u32RASPEng, MS_BOOL bEn);
233 MS_BOOL HAL_NDSRASP_EVENT_GetEventDescriptor(MS_U32 u32RASPEng,MS_U32 *DataArray , MS_U32 ArrSize );
234 MS_U16  HAL_NDSRASP_EVENT_GetEventNum(MS_U32 u32RASPEng);
235 void HAL_NDSRASP_SetBufferBlockLevel(MS_U32 u32RASPEng, MS_U32 bufBlockLv);
236 MS_BOOL HAL_NDSRASP_EVENT_RstCounter(MS_U32 u32RASPEng);
237 MS_BOOL	HAL_NDSRASP_EVENT_RstTimer(MS_U32 u32RASPEng);
238 MS_BOOL HAL_NDSRASP_EVENT_EFrame_Read(MS_U32 u32RASPEng);
239 
240 
241 MS_U32 HAL_NDSRASP_GetPktTimer(MS_U32 u32RASPEng);
242 MS_U32 HAL_NDSRASP_GetPktNum(MS_U32 u32RASPEng);
243 MS_U32 HAL_NDSRASP_GetEcmPktNum(MS_U32 u32RASPEng);
244 
245 MS_U32 HAL_RASP_SetPVRDstBuf(MS_U32 RaspEng, MS_U32 u32StartAddr0, MS_U32 u32EndAddr0, MS_U32 u32StartAddr1, MS_U32 u32EndAddr1);
246 MS_U32 HAL_RASP_RecOpenPid(MS_U32 RaspEng, MS_U16 Pid, MS_U8 RaspFltId);
247 MS_U32 HAL_RASP_DisableRec(MS_U32 RaspEng);
248 MS_U32 HAL_RASP_Close(MS_U32 RaspEng);
249 
250 MS_U32 HAL_RASP_SetFileIn_Config(MS_U32 RaspEng, MS_U32 StartAddr, MS_U32 FileInSize);
251 MS_U32 HAL_RASP_FileIn_Start(MS_U32 RaspEng);
252 MS_U32 HAL_RASP_SetFileIn_Timer(MS_U32 RaspEng, MS_U16 u16Timer);
253 MS_U32 HAL_RASP_SetFileIn_PktSize(MS_U32 RaspEng, MS_U16 PktSize);
254 MS_BOOL HAL_RASP_IsFileIn_Done(MS_U32 RaspEng);
255 MS_U32 HAL_RASP_FileIn_Flush(MS_U32 RaspEng);
256 
257 MS_U32 HAL_RASP_FileIn_BlockTimeStamp(MS_U32 RaspEng,MS_BOOL enbl);
258 MS_U32 HAL_RASP_FileIn_SetPlaybackTimeStamp(MS_U32 RaspEng,MS_U32 u32Stamp);
259 MS_U32 HAL_RASP_FileIn_GetPlaybackTimeStamp(MS_U32 RaspEng);
260 MS_U32 HAL_RASP_FileIn_Timer(MS_U32 RaspEng,MS_BOOL bEnFileinTimer,MS_U16 u16TimerValue);
261 MS_U32 HAL_RASP_FileIn_Reset_TStamp(MS_U32 RaspEng,MS_BOOL bResetPktTimeStamp);
262 
263 MS_U32 HAL_RASP_SetPayloadDstBuf(MS_U32 RaspEng,MS_U32 u32StartAddr0,MS_U32 u32MidAddr0,MS_U32 u32EndAddr0,MS_U32 u32StartAddr1,MS_U32 u32MidAddr1,MS_U32 u32EndAddr1);
264 MS_U32 HAL_RASP_SetECMDstBuf(MS_U32 RaspEng,MS_U32 u32StartAddr0,MS_U32 u32MidAddr0,MS_U32 u32EndAddr0);
265 MS_U32 HAL_NDSRASP_GetEVENT_Status(MS_U32 u32RASPEng, MS_U16 *pEventLog , MS_U32 *pEventDescr);
266 void HAL_NDSRASP_SetDbgLevel(MS_U32 level);
267 void HAL_NDSRASP_ReadEcmPidflt(MS_U32 u32RASPEng , MS_U16 u16Fltid , MS_U16 *pu16Pid);
268 
269 MS_BOOL HAL_RASP_FileIn_IsCMDQ_Full(MS_U32 RaspEng);
270 MS_BOOL HAL_RASP_FileIn_IsCMDQ_Empty(MS_U32 RaspEng);
271 MS_BOOL HAL_RASP_FileIn_GetCmdQueueLevel(MS_U32 RaspEng,MS_U8 * CmdQLvl);
272 MS_BOOL HAL_RASP_FileIn_GetEmptyNum(MS_U32 RaspEng,MS_U8 * CmdQLvl);
273 MS_BOOL HAL_NDSRASP_Livein_Config(MS_U32 rasp_eng, RASP_LIVEIN_SRC_e InputSrc);
274 MS_BOOL HAL_NDSRASP_LiveIn_Init(MS_U32 u32RASPEng,MS_U8 u8PacketLength);
275 MS_BOOL HAL_NDSRASP_FileIn_Init(MS_U32 u32RASPEng,MS_U8 u8PacketLength);
276 MS_BOOL HAL_NDSRASP_SetFileinConfig(MS_U32 RaspEng, MS_BOOL bFileIn, MS_U16 BlockLevel);
277 
278 
279 MS_BOOL HAL_NDSRASP_EVENT_SetEventThreshold(MS_U32 u32RASPEng,MS_U32 u32threshold);
280 MS_BOOL HAL_NDSRASP_EVENT_SetTimerThreshold(MS_U32 u32RASPEng,MS_U16 u16timeout);
281 MS_U32 HAL_NDSRASP_SetExtendConfig(MS_U32 RaspEng, MS_U16 type, MS_U16 extendbytes, MS_U16 syncbyte);
282 
283 #endif // #ifndef __HAL_NDSRASP_H__
284 
285