Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 1 | /* |
Steven Toth | 4893729 | 2008-05-01 07:15:38 -0300 | [diff] [blame] | 2 | MaxLinear MXL5005S VSB/QAM/DVBT tuner driver |
Steven Toth | 7f5c3af | 2008-05-01 06:51:36 -0300 | [diff] [blame] | 3 | |
Steven Toth | 4893729 | 2008-05-01 07:15:38 -0300 | [diff] [blame] | 4 | Copyright (C) 2008 MaxLinear |
Steven Toth | 6d89761 | 2008-09-03 17:12:12 -0300 | [diff] [blame] | 5 | Copyright (C) 2006 Steven Toth <stoth@linuxtv.org> |
Steven Toth | 4893729 | 2008-05-01 07:15:38 -0300 | [diff] [blame] | 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 | |
Steven Toth | 7fa2a14 | 2008-05-03 14:25:55 -0300 | [diff] [blame] | 19 | Copyright (C) 2008 Realtek |
| 20 | Copyright (C) 2008 Jan Hoogenraad |
Steven Toth | 4893729 | 2008-05-01 07:15:38 -0300 | [diff] [blame] | 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 Toth | 5c1b205 | 2008-05-01 07:04:09 -0300 | [diff] [blame] | 60 | #include <linux/kernel.h> |
| 61 | #include <linux/init.h> |
| 62 | #include <linux/module.h> |
| 63 | #include <linux/string.h> |
| 64 | #include <linux/slab.h> |
| 65 | #include <linux/delay.h> |
| 66 | #include "dvb_frontend.h" |
Steven Toth | 2637d5b | 2008-05-01 05:01:31 -0300 | [diff] [blame] | 67 | #include "mxl5005s.h" |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 68 | |
Steven Toth | 77ad55e | 2008-05-03 14:28:43 -0300 | [diff] [blame] | 69 | static int debug; |
Steven Toth | 85d220d | 2008-05-01 05:48:14 -0300 | [diff] [blame] | 70 | |
| 71 | #define dprintk(level, arg...) do { \ |
Steven Toth | 4893729 | 2008-05-01 07:15:38 -0300 | [diff] [blame] | 72 | if (level <= debug) \ |
Steven Toth | 85d220d | 2008-05-01 05:48:14 -0300 | [diff] [blame] | 73 | printk(arg); \ |
| 74 | } while (0) |
| 75 | |
| 76 | #define TUNER_REGS_NUM 104 |
| 77 | #define INITCTRL_NUM 40 |
| 78 | |
| 79 | #ifdef _MXL_PRODUCTION |
| 80 | #define CHCTRL_NUM 39 |
| 81 | #else |
| 82 | #define CHCTRL_NUM 36 |
| 83 | #endif |
| 84 | |
| 85 | #define MXLCTRL_NUM 189 |
| 86 | #define MASTER_CONTROL_ADDR 9 |
| 87 | |
Steven Toth | 85d220d | 2008-05-01 05:48:14 -0300 | [diff] [blame] | 88 | /* Enumeration of Master Control Register State */ |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 89 | enum master_control_state { |
Steven Toth | 85d220d | 2008-05-01 05:48:14 -0300 | [diff] [blame] | 90 | MC_LOAD_START = 1, |
| 91 | MC_POWER_DOWN, |
| 92 | MC_SYNTH_RESET, |
| 93 | MC_SEQ_OFF |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 94 | }; |
Steven Toth | 85d220d | 2008-05-01 05:48:14 -0300 | [diff] [blame] | 95 | |
Steven Toth | 85d220d | 2008-05-01 05:48:14 -0300 | [diff] [blame] | 96 | /* Enumeration of MXL5005 Tuner Modulation Type */ |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 97 | enum { |
Steven Toth | 85d220d | 2008-05-01 05:48:14 -0300 | [diff] [blame] | 98 | MXL_DEFAULT_MODULATION = 0, |
| 99 | MXL_DVBT, |
| 100 | MXL_ATSC, |
| 101 | MXL_QAM, |
| 102 | MXL_ANALOG_CABLE, |
| 103 | MXL_ANALOG_OTA |
Adrian Bunk | 38db143 | 2008-05-16 00:15:53 -0300 | [diff] [blame] | 104 | }; |
Steven Toth | 85d220d | 2008-05-01 05:48:14 -0300 | [diff] [blame] | 105 | |
Steven Toth | 85d220d | 2008-05-01 05:48:14 -0300 | [diff] [blame] | 106 | /* MXL5005 Tuner Register Struct */ |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 107 | struct TunerReg { |
Steven Toth | 85d220d | 2008-05-01 05:48:14 -0300 | [diff] [blame] | 108 | u16 Reg_Num; /* Tuner Register Address */ |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 109 | u16 Reg_Val; /* Current sw programmed value waiting to be writen */ |
| 110 | }; |
Steven Toth | 85d220d | 2008-05-01 05:48:14 -0300 | [diff] [blame] | 111 | |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 112 | enum { |
Steven Toth | 85d220d | 2008-05-01 05:48:14 -0300 | [diff] [blame] | 113 | /* Initialization Control Names */ |
| 114 | DN_IQTN_AMP_CUT = 1, /* 1 */ |
| 115 | BB_MODE, /* 2 */ |
| 116 | BB_BUF, /* 3 */ |
| 117 | BB_BUF_OA, /* 4 */ |
| 118 | BB_ALPF_BANDSELECT, /* 5 */ |
| 119 | BB_IQSWAP, /* 6 */ |
| 120 | BB_DLPF_BANDSEL, /* 7 */ |
| 121 | RFSYN_CHP_GAIN, /* 8 */ |
| 122 | RFSYN_EN_CHP_HIGAIN, /* 9 */ |
| 123 | AGC_IF, /* 10 */ |
| 124 | AGC_RF, /* 11 */ |
| 125 | IF_DIVVAL, /* 12 */ |
| 126 | IF_VCO_BIAS, /* 13 */ |
| 127 | CHCAL_INT_MOD_IF, /* 14 */ |
| 128 | CHCAL_FRAC_MOD_IF, /* 15 */ |
| 129 | DRV_RES_SEL, /* 16 */ |
| 130 | I_DRIVER, /* 17 */ |
| 131 | EN_AAF, /* 18 */ |
| 132 | EN_3P, /* 19 */ |
| 133 | EN_AUX_3P, /* 20 */ |
| 134 | SEL_AAF_BAND, /* 21 */ |
| 135 | SEQ_ENCLK16_CLK_OUT, /* 22 */ |
| 136 | SEQ_SEL4_16B, /* 23 */ |
| 137 | XTAL_CAPSELECT, /* 24 */ |
| 138 | IF_SEL_DBL, /* 25 */ |
| 139 | RFSYN_R_DIV, /* 26 */ |
| 140 | SEQ_EXTSYNTHCALIF, /* 27 */ |
| 141 | SEQ_EXTDCCAL, /* 28 */ |
| 142 | AGC_EN_RSSI, /* 29 */ |
| 143 | RFA_ENCLKRFAGC, /* 30 */ |
| 144 | RFA_RSSI_REFH, /* 31 */ |
| 145 | RFA_RSSI_REF, /* 32 */ |
| 146 | RFA_RSSI_REFL, /* 33 */ |
| 147 | RFA_FLR, /* 34 */ |
| 148 | RFA_CEIL, /* 35 */ |
| 149 | SEQ_EXTIQFSMPULSE, /* 36 */ |
| 150 | OVERRIDE_1, /* 37 */ |
| 151 | BB_INITSTATE_DLPF_TUNE, /* 38 */ |
| 152 | TG_R_DIV, /* 39 */ |
| 153 | EN_CHP_LIN_B, /* 40 */ |
| 154 | |
| 155 | /* Channel Change Control Names */ |
| 156 | DN_POLY = 51, /* 51 */ |
| 157 | DN_RFGAIN, /* 52 */ |
| 158 | DN_CAP_RFLPF, /* 53 */ |
| 159 | DN_EN_VHFUHFBAR, /* 54 */ |
| 160 | DN_GAIN_ADJUST, /* 55 */ |
| 161 | DN_IQTNBUF_AMP, /* 56 */ |
| 162 | DN_IQTNGNBFBIAS_BST, /* 57 */ |
| 163 | RFSYN_EN_OUTMUX, /* 58 */ |
| 164 | RFSYN_SEL_VCO_OUT, /* 59 */ |
| 165 | RFSYN_SEL_VCO_HI, /* 60 */ |
| 166 | RFSYN_SEL_DIVM, /* 61 */ |
| 167 | RFSYN_RF_DIV_BIAS, /* 62 */ |
| 168 | DN_SEL_FREQ, /* 63 */ |
| 169 | RFSYN_VCO_BIAS, /* 64 */ |
| 170 | CHCAL_INT_MOD_RF, /* 65 */ |
| 171 | CHCAL_FRAC_MOD_RF, /* 66 */ |
| 172 | RFSYN_LPF_R, /* 67 */ |
| 173 | CHCAL_EN_INT_RF, /* 68 */ |
| 174 | TG_LO_DIVVAL, /* 69 */ |
| 175 | TG_LO_SELVAL, /* 70 */ |
| 176 | TG_DIV_VAL, /* 71 */ |
| 177 | TG_VCO_BIAS, /* 72 */ |
| 178 | SEQ_EXTPOWERUP, /* 73 */ |
| 179 | OVERRIDE_2, /* 74 */ |
| 180 | OVERRIDE_3, /* 75 */ |
| 181 | OVERRIDE_4, /* 76 */ |
| 182 | SEQ_FSM_PULSE, /* 77 */ |
| 183 | GPIO_4B, /* 78 */ |
| 184 | GPIO_3B, /* 79 */ |
| 185 | GPIO_4, /* 80 */ |
| 186 | GPIO_3, /* 81 */ |
| 187 | GPIO_1B, /* 82 */ |
| 188 | DAC_A_ENABLE, /* 83 */ |
| 189 | DAC_B_ENABLE, /* 84 */ |
| 190 | DAC_DIN_A, /* 85 */ |
| 191 | DAC_DIN_B, /* 86 */ |
| 192 | #ifdef _MXL_PRODUCTION |
| 193 | RFSYN_EN_DIV, /* 87 */ |
| 194 | RFSYN_DIVM, /* 88 */ |
| 195 | DN_BYPASS_AGC_I2C /* 89 */ |
| 196 | #endif |
Adrian Bunk | 38db143 | 2008-05-16 00:15:53 -0300 | [diff] [blame] | 197 | }; |
Steven Toth | 85d220d | 2008-05-01 05:48:14 -0300 | [diff] [blame] | 198 | |
| 199 | /* |
| 200 | * The following context is source code provided by MaxLinear. |
| 201 | * MaxLinear source code - Common_MXL.h (?) |
| 202 | */ |
| 203 | |
| 204 | /* Constants */ |
| 205 | #define MXL5005S_REG_WRITING_TABLE_LEN_MAX 104 |
| 206 | #define MXL5005S_LATCH_BYTE 0xfe |
| 207 | |
| 208 | /* Register address, MSB, and LSB */ |
| 209 | #define MXL5005S_BB_IQSWAP_ADDR 59 |
| 210 | #define MXL5005S_BB_IQSWAP_MSB 0 |
| 211 | #define MXL5005S_BB_IQSWAP_LSB 0 |
| 212 | |
| 213 | #define MXL5005S_BB_DLPF_BANDSEL_ADDR 53 |
| 214 | #define MXL5005S_BB_DLPF_BANDSEL_MSB 4 |
| 215 | #define MXL5005S_BB_DLPF_BANDSEL_LSB 3 |
| 216 | |
| 217 | /* Standard modes */ |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 218 | enum { |
Steven Toth | 85d220d | 2008-05-01 05:48:14 -0300 | [diff] [blame] | 219 | MXL5005S_STANDARD_DVBT, |
| 220 | MXL5005S_STANDARD_ATSC, |
| 221 | }; |
| 222 | #define MXL5005S_STANDARD_MODE_NUM 2 |
| 223 | |
| 224 | /* Bandwidth modes */ |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 225 | enum { |
Steven Toth | 85d220d | 2008-05-01 05:48:14 -0300 | [diff] [blame] | 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 Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 232 | /* MXL5005 Tuner Control Struct */ |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 233 | struct TunerControl { |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 234 | u16 Ctrl_Num; /* Control Number */ |
| 235 | u16 size; /* Number of bits to represent Value */ |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 236 | u16 addr[25]; /* Array of Tuner Register Address for each bit pos */ |
| 237 | u16 bit[25]; /* Array of bit pos in Reg Addr for each bit pos */ |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 238 | u16 val[25]; /* Binary representation of Value */ |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 239 | }; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 240 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 241 | /* MXL5005 Tuner Struct */ |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 242 | struct mxl5005s_state { |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 243 | u8 Mode; /* 0: Analog Mode ; 1: Digital Mode */ |
| 244 | u8 IF_Mode; /* for Analog Mode, 0: zero IF; 1: low IF */ |
| 245 | u32 Chan_Bandwidth; /* filter channel bandwidth (6, 7, 8) */ |
| 246 | u32 IF_OUT; /* Desired IF Out Frequency */ |
| 247 | u16 IF_OUT_LOAD; /* IF Out Load Resistor (200/300 Ohms) */ |
| 248 | u32 RF_IN; /* RF Input Frequency */ |
| 249 | u32 Fxtal; /* XTAL Frequency */ |
| 250 | u8 AGC_Mode; /* AGC Mode 0: Dual AGC; 1: Single AGC */ |
| 251 | u16 TOP; /* Value: take over point */ |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 252 | u8 CLOCK_OUT; /* 0: turn off clk out; 1: turn on clock out */ |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 253 | u8 DIV_OUT; /* 4MHz or 16MHz */ |
| 254 | u8 CAPSELECT; /* 0: disable On-Chip pulling cap; 1: enable */ |
| 255 | u8 EN_RSSI; /* 0: disable RSSI; 1: enable RSSI */ |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 256 | |
| 257 | /* Modulation Type; */ |
| 258 | /* 0 - Default; 1 - DVB-T; 2 - ATSC; 3 - QAM; 4 - Analog Cable */ |
| 259 | u8 Mod_Type; |
| 260 | |
| 261 | /* Tracking Filter Type */ |
| 262 | /* 0 - Default; 1 - Off; 2 - Type C; 3 - Type C-H */ |
| 263 | u8 TF_Type; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 264 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 265 | /* Calculated Settings */ |
| 266 | u32 RF_LO; /* Synth RF LO Frequency */ |
| 267 | u32 IF_LO; /* Synth IF LO Frequency */ |
| 268 | u32 TG_LO; /* Synth TG_LO Frequency */ |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 269 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 270 | /* Pointers to ControlName Arrays */ |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 271 | u16 Init_Ctrl_Num; /* Number of INIT Control Names */ |
| 272 | struct TunerControl |
| 273 | Init_Ctrl[INITCTRL_NUM]; /* INIT Control Names Array Pointer */ |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 274 | |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 275 | u16 CH_Ctrl_Num; /* Number of CH Control Names */ |
| 276 | struct TunerControl |
| 277 | CH_Ctrl[CHCTRL_NUM]; /* CH Control Name Array Pointer */ |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 278 | |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 279 | u16 MXL_Ctrl_Num; /* Number of MXL Control Names */ |
| 280 | struct TunerControl |
| 281 | MXL_Ctrl[MXLCTRL_NUM]; /* MXL Control Name Array Pointer */ |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 282 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 283 | /* Pointer to Tuner Register Array */ |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 284 | u16 TunerRegs_Num; /* Number of Tuner Registers */ |
| 285 | struct TunerReg |
| 286 | TunerRegs[TUNER_REGS_NUM]; /* Tuner Register Array Pointer */ |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 287 | |
Steven Toth | 85d220d | 2008-05-01 05:48:14 -0300 | [diff] [blame] | 288 | /* Linux driver framework specific */ |
Steven Toth | 4893729 | 2008-05-01 07:15:38 -0300 | [diff] [blame] | 289 | struct mxl5005s_config *config; |
Steven Toth | 85d220d | 2008-05-01 05:48:14 -0300 | [diff] [blame] | 290 | struct dvb_frontend *frontend; |
| 291 | struct i2c_adapter *i2c; |
Steven Toth | 4893729 | 2008-05-01 07:15:38 -0300 | [diff] [blame] | 292 | |
| 293 | /* Cache values */ |
| 294 | u32 current_mode; |
| 295 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 296 | }; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 297 | |
Steven Toth | c6c34b1 | 2008-05-03 14:14:54 -0300 | [diff] [blame] | 298 | static u16 MXL_GetMasterControl(u8 *MasterReg, int state); |
| 299 | static u16 MXL_ControlWrite(struct dvb_frontend *fe, u16 ControlNum, u32 value); |
| 300 | static u16 MXL_ControlRead(struct dvb_frontend *fe, u16 controlNum, u32 *value); |
| 301 | static void MXL_RegWriteBit(struct dvb_frontend *fe, u8 address, u8 bit, |
| 302 | u8 bitVal); |
| 303 | static u16 MXL_GetCHRegister(struct dvb_frontend *fe, u8 *RegNum, |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 304 | u8 *RegVal, int *count); |
Steven Toth | c6c34b1 | 2008-05-03 14:14:54 -0300 | [diff] [blame] | 305 | static u32 MXL_Ceiling(u32 value, u32 resolution); |
| 306 | static u16 MXL_RegRead(struct dvb_frontend *fe, u8 RegNum, u8 *RegVal); |
Steven Toth | c6c34b1 | 2008-05-03 14:14:54 -0300 | [diff] [blame] | 307 | static u16 MXL_ControlWrite_Group(struct dvb_frontend *fe, u16 controlNum, |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 308 | u32 value, u16 controlGroup); |
Steven Toth | c6c34b1 | 2008-05-03 14:14:54 -0300 | [diff] [blame] | 309 | static u16 MXL_SetGPIO(struct dvb_frontend *fe, u8 GPIO_Num, u8 GPIO_Val); |
| 310 | static u16 MXL_GetInitRegister(struct dvb_frontend *fe, u8 *RegNum, |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 311 | u8 *RegVal, int *count); |
Steven Toth | c6c34b1 | 2008-05-03 14:14:54 -0300 | [diff] [blame] | 312 | static u32 MXL_GetXtalInt(u32 Xtal_Freq); |
| 313 | static u16 MXL_TuneRF(struct dvb_frontend *fe, u32 RF_Freq); |
| 314 | static void MXL_SynthIFLO_Calc(struct dvb_frontend *fe); |
| 315 | static void MXL_SynthRFTGLO_Calc(struct dvb_frontend *fe); |
| 316 | static u16 MXL_GetCHRegister_ZeroIF(struct dvb_frontend *fe, u8 *RegNum, |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 317 | u8 *RegVal, int *count); |
Steven Toth | c6c34b1 | 2008-05-03 14:14:54 -0300 | [diff] [blame] | 318 | static int mxl5005s_writeregs(struct dvb_frontend *fe, u8 *addrtable, |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 319 | u8 *datatable, u8 len); |
Steven Toth | c6c34b1 | 2008-05-03 14:14:54 -0300 | [diff] [blame] | 320 | static u16 MXL_IFSynthInit(struct dvb_frontend *fe); |
| 321 | static int mxl5005s_AssignTunerMode(struct dvb_frontend *fe, u32 mod_type, |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 322 | u32 bandwidth); |
Steven Toth | c6c34b1 | 2008-05-03 14:14:54 -0300 | [diff] [blame] | 323 | static int mxl5005s_reconfigure(struct dvb_frontend *fe, u32 mod_type, |
| 324 | u32 bandwidth); |
Steven Toth | 4893729 | 2008-05-01 07:15:38 -0300 | [diff] [blame] | 325 | |
| 326 | /* ---------------------------------------------------------------- |
| 327 | * Begin: Custom code salvaged from the Realtek driver. |
Steven Toth | 7fa2a14 | 2008-05-03 14:25:55 -0300 | [diff] [blame] | 328 | * Copyright (C) 2008 Realtek |
| 329 | * Copyright (C) 2008 Jan Hoogenraad |
Steven Toth | 4893729 | 2008-05-01 07:15:38 -0300 | [diff] [blame] | 330 | * This code is placed under the terms of the GNU General Public License |
| 331 | * |
| 332 | * Released by Realtek under GPLv2. |
| 333 | * Thanks to Realtek for a lot of support we received ! |
| 334 | * |
| 335 | * Revision: 080314 - original version |
| 336 | */ |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 337 | |
Steven Toth | c6c34b1 | 2008-05-03 14:14:54 -0300 | [diff] [blame] | 338 | static int mxl5005s_SetRfFreqHz(struct dvb_frontend *fe, unsigned long RfFreqHz) |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 339 | { |
Steven Toth | 85d220d | 2008-05-01 05:48:14 -0300 | [diff] [blame] | 340 | struct mxl5005s_state *state = fe->tuner_priv; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 341 | unsigned char AddrTable[MXL5005S_REG_WRITING_TABLE_LEN_MAX]; |
| 342 | unsigned char ByteTable[MXL5005S_REG_WRITING_TABLE_LEN_MAX]; |
| 343 | int TableLen; |
| 344 | |
Steven Toth | c6c34b1 | 2008-05-03 14:14:54 -0300 | [diff] [blame] | 345 | u32 IfDivval = 0; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 346 | unsigned char MasterControlByte; |
| 347 | |
Steven Toth | 85d220d | 2008-05-01 05:48:14 -0300 | [diff] [blame] | 348 | dprintk(1, "%s() freq=%ld\n", __func__, RfFreqHz); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 349 | |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 350 | /* Set MxL5005S tuner RF frequency according to example code. */ |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 351 | |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 352 | /* Tuner RF frequency setting stage 0 */ |
| 353 | MXL_GetMasterControl(ByteTable, MC_SYNTH_RESET); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 354 | AddrTable[0] = MASTER_CONTROL_ADDR; |
Steven Toth | 85d220d | 2008-05-01 05:48:14 -0300 | [diff] [blame] | 355 | ByteTable[0] |= state->config->AgcMasterByte; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 356 | |
Steven Toth | 4893729 | 2008-05-01 07:15:38 -0300 | [diff] [blame] | 357 | mxl5005s_writeregs(fe, AddrTable, ByteTable, 1); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 358 | |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 359 | /* Tuner RF frequency setting stage 1 */ |
Steven Toth | 85d220d | 2008-05-01 05:48:14 -0300 | [diff] [blame] | 360 | MXL_TuneRF(fe, RfFreqHz); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 361 | |
Steven Toth | 85d220d | 2008-05-01 05:48:14 -0300 | [diff] [blame] | 362 | MXL_ControlRead(fe, IF_DIVVAL, &IfDivval); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 363 | |
Steven Toth | 85d220d | 2008-05-01 05:48:14 -0300 | [diff] [blame] | 364 | MXL_ControlWrite(fe, SEQ_FSM_PULSE, 0); |
| 365 | MXL_ControlWrite(fe, SEQ_EXTPOWERUP, 1); |
| 366 | MXL_ControlWrite(fe, IF_DIVVAL, 8); |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 367 | MXL_GetCHRegister(fe, AddrTable, ByteTable, &TableLen); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 368 | |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 369 | MXL_GetMasterControl(&MasterControlByte, MC_LOAD_START); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 370 | AddrTable[TableLen] = MASTER_CONTROL_ADDR ; |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 371 | ByteTable[TableLen] = MasterControlByte | |
| 372 | state->config->AgcMasterByte; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 373 | TableLen += 1; |
| 374 | |
Steven Toth | 4893729 | 2008-05-01 07:15:38 -0300 | [diff] [blame] | 375 | mxl5005s_writeregs(fe, AddrTable, ByteTable, TableLen); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 376 | |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 377 | /* Wait 30 ms. */ |
Steven Toth | 4893729 | 2008-05-01 07:15:38 -0300 | [diff] [blame] | 378 | msleep(150); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 379 | |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 380 | /* Tuner RF frequency setting stage 2 */ |
| 381 | MXL_ControlWrite(fe, SEQ_FSM_PULSE, 1); |
| 382 | MXL_ControlWrite(fe, IF_DIVVAL, IfDivval); |
| 383 | MXL_GetCHRegister_ZeroIF(fe, AddrTable, ByteTable, &TableLen); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 384 | |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 385 | MXL_GetMasterControl(&MasterControlByte, MC_LOAD_START); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 386 | AddrTable[TableLen] = MASTER_CONTROL_ADDR ; |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 387 | ByteTable[TableLen] = MasterControlByte | |
| 388 | state->config->AgcMasterByte ; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 389 | TableLen += 1; |
| 390 | |
Steven Toth | 4893729 | 2008-05-01 07:15:38 -0300 | [diff] [blame] | 391 | mxl5005s_writeregs(fe, AddrTable, ByteTable, TableLen); |
| 392 | |
| 393 | msleep(100); |
Steven Toth | 8c66a19 | 2008-05-01 06:35:48 -0300 | [diff] [blame] | 394 | |
Steven Toth | 85d220d | 2008-05-01 05:48:14 -0300 | [diff] [blame] | 395 | return 0; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 396 | } |
Steven Toth | 4893729 | 2008-05-01 07:15:38 -0300 | [diff] [blame] | 397 | /* End: Custom code taken from the Realtek driver */ |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 398 | |
Steven Toth | 4893729 | 2008-05-01 07:15:38 -0300 | [diff] [blame] | 399 | /* ---------------------------------------------------------------- |
| 400 | * Begin: Reference driver code found in the Realtek driver. |
Steven Toth | 7fa2a14 | 2008-05-03 14:25:55 -0300 | [diff] [blame] | 401 | * Copyright (C) 2008 MaxLinear |
Steven Toth | 4893729 | 2008-05-01 07:15:38 -0300 | [diff] [blame] | 402 | */ |
Steven Toth | c6c34b1 | 2008-05-03 14:14:54 -0300 | [diff] [blame] | 403 | static u16 MXL5005_RegisterInit(struct dvb_frontend *fe) |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 404 | { |
Steven Toth | 85d220d | 2008-05-01 05:48:14 -0300 | [diff] [blame] | 405 | struct mxl5005s_state *state = fe->tuner_priv; |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 406 | state->TunerRegs_Num = TUNER_REGS_NUM ; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 407 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 408 | state->TunerRegs[0].Reg_Num = 9 ; |
| 409 | state->TunerRegs[0].Reg_Val = 0x40 ; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 410 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 411 | state->TunerRegs[1].Reg_Num = 11 ; |
| 412 | state->TunerRegs[1].Reg_Val = 0x19 ; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 413 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 414 | state->TunerRegs[2].Reg_Num = 12 ; |
| 415 | state->TunerRegs[2].Reg_Val = 0x60 ; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 416 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 417 | state->TunerRegs[3].Reg_Num = 13 ; |
| 418 | state->TunerRegs[3].Reg_Val = 0x00 ; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 419 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 420 | state->TunerRegs[4].Reg_Num = 14 ; |
| 421 | state->TunerRegs[4].Reg_Val = 0x00 ; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 422 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 423 | state->TunerRegs[5].Reg_Num = 15 ; |
| 424 | state->TunerRegs[5].Reg_Val = 0xC0 ; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 425 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 426 | state->TunerRegs[6].Reg_Num = 16 ; |
| 427 | state->TunerRegs[6].Reg_Val = 0x00 ; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 428 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 429 | state->TunerRegs[7].Reg_Num = 17 ; |
| 430 | state->TunerRegs[7].Reg_Val = 0x00 ; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 431 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 432 | state->TunerRegs[8].Reg_Num = 18 ; |
| 433 | state->TunerRegs[8].Reg_Val = 0x00 ; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 434 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 435 | state->TunerRegs[9].Reg_Num = 19 ; |
| 436 | state->TunerRegs[9].Reg_Val = 0x34 ; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 437 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 438 | state->TunerRegs[10].Reg_Num = 21 ; |
| 439 | state->TunerRegs[10].Reg_Val = 0x00 ; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 440 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 441 | state->TunerRegs[11].Reg_Num = 22 ; |
| 442 | state->TunerRegs[11].Reg_Val = 0x6B ; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 443 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 444 | state->TunerRegs[12].Reg_Num = 23 ; |
| 445 | state->TunerRegs[12].Reg_Val = 0x35 ; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 446 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 447 | state->TunerRegs[13].Reg_Num = 24 ; |
| 448 | state->TunerRegs[13].Reg_Val = 0x70 ; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 449 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 450 | state->TunerRegs[14].Reg_Num = 25 ; |
| 451 | state->TunerRegs[14].Reg_Val = 0x3E ; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 452 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 453 | state->TunerRegs[15].Reg_Num = 26 ; |
| 454 | state->TunerRegs[15].Reg_Val = 0x82 ; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 455 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 456 | state->TunerRegs[16].Reg_Num = 31 ; |
| 457 | state->TunerRegs[16].Reg_Val = 0x00 ; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 458 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 459 | state->TunerRegs[17].Reg_Num = 32 ; |
| 460 | state->TunerRegs[17].Reg_Val = 0x40 ; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 461 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 462 | state->TunerRegs[18].Reg_Num = 33 ; |
| 463 | state->TunerRegs[18].Reg_Val = 0x53 ; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 464 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 465 | state->TunerRegs[19].Reg_Num = 34 ; |
| 466 | state->TunerRegs[19].Reg_Val = 0x81 ; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 467 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 468 | state->TunerRegs[20].Reg_Num = 35 ; |
| 469 | state->TunerRegs[20].Reg_Val = 0xC9 ; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 470 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 471 | state->TunerRegs[21].Reg_Num = 36 ; |
| 472 | state->TunerRegs[21].Reg_Val = 0x01 ; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 473 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 474 | state->TunerRegs[22].Reg_Num = 37 ; |
| 475 | state->TunerRegs[22].Reg_Val = 0x00 ; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 476 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 477 | state->TunerRegs[23].Reg_Num = 41 ; |
| 478 | state->TunerRegs[23].Reg_Val = 0x00 ; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 479 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 480 | state->TunerRegs[24].Reg_Num = 42 ; |
| 481 | state->TunerRegs[24].Reg_Val = 0xF8 ; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 482 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 483 | state->TunerRegs[25].Reg_Num = 43 ; |
| 484 | state->TunerRegs[25].Reg_Val = 0x43 ; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 485 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 486 | state->TunerRegs[26].Reg_Num = 44 ; |
| 487 | state->TunerRegs[26].Reg_Val = 0x20 ; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 488 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 489 | state->TunerRegs[27].Reg_Num = 45 ; |
| 490 | state->TunerRegs[27].Reg_Val = 0x80 ; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 491 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 492 | state->TunerRegs[28].Reg_Num = 46 ; |
| 493 | state->TunerRegs[28].Reg_Val = 0x88 ; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 494 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 495 | state->TunerRegs[29].Reg_Num = 47 ; |
| 496 | state->TunerRegs[29].Reg_Val = 0x86 ; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 497 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 498 | state->TunerRegs[30].Reg_Num = 48 ; |
| 499 | state->TunerRegs[30].Reg_Val = 0x00 ; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 500 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 501 | state->TunerRegs[31].Reg_Num = 49 ; |
| 502 | state->TunerRegs[31].Reg_Val = 0x00 ; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 503 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 504 | state->TunerRegs[32].Reg_Num = 53 ; |
| 505 | state->TunerRegs[32].Reg_Val = 0x94 ; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 506 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 507 | state->TunerRegs[33].Reg_Num = 54 ; |
| 508 | state->TunerRegs[33].Reg_Val = 0xFA ; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 509 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 510 | state->TunerRegs[34].Reg_Num = 55 ; |
| 511 | state->TunerRegs[34].Reg_Val = 0x92 ; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 512 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 513 | state->TunerRegs[35].Reg_Num = 56 ; |
| 514 | state->TunerRegs[35].Reg_Val = 0x80 ; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 515 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 516 | state->TunerRegs[36].Reg_Num = 57 ; |
| 517 | state->TunerRegs[36].Reg_Val = 0x41 ; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 518 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 519 | state->TunerRegs[37].Reg_Num = 58 ; |
| 520 | state->TunerRegs[37].Reg_Val = 0xDB ; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 521 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 522 | state->TunerRegs[38].Reg_Num = 59 ; |
| 523 | state->TunerRegs[38].Reg_Val = 0x00 ; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 524 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 525 | state->TunerRegs[39].Reg_Num = 60 ; |
| 526 | state->TunerRegs[39].Reg_Val = 0x00 ; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 527 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 528 | state->TunerRegs[40].Reg_Num = 61 ; |
| 529 | state->TunerRegs[40].Reg_Val = 0x00 ; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 530 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 531 | state->TunerRegs[41].Reg_Num = 62 ; |
| 532 | state->TunerRegs[41].Reg_Val = 0x00 ; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 533 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 534 | state->TunerRegs[42].Reg_Num = 65 ; |
| 535 | state->TunerRegs[42].Reg_Val = 0xF8 ; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 536 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 537 | state->TunerRegs[43].Reg_Num = 66 ; |
| 538 | state->TunerRegs[43].Reg_Val = 0xE4 ; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 539 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 540 | state->TunerRegs[44].Reg_Num = 67 ; |
| 541 | state->TunerRegs[44].Reg_Val = 0x90 ; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 542 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 543 | state->TunerRegs[45].Reg_Num = 68 ; |
| 544 | state->TunerRegs[45].Reg_Val = 0xC0 ; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 545 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 546 | state->TunerRegs[46].Reg_Num = 69 ; |
| 547 | state->TunerRegs[46].Reg_Val = 0x01 ; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 548 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 549 | state->TunerRegs[47].Reg_Num = 70 ; |
| 550 | state->TunerRegs[47].Reg_Val = 0x50 ; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 551 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 552 | state->TunerRegs[48].Reg_Num = 71 ; |
| 553 | state->TunerRegs[48].Reg_Val = 0x06 ; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 554 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 555 | state->TunerRegs[49].Reg_Num = 72 ; |
| 556 | state->TunerRegs[49].Reg_Val = 0x00 ; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 557 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 558 | state->TunerRegs[50].Reg_Num = 73 ; |
| 559 | state->TunerRegs[50].Reg_Val = 0x20 ; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 560 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 561 | state->TunerRegs[51].Reg_Num = 76 ; |
| 562 | state->TunerRegs[51].Reg_Val = 0xBB ; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 563 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 564 | state->TunerRegs[52].Reg_Num = 77 ; |
| 565 | state->TunerRegs[52].Reg_Val = 0x13 ; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 566 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 567 | state->TunerRegs[53].Reg_Num = 81 ; |
| 568 | state->TunerRegs[53].Reg_Val = 0x04 ; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 569 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 570 | state->TunerRegs[54].Reg_Num = 82 ; |
| 571 | state->TunerRegs[54].Reg_Val = 0x75 ; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 572 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 573 | state->TunerRegs[55].Reg_Num = 83 ; |
| 574 | state->TunerRegs[55].Reg_Val = 0x00 ; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 575 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 576 | state->TunerRegs[56].Reg_Num = 84 ; |
| 577 | state->TunerRegs[56].Reg_Val = 0x00 ; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 578 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 579 | state->TunerRegs[57].Reg_Num = 85 ; |
| 580 | state->TunerRegs[57].Reg_Val = 0x00 ; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 581 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 582 | state->TunerRegs[58].Reg_Num = 91 ; |
| 583 | state->TunerRegs[58].Reg_Val = 0x70 ; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 584 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 585 | state->TunerRegs[59].Reg_Num = 92 ; |
| 586 | state->TunerRegs[59].Reg_Val = 0x00 ; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 587 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 588 | state->TunerRegs[60].Reg_Num = 93 ; |
| 589 | state->TunerRegs[60].Reg_Val = 0x00 ; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 590 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 591 | state->TunerRegs[61].Reg_Num = 94 ; |
| 592 | state->TunerRegs[61].Reg_Val = 0x00 ; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 593 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 594 | state->TunerRegs[62].Reg_Num = 95 ; |
| 595 | state->TunerRegs[62].Reg_Val = 0x0C ; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 596 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 597 | state->TunerRegs[63].Reg_Num = 96 ; |
| 598 | state->TunerRegs[63].Reg_Val = 0x00 ; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 599 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 600 | state->TunerRegs[64].Reg_Num = 97 ; |
| 601 | state->TunerRegs[64].Reg_Val = 0x00 ; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 602 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 603 | state->TunerRegs[65].Reg_Num = 98 ; |
| 604 | state->TunerRegs[65].Reg_Val = 0xE2 ; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 605 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 606 | state->TunerRegs[66].Reg_Num = 99 ; |
| 607 | state->TunerRegs[66].Reg_Val = 0x00 ; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 608 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 609 | state->TunerRegs[67].Reg_Num = 100 ; |
| 610 | state->TunerRegs[67].Reg_Val = 0x00 ; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 611 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 612 | state->TunerRegs[68].Reg_Num = 101 ; |
| 613 | state->TunerRegs[68].Reg_Val = 0x12 ; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 614 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 615 | state->TunerRegs[69].Reg_Num = 102 ; |
| 616 | state->TunerRegs[69].Reg_Val = 0x80 ; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 617 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 618 | state->TunerRegs[70].Reg_Num = 103 ; |
| 619 | state->TunerRegs[70].Reg_Val = 0x32 ; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 620 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 621 | state->TunerRegs[71].Reg_Num = 104 ; |
| 622 | state->TunerRegs[71].Reg_Val = 0xB4 ; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 623 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 624 | state->TunerRegs[72].Reg_Num = 105 ; |
| 625 | state->TunerRegs[72].Reg_Val = 0x60 ; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 626 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 627 | state->TunerRegs[73].Reg_Num = 106 ; |
| 628 | state->TunerRegs[73].Reg_Val = 0x83 ; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 629 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 630 | state->TunerRegs[74].Reg_Num = 107 ; |
| 631 | state->TunerRegs[74].Reg_Val = 0x84 ; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 632 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 633 | state->TunerRegs[75].Reg_Num = 108 ; |
| 634 | state->TunerRegs[75].Reg_Val = 0x9C ; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 635 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 636 | state->TunerRegs[76].Reg_Num = 109 ; |
| 637 | state->TunerRegs[76].Reg_Val = 0x02 ; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 638 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 639 | state->TunerRegs[77].Reg_Num = 110 ; |
| 640 | state->TunerRegs[77].Reg_Val = 0x81 ; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 641 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 642 | state->TunerRegs[78].Reg_Num = 111 ; |
| 643 | state->TunerRegs[78].Reg_Val = 0xC0 ; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 644 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 645 | state->TunerRegs[79].Reg_Num = 112 ; |
| 646 | state->TunerRegs[79].Reg_Val = 0x10 ; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 647 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 648 | state->TunerRegs[80].Reg_Num = 131 ; |
| 649 | state->TunerRegs[80].Reg_Val = 0x8A ; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 650 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 651 | state->TunerRegs[81].Reg_Num = 132 ; |
| 652 | state->TunerRegs[81].Reg_Val = 0x10 ; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 653 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 654 | state->TunerRegs[82].Reg_Num = 133 ; |
| 655 | state->TunerRegs[82].Reg_Val = 0x24 ; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 656 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 657 | state->TunerRegs[83].Reg_Num = 134 ; |
| 658 | state->TunerRegs[83].Reg_Val = 0x00 ; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 659 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 660 | state->TunerRegs[84].Reg_Num = 135 ; |
| 661 | state->TunerRegs[84].Reg_Val = 0x00 ; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 662 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 663 | state->TunerRegs[85].Reg_Num = 136 ; |
| 664 | state->TunerRegs[85].Reg_Val = 0x7E ; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 665 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 666 | state->TunerRegs[86].Reg_Num = 137 ; |
| 667 | state->TunerRegs[86].Reg_Val = 0x40 ; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 668 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 669 | state->TunerRegs[87].Reg_Num = 138 ; |
| 670 | state->TunerRegs[87].Reg_Val = 0x38 ; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 671 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 672 | state->TunerRegs[88].Reg_Num = 146 ; |
| 673 | state->TunerRegs[88].Reg_Val = 0xF6 ; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 674 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 675 | state->TunerRegs[89].Reg_Num = 147 ; |
| 676 | state->TunerRegs[89].Reg_Val = 0x1A ; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 677 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 678 | state->TunerRegs[90].Reg_Num = 148 ; |
| 679 | state->TunerRegs[90].Reg_Val = 0x62 ; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 680 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 681 | state->TunerRegs[91].Reg_Num = 149 ; |
| 682 | state->TunerRegs[91].Reg_Val = 0x33 ; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 683 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 684 | state->TunerRegs[92].Reg_Num = 150 ; |
| 685 | state->TunerRegs[92].Reg_Val = 0x80 ; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 686 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 687 | state->TunerRegs[93].Reg_Num = 156 ; |
| 688 | state->TunerRegs[93].Reg_Val = 0x56 ; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 689 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 690 | state->TunerRegs[94].Reg_Num = 157 ; |
| 691 | state->TunerRegs[94].Reg_Val = 0x17 ; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 692 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 693 | state->TunerRegs[95].Reg_Num = 158 ; |
| 694 | state->TunerRegs[95].Reg_Val = 0xA9 ; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 695 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 696 | state->TunerRegs[96].Reg_Num = 159 ; |
| 697 | state->TunerRegs[96].Reg_Val = 0x00 ; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 698 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 699 | state->TunerRegs[97].Reg_Num = 160 ; |
| 700 | state->TunerRegs[97].Reg_Val = 0x00 ; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 701 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 702 | state->TunerRegs[98].Reg_Num = 161 ; |
| 703 | state->TunerRegs[98].Reg_Val = 0x00 ; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 704 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 705 | state->TunerRegs[99].Reg_Num = 162 ; |
| 706 | state->TunerRegs[99].Reg_Val = 0x40 ; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 707 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 708 | state->TunerRegs[100].Reg_Num = 166 ; |
| 709 | state->TunerRegs[100].Reg_Val = 0xAE ; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 710 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 711 | state->TunerRegs[101].Reg_Num = 167 ; |
| 712 | state->TunerRegs[101].Reg_Val = 0x1B ; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 713 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 714 | state->TunerRegs[102].Reg_Num = 168 ; |
| 715 | state->TunerRegs[102].Reg_Val = 0xF2 ; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 716 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 717 | state->TunerRegs[103].Reg_Num = 195 ; |
| 718 | state->TunerRegs[103].Reg_Val = 0x00 ; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 719 | |
| 720 | return 0 ; |
| 721 | } |
| 722 | |
Steven Toth | c6c34b1 | 2008-05-03 14:14:54 -0300 | [diff] [blame] | 723 | static u16 MXL5005_ControlInit(struct dvb_frontend *fe) |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 724 | { |
Steven Toth | 85d220d | 2008-05-01 05:48:14 -0300 | [diff] [blame] | 725 | struct mxl5005s_state *state = fe->tuner_priv; |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 726 | state->Init_Ctrl_Num = INITCTRL_NUM; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 727 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 728 | state->Init_Ctrl[0].Ctrl_Num = DN_IQTN_AMP_CUT ; |
| 729 | state->Init_Ctrl[0].size = 1 ; |
| 730 | state->Init_Ctrl[0].addr[0] = 73; |
| 731 | state->Init_Ctrl[0].bit[0] = 7; |
| 732 | state->Init_Ctrl[0].val[0] = 0; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 733 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 734 | state->Init_Ctrl[1].Ctrl_Num = BB_MODE ; |
| 735 | state->Init_Ctrl[1].size = 1 ; |
| 736 | state->Init_Ctrl[1].addr[0] = 53; |
| 737 | state->Init_Ctrl[1].bit[0] = 2; |
| 738 | state->Init_Ctrl[1].val[0] = 1; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 739 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 740 | state->Init_Ctrl[2].Ctrl_Num = BB_BUF ; |
| 741 | state->Init_Ctrl[2].size = 2 ; |
| 742 | state->Init_Ctrl[2].addr[0] = 53; |
| 743 | state->Init_Ctrl[2].bit[0] = 1; |
| 744 | state->Init_Ctrl[2].val[0] = 0; |
| 745 | state->Init_Ctrl[2].addr[1] = 57; |
| 746 | state->Init_Ctrl[2].bit[1] = 0; |
| 747 | state->Init_Ctrl[2].val[1] = 1; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 748 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 749 | state->Init_Ctrl[3].Ctrl_Num = BB_BUF_OA ; |
| 750 | state->Init_Ctrl[3].size = 1 ; |
| 751 | state->Init_Ctrl[3].addr[0] = 53; |
| 752 | state->Init_Ctrl[3].bit[0] = 0; |
| 753 | state->Init_Ctrl[3].val[0] = 0; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 754 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 755 | state->Init_Ctrl[4].Ctrl_Num = BB_ALPF_BANDSELECT ; |
| 756 | state->Init_Ctrl[4].size = 3 ; |
| 757 | state->Init_Ctrl[4].addr[0] = 53; |
| 758 | state->Init_Ctrl[4].bit[0] = 5; |
| 759 | state->Init_Ctrl[4].val[0] = 0; |
| 760 | state->Init_Ctrl[4].addr[1] = 53; |
| 761 | state->Init_Ctrl[4].bit[1] = 6; |
| 762 | state->Init_Ctrl[4].val[1] = 0; |
| 763 | state->Init_Ctrl[4].addr[2] = 53; |
| 764 | state->Init_Ctrl[4].bit[2] = 7; |
| 765 | state->Init_Ctrl[4].val[2] = 1; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 766 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 767 | state->Init_Ctrl[5].Ctrl_Num = BB_IQSWAP ; |
| 768 | state->Init_Ctrl[5].size = 1 ; |
| 769 | state->Init_Ctrl[5].addr[0] = 59; |
| 770 | state->Init_Ctrl[5].bit[0] = 0; |
| 771 | state->Init_Ctrl[5].val[0] = 0; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 772 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 773 | state->Init_Ctrl[6].Ctrl_Num = BB_DLPF_BANDSEL ; |
| 774 | state->Init_Ctrl[6].size = 2 ; |
| 775 | state->Init_Ctrl[6].addr[0] = 53; |
| 776 | state->Init_Ctrl[6].bit[0] = 3; |
| 777 | state->Init_Ctrl[6].val[0] = 0; |
| 778 | state->Init_Ctrl[6].addr[1] = 53; |
| 779 | state->Init_Ctrl[6].bit[1] = 4; |
| 780 | state->Init_Ctrl[6].val[1] = 1; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 781 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 782 | state->Init_Ctrl[7].Ctrl_Num = RFSYN_CHP_GAIN ; |
| 783 | state->Init_Ctrl[7].size = 4 ; |
| 784 | state->Init_Ctrl[7].addr[0] = 22; |
| 785 | state->Init_Ctrl[7].bit[0] = 4; |
| 786 | state->Init_Ctrl[7].val[0] = 0; |
| 787 | state->Init_Ctrl[7].addr[1] = 22; |
| 788 | state->Init_Ctrl[7].bit[1] = 5; |
| 789 | state->Init_Ctrl[7].val[1] = 1; |
| 790 | state->Init_Ctrl[7].addr[2] = 22; |
| 791 | state->Init_Ctrl[7].bit[2] = 6; |
| 792 | state->Init_Ctrl[7].val[2] = 1; |
| 793 | state->Init_Ctrl[7].addr[3] = 22; |
| 794 | state->Init_Ctrl[7].bit[3] = 7; |
| 795 | state->Init_Ctrl[7].val[3] = 0; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 796 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 797 | state->Init_Ctrl[8].Ctrl_Num = RFSYN_EN_CHP_HIGAIN ; |
| 798 | state->Init_Ctrl[8].size = 1 ; |
| 799 | state->Init_Ctrl[8].addr[0] = 22; |
| 800 | state->Init_Ctrl[8].bit[0] = 2; |
| 801 | state->Init_Ctrl[8].val[0] = 0; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 802 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 803 | state->Init_Ctrl[9].Ctrl_Num = AGC_IF ; |
| 804 | state->Init_Ctrl[9].size = 4 ; |
| 805 | state->Init_Ctrl[9].addr[0] = 76; |
| 806 | state->Init_Ctrl[9].bit[0] = 0; |
| 807 | state->Init_Ctrl[9].val[0] = 1; |
| 808 | state->Init_Ctrl[9].addr[1] = 76; |
| 809 | state->Init_Ctrl[9].bit[1] = 1; |
| 810 | state->Init_Ctrl[9].val[1] = 1; |
| 811 | state->Init_Ctrl[9].addr[2] = 76; |
| 812 | state->Init_Ctrl[9].bit[2] = 2; |
| 813 | state->Init_Ctrl[9].val[2] = 0; |
| 814 | state->Init_Ctrl[9].addr[3] = 76; |
| 815 | state->Init_Ctrl[9].bit[3] = 3; |
| 816 | state->Init_Ctrl[9].val[3] = 1; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 817 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 818 | state->Init_Ctrl[10].Ctrl_Num = AGC_RF ; |
| 819 | state->Init_Ctrl[10].size = 4 ; |
| 820 | state->Init_Ctrl[10].addr[0] = 76; |
| 821 | state->Init_Ctrl[10].bit[0] = 4; |
| 822 | state->Init_Ctrl[10].val[0] = 1; |
| 823 | state->Init_Ctrl[10].addr[1] = 76; |
| 824 | state->Init_Ctrl[10].bit[1] = 5; |
| 825 | state->Init_Ctrl[10].val[1] = 1; |
| 826 | state->Init_Ctrl[10].addr[2] = 76; |
| 827 | state->Init_Ctrl[10].bit[2] = 6; |
| 828 | state->Init_Ctrl[10].val[2] = 0; |
| 829 | state->Init_Ctrl[10].addr[3] = 76; |
| 830 | state->Init_Ctrl[10].bit[3] = 7; |
| 831 | state->Init_Ctrl[10].val[3] = 1; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 832 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 833 | state->Init_Ctrl[11].Ctrl_Num = IF_DIVVAL ; |
| 834 | state->Init_Ctrl[11].size = 5 ; |
| 835 | state->Init_Ctrl[11].addr[0] = 43; |
| 836 | state->Init_Ctrl[11].bit[0] = 3; |
| 837 | state->Init_Ctrl[11].val[0] = 0; |
| 838 | state->Init_Ctrl[11].addr[1] = 43; |
| 839 | state->Init_Ctrl[11].bit[1] = 4; |
| 840 | state->Init_Ctrl[11].val[1] = 0; |
| 841 | state->Init_Ctrl[11].addr[2] = 43; |
| 842 | state->Init_Ctrl[11].bit[2] = 5; |
| 843 | state->Init_Ctrl[11].val[2] = 0; |
| 844 | state->Init_Ctrl[11].addr[3] = 43; |
| 845 | state->Init_Ctrl[11].bit[3] = 6; |
| 846 | state->Init_Ctrl[11].val[3] = 1; |
| 847 | state->Init_Ctrl[11].addr[4] = 43; |
| 848 | state->Init_Ctrl[11].bit[4] = 7; |
| 849 | state->Init_Ctrl[11].val[4] = 0; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 850 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 851 | state->Init_Ctrl[12].Ctrl_Num = IF_VCO_BIAS ; |
| 852 | state->Init_Ctrl[12].size = 6 ; |
| 853 | state->Init_Ctrl[12].addr[0] = 44; |
| 854 | state->Init_Ctrl[12].bit[0] = 2; |
| 855 | state->Init_Ctrl[12].val[0] = 0; |
| 856 | state->Init_Ctrl[12].addr[1] = 44; |
| 857 | state->Init_Ctrl[12].bit[1] = 3; |
| 858 | state->Init_Ctrl[12].val[1] = 0; |
| 859 | state->Init_Ctrl[12].addr[2] = 44; |
| 860 | state->Init_Ctrl[12].bit[2] = 4; |
| 861 | state->Init_Ctrl[12].val[2] = 0; |
| 862 | state->Init_Ctrl[12].addr[3] = 44; |
| 863 | state->Init_Ctrl[12].bit[3] = 5; |
| 864 | state->Init_Ctrl[12].val[3] = 1; |
| 865 | state->Init_Ctrl[12].addr[4] = 44; |
| 866 | state->Init_Ctrl[12].bit[4] = 6; |
| 867 | state->Init_Ctrl[12].val[4] = 0; |
| 868 | state->Init_Ctrl[12].addr[5] = 44; |
| 869 | state->Init_Ctrl[12].bit[5] = 7; |
| 870 | state->Init_Ctrl[12].val[5] = 0; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 871 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 872 | state->Init_Ctrl[13].Ctrl_Num = CHCAL_INT_MOD_IF ; |
| 873 | state->Init_Ctrl[13].size = 7 ; |
| 874 | state->Init_Ctrl[13].addr[0] = 11; |
| 875 | state->Init_Ctrl[13].bit[0] = 0; |
| 876 | state->Init_Ctrl[13].val[0] = 1; |
| 877 | state->Init_Ctrl[13].addr[1] = 11; |
| 878 | state->Init_Ctrl[13].bit[1] = 1; |
| 879 | state->Init_Ctrl[13].val[1] = 0; |
| 880 | state->Init_Ctrl[13].addr[2] = 11; |
| 881 | state->Init_Ctrl[13].bit[2] = 2; |
| 882 | state->Init_Ctrl[13].val[2] = 0; |
| 883 | state->Init_Ctrl[13].addr[3] = 11; |
| 884 | state->Init_Ctrl[13].bit[3] = 3; |
| 885 | state->Init_Ctrl[13].val[3] = 1; |
| 886 | state->Init_Ctrl[13].addr[4] = 11; |
| 887 | state->Init_Ctrl[13].bit[4] = 4; |
| 888 | state->Init_Ctrl[13].val[4] = 1; |
| 889 | state->Init_Ctrl[13].addr[5] = 11; |
| 890 | state->Init_Ctrl[13].bit[5] = 5; |
| 891 | state->Init_Ctrl[13].val[5] = 0; |
| 892 | state->Init_Ctrl[13].addr[6] = 11; |
| 893 | state->Init_Ctrl[13].bit[6] = 6; |
| 894 | state->Init_Ctrl[13].val[6] = 0; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 895 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 896 | state->Init_Ctrl[14].Ctrl_Num = CHCAL_FRAC_MOD_IF ; |
| 897 | state->Init_Ctrl[14].size = 16 ; |
| 898 | state->Init_Ctrl[14].addr[0] = 13; |
| 899 | state->Init_Ctrl[14].bit[0] = 0; |
| 900 | state->Init_Ctrl[14].val[0] = 0; |
| 901 | state->Init_Ctrl[14].addr[1] = 13; |
| 902 | state->Init_Ctrl[14].bit[1] = 1; |
| 903 | state->Init_Ctrl[14].val[1] = 0; |
| 904 | state->Init_Ctrl[14].addr[2] = 13; |
| 905 | state->Init_Ctrl[14].bit[2] = 2; |
| 906 | state->Init_Ctrl[14].val[2] = 0; |
| 907 | state->Init_Ctrl[14].addr[3] = 13; |
| 908 | state->Init_Ctrl[14].bit[3] = 3; |
| 909 | state->Init_Ctrl[14].val[3] = 0; |
| 910 | state->Init_Ctrl[14].addr[4] = 13; |
| 911 | state->Init_Ctrl[14].bit[4] = 4; |
| 912 | state->Init_Ctrl[14].val[4] = 0; |
| 913 | state->Init_Ctrl[14].addr[5] = 13; |
| 914 | state->Init_Ctrl[14].bit[5] = 5; |
| 915 | state->Init_Ctrl[14].val[5] = 0; |
| 916 | state->Init_Ctrl[14].addr[6] = 13; |
| 917 | state->Init_Ctrl[14].bit[6] = 6; |
| 918 | state->Init_Ctrl[14].val[6] = 0; |
| 919 | state->Init_Ctrl[14].addr[7] = 13; |
| 920 | state->Init_Ctrl[14].bit[7] = 7; |
| 921 | state->Init_Ctrl[14].val[7] = 0; |
| 922 | state->Init_Ctrl[14].addr[8] = 12; |
| 923 | state->Init_Ctrl[14].bit[8] = 0; |
| 924 | state->Init_Ctrl[14].val[8] = 0; |
| 925 | state->Init_Ctrl[14].addr[9] = 12; |
| 926 | state->Init_Ctrl[14].bit[9] = 1; |
| 927 | state->Init_Ctrl[14].val[9] = 0; |
| 928 | state->Init_Ctrl[14].addr[10] = 12; |
| 929 | state->Init_Ctrl[14].bit[10] = 2; |
| 930 | state->Init_Ctrl[14].val[10] = 0; |
| 931 | state->Init_Ctrl[14].addr[11] = 12; |
| 932 | state->Init_Ctrl[14].bit[11] = 3; |
| 933 | state->Init_Ctrl[14].val[11] = 0; |
| 934 | state->Init_Ctrl[14].addr[12] = 12; |
| 935 | state->Init_Ctrl[14].bit[12] = 4; |
| 936 | state->Init_Ctrl[14].val[12] = 0; |
| 937 | state->Init_Ctrl[14].addr[13] = 12; |
| 938 | state->Init_Ctrl[14].bit[13] = 5; |
| 939 | state->Init_Ctrl[14].val[13] = 1; |
| 940 | state->Init_Ctrl[14].addr[14] = 12; |
| 941 | state->Init_Ctrl[14].bit[14] = 6; |
| 942 | state->Init_Ctrl[14].val[14] = 1; |
| 943 | state->Init_Ctrl[14].addr[15] = 12; |
| 944 | state->Init_Ctrl[14].bit[15] = 7; |
| 945 | state->Init_Ctrl[14].val[15] = 0; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 946 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 947 | state->Init_Ctrl[15].Ctrl_Num = DRV_RES_SEL ; |
| 948 | state->Init_Ctrl[15].size = 3 ; |
| 949 | state->Init_Ctrl[15].addr[0] = 147; |
| 950 | state->Init_Ctrl[15].bit[0] = 2; |
| 951 | state->Init_Ctrl[15].val[0] = 0; |
| 952 | state->Init_Ctrl[15].addr[1] = 147; |
| 953 | state->Init_Ctrl[15].bit[1] = 3; |
| 954 | state->Init_Ctrl[15].val[1] = 1; |
| 955 | state->Init_Ctrl[15].addr[2] = 147; |
| 956 | state->Init_Ctrl[15].bit[2] = 4; |
| 957 | state->Init_Ctrl[15].val[2] = 1; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 958 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 959 | state->Init_Ctrl[16].Ctrl_Num = I_DRIVER ; |
| 960 | state->Init_Ctrl[16].size = 2 ; |
| 961 | state->Init_Ctrl[16].addr[0] = 147; |
| 962 | state->Init_Ctrl[16].bit[0] = 0; |
| 963 | state->Init_Ctrl[16].val[0] = 0; |
| 964 | state->Init_Ctrl[16].addr[1] = 147; |
| 965 | state->Init_Ctrl[16].bit[1] = 1; |
| 966 | state->Init_Ctrl[16].val[1] = 1; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 967 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 968 | state->Init_Ctrl[17].Ctrl_Num = EN_AAF ; |
| 969 | state->Init_Ctrl[17].size = 1 ; |
| 970 | state->Init_Ctrl[17].addr[0] = 147; |
| 971 | state->Init_Ctrl[17].bit[0] = 7; |
| 972 | state->Init_Ctrl[17].val[0] = 0; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 973 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 974 | state->Init_Ctrl[18].Ctrl_Num = EN_3P ; |
| 975 | state->Init_Ctrl[18].size = 1 ; |
| 976 | state->Init_Ctrl[18].addr[0] = 147; |
| 977 | state->Init_Ctrl[18].bit[0] = 6; |
| 978 | state->Init_Ctrl[18].val[0] = 0; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 979 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 980 | state->Init_Ctrl[19].Ctrl_Num = EN_AUX_3P ; |
| 981 | state->Init_Ctrl[19].size = 1 ; |
| 982 | state->Init_Ctrl[19].addr[0] = 156; |
| 983 | state->Init_Ctrl[19].bit[0] = 0; |
| 984 | state->Init_Ctrl[19].val[0] = 0; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 985 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 986 | state->Init_Ctrl[20].Ctrl_Num = SEL_AAF_BAND ; |
| 987 | state->Init_Ctrl[20].size = 1 ; |
| 988 | state->Init_Ctrl[20].addr[0] = 147; |
| 989 | state->Init_Ctrl[20].bit[0] = 5; |
| 990 | state->Init_Ctrl[20].val[0] = 0; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 991 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 992 | state->Init_Ctrl[21].Ctrl_Num = SEQ_ENCLK16_CLK_OUT ; |
| 993 | state->Init_Ctrl[21].size = 1 ; |
| 994 | state->Init_Ctrl[21].addr[0] = 137; |
| 995 | state->Init_Ctrl[21].bit[0] = 4; |
| 996 | state->Init_Ctrl[21].val[0] = 0; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 997 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 998 | state->Init_Ctrl[22].Ctrl_Num = SEQ_SEL4_16B ; |
| 999 | state->Init_Ctrl[22].size = 1 ; |
| 1000 | state->Init_Ctrl[22].addr[0] = 137; |
| 1001 | state->Init_Ctrl[22].bit[0] = 7; |
| 1002 | state->Init_Ctrl[22].val[0] = 0; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 1003 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 1004 | state->Init_Ctrl[23].Ctrl_Num = XTAL_CAPSELECT ; |
| 1005 | state->Init_Ctrl[23].size = 1 ; |
| 1006 | state->Init_Ctrl[23].addr[0] = 91; |
| 1007 | state->Init_Ctrl[23].bit[0] = 5; |
| 1008 | state->Init_Ctrl[23].val[0] = 1; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 1009 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 1010 | state->Init_Ctrl[24].Ctrl_Num = IF_SEL_DBL ; |
| 1011 | state->Init_Ctrl[24].size = 1 ; |
| 1012 | state->Init_Ctrl[24].addr[0] = 43; |
| 1013 | state->Init_Ctrl[24].bit[0] = 0; |
| 1014 | state->Init_Ctrl[24].val[0] = 1; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 1015 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 1016 | state->Init_Ctrl[25].Ctrl_Num = RFSYN_R_DIV ; |
| 1017 | state->Init_Ctrl[25].size = 2 ; |
| 1018 | state->Init_Ctrl[25].addr[0] = 22; |
| 1019 | state->Init_Ctrl[25].bit[0] = 0; |
| 1020 | state->Init_Ctrl[25].val[0] = 1; |
| 1021 | state->Init_Ctrl[25].addr[1] = 22; |
| 1022 | state->Init_Ctrl[25].bit[1] = 1; |
| 1023 | state->Init_Ctrl[25].val[1] = 1; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 1024 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 1025 | state->Init_Ctrl[26].Ctrl_Num = SEQ_EXTSYNTHCALIF ; |
| 1026 | state->Init_Ctrl[26].size = 1 ; |
| 1027 | state->Init_Ctrl[26].addr[0] = 134; |
| 1028 | state->Init_Ctrl[26].bit[0] = 2; |
| 1029 | state->Init_Ctrl[26].val[0] = 0; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 1030 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 1031 | state->Init_Ctrl[27].Ctrl_Num = SEQ_EXTDCCAL ; |
| 1032 | state->Init_Ctrl[27].size = 1 ; |
| 1033 | state->Init_Ctrl[27].addr[0] = 137; |
| 1034 | state->Init_Ctrl[27].bit[0] = 3; |
| 1035 | state->Init_Ctrl[27].val[0] = 0; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 1036 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 1037 | state->Init_Ctrl[28].Ctrl_Num = AGC_EN_RSSI ; |
| 1038 | state->Init_Ctrl[28].size = 1 ; |
| 1039 | state->Init_Ctrl[28].addr[0] = 77; |
| 1040 | state->Init_Ctrl[28].bit[0] = 7; |
| 1041 | state->Init_Ctrl[28].val[0] = 0; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 1042 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 1043 | state->Init_Ctrl[29].Ctrl_Num = RFA_ENCLKRFAGC ; |
| 1044 | state->Init_Ctrl[29].size = 1 ; |
| 1045 | state->Init_Ctrl[29].addr[0] = 166; |
| 1046 | state->Init_Ctrl[29].bit[0] = 7; |
| 1047 | state->Init_Ctrl[29].val[0] = 1; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 1048 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 1049 | state->Init_Ctrl[30].Ctrl_Num = RFA_RSSI_REFH ; |
| 1050 | state->Init_Ctrl[30].size = 3 ; |
| 1051 | state->Init_Ctrl[30].addr[0] = 166; |
| 1052 | state->Init_Ctrl[30].bit[0] = 0; |
| 1053 | state->Init_Ctrl[30].val[0] = 0; |
| 1054 | state->Init_Ctrl[30].addr[1] = 166; |
| 1055 | state->Init_Ctrl[30].bit[1] = 1; |
| 1056 | state->Init_Ctrl[30].val[1] = 1; |
| 1057 | state->Init_Ctrl[30].addr[2] = 166; |
| 1058 | state->Init_Ctrl[30].bit[2] = 2; |
| 1059 | state->Init_Ctrl[30].val[2] = 1; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 1060 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 1061 | state->Init_Ctrl[31].Ctrl_Num = RFA_RSSI_REF ; |
| 1062 | state->Init_Ctrl[31].size = 3 ; |
| 1063 | state->Init_Ctrl[31].addr[0] = 166; |
| 1064 | state->Init_Ctrl[31].bit[0] = 3; |
| 1065 | state->Init_Ctrl[31].val[0] = 1; |
| 1066 | state->Init_Ctrl[31].addr[1] = 166; |
| 1067 | state->Init_Ctrl[31].bit[1] = 4; |
| 1068 | state->Init_Ctrl[31].val[1] = 0; |
| 1069 | state->Init_Ctrl[31].addr[2] = 166; |
| 1070 | state->Init_Ctrl[31].bit[2] = 5; |
| 1071 | state->Init_Ctrl[31].val[2] = 1; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 1072 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 1073 | state->Init_Ctrl[32].Ctrl_Num = RFA_RSSI_REFL ; |
| 1074 | state->Init_Ctrl[32].size = 3 ; |
| 1075 | state->Init_Ctrl[32].addr[0] = 167; |
| 1076 | state->Init_Ctrl[32].bit[0] = 0; |
| 1077 | state->Init_Ctrl[32].val[0] = 1; |
| 1078 | state->Init_Ctrl[32].addr[1] = 167; |
| 1079 | state->Init_Ctrl[32].bit[1] = 1; |
| 1080 | state->Init_Ctrl[32].val[1] = 1; |
| 1081 | state->Init_Ctrl[32].addr[2] = 167; |
| 1082 | state->Init_Ctrl[32].bit[2] = 2; |
| 1083 | state->Init_Ctrl[32].val[2] = 0; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 1084 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 1085 | state->Init_Ctrl[33].Ctrl_Num = RFA_FLR ; |
| 1086 | state->Init_Ctrl[33].size = 4 ; |
| 1087 | state->Init_Ctrl[33].addr[0] = 168; |
| 1088 | state->Init_Ctrl[33].bit[0] = 0; |
| 1089 | state->Init_Ctrl[33].val[0] = 0; |
| 1090 | state->Init_Ctrl[33].addr[1] = 168; |
| 1091 | state->Init_Ctrl[33].bit[1] = 1; |
| 1092 | state->Init_Ctrl[33].val[1] = 1; |
| 1093 | state->Init_Ctrl[33].addr[2] = 168; |
| 1094 | state->Init_Ctrl[33].bit[2] = 2; |
| 1095 | state->Init_Ctrl[33].val[2] = 0; |
| 1096 | state->Init_Ctrl[33].addr[3] = 168; |
| 1097 | state->Init_Ctrl[33].bit[3] = 3; |
| 1098 | state->Init_Ctrl[33].val[3] = 0; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 1099 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 1100 | state->Init_Ctrl[34].Ctrl_Num = RFA_CEIL ; |
| 1101 | state->Init_Ctrl[34].size = 4 ; |
| 1102 | state->Init_Ctrl[34].addr[0] = 168; |
| 1103 | state->Init_Ctrl[34].bit[0] = 4; |
| 1104 | state->Init_Ctrl[34].val[0] = 1; |
| 1105 | state->Init_Ctrl[34].addr[1] = 168; |
| 1106 | state->Init_Ctrl[34].bit[1] = 5; |
| 1107 | state->Init_Ctrl[34].val[1] = 1; |
| 1108 | state->Init_Ctrl[34].addr[2] = 168; |
| 1109 | state->Init_Ctrl[34].bit[2] = 6; |
| 1110 | state->Init_Ctrl[34].val[2] = 1; |
| 1111 | state->Init_Ctrl[34].addr[3] = 168; |
| 1112 | state->Init_Ctrl[34].bit[3] = 7; |
| 1113 | state->Init_Ctrl[34].val[3] = 1; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 1114 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 1115 | state->Init_Ctrl[35].Ctrl_Num = SEQ_EXTIQFSMPULSE ; |
| 1116 | state->Init_Ctrl[35].size = 1 ; |
| 1117 | state->Init_Ctrl[35].addr[0] = 135; |
| 1118 | state->Init_Ctrl[35].bit[0] = 0; |
| 1119 | state->Init_Ctrl[35].val[0] = 0; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 1120 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 1121 | state->Init_Ctrl[36].Ctrl_Num = OVERRIDE_1 ; |
| 1122 | state->Init_Ctrl[36].size = 1 ; |
| 1123 | state->Init_Ctrl[36].addr[0] = 56; |
| 1124 | state->Init_Ctrl[36].bit[0] = 3; |
| 1125 | state->Init_Ctrl[36].val[0] = 0; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 1126 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 1127 | state->Init_Ctrl[37].Ctrl_Num = BB_INITSTATE_DLPF_TUNE ; |
| 1128 | state->Init_Ctrl[37].size = 7 ; |
| 1129 | state->Init_Ctrl[37].addr[0] = 59; |
| 1130 | state->Init_Ctrl[37].bit[0] = 1; |
| 1131 | state->Init_Ctrl[37].val[0] = 0; |
| 1132 | state->Init_Ctrl[37].addr[1] = 59; |
| 1133 | state->Init_Ctrl[37].bit[1] = 2; |
| 1134 | state->Init_Ctrl[37].val[1] = 0; |
| 1135 | state->Init_Ctrl[37].addr[2] = 59; |
| 1136 | state->Init_Ctrl[37].bit[2] = 3; |
| 1137 | state->Init_Ctrl[37].val[2] = 0; |
| 1138 | state->Init_Ctrl[37].addr[3] = 59; |
| 1139 | state->Init_Ctrl[37].bit[3] = 4; |
| 1140 | state->Init_Ctrl[37].val[3] = 0; |
| 1141 | state->Init_Ctrl[37].addr[4] = 59; |
| 1142 | state->Init_Ctrl[37].bit[4] = 5; |
| 1143 | state->Init_Ctrl[37].val[4] = 0; |
| 1144 | state->Init_Ctrl[37].addr[5] = 59; |
| 1145 | state->Init_Ctrl[37].bit[5] = 6; |
| 1146 | state->Init_Ctrl[37].val[5] = 0; |
| 1147 | state->Init_Ctrl[37].addr[6] = 59; |
| 1148 | state->Init_Ctrl[37].bit[6] = 7; |
| 1149 | state->Init_Ctrl[37].val[6] = 0; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 1150 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 1151 | state->Init_Ctrl[38].Ctrl_Num = TG_R_DIV ; |
| 1152 | state->Init_Ctrl[38].size = 6 ; |
| 1153 | state->Init_Ctrl[38].addr[0] = 32; |
| 1154 | state->Init_Ctrl[38].bit[0] = 2; |
| 1155 | state->Init_Ctrl[38].val[0] = 0; |
| 1156 | state->Init_Ctrl[38].addr[1] = 32; |
| 1157 | state->Init_Ctrl[38].bit[1] = 3; |
| 1158 | state->Init_Ctrl[38].val[1] = 0; |
| 1159 | state->Init_Ctrl[38].addr[2] = 32; |
| 1160 | state->Init_Ctrl[38].bit[2] = 4; |
| 1161 | state->Init_Ctrl[38].val[2] = 0; |
| 1162 | state->Init_Ctrl[38].addr[3] = 32; |
| 1163 | state->Init_Ctrl[38].bit[3] = 5; |
| 1164 | state->Init_Ctrl[38].val[3] = 0; |
| 1165 | state->Init_Ctrl[38].addr[4] = 32; |
| 1166 | state->Init_Ctrl[38].bit[4] = 6; |
| 1167 | state->Init_Ctrl[38].val[4] = 1; |
| 1168 | state->Init_Ctrl[38].addr[5] = 32; |
| 1169 | state->Init_Ctrl[38].bit[5] = 7; |
| 1170 | state->Init_Ctrl[38].val[5] = 0; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 1171 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 1172 | state->Init_Ctrl[39].Ctrl_Num = EN_CHP_LIN_B ; |
| 1173 | state->Init_Ctrl[39].size = 1 ; |
| 1174 | state->Init_Ctrl[39].addr[0] = 25; |
| 1175 | state->Init_Ctrl[39].bit[0] = 3; |
| 1176 | state->Init_Ctrl[39].val[0] = 1; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 1177 | |
| 1178 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 1179 | state->CH_Ctrl_Num = CHCTRL_NUM ; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 1180 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 1181 | state->CH_Ctrl[0].Ctrl_Num = DN_POLY ; |
| 1182 | state->CH_Ctrl[0].size = 2 ; |
| 1183 | state->CH_Ctrl[0].addr[0] = 68; |
| 1184 | state->CH_Ctrl[0].bit[0] = 6; |
| 1185 | state->CH_Ctrl[0].val[0] = 1; |
| 1186 | state->CH_Ctrl[0].addr[1] = 68; |
| 1187 | state->CH_Ctrl[0].bit[1] = 7; |
| 1188 | state->CH_Ctrl[0].val[1] = 1; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 1189 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 1190 | state->CH_Ctrl[1].Ctrl_Num = DN_RFGAIN ; |
| 1191 | state->CH_Ctrl[1].size = 2 ; |
| 1192 | state->CH_Ctrl[1].addr[0] = 70; |
| 1193 | state->CH_Ctrl[1].bit[0] = 6; |
| 1194 | state->CH_Ctrl[1].val[0] = 1; |
| 1195 | state->CH_Ctrl[1].addr[1] = 70; |
| 1196 | state->CH_Ctrl[1].bit[1] = 7; |
| 1197 | state->CH_Ctrl[1].val[1] = 0; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 1198 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 1199 | state->CH_Ctrl[2].Ctrl_Num = DN_CAP_RFLPF ; |
| 1200 | state->CH_Ctrl[2].size = 9 ; |
| 1201 | state->CH_Ctrl[2].addr[0] = 69; |
| 1202 | state->CH_Ctrl[2].bit[0] = 5; |
| 1203 | state->CH_Ctrl[2].val[0] = 0; |
| 1204 | state->CH_Ctrl[2].addr[1] = 69; |
| 1205 | state->CH_Ctrl[2].bit[1] = 6; |
| 1206 | state->CH_Ctrl[2].val[1] = 0; |
| 1207 | state->CH_Ctrl[2].addr[2] = 69; |
| 1208 | state->CH_Ctrl[2].bit[2] = 7; |
| 1209 | state->CH_Ctrl[2].val[2] = 0; |
| 1210 | state->CH_Ctrl[2].addr[3] = 68; |
| 1211 | state->CH_Ctrl[2].bit[3] = 0; |
| 1212 | state->CH_Ctrl[2].val[3] = 0; |
| 1213 | state->CH_Ctrl[2].addr[4] = 68; |
| 1214 | state->CH_Ctrl[2].bit[4] = 1; |
| 1215 | state->CH_Ctrl[2].val[4] = 0; |
| 1216 | state->CH_Ctrl[2].addr[5] = 68; |
| 1217 | state->CH_Ctrl[2].bit[5] = 2; |
| 1218 | state->CH_Ctrl[2].val[5] = 0; |
| 1219 | state->CH_Ctrl[2].addr[6] = 68; |
| 1220 | state->CH_Ctrl[2].bit[6] = 3; |
| 1221 | state->CH_Ctrl[2].val[6] = 0; |
| 1222 | state->CH_Ctrl[2].addr[7] = 68; |
| 1223 | state->CH_Ctrl[2].bit[7] = 4; |
| 1224 | state->CH_Ctrl[2].val[7] = 0; |
| 1225 | state->CH_Ctrl[2].addr[8] = 68; |
| 1226 | state->CH_Ctrl[2].bit[8] = 5; |
| 1227 | state->CH_Ctrl[2].val[8] = 0; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 1228 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 1229 | state->CH_Ctrl[3].Ctrl_Num = DN_EN_VHFUHFBAR ; |
| 1230 | state->CH_Ctrl[3].size = 1 ; |
| 1231 | state->CH_Ctrl[3].addr[0] = 70; |
| 1232 | state->CH_Ctrl[3].bit[0] = 5; |
| 1233 | state->CH_Ctrl[3].val[0] = 0; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 1234 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 1235 | state->CH_Ctrl[4].Ctrl_Num = DN_GAIN_ADJUST ; |
| 1236 | state->CH_Ctrl[4].size = 3 ; |
| 1237 | state->CH_Ctrl[4].addr[0] = 73; |
| 1238 | state->CH_Ctrl[4].bit[0] = 4; |
| 1239 | state->CH_Ctrl[4].val[0] = 0; |
| 1240 | state->CH_Ctrl[4].addr[1] = 73; |
| 1241 | state->CH_Ctrl[4].bit[1] = 5; |
| 1242 | state->CH_Ctrl[4].val[1] = 1; |
| 1243 | state->CH_Ctrl[4].addr[2] = 73; |
| 1244 | state->CH_Ctrl[4].bit[2] = 6; |
| 1245 | state->CH_Ctrl[4].val[2] = 0; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 1246 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 1247 | state->CH_Ctrl[5].Ctrl_Num = DN_IQTNBUF_AMP ; |
| 1248 | state->CH_Ctrl[5].size = 4 ; |
| 1249 | state->CH_Ctrl[5].addr[0] = 70; |
| 1250 | state->CH_Ctrl[5].bit[0] = 0; |
| 1251 | state->CH_Ctrl[5].val[0] = 0; |
| 1252 | state->CH_Ctrl[5].addr[1] = 70; |
| 1253 | state->CH_Ctrl[5].bit[1] = 1; |
| 1254 | state->CH_Ctrl[5].val[1] = 0; |
| 1255 | state->CH_Ctrl[5].addr[2] = 70; |
| 1256 | state->CH_Ctrl[5].bit[2] = 2; |
| 1257 | state->CH_Ctrl[5].val[2] = 0; |
| 1258 | state->CH_Ctrl[5].addr[3] = 70; |
| 1259 | state->CH_Ctrl[5].bit[3] = 3; |
| 1260 | state->CH_Ctrl[5].val[3] = 0; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 1261 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 1262 | state->CH_Ctrl[6].Ctrl_Num = DN_IQTNGNBFBIAS_BST ; |
| 1263 | state->CH_Ctrl[6].size = 1 ; |
| 1264 | state->CH_Ctrl[6].addr[0] = 70; |
| 1265 | state->CH_Ctrl[6].bit[0] = 4; |
| 1266 | state->CH_Ctrl[6].val[0] = 1; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 1267 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 1268 | state->CH_Ctrl[7].Ctrl_Num = RFSYN_EN_OUTMUX ; |
| 1269 | state->CH_Ctrl[7].size = 1 ; |
| 1270 | state->CH_Ctrl[7].addr[0] = 111; |
| 1271 | state->CH_Ctrl[7].bit[0] = 4; |
| 1272 | state->CH_Ctrl[7].val[0] = 0; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 1273 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 1274 | state->CH_Ctrl[8].Ctrl_Num = RFSYN_SEL_VCO_OUT ; |
| 1275 | state->CH_Ctrl[8].size = 1 ; |
| 1276 | state->CH_Ctrl[8].addr[0] = 111; |
| 1277 | state->CH_Ctrl[8].bit[0] = 7; |
| 1278 | state->CH_Ctrl[8].val[0] = 1; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 1279 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 1280 | state->CH_Ctrl[9].Ctrl_Num = RFSYN_SEL_VCO_HI ; |
| 1281 | state->CH_Ctrl[9].size = 1 ; |
| 1282 | state->CH_Ctrl[9].addr[0] = 111; |
| 1283 | state->CH_Ctrl[9].bit[0] = 6; |
| 1284 | state->CH_Ctrl[9].val[0] = 1; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 1285 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 1286 | state->CH_Ctrl[10].Ctrl_Num = RFSYN_SEL_DIVM ; |
| 1287 | state->CH_Ctrl[10].size = 1 ; |
| 1288 | state->CH_Ctrl[10].addr[0] = 111; |
| 1289 | state->CH_Ctrl[10].bit[0] = 5; |
| 1290 | state->CH_Ctrl[10].val[0] = 0; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 1291 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 1292 | state->CH_Ctrl[11].Ctrl_Num = RFSYN_RF_DIV_BIAS ; |
| 1293 | state->CH_Ctrl[11].size = 2 ; |
| 1294 | state->CH_Ctrl[11].addr[0] = 110; |
| 1295 | state->CH_Ctrl[11].bit[0] = 0; |
| 1296 | state->CH_Ctrl[11].val[0] = 1; |
| 1297 | state->CH_Ctrl[11].addr[1] = 110; |
| 1298 | state->CH_Ctrl[11].bit[1] = 1; |
| 1299 | state->CH_Ctrl[11].val[1] = 0; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 1300 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 1301 | state->CH_Ctrl[12].Ctrl_Num = DN_SEL_FREQ ; |
| 1302 | state->CH_Ctrl[12].size = 3 ; |
| 1303 | state->CH_Ctrl[12].addr[0] = 69; |
| 1304 | state->CH_Ctrl[12].bit[0] = 2; |
| 1305 | state->CH_Ctrl[12].val[0] = 0; |
| 1306 | state->CH_Ctrl[12].addr[1] = 69; |
| 1307 | state->CH_Ctrl[12].bit[1] = 3; |
| 1308 | state->CH_Ctrl[12].val[1] = 0; |
| 1309 | state->CH_Ctrl[12].addr[2] = 69; |
| 1310 | state->CH_Ctrl[12].bit[2] = 4; |
| 1311 | state->CH_Ctrl[12].val[2] = 0; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 1312 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 1313 | state->CH_Ctrl[13].Ctrl_Num = RFSYN_VCO_BIAS ; |
| 1314 | state->CH_Ctrl[13].size = 6 ; |
| 1315 | state->CH_Ctrl[13].addr[0] = 110; |
| 1316 | state->CH_Ctrl[13].bit[0] = 2; |
| 1317 | state->CH_Ctrl[13].val[0] = 0; |
| 1318 | state->CH_Ctrl[13].addr[1] = 110; |
| 1319 | state->CH_Ctrl[13].bit[1] = 3; |
| 1320 | state->CH_Ctrl[13].val[1] = 0; |
| 1321 | state->CH_Ctrl[13].addr[2] = 110; |
| 1322 | state->CH_Ctrl[13].bit[2] = 4; |
| 1323 | state->CH_Ctrl[13].val[2] = 0; |
| 1324 | state->CH_Ctrl[13].addr[3] = 110; |
| 1325 | state->CH_Ctrl[13].bit[3] = 5; |
| 1326 | state->CH_Ctrl[13].val[3] = 0; |
| 1327 | state->CH_Ctrl[13].addr[4] = 110; |
| 1328 | state->CH_Ctrl[13].bit[4] = 6; |
| 1329 | state->CH_Ctrl[13].val[4] = 0; |
| 1330 | state->CH_Ctrl[13].addr[5] = 110; |
| 1331 | state->CH_Ctrl[13].bit[5] = 7; |
| 1332 | state->CH_Ctrl[13].val[5] = 1; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 1333 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 1334 | state->CH_Ctrl[14].Ctrl_Num = CHCAL_INT_MOD_RF ; |
| 1335 | state->CH_Ctrl[14].size = 7 ; |
| 1336 | state->CH_Ctrl[14].addr[0] = 14; |
| 1337 | state->CH_Ctrl[14].bit[0] = 0; |
| 1338 | state->CH_Ctrl[14].val[0] = 0; |
| 1339 | state->CH_Ctrl[14].addr[1] = 14; |
| 1340 | state->CH_Ctrl[14].bit[1] = 1; |
| 1341 | state->CH_Ctrl[14].val[1] = 0; |
| 1342 | state->CH_Ctrl[14].addr[2] = 14; |
| 1343 | state->CH_Ctrl[14].bit[2] = 2; |
| 1344 | state->CH_Ctrl[14].val[2] = 0; |
| 1345 | state->CH_Ctrl[14].addr[3] = 14; |
| 1346 | state->CH_Ctrl[14].bit[3] = 3; |
| 1347 | state->CH_Ctrl[14].val[3] = 0; |
| 1348 | state->CH_Ctrl[14].addr[4] = 14; |
| 1349 | state->CH_Ctrl[14].bit[4] = 4; |
| 1350 | state->CH_Ctrl[14].val[4] = 0; |
| 1351 | state->CH_Ctrl[14].addr[5] = 14; |
| 1352 | state->CH_Ctrl[14].bit[5] = 5; |
| 1353 | state->CH_Ctrl[14].val[5] = 0; |
| 1354 | state->CH_Ctrl[14].addr[6] = 14; |
| 1355 | state->CH_Ctrl[14].bit[6] = 6; |
| 1356 | state->CH_Ctrl[14].val[6] = 0; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 1357 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 1358 | state->CH_Ctrl[15].Ctrl_Num = CHCAL_FRAC_MOD_RF ; |
| 1359 | state->CH_Ctrl[15].size = 18 ; |
| 1360 | state->CH_Ctrl[15].addr[0] = 17; |
| 1361 | state->CH_Ctrl[15].bit[0] = 6; |
| 1362 | state->CH_Ctrl[15].val[0] = 0; |
| 1363 | state->CH_Ctrl[15].addr[1] = 17; |
| 1364 | state->CH_Ctrl[15].bit[1] = 7; |
| 1365 | state->CH_Ctrl[15].val[1] = 0; |
| 1366 | state->CH_Ctrl[15].addr[2] = 16; |
| 1367 | state->CH_Ctrl[15].bit[2] = 0; |
| 1368 | state->CH_Ctrl[15].val[2] = 0; |
| 1369 | state->CH_Ctrl[15].addr[3] = 16; |
| 1370 | state->CH_Ctrl[15].bit[3] = 1; |
| 1371 | state->CH_Ctrl[15].val[3] = 0; |
| 1372 | state->CH_Ctrl[15].addr[4] = 16; |
| 1373 | state->CH_Ctrl[15].bit[4] = 2; |
| 1374 | state->CH_Ctrl[15].val[4] = 0; |
| 1375 | state->CH_Ctrl[15].addr[5] = 16; |
| 1376 | state->CH_Ctrl[15].bit[5] = 3; |
| 1377 | state->CH_Ctrl[15].val[5] = 0; |
| 1378 | state->CH_Ctrl[15].addr[6] = 16; |
| 1379 | state->CH_Ctrl[15].bit[6] = 4; |
| 1380 | state->CH_Ctrl[15].val[6] = 0; |
| 1381 | state->CH_Ctrl[15].addr[7] = 16; |
| 1382 | state->CH_Ctrl[15].bit[7] = 5; |
| 1383 | state->CH_Ctrl[15].val[7] = 0; |
| 1384 | state->CH_Ctrl[15].addr[8] = 16; |
| 1385 | state->CH_Ctrl[15].bit[8] = 6; |
| 1386 | state->CH_Ctrl[15].val[8] = 0; |
| 1387 | state->CH_Ctrl[15].addr[9] = 16; |
| 1388 | state->CH_Ctrl[15].bit[9] = 7; |
| 1389 | state->CH_Ctrl[15].val[9] = 0; |
| 1390 | state->CH_Ctrl[15].addr[10] = 15; |
| 1391 | state->CH_Ctrl[15].bit[10] = 0; |
| 1392 | state->CH_Ctrl[15].val[10] = 0; |
| 1393 | state->CH_Ctrl[15].addr[11] = 15; |
| 1394 | state->CH_Ctrl[15].bit[11] = 1; |
| 1395 | state->CH_Ctrl[15].val[11] = 0; |
| 1396 | state->CH_Ctrl[15].addr[12] = 15; |
| 1397 | state->CH_Ctrl[15].bit[12] = 2; |
| 1398 | state->CH_Ctrl[15].val[12] = 0; |
| 1399 | state->CH_Ctrl[15].addr[13] = 15; |
| 1400 | state->CH_Ctrl[15].bit[13] = 3; |
| 1401 | state->CH_Ctrl[15].val[13] = 0; |
| 1402 | state->CH_Ctrl[15].addr[14] = 15; |
| 1403 | state->CH_Ctrl[15].bit[14] = 4; |
| 1404 | state->CH_Ctrl[15].val[14] = 0; |
| 1405 | state->CH_Ctrl[15].addr[15] = 15; |
| 1406 | state->CH_Ctrl[15].bit[15] = 5; |
| 1407 | state->CH_Ctrl[15].val[15] = 0; |
| 1408 | state->CH_Ctrl[15].addr[16] = 15; |
| 1409 | state->CH_Ctrl[15].bit[16] = 6; |
| 1410 | state->CH_Ctrl[15].val[16] = 1; |
| 1411 | state->CH_Ctrl[15].addr[17] = 15; |
| 1412 | state->CH_Ctrl[15].bit[17] = 7; |
| 1413 | state->CH_Ctrl[15].val[17] = 1; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 1414 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 1415 | state->CH_Ctrl[16].Ctrl_Num = RFSYN_LPF_R ; |
| 1416 | state->CH_Ctrl[16].size = 5 ; |
| 1417 | state->CH_Ctrl[16].addr[0] = 112; |
| 1418 | state->CH_Ctrl[16].bit[0] = 0; |
| 1419 | state->CH_Ctrl[16].val[0] = 0; |
| 1420 | state->CH_Ctrl[16].addr[1] = 112; |
| 1421 | state->CH_Ctrl[16].bit[1] = 1; |
| 1422 | state->CH_Ctrl[16].val[1] = 0; |
| 1423 | state->CH_Ctrl[16].addr[2] = 112; |
| 1424 | state->CH_Ctrl[16].bit[2] = 2; |
| 1425 | state->CH_Ctrl[16].val[2] = 0; |
| 1426 | state->CH_Ctrl[16].addr[3] = 112; |
| 1427 | state->CH_Ctrl[16].bit[3] = 3; |
| 1428 | state->CH_Ctrl[16].val[3] = 0; |
| 1429 | state->CH_Ctrl[16].addr[4] = 112; |
| 1430 | state->CH_Ctrl[16].bit[4] = 4; |
| 1431 | state->CH_Ctrl[16].val[4] = 1; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 1432 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 1433 | state->CH_Ctrl[17].Ctrl_Num = CHCAL_EN_INT_RF ; |
| 1434 | state->CH_Ctrl[17].size = 1 ; |
| 1435 | state->CH_Ctrl[17].addr[0] = 14; |
| 1436 | state->CH_Ctrl[17].bit[0] = 7; |
| 1437 | state->CH_Ctrl[17].val[0] = 0; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 1438 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 1439 | state->CH_Ctrl[18].Ctrl_Num = TG_LO_DIVVAL ; |
| 1440 | state->CH_Ctrl[18].size = 4 ; |
| 1441 | state->CH_Ctrl[18].addr[0] = 107; |
| 1442 | state->CH_Ctrl[18].bit[0] = 3; |
| 1443 | state->CH_Ctrl[18].val[0] = 0; |
| 1444 | state->CH_Ctrl[18].addr[1] = 107; |
| 1445 | state->CH_Ctrl[18].bit[1] = 4; |
| 1446 | state->CH_Ctrl[18].val[1] = 0; |
| 1447 | state->CH_Ctrl[18].addr[2] = 107; |
| 1448 | state->CH_Ctrl[18].bit[2] = 5; |
| 1449 | state->CH_Ctrl[18].val[2] = 0; |
| 1450 | state->CH_Ctrl[18].addr[3] = 107; |
| 1451 | state->CH_Ctrl[18].bit[3] = 6; |
| 1452 | state->CH_Ctrl[18].val[3] = 0; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 1453 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 1454 | state->CH_Ctrl[19].Ctrl_Num = TG_LO_SELVAL ; |
| 1455 | state->CH_Ctrl[19].size = 3 ; |
| 1456 | state->CH_Ctrl[19].addr[0] = 107; |
| 1457 | state->CH_Ctrl[19].bit[0] = 7; |
| 1458 | state->CH_Ctrl[19].val[0] = 1; |
| 1459 | state->CH_Ctrl[19].addr[1] = 106; |
| 1460 | state->CH_Ctrl[19].bit[1] = 0; |
| 1461 | state->CH_Ctrl[19].val[1] = 1; |
| 1462 | state->CH_Ctrl[19].addr[2] = 106; |
| 1463 | state->CH_Ctrl[19].bit[2] = 1; |
| 1464 | state->CH_Ctrl[19].val[2] = 1; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 1465 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 1466 | state->CH_Ctrl[20].Ctrl_Num = TG_DIV_VAL ; |
| 1467 | state->CH_Ctrl[20].size = 11 ; |
| 1468 | state->CH_Ctrl[20].addr[0] = 109; |
| 1469 | state->CH_Ctrl[20].bit[0] = 2; |
| 1470 | state->CH_Ctrl[20].val[0] = 0; |
| 1471 | state->CH_Ctrl[20].addr[1] = 109; |
| 1472 | state->CH_Ctrl[20].bit[1] = 3; |
| 1473 | state->CH_Ctrl[20].val[1] = 0; |
| 1474 | state->CH_Ctrl[20].addr[2] = 109; |
| 1475 | state->CH_Ctrl[20].bit[2] = 4; |
| 1476 | state->CH_Ctrl[20].val[2] = 0; |
| 1477 | state->CH_Ctrl[20].addr[3] = 109; |
| 1478 | state->CH_Ctrl[20].bit[3] = 5; |
| 1479 | state->CH_Ctrl[20].val[3] = 0; |
| 1480 | state->CH_Ctrl[20].addr[4] = 109; |
| 1481 | state->CH_Ctrl[20].bit[4] = 6; |
| 1482 | state->CH_Ctrl[20].val[4] = 0; |
| 1483 | state->CH_Ctrl[20].addr[5] = 109; |
| 1484 | state->CH_Ctrl[20].bit[5] = 7; |
| 1485 | state->CH_Ctrl[20].val[5] = 0; |
| 1486 | state->CH_Ctrl[20].addr[6] = 108; |
| 1487 | state->CH_Ctrl[20].bit[6] = 0; |
| 1488 | state->CH_Ctrl[20].val[6] = 0; |
| 1489 | state->CH_Ctrl[20].addr[7] = 108; |
| 1490 | state->CH_Ctrl[20].bit[7] = 1; |
| 1491 | state->CH_Ctrl[20].val[7] = 0; |
| 1492 | state->CH_Ctrl[20].addr[8] = 108; |
| 1493 | state->CH_Ctrl[20].bit[8] = 2; |
| 1494 | state->CH_Ctrl[20].val[8] = 1; |
| 1495 | state->CH_Ctrl[20].addr[9] = 108; |
| 1496 | state->CH_Ctrl[20].bit[9] = 3; |
| 1497 | state->CH_Ctrl[20].val[9] = 1; |
| 1498 | state->CH_Ctrl[20].addr[10] = 108; |
| 1499 | state->CH_Ctrl[20].bit[10] = 4; |
| 1500 | state->CH_Ctrl[20].val[10] = 1; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 1501 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 1502 | state->CH_Ctrl[21].Ctrl_Num = TG_VCO_BIAS ; |
| 1503 | state->CH_Ctrl[21].size = 6 ; |
| 1504 | state->CH_Ctrl[21].addr[0] = 106; |
| 1505 | state->CH_Ctrl[21].bit[0] = 2; |
| 1506 | state->CH_Ctrl[21].val[0] = 0; |
| 1507 | state->CH_Ctrl[21].addr[1] = 106; |
| 1508 | state->CH_Ctrl[21].bit[1] = 3; |
| 1509 | state->CH_Ctrl[21].val[1] = 0; |
| 1510 | state->CH_Ctrl[21].addr[2] = 106; |
| 1511 | state->CH_Ctrl[21].bit[2] = 4; |
| 1512 | state->CH_Ctrl[21].val[2] = 0; |
| 1513 | state->CH_Ctrl[21].addr[3] = 106; |
| 1514 | state->CH_Ctrl[21].bit[3] = 5; |
| 1515 | state->CH_Ctrl[21].val[3] = 0; |
| 1516 | state->CH_Ctrl[21].addr[4] = 106; |
| 1517 | state->CH_Ctrl[21].bit[4] = 6; |
| 1518 | state->CH_Ctrl[21].val[4] = 0; |
| 1519 | state->CH_Ctrl[21].addr[5] = 106; |
| 1520 | state->CH_Ctrl[21].bit[5] = 7; |
| 1521 | state->CH_Ctrl[21].val[5] = 1; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 1522 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 1523 | state->CH_Ctrl[22].Ctrl_Num = SEQ_EXTPOWERUP ; |
| 1524 | state->CH_Ctrl[22].size = 1 ; |
| 1525 | state->CH_Ctrl[22].addr[0] = 138; |
| 1526 | state->CH_Ctrl[22].bit[0] = 4; |
| 1527 | state->CH_Ctrl[22].val[0] = 1; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 1528 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 1529 | state->CH_Ctrl[23].Ctrl_Num = OVERRIDE_2 ; |
| 1530 | state->CH_Ctrl[23].size = 1 ; |
| 1531 | state->CH_Ctrl[23].addr[0] = 17; |
| 1532 | state->CH_Ctrl[23].bit[0] = 5; |
| 1533 | state->CH_Ctrl[23].val[0] = 0; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 1534 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 1535 | state->CH_Ctrl[24].Ctrl_Num = OVERRIDE_3 ; |
| 1536 | state->CH_Ctrl[24].size = 1 ; |
| 1537 | state->CH_Ctrl[24].addr[0] = 111; |
| 1538 | state->CH_Ctrl[24].bit[0] = 3; |
| 1539 | state->CH_Ctrl[24].val[0] = 0; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 1540 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 1541 | state->CH_Ctrl[25].Ctrl_Num = OVERRIDE_4 ; |
| 1542 | state->CH_Ctrl[25].size = 1 ; |
| 1543 | state->CH_Ctrl[25].addr[0] = 112; |
| 1544 | state->CH_Ctrl[25].bit[0] = 7; |
| 1545 | state->CH_Ctrl[25].val[0] = 0; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 1546 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 1547 | state->CH_Ctrl[26].Ctrl_Num = SEQ_FSM_PULSE ; |
| 1548 | state->CH_Ctrl[26].size = 1 ; |
| 1549 | state->CH_Ctrl[26].addr[0] = 136; |
| 1550 | state->CH_Ctrl[26].bit[0] = 7; |
| 1551 | state->CH_Ctrl[26].val[0] = 0; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 1552 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 1553 | state->CH_Ctrl[27].Ctrl_Num = GPIO_4B ; |
| 1554 | state->CH_Ctrl[27].size = 1 ; |
| 1555 | state->CH_Ctrl[27].addr[0] = 149; |
| 1556 | state->CH_Ctrl[27].bit[0] = 7; |
| 1557 | state->CH_Ctrl[27].val[0] = 0; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 1558 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 1559 | state->CH_Ctrl[28].Ctrl_Num = GPIO_3B ; |
| 1560 | state->CH_Ctrl[28].size = 1 ; |
| 1561 | state->CH_Ctrl[28].addr[0] = 149; |
| 1562 | state->CH_Ctrl[28].bit[0] = 6; |
| 1563 | state->CH_Ctrl[28].val[0] = 0; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 1564 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 1565 | state->CH_Ctrl[29].Ctrl_Num = GPIO_4 ; |
| 1566 | state->CH_Ctrl[29].size = 1 ; |
| 1567 | state->CH_Ctrl[29].addr[0] = 149; |
| 1568 | state->CH_Ctrl[29].bit[0] = 5; |
| 1569 | state->CH_Ctrl[29].val[0] = 1; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 1570 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 1571 | state->CH_Ctrl[30].Ctrl_Num = GPIO_3 ; |
| 1572 | state->CH_Ctrl[30].size = 1 ; |
| 1573 | state->CH_Ctrl[30].addr[0] = 149; |
| 1574 | state->CH_Ctrl[30].bit[0] = 4; |
| 1575 | state->CH_Ctrl[30].val[0] = 1; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 1576 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 1577 | state->CH_Ctrl[31].Ctrl_Num = GPIO_1B ; |
| 1578 | state->CH_Ctrl[31].size = 1 ; |
| 1579 | state->CH_Ctrl[31].addr[0] = 149; |
| 1580 | state->CH_Ctrl[31].bit[0] = 3; |
| 1581 | state->CH_Ctrl[31].val[0] = 0; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 1582 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 1583 | state->CH_Ctrl[32].Ctrl_Num = DAC_A_ENABLE ; |
| 1584 | state->CH_Ctrl[32].size = 1 ; |
| 1585 | state->CH_Ctrl[32].addr[0] = 93; |
| 1586 | state->CH_Ctrl[32].bit[0] = 1; |
| 1587 | state->CH_Ctrl[32].val[0] = 0; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 1588 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 1589 | state->CH_Ctrl[33].Ctrl_Num = DAC_B_ENABLE ; |
| 1590 | state->CH_Ctrl[33].size = 1 ; |
| 1591 | state->CH_Ctrl[33].addr[0] = 93; |
| 1592 | state->CH_Ctrl[33].bit[0] = 0; |
| 1593 | state->CH_Ctrl[33].val[0] = 0; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 1594 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 1595 | state->CH_Ctrl[34].Ctrl_Num = DAC_DIN_A ; |
| 1596 | state->CH_Ctrl[34].size = 6 ; |
| 1597 | state->CH_Ctrl[34].addr[0] = 92; |
| 1598 | state->CH_Ctrl[34].bit[0] = 2; |
| 1599 | state->CH_Ctrl[34].val[0] = 0; |
| 1600 | state->CH_Ctrl[34].addr[1] = 92; |
| 1601 | state->CH_Ctrl[34].bit[1] = 3; |
| 1602 | state->CH_Ctrl[34].val[1] = 0; |
| 1603 | state->CH_Ctrl[34].addr[2] = 92; |
| 1604 | state->CH_Ctrl[34].bit[2] = 4; |
| 1605 | state->CH_Ctrl[34].val[2] = 0; |
| 1606 | state->CH_Ctrl[34].addr[3] = 92; |
| 1607 | state->CH_Ctrl[34].bit[3] = 5; |
| 1608 | state->CH_Ctrl[34].val[3] = 0; |
| 1609 | state->CH_Ctrl[34].addr[4] = 92; |
| 1610 | state->CH_Ctrl[34].bit[4] = 6; |
| 1611 | state->CH_Ctrl[34].val[4] = 0; |
| 1612 | state->CH_Ctrl[34].addr[5] = 92; |
| 1613 | state->CH_Ctrl[34].bit[5] = 7; |
| 1614 | state->CH_Ctrl[34].val[5] = 0; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 1615 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 1616 | state->CH_Ctrl[35].Ctrl_Num = DAC_DIN_B ; |
| 1617 | state->CH_Ctrl[35].size = 6 ; |
| 1618 | state->CH_Ctrl[35].addr[0] = 93; |
| 1619 | state->CH_Ctrl[35].bit[0] = 2; |
| 1620 | state->CH_Ctrl[35].val[0] = 0; |
| 1621 | state->CH_Ctrl[35].addr[1] = 93; |
| 1622 | state->CH_Ctrl[35].bit[1] = 3; |
| 1623 | state->CH_Ctrl[35].val[1] = 0; |
| 1624 | state->CH_Ctrl[35].addr[2] = 93; |
| 1625 | state->CH_Ctrl[35].bit[2] = 4; |
| 1626 | state->CH_Ctrl[35].val[2] = 0; |
| 1627 | state->CH_Ctrl[35].addr[3] = 93; |
| 1628 | state->CH_Ctrl[35].bit[3] = 5; |
| 1629 | state->CH_Ctrl[35].val[3] = 0; |
| 1630 | state->CH_Ctrl[35].addr[4] = 93; |
| 1631 | state->CH_Ctrl[35].bit[4] = 6; |
| 1632 | state->CH_Ctrl[35].val[4] = 0; |
| 1633 | state->CH_Ctrl[35].addr[5] = 93; |
| 1634 | state->CH_Ctrl[35].bit[5] = 7; |
| 1635 | state->CH_Ctrl[35].val[5] = 0; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 1636 | |
| 1637 | #ifdef _MXL_PRODUCTION |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 1638 | state->CH_Ctrl[36].Ctrl_Num = RFSYN_EN_DIV ; |
| 1639 | state->CH_Ctrl[36].size = 1 ; |
| 1640 | state->CH_Ctrl[36].addr[0] = 109; |
| 1641 | state->CH_Ctrl[36].bit[0] = 1; |
| 1642 | state->CH_Ctrl[36].val[0] = 1; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 1643 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 1644 | state->CH_Ctrl[37].Ctrl_Num = RFSYN_DIVM ; |
| 1645 | state->CH_Ctrl[37].size = 2 ; |
| 1646 | state->CH_Ctrl[37].addr[0] = 112; |
| 1647 | state->CH_Ctrl[37].bit[0] = 5; |
| 1648 | state->CH_Ctrl[37].val[0] = 0; |
| 1649 | state->CH_Ctrl[37].addr[1] = 112; |
| 1650 | state->CH_Ctrl[37].bit[1] = 6; |
| 1651 | state->CH_Ctrl[37].val[1] = 0; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 1652 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 1653 | state->CH_Ctrl[38].Ctrl_Num = DN_BYPASS_AGC_I2C ; |
| 1654 | state->CH_Ctrl[38].size = 1 ; |
| 1655 | state->CH_Ctrl[38].addr[0] = 65; |
| 1656 | state->CH_Ctrl[38].bit[0] = 1; |
| 1657 | state->CH_Ctrl[38].val[0] = 0; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 1658 | #endif |
| 1659 | |
| 1660 | return 0 ; |
| 1661 | } |
| 1662 | |
Steven Toth | c6c34b1 | 2008-05-03 14:14:54 -0300 | [diff] [blame] | 1663 | static void InitTunerControls(struct dvb_frontend *fe) |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 1664 | { |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 1665 | MXL5005_RegisterInit(fe); |
| 1666 | MXL5005_ControlInit(fe); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 1667 | #ifdef _MXL_INTERNAL |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 1668 | MXL5005_MXLControlInit(fe); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 1669 | #endif |
| 1670 | } |
| 1671 | |
Steven Toth | c6c34b1 | 2008-05-03 14:14:54 -0300 | [diff] [blame] | 1672 | static u16 MXL5005_TunerConfig(struct dvb_frontend *fe, |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 1673 | u8 Mode, /* 0: Analog Mode ; 1: Digital Mode */ |
| 1674 | u8 IF_mode, /* for Analog Mode, 0: zero IF; 1: low IF */ |
| 1675 | u32 Bandwidth, /* filter channel bandwidth (6, 7, 8) */ |
| 1676 | u32 IF_out, /* Desired IF Out Frequency */ |
| 1677 | u32 Fxtal, /* XTAL Frequency */ |
| 1678 | u8 AGC_Mode, /* AGC Mode - Dual AGC: 0, Single AGC: 1 */ |
| 1679 | u16 TOP, /* 0: Dual AGC; Value: take over point */ |
| 1680 | u16 IF_OUT_LOAD, /* IF Out Load Resistor (200 / 300 Ohms) */ |
| 1681 | u8 CLOCK_OUT, /* 0: turn off clk out; 1: turn on clock out */ |
| 1682 | u8 DIV_OUT, /* 0: Div-1; 1: Div-4 */ |
| 1683 | u8 CAPSELECT, /* 0: disable On-Chip pulling cap; 1: enable */ |
| 1684 | u8 EN_RSSI, /* 0: disable RSSI; 1: enable RSSI */ |
| 1685 | |
| 1686 | /* Modulation Type; */ |
| 1687 | /* 0 - Default; 1 - DVB-T; 2 - ATSC; 3 - QAM; 4 - Analog Cable */ |
| 1688 | u8 Mod_Type, |
| 1689 | |
| 1690 | /* Tracking Filter */ |
| 1691 | /* 0 - Default; 1 - Off; 2 - Type C; 3 - Type C-H */ |
| 1692 | u8 TF_Type |
| 1693 | ) |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 1694 | { |
Steven Toth | 85d220d | 2008-05-01 05:48:14 -0300 | [diff] [blame] | 1695 | struct mxl5005s_state *state = fe->tuner_priv; |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 1696 | u16 status = 0; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 1697 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 1698 | state->Mode = Mode; |
| 1699 | state->IF_Mode = IF_mode; |
| 1700 | state->Chan_Bandwidth = Bandwidth; |
| 1701 | state->IF_OUT = IF_out; |
| 1702 | state->Fxtal = Fxtal; |
| 1703 | state->AGC_Mode = AGC_Mode; |
| 1704 | state->TOP = TOP; |
| 1705 | state->IF_OUT_LOAD = IF_OUT_LOAD; |
| 1706 | state->CLOCK_OUT = CLOCK_OUT; |
| 1707 | state->DIV_OUT = DIV_OUT; |
| 1708 | state->CAPSELECT = CAPSELECT; |
| 1709 | state->EN_RSSI = EN_RSSI; |
| 1710 | state->Mod_Type = Mod_Type; |
| 1711 | state->TF_Type = TF_Type; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 1712 | |
Steven Toth | a8214d4 | 2008-05-01 05:02:58 -0300 | [diff] [blame] | 1713 | /* Initialize all the controls and registers */ |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 1714 | InitTunerControls(fe); |
Steven Toth | a8214d4 | 2008-05-01 05:02:58 -0300 | [diff] [blame] | 1715 | |
| 1716 | /* Synthesizer LO frequency calculation */ |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 1717 | MXL_SynthIFLO_Calc(fe); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 1718 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 1719 | return status; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 1720 | } |
| 1721 | |
Steven Toth | c6c34b1 | 2008-05-03 14:14:54 -0300 | [diff] [blame] | 1722 | static void MXL_SynthIFLO_Calc(struct dvb_frontend *fe) |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 1723 | { |
Steven Toth | 85d220d | 2008-05-01 05:48:14 -0300 | [diff] [blame] | 1724 | struct mxl5005s_state *state = fe->tuner_priv; |
| 1725 | if (state->Mode == 1) /* Digital Mode */ |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 1726 | state->IF_LO = state->IF_OUT; |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 1727 | else /* Analog Mode */ { |
| 1728 | if (state->IF_Mode == 0) /* Analog Zero IF mode */ |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 1729 | state->IF_LO = state->IF_OUT + 400000; |
| 1730 | else /* Analog Low IF mode */ |
| 1731 | state->IF_LO = state->IF_OUT + state->Chan_Bandwidth/2; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 1732 | } |
| 1733 | } |
| 1734 | |
Steven Toth | c6c34b1 | 2008-05-03 14:14:54 -0300 | [diff] [blame] | 1735 | static void MXL_SynthRFTGLO_Calc(struct dvb_frontend *fe) |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 1736 | { |
Steven Toth | 85d220d | 2008-05-01 05:48:14 -0300 | [diff] [blame] | 1737 | struct mxl5005s_state *state = fe->tuner_priv; |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 1738 | |
| 1739 | if (state->Mode == 1) /* Digital Mode */ { |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 1740 | /* remove 20.48MHz setting for 2.6.10 */ |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 1741 | state->RF_LO = state->RF_IN; |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 1742 | /* change for 2.6.6 */ |
| 1743 | state->TG_LO = state->RF_IN - 750000; |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 1744 | } else /* Analog Mode */ { |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 1745 | if (state->IF_Mode == 0) /* Analog Zero IF mode */ { |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 1746 | state->RF_LO = state->RF_IN - 400000; |
| 1747 | state->TG_LO = state->RF_IN - 1750000; |
| 1748 | } else /* Analog Low IF mode */ { |
| 1749 | state->RF_LO = state->RF_IN - state->Chan_Bandwidth/2; |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 1750 | state->TG_LO = state->RF_IN - |
| 1751 | state->Chan_Bandwidth + 500000; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 1752 | } |
| 1753 | } |
| 1754 | } |
| 1755 | |
Steven Toth | c6c34b1 | 2008-05-03 14:14:54 -0300 | [diff] [blame] | 1756 | static u16 MXL_OverwriteICDefault(struct dvb_frontend *fe) |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 1757 | { |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 1758 | u16 status = 0; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 1759 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 1760 | status += MXL_ControlWrite(fe, OVERRIDE_1, 1); |
| 1761 | status += MXL_ControlWrite(fe, OVERRIDE_2, 1); |
| 1762 | status += MXL_ControlWrite(fe, OVERRIDE_3, 1); |
| 1763 | status += MXL_ControlWrite(fe, OVERRIDE_4, 1); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 1764 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 1765 | return status; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 1766 | } |
| 1767 | |
Steven Toth | c6c34b1 | 2008-05-03 14:14:54 -0300 | [diff] [blame] | 1768 | static u16 MXL_BlockInit(struct dvb_frontend *fe) |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 1769 | { |
Steven Toth | 85d220d | 2008-05-01 05:48:14 -0300 | [diff] [blame] | 1770 | struct mxl5005s_state *state = fe->tuner_priv; |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 1771 | u16 status = 0; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 1772 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 1773 | status += MXL_OverwriteICDefault(fe); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 1774 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 1775 | /* Downconverter Control Dig Ana */ |
| 1776 | status += MXL_ControlWrite(fe, DN_IQTN_AMP_CUT, state->Mode ? 1 : 0); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 1777 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 1778 | /* Filter Control Dig Ana */ |
| 1779 | status += MXL_ControlWrite(fe, BB_MODE, state->Mode ? 0 : 1); |
| 1780 | status += MXL_ControlWrite(fe, BB_BUF, state->Mode ? 3 : 2); |
| 1781 | status += MXL_ControlWrite(fe, BB_BUF_OA, state->Mode ? 1 : 0); |
| 1782 | status += MXL_ControlWrite(fe, BB_IQSWAP, state->Mode ? 0 : 1); |
| 1783 | status += MXL_ControlWrite(fe, BB_INITSTATE_DLPF_TUNE, 0); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 1784 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 1785 | /* Initialize Low-Pass Filter */ |
| 1786 | if (state->Mode) { /* Digital Mode */ |
| 1787 | switch (state->Chan_Bandwidth) { |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 1788 | case 8000000: |
| 1789 | status += MXL_ControlWrite(fe, BB_DLPF_BANDSEL, 0); |
| 1790 | break; |
| 1791 | case 7000000: |
| 1792 | status += MXL_ControlWrite(fe, BB_DLPF_BANDSEL, 2); |
| 1793 | break; |
| 1794 | case 6000000: |
| 1795 | status += MXL_ControlWrite(fe, |
| 1796 | BB_DLPF_BANDSEL, 3); |
| 1797 | break; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 1798 | } |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 1799 | } else { /* Analog Mode */ |
| 1800 | switch (state->Chan_Bandwidth) { |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 1801 | case 8000000: /* Low Zero */ |
| 1802 | status += MXL_ControlWrite(fe, BB_ALPF_BANDSELECT, |
| 1803 | (state->IF_Mode ? 0 : 3)); |
| 1804 | break; |
| 1805 | case 7000000: |
| 1806 | status += MXL_ControlWrite(fe, BB_ALPF_BANDSELECT, |
| 1807 | (state->IF_Mode ? 1 : 4)); |
| 1808 | break; |
| 1809 | case 6000000: |
| 1810 | status += MXL_ControlWrite(fe, BB_ALPF_BANDSELECT, |
| 1811 | (state->IF_Mode ? 2 : 5)); |
| 1812 | break; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 1813 | } |
| 1814 | } |
| 1815 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 1816 | /* Charge Pump Control Dig Ana */ |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 1817 | status += MXL_ControlWrite(fe, RFSYN_CHP_GAIN, state->Mode ? 5 : 8); |
| 1818 | status += MXL_ControlWrite(fe, |
| 1819 | RFSYN_EN_CHP_HIGAIN, state->Mode ? 1 : 1); |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 1820 | status += MXL_ControlWrite(fe, EN_CHP_LIN_B, state->Mode ? 0 : 0); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 1821 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 1822 | /* AGC TOP Control */ |
| 1823 | if (state->AGC_Mode == 0) /* Dual AGC */ { |
| 1824 | status += MXL_ControlWrite(fe, AGC_IF, 15); |
| 1825 | status += MXL_ControlWrite(fe, AGC_RF, 15); |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 1826 | } else /* Single AGC Mode Dig Ana */ |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 1827 | status += MXL_ControlWrite(fe, AGC_RF, state->Mode ? 15 : 12); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 1828 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 1829 | if (state->TOP == 55) /* TOP == 5.5 */ |
| 1830 | status += MXL_ControlWrite(fe, AGC_IF, 0x0); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 1831 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 1832 | if (state->TOP == 72) /* TOP == 7.2 */ |
| 1833 | status += MXL_ControlWrite(fe, AGC_IF, 0x1); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 1834 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 1835 | if (state->TOP == 92) /* TOP == 9.2 */ |
| 1836 | status += MXL_ControlWrite(fe, AGC_IF, 0x2); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 1837 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 1838 | if (state->TOP == 110) /* TOP == 11.0 */ |
| 1839 | status += MXL_ControlWrite(fe, AGC_IF, 0x3); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 1840 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 1841 | if (state->TOP == 129) /* TOP == 12.9 */ |
| 1842 | status += MXL_ControlWrite(fe, AGC_IF, 0x4); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 1843 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 1844 | if (state->TOP == 147) /* TOP == 14.7 */ |
| 1845 | status += MXL_ControlWrite(fe, AGC_IF, 0x5); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 1846 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 1847 | if (state->TOP == 168) /* TOP == 16.8 */ |
| 1848 | status += MXL_ControlWrite(fe, AGC_IF, 0x6); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 1849 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 1850 | if (state->TOP == 194) /* TOP == 19.4 */ |
| 1851 | status += MXL_ControlWrite(fe, AGC_IF, 0x7); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 1852 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 1853 | if (state->TOP == 212) /* TOP == 21.2 */ |
| 1854 | status += MXL_ControlWrite(fe, AGC_IF, 0x9); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 1855 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 1856 | if (state->TOP == 232) /* TOP == 23.2 */ |
| 1857 | status += MXL_ControlWrite(fe, AGC_IF, 0xA); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 1858 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 1859 | if (state->TOP == 252) /* TOP == 25.2 */ |
| 1860 | status += MXL_ControlWrite(fe, AGC_IF, 0xB); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 1861 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 1862 | if (state->TOP == 271) /* TOP == 27.1 */ |
| 1863 | status += MXL_ControlWrite(fe, AGC_IF, 0xC); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 1864 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 1865 | if (state->TOP == 292) /* TOP == 29.2 */ |
| 1866 | status += MXL_ControlWrite(fe, AGC_IF, 0xD); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 1867 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 1868 | if (state->TOP == 317) /* TOP == 31.7 */ |
| 1869 | status += MXL_ControlWrite(fe, AGC_IF, 0xE); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 1870 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 1871 | if (state->TOP == 349) /* TOP == 34.9 */ |
| 1872 | status += MXL_ControlWrite(fe, AGC_IF, 0xF); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 1873 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 1874 | /* IF Synthesizer Control */ |
| 1875 | status += MXL_IFSynthInit(fe); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 1876 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 1877 | /* IF UpConverter Control */ |
| 1878 | if (state->IF_OUT_LOAD == 200) { |
| 1879 | status += MXL_ControlWrite(fe, DRV_RES_SEL, 6); |
| 1880 | status += MXL_ControlWrite(fe, I_DRIVER, 2); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 1881 | } |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 1882 | if (state->IF_OUT_LOAD == 300) { |
| 1883 | status += MXL_ControlWrite(fe, DRV_RES_SEL, 4); |
| 1884 | status += MXL_ControlWrite(fe, I_DRIVER, 1); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 1885 | } |
| 1886 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 1887 | /* Anti-Alias Filtering Control |
| 1888 | * initialise Anti-Aliasing Filter |
| 1889 | */ |
| 1890 | if (state->Mode) { /* Digital Mode */ |
| 1891 | if (state->IF_OUT >= 4000000UL && state->IF_OUT <= 6280000UL) { |
| 1892 | status += MXL_ControlWrite(fe, EN_AAF, 1); |
| 1893 | status += MXL_ControlWrite(fe, EN_3P, 1); |
| 1894 | status += MXL_ControlWrite(fe, EN_AUX_3P, 1); |
| 1895 | status += MXL_ControlWrite(fe, SEL_AAF_BAND, 0); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 1896 | } |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 1897 | if ((state->IF_OUT == 36125000UL) || |
| 1898 | (state->IF_OUT == 36150000UL)) { |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 1899 | status += MXL_ControlWrite(fe, EN_AAF, 1); |
| 1900 | status += MXL_ControlWrite(fe, EN_3P, 1); |
| 1901 | status += MXL_ControlWrite(fe, EN_AUX_3P, 1); |
| 1902 | status += MXL_ControlWrite(fe, SEL_AAF_BAND, 1); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 1903 | } |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 1904 | if (state->IF_OUT > 36150000UL) { |
| 1905 | status += MXL_ControlWrite(fe, EN_AAF, 0); |
| 1906 | status += MXL_ControlWrite(fe, EN_3P, 1); |
| 1907 | status += MXL_ControlWrite(fe, EN_AUX_3P, 1); |
| 1908 | status += MXL_ControlWrite(fe, SEL_AAF_BAND, 1); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 1909 | } |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 1910 | } else { /* Analog Mode */ |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 1911 | if (state->IF_OUT >= 4000000UL && state->IF_OUT <= 5000000UL) { |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 1912 | status += MXL_ControlWrite(fe, EN_AAF, 1); |
| 1913 | status += MXL_ControlWrite(fe, EN_3P, 1); |
| 1914 | status += MXL_ControlWrite(fe, EN_AUX_3P, 1); |
| 1915 | status += MXL_ControlWrite(fe, SEL_AAF_BAND, 0); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 1916 | } |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 1917 | if (state->IF_OUT > 5000000UL) { |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 1918 | status += MXL_ControlWrite(fe, EN_AAF, 0); |
| 1919 | status += MXL_ControlWrite(fe, EN_3P, 0); |
| 1920 | status += MXL_ControlWrite(fe, EN_AUX_3P, 0); |
| 1921 | status += MXL_ControlWrite(fe, SEL_AAF_BAND, 0); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 1922 | } |
| 1923 | } |
| 1924 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 1925 | /* Demod Clock Out */ |
| 1926 | if (state->CLOCK_OUT) |
| 1927 | status += MXL_ControlWrite(fe, SEQ_ENCLK16_CLK_OUT, 1); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 1928 | else |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 1929 | status += MXL_ControlWrite(fe, SEQ_ENCLK16_CLK_OUT, 0); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 1930 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 1931 | if (state->DIV_OUT == 1) |
| 1932 | status += MXL_ControlWrite(fe, SEQ_SEL4_16B, 1); |
| 1933 | if (state->DIV_OUT == 0) |
| 1934 | status += MXL_ControlWrite(fe, SEQ_SEL4_16B, 0); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 1935 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 1936 | /* Crystal Control */ |
| 1937 | if (state->CAPSELECT) |
| 1938 | status += MXL_ControlWrite(fe, XTAL_CAPSELECT, 1); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 1939 | else |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 1940 | status += MXL_ControlWrite(fe, XTAL_CAPSELECT, 0); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 1941 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 1942 | if (state->Fxtal >= 12000000UL && state->Fxtal <= 16000000UL) |
| 1943 | status += MXL_ControlWrite(fe, IF_SEL_DBL, 1); |
| 1944 | if (state->Fxtal > 16000000UL && state->Fxtal <= 32000000UL) |
| 1945 | status += MXL_ControlWrite(fe, IF_SEL_DBL, 0); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 1946 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 1947 | if (state->Fxtal >= 12000000UL && state->Fxtal <= 22000000UL) |
| 1948 | status += MXL_ControlWrite(fe, RFSYN_R_DIV, 3); |
| 1949 | if (state->Fxtal > 22000000UL && state->Fxtal <= 32000000UL) |
| 1950 | status += MXL_ControlWrite(fe, RFSYN_R_DIV, 0); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 1951 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 1952 | /* Misc Controls */ |
Steven Toth | 85d220d | 2008-05-01 05:48:14 -0300 | [diff] [blame] | 1953 | if (state->Mode == 0 && state->IF_Mode == 1) /* Analog LowIF mode */ |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 1954 | status += MXL_ControlWrite(fe, SEQ_EXTIQFSMPULSE, 0); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 1955 | else |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 1956 | status += MXL_ControlWrite(fe, SEQ_EXTIQFSMPULSE, 1); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 1957 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 1958 | /* status += MXL_ControlRead(fe, IF_DIVVAL, &IF_DIVVAL_Val); */ |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 1959 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 1960 | /* Set TG_R_DIV */ |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 1961 | status += MXL_ControlWrite(fe, TG_R_DIV, |
| 1962 | MXL_Ceiling(state->Fxtal, 1000000)); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 1963 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 1964 | /* Apply Default value to BB_INITSTATE_DLPF_TUNE */ |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 1965 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 1966 | /* RSSI Control */ |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 1967 | if (state->EN_RSSI) { |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 1968 | status += MXL_ControlWrite(fe, SEQ_EXTSYNTHCALIF, 1); |
| 1969 | status += MXL_ControlWrite(fe, SEQ_EXTDCCAL, 1); |
| 1970 | status += MXL_ControlWrite(fe, AGC_EN_RSSI, 1); |
| 1971 | status += MXL_ControlWrite(fe, RFA_ENCLKRFAGC, 1); |
| 1972 | |
| 1973 | /* RSSI reference point */ |
| 1974 | status += MXL_ControlWrite(fe, RFA_RSSI_REF, 2); |
| 1975 | status += MXL_ControlWrite(fe, RFA_RSSI_REFH, 3); |
| 1976 | status += MXL_ControlWrite(fe, RFA_RSSI_REFL, 1); |
| 1977 | |
| 1978 | /* TOP point */ |
| 1979 | status += MXL_ControlWrite(fe, RFA_FLR, 0); |
| 1980 | status += MXL_ControlWrite(fe, RFA_CEIL, 12); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 1981 | } |
| 1982 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 1983 | /* Modulation type bit settings |
| 1984 | * Override the control values preset |
| 1985 | */ |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 1986 | if (state->Mod_Type == MXL_DVBT) /* DVB-T Mode */ { |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 1987 | state->AGC_Mode = 1; /* Single AGC Mode */ |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 1988 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 1989 | /* Enable RSSI */ |
| 1990 | status += MXL_ControlWrite(fe, SEQ_EXTSYNTHCALIF, 1); |
| 1991 | status += MXL_ControlWrite(fe, SEQ_EXTDCCAL, 1); |
| 1992 | status += MXL_ControlWrite(fe, AGC_EN_RSSI, 1); |
| 1993 | status += MXL_ControlWrite(fe, RFA_ENCLKRFAGC, 1); |
| 1994 | |
| 1995 | /* RSSI reference point */ |
| 1996 | status += MXL_ControlWrite(fe, RFA_RSSI_REF, 3); |
| 1997 | status += MXL_ControlWrite(fe, RFA_RSSI_REFH, 5); |
| 1998 | status += MXL_ControlWrite(fe, RFA_RSSI_REFL, 1); |
| 1999 | |
| 2000 | /* TOP point */ |
| 2001 | status += MXL_ControlWrite(fe, RFA_FLR, 2); |
| 2002 | status += MXL_ControlWrite(fe, RFA_CEIL, 13); |
| 2003 | if (state->IF_OUT <= 6280000UL) /* Low IF */ |
| 2004 | status += MXL_ControlWrite(fe, BB_IQSWAP, 0); |
| 2005 | else /* High IF */ |
| 2006 | status += MXL_ControlWrite(fe, BB_IQSWAP, 1); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2007 | |
| 2008 | } |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 2009 | if (state->Mod_Type == MXL_ATSC) /* ATSC Mode */ { |
Steven Toth | 85d220d | 2008-05-01 05:48:14 -0300 | [diff] [blame] | 2010 | state->AGC_Mode = 1; /* Single AGC Mode */ |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2011 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 2012 | /* Enable RSSI */ |
| 2013 | status += MXL_ControlWrite(fe, SEQ_EXTSYNTHCALIF, 1); |
| 2014 | status += MXL_ControlWrite(fe, SEQ_EXTDCCAL, 1); |
| 2015 | status += MXL_ControlWrite(fe, AGC_EN_RSSI, 1); |
| 2016 | status += MXL_ControlWrite(fe, RFA_ENCLKRFAGC, 1); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2017 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 2018 | /* RSSI reference point */ |
| 2019 | status += MXL_ControlWrite(fe, RFA_RSSI_REF, 2); |
| 2020 | status += MXL_ControlWrite(fe, RFA_RSSI_REFH, 4); |
| 2021 | status += MXL_ControlWrite(fe, RFA_RSSI_REFL, 1); |
| 2022 | |
| 2023 | /* TOP point */ |
| 2024 | status += MXL_ControlWrite(fe, RFA_FLR, 2); |
| 2025 | status += MXL_ControlWrite(fe, RFA_CEIL, 13); |
| 2026 | status += MXL_ControlWrite(fe, BB_INITSTATE_DLPF_TUNE, 1); |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 2027 | /* Low Zero */ |
| 2028 | status += MXL_ControlWrite(fe, RFSYN_CHP_GAIN, 5); |
| 2029 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 2030 | if (state->IF_OUT <= 6280000UL) /* Low IF */ |
| 2031 | status += MXL_ControlWrite(fe, BB_IQSWAP, 0); |
| 2032 | else /* High IF */ |
| 2033 | status += MXL_ControlWrite(fe, BB_IQSWAP, 1); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2034 | } |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 2035 | if (state->Mod_Type == MXL_QAM) /* QAM Mode */ { |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 2036 | state->Mode = MXL_DIGITAL_MODE; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2037 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 2038 | /* state->AGC_Mode = 1; */ /* Single AGC Mode */ |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2039 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 2040 | /* Disable RSSI */ /* change here for v2.6.5 */ |
| 2041 | status += MXL_ControlWrite(fe, SEQ_EXTSYNTHCALIF, 1); |
| 2042 | status += MXL_ControlWrite(fe, SEQ_EXTDCCAL, 1); |
| 2043 | status += MXL_ControlWrite(fe, AGC_EN_RSSI, 0); |
| 2044 | status += MXL_ControlWrite(fe, RFA_ENCLKRFAGC, 1); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2045 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 2046 | /* RSSI reference point */ |
| 2047 | status += MXL_ControlWrite(fe, RFA_RSSI_REFH, 5); |
| 2048 | status += MXL_ControlWrite(fe, RFA_RSSI_REF, 3); |
| 2049 | status += MXL_ControlWrite(fe, RFA_RSSI_REFL, 2); |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 2050 | /* change here for v2.6.5 */ |
| 2051 | status += MXL_ControlWrite(fe, RFSYN_CHP_GAIN, 3); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2052 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 2053 | if (state->IF_OUT <= 6280000UL) /* Low IF */ |
| 2054 | status += MXL_ControlWrite(fe, BB_IQSWAP, 0); |
| 2055 | else /* High IF */ |
| 2056 | status += MXL_ControlWrite(fe, BB_IQSWAP, 1); |
Steven Toth | 4893729 | 2008-05-01 07:15:38 -0300 | [diff] [blame] | 2057 | status += MXL_ControlWrite(fe, RFSYN_CHP_GAIN, 2); |
| 2058 | |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2059 | } |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 2060 | if (state->Mod_Type == MXL_ANALOG_CABLE) { |
| 2061 | /* Analog Cable Mode */ |
Steven Toth | 85d220d | 2008-05-01 05:48:14 -0300 | [diff] [blame] | 2062 | /* state->Mode = MXL_DIGITAL_MODE; */ |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2063 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 2064 | state->AGC_Mode = 1; /* Single AGC Mode */ |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2065 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 2066 | /* Disable RSSI */ |
| 2067 | status += MXL_ControlWrite(fe, SEQ_EXTSYNTHCALIF, 1); |
| 2068 | status += MXL_ControlWrite(fe, SEQ_EXTDCCAL, 1); |
| 2069 | status += MXL_ControlWrite(fe, AGC_EN_RSSI, 0); |
| 2070 | status += MXL_ControlWrite(fe, RFA_ENCLKRFAGC, 1); |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 2071 | /* change for 2.6.3 */ |
| 2072 | status += MXL_ControlWrite(fe, AGC_IF, 1); |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 2073 | status += MXL_ControlWrite(fe, AGC_RF, 15); |
| 2074 | status += MXL_ControlWrite(fe, BB_IQSWAP, 1); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2075 | } |
| 2076 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 2077 | if (state->Mod_Type == MXL_ANALOG_OTA) { |
| 2078 | /* Analog OTA Terrestrial mode add for 2.6.7 */ |
| 2079 | /* state->Mode = MXL_ANALOG_MODE; */ |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2080 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 2081 | /* Enable RSSI */ |
| 2082 | status += MXL_ControlWrite(fe, SEQ_EXTSYNTHCALIF, 1); |
| 2083 | status += MXL_ControlWrite(fe, SEQ_EXTDCCAL, 1); |
| 2084 | status += MXL_ControlWrite(fe, AGC_EN_RSSI, 1); |
| 2085 | status += MXL_ControlWrite(fe, RFA_ENCLKRFAGC, 1); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2086 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 2087 | /* RSSI reference point */ |
| 2088 | status += MXL_ControlWrite(fe, RFA_RSSI_REFH, 5); |
| 2089 | status += MXL_ControlWrite(fe, RFA_RSSI_REF, 3); |
| 2090 | status += MXL_ControlWrite(fe, RFA_RSSI_REFL, 2); |
| 2091 | status += MXL_ControlWrite(fe, RFSYN_CHP_GAIN, 3); |
| 2092 | status += MXL_ControlWrite(fe, BB_IQSWAP, 1); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2093 | } |
| 2094 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 2095 | /* RSSI disable */ |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 2096 | if (state->EN_RSSI == 0) { |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 2097 | status += MXL_ControlWrite(fe, SEQ_EXTSYNTHCALIF, 1); |
| 2098 | status += MXL_ControlWrite(fe, SEQ_EXTDCCAL, 1); |
| 2099 | status += MXL_ControlWrite(fe, AGC_EN_RSSI, 0); |
| 2100 | status += MXL_ControlWrite(fe, RFA_ENCLKRFAGC, 1); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2101 | } |
| 2102 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 2103 | return status; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2104 | } |
| 2105 | |
Steven Toth | c6c34b1 | 2008-05-03 14:14:54 -0300 | [diff] [blame] | 2106 | static u16 MXL_IFSynthInit(struct dvb_frontend *fe) |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2107 | { |
Steven Toth | 85d220d | 2008-05-01 05:48:14 -0300 | [diff] [blame] | 2108 | struct mxl5005s_state *state = fe->tuner_priv; |
Steven Toth | a8214d4 | 2008-05-01 05:02:58 -0300 | [diff] [blame] | 2109 | u16 status = 0 ; |
Steven Toth | a8214d4 | 2008-05-01 05:02:58 -0300 | [diff] [blame] | 2110 | u32 Fref = 0 ; |
| 2111 | u32 Kdbl, intModVal ; |
| 2112 | u32 fracModVal ; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2113 | Kdbl = 2 ; |
| 2114 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 2115 | if (state->Fxtal >= 12000000UL && state->Fxtal <= 16000000UL) |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2116 | Kdbl = 2 ; |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 2117 | if (state->Fxtal > 16000000UL && state->Fxtal <= 32000000UL) |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2118 | Kdbl = 1 ; |
| 2119 | |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 2120 | /* IF Synthesizer Control */ |
| 2121 | if (state->Mode == 0 && state->IF_Mode == 1) /* Analog Low IF mode */ { |
Steven Toth | 85d220d | 2008-05-01 05:48:14 -0300 | [diff] [blame] | 2122 | if (state->IF_LO == 41000000UL) { |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 2123 | status += MXL_ControlWrite(fe, IF_DIVVAL, 0x08); |
| 2124 | status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x0C); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2125 | Fref = 328000000UL ; |
| 2126 | } |
Steven Toth | 85d220d | 2008-05-01 05:48:14 -0300 | [diff] [blame] | 2127 | if (state->IF_LO == 47000000UL) { |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 2128 | status += MXL_ControlWrite(fe, IF_DIVVAL, 0x08); |
| 2129 | status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2130 | Fref = 376000000UL ; |
| 2131 | } |
Steven Toth | 85d220d | 2008-05-01 05:48:14 -0300 | [diff] [blame] | 2132 | if (state->IF_LO == 54000000UL) { |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 2133 | status += MXL_ControlWrite(fe, IF_DIVVAL, 0x10); |
| 2134 | status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x0C); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2135 | Fref = 324000000UL ; |
| 2136 | } |
Steven Toth | 85d220d | 2008-05-01 05:48:14 -0300 | [diff] [blame] | 2137 | if (state->IF_LO == 60000000UL) { |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 2138 | status += MXL_ControlWrite(fe, IF_DIVVAL, 0x10); |
| 2139 | status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2140 | Fref = 360000000UL ; |
| 2141 | } |
Steven Toth | 85d220d | 2008-05-01 05:48:14 -0300 | [diff] [blame] | 2142 | if (state->IF_LO == 39250000UL) { |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 2143 | status += MXL_ControlWrite(fe, IF_DIVVAL, 0x08); |
| 2144 | status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x0C); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2145 | Fref = 314000000UL ; |
| 2146 | } |
Steven Toth | 85d220d | 2008-05-01 05:48:14 -0300 | [diff] [blame] | 2147 | if (state->IF_LO == 39650000UL) { |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 2148 | status += MXL_ControlWrite(fe, IF_DIVVAL, 0x08); |
| 2149 | status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x0C); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2150 | Fref = 317200000UL ; |
| 2151 | } |
Steven Toth | 85d220d | 2008-05-01 05:48:14 -0300 | [diff] [blame] | 2152 | if (state->IF_LO == 40150000UL) { |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 2153 | status += MXL_ControlWrite(fe, IF_DIVVAL, 0x08); |
| 2154 | status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x0C); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2155 | Fref = 321200000UL ; |
| 2156 | } |
Steven Toth | 85d220d | 2008-05-01 05:48:14 -0300 | [diff] [blame] | 2157 | if (state->IF_LO == 40650000UL) { |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 2158 | status += MXL_ControlWrite(fe, IF_DIVVAL, 0x08); |
| 2159 | status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x0C); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2160 | Fref = 325200000UL ; |
| 2161 | } |
| 2162 | } |
| 2163 | |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 2164 | if (state->Mode || (state->Mode == 0 && state->IF_Mode == 0)) { |
Steven Toth | 85d220d | 2008-05-01 05:48:14 -0300 | [diff] [blame] | 2165 | if (state->IF_LO == 57000000UL) { |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 2166 | status += MXL_ControlWrite(fe, IF_DIVVAL, 0x10); |
| 2167 | status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2168 | Fref = 342000000UL ; |
| 2169 | } |
Steven Toth | 85d220d | 2008-05-01 05:48:14 -0300 | [diff] [blame] | 2170 | if (state->IF_LO == 44000000UL) { |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 2171 | status += MXL_ControlWrite(fe, IF_DIVVAL, 0x08); |
| 2172 | status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2173 | Fref = 352000000UL ; |
| 2174 | } |
Steven Toth | 85d220d | 2008-05-01 05:48:14 -0300 | [diff] [blame] | 2175 | if (state->IF_LO == 43750000UL) { |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 2176 | status += MXL_ControlWrite(fe, IF_DIVVAL, 0x08); |
| 2177 | status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2178 | Fref = 350000000UL ; |
| 2179 | } |
Steven Toth | 85d220d | 2008-05-01 05:48:14 -0300 | [diff] [blame] | 2180 | if (state->IF_LO == 36650000UL) { |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 2181 | status += MXL_ControlWrite(fe, IF_DIVVAL, 0x04); |
| 2182 | status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2183 | Fref = 366500000UL ; |
| 2184 | } |
Steven Toth | 85d220d | 2008-05-01 05:48:14 -0300 | [diff] [blame] | 2185 | if (state->IF_LO == 36150000UL) { |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 2186 | status += MXL_ControlWrite(fe, IF_DIVVAL, 0x04); |
| 2187 | status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2188 | Fref = 361500000UL ; |
| 2189 | } |
Steven Toth | 85d220d | 2008-05-01 05:48:14 -0300 | [diff] [blame] | 2190 | if (state->IF_LO == 36000000UL) { |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 2191 | status += MXL_ControlWrite(fe, IF_DIVVAL, 0x04); |
| 2192 | status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2193 | Fref = 360000000UL ; |
| 2194 | } |
Steven Toth | 85d220d | 2008-05-01 05:48:14 -0300 | [diff] [blame] | 2195 | if (state->IF_LO == 35250000UL) { |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 2196 | status += MXL_ControlWrite(fe, IF_DIVVAL, 0x04); |
| 2197 | status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2198 | Fref = 352500000UL ; |
| 2199 | } |
Steven Toth | 85d220d | 2008-05-01 05:48:14 -0300 | [diff] [blame] | 2200 | if (state->IF_LO == 34750000UL) { |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 2201 | status += MXL_ControlWrite(fe, IF_DIVVAL, 0x04); |
| 2202 | status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2203 | Fref = 347500000UL ; |
| 2204 | } |
Steven Toth | 85d220d | 2008-05-01 05:48:14 -0300 | [diff] [blame] | 2205 | if (state->IF_LO == 6280000UL) { |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 2206 | status += MXL_ControlWrite(fe, IF_DIVVAL, 0x07); |
| 2207 | status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2208 | Fref = 376800000UL ; |
| 2209 | } |
Steven Toth | 85d220d | 2008-05-01 05:48:14 -0300 | [diff] [blame] | 2210 | if (state->IF_LO == 5000000UL) { |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 2211 | status += MXL_ControlWrite(fe, IF_DIVVAL, 0x09); |
| 2212 | status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2213 | Fref = 360000000UL ; |
| 2214 | } |
Steven Toth | 85d220d | 2008-05-01 05:48:14 -0300 | [diff] [blame] | 2215 | if (state->IF_LO == 4500000UL) { |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 2216 | status += MXL_ControlWrite(fe, IF_DIVVAL, 0x06); |
| 2217 | status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2218 | Fref = 360000000UL ; |
| 2219 | } |
Steven Toth | 85d220d | 2008-05-01 05:48:14 -0300 | [diff] [blame] | 2220 | if (state->IF_LO == 4570000UL) { |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 2221 | status += MXL_ControlWrite(fe, IF_DIVVAL, 0x06); |
| 2222 | status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2223 | Fref = 365600000UL ; |
| 2224 | } |
Steven Toth | 85d220d | 2008-05-01 05:48:14 -0300 | [diff] [blame] | 2225 | if (state->IF_LO == 4000000UL) { |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 2226 | status += MXL_ControlWrite(fe, IF_DIVVAL, 0x05); |
| 2227 | status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2228 | Fref = 360000000UL ; |
| 2229 | } |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 2230 | if (state->IF_LO == 57400000UL) { |
| 2231 | status += MXL_ControlWrite(fe, IF_DIVVAL, 0x10); |
| 2232 | status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2233 | Fref = 344400000UL ; |
| 2234 | } |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 2235 | if (state->IF_LO == 44400000UL) { |
| 2236 | status += MXL_ControlWrite(fe, IF_DIVVAL, 0x08); |
| 2237 | status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2238 | Fref = 355200000UL ; |
| 2239 | } |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 2240 | if (state->IF_LO == 44150000UL) { |
| 2241 | status += MXL_ControlWrite(fe, IF_DIVVAL, 0x08); |
| 2242 | status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2243 | Fref = 353200000UL ; |
| 2244 | } |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 2245 | if (state->IF_LO == 37050000UL) { |
| 2246 | status += MXL_ControlWrite(fe, IF_DIVVAL, 0x04); |
| 2247 | status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2248 | Fref = 370500000UL ; |
| 2249 | } |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 2250 | if (state->IF_LO == 36550000UL) { |
| 2251 | status += MXL_ControlWrite(fe, IF_DIVVAL, 0x04); |
| 2252 | status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2253 | Fref = 365500000UL ; |
| 2254 | } |
Steven Toth | 85d220d | 2008-05-01 05:48:14 -0300 | [diff] [blame] | 2255 | if (state->IF_LO == 36125000UL) { |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 2256 | status += MXL_ControlWrite(fe, IF_DIVVAL, 0x04); |
| 2257 | status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2258 | Fref = 361250000UL ; |
| 2259 | } |
Steven Toth | 85d220d | 2008-05-01 05:48:14 -0300 | [diff] [blame] | 2260 | if (state->IF_LO == 6000000UL) { |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 2261 | status += MXL_ControlWrite(fe, IF_DIVVAL, 0x07); |
| 2262 | status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2263 | Fref = 360000000UL ; |
| 2264 | } |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 2265 | if (state->IF_LO == 5400000UL) { |
| 2266 | status += MXL_ControlWrite(fe, IF_DIVVAL, 0x07); |
| 2267 | status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x0C); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2268 | Fref = 324000000UL ; |
| 2269 | } |
Steven Toth | 85d220d | 2008-05-01 05:48:14 -0300 | [diff] [blame] | 2270 | if (state->IF_LO == 5380000UL) { |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 2271 | status += MXL_ControlWrite(fe, IF_DIVVAL, 0x07); |
| 2272 | status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x0C); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2273 | Fref = 322800000UL ; |
| 2274 | } |
Steven Toth | 85d220d | 2008-05-01 05:48:14 -0300 | [diff] [blame] | 2275 | if (state->IF_LO == 5200000UL) { |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 2276 | status += MXL_ControlWrite(fe, IF_DIVVAL, 0x09); |
| 2277 | status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2278 | Fref = 374400000UL ; |
| 2279 | } |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 2280 | if (state->IF_LO == 4900000UL) { |
| 2281 | status += MXL_ControlWrite(fe, IF_DIVVAL, 0x09); |
| 2282 | status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2283 | Fref = 352800000UL ; |
| 2284 | } |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 2285 | if (state->IF_LO == 4400000UL) { |
| 2286 | status += MXL_ControlWrite(fe, IF_DIVVAL, 0x06); |
| 2287 | status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2288 | Fref = 352000000UL ; |
| 2289 | } |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 2290 | if (state->IF_LO == 4063000UL) /* add for 2.6.8 */ { |
| 2291 | status += MXL_ControlWrite(fe, IF_DIVVAL, 0x05); |
| 2292 | status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2293 | Fref = 365670000UL ; |
| 2294 | } |
| 2295 | } |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 2296 | /* CHCAL_INT_MOD_IF */ |
| 2297 | /* CHCAL_FRAC_MOD_IF */ |
| 2298 | intModVal = Fref / (state->Fxtal * Kdbl/2); |
| 2299 | status += MXL_ControlWrite(fe, CHCAL_INT_MOD_IF, intModVal); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2300 | |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 2301 | fracModVal = (2<<15)*(Fref/1000 - (state->Fxtal/1000 * Kdbl/2) * |
| 2302 | intModVal); |
| 2303 | |
| 2304 | fracModVal = fracModVal / ((state->Fxtal * Kdbl/2)/1000); |
| 2305 | status += MXL_ControlWrite(fe, CHCAL_FRAC_MOD_IF, fracModVal); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2306 | |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2307 | return status ; |
| 2308 | } |
| 2309 | |
Steven Toth | c6c34b1 | 2008-05-03 14:14:54 -0300 | [diff] [blame] | 2310 | static u32 MXL_GetXtalInt(u32 Xtal_Freq) |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2311 | { |
| 2312 | if ((Xtal_Freq % 1000000) == 0) |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 2313 | return (Xtal_Freq / 10000); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2314 | else |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 2315 | return (((Xtal_Freq / 1000000) + 1)*100); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2316 | } |
| 2317 | |
Steven Toth | c6c34b1 | 2008-05-03 14:14:54 -0300 | [diff] [blame] | 2318 | static u16 MXL_TuneRF(struct dvb_frontend *fe, u32 RF_Freq) |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2319 | { |
Steven Toth | 85d220d | 2008-05-01 05:48:14 -0300 | [diff] [blame] | 2320 | struct mxl5005s_state *state = fe->tuner_priv; |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 2321 | u16 status = 0; |
| 2322 | u32 divider_val, E3, E4, E5, E5A; |
| 2323 | u32 Fmax, Fmin, FmaxBin, FminBin; |
Steven Toth | a8214d4 | 2008-05-01 05:02:58 -0300 | [diff] [blame] | 2324 | u32 Kdbl_RF = 2; |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 2325 | u32 tg_divval; |
| 2326 | u32 tg_lo; |
| 2327 | u32 Xtal_Int; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2328 | |
Steven Toth | a8214d4 | 2008-05-01 05:02:58 -0300 | [diff] [blame] | 2329 | u32 Fref_TG; |
| 2330 | u32 Fvco; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2331 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 2332 | Xtal_Int = MXL_GetXtalInt(state->Fxtal); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2333 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 2334 | state->RF_IN = RF_Freq; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2335 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 2336 | MXL_SynthRFTGLO_Calc(fe); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2337 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 2338 | if (state->Fxtal >= 12000000UL && state->Fxtal <= 22000000UL) |
| 2339 | Kdbl_RF = 2; |
| 2340 | if (state->Fxtal > 22000000 && state->Fxtal <= 32000000) |
| 2341 | Kdbl_RF = 1; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2342 | |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 2343 | /* Downconverter Controls |
| 2344 | * Look-Up Table Implementation for: |
| 2345 | * DN_POLY |
| 2346 | * DN_RFGAIN |
| 2347 | * DN_CAP_RFLPF |
| 2348 | * DN_EN_VHFUHFBAR |
| 2349 | * DN_GAIN_ADJUST |
| 2350 | * Change the boundary reference from RF_IN to RF_LO |
| 2351 | */ |
| 2352 | if (state->RF_LO < 40000000UL) |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2353 | return -1; |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 2354 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 2355 | if (state->RF_LO >= 40000000UL && state->RF_LO <= 75000000UL) { |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 2356 | status += MXL_ControlWrite(fe, DN_POLY, 2); |
| 2357 | status += MXL_ControlWrite(fe, DN_RFGAIN, 3); |
| 2358 | status += MXL_ControlWrite(fe, DN_CAP_RFLPF, 423); |
| 2359 | status += MXL_ControlWrite(fe, DN_EN_VHFUHFBAR, 1); |
| 2360 | status += MXL_ControlWrite(fe, DN_GAIN_ADJUST, 1); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2361 | } |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 2362 | if (state->RF_LO > 75000000UL && state->RF_LO <= 100000000UL) { |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 2363 | status += MXL_ControlWrite(fe, DN_POLY, 3); |
| 2364 | status += MXL_ControlWrite(fe, DN_RFGAIN, 3); |
| 2365 | status += MXL_ControlWrite(fe, DN_CAP_RFLPF, 222); |
| 2366 | status += MXL_ControlWrite(fe, DN_EN_VHFUHFBAR, 1); |
| 2367 | status += MXL_ControlWrite(fe, DN_GAIN_ADJUST, 1); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2368 | } |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 2369 | if (state->RF_LO > 100000000UL && state->RF_LO <= 150000000UL) { |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 2370 | status += MXL_ControlWrite(fe, DN_POLY, 3); |
| 2371 | status += MXL_ControlWrite(fe, DN_RFGAIN, 3); |
| 2372 | status += MXL_ControlWrite(fe, DN_CAP_RFLPF, 147); |
| 2373 | status += MXL_ControlWrite(fe, DN_EN_VHFUHFBAR, 1); |
| 2374 | status += MXL_ControlWrite(fe, DN_GAIN_ADJUST, 2); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2375 | } |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 2376 | if (state->RF_LO > 150000000UL && state->RF_LO <= 200000000UL) { |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 2377 | status += MXL_ControlWrite(fe, DN_POLY, 3); |
| 2378 | status += MXL_ControlWrite(fe, DN_RFGAIN, 3); |
| 2379 | status += MXL_ControlWrite(fe, DN_CAP_RFLPF, 9); |
| 2380 | status += MXL_ControlWrite(fe, DN_EN_VHFUHFBAR, 1); |
| 2381 | status += MXL_ControlWrite(fe, DN_GAIN_ADJUST, 2); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2382 | } |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 2383 | if (state->RF_LO > 200000000UL && state->RF_LO <= 300000000UL) { |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 2384 | status += MXL_ControlWrite(fe, DN_POLY, 3); |
| 2385 | status += MXL_ControlWrite(fe, DN_RFGAIN, 3); |
| 2386 | status += MXL_ControlWrite(fe, DN_CAP_RFLPF, 0); |
| 2387 | status += MXL_ControlWrite(fe, DN_EN_VHFUHFBAR, 1); |
| 2388 | status += MXL_ControlWrite(fe, DN_GAIN_ADJUST, 3); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2389 | } |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 2390 | if (state->RF_LO > 300000000UL && state->RF_LO <= 650000000UL) { |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 2391 | status += MXL_ControlWrite(fe, DN_POLY, 3); |
| 2392 | status += MXL_ControlWrite(fe, DN_RFGAIN, 1); |
| 2393 | status += MXL_ControlWrite(fe, DN_CAP_RFLPF, 0); |
| 2394 | status += MXL_ControlWrite(fe, DN_EN_VHFUHFBAR, 0); |
| 2395 | status += MXL_ControlWrite(fe, DN_GAIN_ADJUST, 3); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2396 | } |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 2397 | if (state->RF_LO > 650000000UL && state->RF_LO <= 900000000UL) { |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 2398 | status += MXL_ControlWrite(fe, DN_POLY, 3); |
| 2399 | status += MXL_ControlWrite(fe, DN_RFGAIN, 2); |
| 2400 | status += MXL_ControlWrite(fe, DN_CAP_RFLPF, 0); |
| 2401 | status += MXL_ControlWrite(fe, DN_EN_VHFUHFBAR, 0); |
| 2402 | status += MXL_ControlWrite(fe, DN_GAIN_ADJUST, 3); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2403 | } |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 2404 | if (state->RF_LO > 900000000UL) |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2405 | return -1; |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 2406 | |
| 2407 | /* DN_IQTNBUF_AMP */ |
| 2408 | /* DN_IQTNGNBFBIAS_BST */ |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 2409 | if (state->RF_LO >= 40000000UL && state->RF_LO <= 75000000UL) { |
| 2410 | status += MXL_ControlWrite(fe, DN_IQTNBUF_AMP, 1); |
| 2411 | status += MXL_ControlWrite(fe, DN_IQTNGNBFBIAS_BST, 0); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2412 | } |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 2413 | if (state->RF_LO > 75000000UL && state->RF_LO <= 100000000UL) { |
| 2414 | status += MXL_ControlWrite(fe, DN_IQTNBUF_AMP, 1); |
| 2415 | status += MXL_ControlWrite(fe, DN_IQTNGNBFBIAS_BST, 0); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2416 | } |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 2417 | if (state->RF_LO > 100000000UL && state->RF_LO <= 150000000UL) { |
| 2418 | status += MXL_ControlWrite(fe, DN_IQTNBUF_AMP, 1); |
| 2419 | status += MXL_ControlWrite(fe, DN_IQTNGNBFBIAS_BST, 0); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2420 | } |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 2421 | if (state->RF_LO > 150000000UL && state->RF_LO <= 200000000UL) { |
| 2422 | status += MXL_ControlWrite(fe, DN_IQTNBUF_AMP, 1); |
| 2423 | status += MXL_ControlWrite(fe, DN_IQTNGNBFBIAS_BST, 0); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2424 | } |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 2425 | if (state->RF_LO > 200000000UL && state->RF_LO <= 300000000UL) { |
| 2426 | status += MXL_ControlWrite(fe, DN_IQTNBUF_AMP, 1); |
| 2427 | status += MXL_ControlWrite(fe, DN_IQTNGNBFBIAS_BST, 0); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2428 | } |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 2429 | if (state->RF_LO > 300000000UL && state->RF_LO <= 400000000UL) { |
| 2430 | status += MXL_ControlWrite(fe, DN_IQTNBUF_AMP, 1); |
| 2431 | status += MXL_ControlWrite(fe, DN_IQTNGNBFBIAS_BST, 0); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2432 | } |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 2433 | if (state->RF_LO > 400000000UL && state->RF_LO <= 450000000UL) { |
| 2434 | status += MXL_ControlWrite(fe, DN_IQTNBUF_AMP, 1); |
| 2435 | status += MXL_ControlWrite(fe, DN_IQTNGNBFBIAS_BST, 0); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2436 | } |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 2437 | if (state->RF_LO > 450000000UL && state->RF_LO <= 500000000UL) { |
| 2438 | status += MXL_ControlWrite(fe, DN_IQTNBUF_AMP, 1); |
| 2439 | status += MXL_ControlWrite(fe, DN_IQTNGNBFBIAS_BST, 0); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2440 | } |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 2441 | if (state->RF_LO > 500000000UL && state->RF_LO <= 550000000UL) { |
| 2442 | status += MXL_ControlWrite(fe, DN_IQTNBUF_AMP, 1); |
| 2443 | status += MXL_ControlWrite(fe, DN_IQTNGNBFBIAS_BST, 0); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2444 | } |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 2445 | if (state->RF_LO > 550000000UL && state->RF_LO <= 600000000UL) { |
| 2446 | status += MXL_ControlWrite(fe, DN_IQTNBUF_AMP, 1); |
| 2447 | status += MXL_ControlWrite(fe, DN_IQTNGNBFBIAS_BST, 0); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2448 | } |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 2449 | if (state->RF_LO > 600000000UL && state->RF_LO <= 650000000UL) { |
| 2450 | status += MXL_ControlWrite(fe, DN_IQTNBUF_AMP, 1); |
| 2451 | status += MXL_ControlWrite(fe, DN_IQTNGNBFBIAS_BST, 0); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2452 | } |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 2453 | if (state->RF_LO > 650000000UL && state->RF_LO <= 700000000UL) { |
| 2454 | status += MXL_ControlWrite(fe, DN_IQTNBUF_AMP, 1); |
| 2455 | status += MXL_ControlWrite(fe, DN_IQTNGNBFBIAS_BST, 0); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2456 | } |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 2457 | if (state->RF_LO > 700000000UL && state->RF_LO <= 750000000UL) { |
| 2458 | status += MXL_ControlWrite(fe, DN_IQTNBUF_AMP, 1); |
| 2459 | status += MXL_ControlWrite(fe, DN_IQTNGNBFBIAS_BST, 0); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2460 | } |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 2461 | if (state->RF_LO > 750000000UL && state->RF_LO <= 800000000UL) { |
| 2462 | status += MXL_ControlWrite(fe, DN_IQTNBUF_AMP, 1); |
| 2463 | status += MXL_ControlWrite(fe, DN_IQTNGNBFBIAS_BST, 0); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2464 | } |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 2465 | if (state->RF_LO > 800000000UL && state->RF_LO <= 850000000UL) { |
| 2466 | status += MXL_ControlWrite(fe, DN_IQTNBUF_AMP, 10); |
| 2467 | status += MXL_ControlWrite(fe, DN_IQTNGNBFBIAS_BST, 1); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2468 | } |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 2469 | if (state->RF_LO > 850000000UL && state->RF_LO <= 900000000UL) { |
| 2470 | status += MXL_ControlWrite(fe, DN_IQTNBUF_AMP, 10); |
| 2471 | status += MXL_ControlWrite(fe, DN_IQTNGNBFBIAS_BST, 1); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2472 | } |
| 2473 | |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 2474 | /* |
| 2475 | * Set RF Synth and LO Path Control |
| 2476 | * |
| 2477 | * Look-Up table implementation for: |
| 2478 | * RFSYN_EN_OUTMUX |
| 2479 | * RFSYN_SEL_VCO_OUT |
| 2480 | * RFSYN_SEL_VCO_HI |
| 2481 | * RFSYN_SEL_DIVM |
| 2482 | * RFSYN_RF_DIV_BIAS |
| 2483 | * DN_SEL_FREQ |
| 2484 | * |
| 2485 | * Set divider_val, Fmax, Fmix to use in Equations |
| 2486 | */ |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2487 | FminBin = 28000000UL ; |
| 2488 | FmaxBin = 42500000UL ; |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 2489 | if (state->RF_LO >= 40000000UL && state->RF_LO <= FmaxBin) { |
| 2490 | status += MXL_ControlWrite(fe, RFSYN_EN_OUTMUX, 1); |
| 2491 | status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_OUT, 0); |
| 2492 | status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 0); |
| 2493 | status += MXL_ControlWrite(fe, RFSYN_SEL_DIVM, 0); |
| 2494 | status += MXL_ControlWrite(fe, RFSYN_RF_DIV_BIAS, 1); |
| 2495 | status += MXL_ControlWrite(fe, DN_SEL_FREQ, 1); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2496 | divider_val = 64 ; |
| 2497 | Fmax = FmaxBin ; |
| 2498 | Fmin = FminBin ; |
| 2499 | } |
| 2500 | FminBin = 42500000UL ; |
| 2501 | FmaxBin = 56000000UL ; |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 2502 | if (state->RF_LO > FminBin && state->RF_LO <= FmaxBin) { |
| 2503 | status += MXL_ControlWrite(fe, RFSYN_EN_OUTMUX, 1); |
| 2504 | status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_OUT, 0); |
| 2505 | status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 1); |
| 2506 | status += MXL_ControlWrite(fe, RFSYN_SEL_DIVM, 0); |
| 2507 | status += MXL_ControlWrite(fe, RFSYN_RF_DIV_BIAS, 1); |
| 2508 | status += MXL_ControlWrite(fe, DN_SEL_FREQ, 1); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2509 | divider_val = 64 ; |
| 2510 | Fmax = FmaxBin ; |
| 2511 | Fmin = FminBin ; |
| 2512 | } |
| 2513 | FminBin = 56000000UL ; |
| 2514 | FmaxBin = 85000000UL ; |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 2515 | if (state->RF_LO > FminBin && state->RF_LO <= FmaxBin) { |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 2516 | status += MXL_ControlWrite(fe, RFSYN_EN_OUTMUX, 0); |
| 2517 | status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_OUT, 1); |
| 2518 | status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 0); |
| 2519 | status += MXL_ControlWrite(fe, RFSYN_SEL_DIVM, 0); |
| 2520 | status += MXL_ControlWrite(fe, RFSYN_RF_DIV_BIAS, 1); |
| 2521 | status += MXL_ControlWrite(fe, DN_SEL_FREQ, 1); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2522 | divider_val = 32 ; |
| 2523 | Fmax = FmaxBin ; |
| 2524 | Fmin = FminBin ; |
| 2525 | } |
| 2526 | FminBin = 85000000UL ; |
| 2527 | FmaxBin = 112000000UL ; |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 2528 | if (state->RF_LO > FminBin && state->RF_LO <= FmaxBin) { |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 2529 | status += MXL_ControlWrite(fe, RFSYN_EN_OUTMUX, 0); |
| 2530 | status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_OUT, 1); |
| 2531 | status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 1); |
| 2532 | status += MXL_ControlWrite(fe, RFSYN_SEL_DIVM, 0); |
| 2533 | status += MXL_ControlWrite(fe, RFSYN_RF_DIV_BIAS, 1); |
| 2534 | status += MXL_ControlWrite(fe, DN_SEL_FREQ, 1); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2535 | divider_val = 32 ; |
| 2536 | Fmax = FmaxBin ; |
| 2537 | Fmin = FminBin ; |
| 2538 | } |
| 2539 | FminBin = 112000000UL ; |
| 2540 | FmaxBin = 170000000UL ; |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 2541 | if (state->RF_LO > FminBin && state->RF_LO <= FmaxBin) { |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 2542 | status += MXL_ControlWrite(fe, RFSYN_EN_OUTMUX, 0); |
| 2543 | status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_OUT, 1); |
| 2544 | status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 0); |
| 2545 | status += MXL_ControlWrite(fe, RFSYN_SEL_DIVM, 0); |
| 2546 | status += MXL_ControlWrite(fe, RFSYN_RF_DIV_BIAS, 1); |
| 2547 | status += MXL_ControlWrite(fe, DN_SEL_FREQ, 2); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2548 | divider_val = 16 ; |
| 2549 | Fmax = FmaxBin ; |
| 2550 | Fmin = FminBin ; |
| 2551 | } |
| 2552 | FminBin = 170000000UL ; |
| 2553 | FmaxBin = 225000000UL ; |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 2554 | if (state->RF_LO > FminBin && state->RF_LO <= FmaxBin) { |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 2555 | status += MXL_ControlWrite(fe, RFSYN_EN_OUTMUX, 0); |
| 2556 | status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_OUT, 1); |
| 2557 | status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 1); |
| 2558 | status += MXL_ControlWrite(fe, RFSYN_SEL_DIVM, 0); |
| 2559 | status += MXL_ControlWrite(fe, RFSYN_RF_DIV_BIAS, 1); |
| 2560 | status += MXL_ControlWrite(fe, DN_SEL_FREQ, 2); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2561 | divider_val = 16 ; |
| 2562 | Fmax = FmaxBin ; |
| 2563 | Fmin = FminBin ; |
| 2564 | } |
| 2565 | FminBin = 225000000UL ; |
| 2566 | FmaxBin = 300000000UL ; |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 2567 | if (state->RF_LO > FminBin && state->RF_LO <= FmaxBin) { |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 2568 | status += MXL_ControlWrite(fe, RFSYN_EN_OUTMUX, 0); |
| 2569 | status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_OUT, 1); |
| 2570 | status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 0); |
| 2571 | status += MXL_ControlWrite(fe, RFSYN_SEL_DIVM, 0); |
| 2572 | status += MXL_ControlWrite(fe, RFSYN_RF_DIV_BIAS, 1); |
| 2573 | status += MXL_ControlWrite(fe, DN_SEL_FREQ, 4); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2574 | divider_val = 8 ; |
| 2575 | Fmax = 340000000UL ; |
| 2576 | Fmin = FminBin ; |
| 2577 | } |
| 2578 | FminBin = 300000000UL ; |
| 2579 | FmaxBin = 340000000UL ; |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 2580 | if (state->RF_LO > FminBin && state->RF_LO <= FmaxBin) { |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 2581 | status += MXL_ControlWrite(fe, RFSYN_EN_OUTMUX, 1); |
| 2582 | status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_OUT, 0); |
| 2583 | status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 0); |
| 2584 | status += MXL_ControlWrite(fe, RFSYN_SEL_DIVM, 0); |
| 2585 | status += MXL_ControlWrite(fe, RFSYN_RF_DIV_BIAS, 1); |
| 2586 | status += MXL_ControlWrite(fe, DN_SEL_FREQ, 0); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2587 | divider_val = 8 ; |
| 2588 | Fmax = FmaxBin ; |
| 2589 | Fmin = 225000000UL ; |
| 2590 | } |
| 2591 | FminBin = 340000000UL ; |
| 2592 | FmaxBin = 450000000UL ; |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 2593 | if (state->RF_LO > FminBin && state->RF_LO <= FmaxBin) { |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 2594 | status += MXL_ControlWrite(fe, RFSYN_EN_OUTMUX, 1); |
| 2595 | status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_OUT, 0); |
| 2596 | status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 1); |
| 2597 | status += MXL_ControlWrite(fe, RFSYN_SEL_DIVM, 0); |
| 2598 | status += MXL_ControlWrite(fe, RFSYN_RF_DIV_BIAS, 2); |
| 2599 | status += MXL_ControlWrite(fe, DN_SEL_FREQ, 0); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2600 | divider_val = 8 ; |
| 2601 | Fmax = FmaxBin ; |
| 2602 | Fmin = FminBin ; |
| 2603 | } |
| 2604 | FminBin = 450000000UL ; |
| 2605 | FmaxBin = 680000000UL ; |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 2606 | if (state->RF_LO > FminBin && state->RF_LO <= FmaxBin) { |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 2607 | status += MXL_ControlWrite(fe, RFSYN_EN_OUTMUX, 0); |
| 2608 | status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_OUT, 1); |
| 2609 | status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 0); |
| 2610 | status += MXL_ControlWrite(fe, RFSYN_SEL_DIVM, 1); |
| 2611 | status += MXL_ControlWrite(fe, RFSYN_RF_DIV_BIAS, 1); |
| 2612 | status += MXL_ControlWrite(fe, DN_SEL_FREQ, 0); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2613 | divider_val = 4 ; |
| 2614 | Fmax = FmaxBin ; |
| 2615 | Fmin = FminBin ; |
| 2616 | } |
| 2617 | FminBin = 680000000UL ; |
| 2618 | FmaxBin = 900000000UL ; |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 2619 | if (state->RF_LO > FminBin && state->RF_LO <= FmaxBin) { |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 2620 | status += MXL_ControlWrite(fe, RFSYN_EN_OUTMUX, 0); |
| 2621 | status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_OUT, 1); |
| 2622 | status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 1); |
| 2623 | status += MXL_ControlWrite(fe, RFSYN_SEL_DIVM, 1); |
| 2624 | status += MXL_ControlWrite(fe, RFSYN_RF_DIV_BIAS, 1); |
| 2625 | status += MXL_ControlWrite(fe, DN_SEL_FREQ, 0); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2626 | divider_val = 4 ; |
| 2627 | Fmax = FmaxBin ; |
| 2628 | Fmin = FminBin ; |
| 2629 | } |
| 2630 | |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 2631 | /* CHCAL_INT_MOD_RF |
| 2632 | * CHCAL_FRAC_MOD_RF |
| 2633 | * RFSYN_LPF_R |
| 2634 | * CHCAL_EN_INT_RF |
| 2635 | */ |
| 2636 | /* Equation E3 RFSYN_VCO_BIAS */ |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 2637 | E3 = (((Fmax-state->RF_LO)/1000)*32)/((Fmax-Fmin)/1000) + 8 ; |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 2638 | status += MXL_ControlWrite(fe, RFSYN_VCO_BIAS, E3); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2639 | |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 2640 | /* Equation E4 CHCAL_INT_MOD_RF */ |
| 2641 | E4 = (state->RF_LO*divider_val/1000)/(2*state->Fxtal*Kdbl_RF/1000); |
| 2642 | MXL_ControlWrite(fe, CHCAL_INT_MOD_RF, E4); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2643 | |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 2644 | /* Equation E5 CHCAL_FRAC_MOD_RF CHCAL_EN_INT_RF */ |
| 2645 | E5 = ((2<<17)*(state->RF_LO/10000*divider_val - |
| 2646 | (E4*(2*state->Fxtal*Kdbl_RF)/10000))) / |
| 2647 | (2*state->Fxtal*Kdbl_RF/10000); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2648 | |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 2649 | status += MXL_ControlWrite(fe, CHCAL_FRAC_MOD_RF, E5); |
| 2650 | |
| 2651 | /* Equation E5A RFSYN_LPF_R */ |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 2652 | E5A = (((Fmax - state->RF_LO)/1000)*4/((Fmax-Fmin)/1000)) + 1 ; |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 2653 | status += MXL_ControlWrite(fe, RFSYN_LPF_R, E5A); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2654 | |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 2655 | /* Euqation E5B CHCAL_EN_INIT_RF */ |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 2656 | status += MXL_ControlWrite(fe, CHCAL_EN_INT_RF, ((E5 == 0) ? 1 : 0)); |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 2657 | /*if (E5 == 0) |
| 2658 | * status += MXL_ControlWrite(fe, CHCAL_EN_INT_RF, 1); |
| 2659 | *else |
| 2660 | * status += MXL_ControlWrite(fe, CHCAL_FRAC_MOD_RF, E5); |
| 2661 | */ |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2662 | |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 2663 | /* |
| 2664 | * Set TG Synth |
| 2665 | * |
| 2666 | * Look-Up table implementation for: |
| 2667 | * TG_LO_DIVVAL |
| 2668 | * TG_LO_SELVAL |
| 2669 | * |
| 2670 | * Set divider_val, Fmax, Fmix to use in Equations |
| 2671 | */ |
| 2672 | if (state->TG_LO < 33000000UL) |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2673 | return -1; |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 2674 | |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2675 | FminBin = 33000000UL ; |
| 2676 | FmaxBin = 50000000UL ; |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 2677 | if (state->TG_LO >= FminBin && state->TG_LO <= FmaxBin) { |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 2678 | status += MXL_ControlWrite(fe, TG_LO_DIVVAL, 0x6); |
| 2679 | status += MXL_ControlWrite(fe, TG_LO_SELVAL, 0x0); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2680 | divider_val = 36 ; |
| 2681 | Fmax = FmaxBin ; |
| 2682 | Fmin = FminBin ; |
| 2683 | } |
| 2684 | FminBin = 50000000UL ; |
| 2685 | FmaxBin = 67000000UL ; |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 2686 | if (state->TG_LO > FminBin && state->TG_LO <= FmaxBin) { |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 2687 | status += MXL_ControlWrite(fe, TG_LO_DIVVAL, 0x1); |
| 2688 | status += MXL_ControlWrite(fe, TG_LO_SELVAL, 0x0); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2689 | divider_val = 24 ; |
| 2690 | Fmax = FmaxBin ; |
| 2691 | Fmin = FminBin ; |
| 2692 | } |
| 2693 | FminBin = 67000000UL ; |
| 2694 | FmaxBin = 100000000UL ; |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 2695 | if (state->TG_LO > FminBin && state->TG_LO <= FmaxBin) { |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 2696 | status += MXL_ControlWrite(fe, TG_LO_DIVVAL, 0xC); |
| 2697 | status += MXL_ControlWrite(fe, TG_LO_SELVAL, 0x2); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2698 | divider_val = 18 ; |
| 2699 | Fmax = FmaxBin ; |
| 2700 | Fmin = FminBin ; |
| 2701 | } |
| 2702 | FminBin = 100000000UL ; |
| 2703 | FmaxBin = 150000000UL ; |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 2704 | if (state->TG_LO > FminBin && state->TG_LO <= FmaxBin) { |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 2705 | status += MXL_ControlWrite(fe, TG_LO_DIVVAL, 0x8); |
| 2706 | status += MXL_ControlWrite(fe, TG_LO_SELVAL, 0x2); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2707 | divider_val = 12 ; |
| 2708 | Fmax = FmaxBin ; |
| 2709 | Fmin = FminBin ; |
| 2710 | } |
| 2711 | FminBin = 150000000UL ; |
| 2712 | FmaxBin = 200000000UL ; |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 2713 | if (state->TG_LO > FminBin && state->TG_LO <= FmaxBin) { |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 2714 | status += MXL_ControlWrite(fe, TG_LO_DIVVAL, 0x0); |
| 2715 | status += MXL_ControlWrite(fe, TG_LO_SELVAL, 0x2); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2716 | divider_val = 8 ; |
| 2717 | Fmax = FmaxBin ; |
| 2718 | Fmin = FminBin ; |
| 2719 | } |
| 2720 | FminBin = 200000000UL ; |
| 2721 | FmaxBin = 300000000UL ; |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 2722 | if (state->TG_LO > FminBin && state->TG_LO <= FmaxBin) { |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 2723 | status += MXL_ControlWrite(fe, TG_LO_DIVVAL, 0x8); |
| 2724 | status += MXL_ControlWrite(fe, TG_LO_SELVAL, 0x3); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2725 | divider_val = 6 ; |
| 2726 | Fmax = FmaxBin ; |
| 2727 | Fmin = FminBin ; |
| 2728 | } |
| 2729 | FminBin = 300000000UL ; |
| 2730 | FmaxBin = 400000000UL ; |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 2731 | if (state->TG_LO > FminBin && state->TG_LO <= FmaxBin) { |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 2732 | status += MXL_ControlWrite(fe, TG_LO_DIVVAL, 0x0); |
| 2733 | status += MXL_ControlWrite(fe, TG_LO_SELVAL, 0x3); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2734 | divider_val = 4 ; |
| 2735 | Fmax = FmaxBin ; |
| 2736 | Fmin = FminBin ; |
| 2737 | } |
| 2738 | FminBin = 400000000UL ; |
| 2739 | FmaxBin = 600000000UL ; |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 2740 | if (state->TG_LO > FminBin && state->TG_LO <= FmaxBin) { |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 2741 | status += MXL_ControlWrite(fe, TG_LO_DIVVAL, 0x8); |
| 2742 | status += MXL_ControlWrite(fe, TG_LO_SELVAL, 0x7); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2743 | divider_val = 3 ; |
| 2744 | Fmax = FmaxBin ; |
| 2745 | Fmin = FminBin ; |
| 2746 | } |
| 2747 | FminBin = 600000000UL ; |
| 2748 | FmaxBin = 900000000UL ; |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 2749 | if (state->TG_LO > FminBin && state->TG_LO <= FmaxBin) { |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 2750 | status += MXL_ControlWrite(fe, TG_LO_DIVVAL, 0x0); |
| 2751 | status += MXL_ControlWrite(fe, TG_LO_SELVAL, 0x7); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2752 | divider_val = 2 ; |
| 2753 | Fmax = FmaxBin ; |
| 2754 | Fmin = FminBin ; |
| 2755 | } |
| 2756 | |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 2757 | /* TG_DIV_VAL */ |
| 2758 | tg_divval = (state->TG_LO*divider_val/100000) * |
| 2759 | (MXL_Ceiling(state->Fxtal, 1000000) * 100) / |
| 2760 | (state->Fxtal/1000); |
| 2761 | |
| 2762 | status += MXL_ControlWrite(fe, TG_DIV_VAL, tg_divval); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2763 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 2764 | if (state->TG_LO > 600000000UL) |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 2765 | status += MXL_ControlWrite(fe, TG_DIV_VAL, tg_divval + 1); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2766 | |
| 2767 | Fmax = 1800000000UL ; |
| 2768 | Fmin = 1200000000UL ; |
| 2769 | |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 2770 | /* prevent overflow of 32 bit unsigned integer, use |
| 2771 | * following equation. Edit for v2.6.4 |
| 2772 | */ |
| 2773 | /* Fref_TF = Fref_TG * 1000 */ |
| 2774 | Fref_TG = (state->Fxtal/1000) / MXL_Ceiling(state->Fxtal, 1000000); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2775 | |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 2776 | /* Fvco = Fvco/10 */ |
| 2777 | Fvco = (state->TG_LO/10000) * divider_val * Fref_TG; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2778 | |
| 2779 | tg_lo = (((Fmax/10 - Fvco)/100)*32) / ((Fmax-Fmin)/1000)+8; |
| 2780 | |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 2781 | /* below equation is same as above but much harder to debug. |
| 2782 | * tg_lo = ( ((Fmax/10000 * Xtal_Int)/100) - |
| 2783 | * ((state->TG_LO/10000)*divider_val * |
| 2784 | * (state->Fxtal/10000)/100) )*32/((Fmax-Fmin)/10000 * |
| 2785 | * Xtal_Int/100) + 8; |
| 2786 | */ |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2787 | |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 2788 | status += MXL_ControlWrite(fe, TG_VCO_BIAS , tg_lo); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2789 | |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 2790 | /* add for 2.6.5 Special setting for QAM */ |
| 2791 | if (state->Mod_Type == MXL_QAM) { |
Devin Heitmueller | 48c511e | 2009-10-28 23:10:16 -0300 | [diff] [blame^] | 2792 | if (state->config->qam_gain != 0) |
| 2793 | status += MXL_ControlWrite(fe, RFSYN_CHP_GAIN, |
| 2794 | state->config->qam_gain); |
| 2795 | else if (state->RF_IN < 680000000) |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 2796 | status += MXL_ControlWrite(fe, RFSYN_CHP_GAIN, 3); |
| 2797 | else |
| 2798 | status += MXL_ControlWrite(fe, RFSYN_CHP_GAIN, 2); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2799 | } |
| 2800 | |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 2801 | /* Off Chip Tracking Filter Control */ |
| 2802 | if (state->TF_Type == MXL_TF_OFF) { |
| 2803 | /* Tracking Filter Off State; turn off all the banks */ |
| 2804 | status += MXL_ControlWrite(fe, DAC_A_ENABLE, 0); |
| 2805 | status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0); |
| 2806 | status += MXL_SetGPIO(fe, 3, 1); /* Bank1 Off */ |
| 2807 | status += MXL_SetGPIO(fe, 1, 1); /* Bank2 Off */ |
| 2808 | status += MXL_SetGPIO(fe, 4, 1); /* Bank3 Off */ |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2809 | } |
| 2810 | |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 2811 | if (state->TF_Type == MXL_TF_C) /* Tracking Filter type C */ { |
| 2812 | status += MXL_ControlWrite(fe, DAC_B_ENABLE, 1); |
| 2813 | status += MXL_ControlWrite(fe, DAC_DIN_A, 0); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2814 | |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 2815 | if (state->RF_IN >= 43000000 && state->RF_IN < 150000000) { |
| 2816 | status += MXL_ControlWrite(fe, DAC_A_ENABLE, 0); |
| 2817 | status += MXL_ControlWrite(fe, DAC_DIN_B, 0); |
| 2818 | status += MXL_SetGPIO(fe, 3, 0); |
| 2819 | status += MXL_SetGPIO(fe, 1, 1); |
| 2820 | status += MXL_SetGPIO(fe, 4, 1); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2821 | } |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 2822 | if (state->RF_IN >= 150000000 && state->RF_IN < 280000000) { |
| 2823 | status += MXL_ControlWrite(fe, DAC_A_ENABLE, 0); |
| 2824 | status += MXL_ControlWrite(fe, DAC_DIN_B, 0); |
| 2825 | status += MXL_SetGPIO(fe, 3, 1); |
| 2826 | status += MXL_SetGPIO(fe, 1, 0); |
| 2827 | status += MXL_SetGPIO(fe, 4, 1); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2828 | } |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 2829 | if (state->RF_IN >= 280000000 && state->RF_IN < 360000000) { |
| 2830 | status += MXL_ControlWrite(fe, DAC_A_ENABLE, 0); |
| 2831 | status += MXL_ControlWrite(fe, DAC_DIN_B, 0); |
| 2832 | status += MXL_SetGPIO(fe, 3, 1); |
| 2833 | status += MXL_SetGPIO(fe, 1, 0); |
| 2834 | status += MXL_SetGPIO(fe, 4, 0); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2835 | } |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 2836 | if (state->RF_IN >= 360000000 && state->RF_IN < 560000000) { |
| 2837 | status += MXL_ControlWrite(fe, DAC_A_ENABLE, 0); |
| 2838 | status += MXL_ControlWrite(fe, DAC_DIN_B, 0); |
| 2839 | status += MXL_SetGPIO(fe, 3, 1); |
| 2840 | status += MXL_SetGPIO(fe, 1, 1); |
| 2841 | status += MXL_SetGPIO(fe, 4, 0); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2842 | } |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 2843 | if (state->RF_IN >= 560000000 && state->RF_IN < 580000000) { |
| 2844 | status += MXL_ControlWrite(fe, DAC_A_ENABLE, 1); |
| 2845 | status += MXL_ControlWrite(fe, DAC_DIN_B, 29); |
| 2846 | status += MXL_SetGPIO(fe, 3, 1); |
| 2847 | status += MXL_SetGPIO(fe, 1, 1); |
| 2848 | status += MXL_SetGPIO(fe, 4, 0); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2849 | } |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 2850 | if (state->RF_IN >= 580000000 && state->RF_IN < 630000000) { |
| 2851 | status += MXL_ControlWrite(fe, DAC_A_ENABLE, 1); |
| 2852 | status += MXL_ControlWrite(fe, DAC_DIN_B, 0); |
| 2853 | status += MXL_SetGPIO(fe, 3, 1); |
| 2854 | status += MXL_SetGPIO(fe, 1, 1); |
| 2855 | status += MXL_SetGPIO(fe, 4, 0); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2856 | } |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 2857 | if (state->RF_IN >= 630000000 && state->RF_IN < 700000000) { |
| 2858 | status += MXL_ControlWrite(fe, DAC_A_ENABLE, 1); |
| 2859 | status += MXL_ControlWrite(fe, DAC_DIN_B, 16); |
| 2860 | status += MXL_SetGPIO(fe, 3, 1); |
| 2861 | status += MXL_SetGPIO(fe, 1, 1); |
| 2862 | status += MXL_SetGPIO(fe, 4, 1); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2863 | } |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 2864 | if (state->RF_IN >= 700000000 && state->RF_IN < 760000000) { |
| 2865 | status += MXL_ControlWrite(fe, DAC_A_ENABLE, 1); |
| 2866 | status += MXL_ControlWrite(fe, DAC_DIN_B, 7); |
| 2867 | status += MXL_SetGPIO(fe, 3, 1); |
| 2868 | status += MXL_SetGPIO(fe, 1, 1); |
| 2869 | status += MXL_SetGPIO(fe, 4, 1); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2870 | } |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 2871 | if (state->RF_IN >= 760000000 && state->RF_IN <= 900000000) { |
| 2872 | status += MXL_ControlWrite(fe, DAC_A_ENABLE, 1); |
| 2873 | status += MXL_ControlWrite(fe, DAC_DIN_B, 0); |
| 2874 | status += MXL_SetGPIO(fe, 3, 1); |
| 2875 | status += MXL_SetGPIO(fe, 1, 1); |
| 2876 | status += MXL_SetGPIO(fe, 4, 1); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2877 | } |
| 2878 | } |
| 2879 | |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 2880 | if (state->TF_Type == MXL_TF_C_H) { |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2881 | |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 2882 | /* Tracking Filter type C-H for Hauppauge only */ |
| 2883 | status += MXL_ControlWrite(fe, DAC_DIN_A, 0); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2884 | |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 2885 | if (state->RF_IN >= 43000000 && state->RF_IN < 150000000) { |
| 2886 | status += MXL_ControlWrite(fe, DAC_A_ENABLE, 0); |
| 2887 | status += MXL_SetGPIO(fe, 4, 0); |
| 2888 | status += MXL_SetGPIO(fe, 3, 1); |
| 2889 | status += MXL_SetGPIO(fe, 1, 1); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2890 | } |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 2891 | if (state->RF_IN >= 150000000 && state->RF_IN < 280000000) { |
| 2892 | status += MXL_ControlWrite(fe, DAC_A_ENABLE, 0); |
| 2893 | status += MXL_SetGPIO(fe, 4, 1); |
| 2894 | status += MXL_SetGPIO(fe, 3, 0); |
| 2895 | status += MXL_SetGPIO(fe, 1, 1); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2896 | } |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 2897 | if (state->RF_IN >= 280000000 && state->RF_IN < 360000000) { |
| 2898 | status += MXL_ControlWrite(fe, DAC_A_ENABLE, 0); |
| 2899 | status += MXL_SetGPIO(fe, 4, 1); |
| 2900 | status += MXL_SetGPIO(fe, 3, 0); |
| 2901 | status += MXL_SetGPIO(fe, 1, 0); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2902 | } |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 2903 | if (state->RF_IN >= 360000000 && state->RF_IN < 560000000) { |
| 2904 | status += MXL_ControlWrite(fe, DAC_A_ENABLE, 0); |
| 2905 | status += MXL_SetGPIO(fe, 4, 1); |
| 2906 | status += MXL_SetGPIO(fe, 3, 1); |
| 2907 | status += MXL_SetGPIO(fe, 1, 0); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2908 | } |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 2909 | if (state->RF_IN >= 560000000 && state->RF_IN < 580000000) { |
| 2910 | status += MXL_ControlWrite(fe, DAC_A_ENABLE, 1); |
| 2911 | status += MXL_SetGPIO(fe, 4, 1); |
| 2912 | status += MXL_SetGPIO(fe, 3, 1); |
| 2913 | status += MXL_SetGPIO(fe, 1, 0); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2914 | } |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 2915 | if (state->RF_IN >= 580000000 && state->RF_IN < 630000000) { |
| 2916 | status += MXL_ControlWrite(fe, DAC_A_ENABLE, 1); |
| 2917 | status += MXL_SetGPIO(fe, 4, 1); |
| 2918 | status += MXL_SetGPIO(fe, 3, 1); |
| 2919 | status += MXL_SetGPIO(fe, 1, 0); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2920 | } |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 2921 | if (state->RF_IN >= 630000000 && state->RF_IN < 700000000) { |
| 2922 | status += MXL_ControlWrite(fe, DAC_A_ENABLE, 1); |
| 2923 | status += MXL_SetGPIO(fe, 4, 1); |
| 2924 | status += MXL_SetGPIO(fe, 3, 1); |
| 2925 | status += MXL_SetGPIO(fe, 1, 1); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2926 | } |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 2927 | if (state->RF_IN >= 700000000 && state->RF_IN < 760000000) { |
| 2928 | status += MXL_ControlWrite(fe, DAC_A_ENABLE, 1); |
| 2929 | status += MXL_SetGPIO(fe, 4, 1); |
| 2930 | status += MXL_SetGPIO(fe, 3, 1); |
| 2931 | status += MXL_SetGPIO(fe, 1, 1); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2932 | } |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 2933 | if (state->RF_IN >= 760000000 && state->RF_IN <= 900000000) { |
| 2934 | status += MXL_ControlWrite(fe, DAC_A_ENABLE, 1); |
| 2935 | status += MXL_SetGPIO(fe, 4, 1); |
| 2936 | status += MXL_SetGPIO(fe, 3, 1); |
| 2937 | status += MXL_SetGPIO(fe, 1, 1); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2938 | } |
| 2939 | } |
| 2940 | |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 2941 | if (state->TF_Type == MXL_TF_D) { /* Tracking Filter type D */ |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2942 | |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 2943 | status += MXL_ControlWrite(fe, DAC_DIN_B, 0); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2944 | |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 2945 | if (state->RF_IN >= 43000000 && state->RF_IN < 174000000) { |
| 2946 | status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0); |
| 2947 | status += MXL_SetGPIO(fe, 4, 0); |
| 2948 | status += MXL_SetGPIO(fe, 1, 1); |
| 2949 | status += MXL_SetGPIO(fe, 3, 1); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2950 | } |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 2951 | if (state->RF_IN >= 174000000 && state->RF_IN < 250000000) { |
| 2952 | status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0); |
| 2953 | status += MXL_SetGPIO(fe, 4, 0); |
| 2954 | status += MXL_SetGPIO(fe, 1, 0); |
| 2955 | status += MXL_SetGPIO(fe, 3, 1); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2956 | } |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 2957 | if (state->RF_IN >= 250000000 && state->RF_IN < 310000000) { |
| 2958 | status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0); |
| 2959 | status += MXL_SetGPIO(fe, 4, 1); |
| 2960 | status += MXL_SetGPIO(fe, 1, 0); |
| 2961 | status += MXL_SetGPIO(fe, 3, 1); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2962 | } |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 2963 | if (state->RF_IN >= 310000000 && state->RF_IN < 360000000) { |
| 2964 | status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0); |
| 2965 | status += MXL_SetGPIO(fe, 4, 1); |
| 2966 | status += MXL_SetGPIO(fe, 1, 0); |
| 2967 | status += MXL_SetGPIO(fe, 3, 0); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2968 | } |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 2969 | if (state->RF_IN >= 360000000 && state->RF_IN < 470000000) { |
| 2970 | status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0); |
| 2971 | status += MXL_SetGPIO(fe, 4, 1); |
| 2972 | status += MXL_SetGPIO(fe, 1, 1); |
| 2973 | status += MXL_SetGPIO(fe, 3, 0); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2974 | } |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 2975 | if (state->RF_IN >= 470000000 && state->RF_IN < 640000000) { |
| 2976 | status += MXL_ControlWrite(fe, DAC_B_ENABLE, 1); |
| 2977 | status += MXL_SetGPIO(fe, 4, 1); |
| 2978 | status += MXL_SetGPIO(fe, 1, 1); |
| 2979 | status += MXL_SetGPIO(fe, 3, 0); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2980 | } |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 2981 | if (state->RF_IN >= 640000000 && state->RF_IN <= 900000000) { |
| 2982 | status += MXL_ControlWrite(fe, DAC_B_ENABLE, 1); |
| 2983 | status += MXL_SetGPIO(fe, 4, 1); |
| 2984 | status += MXL_SetGPIO(fe, 1, 1); |
| 2985 | status += MXL_SetGPIO(fe, 3, 1); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2986 | } |
| 2987 | } |
| 2988 | |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 2989 | if (state->TF_Type == MXL_TF_D_L) { |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2990 | |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 2991 | /* Tracking Filter type D-L for Lumanate ONLY change 2.6.3 */ |
| 2992 | status += MXL_ControlWrite(fe, DAC_DIN_A, 0); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 2993 | |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 2994 | /* if UHF and terrestrial => Turn off Tracking Filter */ |
| 2995 | if (state->RF_IN >= 471000000 && |
| 2996 | (state->RF_IN - 471000000)%6000000 != 0) { |
| 2997 | /* Turn off all the banks */ |
| 2998 | status += MXL_SetGPIO(fe, 3, 1); |
| 2999 | status += MXL_SetGPIO(fe, 1, 1); |
| 3000 | status += MXL_SetGPIO(fe, 4, 1); |
| 3001 | status += MXL_ControlWrite(fe, DAC_A_ENABLE, 0); |
| 3002 | status += MXL_ControlWrite(fe, AGC_IF, 10); |
| 3003 | } else { |
| 3004 | /* if VHF or cable => Turn on Tracking Filter */ |
| 3005 | if (state->RF_IN >= 43000000 && |
| 3006 | state->RF_IN < 140000000) { |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3007 | |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 3008 | status += MXL_ControlWrite(fe, DAC_A_ENABLE, 0); |
| 3009 | status += MXL_SetGPIO(fe, 4, 1); |
| 3010 | status += MXL_SetGPIO(fe, 1, 1); |
| 3011 | status += MXL_SetGPIO(fe, 3, 0); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3012 | } |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 3013 | if (state->RF_IN >= 140000000 && |
| 3014 | state->RF_IN < 240000000) { |
| 3015 | status += MXL_ControlWrite(fe, DAC_A_ENABLE, 0); |
| 3016 | status += MXL_SetGPIO(fe, 4, 1); |
| 3017 | status += MXL_SetGPIO(fe, 1, 0); |
| 3018 | status += MXL_SetGPIO(fe, 3, 0); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3019 | } |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 3020 | if (state->RF_IN >= 240000000 && |
| 3021 | state->RF_IN < 340000000) { |
| 3022 | status += MXL_ControlWrite(fe, DAC_A_ENABLE, 0); |
| 3023 | status += MXL_SetGPIO(fe, 4, 0); |
| 3024 | status += MXL_SetGPIO(fe, 1, 1); |
| 3025 | status += MXL_SetGPIO(fe, 3, 0); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3026 | } |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 3027 | if (state->RF_IN >= 340000000 && |
| 3028 | state->RF_IN < 430000000) { |
| 3029 | status += MXL_ControlWrite(fe, DAC_A_ENABLE, 0); |
| 3030 | status += MXL_SetGPIO(fe, 4, 0); |
| 3031 | status += MXL_SetGPIO(fe, 1, 0); |
| 3032 | status += MXL_SetGPIO(fe, 3, 1); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3033 | } |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 3034 | if (state->RF_IN >= 430000000 && |
| 3035 | state->RF_IN < 470000000) { |
| 3036 | status += MXL_ControlWrite(fe, DAC_A_ENABLE, 1); |
| 3037 | status += MXL_SetGPIO(fe, 4, 1); |
| 3038 | status += MXL_SetGPIO(fe, 1, 0); |
| 3039 | status += MXL_SetGPIO(fe, 3, 1); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3040 | } |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 3041 | if (state->RF_IN >= 470000000 && |
| 3042 | state->RF_IN < 570000000) { |
| 3043 | status += MXL_ControlWrite(fe, DAC_A_ENABLE, 1); |
| 3044 | status += MXL_SetGPIO(fe, 4, 0); |
| 3045 | status += MXL_SetGPIO(fe, 1, 0); |
| 3046 | status += MXL_SetGPIO(fe, 3, 1); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3047 | } |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 3048 | if (state->RF_IN >= 570000000 && |
| 3049 | state->RF_IN < 620000000) { |
| 3050 | status += MXL_ControlWrite(fe, DAC_A_ENABLE, 0); |
| 3051 | status += MXL_SetGPIO(fe, 4, 0); |
| 3052 | status += MXL_SetGPIO(fe, 1, 1); |
| 3053 | status += MXL_SetGPIO(fe, 3, 1); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3054 | } |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 3055 | if (state->RF_IN >= 620000000 && |
| 3056 | state->RF_IN < 760000000) { |
| 3057 | status += MXL_ControlWrite(fe, DAC_A_ENABLE, 1); |
| 3058 | status += MXL_SetGPIO(fe, 4, 0); |
| 3059 | status += MXL_SetGPIO(fe, 1, 1); |
| 3060 | status += MXL_SetGPIO(fe, 3, 1); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3061 | } |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 3062 | if (state->RF_IN >= 760000000 && |
| 3063 | state->RF_IN <= 900000000) { |
| 3064 | status += MXL_ControlWrite(fe, DAC_A_ENABLE, 1); |
| 3065 | status += MXL_SetGPIO(fe, 4, 1); |
| 3066 | status += MXL_SetGPIO(fe, 1, 1); |
| 3067 | status += MXL_SetGPIO(fe, 3, 1); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3068 | } |
| 3069 | } |
| 3070 | } |
| 3071 | |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 3072 | if (state->TF_Type == MXL_TF_E) /* Tracking Filter type E */ { |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3073 | |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 3074 | status += MXL_ControlWrite(fe, DAC_DIN_B, 0); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3075 | |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 3076 | if (state->RF_IN >= 43000000 && state->RF_IN < 174000000) { |
| 3077 | status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0); |
| 3078 | status += MXL_SetGPIO(fe, 4, 0); |
| 3079 | status += MXL_SetGPIO(fe, 1, 1); |
| 3080 | status += MXL_SetGPIO(fe, 3, 1); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3081 | } |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 3082 | if (state->RF_IN >= 174000000 && state->RF_IN < 250000000) { |
| 3083 | status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0); |
| 3084 | status += MXL_SetGPIO(fe, 4, 0); |
| 3085 | status += MXL_SetGPIO(fe, 1, 0); |
| 3086 | status += MXL_SetGPIO(fe, 3, 1); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3087 | } |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 3088 | if (state->RF_IN >= 250000000 && state->RF_IN < 310000000) { |
| 3089 | status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0); |
| 3090 | status += MXL_SetGPIO(fe, 4, 1); |
| 3091 | status += MXL_SetGPIO(fe, 1, 0); |
| 3092 | status += MXL_SetGPIO(fe, 3, 1); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3093 | } |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 3094 | if (state->RF_IN >= 310000000 && state->RF_IN < 360000000) { |
| 3095 | status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0); |
| 3096 | status += MXL_SetGPIO(fe, 4, 1); |
| 3097 | status += MXL_SetGPIO(fe, 1, 0); |
| 3098 | status += MXL_SetGPIO(fe, 3, 0); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3099 | } |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 3100 | if (state->RF_IN >= 360000000 && state->RF_IN < 470000000) { |
| 3101 | status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0); |
| 3102 | status += MXL_SetGPIO(fe, 4, 1); |
| 3103 | status += MXL_SetGPIO(fe, 1, 1); |
| 3104 | status += MXL_SetGPIO(fe, 3, 0); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3105 | } |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 3106 | if (state->RF_IN >= 470000000 && state->RF_IN < 640000000) { |
| 3107 | status += MXL_ControlWrite(fe, DAC_B_ENABLE, 1); |
| 3108 | status += MXL_SetGPIO(fe, 4, 1); |
| 3109 | status += MXL_SetGPIO(fe, 1, 1); |
| 3110 | status += MXL_SetGPIO(fe, 3, 0); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3111 | } |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 3112 | if (state->RF_IN >= 640000000 && state->RF_IN <= 900000000) { |
| 3113 | status += MXL_ControlWrite(fe, DAC_B_ENABLE, 1); |
| 3114 | status += MXL_SetGPIO(fe, 4, 1); |
| 3115 | status += MXL_SetGPIO(fe, 1, 1); |
| 3116 | status += MXL_SetGPIO(fe, 3, 1); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3117 | } |
| 3118 | } |
| 3119 | |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 3120 | if (state->TF_Type == MXL_TF_F) { |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3121 | |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 3122 | /* Tracking Filter type F */ |
| 3123 | status += MXL_ControlWrite(fe, DAC_DIN_B, 0); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3124 | |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 3125 | if (state->RF_IN >= 43000000 && state->RF_IN < 160000000) { |
| 3126 | status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0); |
| 3127 | status += MXL_SetGPIO(fe, 4, 0); |
| 3128 | status += MXL_SetGPIO(fe, 1, 1); |
| 3129 | status += MXL_SetGPIO(fe, 3, 1); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3130 | } |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 3131 | if (state->RF_IN >= 160000000 && state->RF_IN < 210000000) { |
| 3132 | status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0); |
| 3133 | status += MXL_SetGPIO(fe, 4, 0); |
| 3134 | status += MXL_SetGPIO(fe, 1, 0); |
| 3135 | status += MXL_SetGPIO(fe, 3, 1); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3136 | } |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 3137 | if (state->RF_IN >= 210000000 && state->RF_IN < 300000000) { |
| 3138 | status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0); |
| 3139 | status += MXL_SetGPIO(fe, 4, 1); |
| 3140 | status += MXL_SetGPIO(fe, 1, 0); |
| 3141 | status += MXL_SetGPIO(fe, 3, 1); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3142 | } |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 3143 | if (state->RF_IN >= 300000000 && state->RF_IN < 390000000) { |
| 3144 | status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0); |
| 3145 | status += MXL_SetGPIO(fe, 4, 1); |
| 3146 | status += MXL_SetGPIO(fe, 1, 0); |
| 3147 | status += MXL_SetGPIO(fe, 3, 0); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3148 | } |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 3149 | if (state->RF_IN >= 390000000 && state->RF_IN < 515000000) { |
| 3150 | status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0); |
| 3151 | status += MXL_SetGPIO(fe, 4, 1); |
| 3152 | status += MXL_SetGPIO(fe, 1, 1); |
| 3153 | status += MXL_SetGPIO(fe, 3, 0); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3154 | } |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 3155 | if (state->RF_IN >= 515000000 && state->RF_IN < 650000000) { |
| 3156 | status += MXL_ControlWrite(fe, DAC_B_ENABLE, 1); |
| 3157 | status += MXL_SetGPIO(fe, 4, 1); |
| 3158 | status += MXL_SetGPIO(fe, 1, 1); |
| 3159 | status += MXL_SetGPIO(fe, 3, 0); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3160 | } |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 3161 | if (state->RF_IN >= 650000000 && state->RF_IN <= 900000000) { |
| 3162 | status += MXL_ControlWrite(fe, DAC_B_ENABLE, 1); |
| 3163 | status += MXL_SetGPIO(fe, 4, 1); |
| 3164 | status += MXL_SetGPIO(fe, 1, 1); |
| 3165 | status += MXL_SetGPIO(fe, 3, 1); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3166 | } |
| 3167 | } |
| 3168 | |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 3169 | if (state->TF_Type == MXL_TF_E_2) { |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3170 | |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 3171 | /* Tracking Filter type E_2 */ |
| 3172 | status += MXL_ControlWrite(fe, DAC_DIN_B, 0); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3173 | |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 3174 | if (state->RF_IN >= 43000000 && state->RF_IN < 174000000) { |
| 3175 | status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0); |
| 3176 | status += MXL_SetGPIO(fe, 4, 0); |
| 3177 | status += MXL_SetGPIO(fe, 1, 1); |
| 3178 | status += MXL_SetGPIO(fe, 3, 1); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3179 | } |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 3180 | if (state->RF_IN >= 174000000 && state->RF_IN < 250000000) { |
| 3181 | status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0); |
| 3182 | status += MXL_SetGPIO(fe, 4, 0); |
| 3183 | status += MXL_SetGPIO(fe, 1, 0); |
| 3184 | status += MXL_SetGPIO(fe, 3, 1); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3185 | } |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 3186 | if (state->RF_IN >= 250000000 && state->RF_IN < 350000000) { |
| 3187 | status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0); |
| 3188 | status += MXL_SetGPIO(fe, 4, 1); |
| 3189 | status += MXL_SetGPIO(fe, 1, 0); |
| 3190 | status += MXL_SetGPIO(fe, 3, 1); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3191 | } |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 3192 | if (state->RF_IN >= 350000000 && state->RF_IN < 400000000) { |
| 3193 | status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0); |
| 3194 | status += MXL_SetGPIO(fe, 4, 1); |
| 3195 | status += MXL_SetGPIO(fe, 1, 0); |
| 3196 | status += MXL_SetGPIO(fe, 3, 0); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3197 | } |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 3198 | if (state->RF_IN >= 400000000 && state->RF_IN < 570000000) { |
| 3199 | status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0); |
| 3200 | status += MXL_SetGPIO(fe, 4, 1); |
| 3201 | status += MXL_SetGPIO(fe, 1, 1); |
| 3202 | status += MXL_SetGPIO(fe, 3, 0); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3203 | } |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 3204 | if (state->RF_IN >= 570000000 && state->RF_IN < 770000000) { |
| 3205 | status += MXL_ControlWrite(fe, DAC_B_ENABLE, 1); |
| 3206 | status += MXL_SetGPIO(fe, 4, 1); |
| 3207 | status += MXL_SetGPIO(fe, 1, 1); |
| 3208 | status += MXL_SetGPIO(fe, 3, 0); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3209 | } |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 3210 | if (state->RF_IN >= 770000000 && state->RF_IN <= 900000000) { |
| 3211 | status += MXL_ControlWrite(fe, DAC_B_ENABLE, 1); |
| 3212 | status += MXL_SetGPIO(fe, 4, 1); |
| 3213 | status += MXL_SetGPIO(fe, 1, 1); |
| 3214 | status += MXL_SetGPIO(fe, 3, 1); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3215 | } |
| 3216 | } |
| 3217 | |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 3218 | if (state->TF_Type == MXL_TF_G) { |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3219 | |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 3220 | /* Tracking Filter type G add for v2.6.8 */ |
| 3221 | status += MXL_ControlWrite(fe, DAC_DIN_B, 0); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3222 | |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 3223 | if (state->RF_IN >= 50000000 && state->RF_IN < 190000000) { |
| 3224 | |
| 3225 | status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0); |
| 3226 | status += MXL_SetGPIO(fe, 4, 0); |
| 3227 | status += MXL_SetGPIO(fe, 1, 1); |
| 3228 | status += MXL_SetGPIO(fe, 3, 1); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3229 | } |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 3230 | if (state->RF_IN >= 190000000 && state->RF_IN < 280000000) { |
| 3231 | status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0); |
| 3232 | status += MXL_SetGPIO(fe, 4, 0); |
| 3233 | status += MXL_SetGPIO(fe, 1, 0); |
| 3234 | status += MXL_SetGPIO(fe, 3, 1); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3235 | } |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 3236 | if (state->RF_IN >= 280000000 && state->RF_IN < 350000000) { |
| 3237 | status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0); |
| 3238 | status += MXL_SetGPIO(fe, 4, 1); |
| 3239 | status += MXL_SetGPIO(fe, 1, 0); |
| 3240 | status += MXL_SetGPIO(fe, 3, 1); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3241 | } |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 3242 | if (state->RF_IN >= 350000000 && state->RF_IN < 400000000) { |
| 3243 | status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0); |
| 3244 | status += MXL_SetGPIO(fe, 4, 1); |
| 3245 | status += MXL_SetGPIO(fe, 1, 0); |
| 3246 | status += MXL_SetGPIO(fe, 3, 0); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3247 | } |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 3248 | if (state->RF_IN >= 400000000 && state->RF_IN < 470000000) { |
| 3249 | status += MXL_ControlWrite(fe, DAC_B_ENABLE, 1); |
| 3250 | status += MXL_SetGPIO(fe, 4, 1); |
| 3251 | status += MXL_SetGPIO(fe, 1, 0); |
| 3252 | status += MXL_SetGPIO(fe, 3, 1); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3253 | } |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 3254 | if (state->RF_IN >= 470000000 && state->RF_IN < 640000000) { |
| 3255 | status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0); |
| 3256 | status += MXL_SetGPIO(fe, 4, 1); |
| 3257 | status += MXL_SetGPIO(fe, 1, 1); |
| 3258 | status += MXL_SetGPIO(fe, 3, 0); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3259 | } |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 3260 | if (state->RF_IN >= 640000000 && state->RF_IN < 820000000) { |
| 3261 | status += MXL_ControlWrite(fe, DAC_B_ENABLE, 1); |
| 3262 | status += MXL_SetGPIO(fe, 4, 1); |
| 3263 | status += MXL_SetGPIO(fe, 1, 1); |
| 3264 | status += MXL_SetGPIO(fe, 3, 0); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3265 | } |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 3266 | if (state->RF_IN >= 820000000 && state->RF_IN <= 900000000) { |
| 3267 | status += MXL_ControlWrite(fe, DAC_B_ENABLE, 1); |
| 3268 | status += MXL_SetGPIO(fe, 4, 1); |
| 3269 | status += MXL_SetGPIO(fe, 1, 1); |
| 3270 | status += MXL_SetGPIO(fe, 3, 1); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3271 | } |
| 3272 | } |
| 3273 | |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 3274 | if (state->TF_Type == MXL_TF_E_NA) { |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3275 | |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 3276 | /* Tracking Filter type E-NA for Empia ONLY change for 2.6.8 */ |
| 3277 | status += MXL_ControlWrite(fe, DAC_DIN_B, 0); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3278 | |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 3279 | /* if UHF and terrestrial=> Turn off Tracking Filter */ |
| 3280 | if (state->RF_IN >= 471000000 && |
| 3281 | (state->RF_IN - 471000000)%6000000 != 0) { |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3282 | |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 3283 | /* Turn off all the banks */ |
| 3284 | status += MXL_SetGPIO(fe, 3, 1); |
| 3285 | status += MXL_SetGPIO(fe, 1, 1); |
| 3286 | status += MXL_SetGPIO(fe, 4, 1); |
| 3287 | status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0); |
| 3288 | |
| 3289 | /* 2.6.12 Turn on RSSI */ |
| 3290 | status += MXL_ControlWrite(fe, SEQ_EXTSYNTHCALIF, 1); |
| 3291 | status += MXL_ControlWrite(fe, SEQ_EXTDCCAL, 1); |
| 3292 | status += MXL_ControlWrite(fe, AGC_EN_RSSI, 1); |
| 3293 | status += MXL_ControlWrite(fe, RFA_ENCLKRFAGC, 1); |
| 3294 | |
| 3295 | /* RSSI reference point */ |
| 3296 | status += MXL_ControlWrite(fe, RFA_RSSI_REFH, 5); |
| 3297 | status += MXL_ControlWrite(fe, RFA_RSSI_REF, 3); |
| 3298 | status += MXL_ControlWrite(fe, RFA_RSSI_REFL, 2); |
| 3299 | |
| 3300 | /* following parameter is from analog OTA mode, |
| 3301 | * can be change to seek better performance */ |
| 3302 | status += MXL_ControlWrite(fe, RFSYN_CHP_GAIN, 3); |
| 3303 | } else { |
| 3304 | /* if VHF or Cable => Turn on Tracking Filter */ |
| 3305 | |
| 3306 | /* 2.6.12 Turn off RSSI */ |
| 3307 | status += MXL_ControlWrite(fe, AGC_EN_RSSI, 0); |
| 3308 | |
| 3309 | /* change back from above condition */ |
| 3310 | status += MXL_ControlWrite(fe, RFSYN_CHP_GAIN, 5); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3311 | |
| 3312 | |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 3313 | if (state->RF_IN >= 43000000 && state->RF_IN < 174000000) { |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3314 | |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 3315 | status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0); |
| 3316 | status += MXL_SetGPIO(fe, 4, 0); |
| 3317 | status += MXL_SetGPIO(fe, 1, 1); |
| 3318 | status += MXL_SetGPIO(fe, 3, 1); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3319 | } |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 3320 | if (state->RF_IN >= 174000000 && state->RF_IN < 250000000) { |
| 3321 | status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0); |
| 3322 | status += MXL_SetGPIO(fe, 4, 0); |
| 3323 | status += MXL_SetGPIO(fe, 1, 0); |
| 3324 | status += MXL_SetGPIO(fe, 3, 1); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3325 | } |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 3326 | if (state->RF_IN >= 250000000 && state->RF_IN < 350000000) { |
| 3327 | status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0); |
| 3328 | status += MXL_SetGPIO(fe, 4, 1); |
| 3329 | status += MXL_SetGPIO(fe, 1, 0); |
| 3330 | status += MXL_SetGPIO(fe, 3, 1); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3331 | } |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 3332 | if (state->RF_IN >= 350000000 && state->RF_IN < 400000000) { |
| 3333 | status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0); |
| 3334 | status += MXL_SetGPIO(fe, 4, 1); |
| 3335 | status += MXL_SetGPIO(fe, 1, 0); |
| 3336 | status += MXL_SetGPIO(fe, 3, 0); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3337 | } |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 3338 | if (state->RF_IN >= 400000000 && state->RF_IN < 570000000) { |
| 3339 | status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0); |
| 3340 | status += MXL_SetGPIO(fe, 4, 1); |
| 3341 | status += MXL_SetGPIO(fe, 1, 1); |
| 3342 | status += MXL_SetGPIO(fe, 3, 0); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3343 | } |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 3344 | if (state->RF_IN >= 570000000 && state->RF_IN < 770000000) { |
| 3345 | status += MXL_ControlWrite(fe, DAC_B_ENABLE, 1); |
| 3346 | status += MXL_SetGPIO(fe, 4, 1); |
| 3347 | status += MXL_SetGPIO(fe, 1, 1); |
| 3348 | status += MXL_SetGPIO(fe, 3, 0); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3349 | } |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 3350 | if (state->RF_IN >= 770000000 && state->RF_IN <= 900000000) { |
| 3351 | status += MXL_ControlWrite(fe, DAC_B_ENABLE, 1); |
| 3352 | status += MXL_SetGPIO(fe, 4, 1); |
| 3353 | status += MXL_SetGPIO(fe, 1, 1); |
| 3354 | status += MXL_SetGPIO(fe, 3, 1); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3355 | } |
| 3356 | } |
| 3357 | } |
| 3358 | return status ; |
| 3359 | } |
| 3360 | |
Steven Toth | c6c34b1 | 2008-05-03 14:14:54 -0300 | [diff] [blame] | 3361 | static u16 MXL_SetGPIO(struct dvb_frontend *fe, u8 GPIO_Num, u8 GPIO_Val) |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3362 | { |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 3363 | u16 status = 0; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3364 | |
| 3365 | if (GPIO_Num == 1) |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 3366 | status += MXL_ControlWrite(fe, GPIO_1B, GPIO_Val ? 0 : 1); |
| 3367 | |
| 3368 | /* GPIO2 is not available */ |
| 3369 | |
| 3370 | if (GPIO_Num == 3) { |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3371 | if (GPIO_Val == 1) { |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 3372 | status += MXL_ControlWrite(fe, GPIO_3, 0); |
| 3373 | status += MXL_ControlWrite(fe, GPIO_3B, 0); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3374 | } |
| 3375 | if (GPIO_Val == 0) { |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 3376 | status += MXL_ControlWrite(fe, GPIO_3, 1); |
| 3377 | status += MXL_ControlWrite(fe, GPIO_3B, 1); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3378 | } |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 3379 | if (GPIO_Val == 3) { /* tri-state */ |
| 3380 | status += MXL_ControlWrite(fe, GPIO_3, 0); |
| 3381 | status += MXL_ControlWrite(fe, GPIO_3B, 1); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3382 | } |
| 3383 | } |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 3384 | if (GPIO_Num == 4) { |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3385 | if (GPIO_Val == 1) { |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 3386 | status += MXL_ControlWrite(fe, GPIO_4, 0); |
| 3387 | status += MXL_ControlWrite(fe, GPIO_4B, 0); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3388 | } |
| 3389 | if (GPIO_Val == 0) { |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 3390 | status += MXL_ControlWrite(fe, GPIO_4, 1); |
| 3391 | status += MXL_ControlWrite(fe, GPIO_4B, 1); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3392 | } |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 3393 | if (GPIO_Val == 3) { /* tri-state */ |
| 3394 | status += MXL_ControlWrite(fe, GPIO_4, 0); |
| 3395 | status += MXL_ControlWrite(fe, GPIO_4B, 1); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3396 | } |
| 3397 | } |
| 3398 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 3399 | return status; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3400 | } |
| 3401 | |
Steven Toth | c6c34b1 | 2008-05-03 14:14:54 -0300 | [diff] [blame] | 3402 | static u16 MXL_ControlWrite(struct dvb_frontend *fe, u16 ControlNum, u32 value) |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3403 | { |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 3404 | u16 status = 0; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3405 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 3406 | /* Will write ALL Matching Control Name */ |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 3407 | /* Write Matching INIT Control */ |
| 3408 | status += MXL_ControlWrite_Group(fe, ControlNum, value, 1); |
| 3409 | /* Write Matching CH Control */ |
| 3410 | status += MXL_ControlWrite_Group(fe, ControlNum, value, 2); |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 3411 | #ifdef _MXL_INTERNAL |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 3412 | /* Write Matching MXL Control */ |
| 3413 | status += MXL_ControlWrite_Group(fe, ControlNum, value, 3); |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 3414 | #endif |
| 3415 | return status; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3416 | } |
| 3417 | |
Steven Toth | c6c34b1 | 2008-05-03 14:14:54 -0300 | [diff] [blame] | 3418 | static u16 MXL_ControlWrite_Group(struct dvb_frontend *fe, u16 controlNum, |
| 3419 | u32 value, u16 controlGroup) |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3420 | { |
Steven Toth | 85d220d | 2008-05-01 05:48:14 -0300 | [diff] [blame] | 3421 | struct mxl5005s_state *state = fe->tuner_priv; |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 3422 | u16 i, j, k; |
| 3423 | u32 highLimit; |
| 3424 | u32 ctrlVal; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3425 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 3426 | if (controlGroup == 1) /* Initial Control */ { |
| 3427 | |
| 3428 | for (i = 0; i < state->Init_Ctrl_Num; i++) { |
| 3429 | |
| 3430 | if (controlNum == state->Init_Ctrl[i].Ctrl_Num) { |
| 3431 | |
| 3432 | highLimit = 1 << state->Init_Ctrl[i].size; |
| 3433 | if (value < highLimit) { |
| 3434 | for (j = 0; j < state->Init_Ctrl[i].size; j++) { |
| 3435 | state->Init_Ctrl[i].val[j] = (u8)((value >> j) & 0x01); |
| 3436 | MXL_RegWriteBit(fe, (u8)(state->Init_Ctrl[i].addr[j]), |
| 3437 | (u8)(state->Init_Ctrl[i].bit[j]), |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 3438 | (u8)((value>>j) & 0x01)); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3439 | } |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 3440 | ctrlVal = 0; |
| 3441 | for (k = 0; k < state->Init_Ctrl[i].size; k++) |
| 3442 | ctrlVal += state->Init_Ctrl[i].val[k] * (1 << k); |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 3443 | } else |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 3444 | return -1; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3445 | } |
| 3446 | } |
| 3447 | } |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 3448 | if (controlGroup == 2) /* Chan change Control */ { |
| 3449 | |
| 3450 | for (i = 0; i < state->CH_Ctrl_Num; i++) { |
| 3451 | |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 3452 | if (controlNum == state->CH_Ctrl[i].Ctrl_Num) { |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 3453 | |
| 3454 | highLimit = 1 << state->CH_Ctrl[i].size; |
| 3455 | if (value < highLimit) { |
| 3456 | for (j = 0; j < state->CH_Ctrl[i].size; j++) { |
| 3457 | state->CH_Ctrl[i].val[j] = (u8)((value >> j) & 0x01); |
| 3458 | MXL_RegWriteBit(fe, (u8)(state->CH_Ctrl[i].addr[j]), |
| 3459 | (u8)(state->CH_Ctrl[i].bit[j]), |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 3460 | (u8)((value>>j) & 0x01)); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3461 | } |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 3462 | ctrlVal = 0; |
| 3463 | for (k = 0; k < state->CH_Ctrl[i].size; k++) |
| 3464 | ctrlVal += state->CH_Ctrl[i].val[k] * (1 << k); |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 3465 | } else |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 3466 | return -1; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3467 | } |
| 3468 | } |
| 3469 | } |
| 3470 | #ifdef _MXL_INTERNAL |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 3471 | if (controlGroup == 3) /* Maxlinear Control */ { |
| 3472 | |
| 3473 | for (i = 0; i < state->MXL_Ctrl_Num; i++) { |
| 3474 | |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 3475 | if (controlNum == state->MXL_Ctrl[i].Ctrl_Num) { |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 3476 | |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 3477 | highLimit = (1 << state->MXL_Ctrl[i].size); |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 3478 | if (value < highLimit) { |
| 3479 | for (j = 0; j < state->MXL_Ctrl[i].size; j++) { |
| 3480 | state->MXL_Ctrl[i].val[j] = (u8)((value >> j) & 0x01); |
| 3481 | MXL_RegWriteBit(fe, (u8)(state->MXL_Ctrl[i].addr[j]), |
| 3482 | (u8)(state->MXL_Ctrl[i].bit[j]), |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 3483 | (u8)((value>>j) & 0x01)); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3484 | } |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 3485 | ctrlVal = 0; |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 3486 | for (k = 0; k < state->MXL_Ctrl[i].size; k++) |
Steven Toth | 5c310b1 | 2008-10-16 20:31:56 -0300 | [diff] [blame] | 3487 | ctrlVal += state-> |
| 3488 | MXL_Ctrl[i].val[k] * |
| 3489 | (1 << k); |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 3490 | } else |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 3491 | return -1; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3492 | } |
| 3493 | } |
| 3494 | } |
| 3495 | #endif |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 3496 | return 0 ; /* successful return */ |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3497 | } |
| 3498 | |
Steven Toth | c6c34b1 | 2008-05-03 14:14:54 -0300 | [diff] [blame] | 3499 | static u16 MXL_RegRead(struct dvb_frontend *fe, u8 RegNum, u8 *RegVal) |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3500 | { |
Steven Toth | 85d220d | 2008-05-01 05:48:14 -0300 | [diff] [blame] | 3501 | struct mxl5005s_state *state = fe->tuner_priv; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3502 | int i ; |
| 3503 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 3504 | for (i = 0; i < 104; i++) { |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 3505 | if (RegNum == state->TunerRegs[i].Reg_Num) { |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 3506 | *RegVal = (u8)(state->TunerRegs[i].Reg_Val); |
| 3507 | return 0; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3508 | } |
| 3509 | } |
| 3510 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 3511 | return 1; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3512 | } |
| 3513 | |
Steven Toth | c6c34b1 | 2008-05-03 14:14:54 -0300 | [diff] [blame] | 3514 | static u16 MXL_ControlRead(struct dvb_frontend *fe, u16 controlNum, u32 *value) |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3515 | { |
Steven Toth | 85d220d | 2008-05-01 05:48:14 -0300 | [diff] [blame] | 3516 | struct mxl5005s_state *state = fe->tuner_priv; |
Steven Toth | a8214d4 | 2008-05-01 05:02:58 -0300 | [diff] [blame] | 3517 | u32 ctrlVal ; |
| 3518 | u16 i, k ; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3519 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 3520 | for (i = 0; i < state->Init_Ctrl_Num ; i++) { |
| 3521 | |
| 3522 | if (controlNum == state->Init_Ctrl[i].Ctrl_Num) { |
| 3523 | |
| 3524 | ctrlVal = 0; |
| 3525 | for (k = 0; k < state->Init_Ctrl[i].size; k++) |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 3526 | ctrlVal += state->Init_Ctrl[i].val[k] * (1<<k); |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 3527 | *value = ctrlVal; |
| 3528 | return 0; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3529 | } |
| 3530 | } |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 3531 | |
| 3532 | for (i = 0; i < state->CH_Ctrl_Num ; i++) { |
| 3533 | |
| 3534 | if (controlNum == state->CH_Ctrl[i].Ctrl_Num) { |
| 3535 | |
| 3536 | ctrlVal = 0; |
| 3537 | for (k = 0; k < state->CH_Ctrl[i].size; k++) |
| 3538 | ctrlVal += state->CH_Ctrl[i].val[k] * (1 << k); |
| 3539 | *value = ctrlVal; |
| 3540 | return 0; |
| 3541 | |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3542 | } |
| 3543 | } |
| 3544 | |
| 3545 | #ifdef _MXL_INTERNAL |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 3546 | for (i = 0; i < state->MXL_Ctrl_Num ; i++) { |
| 3547 | |
| 3548 | if (controlNum == state->MXL_Ctrl[i].Ctrl_Num) { |
| 3549 | |
| 3550 | ctrlVal = 0; |
| 3551 | for (k = 0; k < state->MXL_Ctrl[i].size; k++) |
| 3552 | ctrlVal += state->MXL_Ctrl[i].val[k] * (1<<k); |
| 3553 | *value = ctrlVal; |
| 3554 | return 0; |
| 3555 | |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3556 | } |
| 3557 | } |
| 3558 | #endif |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 3559 | return 1; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3560 | } |
| 3561 | |
Steven Toth | c6c34b1 | 2008-05-03 14:14:54 -0300 | [diff] [blame] | 3562 | static void MXL_RegWriteBit(struct dvb_frontend *fe, u8 address, u8 bit, |
| 3563 | u8 bitVal) |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3564 | { |
Steven Toth | 85d220d | 2008-05-01 05:48:14 -0300 | [diff] [blame] | 3565 | struct mxl5005s_state *state = fe->tuner_priv; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3566 | int i ; |
| 3567 | |
Steven Toth | a8214d4 | 2008-05-01 05:02:58 -0300 | [diff] [blame] | 3568 | const u8 AND_MAP[8] = { |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3569 | 0xFE, 0xFD, 0xFB, 0xF7, |
| 3570 | 0xEF, 0xDF, 0xBF, 0x7F } ; |
| 3571 | |
Steven Toth | a8214d4 | 2008-05-01 05:02:58 -0300 | [diff] [blame] | 3572 | const u8 OR_MAP[8] = { |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3573 | 0x01, 0x02, 0x04, 0x08, |
| 3574 | 0x10, 0x20, 0x40, 0x80 } ; |
| 3575 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 3576 | for (i = 0; i < state->TunerRegs_Num; i++) { |
| 3577 | if (state->TunerRegs[i].Reg_Num == address) { |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3578 | if (bitVal) |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 3579 | state->TunerRegs[i].Reg_Val |= OR_MAP[bit]; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3580 | else |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 3581 | state->TunerRegs[i].Reg_Val &= AND_MAP[bit]; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3582 | break ; |
| 3583 | } |
| 3584 | } |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 3585 | } |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3586 | |
Steven Toth | c6c34b1 | 2008-05-03 14:14:54 -0300 | [diff] [blame] | 3587 | static u32 MXL_Ceiling(u32 value, u32 resolution) |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3588 | { |
Steven Toth | 5c310b1 | 2008-10-16 20:31:56 -0300 | [diff] [blame] | 3589 | return value / resolution + (value % resolution > 0 ? 1 : 0); |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 3590 | } |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3591 | |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 3592 | /* Retrieve the Initialzation Registers */ |
Steven Toth | c6c34b1 | 2008-05-03 14:14:54 -0300 | [diff] [blame] | 3593 | static u16 MXL_GetInitRegister(struct dvb_frontend *fe, u8 *RegNum, |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 3594 | u8 *RegVal, int *count) |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3595 | { |
Steven Toth | a8214d4 | 2008-05-01 05:02:58 -0300 | [diff] [blame] | 3596 | u16 status = 0; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3597 | int i ; |
| 3598 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 3599 | u8 RegAddr[] = { |
| 3600 | 11, 12, 13, 22, 32, 43, 44, 53, 56, 59, 73, |
| 3601 | 76, 77, 91, 134, 135, 137, 147, |
| 3602 | 156, 166, 167, 168, 25 }; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3603 | |
Julia Lawall | 8029712 | 2008-11-12 23:18:21 -0300 | [diff] [blame] | 3604 | *count = ARRAY_SIZE(RegAddr); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3605 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 3606 | status += MXL_BlockInit(fe); |
| 3607 | |
| 3608 | for (i = 0 ; i < *count; i++) { |
| 3609 | RegNum[i] = RegAddr[i]; |
| 3610 | status += MXL_RegRead(fe, RegNum[i], &RegVal[i]); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3611 | } |
| 3612 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 3613 | return status; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3614 | } |
| 3615 | |
Steven Toth | c6c34b1 | 2008-05-03 14:14:54 -0300 | [diff] [blame] | 3616 | static u16 MXL_GetCHRegister(struct dvb_frontend *fe, u8 *RegNum, u8 *RegVal, |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 3617 | int *count) |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3618 | { |
Steven Toth | a8214d4 | 2008-05-01 05:02:58 -0300 | [diff] [blame] | 3619 | u16 status = 0; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3620 | int i ; |
| 3621 | |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 3622 | /* add 77, 166, 167, 168 register for 2.6.12 */ |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3623 | #ifdef _MXL_PRODUCTION |
Steven Toth | a8214d4 | 2008-05-01 05:02:58 -0300 | [diff] [blame] | 3624 | u8 RegAddr[] = {14, 15, 16, 17, 22, 43, 65, 68, 69, 70, 73, 92, 93, 106, |
| 3625 | 107, 108, 109, 110, 111, 112, 136, 138, 149, 77, 166, 167, 168 } ; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3626 | #else |
Steven Toth | a8214d4 | 2008-05-01 05:02:58 -0300 | [diff] [blame] | 3627 | u8 RegAddr[] = {14, 15, 16, 17, 22, 43, 68, 69, 70, 73, 92, 93, 106, |
| 3628 | 107, 108, 109, 110, 111, 112, 136, 138, 149, 77, 166, 167, 168 } ; |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 3629 | /* |
| 3630 | u8 RegAddr[171]; |
| 3631 | for (i = 0; i <= 170; i++) |
| 3632 | RegAddr[i] = i; |
| 3633 | */ |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3634 | #endif |
| 3635 | |
Julia Lawall | 8029712 | 2008-11-12 23:18:21 -0300 | [diff] [blame] | 3636 | *count = ARRAY_SIZE(RegAddr); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3637 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 3638 | for (i = 0 ; i < *count; i++) { |
| 3639 | RegNum[i] = RegAddr[i]; |
| 3640 | status += MXL_RegRead(fe, RegNum[i], &RegVal[i]); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3641 | } |
| 3642 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 3643 | return status; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3644 | } |
| 3645 | |
Steven Toth | c6c34b1 | 2008-05-03 14:14:54 -0300 | [diff] [blame] | 3646 | static u16 MXL_GetCHRegister_ZeroIF(struct dvb_frontend *fe, u8 *RegNum, |
| 3647 | u8 *RegVal, int *count) |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3648 | { |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 3649 | u16 status = 0; |
| 3650 | int i; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3651 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 3652 | u8 RegAddr[] = {43, 136}; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3653 | |
Julia Lawall | 8029712 | 2008-11-12 23:18:21 -0300 | [diff] [blame] | 3654 | *count = ARRAY_SIZE(RegAddr); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3655 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 3656 | for (i = 0; i < *count; i++) { |
| 3657 | RegNum[i] = RegAddr[i]; |
| 3658 | status += MXL_RegRead(fe, RegNum[i], &RegVal[i]); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3659 | } |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3660 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 3661 | return status; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3662 | } |
| 3663 | |
Steven Toth | c6c34b1 | 2008-05-03 14:14:54 -0300 | [diff] [blame] | 3664 | static u16 MXL_GetMasterControl(u8 *MasterReg, int state) |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3665 | { |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 3666 | if (state == 1) /* Load_Start */ |
| 3667 | *MasterReg = 0xF3; |
| 3668 | if (state == 2) /* Power_Down */ |
| 3669 | *MasterReg = 0x41; |
| 3670 | if (state == 3) /* Synth_Reset */ |
| 3671 | *MasterReg = 0xB1; |
| 3672 | if (state == 4) /* Seq_Off */ |
| 3673 | *MasterReg = 0xF1; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3674 | |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 3675 | return 0; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3676 | } |
| 3677 | |
| 3678 | #ifdef _MXL_PRODUCTION |
Steven Toth | c6c34b1 | 2008-05-03 14:14:54 -0300 | [diff] [blame] | 3679 | static u16 MXL_VCORange_Test(struct dvb_frontend *fe, int VCO_Range) |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3680 | { |
Steven Toth | 85d220d | 2008-05-01 05:48:14 -0300 | [diff] [blame] | 3681 | struct mxl5005s_state *state = fe->tuner_priv; |
Steven Toth | a8214d4 | 2008-05-01 05:02:58 -0300 | [diff] [blame] | 3682 | u16 status = 0 ; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3683 | |
Steven Toth | a8214d4 | 2008-05-01 05:02:58 -0300 | [diff] [blame] | 3684 | if (VCO_Range == 1) { |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 3685 | status += MXL_ControlWrite(fe, RFSYN_EN_DIV, 1); |
| 3686 | status += MXL_ControlWrite(fe, RFSYN_EN_OUTMUX, 0); |
| 3687 | status += MXL_ControlWrite(fe, RFSYN_SEL_DIVM, 0); |
| 3688 | status += MXL_ControlWrite(fe, RFSYN_DIVM, 1); |
| 3689 | status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_OUT, 1); |
| 3690 | status += MXL_ControlWrite(fe, RFSYN_RF_DIV_BIAS, 1); |
| 3691 | status += MXL_ControlWrite(fe, DN_SEL_FREQ, 0); |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 3692 | if (state->Mode == 0 && state->IF_Mode == 1) { |
| 3693 | /* Analog Low IF Mode */ |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 3694 | status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 1); |
| 3695 | status += MXL_ControlWrite(fe, RFSYN_VCO_BIAS, 8); |
| 3696 | status += MXL_ControlWrite(fe, CHCAL_INT_MOD_RF, 56); |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 3697 | status += MXL_ControlWrite(fe, |
| 3698 | CHCAL_FRAC_MOD_RF, 180224); |
Steven Toth | a8214d4 | 2008-05-01 05:02:58 -0300 | [diff] [blame] | 3699 | } |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 3700 | if (state->Mode == 0 && state->IF_Mode == 0) { |
| 3701 | /* Analog Zero IF Mode */ |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 3702 | status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 1); |
| 3703 | status += MXL_ControlWrite(fe, RFSYN_VCO_BIAS, 8); |
| 3704 | status += MXL_ControlWrite(fe, CHCAL_INT_MOD_RF, 56); |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 3705 | status += MXL_ControlWrite(fe, |
| 3706 | CHCAL_FRAC_MOD_RF, 222822); |
Steven Toth | a8214d4 | 2008-05-01 05:02:58 -0300 | [diff] [blame] | 3707 | } |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 3708 | if (state->Mode == 1) /* Digital Mode */ { |
| 3709 | status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 1); |
| 3710 | status += MXL_ControlWrite(fe, RFSYN_VCO_BIAS, 8); |
| 3711 | status += MXL_ControlWrite(fe, CHCAL_INT_MOD_RF, 56); |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 3712 | status += MXL_ControlWrite(fe, |
| 3713 | CHCAL_FRAC_MOD_RF, 229376); |
Steven Toth | a8214d4 | 2008-05-01 05:02:58 -0300 | [diff] [blame] | 3714 | } |
| 3715 | } |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3716 | |
Steven Toth | a8214d4 | 2008-05-01 05:02:58 -0300 | [diff] [blame] | 3717 | if (VCO_Range == 2) { |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 3718 | status += MXL_ControlWrite(fe, RFSYN_EN_DIV, 1); |
| 3719 | status += MXL_ControlWrite(fe, RFSYN_EN_OUTMUX, 0); |
| 3720 | status += MXL_ControlWrite(fe, RFSYN_SEL_DIVM, 0); |
| 3721 | status += MXL_ControlWrite(fe, RFSYN_DIVM, 1); |
| 3722 | status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_OUT, 1); |
| 3723 | status += MXL_ControlWrite(fe, RFSYN_RF_DIV_BIAS, 1); |
| 3724 | status += MXL_ControlWrite(fe, DN_SEL_FREQ, 0); |
| 3725 | status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 1); |
| 3726 | status += MXL_ControlWrite(fe, RFSYN_VCO_BIAS, 40); |
| 3727 | status += MXL_ControlWrite(fe, CHCAL_INT_MOD_RF, 41); |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 3728 | if (state->Mode == 0 && state->IF_Mode == 1) { |
| 3729 | /* Analog Low IF Mode */ |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 3730 | status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 1); |
| 3731 | status += MXL_ControlWrite(fe, RFSYN_VCO_BIAS, 40); |
| 3732 | status += MXL_ControlWrite(fe, CHCAL_INT_MOD_RF, 42); |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 3733 | status += MXL_ControlWrite(fe, |
| 3734 | CHCAL_FRAC_MOD_RF, 206438); |
Steven Toth | a8214d4 | 2008-05-01 05:02:58 -0300 | [diff] [blame] | 3735 | } |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 3736 | if (state->Mode == 0 && state->IF_Mode == 0) { |
| 3737 | /* Analog Zero IF Mode */ |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 3738 | status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 1); |
| 3739 | status += MXL_ControlWrite(fe, RFSYN_VCO_BIAS, 40); |
| 3740 | status += MXL_ControlWrite(fe, CHCAL_INT_MOD_RF, 42); |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 3741 | status += MXL_ControlWrite(fe, |
| 3742 | CHCAL_FRAC_MOD_RF, 206438); |
Steven Toth | a8214d4 | 2008-05-01 05:02:58 -0300 | [diff] [blame] | 3743 | } |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 3744 | if (state->Mode == 1) /* Digital Mode */ { |
| 3745 | status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 1); |
| 3746 | status += MXL_ControlWrite(fe, RFSYN_VCO_BIAS, 40); |
| 3747 | status += MXL_ControlWrite(fe, CHCAL_INT_MOD_RF, 41); |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 3748 | status += MXL_ControlWrite(fe, |
| 3749 | CHCAL_FRAC_MOD_RF, 16384); |
Steven Toth | a8214d4 | 2008-05-01 05:02:58 -0300 | [diff] [blame] | 3750 | } |
| 3751 | } |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3752 | |
Steven Toth | a8214d4 | 2008-05-01 05:02:58 -0300 | [diff] [blame] | 3753 | if (VCO_Range == 3) { |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 3754 | status += MXL_ControlWrite(fe, RFSYN_EN_DIV, 1); |
| 3755 | status += MXL_ControlWrite(fe, RFSYN_EN_OUTMUX, 0); |
| 3756 | status += MXL_ControlWrite(fe, RFSYN_SEL_DIVM, 0); |
| 3757 | status += MXL_ControlWrite(fe, RFSYN_DIVM, 1); |
| 3758 | status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_OUT, 1); |
| 3759 | status += MXL_ControlWrite(fe, RFSYN_RF_DIV_BIAS, 1); |
| 3760 | status += MXL_ControlWrite(fe, DN_SEL_FREQ, 0); |
| 3761 | status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 0); |
| 3762 | status += MXL_ControlWrite(fe, RFSYN_VCO_BIAS, 8); |
| 3763 | status += MXL_ControlWrite(fe, CHCAL_INT_MOD_RF, 42); |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 3764 | if (state->Mode == 0 && state->IF_Mode == 1) { |
| 3765 | /* Analog Low IF Mode */ |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 3766 | status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 0); |
| 3767 | status += MXL_ControlWrite(fe, RFSYN_VCO_BIAS, 8); |
| 3768 | status += MXL_ControlWrite(fe, CHCAL_INT_MOD_RF, 44); |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 3769 | status += MXL_ControlWrite(fe, |
| 3770 | CHCAL_FRAC_MOD_RF, 173670); |
Steven Toth | a8214d4 | 2008-05-01 05:02:58 -0300 | [diff] [blame] | 3771 | } |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 3772 | if (state->Mode == 0 && state->IF_Mode == 0) { |
| 3773 | /* Analog Zero IF Mode */ |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 3774 | status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 0); |
| 3775 | status += MXL_ControlWrite(fe, RFSYN_VCO_BIAS, 8); |
| 3776 | status += MXL_ControlWrite(fe, CHCAL_INT_MOD_RF, 44); |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 3777 | status += MXL_ControlWrite(fe, |
| 3778 | CHCAL_FRAC_MOD_RF, 173670); |
Steven Toth | a8214d4 | 2008-05-01 05:02:58 -0300 | [diff] [blame] | 3779 | } |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 3780 | if (state->Mode == 1) /* Digital Mode */ { |
| 3781 | status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 0); |
| 3782 | status += MXL_ControlWrite(fe, RFSYN_VCO_BIAS, 8); |
| 3783 | status += MXL_ControlWrite(fe, CHCAL_INT_MOD_RF, 42); |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 3784 | status += MXL_ControlWrite(fe, |
| 3785 | CHCAL_FRAC_MOD_RF, 245760); |
Steven Toth | a8214d4 | 2008-05-01 05:02:58 -0300 | [diff] [blame] | 3786 | } |
| 3787 | } |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3788 | |
Steven Toth | a8214d4 | 2008-05-01 05:02:58 -0300 | [diff] [blame] | 3789 | if (VCO_Range == 4) { |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 3790 | status += MXL_ControlWrite(fe, RFSYN_EN_DIV, 1); |
| 3791 | status += MXL_ControlWrite(fe, RFSYN_EN_OUTMUX, 0); |
| 3792 | status += MXL_ControlWrite(fe, RFSYN_SEL_DIVM, 0); |
| 3793 | status += MXL_ControlWrite(fe, RFSYN_DIVM, 1); |
| 3794 | status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_OUT, 1); |
| 3795 | status += MXL_ControlWrite(fe, RFSYN_RF_DIV_BIAS, 1); |
| 3796 | status += MXL_ControlWrite(fe, DN_SEL_FREQ, 0); |
| 3797 | status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 0); |
| 3798 | status += MXL_ControlWrite(fe, RFSYN_VCO_BIAS, 40); |
| 3799 | status += MXL_ControlWrite(fe, CHCAL_INT_MOD_RF, 27); |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 3800 | if (state->Mode == 0 && state->IF_Mode == 1) { |
| 3801 | /* Analog Low IF Mode */ |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 3802 | status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 0); |
| 3803 | status += MXL_ControlWrite(fe, RFSYN_VCO_BIAS, 40); |
| 3804 | status += MXL_ControlWrite(fe, CHCAL_INT_MOD_RF, 27); |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 3805 | status += MXL_ControlWrite(fe, |
| 3806 | CHCAL_FRAC_MOD_RF, 206438); |
Steven Toth | a8214d4 | 2008-05-01 05:02:58 -0300 | [diff] [blame] | 3807 | } |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 3808 | if (state->Mode == 0 && state->IF_Mode == 0) { |
| 3809 | /* Analog Zero IF Mode */ |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 3810 | status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 0); |
| 3811 | status += MXL_ControlWrite(fe, RFSYN_VCO_BIAS, 40); |
| 3812 | status += MXL_ControlWrite(fe, CHCAL_INT_MOD_RF, 27); |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 3813 | status += MXL_ControlWrite(fe, |
| 3814 | CHCAL_FRAC_MOD_RF, 206438); |
Steven Toth | a8214d4 | 2008-05-01 05:02:58 -0300 | [diff] [blame] | 3815 | } |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 3816 | if (state->Mode == 1) /* Digital Mode */ { |
| 3817 | status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 0); |
| 3818 | status += MXL_ControlWrite(fe, RFSYN_VCO_BIAS, 40); |
| 3819 | status += MXL_ControlWrite(fe, CHCAL_INT_MOD_RF, 27); |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 3820 | status += MXL_ControlWrite(fe, |
| 3821 | CHCAL_FRAC_MOD_RF, 212992); |
Steven Toth | a8214d4 | 2008-05-01 05:02:58 -0300 | [diff] [blame] | 3822 | } |
| 3823 | } |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3824 | |
Steven Toth | a8214d4 | 2008-05-01 05:02:58 -0300 | [diff] [blame] | 3825 | return status; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3826 | } |
| 3827 | |
Steven Toth | c6c34b1 | 2008-05-03 14:14:54 -0300 | [diff] [blame] | 3828 | static u16 MXL_Hystersis_Test(struct dvb_frontend *fe, int Hystersis) |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3829 | { |
Steven Toth | 85d220d | 2008-05-01 05:48:14 -0300 | [diff] [blame] | 3830 | struct mxl5005s_state *state = fe->tuner_priv; |
Steven Toth | a8214d4 | 2008-05-01 05:02:58 -0300 | [diff] [blame] | 3831 | u16 status = 0; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3832 | |
| 3833 | if (Hystersis == 1) |
Steven Toth | 3935c25 | 2008-05-01 05:45:44 -0300 | [diff] [blame] | 3834 | status += MXL_ControlWrite(fe, DN_BYPASS_AGC_I2C, 1); |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3835 | |
Steven Toth | a8214d4 | 2008-05-01 05:02:58 -0300 | [diff] [blame] | 3836 | return status; |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3837 | } |
| 3838 | #endif |
Steven Toth | 4893729 | 2008-05-01 07:15:38 -0300 | [diff] [blame] | 3839 | /* End: Reference driver code found in the Realtek driver that |
| 3840 | * is copyright MaxLinear */ |
Steven Toth | 52c99bd | 2008-05-01 04:57:01 -0300 | [diff] [blame] | 3841 | |
Steven Toth | 4893729 | 2008-05-01 07:15:38 -0300 | [diff] [blame] | 3842 | /* ---------------------------------------------------------------- |
| 3843 | * Begin: Everything after here is new code to adapt the |
| 3844 | * proprietary Realtek driver into a Linux API tuner. |
Steven Toth | 6d89761 | 2008-09-03 17:12:12 -0300 | [diff] [blame] | 3845 | * Copyright (C) 2008 Steven Toth <stoth@linuxtv.org> |
Steven Toth | 4893729 | 2008-05-01 07:15:38 -0300 | [diff] [blame] | 3846 | */ |
| 3847 | static int mxl5005s_reset(struct dvb_frontend *fe) |
| 3848 | { |
| 3849 | struct mxl5005s_state *state = fe->tuner_priv; |
| 3850 | int ret = 0; |
| 3851 | |
| 3852 | u8 buf[2] = { 0xff, 0x00 }; |
| 3853 | struct i2c_msg msg = { .addr = state->config->i2c_address, .flags = 0, |
| 3854 | .buf = buf, .len = 2 }; |
| 3855 | |
| 3856 | dprintk(2, "%s()\n", __func__); |
| 3857 | |
| 3858 | if (fe->ops.i2c_gate_ctrl) |
| 3859 | fe->ops.i2c_gate_ctrl(fe, 1); |
| 3860 | |
| 3861 | if (i2c_transfer(state->i2c, &msg, 1) != 1) { |
| 3862 | printk(KERN_WARNING "mxl5005s I2C reset failed\n"); |
| 3863 | ret = -EREMOTEIO; |
| 3864 | } |
| 3865 | |
| 3866 | if (fe->ops.i2c_gate_ctrl) |
| 3867 | fe->ops.i2c_gate_ctrl(fe, 0); |
| 3868 | |
| 3869 | return ret; |
| 3870 | } |
| 3871 | |
| 3872 | /* Write a single byte to a single reg, latch the value if required by |
| 3873 | * following the transaction with the latch byte. |
| 3874 | */ |
| 3875 | static int mxl5005s_writereg(struct dvb_frontend *fe, u8 reg, u8 val, int latch) |
| 3876 | { |
| 3877 | struct mxl5005s_state *state = fe->tuner_priv; |
| 3878 | u8 buf[3] = { reg, val, MXL5005S_LATCH_BYTE }; |
| 3879 | struct i2c_msg msg = { .addr = state->config->i2c_address, .flags = 0, |
| 3880 | .buf = buf, .len = 3 }; |
| 3881 | |
| 3882 | if (latch == 0) |
| 3883 | msg.len = 2; |
| 3884 | |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 3885 | dprintk(2, "%s(0x%x, 0x%x, 0x%x)\n", __func__, reg, val, msg.addr); |
Steven Toth | 4893729 | 2008-05-01 07:15:38 -0300 | [diff] [blame] | 3886 | |
| 3887 | if (i2c_transfer(state->i2c, &msg, 1) != 1) { |
| 3888 | printk(KERN_WARNING "mxl5005s I2C write failed\n"); |
| 3889 | return -EREMOTEIO; |
| 3890 | } |
| 3891 | return 0; |
| 3892 | } |
| 3893 | |
Steven Toth | c6c34b1 | 2008-05-03 14:14:54 -0300 | [diff] [blame] | 3894 | static int mxl5005s_writeregs(struct dvb_frontend *fe, u8 *addrtable, |
| 3895 | u8 *datatable, u8 len) |
Steven Toth | 4893729 | 2008-05-01 07:15:38 -0300 | [diff] [blame] | 3896 | { |
| 3897 | int ret = 0, i; |
| 3898 | |
| 3899 | if (fe->ops.i2c_gate_ctrl) |
| 3900 | fe->ops.i2c_gate_ctrl(fe, 1); |
| 3901 | |
| 3902 | for (i = 0 ; i < len-1; i++) { |
| 3903 | ret = mxl5005s_writereg(fe, addrtable[i], datatable[i], 0); |
| 3904 | if (ret < 0) |
| 3905 | break; |
| 3906 | } |
| 3907 | |
| 3908 | ret = mxl5005s_writereg(fe, addrtable[i], datatable[i], 1); |
| 3909 | |
| 3910 | if (fe->ops.i2c_gate_ctrl) |
| 3911 | fe->ops.i2c_gate_ctrl(fe, 0); |
| 3912 | |
| 3913 | return ret; |
| 3914 | } |
Steven Toth | 7f5c3af | 2008-05-01 06:51:36 -0300 | [diff] [blame] | 3915 | |
Steven Toth | c6c34b1 | 2008-05-03 14:14:54 -0300 | [diff] [blame] | 3916 | static int mxl5005s_init(struct dvb_frontend *fe) |
Steven Toth | 85d220d | 2008-05-01 05:48:14 -0300 | [diff] [blame] | 3917 | { |
Jose Alberto Reguero | ca341e4 | 2008-10-13 18:23:49 -0300 | [diff] [blame] | 3918 | struct mxl5005s_state *state = fe->tuner_priv; |
| 3919 | |
Steven Toth | 4893729 | 2008-05-01 07:15:38 -0300 | [diff] [blame] | 3920 | dprintk(1, "%s()\n", __func__); |
Jose Alberto Reguero | ca341e4 | 2008-10-13 18:23:49 -0300 | [diff] [blame] | 3921 | state->current_mode = MXL_QAM; |
Steven Toth | 4893729 | 2008-05-01 07:15:38 -0300 | [diff] [blame] | 3922 | return mxl5005s_reconfigure(fe, MXL_QAM, MXL5005S_BANDWIDTH_6MHZ); |
| 3923 | } |
| 3924 | |
Steven Toth | c6c34b1 | 2008-05-03 14:14:54 -0300 | [diff] [blame] | 3925 | static int mxl5005s_reconfigure(struct dvb_frontend *fe, u32 mod_type, |
| 3926 | u32 bandwidth) |
Steven Toth | 4893729 | 2008-05-01 07:15:38 -0300 | [diff] [blame] | 3927 | { |
| 3928 | struct mxl5005s_state *state = fe->tuner_priv; |
| 3929 | |
| 3930 | u8 AddrTable[MXL5005S_REG_WRITING_TABLE_LEN_MAX]; |
| 3931 | u8 ByteTable[MXL5005S_REG_WRITING_TABLE_LEN_MAX]; |
| 3932 | int TableLen; |
| 3933 | |
| 3934 | dprintk(1, "%s(type=%d, bw=%d)\n", __func__, mod_type, bandwidth); |
| 3935 | |
| 3936 | mxl5005s_reset(fe); |
| 3937 | |
| 3938 | /* Tuner initialization stage 0 */ |
| 3939 | MXL_GetMasterControl(ByteTable, MC_SYNTH_RESET); |
| 3940 | AddrTable[0] = MASTER_CONTROL_ADDR; |
| 3941 | ByteTable[0] |= state->config->AgcMasterByte; |
| 3942 | |
| 3943 | mxl5005s_writeregs(fe, AddrTable, ByteTable, 1); |
| 3944 | |
| 3945 | mxl5005s_AssignTunerMode(fe, mod_type, bandwidth); |
| 3946 | |
| 3947 | /* Tuner initialization stage 1 */ |
| 3948 | MXL_GetInitRegister(fe, AddrTable, ByteTable, &TableLen); |
| 3949 | |
| 3950 | mxl5005s_writeregs(fe, AddrTable, ByteTable, TableLen); |
| 3951 | |
| 3952 | return 0; |
| 3953 | } |
| 3954 | |
Steven Toth | c6c34b1 | 2008-05-03 14:14:54 -0300 | [diff] [blame] | 3955 | static int mxl5005s_AssignTunerMode(struct dvb_frontend *fe, u32 mod_type, |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 3956 | u32 bandwidth) |
Steven Toth | 4893729 | 2008-05-01 07:15:38 -0300 | [diff] [blame] | 3957 | { |
| 3958 | struct mxl5005s_state *state = fe->tuner_priv; |
| 3959 | struct mxl5005s_config *c = state->config; |
| 3960 | |
| 3961 | InitTunerControls(fe); |
Steven Toth | 85d220d | 2008-05-01 05:48:14 -0300 | [diff] [blame] | 3962 | |
| 3963 | /* Set MxL5005S parameters. */ |
Steven Toth | 85d220d | 2008-05-01 05:48:14 -0300 | [diff] [blame] | 3964 | MXL5005_TunerConfig( |
| 3965 | fe, |
Steven Toth | 4893729 | 2008-05-01 07:15:38 -0300 | [diff] [blame] | 3966 | c->mod_mode, |
| 3967 | c->if_mode, |
| 3968 | bandwidth, |
| 3969 | c->if_freq, |
| 3970 | c->xtal_freq, |
| 3971 | c->agc_mode, |
| 3972 | c->top, |
| 3973 | c->output_load, |
| 3974 | c->clock_out, |
| 3975 | c->div_out, |
| 3976 | c->cap_select, |
| 3977 | c->rssi_enable, |
| 3978 | mod_type, |
| 3979 | c->tracking_filter); |
Steven Toth | 85d220d | 2008-05-01 05:48:14 -0300 | [diff] [blame] | 3980 | |
Steven Toth | 4893729 | 2008-05-01 07:15:38 -0300 | [diff] [blame] | 3981 | return 0; |
Steven Toth | 85d220d | 2008-05-01 05:48:14 -0300 | [diff] [blame] | 3982 | } |
| 3983 | |
| 3984 | static int mxl5005s_set_params(struct dvb_frontend *fe, |
| 3985 | struct dvb_frontend_parameters *params) |
| 3986 | { |
Steven Toth | 4893729 | 2008-05-01 07:15:38 -0300 | [diff] [blame] | 3987 | struct mxl5005s_state *state = fe->tuner_priv; |
| 3988 | u32 req_mode, req_bw = 0; |
| 3989 | int ret; |
Steven Toth | 85d220d | 2008-05-01 05:48:14 -0300 | [diff] [blame] | 3990 | |
Steven Toth | 4893729 | 2008-05-01 07:15:38 -0300 | [diff] [blame] | 3991 | dprintk(1, "%s()\n", __func__); |
Steven Toth | 85d220d | 2008-05-01 05:48:14 -0300 | [diff] [blame] | 3992 | |
Steven Toth | 4893729 | 2008-05-01 07:15:38 -0300 | [diff] [blame] | 3993 | if (fe->ops.info.type == FE_ATSC) { |
| 3994 | switch (params->u.vsb.modulation) { |
| 3995 | case VSB_8: |
| 3996 | req_mode = MXL_ATSC; break; |
| 3997 | default: |
| 3998 | case QAM_64: |
| 3999 | case QAM_256: |
| 4000 | case QAM_AUTO: |
| 4001 | req_mode = MXL_QAM; break; |
| 4002 | } |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 4003 | } else |
| 4004 | req_mode = MXL_DVBT; |
Steven Toth | 85d220d | 2008-05-01 05:48:14 -0300 | [diff] [blame] | 4005 | |
Steven Toth | 4893729 | 2008-05-01 07:15:38 -0300 | [diff] [blame] | 4006 | /* Change tuner for new modulation type if reqd */ |
| 4007 | if (req_mode != state->current_mode) { |
| 4008 | switch (req_mode) { |
Andy Walls | cea0213 | 2009-03-23 22:32:35 -0300 | [diff] [blame] | 4009 | case MXL_ATSC: |
| 4010 | case MXL_QAM: |
Steven Toth | 4893729 | 2008-05-01 07:15:38 -0300 | [diff] [blame] | 4011 | req_bw = MXL5005S_BANDWIDTH_6MHZ; |
| 4012 | break; |
Andy Walls | cea0213 | 2009-03-23 22:32:35 -0300 | [diff] [blame] | 4013 | case MXL_DVBT: |
Steven Toth | 4893729 | 2008-05-01 07:15:38 -0300 | [diff] [blame] | 4014 | default: |
| 4015 | /* Assume DVB-T */ |
| 4016 | switch (params->u.ofdm.bandwidth) { |
| 4017 | case BANDWIDTH_6_MHZ: |
| 4018 | req_bw = MXL5005S_BANDWIDTH_6MHZ; |
| 4019 | break; |
| 4020 | case BANDWIDTH_7_MHZ: |
| 4021 | req_bw = MXL5005S_BANDWIDTH_7MHZ; |
| 4022 | break; |
| 4023 | case BANDWIDTH_AUTO: |
| 4024 | case BANDWIDTH_8_MHZ: |
| 4025 | req_bw = MXL5005S_BANDWIDTH_8MHZ; |
| 4026 | break; |
| 4027 | } |
| 4028 | } |
| 4029 | |
| 4030 | state->current_mode = req_mode; |
| 4031 | ret = mxl5005s_reconfigure(fe, req_mode, req_bw); |
| 4032 | |
| 4033 | } else |
| 4034 | ret = 0; |
| 4035 | |
| 4036 | if (ret == 0) { |
| 4037 | dprintk(1, "%s() freq=%d\n", __func__, params->frequency); |
| 4038 | ret = mxl5005s_SetRfFreqHz(fe, params->frequency); |
| 4039 | } |
| 4040 | |
| 4041 | return ret; |
Steven Toth | 85d220d | 2008-05-01 05:48:14 -0300 | [diff] [blame] | 4042 | } |
| 4043 | |
| 4044 | static int mxl5005s_get_frequency(struct dvb_frontend *fe, u32 *frequency) |
| 4045 | { |
| 4046 | struct mxl5005s_state *state = fe->tuner_priv; |
| 4047 | dprintk(1, "%s()\n", __func__); |
| 4048 | |
| 4049 | *frequency = state->RF_IN; |
| 4050 | |
| 4051 | return 0; |
| 4052 | } |
| 4053 | |
| 4054 | static int mxl5005s_get_bandwidth(struct dvb_frontend *fe, u32 *bandwidth) |
| 4055 | { |
| 4056 | struct mxl5005s_state *state = fe->tuner_priv; |
| 4057 | dprintk(1, "%s()\n", __func__); |
| 4058 | |
| 4059 | *bandwidth = state->Chan_Bandwidth; |
| 4060 | |
| 4061 | return 0; |
| 4062 | } |
| 4063 | |
Steven Toth | 85d220d | 2008-05-01 05:48:14 -0300 | [diff] [blame] | 4064 | static int mxl5005s_release(struct dvb_frontend *fe) |
| 4065 | { |
| 4066 | dprintk(1, "%s()\n", __func__); |
| 4067 | kfree(fe->tuner_priv); |
| 4068 | fe->tuner_priv = NULL; |
| 4069 | return 0; |
| 4070 | } |
| 4071 | |
| 4072 | static const struct dvb_tuner_ops mxl5005s_tuner_ops = { |
| 4073 | .info = { |
| 4074 | .name = "MaxLinear MXL5005S", |
| 4075 | .frequency_min = 48000000, |
| 4076 | .frequency_max = 860000000, |
| 4077 | .frequency_step = 50000, |
| 4078 | }, |
| 4079 | |
| 4080 | .release = mxl5005s_release, |
| 4081 | .init = mxl5005s_init, |
| 4082 | |
| 4083 | .set_params = mxl5005s_set_params, |
| 4084 | .get_frequency = mxl5005s_get_frequency, |
| 4085 | .get_bandwidth = mxl5005s_get_bandwidth, |
Steven Toth | 85d220d | 2008-05-01 05:48:14 -0300 | [diff] [blame] | 4086 | }; |
| 4087 | |
| 4088 | struct dvb_frontend *mxl5005s_attach(struct dvb_frontend *fe, |
| 4089 | struct i2c_adapter *i2c, |
| 4090 | struct mxl5005s_config *config) |
| 4091 | { |
| 4092 | struct mxl5005s_state *state = NULL; |
| 4093 | dprintk(1, "%s()\n", __func__); |
| 4094 | |
| 4095 | state = kzalloc(sizeof(struct mxl5005s_state), GFP_KERNEL); |
| 4096 | if (state == NULL) |
| 4097 | return NULL; |
| 4098 | |
| 4099 | state->frontend = fe; |
| 4100 | state->config = config; |
| 4101 | state->i2c = i2c; |
| 4102 | |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 4103 | printk(KERN_INFO "MXL5005S: Attached at address 0x%02x\n", |
| 4104 | config->i2c_address); |
Steven Toth | 85d220d | 2008-05-01 05:48:14 -0300 | [diff] [blame] | 4105 | |
Steven Toth | d211017 | 2008-05-01 19:35:54 -0300 | [diff] [blame] | 4106 | memcpy(&fe->ops.tuner_ops, &mxl5005s_tuner_ops, |
| 4107 | sizeof(struct dvb_tuner_ops)); |
Steven Toth | 85d220d | 2008-05-01 05:48:14 -0300 | [diff] [blame] | 4108 | |
| 4109 | fe->tuner_priv = state; |
| 4110 | return fe; |
| 4111 | } |
| 4112 | EXPORT_SYMBOL(mxl5005s_attach); |
| 4113 | |
| 4114 | MODULE_DESCRIPTION("MaxLinear MXL5005S silicon tuner driver"); |
Steven Toth | 85d220d | 2008-05-01 05:48:14 -0300 | [diff] [blame] | 4115 | MODULE_AUTHOR("Steven Toth"); |
| 4116 | MODULE_LICENSE("GPL"); |