blob: f7ed9a72db4a1a0084915f91e35d7f4489f59adc [file] [log] [blame]
Steven Toth52c99bd2008-05-01 04:57:01 -03001/*
Steven Toth7f5c3af2008-05-01 06:51:36 -03002 MaxLinear MXL5005S VSB/QAM/DVBT tuner driver
3
4 Copyright (C) 2008 MaxLinear
5 Copyright (C) 2006 Steven Toth <stoth@hauppauge.com>
6 Functions:
7 mxl5005s_reset()
8 mxl5005s_writereg()
9 mxl5005s_writeregs()
10 mxl5005s_init()
11 mxl5005s_reconfigure()
12 mxl5005s_AssignTunerMode()
13 mxl5005s_set_params()
14 mxl5005s_get_frequency()
15 mxl5005s_get_bandwidth()
16 mxl5005s_release()
17 mxl5005s_attach()
18
19 Copyright (c) 2008 Realtek
20 Copyright (c) 2008 Jan Hoogenraad, Barnaby Shearer, Andy Hasper
21 Functions:
22 mxl5005s_SetRfFreqHz()
23
24 This program is free software; you can redistribute it and/or modify
25 it under the terms of the GNU General Public License as published by
26 the Free Software Foundation; either version 2 of the License, or
27 (at your option) any later version.
28
29 This program is distributed in the hope that it will be useful,
30 but WITHOUT ANY WARRANTY; without even the implied warranty of
31 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
32 GNU General Public License for more details.
33
34 You should have received a copy of the GNU General Public License
35 along with this program; if not, write to the Free Software
36 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
37
38*/
39
40/*
41 History of this driver (Steven Toth):
42 I was given a public release of a linux driver that included
43 support for the MaxLinear MXL5005S silicon tuner. Analysis of
44 the tuner driver showed clearly three things.
45
46 1. The tuner driver didn't support the LinuxTV tuner API
47 so the code Realtek added had to be removed.
48
49 2. A significant amount of the driver is reference driver code
50 from MaxLinear, I felt it was important to identify and
51 preserve this.
52
53 3. New code has to be added to interface correctly with the
54 LinuxTV API, as a regular kernel module.
55
56 Other than the reference driver enum's, I've clearly marked
57 sections of the code and retained the copyright of the
58 respective owners.
59*/
Steven Toth52c99bd2008-05-01 04:57:01 -030060
Steven Toth2637d5b2008-05-01 05:01:31 -030061#include "mxl5005s.h"
Steven Toth52c99bd2008-05-01 04:57:01 -030062
Steven Toth8c66a192008-05-01 06:35:48 -030063static int debug = 2;
Steven Toth85d220d2008-05-01 05:48:14 -030064
65#define dprintk(level, arg...) do { \
Steven Toth8c66a192008-05-01 06:35:48 -030066 if (level <= debug) \
Steven Toth85d220d2008-05-01 05:48:14 -030067 printk(arg); \
68 } while (0)
69
70#define TUNER_REGS_NUM 104
71#define INITCTRL_NUM 40
72
73#ifdef _MXL_PRODUCTION
74#define CHCTRL_NUM 39
75#else
76#define CHCTRL_NUM 36
77#endif
78
79#define MXLCTRL_NUM 189
80#define MASTER_CONTROL_ADDR 9
81
Steven Toth85d220d2008-05-01 05:48:14 -030082/* Enumeration of Master Control Register State */
83typedef enum
84{
85 MC_LOAD_START = 1,
86 MC_POWER_DOWN,
87 MC_SYNTH_RESET,
88 MC_SEQ_OFF
89} Master_Control_State;
90
Steven Toth85d220d2008-05-01 05:48:14 -030091/* Enumeration of MXL5005 Tuner Modulation Type */
92typedef enum
93{
94 MXL_DEFAULT_MODULATION = 0,
95 MXL_DVBT,
96 MXL_ATSC,
97 MXL_QAM,
98 MXL_ANALOG_CABLE,
99 MXL_ANALOG_OTA
100} Tuner_Modu_Type;
101
Steven Toth85d220d2008-05-01 05:48:14 -0300102/* MXL5005 Tuner Register Struct */
103typedef struct _TunerReg_struct
104{
105 u16 Reg_Num; /* Tuner Register Address */
106 u16 Reg_Val; /* Current sofware programmed value waiting to be writen */
107} TunerReg_struct;
108
109typedef enum
110{
111 /* Initialization Control Names */
112 DN_IQTN_AMP_CUT = 1, /* 1 */
113 BB_MODE, /* 2 */
114 BB_BUF, /* 3 */
115 BB_BUF_OA, /* 4 */
116 BB_ALPF_BANDSELECT, /* 5 */
117 BB_IQSWAP, /* 6 */
118 BB_DLPF_BANDSEL, /* 7 */
119 RFSYN_CHP_GAIN, /* 8 */
120 RFSYN_EN_CHP_HIGAIN, /* 9 */
121 AGC_IF, /* 10 */
122 AGC_RF, /* 11 */
123 IF_DIVVAL, /* 12 */
124 IF_VCO_BIAS, /* 13 */
125 CHCAL_INT_MOD_IF, /* 14 */
126 CHCAL_FRAC_MOD_IF, /* 15 */
127 DRV_RES_SEL, /* 16 */
128 I_DRIVER, /* 17 */
129 EN_AAF, /* 18 */
130 EN_3P, /* 19 */
131 EN_AUX_3P, /* 20 */
132 SEL_AAF_BAND, /* 21 */
133 SEQ_ENCLK16_CLK_OUT, /* 22 */
134 SEQ_SEL4_16B, /* 23 */
135 XTAL_CAPSELECT, /* 24 */
136 IF_SEL_DBL, /* 25 */
137 RFSYN_R_DIV, /* 26 */
138 SEQ_EXTSYNTHCALIF, /* 27 */
139 SEQ_EXTDCCAL, /* 28 */
140 AGC_EN_RSSI, /* 29 */
141 RFA_ENCLKRFAGC, /* 30 */
142 RFA_RSSI_REFH, /* 31 */
143 RFA_RSSI_REF, /* 32 */
144 RFA_RSSI_REFL, /* 33 */
145 RFA_FLR, /* 34 */
146 RFA_CEIL, /* 35 */
147 SEQ_EXTIQFSMPULSE, /* 36 */
148 OVERRIDE_1, /* 37 */
149 BB_INITSTATE_DLPF_TUNE, /* 38 */
150 TG_R_DIV, /* 39 */
151 EN_CHP_LIN_B, /* 40 */
152
153 /* Channel Change Control Names */
154 DN_POLY = 51, /* 51 */
155 DN_RFGAIN, /* 52 */
156 DN_CAP_RFLPF, /* 53 */
157 DN_EN_VHFUHFBAR, /* 54 */
158 DN_GAIN_ADJUST, /* 55 */
159 DN_IQTNBUF_AMP, /* 56 */
160 DN_IQTNGNBFBIAS_BST, /* 57 */
161 RFSYN_EN_OUTMUX, /* 58 */
162 RFSYN_SEL_VCO_OUT, /* 59 */
163 RFSYN_SEL_VCO_HI, /* 60 */
164 RFSYN_SEL_DIVM, /* 61 */
165 RFSYN_RF_DIV_BIAS, /* 62 */
166 DN_SEL_FREQ, /* 63 */
167 RFSYN_VCO_BIAS, /* 64 */
168 CHCAL_INT_MOD_RF, /* 65 */
169 CHCAL_FRAC_MOD_RF, /* 66 */
170 RFSYN_LPF_R, /* 67 */
171 CHCAL_EN_INT_RF, /* 68 */
172 TG_LO_DIVVAL, /* 69 */
173 TG_LO_SELVAL, /* 70 */
174 TG_DIV_VAL, /* 71 */
175 TG_VCO_BIAS, /* 72 */
176 SEQ_EXTPOWERUP, /* 73 */
177 OVERRIDE_2, /* 74 */
178 OVERRIDE_3, /* 75 */
179 OVERRIDE_4, /* 76 */
180 SEQ_FSM_PULSE, /* 77 */
181 GPIO_4B, /* 78 */
182 GPIO_3B, /* 79 */
183 GPIO_4, /* 80 */
184 GPIO_3, /* 81 */
185 GPIO_1B, /* 82 */
186 DAC_A_ENABLE, /* 83 */
187 DAC_B_ENABLE, /* 84 */
188 DAC_DIN_A, /* 85 */
189 DAC_DIN_B, /* 86 */
190#ifdef _MXL_PRODUCTION
191 RFSYN_EN_DIV, /* 87 */
192 RFSYN_DIVM, /* 88 */
193 DN_BYPASS_AGC_I2C /* 89 */
194#endif
195} MXL5005_ControlName;
196
197/*
198 * The following context is source code provided by MaxLinear.
199 * MaxLinear source code - Common_MXL.h (?)
200 */
201
202/* Constants */
203#define MXL5005S_REG_WRITING_TABLE_LEN_MAX 104
204#define MXL5005S_LATCH_BYTE 0xfe
205
206/* Register address, MSB, and LSB */
207#define MXL5005S_BB_IQSWAP_ADDR 59
208#define MXL5005S_BB_IQSWAP_MSB 0
209#define MXL5005S_BB_IQSWAP_LSB 0
210
211#define MXL5005S_BB_DLPF_BANDSEL_ADDR 53
212#define MXL5005S_BB_DLPF_BANDSEL_MSB 4
213#define MXL5005S_BB_DLPF_BANDSEL_LSB 3
214
215/* Standard modes */
216enum
217{
218 MXL5005S_STANDARD_DVBT,
219 MXL5005S_STANDARD_ATSC,
220};
221#define MXL5005S_STANDARD_MODE_NUM 2
222
223/* Bandwidth modes */
224enum
225{
226 MXL5005S_BANDWIDTH_6MHZ = 6000000,
227 MXL5005S_BANDWIDTH_7MHZ = 7000000,
228 MXL5005S_BANDWIDTH_8MHZ = 8000000,
229};
230#define MXL5005S_BANDWIDTH_MODE_NUM 3
231
Steven Toth3935c252008-05-01 05:45:44 -0300232/* MXL5005 Tuner Control Struct */
233typedef struct _TunerControl_struct {
234 u16 Ctrl_Num; /* Control Number */
235 u16 size; /* Number of bits to represent Value */
236 u16 addr[25]; /* Array of Tuner Register Address for each bit position */
237 u16 bit[25]; /* Array of bit position in Register Address for each bit position */
238 u16 val[25]; /* Binary representation of Value */
239} TunerControl_struct;
Steven Toth52c99bd2008-05-01 04:57:01 -0300240
Steven Toth3935c252008-05-01 05:45:44 -0300241/* MXL5005 Tuner Struct */
242struct mxl5005s_state
Steven Toth52c99bd2008-05-01 04:57:01 -0300243{
Steven Toth3935c252008-05-01 05:45:44 -0300244 u8 Mode; /* 0: Analog Mode ; 1: Digital Mode */
245 u8 IF_Mode; /* for Analog Mode, 0: zero IF; 1: low IF */
246 u32 Chan_Bandwidth; /* filter channel bandwidth (6, 7, 8) */
247 u32 IF_OUT; /* Desired IF Out Frequency */
248 u16 IF_OUT_LOAD; /* IF Out Load Resistor (200/300 Ohms) */
249 u32 RF_IN; /* RF Input Frequency */
250 u32 Fxtal; /* XTAL Frequency */
251 u8 AGC_Mode; /* AGC Mode 0: Dual AGC; 1: Single AGC */
252 u16 TOP; /* Value: take over point */
253 u8 CLOCK_OUT; /* 0: turn off clock out; 1: turn on clock out */
254 u8 DIV_OUT; /* 4MHz or 16MHz */
255 u8 CAPSELECT; /* 0: disable On-Chip pulling cap; 1: enable */
256 u8 EN_RSSI; /* 0: disable RSSI; 1: enable RSSI */
257 u8 Mod_Type; /* Modulation Type; */
258 /* 0 - Default; 1 - DVB-T; 2 - ATSC; 3 - QAM; 4 - Analog Cable */
259 u8 TF_Type; /* Tracking Filter Type */
260 /* 0 - Default; 1 - Off; 2 - Type C; 3 - Type C-H */
Steven Toth52c99bd2008-05-01 04:57:01 -0300261
Steven Toth3935c252008-05-01 05:45:44 -0300262 /* Calculated Settings */
263 u32 RF_LO; /* Synth RF LO Frequency */
264 u32 IF_LO; /* Synth IF LO Frequency */
265 u32 TG_LO; /* Synth TG_LO Frequency */
Steven Toth52c99bd2008-05-01 04:57:01 -0300266
Steven Toth3935c252008-05-01 05:45:44 -0300267 /* Pointers to ControlName Arrays */
268 u16 Init_Ctrl_Num; /* Number of INIT Control Names */
269 TunerControl_struct
270 Init_Ctrl[INITCTRL_NUM]; /* INIT Control Names Array Pointer */
Steven Toth52c99bd2008-05-01 04:57:01 -0300271
Steven Toth3935c252008-05-01 05:45:44 -0300272 u16 CH_Ctrl_Num; /* Number of CH Control Names */
273 TunerControl_struct
274 CH_Ctrl[CHCTRL_NUM]; /* CH Control Name Array Pointer */
Steven Toth52c99bd2008-05-01 04:57:01 -0300275
Steven Toth3935c252008-05-01 05:45:44 -0300276 u16 MXL_Ctrl_Num; /* Number of MXL Control Names */
277 TunerControl_struct
278 MXL_Ctrl[MXLCTRL_NUM]; /* MXL Control Name Array Pointer */
Steven Toth52c99bd2008-05-01 04:57:01 -0300279
Steven Toth3935c252008-05-01 05:45:44 -0300280 /* Pointer to Tuner Register Array */
281 u16 TunerRegs_Num; /* Number of Tuner Registers */
282 TunerReg_struct
283 TunerRegs[TUNER_REGS_NUM]; /* Tuner Register Array Pointer */
Steven Toth52c99bd2008-05-01 04:57:01 -0300284
Steven Toth85d220d2008-05-01 05:48:14 -0300285 /* Linux driver framework specific */
Steven Toth8c66a192008-05-01 06:35:48 -0300286 struct mxl5005s_config *config;
Steven Toth85d220d2008-05-01 05:48:14 -0300287 struct dvb_frontend *frontend;
288 struct i2c_adapter *i2c;
Steven Toth7f5c3af2008-05-01 06:51:36 -0300289
290 /* Cache values */
291 u32 current_mode;
292
Steven Toth3935c252008-05-01 05:45:44 -0300293};
Steven Toth52c99bd2008-05-01 04:57:01 -0300294
Steven Toth85d220d2008-05-01 05:48:14 -0300295u16 MXL_ControlWrite(struct dvb_frontend *fe, u16 ControlNum, u32 value);
296u16 MXL_ControlRead(struct dvb_frontend *fe, u16 controlNum, u32 *value);
297u16 MXL_GetMasterControl(u8 *MasterReg, int state);
298void MXL_RegWriteBit(struct dvb_frontend *fe, u8 address, u8 bit, u8 bitVal);
299u16 MXL_GetCHRegister(struct dvb_frontend *fe, u8 *RegNum, u8 *RegVal, int *count);
300u32 MXL_Ceiling(u32 value, u32 resolution);
301u16 MXL_RegRead(struct dvb_frontend *fe, u8 RegNum, u8 *RegVal);
302u16 MXL_RegWrite(struct dvb_frontend *fe, u8 RegNum, u8 RegVal);
303u16 MXL_ControlWrite_Group(struct dvb_frontend *fe, u16 controlNum, u32 value, u16 controlGroup);
304u16 MXL_SetGPIO(struct dvb_frontend *fe, u8 GPIO_Num, u8 GPIO_Val);
305u16 MXL_GetInitRegister(struct dvb_frontend *fe, u8 * RegNum, u8 *RegVal, int *count);
306u32 MXL_GetXtalInt(u32 Xtal_Freq);
307u16 MXL_TuneRF(struct dvb_frontend *fe, u32 RF_Freq);
308void MXL_SynthIFLO_Calc(struct dvb_frontend *fe);
309void MXL_SynthRFTGLO_Calc(struct dvb_frontend *fe);
310u16 MXL_GetCHRegister_ZeroIF(struct dvb_frontend *fe, u8 *RegNum, u8 *RegVal, int *count);
Steven Toth7f5c3af2008-05-01 06:51:36 -0300311int mxl5005s_writeregs(struct dvb_frontend *fe, u8 *addrtable, u8 *datatable, u8 len);
Steven Toth85d220d2008-05-01 05:48:14 -0300312u16 MXL_IFSynthInit(struct dvb_frontend *fe);
Steven Toth7f5c3af2008-05-01 06:51:36 -0300313int mxl5005s_AssignTunerMode(struct dvb_frontend *fe, u32 mod_type, u32 bandwidth);
314int mxl5005s_reconfigure(struct dvb_frontend *fe, u32 mod_type, u32 bandwidth);
315
316/* ----------------------------------------------------------------
317 * Begin: Custom code salvaged from the Realtek driver.
318 * Copyright (c) 2008 Realtek
319 * Copyright (c) 2008 Jan Hoogenraad, Barnaby Shearer, Andy Hasper
320 * This code is placed under the terms of the GNU General Public License
321 *
322 * Released by Realtek under GPLv2.
323 * Thanks to Realtek for a lot of support we received !
324 *
325 * Revision: 080314 - original version
326 */
Steven Toth52c99bd2008-05-01 04:57:01 -0300327
Steven Toth85d220d2008-05-01 05:48:14 -0300328int mxl5005s_SetRfFreqHz(struct dvb_frontend *fe, unsigned long RfFreqHz)
Steven Toth52c99bd2008-05-01 04:57:01 -0300329{
Steven Toth85d220d2008-05-01 05:48:14 -0300330 struct mxl5005s_state *state = fe->tuner_priv;
Steven Toth52c99bd2008-05-01 04:57:01 -0300331 unsigned char AddrTable[MXL5005S_REG_WRITING_TABLE_LEN_MAX];
332 unsigned char ByteTable[MXL5005S_REG_WRITING_TABLE_LEN_MAX];
333 int TableLen;
334
Steven Toth85d220d2008-05-01 05:48:14 -0300335 u32 IfDivval;
Steven Toth52c99bd2008-05-01 04:57:01 -0300336 unsigned char MasterControlByte;
337
Steven Toth85d220d2008-05-01 05:48:14 -0300338 dprintk(1, "%s() freq=%ld\n", __func__, RfFreqHz);
Steven Toth52c99bd2008-05-01 04:57:01 -0300339
340 // Set MxL5005S tuner RF frequency according to MxL5005S tuner example code.
341
342 // Tuner RF frequency setting stage 0
343 MXL_GetMasterControl(ByteTable, MC_SYNTH_RESET) ;
344 AddrTable[0] = MASTER_CONTROL_ADDR;
Steven Toth85d220d2008-05-01 05:48:14 -0300345 ByteTable[0] |= state->config->AgcMasterByte;
Steven Toth52c99bd2008-05-01 04:57:01 -0300346
Steven Toth7f5c3af2008-05-01 06:51:36 -0300347 mxl5005s_writeregs(fe, AddrTable, ByteTable, 1);
Steven Toth52c99bd2008-05-01 04:57:01 -0300348
349 // Tuner RF frequency setting stage 1
Steven Toth85d220d2008-05-01 05:48:14 -0300350 MXL_TuneRF(fe, RfFreqHz);
Steven Toth52c99bd2008-05-01 04:57:01 -0300351
Steven Toth85d220d2008-05-01 05:48:14 -0300352 MXL_ControlRead(fe, IF_DIVVAL, &IfDivval);
Steven Toth52c99bd2008-05-01 04:57:01 -0300353
Steven Toth85d220d2008-05-01 05:48:14 -0300354 MXL_ControlWrite(fe, SEQ_FSM_PULSE, 0);
355 MXL_ControlWrite(fe, SEQ_EXTPOWERUP, 1);
356 MXL_ControlWrite(fe, IF_DIVVAL, 8);
357 MXL_GetCHRegister(fe, AddrTable, ByteTable, &TableLen) ;
Steven Toth52c99bd2008-05-01 04:57:01 -0300358
359 MXL_GetMasterControl(&MasterControlByte, MC_LOAD_START) ;
360 AddrTable[TableLen] = MASTER_CONTROL_ADDR ;
Steven Toth8c66a192008-05-01 06:35:48 -0300361 ByteTable[TableLen] = MasterControlByte | state->config->AgcMasterByte;
Steven Toth52c99bd2008-05-01 04:57:01 -0300362 TableLen += 1;
363
Steven Toth7f5c3af2008-05-01 06:51:36 -0300364 mxl5005s_writeregs(fe, AddrTable, ByteTable, TableLen);
Steven Toth52c99bd2008-05-01 04:57:01 -0300365
366 // Wait 30 ms.
Steven Toth8c66a192008-05-01 06:35:48 -0300367 msleep(150);
Steven Toth52c99bd2008-05-01 04:57:01 -0300368
369 // Tuner RF frequency setting stage 2
Steven Toth85d220d2008-05-01 05:48:14 -0300370 MXL_ControlWrite(fe, SEQ_FSM_PULSE, 1) ;
371 MXL_ControlWrite(fe, IF_DIVVAL, IfDivval) ;
372 MXL_GetCHRegister_ZeroIF(fe, AddrTable, ByteTable, &TableLen) ;
Steven Toth52c99bd2008-05-01 04:57:01 -0300373
374 MXL_GetMasterControl(&MasterControlByte, MC_LOAD_START) ;
375 AddrTable[TableLen] = MASTER_CONTROL_ADDR ;
Steven Toth8c66a192008-05-01 06:35:48 -0300376 ByteTable[TableLen] = MasterControlByte | state->config->AgcMasterByte ;
Steven Toth52c99bd2008-05-01 04:57:01 -0300377 TableLen += 1;
378
Steven Toth7f5c3af2008-05-01 06:51:36 -0300379 mxl5005s_writeregs(fe, AddrTable, ByteTable, TableLen);
Steven Toth52c99bd2008-05-01 04:57:01 -0300380
Steven Toth8c66a192008-05-01 06:35:48 -0300381 msleep(100);
382
Steven Toth85d220d2008-05-01 05:48:14 -0300383 return 0;
Steven Toth52c99bd2008-05-01 04:57:01 -0300384}
Steven Toth7f5c3af2008-05-01 06:51:36 -0300385/* End: Custom code taken from the Realtek driver */
Steven Toth52c99bd2008-05-01 04:57:01 -0300386
Steven Toth7f5c3af2008-05-01 06:51:36 -0300387/* ----------------------------------------------------------------
388 * Begin: Reference driver code found in the Realtek driver.
389 * Copyright (c) 2008 MaxLinear
390 */
Steven Toth3935c252008-05-01 05:45:44 -0300391u16 MXL5005_RegisterInit(struct dvb_frontend *fe)
Steven Toth52c99bd2008-05-01 04:57:01 -0300392{
Steven Toth85d220d2008-05-01 05:48:14 -0300393 struct mxl5005s_state *state = fe->tuner_priv;
Steven Toth3935c252008-05-01 05:45:44 -0300394 state->TunerRegs_Num = TUNER_REGS_NUM ;
395// state->TunerRegs = (TunerReg_struct *) calloc( TUNER_REGS_NUM, sizeof(TunerReg_struct) ) ;
Steven Toth52c99bd2008-05-01 04:57:01 -0300396
Steven Toth3935c252008-05-01 05:45:44 -0300397 state->TunerRegs[0].Reg_Num = 9 ;
398 state->TunerRegs[0].Reg_Val = 0x40 ;
Steven Toth52c99bd2008-05-01 04:57:01 -0300399
Steven Toth3935c252008-05-01 05:45:44 -0300400 state->TunerRegs[1].Reg_Num = 11 ;
401 state->TunerRegs[1].Reg_Val = 0x19 ;
Steven Toth52c99bd2008-05-01 04:57:01 -0300402
Steven Toth3935c252008-05-01 05:45:44 -0300403 state->TunerRegs[2].Reg_Num = 12 ;
404 state->TunerRegs[2].Reg_Val = 0x60 ;
Steven Toth52c99bd2008-05-01 04:57:01 -0300405
Steven Toth3935c252008-05-01 05:45:44 -0300406 state->TunerRegs[3].Reg_Num = 13 ;
407 state->TunerRegs[3].Reg_Val = 0x00 ;
Steven Toth52c99bd2008-05-01 04:57:01 -0300408
Steven Toth3935c252008-05-01 05:45:44 -0300409 state->TunerRegs[4].Reg_Num = 14 ;
410 state->TunerRegs[4].Reg_Val = 0x00 ;
Steven Toth52c99bd2008-05-01 04:57:01 -0300411
Steven Toth3935c252008-05-01 05:45:44 -0300412 state->TunerRegs[5].Reg_Num = 15 ;
413 state->TunerRegs[5].Reg_Val = 0xC0 ;
Steven Toth52c99bd2008-05-01 04:57:01 -0300414
Steven Toth3935c252008-05-01 05:45:44 -0300415 state->TunerRegs[6].Reg_Num = 16 ;
416 state->TunerRegs[6].Reg_Val = 0x00 ;
Steven Toth52c99bd2008-05-01 04:57:01 -0300417
Steven Toth3935c252008-05-01 05:45:44 -0300418 state->TunerRegs[7].Reg_Num = 17 ;
419 state->TunerRegs[7].Reg_Val = 0x00 ;
Steven Toth52c99bd2008-05-01 04:57:01 -0300420
Steven Toth3935c252008-05-01 05:45:44 -0300421 state->TunerRegs[8].Reg_Num = 18 ;
422 state->TunerRegs[8].Reg_Val = 0x00 ;
Steven Toth52c99bd2008-05-01 04:57:01 -0300423
Steven Toth3935c252008-05-01 05:45:44 -0300424 state->TunerRegs[9].Reg_Num = 19 ;
425 state->TunerRegs[9].Reg_Val = 0x34 ;
Steven Toth52c99bd2008-05-01 04:57:01 -0300426
Steven Toth3935c252008-05-01 05:45:44 -0300427 state->TunerRegs[10].Reg_Num = 21 ;
428 state->TunerRegs[10].Reg_Val = 0x00 ;
Steven Toth52c99bd2008-05-01 04:57:01 -0300429
Steven Toth3935c252008-05-01 05:45:44 -0300430 state->TunerRegs[11].Reg_Num = 22 ;
431 state->TunerRegs[11].Reg_Val = 0x6B ;
Steven Toth52c99bd2008-05-01 04:57:01 -0300432
Steven Toth3935c252008-05-01 05:45:44 -0300433 state->TunerRegs[12].Reg_Num = 23 ;
434 state->TunerRegs[12].Reg_Val = 0x35 ;
Steven Toth52c99bd2008-05-01 04:57:01 -0300435
Steven Toth3935c252008-05-01 05:45:44 -0300436 state->TunerRegs[13].Reg_Num = 24 ;
437 state->TunerRegs[13].Reg_Val = 0x70 ;
Steven Toth52c99bd2008-05-01 04:57:01 -0300438
Steven Toth3935c252008-05-01 05:45:44 -0300439 state->TunerRegs[14].Reg_Num = 25 ;
440 state->TunerRegs[14].Reg_Val = 0x3E ;
Steven Toth52c99bd2008-05-01 04:57:01 -0300441
Steven Toth3935c252008-05-01 05:45:44 -0300442 state->TunerRegs[15].Reg_Num = 26 ;
443 state->TunerRegs[15].Reg_Val = 0x82 ;
Steven Toth52c99bd2008-05-01 04:57:01 -0300444
Steven Toth3935c252008-05-01 05:45:44 -0300445 state->TunerRegs[16].Reg_Num = 31 ;
446 state->TunerRegs[16].Reg_Val = 0x00 ;
Steven Toth52c99bd2008-05-01 04:57:01 -0300447
Steven Toth3935c252008-05-01 05:45:44 -0300448 state->TunerRegs[17].Reg_Num = 32 ;
449 state->TunerRegs[17].Reg_Val = 0x40 ;
Steven Toth52c99bd2008-05-01 04:57:01 -0300450
Steven Toth3935c252008-05-01 05:45:44 -0300451 state->TunerRegs[18].Reg_Num = 33 ;
452 state->TunerRegs[18].Reg_Val = 0x53 ;
Steven Toth52c99bd2008-05-01 04:57:01 -0300453
Steven Toth3935c252008-05-01 05:45:44 -0300454 state->TunerRegs[19].Reg_Num = 34 ;
455 state->TunerRegs[19].Reg_Val = 0x81 ;
Steven Toth52c99bd2008-05-01 04:57:01 -0300456
Steven Toth3935c252008-05-01 05:45:44 -0300457 state->TunerRegs[20].Reg_Num = 35 ;
458 state->TunerRegs[20].Reg_Val = 0xC9 ;
Steven Toth52c99bd2008-05-01 04:57:01 -0300459
Steven Toth3935c252008-05-01 05:45:44 -0300460 state->TunerRegs[21].Reg_Num = 36 ;
461 state->TunerRegs[21].Reg_Val = 0x01 ;
Steven Toth52c99bd2008-05-01 04:57:01 -0300462
Steven Toth3935c252008-05-01 05:45:44 -0300463 state->TunerRegs[22].Reg_Num = 37 ;
464 state->TunerRegs[22].Reg_Val = 0x00 ;
Steven Toth52c99bd2008-05-01 04:57:01 -0300465
Steven Toth3935c252008-05-01 05:45:44 -0300466 state->TunerRegs[23].Reg_Num = 41 ;
467 state->TunerRegs[23].Reg_Val = 0x00 ;
Steven Toth52c99bd2008-05-01 04:57:01 -0300468
Steven Toth3935c252008-05-01 05:45:44 -0300469 state->TunerRegs[24].Reg_Num = 42 ;
470 state->TunerRegs[24].Reg_Val = 0xF8 ;
Steven Toth52c99bd2008-05-01 04:57:01 -0300471
Steven Toth3935c252008-05-01 05:45:44 -0300472 state->TunerRegs[25].Reg_Num = 43 ;
473 state->TunerRegs[25].Reg_Val = 0x43 ;
Steven Toth52c99bd2008-05-01 04:57:01 -0300474
Steven Toth3935c252008-05-01 05:45:44 -0300475 state->TunerRegs[26].Reg_Num = 44 ;
476 state->TunerRegs[26].Reg_Val = 0x20 ;
Steven Toth52c99bd2008-05-01 04:57:01 -0300477
Steven Toth3935c252008-05-01 05:45:44 -0300478 state->TunerRegs[27].Reg_Num = 45 ;
479 state->TunerRegs[27].Reg_Val = 0x80 ;
Steven Toth52c99bd2008-05-01 04:57:01 -0300480
Steven Toth3935c252008-05-01 05:45:44 -0300481 state->TunerRegs[28].Reg_Num = 46 ;
482 state->TunerRegs[28].Reg_Val = 0x88 ;
Steven Toth52c99bd2008-05-01 04:57:01 -0300483
Steven Toth3935c252008-05-01 05:45:44 -0300484 state->TunerRegs[29].Reg_Num = 47 ;
485 state->TunerRegs[29].Reg_Val = 0x86 ;
Steven Toth52c99bd2008-05-01 04:57:01 -0300486
Steven Toth3935c252008-05-01 05:45:44 -0300487 state->TunerRegs[30].Reg_Num = 48 ;
488 state->TunerRegs[30].Reg_Val = 0x00 ;
Steven Toth52c99bd2008-05-01 04:57:01 -0300489
Steven Toth3935c252008-05-01 05:45:44 -0300490 state->TunerRegs[31].Reg_Num = 49 ;
491 state->TunerRegs[31].Reg_Val = 0x00 ;
Steven Toth52c99bd2008-05-01 04:57:01 -0300492
Steven Toth3935c252008-05-01 05:45:44 -0300493 state->TunerRegs[32].Reg_Num = 53 ;
494 state->TunerRegs[32].Reg_Val = 0x94 ;
Steven Toth52c99bd2008-05-01 04:57:01 -0300495
Steven Toth3935c252008-05-01 05:45:44 -0300496 state->TunerRegs[33].Reg_Num = 54 ;
497 state->TunerRegs[33].Reg_Val = 0xFA ;
Steven Toth52c99bd2008-05-01 04:57:01 -0300498
Steven Toth3935c252008-05-01 05:45:44 -0300499 state->TunerRegs[34].Reg_Num = 55 ;
500 state->TunerRegs[34].Reg_Val = 0x92 ;
Steven Toth52c99bd2008-05-01 04:57:01 -0300501
Steven Toth3935c252008-05-01 05:45:44 -0300502 state->TunerRegs[35].Reg_Num = 56 ;
503 state->TunerRegs[35].Reg_Val = 0x80 ;
Steven Toth52c99bd2008-05-01 04:57:01 -0300504
Steven Toth3935c252008-05-01 05:45:44 -0300505 state->TunerRegs[36].Reg_Num = 57 ;
506 state->TunerRegs[36].Reg_Val = 0x41 ;
Steven Toth52c99bd2008-05-01 04:57:01 -0300507
Steven Toth3935c252008-05-01 05:45:44 -0300508 state->TunerRegs[37].Reg_Num = 58 ;
509 state->TunerRegs[37].Reg_Val = 0xDB ;
Steven Toth52c99bd2008-05-01 04:57:01 -0300510
Steven Toth3935c252008-05-01 05:45:44 -0300511 state->TunerRegs[38].Reg_Num = 59 ;
512 state->TunerRegs[38].Reg_Val = 0x00 ;
Steven Toth52c99bd2008-05-01 04:57:01 -0300513
Steven Toth3935c252008-05-01 05:45:44 -0300514 state->TunerRegs[39].Reg_Num = 60 ;
515 state->TunerRegs[39].Reg_Val = 0x00 ;
Steven Toth52c99bd2008-05-01 04:57:01 -0300516
Steven Toth3935c252008-05-01 05:45:44 -0300517 state->TunerRegs[40].Reg_Num = 61 ;
518 state->TunerRegs[40].Reg_Val = 0x00 ;
Steven Toth52c99bd2008-05-01 04:57:01 -0300519
Steven Toth3935c252008-05-01 05:45:44 -0300520 state->TunerRegs[41].Reg_Num = 62 ;
521 state->TunerRegs[41].Reg_Val = 0x00 ;
Steven Toth52c99bd2008-05-01 04:57:01 -0300522
Steven Toth3935c252008-05-01 05:45:44 -0300523 state->TunerRegs[42].Reg_Num = 65 ;
524 state->TunerRegs[42].Reg_Val = 0xF8 ;
Steven Toth52c99bd2008-05-01 04:57:01 -0300525
Steven Toth3935c252008-05-01 05:45:44 -0300526 state->TunerRegs[43].Reg_Num = 66 ;
527 state->TunerRegs[43].Reg_Val = 0xE4 ;
Steven Toth52c99bd2008-05-01 04:57:01 -0300528
Steven Toth3935c252008-05-01 05:45:44 -0300529 state->TunerRegs[44].Reg_Num = 67 ;
530 state->TunerRegs[44].Reg_Val = 0x90 ;
Steven Toth52c99bd2008-05-01 04:57:01 -0300531
Steven Toth3935c252008-05-01 05:45:44 -0300532 state->TunerRegs[45].Reg_Num = 68 ;
533 state->TunerRegs[45].Reg_Val = 0xC0 ;
Steven Toth52c99bd2008-05-01 04:57:01 -0300534
Steven Toth3935c252008-05-01 05:45:44 -0300535 state->TunerRegs[46].Reg_Num = 69 ;
536 state->TunerRegs[46].Reg_Val = 0x01 ;
Steven Toth52c99bd2008-05-01 04:57:01 -0300537
Steven Toth3935c252008-05-01 05:45:44 -0300538 state->TunerRegs[47].Reg_Num = 70 ;
539 state->TunerRegs[47].Reg_Val = 0x50 ;
Steven Toth52c99bd2008-05-01 04:57:01 -0300540
Steven Toth3935c252008-05-01 05:45:44 -0300541 state->TunerRegs[48].Reg_Num = 71 ;
542 state->TunerRegs[48].Reg_Val = 0x06 ;
Steven Toth52c99bd2008-05-01 04:57:01 -0300543
Steven Toth3935c252008-05-01 05:45:44 -0300544 state->TunerRegs[49].Reg_Num = 72 ;
545 state->TunerRegs[49].Reg_Val = 0x00 ;
Steven Toth52c99bd2008-05-01 04:57:01 -0300546
Steven Toth3935c252008-05-01 05:45:44 -0300547 state->TunerRegs[50].Reg_Num = 73 ;
548 state->TunerRegs[50].Reg_Val = 0x20 ;
Steven Toth52c99bd2008-05-01 04:57:01 -0300549
Steven Toth3935c252008-05-01 05:45:44 -0300550 state->TunerRegs[51].Reg_Num = 76 ;
551 state->TunerRegs[51].Reg_Val = 0xBB ;
Steven Toth52c99bd2008-05-01 04:57:01 -0300552
Steven Toth3935c252008-05-01 05:45:44 -0300553 state->TunerRegs[52].Reg_Num = 77 ;
554 state->TunerRegs[52].Reg_Val = 0x13 ;
Steven Toth52c99bd2008-05-01 04:57:01 -0300555
Steven Toth3935c252008-05-01 05:45:44 -0300556 state->TunerRegs[53].Reg_Num = 81 ;
557 state->TunerRegs[53].Reg_Val = 0x04 ;
Steven Toth52c99bd2008-05-01 04:57:01 -0300558
Steven Toth3935c252008-05-01 05:45:44 -0300559 state->TunerRegs[54].Reg_Num = 82 ;
560 state->TunerRegs[54].Reg_Val = 0x75 ;
Steven Toth52c99bd2008-05-01 04:57:01 -0300561
Steven Toth3935c252008-05-01 05:45:44 -0300562 state->TunerRegs[55].Reg_Num = 83 ;
563 state->TunerRegs[55].Reg_Val = 0x00 ;
Steven Toth52c99bd2008-05-01 04:57:01 -0300564
Steven Toth3935c252008-05-01 05:45:44 -0300565 state->TunerRegs[56].Reg_Num = 84 ;
566 state->TunerRegs[56].Reg_Val = 0x00 ;
Steven Toth52c99bd2008-05-01 04:57:01 -0300567
Steven Toth3935c252008-05-01 05:45:44 -0300568 state->TunerRegs[57].Reg_Num = 85 ;
569 state->TunerRegs[57].Reg_Val = 0x00 ;
Steven Toth52c99bd2008-05-01 04:57:01 -0300570
Steven Toth3935c252008-05-01 05:45:44 -0300571 state->TunerRegs[58].Reg_Num = 91 ;
572 state->TunerRegs[58].Reg_Val = 0x70 ;
Steven Toth52c99bd2008-05-01 04:57:01 -0300573
Steven Toth3935c252008-05-01 05:45:44 -0300574 state->TunerRegs[59].Reg_Num = 92 ;
575 state->TunerRegs[59].Reg_Val = 0x00 ;
Steven Toth52c99bd2008-05-01 04:57:01 -0300576
Steven Toth3935c252008-05-01 05:45:44 -0300577 state->TunerRegs[60].Reg_Num = 93 ;
578 state->TunerRegs[60].Reg_Val = 0x00 ;
Steven Toth52c99bd2008-05-01 04:57:01 -0300579
Steven Toth3935c252008-05-01 05:45:44 -0300580 state->TunerRegs[61].Reg_Num = 94 ;
581 state->TunerRegs[61].Reg_Val = 0x00 ;
Steven Toth52c99bd2008-05-01 04:57:01 -0300582
Steven Toth3935c252008-05-01 05:45:44 -0300583 state->TunerRegs[62].Reg_Num = 95 ;
584 state->TunerRegs[62].Reg_Val = 0x0C ;
Steven Toth52c99bd2008-05-01 04:57:01 -0300585
Steven Toth3935c252008-05-01 05:45:44 -0300586 state->TunerRegs[63].Reg_Num = 96 ;
587 state->TunerRegs[63].Reg_Val = 0x00 ;
Steven Toth52c99bd2008-05-01 04:57:01 -0300588
Steven Toth3935c252008-05-01 05:45:44 -0300589 state->TunerRegs[64].Reg_Num = 97 ;
590 state->TunerRegs[64].Reg_Val = 0x00 ;
Steven Toth52c99bd2008-05-01 04:57:01 -0300591
Steven Toth3935c252008-05-01 05:45:44 -0300592 state->TunerRegs[65].Reg_Num = 98 ;
593 state->TunerRegs[65].Reg_Val = 0xE2 ;
Steven Toth52c99bd2008-05-01 04:57:01 -0300594
Steven Toth3935c252008-05-01 05:45:44 -0300595 state->TunerRegs[66].Reg_Num = 99 ;
596 state->TunerRegs[66].Reg_Val = 0x00 ;
Steven Toth52c99bd2008-05-01 04:57:01 -0300597
Steven Toth3935c252008-05-01 05:45:44 -0300598 state->TunerRegs[67].Reg_Num = 100 ;
599 state->TunerRegs[67].Reg_Val = 0x00 ;
Steven Toth52c99bd2008-05-01 04:57:01 -0300600
Steven Toth3935c252008-05-01 05:45:44 -0300601 state->TunerRegs[68].Reg_Num = 101 ;
602 state->TunerRegs[68].Reg_Val = 0x12 ;
Steven Toth52c99bd2008-05-01 04:57:01 -0300603
Steven Toth3935c252008-05-01 05:45:44 -0300604 state->TunerRegs[69].Reg_Num = 102 ;
605 state->TunerRegs[69].Reg_Val = 0x80 ;
Steven Toth52c99bd2008-05-01 04:57:01 -0300606
Steven Toth3935c252008-05-01 05:45:44 -0300607 state->TunerRegs[70].Reg_Num = 103 ;
608 state->TunerRegs[70].Reg_Val = 0x32 ;
Steven Toth52c99bd2008-05-01 04:57:01 -0300609
Steven Toth3935c252008-05-01 05:45:44 -0300610 state->TunerRegs[71].Reg_Num = 104 ;
611 state->TunerRegs[71].Reg_Val = 0xB4 ;
Steven Toth52c99bd2008-05-01 04:57:01 -0300612
Steven Toth3935c252008-05-01 05:45:44 -0300613 state->TunerRegs[72].Reg_Num = 105 ;
614 state->TunerRegs[72].Reg_Val = 0x60 ;
Steven Toth52c99bd2008-05-01 04:57:01 -0300615
Steven Toth3935c252008-05-01 05:45:44 -0300616 state->TunerRegs[73].Reg_Num = 106 ;
617 state->TunerRegs[73].Reg_Val = 0x83 ;
Steven Toth52c99bd2008-05-01 04:57:01 -0300618
Steven Toth3935c252008-05-01 05:45:44 -0300619 state->TunerRegs[74].Reg_Num = 107 ;
620 state->TunerRegs[74].Reg_Val = 0x84 ;
Steven Toth52c99bd2008-05-01 04:57:01 -0300621
Steven Toth3935c252008-05-01 05:45:44 -0300622 state->TunerRegs[75].Reg_Num = 108 ;
623 state->TunerRegs[75].Reg_Val = 0x9C ;
Steven Toth52c99bd2008-05-01 04:57:01 -0300624
Steven Toth3935c252008-05-01 05:45:44 -0300625 state->TunerRegs[76].Reg_Num = 109 ;
626 state->TunerRegs[76].Reg_Val = 0x02 ;
Steven Toth52c99bd2008-05-01 04:57:01 -0300627
Steven Toth3935c252008-05-01 05:45:44 -0300628 state->TunerRegs[77].Reg_Num = 110 ;
629 state->TunerRegs[77].Reg_Val = 0x81 ;
Steven Toth52c99bd2008-05-01 04:57:01 -0300630
Steven Toth3935c252008-05-01 05:45:44 -0300631 state->TunerRegs[78].Reg_Num = 111 ;
632 state->TunerRegs[78].Reg_Val = 0xC0 ;
Steven Toth52c99bd2008-05-01 04:57:01 -0300633
Steven Toth3935c252008-05-01 05:45:44 -0300634 state->TunerRegs[79].Reg_Num = 112 ;
635 state->TunerRegs[79].Reg_Val = 0x10 ;
Steven Toth52c99bd2008-05-01 04:57:01 -0300636
Steven Toth3935c252008-05-01 05:45:44 -0300637 state->TunerRegs[80].Reg_Num = 131 ;
638 state->TunerRegs[80].Reg_Val = 0x8A ;
Steven Toth52c99bd2008-05-01 04:57:01 -0300639
Steven Toth3935c252008-05-01 05:45:44 -0300640 state->TunerRegs[81].Reg_Num = 132 ;
641 state->TunerRegs[81].Reg_Val = 0x10 ;
Steven Toth52c99bd2008-05-01 04:57:01 -0300642
Steven Toth3935c252008-05-01 05:45:44 -0300643 state->TunerRegs[82].Reg_Num = 133 ;
644 state->TunerRegs[82].Reg_Val = 0x24 ;
Steven Toth52c99bd2008-05-01 04:57:01 -0300645
Steven Toth3935c252008-05-01 05:45:44 -0300646 state->TunerRegs[83].Reg_Num = 134 ;
647 state->TunerRegs[83].Reg_Val = 0x00 ;
Steven Toth52c99bd2008-05-01 04:57:01 -0300648
Steven Toth3935c252008-05-01 05:45:44 -0300649 state->TunerRegs[84].Reg_Num = 135 ;
650 state->TunerRegs[84].Reg_Val = 0x00 ;
Steven Toth52c99bd2008-05-01 04:57:01 -0300651
Steven Toth3935c252008-05-01 05:45:44 -0300652 state->TunerRegs[85].Reg_Num = 136 ;
653 state->TunerRegs[85].Reg_Val = 0x7E ;
Steven Toth52c99bd2008-05-01 04:57:01 -0300654
Steven Toth3935c252008-05-01 05:45:44 -0300655 state->TunerRegs[86].Reg_Num = 137 ;
656 state->TunerRegs[86].Reg_Val = 0x40 ;
Steven Toth52c99bd2008-05-01 04:57:01 -0300657
Steven Toth3935c252008-05-01 05:45:44 -0300658 state->TunerRegs[87].Reg_Num = 138 ;
659 state->TunerRegs[87].Reg_Val = 0x38 ;
Steven Toth52c99bd2008-05-01 04:57:01 -0300660
Steven Toth3935c252008-05-01 05:45:44 -0300661 state->TunerRegs[88].Reg_Num = 146 ;
662 state->TunerRegs[88].Reg_Val = 0xF6 ;
Steven Toth52c99bd2008-05-01 04:57:01 -0300663
Steven Toth3935c252008-05-01 05:45:44 -0300664 state->TunerRegs[89].Reg_Num = 147 ;
665 state->TunerRegs[89].Reg_Val = 0x1A ;
Steven Toth52c99bd2008-05-01 04:57:01 -0300666
Steven Toth3935c252008-05-01 05:45:44 -0300667 state->TunerRegs[90].Reg_Num = 148 ;
668 state->TunerRegs[90].Reg_Val = 0x62 ;
Steven Toth52c99bd2008-05-01 04:57:01 -0300669
Steven Toth3935c252008-05-01 05:45:44 -0300670 state->TunerRegs[91].Reg_Num = 149 ;
671 state->TunerRegs[91].Reg_Val = 0x33 ;
Steven Toth52c99bd2008-05-01 04:57:01 -0300672
Steven Toth3935c252008-05-01 05:45:44 -0300673 state->TunerRegs[92].Reg_Num = 150 ;
674 state->TunerRegs[92].Reg_Val = 0x80 ;
Steven Toth52c99bd2008-05-01 04:57:01 -0300675
Steven Toth3935c252008-05-01 05:45:44 -0300676 state->TunerRegs[93].Reg_Num = 156 ;
677 state->TunerRegs[93].Reg_Val = 0x56 ;
Steven Toth52c99bd2008-05-01 04:57:01 -0300678
Steven Toth3935c252008-05-01 05:45:44 -0300679 state->TunerRegs[94].Reg_Num = 157 ;
680 state->TunerRegs[94].Reg_Val = 0x17 ;
Steven Toth52c99bd2008-05-01 04:57:01 -0300681
Steven Toth3935c252008-05-01 05:45:44 -0300682 state->TunerRegs[95].Reg_Num = 158 ;
683 state->TunerRegs[95].Reg_Val = 0xA9 ;
Steven Toth52c99bd2008-05-01 04:57:01 -0300684
Steven Toth3935c252008-05-01 05:45:44 -0300685 state->TunerRegs[96].Reg_Num = 159 ;
686 state->TunerRegs[96].Reg_Val = 0x00 ;
Steven Toth52c99bd2008-05-01 04:57:01 -0300687
Steven Toth3935c252008-05-01 05:45:44 -0300688 state->TunerRegs[97].Reg_Num = 160 ;
689 state->TunerRegs[97].Reg_Val = 0x00 ;
Steven Toth52c99bd2008-05-01 04:57:01 -0300690
Steven Toth3935c252008-05-01 05:45:44 -0300691 state->TunerRegs[98].Reg_Num = 161 ;
692 state->TunerRegs[98].Reg_Val = 0x00 ;
Steven Toth52c99bd2008-05-01 04:57:01 -0300693
Steven Toth3935c252008-05-01 05:45:44 -0300694 state->TunerRegs[99].Reg_Num = 162 ;
695 state->TunerRegs[99].Reg_Val = 0x40 ;
Steven Toth52c99bd2008-05-01 04:57:01 -0300696
Steven Toth3935c252008-05-01 05:45:44 -0300697 state->TunerRegs[100].Reg_Num = 166 ;
698 state->TunerRegs[100].Reg_Val = 0xAE ;
Steven Toth52c99bd2008-05-01 04:57:01 -0300699
Steven Toth3935c252008-05-01 05:45:44 -0300700 state->TunerRegs[101].Reg_Num = 167 ;
701 state->TunerRegs[101].Reg_Val = 0x1B ;
Steven Toth52c99bd2008-05-01 04:57:01 -0300702
Steven Toth3935c252008-05-01 05:45:44 -0300703 state->TunerRegs[102].Reg_Num = 168 ;
704 state->TunerRegs[102].Reg_Val = 0xF2 ;
Steven Toth52c99bd2008-05-01 04:57:01 -0300705
Steven Toth3935c252008-05-01 05:45:44 -0300706 state->TunerRegs[103].Reg_Num = 195 ;
707 state->TunerRegs[103].Reg_Val = 0x00 ;
Steven Toth52c99bd2008-05-01 04:57:01 -0300708
709 return 0 ;
710}
711
Steven Toth3935c252008-05-01 05:45:44 -0300712u16 MXL5005_ControlInit(struct dvb_frontend *fe)
Steven Toth52c99bd2008-05-01 04:57:01 -0300713{
Steven Toth85d220d2008-05-01 05:48:14 -0300714 struct mxl5005s_state *state = fe->tuner_priv;
Steven Toth3935c252008-05-01 05:45:44 -0300715 state->Init_Ctrl_Num = INITCTRL_NUM;
Steven Toth52c99bd2008-05-01 04:57:01 -0300716
Steven Toth3935c252008-05-01 05:45:44 -0300717 state->Init_Ctrl[0].Ctrl_Num = DN_IQTN_AMP_CUT ;
718 state->Init_Ctrl[0].size = 1 ;
719 state->Init_Ctrl[0].addr[0] = 73;
720 state->Init_Ctrl[0].bit[0] = 7;
721 state->Init_Ctrl[0].val[0] = 0;
Steven Toth52c99bd2008-05-01 04:57:01 -0300722
Steven Toth3935c252008-05-01 05:45:44 -0300723 state->Init_Ctrl[1].Ctrl_Num = BB_MODE ;
724 state->Init_Ctrl[1].size = 1 ;
725 state->Init_Ctrl[1].addr[0] = 53;
726 state->Init_Ctrl[1].bit[0] = 2;
727 state->Init_Ctrl[1].val[0] = 1;
Steven Toth52c99bd2008-05-01 04:57:01 -0300728
Steven Toth3935c252008-05-01 05:45:44 -0300729 state->Init_Ctrl[2].Ctrl_Num = BB_BUF ;
730 state->Init_Ctrl[2].size = 2 ;
731 state->Init_Ctrl[2].addr[0] = 53;
732 state->Init_Ctrl[2].bit[0] = 1;
733 state->Init_Ctrl[2].val[0] = 0;
734 state->Init_Ctrl[2].addr[1] = 57;
735 state->Init_Ctrl[2].bit[1] = 0;
736 state->Init_Ctrl[2].val[1] = 1;
Steven Toth52c99bd2008-05-01 04:57:01 -0300737
Steven Toth3935c252008-05-01 05:45:44 -0300738 state->Init_Ctrl[3].Ctrl_Num = BB_BUF_OA ;
739 state->Init_Ctrl[3].size = 1 ;
740 state->Init_Ctrl[3].addr[0] = 53;
741 state->Init_Ctrl[3].bit[0] = 0;
742 state->Init_Ctrl[3].val[0] = 0;
Steven Toth52c99bd2008-05-01 04:57:01 -0300743
Steven Toth3935c252008-05-01 05:45:44 -0300744 state->Init_Ctrl[4].Ctrl_Num = BB_ALPF_BANDSELECT ;
745 state->Init_Ctrl[4].size = 3 ;
746 state->Init_Ctrl[4].addr[0] = 53;
747 state->Init_Ctrl[4].bit[0] = 5;
748 state->Init_Ctrl[4].val[0] = 0;
749 state->Init_Ctrl[4].addr[1] = 53;
750 state->Init_Ctrl[4].bit[1] = 6;
751 state->Init_Ctrl[4].val[1] = 0;
752 state->Init_Ctrl[4].addr[2] = 53;
753 state->Init_Ctrl[4].bit[2] = 7;
754 state->Init_Ctrl[4].val[2] = 1;
Steven Toth52c99bd2008-05-01 04:57:01 -0300755
Steven Toth3935c252008-05-01 05:45:44 -0300756 state->Init_Ctrl[5].Ctrl_Num = BB_IQSWAP ;
757 state->Init_Ctrl[5].size = 1 ;
758 state->Init_Ctrl[5].addr[0] = 59;
759 state->Init_Ctrl[5].bit[0] = 0;
760 state->Init_Ctrl[5].val[0] = 0;
Steven Toth52c99bd2008-05-01 04:57:01 -0300761
Steven Toth3935c252008-05-01 05:45:44 -0300762 state->Init_Ctrl[6].Ctrl_Num = BB_DLPF_BANDSEL ;
763 state->Init_Ctrl[6].size = 2 ;
764 state->Init_Ctrl[6].addr[0] = 53;
765 state->Init_Ctrl[6].bit[0] = 3;
766 state->Init_Ctrl[6].val[0] = 0;
767 state->Init_Ctrl[6].addr[1] = 53;
768 state->Init_Ctrl[6].bit[1] = 4;
769 state->Init_Ctrl[6].val[1] = 1;
Steven Toth52c99bd2008-05-01 04:57:01 -0300770
Steven Toth3935c252008-05-01 05:45:44 -0300771 state->Init_Ctrl[7].Ctrl_Num = RFSYN_CHP_GAIN ;
772 state->Init_Ctrl[7].size = 4 ;
773 state->Init_Ctrl[7].addr[0] = 22;
774 state->Init_Ctrl[7].bit[0] = 4;
775 state->Init_Ctrl[7].val[0] = 0;
776 state->Init_Ctrl[7].addr[1] = 22;
777 state->Init_Ctrl[7].bit[1] = 5;
778 state->Init_Ctrl[7].val[1] = 1;
779 state->Init_Ctrl[7].addr[2] = 22;
780 state->Init_Ctrl[7].bit[2] = 6;
781 state->Init_Ctrl[7].val[2] = 1;
782 state->Init_Ctrl[7].addr[3] = 22;
783 state->Init_Ctrl[7].bit[3] = 7;
784 state->Init_Ctrl[7].val[3] = 0;
Steven Toth52c99bd2008-05-01 04:57:01 -0300785
Steven Toth3935c252008-05-01 05:45:44 -0300786 state->Init_Ctrl[8].Ctrl_Num = RFSYN_EN_CHP_HIGAIN ;
787 state->Init_Ctrl[8].size = 1 ;
788 state->Init_Ctrl[8].addr[0] = 22;
789 state->Init_Ctrl[8].bit[0] = 2;
790 state->Init_Ctrl[8].val[0] = 0;
Steven Toth52c99bd2008-05-01 04:57:01 -0300791
Steven Toth3935c252008-05-01 05:45:44 -0300792 state->Init_Ctrl[9].Ctrl_Num = AGC_IF ;
793 state->Init_Ctrl[9].size = 4 ;
794 state->Init_Ctrl[9].addr[0] = 76;
795 state->Init_Ctrl[9].bit[0] = 0;
796 state->Init_Ctrl[9].val[0] = 1;
797 state->Init_Ctrl[9].addr[1] = 76;
798 state->Init_Ctrl[9].bit[1] = 1;
799 state->Init_Ctrl[9].val[1] = 1;
800 state->Init_Ctrl[9].addr[2] = 76;
801 state->Init_Ctrl[9].bit[2] = 2;
802 state->Init_Ctrl[9].val[2] = 0;
803 state->Init_Ctrl[9].addr[3] = 76;
804 state->Init_Ctrl[9].bit[3] = 3;
805 state->Init_Ctrl[9].val[3] = 1;
Steven Toth52c99bd2008-05-01 04:57:01 -0300806
Steven Toth3935c252008-05-01 05:45:44 -0300807 state->Init_Ctrl[10].Ctrl_Num = AGC_RF ;
808 state->Init_Ctrl[10].size = 4 ;
809 state->Init_Ctrl[10].addr[0] = 76;
810 state->Init_Ctrl[10].bit[0] = 4;
811 state->Init_Ctrl[10].val[0] = 1;
812 state->Init_Ctrl[10].addr[1] = 76;
813 state->Init_Ctrl[10].bit[1] = 5;
814 state->Init_Ctrl[10].val[1] = 1;
815 state->Init_Ctrl[10].addr[2] = 76;
816 state->Init_Ctrl[10].bit[2] = 6;
817 state->Init_Ctrl[10].val[2] = 0;
818 state->Init_Ctrl[10].addr[3] = 76;
819 state->Init_Ctrl[10].bit[3] = 7;
820 state->Init_Ctrl[10].val[3] = 1;
Steven Toth52c99bd2008-05-01 04:57:01 -0300821
Steven Toth3935c252008-05-01 05:45:44 -0300822 state->Init_Ctrl[11].Ctrl_Num = IF_DIVVAL ;
823 state->Init_Ctrl[11].size = 5 ;
824 state->Init_Ctrl[11].addr[0] = 43;
825 state->Init_Ctrl[11].bit[0] = 3;
826 state->Init_Ctrl[11].val[0] = 0;
827 state->Init_Ctrl[11].addr[1] = 43;
828 state->Init_Ctrl[11].bit[1] = 4;
829 state->Init_Ctrl[11].val[1] = 0;
830 state->Init_Ctrl[11].addr[2] = 43;
831 state->Init_Ctrl[11].bit[2] = 5;
832 state->Init_Ctrl[11].val[2] = 0;
833 state->Init_Ctrl[11].addr[3] = 43;
834 state->Init_Ctrl[11].bit[3] = 6;
835 state->Init_Ctrl[11].val[3] = 1;
836 state->Init_Ctrl[11].addr[4] = 43;
837 state->Init_Ctrl[11].bit[4] = 7;
838 state->Init_Ctrl[11].val[4] = 0;
Steven Toth52c99bd2008-05-01 04:57:01 -0300839
Steven Toth3935c252008-05-01 05:45:44 -0300840 state->Init_Ctrl[12].Ctrl_Num = IF_VCO_BIAS ;
841 state->Init_Ctrl[12].size = 6 ;
842 state->Init_Ctrl[12].addr[0] = 44;
843 state->Init_Ctrl[12].bit[0] = 2;
844 state->Init_Ctrl[12].val[0] = 0;
845 state->Init_Ctrl[12].addr[1] = 44;
846 state->Init_Ctrl[12].bit[1] = 3;
847 state->Init_Ctrl[12].val[1] = 0;
848 state->Init_Ctrl[12].addr[2] = 44;
849 state->Init_Ctrl[12].bit[2] = 4;
850 state->Init_Ctrl[12].val[2] = 0;
851 state->Init_Ctrl[12].addr[3] = 44;
852 state->Init_Ctrl[12].bit[3] = 5;
853 state->Init_Ctrl[12].val[3] = 1;
854 state->Init_Ctrl[12].addr[4] = 44;
855 state->Init_Ctrl[12].bit[4] = 6;
856 state->Init_Ctrl[12].val[4] = 0;
857 state->Init_Ctrl[12].addr[5] = 44;
858 state->Init_Ctrl[12].bit[5] = 7;
859 state->Init_Ctrl[12].val[5] = 0;
Steven Toth52c99bd2008-05-01 04:57:01 -0300860
Steven Toth3935c252008-05-01 05:45:44 -0300861 state->Init_Ctrl[13].Ctrl_Num = CHCAL_INT_MOD_IF ;
862 state->Init_Ctrl[13].size = 7 ;
863 state->Init_Ctrl[13].addr[0] = 11;
864 state->Init_Ctrl[13].bit[0] = 0;
865 state->Init_Ctrl[13].val[0] = 1;
866 state->Init_Ctrl[13].addr[1] = 11;
867 state->Init_Ctrl[13].bit[1] = 1;
868 state->Init_Ctrl[13].val[1] = 0;
869 state->Init_Ctrl[13].addr[2] = 11;
870 state->Init_Ctrl[13].bit[2] = 2;
871 state->Init_Ctrl[13].val[2] = 0;
872 state->Init_Ctrl[13].addr[3] = 11;
873 state->Init_Ctrl[13].bit[3] = 3;
874 state->Init_Ctrl[13].val[3] = 1;
875 state->Init_Ctrl[13].addr[4] = 11;
876 state->Init_Ctrl[13].bit[4] = 4;
877 state->Init_Ctrl[13].val[4] = 1;
878 state->Init_Ctrl[13].addr[5] = 11;
879 state->Init_Ctrl[13].bit[5] = 5;
880 state->Init_Ctrl[13].val[5] = 0;
881 state->Init_Ctrl[13].addr[6] = 11;
882 state->Init_Ctrl[13].bit[6] = 6;
883 state->Init_Ctrl[13].val[6] = 0;
Steven Toth52c99bd2008-05-01 04:57:01 -0300884
Steven Toth3935c252008-05-01 05:45:44 -0300885 state->Init_Ctrl[14].Ctrl_Num = CHCAL_FRAC_MOD_IF ;
886 state->Init_Ctrl[14].size = 16 ;
887 state->Init_Ctrl[14].addr[0] = 13;
888 state->Init_Ctrl[14].bit[0] = 0;
889 state->Init_Ctrl[14].val[0] = 0;
890 state->Init_Ctrl[14].addr[1] = 13;
891 state->Init_Ctrl[14].bit[1] = 1;
892 state->Init_Ctrl[14].val[1] = 0;
893 state->Init_Ctrl[14].addr[2] = 13;
894 state->Init_Ctrl[14].bit[2] = 2;
895 state->Init_Ctrl[14].val[2] = 0;
896 state->Init_Ctrl[14].addr[3] = 13;
897 state->Init_Ctrl[14].bit[3] = 3;
898 state->Init_Ctrl[14].val[3] = 0;
899 state->Init_Ctrl[14].addr[4] = 13;
900 state->Init_Ctrl[14].bit[4] = 4;
901 state->Init_Ctrl[14].val[4] = 0;
902 state->Init_Ctrl[14].addr[5] = 13;
903 state->Init_Ctrl[14].bit[5] = 5;
904 state->Init_Ctrl[14].val[5] = 0;
905 state->Init_Ctrl[14].addr[6] = 13;
906 state->Init_Ctrl[14].bit[6] = 6;
907 state->Init_Ctrl[14].val[6] = 0;
908 state->Init_Ctrl[14].addr[7] = 13;
909 state->Init_Ctrl[14].bit[7] = 7;
910 state->Init_Ctrl[14].val[7] = 0;
911 state->Init_Ctrl[14].addr[8] = 12;
912 state->Init_Ctrl[14].bit[8] = 0;
913 state->Init_Ctrl[14].val[8] = 0;
914 state->Init_Ctrl[14].addr[9] = 12;
915 state->Init_Ctrl[14].bit[9] = 1;
916 state->Init_Ctrl[14].val[9] = 0;
917 state->Init_Ctrl[14].addr[10] = 12;
918 state->Init_Ctrl[14].bit[10] = 2;
919 state->Init_Ctrl[14].val[10] = 0;
920 state->Init_Ctrl[14].addr[11] = 12;
921 state->Init_Ctrl[14].bit[11] = 3;
922 state->Init_Ctrl[14].val[11] = 0;
923 state->Init_Ctrl[14].addr[12] = 12;
924 state->Init_Ctrl[14].bit[12] = 4;
925 state->Init_Ctrl[14].val[12] = 0;
926 state->Init_Ctrl[14].addr[13] = 12;
927 state->Init_Ctrl[14].bit[13] = 5;
928 state->Init_Ctrl[14].val[13] = 1;
929 state->Init_Ctrl[14].addr[14] = 12;
930 state->Init_Ctrl[14].bit[14] = 6;
931 state->Init_Ctrl[14].val[14] = 1;
932 state->Init_Ctrl[14].addr[15] = 12;
933 state->Init_Ctrl[14].bit[15] = 7;
934 state->Init_Ctrl[14].val[15] = 0;
Steven Toth52c99bd2008-05-01 04:57:01 -0300935
Steven Toth3935c252008-05-01 05:45:44 -0300936 state->Init_Ctrl[15].Ctrl_Num = DRV_RES_SEL ;
937 state->Init_Ctrl[15].size = 3 ;
938 state->Init_Ctrl[15].addr[0] = 147;
939 state->Init_Ctrl[15].bit[0] = 2;
940 state->Init_Ctrl[15].val[0] = 0;
941 state->Init_Ctrl[15].addr[1] = 147;
942 state->Init_Ctrl[15].bit[1] = 3;
943 state->Init_Ctrl[15].val[1] = 1;
944 state->Init_Ctrl[15].addr[2] = 147;
945 state->Init_Ctrl[15].bit[2] = 4;
946 state->Init_Ctrl[15].val[2] = 1;
Steven Toth52c99bd2008-05-01 04:57:01 -0300947
Steven Toth3935c252008-05-01 05:45:44 -0300948 state->Init_Ctrl[16].Ctrl_Num = I_DRIVER ;
949 state->Init_Ctrl[16].size = 2 ;
950 state->Init_Ctrl[16].addr[0] = 147;
951 state->Init_Ctrl[16].bit[0] = 0;
952 state->Init_Ctrl[16].val[0] = 0;
953 state->Init_Ctrl[16].addr[1] = 147;
954 state->Init_Ctrl[16].bit[1] = 1;
955 state->Init_Ctrl[16].val[1] = 1;
Steven Toth52c99bd2008-05-01 04:57:01 -0300956
Steven Toth3935c252008-05-01 05:45:44 -0300957 state->Init_Ctrl[17].Ctrl_Num = EN_AAF ;
958 state->Init_Ctrl[17].size = 1 ;
959 state->Init_Ctrl[17].addr[0] = 147;
960 state->Init_Ctrl[17].bit[0] = 7;
961 state->Init_Ctrl[17].val[0] = 0;
Steven Toth52c99bd2008-05-01 04:57:01 -0300962
Steven Toth3935c252008-05-01 05:45:44 -0300963 state->Init_Ctrl[18].Ctrl_Num = EN_3P ;
964 state->Init_Ctrl[18].size = 1 ;
965 state->Init_Ctrl[18].addr[0] = 147;
966 state->Init_Ctrl[18].bit[0] = 6;
967 state->Init_Ctrl[18].val[0] = 0;
Steven Toth52c99bd2008-05-01 04:57:01 -0300968
Steven Toth3935c252008-05-01 05:45:44 -0300969 state->Init_Ctrl[19].Ctrl_Num = EN_AUX_3P ;
970 state->Init_Ctrl[19].size = 1 ;
971 state->Init_Ctrl[19].addr[0] = 156;
972 state->Init_Ctrl[19].bit[0] = 0;
973 state->Init_Ctrl[19].val[0] = 0;
Steven Toth52c99bd2008-05-01 04:57:01 -0300974
Steven Toth3935c252008-05-01 05:45:44 -0300975 state->Init_Ctrl[20].Ctrl_Num = SEL_AAF_BAND ;
976 state->Init_Ctrl[20].size = 1 ;
977 state->Init_Ctrl[20].addr[0] = 147;
978 state->Init_Ctrl[20].bit[0] = 5;
979 state->Init_Ctrl[20].val[0] = 0;
Steven Toth52c99bd2008-05-01 04:57:01 -0300980
Steven Toth3935c252008-05-01 05:45:44 -0300981 state->Init_Ctrl[21].Ctrl_Num = SEQ_ENCLK16_CLK_OUT ;
982 state->Init_Ctrl[21].size = 1 ;
983 state->Init_Ctrl[21].addr[0] = 137;
984 state->Init_Ctrl[21].bit[0] = 4;
985 state->Init_Ctrl[21].val[0] = 0;
Steven Toth52c99bd2008-05-01 04:57:01 -0300986
Steven Toth3935c252008-05-01 05:45:44 -0300987 state->Init_Ctrl[22].Ctrl_Num = SEQ_SEL4_16B ;
988 state->Init_Ctrl[22].size = 1 ;
989 state->Init_Ctrl[22].addr[0] = 137;
990 state->Init_Ctrl[22].bit[0] = 7;
991 state->Init_Ctrl[22].val[0] = 0;
Steven Toth52c99bd2008-05-01 04:57:01 -0300992
Steven Toth3935c252008-05-01 05:45:44 -0300993 state->Init_Ctrl[23].Ctrl_Num = XTAL_CAPSELECT ;
994 state->Init_Ctrl[23].size = 1 ;
995 state->Init_Ctrl[23].addr[0] = 91;
996 state->Init_Ctrl[23].bit[0] = 5;
997 state->Init_Ctrl[23].val[0] = 1;
Steven Toth52c99bd2008-05-01 04:57:01 -0300998
Steven Toth3935c252008-05-01 05:45:44 -0300999 state->Init_Ctrl[24].Ctrl_Num = IF_SEL_DBL ;
1000 state->Init_Ctrl[24].size = 1 ;
1001 state->Init_Ctrl[24].addr[0] = 43;
1002 state->Init_Ctrl[24].bit[0] = 0;
1003 state->Init_Ctrl[24].val[0] = 1;
Steven Toth52c99bd2008-05-01 04:57:01 -03001004
Steven Toth3935c252008-05-01 05:45:44 -03001005 state->Init_Ctrl[25].Ctrl_Num = RFSYN_R_DIV ;
1006 state->Init_Ctrl[25].size = 2 ;
1007 state->Init_Ctrl[25].addr[0] = 22;
1008 state->Init_Ctrl[25].bit[0] = 0;
1009 state->Init_Ctrl[25].val[0] = 1;
1010 state->Init_Ctrl[25].addr[1] = 22;
1011 state->Init_Ctrl[25].bit[1] = 1;
1012 state->Init_Ctrl[25].val[1] = 1;
Steven Toth52c99bd2008-05-01 04:57:01 -03001013
Steven Toth3935c252008-05-01 05:45:44 -03001014 state->Init_Ctrl[26].Ctrl_Num = SEQ_EXTSYNTHCALIF ;
1015 state->Init_Ctrl[26].size = 1 ;
1016 state->Init_Ctrl[26].addr[0] = 134;
1017 state->Init_Ctrl[26].bit[0] = 2;
1018 state->Init_Ctrl[26].val[0] = 0;
Steven Toth52c99bd2008-05-01 04:57:01 -03001019
Steven Toth3935c252008-05-01 05:45:44 -03001020 state->Init_Ctrl[27].Ctrl_Num = SEQ_EXTDCCAL ;
1021 state->Init_Ctrl[27].size = 1 ;
1022 state->Init_Ctrl[27].addr[0] = 137;
1023 state->Init_Ctrl[27].bit[0] = 3;
1024 state->Init_Ctrl[27].val[0] = 0;
Steven Toth52c99bd2008-05-01 04:57:01 -03001025
Steven Toth3935c252008-05-01 05:45:44 -03001026 state->Init_Ctrl[28].Ctrl_Num = AGC_EN_RSSI ;
1027 state->Init_Ctrl[28].size = 1 ;
1028 state->Init_Ctrl[28].addr[0] = 77;
1029 state->Init_Ctrl[28].bit[0] = 7;
1030 state->Init_Ctrl[28].val[0] = 0;
Steven Toth52c99bd2008-05-01 04:57:01 -03001031
Steven Toth3935c252008-05-01 05:45:44 -03001032 state->Init_Ctrl[29].Ctrl_Num = RFA_ENCLKRFAGC ;
1033 state->Init_Ctrl[29].size = 1 ;
1034 state->Init_Ctrl[29].addr[0] = 166;
1035 state->Init_Ctrl[29].bit[0] = 7;
1036 state->Init_Ctrl[29].val[0] = 1;
Steven Toth52c99bd2008-05-01 04:57:01 -03001037
Steven Toth3935c252008-05-01 05:45:44 -03001038 state->Init_Ctrl[30].Ctrl_Num = RFA_RSSI_REFH ;
1039 state->Init_Ctrl[30].size = 3 ;
1040 state->Init_Ctrl[30].addr[0] = 166;
1041 state->Init_Ctrl[30].bit[0] = 0;
1042 state->Init_Ctrl[30].val[0] = 0;
1043 state->Init_Ctrl[30].addr[1] = 166;
1044 state->Init_Ctrl[30].bit[1] = 1;
1045 state->Init_Ctrl[30].val[1] = 1;
1046 state->Init_Ctrl[30].addr[2] = 166;
1047 state->Init_Ctrl[30].bit[2] = 2;
1048 state->Init_Ctrl[30].val[2] = 1;
Steven Toth52c99bd2008-05-01 04:57:01 -03001049
Steven Toth3935c252008-05-01 05:45:44 -03001050 state->Init_Ctrl[31].Ctrl_Num = RFA_RSSI_REF ;
1051 state->Init_Ctrl[31].size = 3 ;
1052 state->Init_Ctrl[31].addr[0] = 166;
1053 state->Init_Ctrl[31].bit[0] = 3;
1054 state->Init_Ctrl[31].val[0] = 1;
1055 state->Init_Ctrl[31].addr[1] = 166;
1056 state->Init_Ctrl[31].bit[1] = 4;
1057 state->Init_Ctrl[31].val[1] = 0;
1058 state->Init_Ctrl[31].addr[2] = 166;
1059 state->Init_Ctrl[31].bit[2] = 5;
1060 state->Init_Ctrl[31].val[2] = 1;
Steven Toth52c99bd2008-05-01 04:57:01 -03001061
Steven Toth3935c252008-05-01 05:45:44 -03001062 state->Init_Ctrl[32].Ctrl_Num = RFA_RSSI_REFL ;
1063 state->Init_Ctrl[32].size = 3 ;
1064 state->Init_Ctrl[32].addr[0] = 167;
1065 state->Init_Ctrl[32].bit[0] = 0;
1066 state->Init_Ctrl[32].val[0] = 1;
1067 state->Init_Ctrl[32].addr[1] = 167;
1068 state->Init_Ctrl[32].bit[1] = 1;
1069 state->Init_Ctrl[32].val[1] = 1;
1070 state->Init_Ctrl[32].addr[2] = 167;
1071 state->Init_Ctrl[32].bit[2] = 2;
1072 state->Init_Ctrl[32].val[2] = 0;
Steven Toth52c99bd2008-05-01 04:57:01 -03001073
Steven Toth3935c252008-05-01 05:45:44 -03001074 state->Init_Ctrl[33].Ctrl_Num = RFA_FLR ;
1075 state->Init_Ctrl[33].size = 4 ;
1076 state->Init_Ctrl[33].addr[0] = 168;
1077 state->Init_Ctrl[33].bit[0] = 0;
1078 state->Init_Ctrl[33].val[0] = 0;
1079 state->Init_Ctrl[33].addr[1] = 168;
1080 state->Init_Ctrl[33].bit[1] = 1;
1081 state->Init_Ctrl[33].val[1] = 1;
1082 state->Init_Ctrl[33].addr[2] = 168;
1083 state->Init_Ctrl[33].bit[2] = 2;
1084 state->Init_Ctrl[33].val[2] = 0;
1085 state->Init_Ctrl[33].addr[3] = 168;
1086 state->Init_Ctrl[33].bit[3] = 3;
1087 state->Init_Ctrl[33].val[3] = 0;
Steven Toth52c99bd2008-05-01 04:57:01 -03001088
Steven Toth3935c252008-05-01 05:45:44 -03001089 state->Init_Ctrl[34].Ctrl_Num = RFA_CEIL ;
1090 state->Init_Ctrl[34].size = 4 ;
1091 state->Init_Ctrl[34].addr[0] = 168;
1092 state->Init_Ctrl[34].bit[0] = 4;
1093 state->Init_Ctrl[34].val[0] = 1;
1094 state->Init_Ctrl[34].addr[1] = 168;
1095 state->Init_Ctrl[34].bit[1] = 5;
1096 state->Init_Ctrl[34].val[1] = 1;
1097 state->Init_Ctrl[34].addr[2] = 168;
1098 state->Init_Ctrl[34].bit[2] = 6;
1099 state->Init_Ctrl[34].val[2] = 1;
1100 state->Init_Ctrl[34].addr[3] = 168;
1101 state->Init_Ctrl[34].bit[3] = 7;
1102 state->Init_Ctrl[34].val[3] = 1;
Steven Toth52c99bd2008-05-01 04:57:01 -03001103
Steven Toth3935c252008-05-01 05:45:44 -03001104 state->Init_Ctrl[35].Ctrl_Num = SEQ_EXTIQFSMPULSE ;
1105 state->Init_Ctrl[35].size = 1 ;
1106 state->Init_Ctrl[35].addr[0] = 135;
1107 state->Init_Ctrl[35].bit[0] = 0;
1108 state->Init_Ctrl[35].val[0] = 0;
Steven Toth52c99bd2008-05-01 04:57:01 -03001109
Steven Toth3935c252008-05-01 05:45:44 -03001110 state->Init_Ctrl[36].Ctrl_Num = OVERRIDE_1 ;
1111 state->Init_Ctrl[36].size = 1 ;
1112 state->Init_Ctrl[36].addr[0] = 56;
1113 state->Init_Ctrl[36].bit[0] = 3;
1114 state->Init_Ctrl[36].val[0] = 0;
Steven Toth52c99bd2008-05-01 04:57:01 -03001115
Steven Toth3935c252008-05-01 05:45:44 -03001116 state->Init_Ctrl[37].Ctrl_Num = BB_INITSTATE_DLPF_TUNE ;
1117 state->Init_Ctrl[37].size = 7 ;
1118 state->Init_Ctrl[37].addr[0] = 59;
1119 state->Init_Ctrl[37].bit[0] = 1;
1120 state->Init_Ctrl[37].val[0] = 0;
1121 state->Init_Ctrl[37].addr[1] = 59;
1122 state->Init_Ctrl[37].bit[1] = 2;
1123 state->Init_Ctrl[37].val[1] = 0;
1124 state->Init_Ctrl[37].addr[2] = 59;
1125 state->Init_Ctrl[37].bit[2] = 3;
1126 state->Init_Ctrl[37].val[2] = 0;
1127 state->Init_Ctrl[37].addr[3] = 59;
1128 state->Init_Ctrl[37].bit[3] = 4;
1129 state->Init_Ctrl[37].val[3] = 0;
1130 state->Init_Ctrl[37].addr[4] = 59;
1131 state->Init_Ctrl[37].bit[4] = 5;
1132 state->Init_Ctrl[37].val[4] = 0;
1133 state->Init_Ctrl[37].addr[5] = 59;
1134 state->Init_Ctrl[37].bit[5] = 6;
1135 state->Init_Ctrl[37].val[5] = 0;
1136 state->Init_Ctrl[37].addr[6] = 59;
1137 state->Init_Ctrl[37].bit[6] = 7;
1138 state->Init_Ctrl[37].val[6] = 0;
Steven Toth52c99bd2008-05-01 04:57:01 -03001139
Steven Toth3935c252008-05-01 05:45:44 -03001140 state->Init_Ctrl[38].Ctrl_Num = TG_R_DIV ;
1141 state->Init_Ctrl[38].size = 6 ;
1142 state->Init_Ctrl[38].addr[0] = 32;
1143 state->Init_Ctrl[38].bit[0] = 2;
1144 state->Init_Ctrl[38].val[0] = 0;
1145 state->Init_Ctrl[38].addr[1] = 32;
1146 state->Init_Ctrl[38].bit[1] = 3;
1147 state->Init_Ctrl[38].val[1] = 0;
1148 state->Init_Ctrl[38].addr[2] = 32;
1149 state->Init_Ctrl[38].bit[2] = 4;
1150 state->Init_Ctrl[38].val[2] = 0;
1151 state->Init_Ctrl[38].addr[3] = 32;
1152 state->Init_Ctrl[38].bit[3] = 5;
1153 state->Init_Ctrl[38].val[3] = 0;
1154 state->Init_Ctrl[38].addr[4] = 32;
1155 state->Init_Ctrl[38].bit[4] = 6;
1156 state->Init_Ctrl[38].val[4] = 1;
1157 state->Init_Ctrl[38].addr[5] = 32;
1158 state->Init_Ctrl[38].bit[5] = 7;
1159 state->Init_Ctrl[38].val[5] = 0;
Steven Toth52c99bd2008-05-01 04:57:01 -03001160
Steven Toth3935c252008-05-01 05:45:44 -03001161 state->Init_Ctrl[39].Ctrl_Num = EN_CHP_LIN_B ;
1162 state->Init_Ctrl[39].size = 1 ;
1163 state->Init_Ctrl[39].addr[0] = 25;
1164 state->Init_Ctrl[39].bit[0] = 3;
1165 state->Init_Ctrl[39].val[0] = 1;
Steven Toth52c99bd2008-05-01 04:57:01 -03001166
1167
Steven Toth3935c252008-05-01 05:45:44 -03001168 state->CH_Ctrl_Num = CHCTRL_NUM ;
Steven Toth52c99bd2008-05-01 04:57:01 -03001169
Steven Toth3935c252008-05-01 05:45:44 -03001170 state->CH_Ctrl[0].Ctrl_Num = DN_POLY ;
1171 state->CH_Ctrl[0].size = 2 ;
1172 state->CH_Ctrl[0].addr[0] = 68;
1173 state->CH_Ctrl[0].bit[0] = 6;
1174 state->CH_Ctrl[0].val[0] = 1;
1175 state->CH_Ctrl[0].addr[1] = 68;
1176 state->CH_Ctrl[0].bit[1] = 7;
1177 state->CH_Ctrl[0].val[1] = 1;
Steven Toth52c99bd2008-05-01 04:57:01 -03001178
Steven Toth3935c252008-05-01 05:45:44 -03001179 state->CH_Ctrl[1].Ctrl_Num = DN_RFGAIN ;
1180 state->CH_Ctrl[1].size = 2 ;
1181 state->CH_Ctrl[1].addr[0] = 70;
1182 state->CH_Ctrl[1].bit[0] = 6;
1183 state->CH_Ctrl[1].val[0] = 1;
1184 state->CH_Ctrl[1].addr[1] = 70;
1185 state->CH_Ctrl[1].bit[1] = 7;
1186 state->CH_Ctrl[1].val[1] = 0;
Steven Toth52c99bd2008-05-01 04:57:01 -03001187
Steven Toth3935c252008-05-01 05:45:44 -03001188 state->CH_Ctrl[2].Ctrl_Num = DN_CAP_RFLPF ;
1189 state->CH_Ctrl[2].size = 9 ;
1190 state->CH_Ctrl[2].addr[0] = 69;
1191 state->CH_Ctrl[2].bit[0] = 5;
1192 state->CH_Ctrl[2].val[0] = 0;
1193 state->CH_Ctrl[2].addr[1] = 69;
1194 state->CH_Ctrl[2].bit[1] = 6;
1195 state->CH_Ctrl[2].val[1] = 0;
1196 state->CH_Ctrl[2].addr[2] = 69;
1197 state->CH_Ctrl[2].bit[2] = 7;
1198 state->CH_Ctrl[2].val[2] = 0;
1199 state->CH_Ctrl[2].addr[3] = 68;
1200 state->CH_Ctrl[2].bit[3] = 0;
1201 state->CH_Ctrl[2].val[3] = 0;
1202 state->CH_Ctrl[2].addr[4] = 68;
1203 state->CH_Ctrl[2].bit[4] = 1;
1204 state->CH_Ctrl[2].val[4] = 0;
1205 state->CH_Ctrl[2].addr[5] = 68;
1206 state->CH_Ctrl[2].bit[5] = 2;
1207 state->CH_Ctrl[2].val[5] = 0;
1208 state->CH_Ctrl[2].addr[6] = 68;
1209 state->CH_Ctrl[2].bit[6] = 3;
1210 state->CH_Ctrl[2].val[6] = 0;
1211 state->CH_Ctrl[2].addr[7] = 68;
1212 state->CH_Ctrl[2].bit[7] = 4;
1213 state->CH_Ctrl[2].val[7] = 0;
1214 state->CH_Ctrl[2].addr[8] = 68;
1215 state->CH_Ctrl[2].bit[8] = 5;
1216 state->CH_Ctrl[2].val[8] = 0;
Steven Toth52c99bd2008-05-01 04:57:01 -03001217
Steven Toth3935c252008-05-01 05:45:44 -03001218 state->CH_Ctrl[3].Ctrl_Num = DN_EN_VHFUHFBAR ;
1219 state->CH_Ctrl[3].size = 1 ;
1220 state->CH_Ctrl[3].addr[0] = 70;
1221 state->CH_Ctrl[3].bit[0] = 5;
1222 state->CH_Ctrl[3].val[0] = 0;
Steven Toth52c99bd2008-05-01 04:57:01 -03001223
Steven Toth3935c252008-05-01 05:45:44 -03001224 state->CH_Ctrl[4].Ctrl_Num = DN_GAIN_ADJUST ;
1225 state->CH_Ctrl[4].size = 3 ;
1226 state->CH_Ctrl[4].addr[0] = 73;
1227 state->CH_Ctrl[4].bit[0] = 4;
1228 state->CH_Ctrl[4].val[0] = 0;
1229 state->CH_Ctrl[4].addr[1] = 73;
1230 state->CH_Ctrl[4].bit[1] = 5;
1231 state->CH_Ctrl[4].val[1] = 1;
1232 state->CH_Ctrl[4].addr[2] = 73;
1233 state->CH_Ctrl[4].bit[2] = 6;
1234 state->CH_Ctrl[4].val[2] = 0;
Steven Toth52c99bd2008-05-01 04:57:01 -03001235
Steven Toth3935c252008-05-01 05:45:44 -03001236 state->CH_Ctrl[5].Ctrl_Num = DN_IQTNBUF_AMP ;
1237 state->CH_Ctrl[5].size = 4 ;
1238 state->CH_Ctrl[5].addr[0] = 70;
1239 state->CH_Ctrl[5].bit[0] = 0;
1240 state->CH_Ctrl[5].val[0] = 0;
1241 state->CH_Ctrl[5].addr[1] = 70;
1242 state->CH_Ctrl[5].bit[1] = 1;
1243 state->CH_Ctrl[5].val[1] = 0;
1244 state->CH_Ctrl[5].addr[2] = 70;
1245 state->CH_Ctrl[5].bit[2] = 2;
1246 state->CH_Ctrl[5].val[2] = 0;
1247 state->CH_Ctrl[5].addr[3] = 70;
1248 state->CH_Ctrl[5].bit[3] = 3;
1249 state->CH_Ctrl[5].val[3] = 0;
Steven Toth52c99bd2008-05-01 04:57:01 -03001250
Steven Toth3935c252008-05-01 05:45:44 -03001251 state->CH_Ctrl[6].Ctrl_Num = DN_IQTNGNBFBIAS_BST ;
1252 state->CH_Ctrl[6].size = 1 ;
1253 state->CH_Ctrl[6].addr[0] = 70;
1254 state->CH_Ctrl[6].bit[0] = 4;
1255 state->CH_Ctrl[6].val[0] = 1;
Steven Toth52c99bd2008-05-01 04:57:01 -03001256
Steven Toth3935c252008-05-01 05:45:44 -03001257 state->CH_Ctrl[7].Ctrl_Num = RFSYN_EN_OUTMUX ;
1258 state->CH_Ctrl[7].size = 1 ;
1259 state->CH_Ctrl[7].addr[0] = 111;
1260 state->CH_Ctrl[7].bit[0] = 4;
1261 state->CH_Ctrl[7].val[0] = 0;
Steven Toth52c99bd2008-05-01 04:57:01 -03001262
Steven Toth3935c252008-05-01 05:45:44 -03001263 state->CH_Ctrl[8].Ctrl_Num = RFSYN_SEL_VCO_OUT ;
1264 state->CH_Ctrl[8].size = 1 ;
1265 state->CH_Ctrl[8].addr[0] = 111;
1266 state->CH_Ctrl[8].bit[0] = 7;
1267 state->CH_Ctrl[8].val[0] = 1;
Steven Toth52c99bd2008-05-01 04:57:01 -03001268
Steven Toth3935c252008-05-01 05:45:44 -03001269 state->CH_Ctrl[9].Ctrl_Num = RFSYN_SEL_VCO_HI ;
1270 state->CH_Ctrl[9].size = 1 ;
1271 state->CH_Ctrl[9].addr[0] = 111;
1272 state->CH_Ctrl[9].bit[0] = 6;
1273 state->CH_Ctrl[9].val[0] = 1;
Steven Toth52c99bd2008-05-01 04:57:01 -03001274
Steven Toth3935c252008-05-01 05:45:44 -03001275 state->CH_Ctrl[10].Ctrl_Num = RFSYN_SEL_DIVM ;
1276 state->CH_Ctrl[10].size = 1 ;
1277 state->CH_Ctrl[10].addr[0] = 111;
1278 state->CH_Ctrl[10].bit[0] = 5;
1279 state->CH_Ctrl[10].val[0] = 0;
Steven Toth52c99bd2008-05-01 04:57:01 -03001280
Steven Toth3935c252008-05-01 05:45:44 -03001281 state->CH_Ctrl[11].Ctrl_Num = RFSYN_RF_DIV_BIAS ;
1282 state->CH_Ctrl[11].size = 2 ;
1283 state->CH_Ctrl[11].addr[0] = 110;
1284 state->CH_Ctrl[11].bit[0] = 0;
1285 state->CH_Ctrl[11].val[0] = 1;
1286 state->CH_Ctrl[11].addr[1] = 110;
1287 state->CH_Ctrl[11].bit[1] = 1;
1288 state->CH_Ctrl[11].val[1] = 0;
Steven Toth52c99bd2008-05-01 04:57:01 -03001289
Steven Toth3935c252008-05-01 05:45:44 -03001290 state->CH_Ctrl[12].Ctrl_Num = DN_SEL_FREQ ;
1291 state->CH_Ctrl[12].size = 3 ;
1292 state->CH_Ctrl[12].addr[0] = 69;
1293 state->CH_Ctrl[12].bit[0] = 2;
1294 state->CH_Ctrl[12].val[0] = 0;
1295 state->CH_Ctrl[12].addr[1] = 69;
1296 state->CH_Ctrl[12].bit[1] = 3;
1297 state->CH_Ctrl[12].val[1] = 0;
1298 state->CH_Ctrl[12].addr[2] = 69;
1299 state->CH_Ctrl[12].bit[2] = 4;
1300 state->CH_Ctrl[12].val[2] = 0;
Steven Toth52c99bd2008-05-01 04:57:01 -03001301
Steven Toth3935c252008-05-01 05:45:44 -03001302 state->CH_Ctrl[13].Ctrl_Num = RFSYN_VCO_BIAS ;
1303 state->CH_Ctrl[13].size = 6 ;
1304 state->CH_Ctrl[13].addr[0] = 110;
1305 state->CH_Ctrl[13].bit[0] = 2;
1306 state->CH_Ctrl[13].val[0] = 0;
1307 state->CH_Ctrl[13].addr[1] = 110;
1308 state->CH_Ctrl[13].bit[1] = 3;
1309 state->CH_Ctrl[13].val[1] = 0;
1310 state->CH_Ctrl[13].addr[2] = 110;
1311 state->CH_Ctrl[13].bit[2] = 4;
1312 state->CH_Ctrl[13].val[2] = 0;
1313 state->CH_Ctrl[13].addr[3] = 110;
1314 state->CH_Ctrl[13].bit[3] = 5;
1315 state->CH_Ctrl[13].val[3] = 0;
1316 state->CH_Ctrl[13].addr[4] = 110;
1317 state->CH_Ctrl[13].bit[4] = 6;
1318 state->CH_Ctrl[13].val[4] = 0;
1319 state->CH_Ctrl[13].addr[5] = 110;
1320 state->CH_Ctrl[13].bit[5] = 7;
1321 state->CH_Ctrl[13].val[5] = 1;
Steven Toth52c99bd2008-05-01 04:57:01 -03001322
Steven Toth3935c252008-05-01 05:45:44 -03001323 state->CH_Ctrl[14].Ctrl_Num = CHCAL_INT_MOD_RF ;
1324 state->CH_Ctrl[14].size = 7 ;
1325 state->CH_Ctrl[14].addr[0] = 14;
1326 state->CH_Ctrl[14].bit[0] = 0;
1327 state->CH_Ctrl[14].val[0] = 0;
1328 state->CH_Ctrl[14].addr[1] = 14;
1329 state->CH_Ctrl[14].bit[1] = 1;
1330 state->CH_Ctrl[14].val[1] = 0;
1331 state->CH_Ctrl[14].addr[2] = 14;
1332 state->CH_Ctrl[14].bit[2] = 2;
1333 state->CH_Ctrl[14].val[2] = 0;
1334 state->CH_Ctrl[14].addr[3] = 14;
1335 state->CH_Ctrl[14].bit[3] = 3;
1336 state->CH_Ctrl[14].val[3] = 0;
1337 state->CH_Ctrl[14].addr[4] = 14;
1338 state->CH_Ctrl[14].bit[4] = 4;
1339 state->CH_Ctrl[14].val[4] = 0;
1340 state->CH_Ctrl[14].addr[5] = 14;
1341 state->CH_Ctrl[14].bit[5] = 5;
1342 state->CH_Ctrl[14].val[5] = 0;
1343 state->CH_Ctrl[14].addr[6] = 14;
1344 state->CH_Ctrl[14].bit[6] = 6;
1345 state->CH_Ctrl[14].val[6] = 0;
Steven Toth52c99bd2008-05-01 04:57:01 -03001346
Steven Toth3935c252008-05-01 05:45:44 -03001347 state->CH_Ctrl[15].Ctrl_Num = CHCAL_FRAC_MOD_RF ;
1348 state->CH_Ctrl[15].size = 18 ;
1349 state->CH_Ctrl[15].addr[0] = 17;
1350 state->CH_Ctrl[15].bit[0] = 6;
1351 state->CH_Ctrl[15].val[0] = 0;
1352 state->CH_Ctrl[15].addr[1] = 17;
1353 state->CH_Ctrl[15].bit[1] = 7;
1354 state->CH_Ctrl[15].val[1] = 0;
1355 state->CH_Ctrl[15].addr[2] = 16;
1356 state->CH_Ctrl[15].bit[2] = 0;
1357 state->CH_Ctrl[15].val[2] = 0;
1358 state->CH_Ctrl[15].addr[3] = 16;
1359 state->CH_Ctrl[15].bit[3] = 1;
1360 state->CH_Ctrl[15].val[3] = 0;
1361 state->CH_Ctrl[15].addr[4] = 16;
1362 state->CH_Ctrl[15].bit[4] = 2;
1363 state->CH_Ctrl[15].val[4] = 0;
1364 state->CH_Ctrl[15].addr[5] = 16;
1365 state->CH_Ctrl[15].bit[5] = 3;
1366 state->CH_Ctrl[15].val[5] = 0;
1367 state->CH_Ctrl[15].addr[6] = 16;
1368 state->CH_Ctrl[15].bit[6] = 4;
1369 state->CH_Ctrl[15].val[6] = 0;
1370 state->CH_Ctrl[15].addr[7] = 16;
1371 state->CH_Ctrl[15].bit[7] = 5;
1372 state->CH_Ctrl[15].val[7] = 0;
1373 state->CH_Ctrl[15].addr[8] = 16;
1374 state->CH_Ctrl[15].bit[8] = 6;
1375 state->CH_Ctrl[15].val[8] = 0;
1376 state->CH_Ctrl[15].addr[9] = 16;
1377 state->CH_Ctrl[15].bit[9] = 7;
1378 state->CH_Ctrl[15].val[9] = 0;
1379 state->CH_Ctrl[15].addr[10] = 15;
1380 state->CH_Ctrl[15].bit[10] = 0;
1381 state->CH_Ctrl[15].val[10] = 0;
1382 state->CH_Ctrl[15].addr[11] = 15;
1383 state->CH_Ctrl[15].bit[11] = 1;
1384 state->CH_Ctrl[15].val[11] = 0;
1385 state->CH_Ctrl[15].addr[12] = 15;
1386 state->CH_Ctrl[15].bit[12] = 2;
1387 state->CH_Ctrl[15].val[12] = 0;
1388 state->CH_Ctrl[15].addr[13] = 15;
1389 state->CH_Ctrl[15].bit[13] = 3;
1390 state->CH_Ctrl[15].val[13] = 0;
1391 state->CH_Ctrl[15].addr[14] = 15;
1392 state->CH_Ctrl[15].bit[14] = 4;
1393 state->CH_Ctrl[15].val[14] = 0;
1394 state->CH_Ctrl[15].addr[15] = 15;
1395 state->CH_Ctrl[15].bit[15] = 5;
1396 state->CH_Ctrl[15].val[15] = 0;
1397 state->CH_Ctrl[15].addr[16] = 15;
1398 state->CH_Ctrl[15].bit[16] = 6;
1399 state->CH_Ctrl[15].val[16] = 1;
1400 state->CH_Ctrl[15].addr[17] = 15;
1401 state->CH_Ctrl[15].bit[17] = 7;
1402 state->CH_Ctrl[15].val[17] = 1;
Steven Toth52c99bd2008-05-01 04:57:01 -03001403
Steven Toth3935c252008-05-01 05:45:44 -03001404 state->CH_Ctrl[16].Ctrl_Num = RFSYN_LPF_R ;
1405 state->CH_Ctrl[16].size = 5 ;
1406 state->CH_Ctrl[16].addr[0] = 112;
1407 state->CH_Ctrl[16].bit[0] = 0;
1408 state->CH_Ctrl[16].val[0] = 0;
1409 state->CH_Ctrl[16].addr[1] = 112;
1410 state->CH_Ctrl[16].bit[1] = 1;
1411 state->CH_Ctrl[16].val[1] = 0;
1412 state->CH_Ctrl[16].addr[2] = 112;
1413 state->CH_Ctrl[16].bit[2] = 2;
1414 state->CH_Ctrl[16].val[2] = 0;
1415 state->CH_Ctrl[16].addr[3] = 112;
1416 state->CH_Ctrl[16].bit[3] = 3;
1417 state->CH_Ctrl[16].val[3] = 0;
1418 state->CH_Ctrl[16].addr[4] = 112;
1419 state->CH_Ctrl[16].bit[4] = 4;
1420 state->CH_Ctrl[16].val[4] = 1;
Steven Toth52c99bd2008-05-01 04:57:01 -03001421
Steven Toth3935c252008-05-01 05:45:44 -03001422 state->CH_Ctrl[17].Ctrl_Num = CHCAL_EN_INT_RF ;
1423 state->CH_Ctrl[17].size = 1 ;
1424 state->CH_Ctrl[17].addr[0] = 14;
1425 state->CH_Ctrl[17].bit[0] = 7;
1426 state->CH_Ctrl[17].val[0] = 0;
Steven Toth52c99bd2008-05-01 04:57:01 -03001427
Steven Toth3935c252008-05-01 05:45:44 -03001428 state->CH_Ctrl[18].Ctrl_Num = TG_LO_DIVVAL ;
1429 state->CH_Ctrl[18].size = 4 ;
1430 state->CH_Ctrl[18].addr[0] = 107;
1431 state->CH_Ctrl[18].bit[0] = 3;
1432 state->CH_Ctrl[18].val[0] = 0;
1433 state->CH_Ctrl[18].addr[1] = 107;
1434 state->CH_Ctrl[18].bit[1] = 4;
1435 state->CH_Ctrl[18].val[1] = 0;
1436 state->CH_Ctrl[18].addr[2] = 107;
1437 state->CH_Ctrl[18].bit[2] = 5;
1438 state->CH_Ctrl[18].val[2] = 0;
1439 state->CH_Ctrl[18].addr[3] = 107;
1440 state->CH_Ctrl[18].bit[3] = 6;
1441 state->CH_Ctrl[18].val[3] = 0;
Steven Toth52c99bd2008-05-01 04:57:01 -03001442
Steven Toth3935c252008-05-01 05:45:44 -03001443 state->CH_Ctrl[19].Ctrl_Num = TG_LO_SELVAL ;
1444 state->CH_Ctrl[19].size = 3 ;
1445 state->CH_Ctrl[19].addr[0] = 107;
1446 state->CH_Ctrl[19].bit[0] = 7;
1447 state->CH_Ctrl[19].val[0] = 1;
1448 state->CH_Ctrl[19].addr[1] = 106;
1449 state->CH_Ctrl[19].bit[1] = 0;
1450 state->CH_Ctrl[19].val[1] = 1;
1451 state->CH_Ctrl[19].addr[2] = 106;
1452 state->CH_Ctrl[19].bit[2] = 1;
1453 state->CH_Ctrl[19].val[2] = 1;
Steven Toth52c99bd2008-05-01 04:57:01 -03001454
Steven Toth3935c252008-05-01 05:45:44 -03001455 state->CH_Ctrl[20].Ctrl_Num = TG_DIV_VAL ;
1456 state->CH_Ctrl[20].size = 11 ;
1457 state->CH_Ctrl[20].addr[0] = 109;
1458 state->CH_Ctrl[20].bit[0] = 2;
1459 state->CH_Ctrl[20].val[0] = 0;
1460 state->CH_Ctrl[20].addr[1] = 109;
1461 state->CH_Ctrl[20].bit[1] = 3;
1462 state->CH_Ctrl[20].val[1] = 0;
1463 state->CH_Ctrl[20].addr[2] = 109;
1464 state->CH_Ctrl[20].bit[2] = 4;
1465 state->CH_Ctrl[20].val[2] = 0;
1466 state->CH_Ctrl[20].addr[3] = 109;
1467 state->CH_Ctrl[20].bit[3] = 5;
1468 state->CH_Ctrl[20].val[3] = 0;
1469 state->CH_Ctrl[20].addr[4] = 109;
1470 state->CH_Ctrl[20].bit[4] = 6;
1471 state->CH_Ctrl[20].val[4] = 0;
1472 state->CH_Ctrl[20].addr[5] = 109;
1473 state->CH_Ctrl[20].bit[5] = 7;
1474 state->CH_Ctrl[20].val[5] = 0;
1475 state->CH_Ctrl[20].addr[6] = 108;
1476 state->CH_Ctrl[20].bit[6] = 0;
1477 state->CH_Ctrl[20].val[6] = 0;
1478 state->CH_Ctrl[20].addr[7] = 108;
1479 state->CH_Ctrl[20].bit[7] = 1;
1480 state->CH_Ctrl[20].val[7] = 0;
1481 state->CH_Ctrl[20].addr[8] = 108;
1482 state->CH_Ctrl[20].bit[8] = 2;
1483 state->CH_Ctrl[20].val[8] = 1;
1484 state->CH_Ctrl[20].addr[9] = 108;
1485 state->CH_Ctrl[20].bit[9] = 3;
1486 state->CH_Ctrl[20].val[9] = 1;
1487 state->CH_Ctrl[20].addr[10] = 108;
1488 state->CH_Ctrl[20].bit[10] = 4;
1489 state->CH_Ctrl[20].val[10] = 1;
Steven Toth52c99bd2008-05-01 04:57:01 -03001490
Steven Toth3935c252008-05-01 05:45:44 -03001491 state->CH_Ctrl[21].Ctrl_Num = TG_VCO_BIAS ;
1492 state->CH_Ctrl[21].size = 6 ;
1493 state->CH_Ctrl[21].addr[0] = 106;
1494 state->CH_Ctrl[21].bit[0] = 2;
1495 state->CH_Ctrl[21].val[0] = 0;
1496 state->CH_Ctrl[21].addr[1] = 106;
1497 state->CH_Ctrl[21].bit[1] = 3;
1498 state->CH_Ctrl[21].val[1] = 0;
1499 state->CH_Ctrl[21].addr[2] = 106;
1500 state->CH_Ctrl[21].bit[2] = 4;
1501 state->CH_Ctrl[21].val[2] = 0;
1502 state->CH_Ctrl[21].addr[3] = 106;
1503 state->CH_Ctrl[21].bit[3] = 5;
1504 state->CH_Ctrl[21].val[3] = 0;
1505 state->CH_Ctrl[21].addr[4] = 106;
1506 state->CH_Ctrl[21].bit[4] = 6;
1507 state->CH_Ctrl[21].val[4] = 0;
1508 state->CH_Ctrl[21].addr[5] = 106;
1509 state->CH_Ctrl[21].bit[5] = 7;
1510 state->CH_Ctrl[21].val[5] = 1;
Steven Toth52c99bd2008-05-01 04:57:01 -03001511
Steven Toth3935c252008-05-01 05:45:44 -03001512 state->CH_Ctrl[22].Ctrl_Num = SEQ_EXTPOWERUP ;
1513 state->CH_Ctrl[22].size = 1 ;
1514 state->CH_Ctrl[22].addr[0] = 138;
1515 state->CH_Ctrl[22].bit[0] = 4;
1516 state->CH_Ctrl[22].val[0] = 1;
Steven Toth52c99bd2008-05-01 04:57:01 -03001517
Steven Toth3935c252008-05-01 05:45:44 -03001518 state->CH_Ctrl[23].Ctrl_Num = OVERRIDE_2 ;
1519 state->CH_Ctrl[23].size = 1 ;
1520 state->CH_Ctrl[23].addr[0] = 17;
1521 state->CH_Ctrl[23].bit[0] = 5;
1522 state->CH_Ctrl[23].val[0] = 0;
Steven Toth52c99bd2008-05-01 04:57:01 -03001523
Steven Toth3935c252008-05-01 05:45:44 -03001524 state->CH_Ctrl[24].Ctrl_Num = OVERRIDE_3 ;
1525 state->CH_Ctrl[24].size = 1 ;
1526 state->CH_Ctrl[24].addr[0] = 111;
1527 state->CH_Ctrl[24].bit[0] = 3;
1528 state->CH_Ctrl[24].val[0] = 0;
Steven Toth52c99bd2008-05-01 04:57:01 -03001529
Steven Toth3935c252008-05-01 05:45:44 -03001530 state->CH_Ctrl[25].Ctrl_Num = OVERRIDE_4 ;
1531 state->CH_Ctrl[25].size = 1 ;
1532 state->CH_Ctrl[25].addr[0] = 112;
1533 state->CH_Ctrl[25].bit[0] = 7;
1534 state->CH_Ctrl[25].val[0] = 0;
Steven Toth52c99bd2008-05-01 04:57:01 -03001535
Steven Toth3935c252008-05-01 05:45:44 -03001536 state->CH_Ctrl[26].Ctrl_Num = SEQ_FSM_PULSE ;
1537 state->CH_Ctrl[26].size = 1 ;
1538 state->CH_Ctrl[26].addr[0] = 136;
1539 state->CH_Ctrl[26].bit[0] = 7;
1540 state->CH_Ctrl[26].val[0] = 0;
Steven Toth52c99bd2008-05-01 04:57:01 -03001541
Steven Toth3935c252008-05-01 05:45:44 -03001542 state->CH_Ctrl[27].Ctrl_Num = GPIO_4B ;
1543 state->CH_Ctrl[27].size = 1 ;
1544 state->CH_Ctrl[27].addr[0] = 149;
1545 state->CH_Ctrl[27].bit[0] = 7;
1546 state->CH_Ctrl[27].val[0] = 0;
Steven Toth52c99bd2008-05-01 04:57:01 -03001547
Steven Toth3935c252008-05-01 05:45:44 -03001548 state->CH_Ctrl[28].Ctrl_Num = GPIO_3B ;
1549 state->CH_Ctrl[28].size = 1 ;
1550 state->CH_Ctrl[28].addr[0] = 149;
1551 state->CH_Ctrl[28].bit[0] = 6;
1552 state->CH_Ctrl[28].val[0] = 0;
Steven Toth52c99bd2008-05-01 04:57:01 -03001553
Steven Toth3935c252008-05-01 05:45:44 -03001554 state->CH_Ctrl[29].Ctrl_Num = GPIO_4 ;
1555 state->CH_Ctrl[29].size = 1 ;
1556 state->CH_Ctrl[29].addr[0] = 149;
1557 state->CH_Ctrl[29].bit[0] = 5;
1558 state->CH_Ctrl[29].val[0] = 1;
Steven Toth52c99bd2008-05-01 04:57:01 -03001559
Steven Toth3935c252008-05-01 05:45:44 -03001560 state->CH_Ctrl[30].Ctrl_Num = GPIO_3 ;
1561 state->CH_Ctrl[30].size = 1 ;
1562 state->CH_Ctrl[30].addr[0] = 149;
1563 state->CH_Ctrl[30].bit[0] = 4;
1564 state->CH_Ctrl[30].val[0] = 1;
Steven Toth52c99bd2008-05-01 04:57:01 -03001565
Steven Toth3935c252008-05-01 05:45:44 -03001566 state->CH_Ctrl[31].Ctrl_Num = GPIO_1B ;
1567 state->CH_Ctrl[31].size = 1 ;
1568 state->CH_Ctrl[31].addr[0] = 149;
1569 state->CH_Ctrl[31].bit[0] = 3;
1570 state->CH_Ctrl[31].val[0] = 0;
Steven Toth52c99bd2008-05-01 04:57:01 -03001571
Steven Toth3935c252008-05-01 05:45:44 -03001572 state->CH_Ctrl[32].Ctrl_Num = DAC_A_ENABLE ;
1573 state->CH_Ctrl[32].size = 1 ;
1574 state->CH_Ctrl[32].addr[0] = 93;
1575 state->CH_Ctrl[32].bit[0] = 1;
1576 state->CH_Ctrl[32].val[0] = 0;
Steven Toth52c99bd2008-05-01 04:57:01 -03001577
Steven Toth3935c252008-05-01 05:45:44 -03001578 state->CH_Ctrl[33].Ctrl_Num = DAC_B_ENABLE ;
1579 state->CH_Ctrl[33].size = 1 ;
1580 state->CH_Ctrl[33].addr[0] = 93;
1581 state->CH_Ctrl[33].bit[0] = 0;
1582 state->CH_Ctrl[33].val[0] = 0;
Steven Toth52c99bd2008-05-01 04:57:01 -03001583
Steven Toth3935c252008-05-01 05:45:44 -03001584 state->CH_Ctrl[34].Ctrl_Num = DAC_DIN_A ;
1585 state->CH_Ctrl[34].size = 6 ;
1586 state->CH_Ctrl[34].addr[0] = 92;
1587 state->CH_Ctrl[34].bit[0] = 2;
1588 state->CH_Ctrl[34].val[0] = 0;
1589 state->CH_Ctrl[34].addr[1] = 92;
1590 state->CH_Ctrl[34].bit[1] = 3;
1591 state->CH_Ctrl[34].val[1] = 0;
1592 state->CH_Ctrl[34].addr[2] = 92;
1593 state->CH_Ctrl[34].bit[2] = 4;
1594 state->CH_Ctrl[34].val[2] = 0;
1595 state->CH_Ctrl[34].addr[3] = 92;
1596 state->CH_Ctrl[34].bit[3] = 5;
1597 state->CH_Ctrl[34].val[3] = 0;
1598 state->CH_Ctrl[34].addr[4] = 92;
1599 state->CH_Ctrl[34].bit[4] = 6;
1600 state->CH_Ctrl[34].val[4] = 0;
1601 state->CH_Ctrl[34].addr[5] = 92;
1602 state->CH_Ctrl[34].bit[5] = 7;
1603 state->CH_Ctrl[34].val[5] = 0;
Steven Toth52c99bd2008-05-01 04:57:01 -03001604
Steven Toth3935c252008-05-01 05:45:44 -03001605 state->CH_Ctrl[35].Ctrl_Num = DAC_DIN_B ;
1606 state->CH_Ctrl[35].size = 6 ;
1607 state->CH_Ctrl[35].addr[0] = 93;
1608 state->CH_Ctrl[35].bit[0] = 2;
1609 state->CH_Ctrl[35].val[0] = 0;
1610 state->CH_Ctrl[35].addr[1] = 93;
1611 state->CH_Ctrl[35].bit[1] = 3;
1612 state->CH_Ctrl[35].val[1] = 0;
1613 state->CH_Ctrl[35].addr[2] = 93;
1614 state->CH_Ctrl[35].bit[2] = 4;
1615 state->CH_Ctrl[35].val[2] = 0;
1616 state->CH_Ctrl[35].addr[3] = 93;
1617 state->CH_Ctrl[35].bit[3] = 5;
1618 state->CH_Ctrl[35].val[3] = 0;
1619 state->CH_Ctrl[35].addr[4] = 93;
1620 state->CH_Ctrl[35].bit[4] = 6;
1621 state->CH_Ctrl[35].val[4] = 0;
1622 state->CH_Ctrl[35].addr[5] = 93;
1623 state->CH_Ctrl[35].bit[5] = 7;
1624 state->CH_Ctrl[35].val[5] = 0;
Steven Toth52c99bd2008-05-01 04:57:01 -03001625
1626#ifdef _MXL_PRODUCTION
Steven Toth3935c252008-05-01 05:45:44 -03001627 state->CH_Ctrl[36].Ctrl_Num = RFSYN_EN_DIV ;
1628 state->CH_Ctrl[36].size = 1 ;
1629 state->CH_Ctrl[36].addr[0] = 109;
1630 state->CH_Ctrl[36].bit[0] = 1;
1631 state->CH_Ctrl[36].val[0] = 1;
Steven Toth52c99bd2008-05-01 04:57:01 -03001632
Steven Toth3935c252008-05-01 05:45:44 -03001633 state->CH_Ctrl[37].Ctrl_Num = RFSYN_DIVM ;
1634 state->CH_Ctrl[37].size = 2 ;
1635 state->CH_Ctrl[37].addr[0] = 112;
1636 state->CH_Ctrl[37].bit[0] = 5;
1637 state->CH_Ctrl[37].val[0] = 0;
1638 state->CH_Ctrl[37].addr[1] = 112;
1639 state->CH_Ctrl[37].bit[1] = 6;
1640 state->CH_Ctrl[37].val[1] = 0;
Steven Toth52c99bd2008-05-01 04:57:01 -03001641
Steven Toth3935c252008-05-01 05:45:44 -03001642 state->CH_Ctrl[38].Ctrl_Num = DN_BYPASS_AGC_I2C ;
1643 state->CH_Ctrl[38].size = 1 ;
1644 state->CH_Ctrl[38].addr[0] = 65;
1645 state->CH_Ctrl[38].bit[0] = 1;
1646 state->CH_Ctrl[38].val[0] = 0;
Steven Toth52c99bd2008-05-01 04:57:01 -03001647#endif
1648
1649 return 0 ;
1650}
1651
Steven Toth52c99bd2008-05-01 04:57:01 -03001652// MaxLinear source code - MXL5005_c.cpp
Steven Toth52c99bd2008-05-01 04:57:01 -03001653// MXL5005.cpp : Defines the initialization routines for the DLL.
1654// 2.6.12
Steven Toth3935c252008-05-01 05:45:44 -03001655void InitTunerControls(struct dvb_frontend *fe)
Steven Toth52c99bd2008-05-01 04:57:01 -03001656{
Steven Toth3935c252008-05-01 05:45:44 -03001657 MXL5005_RegisterInit(fe);
1658 MXL5005_ControlInit(fe);
Steven Toth52c99bd2008-05-01 04:57:01 -03001659#ifdef _MXL_INTERNAL
Steven Toth3935c252008-05-01 05:45:44 -03001660 MXL5005_MXLControlInit(fe);
Steven Toth52c99bd2008-05-01 04:57:01 -03001661#endif
1662}
1663
Steven Toth52c99bd2008-05-01 04:57:01 -03001664///////////////////////////////////////////////////////////////////////////////
1665// //
1666// Function: MXL_ConfigTuner //
1667// //
1668// Description: Configure MXL5005Tuner structure for desired //
1669// Channel Bandwidth/Channel Frequency //
1670// //
1671// //
1672// Functions used: //
Steven Totha8214d42008-05-01 05:02:58 -03001673// MXL_SynthIFLO_Calc //
Steven Toth52c99bd2008-05-01 04:57:01 -03001674// //
1675// Inputs: //
1676// Tuner_struct: structure defined at higher level //
1677// Mode: Tuner Mode (Analog/Digital) //
1678// IF_Mode: IF Mode ( Zero/Low ) //
Steven Toth3935c252008-05-01 05:45:44 -03001679// Bandwidth: Filter Channel Bandwidth (in Hz) //
Steven Toth52c99bd2008-05-01 04:57:01 -03001680// IF_out: Desired IF out Frequency (in Hz) //
1681// Fxtal: Crystal Frerquency (in Hz) //
Steven Toth3935c252008-05-01 05:45:44 -03001682// TOP: 0: Dual AGC; Value: take over point //
1683// IF_OUT_LOAD: IF out load resistor (200/300 Ohms) //
1684// CLOCK_OUT: 0: Turn off clock out; 1: turn on clock out //
1685// DIV_OUT: 0: Div-1; 1: Div-4 //
1686// CAPSELECT: 0: Disable On-chip pulling cap; 1: Enable //
1687// EN_RSSI: 0: Disable RSSI; 1: Enable RSSI //
Steven Toth52c99bd2008-05-01 04:57:01 -03001688// //
1689// Outputs: //
1690// Tuner //
1691// //
1692// Return: //
1693// 0 : Successful //
1694// > 0 : Failed //
1695// //
1696///////////////////////////////////////////////////////////////////////////////
Steven Toth3935c252008-05-01 05:45:44 -03001697u16 MXL5005_TunerConfig(struct dvb_frontend *fe,
1698 u8 Mode, /* 0: Analog Mode ; 1: Digital Mode */
1699 u8 IF_mode, /* for Analog Mode, 0: zero IF; 1: low IF */
1700 u32 Bandwidth, /* filter channel bandwidth (6, 7, 8) */
1701 u32 IF_out, /* Desired IF Out Frequency */
1702 u32 Fxtal, /* XTAL Frequency */
1703 u8 AGC_Mode, /* AGC Mode - Dual AGC: 0, Single AGC: 1 */
1704 u16 TOP, /* 0: Dual AGC; Value: take over point */
1705 u16 IF_OUT_LOAD, /* IF Out Load Resistor (200 / 300 Ohms) */
1706 u8 CLOCK_OUT, /* 0: turn off clock out; 1: turn on clock out */
1707 u8 DIV_OUT, /* 0: Div-1; 1: Div-4 */
1708 u8 CAPSELECT, /* 0: disable On-Chip pulling cap; 1: enable */
1709 u8 EN_RSSI, /* 0: disable RSSI; 1: enable RSSI */
1710 u8 Mod_Type, /* Modulation Type; */
1711 /* 0 - Default; 1 - DVB-T; 2 - ATSC; 3 - QAM; 4 - Analog Cable */
1712 u8 TF_Type /* Tracking Filter */
1713 /* 0 - Default; 1 - Off; 2 - Type C; 3 - Type C-H */
Steven Toth52c99bd2008-05-01 04:57:01 -03001714 )
1715{
Steven Toth85d220d2008-05-01 05:48:14 -03001716 struct mxl5005s_state *state = fe->tuner_priv;
Steven Toth3935c252008-05-01 05:45:44 -03001717 u16 status = 0;
Steven Toth52c99bd2008-05-01 04:57:01 -03001718
Steven Toth3935c252008-05-01 05:45:44 -03001719 state->Mode = Mode;
1720 state->IF_Mode = IF_mode;
1721 state->Chan_Bandwidth = Bandwidth;
1722 state->IF_OUT = IF_out;
1723 state->Fxtal = Fxtal;
1724 state->AGC_Mode = AGC_Mode;
1725 state->TOP = TOP;
1726 state->IF_OUT_LOAD = IF_OUT_LOAD;
1727 state->CLOCK_OUT = CLOCK_OUT;
1728 state->DIV_OUT = DIV_OUT;
1729 state->CAPSELECT = CAPSELECT;
1730 state->EN_RSSI = EN_RSSI;
1731 state->Mod_Type = Mod_Type;
1732 state->TF_Type = TF_Type;
Steven Toth52c99bd2008-05-01 04:57:01 -03001733
Steven Totha8214d42008-05-01 05:02:58 -03001734 /* Initialize all the controls and registers */
Steven Toth3935c252008-05-01 05:45:44 -03001735 InitTunerControls(fe);
Steven Totha8214d42008-05-01 05:02:58 -03001736
1737 /* Synthesizer LO frequency calculation */
Steven Toth3935c252008-05-01 05:45:44 -03001738 MXL_SynthIFLO_Calc(fe);
Steven Toth52c99bd2008-05-01 04:57:01 -03001739
Steven Toth3935c252008-05-01 05:45:44 -03001740 return status;
Steven Toth52c99bd2008-05-01 04:57:01 -03001741}
1742
1743///////////////////////////////////////////////////////////////////////////////
1744// //
1745// Function: MXL_SynthIFLO_Calc //
1746// //
1747// Description: Calculate Internal IF-LO Frequency //
1748// //
1749// Globals: //
1750// NONE //
1751// //
1752// Functions used: //
1753// NONE //
1754// //
1755// Inputs: //
1756// Tuner_struct: structure defined at higher level //
1757// //
1758// Outputs: //
1759// Tuner //
1760// //
1761// Return: //
1762// 0 : Successful //
1763// > 0 : Failed //
1764// //
1765///////////////////////////////////////////////////////////////////////////////
Steven Toth3935c252008-05-01 05:45:44 -03001766void MXL_SynthIFLO_Calc(struct dvb_frontend *fe)
Steven Toth52c99bd2008-05-01 04:57:01 -03001767{
Steven Toth85d220d2008-05-01 05:48:14 -03001768 struct mxl5005s_state *state = fe->tuner_priv;
1769 if (state->Mode == 1) /* Digital Mode */
Steven Toth3935c252008-05-01 05:45:44 -03001770 state->IF_LO = state->IF_OUT;
1771 else /* Analog Mode */
Steven Toth52c99bd2008-05-01 04:57:01 -03001772 {
Steven Toth3935c252008-05-01 05:45:44 -03001773 if(state->IF_Mode == 0) /* Analog Zero IF mode */
1774 state->IF_LO = state->IF_OUT + 400000;
1775 else /* Analog Low IF mode */
1776 state->IF_LO = state->IF_OUT + state->Chan_Bandwidth/2;
Steven Toth52c99bd2008-05-01 04:57:01 -03001777 }
1778}
1779
1780///////////////////////////////////////////////////////////////////////////////
1781// //
1782// Function: MXL_SynthRFTGLO_Calc //
1783// //
1784// Description: Calculate Internal RF-LO frequency and //
1785// internal Tone-Gen(TG)-LO frequency //
1786// //
1787// Globals: //
1788// NONE //
1789// //
1790// Functions used: //
1791// NONE //
1792// //
1793// Inputs: //
1794// Tuner_struct: structure defined at higher level //
1795// //
1796// Outputs: //
1797// Tuner //
1798// //
1799// Return: //
1800// 0 : Successful //
1801// > 0 : Failed //
1802// //
1803///////////////////////////////////////////////////////////////////////////////
Steven Toth3935c252008-05-01 05:45:44 -03001804void MXL_SynthRFTGLO_Calc(struct dvb_frontend *fe)
Steven Toth52c99bd2008-05-01 04:57:01 -03001805{
Steven Toth85d220d2008-05-01 05:48:14 -03001806 struct mxl5005s_state *state = fe->tuner_priv;
Steven Toth3935c252008-05-01 05:45:44 -03001807
1808 if (state->Mode == 1) /* Digital Mode */ {
Steven Toth52c99bd2008-05-01 04:57:01 -03001809 //remove 20.48MHz setting for 2.6.10
Steven Toth3935c252008-05-01 05:45:44 -03001810 state->RF_LO = state->RF_IN;
1811 state->TG_LO = state->RF_IN - 750000; //change for 2.6.6
1812 } else /* Analog Mode */ {
1813 if(state->IF_Mode == 0) /* Analog Zero IF mode */ {
1814 state->RF_LO = state->RF_IN - 400000;
1815 state->TG_LO = state->RF_IN - 1750000;
1816 } else /* Analog Low IF mode */ {
1817 state->RF_LO = state->RF_IN - state->Chan_Bandwidth/2;
1818 state->TG_LO = state->RF_IN - state->Chan_Bandwidth + 500000;
Steven Toth52c99bd2008-05-01 04:57:01 -03001819 }
1820 }
1821}
1822
1823///////////////////////////////////////////////////////////////////////////////
1824// //
1825// Function: MXL_OverwriteICDefault //
1826// //
1827// Description: Overwrite the Default Register Setting //
1828// //
1829// //
1830// Functions used: //
1831// //
1832// Inputs: //
1833// Tuner_struct: structure defined at higher level //
1834// Outputs: //
1835// Tuner //
1836// //
1837// Return: //
1838// 0 : Successful //
1839// > 0 : Failed //
1840// //
1841///////////////////////////////////////////////////////////////////////////////
Steven Toth3935c252008-05-01 05:45:44 -03001842u16 MXL_OverwriteICDefault(struct dvb_frontend *fe)
Steven Toth52c99bd2008-05-01 04:57:01 -03001843{
Steven Toth3935c252008-05-01 05:45:44 -03001844 u16 status = 0;
Steven Toth52c99bd2008-05-01 04:57:01 -03001845
Steven Toth3935c252008-05-01 05:45:44 -03001846 status += MXL_ControlWrite(fe, OVERRIDE_1, 1);
1847 status += MXL_ControlWrite(fe, OVERRIDE_2, 1);
1848 status += MXL_ControlWrite(fe, OVERRIDE_3, 1);
1849 status += MXL_ControlWrite(fe, OVERRIDE_4, 1);
Steven Toth52c99bd2008-05-01 04:57:01 -03001850
Steven Toth3935c252008-05-01 05:45:44 -03001851 return status;
Steven Toth52c99bd2008-05-01 04:57:01 -03001852}
1853
1854///////////////////////////////////////////////////////////////////////////////
1855// //
1856// Function: MXL_BlockInit //
1857// //
1858// Description: Tuner Initialization as a function of 'User Settings' //
1859// * User settings in Tuner strcuture must be assigned //
1860// first //
1861// //
1862// Globals: //
1863// NONE //
1864// //
1865// Functions used: //
1866// Tuner_struct: structure defined at higher level //
1867// //
1868// Inputs: //
1869// Tuner : Tuner structure defined at higher level //
1870// //
1871// Outputs: //
1872// Tuner //
1873// //
1874// Return: //
1875// 0 : Successful //
1876// > 0 : Failed //
1877// //
1878///////////////////////////////////////////////////////////////////////////////
Steven Toth3935c252008-05-01 05:45:44 -03001879u16 MXL_BlockInit(struct dvb_frontend *fe)
Steven Toth52c99bd2008-05-01 04:57:01 -03001880{
Steven Toth85d220d2008-05-01 05:48:14 -03001881 struct mxl5005s_state *state = fe->tuner_priv;
Steven Toth3935c252008-05-01 05:45:44 -03001882 u16 status = 0;
Steven Toth52c99bd2008-05-01 04:57:01 -03001883
Steven Toth3935c252008-05-01 05:45:44 -03001884 status += MXL_OverwriteICDefault(fe);
Steven Toth52c99bd2008-05-01 04:57:01 -03001885
Steven Toth3935c252008-05-01 05:45:44 -03001886 /* Downconverter Control Dig Ana */
1887 status += MXL_ControlWrite(fe, DN_IQTN_AMP_CUT, state->Mode ? 1 : 0);
Steven Toth52c99bd2008-05-01 04:57:01 -03001888
Steven Toth3935c252008-05-01 05:45:44 -03001889 /* Filter Control Dig Ana */
1890 status += MXL_ControlWrite(fe, BB_MODE, state->Mode ? 0 : 1);
1891 status += MXL_ControlWrite(fe, BB_BUF, state->Mode ? 3 : 2);
1892 status += MXL_ControlWrite(fe, BB_BUF_OA, state->Mode ? 1 : 0);
1893 status += MXL_ControlWrite(fe, BB_IQSWAP, state->Mode ? 0 : 1);
1894 status += MXL_ControlWrite(fe, BB_INITSTATE_DLPF_TUNE, 0);
Steven Toth52c99bd2008-05-01 04:57:01 -03001895
Steven Toth3935c252008-05-01 05:45:44 -03001896 /* Initialize Low-Pass Filter */
1897 if (state->Mode) { /* Digital Mode */
1898 switch (state->Chan_Bandwidth) {
Steven Toth52c99bd2008-05-01 04:57:01 -03001899 case 8000000:
Steven Toth3935c252008-05-01 05:45:44 -03001900 status += MXL_ControlWrite(fe, BB_DLPF_BANDSEL, 0);
1901 break;
Steven Toth52c99bd2008-05-01 04:57:01 -03001902 case 7000000:
Steven Toth3935c252008-05-01 05:45:44 -03001903 status += MXL_ControlWrite(fe, BB_DLPF_BANDSEL, 2);
1904 break;
Steven Toth52c99bd2008-05-01 04:57:01 -03001905 case 6000000:
Steven Toth8c66a192008-05-01 06:35:48 -03001906 printk("%s() doing 6MHz digital\n", __func__);
Steven Toth3935c252008-05-01 05:45:44 -03001907 status += MXL_ControlWrite(fe, BB_DLPF_BANDSEL, 3);
1908 break;
Steven Toth52c99bd2008-05-01 04:57:01 -03001909 }
Steven Toth3935c252008-05-01 05:45:44 -03001910 } else { /* Analog Mode */
1911 switch (state->Chan_Bandwidth) {
1912 case 8000000: /* Low Zero */
1913 status += MXL_ControlWrite(fe, BB_ALPF_BANDSELECT, (state->IF_Mode ? 0 : 3));
1914 break;
Steven Toth52c99bd2008-05-01 04:57:01 -03001915 case 7000000:
Steven Toth3935c252008-05-01 05:45:44 -03001916 status += MXL_ControlWrite(fe, BB_ALPF_BANDSELECT, (state->IF_Mode ? 1 : 4));
1917 break;
Steven Toth52c99bd2008-05-01 04:57:01 -03001918 case 6000000:
Steven Toth3935c252008-05-01 05:45:44 -03001919 status += MXL_ControlWrite(fe, BB_ALPF_BANDSELECT, (state->IF_Mode ? 2 : 5));
1920 break;
Steven Toth52c99bd2008-05-01 04:57:01 -03001921 }
1922 }
1923
Steven Toth3935c252008-05-01 05:45:44 -03001924 /* Charge Pump Control Dig Ana */
1925 status += MXL_ControlWrite(fe, RFSYN_CHP_GAIN, state->Mode ? 5 : 8);
1926 status += MXL_ControlWrite(fe, RFSYN_EN_CHP_HIGAIN, state->Mode ? 1 : 1);
1927 status += MXL_ControlWrite(fe, EN_CHP_LIN_B, state->Mode ? 0 : 0);
Steven Toth52c99bd2008-05-01 04:57:01 -03001928
Steven Toth3935c252008-05-01 05:45:44 -03001929 /* AGC TOP Control */
1930 if (state->AGC_Mode == 0) /* Dual AGC */ {
1931 status += MXL_ControlWrite(fe, AGC_IF, 15);
1932 status += MXL_ControlWrite(fe, AGC_RF, 15);
Steven Toth52c99bd2008-05-01 04:57:01 -03001933 }
Steven Toth3935c252008-05-01 05:45:44 -03001934 else /* Single AGC Mode Dig Ana */
1935 status += MXL_ControlWrite(fe, AGC_RF, state->Mode ? 15 : 12);
Steven Toth52c99bd2008-05-01 04:57:01 -03001936
Steven Toth3935c252008-05-01 05:45:44 -03001937 if (state->TOP == 55) /* TOP == 5.5 */
1938 status += MXL_ControlWrite(fe, AGC_IF, 0x0);
Steven Toth52c99bd2008-05-01 04:57:01 -03001939
Steven Toth3935c252008-05-01 05:45:44 -03001940 if (state->TOP == 72) /* TOP == 7.2 */
1941 status += MXL_ControlWrite(fe, AGC_IF, 0x1);
Steven Toth52c99bd2008-05-01 04:57:01 -03001942
Steven Toth3935c252008-05-01 05:45:44 -03001943 if (state->TOP == 92) /* TOP == 9.2 */
1944 status += MXL_ControlWrite(fe, AGC_IF, 0x2);
Steven Toth52c99bd2008-05-01 04:57:01 -03001945
Steven Toth3935c252008-05-01 05:45:44 -03001946 if (state->TOP == 110) /* TOP == 11.0 */
1947 status += MXL_ControlWrite(fe, AGC_IF, 0x3);
Steven Toth52c99bd2008-05-01 04:57:01 -03001948
Steven Toth3935c252008-05-01 05:45:44 -03001949 if (state->TOP == 129) /* TOP == 12.9 */
1950 status += MXL_ControlWrite(fe, AGC_IF, 0x4);
Steven Toth52c99bd2008-05-01 04:57:01 -03001951
Steven Toth3935c252008-05-01 05:45:44 -03001952 if (state->TOP == 147) /* TOP == 14.7 */
1953 status += MXL_ControlWrite(fe, AGC_IF, 0x5);
Steven Toth52c99bd2008-05-01 04:57:01 -03001954
Steven Toth3935c252008-05-01 05:45:44 -03001955 if (state->TOP == 168) /* TOP == 16.8 */
1956 status += MXL_ControlWrite(fe, AGC_IF, 0x6);
Steven Toth52c99bd2008-05-01 04:57:01 -03001957
Steven Toth3935c252008-05-01 05:45:44 -03001958 if (state->TOP == 194) /* TOP == 19.4 */
1959 status += MXL_ControlWrite(fe, AGC_IF, 0x7);
Steven Toth52c99bd2008-05-01 04:57:01 -03001960
Steven Toth3935c252008-05-01 05:45:44 -03001961 if (state->TOP == 212) /* TOP == 21.2 */
1962 status += MXL_ControlWrite(fe, AGC_IF, 0x9);
Steven Toth52c99bd2008-05-01 04:57:01 -03001963
Steven Toth3935c252008-05-01 05:45:44 -03001964 if (state->TOP == 232) /* TOP == 23.2 */
1965 status += MXL_ControlWrite(fe, AGC_IF, 0xA);
Steven Toth52c99bd2008-05-01 04:57:01 -03001966
Steven Toth3935c252008-05-01 05:45:44 -03001967 if (state->TOP == 252) /* TOP == 25.2 */
1968 status += MXL_ControlWrite(fe, AGC_IF, 0xB);
Steven Toth52c99bd2008-05-01 04:57:01 -03001969
Steven Toth3935c252008-05-01 05:45:44 -03001970 if (state->TOP == 271) /* TOP == 27.1 */
1971 status += MXL_ControlWrite(fe, AGC_IF, 0xC);
Steven Toth52c99bd2008-05-01 04:57:01 -03001972
Steven Toth3935c252008-05-01 05:45:44 -03001973 if (state->TOP == 292) /* TOP == 29.2 */
1974 status += MXL_ControlWrite(fe, AGC_IF, 0xD);
Steven Toth52c99bd2008-05-01 04:57:01 -03001975
Steven Toth3935c252008-05-01 05:45:44 -03001976 if (state->TOP == 317) /* TOP == 31.7 */
1977 status += MXL_ControlWrite(fe, AGC_IF, 0xE);
Steven Toth52c99bd2008-05-01 04:57:01 -03001978
Steven Toth3935c252008-05-01 05:45:44 -03001979 if (state->TOP == 349) /* TOP == 34.9 */
1980 status += MXL_ControlWrite(fe, AGC_IF, 0xF);
Steven Toth52c99bd2008-05-01 04:57:01 -03001981
Steven Toth3935c252008-05-01 05:45:44 -03001982 /* IF Synthesizer Control */
1983 status += MXL_IFSynthInit(fe);
Steven Toth52c99bd2008-05-01 04:57:01 -03001984
Steven Toth3935c252008-05-01 05:45:44 -03001985 /* IF UpConverter Control */
1986 if (state->IF_OUT_LOAD == 200) {
1987 status += MXL_ControlWrite(fe, DRV_RES_SEL, 6);
1988 status += MXL_ControlWrite(fe, I_DRIVER, 2);
Steven Toth52c99bd2008-05-01 04:57:01 -03001989 }
Steven Toth3935c252008-05-01 05:45:44 -03001990 if (state->IF_OUT_LOAD == 300) {
1991 status += MXL_ControlWrite(fe, DRV_RES_SEL, 4);
1992 status += MXL_ControlWrite(fe, I_DRIVER, 1);
Steven Toth52c99bd2008-05-01 04:57:01 -03001993 }
1994
Steven Toth3935c252008-05-01 05:45:44 -03001995 /* Anti-Alias Filtering Control
1996 * initialise Anti-Aliasing Filter
1997 */
1998 if (state->Mode) { /* Digital Mode */
1999 if (state->IF_OUT >= 4000000UL && state->IF_OUT <= 6280000UL) {
2000 status += MXL_ControlWrite(fe, EN_AAF, 1);
2001 status += MXL_ControlWrite(fe, EN_3P, 1);
2002 status += MXL_ControlWrite(fe, EN_AUX_3P, 1);
2003 status += MXL_ControlWrite(fe, SEL_AAF_BAND, 0);
Steven Toth52c99bd2008-05-01 04:57:01 -03002004 }
Steven Toth3935c252008-05-01 05:45:44 -03002005 if ((state->IF_OUT == 36125000UL) || (state->IF_OUT == 36150000UL)) {
2006 status += MXL_ControlWrite(fe, EN_AAF, 1);
2007 status += MXL_ControlWrite(fe, EN_3P, 1);
2008 status += MXL_ControlWrite(fe, EN_AUX_3P, 1);
2009 status += MXL_ControlWrite(fe, SEL_AAF_BAND, 1);
Steven Toth52c99bd2008-05-01 04:57:01 -03002010 }
Steven Toth3935c252008-05-01 05:45:44 -03002011 if (state->IF_OUT > 36150000UL) {
2012 status += MXL_ControlWrite(fe, EN_AAF, 0);
2013 status += MXL_ControlWrite(fe, EN_3P, 1);
2014 status += MXL_ControlWrite(fe, EN_AUX_3P, 1);
2015 status += MXL_ControlWrite(fe, SEL_AAF_BAND, 1);
Steven Toth52c99bd2008-05-01 04:57:01 -03002016 }
Steven Toth3935c252008-05-01 05:45:44 -03002017 } else { /* Analog Mode */
2018 if (state->IF_OUT >= 4000000UL && state->IF_OUT <= 5000000UL)
Steven Toth52c99bd2008-05-01 04:57:01 -03002019 {
Steven Toth3935c252008-05-01 05:45:44 -03002020 status += MXL_ControlWrite(fe, EN_AAF, 1);
2021 status += MXL_ControlWrite(fe, EN_3P, 1);
2022 status += MXL_ControlWrite(fe, EN_AUX_3P, 1);
2023 status += MXL_ControlWrite(fe, SEL_AAF_BAND, 0);
Steven Toth52c99bd2008-05-01 04:57:01 -03002024 }
Steven Toth3935c252008-05-01 05:45:44 -03002025 if (state->IF_OUT > 5000000UL)
Steven Toth52c99bd2008-05-01 04:57:01 -03002026 {
Steven Toth3935c252008-05-01 05:45:44 -03002027 status += MXL_ControlWrite(fe, EN_AAF, 0);
2028 status += MXL_ControlWrite(fe, EN_3P, 0);
2029 status += MXL_ControlWrite(fe, EN_AUX_3P, 0);
2030 status += MXL_ControlWrite(fe, SEL_AAF_BAND, 0);
Steven Toth52c99bd2008-05-01 04:57:01 -03002031 }
2032 }
2033
Steven Toth3935c252008-05-01 05:45:44 -03002034 /* Demod Clock Out */
2035 if (state->CLOCK_OUT)
2036 status += MXL_ControlWrite(fe, SEQ_ENCLK16_CLK_OUT, 1);
Steven Toth52c99bd2008-05-01 04:57:01 -03002037 else
Steven Toth3935c252008-05-01 05:45:44 -03002038 status += MXL_ControlWrite(fe, SEQ_ENCLK16_CLK_OUT, 0);
Steven Toth52c99bd2008-05-01 04:57:01 -03002039
Steven Toth3935c252008-05-01 05:45:44 -03002040 if (state->DIV_OUT == 1)
2041 status += MXL_ControlWrite(fe, SEQ_SEL4_16B, 1);
2042 if (state->DIV_OUT == 0)
2043 status += MXL_ControlWrite(fe, SEQ_SEL4_16B, 0);
Steven Toth52c99bd2008-05-01 04:57:01 -03002044
Steven Toth3935c252008-05-01 05:45:44 -03002045 /* Crystal Control */
2046 if (state->CAPSELECT)
2047 status += MXL_ControlWrite(fe, XTAL_CAPSELECT, 1);
Steven Toth52c99bd2008-05-01 04:57:01 -03002048 else
Steven Toth3935c252008-05-01 05:45:44 -03002049 status += MXL_ControlWrite(fe, XTAL_CAPSELECT, 0);
Steven Toth52c99bd2008-05-01 04:57:01 -03002050
Steven Toth3935c252008-05-01 05:45:44 -03002051 if (state->Fxtal >= 12000000UL && state->Fxtal <= 16000000UL)
2052 status += MXL_ControlWrite(fe, IF_SEL_DBL, 1);
2053 if (state->Fxtal > 16000000UL && state->Fxtal <= 32000000UL)
2054 status += MXL_ControlWrite(fe, IF_SEL_DBL, 0);
Steven Toth52c99bd2008-05-01 04:57:01 -03002055
Steven Toth3935c252008-05-01 05:45:44 -03002056 if (state->Fxtal >= 12000000UL && state->Fxtal <= 22000000UL)
2057 status += MXL_ControlWrite(fe, RFSYN_R_DIV, 3);
2058 if (state->Fxtal > 22000000UL && state->Fxtal <= 32000000UL)
2059 status += MXL_ControlWrite(fe, RFSYN_R_DIV, 0);
Steven Toth52c99bd2008-05-01 04:57:01 -03002060
Steven Toth3935c252008-05-01 05:45:44 -03002061 /* Misc Controls */
Steven Toth85d220d2008-05-01 05:48:14 -03002062 if (state->Mode == 0 && state->IF_Mode == 1) /* Analog LowIF mode */
Steven Toth3935c252008-05-01 05:45:44 -03002063 status += MXL_ControlWrite(fe, SEQ_EXTIQFSMPULSE, 0);
Steven Toth52c99bd2008-05-01 04:57:01 -03002064 else
Steven Toth3935c252008-05-01 05:45:44 -03002065 status += MXL_ControlWrite(fe, SEQ_EXTIQFSMPULSE, 1);
Steven Toth52c99bd2008-05-01 04:57:01 -03002066
Steven Toth3935c252008-05-01 05:45:44 -03002067 /* status += MXL_ControlRead(fe, IF_DIVVAL, &IF_DIVVAL_Val); */
Steven Toth52c99bd2008-05-01 04:57:01 -03002068
Steven Toth3935c252008-05-01 05:45:44 -03002069 /* Set TG_R_DIV */
2070 status += MXL_ControlWrite(fe, TG_R_DIV, MXL_Ceiling(state->Fxtal, 1000000));
Steven Toth52c99bd2008-05-01 04:57:01 -03002071
Steven Toth3935c252008-05-01 05:45:44 -03002072 /* Apply Default value to BB_INITSTATE_DLPF_TUNE */
Steven Toth52c99bd2008-05-01 04:57:01 -03002073
Steven Toth3935c252008-05-01 05:45:44 -03002074 /* RSSI Control */
2075 if (state->EN_RSSI)
Steven Toth52c99bd2008-05-01 04:57:01 -03002076 {
Steven Toth3935c252008-05-01 05:45:44 -03002077 status += MXL_ControlWrite(fe, SEQ_EXTSYNTHCALIF, 1);
2078 status += MXL_ControlWrite(fe, SEQ_EXTDCCAL, 1);
2079 status += MXL_ControlWrite(fe, AGC_EN_RSSI, 1);
2080 status += MXL_ControlWrite(fe, RFA_ENCLKRFAGC, 1);
2081
2082 /* RSSI reference point */
2083 status += MXL_ControlWrite(fe, RFA_RSSI_REF, 2);
2084 status += MXL_ControlWrite(fe, RFA_RSSI_REFH, 3);
2085 status += MXL_ControlWrite(fe, RFA_RSSI_REFL, 1);
2086
2087 /* TOP point */
2088 status += MXL_ControlWrite(fe, RFA_FLR, 0);
2089 status += MXL_ControlWrite(fe, RFA_CEIL, 12);
Steven Toth52c99bd2008-05-01 04:57:01 -03002090 }
2091
Steven Toth3935c252008-05-01 05:45:44 -03002092 /* Modulation type bit settings
2093 * Override the control values preset
2094 */
2095 if (state->Mod_Type == MXL_DVBT) /* DVB-T Mode */
Steven Toth52c99bd2008-05-01 04:57:01 -03002096 {
Steven Toth3935c252008-05-01 05:45:44 -03002097 state->AGC_Mode = 1; /* Single AGC Mode */
Steven Toth52c99bd2008-05-01 04:57:01 -03002098
Steven Toth3935c252008-05-01 05:45:44 -03002099 /* Enable RSSI */
2100 status += MXL_ControlWrite(fe, SEQ_EXTSYNTHCALIF, 1);
2101 status += MXL_ControlWrite(fe, SEQ_EXTDCCAL, 1);
2102 status += MXL_ControlWrite(fe, AGC_EN_RSSI, 1);
2103 status += MXL_ControlWrite(fe, RFA_ENCLKRFAGC, 1);
2104
2105 /* RSSI reference point */
2106 status += MXL_ControlWrite(fe, RFA_RSSI_REF, 3);
2107 status += MXL_ControlWrite(fe, RFA_RSSI_REFH, 5);
2108 status += MXL_ControlWrite(fe, RFA_RSSI_REFL, 1);
2109
2110 /* TOP point */
2111 status += MXL_ControlWrite(fe, RFA_FLR, 2);
2112 status += MXL_ControlWrite(fe, RFA_CEIL, 13);
2113 if (state->IF_OUT <= 6280000UL) /* Low IF */
2114 status += MXL_ControlWrite(fe, BB_IQSWAP, 0);
2115 else /* High IF */
2116 status += MXL_ControlWrite(fe, BB_IQSWAP, 1);
Steven Toth52c99bd2008-05-01 04:57:01 -03002117
2118 }
Steven Toth3935c252008-05-01 05:45:44 -03002119 if (state->Mod_Type == MXL_ATSC) /* ATSC Mode */
Steven Toth52c99bd2008-05-01 04:57:01 -03002120 {
Steven Toth85d220d2008-05-01 05:48:14 -03002121 state->AGC_Mode = 1; /* Single AGC Mode */
Steven Toth52c99bd2008-05-01 04:57:01 -03002122
Steven Toth3935c252008-05-01 05:45:44 -03002123 /* Enable RSSI */
2124 status += MXL_ControlWrite(fe, SEQ_EXTSYNTHCALIF, 1);
2125 status += MXL_ControlWrite(fe, SEQ_EXTDCCAL, 1);
2126 status += MXL_ControlWrite(fe, AGC_EN_RSSI, 1);
2127 status += MXL_ControlWrite(fe, RFA_ENCLKRFAGC, 1);
Steven Toth52c99bd2008-05-01 04:57:01 -03002128
Steven Toth3935c252008-05-01 05:45:44 -03002129 /* RSSI reference point */
2130 status += MXL_ControlWrite(fe, RFA_RSSI_REF, 2);
2131 status += MXL_ControlWrite(fe, RFA_RSSI_REFH, 4);
2132 status += MXL_ControlWrite(fe, RFA_RSSI_REFL, 1);
2133
2134 /* TOP point */
2135 status += MXL_ControlWrite(fe, RFA_FLR, 2);
2136 status += MXL_ControlWrite(fe, RFA_CEIL, 13);
2137 status += MXL_ControlWrite(fe, BB_INITSTATE_DLPF_TUNE, 1);
2138 status += MXL_ControlWrite(fe, RFSYN_CHP_GAIN, 5); /* Low Zero */
2139 if (state->IF_OUT <= 6280000UL) /* Low IF */
2140 status += MXL_ControlWrite(fe, BB_IQSWAP, 0);
2141 else /* High IF */
2142 status += MXL_ControlWrite(fe, BB_IQSWAP, 1);
Steven Toth52c99bd2008-05-01 04:57:01 -03002143 }
Steven Toth3935c252008-05-01 05:45:44 -03002144 if (state->Mod_Type == MXL_QAM) /* QAM Mode */
Steven Toth52c99bd2008-05-01 04:57:01 -03002145 {
Steven Toth3935c252008-05-01 05:45:44 -03002146 state->Mode = MXL_DIGITAL_MODE;
Steven Toth52c99bd2008-05-01 04:57:01 -03002147
Steven Toth3935c252008-05-01 05:45:44 -03002148 /* state->AGC_Mode = 1; */ /* Single AGC Mode */
Steven Toth52c99bd2008-05-01 04:57:01 -03002149
Steven Toth3935c252008-05-01 05:45:44 -03002150 /* Disable RSSI */ /* change here for v2.6.5 */
2151 status += MXL_ControlWrite(fe, SEQ_EXTSYNTHCALIF, 1);
2152 status += MXL_ControlWrite(fe, SEQ_EXTDCCAL, 1);
2153 status += MXL_ControlWrite(fe, AGC_EN_RSSI, 0);
2154 status += MXL_ControlWrite(fe, RFA_ENCLKRFAGC, 1);
Steven Toth52c99bd2008-05-01 04:57:01 -03002155
Steven Toth3935c252008-05-01 05:45:44 -03002156 /* RSSI reference point */
2157 status += MXL_ControlWrite(fe, RFA_RSSI_REFH, 5);
2158 status += MXL_ControlWrite(fe, RFA_RSSI_REF, 3);
2159 status += MXL_ControlWrite(fe, RFA_RSSI_REFL, 2);
2160 status += MXL_ControlWrite(fe, RFSYN_CHP_GAIN, 3); /* change here for v2.6.5 */
Steven Toth52c99bd2008-05-01 04:57:01 -03002161
Steven Toth3935c252008-05-01 05:45:44 -03002162 if (state->IF_OUT <= 6280000UL) /* Low IF */
2163 status += MXL_ControlWrite(fe, BB_IQSWAP, 0);
2164 else /* High IF */
2165 status += MXL_ControlWrite(fe, BB_IQSWAP, 1);
Steven Toth8c66a192008-05-01 06:35:48 -03002166 status += MXL_ControlWrite(fe, RFSYN_CHP_GAIN, 2);
2167
Steven Toth52c99bd2008-05-01 04:57:01 -03002168 }
Steven Toth3935c252008-05-01 05:45:44 -03002169 if (state->Mod_Type == MXL_ANALOG_CABLE) {
2170 /* Analog Cable Mode */
Steven Toth85d220d2008-05-01 05:48:14 -03002171 /* state->Mode = MXL_DIGITAL_MODE; */
Steven Toth52c99bd2008-05-01 04:57:01 -03002172
Steven Toth3935c252008-05-01 05:45:44 -03002173 state->AGC_Mode = 1; /* Single AGC Mode */
Steven Toth52c99bd2008-05-01 04:57:01 -03002174
Steven Toth3935c252008-05-01 05:45:44 -03002175 /* Disable RSSI */
2176 status += MXL_ControlWrite(fe, SEQ_EXTSYNTHCALIF, 1);
2177 status += MXL_ControlWrite(fe, SEQ_EXTDCCAL, 1);
2178 status += MXL_ControlWrite(fe, AGC_EN_RSSI, 0);
2179 status += MXL_ControlWrite(fe, RFA_ENCLKRFAGC, 1);
2180 status += MXL_ControlWrite(fe, AGC_IF, 1); /* change for 2.6.3 */
2181 status += MXL_ControlWrite(fe, AGC_RF, 15);
2182 status += MXL_ControlWrite(fe, BB_IQSWAP, 1);
Steven Toth52c99bd2008-05-01 04:57:01 -03002183 }
2184
Steven Toth3935c252008-05-01 05:45:44 -03002185 if (state->Mod_Type == MXL_ANALOG_OTA) {
2186 /* Analog OTA Terrestrial mode add for 2.6.7 */
2187 /* state->Mode = MXL_ANALOG_MODE; */
Steven Toth52c99bd2008-05-01 04:57:01 -03002188
Steven Toth3935c252008-05-01 05:45:44 -03002189 /* Enable RSSI */
2190 status += MXL_ControlWrite(fe, SEQ_EXTSYNTHCALIF, 1);
2191 status += MXL_ControlWrite(fe, SEQ_EXTDCCAL, 1);
2192 status += MXL_ControlWrite(fe, AGC_EN_RSSI, 1);
2193 status += MXL_ControlWrite(fe, RFA_ENCLKRFAGC, 1);
Steven Toth52c99bd2008-05-01 04:57:01 -03002194
Steven Toth3935c252008-05-01 05:45:44 -03002195 /* RSSI reference point */
2196 status += MXL_ControlWrite(fe, RFA_RSSI_REFH, 5);
2197 status += MXL_ControlWrite(fe, RFA_RSSI_REF, 3);
2198 status += MXL_ControlWrite(fe, RFA_RSSI_REFL, 2);
2199 status += MXL_ControlWrite(fe, RFSYN_CHP_GAIN, 3);
2200 status += MXL_ControlWrite(fe, BB_IQSWAP, 1);
Steven Toth52c99bd2008-05-01 04:57:01 -03002201 }
2202
Steven Toth3935c252008-05-01 05:45:44 -03002203 /* RSSI disable */
Steven Toth8c66a192008-05-01 06:35:48 -03002204 if(state->EN_RSSI == 0) {
Steven Toth3935c252008-05-01 05:45:44 -03002205 status += MXL_ControlWrite(fe, SEQ_EXTSYNTHCALIF, 1);
2206 status += MXL_ControlWrite(fe, SEQ_EXTDCCAL, 1);
2207 status += MXL_ControlWrite(fe, AGC_EN_RSSI, 0);
2208 status += MXL_ControlWrite(fe, RFA_ENCLKRFAGC, 1);
Steven Toth52c99bd2008-05-01 04:57:01 -03002209 }
2210
Steven Toth3935c252008-05-01 05:45:44 -03002211 return status;
Steven Toth52c99bd2008-05-01 04:57:01 -03002212}
2213
2214///////////////////////////////////////////////////////////////////////////////
2215// //
2216// Function: MXL_IFSynthInit //
2217// //
2218// Description: Tuner IF Synthesizer related register initialization //
2219// //
2220// Globals: //
2221// NONE //
2222// //
2223// Functions used: //
2224// Tuner_struct: structure defined at higher level //
2225// //
2226// Inputs: //
2227// Tuner : Tuner structure defined at higher level //
2228// //
2229// Outputs: //
2230// Tuner //
2231// //
2232// Return: //
2233// 0 : Successful //
2234// > 0 : Failed //
2235// //
2236///////////////////////////////////////////////////////////////////////////////
Steven Toth85d220d2008-05-01 05:48:14 -03002237u16 MXL_IFSynthInit(struct dvb_frontend *fe)
Steven Toth52c99bd2008-05-01 04:57:01 -03002238{
Steven Toth85d220d2008-05-01 05:48:14 -03002239 struct mxl5005s_state *state = fe->tuner_priv;
Steven Totha8214d42008-05-01 05:02:58 -03002240 u16 status = 0 ;
Steven Toth52c99bd2008-05-01 04:57:01 -03002241 // Declare Local Variables
Steven Totha8214d42008-05-01 05:02:58 -03002242 u32 Fref = 0 ;
2243 u32 Kdbl, intModVal ;
2244 u32 fracModVal ;
Steven Toth52c99bd2008-05-01 04:57:01 -03002245 Kdbl = 2 ;
2246
Steven Toth3935c252008-05-01 05:45:44 -03002247 if (state->Fxtal >= 12000000UL && state->Fxtal <= 16000000UL)
Steven Toth52c99bd2008-05-01 04:57:01 -03002248 Kdbl = 2 ;
Steven Toth3935c252008-05-01 05:45:44 -03002249 if (state->Fxtal > 16000000UL && state->Fxtal <= 32000000UL)
Steven Toth52c99bd2008-05-01 04:57:01 -03002250 Kdbl = 1 ;
2251
2252 //
2253 // IF Synthesizer Control
2254 //
Steven Toth85d220d2008-05-01 05:48:14 -03002255 if (state->Mode == 0 && state->IF_Mode == 1) // Analog Low IF mode
Steven Toth52c99bd2008-05-01 04:57:01 -03002256 {
Steven Toth85d220d2008-05-01 05:48:14 -03002257 if (state->IF_LO == 41000000UL) {
Steven Toth3935c252008-05-01 05:45:44 -03002258 status += MXL_ControlWrite(fe, IF_DIVVAL, 0x08) ;
2259 status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x0C) ;
Steven Toth52c99bd2008-05-01 04:57:01 -03002260 Fref = 328000000UL ;
2261 }
Steven Toth85d220d2008-05-01 05:48:14 -03002262 if (state->IF_LO == 47000000UL) {
Steven Toth3935c252008-05-01 05:45:44 -03002263 status += MXL_ControlWrite(fe, IF_DIVVAL, 0x08) ;
2264 status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08) ;
Steven Toth52c99bd2008-05-01 04:57:01 -03002265 Fref = 376000000UL ;
2266 }
Steven Toth85d220d2008-05-01 05:48:14 -03002267 if (state->IF_LO == 54000000UL) {
Steven Toth3935c252008-05-01 05:45:44 -03002268 status += MXL_ControlWrite(fe, IF_DIVVAL, 0x10) ;
2269 status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x0C) ;
Steven Toth52c99bd2008-05-01 04:57:01 -03002270 Fref = 324000000UL ;
2271 }
Steven Toth85d220d2008-05-01 05:48:14 -03002272 if (state->IF_LO == 60000000UL) {
Steven Toth3935c252008-05-01 05:45:44 -03002273 status += MXL_ControlWrite(fe, IF_DIVVAL, 0x10) ;
2274 status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08) ;
Steven Toth52c99bd2008-05-01 04:57:01 -03002275 Fref = 360000000UL ;
2276 }
Steven Toth85d220d2008-05-01 05:48:14 -03002277 if (state->IF_LO == 39250000UL) {
Steven Toth3935c252008-05-01 05:45:44 -03002278 status += MXL_ControlWrite(fe, IF_DIVVAL, 0x08) ;
2279 status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x0C) ;
Steven Toth52c99bd2008-05-01 04:57:01 -03002280 Fref = 314000000UL ;
2281 }
Steven Toth85d220d2008-05-01 05:48:14 -03002282 if (state->IF_LO == 39650000UL) {
Steven Toth3935c252008-05-01 05:45:44 -03002283 status += MXL_ControlWrite(fe, IF_DIVVAL, 0x08) ;
2284 status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x0C) ;
Steven Toth52c99bd2008-05-01 04:57:01 -03002285 Fref = 317200000UL ;
2286 }
Steven Toth85d220d2008-05-01 05:48:14 -03002287 if (state->IF_LO == 40150000UL) {
Steven Toth3935c252008-05-01 05:45:44 -03002288 status += MXL_ControlWrite(fe, IF_DIVVAL, 0x08) ;
2289 status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x0C) ;
Steven Toth52c99bd2008-05-01 04:57:01 -03002290 Fref = 321200000UL ;
2291 }
Steven Toth85d220d2008-05-01 05:48:14 -03002292 if (state->IF_LO == 40650000UL) {
Steven Toth3935c252008-05-01 05:45:44 -03002293 status += MXL_ControlWrite(fe, IF_DIVVAL, 0x08) ;
2294 status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x0C) ;
Steven Toth52c99bd2008-05-01 04:57:01 -03002295 Fref = 325200000UL ;
2296 }
2297 }
2298
Steven Toth85d220d2008-05-01 05:48:14 -03002299 if (state->Mode || (state->Mode == 0 && state->IF_Mode == 0))
Steven Toth52c99bd2008-05-01 04:57:01 -03002300 {
Steven Toth85d220d2008-05-01 05:48:14 -03002301 if (state->IF_LO == 57000000UL) {
Steven Toth3935c252008-05-01 05:45:44 -03002302 status += MXL_ControlWrite(fe, IF_DIVVAL, 0x10) ;
2303 status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08) ;
Steven Toth52c99bd2008-05-01 04:57:01 -03002304 Fref = 342000000UL ;
2305 }
Steven Toth85d220d2008-05-01 05:48:14 -03002306 if (state->IF_LO == 44000000UL) {
Steven Toth3935c252008-05-01 05:45:44 -03002307 status += MXL_ControlWrite(fe, IF_DIVVAL, 0x08) ;
2308 status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08) ;
Steven Toth52c99bd2008-05-01 04:57:01 -03002309 Fref = 352000000UL ;
2310 }
Steven Toth85d220d2008-05-01 05:48:14 -03002311 if (state->IF_LO == 43750000UL) {
Steven Toth3935c252008-05-01 05:45:44 -03002312 status += MXL_ControlWrite(fe, IF_DIVVAL, 0x08) ;
2313 status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08) ;
Steven Toth52c99bd2008-05-01 04:57:01 -03002314 Fref = 350000000UL ;
2315 }
Steven Toth85d220d2008-05-01 05:48:14 -03002316 if (state->IF_LO == 36650000UL) {
Steven Toth3935c252008-05-01 05:45:44 -03002317 status += MXL_ControlWrite(fe, IF_DIVVAL, 0x04) ;
2318 status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08) ;
Steven Toth52c99bd2008-05-01 04:57:01 -03002319 Fref = 366500000UL ;
2320 }
Steven Toth85d220d2008-05-01 05:48:14 -03002321 if (state->IF_LO == 36150000UL) {
Steven Toth3935c252008-05-01 05:45:44 -03002322 status += MXL_ControlWrite(fe, IF_DIVVAL, 0x04) ;
2323 status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08) ;
Steven Toth52c99bd2008-05-01 04:57:01 -03002324 Fref = 361500000UL ;
2325 }
Steven Toth85d220d2008-05-01 05:48:14 -03002326 if (state->IF_LO == 36000000UL) {
Steven Toth3935c252008-05-01 05:45:44 -03002327 status += MXL_ControlWrite(fe, IF_DIVVAL, 0x04) ;
2328 status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08) ;
Steven Toth52c99bd2008-05-01 04:57:01 -03002329 Fref = 360000000UL ;
2330 }
Steven Toth85d220d2008-05-01 05:48:14 -03002331 if (state->IF_LO == 35250000UL) {
Steven Toth3935c252008-05-01 05:45:44 -03002332 status += MXL_ControlWrite(fe, IF_DIVVAL, 0x04) ;
2333 status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08) ;
Steven Toth52c99bd2008-05-01 04:57:01 -03002334 Fref = 352500000UL ;
2335 }
Steven Toth85d220d2008-05-01 05:48:14 -03002336 if (state->IF_LO == 34750000UL) {
Steven Toth3935c252008-05-01 05:45:44 -03002337 status += MXL_ControlWrite(fe, IF_DIVVAL, 0x04) ;
2338 status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08) ;
Steven Toth52c99bd2008-05-01 04:57:01 -03002339 Fref = 347500000UL ;
2340 }
Steven Toth85d220d2008-05-01 05:48:14 -03002341 if (state->IF_LO == 6280000UL) {
Steven Toth3935c252008-05-01 05:45:44 -03002342 status += MXL_ControlWrite(fe, IF_DIVVAL, 0x07) ;
2343 status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08) ;
Steven Toth52c99bd2008-05-01 04:57:01 -03002344 Fref = 376800000UL ;
2345 }
Steven Toth85d220d2008-05-01 05:48:14 -03002346 if (state->IF_LO == 5000000UL) {
Steven Toth3935c252008-05-01 05:45:44 -03002347 status += MXL_ControlWrite(fe, IF_DIVVAL, 0x09) ;
2348 status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08) ;
Steven Toth52c99bd2008-05-01 04:57:01 -03002349 Fref = 360000000UL ;
2350 }
Steven Toth85d220d2008-05-01 05:48:14 -03002351 if (state->IF_LO == 4500000UL) {
Steven Toth3935c252008-05-01 05:45:44 -03002352 status += MXL_ControlWrite(fe, IF_DIVVAL, 0x06) ;
2353 status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08) ;
Steven Toth52c99bd2008-05-01 04:57:01 -03002354 Fref = 360000000UL ;
2355 }
Steven Toth85d220d2008-05-01 05:48:14 -03002356 if (state->IF_LO == 4570000UL) {
Steven Toth3935c252008-05-01 05:45:44 -03002357 status += MXL_ControlWrite(fe, IF_DIVVAL, 0x06) ;
2358 status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08) ;
Steven Toth52c99bd2008-05-01 04:57:01 -03002359 Fref = 365600000UL ;
2360 }
Steven Toth85d220d2008-05-01 05:48:14 -03002361 if (state->IF_LO == 4000000UL) {
Steven Toth3935c252008-05-01 05:45:44 -03002362 status += MXL_ControlWrite(fe, IF_DIVVAL, 0x05) ;
2363 status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08) ;
Steven Toth52c99bd2008-05-01 04:57:01 -03002364 Fref = 360000000UL ;
2365 }
Steven Toth85d220d2008-05-01 05:48:14 -03002366 if (state->IF_LO == 57400000UL)
Steven Toth52c99bd2008-05-01 04:57:01 -03002367 {
Steven Toth3935c252008-05-01 05:45:44 -03002368 status += MXL_ControlWrite(fe, IF_DIVVAL, 0x10) ;
2369 status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08) ;
Steven Toth52c99bd2008-05-01 04:57:01 -03002370 Fref = 344400000UL ;
2371 }
Steven Toth85d220d2008-05-01 05:48:14 -03002372 if (state->IF_LO == 44400000UL)
Steven Toth52c99bd2008-05-01 04:57:01 -03002373 {
Steven Toth3935c252008-05-01 05:45:44 -03002374 status += MXL_ControlWrite(fe, IF_DIVVAL, 0x08) ;
2375 status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08) ;
Steven Toth52c99bd2008-05-01 04:57:01 -03002376 Fref = 355200000UL ;
2377 }
Steven Toth85d220d2008-05-01 05:48:14 -03002378 if (state->IF_LO == 44150000UL)
Steven Toth52c99bd2008-05-01 04:57:01 -03002379 {
Steven Toth3935c252008-05-01 05:45:44 -03002380 status += MXL_ControlWrite(fe, IF_DIVVAL, 0x08) ;
2381 status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08) ;
Steven Toth52c99bd2008-05-01 04:57:01 -03002382 Fref = 353200000UL ;
2383 }
Steven Toth85d220d2008-05-01 05:48:14 -03002384 if (state->IF_LO == 37050000UL)
Steven Toth52c99bd2008-05-01 04:57:01 -03002385 {
Steven Toth3935c252008-05-01 05:45:44 -03002386 status += MXL_ControlWrite(fe, IF_DIVVAL, 0x04) ;
2387 status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08) ;
Steven Toth52c99bd2008-05-01 04:57:01 -03002388 Fref = 370500000UL ;
2389 }
Steven Toth85d220d2008-05-01 05:48:14 -03002390 if (state->IF_LO == 36550000UL)
Steven Toth52c99bd2008-05-01 04:57:01 -03002391 {
Steven Toth3935c252008-05-01 05:45:44 -03002392 status += MXL_ControlWrite(fe, IF_DIVVAL, 0x04) ;
2393 status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08) ;
Steven Toth52c99bd2008-05-01 04:57:01 -03002394 Fref = 365500000UL ;
2395 }
Steven Toth85d220d2008-05-01 05:48:14 -03002396 if (state->IF_LO == 36125000UL) {
Steven Toth3935c252008-05-01 05:45:44 -03002397 status += MXL_ControlWrite(fe, IF_DIVVAL, 0x04) ;
2398 status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08) ;
Steven Toth52c99bd2008-05-01 04:57:01 -03002399 Fref = 361250000UL ;
2400 }
Steven Toth85d220d2008-05-01 05:48:14 -03002401 if (state->IF_LO == 6000000UL) {
Steven Toth3935c252008-05-01 05:45:44 -03002402 status += MXL_ControlWrite(fe, IF_DIVVAL, 0x07) ;
2403 status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08) ;
Steven Toth52c99bd2008-05-01 04:57:01 -03002404 Fref = 360000000UL ;
2405 }
Steven Toth85d220d2008-05-01 05:48:14 -03002406 if (state->IF_LO == 5400000UL)
Steven Toth52c99bd2008-05-01 04:57:01 -03002407 {
Steven Toth3935c252008-05-01 05:45:44 -03002408 status += MXL_ControlWrite(fe, IF_DIVVAL, 0x07) ;
2409 status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x0C) ;
Steven Toth52c99bd2008-05-01 04:57:01 -03002410 Fref = 324000000UL ;
2411 }
Steven Toth85d220d2008-05-01 05:48:14 -03002412 if (state->IF_LO == 5380000UL) {
Steven Toth8c66a192008-05-01 06:35:48 -03002413 printk("%s() doing 5.38\n", __func__);
Steven Toth3935c252008-05-01 05:45:44 -03002414 status += MXL_ControlWrite(fe, IF_DIVVAL, 0x07) ;
2415 status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x0C) ;
Steven Toth52c99bd2008-05-01 04:57:01 -03002416 Fref = 322800000UL ;
2417 }
Steven Toth85d220d2008-05-01 05:48:14 -03002418 if (state->IF_LO == 5200000UL) {
Steven Toth3935c252008-05-01 05:45:44 -03002419 status += MXL_ControlWrite(fe, IF_DIVVAL, 0x09) ;
2420 status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08) ;
Steven Toth52c99bd2008-05-01 04:57:01 -03002421 Fref = 374400000UL ;
2422 }
Steven Toth85d220d2008-05-01 05:48:14 -03002423 if (state->IF_LO == 4900000UL)
Steven Toth52c99bd2008-05-01 04:57:01 -03002424 {
Steven Toth3935c252008-05-01 05:45:44 -03002425 status += MXL_ControlWrite(fe, IF_DIVVAL, 0x09) ;
2426 status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08) ;
Steven Toth52c99bd2008-05-01 04:57:01 -03002427 Fref = 352800000UL ;
2428 }
Steven Toth85d220d2008-05-01 05:48:14 -03002429 if (state->IF_LO == 4400000UL)
Steven Toth52c99bd2008-05-01 04:57:01 -03002430 {
Steven Toth3935c252008-05-01 05:45:44 -03002431 status += MXL_ControlWrite(fe, IF_DIVVAL, 0x06) ;
2432 status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08) ;
Steven Toth52c99bd2008-05-01 04:57:01 -03002433 Fref = 352000000UL ;
2434 }
Steven Toth85d220d2008-05-01 05:48:14 -03002435 if (state->IF_LO == 4063000UL) //add for 2.6.8
Steven Toth52c99bd2008-05-01 04:57:01 -03002436 {
Steven Toth3935c252008-05-01 05:45:44 -03002437 status += MXL_ControlWrite(fe, IF_DIVVAL, 0x05) ;
2438 status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08) ;
Steven Toth52c99bd2008-05-01 04:57:01 -03002439 Fref = 365670000UL ;
2440 }
2441 }
2442 // CHCAL_INT_MOD_IF
2443 // CHCAL_FRAC_MOD_IF
Steven Toth3935c252008-05-01 05:45:44 -03002444 intModVal = Fref / (state->Fxtal * Kdbl/2) ;
2445 status += MXL_ControlWrite(fe, CHCAL_INT_MOD_IF, intModVal ) ;
Steven Toth52c99bd2008-05-01 04:57:01 -03002446
Steven Toth3935c252008-05-01 05:45:44 -03002447 fracModVal = (2<<15)*(Fref/1000 - (state->Fxtal/1000 * Kdbl/2) * intModVal);
2448 fracModVal = fracModVal / ((state->Fxtal * Kdbl/2)/1000) ;
2449 status += MXL_ControlWrite(fe, CHCAL_FRAC_MOD_IF, fracModVal) ;
Steven Toth52c99bd2008-05-01 04:57:01 -03002450
Steven Toth52c99bd2008-05-01 04:57:01 -03002451 return status ;
2452}
2453
2454///////////////////////////////////////////////////////////////////////////////
2455// //
2456// Function: MXL_GetXtalInt //
2457// //
Steven Totha8214d42008-05-01 05:02:58 -03002458// Description: return the Crystal Integration Value for //
2459// TG_VCO_BIAS calculation //
Steven Toth52c99bd2008-05-01 04:57:01 -03002460// //
2461// Globals: //
2462// NONE //
2463// //
2464// Functions used: //
Steven Totha8214d42008-05-01 05:02:58 -03002465// NONE //
Steven Toth52c99bd2008-05-01 04:57:01 -03002466// //
2467// Inputs: //
2468// Crystal Frequency Value in Hz //
2469// //
2470// Outputs: //
2471// Calculated Crystal Frequency Integration Value //
2472// //
2473// Return: //
2474// 0 : Successful //
2475// > 0 : Failed //
2476// //
2477///////////////////////////////////////////////////////////////////////////////
Steven Totha8214d42008-05-01 05:02:58 -03002478u32 MXL_GetXtalInt(u32 Xtal_Freq)
Steven Toth52c99bd2008-05-01 04:57:01 -03002479{
2480 if ((Xtal_Freq % 1000000) == 0)
2481 return (Xtal_Freq / 10000) ;
2482 else
2483 return (((Xtal_Freq / 1000000) + 1)*100) ;
2484}
2485
2486///////////////////////////////////////////////////////////////////////////////
2487// //
2488// Function: MXL5005_TuneRF //
2489// //
2490// Description: Set control names to tune to requested RF_IN frequency //
2491// //
2492// Globals: //
2493// None //
2494// //
2495// Functions used: //
2496// MXL_SynthRFTGLO_Calc //
2497// MXL5005_ControlWrite //
Steven Toth3935c252008-05-01 05:45:44 -03002498// MXL_GetXtalInt //
Steven Toth52c99bd2008-05-01 04:57:01 -03002499// //
2500// Inputs: //
2501// Tuner : Tuner structure defined at higher level //
2502// //
2503// Outputs: //
2504// Tuner //
2505// //
2506// Return: //
2507// 0 : Successful //
2508// 1 : Unsuccessful //
2509///////////////////////////////////////////////////////////////////////////////
Steven Toth3935c252008-05-01 05:45:44 -03002510u16 MXL_TuneRF(struct dvb_frontend *fe, u32 RF_Freq)
Steven Toth52c99bd2008-05-01 04:57:01 -03002511{
Steven Toth85d220d2008-05-01 05:48:14 -03002512 struct mxl5005s_state *state = fe->tuner_priv;
Steven Toth52c99bd2008-05-01 04:57:01 -03002513 // Declare Local Variables
Steven Toth3935c252008-05-01 05:45:44 -03002514 u16 status = 0;
2515 u32 divider_val, E3, E4, E5, E5A;
2516 u32 Fmax, Fmin, FmaxBin, FminBin;
Steven Totha8214d42008-05-01 05:02:58 -03002517 u32 Kdbl_RF = 2;
Steven Toth3935c252008-05-01 05:45:44 -03002518 u32 tg_divval;
2519 u32 tg_lo;
2520 u32 Xtal_Int;
Steven Toth52c99bd2008-05-01 04:57:01 -03002521
Steven Totha8214d42008-05-01 05:02:58 -03002522 u32 Fref_TG;
2523 u32 Fvco;
2524// u32 temp;
Steven Toth52c99bd2008-05-01 04:57:01 -03002525
2526
Steven Toth3935c252008-05-01 05:45:44 -03002527 Xtal_Int = MXL_GetXtalInt(state->Fxtal);
Steven Toth52c99bd2008-05-01 04:57:01 -03002528
Steven Toth3935c252008-05-01 05:45:44 -03002529 state->RF_IN = RF_Freq;
Steven Toth52c99bd2008-05-01 04:57:01 -03002530
Steven Toth3935c252008-05-01 05:45:44 -03002531 MXL_SynthRFTGLO_Calc(fe);
Steven Toth52c99bd2008-05-01 04:57:01 -03002532
Steven Toth3935c252008-05-01 05:45:44 -03002533 if (state->Fxtal >= 12000000UL && state->Fxtal <= 22000000UL)
2534 Kdbl_RF = 2;
2535 if (state->Fxtal > 22000000 && state->Fxtal <= 32000000)
2536 Kdbl_RF = 1;
Steven Toth52c99bd2008-05-01 04:57:01 -03002537
2538 //
2539 // Downconverter Controls
2540 //
2541 // Look-Up Table Implementation for:
2542 // DN_POLY
2543 // DN_RFGAIN
2544 // DN_CAP_RFLPF
2545 // DN_EN_VHFUHFBAR
2546 // DN_GAIN_ADJUST
2547 // Change the boundary reference from RF_IN to RF_LO
Steven Toth3935c252008-05-01 05:45:44 -03002548 if (state->RF_LO < 40000000UL) {
Steven Toth52c99bd2008-05-01 04:57:01 -03002549 return -1;
2550 }
Steven Toth3935c252008-05-01 05:45:44 -03002551 if (state->RF_LO >= 40000000UL && state->RF_LO <= 75000000UL) {
Steven Toth52c99bd2008-05-01 04:57:01 -03002552 // Look-Up Table implementation
Steven Toth3935c252008-05-01 05:45:44 -03002553 status += MXL_ControlWrite(fe, DN_POLY, 2);
2554 status += MXL_ControlWrite(fe, DN_RFGAIN, 3);
2555 status += MXL_ControlWrite(fe, DN_CAP_RFLPF, 423);
2556 status += MXL_ControlWrite(fe, DN_EN_VHFUHFBAR, 1);
2557 status += MXL_ControlWrite(fe, DN_GAIN_ADJUST, 1);
Steven Toth52c99bd2008-05-01 04:57:01 -03002558 }
Steven Toth3935c252008-05-01 05:45:44 -03002559 if (state->RF_LO > 75000000UL && state->RF_LO <= 100000000UL) {
Steven Toth52c99bd2008-05-01 04:57:01 -03002560 // Look-Up Table implementation
Steven Toth3935c252008-05-01 05:45:44 -03002561 status += MXL_ControlWrite(fe, DN_POLY, 3);
2562 status += MXL_ControlWrite(fe, DN_RFGAIN, 3);
2563 status += MXL_ControlWrite(fe, DN_CAP_RFLPF, 222);
2564 status += MXL_ControlWrite(fe, DN_EN_VHFUHFBAR, 1);
2565 status += MXL_ControlWrite(fe, DN_GAIN_ADJUST, 1);
Steven Toth52c99bd2008-05-01 04:57:01 -03002566 }
Steven Toth3935c252008-05-01 05:45:44 -03002567 if (state->RF_LO > 100000000UL && state->RF_LO <= 150000000UL) {
Steven Toth52c99bd2008-05-01 04:57:01 -03002568 // Look-Up Table implementation
Steven Toth3935c252008-05-01 05:45:44 -03002569 status += MXL_ControlWrite(fe, DN_POLY, 3);
2570 status += MXL_ControlWrite(fe, DN_RFGAIN, 3);
2571 status += MXL_ControlWrite(fe, DN_CAP_RFLPF, 147);
2572 status += MXL_ControlWrite(fe, DN_EN_VHFUHFBAR, 1);
2573 status += MXL_ControlWrite(fe, DN_GAIN_ADJUST, 2);
Steven Toth52c99bd2008-05-01 04:57:01 -03002574 }
Steven Toth3935c252008-05-01 05:45:44 -03002575 if (state->RF_LO > 150000000UL && state->RF_LO <= 200000000UL) {
Steven Toth52c99bd2008-05-01 04:57:01 -03002576 // Look-Up Table implementation
Steven Toth3935c252008-05-01 05:45:44 -03002577 status += MXL_ControlWrite(fe, DN_POLY, 3);
2578 status += MXL_ControlWrite(fe, DN_RFGAIN, 3);
2579 status += MXL_ControlWrite(fe, DN_CAP_RFLPF, 9);
2580 status += MXL_ControlWrite(fe, DN_EN_VHFUHFBAR, 1);
2581 status += MXL_ControlWrite(fe, DN_GAIN_ADJUST, 2);
Steven Toth52c99bd2008-05-01 04:57:01 -03002582 }
Steven Toth3935c252008-05-01 05:45:44 -03002583 if (state->RF_LO > 200000000UL && state->RF_LO <= 300000000UL) {
Steven Toth52c99bd2008-05-01 04:57:01 -03002584 // Look-Up Table implementation
Steven Toth3935c252008-05-01 05:45:44 -03002585 status += MXL_ControlWrite(fe, DN_POLY, 3) ;
2586 status += MXL_ControlWrite(fe, DN_RFGAIN, 3) ;
2587 status += MXL_ControlWrite(fe, DN_CAP_RFLPF, 0) ;
2588 status += MXL_ControlWrite(fe, DN_EN_VHFUHFBAR, 1) ;
2589 status += MXL_ControlWrite(fe, DN_GAIN_ADJUST, 3) ;
Steven Toth52c99bd2008-05-01 04:57:01 -03002590 }
Steven Toth3935c252008-05-01 05:45:44 -03002591 if (state->RF_LO > 300000000UL && state->RF_LO <= 650000000UL) {
Steven Toth52c99bd2008-05-01 04:57:01 -03002592 // Look-Up Table implementation
Steven Toth3935c252008-05-01 05:45:44 -03002593 status += MXL_ControlWrite(fe, DN_POLY, 3) ;
2594 status += MXL_ControlWrite(fe, DN_RFGAIN, 1) ;
2595 status += MXL_ControlWrite(fe, DN_CAP_RFLPF, 0) ;
2596 status += MXL_ControlWrite(fe, DN_EN_VHFUHFBAR, 0) ;
2597 status += MXL_ControlWrite(fe, DN_GAIN_ADJUST, 3) ;
Steven Toth52c99bd2008-05-01 04:57:01 -03002598 }
Steven Toth3935c252008-05-01 05:45:44 -03002599 if (state->RF_LO > 650000000UL && state->RF_LO <= 900000000UL) {
Steven Toth52c99bd2008-05-01 04:57:01 -03002600 // Look-Up Table implementation
Steven Toth3935c252008-05-01 05:45:44 -03002601 status += MXL_ControlWrite(fe, DN_POLY, 3) ;
2602 status += MXL_ControlWrite(fe, DN_RFGAIN, 2) ;
2603 status += MXL_ControlWrite(fe, DN_CAP_RFLPF, 0) ;
2604 status += MXL_ControlWrite(fe, DN_EN_VHFUHFBAR, 0) ;
2605 status += MXL_ControlWrite(fe, DN_GAIN_ADJUST, 3) ;
Steven Toth52c99bd2008-05-01 04:57:01 -03002606 }
Steven Toth3935c252008-05-01 05:45:44 -03002607 if (state->RF_LO > 900000000UL) {
Steven Toth52c99bd2008-05-01 04:57:01 -03002608 return -1;
2609 }
2610 // DN_IQTNBUF_AMP
2611 // DN_IQTNGNBFBIAS_BST
Steven Toth3935c252008-05-01 05:45:44 -03002612 if (state->RF_LO >= 40000000UL && state->RF_LO <= 75000000UL) {
2613 status += MXL_ControlWrite(fe, DN_IQTNBUF_AMP, 1);
2614 status += MXL_ControlWrite(fe, DN_IQTNGNBFBIAS_BST, 0);
Steven Toth52c99bd2008-05-01 04:57:01 -03002615 }
Steven Toth3935c252008-05-01 05:45:44 -03002616 if (state->RF_LO > 75000000UL && state->RF_LO <= 100000000UL) {
2617 status += MXL_ControlWrite(fe, DN_IQTNBUF_AMP, 1);
2618 status += MXL_ControlWrite(fe, DN_IQTNGNBFBIAS_BST, 0);
Steven Toth52c99bd2008-05-01 04:57:01 -03002619 }
Steven Toth3935c252008-05-01 05:45:44 -03002620 if (state->RF_LO > 100000000UL && state->RF_LO <= 150000000UL) {
2621 status += MXL_ControlWrite(fe, DN_IQTNBUF_AMP, 1);
2622 status += MXL_ControlWrite(fe, DN_IQTNGNBFBIAS_BST, 0);
Steven Toth52c99bd2008-05-01 04:57:01 -03002623 }
Steven Toth3935c252008-05-01 05:45:44 -03002624 if (state->RF_LO > 150000000UL && state->RF_LO <= 200000000UL) {
2625 status += MXL_ControlWrite(fe, DN_IQTNBUF_AMP, 1);
2626 status += MXL_ControlWrite(fe, DN_IQTNGNBFBIAS_BST, 0);
Steven Toth52c99bd2008-05-01 04:57:01 -03002627 }
Steven Toth3935c252008-05-01 05:45:44 -03002628 if (state->RF_LO > 200000000UL && state->RF_LO <= 300000000UL) {
2629 status += MXL_ControlWrite(fe, DN_IQTNBUF_AMP, 1);
2630 status += MXL_ControlWrite(fe, DN_IQTNGNBFBIAS_BST, 0);
Steven Toth52c99bd2008-05-01 04:57:01 -03002631 }
Steven Toth3935c252008-05-01 05:45:44 -03002632 if (state->RF_LO > 300000000UL && state->RF_LO <= 400000000UL) {
2633 status += MXL_ControlWrite(fe, DN_IQTNBUF_AMP, 1);
2634 status += MXL_ControlWrite(fe, DN_IQTNGNBFBIAS_BST, 0);
Steven Toth52c99bd2008-05-01 04:57:01 -03002635 }
Steven Toth3935c252008-05-01 05:45:44 -03002636 if (state->RF_LO > 400000000UL && state->RF_LO <= 450000000UL) {
2637 status += MXL_ControlWrite(fe, DN_IQTNBUF_AMP, 1);
2638 status += MXL_ControlWrite(fe, DN_IQTNGNBFBIAS_BST, 0);
Steven Toth52c99bd2008-05-01 04:57:01 -03002639 }
Steven Toth3935c252008-05-01 05:45:44 -03002640 if (state->RF_LO > 450000000UL && state->RF_LO <= 500000000UL) {
2641 status += MXL_ControlWrite(fe, DN_IQTNBUF_AMP, 1);
2642 status += MXL_ControlWrite(fe, DN_IQTNGNBFBIAS_BST, 0);
Steven Toth52c99bd2008-05-01 04:57:01 -03002643 }
Steven Toth3935c252008-05-01 05:45:44 -03002644 if (state->RF_LO > 500000000UL && state->RF_LO <= 550000000UL) {
2645 status += MXL_ControlWrite(fe, DN_IQTNBUF_AMP, 1);
2646 status += MXL_ControlWrite(fe, DN_IQTNGNBFBIAS_BST, 0);
Steven Toth52c99bd2008-05-01 04:57:01 -03002647 }
Steven Toth3935c252008-05-01 05:45:44 -03002648 if (state->RF_LO > 550000000UL && state->RF_LO <= 600000000UL) {
2649 status += MXL_ControlWrite(fe, DN_IQTNBUF_AMP, 1);
2650 status += MXL_ControlWrite(fe, DN_IQTNGNBFBIAS_BST, 0);
Steven Toth52c99bd2008-05-01 04:57:01 -03002651 }
Steven Toth3935c252008-05-01 05:45:44 -03002652 if (state->RF_LO > 600000000UL && state->RF_LO <= 650000000UL) {
2653 status += MXL_ControlWrite(fe, DN_IQTNBUF_AMP, 1);
2654 status += MXL_ControlWrite(fe, DN_IQTNGNBFBIAS_BST, 0);
Steven Toth52c99bd2008-05-01 04:57:01 -03002655 }
Steven Toth3935c252008-05-01 05:45:44 -03002656 if (state->RF_LO > 650000000UL && state->RF_LO <= 700000000UL) {
2657 status += MXL_ControlWrite(fe, DN_IQTNBUF_AMP, 1);
2658 status += MXL_ControlWrite(fe, DN_IQTNGNBFBIAS_BST, 0);
Steven Toth52c99bd2008-05-01 04:57:01 -03002659 }
Steven Toth3935c252008-05-01 05:45:44 -03002660 if (state->RF_LO > 700000000UL && state->RF_LO <= 750000000UL) {
2661 status += MXL_ControlWrite(fe, DN_IQTNBUF_AMP, 1);
2662 status += MXL_ControlWrite(fe, DN_IQTNGNBFBIAS_BST, 0);
Steven Toth52c99bd2008-05-01 04:57:01 -03002663 }
Steven Toth3935c252008-05-01 05:45:44 -03002664 if (state->RF_LO > 750000000UL && state->RF_LO <= 800000000UL) {
2665 status += MXL_ControlWrite(fe, DN_IQTNBUF_AMP, 1);
2666 status += MXL_ControlWrite(fe, DN_IQTNGNBFBIAS_BST, 0);
Steven Toth52c99bd2008-05-01 04:57:01 -03002667 }
Steven Toth3935c252008-05-01 05:45:44 -03002668 if (state->RF_LO > 800000000UL && state->RF_LO <= 850000000UL) {
2669 status += MXL_ControlWrite(fe, DN_IQTNBUF_AMP, 10);
2670 status += MXL_ControlWrite(fe, DN_IQTNGNBFBIAS_BST, 1);
Steven Toth52c99bd2008-05-01 04:57:01 -03002671 }
Steven Toth3935c252008-05-01 05:45:44 -03002672 if (state->RF_LO > 850000000UL && state->RF_LO <= 900000000UL) {
2673 status += MXL_ControlWrite(fe, DN_IQTNBUF_AMP, 10);
2674 status += MXL_ControlWrite(fe, DN_IQTNGNBFBIAS_BST, 1);
Steven Toth52c99bd2008-05-01 04:57:01 -03002675 }
2676
2677 //
2678 // Set RF Synth and LO Path Control
2679 //
2680 // Look-Up table implementation for:
2681 // RFSYN_EN_OUTMUX
2682 // RFSYN_SEL_VCO_OUT
2683 // RFSYN_SEL_VCO_HI
2684 // RFSYN_SEL_DIVM
2685 // RFSYN_RF_DIV_BIAS
2686 // DN_SEL_FREQ
2687 //
2688 // Set divider_val, Fmax, Fmix to use in Equations
2689 FminBin = 28000000UL ;
2690 FmaxBin = 42500000UL ;
Steven Toth3935c252008-05-01 05:45:44 -03002691 if (state->RF_LO >= 40000000UL && state->RF_LO <= FmaxBin) {
2692 status += MXL_ControlWrite(fe, RFSYN_EN_OUTMUX, 1);
2693 status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_OUT, 0);
2694 status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 0);
2695 status += MXL_ControlWrite(fe, RFSYN_SEL_DIVM, 0);
2696 status += MXL_ControlWrite(fe, RFSYN_RF_DIV_BIAS, 1);
2697 status += MXL_ControlWrite(fe, DN_SEL_FREQ, 1);
Steven Toth52c99bd2008-05-01 04:57:01 -03002698 divider_val = 64 ;
2699 Fmax = FmaxBin ;
2700 Fmin = FminBin ;
2701 }
2702 FminBin = 42500000UL ;
2703 FmaxBin = 56000000UL ;
Steven Toth3935c252008-05-01 05:45:44 -03002704 if (state->RF_LO > FminBin && state->RF_LO <= FmaxBin) {
2705 status += MXL_ControlWrite(fe, RFSYN_EN_OUTMUX, 1);
2706 status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_OUT, 0);
2707 status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 1);
2708 status += MXL_ControlWrite(fe, RFSYN_SEL_DIVM, 0);
2709 status += MXL_ControlWrite(fe, RFSYN_RF_DIV_BIAS, 1);
2710 status += MXL_ControlWrite(fe, DN_SEL_FREQ, 1);
Steven Toth52c99bd2008-05-01 04:57:01 -03002711 divider_val = 64 ;
2712 Fmax = FmaxBin ;
2713 Fmin = FminBin ;
2714 }
2715 FminBin = 56000000UL ;
2716 FmaxBin = 85000000UL ;
Steven Toth3935c252008-05-01 05:45:44 -03002717 if (state->RF_LO > FminBin && state->RF_LO <= FmaxBin) {
2718 status += MXL_ControlWrite(fe, RFSYN_EN_OUTMUX, 0) ;
2719 status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_OUT, 1) ;
2720 status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 0) ;
2721 status += MXL_ControlWrite(fe, RFSYN_SEL_DIVM, 0) ;
2722 status += MXL_ControlWrite(fe, RFSYN_RF_DIV_BIAS, 1) ;
2723 status += MXL_ControlWrite(fe, DN_SEL_FREQ, 1) ;
Steven Toth52c99bd2008-05-01 04:57:01 -03002724 divider_val = 32 ;
2725 Fmax = FmaxBin ;
2726 Fmin = FminBin ;
2727 }
2728 FminBin = 85000000UL ;
2729 FmaxBin = 112000000UL ;
Steven Toth3935c252008-05-01 05:45:44 -03002730 if (state->RF_LO > FminBin && state->RF_LO <= FmaxBin) {
2731 status += MXL_ControlWrite(fe, RFSYN_EN_OUTMUX, 0) ;
2732 status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_OUT, 1) ;
2733 status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 1) ;
2734 status += MXL_ControlWrite(fe, RFSYN_SEL_DIVM, 0) ;
2735 status += MXL_ControlWrite(fe, RFSYN_RF_DIV_BIAS, 1) ;
2736 status += MXL_ControlWrite(fe, DN_SEL_FREQ, 1) ;
Steven Toth52c99bd2008-05-01 04:57:01 -03002737 divider_val = 32 ;
2738 Fmax = FmaxBin ;
2739 Fmin = FminBin ;
2740 }
2741 FminBin = 112000000UL ;
2742 FmaxBin = 170000000UL ;
Steven Toth3935c252008-05-01 05:45:44 -03002743 if (state->RF_LO > FminBin && state->RF_LO <= FmaxBin) {
2744 status += MXL_ControlWrite(fe, RFSYN_EN_OUTMUX, 0) ;
2745 status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_OUT, 1) ;
2746 status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 0) ;
2747 status += MXL_ControlWrite(fe, RFSYN_SEL_DIVM, 0) ;
2748 status += MXL_ControlWrite(fe, RFSYN_RF_DIV_BIAS, 1) ;
2749 status += MXL_ControlWrite(fe, DN_SEL_FREQ, 2) ;
Steven Toth52c99bd2008-05-01 04:57:01 -03002750 divider_val = 16 ;
2751 Fmax = FmaxBin ;
2752 Fmin = FminBin ;
2753 }
2754 FminBin = 170000000UL ;
2755 FmaxBin = 225000000UL ;
Steven Toth3935c252008-05-01 05:45:44 -03002756 if (state->RF_LO > FminBin && state->RF_LO <= FmaxBin) {
2757 status += MXL_ControlWrite(fe, RFSYN_EN_OUTMUX, 0) ;
2758 status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_OUT, 1) ;
2759 status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 1) ;
2760 status += MXL_ControlWrite(fe, RFSYN_SEL_DIVM, 0) ;
2761 status += MXL_ControlWrite(fe, RFSYN_RF_DIV_BIAS, 1) ;
2762 status += MXL_ControlWrite(fe, DN_SEL_FREQ, 2) ;
Steven Toth52c99bd2008-05-01 04:57:01 -03002763 divider_val = 16 ;
2764 Fmax = FmaxBin ;
2765 Fmin = FminBin ;
2766 }
2767 FminBin = 225000000UL ;
2768 FmaxBin = 300000000UL ;
Steven Toth3935c252008-05-01 05:45:44 -03002769 if (state->RF_LO > FminBin && state->RF_LO <= FmaxBin) {
2770 status += MXL_ControlWrite(fe, RFSYN_EN_OUTMUX, 0) ;
2771 status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_OUT, 1) ;
2772 status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 0) ;
2773 status += MXL_ControlWrite(fe, RFSYN_SEL_DIVM, 0) ;
2774 status += MXL_ControlWrite(fe, RFSYN_RF_DIV_BIAS, 1) ;
2775 status += MXL_ControlWrite(fe, DN_SEL_FREQ, 4) ;
Steven Toth52c99bd2008-05-01 04:57:01 -03002776 divider_val = 8 ;
2777 Fmax = 340000000UL ;
2778 Fmin = FminBin ;
2779 }
2780 FminBin = 300000000UL ;
2781 FmaxBin = 340000000UL ;
Steven Toth3935c252008-05-01 05:45:44 -03002782 if (state->RF_LO > FminBin && state->RF_LO <= FmaxBin) {
2783 status += MXL_ControlWrite(fe, RFSYN_EN_OUTMUX, 1) ;
2784 status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_OUT, 0) ;
2785 status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 0) ;
2786 status += MXL_ControlWrite(fe, RFSYN_SEL_DIVM, 0) ;
2787 status += MXL_ControlWrite(fe, RFSYN_RF_DIV_BIAS, 1) ;
2788 status += MXL_ControlWrite(fe, DN_SEL_FREQ, 0) ;
Steven Toth52c99bd2008-05-01 04:57:01 -03002789 divider_val = 8 ;
2790 Fmax = FmaxBin ;
2791 Fmin = 225000000UL ;
2792 }
2793 FminBin = 340000000UL ;
2794 FmaxBin = 450000000UL ;
Steven Toth3935c252008-05-01 05:45:44 -03002795 if (state->RF_LO > FminBin && state->RF_LO <= FmaxBin) {
2796 status += MXL_ControlWrite(fe, RFSYN_EN_OUTMUX, 1) ;
2797 status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_OUT, 0) ;
2798 status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 1) ;
2799 status += MXL_ControlWrite(fe, RFSYN_SEL_DIVM, 0) ;
2800 status += MXL_ControlWrite(fe, RFSYN_RF_DIV_BIAS, 2) ;
2801 status += MXL_ControlWrite(fe, DN_SEL_FREQ, 0) ;
Steven Toth52c99bd2008-05-01 04:57:01 -03002802 divider_val = 8 ;
2803 Fmax = FmaxBin ;
2804 Fmin = FminBin ;
2805 }
2806 FminBin = 450000000UL ;
2807 FmaxBin = 680000000UL ;
Steven Toth3935c252008-05-01 05:45:44 -03002808 if (state->RF_LO > FminBin && state->RF_LO <= FmaxBin) {
2809 status += MXL_ControlWrite(fe, RFSYN_EN_OUTMUX, 0) ;
2810 status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_OUT, 1) ;
2811 status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 0) ;
2812 status += MXL_ControlWrite(fe, RFSYN_SEL_DIVM, 1) ;
2813 status += MXL_ControlWrite(fe, RFSYN_RF_DIV_BIAS, 1) ;
2814 status += MXL_ControlWrite(fe, DN_SEL_FREQ, 0) ;
Steven Toth52c99bd2008-05-01 04:57:01 -03002815 divider_val = 4 ;
2816 Fmax = FmaxBin ;
2817 Fmin = FminBin ;
2818 }
2819 FminBin = 680000000UL ;
2820 FmaxBin = 900000000UL ;
Steven Toth3935c252008-05-01 05:45:44 -03002821 if (state->RF_LO > FminBin && state->RF_LO <= FmaxBin) {
2822 status += MXL_ControlWrite(fe, RFSYN_EN_OUTMUX, 0) ;
2823 status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_OUT, 1) ;
2824 status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 1) ;
2825 status += MXL_ControlWrite(fe, RFSYN_SEL_DIVM, 1) ;
2826 status += MXL_ControlWrite(fe, RFSYN_RF_DIV_BIAS, 1) ;
2827 status += MXL_ControlWrite(fe, DN_SEL_FREQ, 0) ;
Steven Toth52c99bd2008-05-01 04:57:01 -03002828 divider_val = 4 ;
2829 Fmax = FmaxBin ;
2830 Fmin = FminBin ;
2831 }
2832
2833 // CHCAL_INT_MOD_RF
2834 // CHCAL_FRAC_MOD_RF
2835 // RFSYN_LPF_R
2836 // CHCAL_EN_INT_RF
2837
2838 // Equation E3
2839 // RFSYN_VCO_BIAS
Steven Toth3935c252008-05-01 05:45:44 -03002840 E3 = (((Fmax-state->RF_LO)/1000)*32)/((Fmax-Fmin)/1000) + 8 ;
2841 status += MXL_ControlWrite(fe, RFSYN_VCO_BIAS, E3) ;
Steven Toth52c99bd2008-05-01 04:57:01 -03002842
2843 // Equation E4
2844 // CHCAL_INT_MOD_RF
Steven Toth3935c252008-05-01 05:45:44 -03002845 E4 = (state->RF_LO*divider_val/1000)/(2*state->Fxtal*Kdbl_RF/1000) ;
2846 MXL_ControlWrite(fe, CHCAL_INT_MOD_RF, E4) ;
Steven Toth52c99bd2008-05-01 04:57:01 -03002847
2848 // Equation E5
2849 // CHCAL_FRAC_MOD_RF
2850 // CHCAL_EN_INT_RF
Steven Toth3935c252008-05-01 05:45:44 -03002851 E5 = ((2<<17)*(state->RF_LO/10000*divider_val - (E4*(2*state->Fxtal*Kdbl_RF)/10000)))/(2*state->Fxtal*Kdbl_RF/10000) ;
2852 status += MXL_ControlWrite(fe, CHCAL_FRAC_MOD_RF, E5) ;
Steven Toth52c99bd2008-05-01 04:57:01 -03002853
2854 // Equation E5A
2855 // RFSYN_LPF_R
Steven Toth3935c252008-05-01 05:45:44 -03002856 E5A = (((Fmax - state->RF_LO)/1000)*4/((Fmax-Fmin)/1000)) + 1 ;
2857 status += MXL_ControlWrite(fe, RFSYN_LPF_R, E5A) ;
Steven Toth52c99bd2008-05-01 04:57:01 -03002858
2859 // Euqation E5B
2860 // CHCAL_EN_INIT_RF
Steven Toth3935c252008-05-01 05:45:44 -03002861 status += MXL_ControlWrite(fe, CHCAL_EN_INT_RF, ((E5 == 0) ? 1 : 0));
Steven Toth52c99bd2008-05-01 04:57:01 -03002862 //if (E5 == 0)
Steven Toth3935c252008-05-01 05:45:44 -03002863 // status += MXL_ControlWrite(fe, CHCAL_EN_INT_RF, 1);
Steven Toth52c99bd2008-05-01 04:57:01 -03002864 //else
Steven Toth3935c252008-05-01 05:45:44 -03002865 // status += MXL_ControlWrite(fe, CHCAL_FRAC_MOD_RF, E5) ;
Steven Toth52c99bd2008-05-01 04:57:01 -03002866
2867 //
2868 // Set TG Synth
2869 //
2870 // Look-Up table implementation for:
2871 // TG_LO_DIVVAL
2872 // TG_LO_SELVAL
2873 //
2874 // Set divider_val, Fmax, Fmix to use in Equations
Steven Toth3935c252008-05-01 05:45:44 -03002875 if (state->TG_LO < 33000000UL) {
Steven Toth52c99bd2008-05-01 04:57:01 -03002876 return -1;
2877 }
2878 FminBin = 33000000UL ;
2879 FmaxBin = 50000000UL ;
Steven Toth3935c252008-05-01 05:45:44 -03002880 if (state->TG_LO >= FminBin && state->TG_LO <= FmaxBin) {
2881 status += MXL_ControlWrite(fe, TG_LO_DIVVAL, 0x6) ;
2882 status += MXL_ControlWrite(fe, TG_LO_SELVAL, 0x0) ;
Steven Toth52c99bd2008-05-01 04:57:01 -03002883 divider_val = 36 ;
2884 Fmax = FmaxBin ;
2885 Fmin = FminBin ;
2886 }
2887 FminBin = 50000000UL ;
2888 FmaxBin = 67000000UL ;
Steven Toth3935c252008-05-01 05:45:44 -03002889 if (state->TG_LO > FminBin && state->TG_LO <= FmaxBin) {
2890 status += MXL_ControlWrite(fe, TG_LO_DIVVAL, 0x1) ;
2891 status += MXL_ControlWrite(fe, TG_LO_SELVAL, 0x0) ;
Steven Toth52c99bd2008-05-01 04:57:01 -03002892 divider_val = 24 ;
2893 Fmax = FmaxBin ;
2894 Fmin = FminBin ;
2895 }
2896 FminBin = 67000000UL ;
2897 FmaxBin = 100000000UL ;
Steven Toth3935c252008-05-01 05:45:44 -03002898 if (state->TG_LO > FminBin && state->TG_LO <= FmaxBin) {
2899 status += MXL_ControlWrite(fe, TG_LO_DIVVAL, 0xC) ;
2900 status += MXL_ControlWrite(fe, TG_LO_SELVAL, 0x2) ;
Steven Toth52c99bd2008-05-01 04:57:01 -03002901 divider_val = 18 ;
2902 Fmax = FmaxBin ;
2903 Fmin = FminBin ;
2904 }
2905 FminBin = 100000000UL ;
2906 FmaxBin = 150000000UL ;
Steven Toth3935c252008-05-01 05:45:44 -03002907 if (state->TG_LO > FminBin && state->TG_LO <= FmaxBin) {
2908 status += MXL_ControlWrite(fe, TG_LO_DIVVAL, 0x8) ;
2909 status += MXL_ControlWrite(fe, TG_LO_SELVAL, 0x2) ;
Steven Toth52c99bd2008-05-01 04:57:01 -03002910 divider_val = 12 ;
2911 Fmax = FmaxBin ;
2912 Fmin = FminBin ;
2913 }
2914 FminBin = 150000000UL ;
2915 FmaxBin = 200000000UL ;
Steven Toth3935c252008-05-01 05:45:44 -03002916 if (state->TG_LO > FminBin && state->TG_LO <= FmaxBin) {
2917 status += MXL_ControlWrite(fe, TG_LO_DIVVAL, 0x0) ;
2918 status += MXL_ControlWrite(fe, TG_LO_SELVAL, 0x2) ;
Steven Toth52c99bd2008-05-01 04:57:01 -03002919 divider_val = 8 ;
2920 Fmax = FmaxBin ;
2921 Fmin = FminBin ;
2922 }
2923 FminBin = 200000000UL ;
2924 FmaxBin = 300000000UL ;
Steven Toth3935c252008-05-01 05:45:44 -03002925 if (state->TG_LO > FminBin && state->TG_LO <= FmaxBin) {
2926 status += MXL_ControlWrite(fe, TG_LO_DIVVAL, 0x8) ;
2927 status += MXL_ControlWrite(fe, TG_LO_SELVAL, 0x3) ;
Steven Toth52c99bd2008-05-01 04:57:01 -03002928 divider_val = 6 ;
2929 Fmax = FmaxBin ;
2930 Fmin = FminBin ;
2931 }
2932 FminBin = 300000000UL ;
2933 FmaxBin = 400000000UL ;
Steven Toth3935c252008-05-01 05:45:44 -03002934 if (state->TG_LO > FminBin && state->TG_LO <= FmaxBin) {
2935 status += MXL_ControlWrite(fe, TG_LO_DIVVAL, 0x0) ;
2936 status += MXL_ControlWrite(fe, TG_LO_SELVAL, 0x3) ;
Steven Toth52c99bd2008-05-01 04:57:01 -03002937 divider_val = 4 ;
2938 Fmax = FmaxBin ;
2939 Fmin = FminBin ;
2940 }
2941 FminBin = 400000000UL ;
2942 FmaxBin = 600000000UL ;
Steven Toth3935c252008-05-01 05:45:44 -03002943 if (state->TG_LO > FminBin && state->TG_LO <= FmaxBin) {
2944 status += MXL_ControlWrite(fe, TG_LO_DIVVAL, 0x8) ;
2945 status += MXL_ControlWrite(fe, TG_LO_SELVAL, 0x7) ;
Steven Toth52c99bd2008-05-01 04:57:01 -03002946 divider_val = 3 ;
2947 Fmax = FmaxBin ;
2948 Fmin = FminBin ;
2949 }
2950 FminBin = 600000000UL ;
2951 FmaxBin = 900000000UL ;
Steven Toth3935c252008-05-01 05:45:44 -03002952 if (state->TG_LO > FminBin && state->TG_LO <= FmaxBin) {
2953 status += MXL_ControlWrite(fe, TG_LO_DIVVAL, 0x0) ;
2954 status += MXL_ControlWrite(fe, TG_LO_SELVAL, 0x7) ;
Steven Toth52c99bd2008-05-01 04:57:01 -03002955 divider_val = 2 ;
2956 Fmax = FmaxBin ;
2957 Fmin = FminBin ;
2958 }
2959
2960 // TG_DIV_VAL
Steven Toth3935c252008-05-01 05:45:44 -03002961 tg_divval = (state->TG_LO*divider_val/100000)
2962 *(MXL_Ceiling(state->Fxtal,1000000) * 100) / (state->Fxtal/1000) ;
2963 status += MXL_ControlWrite(fe, TG_DIV_VAL, tg_divval) ;
Steven Toth52c99bd2008-05-01 04:57:01 -03002964
Steven Toth3935c252008-05-01 05:45:44 -03002965 if (state->TG_LO > 600000000UL)
2966 status += MXL_ControlWrite(fe, TG_DIV_VAL, tg_divval + 1 ) ;
Steven Toth52c99bd2008-05-01 04:57:01 -03002967
2968 Fmax = 1800000000UL ;
2969 Fmin = 1200000000UL ;
2970
2971
2972
2973 // to prevent overflow of 32 bit unsigned integer, use following equation. Edit for v2.6.4
Steven Toth3935c252008-05-01 05:45:44 -03002974 Fref_TG = (state->Fxtal/1000)/ MXL_Ceiling(state->Fxtal, 1000000) ; // Fref_TF = Fref_TG*1000
Steven Toth52c99bd2008-05-01 04:57:01 -03002975
Steven Toth3935c252008-05-01 05:45:44 -03002976 Fvco = (state->TG_LO/10000) * divider_val * Fref_TG; //Fvco = Fvco/10
Steven Toth52c99bd2008-05-01 04:57:01 -03002977
2978 tg_lo = (((Fmax/10 - Fvco)/100)*32) / ((Fmax-Fmin)/1000)+8;
2979
2980 //below equation is same as above but much harder to debug.
Steven Toth3935c252008-05-01 05:45:44 -03002981 //tg_lo = ( ((Fmax/10000 * Xtal_Int)/100) - ((state->TG_LO/10000)*divider_val*(state->Fxtal/10000)/100) )*32/((Fmax-Fmin)/10000 * Xtal_Int/100) + 8 ;
Steven Toth52c99bd2008-05-01 04:57:01 -03002982
2983
Steven Toth3935c252008-05-01 05:45:44 -03002984 status += MXL_ControlWrite(fe, TG_VCO_BIAS , tg_lo) ;
Steven Toth52c99bd2008-05-01 04:57:01 -03002985
2986
2987
2988 //add for 2.6.5
2989 //Special setting for QAM
Steven Toth3935c252008-05-01 05:45:44 -03002990 if(state->Mod_Type == MXL_QAM)
Steven Toth52c99bd2008-05-01 04:57:01 -03002991 {
Steven Toth3935c252008-05-01 05:45:44 -03002992 if(state->RF_IN < 680000000)
2993 status += MXL_ControlWrite(fe, RFSYN_CHP_GAIN, 3) ;
Steven Toth52c99bd2008-05-01 04:57:01 -03002994 else
Steven Toth3935c252008-05-01 05:45:44 -03002995 status += MXL_ControlWrite(fe, RFSYN_CHP_GAIN, 2) ;
Steven Toth52c99bd2008-05-01 04:57:01 -03002996 }
2997
2998
2999 //remove 20.48MHz setting for 2.6.10
3000
3001 //
3002 // Off Chip Tracking Filter Control
3003 //
Steven Toth85d220d2008-05-01 05:48:14 -03003004 if (state->TF_Type == MXL_TF_OFF) // Tracking Filter Off State; turn off all the banks
Steven Toth52c99bd2008-05-01 04:57:01 -03003005 {
Steven Toth3935c252008-05-01 05:45:44 -03003006 status += MXL_ControlWrite(fe, DAC_A_ENABLE, 0) ;
3007 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0) ;
Steven Toth52c99bd2008-05-01 04:57:01 -03003008
Steven Toth3935c252008-05-01 05:45:44 -03003009 status += MXL_SetGPIO(fe, 3, 1) ; // turn off Bank 1
3010 status += MXL_SetGPIO(fe, 1, 1) ; // turn off Bank 2
3011 status += MXL_SetGPIO(fe, 4, 1) ; // turn off Bank 3
Steven Toth52c99bd2008-05-01 04:57:01 -03003012 }
3013
Steven Toth85d220d2008-05-01 05:48:14 -03003014 if (state->TF_Type == MXL_TF_C) // Tracking Filter type C
Steven Toth52c99bd2008-05-01 04:57:01 -03003015 {
Steven Toth3935c252008-05-01 05:45:44 -03003016 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 1) ;
3017 status += MXL_ControlWrite(fe, DAC_DIN_A, 0) ;
Steven Toth52c99bd2008-05-01 04:57:01 -03003018
Steven Toth3935c252008-05-01 05:45:44 -03003019 if (state->RF_IN >= 43000000 && state->RF_IN < 150000000)
Steven Toth52c99bd2008-05-01 04:57:01 -03003020 {
3021
Steven Toth3935c252008-05-01 05:45:44 -03003022 status += MXL_ControlWrite(fe, DAC_A_ENABLE, 0) ; // Bank4 Off
3023 status += MXL_ControlWrite(fe, DAC_DIN_B, 0) ;
3024 status += MXL_SetGPIO(fe, 3, 0) ; // Bank1 On
3025 status += MXL_SetGPIO(fe, 1, 1) ; // Bank2 Off
3026 status += MXL_SetGPIO(fe, 4, 1) ; // Bank3 Off
Steven Toth52c99bd2008-05-01 04:57:01 -03003027 }
Steven Toth3935c252008-05-01 05:45:44 -03003028 if (state->RF_IN >= 150000000 && state->RF_IN < 280000000)
Steven Toth52c99bd2008-05-01 04:57:01 -03003029 {
Steven Toth3935c252008-05-01 05:45:44 -03003030 status += MXL_ControlWrite(fe, DAC_A_ENABLE, 0) ; // Bank4 Off
3031 status += MXL_ControlWrite(fe, DAC_DIN_B, 0) ;
3032 status += MXL_SetGPIO(fe, 3, 1) ; // Bank1 Off
3033 status += MXL_SetGPIO(fe, 1, 0) ; // Bank2 On
3034 status += MXL_SetGPIO(fe, 4, 1) ; // Bank3 Off
Steven Toth52c99bd2008-05-01 04:57:01 -03003035 }
Steven Toth3935c252008-05-01 05:45:44 -03003036 if (state->RF_IN >= 280000000 && state->RF_IN < 360000000)
Steven Toth52c99bd2008-05-01 04:57:01 -03003037 {
Steven Toth3935c252008-05-01 05:45:44 -03003038 status += MXL_ControlWrite(fe, DAC_A_ENABLE, 0) ; // Bank4 Off
3039 status += MXL_ControlWrite(fe, DAC_DIN_B, 0) ;
3040 status += MXL_SetGPIO(fe, 3, 1) ; // Bank1 Off
3041 status += MXL_SetGPIO(fe, 1, 0) ; // Bank2 On
3042 status += MXL_SetGPIO(fe, 4, 0) ; // Bank3 On
Steven Toth52c99bd2008-05-01 04:57:01 -03003043 }
Steven Toth3935c252008-05-01 05:45:44 -03003044 if (state->RF_IN >= 360000000 && state->RF_IN < 560000000)
Steven Toth52c99bd2008-05-01 04:57:01 -03003045 {
Steven Toth3935c252008-05-01 05:45:44 -03003046 status += MXL_ControlWrite(fe, DAC_A_ENABLE, 0) ; // Bank4 Off
3047 status += MXL_ControlWrite(fe, DAC_DIN_B, 0) ;
3048 status += MXL_SetGPIO(fe, 3, 1) ; // Bank1 Off
3049 status += MXL_SetGPIO(fe, 1, 1) ; // Bank2 Off
3050 status += MXL_SetGPIO(fe, 4, 0) ; // Bank3 On
Steven Toth52c99bd2008-05-01 04:57:01 -03003051 }
Steven Toth3935c252008-05-01 05:45:44 -03003052 if (state->RF_IN >= 560000000 && state->RF_IN < 580000000)
Steven Toth52c99bd2008-05-01 04:57:01 -03003053 {
Steven Toth3935c252008-05-01 05:45:44 -03003054 status += MXL_ControlWrite(fe, DAC_A_ENABLE, 1) ; // Bank4 On
3055 status += MXL_ControlWrite(fe, DAC_DIN_B, 29) ;
3056 status += MXL_SetGPIO(fe, 3, 1) ; // Bank1 Off
3057 status += MXL_SetGPIO(fe, 1, 1) ; // Bank2 Off
3058 status += MXL_SetGPIO(fe, 4, 0) ; // Bank3 On
Steven Toth52c99bd2008-05-01 04:57:01 -03003059 }
Steven Toth3935c252008-05-01 05:45:44 -03003060 if (state->RF_IN >= 580000000 && state->RF_IN < 630000000)
Steven Toth52c99bd2008-05-01 04:57:01 -03003061 {
Steven Toth3935c252008-05-01 05:45:44 -03003062 status += MXL_ControlWrite(fe, DAC_A_ENABLE, 1) ; // Bank4 On
3063 status += MXL_ControlWrite(fe, DAC_DIN_B, 0) ;
3064 status += MXL_SetGPIO(fe, 3, 1) ; // Bank1 Off
3065 status += MXL_SetGPIO(fe, 1, 1) ; // Bank2 Off
3066 status += MXL_SetGPIO(fe, 4, 0) ; // Bank3 On
Steven Toth52c99bd2008-05-01 04:57:01 -03003067 }
Steven Toth3935c252008-05-01 05:45:44 -03003068 if (state->RF_IN >= 630000000 && state->RF_IN < 700000000)
Steven Toth52c99bd2008-05-01 04:57:01 -03003069 {
Steven Toth3935c252008-05-01 05:45:44 -03003070 status += MXL_ControlWrite(fe, DAC_A_ENABLE, 1) ; // Bank4 On
3071 status += MXL_ControlWrite(fe, DAC_DIN_B, 16) ;
3072 status += MXL_SetGPIO(fe, 3, 1) ; // Bank1 Off
3073 status += MXL_SetGPIO(fe, 1, 1) ; // Bank2 Off
3074 status += MXL_SetGPIO(fe, 4, 1) ; // Bank3 Off
Steven Toth52c99bd2008-05-01 04:57:01 -03003075 }
Steven Toth3935c252008-05-01 05:45:44 -03003076 if (state->RF_IN >= 700000000 && state->RF_IN < 760000000)
Steven Toth52c99bd2008-05-01 04:57:01 -03003077 {
Steven Toth3935c252008-05-01 05:45:44 -03003078 status += MXL_ControlWrite(fe, DAC_A_ENABLE, 1) ; // Bank4 On
3079 status += MXL_ControlWrite(fe, DAC_DIN_B, 7) ;
3080 status += MXL_SetGPIO(fe, 3, 1) ; // Bank1 Off
3081 status += MXL_SetGPIO(fe, 1, 1) ; // Bank2 Off
3082 status += MXL_SetGPIO(fe, 4, 1) ; // Bank3 Off
Steven Toth52c99bd2008-05-01 04:57:01 -03003083 }
Steven Toth3935c252008-05-01 05:45:44 -03003084 if (state->RF_IN >= 760000000 && state->RF_IN <= 900000000)
Steven Toth52c99bd2008-05-01 04:57:01 -03003085 {
Steven Toth3935c252008-05-01 05:45:44 -03003086 status += MXL_ControlWrite(fe, DAC_A_ENABLE, 1) ; // Bank4 On
3087 status += MXL_ControlWrite(fe, DAC_DIN_B, 0) ;
3088 status += MXL_SetGPIO(fe, 3, 1) ; // Bank1 Off
3089 status += MXL_SetGPIO(fe, 1, 1) ; // Bank2 Off
3090 status += MXL_SetGPIO(fe, 4, 1) ; // Bank3 Off
Steven Toth52c99bd2008-05-01 04:57:01 -03003091 }
3092 }
3093
Steven Toth85d220d2008-05-01 05:48:14 -03003094 if (state->TF_Type == MXL_TF_C_H) // Tracking Filter type C-H for Hauppauge only
Steven Toth52c99bd2008-05-01 04:57:01 -03003095 {
Steven Toth8c66a192008-05-01 06:35:48 -03003096 printk("%s() CH filter\n", __func__);
Steven Toth3935c252008-05-01 05:45:44 -03003097 status += MXL_ControlWrite(fe, DAC_DIN_A, 0) ;
Steven Toth52c99bd2008-05-01 04:57:01 -03003098
Steven Toth3935c252008-05-01 05:45:44 -03003099 if (state->RF_IN >= 43000000 && state->RF_IN < 150000000)
Steven Toth52c99bd2008-05-01 04:57:01 -03003100 {
3101
Steven Toth3935c252008-05-01 05:45:44 -03003102 status += MXL_ControlWrite(fe, DAC_A_ENABLE, 0) ; // Bank4 Off
3103 status += MXL_SetGPIO(fe, 4, 0) ; // Bank1 On
3104 status += MXL_SetGPIO(fe, 3, 1) ; // Bank2 Off
3105 status += MXL_SetGPIO(fe, 1, 1) ; // Bank3 Off
Steven Toth52c99bd2008-05-01 04:57:01 -03003106 }
Steven Toth3935c252008-05-01 05:45:44 -03003107 if (state->RF_IN >= 150000000 && state->RF_IN < 280000000)
Steven Toth52c99bd2008-05-01 04:57:01 -03003108 {
Steven Toth3935c252008-05-01 05:45:44 -03003109 status += MXL_ControlWrite(fe, DAC_A_ENABLE, 0) ; // Bank4 Off
3110 status += MXL_SetGPIO(fe, 4, 1) ; // Bank1 Off
3111 status += MXL_SetGPIO(fe, 3, 0) ; // Bank2 On
3112 status += MXL_SetGPIO(fe, 1, 1) ; // Bank3 Off
Steven Toth52c99bd2008-05-01 04:57:01 -03003113 }
Steven Toth3935c252008-05-01 05:45:44 -03003114 if (state->RF_IN >= 280000000 && state->RF_IN < 360000000)
Steven Toth52c99bd2008-05-01 04:57:01 -03003115 {
Steven Toth3935c252008-05-01 05:45:44 -03003116 status += MXL_ControlWrite(fe, DAC_A_ENABLE, 0) ; // Bank4 Off
3117 status += MXL_SetGPIO(fe, 4, 1) ; // Bank1 Off
3118 status += MXL_SetGPIO(fe, 3, 0) ; // Bank2 On
3119 status += MXL_SetGPIO(fe, 1, 0) ; // Bank3 On
Steven Toth52c99bd2008-05-01 04:57:01 -03003120 }
Steven Toth3935c252008-05-01 05:45:44 -03003121 if (state->RF_IN >= 360000000 && state->RF_IN < 560000000)
Steven Toth52c99bd2008-05-01 04:57:01 -03003122 {
Steven Toth3935c252008-05-01 05:45:44 -03003123 status += MXL_ControlWrite(fe, DAC_A_ENABLE, 0) ; // Bank4 Off
3124 status += MXL_SetGPIO(fe, 4, 1) ; // Bank1 Off
3125 status += MXL_SetGPIO(fe, 3, 1) ; // Bank2 Off
3126 status += MXL_SetGPIO(fe, 1, 0) ; // Bank3 On
Steven Toth52c99bd2008-05-01 04:57:01 -03003127 }
Steven Toth3935c252008-05-01 05:45:44 -03003128 if (state->RF_IN >= 560000000 && state->RF_IN < 580000000)
Steven Toth52c99bd2008-05-01 04:57:01 -03003129 {
Steven Toth3935c252008-05-01 05:45:44 -03003130 status += MXL_ControlWrite(fe, DAC_A_ENABLE, 1) ; // Bank4 On
3131 status += MXL_SetGPIO(fe, 4, 1) ; // Bank1 Off
3132 status += MXL_SetGPIO(fe, 3, 1) ; // Bank2 Off
3133 status += MXL_SetGPIO(fe, 1, 0) ; // Bank3 On
Steven Toth52c99bd2008-05-01 04:57:01 -03003134 }
Steven Toth3935c252008-05-01 05:45:44 -03003135 if (state->RF_IN >= 580000000 && state->RF_IN < 630000000)
Steven Toth52c99bd2008-05-01 04:57:01 -03003136 {
Steven Toth3935c252008-05-01 05:45:44 -03003137 status += MXL_ControlWrite(fe, DAC_A_ENABLE, 1) ; // Bank4 On
3138 status += MXL_SetGPIO(fe, 4, 1) ; // Bank1 Off
3139 status += MXL_SetGPIO(fe, 3, 1) ; // Bank2 Off
3140 status += MXL_SetGPIO(fe, 1, 0) ; // Bank3 On
Steven Toth52c99bd2008-05-01 04:57:01 -03003141 }
Steven Toth3935c252008-05-01 05:45:44 -03003142 if (state->RF_IN >= 630000000 && state->RF_IN < 700000000)
Steven Toth52c99bd2008-05-01 04:57:01 -03003143 {
Steven Toth3935c252008-05-01 05:45:44 -03003144 status += MXL_ControlWrite(fe, DAC_A_ENABLE, 1) ; // Bank4 On
3145 status += MXL_SetGPIO(fe, 4, 1) ; // Bank1 Off
3146 status += MXL_SetGPIO(fe, 3, 1) ; // Bank2 Off
3147 status += MXL_SetGPIO(fe, 1, 1) ; // Bank3 Off
Steven Toth52c99bd2008-05-01 04:57:01 -03003148 }
Steven Toth3935c252008-05-01 05:45:44 -03003149 if (state->RF_IN >= 700000000 && state->RF_IN < 760000000)
Steven Toth52c99bd2008-05-01 04:57:01 -03003150 {
Steven Toth3935c252008-05-01 05:45:44 -03003151 status += MXL_ControlWrite(fe, DAC_A_ENABLE, 1) ; // Bank4 On
3152 status += MXL_SetGPIO(fe, 4, 1) ; // Bank1 Off
3153 status += MXL_SetGPIO(fe, 3, 1) ; // Bank2 Off
3154 status += MXL_SetGPIO(fe, 1, 1) ; // Bank3 Off
Steven Toth52c99bd2008-05-01 04:57:01 -03003155 }
Steven Toth3935c252008-05-01 05:45:44 -03003156 if (state->RF_IN >= 760000000 && state->RF_IN <= 900000000)
Steven Toth52c99bd2008-05-01 04:57:01 -03003157 {
Steven Toth3935c252008-05-01 05:45:44 -03003158 status += MXL_ControlWrite(fe, DAC_A_ENABLE, 1) ; // Bank4 On
3159 status += MXL_SetGPIO(fe, 4, 1) ; // Bank1 Off
3160 status += MXL_SetGPIO(fe, 3, 1) ; // Bank2 Off
3161 status += MXL_SetGPIO(fe, 1, 1) ; // Bank3 Off
Steven Toth52c99bd2008-05-01 04:57:01 -03003162 }
3163 }
3164
Steven Toth85d220d2008-05-01 05:48:14 -03003165 if (state->TF_Type == MXL_TF_D) // Tracking Filter type D
Steven Toth52c99bd2008-05-01 04:57:01 -03003166 {
Steven Toth3935c252008-05-01 05:45:44 -03003167 status += MXL_ControlWrite(fe, DAC_DIN_B, 0) ;
Steven Toth52c99bd2008-05-01 04:57:01 -03003168
Steven Toth3935c252008-05-01 05:45:44 -03003169 if (state->RF_IN >= 43000000 && state->RF_IN < 174000000)
Steven Toth52c99bd2008-05-01 04:57:01 -03003170 {
3171
Steven Toth3935c252008-05-01 05:45:44 -03003172 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0) ; // Bank4 Off
3173 status += MXL_SetGPIO(fe, 4, 0) ; // Bank1 On
3174 status += MXL_SetGPIO(fe, 1, 1) ; // Bank2 Off
3175 status += MXL_SetGPIO(fe, 3, 1) ; // Bank3 Off
Steven Toth52c99bd2008-05-01 04:57:01 -03003176 }
Steven Toth3935c252008-05-01 05:45:44 -03003177 if (state->RF_IN >= 174000000 && state->RF_IN < 250000000)
Steven Toth52c99bd2008-05-01 04:57:01 -03003178 {
Steven Toth3935c252008-05-01 05:45:44 -03003179 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0) ; // Bank4 Off
3180 status += MXL_SetGPIO(fe, 4, 0) ; // Bank1 On
3181 status += MXL_SetGPIO(fe, 1, 0) ; // Bank2 On
3182 status += MXL_SetGPIO(fe, 3, 1) ; // Bank3 Off
Steven Toth52c99bd2008-05-01 04:57:01 -03003183 }
Steven Toth3935c252008-05-01 05:45:44 -03003184 if (state->RF_IN >= 250000000 && state->RF_IN < 310000000)
Steven Toth52c99bd2008-05-01 04:57:01 -03003185 {
Steven Toth3935c252008-05-01 05:45:44 -03003186 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0) ; // Bank4 Off
3187 status += MXL_SetGPIO(fe, 4, 1) ; // Bank1 Off
3188 status += MXL_SetGPIO(fe, 1, 0) ; // Bank2 On
3189 status += MXL_SetGPIO(fe, 3, 1) ; // Bank3 Off
Steven Toth52c99bd2008-05-01 04:57:01 -03003190 }
Steven Toth3935c252008-05-01 05:45:44 -03003191 if (state->RF_IN >= 310000000 && state->RF_IN < 360000000)
Steven Toth52c99bd2008-05-01 04:57:01 -03003192 {
Steven Toth3935c252008-05-01 05:45:44 -03003193 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0) ; // Bank4 Off
3194 status += MXL_SetGPIO(fe, 4, 1) ; // Bank1 Off
3195 status += MXL_SetGPIO(fe, 1, 0) ; // Bank2 On
3196 status += MXL_SetGPIO(fe, 3, 0) ; // Bank3 On
Steven Toth52c99bd2008-05-01 04:57:01 -03003197 }
Steven Toth3935c252008-05-01 05:45:44 -03003198 if (state->RF_IN >= 360000000 && state->RF_IN < 470000000)
Steven Toth52c99bd2008-05-01 04:57:01 -03003199 {
Steven Toth3935c252008-05-01 05:45:44 -03003200 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0) ; // Bank4 Off
3201 status += MXL_SetGPIO(fe, 4, 1) ; // Bank1 Off
3202 status += MXL_SetGPIO(fe, 1, 1) ; // Bank2 Off
3203 status += MXL_SetGPIO(fe, 3, 0) ; // Bank3 On
Steven Toth52c99bd2008-05-01 04:57:01 -03003204 }
Steven Toth3935c252008-05-01 05:45:44 -03003205 if (state->RF_IN >= 470000000 && state->RF_IN < 640000000)
Steven Toth52c99bd2008-05-01 04:57:01 -03003206 {
Steven Toth3935c252008-05-01 05:45:44 -03003207 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 1) ; // Bank4 On
3208 status += MXL_SetGPIO(fe, 4, 1) ; // Bank1 Off
3209 status += MXL_SetGPIO(fe, 1, 1) ; // Bank2 Off
3210 status += MXL_SetGPIO(fe, 3, 0) ; // Bank3 On
Steven Toth52c99bd2008-05-01 04:57:01 -03003211 }
Steven Toth3935c252008-05-01 05:45:44 -03003212 if (state->RF_IN >= 640000000 && state->RF_IN <= 900000000)
Steven Toth52c99bd2008-05-01 04:57:01 -03003213 {
Steven Toth3935c252008-05-01 05:45:44 -03003214 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 1) ; // Bank4 On
3215 status += MXL_SetGPIO(fe, 4, 1) ; // Bank1 Off
3216 status += MXL_SetGPIO(fe, 1, 1) ; // Bank2 Off
3217 status += MXL_SetGPIO(fe, 3, 1) ; // Bank3 Off
Steven Toth52c99bd2008-05-01 04:57:01 -03003218 }
3219 }
3220
3221
Steven Toth85d220d2008-05-01 05:48:14 -03003222 if (state->TF_Type == MXL_TF_D_L) // Tracking Filter type D-L for Lumanate ONLY change for 2.6.3
Steven Toth52c99bd2008-05-01 04:57:01 -03003223 {
Steven Toth3935c252008-05-01 05:45:44 -03003224 status += MXL_ControlWrite(fe, DAC_DIN_A, 0) ;
Steven Toth52c99bd2008-05-01 04:57:01 -03003225
Steven Totha8214d42008-05-01 05:02:58 -03003226 // if UHF and terrestrial => Turn off Tracking Filter
Steven Toth3935c252008-05-01 05:45:44 -03003227 if (state->RF_IN >= 471000000 && (state->RF_IN - 471000000)%6000000 != 0)
Steven Toth52c99bd2008-05-01 04:57:01 -03003228 {
3229 // Turn off all the banks
Steven Toth3935c252008-05-01 05:45:44 -03003230 status += MXL_SetGPIO(fe, 3, 1) ;
3231 status += MXL_SetGPIO(fe, 1, 1) ;
3232 status += MXL_SetGPIO(fe, 4, 1) ;
3233 status += MXL_ControlWrite(fe, DAC_A_ENABLE, 0) ;
Steven Toth52c99bd2008-05-01 04:57:01 -03003234
Steven Toth3935c252008-05-01 05:45:44 -03003235 status += MXL_ControlWrite(fe, AGC_IF, 10) ;
Steven Toth52c99bd2008-05-01 04:57:01 -03003236 }
3237
3238 else // if VHF or cable => Turn on Tracking Filter
3239 {
Steven Toth3935c252008-05-01 05:45:44 -03003240 if (state->RF_IN >= 43000000 && state->RF_IN < 140000000)
Steven Toth52c99bd2008-05-01 04:57:01 -03003241 {
3242
Steven Toth3935c252008-05-01 05:45:44 -03003243 status += MXL_ControlWrite(fe, DAC_A_ENABLE, 0) ; // Bank4 Off
3244 status += MXL_SetGPIO(fe, 4, 1) ; // Bank1 On
3245 status += MXL_SetGPIO(fe, 1, 1) ; // Bank2 Off
3246 status += MXL_SetGPIO(fe, 3, 0) ; // Bank3 Off
Steven Toth52c99bd2008-05-01 04:57:01 -03003247 }
Steven Toth3935c252008-05-01 05:45:44 -03003248 if (state->RF_IN >= 140000000 && state->RF_IN < 240000000)
Steven Toth52c99bd2008-05-01 04:57:01 -03003249 {
Steven Toth3935c252008-05-01 05:45:44 -03003250 status += MXL_ControlWrite(fe, DAC_A_ENABLE, 0) ; // Bank4 Off
3251 status += MXL_SetGPIO(fe, 4, 1) ; // Bank1 On
3252 status += MXL_SetGPIO(fe, 1, 0) ; // Bank2 On
3253 status += MXL_SetGPIO(fe, 3, 0) ; // Bank3 Off
Steven Toth52c99bd2008-05-01 04:57:01 -03003254 }
Steven Toth3935c252008-05-01 05:45:44 -03003255 if (state->RF_IN >= 240000000 && state->RF_IN < 340000000)
Steven Toth52c99bd2008-05-01 04:57:01 -03003256 {
Steven Toth3935c252008-05-01 05:45:44 -03003257 status += MXL_ControlWrite(fe, DAC_A_ENABLE, 0) ; // Bank4 Off
3258 status += MXL_SetGPIO(fe, 4, 0) ; // Bank1 Off
3259 status += MXL_SetGPIO(fe, 1, 1) ; // Bank2 On
3260 status += MXL_SetGPIO(fe, 3, 0) ; // Bank3 Off
Steven Toth52c99bd2008-05-01 04:57:01 -03003261 }
Steven Toth3935c252008-05-01 05:45:44 -03003262 if (state->RF_IN >= 340000000 && state->RF_IN < 430000000)
Steven Toth52c99bd2008-05-01 04:57:01 -03003263 {
Steven Toth3935c252008-05-01 05:45:44 -03003264 status += MXL_ControlWrite(fe, DAC_A_ENABLE, 0) ; // Bank4 Off
3265 status += MXL_SetGPIO(fe, 4, 0) ; // Bank1 Off
3266 status += MXL_SetGPIO(fe, 1, 0) ; // Bank2 On
3267 status += MXL_SetGPIO(fe, 3, 1) ; // Bank3 On
Steven Toth52c99bd2008-05-01 04:57:01 -03003268 }
Steven Toth3935c252008-05-01 05:45:44 -03003269 if (state->RF_IN >= 430000000 && state->RF_IN < 470000000)
Steven Toth52c99bd2008-05-01 04:57:01 -03003270 {
Steven Toth3935c252008-05-01 05:45:44 -03003271 status += MXL_ControlWrite(fe, DAC_A_ENABLE, 1) ; // Bank4 Off
3272 status += MXL_SetGPIO(fe, 4, 1) ; // Bank1 Off
3273 status += MXL_SetGPIO(fe, 1, 0) ; // Bank2 Off
3274 status += MXL_SetGPIO(fe, 3, 1) ; // Bank3 On
Steven Toth52c99bd2008-05-01 04:57:01 -03003275 }
Steven Toth3935c252008-05-01 05:45:44 -03003276 if (state->RF_IN >= 470000000 && state->RF_IN < 570000000)
Steven Toth52c99bd2008-05-01 04:57:01 -03003277 {
Steven Toth3935c252008-05-01 05:45:44 -03003278 status += MXL_ControlWrite(fe, DAC_A_ENABLE, 1) ; // Bank4 On
3279 status += MXL_SetGPIO(fe, 4, 0) ; // Bank1 Off
3280 status += MXL_SetGPIO(fe, 1, 0) ; // Bank2 Off
3281 status += MXL_SetGPIO(fe, 3, 1) ; // Bank3 On
Steven Toth52c99bd2008-05-01 04:57:01 -03003282 }
Steven Toth3935c252008-05-01 05:45:44 -03003283 if (state->RF_IN >= 570000000 && state->RF_IN < 620000000)
Steven Toth52c99bd2008-05-01 04:57:01 -03003284 {
Steven Toth3935c252008-05-01 05:45:44 -03003285 status += MXL_ControlWrite(fe, DAC_A_ENABLE, 0) ; // Bank4 On
3286 status += MXL_SetGPIO(fe, 4, 0) ; // Bank1 Off
3287 status += MXL_SetGPIO(fe, 1, 1) ; // Bank2 Off
3288 status += MXL_SetGPIO(fe, 3, 1) ; // Bank3 Offq
Steven Toth52c99bd2008-05-01 04:57:01 -03003289 }
Steven Toth3935c252008-05-01 05:45:44 -03003290 if (state->RF_IN >= 620000000 && state->RF_IN < 760000000)
Steven Toth52c99bd2008-05-01 04:57:01 -03003291 {
Steven Toth3935c252008-05-01 05:45:44 -03003292 status += MXL_ControlWrite(fe, DAC_A_ENABLE, 1) ; // Bank4 On
3293 status += MXL_SetGPIO(fe, 4, 0) ; // Bank1 Off
3294 status += MXL_SetGPIO(fe, 1, 1) ; // Bank2 Off
3295 status += MXL_SetGPIO(fe, 3, 1) ; // Bank3 Off
Steven Toth52c99bd2008-05-01 04:57:01 -03003296 }
Steven Toth3935c252008-05-01 05:45:44 -03003297 if (state->RF_IN >= 760000000 && state->RF_IN <= 900000000)
Steven Toth52c99bd2008-05-01 04:57:01 -03003298 {
Steven Toth3935c252008-05-01 05:45:44 -03003299 status += MXL_ControlWrite(fe, DAC_A_ENABLE, 1) ; // Bank4 On
3300 status += MXL_SetGPIO(fe, 4, 1) ; // Bank1 Off
3301 status += MXL_SetGPIO(fe, 1, 1) ; // Bank2 Off
3302 status += MXL_SetGPIO(fe, 3, 1) ; // Bank3 Off
Steven Toth52c99bd2008-05-01 04:57:01 -03003303 }
3304 }
3305 }
3306
Steven Toth85d220d2008-05-01 05:48:14 -03003307 if (state->TF_Type == MXL_TF_E) // Tracking Filter type E
Steven Toth52c99bd2008-05-01 04:57:01 -03003308 {
Steven Toth3935c252008-05-01 05:45:44 -03003309 status += MXL_ControlWrite(fe, DAC_DIN_B, 0) ;
Steven Toth52c99bd2008-05-01 04:57:01 -03003310
Steven Toth3935c252008-05-01 05:45:44 -03003311 if (state->RF_IN >= 43000000 && state->RF_IN < 174000000)
Steven Toth52c99bd2008-05-01 04:57:01 -03003312 {
3313
Steven Toth3935c252008-05-01 05:45:44 -03003314 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0) ; // Bank4 Off
3315 status += MXL_SetGPIO(fe, 4, 0) ; // Bank1 On
3316 status += MXL_SetGPIO(fe, 1, 1) ; // Bank2 Off
3317 status += MXL_SetGPIO(fe, 3, 1) ; // Bank3 Off
Steven Toth52c99bd2008-05-01 04:57:01 -03003318 }
Steven Toth3935c252008-05-01 05:45:44 -03003319 if (state->RF_IN >= 174000000 && state->RF_IN < 250000000)
Steven Toth52c99bd2008-05-01 04:57:01 -03003320 {
Steven Toth3935c252008-05-01 05:45:44 -03003321 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0) ; // Bank4 Off
3322 status += MXL_SetGPIO(fe, 4, 0) ; // Bank1 On
3323 status += MXL_SetGPIO(fe, 1, 0) ; // Bank2 On
3324 status += MXL_SetGPIO(fe, 3, 1) ; // Bank3 Off
Steven Toth52c99bd2008-05-01 04:57:01 -03003325 }
Steven Toth3935c252008-05-01 05:45:44 -03003326 if (state->RF_IN >= 250000000 && state->RF_IN < 310000000)
Steven Toth52c99bd2008-05-01 04:57:01 -03003327 {
Steven Toth3935c252008-05-01 05:45:44 -03003328 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0) ; // Bank4 Off
3329 status += MXL_SetGPIO(fe, 4, 1) ; // Bank1 Off
3330 status += MXL_SetGPIO(fe, 1, 0) ; // Bank2 On
3331 status += MXL_SetGPIO(fe, 3, 1) ; // Bank3 Off
Steven Toth52c99bd2008-05-01 04:57:01 -03003332 }
Steven Toth3935c252008-05-01 05:45:44 -03003333 if (state->RF_IN >= 310000000 && state->RF_IN < 360000000)
Steven Toth52c99bd2008-05-01 04:57:01 -03003334 {
Steven Toth3935c252008-05-01 05:45:44 -03003335 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0) ; // Bank4 Off
3336 status += MXL_SetGPIO(fe, 4, 1) ; // Bank1 Off
3337 status += MXL_SetGPIO(fe, 1, 0) ; // Bank2 On
3338 status += MXL_SetGPIO(fe, 3, 0) ; // Bank3 On
Steven Toth52c99bd2008-05-01 04:57:01 -03003339 }
Steven Toth3935c252008-05-01 05:45:44 -03003340 if (state->RF_IN >= 360000000 && state->RF_IN < 470000000)
Steven Toth52c99bd2008-05-01 04:57:01 -03003341 {
Steven Toth3935c252008-05-01 05:45:44 -03003342 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0) ; // Bank4 Off
3343 status += MXL_SetGPIO(fe, 4, 1) ; // Bank1 Off
3344 status += MXL_SetGPIO(fe, 1, 1) ; // Bank2 Off
3345 status += MXL_SetGPIO(fe, 3, 0) ; // Bank3 On
Steven Toth52c99bd2008-05-01 04:57:01 -03003346 }
Steven Toth3935c252008-05-01 05:45:44 -03003347 if (state->RF_IN >= 470000000 && state->RF_IN < 640000000)
Steven Toth52c99bd2008-05-01 04:57:01 -03003348 {
Steven Toth3935c252008-05-01 05:45:44 -03003349 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 1) ; // Bank4 On
3350 status += MXL_SetGPIO(fe, 4, 1) ; // Bank1 Off
3351 status += MXL_SetGPIO(fe, 1, 1) ; // Bank2 Off
3352 status += MXL_SetGPIO(fe, 3, 0) ; // Bank3 On
Steven Toth52c99bd2008-05-01 04:57:01 -03003353 }
Steven Toth3935c252008-05-01 05:45:44 -03003354 if (state->RF_IN >= 640000000 && state->RF_IN <= 900000000)
Steven Toth52c99bd2008-05-01 04:57:01 -03003355 {
Steven Toth3935c252008-05-01 05:45:44 -03003356 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 1) ; // Bank4 On
3357 status += MXL_SetGPIO(fe, 4, 1) ; // Bank1 Off
3358 status += MXL_SetGPIO(fe, 1, 1) ; // Bank2 Off
3359 status += MXL_SetGPIO(fe, 3, 1) ; // Bank3 Off
Steven Toth52c99bd2008-05-01 04:57:01 -03003360 }
3361 }
3362
Steven Toth85d220d2008-05-01 05:48:14 -03003363 if (state->TF_Type == MXL_TF_F) // Tracking Filter type F
Steven Toth52c99bd2008-05-01 04:57:01 -03003364 {
Steven Toth3935c252008-05-01 05:45:44 -03003365 status += MXL_ControlWrite(fe, DAC_DIN_B, 0) ;
Steven Toth52c99bd2008-05-01 04:57:01 -03003366
Steven Toth3935c252008-05-01 05:45:44 -03003367 if (state->RF_IN >= 43000000 && state->RF_IN < 160000000)
Steven Toth52c99bd2008-05-01 04:57:01 -03003368 {
3369
Steven Toth3935c252008-05-01 05:45:44 -03003370 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0) ; // Bank4 Off
3371 status += MXL_SetGPIO(fe, 4, 0) ; // Bank1 On
3372 status += MXL_SetGPIO(fe, 1, 1) ; // Bank2 Off
3373 status += MXL_SetGPIO(fe, 3, 1) ; // Bank3 Off
Steven Toth52c99bd2008-05-01 04:57:01 -03003374 }
Steven Toth3935c252008-05-01 05:45:44 -03003375 if (state->RF_IN >= 160000000 && state->RF_IN < 210000000)
Steven Toth52c99bd2008-05-01 04:57:01 -03003376 {
Steven Toth3935c252008-05-01 05:45:44 -03003377 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0) ; // Bank4 Off
3378 status += MXL_SetGPIO(fe, 4, 0) ; // Bank1 On
3379 status += MXL_SetGPIO(fe, 1, 0) ; // Bank2 On
3380 status += MXL_SetGPIO(fe, 3, 1) ; // Bank3 Off
Steven Toth52c99bd2008-05-01 04:57:01 -03003381 }
Steven Toth3935c252008-05-01 05:45:44 -03003382 if (state->RF_IN >= 210000000 && state->RF_IN < 300000000)
Steven Toth52c99bd2008-05-01 04:57:01 -03003383 {
Steven Toth3935c252008-05-01 05:45:44 -03003384 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0) ; // Bank4 Off
3385 status += MXL_SetGPIO(fe, 4, 1) ; // Bank1 Off
3386 status += MXL_SetGPIO(fe, 1, 0) ; // Bank2 On
3387 status += MXL_SetGPIO(fe, 3, 1) ; // Bank3 Off
Steven Toth52c99bd2008-05-01 04:57:01 -03003388 }
Steven Toth3935c252008-05-01 05:45:44 -03003389 if (state->RF_IN >= 300000000 && state->RF_IN < 390000000)
Steven Toth52c99bd2008-05-01 04:57:01 -03003390 {
Steven Toth3935c252008-05-01 05:45:44 -03003391 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0) ; // Bank4 Off
3392 status += MXL_SetGPIO(fe, 4, 1) ; // Bank1 Off
3393 status += MXL_SetGPIO(fe, 1, 0) ; // Bank2 On
3394 status += MXL_SetGPIO(fe, 3, 0) ; // Bank3 On
Steven Toth52c99bd2008-05-01 04:57:01 -03003395 }
Steven Toth3935c252008-05-01 05:45:44 -03003396 if (state->RF_IN >= 390000000 && state->RF_IN < 515000000)
Steven Toth52c99bd2008-05-01 04:57:01 -03003397 {
Steven Toth3935c252008-05-01 05:45:44 -03003398 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0) ; // Bank4 Off
3399 status += MXL_SetGPIO(fe, 4, 1) ; // Bank1 Off
3400 status += MXL_SetGPIO(fe, 1, 1) ; // Bank2 Off
3401 status += MXL_SetGPIO(fe, 3, 0) ; // Bank3 On
Steven Toth52c99bd2008-05-01 04:57:01 -03003402 }
Steven Toth3935c252008-05-01 05:45:44 -03003403 if (state->RF_IN >= 515000000 && state->RF_IN < 650000000)
Steven Toth52c99bd2008-05-01 04:57:01 -03003404 {
Steven Toth3935c252008-05-01 05:45:44 -03003405 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 1) ; // Bank4 On
3406 status += MXL_SetGPIO(fe, 4, 1) ; // Bank1 Off
3407 status += MXL_SetGPIO(fe, 1, 1) ; // Bank2 Off
3408 status += MXL_SetGPIO(fe, 3, 0) ; // Bank3 On
Steven Toth52c99bd2008-05-01 04:57:01 -03003409 }
Steven Toth3935c252008-05-01 05:45:44 -03003410 if (state->RF_IN >= 650000000 && state->RF_IN <= 900000000)
Steven Toth52c99bd2008-05-01 04:57:01 -03003411 {
Steven Toth3935c252008-05-01 05:45:44 -03003412 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 1) ; // Bank4 On
3413 status += MXL_SetGPIO(fe, 4, 1) ; // Bank1 Off
3414 status += MXL_SetGPIO(fe, 1, 1) ; // Bank2 Off
3415 status += MXL_SetGPIO(fe, 3, 1) ; // Bank3 Off
Steven Toth52c99bd2008-05-01 04:57:01 -03003416 }
3417 }
3418
Steven Toth85d220d2008-05-01 05:48:14 -03003419 if (state->TF_Type == MXL_TF_E_2) // Tracking Filter type E_2
Steven Toth52c99bd2008-05-01 04:57:01 -03003420 {
Steven Toth3935c252008-05-01 05:45:44 -03003421 status += MXL_ControlWrite(fe, DAC_DIN_B, 0) ;
Steven Toth52c99bd2008-05-01 04:57:01 -03003422
Steven Toth3935c252008-05-01 05:45:44 -03003423 if (state->RF_IN >= 43000000 && state->RF_IN < 174000000)
Steven Toth52c99bd2008-05-01 04:57:01 -03003424 {
3425
Steven Toth3935c252008-05-01 05:45:44 -03003426 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0) ; // Bank4 Off
3427 status += MXL_SetGPIO(fe, 4, 0) ; // Bank1 On
3428 status += MXL_SetGPIO(fe, 1, 1) ; // Bank2 Off
3429 status += MXL_SetGPIO(fe, 3, 1) ; // Bank3 Off
Steven Toth52c99bd2008-05-01 04:57:01 -03003430 }
Steven Toth3935c252008-05-01 05:45:44 -03003431 if (state->RF_IN >= 174000000 && state->RF_IN < 250000000)
Steven Toth52c99bd2008-05-01 04:57:01 -03003432 {
Steven Toth3935c252008-05-01 05:45:44 -03003433 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0) ; // Bank4 Off
3434 status += MXL_SetGPIO(fe, 4, 0) ; // Bank1 On
3435 status += MXL_SetGPIO(fe, 1, 0) ; // Bank2 On
3436 status += MXL_SetGPIO(fe, 3, 1) ; // Bank3 Off
Steven Toth52c99bd2008-05-01 04:57:01 -03003437 }
Steven Toth3935c252008-05-01 05:45:44 -03003438 if (state->RF_IN >= 250000000 && state->RF_IN < 350000000)
Steven Toth52c99bd2008-05-01 04:57:01 -03003439 {
Steven Toth3935c252008-05-01 05:45:44 -03003440 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0) ; // Bank4 Off
3441 status += MXL_SetGPIO(fe, 4, 1) ; // Bank1 Off
3442 status += MXL_SetGPIO(fe, 1, 0) ; // Bank2 On
3443 status += MXL_SetGPIO(fe, 3, 1) ; // Bank3 Off
Steven Toth52c99bd2008-05-01 04:57:01 -03003444 }
Steven Toth3935c252008-05-01 05:45:44 -03003445 if (state->RF_IN >= 350000000 && state->RF_IN < 400000000)
Steven Toth52c99bd2008-05-01 04:57:01 -03003446 {
Steven Toth3935c252008-05-01 05:45:44 -03003447 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0) ; // Bank4 Off
3448 status += MXL_SetGPIO(fe, 4, 1) ; // Bank1 Off
3449 status += MXL_SetGPIO(fe, 1, 0) ; // Bank2 On
3450 status += MXL_SetGPIO(fe, 3, 0) ; // Bank3 On
Steven Toth52c99bd2008-05-01 04:57:01 -03003451 }
Steven Toth3935c252008-05-01 05:45:44 -03003452 if (state->RF_IN >= 400000000 && state->RF_IN < 570000000)
Steven Toth52c99bd2008-05-01 04:57:01 -03003453 {
Steven Toth3935c252008-05-01 05:45:44 -03003454 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0) ; // Bank4 Off
3455 status += MXL_SetGPIO(fe, 4, 1) ; // Bank1 Off
3456 status += MXL_SetGPIO(fe, 1, 1) ; // Bank2 Off
3457 status += MXL_SetGPIO(fe, 3, 0) ; // Bank3 On
Steven Toth52c99bd2008-05-01 04:57:01 -03003458 }
Steven Toth3935c252008-05-01 05:45:44 -03003459 if (state->RF_IN >= 570000000 && state->RF_IN < 770000000)
Steven Toth52c99bd2008-05-01 04:57:01 -03003460 {
Steven Toth3935c252008-05-01 05:45:44 -03003461 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 1) ; // Bank4 On
3462 status += MXL_SetGPIO(fe, 4, 1) ; // Bank1 Off
3463 status += MXL_SetGPIO(fe, 1, 1) ; // Bank2 Off
3464 status += MXL_SetGPIO(fe, 3, 0) ; // Bank3 On
Steven Toth52c99bd2008-05-01 04:57:01 -03003465 }
Steven Toth3935c252008-05-01 05:45:44 -03003466 if (state->RF_IN >= 770000000 && state->RF_IN <= 900000000)
Steven Toth52c99bd2008-05-01 04:57:01 -03003467 {
Steven Toth3935c252008-05-01 05:45:44 -03003468 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 1) ; // Bank4 On
3469 status += MXL_SetGPIO(fe, 4, 1) ; // Bank1 Off
3470 status += MXL_SetGPIO(fe, 1, 1) ; // Bank2 Off
3471 status += MXL_SetGPIO(fe, 3, 1) ; // Bank3 Off
Steven Toth52c99bd2008-05-01 04:57:01 -03003472 }
3473 }
3474
Steven Toth85d220d2008-05-01 05:48:14 -03003475 if (state->TF_Type == MXL_TF_G) // Tracking Filter type G add for v2.6.8
Steven Toth52c99bd2008-05-01 04:57:01 -03003476 {
Steven Toth3935c252008-05-01 05:45:44 -03003477 status += MXL_ControlWrite(fe, DAC_DIN_B, 0) ;
Steven Toth52c99bd2008-05-01 04:57:01 -03003478
Steven Toth3935c252008-05-01 05:45:44 -03003479 if (state->RF_IN >= 50000000 && state->RF_IN < 190000000)
Steven Toth52c99bd2008-05-01 04:57:01 -03003480 {
3481
Steven Toth3935c252008-05-01 05:45:44 -03003482 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0) ; // Bank4 Off
3483 status += MXL_SetGPIO(fe, 4, 0) ; // Bank1 On
3484 status += MXL_SetGPIO(fe, 1, 1) ; // Bank2 Off
3485 status += MXL_SetGPIO(fe, 3, 1) ; // Bank3 Off
Steven Toth52c99bd2008-05-01 04:57:01 -03003486 }
Steven Toth3935c252008-05-01 05:45:44 -03003487 if (state->RF_IN >= 190000000 && state->RF_IN < 280000000)
Steven Toth52c99bd2008-05-01 04:57:01 -03003488 {
Steven Toth3935c252008-05-01 05:45:44 -03003489 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0) ; // Bank4 Off
3490 status += MXL_SetGPIO(fe, 4, 0) ; // Bank1 On
3491 status += MXL_SetGPIO(fe, 1, 0) ; // Bank2 On
3492 status += MXL_SetGPIO(fe, 3, 1) ; // Bank3 Off
Steven Toth52c99bd2008-05-01 04:57:01 -03003493 }
Steven Toth3935c252008-05-01 05:45:44 -03003494 if (state->RF_IN >= 280000000 && state->RF_IN < 350000000)
Steven Toth52c99bd2008-05-01 04:57:01 -03003495 {
Steven Toth3935c252008-05-01 05:45:44 -03003496 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0) ; // Bank4 Off
3497 status += MXL_SetGPIO(fe, 4, 1) ; // Bank1 Off
3498 status += MXL_SetGPIO(fe, 1, 0) ; // Bank2 On
3499 status += MXL_SetGPIO(fe, 3, 1) ; // Bank3 Off
Steven Toth52c99bd2008-05-01 04:57:01 -03003500 }
Steven Toth3935c252008-05-01 05:45:44 -03003501 if (state->RF_IN >= 350000000 && state->RF_IN < 400000000)
Steven Toth52c99bd2008-05-01 04:57:01 -03003502 {
Steven Toth3935c252008-05-01 05:45:44 -03003503 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0) ; // Bank4 Off
3504 status += MXL_SetGPIO(fe, 4, 1) ; // Bank1 Off
3505 status += MXL_SetGPIO(fe, 1, 0) ; // Bank2 On
3506 status += MXL_SetGPIO(fe, 3, 0) ; // Bank3 On
Steven Toth52c99bd2008-05-01 04:57:01 -03003507 }
Steven Toth3935c252008-05-01 05:45:44 -03003508 if (state->RF_IN >= 400000000 && state->RF_IN < 470000000) //modified for 2.6.11
Steven Toth52c99bd2008-05-01 04:57:01 -03003509 {
Steven Toth3935c252008-05-01 05:45:44 -03003510 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 1) ; // Bank4 On
3511 status += MXL_SetGPIO(fe, 4, 1) ; // Bank1 On
3512 status += MXL_SetGPIO(fe, 1, 0) ; // Bank2 Off
3513 status += MXL_SetGPIO(fe, 3, 1) ; // Bank3 Off
Steven Toth52c99bd2008-05-01 04:57:01 -03003514 }
Steven Toth3935c252008-05-01 05:45:44 -03003515 if (state->RF_IN >= 470000000 && state->RF_IN < 640000000)
Steven Toth52c99bd2008-05-01 04:57:01 -03003516 {
Steven Toth3935c252008-05-01 05:45:44 -03003517 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0) ; // Bank4 Off
3518 status += MXL_SetGPIO(fe, 4, 1) ; // Bank1 Off
3519 status += MXL_SetGPIO(fe, 1, 1) ; // Bank2 Off
3520 status += MXL_SetGPIO(fe, 3, 0) ; // Bank3 On
Steven Toth52c99bd2008-05-01 04:57:01 -03003521 }
Steven Toth3935c252008-05-01 05:45:44 -03003522 if (state->RF_IN >= 640000000 && state->RF_IN < 820000000)
Steven Toth52c99bd2008-05-01 04:57:01 -03003523 {
Steven Toth3935c252008-05-01 05:45:44 -03003524 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 1) ; // Bank4 On
3525 status += MXL_SetGPIO(fe, 4, 1) ; // Bank1 Off
3526 status += MXL_SetGPIO(fe, 1, 1) ; // Bank2 Off
3527 status += MXL_SetGPIO(fe, 3, 0) ; // Bank3 On
Steven Toth52c99bd2008-05-01 04:57:01 -03003528 }
Steven Toth3935c252008-05-01 05:45:44 -03003529 if (state->RF_IN >= 820000000 && state->RF_IN <= 900000000)
Steven Toth52c99bd2008-05-01 04:57:01 -03003530 {
Steven Toth3935c252008-05-01 05:45:44 -03003531 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 1) ; // Bank4 On
3532 status += MXL_SetGPIO(fe, 4, 1) ; // Bank1 Off
3533 status += MXL_SetGPIO(fe, 1, 1) ; // Bank2 Off
3534 status += MXL_SetGPIO(fe, 3, 1) ; // Bank3 Off
Steven Toth52c99bd2008-05-01 04:57:01 -03003535 }
3536 }
3537
Steven Toth85d220d2008-05-01 05:48:14 -03003538 if (state->TF_Type == MXL_TF_E_NA) // Tracking Filter type E-NA for Empia ONLY change for 2.6.8
Steven Toth52c99bd2008-05-01 04:57:01 -03003539 {
Steven Toth3935c252008-05-01 05:45:44 -03003540 status += MXL_ControlWrite(fe, DAC_DIN_B, 0) ;
Steven Toth52c99bd2008-05-01 04:57:01 -03003541
Steven Totha8214d42008-05-01 05:02:58 -03003542 // if UHF and terrestrial=> Turn off Tracking Filter
Steven Toth3935c252008-05-01 05:45:44 -03003543 if (state->RF_IN >= 471000000 && (state->RF_IN - 471000000)%6000000 != 0)
Steven Toth52c99bd2008-05-01 04:57:01 -03003544 {
3545 // Turn off all the banks
Steven Toth3935c252008-05-01 05:45:44 -03003546 status += MXL_SetGPIO(fe, 3, 1) ;
3547 status += MXL_SetGPIO(fe, 1, 1) ;
3548 status += MXL_SetGPIO(fe, 4, 1) ;
3549 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0) ;
Steven Toth52c99bd2008-05-01 04:57:01 -03003550
3551 //2.6.12
3552 //Turn on RSSI
Steven Toth3935c252008-05-01 05:45:44 -03003553 status += MXL_ControlWrite(fe, SEQ_EXTSYNTHCALIF, 1) ;
3554 status += MXL_ControlWrite(fe, SEQ_EXTDCCAL, 1) ;
3555 status += MXL_ControlWrite(fe, AGC_EN_RSSI, 1) ;
3556 status += MXL_ControlWrite(fe, RFA_ENCLKRFAGC, 1) ;
Steven Toth52c99bd2008-05-01 04:57:01 -03003557
3558 // RSSI reference point
Steven Toth3935c252008-05-01 05:45:44 -03003559 status += MXL_ControlWrite(fe, RFA_RSSI_REFH, 5) ;
3560 status += MXL_ControlWrite(fe, RFA_RSSI_REF, 3) ;
3561 status += MXL_ControlWrite(fe, RFA_RSSI_REFL, 2) ;
Steven Toth52c99bd2008-05-01 04:57:01 -03003562
3563
Steven Toth3935c252008-05-01 05:45:44 -03003564 //status += MXL_ControlWrite(fe, AGC_IF, 10) ; //doesn't matter since RSSI is turn on
Steven Toth52c99bd2008-05-01 04:57:01 -03003565
3566 //following parameter is from analog OTA mode, can be change to seek better performance
Steven Toth3935c252008-05-01 05:45:44 -03003567 status += MXL_ControlWrite(fe, RFSYN_CHP_GAIN, 3) ;
Steven Toth52c99bd2008-05-01 04:57:01 -03003568 }
3569
3570 else //if VHF or Cable => Turn on Tracking Filter
3571 {
3572 //2.6.12
3573 //Turn off RSSI
Steven Toth3935c252008-05-01 05:45:44 -03003574 status += MXL_ControlWrite(fe, AGC_EN_RSSI, 0) ;
Steven Toth52c99bd2008-05-01 04:57:01 -03003575
3576 //change back from above condition
Steven Toth3935c252008-05-01 05:45:44 -03003577 status += MXL_ControlWrite(fe, RFSYN_CHP_GAIN, 5) ;
Steven Toth52c99bd2008-05-01 04:57:01 -03003578
3579
Steven Toth3935c252008-05-01 05:45:44 -03003580 if (state->RF_IN >= 43000000 && state->RF_IN < 174000000)
Steven Toth52c99bd2008-05-01 04:57:01 -03003581 {
3582
Steven Toth3935c252008-05-01 05:45:44 -03003583 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0) ; // Bank4 Off
3584 status += MXL_SetGPIO(fe, 4, 0) ; // Bank1 On
3585 status += MXL_SetGPIO(fe, 1, 1) ; // Bank2 Off
3586 status += MXL_SetGPIO(fe, 3, 1) ; // Bank3 Off
Steven Toth52c99bd2008-05-01 04:57:01 -03003587 }
Steven Toth3935c252008-05-01 05:45:44 -03003588 if (state->RF_IN >= 174000000 && state->RF_IN < 250000000)
Steven Toth52c99bd2008-05-01 04:57:01 -03003589 {
Steven Toth3935c252008-05-01 05:45:44 -03003590 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0) ; // Bank4 Off
3591 status += MXL_SetGPIO(fe, 4, 0) ; // Bank1 On
3592 status += MXL_SetGPIO(fe, 1, 0) ; // Bank2 On
3593 status += MXL_SetGPIO(fe, 3, 1) ; // Bank3 Off
Steven Toth52c99bd2008-05-01 04:57:01 -03003594 }
Steven Toth3935c252008-05-01 05:45:44 -03003595 if (state->RF_IN >= 250000000 && state->RF_IN < 350000000)
Steven Toth52c99bd2008-05-01 04:57:01 -03003596 {
Steven Toth3935c252008-05-01 05:45:44 -03003597 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0) ; // Bank4 Off
3598 status += MXL_SetGPIO(fe, 4, 1) ; // Bank1 Off
3599 status += MXL_SetGPIO(fe, 1, 0) ; // Bank2 On
3600 status += MXL_SetGPIO(fe, 3, 1) ; // Bank3 Off
Steven Toth52c99bd2008-05-01 04:57:01 -03003601 }
Steven Toth3935c252008-05-01 05:45:44 -03003602 if (state->RF_IN >= 350000000 && state->RF_IN < 400000000)
Steven Toth52c99bd2008-05-01 04:57:01 -03003603 {
Steven Toth3935c252008-05-01 05:45:44 -03003604 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0) ; // Bank4 Off
3605 status += MXL_SetGPIO(fe, 4, 1) ; // Bank1 Off
3606 status += MXL_SetGPIO(fe, 1, 0) ; // Bank2 On
3607 status += MXL_SetGPIO(fe, 3, 0) ; // Bank3 On
Steven Toth52c99bd2008-05-01 04:57:01 -03003608 }
Steven Toth3935c252008-05-01 05:45:44 -03003609 if (state->RF_IN >= 400000000 && state->RF_IN < 570000000)
Steven Toth52c99bd2008-05-01 04:57:01 -03003610 {
Steven Toth3935c252008-05-01 05:45:44 -03003611 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0) ; // Bank4 Off
3612 status += MXL_SetGPIO(fe, 4, 1) ; // Bank1 Off
3613 status += MXL_SetGPIO(fe, 1, 1) ; // Bank2 Off
3614 status += MXL_SetGPIO(fe, 3, 0) ; // Bank3 On
Steven Toth52c99bd2008-05-01 04:57:01 -03003615 }
Steven Toth3935c252008-05-01 05:45:44 -03003616 if (state->RF_IN >= 570000000 && state->RF_IN < 770000000)
Steven Toth52c99bd2008-05-01 04:57:01 -03003617 {
Steven Toth3935c252008-05-01 05:45:44 -03003618 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 1) ; // Bank4 On
3619 status += MXL_SetGPIO(fe, 4, 1) ; // Bank1 Off
3620 status += MXL_SetGPIO(fe, 1, 1) ; // Bank2 Off
3621 status += MXL_SetGPIO(fe, 3, 0) ; // Bank3 On
Steven Toth52c99bd2008-05-01 04:57:01 -03003622 }
Steven Toth3935c252008-05-01 05:45:44 -03003623 if (state->RF_IN >= 770000000 && state->RF_IN <= 900000000)
Steven Toth52c99bd2008-05-01 04:57:01 -03003624 {
Steven Toth3935c252008-05-01 05:45:44 -03003625 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 1) ; // Bank4 On
3626 status += MXL_SetGPIO(fe, 4, 1) ; // Bank1 Off
3627 status += MXL_SetGPIO(fe, 1, 1) ; // Bank2 Off
3628 status += MXL_SetGPIO(fe, 3, 1) ; // Bank3 Off
Steven Toth52c99bd2008-05-01 04:57:01 -03003629 }
3630 }
3631 }
3632 return status ;
3633}
3634
Steven Toth3935c252008-05-01 05:45:44 -03003635u16 MXL_SetGPIO(struct dvb_frontend *fe, u8 GPIO_Num, u8 GPIO_Val)
Steven Toth52c99bd2008-05-01 04:57:01 -03003636{
Steven Toth3935c252008-05-01 05:45:44 -03003637 u16 status = 0;
Steven Toth52c99bd2008-05-01 04:57:01 -03003638
3639 if (GPIO_Num == 1)
Steven Toth3935c252008-05-01 05:45:44 -03003640 status += MXL_ControlWrite(fe, GPIO_1B, GPIO_Val ? 0 : 1);
3641
3642 /* GPIO2 is not available */
3643
3644 if (GPIO_Num == 3) {
Steven Toth52c99bd2008-05-01 04:57:01 -03003645 if (GPIO_Val == 1) {
Steven Toth3935c252008-05-01 05:45:44 -03003646 status += MXL_ControlWrite(fe, GPIO_3, 0);
3647 status += MXL_ControlWrite(fe, GPIO_3B, 0);
Steven Toth52c99bd2008-05-01 04:57:01 -03003648 }
3649 if (GPIO_Val == 0) {
Steven Toth3935c252008-05-01 05:45:44 -03003650 status += MXL_ControlWrite(fe, GPIO_3, 1);
3651 status += MXL_ControlWrite(fe, GPIO_3B, 1);
Steven Toth52c99bd2008-05-01 04:57:01 -03003652 }
Steven Toth3935c252008-05-01 05:45:44 -03003653 if (GPIO_Val == 3) { /* tri-state */
3654 status += MXL_ControlWrite(fe, GPIO_3, 0);
3655 status += MXL_ControlWrite(fe, GPIO_3B, 1);
Steven Toth52c99bd2008-05-01 04:57:01 -03003656 }
3657 }
Steven Toth3935c252008-05-01 05:45:44 -03003658 if (GPIO_Num == 4) {
Steven Toth52c99bd2008-05-01 04:57:01 -03003659 if (GPIO_Val == 1) {
Steven Toth3935c252008-05-01 05:45:44 -03003660 status += MXL_ControlWrite(fe, GPIO_4, 0);
3661 status += MXL_ControlWrite(fe, GPIO_4B, 0);
Steven Toth52c99bd2008-05-01 04:57:01 -03003662 }
3663 if (GPIO_Val == 0) {
Steven Toth3935c252008-05-01 05:45:44 -03003664 status += MXL_ControlWrite(fe, GPIO_4, 1);
3665 status += MXL_ControlWrite(fe, GPIO_4B, 1);
Steven Toth52c99bd2008-05-01 04:57:01 -03003666 }
Steven Toth3935c252008-05-01 05:45:44 -03003667 if (GPIO_Val == 3) { /* tri-state */
3668 status += MXL_ControlWrite(fe, GPIO_4, 0);
3669 status += MXL_ControlWrite(fe, GPIO_4B, 1);
Steven Toth52c99bd2008-05-01 04:57:01 -03003670 }
3671 }
3672
Steven Toth3935c252008-05-01 05:45:44 -03003673 return status;
Steven Toth52c99bd2008-05-01 04:57:01 -03003674}
3675
3676///////////////////////////////////////////////////////////////////////////////
3677// //
3678// Function: MXL_ControlWrite //
3679// //
3680// Description: Update control name value //
3681// //
3682// Globals: //
3683// NONE //
3684// //
3685// Functions used: //
3686// MXL_ControlWrite( Tuner, controlName, value, Group ) //
3687// //
3688// Inputs: //
3689// Tuner : Tuner structure //
3690// ControlName : Control name to be updated //
3691// value : Value to be written //
3692// //
3693// Outputs: //
3694// Tuner : Tuner structure defined at higher level //
3695// //
3696// Return: //
3697// 0 : Successful write //
3698// >0 : Value exceed maximum allowed for control number //
3699// //
3700///////////////////////////////////////////////////////////////////////////////
Steven Toth3935c252008-05-01 05:45:44 -03003701u16 MXL_ControlWrite(struct dvb_frontend *fe, u16 ControlNum, u32 value)
Steven Toth52c99bd2008-05-01 04:57:01 -03003702{
Steven Toth3935c252008-05-01 05:45:44 -03003703 u16 status = 0;
Steven Toth52c99bd2008-05-01 04:57:01 -03003704
Steven Toth3935c252008-05-01 05:45:44 -03003705 /* Will write ALL Matching Control Name */
Steven Toth85d220d2008-05-01 05:48:14 -03003706 status += MXL_ControlWrite_Group(fe, ControlNum, value, 1); /* Write Matching INIT Control */
3707 status += MXL_ControlWrite_Group(fe, ControlNum, value, 2); /* Write Matching CH Control */
Steven Toth3935c252008-05-01 05:45:44 -03003708#ifdef _MXL_INTERNAL
Steven Toth85d220d2008-05-01 05:48:14 -03003709 status += MXL_ControlWrite_Group(fe, ControlNum, value, 3); /* Write Matching MXL Control */
Steven Toth3935c252008-05-01 05:45:44 -03003710#endif
3711 return status;
Steven Toth52c99bd2008-05-01 04:57:01 -03003712}
3713
3714///////////////////////////////////////////////////////////////////////////////
3715// //
3716// Function: MXL_ControlWrite //
3717// //
3718// Description: Update control name value //
3719// //
3720// Globals: //
3721// NONE //
3722// //
3723// Functions used: //
3724// strcmp //
3725// //
3726// Inputs: //
3727// Tuner_struct: structure defined at higher level //
3728// ControlName : Control Name //
3729// value : Value Assigned to Control Name //
3730// controlGroup : Control Register Group //
3731// //
3732// Outputs: //
3733// NONE //
3734// //
3735// Return: //
3736// 0 : Successful write //
3737// 1 : Value exceed maximum allowed for control name //
3738// 2 : Control name not found //
3739// //
3740///////////////////////////////////////////////////////////////////////////////
Steven Toth3935c252008-05-01 05:45:44 -03003741u16 MXL_ControlWrite_Group(struct dvb_frontend *fe, u16 controlNum, u32 value, u16 controlGroup)
Steven Toth52c99bd2008-05-01 04:57:01 -03003742{
Steven Toth85d220d2008-05-01 05:48:14 -03003743 struct mxl5005s_state *state = fe->tuner_priv;
Steven Toth3935c252008-05-01 05:45:44 -03003744 u16 i, j, k;
3745 u32 highLimit;
3746 u32 ctrlVal;
Steven Toth52c99bd2008-05-01 04:57:01 -03003747
Steven Toth3935c252008-05-01 05:45:44 -03003748 if (controlGroup == 1) /* Initial Control */ {
3749
3750 for (i = 0; i < state->Init_Ctrl_Num; i++) {
3751
3752 if (controlNum == state->Init_Ctrl[i].Ctrl_Num) {
3753
3754 highLimit = 1 << state->Init_Ctrl[i].size;
3755 if (value < highLimit) {
3756 for (j = 0; j < state->Init_Ctrl[i].size; j++) {
3757 state->Init_Ctrl[i].val[j] = (u8)((value >> j) & 0x01);
3758 MXL_RegWriteBit(fe, (u8)(state->Init_Ctrl[i].addr[j]),
3759 (u8)(state->Init_Ctrl[i].bit[j]),
3760 (u8)((value>>j) & 0x01) );
Steven Toth52c99bd2008-05-01 04:57:01 -03003761 }
Steven Toth3935c252008-05-01 05:45:44 -03003762 ctrlVal = 0;
3763 for (k = 0; k < state->Init_Ctrl[i].size; k++)
3764 ctrlVal += state->Init_Ctrl[i].val[k] * (1 << k);
Steven Toth52c99bd2008-05-01 04:57:01 -03003765 }
3766 else
Steven Toth3935c252008-05-01 05:45:44 -03003767 return -1;
Steven Toth52c99bd2008-05-01 04:57:01 -03003768 }
3769 }
3770 }
Steven Toth3935c252008-05-01 05:45:44 -03003771 if (controlGroup == 2) /* Chan change Control */ {
3772
3773 for (i = 0; i < state->CH_Ctrl_Num; i++) {
3774
3775 if (controlNum == state->CH_Ctrl[i].Ctrl_Num ) {
3776
3777 highLimit = 1 << state->CH_Ctrl[i].size;
3778 if (value < highLimit) {
3779 for (j = 0; j < state->CH_Ctrl[i].size; j++) {
3780 state->CH_Ctrl[i].val[j] = (u8)((value >> j) & 0x01);
3781 MXL_RegWriteBit(fe, (u8)(state->CH_Ctrl[i].addr[j]),
3782 (u8)(state->CH_Ctrl[i].bit[j]),
3783 (u8)((value>>j) & 0x01) );
Steven Toth52c99bd2008-05-01 04:57:01 -03003784 }
Steven Toth3935c252008-05-01 05:45:44 -03003785 ctrlVal = 0;
3786 for (k = 0; k < state->CH_Ctrl[i].size; k++)
3787 ctrlVal += state->CH_Ctrl[i].val[k] * (1 << k);
Steven Toth52c99bd2008-05-01 04:57:01 -03003788 }
3789 else
Steven Toth3935c252008-05-01 05:45:44 -03003790 return -1;
Steven Toth52c99bd2008-05-01 04:57:01 -03003791 }
3792 }
3793 }
3794#ifdef _MXL_INTERNAL
Steven Toth3935c252008-05-01 05:45:44 -03003795 if (controlGroup == 3) /* Maxlinear Control */ {
3796
3797 for (i = 0; i < state->MXL_Ctrl_Num; i++) {
3798
3799 if (controlNum == state->MXL_Ctrl[i].Ctrl_Num ) {
3800
3801 highLimit = (1 << state->MXL_Ctrl[i].size) ;
3802 if (value < highLimit) {
3803 for (j = 0; j < state->MXL_Ctrl[i].size; j++) {
3804 state->MXL_Ctrl[i].val[j] = (u8)((value >> j) & 0x01);
3805 MXL_RegWriteBit(fe, (u8)(state->MXL_Ctrl[i].addr[j]),
3806 (u8)(state->MXL_Ctrl[i].bit[j]),
3807 (u8)((value>>j) & 0x01) );
Steven Toth52c99bd2008-05-01 04:57:01 -03003808 }
Steven Toth3935c252008-05-01 05:45:44 -03003809 ctrlVal = 0;
3810 for(k = 0; k < state->MXL_Ctrl[i].size; k++)
3811 ctrlVal += state->MXL_Ctrl[i].val[k] * (1 << k);
Steven Toth52c99bd2008-05-01 04:57:01 -03003812 }
3813 else
Steven Toth3935c252008-05-01 05:45:44 -03003814 return -1;
Steven Toth52c99bd2008-05-01 04:57:01 -03003815 }
3816 }
3817 }
3818#endif
Steven Toth3935c252008-05-01 05:45:44 -03003819 return 0 ; /* successful return */
Steven Toth52c99bd2008-05-01 04:57:01 -03003820}
3821
3822///////////////////////////////////////////////////////////////////////////////
3823// //
3824// Function: MXL_RegWrite //
3825// //
3826// Description: Update tuner register value //
3827// //
3828// Globals: //
3829// NONE //
3830// //
3831// Functions used: //
3832// NONE //
3833// //
3834// Inputs: //
3835// Tuner_struct: structure defined at higher level //
3836// RegNum : Register address to be assigned a value //
3837// RegVal : Register value to write //
3838// //
3839// Outputs: //
3840// NONE //
3841// //
3842// Return: //
3843// 0 : Successful write //
3844// -1 : Invalid Register Address //
3845// //
3846///////////////////////////////////////////////////////////////////////////////
Steven Toth3935c252008-05-01 05:45:44 -03003847u16 MXL_RegWrite(struct dvb_frontend *fe, u8 RegNum, u8 RegVal)
Steven Toth52c99bd2008-05-01 04:57:01 -03003848{
Steven Toth85d220d2008-05-01 05:48:14 -03003849 struct mxl5005s_state *state = fe->tuner_priv;
Steven Toth52c99bd2008-05-01 04:57:01 -03003850 int i ;
3851
Steven Toth3935c252008-05-01 05:45:44 -03003852 for (i = 0; i < 104; i++) {
3853 if (RegNum == state->TunerRegs[i].Reg_Num) {
3854 state->TunerRegs[i].Reg_Val = RegVal;
3855 return 0;
Steven Toth52c99bd2008-05-01 04:57:01 -03003856 }
3857 }
3858
Steven Toth3935c252008-05-01 05:45:44 -03003859 return 1;
Steven Toth52c99bd2008-05-01 04:57:01 -03003860}
3861
3862///////////////////////////////////////////////////////////////////////////////
3863// //
3864// Function: MXL_RegRead //
3865// //
3866// Description: Retrieve tuner register value //
3867// //
3868// Globals: //
3869// NONE //
3870// //
3871// Functions used: //
3872// NONE //
3873// //
3874// Inputs: //
3875// Tuner_struct: structure defined at higher level //
3876// RegNum : Register address to be assigned a value //
3877// //
3878// Outputs: //
3879// RegVal : Retrieved register value //
3880// //
3881// Return: //
3882// 0 : Successful read //
3883// -1 : Invalid Register Address //
3884// //
3885///////////////////////////////////////////////////////////////////////////////
Steven Toth3935c252008-05-01 05:45:44 -03003886u16 MXL_RegRead(struct dvb_frontend *fe, u8 RegNum, u8 *RegVal)
Steven Toth52c99bd2008-05-01 04:57:01 -03003887{
Steven Toth85d220d2008-05-01 05:48:14 -03003888 struct mxl5005s_state *state = fe->tuner_priv;
Steven Toth52c99bd2008-05-01 04:57:01 -03003889 int i ;
3890
Steven Toth3935c252008-05-01 05:45:44 -03003891 for (i = 0; i < 104; i++) {
3892 if (RegNum == state->TunerRegs[i].Reg_Num ) {
3893 *RegVal = (u8)(state->TunerRegs[i].Reg_Val);
3894 return 0;
Steven Toth52c99bd2008-05-01 04:57:01 -03003895 }
3896 }
3897
Steven Toth3935c252008-05-01 05:45:44 -03003898 return 1;
Steven Toth52c99bd2008-05-01 04:57:01 -03003899}
3900
3901///////////////////////////////////////////////////////////////////////////////
3902// //
3903// Function: MXL_ControlRead //
3904// //
3905// Description: Retrieve the control value based on the control name //
3906// //
3907// Globals: //
3908// NONE //
3909// //
3910// Inputs: //
3911// Tuner_struct : structure defined at higher level //
3912// ControlName : Control Name //
3913// //
3914// Outputs: //
3915// value : returned control value //
3916// //
3917// Return: //
3918// 0 : Successful read //
3919// -1 : Invalid control name //
3920// //
3921///////////////////////////////////////////////////////////////////////////////
Steven Toth85d220d2008-05-01 05:48:14 -03003922u16 MXL_ControlRead(struct dvb_frontend *fe, u16 controlNum, u32 *value)
Steven Toth52c99bd2008-05-01 04:57:01 -03003923{
Steven Toth85d220d2008-05-01 05:48:14 -03003924 struct mxl5005s_state *state = fe->tuner_priv;
Steven Totha8214d42008-05-01 05:02:58 -03003925 u32 ctrlVal ;
3926 u16 i, k ;
Steven Toth52c99bd2008-05-01 04:57:01 -03003927
Steven Toth3935c252008-05-01 05:45:44 -03003928 for (i = 0; i < state->Init_Ctrl_Num ; i++) {
3929
3930 if (controlNum == state->Init_Ctrl[i].Ctrl_Num) {
3931
3932 ctrlVal = 0;
3933 for (k = 0; k < state->Init_Ctrl[i].size; k++)
3934 ctrlVal += state->Init_Ctrl[i].val[k] * (1 << k);
3935 *value = ctrlVal;
3936 return 0;
Steven Toth52c99bd2008-05-01 04:57:01 -03003937 }
3938 }
Steven Toth3935c252008-05-01 05:45:44 -03003939
3940 for (i = 0; i < state->CH_Ctrl_Num ; i++) {
3941
3942 if (controlNum == state->CH_Ctrl[i].Ctrl_Num) {
3943
3944 ctrlVal = 0;
3945 for (k = 0; k < state->CH_Ctrl[i].size; k++)
3946 ctrlVal += state->CH_Ctrl[i].val[k] * (1 << k);
3947 *value = ctrlVal;
3948 return 0;
3949
Steven Toth52c99bd2008-05-01 04:57:01 -03003950 }
3951 }
3952
3953#ifdef _MXL_INTERNAL
Steven Toth3935c252008-05-01 05:45:44 -03003954 for (i = 0; i < state->MXL_Ctrl_Num ; i++) {
3955
3956 if (controlNum == state->MXL_Ctrl[i].Ctrl_Num) {
3957
3958 ctrlVal = 0;
3959 for (k = 0; k < state->MXL_Ctrl[i].size; k++)
3960 ctrlVal += state->MXL_Ctrl[i].val[k] * (1<<k);
3961 *value = ctrlVal;
3962 return 0;
3963
Steven Toth52c99bd2008-05-01 04:57:01 -03003964 }
3965 }
3966#endif
Steven Toth3935c252008-05-01 05:45:44 -03003967 return 1;
Steven Toth52c99bd2008-05-01 04:57:01 -03003968}
3969
3970///////////////////////////////////////////////////////////////////////////////
3971// //
3972// Function: MXL_ControlRegRead //
3973// //
3974// Description: Retrieve the register addresses and count related to a //
Steven Totha8214d42008-05-01 05:02:58 -03003975// a specific control name //
Steven Toth52c99bd2008-05-01 04:57:01 -03003976// //
3977// Globals: //
3978// NONE //
3979// //
3980// Inputs: //
3981// Tuner_struct : structure defined at higher level //
3982// ControlName : Control Name //
3983// //
3984// Outputs: //
3985// RegNum : returned register address array //
Steven Totha8214d42008-05-01 05:02:58 -03003986// count : returned register count related to a control //
Steven Toth52c99bd2008-05-01 04:57:01 -03003987// //
3988// Return: //
3989// 0 : Successful read //
3990// -1 : Invalid control name //
3991// //
3992///////////////////////////////////////////////////////////////////////////////
Steven Toth3935c252008-05-01 05:45:44 -03003993u16 MXL_ControlRegRead(struct dvb_frontend *fe, u16 controlNum, u8 *RegNum, int * count)
Steven Toth52c99bd2008-05-01 04:57:01 -03003994{
Steven Toth85d220d2008-05-01 05:48:14 -03003995 struct mxl5005s_state *state = fe->tuner_priv;
Steven Totha8214d42008-05-01 05:02:58 -03003996 u16 i, j, k ;
3997 u16 Count ;
Steven Toth52c99bd2008-05-01 04:57:01 -03003998
Steven Toth3935c252008-05-01 05:45:44 -03003999 for (i = 0; i < state->Init_Ctrl_Num ; i++) {
Steven Toth52c99bd2008-05-01 04:57:01 -03004000
Steven Toth3935c252008-05-01 05:45:44 -03004001 if ( controlNum == state->Init_Ctrl[i].Ctrl_Num ) {
4002
4003 Count = 1;
4004 RegNum[0] = (u8)(state->Init_Ctrl[i].addr[0]);
4005
4006 for (k = 1; k < state->Init_Ctrl[i].size; k++) {
4007
4008 for (j = 0; j < Count; j++) {
4009
4010 if (state->Init_Ctrl[i].addr[k] != RegNum[j]) {
4011
4012 Count ++;
4013 RegNum[Count-1] = (u8)(state->Init_Ctrl[i].addr[k]);
4014
Steven Toth52c99bd2008-05-01 04:57:01 -03004015 }
4016 }
4017
4018 }
Steven Toth3935c252008-05-01 05:45:44 -03004019 *count = Count;
4020 return 0;
Steven Toth52c99bd2008-05-01 04:57:01 -03004021 }
4022 }
Steven Toth3935c252008-05-01 05:45:44 -03004023 for (i = 0; i < state->CH_Ctrl_Num ; i++) {
Steven Toth52c99bd2008-05-01 04:57:01 -03004024
Steven Toth3935c252008-05-01 05:45:44 -03004025 if ( controlNum == state->CH_Ctrl[i].Ctrl_Num ) {
4026
4027 Count = 1;
4028 RegNum[0] = (u8)(state->CH_Ctrl[i].addr[0]);
4029
4030 for (k = 1; k < state->CH_Ctrl[i].size; k++) {
4031
4032 for (j= 0; j<Count; j++) {
4033
4034 if (state->CH_Ctrl[i].addr[k] != RegNum[j]) {
4035
4036 Count ++;
4037 RegNum[Count-1] = (u8)(state->CH_Ctrl[i].addr[k]);
4038
Steven Toth52c99bd2008-05-01 04:57:01 -03004039 }
4040 }
4041 }
Steven Toth3935c252008-05-01 05:45:44 -03004042 *count = Count;
4043 return 0;
Steven Toth52c99bd2008-05-01 04:57:01 -03004044 }
4045 }
4046#ifdef _MXL_INTERNAL
Steven Toth3935c252008-05-01 05:45:44 -03004047 for (i = 0; i < state->MXL_Ctrl_Num ; i++) {
Steven Toth52c99bd2008-05-01 04:57:01 -03004048
Steven Toth3935c252008-05-01 05:45:44 -03004049 if ( controlNum == state->MXL_Ctrl[i].Ctrl_Num ) {
4050
4051 Count = 1;
4052 RegNum[0] = (u8)(state->MXL_Ctrl[i].addr[0]);
4053
4054 for (k = 1; k < state->MXL_Ctrl[i].size; k++) {
4055
4056 for (j = 0; j<Count; j++) {
4057
4058 if (state->MXL_Ctrl[i].addr[k] != RegNum[j]) {
4059
4060 Count ++;
4061 RegNum[Count-1] = (u8)state->MXL_Ctrl[i].addr[k];
4062
Steven Toth52c99bd2008-05-01 04:57:01 -03004063 }
4064 }
4065 }
Steven Toth3935c252008-05-01 05:45:44 -03004066 *count = Count;
4067 return 0;
Steven Toth52c99bd2008-05-01 04:57:01 -03004068 }
4069 }
4070#endif
Steven Toth3935c252008-05-01 05:45:44 -03004071 *count = 0;
4072 return 1;
Steven Toth52c99bd2008-05-01 04:57:01 -03004073}
4074
4075///////////////////////////////////////////////////////////////////////////////
4076// //
4077// Function: MXL_RegWriteBit //
4078// //
4079// Description: Write a register for specified register address, //
4080// register bit and register bit value //
4081// //
4082// Globals: //
4083// NONE //
4084// //
4085// Inputs: //
4086// Tuner_struct : structure defined at higher level //
4087// address : register address //
Steven Toth3935c252008-05-01 05:45:44 -03004088// bit : register bit number //
Steven Totha8214d42008-05-01 05:02:58 -03004089// bitVal : register bit value //
Steven Toth52c99bd2008-05-01 04:57:01 -03004090// //
4091// Outputs: //
4092// NONE //
4093// //
4094// Return: //
4095// NONE //
4096// //
4097///////////////////////////////////////////////////////////////////////////////
Steven Toth3935c252008-05-01 05:45:44 -03004098void MXL_RegWriteBit(struct dvb_frontend *fe, u8 address, u8 bit, u8 bitVal)
Steven Toth52c99bd2008-05-01 04:57:01 -03004099{
Steven Toth85d220d2008-05-01 05:48:14 -03004100 struct mxl5005s_state *state = fe->tuner_priv;
Steven Toth52c99bd2008-05-01 04:57:01 -03004101 int i ;
4102
Steven Totha8214d42008-05-01 05:02:58 -03004103 const u8 AND_MAP[8] = {
Steven Toth52c99bd2008-05-01 04:57:01 -03004104 0xFE, 0xFD, 0xFB, 0xF7,
4105 0xEF, 0xDF, 0xBF, 0x7F } ;
4106
Steven Totha8214d42008-05-01 05:02:58 -03004107 const u8 OR_MAP[8] = {
Steven Toth52c99bd2008-05-01 04:57:01 -03004108 0x01, 0x02, 0x04, 0x08,
4109 0x10, 0x20, 0x40, 0x80 } ;
4110
Steven Toth3935c252008-05-01 05:45:44 -03004111 for (i = 0; i < state->TunerRegs_Num; i++) {
4112 if (state->TunerRegs[i].Reg_Num == address) {
Steven Toth52c99bd2008-05-01 04:57:01 -03004113 if (bitVal)
Steven Toth3935c252008-05-01 05:45:44 -03004114 state->TunerRegs[i].Reg_Val |= OR_MAP[bit];
Steven Toth52c99bd2008-05-01 04:57:01 -03004115 else
Steven Toth3935c252008-05-01 05:45:44 -03004116 state->TunerRegs[i].Reg_Val &= AND_MAP[bit];
Steven Toth52c99bd2008-05-01 04:57:01 -03004117 break ;
4118 }
4119 }
Steven Toth3935c252008-05-01 05:45:44 -03004120}
Steven Toth52c99bd2008-05-01 04:57:01 -03004121
4122///////////////////////////////////////////////////////////////////////////////
4123// //
4124// Function: MXL_Ceiling //
4125// //
4126// Description: Complete to closest increment of resolution //
4127// //
4128// Globals: //
4129// NONE //
4130// //
4131// Functions used: //
4132// NONE //
4133// //
4134// Inputs: //
4135// value : Input number to compute //
4136// resolution : Increment step //
4137// //
4138// Outputs: //
4139// NONE //
4140// //
4141// Return: //
4142// Computed value //
4143// //
4144///////////////////////////////////////////////////////////////////////////////
Steven Toth3935c252008-05-01 05:45:44 -03004145u32 MXL_Ceiling(u32 value, u32 resolution)
Steven Toth52c99bd2008-05-01 04:57:01 -03004146{
Steven Toth3935c252008-05-01 05:45:44 -03004147 return (value/resolution + (value % resolution > 0 ? 1 : 0));
4148}
Steven Toth52c99bd2008-05-01 04:57:01 -03004149
4150//
4151// Retrieve the Initialzation Registers
4152//
Steven Toth3935c252008-05-01 05:45:44 -03004153u16 MXL_GetInitRegister(struct dvb_frontend *fe, u8 * RegNum, u8 *RegVal, int *count)
Steven Toth52c99bd2008-05-01 04:57:01 -03004154{
Steven Totha8214d42008-05-01 05:02:58 -03004155 u16 status = 0;
Steven Toth52c99bd2008-05-01 04:57:01 -03004156 int i ;
4157
Steven Toth3935c252008-05-01 05:45:44 -03004158 u8 RegAddr[] = {
4159 11, 12, 13, 22, 32, 43, 44, 53, 56, 59, 73,
4160 76, 77, 91, 134, 135, 137, 147,
4161 156, 166, 167, 168, 25 };
Steven Toth52c99bd2008-05-01 04:57:01 -03004162
Steven Toth3935c252008-05-01 05:45:44 -03004163 *count = sizeof(RegAddr) / sizeof(u8);
Steven Toth52c99bd2008-05-01 04:57:01 -03004164
Steven Toth3935c252008-05-01 05:45:44 -03004165 status += MXL_BlockInit(fe);
4166
4167 for (i = 0 ; i < *count; i++) {
4168 RegNum[i] = RegAddr[i];
4169 status += MXL_RegRead(fe, RegNum[i], &RegVal[i]);
Steven Toth52c99bd2008-05-01 04:57:01 -03004170 }
4171
Steven Toth3935c252008-05-01 05:45:44 -03004172 return status;
Steven Toth52c99bd2008-05-01 04:57:01 -03004173}
4174
Steven Toth3935c252008-05-01 05:45:44 -03004175u16 MXL_GetCHRegister(struct dvb_frontend *fe, u8 * RegNum, u8 *RegVal, int *count)
Steven Toth52c99bd2008-05-01 04:57:01 -03004176{
Steven Totha8214d42008-05-01 05:02:58 -03004177 u16 status = 0;
Steven Toth52c99bd2008-05-01 04:57:01 -03004178 int i ;
4179
4180//add 77, 166, 167, 168 register for 2.6.12
4181#ifdef _MXL_PRODUCTION
Steven Totha8214d42008-05-01 05:02:58 -03004182 u8 RegAddr[] = {14, 15, 16, 17, 22, 43, 65, 68, 69, 70, 73, 92, 93, 106,
4183 107, 108, 109, 110, 111, 112, 136, 138, 149, 77, 166, 167, 168 } ;
Steven Toth52c99bd2008-05-01 04:57:01 -03004184#else
Steven Totha8214d42008-05-01 05:02:58 -03004185 u8 RegAddr[] = {14, 15, 16, 17, 22, 43, 68, 69, 70, 73, 92, 93, 106,
4186 107, 108, 109, 110, 111, 112, 136, 138, 149, 77, 166, 167, 168 } ;
4187 //u8 RegAddr[171];
Steven Toth52c99bd2008-05-01 04:57:01 -03004188 //for (i=0; i<=170; i++)
4189 // RegAddr[i] = i;
4190#endif
4191
Steven Toth3935c252008-05-01 05:45:44 -03004192 *count = sizeof(RegAddr) / sizeof(u8);
Steven Toth52c99bd2008-05-01 04:57:01 -03004193
Steven Toth3935c252008-05-01 05:45:44 -03004194 for (i = 0 ; i < *count; i++) {
4195 RegNum[i] = RegAddr[i];
4196 status += MXL_RegRead(fe, RegNum[i], &RegVal[i]);
Steven Toth52c99bd2008-05-01 04:57:01 -03004197 }
4198
Steven Toth3935c252008-05-01 05:45:44 -03004199 return status;
Steven Toth52c99bd2008-05-01 04:57:01 -03004200}
4201
Steven Toth3935c252008-05-01 05:45:44 -03004202u16 MXL_GetCHRegister_ZeroIF(struct dvb_frontend *fe, u8 * RegNum, u8 *RegVal, int *count)
Steven Toth52c99bd2008-05-01 04:57:01 -03004203{
Steven Toth3935c252008-05-01 05:45:44 -03004204 u16 status = 0;
4205 int i;
Steven Toth52c99bd2008-05-01 04:57:01 -03004206
Steven Toth3935c252008-05-01 05:45:44 -03004207 u8 RegAddr[] = {43, 136};
Steven Toth52c99bd2008-05-01 04:57:01 -03004208
Steven Toth3935c252008-05-01 05:45:44 -03004209 *count = sizeof(RegAddr) / sizeof(u8);
Steven Toth52c99bd2008-05-01 04:57:01 -03004210
Steven Toth3935c252008-05-01 05:45:44 -03004211 for (i = 0; i < *count; i++) {
4212 RegNum[i] = RegAddr[i];
4213 status += MXL_RegRead(fe, RegNum[i], &RegVal[i]);
Steven Toth52c99bd2008-05-01 04:57:01 -03004214 }
Steven Toth52c99bd2008-05-01 04:57:01 -03004215
Steven Toth3935c252008-05-01 05:45:44 -03004216 return status;
Steven Toth52c99bd2008-05-01 04:57:01 -03004217}
4218
Steven Toth3935c252008-05-01 05:45:44 -03004219u16 MXL_GetCHRegister_LowIF(struct dvb_frontend *fe, u8 * RegNum, u8 *RegVal, int *count)
Steven Toth52c99bd2008-05-01 04:57:01 -03004220{
Steven Toth3935c252008-05-01 05:45:44 -03004221 u16 status = 0;
4222 int i;
Steven Toth52c99bd2008-05-01 04:57:01 -03004223
Steven Toth3935c252008-05-01 05:45:44 -03004224 u8 RegAddr[] = { 138 };
Steven Toth52c99bd2008-05-01 04:57:01 -03004225
Steven Toth3935c252008-05-01 05:45:44 -03004226 *count = sizeof(RegAddr) / sizeof(u8);
Steven Toth52c99bd2008-05-01 04:57:01 -03004227
Steven Toth3935c252008-05-01 05:45:44 -03004228 for (i = 0; i < *count; i++) {
4229 RegNum[i] = RegAddr[i];
4230 status += MXL_RegRead(fe, RegNum[i], &RegVal[i]);
Steven Toth52c99bd2008-05-01 04:57:01 -03004231 }
Steven Toth52c99bd2008-05-01 04:57:01 -03004232
Steven Toth3935c252008-05-01 05:45:44 -03004233 return status;
Steven Toth52c99bd2008-05-01 04:57:01 -03004234}
4235
Steven Totha8214d42008-05-01 05:02:58 -03004236u16 MXL_GetMasterControl(u8 *MasterReg, int state)
Steven Toth52c99bd2008-05-01 04:57:01 -03004237{
Steven Toth3935c252008-05-01 05:45:44 -03004238 if (state == 1) /* Load_Start */
4239 *MasterReg = 0xF3;
4240 if (state == 2) /* Power_Down */
4241 *MasterReg = 0x41;
4242 if (state == 3) /* Synth_Reset */
4243 *MasterReg = 0xB1;
4244 if (state == 4) /* Seq_Off */
4245 *MasterReg = 0xF1;
Steven Toth52c99bd2008-05-01 04:57:01 -03004246
Steven Toth3935c252008-05-01 05:45:44 -03004247 return 0;
Steven Toth52c99bd2008-05-01 04:57:01 -03004248}
4249
4250#ifdef _MXL_PRODUCTION
Steven Toth3935c252008-05-01 05:45:44 -03004251u16 MXL_VCORange_Test(struct dvb_frontend *fe, int VCO_Range)
Steven Toth52c99bd2008-05-01 04:57:01 -03004252{
Steven Toth85d220d2008-05-01 05:48:14 -03004253 struct mxl5005s_state *state = fe->tuner_priv;
Steven Totha8214d42008-05-01 05:02:58 -03004254 u16 status = 0 ;
Steven Toth52c99bd2008-05-01 04:57:01 -03004255
Steven Totha8214d42008-05-01 05:02:58 -03004256 if (VCO_Range == 1) {
Steven Toth3935c252008-05-01 05:45:44 -03004257 status += MXL_ControlWrite(fe, RFSYN_EN_DIV, 1);
4258 status += MXL_ControlWrite(fe, RFSYN_EN_OUTMUX, 0);
4259 status += MXL_ControlWrite(fe, RFSYN_SEL_DIVM, 0);
4260 status += MXL_ControlWrite(fe, RFSYN_DIVM, 1);
4261 status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_OUT, 1);
4262 status += MXL_ControlWrite(fe, RFSYN_RF_DIV_BIAS, 1);
4263 status += MXL_ControlWrite(fe, DN_SEL_FREQ, 0);
4264 if (state->Mode == 0 && state->IF_Mode == 1) /* Analog Low IF Mode */ {
4265 status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 1);
4266 status += MXL_ControlWrite(fe, RFSYN_VCO_BIAS, 8);
4267 status += MXL_ControlWrite(fe, CHCAL_INT_MOD_RF, 56);
4268 status += MXL_ControlWrite(fe, CHCAL_FRAC_MOD_RF, 180224);
Steven Totha8214d42008-05-01 05:02:58 -03004269 }
Steven Toth3935c252008-05-01 05:45:44 -03004270 if (state->Mode == 0 && state->IF_Mode == 0) /* Analog Zero IF Mode */ {
4271 status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 1);
4272 status += MXL_ControlWrite(fe, RFSYN_VCO_BIAS, 8);
4273 status += MXL_ControlWrite(fe, CHCAL_INT_MOD_RF, 56);
4274 status += MXL_ControlWrite(fe, CHCAL_FRAC_MOD_RF, 222822);
Steven Totha8214d42008-05-01 05:02:58 -03004275 }
Steven Toth3935c252008-05-01 05:45:44 -03004276 if (state->Mode == 1) /* Digital Mode */ {
4277 status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 1);
4278 status += MXL_ControlWrite(fe, RFSYN_VCO_BIAS, 8);
4279 status += MXL_ControlWrite(fe, CHCAL_INT_MOD_RF, 56);
4280 status += MXL_ControlWrite(fe, CHCAL_FRAC_MOD_RF, 229376);
Steven Totha8214d42008-05-01 05:02:58 -03004281 }
4282 }
Steven Toth52c99bd2008-05-01 04:57:01 -03004283
Steven Totha8214d42008-05-01 05:02:58 -03004284 if (VCO_Range == 2) {
Steven Toth3935c252008-05-01 05:45:44 -03004285 status += MXL_ControlWrite(fe, RFSYN_EN_DIV, 1);
4286 status += MXL_ControlWrite(fe, RFSYN_EN_OUTMUX, 0);
4287 status += MXL_ControlWrite(fe, RFSYN_SEL_DIVM, 0);
4288 status += MXL_ControlWrite(fe, RFSYN_DIVM, 1);
4289 status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_OUT, 1);
4290 status += MXL_ControlWrite(fe, RFSYN_RF_DIV_BIAS, 1);
4291 status += MXL_ControlWrite(fe, DN_SEL_FREQ, 0);
4292 status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 1);
4293 status += MXL_ControlWrite(fe, RFSYN_VCO_BIAS, 40);
4294 status += MXL_ControlWrite(fe, CHCAL_INT_MOD_RF, 41);
4295 if (state->Mode == 0 && state->IF_Mode == 1) /* Analog Low IF Mode */ {
4296 status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 1);
4297 status += MXL_ControlWrite(fe, RFSYN_VCO_BIAS, 40);
4298 status += MXL_ControlWrite(fe, CHCAL_INT_MOD_RF, 42);
4299 status += MXL_ControlWrite(fe, CHCAL_FRAC_MOD_RF, 206438);
Steven Totha8214d42008-05-01 05:02:58 -03004300 }
Steven Toth3935c252008-05-01 05:45:44 -03004301 if (state->Mode == 0 && state->IF_Mode == 0) /* Analog Zero IF Mode */ {
4302 status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 1);
4303 status += MXL_ControlWrite(fe, RFSYN_VCO_BIAS, 40);
4304 status += MXL_ControlWrite(fe, CHCAL_INT_MOD_RF, 42);
4305 status += MXL_ControlWrite(fe, CHCAL_FRAC_MOD_RF, 206438);
Steven Totha8214d42008-05-01 05:02:58 -03004306 }
Steven Toth3935c252008-05-01 05:45:44 -03004307 if (state->Mode == 1) /* Digital Mode */ {
4308 status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 1);
4309 status += MXL_ControlWrite(fe, RFSYN_VCO_BIAS, 40);
4310 status += MXL_ControlWrite(fe, CHCAL_INT_MOD_RF, 41);
4311 status += MXL_ControlWrite(fe, CHCAL_FRAC_MOD_RF, 16384);
Steven Totha8214d42008-05-01 05:02:58 -03004312 }
4313 }
Steven Toth52c99bd2008-05-01 04:57:01 -03004314
Steven Totha8214d42008-05-01 05:02:58 -03004315 if (VCO_Range == 3) {
Steven Toth3935c252008-05-01 05:45:44 -03004316 status += MXL_ControlWrite(fe, RFSYN_EN_DIV, 1);
4317 status += MXL_ControlWrite(fe, RFSYN_EN_OUTMUX, 0);
4318 status += MXL_ControlWrite(fe, RFSYN_SEL_DIVM, 0);
4319 status += MXL_ControlWrite(fe, RFSYN_DIVM, 1);
4320 status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_OUT, 1);
4321 status += MXL_ControlWrite(fe, RFSYN_RF_DIV_BIAS, 1);
4322 status += MXL_ControlWrite(fe, DN_SEL_FREQ, 0);
4323 status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 0);
4324 status += MXL_ControlWrite(fe, RFSYN_VCO_BIAS, 8);
4325 status += MXL_ControlWrite(fe, CHCAL_INT_MOD_RF, 42);
4326 if (state->Mode == 0 && state->IF_Mode == 1) /* Analog Low IF Mode */ {
4327 status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 0);
4328 status += MXL_ControlWrite(fe, RFSYN_VCO_BIAS, 8);
4329 status += MXL_ControlWrite(fe, CHCAL_INT_MOD_RF, 44);
4330 status += MXL_ControlWrite(fe, CHCAL_FRAC_MOD_RF, 173670);
Steven Totha8214d42008-05-01 05:02:58 -03004331 }
Steven Toth3935c252008-05-01 05:45:44 -03004332 if (state->Mode == 0 && state->IF_Mode == 0) /* Analog Zero IF Mode */ {
4333 status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 0);
4334 status += MXL_ControlWrite(fe, RFSYN_VCO_BIAS, 8);
4335 status += MXL_ControlWrite(fe, CHCAL_INT_MOD_RF, 44);
4336 status += MXL_ControlWrite(fe, CHCAL_FRAC_MOD_RF, 173670);
Steven Totha8214d42008-05-01 05:02:58 -03004337 }
Steven Toth3935c252008-05-01 05:45:44 -03004338 if (state->Mode == 1) /* Digital Mode */ {
4339 status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 0);
4340 status += MXL_ControlWrite(fe, RFSYN_VCO_BIAS, 8);
4341 status += MXL_ControlWrite(fe, CHCAL_INT_MOD_RF, 42);
4342 status += MXL_ControlWrite(fe, CHCAL_FRAC_MOD_RF, 245760);
Steven Totha8214d42008-05-01 05:02:58 -03004343 }
4344 }
Steven Toth52c99bd2008-05-01 04:57:01 -03004345
Steven Totha8214d42008-05-01 05:02:58 -03004346 if (VCO_Range == 4) {
Steven Toth3935c252008-05-01 05:45:44 -03004347 status += MXL_ControlWrite(fe, RFSYN_EN_DIV, 1);
4348 status += MXL_ControlWrite(fe, RFSYN_EN_OUTMUX, 0);
4349 status += MXL_ControlWrite(fe, RFSYN_SEL_DIVM, 0);
4350 status += MXL_ControlWrite(fe, RFSYN_DIVM, 1);
4351 status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_OUT, 1);
4352 status += MXL_ControlWrite(fe, RFSYN_RF_DIV_BIAS, 1);
4353 status += MXL_ControlWrite(fe, DN_SEL_FREQ, 0);
4354 status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 0);
4355 status += MXL_ControlWrite(fe, RFSYN_VCO_BIAS, 40);
4356 status += MXL_ControlWrite(fe, CHCAL_INT_MOD_RF, 27);
4357 if (state->Mode == 0 && state->IF_Mode == 1) /* Analog Low IF Mode */ {
4358 status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 0);
4359 status += MXL_ControlWrite(fe, RFSYN_VCO_BIAS, 40);
4360 status += MXL_ControlWrite(fe, CHCAL_INT_MOD_RF, 27);
4361 status += MXL_ControlWrite(fe, CHCAL_FRAC_MOD_RF, 206438);
Steven Totha8214d42008-05-01 05:02:58 -03004362 }
Steven Toth3935c252008-05-01 05:45:44 -03004363 if (state->Mode == 0 && state->IF_Mode == 0) /* Analog Zero IF Mode */ {
4364 status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 0);
4365 status += MXL_ControlWrite(fe, RFSYN_VCO_BIAS, 40);
4366 status += MXL_ControlWrite(fe, CHCAL_INT_MOD_RF, 27);
4367 status += MXL_ControlWrite(fe, CHCAL_FRAC_MOD_RF, 206438);
Steven Totha8214d42008-05-01 05:02:58 -03004368 }
Steven Toth3935c252008-05-01 05:45:44 -03004369 if (state->Mode == 1) /* Digital Mode */ {
4370 status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 0);
4371 status += MXL_ControlWrite(fe, RFSYN_VCO_BIAS, 40);
4372 status += MXL_ControlWrite(fe, CHCAL_INT_MOD_RF, 27);
4373 status += MXL_ControlWrite(fe, CHCAL_FRAC_MOD_RF, 212992);
Steven Totha8214d42008-05-01 05:02:58 -03004374 }
4375 }
Steven Toth52c99bd2008-05-01 04:57:01 -03004376
Steven Totha8214d42008-05-01 05:02:58 -03004377 return status;
Steven Toth52c99bd2008-05-01 04:57:01 -03004378}
4379
Steven Toth3935c252008-05-01 05:45:44 -03004380u16 MXL_Hystersis_Test(struct dvb_frontend *fe, int Hystersis)
Steven Toth52c99bd2008-05-01 04:57:01 -03004381{
Steven Toth85d220d2008-05-01 05:48:14 -03004382 struct mxl5005s_state *state = fe->tuner_priv;
Steven Totha8214d42008-05-01 05:02:58 -03004383 u16 status = 0;
Steven Toth52c99bd2008-05-01 04:57:01 -03004384
4385 if (Hystersis == 1)
Steven Toth3935c252008-05-01 05:45:44 -03004386 status += MXL_ControlWrite(fe, DN_BYPASS_AGC_I2C, 1);
Steven Toth52c99bd2008-05-01 04:57:01 -03004387
Steven Totha8214d42008-05-01 05:02:58 -03004388 return status;
Steven Toth52c99bd2008-05-01 04:57:01 -03004389}
4390#endif
Steven Toth7f5c3af2008-05-01 06:51:36 -03004391/* End: Reference driver code found in the Realtek driver that
4392 * is copyright MaxLinear */
Steven Toth52c99bd2008-05-01 04:57:01 -03004393
Steven Toth7f5c3af2008-05-01 06:51:36 -03004394/* ----------------------------------------------------------------
4395 * Begin: Everything after here is new code to adapt the
4396 * proprietary Realtek driver into a Linux API tuner.
4397 * Copyright (C) 2008 Steven Toth <stoth@hauppauge.com>
4398 */
4399static int mxl5005s_reset(struct dvb_frontend *fe)
4400{
4401 struct mxl5005s_state *state = fe->tuner_priv;
4402 int ret = 0;
4403
4404 u8 buf[2] = { 0xff, 0x00 };
4405 struct i2c_msg msg = { .addr = state->config->i2c_address, .flags = 0,
4406 .buf = buf, .len = 2 };
4407
4408 dprintk(2, "%s()\n", __func__);
4409
4410 if (fe->ops.i2c_gate_ctrl)
4411 fe->ops.i2c_gate_ctrl(fe, 1);
4412
4413 if (i2c_transfer(state->i2c, &msg, 1) != 1) {
4414 printk(KERN_WARNING "mxl5005s I2C reset failed\n");
4415 ret = -EREMOTEIO;
4416 }
4417
4418 if (fe->ops.i2c_gate_ctrl)
4419 fe->ops.i2c_gate_ctrl(fe, 0);
4420
4421 return ret;
4422}
4423
4424/* Write a single byte to a single reg, latch the value if required by
4425 * following the transaction with the latch byte.
4426 */
4427static int mxl5005s_writereg(struct dvb_frontend *fe, u8 reg, u8 val, int latch)
4428{
4429 struct mxl5005s_state *state = fe->tuner_priv;
4430 u8 buf[3] = { reg, val, MXL5005S_LATCH_BYTE };
4431 struct i2c_msg msg = { .addr = state->config->i2c_address, .flags = 0,
4432 .buf = buf, .len = 3 };
4433
4434 if (latch == 0)
4435 msg.len = 2;
4436
4437 dprintk(2, "%s(reg = 0x%x val = 0x%x addr = 0x%x)\n", __func__, reg, val, msg.addr);
4438
4439 if (i2c_transfer(state->i2c, &msg, 1) != 1) {
4440 printk(KERN_WARNING "mxl5005s I2C write failed\n");
4441 return -EREMOTEIO;
4442 }
4443 return 0;
4444}
4445
4446int mxl5005s_writeregs(struct dvb_frontend *fe, u8 *addrtable, u8 *datatable, u8 len)
4447{
4448 int ret = 0, i;
4449
4450 if (fe->ops.i2c_gate_ctrl)
4451 fe->ops.i2c_gate_ctrl(fe, 1);
4452
4453 for (i = 0 ; i < len-1; i++) {
4454 ret = mxl5005s_writereg(fe, addrtable[i], datatable[i], 0);
4455 if (ret < 0)
4456 break;
4457 }
4458
4459 ret = mxl5005s_writereg(fe, addrtable[i], datatable[i], 1);
4460
4461 if (fe->ops.i2c_gate_ctrl)
4462 fe->ops.i2c_gate_ctrl(fe, 0);
4463
4464 return ret;
4465}
4466
Steven Toth85d220d2008-05-01 05:48:14 -03004467
Steven Toth8c66a192008-05-01 06:35:48 -03004468int mxl5005s_init(struct dvb_frontend *fe)
Steven Toth85d220d2008-05-01 05:48:14 -03004469{
Steven Toth7f5c3af2008-05-01 06:51:36 -03004470 dprintk(1, "%s()\n", __func__);
4471 return mxl5005s_reconfigure(fe, MXL_QAM, MXL5005S_BANDWIDTH_6MHZ);
4472}
4473
4474int mxl5005s_reconfigure(struct dvb_frontend *fe, u32 mod_type, u32 bandwidth)
4475{
Steven Toth8c66a192008-05-01 06:35:48 -03004476 struct mxl5005s_state *state = fe->tuner_priv;
4477
4478 u8 AddrTable[MXL5005S_REG_WRITING_TABLE_LEN_MAX];
4479 u8 ByteTable[MXL5005S_REG_WRITING_TABLE_LEN_MAX];
4480 int TableLen;
4481
Steven Toth7f5c3af2008-05-01 06:51:36 -03004482 dprintk(1, "%s(type=%d, bw=%d)\n", __func__, mod_type, bandwidth);
Steven Toth8c66a192008-05-01 06:35:48 -03004483
4484 mxl5005s_reset(fe);
4485
4486 /* Tuner initialization stage 0 */
4487 MXL_GetMasterControl(ByteTable, MC_SYNTH_RESET);
4488 AddrTable[0] = MASTER_CONTROL_ADDR;
4489 ByteTable[0] |= state->config->AgcMasterByte;
4490
Steven Toth7f5c3af2008-05-01 06:51:36 -03004491 mxl5005s_writeregs(fe, AddrTable, ByteTable, 1);
Steven Toth8c66a192008-05-01 06:35:48 -03004492
Steven Toth7f5c3af2008-05-01 06:51:36 -03004493 mxl5005s_AssignTunerMode(fe, mod_type, bandwidth);
Steven Toth8c66a192008-05-01 06:35:48 -03004494
4495 /* Tuner initialization stage 1 */
4496 MXL_GetInitRegister(fe, AddrTable, ByteTable, &TableLen);
4497
Steven Toth7f5c3af2008-05-01 06:51:36 -03004498 mxl5005s_writeregs(fe, AddrTable, ByteTable, TableLen);
Steven Toth8c66a192008-05-01 06:35:48 -03004499
4500 return 0;
4501}
4502
Steven Toth7f5c3af2008-05-01 06:51:36 -03004503int mxl5005s_AssignTunerMode(struct dvb_frontend *fe, u32 mod_type, u32 bandwidth)
Steven Toth8c66a192008-05-01 06:35:48 -03004504{
4505 struct mxl5005s_state *state = fe->tuner_priv;
4506 struct mxl5005s_config *c = state->config;
4507
4508 InitTunerControls(fe);
Steven Toth85d220d2008-05-01 05:48:14 -03004509
4510 /* Set MxL5005S parameters. */
Steven Toth85d220d2008-05-01 05:48:14 -03004511 MXL5005_TunerConfig(
4512 fe,
Steven Toth8c66a192008-05-01 06:35:48 -03004513 c->mod_mode,
4514 c->if_mode,
Steven Toth7f5c3af2008-05-01 06:51:36 -03004515 bandwidth,
Steven Toth8c66a192008-05-01 06:35:48 -03004516 c->if_freq,
4517 c->xtal_freq,
4518 c->agc_mode,
4519 c->top,
4520 c->output_load,
4521 c->clock_out,
4522 c->div_out,
4523 c->cap_select,
4524 c->rssi_enable,
Steven Toth7f5c3af2008-05-01 06:51:36 -03004525 mod_type,
Steven Toth8c66a192008-05-01 06:35:48 -03004526 c->tracking_filter);
Steven Toth85d220d2008-05-01 05:48:14 -03004527
4528 return 0;
4529}
4530
4531static int mxl5005s_set_params(struct dvb_frontend *fe,
4532 struct dvb_frontend_parameters *params)
4533{
Steven Toth7f5c3af2008-05-01 06:51:36 -03004534 struct mxl5005s_state *state = fe->tuner_priv;
4535 u32 req_mode, req_bw = 0;
4536 int ret;
Steven Toth85d220d2008-05-01 05:48:14 -03004537
Steven Toth7f5c3af2008-05-01 06:51:36 -03004538 dprintk(1, "%s()\n", __func__);
Steven Toth85d220d2008-05-01 05:48:14 -03004539
Steven Toth7f5c3af2008-05-01 06:51:36 -03004540 if (fe->ops.info.type == FE_ATSC) {
4541 switch (params->u.vsb.modulation) {
4542 case VSB_8:
4543 req_mode = MXL_ATSC; break;
4544 default:
4545 case QAM_64:
4546 case QAM_256:
4547 case QAM_AUTO:
4548 req_mode = MXL_QAM; break;
4549 }
4550 }
4551 else req_mode = MXL_DVBT;
Steven Toth85d220d2008-05-01 05:48:14 -03004552
Steven Toth7f5c3af2008-05-01 06:51:36 -03004553 /* Change tuner for new modulation type if reqd */
4554 if (req_mode != state->current_mode) {
4555 switch (req_mode) {
4556 case VSB_8:
4557 case QAM_64:
4558 case QAM_256:
4559 case QAM_AUTO:
4560 req_bw = MXL5005S_BANDWIDTH_6MHZ;
4561 break;
4562 default:
4563 /* Assume DVB-T */
4564 switch (params->u.ofdm.bandwidth) {
4565 case BANDWIDTH_6_MHZ:
4566 req_bw = MXL5005S_BANDWIDTH_6MHZ;
4567 break;
4568 case BANDWIDTH_7_MHZ:
4569 req_bw = MXL5005S_BANDWIDTH_7MHZ;
4570 break;
4571 case BANDWIDTH_AUTO:
4572 case BANDWIDTH_8_MHZ:
4573 req_bw = MXL5005S_BANDWIDTH_8MHZ;
4574 break;
4575 }
4576 }
Steven Toth8c66a192008-05-01 06:35:48 -03004577
Steven Toth7f5c3af2008-05-01 06:51:36 -03004578 state->current_mode = req_mode;
4579 ret = mxl5005s_reconfigure(fe, req_mode, req_bw);
Steven Toth8c66a192008-05-01 06:35:48 -03004580
Steven Toth7f5c3af2008-05-01 06:51:36 -03004581 } else
4582 ret = 0;
4583
4584 if (ret == 0) {
4585 dprintk(1, "%s() freq=%d\n", __func__, params->frequency);
4586 ret = mxl5005s_SetRfFreqHz(fe, params->frequency);
4587 }
4588
4589 return ret;
Steven Toth85d220d2008-05-01 05:48:14 -03004590}
4591
4592static int mxl5005s_get_frequency(struct dvb_frontend *fe, u32 *frequency)
4593{
4594 struct mxl5005s_state *state = fe->tuner_priv;
4595 dprintk(1, "%s()\n", __func__);
4596
4597 *frequency = state->RF_IN;
4598
4599 return 0;
4600}
4601
4602static int mxl5005s_get_bandwidth(struct dvb_frontend *fe, u32 *bandwidth)
4603{
4604 struct mxl5005s_state *state = fe->tuner_priv;
4605 dprintk(1, "%s()\n", __func__);
4606
4607 *bandwidth = state->Chan_Bandwidth;
4608
4609 return 0;
4610}
4611
Steven Toth85d220d2008-05-01 05:48:14 -03004612static int mxl5005s_release(struct dvb_frontend *fe)
4613{
4614 dprintk(1, "%s()\n", __func__);
4615 kfree(fe->tuner_priv);
4616 fe->tuner_priv = NULL;
4617 return 0;
4618}
4619
4620static const struct dvb_tuner_ops mxl5005s_tuner_ops = {
4621 .info = {
4622 .name = "MaxLinear MXL5005S",
4623 .frequency_min = 48000000,
4624 .frequency_max = 860000000,
4625 .frequency_step = 50000,
4626 },
4627
4628 .release = mxl5005s_release,
4629 .init = mxl5005s_init,
4630
4631 .set_params = mxl5005s_set_params,
4632 .get_frequency = mxl5005s_get_frequency,
4633 .get_bandwidth = mxl5005s_get_bandwidth,
Steven Toth85d220d2008-05-01 05:48:14 -03004634};
4635
4636struct dvb_frontend *mxl5005s_attach(struct dvb_frontend *fe,
4637 struct i2c_adapter *i2c,
4638 struct mxl5005s_config *config)
4639{
4640 struct mxl5005s_state *state = NULL;
4641 dprintk(1, "%s()\n", __func__);
4642
4643 state = kzalloc(sizeof(struct mxl5005s_state), GFP_KERNEL);
4644 if (state == NULL)
4645 return NULL;
4646
4647 state->frontend = fe;
4648 state->config = config;
4649 state->i2c = i2c;
Steven Toth7f5c3af2008-05-01 06:51:36 -03004650 state->current_mode = MXL_QAM;
Steven Toth85d220d2008-05-01 05:48:14 -03004651
4652 printk(KERN_INFO "MXL5005S: Attached at address 0x%02x\n", config->i2c_address);
4653
4654 memcpy(&fe->ops.tuner_ops, &mxl5005s_tuner_ops, sizeof(struct dvb_tuner_ops));
4655
4656 fe->tuner_priv = state;
4657 return fe;
4658}
4659EXPORT_SYMBOL(mxl5005s_attach);
4660
4661MODULE_DESCRIPTION("MaxLinear MXL5005S silicon tuner driver");
Steven Toth85d220d2008-05-01 05:48:14 -03004662MODULE_AUTHOR("Steven Toth");
4663MODULE_LICENSE("GPL");