xref: /utopia/UTPA2-700.0.x/modules/demodulator/hal/maxim/demod/halDMD_INTERN_DVBS.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-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 #ifndef _INTERN_DVBS_H_
96 #define _INTERN_DVBS_H_
97 
98 #ifdef _INTERN_DVBS_C_
99 #define EXTSEL
100 #else
101 #define EXTSEL extern
102 #endif
103 
104 #define NEW_TR_MODULE
105 //--------------------------------------------------------------------
106 
107 // #define     DEMOD_DYNAMIC_SLAVE_ID_1          0x32
108 // #define     DEMOD_DYNAMIC_SLAVE_ID_2          0x72
109 // #define     DEMOD_DYNAMIC_SLAVE_ID_3          0xB2
110 // #define     DEMOD_DYNAMIC_SLAVE_ID_4          0xF2
111 
112 #define     DEMOD_ADDR_H            0x00
113 #define     DEMOD_ADDR_L            0x01
114 #define     DEMOD_WRITE_REG         0x02
115 #define     DEMOD_WRITE_REG_EX      0x03
116 #define     DEMOD_READ_REG          0x04
117 #define     DEMOD_RAM_CONTROL       0x05
118 
119 #if  0//DTV_SCAN_AUTO_FINE_TUNE_ENABLE
120     //INTERN_DVBT_ Capture Range fix to 500K
121     #define DEMOD_CAPTURE_RANGE_500_K            500
122     #define DEMOD_CAPTURE_RANGE_SIZE			 DEMOD_CAPTURE_RANGE_500_K
123 #endif
124 
125 #define MDrv_ReadByte(x)  HAL_DMD_RIU_ReadByte(x)
126 #define MDrv_WriteByte(x,y)  HAL_DMD_RIU_WriteByte(x,y)
127 
128 #if 1
129 #define U8      unsigned char
130 #define U16     unsigned short
131 #define U32     unsigned long
132 #define BOOL    unsigned char
133 #define BOOLEAN  unsigned char
134 #if 0
135 #define BIT0     0x01
136 #define BIT1     0x02
137 #define BIT2     0x04
138 #define BIT3     0x08
139 #define BIT4     0x10
140 #define BIT5     0x20
141 #define BIT6     0x40
142 #define BIT7     0x80
143 #endif
144 #define BYTE     MAPI_U8
145 
146 #define WORD     MAPI_WORD
147 #define E_RESULT_SUCCESS     MAPI_TRUE
148 #define E_RESULT_FAILURE     MAPI_FALSE
149 #define FUNCTION_RESULT      MAPI_BOOL
150 
151 
152 #define INTERN_DVBS_TS_SERIAL_INVERSION       			0
153 #define INTERN_DVBS_TS_PARALLEL_INVERSION     			1
154 #define INTERN_DVBS_DTV_DRIVING_LEVEL          			1
155 #define INTERN_DVBS_WEAK_SIGNAL_PICTURE_FREEZE_ENABLE  	1
156 #endif
157 
158 typedef struct
159 {
160     MS_U8        cmd_code;
161     MS_U8        param[64];
162 } S_CMDPKTREG;
163 typedef enum
164 {
165     TS_MODUL_MODE,
166     TS_FFX_VALUE,
167     TS_GUARD_INTERVAL,
168     TS_CODE_RATE,
169 
170     TS_PARAM_MAX_NUM
171 }E_SIGNAL_TYPE;
172 
173 typedef enum
174 {
175     CMD_SYSTEM_INIT = 0,
176     CMD_DAC_CALI,
177     CMD_DVBT_CONFIG,
178     CMD_DVBC_CONFIG,
179     CMD_VIF_CTRL,
180     CMD_FSM_CTRL,
181     CMD_INDIR_RREG,
182     CMD_INDIR_WREG,
183     CMD_GET_INFO,
184     CMD_TS_CTRL,
185     CMD_TUNED_VALUE,
186 
187     CMD_MAX_NUM
188 }E_CMD_CODE;
189 typedef enum
190 {
191     TS_PARALLEL = 0,
192     TS_SERIAL = 1,
193 
194     TS_MODE_MAX_NUM
195 }E_TS_MODE;
196 typedef enum
197 {
198     E_SYS_UNKOWN = -1,
199     E_SYS_DVBT,
200     E_SYS_DVBC,
201     E_SYS_ATSC,
202     E_SYS_VIF,
203     E_SYS_DVBS,
204 
205     E_SYS_NUM
206 }E_SYSTEM;
207 
208 //--------------------------------------------------------------------
209 MS_BOOL INTERN_DVBS_Reset ( void );
210 MS_U16 	INTERN_DVBS_DSPReg_Init(const MS_U8 *u8DVBS_DSPReg,  MS_U8 u8Size);
211 MS_BOOL INTERN_DVBS_Cmd_Packet_Send(S_CMDPKTREG* pCmdPacket, MS_U8 param_cnt);
212 MS_BOOL INTERN_DVBS_Exit ( void );
213 MS_BOOL INTERN_DVBS_Active(MS_BOOL bEnable);
214 
215 MS_BOOL INTERN_DVBS_GetPostViterbiBer(MS_U32 *BitErr, MS_U16 *BitErrPeriod);
216 
217 MS_BOOL INTERN_DVBS_GetPerViterbiBer(float *perber);
218 MS_BOOL INTERN_DVBS_GetPacketErr(MS_U16 *pktErr);
219 
220 MS_BOOL INTERN_DVBS_Power_On_Initialization(MS_BOOL bRFAGCTristateEnable, MS_U8 u8ADCIQMode, MS_U8 u8PadSel, MS_BOOL bPGAEnable, MS_U8 u8PGAGain, const MS_U8 *u8DMD_DVBS_DSPRegInitExt, MS_U8 u8DMD_DVBS_DSPRegInitSize);
221 
222 MS_BOOL INTERN_DVBS_Serial_Control(MS_BOOL bEnable, MS_U8 u8TSClk);
223 MS_BOOL INTERN_DVBS_Config(MS_U32 u32SymbolRate, DMD_DVBS_MODULATION_TYPE eQamMode, MS_U32 u32IFFreq, MS_BOOL bSpecInv, MS_BOOL bSerialTS, MS_U8 u8TSClk, MS_U16 *pu16_symbol_rate_list,MS_U8 u8_symbol_rate_list_num);
224 MS_BOOL INTERN_DVBS_BlindScan_Config(MS_U32 u32SymbolRate, DMD_DVBS_MODULATION_TYPE eQamMode, MS_U32 u32IFFreq, MS_BOOL bSpecInv, MS_BOOL bSerialTS, MS_U8 u8TSClk, MS_U16 *pu16_symbol_rate_list,MS_U8 u8_symbol_rate_list_num);
225 MS_BOOL INTERN_DVBS_Active(MS_BOOL bEnable);
226 MS_BOOL INTERN_DVBS_GetLock(DMD_DVBS_GETLOCK_TYPE eType, MS_U16 fCurrRFPowerDbm, MS_U16 fNoChannelRFPowerDbm, MS_U32 u32TimeInterval);
227 MS_BOOL INTERN_DVBS_GetSignalStrength(MS_U16 fRFPowerDbm, DMD_DVBS_DEMOD_TYPE *pDemodType, MS_U8  *u8_DVBS2_CurrentCodeRateLocal,  MS_U8   *u8_DVBS2_CurrentConstellationLocal);
228 //MS_BOOL INTERN_DVBS_GetSignalQuality(MS_U16 *quality, const DMD_DVBS_InitData *sDMD_DVBS_InitData, MS_U8 u8SarValue, float fRFPowerDbm);
229 
230 MS_BOOL INTERN_DVBS_GetSNR(MS_U32 *u32NDA_SNR_A, MS_U32 *u32NDA_SNR_AB);
231 
232 MS_BOOL INTERN_DVBS_GetIFAGC(MS_U8 *ifagc_reg, MS_U8 *ifagc_reg_lsb, MS_U16 *ifagc_err);
233 MS_BOOL INTERN_DVBS_Get_CELL_ID(MS_U16 *cell_id);
234 // MS_BOOL INTERN_DVBC_Get_TPS_Parameter_Const( MS_U16 * TPS_parameter, E_SIGNAL_TYPE eSignalType);
235 MS_BOOL INTERN_DVBS_Version(MS_U16 *ver);
236 MS_BOOL INTERN_DVBS_GetCurrentSymbolRate(MS_U32 *u32SymbolRate);
237 MS_BOOL INTERN_DVBS_Get_FreqOffset(MS_S16 *s16CFO);
238 
239 void INTERN_DVBS_info(void);
240 MS_BOOL INTERN_DVBS_Show_AGC_Info(void);
241 MS_BOOL INTERN_DVBS_GetTsDivNum(MS_U32 *u32SymbolRate, MS_U8* system_type_reg, MS_U8 *code_rate_idx, MS_U8 *fec_type_idx, MS_U8 *pilot_flag, MS_U32 *u32temp, MS_U8 *code_rate_reg);
242 MS_BOOL INTERN_DVBS_GetCurrentModulationType(DMD_DVBS_MODULATION_TYPE *pQAMMode);
243 MS_BOOL INTERN_DVBS_GetCurrentDemodType(DMD_DVBS_DEMOD_TYPE *pDemodType);
244 MS_BOOL INTERN_DVBS_GetCurrentDemodCodeRate(DMD_DVBS_CODE_RATE_TYPE *pCodeRate);
245 MS_BOOL INTERN_DVBS_GetTunrSignalLevel_PWR(MS_U16 *u16Data);
246 //--------------------------------------------------------------------
247 MS_BOOL INTERN_DVBS_GetRollOff(MS_U8 *pRollOff);
248 MS_BOOL INTERN_DVBS_BlindScan_GetTunerFreq(MS_U16 *u16TunerCenterFreq, MS_U16 *u16TunerCutOffFreq);
249 
250 MS_BOOL INTERN_DVBS_BlindScan_Start(MS_U16 u16StartFreq,MS_U16 u16EndFreq);
251 MS_BOOL INTERN_DVBS_BlindScan_NextFreq(MS_BOOL* bBlindScanEnd);
252 MS_BOOL INTERN_DVBS_BlindScan_Cancel(void);
253 MS_BOOL INTERN_DVBS_BlindScan_End(void);
254 MS_BOOL INTERN_DVBS_BlindScan_GetChannel(MS_U16 u16ReadStart,MS_U16* u16TPNum,HAL_DEMOD_MS_FE_CARRIER_PARAM *pTable);
255 MS_BOOL INTERN_DVBS_BlindScan_GetCurrentFreq(MS_U32 *u32CurrentFeq);
256 MS_BOOL INTERN_DVBS_BlindScan_WaitCurFreqFinished(MS_U8* u8Progress,MS_U8 *u8FindNum, MS_U8 *substate_reg, MS_U32  *u32Data, MS_U16 *symbolrate_reg, MS_U16 *CFO_reg);
257 
258 MS_BOOL INTERN_DVBS_DiSEqC_Init(void);
259 MS_BOOL INTERN_DVBS_DiSEqC_SetLNBOut(MS_BOOL bLow);
260 MS_BOOL INTERN_DVBS_DiSEqC_GetLNBOut(MS_BOOL* bLNBOutLow);
261 MS_BOOL INTERN_DVBS_DiSEqC_Set22kOnOff(MS_BOOL b22kOn);
262 MS_BOOL INTERN_DVBS_DiSEqC_Get22kOnOff(MS_BOOL* b22kOn);
263 MS_BOOL INTERN_DVBS_DiSEqC_SendCmd(MS_U8* pCmd,MS_U8 u8CmdSize);
264 MS_BOOL INTERN_DVBS_DiSEqC_SetTxToneMode(MS_BOOL bTxTone22kOff);
265 MS_BOOL INTERN_DVBS_DiSEqC_SetTone(MS_BOOL bTone1);
266 MS_BOOL INTERN_DVBS_UnicableAGCCheckPower(MS_BOOL pbAGCCheckPower);
267 
268 //MS_BOOL INTERN_DVBS_Demod_Restart(MS_U32 u32SymbolRate, MS_U32 u32Frequency);
269 MS_BOOL INTERN_DVBS_Get_DTV_SQuality_BAR(MS_U8 *u8_gSQValue);
270 MS_BOOL INTERN_DVBS_Demod_Get_Debug_Info_get_once(void);
271 MS_BOOL INTERN_DVBS_Demod_Get_Debug_Info_polling(void);
272 MS_BOOL INTERN_DVBS_WriteReg2bytes(MS_U16 u16Addr, MS_U16 u16Data);
273 MS_BOOL INTERN_DVBS_ReadReg2bytes(MS_U16 u16Addr, MS_U16 *pu16Data);
274 MS_BOOL INTERN_DVBS_DTV_FrontendSetFreeze(void);
275 MS_BOOL INTERN_DVBS_DTV_FrontendUnFreeze(void);
276 MS_BOOL INTERN_DVBS_DTV_InnerSetFreeze(void);
277 MS_BOOL INTERN_DVBS_DTV_InnerUnFreeze(void);
278 MS_BOOL INTERN_DVBS_PowerSaving (void);
279 
280 #define INTERN_DVBS_LOAD_FW_FROM_CODE_MEMORY
281 
282 #undef EXTSEL
283 #endif
284 
285