xref: /utopia/UTPA2-700.0.x/projects/tmplib/include/drvDMD_INTERN_ATSC.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   drvDMD_DVBT_INTERN.h
98 /// @brief  DVBT Driver Interface
99 /// @author MStar Semiconductor Inc.
100 ///////////////////////////////////////////////////////////////////////////////////////////////////
101 #include "drvDMD_ATSC.h"
102 
103 #if 0
104 
105 
106 #ifndef _DRV_ATSC_H_
107 #define _DRV_ATSC_H_
108 
109 #include "MsDevice.h"
110 #include "MsCommon.h"
111 
112 #ifdef __cplusplus
113 extern "C"
114 {
115 #endif
116 
117 
118 //-------------------------------------------------------------------------------------------------
119 //  Driver Capability
120 //-------------------------------------------------------------------------------------------------
121 
122 
123 //-------------------------------------------------------------------------------------------------
124 //  Macro and Define
125 //-------------------------------------------------------------------------------------------------
126 #define MSIF_DMD_ATSC_INTERN_LIB_CODE           {'D','M','D','_','A','T', 'S','C','_','I','N','T','E','R','N','_'} //Lib code
127 #define MSIF_DMD_ATSC_INTERN_LIBVER             {'0','0'}      //LIB version
128 #define MSIF_DMD_ATSC_INTERN_BUILDNUM           {'0','0' }    //Build Number
129 #define MSIF_DMD_ATSC_INTERN_CHANGELIST         {'0','0','0','0','0','0','0','0'} //P4 ChangeList Number
130 
131 #define DMD_ATSC_INTERN_VER                 /* Character String for DRV/API version             */  \
132     MSIF_TAG,                           /* 'MSIF'                                           */  \
133     MSIF_CLASS,                         /* '00'                                             */  \
134     MSIF_CUS,                           /* 0x0000                                           */  \
135     MSIF_MOD,                           /* 0x0000                                           */  \
136     MSIF_CHIP,                                                                                  \
137     MSIF_CPU,                                                                                   \
138     MSIF_DMD_ATSC_INTERN_LIB_CODE,      /* IP__                                             */  \
139     MSIF_DMD_ATSC_INTERN_LIBVER,        /* 0.0 ~ Z.Z                                        */  \
140     MSIF_DMD_ATSC_INTERN_BUILDNUM,      /* 00 ~ 99                                          */  \
141     MSIF_DMD_ATSC_INTERN_CHANGELIST,    /* CL#                                              */  \
142     MSIF_OS
143 
144 #define IS_BITS_SET(val, bits)                  (((val)&(bits)) == (bits))
145 
146 //-------------------------------------------------------------------------------------------------
147 //  Type and Structure
148 //-------------------------------------------------------------------------------------------------
149 typedef enum
150 {
151     DMD_ATSC_DBGLV_NONE,    // disable all the debug message
152     DMD_ATSC_DBGLV_INFO,    // information
153     DMD_ATSC_DBGLV_NOTICE,  // normal but significant condition
154     DMD_ATSC_DBGLV_WARNING, // warning conditions
155     DMD_ATSC_DBGLV_ERR,     // error conditions
156     DMD_ATSC_DBGLV_CRIT,    // critical conditions
157     DMD_ATSC_DBGLV_ALERT,   // action must be taken immediately
158     DMD_ATSC_DBGLV_EMERG,   // system is unusable
159     DMD_ATSC_DBGLV_DEBUG,   // debug-level messages
160 } DMD_ATSC_DbgLv;
161 
162 typedef enum
163 {
164     DMD_ATSC_DEMOD_ATSC_VSB,
165     DMD_ATSC_DEMOD_ATSC_64QAM,
166     DMD_ATSC_DEMOD_ATSC_256QAM,
167     DMD_ATSC_DEMOD_MAX,
168     DMD_ATSC_DEMOD_NULL = DMD_ATSC_DEMOD_MAX,
169 } DMD_ATSC_DEMOD_TYPE;
170 
171 typedef enum
172 {
173     DMD_ATSC_SIGNAL_NO                   = 0,    /* little or no input power detected    */
174     DMD_ATSC_SIGNAL_WEAK                 = 1,    /* some power detected.                 */
175     DMD_ATSC_SIGNAL_MODERATE             = 2,
176     DMD_ATSC_SIGNAL_STRONG               = 4,
177     DMD_ATSC_SIGNAL_VERY_STRONG          = 8
178 } DMD_ATSC_SIGNAL_CONDITION;
179 
180 typedef enum
181 {
182     DMD_ATSC_GETLOCK,
183     DMD_ATSC_GETLOCK_VSB_AGCLOCK,
184     DMD_ATSC_GETLOCK_VSB_PRELOCK, // pilot lock
185     DMD_ATSC_GETLOCK_VSB_FSYNCLOCK,
186     DMD_ATSC_GETLOCK_VSB_CELOCK,
187     DMD_ATSC_GETLOCK_VSB_FECLOCK,
188     DMD_ATSC_GETLOCK_QAM_AGCLOCK,
189     DMD_ATSC_GETLOCK_QAM_PRELOCK, // TR lock
190     DMD_ATSC_GETLOCK_QAM_MAINLOCK,
191 } DMD_ATSC_GETLOCK_TYPE;
192 
193 typedef enum
194 {
195     DMD_ATSC_LOCK,
196     DMD_ATSC_CHECKING,
197     DMD_ATSC_CHECKEND,
198     DMD_ATSC_UNLOCK,
199     DMD_ATSC_NULL,
200 } DMD_ATSC_LOCK_STATUS;
201 
202 /// For demod init
203 typedef struct
204 {
205     // init
206     MS_U16 u16VSBAGCLockCheckTime;
207     MS_U16 u16VSBPreLockCheckTime;
208     MS_U16 u16VSBFSyncLockCheckTime;
209     MS_U16 u16VSBFECLockCheckTime;
210 
211     MS_U16 u16QAMAGCLockCheckTime;
212     MS_U16 u16QAMPreLockCheckTime;
213     MS_U16 u16QAMMainLockCheckTime;
214 
215     // register init
216     MS_U8 *u8DMD_ATSC_DSPRegInitExt; // TODO use system variable type
217     MS_U8 u8DMD_ATSC_DSPRegInitSize;
218     MS_U8 *u8DMD_ATSC_InitExt; // TODO use system variable type
219 
220     MS_U16  u16IF_KHZ;
221     MS_BOOL bIQSwap;
222 } DMD_ATSC_InitData;
223 
224 typedef enum
225 {
226     E_DMD_ATSC_FAIL=0,
227     E_DMD_ATSC_OK=1
228 } DMD_ATSC_Result;
229 
230 typedef struct
231 {
232     MS_U8 u8Version;
233     MS_U32 u32ATSCScanTimeStart;
234     MS_U32 u32ATSCFECLockTime;
235     DMD_ATSC_LOCK_STATUS eStatus;
236     MS_U32 u32ATSCLockStatus;
237 } DMD_ATSC_Info;
238 
239 #define DMD_ATSC_LOCK_VSB_PRE_LOCK BIT_(0)
240 #define DMD_ATSC_LOCK_VSB_FSYNC_LOCK BIT_(1)
241 #define DMD_ATSC_LOCK_VSB_CE_LOCK BIT_(2)
242 #define DMD_ATSC_LOCK_VSB_FEC_LOCK BIT_(3)
243 
244 #define DMD_ATSC_LOCK_QAM_AGC_LOCK BIT_(8)
245 #define DMD_ATSC_LOCK_QAM_PRE_LOCK BIT_(9)
246 #define DMD_ATSC_LOCK_QAM_MAIN_LOCK BIT_(10)
247 
248 //typedef void(*P_DMD_ISR_Proc)(MS_U8 u8DMDID);
249 
250 
251 //-------------------------------------------------------------------------------------------------
252 //  Function and Variable
253 //-------------------------------------------------------------------------------------------------
254 ////////////////////////////////////////////////////////////////////////////////
255 /// MDrv_DMD_DVBT_Init
256 ////////////////////////////////////////////////////////////////////////////////
257 extern MS_BOOL MDrv_DMD_ATSC_Init(DMD_ATSC_InitData *pDMD_DVBT_InitData, MS_U32 u32InitDataLen);
258 ////////////////////////////////////////////////////////////////////////////////
259 /// Should be called when exit VD input source
260 ////////////////////////////////////////////////////////////////////////////////
261 extern MS_BOOL MDrv_DMD_ATSC_Exit(void);
262 //------------------------------------------------------------------------------
263 /// Set detailed level of DVBT driver debug message
264 /// u8DbgLevel : debug level for Parallel Flash driver\n
265 /// AVD_DBGLV_NONE,    ///< disable all the debug message\n
266 /// AVD_DBGLV_INFO,    ///< information\n
267 /// AVD_DBGLV_NOTICE,  ///< normal but significant condition\n
268 /// AVD_DBGLV_WARNING, ///< warning conditions\n
269 /// AVD_DBGLV_ERR,     ///< error conditions\n
270 /// AVD_DBGLV_CRIT,    ///< critical conditions\n
271 /// AVD_DBGLV_ALERT,   ///< action must be taken immediately\n
272 /// AVD_DBGLV_EMERG,   ///< system is unusable\n
273 /// AVD_DBGLV_DEBUG,   ///< debug-level messages\n
274 /// @return TRUE : succeed
275 /// @return FALSE : failed to set the debug level
276 //------------------------------------------------------------------------------
277 extern MS_BOOL MDrv_DMD_ATSC_SetDbgLevel(DMD_ATSC_DbgLv u8DbgLevel);
278 //-------------------------------------------------------------------------------------------------
279 /// Get the information of DVBT driver\n
280 /// @return the pointer to the driver information
281 //-------------------------------------------------------------------------------------------------
282 extern DMD_ATSC_Info* MDrv_DMD_ATSC_GetInfo(void);
283 //-------------------------------------------------------------------------------------------------
284 /// Get DVBT driver version
285 /// when get ok, return the pointer to the driver version
286 //-------------------------------------------------------------------------------------------------
287 extern MS_BOOL MDrv_DMD_ATSC_GetLibVer(const MSIF_Version **ppVersion);
288 ////////////////////////////////////////////////////////////////////////////////
289 /// To get DVBT's register  value, only for special purpose.\n
290 /// u16Addr       : the address of DVBT's register\n
291 /// return the value of AFEC's register\n
292 ////////////////////////////////////////////////////////////////////////////////
293 extern MS_BOOL MDrv_DMD_ATSC_GetReg(MS_U16 u16Addr, MS_U8 *pu8Data);
294 ////////////////////////////////////////////////////////////////////////////////
295 /// To set DVBT's register value, only for special purpose.\n
296 /// u16Addr       : the address of DVBT's register\n
297 /// u8Value        : the value to be set\n
298 ////////////////////////////////////////////////////////////////////////////////
299 extern MS_BOOL MDrv_DMD_ATSC_SetReg(MS_U16 u16Addr, MS_U8 u8Data);
300 ////////////////////////////////////////////////////////////////////////////////
301 /// MDrv_DMD_DVBT_SetSerialControl
302 ////////////////////////////////////////////////////////////////////////////////
303 extern MS_BOOL MDrv_DMD_ATSC_SetSerialControl(MS_BOOL bEnable);
304 ////////////////////////////////////////////////////////////////////////////////
305 /// MDrv_DMD_ATSC_SetReset
306 ////////////////////////////////////////////////////////////////////////////////
307 extern void MDrv_DMD_ATSC_SetReset(void);
308 ////////////////////////////////////////////////////////////////////////////////
309 /// MDrv_DMD_DVBT_SetConfig
310 ////////////////////////////////////////////////////////////////////////////////
311 extern MS_BOOL MDrv_DMD_ATSC_SetConfig(DMD_ATSC_DEMOD_TYPE eType, MS_BOOL bEnable);
312 ////////////////////////////////////////////////////////////////////////////////
313 /// MDrv_DMD_DVBT_SetActive
314 ////////////////////////////////////////////////////////////////////////////////
315 extern MS_BOOL MDrv_DMD_ATSC_SetActive(MS_BOOL bEnable);
316 ////////////////////////////////////////////////////////////////////////////////
317 /// MDrv_DMD_DVBT_Get_Lock
318 ////////////////////////////////////////////////////////////////////////////////
319 extern DMD_ATSC_LOCK_STATUS MDrv_DMD_ATSC_GetLock(DMD_ATSC_GETLOCK_TYPE eType);
320 ////////////////////////////////////////////////////////////////////////////////
321 /// MDrv_DMD_ATSC_GetModulationMode
322 ////////////////////////////////////////////////////////////////////////////////
323 extern DMD_ATSC_DEMOD_TYPE MDrv_DMD_ATSC_GetModulationMode(void);
324 ////////////////////////////////////////////////////////////////////////////////
325 /// MDrv_DMD_DVBT_GetSignalStrength
326 ////////////////////////////////////////////////////////////////////////////////
327 extern MS_BOOL MDrv_DMD_ATSC_GetSignalStrength(MS_U16 *u16Strength);
328 ////////////////////////////////////////////////////////////////////////////////
329 /// MDrv_DMD_DVBT_GetSignalQuality
330 ////////////////////////////////////////////////////////////////////////////////
331 extern DMD_ATSC_SIGNAL_CONDITION MDrv_DMD_ATSC_GetSignalQuality(void);
332 ////////////////////////////////////////////////////////////////////////////////
333 /// MDrv_DMD_DVBT_GetCellID
334 ////////////////////////////////////////////////////////////////////////////////
335 extern MS_BOOL MDrv_DMD_ATSC_GetCellID(MS_U16 *u16CellID);
336 
337 extern MS_U32 MDrv_DMD_ATSC_SetPowerState(EN_POWER_MODE u16PowerState);
338 
339 #ifdef __cplusplus
340 }
341 #endif
342 
343 
344 #endif // _DRV_DVBT_H_
345 
346 #endif//#if 0
347