162306a36Sopenharmony_ci/* 262306a36Sopenharmony_ci MaxLinear MXL5005S VSB/QAM/DVBT tuner driver 362306a36Sopenharmony_ci 462306a36Sopenharmony_ci Copyright (C) 2008 MaxLinear 562306a36Sopenharmony_ci Copyright (C) 2006 Steven Toth <stoth@linuxtv.org> 662306a36Sopenharmony_ci Functions: 762306a36Sopenharmony_ci mxl5005s_reset() 862306a36Sopenharmony_ci mxl5005s_writereg() 962306a36Sopenharmony_ci mxl5005s_writeregs() 1062306a36Sopenharmony_ci mxl5005s_init() 1162306a36Sopenharmony_ci mxl5005s_reconfigure() 1262306a36Sopenharmony_ci mxl5005s_AssignTunerMode() 1362306a36Sopenharmony_ci mxl5005s_set_params() 1462306a36Sopenharmony_ci mxl5005s_get_frequency() 1562306a36Sopenharmony_ci mxl5005s_get_bandwidth() 1662306a36Sopenharmony_ci mxl5005s_release() 1762306a36Sopenharmony_ci mxl5005s_attach() 1862306a36Sopenharmony_ci 1962306a36Sopenharmony_ci Copyright (C) 2008 Realtek 2062306a36Sopenharmony_ci Copyright (C) 2008 Jan Hoogenraad 2162306a36Sopenharmony_ci Functions: 2262306a36Sopenharmony_ci mxl5005s_SetRfFreqHz() 2362306a36Sopenharmony_ci 2462306a36Sopenharmony_ci This program is free software; you can redistribute it and/or modify 2562306a36Sopenharmony_ci it under the terms of the GNU General Public License as published by 2662306a36Sopenharmony_ci the Free Software Foundation; either version 2 of the License, or 2762306a36Sopenharmony_ci (at your option) any later version. 2862306a36Sopenharmony_ci 2962306a36Sopenharmony_ci This program is distributed in the hope that it will be useful, 3062306a36Sopenharmony_ci but WITHOUT ANY WARRANTY; without even the implied warranty of 3162306a36Sopenharmony_ci MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 3262306a36Sopenharmony_ci GNU General Public License for more details. 3362306a36Sopenharmony_ci 3462306a36Sopenharmony_ci You should have received a copy of the GNU General Public License 3562306a36Sopenharmony_ci along with this program; if not, write to the Free Software 3662306a36Sopenharmony_ci Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 3762306a36Sopenharmony_ci 3862306a36Sopenharmony_ci*/ 3962306a36Sopenharmony_ci 4062306a36Sopenharmony_ci/* 4162306a36Sopenharmony_ci History of this driver (Steven Toth): 4262306a36Sopenharmony_ci I was given a public release of a linux driver that included 4362306a36Sopenharmony_ci support for the MaxLinear MXL5005S silicon tuner. Analysis of 4462306a36Sopenharmony_ci the tuner driver showed clearly three things. 4562306a36Sopenharmony_ci 4662306a36Sopenharmony_ci 1. The tuner driver didn't support the LinuxTV tuner API 4762306a36Sopenharmony_ci so the code Realtek added had to be removed. 4862306a36Sopenharmony_ci 4962306a36Sopenharmony_ci 2. A significant amount of the driver is reference driver code 5062306a36Sopenharmony_ci from MaxLinear, I felt it was important to identify and 5162306a36Sopenharmony_ci preserve this. 5262306a36Sopenharmony_ci 5362306a36Sopenharmony_ci 3. New code has to be added to interface correctly with the 5462306a36Sopenharmony_ci LinuxTV API, as a regular kernel module. 5562306a36Sopenharmony_ci 5662306a36Sopenharmony_ci Other than the reference driver enum's, I've clearly marked 5762306a36Sopenharmony_ci sections of the code and retained the copyright of the 5862306a36Sopenharmony_ci respective owners. 5962306a36Sopenharmony_ci*/ 6062306a36Sopenharmony_ci#include <linux/kernel.h> 6162306a36Sopenharmony_ci#include <linux/init.h> 6262306a36Sopenharmony_ci#include <linux/module.h> 6362306a36Sopenharmony_ci#include <linux/string.h> 6462306a36Sopenharmony_ci#include <linux/slab.h> 6562306a36Sopenharmony_ci#include <linux/delay.h> 6662306a36Sopenharmony_ci#include <media/dvb_frontend.h> 6762306a36Sopenharmony_ci#include "mxl5005s.h" 6862306a36Sopenharmony_ci 6962306a36Sopenharmony_cistatic int debug; 7062306a36Sopenharmony_ci 7162306a36Sopenharmony_ci#define dprintk(level, arg...) do { \ 7262306a36Sopenharmony_ci if (level <= debug) \ 7362306a36Sopenharmony_ci printk(arg); \ 7462306a36Sopenharmony_ci } while (0) 7562306a36Sopenharmony_ci 7662306a36Sopenharmony_ci#define TUNER_REGS_NUM 104 7762306a36Sopenharmony_ci#define INITCTRL_NUM 40 7862306a36Sopenharmony_ci 7962306a36Sopenharmony_ci#ifdef _MXL_PRODUCTION 8062306a36Sopenharmony_ci#define CHCTRL_NUM 39 8162306a36Sopenharmony_ci#else 8262306a36Sopenharmony_ci#define CHCTRL_NUM 36 8362306a36Sopenharmony_ci#endif 8462306a36Sopenharmony_ci 8562306a36Sopenharmony_ci#define MXLCTRL_NUM 189 8662306a36Sopenharmony_ci#define MASTER_CONTROL_ADDR 9 8762306a36Sopenharmony_ci 8862306a36Sopenharmony_ci/* Enumeration of Master Control Register State */ 8962306a36Sopenharmony_cienum master_control_state { 9062306a36Sopenharmony_ci MC_LOAD_START = 1, 9162306a36Sopenharmony_ci MC_POWER_DOWN, 9262306a36Sopenharmony_ci MC_SYNTH_RESET, 9362306a36Sopenharmony_ci MC_SEQ_OFF 9462306a36Sopenharmony_ci}; 9562306a36Sopenharmony_ci 9662306a36Sopenharmony_ci/* Enumeration of MXL5005 Tuner Modulation Type */ 9762306a36Sopenharmony_cienum { 9862306a36Sopenharmony_ci MXL_DEFAULT_MODULATION = 0, 9962306a36Sopenharmony_ci MXL_DVBT, 10062306a36Sopenharmony_ci MXL_ATSC, 10162306a36Sopenharmony_ci MXL_QAM, 10262306a36Sopenharmony_ci MXL_ANALOG_CABLE, 10362306a36Sopenharmony_ci MXL_ANALOG_OTA 10462306a36Sopenharmony_ci}; 10562306a36Sopenharmony_ci 10662306a36Sopenharmony_ci/* MXL5005 Tuner Register Struct */ 10762306a36Sopenharmony_cistruct TunerReg { 10862306a36Sopenharmony_ci u16 Reg_Num; /* Tuner Register Address */ 10962306a36Sopenharmony_ci u16 Reg_Val; /* Current sw programmed value waiting to be written */ 11062306a36Sopenharmony_ci}; 11162306a36Sopenharmony_ci 11262306a36Sopenharmony_cienum { 11362306a36Sopenharmony_ci /* Initialization Control Names */ 11462306a36Sopenharmony_ci DN_IQTN_AMP_CUT = 1, /* 1 */ 11562306a36Sopenharmony_ci BB_MODE, /* 2 */ 11662306a36Sopenharmony_ci BB_BUF, /* 3 */ 11762306a36Sopenharmony_ci BB_BUF_OA, /* 4 */ 11862306a36Sopenharmony_ci BB_ALPF_BANDSELECT, /* 5 */ 11962306a36Sopenharmony_ci BB_IQSWAP, /* 6 */ 12062306a36Sopenharmony_ci BB_DLPF_BANDSEL, /* 7 */ 12162306a36Sopenharmony_ci RFSYN_CHP_GAIN, /* 8 */ 12262306a36Sopenharmony_ci RFSYN_EN_CHP_HIGAIN, /* 9 */ 12362306a36Sopenharmony_ci AGC_IF, /* 10 */ 12462306a36Sopenharmony_ci AGC_RF, /* 11 */ 12562306a36Sopenharmony_ci IF_DIVVAL, /* 12 */ 12662306a36Sopenharmony_ci IF_VCO_BIAS, /* 13 */ 12762306a36Sopenharmony_ci CHCAL_INT_MOD_IF, /* 14 */ 12862306a36Sopenharmony_ci CHCAL_FRAC_MOD_IF, /* 15 */ 12962306a36Sopenharmony_ci DRV_RES_SEL, /* 16 */ 13062306a36Sopenharmony_ci I_DRIVER, /* 17 */ 13162306a36Sopenharmony_ci EN_AAF, /* 18 */ 13262306a36Sopenharmony_ci EN_3P, /* 19 */ 13362306a36Sopenharmony_ci EN_AUX_3P, /* 20 */ 13462306a36Sopenharmony_ci SEL_AAF_BAND, /* 21 */ 13562306a36Sopenharmony_ci SEQ_ENCLK16_CLK_OUT, /* 22 */ 13662306a36Sopenharmony_ci SEQ_SEL4_16B, /* 23 */ 13762306a36Sopenharmony_ci XTAL_CAPSELECT, /* 24 */ 13862306a36Sopenharmony_ci IF_SEL_DBL, /* 25 */ 13962306a36Sopenharmony_ci RFSYN_R_DIV, /* 26 */ 14062306a36Sopenharmony_ci SEQ_EXTSYNTHCALIF, /* 27 */ 14162306a36Sopenharmony_ci SEQ_EXTDCCAL, /* 28 */ 14262306a36Sopenharmony_ci AGC_EN_RSSI, /* 29 */ 14362306a36Sopenharmony_ci RFA_ENCLKRFAGC, /* 30 */ 14462306a36Sopenharmony_ci RFA_RSSI_REFH, /* 31 */ 14562306a36Sopenharmony_ci RFA_RSSI_REF, /* 32 */ 14662306a36Sopenharmony_ci RFA_RSSI_REFL, /* 33 */ 14762306a36Sopenharmony_ci RFA_FLR, /* 34 */ 14862306a36Sopenharmony_ci RFA_CEIL, /* 35 */ 14962306a36Sopenharmony_ci SEQ_EXTIQFSMPULSE, /* 36 */ 15062306a36Sopenharmony_ci OVERRIDE_1, /* 37 */ 15162306a36Sopenharmony_ci BB_INITSTATE_DLPF_TUNE, /* 38 */ 15262306a36Sopenharmony_ci TG_R_DIV, /* 39 */ 15362306a36Sopenharmony_ci EN_CHP_LIN_B, /* 40 */ 15462306a36Sopenharmony_ci 15562306a36Sopenharmony_ci /* Channel Change Control Names */ 15662306a36Sopenharmony_ci DN_POLY = 51, /* 51 */ 15762306a36Sopenharmony_ci DN_RFGAIN, /* 52 */ 15862306a36Sopenharmony_ci DN_CAP_RFLPF, /* 53 */ 15962306a36Sopenharmony_ci DN_EN_VHFUHFBAR, /* 54 */ 16062306a36Sopenharmony_ci DN_GAIN_ADJUST, /* 55 */ 16162306a36Sopenharmony_ci DN_IQTNBUF_AMP, /* 56 */ 16262306a36Sopenharmony_ci DN_IQTNGNBFBIAS_BST, /* 57 */ 16362306a36Sopenharmony_ci RFSYN_EN_OUTMUX, /* 58 */ 16462306a36Sopenharmony_ci RFSYN_SEL_VCO_OUT, /* 59 */ 16562306a36Sopenharmony_ci RFSYN_SEL_VCO_HI, /* 60 */ 16662306a36Sopenharmony_ci RFSYN_SEL_DIVM, /* 61 */ 16762306a36Sopenharmony_ci RFSYN_RF_DIV_BIAS, /* 62 */ 16862306a36Sopenharmony_ci DN_SEL_FREQ, /* 63 */ 16962306a36Sopenharmony_ci RFSYN_VCO_BIAS, /* 64 */ 17062306a36Sopenharmony_ci CHCAL_INT_MOD_RF, /* 65 */ 17162306a36Sopenharmony_ci CHCAL_FRAC_MOD_RF, /* 66 */ 17262306a36Sopenharmony_ci RFSYN_LPF_R, /* 67 */ 17362306a36Sopenharmony_ci CHCAL_EN_INT_RF, /* 68 */ 17462306a36Sopenharmony_ci TG_LO_DIVVAL, /* 69 */ 17562306a36Sopenharmony_ci TG_LO_SELVAL, /* 70 */ 17662306a36Sopenharmony_ci TG_DIV_VAL, /* 71 */ 17762306a36Sopenharmony_ci TG_VCO_BIAS, /* 72 */ 17862306a36Sopenharmony_ci SEQ_EXTPOWERUP, /* 73 */ 17962306a36Sopenharmony_ci OVERRIDE_2, /* 74 */ 18062306a36Sopenharmony_ci OVERRIDE_3, /* 75 */ 18162306a36Sopenharmony_ci OVERRIDE_4, /* 76 */ 18262306a36Sopenharmony_ci SEQ_FSM_PULSE, /* 77 */ 18362306a36Sopenharmony_ci GPIO_4B, /* 78 */ 18462306a36Sopenharmony_ci GPIO_3B, /* 79 */ 18562306a36Sopenharmony_ci GPIO_4, /* 80 */ 18662306a36Sopenharmony_ci GPIO_3, /* 81 */ 18762306a36Sopenharmony_ci GPIO_1B, /* 82 */ 18862306a36Sopenharmony_ci DAC_A_ENABLE, /* 83 */ 18962306a36Sopenharmony_ci DAC_B_ENABLE, /* 84 */ 19062306a36Sopenharmony_ci DAC_DIN_A, /* 85 */ 19162306a36Sopenharmony_ci DAC_DIN_B, /* 86 */ 19262306a36Sopenharmony_ci#ifdef _MXL_PRODUCTION 19362306a36Sopenharmony_ci RFSYN_EN_DIV, /* 87 */ 19462306a36Sopenharmony_ci RFSYN_DIVM, /* 88 */ 19562306a36Sopenharmony_ci DN_BYPASS_AGC_I2C /* 89 */ 19662306a36Sopenharmony_ci#endif 19762306a36Sopenharmony_ci}; 19862306a36Sopenharmony_ci 19962306a36Sopenharmony_ci/* 20062306a36Sopenharmony_ci * The following context is source code provided by MaxLinear. 20162306a36Sopenharmony_ci * MaxLinear source code - Common_MXL.h (?) 20262306a36Sopenharmony_ci */ 20362306a36Sopenharmony_ci 20462306a36Sopenharmony_ci/* Constants */ 20562306a36Sopenharmony_ci#define MXL5005S_REG_WRITING_TABLE_LEN_MAX 104 20662306a36Sopenharmony_ci#define MXL5005S_LATCH_BYTE 0xfe 20762306a36Sopenharmony_ci 20862306a36Sopenharmony_ci/* Register address, MSB, and LSB */ 20962306a36Sopenharmony_ci#define MXL5005S_BB_IQSWAP_ADDR 59 21062306a36Sopenharmony_ci#define MXL5005S_BB_IQSWAP_MSB 0 21162306a36Sopenharmony_ci#define MXL5005S_BB_IQSWAP_LSB 0 21262306a36Sopenharmony_ci 21362306a36Sopenharmony_ci#define MXL5005S_BB_DLPF_BANDSEL_ADDR 53 21462306a36Sopenharmony_ci#define MXL5005S_BB_DLPF_BANDSEL_MSB 4 21562306a36Sopenharmony_ci#define MXL5005S_BB_DLPF_BANDSEL_LSB 3 21662306a36Sopenharmony_ci 21762306a36Sopenharmony_ci/* Standard modes */ 21862306a36Sopenharmony_cienum { 21962306a36Sopenharmony_ci MXL5005S_STANDARD_DVBT, 22062306a36Sopenharmony_ci MXL5005S_STANDARD_ATSC, 22162306a36Sopenharmony_ci}; 22262306a36Sopenharmony_ci#define MXL5005S_STANDARD_MODE_NUM 2 22362306a36Sopenharmony_ci 22462306a36Sopenharmony_ci/* Bandwidth modes */ 22562306a36Sopenharmony_cienum { 22662306a36Sopenharmony_ci MXL5005S_BANDWIDTH_6MHZ = 6000000, 22762306a36Sopenharmony_ci MXL5005S_BANDWIDTH_7MHZ = 7000000, 22862306a36Sopenharmony_ci MXL5005S_BANDWIDTH_8MHZ = 8000000, 22962306a36Sopenharmony_ci}; 23062306a36Sopenharmony_ci#define MXL5005S_BANDWIDTH_MODE_NUM 3 23162306a36Sopenharmony_ci 23262306a36Sopenharmony_ci/* MXL5005 Tuner Control Struct */ 23362306a36Sopenharmony_cistruct TunerControl { 23462306a36Sopenharmony_ci u16 Ctrl_Num; /* Control Number */ 23562306a36Sopenharmony_ci u16 size; /* Number of bits to represent Value */ 23662306a36Sopenharmony_ci u16 addr[25]; /* Array of Tuner Register Address for each bit pos */ 23762306a36Sopenharmony_ci u16 bit[25]; /* Array of bit pos in Reg Addr for each bit pos */ 23862306a36Sopenharmony_ci u16 val[25]; /* Binary representation of Value */ 23962306a36Sopenharmony_ci}; 24062306a36Sopenharmony_ci 24162306a36Sopenharmony_ci/* MXL5005 Tuner Struct */ 24262306a36Sopenharmony_cistruct mxl5005s_state { 24362306a36Sopenharmony_ci u8 Mode; /* 0: Analog Mode ; 1: Digital Mode */ 24462306a36Sopenharmony_ci u8 IF_Mode; /* for Analog Mode, 0: zero IF; 1: low IF */ 24562306a36Sopenharmony_ci u32 Chan_Bandwidth; /* filter channel bandwidth (6, 7, 8) */ 24662306a36Sopenharmony_ci u32 IF_OUT; /* Desired IF Out Frequency */ 24762306a36Sopenharmony_ci u16 IF_OUT_LOAD; /* IF Out Load Resistor (200/300 Ohms) */ 24862306a36Sopenharmony_ci u32 RF_IN; /* RF Input Frequency */ 24962306a36Sopenharmony_ci u32 Fxtal; /* XTAL Frequency */ 25062306a36Sopenharmony_ci u8 AGC_Mode; /* AGC Mode 0: Dual AGC; 1: Single AGC */ 25162306a36Sopenharmony_ci u16 TOP; /* Value: take over point */ 25262306a36Sopenharmony_ci u8 CLOCK_OUT; /* 0: turn off clk out; 1: turn on clock out */ 25362306a36Sopenharmony_ci u8 DIV_OUT; /* 4MHz or 16MHz */ 25462306a36Sopenharmony_ci u8 CAPSELECT; /* 0: disable On-Chip pulling cap; 1: enable */ 25562306a36Sopenharmony_ci u8 EN_RSSI; /* 0: disable RSSI; 1: enable RSSI */ 25662306a36Sopenharmony_ci 25762306a36Sopenharmony_ci /* Modulation Type; */ 25862306a36Sopenharmony_ci /* 0 - Default; 1 - DVB-T; 2 - ATSC; 3 - QAM; 4 - Analog Cable */ 25962306a36Sopenharmony_ci u8 Mod_Type; 26062306a36Sopenharmony_ci 26162306a36Sopenharmony_ci /* Tracking Filter Type */ 26262306a36Sopenharmony_ci /* 0 - Default; 1 - Off; 2 - Type C; 3 - Type C-H */ 26362306a36Sopenharmony_ci u8 TF_Type; 26462306a36Sopenharmony_ci 26562306a36Sopenharmony_ci /* Calculated Settings */ 26662306a36Sopenharmony_ci u32 RF_LO; /* Synth RF LO Frequency */ 26762306a36Sopenharmony_ci u32 IF_LO; /* Synth IF LO Frequency */ 26862306a36Sopenharmony_ci u32 TG_LO; /* Synth TG_LO Frequency */ 26962306a36Sopenharmony_ci 27062306a36Sopenharmony_ci /* Pointers to ControlName Arrays */ 27162306a36Sopenharmony_ci u16 Init_Ctrl_Num; /* Number of INIT Control Names */ 27262306a36Sopenharmony_ci struct TunerControl 27362306a36Sopenharmony_ci Init_Ctrl[INITCTRL_NUM]; /* INIT Control Names Array Pointer */ 27462306a36Sopenharmony_ci 27562306a36Sopenharmony_ci u16 CH_Ctrl_Num; /* Number of CH Control Names */ 27662306a36Sopenharmony_ci struct TunerControl 27762306a36Sopenharmony_ci CH_Ctrl[CHCTRL_NUM]; /* CH Control Name Array Pointer */ 27862306a36Sopenharmony_ci 27962306a36Sopenharmony_ci u16 MXL_Ctrl_Num; /* Number of MXL Control Names */ 28062306a36Sopenharmony_ci struct TunerControl 28162306a36Sopenharmony_ci MXL_Ctrl[MXLCTRL_NUM]; /* MXL Control Name Array Pointer */ 28262306a36Sopenharmony_ci 28362306a36Sopenharmony_ci /* Pointer to Tuner Register Array */ 28462306a36Sopenharmony_ci u16 TunerRegs_Num; /* Number of Tuner Registers */ 28562306a36Sopenharmony_ci struct TunerReg 28662306a36Sopenharmony_ci TunerRegs[TUNER_REGS_NUM]; /* Tuner Register Array Pointer */ 28762306a36Sopenharmony_ci 28862306a36Sopenharmony_ci /* Linux driver framework specific */ 28962306a36Sopenharmony_ci struct mxl5005s_config *config; 29062306a36Sopenharmony_ci struct dvb_frontend *frontend; 29162306a36Sopenharmony_ci struct i2c_adapter *i2c; 29262306a36Sopenharmony_ci 29362306a36Sopenharmony_ci /* Cache values */ 29462306a36Sopenharmony_ci u32 current_mode; 29562306a36Sopenharmony_ci 29662306a36Sopenharmony_ci}; 29762306a36Sopenharmony_ci 29862306a36Sopenharmony_cistatic u16 MXL_GetMasterControl(u8 *MasterReg, int state); 29962306a36Sopenharmony_cistatic u16 MXL_ControlWrite(struct dvb_frontend *fe, u16 ControlNum, u32 value); 30062306a36Sopenharmony_cistatic u16 MXL_ControlRead(struct dvb_frontend *fe, u16 controlNum, u32 *value); 30162306a36Sopenharmony_cistatic void MXL_RegWriteBit(struct dvb_frontend *fe, u8 address, u8 bit, 30262306a36Sopenharmony_ci u8 bitVal); 30362306a36Sopenharmony_cistatic u16 MXL_GetCHRegister(struct dvb_frontend *fe, u8 *RegNum, 30462306a36Sopenharmony_ci u8 *RegVal, int *count); 30562306a36Sopenharmony_cistatic u32 MXL_Ceiling(u32 value, u32 resolution); 30662306a36Sopenharmony_cistatic u16 MXL_RegRead(struct dvb_frontend *fe, u8 RegNum, u8 *RegVal); 30762306a36Sopenharmony_cistatic u16 MXL_ControlWrite_Group(struct dvb_frontend *fe, u16 controlNum, 30862306a36Sopenharmony_ci u32 value, u16 controlGroup); 30962306a36Sopenharmony_cistatic u16 MXL_SetGPIO(struct dvb_frontend *fe, u8 GPIO_Num, u8 GPIO_Val); 31062306a36Sopenharmony_cistatic u16 MXL_GetInitRegister(struct dvb_frontend *fe, u8 *RegNum, 31162306a36Sopenharmony_ci u8 *RegVal, int *count); 31262306a36Sopenharmony_cistatic u16 MXL_TuneRF(struct dvb_frontend *fe, u32 RF_Freq); 31362306a36Sopenharmony_cistatic void MXL_SynthIFLO_Calc(struct dvb_frontend *fe); 31462306a36Sopenharmony_cistatic void MXL_SynthRFTGLO_Calc(struct dvb_frontend *fe); 31562306a36Sopenharmony_cistatic u16 MXL_GetCHRegister_ZeroIF(struct dvb_frontend *fe, u8 *RegNum, 31662306a36Sopenharmony_ci u8 *RegVal, int *count); 31762306a36Sopenharmony_cistatic int mxl5005s_writeregs(struct dvb_frontend *fe, u8 *addrtable, 31862306a36Sopenharmony_ci u8 *datatable, u8 len); 31962306a36Sopenharmony_cistatic u16 MXL_IFSynthInit(struct dvb_frontend *fe); 32062306a36Sopenharmony_cistatic int mxl5005s_AssignTunerMode(struct dvb_frontend *fe, u32 mod_type, 32162306a36Sopenharmony_ci u32 bandwidth); 32262306a36Sopenharmony_cistatic int mxl5005s_reconfigure(struct dvb_frontend *fe, u32 mod_type, 32362306a36Sopenharmony_ci u32 bandwidth); 32462306a36Sopenharmony_ci 32562306a36Sopenharmony_ci/* ---------------------------------------------------------------- 32662306a36Sopenharmony_ci * Begin: Custom code salvaged from the Realtek driver. 32762306a36Sopenharmony_ci * Copyright (C) 2008 Realtek 32862306a36Sopenharmony_ci * Copyright (C) 2008 Jan Hoogenraad 32962306a36Sopenharmony_ci * This code is placed under the terms of the GNU General Public License 33062306a36Sopenharmony_ci * 33162306a36Sopenharmony_ci * Released by Realtek under GPLv2. 33262306a36Sopenharmony_ci * Thanks to Realtek for a lot of support we received ! 33362306a36Sopenharmony_ci * 33462306a36Sopenharmony_ci * Revision: 080314 - original version 33562306a36Sopenharmony_ci */ 33662306a36Sopenharmony_ci 33762306a36Sopenharmony_cistatic int mxl5005s_SetRfFreqHz(struct dvb_frontend *fe, unsigned long RfFreqHz) 33862306a36Sopenharmony_ci{ 33962306a36Sopenharmony_ci struct mxl5005s_state *state = fe->tuner_priv; 34062306a36Sopenharmony_ci unsigned char AddrTable[MXL5005S_REG_WRITING_TABLE_LEN_MAX]; 34162306a36Sopenharmony_ci unsigned char ByteTable[MXL5005S_REG_WRITING_TABLE_LEN_MAX]; 34262306a36Sopenharmony_ci int TableLen; 34362306a36Sopenharmony_ci 34462306a36Sopenharmony_ci u32 IfDivval = 0; 34562306a36Sopenharmony_ci unsigned char MasterControlByte; 34662306a36Sopenharmony_ci 34762306a36Sopenharmony_ci dprintk(1, "%s() freq=%ld\n", __func__, RfFreqHz); 34862306a36Sopenharmony_ci 34962306a36Sopenharmony_ci /* Set MxL5005S tuner RF frequency according to example code. */ 35062306a36Sopenharmony_ci 35162306a36Sopenharmony_ci /* Tuner RF frequency setting stage 0 */ 35262306a36Sopenharmony_ci MXL_GetMasterControl(ByteTable, MC_SYNTH_RESET); 35362306a36Sopenharmony_ci AddrTable[0] = MASTER_CONTROL_ADDR; 35462306a36Sopenharmony_ci ByteTable[0] |= state->config->AgcMasterByte; 35562306a36Sopenharmony_ci 35662306a36Sopenharmony_ci mxl5005s_writeregs(fe, AddrTable, ByteTable, 1); 35762306a36Sopenharmony_ci 35862306a36Sopenharmony_ci /* Tuner RF frequency setting stage 1 */ 35962306a36Sopenharmony_ci MXL_TuneRF(fe, RfFreqHz); 36062306a36Sopenharmony_ci 36162306a36Sopenharmony_ci MXL_ControlRead(fe, IF_DIVVAL, &IfDivval); 36262306a36Sopenharmony_ci 36362306a36Sopenharmony_ci MXL_ControlWrite(fe, SEQ_FSM_PULSE, 0); 36462306a36Sopenharmony_ci MXL_ControlWrite(fe, SEQ_EXTPOWERUP, 1); 36562306a36Sopenharmony_ci MXL_ControlWrite(fe, IF_DIVVAL, 8); 36662306a36Sopenharmony_ci MXL_GetCHRegister(fe, AddrTable, ByteTable, &TableLen); 36762306a36Sopenharmony_ci 36862306a36Sopenharmony_ci MXL_GetMasterControl(&MasterControlByte, MC_LOAD_START); 36962306a36Sopenharmony_ci AddrTable[TableLen] = MASTER_CONTROL_ADDR ; 37062306a36Sopenharmony_ci ByteTable[TableLen] = MasterControlByte | 37162306a36Sopenharmony_ci state->config->AgcMasterByte; 37262306a36Sopenharmony_ci TableLen += 1; 37362306a36Sopenharmony_ci 37462306a36Sopenharmony_ci mxl5005s_writeregs(fe, AddrTable, ByteTable, TableLen); 37562306a36Sopenharmony_ci 37662306a36Sopenharmony_ci /* Wait 30 ms. */ 37762306a36Sopenharmony_ci msleep(150); 37862306a36Sopenharmony_ci 37962306a36Sopenharmony_ci /* Tuner RF frequency setting stage 2 */ 38062306a36Sopenharmony_ci MXL_ControlWrite(fe, SEQ_FSM_PULSE, 1); 38162306a36Sopenharmony_ci MXL_ControlWrite(fe, IF_DIVVAL, IfDivval); 38262306a36Sopenharmony_ci MXL_GetCHRegister_ZeroIF(fe, AddrTable, ByteTable, &TableLen); 38362306a36Sopenharmony_ci 38462306a36Sopenharmony_ci MXL_GetMasterControl(&MasterControlByte, MC_LOAD_START); 38562306a36Sopenharmony_ci AddrTable[TableLen] = MASTER_CONTROL_ADDR ; 38662306a36Sopenharmony_ci ByteTable[TableLen] = MasterControlByte | 38762306a36Sopenharmony_ci state->config->AgcMasterByte ; 38862306a36Sopenharmony_ci TableLen += 1; 38962306a36Sopenharmony_ci 39062306a36Sopenharmony_ci mxl5005s_writeregs(fe, AddrTable, ByteTable, TableLen); 39162306a36Sopenharmony_ci 39262306a36Sopenharmony_ci msleep(100); 39362306a36Sopenharmony_ci 39462306a36Sopenharmony_ci return 0; 39562306a36Sopenharmony_ci} 39662306a36Sopenharmony_ci/* End: Custom code taken from the Realtek driver */ 39762306a36Sopenharmony_ci 39862306a36Sopenharmony_ci/* ---------------------------------------------------------------- 39962306a36Sopenharmony_ci * Begin: Reference driver code found in the Realtek driver. 40062306a36Sopenharmony_ci * Copyright (C) 2008 MaxLinear 40162306a36Sopenharmony_ci */ 40262306a36Sopenharmony_cistatic u16 MXL5005_RegisterInit(struct dvb_frontend *fe) 40362306a36Sopenharmony_ci{ 40462306a36Sopenharmony_ci struct mxl5005s_state *state = fe->tuner_priv; 40562306a36Sopenharmony_ci state->TunerRegs_Num = TUNER_REGS_NUM ; 40662306a36Sopenharmony_ci 40762306a36Sopenharmony_ci state->TunerRegs[0].Reg_Num = 9 ; 40862306a36Sopenharmony_ci state->TunerRegs[0].Reg_Val = 0x40 ; 40962306a36Sopenharmony_ci 41062306a36Sopenharmony_ci state->TunerRegs[1].Reg_Num = 11 ; 41162306a36Sopenharmony_ci state->TunerRegs[1].Reg_Val = 0x19 ; 41262306a36Sopenharmony_ci 41362306a36Sopenharmony_ci state->TunerRegs[2].Reg_Num = 12 ; 41462306a36Sopenharmony_ci state->TunerRegs[2].Reg_Val = 0x60 ; 41562306a36Sopenharmony_ci 41662306a36Sopenharmony_ci state->TunerRegs[3].Reg_Num = 13 ; 41762306a36Sopenharmony_ci state->TunerRegs[3].Reg_Val = 0x00 ; 41862306a36Sopenharmony_ci 41962306a36Sopenharmony_ci state->TunerRegs[4].Reg_Num = 14 ; 42062306a36Sopenharmony_ci state->TunerRegs[4].Reg_Val = 0x00 ; 42162306a36Sopenharmony_ci 42262306a36Sopenharmony_ci state->TunerRegs[5].Reg_Num = 15 ; 42362306a36Sopenharmony_ci state->TunerRegs[5].Reg_Val = 0xC0 ; 42462306a36Sopenharmony_ci 42562306a36Sopenharmony_ci state->TunerRegs[6].Reg_Num = 16 ; 42662306a36Sopenharmony_ci state->TunerRegs[6].Reg_Val = 0x00 ; 42762306a36Sopenharmony_ci 42862306a36Sopenharmony_ci state->TunerRegs[7].Reg_Num = 17 ; 42962306a36Sopenharmony_ci state->TunerRegs[7].Reg_Val = 0x00 ; 43062306a36Sopenharmony_ci 43162306a36Sopenharmony_ci state->TunerRegs[8].Reg_Num = 18 ; 43262306a36Sopenharmony_ci state->TunerRegs[8].Reg_Val = 0x00 ; 43362306a36Sopenharmony_ci 43462306a36Sopenharmony_ci state->TunerRegs[9].Reg_Num = 19 ; 43562306a36Sopenharmony_ci state->TunerRegs[9].Reg_Val = 0x34 ; 43662306a36Sopenharmony_ci 43762306a36Sopenharmony_ci state->TunerRegs[10].Reg_Num = 21 ; 43862306a36Sopenharmony_ci state->TunerRegs[10].Reg_Val = 0x00 ; 43962306a36Sopenharmony_ci 44062306a36Sopenharmony_ci state->TunerRegs[11].Reg_Num = 22 ; 44162306a36Sopenharmony_ci state->TunerRegs[11].Reg_Val = 0x6B ; 44262306a36Sopenharmony_ci 44362306a36Sopenharmony_ci state->TunerRegs[12].Reg_Num = 23 ; 44462306a36Sopenharmony_ci state->TunerRegs[12].Reg_Val = 0x35 ; 44562306a36Sopenharmony_ci 44662306a36Sopenharmony_ci state->TunerRegs[13].Reg_Num = 24 ; 44762306a36Sopenharmony_ci state->TunerRegs[13].Reg_Val = 0x70 ; 44862306a36Sopenharmony_ci 44962306a36Sopenharmony_ci state->TunerRegs[14].Reg_Num = 25 ; 45062306a36Sopenharmony_ci state->TunerRegs[14].Reg_Val = 0x3E ; 45162306a36Sopenharmony_ci 45262306a36Sopenharmony_ci state->TunerRegs[15].Reg_Num = 26 ; 45362306a36Sopenharmony_ci state->TunerRegs[15].Reg_Val = 0x82 ; 45462306a36Sopenharmony_ci 45562306a36Sopenharmony_ci state->TunerRegs[16].Reg_Num = 31 ; 45662306a36Sopenharmony_ci state->TunerRegs[16].Reg_Val = 0x00 ; 45762306a36Sopenharmony_ci 45862306a36Sopenharmony_ci state->TunerRegs[17].Reg_Num = 32 ; 45962306a36Sopenharmony_ci state->TunerRegs[17].Reg_Val = 0x40 ; 46062306a36Sopenharmony_ci 46162306a36Sopenharmony_ci state->TunerRegs[18].Reg_Num = 33 ; 46262306a36Sopenharmony_ci state->TunerRegs[18].Reg_Val = 0x53 ; 46362306a36Sopenharmony_ci 46462306a36Sopenharmony_ci state->TunerRegs[19].Reg_Num = 34 ; 46562306a36Sopenharmony_ci state->TunerRegs[19].Reg_Val = 0x81 ; 46662306a36Sopenharmony_ci 46762306a36Sopenharmony_ci state->TunerRegs[20].Reg_Num = 35 ; 46862306a36Sopenharmony_ci state->TunerRegs[20].Reg_Val = 0xC9 ; 46962306a36Sopenharmony_ci 47062306a36Sopenharmony_ci state->TunerRegs[21].Reg_Num = 36 ; 47162306a36Sopenharmony_ci state->TunerRegs[21].Reg_Val = 0x01 ; 47262306a36Sopenharmony_ci 47362306a36Sopenharmony_ci state->TunerRegs[22].Reg_Num = 37 ; 47462306a36Sopenharmony_ci state->TunerRegs[22].Reg_Val = 0x00 ; 47562306a36Sopenharmony_ci 47662306a36Sopenharmony_ci state->TunerRegs[23].Reg_Num = 41 ; 47762306a36Sopenharmony_ci state->TunerRegs[23].Reg_Val = 0x00 ; 47862306a36Sopenharmony_ci 47962306a36Sopenharmony_ci state->TunerRegs[24].Reg_Num = 42 ; 48062306a36Sopenharmony_ci state->TunerRegs[24].Reg_Val = 0xF8 ; 48162306a36Sopenharmony_ci 48262306a36Sopenharmony_ci state->TunerRegs[25].Reg_Num = 43 ; 48362306a36Sopenharmony_ci state->TunerRegs[25].Reg_Val = 0x43 ; 48462306a36Sopenharmony_ci 48562306a36Sopenharmony_ci state->TunerRegs[26].Reg_Num = 44 ; 48662306a36Sopenharmony_ci state->TunerRegs[26].Reg_Val = 0x20 ; 48762306a36Sopenharmony_ci 48862306a36Sopenharmony_ci state->TunerRegs[27].Reg_Num = 45 ; 48962306a36Sopenharmony_ci state->TunerRegs[27].Reg_Val = 0x80 ; 49062306a36Sopenharmony_ci 49162306a36Sopenharmony_ci state->TunerRegs[28].Reg_Num = 46 ; 49262306a36Sopenharmony_ci state->TunerRegs[28].Reg_Val = 0x88 ; 49362306a36Sopenharmony_ci 49462306a36Sopenharmony_ci state->TunerRegs[29].Reg_Num = 47 ; 49562306a36Sopenharmony_ci state->TunerRegs[29].Reg_Val = 0x86 ; 49662306a36Sopenharmony_ci 49762306a36Sopenharmony_ci state->TunerRegs[30].Reg_Num = 48 ; 49862306a36Sopenharmony_ci state->TunerRegs[30].Reg_Val = 0x00 ; 49962306a36Sopenharmony_ci 50062306a36Sopenharmony_ci state->TunerRegs[31].Reg_Num = 49 ; 50162306a36Sopenharmony_ci state->TunerRegs[31].Reg_Val = 0x00 ; 50262306a36Sopenharmony_ci 50362306a36Sopenharmony_ci state->TunerRegs[32].Reg_Num = 53 ; 50462306a36Sopenharmony_ci state->TunerRegs[32].Reg_Val = 0x94 ; 50562306a36Sopenharmony_ci 50662306a36Sopenharmony_ci state->TunerRegs[33].Reg_Num = 54 ; 50762306a36Sopenharmony_ci state->TunerRegs[33].Reg_Val = 0xFA ; 50862306a36Sopenharmony_ci 50962306a36Sopenharmony_ci state->TunerRegs[34].Reg_Num = 55 ; 51062306a36Sopenharmony_ci state->TunerRegs[34].Reg_Val = 0x92 ; 51162306a36Sopenharmony_ci 51262306a36Sopenharmony_ci state->TunerRegs[35].Reg_Num = 56 ; 51362306a36Sopenharmony_ci state->TunerRegs[35].Reg_Val = 0x80 ; 51462306a36Sopenharmony_ci 51562306a36Sopenharmony_ci state->TunerRegs[36].Reg_Num = 57 ; 51662306a36Sopenharmony_ci state->TunerRegs[36].Reg_Val = 0x41 ; 51762306a36Sopenharmony_ci 51862306a36Sopenharmony_ci state->TunerRegs[37].Reg_Num = 58 ; 51962306a36Sopenharmony_ci state->TunerRegs[37].Reg_Val = 0xDB ; 52062306a36Sopenharmony_ci 52162306a36Sopenharmony_ci state->TunerRegs[38].Reg_Num = 59 ; 52262306a36Sopenharmony_ci state->TunerRegs[38].Reg_Val = 0x00 ; 52362306a36Sopenharmony_ci 52462306a36Sopenharmony_ci state->TunerRegs[39].Reg_Num = 60 ; 52562306a36Sopenharmony_ci state->TunerRegs[39].Reg_Val = 0x00 ; 52662306a36Sopenharmony_ci 52762306a36Sopenharmony_ci state->TunerRegs[40].Reg_Num = 61 ; 52862306a36Sopenharmony_ci state->TunerRegs[40].Reg_Val = 0x00 ; 52962306a36Sopenharmony_ci 53062306a36Sopenharmony_ci state->TunerRegs[41].Reg_Num = 62 ; 53162306a36Sopenharmony_ci state->TunerRegs[41].Reg_Val = 0x00 ; 53262306a36Sopenharmony_ci 53362306a36Sopenharmony_ci state->TunerRegs[42].Reg_Num = 65 ; 53462306a36Sopenharmony_ci state->TunerRegs[42].Reg_Val = 0xF8 ; 53562306a36Sopenharmony_ci 53662306a36Sopenharmony_ci state->TunerRegs[43].Reg_Num = 66 ; 53762306a36Sopenharmony_ci state->TunerRegs[43].Reg_Val = 0xE4 ; 53862306a36Sopenharmony_ci 53962306a36Sopenharmony_ci state->TunerRegs[44].Reg_Num = 67 ; 54062306a36Sopenharmony_ci state->TunerRegs[44].Reg_Val = 0x90 ; 54162306a36Sopenharmony_ci 54262306a36Sopenharmony_ci state->TunerRegs[45].Reg_Num = 68 ; 54362306a36Sopenharmony_ci state->TunerRegs[45].Reg_Val = 0xC0 ; 54462306a36Sopenharmony_ci 54562306a36Sopenharmony_ci state->TunerRegs[46].Reg_Num = 69 ; 54662306a36Sopenharmony_ci state->TunerRegs[46].Reg_Val = 0x01 ; 54762306a36Sopenharmony_ci 54862306a36Sopenharmony_ci state->TunerRegs[47].Reg_Num = 70 ; 54962306a36Sopenharmony_ci state->TunerRegs[47].Reg_Val = 0x50 ; 55062306a36Sopenharmony_ci 55162306a36Sopenharmony_ci state->TunerRegs[48].Reg_Num = 71 ; 55262306a36Sopenharmony_ci state->TunerRegs[48].Reg_Val = 0x06 ; 55362306a36Sopenharmony_ci 55462306a36Sopenharmony_ci state->TunerRegs[49].Reg_Num = 72 ; 55562306a36Sopenharmony_ci state->TunerRegs[49].Reg_Val = 0x00 ; 55662306a36Sopenharmony_ci 55762306a36Sopenharmony_ci state->TunerRegs[50].Reg_Num = 73 ; 55862306a36Sopenharmony_ci state->TunerRegs[50].Reg_Val = 0x20 ; 55962306a36Sopenharmony_ci 56062306a36Sopenharmony_ci state->TunerRegs[51].Reg_Num = 76 ; 56162306a36Sopenharmony_ci state->TunerRegs[51].Reg_Val = 0xBB ; 56262306a36Sopenharmony_ci 56362306a36Sopenharmony_ci state->TunerRegs[52].Reg_Num = 77 ; 56462306a36Sopenharmony_ci state->TunerRegs[52].Reg_Val = 0x13 ; 56562306a36Sopenharmony_ci 56662306a36Sopenharmony_ci state->TunerRegs[53].Reg_Num = 81 ; 56762306a36Sopenharmony_ci state->TunerRegs[53].Reg_Val = 0x04 ; 56862306a36Sopenharmony_ci 56962306a36Sopenharmony_ci state->TunerRegs[54].Reg_Num = 82 ; 57062306a36Sopenharmony_ci state->TunerRegs[54].Reg_Val = 0x75 ; 57162306a36Sopenharmony_ci 57262306a36Sopenharmony_ci state->TunerRegs[55].Reg_Num = 83 ; 57362306a36Sopenharmony_ci state->TunerRegs[55].Reg_Val = 0x00 ; 57462306a36Sopenharmony_ci 57562306a36Sopenharmony_ci state->TunerRegs[56].Reg_Num = 84 ; 57662306a36Sopenharmony_ci state->TunerRegs[56].Reg_Val = 0x00 ; 57762306a36Sopenharmony_ci 57862306a36Sopenharmony_ci state->TunerRegs[57].Reg_Num = 85 ; 57962306a36Sopenharmony_ci state->TunerRegs[57].Reg_Val = 0x00 ; 58062306a36Sopenharmony_ci 58162306a36Sopenharmony_ci state->TunerRegs[58].Reg_Num = 91 ; 58262306a36Sopenharmony_ci state->TunerRegs[58].Reg_Val = 0x70 ; 58362306a36Sopenharmony_ci 58462306a36Sopenharmony_ci state->TunerRegs[59].Reg_Num = 92 ; 58562306a36Sopenharmony_ci state->TunerRegs[59].Reg_Val = 0x00 ; 58662306a36Sopenharmony_ci 58762306a36Sopenharmony_ci state->TunerRegs[60].Reg_Num = 93 ; 58862306a36Sopenharmony_ci state->TunerRegs[60].Reg_Val = 0x00 ; 58962306a36Sopenharmony_ci 59062306a36Sopenharmony_ci state->TunerRegs[61].Reg_Num = 94 ; 59162306a36Sopenharmony_ci state->TunerRegs[61].Reg_Val = 0x00 ; 59262306a36Sopenharmony_ci 59362306a36Sopenharmony_ci state->TunerRegs[62].Reg_Num = 95 ; 59462306a36Sopenharmony_ci state->TunerRegs[62].Reg_Val = 0x0C ; 59562306a36Sopenharmony_ci 59662306a36Sopenharmony_ci state->TunerRegs[63].Reg_Num = 96 ; 59762306a36Sopenharmony_ci state->TunerRegs[63].Reg_Val = 0x00 ; 59862306a36Sopenharmony_ci 59962306a36Sopenharmony_ci state->TunerRegs[64].Reg_Num = 97 ; 60062306a36Sopenharmony_ci state->TunerRegs[64].Reg_Val = 0x00 ; 60162306a36Sopenharmony_ci 60262306a36Sopenharmony_ci state->TunerRegs[65].Reg_Num = 98 ; 60362306a36Sopenharmony_ci state->TunerRegs[65].Reg_Val = 0xE2 ; 60462306a36Sopenharmony_ci 60562306a36Sopenharmony_ci state->TunerRegs[66].Reg_Num = 99 ; 60662306a36Sopenharmony_ci state->TunerRegs[66].Reg_Val = 0x00 ; 60762306a36Sopenharmony_ci 60862306a36Sopenharmony_ci state->TunerRegs[67].Reg_Num = 100 ; 60962306a36Sopenharmony_ci state->TunerRegs[67].Reg_Val = 0x00 ; 61062306a36Sopenharmony_ci 61162306a36Sopenharmony_ci state->TunerRegs[68].Reg_Num = 101 ; 61262306a36Sopenharmony_ci state->TunerRegs[68].Reg_Val = 0x12 ; 61362306a36Sopenharmony_ci 61462306a36Sopenharmony_ci state->TunerRegs[69].Reg_Num = 102 ; 61562306a36Sopenharmony_ci state->TunerRegs[69].Reg_Val = 0x80 ; 61662306a36Sopenharmony_ci 61762306a36Sopenharmony_ci state->TunerRegs[70].Reg_Num = 103 ; 61862306a36Sopenharmony_ci state->TunerRegs[70].Reg_Val = 0x32 ; 61962306a36Sopenharmony_ci 62062306a36Sopenharmony_ci state->TunerRegs[71].Reg_Num = 104 ; 62162306a36Sopenharmony_ci state->TunerRegs[71].Reg_Val = 0xB4 ; 62262306a36Sopenharmony_ci 62362306a36Sopenharmony_ci state->TunerRegs[72].Reg_Num = 105 ; 62462306a36Sopenharmony_ci state->TunerRegs[72].Reg_Val = 0x60 ; 62562306a36Sopenharmony_ci 62662306a36Sopenharmony_ci state->TunerRegs[73].Reg_Num = 106 ; 62762306a36Sopenharmony_ci state->TunerRegs[73].Reg_Val = 0x83 ; 62862306a36Sopenharmony_ci 62962306a36Sopenharmony_ci state->TunerRegs[74].Reg_Num = 107 ; 63062306a36Sopenharmony_ci state->TunerRegs[74].Reg_Val = 0x84 ; 63162306a36Sopenharmony_ci 63262306a36Sopenharmony_ci state->TunerRegs[75].Reg_Num = 108 ; 63362306a36Sopenharmony_ci state->TunerRegs[75].Reg_Val = 0x9C ; 63462306a36Sopenharmony_ci 63562306a36Sopenharmony_ci state->TunerRegs[76].Reg_Num = 109 ; 63662306a36Sopenharmony_ci state->TunerRegs[76].Reg_Val = 0x02 ; 63762306a36Sopenharmony_ci 63862306a36Sopenharmony_ci state->TunerRegs[77].Reg_Num = 110 ; 63962306a36Sopenharmony_ci state->TunerRegs[77].Reg_Val = 0x81 ; 64062306a36Sopenharmony_ci 64162306a36Sopenharmony_ci state->TunerRegs[78].Reg_Num = 111 ; 64262306a36Sopenharmony_ci state->TunerRegs[78].Reg_Val = 0xC0 ; 64362306a36Sopenharmony_ci 64462306a36Sopenharmony_ci state->TunerRegs[79].Reg_Num = 112 ; 64562306a36Sopenharmony_ci state->TunerRegs[79].Reg_Val = 0x10 ; 64662306a36Sopenharmony_ci 64762306a36Sopenharmony_ci state->TunerRegs[80].Reg_Num = 131 ; 64862306a36Sopenharmony_ci state->TunerRegs[80].Reg_Val = 0x8A ; 64962306a36Sopenharmony_ci 65062306a36Sopenharmony_ci state->TunerRegs[81].Reg_Num = 132 ; 65162306a36Sopenharmony_ci state->TunerRegs[81].Reg_Val = 0x10 ; 65262306a36Sopenharmony_ci 65362306a36Sopenharmony_ci state->TunerRegs[82].Reg_Num = 133 ; 65462306a36Sopenharmony_ci state->TunerRegs[82].Reg_Val = 0x24 ; 65562306a36Sopenharmony_ci 65662306a36Sopenharmony_ci state->TunerRegs[83].Reg_Num = 134 ; 65762306a36Sopenharmony_ci state->TunerRegs[83].Reg_Val = 0x00 ; 65862306a36Sopenharmony_ci 65962306a36Sopenharmony_ci state->TunerRegs[84].Reg_Num = 135 ; 66062306a36Sopenharmony_ci state->TunerRegs[84].Reg_Val = 0x00 ; 66162306a36Sopenharmony_ci 66262306a36Sopenharmony_ci state->TunerRegs[85].Reg_Num = 136 ; 66362306a36Sopenharmony_ci state->TunerRegs[85].Reg_Val = 0x7E ; 66462306a36Sopenharmony_ci 66562306a36Sopenharmony_ci state->TunerRegs[86].Reg_Num = 137 ; 66662306a36Sopenharmony_ci state->TunerRegs[86].Reg_Val = 0x40 ; 66762306a36Sopenharmony_ci 66862306a36Sopenharmony_ci state->TunerRegs[87].Reg_Num = 138 ; 66962306a36Sopenharmony_ci state->TunerRegs[87].Reg_Val = 0x38 ; 67062306a36Sopenharmony_ci 67162306a36Sopenharmony_ci state->TunerRegs[88].Reg_Num = 146 ; 67262306a36Sopenharmony_ci state->TunerRegs[88].Reg_Val = 0xF6 ; 67362306a36Sopenharmony_ci 67462306a36Sopenharmony_ci state->TunerRegs[89].Reg_Num = 147 ; 67562306a36Sopenharmony_ci state->TunerRegs[89].Reg_Val = 0x1A ; 67662306a36Sopenharmony_ci 67762306a36Sopenharmony_ci state->TunerRegs[90].Reg_Num = 148 ; 67862306a36Sopenharmony_ci state->TunerRegs[90].Reg_Val = 0x62 ; 67962306a36Sopenharmony_ci 68062306a36Sopenharmony_ci state->TunerRegs[91].Reg_Num = 149 ; 68162306a36Sopenharmony_ci state->TunerRegs[91].Reg_Val = 0x33 ; 68262306a36Sopenharmony_ci 68362306a36Sopenharmony_ci state->TunerRegs[92].Reg_Num = 150 ; 68462306a36Sopenharmony_ci state->TunerRegs[92].Reg_Val = 0x80 ; 68562306a36Sopenharmony_ci 68662306a36Sopenharmony_ci state->TunerRegs[93].Reg_Num = 156 ; 68762306a36Sopenharmony_ci state->TunerRegs[93].Reg_Val = 0x56 ; 68862306a36Sopenharmony_ci 68962306a36Sopenharmony_ci state->TunerRegs[94].Reg_Num = 157 ; 69062306a36Sopenharmony_ci state->TunerRegs[94].Reg_Val = 0x17 ; 69162306a36Sopenharmony_ci 69262306a36Sopenharmony_ci state->TunerRegs[95].Reg_Num = 158 ; 69362306a36Sopenharmony_ci state->TunerRegs[95].Reg_Val = 0xA9 ; 69462306a36Sopenharmony_ci 69562306a36Sopenharmony_ci state->TunerRegs[96].Reg_Num = 159 ; 69662306a36Sopenharmony_ci state->TunerRegs[96].Reg_Val = 0x00 ; 69762306a36Sopenharmony_ci 69862306a36Sopenharmony_ci state->TunerRegs[97].Reg_Num = 160 ; 69962306a36Sopenharmony_ci state->TunerRegs[97].Reg_Val = 0x00 ; 70062306a36Sopenharmony_ci 70162306a36Sopenharmony_ci state->TunerRegs[98].Reg_Num = 161 ; 70262306a36Sopenharmony_ci state->TunerRegs[98].Reg_Val = 0x00 ; 70362306a36Sopenharmony_ci 70462306a36Sopenharmony_ci state->TunerRegs[99].Reg_Num = 162 ; 70562306a36Sopenharmony_ci state->TunerRegs[99].Reg_Val = 0x40 ; 70662306a36Sopenharmony_ci 70762306a36Sopenharmony_ci state->TunerRegs[100].Reg_Num = 166 ; 70862306a36Sopenharmony_ci state->TunerRegs[100].Reg_Val = 0xAE ; 70962306a36Sopenharmony_ci 71062306a36Sopenharmony_ci state->TunerRegs[101].Reg_Num = 167 ; 71162306a36Sopenharmony_ci state->TunerRegs[101].Reg_Val = 0x1B ; 71262306a36Sopenharmony_ci 71362306a36Sopenharmony_ci state->TunerRegs[102].Reg_Num = 168 ; 71462306a36Sopenharmony_ci state->TunerRegs[102].Reg_Val = 0xF2 ; 71562306a36Sopenharmony_ci 71662306a36Sopenharmony_ci state->TunerRegs[103].Reg_Num = 195 ; 71762306a36Sopenharmony_ci state->TunerRegs[103].Reg_Val = 0x00 ; 71862306a36Sopenharmony_ci 71962306a36Sopenharmony_ci return 0 ; 72062306a36Sopenharmony_ci} 72162306a36Sopenharmony_ci 72262306a36Sopenharmony_cistatic u16 MXL5005_ControlInit(struct dvb_frontend *fe) 72362306a36Sopenharmony_ci{ 72462306a36Sopenharmony_ci struct mxl5005s_state *state = fe->tuner_priv; 72562306a36Sopenharmony_ci state->Init_Ctrl_Num = INITCTRL_NUM; 72662306a36Sopenharmony_ci 72762306a36Sopenharmony_ci state->Init_Ctrl[0].Ctrl_Num = DN_IQTN_AMP_CUT ; 72862306a36Sopenharmony_ci state->Init_Ctrl[0].size = 1 ; 72962306a36Sopenharmony_ci state->Init_Ctrl[0].addr[0] = 73; 73062306a36Sopenharmony_ci state->Init_Ctrl[0].bit[0] = 7; 73162306a36Sopenharmony_ci state->Init_Ctrl[0].val[0] = 0; 73262306a36Sopenharmony_ci 73362306a36Sopenharmony_ci state->Init_Ctrl[1].Ctrl_Num = BB_MODE ; 73462306a36Sopenharmony_ci state->Init_Ctrl[1].size = 1 ; 73562306a36Sopenharmony_ci state->Init_Ctrl[1].addr[0] = 53; 73662306a36Sopenharmony_ci state->Init_Ctrl[1].bit[0] = 2; 73762306a36Sopenharmony_ci state->Init_Ctrl[1].val[0] = 1; 73862306a36Sopenharmony_ci 73962306a36Sopenharmony_ci state->Init_Ctrl[2].Ctrl_Num = BB_BUF ; 74062306a36Sopenharmony_ci state->Init_Ctrl[2].size = 2 ; 74162306a36Sopenharmony_ci state->Init_Ctrl[2].addr[0] = 53; 74262306a36Sopenharmony_ci state->Init_Ctrl[2].bit[0] = 1; 74362306a36Sopenharmony_ci state->Init_Ctrl[2].val[0] = 0; 74462306a36Sopenharmony_ci state->Init_Ctrl[2].addr[1] = 57; 74562306a36Sopenharmony_ci state->Init_Ctrl[2].bit[1] = 0; 74662306a36Sopenharmony_ci state->Init_Ctrl[2].val[1] = 1; 74762306a36Sopenharmony_ci 74862306a36Sopenharmony_ci state->Init_Ctrl[3].Ctrl_Num = BB_BUF_OA ; 74962306a36Sopenharmony_ci state->Init_Ctrl[3].size = 1 ; 75062306a36Sopenharmony_ci state->Init_Ctrl[3].addr[0] = 53; 75162306a36Sopenharmony_ci state->Init_Ctrl[3].bit[0] = 0; 75262306a36Sopenharmony_ci state->Init_Ctrl[3].val[0] = 0; 75362306a36Sopenharmony_ci 75462306a36Sopenharmony_ci state->Init_Ctrl[4].Ctrl_Num = BB_ALPF_BANDSELECT ; 75562306a36Sopenharmony_ci state->Init_Ctrl[4].size = 3 ; 75662306a36Sopenharmony_ci state->Init_Ctrl[4].addr[0] = 53; 75762306a36Sopenharmony_ci state->Init_Ctrl[4].bit[0] = 5; 75862306a36Sopenharmony_ci state->Init_Ctrl[4].val[0] = 0; 75962306a36Sopenharmony_ci state->Init_Ctrl[4].addr[1] = 53; 76062306a36Sopenharmony_ci state->Init_Ctrl[4].bit[1] = 6; 76162306a36Sopenharmony_ci state->Init_Ctrl[4].val[1] = 0; 76262306a36Sopenharmony_ci state->Init_Ctrl[4].addr[2] = 53; 76362306a36Sopenharmony_ci state->Init_Ctrl[4].bit[2] = 7; 76462306a36Sopenharmony_ci state->Init_Ctrl[4].val[2] = 1; 76562306a36Sopenharmony_ci 76662306a36Sopenharmony_ci state->Init_Ctrl[5].Ctrl_Num = BB_IQSWAP ; 76762306a36Sopenharmony_ci state->Init_Ctrl[5].size = 1 ; 76862306a36Sopenharmony_ci state->Init_Ctrl[5].addr[0] = 59; 76962306a36Sopenharmony_ci state->Init_Ctrl[5].bit[0] = 0; 77062306a36Sopenharmony_ci state->Init_Ctrl[5].val[0] = 0; 77162306a36Sopenharmony_ci 77262306a36Sopenharmony_ci state->Init_Ctrl[6].Ctrl_Num = BB_DLPF_BANDSEL ; 77362306a36Sopenharmony_ci state->Init_Ctrl[6].size = 2 ; 77462306a36Sopenharmony_ci state->Init_Ctrl[6].addr[0] = 53; 77562306a36Sopenharmony_ci state->Init_Ctrl[6].bit[0] = 3; 77662306a36Sopenharmony_ci state->Init_Ctrl[6].val[0] = 0; 77762306a36Sopenharmony_ci state->Init_Ctrl[6].addr[1] = 53; 77862306a36Sopenharmony_ci state->Init_Ctrl[6].bit[1] = 4; 77962306a36Sopenharmony_ci state->Init_Ctrl[6].val[1] = 1; 78062306a36Sopenharmony_ci 78162306a36Sopenharmony_ci state->Init_Ctrl[7].Ctrl_Num = RFSYN_CHP_GAIN ; 78262306a36Sopenharmony_ci state->Init_Ctrl[7].size = 4 ; 78362306a36Sopenharmony_ci state->Init_Ctrl[7].addr[0] = 22; 78462306a36Sopenharmony_ci state->Init_Ctrl[7].bit[0] = 4; 78562306a36Sopenharmony_ci state->Init_Ctrl[7].val[0] = 0; 78662306a36Sopenharmony_ci state->Init_Ctrl[7].addr[1] = 22; 78762306a36Sopenharmony_ci state->Init_Ctrl[7].bit[1] = 5; 78862306a36Sopenharmony_ci state->Init_Ctrl[7].val[1] = 1; 78962306a36Sopenharmony_ci state->Init_Ctrl[7].addr[2] = 22; 79062306a36Sopenharmony_ci state->Init_Ctrl[7].bit[2] = 6; 79162306a36Sopenharmony_ci state->Init_Ctrl[7].val[2] = 1; 79262306a36Sopenharmony_ci state->Init_Ctrl[7].addr[3] = 22; 79362306a36Sopenharmony_ci state->Init_Ctrl[7].bit[3] = 7; 79462306a36Sopenharmony_ci state->Init_Ctrl[7].val[3] = 0; 79562306a36Sopenharmony_ci 79662306a36Sopenharmony_ci state->Init_Ctrl[8].Ctrl_Num = RFSYN_EN_CHP_HIGAIN ; 79762306a36Sopenharmony_ci state->Init_Ctrl[8].size = 1 ; 79862306a36Sopenharmony_ci state->Init_Ctrl[8].addr[0] = 22; 79962306a36Sopenharmony_ci state->Init_Ctrl[8].bit[0] = 2; 80062306a36Sopenharmony_ci state->Init_Ctrl[8].val[0] = 0; 80162306a36Sopenharmony_ci 80262306a36Sopenharmony_ci state->Init_Ctrl[9].Ctrl_Num = AGC_IF ; 80362306a36Sopenharmony_ci state->Init_Ctrl[9].size = 4 ; 80462306a36Sopenharmony_ci state->Init_Ctrl[9].addr[0] = 76; 80562306a36Sopenharmony_ci state->Init_Ctrl[9].bit[0] = 0; 80662306a36Sopenharmony_ci state->Init_Ctrl[9].val[0] = 1; 80762306a36Sopenharmony_ci state->Init_Ctrl[9].addr[1] = 76; 80862306a36Sopenharmony_ci state->Init_Ctrl[9].bit[1] = 1; 80962306a36Sopenharmony_ci state->Init_Ctrl[9].val[1] = 1; 81062306a36Sopenharmony_ci state->Init_Ctrl[9].addr[2] = 76; 81162306a36Sopenharmony_ci state->Init_Ctrl[9].bit[2] = 2; 81262306a36Sopenharmony_ci state->Init_Ctrl[9].val[2] = 0; 81362306a36Sopenharmony_ci state->Init_Ctrl[9].addr[3] = 76; 81462306a36Sopenharmony_ci state->Init_Ctrl[9].bit[3] = 3; 81562306a36Sopenharmony_ci state->Init_Ctrl[9].val[3] = 1; 81662306a36Sopenharmony_ci 81762306a36Sopenharmony_ci state->Init_Ctrl[10].Ctrl_Num = AGC_RF ; 81862306a36Sopenharmony_ci state->Init_Ctrl[10].size = 4 ; 81962306a36Sopenharmony_ci state->Init_Ctrl[10].addr[0] = 76; 82062306a36Sopenharmony_ci state->Init_Ctrl[10].bit[0] = 4; 82162306a36Sopenharmony_ci state->Init_Ctrl[10].val[0] = 1; 82262306a36Sopenharmony_ci state->Init_Ctrl[10].addr[1] = 76; 82362306a36Sopenharmony_ci state->Init_Ctrl[10].bit[1] = 5; 82462306a36Sopenharmony_ci state->Init_Ctrl[10].val[1] = 1; 82562306a36Sopenharmony_ci state->Init_Ctrl[10].addr[2] = 76; 82662306a36Sopenharmony_ci state->Init_Ctrl[10].bit[2] = 6; 82762306a36Sopenharmony_ci state->Init_Ctrl[10].val[2] = 0; 82862306a36Sopenharmony_ci state->Init_Ctrl[10].addr[3] = 76; 82962306a36Sopenharmony_ci state->Init_Ctrl[10].bit[3] = 7; 83062306a36Sopenharmony_ci state->Init_Ctrl[10].val[3] = 1; 83162306a36Sopenharmony_ci 83262306a36Sopenharmony_ci state->Init_Ctrl[11].Ctrl_Num = IF_DIVVAL ; 83362306a36Sopenharmony_ci state->Init_Ctrl[11].size = 5 ; 83462306a36Sopenharmony_ci state->Init_Ctrl[11].addr[0] = 43; 83562306a36Sopenharmony_ci state->Init_Ctrl[11].bit[0] = 3; 83662306a36Sopenharmony_ci state->Init_Ctrl[11].val[0] = 0; 83762306a36Sopenharmony_ci state->Init_Ctrl[11].addr[1] = 43; 83862306a36Sopenharmony_ci state->Init_Ctrl[11].bit[1] = 4; 83962306a36Sopenharmony_ci state->Init_Ctrl[11].val[1] = 0; 84062306a36Sopenharmony_ci state->Init_Ctrl[11].addr[2] = 43; 84162306a36Sopenharmony_ci state->Init_Ctrl[11].bit[2] = 5; 84262306a36Sopenharmony_ci state->Init_Ctrl[11].val[2] = 0; 84362306a36Sopenharmony_ci state->Init_Ctrl[11].addr[3] = 43; 84462306a36Sopenharmony_ci state->Init_Ctrl[11].bit[3] = 6; 84562306a36Sopenharmony_ci state->Init_Ctrl[11].val[3] = 1; 84662306a36Sopenharmony_ci state->Init_Ctrl[11].addr[4] = 43; 84762306a36Sopenharmony_ci state->Init_Ctrl[11].bit[4] = 7; 84862306a36Sopenharmony_ci state->Init_Ctrl[11].val[4] = 0; 84962306a36Sopenharmony_ci 85062306a36Sopenharmony_ci state->Init_Ctrl[12].Ctrl_Num = IF_VCO_BIAS ; 85162306a36Sopenharmony_ci state->Init_Ctrl[12].size = 6 ; 85262306a36Sopenharmony_ci state->Init_Ctrl[12].addr[0] = 44; 85362306a36Sopenharmony_ci state->Init_Ctrl[12].bit[0] = 2; 85462306a36Sopenharmony_ci state->Init_Ctrl[12].val[0] = 0; 85562306a36Sopenharmony_ci state->Init_Ctrl[12].addr[1] = 44; 85662306a36Sopenharmony_ci state->Init_Ctrl[12].bit[1] = 3; 85762306a36Sopenharmony_ci state->Init_Ctrl[12].val[1] = 0; 85862306a36Sopenharmony_ci state->Init_Ctrl[12].addr[2] = 44; 85962306a36Sopenharmony_ci state->Init_Ctrl[12].bit[2] = 4; 86062306a36Sopenharmony_ci state->Init_Ctrl[12].val[2] = 0; 86162306a36Sopenharmony_ci state->Init_Ctrl[12].addr[3] = 44; 86262306a36Sopenharmony_ci state->Init_Ctrl[12].bit[3] = 5; 86362306a36Sopenharmony_ci state->Init_Ctrl[12].val[3] = 1; 86462306a36Sopenharmony_ci state->Init_Ctrl[12].addr[4] = 44; 86562306a36Sopenharmony_ci state->Init_Ctrl[12].bit[4] = 6; 86662306a36Sopenharmony_ci state->Init_Ctrl[12].val[4] = 0; 86762306a36Sopenharmony_ci state->Init_Ctrl[12].addr[5] = 44; 86862306a36Sopenharmony_ci state->Init_Ctrl[12].bit[5] = 7; 86962306a36Sopenharmony_ci state->Init_Ctrl[12].val[5] = 0; 87062306a36Sopenharmony_ci 87162306a36Sopenharmony_ci state->Init_Ctrl[13].Ctrl_Num = CHCAL_INT_MOD_IF ; 87262306a36Sopenharmony_ci state->Init_Ctrl[13].size = 7 ; 87362306a36Sopenharmony_ci state->Init_Ctrl[13].addr[0] = 11; 87462306a36Sopenharmony_ci state->Init_Ctrl[13].bit[0] = 0; 87562306a36Sopenharmony_ci state->Init_Ctrl[13].val[0] = 1; 87662306a36Sopenharmony_ci state->Init_Ctrl[13].addr[1] = 11; 87762306a36Sopenharmony_ci state->Init_Ctrl[13].bit[1] = 1; 87862306a36Sopenharmony_ci state->Init_Ctrl[13].val[1] = 0; 87962306a36Sopenharmony_ci state->Init_Ctrl[13].addr[2] = 11; 88062306a36Sopenharmony_ci state->Init_Ctrl[13].bit[2] = 2; 88162306a36Sopenharmony_ci state->Init_Ctrl[13].val[2] = 0; 88262306a36Sopenharmony_ci state->Init_Ctrl[13].addr[3] = 11; 88362306a36Sopenharmony_ci state->Init_Ctrl[13].bit[3] = 3; 88462306a36Sopenharmony_ci state->Init_Ctrl[13].val[3] = 1; 88562306a36Sopenharmony_ci state->Init_Ctrl[13].addr[4] = 11; 88662306a36Sopenharmony_ci state->Init_Ctrl[13].bit[4] = 4; 88762306a36Sopenharmony_ci state->Init_Ctrl[13].val[4] = 1; 88862306a36Sopenharmony_ci state->Init_Ctrl[13].addr[5] = 11; 88962306a36Sopenharmony_ci state->Init_Ctrl[13].bit[5] = 5; 89062306a36Sopenharmony_ci state->Init_Ctrl[13].val[5] = 0; 89162306a36Sopenharmony_ci state->Init_Ctrl[13].addr[6] = 11; 89262306a36Sopenharmony_ci state->Init_Ctrl[13].bit[6] = 6; 89362306a36Sopenharmony_ci state->Init_Ctrl[13].val[6] = 0; 89462306a36Sopenharmony_ci 89562306a36Sopenharmony_ci state->Init_Ctrl[14].Ctrl_Num = CHCAL_FRAC_MOD_IF ; 89662306a36Sopenharmony_ci state->Init_Ctrl[14].size = 16 ; 89762306a36Sopenharmony_ci state->Init_Ctrl[14].addr[0] = 13; 89862306a36Sopenharmony_ci state->Init_Ctrl[14].bit[0] = 0; 89962306a36Sopenharmony_ci state->Init_Ctrl[14].val[0] = 0; 90062306a36Sopenharmony_ci state->Init_Ctrl[14].addr[1] = 13; 90162306a36Sopenharmony_ci state->Init_Ctrl[14].bit[1] = 1; 90262306a36Sopenharmony_ci state->Init_Ctrl[14].val[1] = 0; 90362306a36Sopenharmony_ci state->Init_Ctrl[14].addr[2] = 13; 90462306a36Sopenharmony_ci state->Init_Ctrl[14].bit[2] = 2; 90562306a36Sopenharmony_ci state->Init_Ctrl[14].val[2] = 0; 90662306a36Sopenharmony_ci state->Init_Ctrl[14].addr[3] = 13; 90762306a36Sopenharmony_ci state->Init_Ctrl[14].bit[3] = 3; 90862306a36Sopenharmony_ci state->Init_Ctrl[14].val[3] = 0; 90962306a36Sopenharmony_ci state->Init_Ctrl[14].addr[4] = 13; 91062306a36Sopenharmony_ci state->Init_Ctrl[14].bit[4] = 4; 91162306a36Sopenharmony_ci state->Init_Ctrl[14].val[4] = 0; 91262306a36Sopenharmony_ci state->Init_Ctrl[14].addr[5] = 13; 91362306a36Sopenharmony_ci state->Init_Ctrl[14].bit[5] = 5; 91462306a36Sopenharmony_ci state->Init_Ctrl[14].val[5] = 0; 91562306a36Sopenharmony_ci state->Init_Ctrl[14].addr[6] = 13; 91662306a36Sopenharmony_ci state->Init_Ctrl[14].bit[6] = 6; 91762306a36Sopenharmony_ci state->Init_Ctrl[14].val[6] = 0; 91862306a36Sopenharmony_ci state->Init_Ctrl[14].addr[7] = 13; 91962306a36Sopenharmony_ci state->Init_Ctrl[14].bit[7] = 7; 92062306a36Sopenharmony_ci state->Init_Ctrl[14].val[7] = 0; 92162306a36Sopenharmony_ci state->Init_Ctrl[14].addr[8] = 12; 92262306a36Sopenharmony_ci state->Init_Ctrl[14].bit[8] = 0; 92362306a36Sopenharmony_ci state->Init_Ctrl[14].val[8] = 0; 92462306a36Sopenharmony_ci state->Init_Ctrl[14].addr[9] = 12; 92562306a36Sopenharmony_ci state->Init_Ctrl[14].bit[9] = 1; 92662306a36Sopenharmony_ci state->Init_Ctrl[14].val[9] = 0; 92762306a36Sopenharmony_ci state->Init_Ctrl[14].addr[10] = 12; 92862306a36Sopenharmony_ci state->Init_Ctrl[14].bit[10] = 2; 92962306a36Sopenharmony_ci state->Init_Ctrl[14].val[10] = 0; 93062306a36Sopenharmony_ci state->Init_Ctrl[14].addr[11] = 12; 93162306a36Sopenharmony_ci state->Init_Ctrl[14].bit[11] = 3; 93262306a36Sopenharmony_ci state->Init_Ctrl[14].val[11] = 0; 93362306a36Sopenharmony_ci state->Init_Ctrl[14].addr[12] = 12; 93462306a36Sopenharmony_ci state->Init_Ctrl[14].bit[12] = 4; 93562306a36Sopenharmony_ci state->Init_Ctrl[14].val[12] = 0; 93662306a36Sopenharmony_ci state->Init_Ctrl[14].addr[13] = 12; 93762306a36Sopenharmony_ci state->Init_Ctrl[14].bit[13] = 5; 93862306a36Sopenharmony_ci state->Init_Ctrl[14].val[13] = 1; 93962306a36Sopenharmony_ci state->Init_Ctrl[14].addr[14] = 12; 94062306a36Sopenharmony_ci state->Init_Ctrl[14].bit[14] = 6; 94162306a36Sopenharmony_ci state->Init_Ctrl[14].val[14] = 1; 94262306a36Sopenharmony_ci state->Init_Ctrl[14].addr[15] = 12; 94362306a36Sopenharmony_ci state->Init_Ctrl[14].bit[15] = 7; 94462306a36Sopenharmony_ci state->Init_Ctrl[14].val[15] = 0; 94562306a36Sopenharmony_ci 94662306a36Sopenharmony_ci state->Init_Ctrl[15].Ctrl_Num = DRV_RES_SEL ; 94762306a36Sopenharmony_ci state->Init_Ctrl[15].size = 3 ; 94862306a36Sopenharmony_ci state->Init_Ctrl[15].addr[0] = 147; 94962306a36Sopenharmony_ci state->Init_Ctrl[15].bit[0] = 2; 95062306a36Sopenharmony_ci state->Init_Ctrl[15].val[0] = 0; 95162306a36Sopenharmony_ci state->Init_Ctrl[15].addr[1] = 147; 95262306a36Sopenharmony_ci state->Init_Ctrl[15].bit[1] = 3; 95362306a36Sopenharmony_ci state->Init_Ctrl[15].val[1] = 1; 95462306a36Sopenharmony_ci state->Init_Ctrl[15].addr[2] = 147; 95562306a36Sopenharmony_ci state->Init_Ctrl[15].bit[2] = 4; 95662306a36Sopenharmony_ci state->Init_Ctrl[15].val[2] = 1; 95762306a36Sopenharmony_ci 95862306a36Sopenharmony_ci state->Init_Ctrl[16].Ctrl_Num = I_DRIVER ; 95962306a36Sopenharmony_ci state->Init_Ctrl[16].size = 2 ; 96062306a36Sopenharmony_ci state->Init_Ctrl[16].addr[0] = 147; 96162306a36Sopenharmony_ci state->Init_Ctrl[16].bit[0] = 0; 96262306a36Sopenharmony_ci state->Init_Ctrl[16].val[0] = 0; 96362306a36Sopenharmony_ci state->Init_Ctrl[16].addr[1] = 147; 96462306a36Sopenharmony_ci state->Init_Ctrl[16].bit[1] = 1; 96562306a36Sopenharmony_ci state->Init_Ctrl[16].val[1] = 1; 96662306a36Sopenharmony_ci 96762306a36Sopenharmony_ci state->Init_Ctrl[17].Ctrl_Num = EN_AAF ; 96862306a36Sopenharmony_ci state->Init_Ctrl[17].size = 1 ; 96962306a36Sopenharmony_ci state->Init_Ctrl[17].addr[0] = 147; 97062306a36Sopenharmony_ci state->Init_Ctrl[17].bit[0] = 7; 97162306a36Sopenharmony_ci state->Init_Ctrl[17].val[0] = 0; 97262306a36Sopenharmony_ci 97362306a36Sopenharmony_ci state->Init_Ctrl[18].Ctrl_Num = EN_3P ; 97462306a36Sopenharmony_ci state->Init_Ctrl[18].size = 1 ; 97562306a36Sopenharmony_ci state->Init_Ctrl[18].addr[0] = 147; 97662306a36Sopenharmony_ci state->Init_Ctrl[18].bit[0] = 6; 97762306a36Sopenharmony_ci state->Init_Ctrl[18].val[0] = 0; 97862306a36Sopenharmony_ci 97962306a36Sopenharmony_ci state->Init_Ctrl[19].Ctrl_Num = EN_AUX_3P ; 98062306a36Sopenharmony_ci state->Init_Ctrl[19].size = 1 ; 98162306a36Sopenharmony_ci state->Init_Ctrl[19].addr[0] = 156; 98262306a36Sopenharmony_ci state->Init_Ctrl[19].bit[0] = 0; 98362306a36Sopenharmony_ci state->Init_Ctrl[19].val[0] = 0; 98462306a36Sopenharmony_ci 98562306a36Sopenharmony_ci state->Init_Ctrl[20].Ctrl_Num = SEL_AAF_BAND ; 98662306a36Sopenharmony_ci state->Init_Ctrl[20].size = 1 ; 98762306a36Sopenharmony_ci state->Init_Ctrl[20].addr[0] = 147; 98862306a36Sopenharmony_ci state->Init_Ctrl[20].bit[0] = 5; 98962306a36Sopenharmony_ci state->Init_Ctrl[20].val[0] = 0; 99062306a36Sopenharmony_ci 99162306a36Sopenharmony_ci state->Init_Ctrl[21].Ctrl_Num = SEQ_ENCLK16_CLK_OUT ; 99262306a36Sopenharmony_ci state->Init_Ctrl[21].size = 1 ; 99362306a36Sopenharmony_ci state->Init_Ctrl[21].addr[0] = 137; 99462306a36Sopenharmony_ci state->Init_Ctrl[21].bit[0] = 4; 99562306a36Sopenharmony_ci state->Init_Ctrl[21].val[0] = 0; 99662306a36Sopenharmony_ci 99762306a36Sopenharmony_ci state->Init_Ctrl[22].Ctrl_Num = SEQ_SEL4_16B ; 99862306a36Sopenharmony_ci state->Init_Ctrl[22].size = 1 ; 99962306a36Sopenharmony_ci state->Init_Ctrl[22].addr[0] = 137; 100062306a36Sopenharmony_ci state->Init_Ctrl[22].bit[0] = 7; 100162306a36Sopenharmony_ci state->Init_Ctrl[22].val[0] = 0; 100262306a36Sopenharmony_ci 100362306a36Sopenharmony_ci state->Init_Ctrl[23].Ctrl_Num = XTAL_CAPSELECT ; 100462306a36Sopenharmony_ci state->Init_Ctrl[23].size = 1 ; 100562306a36Sopenharmony_ci state->Init_Ctrl[23].addr[0] = 91; 100662306a36Sopenharmony_ci state->Init_Ctrl[23].bit[0] = 5; 100762306a36Sopenharmony_ci state->Init_Ctrl[23].val[0] = 1; 100862306a36Sopenharmony_ci 100962306a36Sopenharmony_ci state->Init_Ctrl[24].Ctrl_Num = IF_SEL_DBL ; 101062306a36Sopenharmony_ci state->Init_Ctrl[24].size = 1 ; 101162306a36Sopenharmony_ci state->Init_Ctrl[24].addr[0] = 43; 101262306a36Sopenharmony_ci state->Init_Ctrl[24].bit[0] = 0; 101362306a36Sopenharmony_ci state->Init_Ctrl[24].val[0] = 1; 101462306a36Sopenharmony_ci 101562306a36Sopenharmony_ci state->Init_Ctrl[25].Ctrl_Num = RFSYN_R_DIV ; 101662306a36Sopenharmony_ci state->Init_Ctrl[25].size = 2 ; 101762306a36Sopenharmony_ci state->Init_Ctrl[25].addr[0] = 22; 101862306a36Sopenharmony_ci state->Init_Ctrl[25].bit[0] = 0; 101962306a36Sopenharmony_ci state->Init_Ctrl[25].val[0] = 1; 102062306a36Sopenharmony_ci state->Init_Ctrl[25].addr[1] = 22; 102162306a36Sopenharmony_ci state->Init_Ctrl[25].bit[1] = 1; 102262306a36Sopenharmony_ci state->Init_Ctrl[25].val[1] = 1; 102362306a36Sopenharmony_ci 102462306a36Sopenharmony_ci state->Init_Ctrl[26].Ctrl_Num = SEQ_EXTSYNTHCALIF ; 102562306a36Sopenharmony_ci state->Init_Ctrl[26].size = 1 ; 102662306a36Sopenharmony_ci state->Init_Ctrl[26].addr[0] = 134; 102762306a36Sopenharmony_ci state->Init_Ctrl[26].bit[0] = 2; 102862306a36Sopenharmony_ci state->Init_Ctrl[26].val[0] = 0; 102962306a36Sopenharmony_ci 103062306a36Sopenharmony_ci state->Init_Ctrl[27].Ctrl_Num = SEQ_EXTDCCAL ; 103162306a36Sopenharmony_ci state->Init_Ctrl[27].size = 1 ; 103262306a36Sopenharmony_ci state->Init_Ctrl[27].addr[0] = 137; 103362306a36Sopenharmony_ci state->Init_Ctrl[27].bit[0] = 3; 103462306a36Sopenharmony_ci state->Init_Ctrl[27].val[0] = 0; 103562306a36Sopenharmony_ci 103662306a36Sopenharmony_ci state->Init_Ctrl[28].Ctrl_Num = AGC_EN_RSSI ; 103762306a36Sopenharmony_ci state->Init_Ctrl[28].size = 1 ; 103862306a36Sopenharmony_ci state->Init_Ctrl[28].addr[0] = 77; 103962306a36Sopenharmony_ci state->Init_Ctrl[28].bit[0] = 7; 104062306a36Sopenharmony_ci state->Init_Ctrl[28].val[0] = 0; 104162306a36Sopenharmony_ci 104262306a36Sopenharmony_ci state->Init_Ctrl[29].Ctrl_Num = RFA_ENCLKRFAGC ; 104362306a36Sopenharmony_ci state->Init_Ctrl[29].size = 1 ; 104462306a36Sopenharmony_ci state->Init_Ctrl[29].addr[0] = 166; 104562306a36Sopenharmony_ci state->Init_Ctrl[29].bit[0] = 7; 104662306a36Sopenharmony_ci state->Init_Ctrl[29].val[0] = 1; 104762306a36Sopenharmony_ci 104862306a36Sopenharmony_ci state->Init_Ctrl[30].Ctrl_Num = RFA_RSSI_REFH ; 104962306a36Sopenharmony_ci state->Init_Ctrl[30].size = 3 ; 105062306a36Sopenharmony_ci state->Init_Ctrl[30].addr[0] = 166; 105162306a36Sopenharmony_ci state->Init_Ctrl[30].bit[0] = 0; 105262306a36Sopenharmony_ci state->Init_Ctrl[30].val[0] = 0; 105362306a36Sopenharmony_ci state->Init_Ctrl[30].addr[1] = 166; 105462306a36Sopenharmony_ci state->Init_Ctrl[30].bit[1] = 1; 105562306a36Sopenharmony_ci state->Init_Ctrl[30].val[1] = 1; 105662306a36Sopenharmony_ci state->Init_Ctrl[30].addr[2] = 166; 105762306a36Sopenharmony_ci state->Init_Ctrl[30].bit[2] = 2; 105862306a36Sopenharmony_ci state->Init_Ctrl[30].val[2] = 1; 105962306a36Sopenharmony_ci 106062306a36Sopenharmony_ci state->Init_Ctrl[31].Ctrl_Num = RFA_RSSI_REF ; 106162306a36Sopenharmony_ci state->Init_Ctrl[31].size = 3 ; 106262306a36Sopenharmony_ci state->Init_Ctrl[31].addr[0] = 166; 106362306a36Sopenharmony_ci state->Init_Ctrl[31].bit[0] = 3; 106462306a36Sopenharmony_ci state->Init_Ctrl[31].val[0] = 1; 106562306a36Sopenharmony_ci state->Init_Ctrl[31].addr[1] = 166; 106662306a36Sopenharmony_ci state->Init_Ctrl[31].bit[1] = 4; 106762306a36Sopenharmony_ci state->Init_Ctrl[31].val[1] = 0; 106862306a36Sopenharmony_ci state->Init_Ctrl[31].addr[2] = 166; 106962306a36Sopenharmony_ci state->Init_Ctrl[31].bit[2] = 5; 107062306a36Sopenharmony_ci state->Init_Ctrl[31].val[2] = 1; 107162306a36Sopenharmony_ci 107262306a36Sopenharmony_ci state->Init_Ctrl[32].Ctrl_Num = RFA_RSSI_REFL ; 107362306a36Sopenharmony_ci state->Init_Ctrl[32].size = 3 ; 107462306a36Sopenharmony_ci state->Init_Ctrl[32].addr[0] = 167; 107562306a36Sopenharmony_ci state->Init_Ctrl[32].bit[0] = 0; 107662306a36Sopenharmony_ci state->Init_Ctrl[32].val[0] = 1; 107762306a36Sopenharmony_ci state->Init_Ctrl[32].addr[1] = 167; 107862306a36Sopenharmony_ci state->Init_Ctrl[32].bit[1] = 1; 107962306a36Sopenharmony_ci state->Init_Ctrl[32].val[1] = 1; 108062306a36Sopenharmony_ci state->Init_Ctrl[32].addr[2] = 167; 108162306a36Sopenharmony_ci state->Init_Ctrl[32].bit[2] = 2; 108262306a36Sopenharmony_ci state->Init_Ctrl[32].val[2] = 0; 108362306a36Sopenharmony_ci 108462306a36Sopenharmony_ci state->Init_Ctrl[33].Ctrl_Num = RFA_FLR ; 108562306a36Sopenharmony_ci state->Init_Ctrl[33].size = 4 ; 108662306a36Sopenharmony_ci state->Init_Ctrl[33].addr[0] = 168; 108762306a36Sopenharmony_ci state->Init_Ctrl[33].bit[0] = 0; 108862306a36Sopenharmony_ci state->Init_Ctrl[33].val[0] = 0; 108962306a36Sopenharmony_ci state->Init_Ctrl[33].addr[1] = 168; 109062306a36Sopenharmony_ci state->Init_Ctrl[33].bit[1] = 1; 109162306a36Sopenharmony_ci state->Init_Ctrl[33].val[1] = 1; 109262306a36Sopenharmony_ci state->Init_Ctrl[33].addr[2] = 168; 109362306a36Sopenharmony_ci state->Init_Ctrl[33].bit[2] = 2; 109462306a36Sopenharmony_ci state->Init_Ctrl[33].val[2] = 0; 109562306a36Sopenharmony_ci state->Init_Ctrl[33].addr[3] = 168; 109662306a36Sopenharmony_ci state->Init_Ctrl[33].bit[3] = 3; 109762306a36Sopenharmony_ci state->Init_Ctrl[33].val[3] = 0; 109862306a36Sopenharmony_ci 109962306a36Sopenharmony_ci state->Init_Ctrl[34].Ctrl_Num = RFA_CEIL ; 110062306a36Sopenharmony_ci state->Init_Ctrl[34].size = 4 ; 110162306a36Sopenharmony_ci state->Init_Ctrl[34].addr[0] = 168; 110262306a36Sopenharmony_ci state->Init_Ctrl[34].bit[0] = 4; 110362306a36Sopenharmony_ci state->Init_Ctrl[34].val[0] = 1; 110462306a36Sopenharmony_ci state->Init_Ctrl[34].addr[1] = 168; 110562306a36Sopenharmony_ci state->Init_Ctrl[34].bit[1] = 5; 110662306a36Sopenharmony_ci state->Init_Ctrl[34].val[1] = 1; 110762306a36Sopenharmony_ci state->Init_Ctrl[34].addr[2] = 168; 110862306a36Sopenharmony_ci state->Init_Ctrl[34].bit[2] = 6; 110962306a36Sopenharmony_ci state->Init_Ctrl[34].val[2] = 1; 111062306a36Sopenharmony_ci state->Init_Ctrl[34].addr[3] = 168; 111162306a36Sopenharmony_ci state->Init_Ctrl[34].bit[3] = 7; 111262306a36Sopenharmony_ci state->Init_Ctrl[34].val[3] = 1; 111362306a36Sopenharmony_ci 111462306a36Sopenharmony_ci state->Init_Ctrl[35].Ctrl_Num = SEQ_EXTIQFSMPULSE ; 111562306a36Sopenharmony_ci state->Init_Ctrl[35].size = 1 ; 111662306a36Sopenharmony_ci state->Init_Ctrl[35].addr[0] = 135; 111762306a36Sopenharmony_ci state->Init_Ctrl[35].bit[0] = 0; 111862306a36Sopenharmony_ci state->Init_Ctrl[35].val[0] = 0; 111962306a36Sopenharmony_ci 112062306a36Sopenharmony_ci state->Init_Ctrl[36].Ctrl_Num = OVERRIDE_1 ; 112162306a36Sopenharmony_ci state->Init_Ctrl[36].size = 1 ; 112262306a36Sopenharmony_ci state->Init_Ctrl[36].addr[0] = 56; 112362306a36Sopenharmony_ci state->Init_Ctrl[36].bit[0] = 3; 112462306a36Sopenharmony_ci state->Init_Ctrl[36].val[0] = 0; 112562306a36Sopenharmony_ci 112662306a36Sopenharmony_ci state->Init_Ctrl[37].Ctrl_Num = BB_INITSTATE_DLPF_TUNE ; 112762306a36Sopenharmony_ci state->Init_Ctrl[37].size = 7 ; 112862306a36Sopenharmony_ci state->Init_Ctrl[37].addr[0] = 59; 112962306a36Sopenharmony_ci state->Init_Ctrl[37].bit[0] = 1; 113062306a36Sopenharmony_ci state->Init_Ctrl[37].val[0] = 0; 113162306a36Sopenharmony_ci state->Init_Ctrl[37].addr[1] = 59; 113262306a36Sopenharmony_ci state->Init_Ctrl[37].bit[1] = 2; 113362306a36Sopenharmony_ci state->Init_Ctrl[37].val[1] = 0; 113462306a36Sopenharmony_ci state->Init_Ctrl[37].addr[2] = 59; 113562306a36Sopenharmony_ci state->Init_Ctrl[37].bit[2] = 3; 113662306a36Sopenharmony_ci state->Init_Ctrl[37].val[2] = 0; 113762306a36Sopenharmony_ci state->Init_Ctrl[37].addr[3] = 59; 113862306a36Sopenharmony_ci state->Init_Ctrl[37].bit[3] = 4; 113962306a36Sopenharmony_ci state->Init_Ctrl[37].val[3] = 0; 114062306a36Sopenharmony_ci state->Init_Ctrl[37].addr[4] = 59; 114162306a36Sopenharmony_ci state->Init_Ctrl[37].bit[4] = 5; 114262306a36Sopenharmony_ci state->Init_Ctrl[37].val[4] = 0; 114362306a36Sopenharmony_ci state->Init_Ctrl[37].addr[5] = 59; 114462306a36Sopenharmony_ci state->Init_Ctrl[37].bit[5] = 6; 114562306a36Sopenharmony_ci state->Init_Ctrl[37].val[5] = 0; 114662306a36Sopenharmony_ci state->Init_Ctrl[37].addr[6] = 59; 114762306a36Sopenharmony_ci state->Init_Ctrl[37].bit[6] = 7; 114862306a36Sopenharmony_ci state->Init_Ctrl[37].val[6] = 0; 114962306a36Sopenharmony_ci 115062306a36Sopenharmony_ci state->Init_Ctrl[38].Ctrl_Num = TG_R_DIV ; 115162306a36Sopenharmony_ci state->Init_Ctrl[38].size = 6 ; 115262306a36Sopenharmony_ci state->Init_Ctrl[38].addr[0] = 32; 115362306a36Sopenharmony_ci state->Init_Ctrl[38].bit[0] = 2; 115462306a36Sopenharmony_ci state->Init_Ctrl[38].val[0] = 0; 115562306a36Sopenharmony_ci state->Init_Ctrl[38].addr[1] = 32; 115662306a36Sopenharmony_ci state->Init_Ctrl[38].bit[1] = 3; 115762306a36Sopenharmony_ci state->Init_Ctrl[38].val[1] = 0; 115862306a36Sopenharmony_ci state->Init_Ctrl[38].addr[2] = 32; 115962306a36Sopenharmony_ci state->Init_Ctrl[38].bit[2] = 4; 116062306a36Sopenharmony_ci state->Init_Ctrl[38].val[2] = 0; 116162306a36Sopenharmony_ci state->Init_Ctrl[38].addr[3] = 32; 116262306a36Sopenharmony_ci state->Init_Ctrl[38].bit[3] = 5; 116362306a36Sopenharmony_ci state->Init_Ctrl[38].val[3] = 0; 116462306a36Sopenharmony_ci state->Init_Ctrl[38].addr[4] = 32; 116562306a36Sopenharmony_ci state->Init_Ctrl[38].bit[4] = 6; 116662306a36Sopenharmony_ci state->Init_Ctrl[38].val[4] = 1; 116762306a36Sopenharmony_ci state->Init_Ctrl[38].addr[5] = 32; 116862306a36Sopenharmony_ci state->Init_Ctrl[38].bit[5] = 7; 116962306a36Sopenharmony_ci state->Init_Ctrl[38].val[5] = 0; 117062306a36Sopenharmony_ci 117162306a36Sopenharmony_ci state->Init_Ctrl[39].Ctrl_Num = EN_CHP_LIN_B ; 117262306a36Sopenharmony_ci state->Init_Ctrl[39].size = 1 ; 117362306a36Sopenharmony_ci state->Init_Ctrl[39].addr[0] = 25; 117462306a36Sopenharmony_ci state->Init_Ctrl[39].bit[0] = 3; 117562306a36Sopenharmony_ci state->Init_Ctrl[39].val[0] = 1; 117662306a36Sopenharmony_ci 117762306a36Sopenharmony_ci 117862306a36Sopenharmony_ci state->CH_Ctrl_Num = CHCTRL_NUM ; 117962306a36Sopenharmony_ci 118062306a36Sopenharmony_ci state->CH_Ctrl[0].Ctrl_Num = DN_POLY ; 118162306a36Sopenharmony_ci state->CH_Ctrl[0].size = 2 ; 118262306a36Sopenharmony_ci state->CH_Ctrl[0].addr[0] = 68; 118362306a36Sopenharmony_ci state->CH_Ctrl[0].bit[0] = 6; 118462306a36Sopenharmony_ci state->CH_Ctrl[0].val[0] = 1; 118562306a36Sopenharmony_ci state->CH_Ctrl[0].addr[1] = 68; 118662306a36Sopenharmony_ci state->CH_Ctrl[0].bit[1] = 7; 118762306a36Sopenharmony_ci state->CH_Ctrl[0].val[1] = 1; 118862306a36Sopenharmony_ci 118962306a36Sopenharmony_ci state->CH_Ctrl[1].Ctrl_Num = DN_RFGAIN ; 119062306a36Sopenharmony_ci state->CH_Ctrl[1].size = 2 ; 119162306a36Sopenharmony_ci state->CH_Ctrl[1].addr[0] = 70; 119262306a36Sopenharmony_ci state->CH_Ctrl[1].bit[0] = 6; 119362306a36Sopenharmony_ci state->CH_Ctrl[1].val[0] = 1; 119462306a36Sopenharmony_ci state->CH_Ctrl[1].addr[1] = 70; 119562306a36Sopenharmony_ci state->CH_Ctrl[1].bit[1] = 7; 119662306a36Sopenharmony_ci state->CH_Ctrl[1].val[1] = 0; 119762306a36Sopenharmony_ci 119862306a36Sopenharmony_ci state->CH_Ctrl[2].Ctrl_Num = DN_CAP_RFLPF ; 119962306a36Sopenharmony_ci state->CH_Ctrl[2].size = 9 ; 120062306a36Sopenharmony_ci state->CH_Ctrl[2].addr[0] = 69; 120162306a36Sopenharmony_ci state->CH_Ctrl[2].bit[0] = 5; 120262306a36Sopenharmony_ci state->CH_Ctrl[2].val[0] = 0; 120362306a36Sopenharmony_ci state->CH_Ctrl[2].addr[1] = 69; 120462306a36Sopenharmony_ci state->CH_Ctrl[2].bit[1] = 6; 120562306a36Sopenharmony_ci state->CH_Ctrl[2].val[1] = 0; 120662306a36Sopenharmony_ci state->CH_Ctrl[2].addr[2] = 69; 120762306a36Sopenharmony_ci state->CH_Ctrl[2].bit[2] = 7; 120862306a36Sopenharmony_ci state->CH_Ctrl[2].val[2] = 0; 120962306a36Sopenharmony_ci state->CH_Ctrl[2].addr[3] = 68; 121062306a36Sopenharmony_ci state->CH_Ctrl[2].bit[3] = 0; 121162306a36Sopenharmony_ci state->CH_Ctrl[2].val[3] = 0; 121262306a36Sopenharmony_ci state->CH_Ctrl[2].addr[4] = 68; 121362306a36Sopenharmony_ci state->CH_Ctrl[2].bit[4] = 1; 121462306a36Sopenharmony_ci state->CH_Ctrl[2].val[4] = 0; 121562306a36Sopenharmony_ci state->CH_Ctrl[2].addr[5] = 68; 121662306a36Sopenharmony_ci state->CH_Ctrl[2].bit[5] = 2; 121762306a36Sopenharmony_ci state->CH_Ctrl[2].val[5] = 0; 121862306a36Sopenharmony_ci state->CH_Ctrl[2].addr[6] = 68; 121962306a36Sopenharmony_ci state->CH_Ctrl[2].bit[6] = 3; 122062306a36Sopenharmony_ci state->CH_Ctrl[2].val[6] = 0; 122162306a36Sopenharmony_ci state->CH_Ctrl[2].addr[7] = 68; 122262306a36Sopenharmony_ci state->CH_Ctrl[2].bit[7] = 4; 122362306a36Sopenharmony_ci state->CH_Ctrl[2].val[7] = 0; 122462306a36Sopenharmony_ci state->CH_Ctrl[2].addr[8] = 68; 122562306a36Sopenharmony_ci state->CH_Ctrl[2].bit[8] = 5; 122662306a36Sopenharmony_ci state->CH_Ctrl[2].val[8] = 0; 122762306a36Sopenharmony_ci 122862306a36Sopenharmony_ci state->CH_Ctrl[3].Ctrl_Num = DN_EN_VHFUHFBAR ; 122962306a36Sopenharmony_ci state->CH_Ctrl[3].size = 1 ; 123062306a36Sopenharmony_ci state->CH_Ctrl[3].addr[0] = 70; 123162306a36Sopenharmony_ci state->CH_Ctrl[3].bit[0] = 5; 123262306a36Sopenharmony_ci state->CH_Ctrl[3].val[0] = 0; 123362306a36Sopenharmony_ci 123462306a36Sopenharmony_ci state->CH_Ctrl[4].Ctrl_Num = DN_GAIN_ADJUST ; 123562306a36Sopenharmony_ci state->CH_Ctrl[4].size = 3 ; 123662306a36Sopenharmony_ci state->CH_Ctrl[4].addr[0] = 73; 123762306a36Sopenharmony_ci state->CH_Ctrl[4].bit[0] = 4; 123862306a36Sopenharmony_ci state->CH_Ctrl[4].val[0] = 0; 123962306a36Sopenharmony_ci state->CH_Ctrl[4].addr[1] = 73; 124062306a36Sopenharmony_ci state->CH_Ctrl[4].bit[1] = 5; 124162306a36Sopenharmony_ci state->CH_Ctrl[4].val[1] = 1; 124262306a36Sopenharmony_ci state->CH_Ctrl[4].addr[2] = 73; 124362306a36Sopenharmony_ci state->CH_Ctrl[4].bit[2] = 6; 124462306a36Sopenharmony_ci state->CH_Ctrl[4].val[2] = 0; 124562306a36Sopenharmony_ci 124662306a36Sopenharmony_ci state->CH_Ctrl[5].Ctrl_Num = DN_IQTNBUF_AMP ; 124762306a36Sopenharmony_ci state->CH_Ctrl[5].size = 4 ; 124862306a36Sopenharmony_ci state->CH_Ctrl[5].addr[0] = 70; 124962306a36Sopenharmony_ci state->CH_Ctrl[5].bit[0] = 0; 125062306a36Sopenharmony_ci state->CH_Ctrl[5].val[0] = 0; 125162306a36Sopenharmony_ci state->CH_Ctrl[5].addr[1] = 70; 125262306a36Sopenharmony_ci state->CH_Ctrl[5].bit[1] = 1; 125362306a36Sopenharmony_ci state->CH_Ctrl[5].val[1] = 0; 125462306a36Sopenharmony_ci state->CH_Ctrl[5].addr[2] = 70; 125562306a36Sopenharmony_ci state->CH_Ctrl[5].bit[2] = 2; 125662306a36Sopenharmony_ci state->CH_Ctrl[5].val[2] = 0; 125762306a36Sopenharmony_ci state->CH_Ctrl[5].addr[3] = 70; 125862306a36Sopenharmony_ci state->CH_Ctrl[5].bit[3] = 3; 125962306a36Sopenharmony_ci state->CH_Ctrl[5].val[3] = 0; 126062306a36Sopenharmony_ci 126162306a36Sopenharmony_ci state->CH_Ctrl[6].Ctrl_Num = DN_IQTNGNBFBIAS_BST ; 126262306a36Sopenharmony_ci state->CH_Ctrl[6].size = 1 ; 126362306a36Sopenharmony_ci state->CH_Ctrl[6].addr[0] = 70; 126462306a36Sopenharmony_ci state->CH_Ctrl[6].bit[0] = 4; 126562306a36Sopenharmony_ci state->CH_Ctrl[6].val[0] = 1; 126662306a36Sopenharmony_ci 126762306a36Sopenharmony_ci state->CH_Ctrl[7].Ctrl_Num = RFSYN_EN_OUTMUX ; 126862306a36Sopenharmony_ci state->CH_Ctrl[7].size = 1 ; 126962306a36Sopenharmony_ci state->CH_Ctrl[7].addr[0] = 111; 127062306a36Sopenharmony_ci state->CH_Ctrl[7].bit[0] = 4; 127162306a36Sopenharmony_ci state->CH_Ctrl[7].val[0] = 0; 127262306a36Sopenharmony_ci 127362306a36Sopenharmony_ci state->CH_Ctrl[8].Ctrl_Num = RFSYN_SEL_VCO_OUT ; 127462306a36Sopenharmony_ci state->CH_Ctrl[8].size = 1 ; 127562306a36Sopenharmony_ci state->CH_Ctrl[8].addr[0] = 111; 127662306a36Sopenharmony_ci state->CH_Ctrl[8].bit[0] = 7; 127762306a36Sopenharmony_ci state->CH_Ctrl[8].val[0] = 1; 127862306a36Sopenharmony_ci 127962306a36Sopenharmony_ci state->CH_Ctrl[9].Ctrl_Num = RFSYN_SEL_VCO_HI ; 128062306a36Sopenharmony_ci state->CH_Ctrl[9].size = 1 ; 128162306a36Sopenharmony_ci state->CH_Ctrl[9].addr[0] = 111; 128262306a36Sopenharmony_ci state->CH_Ctrl[9].bit[0] = 6; 128362306a36Sopenharmony_ci state->CH_Ctrl[9].val[0] = 1; 128462306a36Sopenharmony_ci 128562306a36Sopenharmony_ci state->CH_Ctrl[10].Ctrl_Num = RFSYN_SEL_DIVM ; 128662306a36Sopenharmony_ci state->CH_Ctrl[10].size = 1 ; 128762306a36Sopenharmony_ci state->CH_Ctrl[10].addr[0] = 111; 128862306a36Sopenharmony_ci state->CH_Ctrl[10].bit[0] = 5; 128962306a36Sopenharmony_ci state->CH_Ctrl[10].val[0] = 0; 129062306a36Sopenharmony_ci 129162306a36Sopenharmony_ci state->CH_Ctrl[11].Ctrl_Num = RFSYN_RF_DIV_BIAS ; 129262306a36Sopenharmony_ci state->CH_Ctrl[11].size = 2 ; 129362306a36Sopenharmony_ci state->CH_Ctrl[11].addr[0] = 110; 129462306a36Sopenharmony_ci state->CH_Ctrl[11].bit[0] = 0; 129562306a36Sopenharmony_ci state->CH_Ctrl[11].val[0] = 1; 129662306a36Sopenharmony_ci state->CH_Ctrl[11].addr[1] = 110; 129762306a36Sopenharmony_ci state->CH_Ctrl[11].bit[1] = 1; 129862306a36Sopenharmony_ci state->CH_Ctrl[11].val[1] = 0; 129962306a36Sopenharmony_ci 130062306a36Sopenharmony_ci state->CH_Ctrl[12].Ctrl_Num = DN_SEL_FREQ ; 130162306a36Sopenharmony_ci state->CH_Ctrl[12].size = 3 ; 130262306a36Sopenharmony_ci state->CH_Ctrl[12].addr[0] = 69; 130362306a36Sopenharmony_ci state->CH_Ctrl[12].bit[0] = 2; 130462306a36Sopenharmony_ci state->CH_Ctrl[12].val[0] = 0; 130562306a36Sopenharmony_ci state->CH_Ctrl[12].addr[1] = 69; 130662306a36Sopenharmony_ci state->CH_Ctrl[12].bit[1] = 3; 130762306a36Sopenharmony_ci state->CH_Ctrl[12].val[1] = 0; 130862306a36Sopenharmony_ci state->CH_Ctrl[12].addr[2] = 69; 130962306a36Sopenharmony_ci state->CH_Ctrl[12].bit[2] = 4; 131062306a36Sopenharmony_ci state->CH_Ctrl[12].val[2] = 0; 131162306a36Sopenharmony_ci 131262306a36Sopenharmony_ci state->CH_Ctrl[13].Ctrl_Num = RFSYN_VCO_BIAS ; 131362306a36Sopenharmony_ci state->CH_Ctrl[13].size = 6 ; 131462306a36Sopenharmony_ci state->CH_Ctrl[13].addr[0] = 110; 131562306a36Sopenharmony_ci state->CH_Ctrl[13].bit[0] = 2; 131662306a36Sopenharmony_ci state->CH_Ctrl[13].val[0] = 0; 131762306a36Sopenharmony_ci state->CH_Ctrl[13].addr[1] = 110; 131862306a36Sopenharmony_ci state->CH_Ctrl[13].bit[1] = 3; 131962306a36Sopenharmony_ci state->CH_Ctrl[13].val[1] = 0; 132062306a36Sopenharmony_ci state->CH_Ctrl[13].addr[2] = 110; 132162306a36Sopenharmony_ci state->CH_Ctrl[13].bit[2] = 4; 132262306a36Sopenharmony_ci state->CH_Ctrl[13].val[2] = 0; 132362306a36Sopenharmony_ci state->CH_Ctrl[13].addr[3] = 110; 132462306a36Sopenharmony_ci state->CH_Ctrl[13].bit[3] = 5; 132562306a36Sopenharmony_ci state->CH_Ctrl[13].val[3] = 0; 132662306a36Sopenharmony_ci state->CH_Ctrl[13].addr[4] = 110; 132762306a36Sopenharmony_ci state->CH_Ctrl[13].bit[4] = 6; 132862306a36Sopenharmony_ci state->CH_Ctrl[13].val[4] = 0; 132962306a36Sopenharmony_ci state->CH_Ctrl[13].addr[5] = 110; 133062306a36Sopenharmony_ci state->CH_Ctrl[13].bit[5] = 7; 133162306a36Sopenharmony_ci state->CH_Ctrl[13].val[5] = 1; 133262306a36Sopenharmony_ci 133362306a36Sopenharmony_ci state->CH_Ctrl[14].Ctrl_Num = CHCAL_INT_MOD_RF ; 133462306a36Sopenharmony_ci state->CH_Ctrl[14].size = 7 ; 133562306a36Sopenharmony_ci state->CH_Ctrl[14].addr[0] = 14; 133662306a36Sopenharmony_ci state->CH_Ctrl[14].bit[0] = 0; 133762306a36Sopenharmony_ci state->CH_Ctrl[14].val[0] = 0; 133862306a36Sopenharmony_ci state->CH_Ctrl[14].addr[1] = 14; 133962306a36Sopenharmony_ci state->CH_Ctrl[14].bit[1] = 1; 134062306a36Sopenharmony_ci state->CH_Ctrl[14].val[1] = 0; 134162306a36Sopenharmony_ci state->CH_Ctrl[14].addr[2] = 14; 134262306a36Sopenharmony_ci state->CH_Ctrl[14].bit[2] = 2; 134362306a36Sopenharmony_ci state->CH_Ctrl[14].val[2] = 0; 134462306a36Sopenharmony_ci state->CH_Ctrl[14].addr[3] = 14; 134562306a36Sopenharmony_ci state->CH_Ctrl[14].bit[3] = 3; 134662306a36Sopenharmony_ci state->CH_Ctrl[14].val[3] = 0; 134762306a36Sopenharmony_ci state->CH_Ctrl[14].addr[4] = 14; 134862306a36Sopenharmony_ci state->CH_Ctrl[14].bit[4] = 4; 134962306a36Sopenharmony_ci state->CH_Ctrl[14].val[4] = 0; 135062306a36Sopenharmony_ci state->CH_Ctrl[14].addr[5] = 14; 135162306a36Sopenharmony_ci state->CH_Ctrl[14].bit[5] = 5; 135262306a36Sopenharmony_ci state->CH_Ctrl[14].val[5] = 0; 135362306a36Sopenharmony_ci state->CH_Ctrl[14].addr[6] = 14; 135462306a36Sopenharmony_ci state->CH_Ctrl[14].bit[6] = 6; 135562306a36Sopenharmony_ci state->CH_Ctrl[14].val[6] = 0; 135662306a36Sopenharmony_ci 135762306a36Sopenharmony_ci state->CH_Ctrl[15].Ctrl_Num = CHCAL_FRAC_MOD_RF ; 135862306a36Sopenharmony_ci state->CH_Ctrl[15].size = 18 ; 135962306a36Sopenharmony_ci state->CH_Ctrl[15].addr[0] = 17; 136062306a36Sopenharmony_ci state->CH_Ctrl[15].bit[0] = 6; 136162306a36Sopenharmony_ci state->CH_Ctrl[15].val[0] = 0; 136262306a36Sopenharmony_ci state->CH_Ctrl[15].addr[1] = 17; 136362306a36Sopenharmony_ci state->CH_Ctrl[15].bit[1] = 7; 136462306a36Sopenharmony_ci state->CH_Ctrl[15].val[1] = 0; 136562306a36Sopenharmony_ci state->CH_Ctrl[15].addr[2] = 16; 136662306a36Sopenharmony_ci state->CH_Ctrl[15].bit[2] = 0; 136762306a36Sopenharmony_ci state->CH_Ctrl[15].val[2] = 0; 136862306a36Sopenharmony_ci state->CH_Ctrl[15].addr[3] = 16; 136962306a36Sopenharmony_ci state->CH_Ctrl[15].bit[3] = 1; 137062306a36Sopenharmony_ci state->CH_Ctrl[15].val[3] = 0; 137162306a36Sopenharmony_ci state->CH_Ctrl[15].addr[4] = 16; 137262306a36Sopenharmony_ci state->CH_Ctrl[15].bit[4] = 2; 137362306a36Sopenharmony_ci state->CH_Ctrl[15].val[4] = 0; 137462306a36Sopenharmony_ci state->CH_Ctrl[15].addr[5] = 16; 137562306a36Sopenharmony_ci state->CH_Ctrl[15].bit[5] = 3; 137662306a36Sopenharmony_ci state->CH_Ctrl[15].val[5] = 0; 137762306a36Sopenharmony_ci state->CH_Ctrl[15].addr[6] = 16; 137862306a36Sopenharmony_ci state->CH_Ctrl[15].bit[6] = 4; 137962306a36Sopenharmony_ci state->CH_Ctrl[15].val[6] = 0; 138062306a36Sopenharmony_ci state->CH_Ctrl[15].addr[7] = 16; 138162306a36Sopenharmony_ci state->CH_Ctrl[15].bit[7] = 5; 138262306a36Sopenharmony_ci state->CH_Ctrl[15].val[7] = 0; 138362306a36Sopenharmony_ci state->CH_Ctrl[15].addr[8] = 16; 138462306a36Sopenharmony_ci state->CH_Ctrl[15].bit[8] = 6; 138562306a36Sopenharmony_ci state->CH_Ctrl[15].val[8] = 0; 138662306a36Sopenharmony_ci state->CH_Ctrl[15].addr[9] = 16; 138762306a36Sopenharmony_ci state->CH_Ctrl[15].bit[9] = 7; 138862306a36Sopenharmony_ci state->CH_Ctrl[15].val[9] = 0; 138962306a36Sopenharmony_ci state->CH_Ctrl[15].addr[10] = 15; 139062306a36Sopenharmony_ci state->CH_Ctrl[15].bit[10] = 0; 139162306a36Sopenharmony_ci state->CH_Ctrl[15].val[10] = 0; 139262306a36Sopenharmony_ci state->CH_Ctrl[15].addr[11] = 15; 139362306a36Sopenharmony_ci state->CH_Ctrl[15].bit[11] = 1; 139462306a36Sopenharmony_ci state->CH_Ctrl[15].val[11] = 0; 139562306a36Sopenharmony_ci state->CH_Ctrl[15].addr[12] = 15; 139662306a36Sopenharmony_ci state->CH_Ctrl[15].bit[12] = 2; 139762306a36Sopenharmony_ci state->CH_Ctrl[15].val[12] = 0; 139862306a36Sopenharmony_ci state->CH_Ctrl[15].addr[13] = 15; 139962306a36Sopenharmony_ci state->CH_Ctrl[15].bit[13] = 3; 140062306a36Sopenharmony_ci state->CH_Ctrl[15].val[13] = 0; 140162306a36Sopenharmony_ci state->CH_Ctrl[15].addr[14] = 15; 140262306a36Sopenharmony_ci state->CH_Ctrl[15].bit[14] = 4; 140362306a36Sopenharmony_ci state->CH_Ctrl[15].val[14] = 0; 140462306a36Sopenharmony_ci state->CH_Ctrl[15].addr[15] = 15; 140562306a36Sopenharmony_ci state->CH_Ctrl[15].bit[15] = 5; 140662306a36Sopenharmony_ci state->CH_Ctrl[15].val[15] = 0; 140762306a36Sopenharmony_ci state->CH_Ctrl[15].addr[16] = 15; 140862306a36Sopenharmony_ci state->CH_Ctrl[15].bit[16] = 6; 140962306a36Sopenharmony_ci state->CH_Ctrl[15].val[16] = 1; 141062306a36Sopenharmony_ci state->CH_Ctrl[15].addr[17] = 15; 141162306a36Sopenharmony_ci state->CH_Ctrl[15].bit[17] = 7; 141262306a36Sopenharmony_ci state->CH_Ctrl[15].val[17] = 1; 141362306a36Sopenharmony_ci 141462306a36Sopenharmony_ci state->CH_Ctrl[16].Ctrl_Num = RFSYN_LPF_R ; 141562306a36Sopenharmony_ci state->CH_Ctrl[16].size = 5 ; 141662306a36Sopenharmony_ci state->CH_Ctrl[16].addr[0] = 112; 141762306a36Sopenharmony_ci state->CH_Ctrl[16].bit[0] = 0; 141862306a36Sopenharmony_ci state->CH_Ctrl[16].val[0] = 0; 141962306a36Sopenharmony_ci state->CH_Ctrl[16].addr[1] = 112; 142062306a36Sopenharmony_ci state->CH_Ctrl[16].bit[1] = 1; 142162306a36Sopenharmony_ci state->CH_Ctrl[16].val[1] = 0; 142262306a36Sopenharmony_ci state->CH_Ctrl[16].addr[2] = 112; 142362306a36Sopenharmony_ci state->CH_Ctrl[16].bit[2] = 2; 142462306a36Sopenharmony_ci state->CH_Ctrl[16].val[2] = 0; 142562306a36Sopenharmony_ci state->CH_Ctrl[16].addr[3] = 112; 142662306a36Sopenharmony_ci state->CH_Ctrl[16].bit[3] = 3; 142762306a36Sopenharmony_ci state->CH_Ctrl[16].val[3] = 0; 142862306a36Sopenharmony_ci state->CH_Ctrl[16].addr[4] = 112; 142962306a36Sopenharmony_ci state->CH_Ctrl[16].bit[4] = 4; 143062306a36Sopenharmony_ci state->CH_Ctrl[16].val[4] = 1; 143162306a36Sopenharmony_ci 143262306a36Sopenharmony_ci state->CH_Ctrl[17].Ctrl_Num = CHCAL_EN_INT_RF ; 143362306a36Sopenharmony_ci state->CH_Ctrl[17].size = 1 ; 143462306a36Sopenharmony_ci state->CH_Ctrl[17].addr[0] = 14; 143562306a36Sopenharmony_ci state->CH_Ctrl[17].bit[0] = 7; 143662306a36Sopenharmony_ci state->CH_Ctrl[17].val[0] = 0; 143762306a36Sopenharmony_ci 143862306a36Sopenharmony_ci state->CH_Ctrl[18].Ctrl_Num = TG_LO_DIVVAL ; 143962306a36Sopenharmony_ci state->CH_Ctrl[18].size = 4 ; 144062306a36Sopenharmony_ci state->CH_Ctrl[18].addr[0] = 107; 144162306a36Sopenharmony_ci state->CH_Ctrl[18].bit[0] = 3; 144262306a36Sopenharmony_ci state->CH_Ctrl[18].val[0] = 0; 144362306a36Sopenharmony_ci state->CH_Ctrl[18].addr[1] = 107; 144462306a36Sopenharmony_ci state->CH_Ctrl[18].bit[1] = 4; 144562306a36Sopenharmony_ci state->CH_Ctrl[18].val[1] = 0; 144662306a36Sopenharmony_ci state->CH_Ctrl[18].addr[2] = 107; 144762306a36Sopenharmony_ci state->CH_Ctrl[18].bit[2] = 5; 144862306a36Sopenharmony_ci state->CH_Ctrl[18].val[2] = 0; 144962306a36Sopenharmony_ci state->CH_Ctrl[18].addr[3] = 107; 145062306a36Sopenharmony_ci state->CH_Ctrl[18].bit[3] = 6; 145162306a36Sopenharmony_ci state->CH_Ctrl[18].val[3] = 0; 145262306a36Sopenharmony_ci 145362306a36Sopenharmony_ci state->CH_Ctrl[19].Ctrl_Num = TG_LO_SELVAL ; 145462306a36Sopenharmony_ci state->CH_Ctrl[19].size = 3 ; 145562306a36Sopenharmony_ci state->CH_Ctrl[19].addr[0] = 107; 145662306a36Sopenharmony_ci state->CH_Ctrl[19].bit[0] = 7; 145762306a36Sopenharmony_ci state->CH_Ctrl[19].val[0] = 1; 145862306a36Sopenharmony_ci state->CH_Ctrl[19].addr[1] = 106; 145962306a36Sopenharmony_ci state->CH_Ctrl[19].bit[1] = 0; 146062306a36Sopenharmony_ci state->CH_Ctrl[19].val[1] = 1; 146162306a36Sopenharmony_ci state->CH_Ctrl[19].addr[2] = 106; 146262306a36Sopenharmony_ci state->CH_Ctrl[19].bit[2] = 1; 146362306a36Sopenharmony_ci state->CH_Ctrl[19].val[2] = 1; 146462306a36Sopenharmony_ci 146562306a36Sopenharmony_ci state->CH_Ctrl[20].Ctrl_Num = TG_DIV_VAL ; 146662306a36Sopenharmony_ci state->CH_Ctrl[20].size = 11 ; 146762306a36Sopenharmony_ci state->CH_Ctrl[20].addr[0] = 109; 146862306a36Sopenharmony_ci state->CH_Ctrl[20].bit[0] = 2; 146962306a36Sopenharmony_ci state->CH_Ctrl[20].val[0] = 0; 147062306a36Sopenharmony_ci state->CH_Ctrl[20].addr[1] = 109; 147162306a36Sopenharmony_ci state->CH_Ctrl[20].bit[1] = 3; 147262306a36Sopenharmony_ci state->CH_Ctrl[20].val[1] = 0; 147362306a36Sopenharmony_ci state->CH_Ctrl[20].addr[2] = 109; 147462306a36Sopenharmony_ci state->CH_Ctrl[20].bit[2] = 4; 147562306a36Sopenharmony_ci state->CH_Ctrl[20].val[2] = 0; 147662306a36Sopenharmony_ci state->CH_Ctrl[20].addr[3] = 109; 147762306a36Sopenharmony_ci state->CH_Ctrl[20].bit[3] = 5; 147862306a36Sopenharmony_ci state->CH_Ctrl[20].val[3] = 0; 147962306a36Sopenharmony_ci state->CH_Ctrl[20].addr[4] = 109; 148062306a36Sopenharmony_ci state->CH_Ctrl[20].bit[4] = 6; 148162306a36Sopenharmony_ci state->CH_Ctrl[20].val[4] = 0; 148262306a36Sopenharmony_ci state->CH_Ctrl[20].addr[5] = 109; 148362306a36Sopenharmony_ci state->CH_Ctrl[20].bit[5] = 7; 148462306a36Sopenharmony_ci state->CH_Ctrl[20].val[5] = 0; 148562306a36Sopenharmony_ci state->CH_Ctrl[20].addr[6] = 108; 148662306a36Sopenharmony_ci state->CH_Ctrl[20].bit[6] = 0; 148762306a36Sopenharmony_ci state->CH_Ctrl[20].val[6] = 0; 148862306a36Sopenharmony_ci state->CH_Ctrl[20].addr[7] = 108; 148962306a36Sopenharmony_ci state->CH_Ctrl[20].bit[7] = 1; 149062306a36Sopenharmony_ci state->CH_Ctrl[20].val[7] = 0; 149162306a36Sopenharmony_ci state->CH_Ctrl[20].addr[8] = 108; 149262306a36Sopenharmony_ci state->CH_Ctrl[20].bit[8] = 2; 149362306a36Sopenharmony_ci state->CH_Ctrl[20].val[8] = 1; 149462306a36Sopenharmony_ci state->CH_Ctrl[20].addr[9] = 108; 149562306a36Sopenharmony_ci state->CH_Ctrl[20].bit[9] = 3; 149662306a36Sopenharmony_ci state->CH_Ctrl[20].val[9] = 1; 149762306a36Sopenharmony_ci state->CH_Ctrl[20].addr[10] = 108; 149862306a36Sopenharmony_ci state->CH_Ctrl[20].bit[10] = 4; 149962306a36Sopenharmony_ci state->CH_Ctrl[20].val[10] = 1; 150062306a36Sopenharmony_ci 150162306a36Sopenharmony_ci state->CH_Ctrl[21].Ctrl_Num = TG_VCO_BIAS ; 150262306a36Sopenharmony_ci state->CH_Ctrl[21].size = 6 ; 150362306a36Sopenharmony_ci state->CH_Ctrl[21].addr[0] = 106; 150462306a36Sopenharmony_ci state->CH_Ctrl[21].bit[0] = 2; 150562306a36Sopenharmony_ci state->CH_Ctrl[21].val[0] = 0; 150662306a36Sopenharmony_ci state->CH_Ctrl[21].addr[1] = 106; 150762306a36Sopenharmony_ci state->CH_Ctrl[21].bit[1] = 3; 150862306a36Sopenharmony_ci state->CH_Ctrl[21].val[1] = 0; 150962306a36Sopenharmony_ci state->CH_Ctrl[21].addr[2] = 106; 151062306a36Sopenharmony_ci state->CH_Ctrl[21].bit[2] = 4; 151162306a36Sopenharmony_ci state->CH_Ctrl[21].val[2] = 0; 151262306a36Sopenharmony_ci state->CH_Ctrl[21].addr[3] = 106; 151362306a36Sopenharmony_ci state->CH_Ctrl[21].bit[3] = 5; 151462306a36Sopenharmony_ci state->CH_Ctrl[21].val[3] = 0; 151562306a36Sopenharmony_ci state->CH_Ctrl[21].addr[4] = 106; 151662306a36Sopenharmony_ci state->CH_Ctrl[21].bit[4] = 6; 151762306a36Sopenharmony_ci state->CH_Ctrl[21].val[4] = 0; 151862306a36Sopenharmony_ci state->CH_Ctrl[21].addr[5] = 106; 151962306a36Sopenharmony_ci state->CH_Ctrl[21].bit[5] = 7; 152062306a36Sopenharmony_ci state->CH_Ctrl[21].val[5] = 1; 152162306a36Sopenharmony_ci 152262306a36Sopenharmony_ci state->CH_Ctrl[22].Ctrl_Num = SEQ_EXTPOWERUP ; 152362306a36Sopenharmony_ci state->CH_Ctrl[22].size = 1 ; 152462306a36Sopenharmony_ci state->CH_Ctrl[22].addr[0] = 138; 152562306a36Sopenharmony_ci state->CH_Ctrl[22].bit[0] = 4; 152662306a36Sopenharmony_ci state->CH_Ctrl[22].val[0] = 1; 152762306a36Sopenharmony_ci 152862306a36Sopenharmony_ci state->CH_Ctrl[23].Ctrl_Num = OVERRIDE_2 ; 152962306a36Sopenharmony_ci state->CH_Ctrl[23].size = 1 ; 153062306a36Sopenharmony_ci state->CH_Ctrl[23].addr[0] = 17; 153162306a36Sopenharmony_ci state->CH_Ctrl[23].bit[0] = 5; 153262306a36Sopenharmony_ci state->CH_Ctrl[23].val[0] = 0; 153362306a36Sopenharmony_ci 153462306a36Sopenharmony_ci state->CH_Ctrl[24].Ctrl_Num = OVERRIDE_3 ; 153562306a36Sopenharmony_ci state->CH_Ctrl[24].size = 1 ; 153662306a36Sopenharmony_ci state->CH_Ctrl[24].addr[0] = 111; 153762306a36Sopenharmony_ci state->CH_Ctrl[24].bit[0] = 3; 153862306a36Sopenharmony_ci state->CH_Ctrl[24].val[0] = 0; 153962306a36Sopenharmony_ci 154062306a36Sopenharmony_ci state->CH_Ctrl[25].Ctrl_Num = OVERRIDE_4 ; 154162306a36Sopenharmony_ci state->CH_Ctrl[25].size = 1 ; 154262306a36Sopenharmony_ci state->CH_Ctrl[25].addr[0] = 112; 154362306a36Sopenharmony_ci state->CH_Ctrl[25].bit[0] = 7; 154462306a36Sopenharmony_ci state->CH_Ctrl[25].val[0] = 0; 154562306a36Sopenharmony_ci 154662306a36Sopenharmony_ci state->CH_Ctrl[26].Ctrl_Num = SEQ_FSM_PULSE ; 154762306a36Sopenharmony_ci state->CH_Ctrl[26].size = 1 ; 154862306a36Sopenharmony_ci state->CH_Ctrl[26].addr[0] = 136; 154962306a36Sopenharmony_ci state->CH_Ctrl[26].bit[0] = 7; 155062306a36Sopenharmony_ci state->CH_Ctrl[26].val[0] = 0; 155162306a36Sopenharmony_ci 155262306a36Sopenharmony_ci state->CH_Ctrl[27].Ctrl_Num = GPIO_4B ; 155362306a36Sopenharmony_ci state->CH_Ctrl[27].size = 1 ; 155462306a36Sopenharmony_ci state->CH_Ctrl[27].addr[0] = 149; 155562306a36Sopenharmony_ci state->CH_Ctrl[27].bit[0] = 7; 155662306a36Sopenharmony_ci state->CH_Ctrl[27].val[0] = 0; 155762306a36Sopenharmony_ci 155862306a36Sopenharmony_ci state->CH_Ctrl[28].Ctrl_Num = GPIO_3B ; 155962306a36Sopenharmony_ci state->CH_Ctrl[28].size = 1 ; 156062306a36Sopenharmony_ci state->CH_Ctrl[28].addr[0] = 149; 156162306a36Sopenharmony_ci state->CH_Ctrl[28].bit[0] = 6; 156262306a36Sopenharmony_ci state->CH_Ctrl[28].val[0] = 0; 156362306a36Sopenharmony_ci 156462306a36Sopenharmony_ci state->CH_Ctrl[29].Ctrl_Num = GPIO_4 ; 156562306a36Sopenharmony_ci state->CH_Ctrl[29].size = 1 ; 156662306a36Sopenharmony_ci state->CH_Ctrl[29].addr[0] = 149; 156762306a36Sopenharmony_ci state->CH_Ctrl[29].bit[0] = 5; 156862306a36Sopenharmony_ci state->CH_Ctrl[29].val[0] = 1; 156962306a36Sopenharmony_ci 157062306a36Sopenharmony_ci state->CH_Ctrl[30].Ctrl_Num = GPIO_3 ; 157162306a36Sopenharmony_ci state->CH_Ctrl[30].size = 1 ; 157262306a36Sopenharmony_ci state->CH_Ctrl[30].addr[0] = 149; 157362306a36Sopenharmony_ci state->CH_Ctrl[30].bit[0] = 4; 157462306a36Sopenharmony_ci state->CH_Ctrl[30].val[0] = 1; 157562306a36Sopenharmony_ci 157662306a36Sopenharmony_ci state->CH_Ctrl[31].Ctrl_Num = GPIO_1B ; 157762306a36Sopenharmony_ci state->CH_Ctrl[31].size = 1 ; 157862306a36Sopenharmony_ci state->CH_Ctrl[31].addr[0] = 149; 157962306a36Sopenharmony_ci state->CH_Ctrl[31].bit[0] = 3; 158062306a36Sopenharmony_ci state->CH_Ctrl[31].val[0] = 0; 158162306a36Sopenharmony_ci 158262306a36Sopenharmony_ci state->CH_Ctrl[32].Ctrl_Num = DAC_A_ENABLE ; 158362306a36Sopenharmony_ci state->CH_Ctrl[32].size = 1 ; 158462306a36Sopenharmony_ci state->CH_Ctrl[32].addr[0] = 93; 158562306a36Sopenharmony_ci state->CH_Ctrl[32].bit[0] = 1; 158662306a36Sopenharmony_ci state->CH_Ctrl[32].val[0] = 0; 158762306a36Sopenharmony_ci 158862306a36Sopenharmony_ci state->CH_Ctrl[33].Ctrl_Num = DAC_B_ENABLE ; 158962306a36Sopenharmony_ci state->CH_Ctrl[33].size = 1 ; 159062306a36Sopenharmony_ci state->CH_Ctrl[33].addr[0] = 93; 159162306a36Sopenharmony_ci state->CH_Ctrl[33].bit[0] = 0; 159262306a36Sopenharmony_ci state->CH_Ctrl[33].val[0] = 0; 159362306a36Sopenharmony_ci 159462306a36Sopenharmony_ci state->CH_Ctrl[34].Ctrl_Num = DAC_DIN_A ; 159562306a36Sopenharmony_ci state->CH_Ctrl[34].size = 6 ; 159662306a36Sopenharmony_ci state->CH_Ctrl[34].addr[0] = 92; 159762306a36Sopenharmony_ci state->CH_Ctrl[34].bit[0] = 2; 159862306a36Sopenharmony_ci state->CH_Ctrl[34].val[0] = 0; 159962306a36Sopenharmony_ci state->CH_Ctrl[34].addr[1] = 92; 160062306a36Sopenharmony_ci state->CH_Ctrl[34].bit[1] = 3; 160162306a36Sopenharmony_ci state->CH_Ctrl[34].val[1] = 0; 160262306a36Sopenharmony_ci state->CH_Ctrl[34].addr[2] = 92; 160362306a36Sopenharmony_ci state->CH_Ctrl[34].bit[2] = 4; 160462306a36Sopenharmony_ci state->CH_Ctrl[34].val[2] = 0; 160562306a36Sopenharmony_ci state->CH_Ctrl[34].addr[3] = 92; 160662306a36Sopenharmony_ci state->CH_Ctrl[34].bit[3] = 5; 160762306a36Sopenharmony_ci state->CH_Ctrl[34].val[3] = 0; 160862306a36Sopenharmony_ci state->CH_Ctrl[34].addr[4] = 92; 160962306a36Sopenharmony_ci state->CH_Ctrl[34].bit[4] = 6; 161062306a36Sopenharmony_ci state->CH_Ctrl[34].val[4] = 0; 161162306a36Sopenharmony_ci state->CH_Ctrl[34].addr[5] = 92; 161262306a36Sopenharmony_ci state->CH_Ctrl[34].bit[5] = 7; 161362306a36Sopenharmony_ci state->CH_Ctrl[34].val[5] = 0; 161462306a36Sopenharmony_ci 161562306a36Sopenharmony_ci state->CH_Ctrl[35].Ctrl_Num = DAC_DIN_B ; 161662306a36Sopenharmony_ci state->CH_Ctrl[35].size = 6 ; 161762306a36Sopenharmony_ci state->CH_Ctrl[35].addr[0] = 93; 161862306a36Sopenharmony_ci state->CH_Ctrl[35].bit[0] = 2; 161962306a36Sopenharmony_ci state->CH_Ctrl[35].val[0] = 0; 162062306a36Sopenharmony_ci state->CH_Ctrl[35].addr[1] = 93; 162162306a36Sopenharmony_ci state->CH_Ctrl[35].bit[1] = 3; 162262306a36Sopenharmony_ci state->CH_Ctrl[35].val[1] = 0; 162362306a36Sopenharmony_ci state->CH_Ctrl[35].addr[2] = 93; 162462306a36Sopenharmony_ci state->CH_Ctrl[35].bit[2] = 4; 162562306a36Sopenharmony_ci state->CH_Ctrl[35].val[2] = 0; 162662306a36Sopenharmony_ci state->CH_Ctrl[35].addr[3] = 93; 162762306a36Sopenharmony_ci state->CH_Ctrl[35].bit[3] = 5; 162862306a36Sopenharmony_ci state->CH_Ctrl[35].val[3] = 0; 162962306a36Sopenharmony_ci state->CH_Ctrl[35].addr[4] = 93; 163062306a36Sopenharmony_ci state->CH_Ctrl[35].bit[4] = 6; 163162306a36Sopenharmony_ci state->CH_Ctrl[35].val[4] = 0; 163262306a36Sopenharmony_ci state->CH_Ctrl[35].addr[5] = 93; 163362306a36Sopenharmony_ci state->CH_Ctrl[35].bit[5] = 7; 163462306a36Sopenharmony_ci state->CH_Ctrl[35].val[5] = 0; 163562306a36Sopenharmony_ci 163662306a36Sopenharmony_ci#ifdef _MXL_PRODUCTION 163762306a36Sopenharmony_ci state->CH_Ctrl[36].Ctrl_Num = RFSYN_EN_DIV ; 163862306a36Sopenharmony_ci state->CH_Ctrl[36].size = 1 ; 163962306a36Sopenharmony_ci state->CH_Ctrl[36].addr[0] = 109; 164062306a36Sopenharmony_ci state->CH_Ctrl[36].bit[0] = 1; 164162306a36Sopenharmony_ci state->CH_Ctrl[36].val[0] = 1; 164262306a36Sopenharmony_ci 164362306a36Sopenharmony_ci state->CH_Ctrl[37].Ctrl_Num = RFSYN_DIVM ; 164462306a36Sopenharmony_ci state->CH_Ctrl[37].size = 2 ; 164562306a36Sopenharmony_ci state->CH_Ctrl[37].addr[0] = 112; 164662306a36Sopenharmony_ci state->CH_Ctrl[37].bit[0] = 5; 164762306a36Sopenharmony_ci state->CH_Ctrl[37].val[0] = 0; 164862306a36Sopenharmony_ci state->CH_Ctrl[37].addr[1] = 112; 164962306a36Sopenharmony_ci state->CH_Ctrl[37].bit[1] = 6; 165062306a36Sopenharmony_ci state->CH_Ctrl[37].val[1] = 0; 165162306a36Sopenharmony_ci 165262306a36Sopenharmony_ci state->CH_Ctrl[38].Ctrl_Num = DN_BYPASS_AGC_I2C ; 165362306a36Sopenharmony_ci state->CH_Ctrl[38].size = 1 ; 165462306a36Sopenharmony_ci state->CH_Ctrl[38].addr[0] = 65; 165562306a36Sopenharmony_ci state->CH_Ctrl[38].bit[0] = 1; 165662306a36Sopenharmony_ci state->CH_Ctrl[38].val[0] = 0; 165762306a36Sopenharmony_ci#endif 165862306a36Sopenharmony_ci 165962306a36Sopenharmony_ci return 0 ; 166062306a36Sopenharmony_ci} 166162306a36Sopenharmony_ci 166262306a36Sopenharmony_cistatic void InitTunerControls(struct dvb_frontend *fe) 166362306a36Sopenharmony_ci{ 166462306a36Sopenharmony_ci MXL5005_RegisterInit(fe); 166562306a36Sopenharmony_ci MXL5005_ControlInit(fe); 166662306a36Sopenharmony_ci#ifdef _MXL_INTERNAL 166762306a36Sopenharmony_ci MXL5005_MXLControlInit(fe); 166862306a36Sopenharmony_ci#endif 166962306a36Sopenharmony_ci} 167062306a36Sopenharmony_ci 167162306a36Sopenharmony_cistatic u16 MXL5005_TunerConfig(struct dvb_frontend *fe, 167262306a36Sopenharmony_ci u8 Mode, /* 0: Analog Mode ; 1: Digital Mode */ 167362306a36Sopenharmony_ci u8 IF_mode, /* for Analog Mode, 0: zero IF; 1: low IF */ 167462306a36Sopenharmony_ci u32 Bandwidth, /* filter channel bandwidth (6, 7, 8) */ 167562306a36Sopenharmony_ci u32 IF_out, /* Desired IF Out Frequency */ 167662306a36Sopenharmony_ci u32 Fxtal, /* XTAL Frequency */ 167762306a36Sopenharmony_ci u8 AGC_Mode, /* AGC Mode - Dual AGC: 0, Single AGC: 1 */ 167862306a36Sopenharmony_ci u16 TOP, /* 0: Dual AGC; Value: take over point */ 167962306a36Sopenharmony_ci u16 IF_OUT_LOAD, /* IF Out Load Resistor (200 / 300 Ohms) */ 168062306a36Sopenharmony_ci u8 CLOCK_OUT, /* 0: turn off clk out; 1: turn on clock out */ 168162306a36Sopenharmony_ci u8 DIV_OUT, /* 0: Div-1; 1: Div-4 */ 168262306a36Sopenharmony_ci u8 CAPSELECT, /* 0: disable On-Chip pulling cap; 1: enable */ 168362306a36Sopenharmony_ci u8 EN_RSSI, /* 0: disable RSSI; 1: enable RSSI */ 168462306a36Sopenharmony_ci 168562306a36Sopenharmony_ci /* Modulation Type; */ 168662306a36Sopenharmony_ci /* 0 - Default; 1 - DVB-T; 2 - ATSC; 3 - QAM; 4 - Analog Cable */ 168762306a36Sopenharmony_ci u8 Mod_Type, 168862306a36Sopenharmony_ci 168962306a36Sopenharmony_ci /* Tracking Filter */ 169062306a36Sopenharmony_ci /* 0 - Default; 1 - Off; 2 - Type C; 3 - Type C-H */ 169162306a36Sopenharmony_ci u8 TF_Type 169262306a36Sopenharmony_ci ) 169362306a36Sopenharmony_ci{ 169462306a36Sopenharmony_ci struct mxl5005s_state *state = fe->tuner_priv; 169562306a36Sopenharmony_ci 169662306a36Sopenharmony_ci state->Mode = Mode; 169762306a36Sopenharmony_ci state->IF_Mode = IF_mode; 169862306a36Sopenharmony_ci state->Chan_Bandwidth = Bandwidth; 169962306a36Sopenharmony_ci state->IF_OUT = IF_out; 170062306a36Sopenharmony_ci state->Fxtal = Fxtal; 170162306a36Sopenharmony_ci state->AGC_Mode = AGC_Mode; 170262306a36Sopenharmony_ci state->TOP = TOP; 170362306a36Sopenharmony_ci state->IF_OUT_LOAD = IF_OUT_LOAD; 170462306a36Sopenharmony_ci state->CLOCK_OUT = CLOCK_OUT; 170562306a36Sopenharmony_ci state->DIV_OUT = DIV_OUT; 170662306a36Sopenharmony_ci state->CAPSELECT = CAPSELECT; 170762306a36Sopenharmony_ci state->EN_RSSI = EN_RSSI; 170862306a36Sopenharmony_ci state->Mod_Type = Mod_Type; 170962306a36Sopenharmony_ci state->TF_Type = TF_Type; 171062306a36Sopenharmony_ci 171162306a36Sopenharmony_ci /* Initialize all the controls and registers */ 171262306a36Sopenharmony_ci InitTunerControls(fe); 171362306a36Sopenharmony_ci 171462306a36Sopenharmony_ci /* Synthesizer LO frequency calculation */ 171562306a36Sopenharmony_ci MXL_SynthIFLO_Calc(fe); 171662306a36Sopenharmony_ci 171762306a36Sopenharmony_ci return 0; 171862306a36Sopenharmony_ci} 171962306a36Sopenharmony_ci 172062306a36Sopenharmony_cistatic void MXL_SynthIFLO_Calc(struct dvb_frontend *fe) 172162306a36Sopenharmony_ci{ 172262306a36Sopenharmony_ci struct mxl5005s_state *state = fe->tuner_priv; 172362306a36Sopenharmony_ci if (state->Mode == 1) /* Digital Mode */ 172462306a36Sopenharmony_ci state->IF_LO = state->IF_OUT; 172562306a36Sopenharmony_ci else /* Analog Mode */ { 172662306a36Sopenharmony_ci if (state->IF_Mode == 0) /* Analog Zero IF mode */ 172762306a36Sopenharmony_ci state->IF_LO = state->IF_OUT + 400000; 172862306a36Sopenharmony_ci else /* Analog Low IF mode */ 172962306a36Sopenharmony_ci state->IF_LO = state->IF_OUT + state->Chan_Bandwidth/2; 173062306a36Sopenharmony_ci } 173162306a36Sopenharmony_ci} 173262306a36Sopenharmony_ci 173362306a36Sopenharmony_cistatic void MXL_SynthRFTGLO_Calc(struct dvb_frontend *fe) 173462306a36Sopenharmony_ci{ 173562306a36Sopenharmony_ci struct mxl5005s_state *state = fe->tuner_priv; 173662306a36Sopenharmony_ci 173762306a36Sopenharmony_ci if (state->Mode == 1) /* Digital Mode */ { 173862306a36Sopenharmony_ci /* remove 20.48MHz setting for 2.6.10 */ 173962306a36Sopenharmony_ci state->RF_LO = state->RF_IN; 174062306a36Sopenharmony_ci /* change for 2.6.6 */ 174162306a36Sopenharmony_ci state->TG_LO = state->RF_IN - 750000; 174262306a36Sopenharmony_ci } else /* Analog Mode */ { 174362306a36Sopenharmony_ci if (state->IF_Mode == 0) /* Analog Zero IF mode */ { 174462306a36Sopenharmony_ci state->RF_LO = state->RF_IN - 400000; 174562306a36Sopenharmony_ci state->TG_LO = state->RF_IN - 1750000; 174662306a36Sopenharmony_ci } else /* Analog Low IF mode */ { 174762306a36Sopenharmony_ci state->RF_LO = state->RF_IN - state->Chan_Bandwidth/2; 174862306a36Sopenharmony_ci state->TG_LO = state->RF_IN - 174962306a36Sopenharmony_ci state->Chan_Bandwidth + 500000; 175062306a36Sopenharmony_ci } 175162306a36Sopenharmony_ci } 175262306a36Sopenharmony_ci} 175362306a36Sopenharmony_ci 175462306a36Sopenharmony_cistatic u16 MXL_OverwriteICDefault(struct dvb_frontend *fe) 175562306a36Sopenharmony_ci{ 175662306a36Sopenharmony_ci u16 status = 0; 175762306a36Sopenharmony_ci 175862306a36Sopenharmony_ci status += MXL_ControlWrite(fe, OVERRIDE_1, 1); 175962306a36Sopenharmony_ci status += MXL_ControlWrite(fe, OVERRIDE_2, 1); 176062306a36Sopenharmony_ci status += MXL_ControlWrite(fe, OVERRIDE_3, 1); 176162306a36Sopenharmony_ci status += MXL_ControlWrite(fe, OVERRIDE_4, 1); 176262306a36Sopenharmony_ci 176362306a36Sopenharmony_ci return status; 176462306a36Sopenharmony_ci} 176562306a36Sopenharmony_ci 176662306a36Sopenharmony_cistatic u16 MXL_BlockInit(struct dvb_frontend *fe) 176762306a36Sopenharmony_ci{ 176862306a36Sopenharmony_ci struct mxl5005s_state *state = fe->tuner_priv; 176962306a36Sopenharmony_ci u16 status = 0; 177062306a36Sopenharmony_ci 177162306a36Sopenharmony_ci status += MXL_OverwriteICDefault(fe); 177262306a36Sopenharmony_ci 177362306a36Sopenharmony_ci /* Downconverter Control Dig Ana */ 177462306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DN_IQTN_AMP_CUT, state->Mode ? 1 : 0); 177562306a36Sopenharmony_ci 177662306a36Sopenharmony_ci /* Filter Control Dig Ana */ 177762306a36Sopenharmony_ci status += MXL_ControlWrite(fe, BB_MODE, state->Mode ? 0 : 1); 177862306a36Sopenharmony_ci status += MXL_ControlWrite(fe, BB_BUF, state->Mode ? 3 : 2); 177962306a36Sopenharmony_ci status += MXL_ControlWrite(fe, BB_BUF_OA, state->Mode ? 1 : 0); 178062306a36Sopenharmony_ci status += MXL_ControlWrite(fe, BB_IQSWAP, state->Mode ? 0 : 1); 178162306a36Sopenharmony_ci status += MXL_ControlWrite(fe, BB_INITSTATE_DLPF_TUNE, 0); 178262306a36Sopenharmony_ci 178362306a36Sopenharmony_ci /* Initialize Low-Pass Filter */ 178462306a36Sopenharmony_ci if (state->Mode) { /* Digital Mode */ 178562306a36Sopenharmony_ci switch (state->Chan_Bandwidth) { 178662306a36Sopenharmony_ci case 8000000: 178762306a36Sopenharmony_ci status += MXL_ControlWrite(fe, BB_DLPF_BANDSEL, 0); 178862306a36Sopenharmony_ci break; 178962306a36Sopenharmony_ci case 7000000: 179062306a36Sopenharmony_ci status += MXL_ControlWrite(fe, BB_DLPF_BANDSEL, 2); 179162306a36Sopenharmony_ci break; 179262306a36Sopenharmony_ci case 6000000: 179362306a36Sopenharmony_ci status += MXL_ControlWrite(fe, 179462306a36Sopenharmony_ci BB_DLPF_BANDSEL, 3); 179562306a36Sopenharmony_ci break; 179662306a36Sopenharmony_ci } 179762306a36Sopenharmony_ci } else { /* Analog Mode */ 179862306a36Sopenharmony_ci switch (state->Chan_Bandwidth) { 179962306a36Sopenharmony_ci case 8000000: /* Low Zero */ 180062306a36Sopenharmony_ci status += MXL_ControlWrite(fe, BB_ALPF_BANDSELECT, 180162306a36Sopenharmony_ci (state->IF_Mode ? 0 : 3)); 180262306a36Sopenharmony_ci break; 180362306a36Sopenharmony_ci case 7000000: 180462306a36Sopenharmony_ci status += MXL_ControlWrite(fe, BB_ALPF_BANDSELECT, 180562306a36Sopenharmony_ci (state->IF_Mode ? 1 : 4)); 180662306a36Sopenharmony_ci break; 180762306a36Sopenharmony_ci case 6000000: 180862306a36Sopenharmony_ci status += MXL_ControlWrite(fe, BB_ALPF_BANDSELECT, 180962306a36Sopenharmony_ci (state->IF_Mode ? 2 : 5)); 181062306a36Sopenharmony_ci break; 181162306a36Sopenharmony_ci } 181262306a36Sopenharmony_ci } 181362306a36Sopenharmony_ci 181462306a36Sopenharmony_ci /* Charge Pump Control Dig Ana */ 181562306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFSYN_CHP_GAIN, state->Mode ? 5 : 8); 181662306a36Sopenharmony_ci status += MXL_ControlWrite(fe, 181762306a36Sopenharmony_ci RFSYN_EN_CHP_HIGAIN, state->Mode ? 1 : 1); 181862306a36Sopenharmony_ci status += MXL_ControlWrite(fe, EN_CHP_LIN_B, state->Mode ? 0 : 0); 181962306a36Sopenharmony_ci 182062306a36Sopenharmony_ci /* AGC TOP Control */ 182162306a36Sopenharmony_ci if (state->AGC_Mode == 0) /* Dual AGC */ { 182262306a36Sopenharmony_ci status += MXL_ControlWrite(fe, AGC_IF, 15); 182362306a36Sopenharmony_ci status += MXL_ControlWrite(fe, AGC_RF, 15); 182462306a36Sopenharmony_ci } else /* Single AGC Mode Dig Ana */ 182562306a36Sopenharmony_ci status += MXL_ControlWrite(fe, AGC_RF, state->Mode ? 15 : 12); 182662306a36Sopenharmony_ci 182762306a36Sopenharmony_ci if (state->TOP == 55) /* TOP == 5.5 */ 182862306a36Sopenharmony_ci status += MXL_ControlWrite(fe, AGC_IF, 0x0); 182962306a36Sopenharmony_ci 183062306a36Sopenharmony_ci if (state->TOP == 72) /* TOP == 7.2 */ 183162306a36Sopenharmony_ci status += MXL_ControlWrite(fe, AGC_IF, 0x1); 183262306a36Sopenharmony_ci 183362306a36Sopenharmony_ci if (state->TOP == 92) /* TOP == 9.2 */ 183462306a36Sopenharmony_ci status += MXL_ControlWrite(fe, AGC_IF, 0x2); 183562306a36Sopenharmony_ci 183662306a36Sopenharmony_ci if (state->TOP == 110) /* TOP == 11.0 */ 183762306a36Sopenharmony_ci status += MXL_ControlWrite(fe, AGC_IF, 0x3); 183862306a36Sopenharmony_ci 183962306a36Sopenharmony_ci if (state->TOP == 129) /* TOP == 12.9 */ 184062306a36Sopenharmony_ci status += MXL_ControlWrite(fe, AGC_IF, 0x4); 184162306a36Sopenharmony_ci 184262306a36Sopenharmony_ci if (state->TOP == 147) /* TOP == 14.7 */ 184362306a36Sopenharmony_ci status += MXL_ControlWrite(fe, AGC_IF, 0x5); 184462306a36Sopenharmony_ci 184562306a36Sopenharmony_ci if (state->TOP == 168) /* TOP == 16.8 */ 184662306a36Sopenharmony_ci status += MXL_ControlWrite(fe, AGC_IF, 0x6); 184762306a36Sopenharmony_ci 184862306a36Sopenharmony_ci if (state->TOP == 194) /* TOP == 19.4 */ 184962306a36Sopenharmony_ci status += MXL_ControlWrite(fe, AGC_IF, 0x7); 185062306a36Sopenharmony_ci 185162306a36Sopenharmony_ci if (state->TOP == 212) /* TOP == 21.2 */ 185262306a36Sopenharmony_ci status += MXL_ControlWrite(fe, AGC_IF, 0x9); 185362306a36Sopenharmony_ci 185462306a36Sopenharmony_ci if (state->TOP == 232) /* TOP == 23.2 */ 185562306a36Sopenharmony_ci status += MXL_ControlWrite(fe, AGC_IF, 0xA); 185662306a36Sopenharmony_ci 185762306a36Sopenharmony_ci if (state->TOP == 252) /* TOP == 25.2 */ 185862306a36Sopenharmony_ci status += MXL_ControlWrite(fe, AGC_IF, 0xB); 185962306a36Sopenharmony_ci 186062306a36Sopenharmony_ci if (state->TOP == 271) /* TOP == 27.1 */ 186162306a36Sopenharmony_ci status += MXL_ControlWrite(fe, AGC_IF, 0xC); 186262306a36Sopenharmony_ci 186362306a36Sopenharmony_ci if (state->TOP == 292) /* TOP == 29.2 */ 186462306a36Sopenharmony_ci status += MXL_ControlWrite(fe, AGC_IF, 0xD); 186562306a36Sopenharmony_ci 186662306a36Sopenharmony_ci if (state->TOP == 317) /* TOP == 31.7 */ 186762306a36Sopenharmony_ci status += MXL_ControlWrite(fe, AGC_IF, 0xE); 186862306a36Sopenharmony_ci 186962306a36Sopenharmony_ci if (state->TOP == 349) /* TOP == 34.9 */ 187062306a36Sopenharmony_ci status += MXL_ControlWrite(fe, AGC_IF, 0xF); 187162306a36Sopenharmony_ci 187262306a36Sopenharmony_ci /* IF Synthesizer Control */ 187362306a36Sopenharmony_ci status += MXL_IFSynthInit(fe); 187462306a36Sopenharmony_ci 187562306a36Sopenharmony_ci /* IF UpConverter Control */ 187662306a36Sopenharmony_ci if (state->IF_OUT_LOAD == 200) { 187762306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DRV_RES_SEL, 6); 187862306a36Sopenharmony_ci status += MXL_ControlWrite(fe, I_DRIVER, 2); 187962306a36Sopenharmony_ci } 188062306a36Sopenharmony_ci if (state->IF_OUT_LOAD == 300) { 188162306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DRV_RES_SEL, 4); 188262306a36Sopenharmony_ci status += MXL_ControlWrite(fe, I_DRIVER, 1); 188362306a36Sopenharmony_ci } 188462306a36Sopenharmony_ci 188562306a36Sopenharmony_ci /* Anti-Alias Filtering Control 188662306a36Sopenharmony_ci * initialise Anti-Aliasing Filter 188762306a36Sopenharmony_ci */ 188862306a36Sopenharmony_ci if (state->Mode) { /* Digital Mode */ 188962306a36Sopenharmony_ci if (state->IF_OUT >= 4000000UL && state->IF_OUT <= 6280000UL) { 189062306a36Sopenharmony_ci status += MXL_ControlWrite(fe, EN_AAF, 1); 189162306a36Sopenharmony_ci status += MXL_ControlWrite(fe, EN_3P, 1); 189262306a36Sopenharmony_ci status += MXL_ControlWrite(fe, EN_AUX_3P, 1); 189362306a36Sopenharmony_ci status += MXL_ControlWrite(fe, SEL_AAF_BAND, 0); 189462306a36Sopenharmony_ci } 189562306a36Sopenharmony_ci if ((state->IF_OUT == 36125000UL) || 189662306a36Sopenharmony_ci (state->IF_OUT == 36150000UL)) { 189762306a36Sopenharmony_ci status += MXL_ControlWrite(fe, EN_AAF, 1); 189862306a36Sopenharmony_ci status += MXL_ControlWrite(fe, EN_3P, 1); 189962306a36Sopenharmony_ci status += MXL_ControlWrite(fe, EN_AUX_3P, 1); 190062306a36Sopenharmony_ci status += MXL_ControlWrite(fe, SEL_AAF_BAND, 1); 190162306a36Sopenharmony_ci } 190262306a36Sopenharmony_ci if (state->IF_OUT > 36150000UL) { 190362306a36Sopenharmony_ci status += MXL_ControlWrite(fe, EN_AAF, 0); 190462306a36Sopenharmony_ci status += MXL_ControlWrite(fe, EN_3P, 1); 190562306a36Sopenharmony_ci status += MXL_ControlWrite(fe, EN_AUX_3P, 1); 190662306a36Sopenharmony_ci status += MXL_ControlWrite(fe, SEL_AAF_BAND, 1); 190762306a36Sopenharmony_ci } 190862306a36Sopenharmony_ci } else { /* Analog Mode */ 190962306a36Sopenharmony_ci if (state->IF_OUT >= 4000000UL && state->IF_OUT <= 5000000UL) { 191062306a36Sopenharmony_ci status += MXL_ControlWrite(fe, EN_AAF, 1); 191162306a36Sopenharmony_ci status += MXL_ControlWrite(fe, EN_3P, 1); 191262306a36Sopenharmony_ci status += MXL_ControlWrite(fe, EN_AUX_3P, 1); 191362306a36Sopenharmony_ci status += MXL_ControlWrite(fe, SEL_AAF_BAND, 0); 191462306a36Sopenharmony_ci } 191562306a36Sopenharmony_ci if (state->IF_OUT > 5000000UL) { 191662306a36Sopenharmony_ci status += MXL_ControlWrite(fe, EN_AAF, 0); 191762306a36Sopenharmony_ci status += MXL_ControlWrite(fe, EN_3P, 0); 191862306a36Sopenharmony_ci status += MXL_ControlWrite(fe, EN_AUX_3P, 0); 191962306a36Sopenharmony_ci status += MXL_ControlWrite(fe, SEL_AAF_BAND, 0); 192062306a36Sopenharmony_ci } 192162306a36Sopenharmony_ci } 192262306a36Sopenharmony_ci 192362306a36Sopenharmony_ci /* Demod Clock Out */ 192462306a36Sopenharmony_ci if (state->CLOCK_OUT) 192562306a36Sopenharmony_ci status += MXL_ControlWrite(fe, SEQ_ENCLK16_CLK_OUT, 1); 192662306a36Sopenharmony_ci else 192762306a36Sopenharmony_ci status += MXL_ControlWrite(fe, SEQ_ENCLK16_CLK_OUT, 0); 192862306a36Sopenharmony_ci 192962306a36Sopenharmony_ci if (state->DIV_OUT == 1) 193062306a36Sopenharmony_ci status += MXL_ControlWrite(fe, SEQ_SEL4_16B, 1); 193162306a36Sopenharmony_ci if (state->DIV_OUT == 0) 193262306a36Sopenharmony_ci status += MXL_ControlWrite(fe, SEQ_SEL4_16B, 0); 193362306a36Sopenharmony_ci 193462306a36Sopenharmony_ci /* Crystal Control */ 193562306a36Sopenharmony_ci if (state->CAPSELECT) 193662306a36Sopenharmony_ci status += MXL_ControlWrite(fe, XTAL_CAPSELECT, 1); 193762306a36Sopenharmony_ci else 193862306a36Sopenharmony_ci status += MXL_ControlWrite(fe, XTAL_CAPSELECT, 0); 193962306a36Sopenharmony_ci 194062306a36Sopenharmony_ci if (state->Fxtal >= 12000000UL && state->Fxtal <= 16000000UL) 194162306a36Sopenharmony_ci status += MXL_ControlWrite(fe, IF_SEL_DBL, 1); 194262306a36Sopenharmony_ci if (state->Fxtal > 16000000UL && state->Fxtal <= 32000000UL) 194362306a36Sopenharmony_ci status += MXL_ControlWrite(fe, IF_SEL_DBL, 0); 194462306a36Sopenharmony_ci 194562306a36Sopenharmony_ci if (state->Fxtal >= 12000000UL && state->Fxtal <= 22000000UL) 194662306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFSYN_R_DIV, 3); 194762306a36Sopenharmony_ci if (state->Fxtal > 22000000UL && state->Fxtal <= 32000000UL) 194862306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFSYN_R_DIV, 0); 194962306a36Sopenharmony_ci 195062306a36Sopenharmony_ci /* Misc Controls */ 195162306a36Sopenharmony_ci if (state->Mode == 0 && state->IF_Mode == 1) /* Analog LowIF mode */ 195262306a36Sopenharmony_ci status += MXL_ControlWrite(fe, SEQ_EXTIQFSMPULSE, 0); 195362306a36Sopenharmony_ci else 195462306a36Sopenharmony_ci status += MXL_ControlWrite(fe, SEQ_EXTIQFSMPULSE, 1); 195562306a36Sopenharmony_ci 195662306a36Sopenharmony_ci /* status += MXL_ControlRead(fe, IF_DIVVAL, &IF_DIVVAL_Val); */ 195762306a36Sopenharmony_ci 195862306a36Sopenharmony_ci /* Set TG_R_DIV */ 195962306a36Sopenharmony_ci status += MXL_ControlWrite(fe, TG_R_DIV, 196062306a36Sopenharmony_ci MXL_Ceiling(state->Fxtal, 1000000)); 196162306a36Sopenharmony_ci 196262306a36Sopenharmony_ci /* Apply Default value to BB_INITSTATE_DLPF_TUNE */ 196362306a36Sopenharmony_ci 196462306a36Sopenharmony_ci /* RSSI Control */ 196562306a36Sopenharmony_ci if (state->EN_RSSI) { 196662306a36Sopenharmony_ci status += MXL_ControlWrite(fe, SEQ_EXTSYNTHCALIF, 1); 196762306a36Sopenharmony_ci status += MXL_ControlWrite(fe, SEQ_EXTDCCAL, 1); 196862306a36Sopenharmony_ci status += MXL_ControlWrite(fe, AGC_EN_RSSI, 1); 196962306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFA_ENCLKRFAGC, 1); 197062306a36Sopenharmony_ci 197162306a36Sopenharmony_ci /* RSSI reference point */ 197262306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFA_RSSI_REF, 2); 197362306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFA_RSSI_REFH, 3); 197462306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFA_RSSI_REFL, 1); 197562306a36Sopenharmony_ci 197662306a36Sopenharmony_ci /* TOP point */ 197762306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFA_FLR, 0); 197862306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFA_CEIL, 12); 197962306a36Sopenharmony_ci } 198062306a36Sopenharmony_ci 198162306a36Sopenharmony_ci /* Modulation type bit settings 198262306a36Sopenharmony_ci * Override the control values preset 198362306a36Sopenharmony_ci */ 198462306a36Sopenharmony_ci if (state->Mod_Type == MXL_DVBT) /* DVB-T Mode */ { 198562306a36Sopenharmony_ci state->AGC_Mode = 1; /* Single AGC Mode */ 198662306a36Sopenharmony_ci 198762306a36Sopenharmony_ci /* Enable RSSI */ 198862306a36Sopenharmony_ci status += MXL_ControlWrite(fe, SEQ_EXTSYNTHCALIF, 1); 198962306a36Sopenharmony_ci status += MXL_ControlWrite(fe, SEQ_EXTDCCAL, 1); 199062306a36Sopenharmony_ci status += MXL_ControlWrite(fe, AGC_EN_RSSI, 1); 199162306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFA_ENCLKRFAGC, 1); 199262306a36Sopenharmony_ci 199362306a36Sopenharmony_ci /* RSSI reference point */ 199462306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFA_RSSI_REF, 3); 199562306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFA_RSSI_REFH, 5); 199662306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFA_RSSI_REFL, 1); 199762306a36Sopenharmony_ci 199862306a36Sopenharmony_ci /* TOP point */ 199962306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFA_FLR, 2); 200062306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFA_CEIL, 13); 200162306a36Sopenharmony_ci if (state->IF_OUT <= 6280000UL) /* Low IF */ 200262306a36Sopenharmony_ci status += MXL_ControlWrite(fe, BB_IQSWAP, 0); 200362306a36Sopenharmony_ci else /* High IF */ 200462306a36Sopenharmony_ci status += MXL_ControlWrite(fe, BB_IQSWAP, 1); 200562306a36Sopenharmony_ci 200662306a36Sopenharmony_ci } 200762306a36Sopenharmony_ci if (state->Mod_Type == MXL_ATSC) /* ATSC Mode */ { 200862306a36Sopenharmony_ci state->AGC_Mode = 1; /* Single AGC Mode */ 200962306a36Sopenharmony_ci 201062306a36Sopenharmony_ci /* Enable RSSI */ 201162306a36Sopenharmony_ci status += MXL_ControlWrite(fe, SEQ_EXTSYNTHCALIF, 1); 201262306a36Sopenharmony_ci status += MXL_ControlWrite(fe, SEQ_EXTDCCAL, 1); 201362306a36Sopenharmony_ci status += MXL_ControlWrite(fe, AGC_EN_RSSI, 1); 201462306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFA_ENCLKRFAGC, 1); 201562306a36Sopenharmony_ci 201662306a36Sopenharmony_ci /* RSSI reference point */ 201762306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFA_RSSI_REF, 2); 201862306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFA_RSSI_REFH, 4); 201962306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFA_RSSI_REFL, 1); 202062306a36Sopenharmony_ci 202162306a36Sopenharmony_ci /* TOP point */ 202262306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFA_FLR, 2); 202362306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFA_CEIL, 13); 202462306a36Sopenharmony_ci status += MXL_ControlWrite(fe, BB_INITSTATE_DLPF_TUNE, 1); 202562306a36Sopenharmony_ci /* Low Zero */ 202662306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFSYN_CHP_GAIN, 5); 202762306a36Sopenharmony_ci 202862306a36Sopenharmony_ci if (state->IF_OUT <= 6280000UL) /* Low IF */ 202962306a36Sopenharmony_ci status += MXL_ControlWrite(fe, BB_IQSWAP, 0); 203062306a36Sopenharmony_ci else /* High IF */ 203162306a36Sopenharmony_ci status += MXL_ControlWrite(fe, BB_IQSWAP, 1); 203262306a36Sopenharmony_ci } 203362306a36Sopenharmony_ci if (state->Mod_Type == MXL_QAM) /* QAM Mode */ { 203462306a36Sopenharmony_ci state->Mode = MXL_DIGITAL_MODE; 203562306a36Sopenharmony_ci 203662306a36Sopenharmony_ci /* state->AGC_Mode = 1; */ /* Single AGC Mode */ 203762306a36Sopenharmony_ci 203862306a36Sopenharmony_ci /* Disable RSSI */ /* change here for v2.6.5 */ 203962306a36Sopenharmony_ci status += MXL_ControlWrite(fe, SEQ_EXTSYNTHCALIF, 1); 204062306a36Sopenharmony_ci status += MXL_ControlWrite(fe, SEQ_EXTDCCAL, 1); 204162306a36Sopenharmony_ci status += MXL_ControlWrite(fe, AGC_EN_RSSI, 0); 204262306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFA_ENCLKRFAGC, 1); 204362306a36Sopenharmony_ci 204462306a36Sopenharmony_ci /* RSSI reference point */ 204562306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFA_RSSI_REFH, 5); 204662306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFA_RSSI_REF, 3); 204762306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFA_RSSI_REFL, 2); 204862306a36Sopenharmony_ci /* change here for v2.6.5 */ 204962306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFSYN_CHP_GAIN, 3); 205062306a36Sopenharmony_ci 205162306a36Sopenharmony_ci if (state->IF_OUT <= 6280000UL) /* Low IF */ 205262306a36Sopenharmony_ci status += MXL_ControlWrite(fe, BB_IQSWAP, 0); 205362306a36Sopenharmony_ci else /* High IF */ 205462306a36Sopenharmony_ci status += MXL_ControlWrite(fe, BB_IQSWAP, 1); 205562306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFSYN_CHP_GAIN, 2); 205662306a36Sopenharmony_ci 205762306a36Sopenharmony_ci } 205862306a36Sopenharmony_ci if (state->Mod_Type == MXL_ANALOG_CABLE) { 205962306a36Sopenharmony_ci /* Analog Cable Mode */ 206062306a36Sopenharmony_ci /* state->Mode = MXL_DIGITAL_MODE; */ 206162306a36Sopenharmony_ci 206262306a36Sopenharmony_ci state->AGC_Mode = 1; /* Single AGC Mode */ 206362306a36Sopenharmony_ci 206462306a36Sopenharmony_ci /* Disable RSSI */ 206562306a36Sopenharmony_ci status += MXL_ControlWrite(fe, SEQ_EXTSYNTHCALIF, 1); 206662306a36Sopenharmony_ci status += MXL_ControlWrite(fe, SEQ_EXTDCCAL, 1); 206762306a36Sopenharmony_ci status += MXL_ControlWrite(fe, AGC_EN_RSSI, 0); 206862306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFA_ENCLKRFAGC, 1); 206962306a36Sopenharmony_ci /* change for 2.6.3 */ 207062306a36Sopenharmony_ci status += MXL_ControlWrite(fe, AGC_IF, 1); 207162306a36Sopenharmony_ci status += MXL_ControlWrite(fe, AGC_RF, 15); 207262306a36Sopenharmony_ci status += MXL_ControlWrite(fe, BB_IQSWAP, 1); 207362306a36Sopenharmony_ci } 207462306a36Sopenharmony_ci 207562306a36Sopenharmony_ci if (state->Mod_Type == MXL_ANALOG_OTA) { 207662306a36Sopenharmony_ci /* Analog OTA Terrestrial mode add for 2.6.7 */ 207762306a36Sopenharmony_ci /* state->Mode = MXL_ANALOG_MODE; */ 207862306a36Sopenharmony_ci 207962306a36Sopenharmony_ci /* Enable RSSI */ 208062306a36Sopenharmony_ci status += MXL_ControlWrite(fe, SEQ_EXTSYNTHCALIF, 1); 208162306a36Sopenharmony_ci status += MXL_ControlWrite(fe, SEQ_EXTDCCAL, 1); 208262306a36Sopenharmony_ci status += MXL_ControlWrite(fe, AGC_EN_RSSI, 1); 208362306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFA_ENCLKRFAGC, 1); 208462306a36Sopenharmony_ci 208562306a36Sopenharmony_ci /* RSSI reference point */ 208662306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFA_RSSI_REFH, 5); 208762306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFA_RSSI_REF, 3); 208862306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFA_RSSI_REFL, 2); 208962306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFSYN_CHP_GAIN, 3); 209062306a36Sopenharmony_ci status += MXL_ControlWrite(fe, BB_IQSWAP, 1); 209162306a36Sopenharmony_ci } 209262306a36Sopenharmony_ci 209362306a36Sopenharmony_ci /* RSSI disable */ 209462306a36Sopenharmony_ci if (state->EN_RSSI == 0) { 209562306a36Sopenharmony_ci status += MXL_ControlWrite(fe, SEQ_EXTSYNTHCALIF, 1); 209662306a36Sopenharmony_ci status += MXL_ControlWrite(fe, SEQ_EXTDCCAL, 1); 209762306a36Sopenharmony_ci status += MXL_ControlWrite(fe, AGC_EN_RSSI, 0); 209862306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFA_ENCLKRFAGC, 1); 209962306a36Sopenharmony_ci } 210062306a36Sopenharmony_ci 210162306a36Sopenharmony_ci return status; 210262306a36Sopenharmony_ci} 210362306a36Sopenharmony_ci 210462306a36Sopenharmony_cistatic u16 MXL_IFSynthInit(struct dvb_frontend *fe) 210562306a36Sopenharmony_ci{ 210662306a36Sopenharmony_ci struct mxl5005s_state *state = fe->tuner_priv; 210762306a36Sopenharmony_ci u16 status = 0 ; 210862306a36Sopenharmony_ci u32 Fref = 0 ; 210962306a36Sopenharmony_ci u32 Kdbl, intModVal ; 211062306a36Sopenharmony_ci u32 fracModVal ; 211162306a36Sopenharmony_ci Kdbl = 2 ; 211262306a36Sopenharmony_ci 211362306a36Sopenharmony_ci if (state->Fxtal >= 12000000UL && state->Fxtal <= 16000000UL) 211462306a36Sopenharmony_ci Kdbl = 2 ; 211562306a36Sopenharmony_ci if (state->Fxtal > 16000000UL && state->Fxtal <= 32000000UL) 211662306a36Sopenharmony_ci Kdbl = 1 ; 211762306a36Sopenharmony_ci 211862306a36Sopenharmony_ci /* IF Synthesizer Control */ 211962306a36Sopenharmony_ci if (state->Mode == 0 && state->IF_Mode == 1) /* Analog Low IF mode */ { 212062306a36Sopenharmony_ci if (state->IF_LO == 41000000UL) { 212162306a36Sopenharmony_ci status += MXL_ControlWrite(fe, IF_DIVVAL, 0x08); 212262306a36Sopenharmony_ci status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x0C); 212362306a36Sopenharmony_ci Fref = 328000000UL ; 212462306a36Sopenharmony_ci } 212562306a36Sopenharmony_ci if (state->IF_LO == 47000000UL) { 212662306a36Sopenharmony_ci status += MXL_ControlWrite(fe, IF_DIVVAL, 0x08); 212762306a36Sopenharmony_ci status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08); 212862306a36Sopenharmony_ci Fref = 376000000UL ; 212962306a36Sopenharmony_ci } 213062306a36Sopenharmony_ci if (state->IF_LO == 54000000UL) { 213162306a36Sopenharmony_ci status += MXL_ControlWrite(fe, IF_DIVVAL, 0x10); 213262306a36Sopenharmony_ci status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x0C); 213362306a36Sopenharmony_ci Fref = 324000000UL ; 213462306a36Sopenharmony_ci } 213562306a36Sopenharmony_ci if (state->IF_LO == 60000000UL) { 213662306a36Sopenharmony_ci status += MXL_ControlWrite(fe, IF_DIVVAL, 0x10); 213762306a36Sopenharmony_ci status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08); 213862306a36Sopenharmony_ci Fref = 360000000UL ; 213962306a36Sopenharmony_ci } 214062306a36Sopenharmony_ci if (state->IF_LO == 39250000UL) { 214162306a36Sopenharmony_ci status += MXL_ControlWrite(fe, IF_DIVVAL, 0x08); 214262306a36Sopenharmony_ci status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x0C); 214362306a36Sopenharmony_ci Fref = 314000000UL ; 214462306a36Sopenharmony_ci } 214562306a36Sopenharmony_ci if (state->IF_LO == 39650000UL) { 214662306a36Sopenharmony_ci status += MXL_ControlWrite(fe, IF_DIVVAL, 0x08); 214762306a36Sopenharmony_ci status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x0C); 214862306a36Sopenharmony_ci Fref = 317200000UL ; 214962306a36Sopenharmony_ci } 215062306a36Sopenharmony_ci if (state->IF_LO == 40150000UL) { 215162306a36Sopenharmony_ci status += MXL_ControlWrite(fe, IF_DIVVAL, 0x08); 215262306a36Sopenharmony_ci status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x0C); 215362306a36Sopenharmony_ci Fref = 321200000UL ; 215462306a36Sopenharmony_ci } 215562306a36Sopenharmony_ci if (state->IF_LO == 40650000UL) { 215662306a36Sopenharmony_ci status += MXL_ControlWrite(fe, IF_DIVVAL, 0x08); 215762306a36Sopenharmony_ci status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x0C); 215862306a36Sopenharmony_ci Fref = 325200000UL ; 215962306a36Sopenharmony_ci } 216062306a36Sopenharmony_ci } 216162306a36Sopenharmony_ci 216262306a36Sopenharmony_ci if (state->Mode || (state->Mode == 0 && state->IF_Mode == 0)) { 216362306a36Sopenharmony_ci if (state->IF_LO == 57000000UL) { 216462306a36Sopenharmony_ci status += MXL_ControlWrite(fe, IF_DIVVAL, 0x10); 216562306a36Sopenharmony_ci status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08); 216662306a36Sopenharmony_ci Fref = 342000000UL ; 216762306a36Sopenharmony_ci } 216862306a36Sopenharmony_ci if (state->IF_LO == 44000000UL) { 216962306a36Sopenharmony_ci status += MXL_ControlWrite(fe, IF_DIVVAL, 0x08); 217062306a36Sopenharmony_ci status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08); 217162306a36Sopenharmony_ci Fref = 352000000UL ; 217262306a36Sopenharmony_ci } 217362306a36Sopenharmony_ci if (state->IF_LO == 43750000UL) { 217462306a36Sopenharmony_ci status += MXL_ControlWrite(fe, IF_DIVVAL, 0x08); 217562306a36Sopenharmony_ci status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08); 217662306a36Sopenharmony_ci Fref = 350000000UL ; 217762306a36Sopenharmony_ci } 217862306a36Sopenharmony_ci if (state->IF_LO == 36650000UL) { 217962306a36Sopenharmony_ci status += MXL_ControlWrite(fe, IF_DIVVAL, 0x04); 218062306a36Sopenharmony_ci status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08); 218162306a36Sopenharmony_ci Fref = 366500000UL ; 218262306a36Sopenharmony_ci } 218362306a36Sopenharmony_ci if (state->IF_LO == 36150000UL) { 218462306a36Sopenharmony_ci status += MXL_ControlWrite(fe, IF_DIVVAL, 0x04); 218562306a36Sopenharmony_ci status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08); 218662306a36Sopenharmony_ci Fref = 361500000UL ; 218762306a36Sopenharmony_ci } 218862306a36Sopenharmony_ci if (state->IF_LO == 36000000UL) { 218962306a36Sopenharmony_ci status += MXL_ControlWrite(fe, IF_DIVVAL, 0x04); 219062306a36Sopenharmony_ci status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08); 219162306a36Sopenharmony_ci Fref = 360000000UL ; 219262306a36Sopenharmony_ci } 219362306a36Sopenharmony_ci if (state->IF_LO == 35250000UL) { 219462306a36Sopenharmony_ci status += MXL_ControlWrite(fe, IF_DIVVAL, 0x04); 219562306a36Sopenharmony_ci status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08); 219662306a36Sopenharmony_ci Fref = 352500000UL ; 219762306a36Sopenharmony_ci } 219862306a36Sopenharmony_ci if (state->IF_LO == 34750000UL) { 219962306a36Sopenharmony_ci status += MXL_ControlWrite(fe, IF_DIVVAL, 0x04); 220062306a36Sopenharmony_ci status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08); 220162306a36Sopenharmony_ci Fref = 347500000UL ; 220262306a36Sopenharmony_ci } 220362306a36Sopenharmony_ci if (state->IF_LO == 6280000UL) { 220462306a36Sopenharmony_ci status += MXL_ControlWrite(fe, IF_DIVVAL, 0x07); 220562306a36Sopenharmony_ci status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08); 220662306a36Sopenharmony_ci Fref = 376800000UL ; 220762306a36Sopenharmony_ci } 220862306a36Sopenharmony_ci if (state->IF_LO == 5000000UL) { 220962306a36Sopenharmony_ci status += MXL_ControlWrite(fe, IF_DIVVAL, 0x09); 221062306a36Sopenharmony_ci status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08); 221162306a36Sopenharmony_ci Fref = 360000000UL ; 221262306a36Sopenharmony_ci } 221362306a36Sopenharmony_ci if (state->IF_LO == 4500000UL) { 221462306a36Sopenharmony_ci status += MXL_ControlWrite(fe, IF_DIVVAL, 0x06); 221562306a36Sopenharmony_ci status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08); 221662306a36Sopenharmony_ci Fref = 360000000UL ; 221762306a36Sopenharmony_ci } 221862306a36Sopenharmony_ci if (state->IF_LO == 4570000UL) { 221962306a36Sopenharmony_ci status += MXL_ControlWrite(fe, IF_DIVVAL, 0x06); 222062306a36Sopenharmony_ci status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08); 222162306a36Sopenharmony_ci Fref = 365600000UL ; 222262306a36Sopenharmony_ci } 222362306a36Sopenharmony_ci if (state->IF_LO == 4000000UL) { 222462306a36Sopenharmony_ci status += MXL_ControlWrite(fe, IF_DIVVAL, 0x05); 222562306a36Sopenharmony_ci status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08); 222662306a36Sopenharmony_ci Fref = 360000000UL ; 222762306a36Sopenharmony_ci } 222862306a36Sopenharmony_ci if (state->IF_LO == 57400000UL) { 222962306a36Sopenharmony_ci status += MXL_ControlWrite(fe, IF_DIVVAL, 0x10); 223062306a36Sopenharmony_ci status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08); 223162306a36Sopenharmony_ci Fref = 344400000UL ; 223262306a36Sopenharmony_ci } 223362306a36Sopenharmony_ci if (state->IF_LO == 44400000UL) { 223462306a36Sopenharmony_ci status += MXL_ControlWrite(fe, IF_DIVVAL, 0x08); 223562306a36Sopenharmony_ci status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08); 223662306a36Sopenharmony_ci Fref = 355200000UL ; 223762306a36Sopenharmony_ci } 223862306a36Sopenharmony_ci if (state->IF_LO == 44150000UL) { 223962306a36Sopenharmony_ci status += MXL_ControlWrite(fe, IF_DIVVAL, 0x08); 224062306a36Sopenharmony_ci status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08); 224162306a36Sopenharmony_ci Fref = 353200000UL ; 224262306a36Sopenharmony_ci } 224362306a36Sopenharmony_ci if (state->IF_LO == 37050000UL) { 224462306a36Sopenharmony_ci status += MXL_ControlWrite(fe, IF_DIVVAL, 0x04); 224562306a36Sopenharmony_ci status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08); 224662306a36Sopenharmony_ci Fref = 370500000UL ; 224762306a36Sopenharmony_ci } 224862306a36Sopenharmony_ci if (state->IF_LO == 36550000UL) { 224962306a36Sopenharmony_ci status += MXL_ControlWrite(fe, IF_DIVVAL, 0x04); 225062306a36Sopenharmony_ci status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08); 225162306a36Sopenharmony_ci Fref = 365500000UL ; 225262306a36Sopenharmony_ci } 225362306a36Sopenharmony_ci if (state->IF_LO == 36125000UL) { 225462306a36Sopenharmony_ci status += MXL_ControlWrite(fe, IF_DIVVAL, 0x04); 225562306a36Sopenharmony_ci status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08); 225662306a36Sopenharmony_ci Fref = 361250000UL ; 225762306a36Sopenharmony_ci } 225862306a36Sopenharmony_ci if (state->IF_LO == 6000000UL) { 225962306a36Sopenharmony_ci status += MXL_ControlWrite(fe, IF_DIVVAL, 0x07); 226062306a36Sopenharmony_ci status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08); 226162306a36Sopenharmony_ci Fref = 360000000UL ; 226262306a36Sopenharmony_ci } 226362306a36Sopenharmony_ci if (state->IF_LO == 5400000UL) { 226462306a36Sopenharmony_ci status += MXL_ControlWrite(fe, IF_DIVVAL, 0x07); 226562306a36Sopenharmony_ci status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x0C); 226662306a36Sopenharmony_ci Fref = 324000000UL ; 226762306a36Sopenharmony_ci } 226862306a36Sopenharmony_ci if (state->IF_LO == 5380000UL) { 226962306a36Sopenharmony_ci status += MXL_ControlWrite(fe, IF_DIVVAL, 0x07); 227062306a36Sopenharmony_ci status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x0C); 227162306a36Sopenharmony_ci Fref = 322800000UL ; 227262306a36Sopenharmony_ci } 227362306a36Sopenharmony_ci if (state->IF_LO == 5200000UL) { 227462306a36Sopenharmony_ci status += MXL_ControlWrite(fe, IF_DIVVAL, 0x09); 227562306a36Sopenharmony_ci status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08); 227662306a36Sopenharmony_ci Fref = 374400000UL ; 227762306a36Sopenharmony_ci } 227862306a36Sopenharmony_ci if (state->IF_LO == 4900000UL) { 227962306a36Sopenharmony_ci status += MXL_ControlWrite(fe, IF_DIVVAL, 0x09); 228062306a36Sopenharmony_ci status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08); 228162306a36Sopenharmony_ci Fref = 352800000UL ; 228262306a36Sopenharmony_ci } 228362306a36Sopenharmony_ci if (state->IF_LO == 4400000UL) { 228462306a36Sopenharmony_ci status += MXL_ControlWrite(fe, IF_DIVVAL, 0x06); 228562306a36Sopenharmony_ci status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08); 228662306a36Sopenharmony_ci Fref = 352000000UL ; 228762306a36Sopenharmony_ci } 228862306a36Sopenharmony_ci if (state->IF_LO == 4063000UL) /* add for 2.6.8 */ { 228962306a36Sopenharmony_ci status += MXL_ControlWrite(fe, IF_DIVVAL, 0x05); 229062306a36Sopenharmony_ci status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08); 229162306a36Sopenharmony_ci Fref = 365670000UL ; 229262306a36Sopenharmony_ci } 229362306a36Sopenharmony_ci } 229462306a36Sopenharmony_ci /* CHCAL_INT_MOD_IF */ 229562306a36Sopenharmony_ci /* CHCAL_FRAC_MOD_IF */ 229662306a36Sopenharmony_ci intModVal = Fref / (state->Fxtal * Kdbl/2); 229762306a36Sopenharmony_ci status += MXL_ControlWrite(fe, CHCAL_INT_MOD_IF, intModVal); 229862306a36Sopenharmony_ci 229962306a36Sopenharmony_ci fracModVal = (2<<15)*(Fref/1000 - (state->Fxtal/1000 * Kdbl/2) * 230062306a36Sopenharmony_ci intModVal); 230162306a36Sopenharmony_ci 230262306a36Sopenharmony_ci fracModVal = fracModVal / ((state->Fxtal * Kdbl/2)/1000); 230362306a36Sopenharmony_ci status += MXL_ControlWrite(fe, CHCAL_FRAC_MOD_IF, fracModVal); 230462306a36Sopenharmony_ci 230562306a36Sopenharmony_ci return status ; 230662306a36Sopenharmony_ci} 230762306a36Sopenharmony_ci 230862306a36Sopenharmony_cistatic u16 MXL_TuneRF(struct dvb_frontend *fe, u32 RF_Freq) 230962306a36Sopenharmony_ci{ 231062306a36Sopenharmony_ci struct mxl5005s_state *state = fe->tuner_priv; 231162306a36Sopenharmony_ci u16 status = 0; 231262306a36Sopenharmony_ci u32 divider_val, E3, E4, E5, E5A; 231362306a36Sopenharmony_ci u32 Fmax, Fmin, FmaxBin, FminBin; 231462306a36Sopenharmony_ci u32 Kdbl_RF = 2; 231562306a36Sopenharmony_ci u32 tg_divval; 231662306a36Sopenharmony_ci u32 tg_lo; 231762306a36Sopenharmony_ci 231862306a36Sopenharmony_ci u32 Fref_TG; 231962306a36Sopenharmony_ci u32 Fvco; 232062306a36Sopenharmony_ci 232162306a36Sopenharmony_ci state->RF_IN = RF_Freq; 232262306a36Sopenharmony_ci 232362306a36Sopenharmony_ci MXL_SynthRFTGLO_Calc(fe); 232462306a36Sopenharmony_ci 232562306a36Sopenharmony_ci if (state->Fxtal >= 12000000UL && state->Fxtal <= 22000000UL) 232662306a36Sopenharmony_ci Kdbl_RF = 2; 232762306a36Sopenharmony_ci if (state->Fxtal > 22000000 && state->Fxtal <= 32000000) 232862306a36Sopenharmony_ci Kdbl_RF = 1; 232962306a36Sopenharmony_ci 233062306a36Sopenharmony_ci /* Downconverter Controls 233162306a36Sopenharmony_ci * Look-Up Table Implementation for: 233262306a36Sopenharmony_ci * DN_POLY 233362306a36Sopenharmony_ci * DN_RFGAIN 233462306a36Sopenharmony_ci * DN_CAP_RFLPF 233562306a36Sopenharmony_ci * DN_EN_VHFUHFBAR 233662306a36Sopenharmony_ci * DN_GAIN_ADJUST 233762306a36Sopenharmony_ci * Change the boundary reference from RF_IN to RF_LO 233862306a36Sopenharmony_ci */ 233962306a36Sopenharmony_ci if (state->RF_LO < 40000000UL) 234062306a36Sopenharmony_ci return -1; 234162306a36Sopenharmony_ci 234262306a36Sopenharmony_ci if (state->RF_LO >= 40000000UL && state->RF_LO <= 75000000UL) { 234362306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DN_POLY, 2); 234462306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DN_RFGAIN, 3); 234562306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DN_CAP_RFLPF, 423); 234662306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DN_EN_VHFUHFBAR, 1); 234762306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DN_GAIN_ADJUST, 1); 234862306a36Sopenharmony_ci } 234962306a36Sopenharmony_ci if (state->RF_LO > 75000000UL && state->RF_LO <= 100000000UL) { 235062306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DN_POLY, 3); 235162306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DN_RFGAIN, 3); 235262306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DN_CAP_RFLPF, 222); 235362306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DN_EN_VHFUHFBAR, 1); 235462306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DN_GAIN_ADJUST, 1); 235562306a36Sopenharmony_ci } 235662306a36Sopenharmony_ci if (state->RF_LO > 100000000UL && state->RF_LO <= 150000000UL) { 235762306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DN_POLY, 3); 235862306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DN_RFGAIN, 3); 235962306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DN_CAP_RFLPF, 147); 236062306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DN_EN_VHFUHFBAR, 1); 236162306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DN_GAIN_ADJUST, 2); 236262306a36Sopenharmony_ci } 236362306a36Sopenharmony_ci if (state->RF_LO > 150000000UL && state->RF_LO <= 200000000UL) { 236462306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DN_POLY, 3); 236562306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DN_RFGAIN, 3); 236662306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DN_CAP_RFLPF, 9); 236762306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DN_EN_VHFUHFBAR, 1); 236862306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DN_GAIN_ADJUST, 2); 236962306a36Sopenharmony_ci } 237062306a36Sopenharmony_ci if (state->RF_LO > 200000000UL && state->RF_LO <= 300000000UL) { 237162306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DN_POLY, 3); 237262306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DN_RFGAIN, 3); 237362306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DN_CAP_RFLPF, 0); 237462306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DN_EN_VHFUHFBAR, 1); 237562306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DN_GAIN_ADJUST, 3); 237662306a36Sopenharmony_ci } 237762306a36Sopenharmony_ci if (state->RF_LO > 300000000UL && state->RF_LO <= 650000000UL) { 237862306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DN_POLY, 3); 237962306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DN_RFGAIN, 1); 238062306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DN_CAP_RFLPF, 0); 238162306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DN_EN_VHFUHFBAR, 0); 238262306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DN_GAIN_ADJUST, 3); 238362306a36Sopenharmony_ci } 238462306a36Sopenharmony_ci if (state->RF_LO > 650000000UL && state->RF_LO <= 900000000UL) { 238562306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DN_POLY, 3); 238662306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DN_RFGAIN, 2); 238762306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DN_CAP_RFLPF, 0); 238862306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DN_EN_VHFUHFBAR, 0); 238962306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DN_GAIN_ADJUST, 3); 239062306a36Sopenharmony_ci } 239162306a36Sopenharmony_ci if (state->RF_LO > 900000000UL) 239262306a36Sopenharmony_ci return -1; 239362306a36Sopenharmony_ci 239462306a36Sopenharmony_ci /* DN_IQTNBUF_AMP */ 239562306a36Sopenharmony_ci /* DN_IQTNGNBFBIAS_BST */ 239662306a36Sopenharmony_ci if (state->RF_LO >= 40000000UL && state->RF_LO <= 75000000UL) { 239762306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DN_IQTNBUF_AMP, 1); 239862306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DN_IQTNGNBFBIAS_BST, 0); 239962306a36Sopenharmony_ci } 240062306a36Sopenharmony_ci if (state->RF_LO > 75000000UL && state->RF_LO <= 100000000UL) { 240162306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DN_IQTNBUF_AMP, 1); 240262306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DN_IQTNGNBFBIAS_BST, 0); 240362306a36Sopenharmony_ci } 240462306a36Sopenharmony_ci if (state->RF_LO > 100000000UL && state->RF_LO <= 150000000UL) { 240562306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DN_IQTNBUF_AMP, 1); 240662306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DN_IQTNGNBFBIAS_BST, 0); 240762306a36Sopenharmony_ci } 240862306a36Sopenharmony_ci if (state->RF_LO > 150000000UL && state->RF_LO <= 200000000UL) { 240962306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DN_IQTNBUF_AMP, 1); 241062306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DN_IQTNGNBFBIAS_BST, 0); 241162306a36Sopenharmony_ci } 241262306a36Sopenharmony_ci if (state->RF_LO > 200000000UL && state->RF_LO <= 300000000UL) { 241362306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DN_IQTNBUF_AMP, 1); 241462306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DN_IQTNGNBFBIAS_BST, 0); 241562306a36Sopenharmony_ci } 241662306a36Sopenharmony_ci if (state->RF_LO > 300000000UL && state->RF_LO <= 400000000UL) { 241762306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DN_IQTNBUF_AMP, 1); 241862306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DN_IQTNGNBFBIAS_BST, 0); 241962306a36Sopenharmony_ci } 242062306a36Sopenharmony_ci if (state->RF_LO > 400000000UL && state->RF_LO <= 450000000UL) { 242162306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DN_IQTNBUF_AMP, 1); 242262306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DN_IQTNGNBFBIAS_BST, 0); 242362306a36Sopenharmony_ci } 242462306a36Sopenharmony_ci if (state->RF_LO > 450000000UL && state->RF_LO <= 500000000UL) { 242562306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DN_IQTNBUF_AMP, 1); 242662306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DN_IQTNGNBFBIAS_BST, 0); 242762306a36Sopenharmony_ci } 242862306a36Sopenharmony_ci if (state->RF_LO > 500000000UL && state->RF_LO <= 550000000UL) { 242962306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DN_IQTNBUF_AMP, 1); 243062306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DN_IQTNGNBFBIAS_BST, 0); 243162306a36Sopenharmony_ci } 243262306a36Sopenharmony_ci if (state->RF_LO > 550000000UL && state->RF_LO <= 600000000UL) { 243362306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DN_IQTNBUF_AMP, 1); 243462306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DN_IQTNGNBFBIAS_BST, 0); 243562306a36Sopenharmony_ci } 243662306a36Sopenharmony_ci if (state->RF_LO > 600000000UL && state->RF_LO <= 650000000UL) { 243762306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DN_IQTNBUF_AMP, 1); 243862306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DN_IQTNGNBFBIAS_BST, 0); 243962306a36Sopenharmony_ci } 244062306a36Sopenharmony_ci if (state->RF_LO > 650000000UL && state->RF_LO <= 700000000UL) { 244162306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DN_IQTNBUF_AMP, 1); 244262306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DN_IQTNGNBFBIAS_BST, 0); 244362306a36Sopenharmony_ci } 244462306a36Sopenharmony_ci if (state->RF_LO > 700000000UL && state->RF_LO <= 750000000UL) { 244562306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DN_IQTNBUF_AMP, 1); 244662306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DN_IQTNGNBFBIAS_BST, 0); 244762306a36Sopenharmony_ci } 244862306a36Sopenharmony_ci if (state->RF_LO > 750000000UL && state->RF_LO <= 800000000UL) { 244962306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DN_IQTNBUF_AMP, 1); 245062306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DN_IQTNGNBFBIAS_BST, 0); 245162306a36Sopenharmony_ci } 245262306a36Sopenharmony_ci if (state->RF_LO > 800000000UL && state->RF_LO <= 850000000UL) { 245362306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DN_IQTNBUF_AMP, 10); 245462306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DN_IQTNGNBFBIAS_BST, 1); 245562306a36Sopenharmony_ci } 245662306a36Sopenharmony_ci if (state->RF_LO > 850000000UL && state->RF_LO <= 900000000UL) { 245762306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DN_IQTNBUF_AMP, 10); 245862306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DN_IQTNGNBFBIAS_BST, 1); 245962306a36Sopenharmony_ci } 246062306a36Sopenharmony_ci 246162306a36Sopenharmony_ci /* 246262306a36Sopenharmony_ci * Set RF Synth and LO Path Control 246362306a36Sopenharmony_ci * 246462306a36Sopenharmony_ci * Look-Up table implementation for: 246562306a36Sopenharmony_ci * RFSYN_EN_OUTMUX 246662306a36Sopenharmony_ci * RFSYN_SEL_VCO_OUT 246762306a36Sopenharmony_ci * RFSYN_SEL_VCO_HI 246862306a36Sopenharmony_ci * RFSYN_SEL_DIVM 246962306a36Sopenharmony_ci * RFSYN_RF_DIV_BIAS 247062306a36Sopenharmony_ci * DN_SEL_FREQ 247162306a36Sopenharmony_ci * 247262306a36Sopenharmony_ci * Set divider_val, Fmax, Fmix to use in Equations 247362306a36Sopenharmony_ci */ 247462306a36Sopenharmony_ci FminBin = 28000000UL ; 247562306a36Sopenharmony_ci FmaxBin = 42500000UL ; 247662306a36Sopenharmony_ci if (state->RF_LO >= 40000000UL && state->RF_LO <= FmaxBin) { 247762306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFSYN_EN_OUTMUX, 1); 247862306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_OUT, 0); 247962306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 0); 248062306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFSYN_SEL_DIVM, 0); 248162306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFSYN_RF_DIV_BIAS, 1); 248262306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DN_SEL_FREQ, 1); 248362306a36Sopenharmony_ci divider_val = 64 ; 248462306a36Sopenharmony_ci Fmax = FmaxBin ; 248562306a36Sopenharmony_ci Fmin = FminBin ; 248662306a36Sopenharmony_ci } 248762306a36Sopenharmony_ci FminBin = 42500000UL ; 248862306a36Sopenharmony_ci FmaxBin = 56000000UL ; 248962306a36Sopenharmony_ci if (state->RF_LO > FminBin && state->RF_LO <= FmaxBin) { 249062306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFSYN_EN_OUTMUX, 1); 249162306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_OUT, 0); 249262306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 1); 249362306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFSYN_SEL_DIVM, 0); 249462306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFSYN_RF_DIV_BIAS, 1); 249562306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DN_SEL_FREQ, 1); 249662306a36Sopenharmony_ci divider_val = 64 ; 249762306a36Sopenharmony_ci Fmax = FmaxBin ; 249862306a36Sopenharmony_ci Fmin = FminBin ; 249962306a36Sopenharmony_ci } 250062306a36Sopenharmony_ci FminBin = 56000000UL ; 250162306a36Sopenharmony_ci FmaxBin = 85000000UL ; 250262306a36Sopenharmony_ci if (state->RF_LO > FminBin && state->RF_LO <= FmaxBin) { 250362306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFSYN_EN_OUTMUX, 0); 250462306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_OUT, 1); 250562306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 0); 250662306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFSYN_SEL_DIVM, 0); 250762306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFSYN_RF_DIV_BIAS, 1); 250862306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DN_SEL_FREQ, 1); 250962306a36Sopenharmony_ci divider_val = 32 ; 251062306a36Sopenharmony_ci Fmax = FmaxBin ; 251162306a36Sopenharmony_ci Fmin = FminBin ; 251262306a36Sopenharmony_ci } 251362306a36Sopenharmony_ci FminBin = 85000000UL ; 251462306a36Sopenharmony_ci FmaxBin = 112000000UL ; 251562306a36Sopenharmony_ci if (state->RF_LO > FminBin && state->RF_LO <= FmaxBin) { 251662306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFSYN_EN_OUTMUX, 0); 251762306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_OUT, 1); 251862306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 1); 251962306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFSYN_SEL_DIVM, 0); 252062306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFSYN_RF_DIV_BIAS, 1); 252162306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DN_SEL_FREQ, 1); 252262306a36Sopenharmony_ci divider_val = 32 ; 252362306a36Sopenharmony_ci Fmax = FmaxBin ; 252462306a36Sopenharmony_ci Fmin = FminBin ; 252562306a36Sopenharmony_ci } 252662306a36Sopenharmony_ci FminBin = 112000000UL ; 252762306a36Sopenharmony_ci FmaxBin = 170000000UL ; 252862306a36Sopenharmony_ci if (state->RF_LO > FminBin && state->RF_LO <= FmaxBin) { 252962306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFSYN_EN_OUTMUX, 0); 253062306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_OUT, 1); 253162306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 0); 253262306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFSYN_SEL_DIVM, 0); 253362306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFSYN_RF_DIV_BIAS, 1); 253462306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DN_SEL_FREQ, 2); 253562306a36Sopenharmony_ci divider_val = 16 ; 253662306a36Sopenharmony_ci Fmax = FmaxBin ; 253762306a36Sopenharmony_ci Fmin = FminBin ; 253862306a36Sopenharmony_ci } 253962306a36Sopenharmony_ci FminBin = 170000000UL ; 254062306a36Sopenharmony_ci FmaxBin = 225000000UL ; 254162306a36Sopenharmony_ci if (state->RF_LO > FminBin && state->RF_LO <= FmaxBin) { 254262306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFSYN_EN_OUTMUX, 0); 254362306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_OUT, 1); 254462306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 1); 254562306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFSYN_SEL_DIVM, 0); 254662306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFSYN_RF_DIV_BIAS, 1); 254762306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DN_SEL_FREQ, 2); 254862306a36Sopenharmony_ci divider_val = 16 ; 254962306a36Sopenharmony_ci Fmax = FmaxBin ; 255062306a36Sopenharmony_ci Fmin = FminBin ; 255162306a36Sopenharmony_ci } 255262306a36Sopenharmony_ci FminBin = 225000000UL ; 255362306a36Sopenharmony_ci FmaxBin = 300000000UL ; 255462306a36Sopenharmony_ci if (state->RF_LO > FminBin && state->RF_LO <= FmaxBin) { 255562306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFSYN_EN_OUTMUX, 0); 255662306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_OUT, 1); 255762306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 0); 255862306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFSYN_SEL_DIVM, 0); 255962306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFSYN_RF_DIV_BIAS, 1); 256062306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DN_SEL_FREQ, 4); 256162306a36Sopenharmony_ci divider_val = 8 ; 256262306a36Sopenharmony_ci Fmax = 340000000UL ; 256362306a36Sopenharmony_ci Fmin = FminBin ; 256462306a36Sopenharmony_ci } 256562306a36Sopenharmony_ci FminBin = 300000000UL ; 256662306a36Sopenharmony_ci FmaxBin = 340000000UL ; 256762306a36Sopenharmony_ci if (state->RF_LO > FminBin && state->RF_LO <= FmaxBin) { 256862306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFSYN_EN_OUTMUX, 1); 256962306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_OUT, 0); 257062306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 0); 257162306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFSYN_SEL_DIVM, 0); 257262306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFSYN_RF_DIV_BIAS, 1); 257362306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DN_SEL_FREQ, 0); 257462306a36Sopenharmony_ci divider_val = 8 ; 257562306a36Sopenharmony_ci Fmax = FmaxBin ; 257662306a36Sopenharmony_ci Fmin = 225000000UL ; 257762306a36Sopenharmony_ci } 257862306a36Sopenharmony_ci FminBin = 340000000UL ; 257962306a36Sopenharmony_ci FmaxBin = 450000000UL ; 258062306a36Sopenharmony_ci if (state->RF_LO > FminBin && state->RF_LO <= FmaxBin) { 258162306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFSYN_EN_OUTMUX, 1); 258262306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_OUT, 0); 258362306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 1); 258462306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFSYN_SEL_DIVM, 0); 258562306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFSYN_RF_DIV_BIAS, 2); 258662306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DN_SEL_FREQ, 0); 258762306a36Sopenharmony_ci divider_val = 8 ; 258862306a36Sopenharmony_ci Fmax = FmaxBin ; 258962306a36Sopenharmony_ci Fmin = FminBin ; 259062306a36Sopenharmony_ci } 259162306a36Sopenharmony_ci FminBin = 450000000UL ; 259262306a36Sopenharmony_ci FmaxBin = 680000000UL ; 259362306a36Sopenharmony_ci if (state->RF_LO > FminBin && state->RF_LO <= FmaxBin) { 259462306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFSYN_EN_OUTMUX, 0); 259562306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_OUT, 1); 259662306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 0); 259762306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFSYN_SEL_DIVM, 1); 259862306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFSYN_RF_DIV_BIAS, 1); 259962306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DN_SEL_FREQ, 0); 260062306a36Sopenharmony_ci divider_val = 4 ; 260162306a36Sopenharmony_ci Fmax = FmaxBin ; 260262306a36Sopenharmony_ci Fmin = FminBin ; 260362306a36Sopenharmony_ci } 260462306a36Sopenharmony_ci FminBin = 680000000UL ; 260562306a36Sopenharmony_ci FmaxBin = 900000000UL ; 260662306a36Sopenharmony_ci if (state->RF_LO > FminBin && state->RF_LO <= FmaxBin) { 260762306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFSYN_EN_OUTMUX, 0); 260862306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_OUT, 1); 260962306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 1); 261062306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFSYN_SEL_DIVM, 1); 261162306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFSYN_RF_DIV_BIAS, 1); 261262306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DN_SEL_FREQ, 0); 261362306a36Sopenharmony_ci divider_val = 4 ; 261462306a36Sopenharmony_ci Fmax = FmaxBin ; 261562306a36Sopenharmony_ci Fmin = FminBin ; 261662306a36Sopenharmony_ci } 261762306a36Sopenharmony_ci 261862306a36Sopenharmony_ci /* CHCAL_INT_MOD_RF 261962306a36Sopenharmony_ci * CHCAL_FRAC_MOD_RF 262062306a36Sopenharmony_ci * RFSYN_LPF_R 262162306a36Sopenharmony_ci * CHCAL_EN_INT_RF 262262306a36Sopenharmony_ci */ 262362306a36Sopenharmony_ci /* Equation E3 RFSYN_VCO_BIAS */ 262462306a36Sopenharmony_ci E3 = (((Fmax-state->RF_LO)/1000)*32)/((Fmax-Fmin)/1000) + 8 ; 262562306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFSYN_VCO_BIAS, E3); 262662306a36Sopenharmony_ci 262762306a36Sopenharmony_ci /* Equation E4 CHCAL_INT_MOD_RF */ 262862306a36Sopenharmony_ci E4 = (state->RF_LO*divider_val/1000)/(2*state->Fxtal*Kdbl_RF/1000); 262962306a36Sopenharmony_ci MXL_ControlWrite(fe, CHCAL_INT_MOD_RF, E4); 263062306a36Sopenharmony_ci 263162306a36Sopenharmony_ci /* Equation E5 CHCAL_FRAC_MOD_RF CHCAL_EN_INT_RF */ 263262306a36Sopenharmony_ci E5 = ((2<<17)*(state->RF_LO/10000*divider_val - 263362306a36Sopenharmony_ci (E4*(2*state->Fxtal*Kdbl_RF)/10000))) / 263462306a36Sopenharmony_ci (2*state->Fxtal*Kdbl_RF/10000); 263562306a36Sopenharmony_ci 263662306a36Sopenharmony_ci status += MXL_ControlWrite(fe, CHCAL_FRAC_MOD_RF, E5); 263762306a36Sopenharmony_ci 263862306a36Sopenharmony_ci /* Equation E5A RFSYN_LPF_R */ 263962306a36Sopenharmony_ci E5A = (((Fmax - state->RF_LO)/1000)*4/((Fmax-Fmin)/1000)) + 1 ; 264062306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFSYN_LPF_R, E5A); 264162306a36Sopenharmony_ci 264262306a36Sopenharmony_ci /* Euqation E5B CHCAL_EN_INIT_RF */ 264362306a36Sopenharmony_ci status += MXL_ControlWrite(fe, CHCAL_EN_INT_RF, ((E5 == 0) ? 1 : 0)); 264462306a36Sopenharmony_ci /*if (E5 == 0) 264562306a36Sopenharmony_ci * status += MXL_ControlWrite(fe, CHCAL_EN_INT_RF, 1); 264662306a36Sopenharmony_ci *else 264762306a36Sopenharmony_ci * status += MXL_ControlWrite(fe, CHCAL_FRAC_MOD_RF, E5); 264862306a36Sopenharmony_ci */ 264962306a36Sopenharmony_ci 265062306a36Sopenharmony_ci /* 265162306a36Sopenharmony_ci * Set TG Synth 265262306a36Sopenharmony_ci * 265362306a36Sopenharmony_ci * Look-Up table implementation for: 265462306a36Sopenharmony_ci * TG_LO_DIVVAL 265562306a36Sopenharmony_ci * TG_LO_SELVAL 265662306a36Sopenharmony_ci * 265762306a36Sopenharmony_ci * Set divider_val, Fmax, Fmix to use in Equations 265862306a36Sopenharmony_ci */ 265962306a36Sopenharmony_ci if (state->TG_LO < 33000000UL) 266062306a36Sopenharmony_ci return -1; 266162306a36Sopenharmony_ci 266262306a36Sopenharmony_ci FminBin = 33000000UL ; 266362306a36Sopenharmony_ci FmaxBin = 50000000UL ; 266462306a36Sopenharmony_ci if (state->TG_LO >= FminBin && state->TG_LO <= FmaxBin) { 266562306a36Sopenharmony_ci status += MXL_ControlWrite(fe, TG_LO_DIVVAL, 0x6); 266662306a36Sopenharmony_ci status += MXL_ControlWrite(fe, TG_LO_SELVAL, 0x0); 266762306a36Sopenharmony_ci divider_val = 36 ; 266862306a36Sopenharmony_ci Fmax = FmaxBin ; 266962306a36Sopenharmony_ci Fmin = FminBin ; 267062306a36Sopenharmony_ci } 267162306a36Sopenharmony_ci FminBin = 50000000UL ; 267262306a36Sopenharmony_ci FmaxBin = 67000000UL ; 267362306a36Sopenharmony_ci if (state->TG_LO > FminBin && state->TG_LO <= FmaxBin) { 267462306a36Sopenharmony_ci status += MXL_ControlWrite(fe, TG_LO_DIVVAL, 0x1); 267562306a36Sopenharmony_ci status += MXL_ControlWrite(fe, TG_LO_SELVAL, 0x0); 267662306a36Sopenharmony_ci divider_val = 24 ; 267762306a36Sopenharmony_ci Fmax = FmaxBin ; 267862306a36Sopenharmony_ci Fmin = FminBin ; 267962306a36Sopenharmony_ci } 268062306a36Sopenharmony_ci FminBin = 67000000UL ; 268162306a36Sopenharmony_ci FmaxBin = 100000000UL ; 268262306a36Sopenharmony_ci if (state->TG_LO > FminBin && state->TG_LO <= FmaxBin) { 268362306a36Sopenharmony_ci status += MXL_ControlWrite(fe, TG_LO_DIVVAL, 0xC); 268462306a36Sopenharmony_ci status += MXL_ControlWrite(fe, TG_LO_SELVAL, 0x2); 268562306a36Sopenharmony_ci divider_val = 18 ; 268662306a36Sopenharmony_ci Fmax = FmaxBin ; 268762306a36Sopenharmony_ci Fmin = FminBin ; 268862306a36Sopenharmony_ci } 268962306a36Sopenharmony_ci FminBin = 100000000UL ; 269062306a36Sopenharmony_ci FmaxBin = 150000000UL ; 269162306a36Sopenharmony_ci if (state->TG_LO > FminBin && state->TG_LO <= FmaxBin) { 269262306a36Sopenharmony_ci status += MXL_ControlWrite(fe, TG_LO_DIVVAL, 0x8); 269362306a36Sopenharmony_ci status += MXL_ControlWrite(fe, TG_LO_SELVAL, 0x2); 269462306a36Sopenharmony_ci divider_val = 12 ; 269562306a36Sopenharmony_ci Fmax = FmaxBin ; 269662306a36Sopenharmony_ci Fmin = FminBin ; 269762306a36Sopenharmony_ci } 269862306a36Sopenharmony_ci FminBin = 150000000UL ; 269962306a36Sopenharmony_ci FmaxBin = 200000000UL ; 270062306a36Sopenharmony_ci if (state->TG_LO > FminBin && state->TG_LO <= FmaxBin) { 270162306a36Sopenharmony_ci status += MXL_ControlWrite(fe, TG_LO_DIVVAL, 0x0); 270262306a36Sopenharmony_ci status += MXL_ControlWrite(fe, TG_LO_SELVAL, 0x2); 270362306a36Sopenharmony_ci divider_val = 8 ; 270462306a36Sopenharmony_ci Fmax = FmaxBin ; 270562306a36Sopenharmony_ci Fmin = FminBin ; 270662306a36Sopenharmony_ci } 270762306a36Sopenharmony_ci FminBin = 200000000UL ; 270862306a36Sopenharmony_ci FmaxBin = 300000000UL ; 270962306a36Sopenharmony_ci if (state->TG_LO > FminBin && state->TG_LO <= FmaxBin) { 271062306a36Sopenharmony_ci status += MXL_ControlWrite(fe, TG_LO_DIVVAL, 0x8); 271162306a36Sopenharmony_ci status += MXL_ControlWrite(fe, TG_LO_SELVAL, 0x3); 271262306a36Sopenharmony_ci divider_val = 6 ; 271362306a36Sopenharmony_ci Fmax = FmaxBin ; 271462306a36Sopenharmony_ci Fmin = FminBin ; 271562306a36Sopenharmony_ci } 271662306a36Sopenharmony_ci FminBin = 300000000UL ; 271762306a36Sopenharmony_ci FmaxBin = 400000000UL ; 271862306a36Sopenharmony_ci if (state->TG_LO > FminBin && state->TG_LO <= FmaxBin) { 271962306a36Sopenharmony_ci status += MXL_ControlWrite(fe, TG_LO_DIVVAL, 0x0); 272062306a36Sopenharmony_ci status += MXL_ControlWrite(fe, TG_LO_SELVAL, 0x3); 272162306a36Sopenharmony_ci divider_val = 4 ; 272262306a36Sopenharmony_ci Fmax = FmaxBin ; 272362306a36Sopenharmony_ci Fmin = FminBin ; 272462306a36Sopenharmony_ci } 272562306a36Sopenharmony_ci FminBin = 400000000UL ; 272662306a36Sopenharmony_ci FmaxBin = 600000000UL ; 272762306a36Sopenharmony_ci if (state->TG_LO > FminBin && state->TG_LO <= FmaxBin) { 272862306a36Sopenharmony_ci status += MXL_ControlWrite(fe, TG_LO_DIVVAL, 0x8); 272962306a36Sopenharmony_ci status += MXL_ControlWrite(fe, TG_LO_SELVAL, 0x7); 273062306a36Sopenharmony_ci divider_val = 3 ; 273162306a36Sopenharmony_ci Fmax = FmaxBin ; 273262306a36Sopenharmony_ci Fmin = FminBin ; 273362306a36Sopenharmony_ci } 273462306a36Sopenharmony_ci FminBin = 600000000UL ; 273562306a36Sopenharmony_ci FmaxBin = 900000000UL ; 273662306a36Sopenharmony_ci if (state->TG_LO > FminBin && state->TG_LO <= FmaxBin) { 273762306a36Sopenharmony_ci status += MXL_ControlWrite(fe, TG_LO_DIVVAL, 0x0); 273862306a36Sopenharmony_ci status += MXL_ControlWrite(fe, TG_LO_SELVAL, 0x7); 273962306a36Sopenharmony_ci divider_val = 2 ; 274062306a36Sopenharmony_ci } 274162306a36Sopenharmony_ci 274262306a36Sopenharmony_ci /* TG_DIV_VAL */ 274362306a36Sopenharmony_ci tg_divval = (state->TG_LO*divider_val/100000) * 274462306a36Sopenharmony_ci (MXL_Ceiling(state->Fxtal, 1000000) * 100) / 274562306a36Sopenharmony_ci (state->Fxtal/1000); 274662306a36Sopenharmony_ci 274762306a36Sopenharmony_ci status += MXL_ControlWrite(fe, TG_DIV_VAL, tg_divval); 274862306a36Sopenharmony_ci 274962306a36Sopenharmony_ci if (state->TG_LO > 600000000UL) 275062306a36Sopenharmony_ci status += MXL_ControlWrite(fe, TG_DIV_VAL, tg_divval + 1); 275162306a36Sopenharmony_ci 275262306a36Sopenharmony_ci Fmax = 1800000000UL ; 275362306a36Sopenharmony_ci Fmin = 1200000000UL ; 275462306a36Sopenharmony_ci 275562306a36Sopenharmony_ci /* prevent overflow of 32 bit unsigned integer, use 275662306a36Sopenharmony_ci * following equation. Edit for v2.6.4 275762306a36Sopenharmony_ci */ 275862306a36Sopenharmony_ci /* Fref_TF = Fref_TG * 1000 */ 275962306a36Sopenharmony_ci Fref_TG = (state->Fxtal/1000) / MXL_Ceiling(state->Fxtal, 1000000); 276062306a36Sopenharmony_ci 276162306a36Sopenharmony_ci /* Fvco = Fvco/10 */ 276262306a36Sopenharmony_ci Fvco = (state->TG_LO/10000) * divider_val * Fref_TG; 276362306a36Sopenharmony_ci 276462306a36Sopenharmony_ci tg_lo = (((Fmax/10 - Fvco)/100)*32) / ((Fmax-Fmin)/1000)+8; 276562306a36Sopenharmony_ci 276662306a36Sopenharmony_ci /* below equation is same as above but much harder to debug. 276762306a36Sopenharmony_ci * 276862306a36Sopenharmony_ci * static u32 MXL_GetXtalInt(u32 Xtal_Freq) 276962306a36Sopenharmony_ci * { 277062306a36Sopenharmony_ci * if ((Xtal_Freq % 1000000) == 0) 277162306a36Sopenharmony_ci * return (Xtal_Freq / 10000); 277262306a36Sopenharmony_ci * else 277362306a36Sopenharmony_ci * return (((Xtal_Freq / 1000000) + 1)*100); 277462306a36Sopenharmony_ci * } 277562306a36Sopenharmony_ci * 277662306a36Sopenharmony_ci * u32 Xtal_Int = MXL_GetXtalInt(state->Fxtal); 277762306a36Sopenharmony_ci * tg_lo = ( ((Fmax/10000 * Xtal_Int)/100) - 277862306a36Sopenharmony_ci * ((state->TG_LO/10000)*divider_val * 277962306a36Sopenharmony_ci * (state->Fxtal/10000)/100) )*32/((Fmax-Fmin)/10000 * 278062306a36Sopenharmony_ci * Xtal_Int/100) + 8; 278162306a36Sopenharmony_ci */ 278262306a36Sopenharmony_ci 278362306a36Sopenharmony_ci status += MXL_ControlWrite(fe, TG_VCO_BIAS , tg_lo); 278462306a36Sopenharmony_ci 278562306a36Sopenharmony_ci /* add for 2.6.5 Special setting for QAM */ 278662306a36Sopenharmony_ci if (state->Mod_Type == MXL_QAM) { 278762306a36Sopenharmony_ci if (state->config->qam_gain != 0) 278862306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFSYN_CHP_GAIN, 278962306a36Sopenharmony_ci state->config->qam_gain); 279062306a36Sopenharmony_ci else if (state->RF_IN < 680000000) 279162306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFSYN_CHP_GAIN, 3); 279262306a36Sopenharmony_ci else 279362306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFSYN_CHP_GAIN, 2); 279462306a36Sopenharmony_ci } 279562306a36Sopenharmony_ci 279662306a36Sopenharmony_ci /* Off Chip Tracking Filter Control */ 279762306a36Sopenharmony_ci if (state->TF_Type == MXL_TF_OFF) { 279862306a36Sopenharmony_ci /* Tracking Filter Off State; turn off all the banks */ 279962306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DAC_A_ENABLE, 0); 280062306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0); 280162306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 3, 1); /* Bank1 Off */ 280262306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 1, 1); /* Bank2 Off */ 280362306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 4, 1); /* Bank3 Off */ 280462306a36Sopenharmony_ci } 280562306a36Sopenharmony_ci 280662306a36Sopenharmony_ci if (state->TF_Type == MXL_TF_C) /* Tracking Filter type C */ { 280762306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DAC_B_ENABLE, 1); 280862306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DAC_DIN_A, 0); 280962306a36Sopenharmony_ci 281062306a36Sopenharmony_ci if (state->RF_IN >= 43000000 && state->RF_IN < 150000000) { 281162306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DAC_A_ENABLE, 0); 281262306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DAC_DIN_B, 0); 281362306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 3, 0); 281462306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 1, 1); 281562306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 4, 1); 281662306a36Sopenharmony_ci } 281762306a36Sopenharmony_ci if (state->RF_IN >= 150000000 && state->RF_IN < 280000000) { 281862306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DAC_A_ENABLE, 0); 281962306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DAC_DIN_B, 0); 282062306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 3, 1); 282162306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 1, 0); 282262306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 4, 1); 282362306a36Sopenharmony_ci } 282462306a36Sopenharmony_ci if (state->RF_IN >= 280000000 && state->RF_IN < 360000000) { 282562306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DAC_A_ENABLE, 0); 282662306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DAC_DIN_B, 0); 282762306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 3, 1); 282862306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 1, 0); 282962306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 4, 0); 283062306a36Sopenharmony_ci } 283162306a36Sopenharmony_ci if (state->RF_IN >= 360000000 && state->RF_IN < 560000000) { 283262306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DAC_A_ENABLE, 0); 283362306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DAC_DIN_B, 0); 283462306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 3, 1); 283562306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 1, 1); 283662306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 4, 0); 283762306a36Sopenharmony_ci } 283862306a36Sopenharmony_ci if (state->RF_IN >= 560000000 && state->RF_IN < 580000000) { 283962306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DAC_A_ENABLE, 1); 284062306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DAC_DIN_B, 29); 284162306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 3, 1); 284262306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 1, 1); 284362306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 4, 0); 284462306a36Sopenharmony_ci } 284562306a36Sopenharmony_ci if (state->RF_IN >= 580000000 && state->RF_IN < 630000000) { 284662306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DAC_A_ENABLE, 1); 284762306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DAC_DIN_B, 0); 284862306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 3, 1); 284962306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 1, 1); 285062306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 4, 0); 285162306a36Sopenharmony_ci } 285262306a36Sopenharmony_ci if (state->RF_IN >= 630000000 && state->RF_IN < 700000000) { 285362306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DAC_A_ENABLE, 1); 285462306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DAC_DIN_B, 16); 285562306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 3, 1); 285662306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 1, 1); 285762306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 4, 1); 285862306a36Sopenharmony_ci } 285962306a36Sopenharmony_ci if (state->RF_IN >= 700000000 && state->RF_IN < 760000000) { 286062306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DAC_A_ENABLE, 1); 286162306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DAC_DIN_B, 7); 286262306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 3, 1); 286362306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 1, 1); 286462306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 4, 1); 286562306a36Sopenharmony_ci } 286662306a36Sopenharmony_ci if (state->RF_IN >= 760000000 && state->RF_IN <= 900000000) { 286762306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DAC_A_ENABLE, 1); 286862306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DAC_DIN_B, 0); 286962306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 3, 1); 287062306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 1, 1); 287162306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 4, 1); 287262306a36Sopenharmony_ci } 287362306a36Sopenharmony_ci } 287462306a36Sopenharmony_ci 287562306a36Sopenharmony_ci if (state->TF_Type == MXL_TF_C_H) { 287662306a36Sopenharmony_ci 287762306a36Sopenharmony_ci /* Tracking Filter type C-H for Hauppauge only */ 287862306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DAC_DIN_A, 0); 287962306a36Sopenharmony_ci 288062306a36Sopenharmony_ci if (state->RF_IN >= 43000000 && state->RF_IN < 150000000) { 288162306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DAC_A_ENABLE, 0); 288262306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 4, 0); 288362306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 3, 1); 288462306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 1, 1); 288562306a36Sopenharmony_ci } 288662306a36Sopenharmony_ci if (state->RF_IN >= 150000000 && state->RF_IN < 280000000) { 288762306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DAC_A_ENABLE, 0); 288862306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 4, 1); 288962306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 3, 0); 289062306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 1, 1); 289162306a36Sopenharmony_ci } 289262306a36Sopenharmony_ci if (state->RF_IN >= 280000000 && state->RF_IN < 360000000) { 289362306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DAC_A_ENABLE, 0); 289462306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 4, 1); 289562306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 3, 0); 289662306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 1, 0); 289762306a36Sopenharmony_ci } 289862306a36Sopenharmony_ci if (state->RF_IN >= 360000000 && state->RF_IN < 560000000) { 289962306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DAC_A_ENABLE, 0); 290062306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 4, 1); 290162306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 3, 1); 290262306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 1, 0); 290362306a36Sopenharmony_ci } 290462306a36Sopenharmony_ci if (state->RF_IN >= 560000000 && state->RF_IN < 580000000) { 290562306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DAC_A_ENABLE, 1); 290662306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 4, 1); 290762306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 3, 1); 290862306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 1, 0); 290962306a36Sopenharmony_ci } 291062306a36Sopenharmony_ci if (state->RF_IN >= 580000000 && state->RF_IN < 630000000) { 291162306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DAC_A_ENABLE, 1); 291262306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 4, 1); 291362306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 3, 1); 291462306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 1, 0); 291562306a36Sopenharmony_ci } 291662306a36Sopenharmony_ci if (state->RF_IN >= 630000000 && state->RF_IN < 700000000) { 291762306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DAC_A_ENABLE, 1); 291862306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 4, 1); 291962306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 3, 1); 292062306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 1, 1); 292162306a36Sopenharmony_ci } 292262306a36Sopenharmony_ci if (state->RF_IN >= 700000000 && state->RF_IN < 760000000) { 292362306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DAC_A_ENABLE, 1); 292462306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 4, 1); 292562306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 3, 1); 292662306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 1, 1); 292762306a36Sopenharmony_ci } 292862306a36Sopenharmony_ci if (state->RF_IN >= 760000000 && state->RF_IN <= 900000000) { 292962306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DAC_A_ENABLE, 1); 293062306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 4, 1); 293162306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 3, 1); 293262306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 1, 1); 293362306a36Sopenharmony_ci } 293462306a36Sopenharmony_ci } 293562306a36Sopenharmony_ci 293662306a36Sopenharmony_ci if (state->TF_Type == MXL_TF_D) { /* Tracking Filter type D */ 293762306a36Sopenharmony_ci 293862306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DAC_DIN_B, 0); 293962306a36Sopenharmony_ci 294062306a36Sopenharmony_ci if (state->RF_IN >= 43000000 && state->RF_IN < 174000000) { 294162306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0); 294262306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 4, 0); 294362306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 1, 1); 294462306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 3, 1); 294562306a36Sopenharmony_ci } 294662306a36Sopenharmony_ci if (state->RF_IN >= 174000000 && state->RF_IN < 250000000) { 294762306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0); 294862306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 4, 0); 294962306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 1, 0); 295062306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 3, 1); 295162306a36Sopenharmony_ci } 295262306a36Sopenharmony_ci if (state->RF_IN >= 250000000 && state->RF_IN < 310000000) { 295362306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0); 295462306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 4, 1); 295562306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 1, 0); 295662306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 3, 1); 295762306a36Sopenharmony_ci } 295862306a36Sopenharmony_ci if (state->RF_IN >= 310000000 && state->RF_IN < 360000000) { 295962306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0); 296062306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 4, 1); 296162306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 1, 0); 296262306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 3, 0); 296362306a36Sopenharmony_ci } 296462306a36Sopenharmony_ci if (state->RF_IN >= 360000000 && state->RF_IN < 470000000) { 296562306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0); 296662306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 4, 1); 296762306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 1, 1); 296862306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 3, 0); 296962306a36Sopenharmony_ci } 297062306a36Sopenharmony_ci if (state->RF_IN >= 470000000 && state->RF_IN < 640000000) { 297162306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DAC_B_ENABLE, 1); 297262306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 4, 1); 297362306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 1, 1); 297462306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 3, 0); 297562306a36Sopenharmony_ci } 297662306a36Sopenharmony_ci if (state->RF_IN >= 640000000 && state->RF_IN <= 900000000) { 297762306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DAC_B_ENABLE, 1); 297862306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 4, 1); 297962306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 1, 1); 298062306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 3, 1); 298162306a36Sopenharmony_ci } 298262306a36Sopenharmony_ci } 298362306a36Sopenharmony_ci 298462306a36Sopenharmony_ci if (state->TF_Type == MXL_TF_D_L) { 298562306a36Sopenharmony_ci 298662306a36Sopenharmony_ci /* Tracking Filter type D-L for Lumanate ONLY change 2.6.3 */ 298762306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DAC_DIN_A, 0); 298862306a36Sopenharmony_ci 298962306a36Sopenharmony_ci /* if UHF and terrestrial => Turn off Tracking Filter */ 299062306a36Sopenharmony_ci if (state->RF_IN >= 471000000 && 299162306a36Sopenharmony_ci (state->RF_IN - 471000000)%6000000 != 0) { 299262306a36Sopenharmony_ci /* Turn off all the banks */ 299362306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 3, 1); 299462306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 1, 1); 299562306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 4, 1); 299662306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DAC_A_ENABLE, 0); 299762306a36Sopenharmony_ci status += MXL_ControlWrite(fe, AGC_IF, 10); 299862306a36Sopenharmony_ci } else { 299962306a36Sopenharmony_ci /* if VHF or cable => Turn on Tracking Filter */ 300062306a36Sopenharmony_ci if (state->RF_IN >= 43000000 && 300162306a36Sopenharmony_ci state->RF_IN < 140000000) { 300262306a36Sopenharmony_ci 300362306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DAC_A_ENABLE, 0); 300462306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 4, 1); 300562306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 1, 1); 300662306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 3, 0); 300762306a36Sopenharmony_ci } 300862306a36Sopenharmony_ci if (state->RF_IN >= 140000000 && 300962306a36Sopenharmony_ci state->RF_IN < 240000000) { 301062306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DAC_A_ENABLE, 0); 301162306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 4, 1); 301262306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 1, 0); 301362306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 3, 0); 301462306a36Sopenharmony_ci } 301562306a36Sopenharmony_ci if (state->RF_IN >= 240000000 && 301662306a36Sopenharmony_ci state->RF_IN < 340000000) { 301762306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DAC_A_ENABLE, 0); 301862306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 4, 0); 301962306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 1, 1); 302062306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 3, 0); 302162306a36Sopenharmony_ci } 302262306a36Sopenharmony_ci if (state->RF_IN >= 340000000 && 302362306a36Sopenharmony_ci state->RF_IN < 430000000) { 302462306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DAC_A_ENABLE, 0); 302562306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 4, 0); 302662306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 1, 0); 302762306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 3, 1); 302862306a36Sopenharmony_ci } 302962306a36Sopenharmony_ci if (state->RF_IN >= 430000000 && 303062306a36Sopenharmony_ci state->RF_IN < 470000000) { 303162306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DAC_A_ENABLE, 1); 303262306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 4, 1); 303362306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 1, 0); 303462306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 3, 1); 303562306a36Sopenharmony_ci } 303662306a36Sopenharmony_ci if (state->RF_IN >= 470000000 && 303762306a36Sopenharmony_ci state->RF_IN < 570000000) { 303862306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DAC_A_ENABLE, 1); 303962306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 4, 0); 304062306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 1, 0); 304162306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 3, 1); 304262306a36Sopenharmony_ci } 304362306a36Sopenharmony_ci if (state->RF_IN >= 570000000 && 304462306a36Sopenharmony_ci state->RF_IN < 620000000) { 304562306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DAC_A_ENABLE, 0); 304662306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 4, 0); 304762306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 1, 1); 304862306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 3, 1); 304962306a36Sopenharmony_ci } 305062306a36Sopenharmony_ci if (state->RF_IN >= 620000000 && 305162306a36Sopenharmony_ci state->RF_IN < 760000000) { 305262306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DAC_A_ENABLE, 1); 305362306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 4, 0); 305462306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 1, 1); 305562306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 3, 1); 305662306a36Sopenharmony_ci } 305762306a36Sopenharmony_ci if (state->RF_IN >= 760000000 && 305862306a36Sopenharmony_ci state->RF_IN <= 900000000) { 305962306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DAC_A_ENABLE, 1); 306062306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 4, 1); 306162306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 1, 1); 306262306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 3, 1); 306362306a36Sopenharmony_ci } 306462306a36Sopenharmony_ci } 306562306a36Sopenharmony_ci } 306662306a36Sopenharmony_ci 306762306a36Sopenharmony_ci if (state->TF_Type == MXL_TF_E) /* Tracking Filter type E */ { 306862306a36Sopenharmony_ci 306962306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DAC_DIN_B, 0); 307062306a36Sopenharmony_ci 307162306a36Sopenharmony_ci if (state->RF_IN >= 43000000 && state->RF_IN < 174000000) { 307262306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0); 307362306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 4, 0); 307462306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 1, 1); 307562306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 3, 1); 307662306a36Sopenharmony_ci } 307762306a36Sopenharmony_ci if (state->RF_IN >= 174000000 && state->RF_IN < 250000000) { 307862306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0); 307962306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 4, 0); 308062306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 1, 0); 308162306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 3, 1); 308262306a36Sopenharmony_ci } 308362306a36Sopenharmony_ci if (state->RF_IN >= 250000000 && state->RF_IN < 310000000) { 308462306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0); 308562306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 4, 1); 308662306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 1, 0); 308762306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 3, 1); 308862306a36Sopenharmony_ci } 308962306a36Sopenharmony_ci if (state->RF_IN >= 310000000 && state->RF_IN < 360000000) { 309062306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0); 309162306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 4, 1); 309262306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 1, 0); 309362306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 3, 0); 309462306a36Sopenharmony_ci } 309562306a36Sopenharmony_ci if (state->RF_IN >= 360000000 && state->RF_IN < 470000000) { 309662306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0); 309762306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 4, 1); 309862306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 1, 1); 309962306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 3, 0); 310062306a36Sopenharmony_ci } 310162306a36Sopenharmony_ci if (state->RF_IN >= 470000000 && state->RF_IN < 640000000) { 310262306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DAC_B_ENABLE, 1); 310362306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 4, 1); 310462306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 1, 1); 310562306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 3, 0); 310662306a36Sopenharmony_ci } 310762306a36Sopenharmony_ci if (state->RF_IN >= 640000000 && state->RF_IN <= 900000000) { 310862306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DAC_B_ENABLE, 1); 310962306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 4, 1); 311062306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 1, 1); 311162306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 3, 1); 311262306a36Sopenharmony_ci } 311362306a36Sopenharmony_ci } 311462306a36Sopenharmony_ci 311562306a36Sopenharmony_ci if (state->TF_Type == MXL_TF_F) { 311662306a36Sopenharmony_ci 311762306a36Sopenharmony_ci /* Tracking Filter type F */ 311862306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DAC_DIN_B, 0); 311962306a36Sopenharmony_ci 312062306a36Sopenharmony_ci if (state->RF_IN >= 43000000 && state->RF_IN < 160000000) { 312162306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0); 312262306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 4, 0); 312362306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 1, 1); 312462306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 3, 1); 312562306a36Sopenharmony_ci } 312662306a36Sopenharmony_ci if (state->RF_IN >= 160000000 && state->RF_IN < 210000000) { 312762306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0); 312862306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 4, 0); 312962306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 1, 0); 313062306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 3, 1); 313162306a36Sopenharmony_ci } 313262306a36Sopenharmony_ci if (state->RF_IN >= 210000000 && state->RF_IN < 300000000) { 313362306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0); 313462306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 4, 1); 313562306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 1, 0); 313662306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 3, 1); 313762306a36Sopenharmony_ci } 313862306a36Sopenharmony_ci if (state->RF_IN >= 300000000 && state->RF_IN < 390000000) { 313962306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0); 314062306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 4, 1); 314162306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 1, 0); 314262306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 3, 0); 314362306a36Sopenharmony_ci } 314462306a36Sopenharmony_ci if (state->RF_IN >= 390000000 && state->RF_IN < 515000000) { 314562306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0); 314662306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 4, 1); 314762306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 1, 1); 314862306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 3, 0); 314962306a36Sopenharmony_ci } 315062306a36Sopenharmony_ci if (state->RF_IN >= 515000000 && state->RF_IN < 650000000) { 315162306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DAC_B_ENABLE, 1); 315262306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 4, 1); 315362306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 1, 1); 315462306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 3, 0); 315562306a36Sopenharmony_ci } 315662306a36Sopenharmony_ci if (state->RF_IN >= 650000000 && state->RF_IN <= 900000000) { 315762306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DAC_B_ENABLE, 1); 315862306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 4, 1); 315962306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 1, 1); 316062306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 3, 1); 316162306a36Sopenharmony_ci } 316262306a36Sopenharmony_ci } 316362306a36Sopenharmony_ci 316462306a36Sopenharmony_ci if (state->TF_Type == MXL_TF_E_2) { 316562306a36Sopenharmony_ci 316662306a36Sopenharmony_ci /* Tracking Filter type E_2 */ 316762306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DAC_DIN_B, 0); 316862306a36Sopenharmony_ci 316962306a36Sopenharmony_ci if (state->RF_IN >= 43000000 && state->RF_IN < 174000000) { 317062306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0); 317162306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 4, 0); 317262306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 1, 1); 317362306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 3, 1); 317462306a36Sopenharmony_ci } 317562306a36Sopenharmony_ci if (state->RF_IN >= 174000000 && state->RF_IN < 250000000) { 317662306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0); 317762306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 4, 0); 317862306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 1, 0); 317962306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 3, 1); 318062306a36Sopenharmony_ci } 318162306a36Sopenharmony_ci if (state->RF_IN >= 250000000 && state->RF_IN < 350000000) { 318262306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0); 318362306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 4, 1); 318462306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 1, 0); 318562306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 3, 1); 318662306a36Sopenharmony_ci } 318762306a36Sopenharmony_ci if (state->RF_IN >= 350000000 && state->RF_IN < 400000000) { 318862306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0); 318962306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 4, 1); 319062306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 1, 0); 319162306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 3, 0); 319262306a36Sopenharmony_ci } 319362306a36Sopenharmony_ci if (state->RF_IN >= 400000000 && state->RF_IN < 570000000) { 319462306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0); 319562306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 4, 1); 319662306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 1, 1); 319762306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 3, 0); 319862306a36Sopenharmony_ci } 319962306a36Sopenharmony_ci if (state->RF_IN >= 570000000 && state->RF_IN < 770000000) { 320062306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DAC_B_ENABLE, 1); 320162306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 4, 1); 320262306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 1, 1); 320362306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 3, 0); 320462306a36Sopenharmony_ci } 320562306a36Sopenharmony_ci if (state->RF_IN >= 770000000 && state->RF_IN <= 900000000) { 320662306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DAC_B_ENABLE, 1); 320762306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 4, 1); 320862306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 1, 1); 320962306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 3, 1); 321062306a36Sopenharmony_ci } 321162306a36Sopenharmony_ci } 321262306a36Sopenharmony_ci 321362306a36Sopenharmony_ci if (state->TF_Type == MXL_TF_G) { 321462306a36Sopenharmony_ci 321562306a36Sopenharmony_ci /* Tracking Filter type G add for v2.6.8 */ 321662306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DAC_DIN_B, 0); 321762306a36Sopenharmony_ci 321862306a36Sopenharmony_ci if (state->RF_IN >= 50000000 && state->RF_IN < 190000000) { 321962306a36Sopenharmony_ci 322062306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0); 322162306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 4, 0); 322262306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 1, 1); 322362306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 3, 1); 322462306a36Sopenharmony_ci } 322562306a36Sopenharmony_ci if (state->RF_IN >= 190000000 && state->RF_IN < 280000000) { 322662306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0); 322762306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 4, 0); 322862306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 1, 0); 322962306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 3, 1); 323062306a36Sopenharmony_ci } 323162306a36Sopenharmony_ci if (state->RF_IN >= 280000000 && state->RF_IN < 350000000) { 323262306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0); 323362306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 4, 1); 323462306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 1, 0); 323562306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 3, 1); 323662306a36Sopenharmony_ci } 323762306a36Sopenharmony_ci if (state->RF_IN >= 350000000 && state->RF_IN < 400000000) { 323862306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0); 323962306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 4, 1); 324062306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 1, 0); 324162306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 3, 0); 324262306a36Sopenharmony_ci } 324362306a36Sopenharmony_ci if (state->RF_IN >= 400000000 && state->RF_IN < 470000000) { 324462306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DAC_B_ENABLE, 1); 324562306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 4, 1); 324662306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 1, 0); 324762306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 3, 1); 324862306a36Sopenharmony_ci } 324962306a36Sopenharmony_ci if (state->RF_IN >= 470000000 && state->RF_IN < 640000000) { 325062306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0); 325162306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 4, 1); 325262306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 1, 1); 325362306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 3, 0); 325462306a36Sopenharmony_ci } 325562306a36Sopenharmony_ci if (state->RF_IN >= 640000000 && state->RF_IN < 820000000) { 325662306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DAC_B_ENABLE, 1); 325762306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 4, 1); 325862306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 1, 1); 325962306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 3, 0); 326062306a36Sopenharmony_ci } 326162306a36Sopenharmony_ci if (state->RF_IN >= 820000000 && state->RF_IN <= 900000000) { 326262306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DAC_B_ENABLE, 1); 326362306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 4, 1); 326462306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 1, 1); 326562306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 3, 1); 326662306a36Sopenharmony_ci } 326762306a36Sopenharmony_ci } 326862306a36Sopenharmony_ci 326962306a36Sopenharmony_ci if (state->TF_Type == MXL_TF_E_NA) { 327062306a36Sopenharmony_ci 327162306a36Sopenharmony_ci /* Tracking Filter type E-NA for Empia ONLY change for 2.6.8 */ 327262306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DAC_DIN_B, 0); 327362306a36Sopenharmony_ci 327462306a36Sopenharmony_ci /* if UHF and terrestrial=> Turn off Tracking Filter */ 327562306a36Sopenharmony_ci if (state->RF_IN >= 471000000 && 327662306a36Sopenharmony_ci (state->RF_IN - 471000000)%6000000 != 0) { 327762306a36Sopenharmony_ci 327862306a36Sopenharmony_ci /* Turn off all the banks */ 327962306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 3, 1); 328062306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 1, 1); 328162306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 4, 1); 328262306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0); 328362306a36Sopenharmony_ci 328462306a36Sopenharmony_ci /* 2.6.12 Turn on RSSI */ 328562306a36Sopenharmony_ci status += MXL_ControlWrite(fe, SEQ_EXTSYNTHCALIF, 1); 328662306a36Sopenharmony_ci status += MXL_ControlWrite(fe, SEQ_EXTDCCAL, 1); 328762306a36Sopenharmony_ci status += MXL_ControlWrite(fe, AGC_EN_RSSI, 1); 328862306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFA_ENCLKRFAGC, 1); 328962306a36Sopenharmony_ci 329062306a36Sopenharmony_ci /* RSSI reference point */ 329162306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFA_RSSI_REFH, 5); 329262306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFA_RSSI_REF, 3); 329362306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFA_RSSI_REFL, 2); 329462306a36Sopenharmony_ci 329562306a36Sopenharmony_ci /* following parameter is from analog OTA mode, 329662306a36Sopenharmony_ci * can be change to seek better performance */ 329762306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFSYN_CHP_GAIN, 3); 329862306a36Sopenharmony_ci } else { 329962306a36Sopenharmony_ci /* if VHF or Cable => Turn on Tracking Filter */ 330062306a36Sopenharmony_ci 330162306a36Sopenharmony_ci /* 2.6.12 Turn off RSSI */ 330262306a36Sopenharmony_ci status += MXL_ControlWrite(fe, AGC_EN_RSSI, 0); 330362306a36Sopenharmony_ci 330462306a36Sopenharmony_ci /* change back from above condition */ 330562306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFSYN_CHP_GAIN, 5); 330662306a36Sopenharmony_ci 330762306a36Sopenharmony_ci 330862306a36Sopenharmony_ci if (state->RF_IN >= 43000000 && state->RF_IN < 174000000) { 330962306a36Sopenharmony_ci 331062306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0); 331162306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 4, 0); 331262306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 1, 1); 331362306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 3, 1); 331462306a36Sopenharmony_ci } 331562306a36Sopenharmony_ci if (state->RF_IN >= 174000000 && state->RF_IN < 250000000) { 331662306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0); 331762306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 4, 0); 331862306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 1, 0); 331962306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 3, 1); 332062306a36Sopenharmony_ci } 332162306a36Sopenharmony_ci if (state->RF_IN >= 250000000 && state->RF_IN < 350000000) { 332262306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0); 332362306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 4, 1); 332462306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 1, 0); 332562306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 3, 1); 332662306a36Sopenharmony_ci } 332762306a36Sopenharmony_ci if (state->RF_IN >= 350000000 && state->RF_IN < 400000000) { 332862306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0); 332962306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 4, 1); 333062306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 1, 0); 333162306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 3, 0); 333262306a36Sopenharmony_ci } 333362306a36Sopenharmony_ci if (state->RF_IN >= 400000000 && state->RF_IN < 570000000) { 333462306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0); 333562306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 4, 1); 333662306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 1, 1); 333762306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 3, 0); 333862306a36Sopenharmony_ci } 333962306a36Sopenharmony_ci if (state->RF_IN >= 570000000 && state->RF_IN < 770000000) { 334062306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DAC_B_ENABLE, 1); 334162306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 4, 1); 334262306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 1, 1); 334362306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 3, 0); 334462306a36Sopenharmony_ci } 334562306a36Sopenharmony_ci if (state->RF_IN >= 770000000 && state->RF_IN <= 900000000) { 334662306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DAC_B_ENABLE, 1); 334762306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 4, 1); 334862306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 1, 1); 334962306a36Sopenharmony_ci status += MXL_SetGPIO(fe, 3, 1); 335062306a36Sopenharmony_ci } 335162306a36Sopenharmony_ci } 335262306a36Sopenharmony_ci } 335362306a36Sopenharmony_ci return status ; 335462306a36Sopenharmony_ci} 335562306a36Sopenharmony_ci 335662306a36Sopenharmony_cistatic u16 MXL_SetGPIO(struct dvb_frontend *fe, u8 GPIO_Num, u8 GPIO_Val) 335762306a36Sopenharmony_ci{ 335862306a36Sopenharmony_ci u16 status = 0; 335962306a36Sopenharmony_ci 336062306a36Sopenharmony_ci if (GPIO_Num == 1) 336162306a36Sopenharmony_ci status += MXL_ControlWrite(fe, GPIO_1B, GPIO_Val ? 0 : 1); 336262306a36Sopenharmony_ci 336362306a36Sopenharmony_ci /* GPIO2 is not available */ 336462306a36Sopenharmony_ci 336562306a36Sopenharmony_ci if (GPIO_Num == 3) { 336662306a36Sopenharmony_ci if (GPIO_Val == 1) { 336762306a36Sopenharmony_ci status += MXL_ControlWrite(fe, GPIO_3, 0); 336862306a36Sopenharmony_ci status += MXL_ControlWrite(fe, GPIO_3B, 0); 336962306a36Sopenharmony_ci } 337062306a36Sopenharmony_ci if (GPIO_Val == 0) { 337162306a36Sopenharmony_ci status += MXL_ControlWrite(fe, GPIO_3, 1); 337262306a36Sopenharmony_ci status += MXL_ControlWrite(fe, GPIO_3B, 1); 337362306a36Sopenharmony_ci } 337462306a36Sopenharmony_ci if (GPIO_Val == 3) { /* tri-state */ 337562306a36Sopenharmony_ci status += MXL_ControlWrite(fe, GPIO_3, 0); 337662306a36Sopenharmony_ci status += MXL_ControlWrite(fe, GPIO_3B, 1); 337762306a36Sopenharmony_ci } 337862306a36Sopenharmony_ci } 337962306a36Sopenharmony_ci if (GPIO_Num == 4) { 338062306a36Sopenharmony_ci if (GPIO_Val == 1) { 338162306a36Sopenharmony_ci status += MXL_ControlWrite(fe, GPIO_4, 0); 338262306a36Sopenharmony_ci status += MXL_ControlWrite(fe, GPIO_4B, 0); 338362306a36Sopenharmony_ci } 338462306a36Sopenharmony_ci if (GPIO_Val == 0) { 338562306a36Sopenharmony_ci status += MXL_ControlWrite(fe, GPIO_4, 1); 338662306a36Sopenharmony_ci status += MXL_ControlWrite(fe, GPIO_4B, 1); 338762306a36Sopenharmony_ci } 338862306a36Sopenharmony_ci if (GPIO_Val == 3) { /* tri-state */ 338962306a36Sopenharmony_ci status += MXL_ControlWrite(fe, GPIO_4, 0); 339062306a36Sopenharmony_ci status += MXL_ControlWrite(fe, GPIO_4B, 1); 339162306a36Sopenharmony_ci } 339262306a36Sopenharmony_ci } 339362306a36Sopenharmony_ci 339462306a36Sopenharmony_ci return status; 339562306a36Sopenharmony_ci} 339662306a36Sopenharmony_ci 339762306a36Sopenharmony_cistatic u16 MXL_ControlWrite(struct dvb_frontend *fe, u16 ControlNum, u32 value) 339862306a36Sopenharmony_ci{ 339962306a36Sopenharmony_ci u16 status = 0; 340062306a36Sopenharmony_ci 340162306a36Sopenharmony_ci /* Will write ALL Matching Control Name */ 340262306a36Sopenharmony_ci /* Write Matching INIT Control */ 340362306a36Sopenharmony_ci status += MXL_ControlWrite_Group(fe, ControlNum, value, 1); 340462306a36Sopenharmony_ci /* Write Matching CH Control */ 340562306a36Sopenharmony_ci status += MXL_ControlWrite_Group(fe, ControlNum, value, 2); 340662306a36Sopenharmony_ci#ifdef _MXL_INTERNAL 340762306a36Sopenharmony_ci /* Write Matching MXL Control */ 340862306a36Sopenharmony_ci status += MXL_ControlWrite_Group(fe, ControlNum, value, 3); 340962306a36Sopenharmony_ci#endif 341062306a36Sopenharmony_ci return status; 341162306a36Sopenharmony_ci} 341262306a36Sopenharmony_ci 341362306a36Sopenharmony_cistatic u16 MXL_ControlWrite_Group(struct dvb_frontend *fe, u16 controlNum, 341462306a36Sopenharmony_ci u32 value, u16 controlGroup) 341562306a36Sopenharmony_ci{ 341662306a36Sopenharmony_ci struct mxl5005s_state *state = fe->tuner_priv; 341762306a36Sopenharmony_ci u16 i, j; 341862306a36Sopenharmony_ci u32 highLimit; 341962306a36Sopenharmony_ci 342062306a36Sopenharmony_ci if (controlGroup == 1) /* Initial Control */ { 342162306a36Sopenharmony_ci 342262306a36Sopenharmony_ci for (i = 0; i < state->Init_Ctrl_Num; i++) { 342362306a36Sopenharmony_ci 342462306a36Sopenharmony_ci if (controlNum == state->Init_Ctrl[i].Ctrl_Num) { 342562306a36Sopenharmony_ci 342662306a36Sopenharmony_ci u16 size = min_t(u16, state->Init_Ctrl[i].size, 342762306a36Sopenharmony_ci ARRAY_SIZE(state->Init_Ctrl[i].val)); 342862306a36Sopenharmony_ci highLimit = 1 << size; 342962306a36Sopenharmony_ci if (value < highLimit) { 343062306a36Sopenharmony_ci for (j = 0; j < size; j++) { 343162306a36Sopenharmony_ci state->Init_Ctrl[i].val[j] = (u8)((value >> j) & 0x01); 343262306a36Sopenharmony_ci MXL_RegWriteBit(fe, (u8)(state->Init_Ctrl[i].addr[j]), 343362306a36Sopenharmony_ci (u8)(state->Init_Ctrl[i].bit[j]), 343462306a36Sopenharmony_ci (u8)((value>>j) & 0x01)); 343562306a36Sopenharmony_ci } 343662306a36Sopenharmony_ci } else 343762306a36Sopenharmony_ci return -1; 343862306a36Sopenharmony_ci } 343962306a36Sopenharmony_ci } 344062306a36Sopenharmony_ci } 344162306a36Sopenharmony_ci if (controlGroup == 2) /* Chan change Control */ { 344262306a36Sopenharmony_ci 344362306a36Sopenharmony_ci for (i = 0; i < state->CH_Ctrl_Num; i++) { 344462306a36Sopenharmony_ci 344562306a36Sopenharmony_ci if (controlNum == state->CH_Ctrl[i].Ctrl_Num) { 344662306a36Sopenharmony_ci 344762306a36Sopenharmony_ci u16 size = min_t(u16, state->CH_Ctrl[i].size, 344862306a36Sopenharmony_ci ARRAY_SIZE(state->CH_Ctrl[i].val)); 344962306a36Sopenharmony_ci highLimit = 1 << size; 345062306a36Sopenharmony_ci if (value < highLimit) { 345162306a36Sopenharmony_ci for (j = 0; j < size; j++) { 345262306a36Sopenharmony_ci state->CH_Ctrl[i].val[j] = (u8)((value >> j) & 0x01); 345362306a36Sopenharmony_ci MXL_RegWriteBit(fe, (u8)(state->CH_Ctrl[i].addr[j]), 345462306a36Sopenharmony_ci (u8)(state->CH_Ctrl[i].bit[j]), 345562306a36Sopenharmony_ci (u8)((value>>j) & 0x01)); 345662306a36Sopenharmony_ci } 345762306a36Sopenharmony_ci } else 345862306a36Sopenharmony_ci return -1; 345962306a36Sopenharmony_ci } 346062306a36Sopenharmony_ci } 346162306a36Sopenharmony_ci } 346262306a36Sopenharmony_ci#ifdef _MXL_INTERNAL 346362306a36Sopenharmony_ci if (controlGroup == 3) /* Maxlinear Control */ { 346462306a36Sopenharmony_ci 346562306a36Sopenharmony_ci for (i = 0; i < state->MXL_Ctrl_Num; i++) { 346662306a36Sopenharmony_ci 346762306a36Sopenharmony_ci if (controlNum == state->MXL_Ctrl[i].Ctrl_Num) { 346862306a36Sopenharmony_ci 346962306a36Sopenharmony_ci highLimit = (1 << state->MXL_Ctrl[i].size); 347062306a36Sopenharmony_ci if (value < highLimit) { 347162306a36Sopenharmony_ci for (j = 0; j < state->MXL_Ctrl[i].size; j++) { 347262306a36Sopenharmony_ci state->MXL_Ctrl[i].val[j] = (u8)((value >> j) & 0x01); 347362306a36Sopenharmony_ci MXL_RegWriteBit(fe, (u8)(state->MXL_Ctrl[i].addr[j]), 347462306a36Sopenharmony_ci (u8)(state->MXL_Ctrl[i].bit[j]), 347562306a36Sopenharmony_ci (u8)((value>>j) & 0x01)); 347662306a36Sopenharmony_ci } 347762306a36Sopenharmony_ci } else 347862306a36Sopenharmony_ci return -1; 347962306a36Sopenharmony_ci } 348062306a36Sopenharmony_ci } 348162306a36Sopenharmony_ci } 348262306a36Sopenharmony_ci#endif 348362306a36Sopenharmony_ci return 0 ; /* successful return */ 348462306a36Sopenharmony_ci} 348562306a36Sopenharmony_ci 348662306a36Sopenharmony_cistatic u16 MXL_RegRead(struct dvb_frontend *fe, u8 RegNum, u8 *RegVal) 348762306a36Sopenharmony_ci{ 348862306a36Sopenharmony_ci struct mxl5005s_state *state = fe->tuner_priv; 348962306a36Sopenharmony_ci int i ; 349062306a36Sopenharmony_ci 349162306a36Sopenharmony_ci for (i = 0; i < 104; i++) { 349262306a36Sopenharmony_ci if (RegNum == state->TunerRegs[i].Reg_Num) { 349362306a36Sopenharmony_ci *RegVal = (u8)(state->TunerRegs[i].Reg_Val); 349462306a36Sopenharmony_ci return 0; 349562306a36Sopenharmony_ci } 349662306a36Sopenharmony_ci } 349762306a36Sopenharmony_ci 349862306a36Sopenharmony_ci return 1; 349962306a36Sopenharmony_ci} 350062306a36Sopenharmony_ci 350162306a36Sopenharmony_cistatic u16 MXL_ControlRead(struct dvb_frontend *fe, u16 controlNum, u32 *value) 350262306a36Sopenharmony_ci{ 350362306a36Sopenharmony_ci struct mxl5005s_state *state = fe->tuner_priv; 350462306a36Sopenharmony_ci u32 ctrlVal ; 350562306a36Sopenharmony_ci u16 i, k ; 350662306a36Sopenharmony_ci 350762306a36Sopenharmony_ci for (i = 0; i < state->Init_Ctrl_Num ; i++) { 350862306a36Sopenharmony_ci 350962306a36Sopenharmony_ci if (controlNum == state->Init_Ctrl[i].Ctrl_Num) { 351062306a36Sopenharmony_ci 351162306a36Sopenharmony_ci ctrlVal = 0; 351262306a36Sopenharmony_ci for (k = 0; k < state->Init_Ctrl[i].size; k++) 351362306a36Sopenharmony_ci ctrlVal += state->Init_Ctrl[i].val[k] * (1<<k); 351462306a36Sopenharmony_ci *value = ctrlVal; 351562306a36Sopenharmony_ci return 0; 351662306a36Sopenharmony_ci } 351762306a36Sopenharmony_ci } 351862306a36Sopenharmony_ci 351962306a36Sopenharmony_ci for (i = 0; i < state->CH_Ctrl_Num ; i++) { 352062306a36Sopenharmony_ci 352162306a36Sopenharmony_ci if (controlNum == state->CH_Ctrl[i].Ctrl_Num) { 352262306a36Sopenharmony_ci 352362306a36Sopenharmony_ci ctrlVal = 0; 352462306a36Sopenharmony_ci for (k = 0; k < state->CH_Ctrl[i].size; k++) 352562306a36Sopenharmony_ci ctrlVal += state->CH_Ctrl[i].val[k] * (1 << k); 352662306a36Sopenharmony_ci *value = ctrlVal; 352762306a36Sopenharmony_ci return 0; 352862306a36Sopenharmony_ci 352962306a36Sopenharmony_ci } 353062306a36Sopenharmony_ci } 353162306a36Sopenharmony_ci 353262306a36Sopenharmony_ci#ifdef _MXL_INTERNAL 353362306a36Sopenharmony_ci for (i = 0; i < state->MXL_Ctrl_Num ; i++) { 353462306a36Sopenharmony_ci 353562306a36Sopenharmony_ci if (controlNum == state->MXL_Ctrl[i].Ctrl_Num) { 353662306a36Sopenharmony_ci 353762306a36Sopenharmony_ci ctrlVal = 0; 353862306a36Sopenharmony_ci for (k = 0; k < state->MXL_Ctrl[i].size; k++) 353962306a36Sopenharmony_ci ctrlVal += state->MXL_Ctrl[i].val[k] * (1<<k); 354062306a36Sopenharmony_ci *value = ctrlVal; 354162306a36Sopenharmony_ci return 0; 354262306a36Sopenharmony_ci 354362306a36Sopenharmony_ci } 354462306a36Sopenharmony_ci } 354562306a36Sopenharmony_ci#endif 354662306a36Sopenharmony_ci return 1; 354762306a36Sopenharmony_ci} 354862306a36Sopenharmony_ci 354962306a36Sopenharmony_cistatic void MXL_RegWriteBit(struct dvb_frontend *fe, u8 address, u8 bit, 355062306a36Sopenharmony_ci u8 bitVal) 355162306a36Sopenharmony_ci{ 355262306a36Sopenharmony_ci struct mxl5005s_state *state = fe->tuner_priv; 355362306a36Sopenharmony_ci int i ; 355462306a36Sopenharmony_ci 355562306a36Sopenharmony_ci const u8 AND_MAP[8] = { 355662306a36Sopenharmony_ci 0xFE, 0xFD, 0xFB, 0xF7, 355762306a36Sopenharmony_ci 0xEF, 0xDF, 0xBF, 0x7F } ; 355862306a36Sopenharmony_ci 355962306a36Sopenharmony_ci const u8 OR_MAP[8] = { 356062306a36Sopenharmony_ci 0x01, 0x02, 0x04, 0x08, 356162306a36Sopenharmony_ci 0x10, 0x20, 0x40, 0x80 } ; 356262306a36Sopenharmony_ci 356362306a36Sopenharmony_ci for (i = 0; i < state->TunerRegs_Num; i++) { 356462306a36Sopenharmony_ci if (state->TunerRegs[i].Reg_Num == address) { 356562306a36Sopenharmony_ci if (bitVal) 356662306a36Sopenharmony_ci state->TunerRegs[i].Reg_Val |= OR_MAP[bit]; 356762306a36Sopenharmony_ci else 356862306a36Sopenharmony_ci state->TunerRegs[i].Reg_Val &= AND_MAP[bit]; 356962306a36Sopenharmony_ci break ; 357062306a36Sopenharmony_ci } 357162306a36Sopenharmony_ci } 357262306a36Sopenharmony_ci} 357362306a36Sopenharmony_ci 357462306a36Sopenharmony_cistatic u32 MXL_Ceiling(u32 value, u32 resolution) 357562306a36Sopenharmony_ci{ 357662306a36Sopenharmony_ci return value / resolution + (value % resolution > 0 ? 1 : 0); 357762306a36Sopenharmony_ci} 357862306a36Sopenharmony_ci 357962306a36Sopenharmony_ci/* Retrieve the Initialization Registers */ 358062306a36Sopenharmony_cistatic u16 MXL_GetInitRegister(struct dvb_frontend *fe, u8 *RegNum, 358162306a36Sopenharmony_ci u8 *RegVal, int *count) 358262306a36Sopenharmony_ci{ 358362306a36Sopenharmony_ci u16 status = 0; 358462306a36Sopenharmony_ci int i ; 358562306a36Sopenharmony_ci 358662306a36Sopenharmony_ci static const u8 RegAddr[] = { 358762306a36Sopenharmony_ci 11, 12, 13, 22, 32, 43, 44, 53, 56, 59, 73, 358862306a36Sopenharmony_ci 76, 77, 91, 134, 135, 137, 147, 358962306a36Sopenharmony_ci 156, 166, 167, 168, 25 359062306a36Sopenharmony_ci }; 359162306a36Sopenharmony_ci 359262306a36Sopenharmony_ci *count = ARRAY_SIZE(RegAddr); 359362306a36Sopenharmony_ci 359462306a36Sopenharmony_ci status += MXL_BlockInit(fe); 359562306a36Sopenharmony_ci 359662306a36Sopenharmony_ci for (i = 0 ; i < *count; i++) { 359762306a36Sopenharmony_ci RegNum[i] = RegAddr[i]; 359862306a36Sopenharmony_ci status += MXL_RegRead(fe, RegNum[i], &RegVal[i]); 359962306a36Sopenharmony_ci } 360062306a36Sopenharmony_ci 360162306a36Sopenharmony_ci return status; 360262306a36Sopenharmony_ci} 360362306a36Sopenharmony_ci 360462306a36Sopenharmony_cistatic u16 MXL_GetCHRegister(struct dvb_frontend *fe, u8 *RegNum, u8 *RegVal, 360562306a36Sopenharmony_ci int *count) 360662306a36Sopenharmony_ci{ 360762306a36Sopenharmony_ci u16 status = 0; 360862306a36Sopenharmony_ci int i ; 360962306a36Sopenharmony_ci 361062306a36Sopenharmony_ci/* add 77, 166, 167, 168 register for 2.6.12 */ 361162306a36Sopenharmony_ci#ifdef _MXL_PRODUCTION 361262306a36Sopenharmony_ci static const u8 RegAddr[] = { 361362306a36Sopenharmony_ci 14, 15, 16, 17, 22, 43, 65, 68, 69, 70, 73, 92, 93, 106, 361462306a36Sopenharmony_ci 107, 108, 109, 110, 111, 112, 136, 138, 149, 77, 166, 167, 168 361562306a36Sopenharmony_ci }; 361662306a36Sopenharmony_ci#else 361762306a36Sopenharmony_ci static const u8 RegAddr[] = { 361862306a36Sopenharmony_ci 14, 15, 16, 17, 22, 43, 68, 69, 70, 73, 92, 93, 106, 361962306a36Sopenharmony_ci 107, 108, 109, 110, 111, 112, 136, 138, 149, 77, 166, 167, 168 362062306a36Sopenharmony_ci }; 362162306a36Sopenharmony_ci /* 362262306a36Sopenharmony_ci u8 RegAddr[171]; 362362306a36Sopenharmony_ci for (i = 0; i <= 170; i++) 362462306a36Sopenharmony_ci RegAddr[i] = i; 362562306a36Sopenharmony_ci */ 362662306a36Sopenharmony_ci#endif 362762306a36Sopenharmony_ci 362862306a36Sopenharmony_ci *count = ARRAY_SIZE(RegAddr); 362962306a36Sopenharmony_ci 363062306a36Sopenharmony_ci for (i = 0 ; i < *count; i++) { 363162306a36Sopenharmony_ci RegNum[i] = RegAddr[i]; 363262306a36Sopenharmony_ci status += MXL_RegRead(fe, RegNum[i], &RegVal[i]); 363362306a36Sopenharmony_ci } 363462306a36Sopenharmony_ci 363562306a36Sopenharmony_ci return status; 363662306a36Sopenharmony_ci} 363762306a36Sopenharmony_ci 363862306a36Sopenharmony_cistatic u16 MXL_GetCHRegister_ZeroIF(struct dvb_frontend *fe, u8 *RegNum, 363962306a36Sopenharmony_ci u8 *RegVal, int *count) 364062306a36Sopenharmony_ci{ 364162306a36Sopenharmony_ci u16 status = 0; 364262306a36Sopenharmony_ci int i; 364362306a36Sopenharmony_ci 364462306a36Sopenharmony_ci static const u8 RegAddr[] = {43, 136}; 364562306a36Sopenharmony_ci 364662306a36Sopenharmony_ci *count = ARRAY_SIZE(RegAddr); 364762306a36Sopenharmony_ci 364862306a36Sopenharmony_ci for (i = 0; i < *count; i++) { 364962306a36Sopenharmony_ci RegNum[i] = RegAddr[i]; 365062306a36Sopenharmony_ci status += MXL_RegRead(fe, RegNum[i], &RegVal[i]); 365162306a36Sopenharmony_ci } 365262306a36Sopenharmony_ci 365362306a36Sopenharmony_ci return status; 365462306a36Sopenharmony_ci} 365562306a36Sopenharmony_ci 365662306a36Sopenharmony_cistatic u16 MXL_GetMasterControl(u8 *MasterReg, int state) 365762306a36Sopenharmony_ci{ 365862306a36Sopenharmony_ci if (state == 1) /* Load_Start */ 365962306a36Sopenharmony_ci *MasterReg = 0xF3; 366062306a36Sopenharmony_ci if (state == 2) /* Power_Down */ 366162306a36Sopenharmony_ci *MasterReg = 0x41; 366262306a36Sopenharmony_ci if (state == 3) /* Synth_Reset */ 366362306a36Sopenharmony_ci *MasterReg = 0xB1; 366462306a36Sopenharmony_ci if (state == 4) /* Seq_Off */ 366562306a36Sopenharmony_ci *MasterReg = 0xF1; 366662306a36Sopenharmony_ci 366762306a36Sopenharmony_ci return 0; 366862306a36Sopenharmony_ci} 366962306a36Sopenharmony_ci 367062306a36Sopenharmony_ci#ifdef _MXL_PRODUCTION 367162306a36Sopenharmony_cistatic u16 MXL_VCORange_Test(struct dvb_frontend *fe, int VCO_Range) 367262306a36Sopenharmony_ci{ 367362306a36Sopenharmony_ci struct mxl5005s_state *state = fe->tuner_priv; 367462306a36Sopenharmony_ci u16 status = 0 ; 367562306a36Sopenharmony_ci 367662306a36Sopenharmony_ci if (VCO_Range == 1) { 367762306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFSYN_EN_DIV, 1); 367862306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFSYN_EN_OUTMUX, 0); 367962306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFSYN_SEL_DIVM, 0); 368062306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFSYN_DIVM, 1); 368162306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_OUT, 1); 368262306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFSYN_RF_DIV_BIAS, 1); 368362306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DN_SEL_FREQ, 0); 368462306a36Sopenharmony_ci if (state->Mode == 0 && state->IF_Mode == 1) { 368562306a36Sopenharmony_ci /* Analog Low IF Mode */ 368662306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 1); 368762306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFSYN_VCO_BIAS, 8); 368862306a36Sopenharmony_ci status += MXL_ControlWrite(fe, CHCAL_INT_MOD_RF, 56); 368962306a36Sopenharmony_ci status += MXL_ControlWrite(fe, 369062306a36Sopenharmony_ci CHCAL_FRAC_MOD_RF, 180224); 369162306a36Sopenharmony_ci } 369262306a36Sopenharmony_ci if (state->Mode == 0 && state->IF_Mode == 0) { 369362306a36Sopenharmony_ci /* Analog Zero IF Mode */ 369462306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 1); 369562306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFSYN_VCO_BIAS, 8); 369662306a36Sopenharmony_ci status += MXL_ControlWrite(fe, CHCAL_INT_MOD_RF, 56); 369762306a36Sopenharmony_ci status += MXL_ControlWrite(fe, 369862306a36Sopenharmony_ci CHCAL_FRAC_MOD_RF, 222822); 369962306a36Sopenharmony_ci } 370062306a36Sopenharmony_ci if (state->Mode == 1) /* Digital Mode */ { 370162306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 1); 370262306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFSYN_VCO_BIAS, 8); 370362306a36Sopenharmony_ci status += MXL_ControlWrite(fe, CHCAL_INT_MOD_RF, 56); 370462306a36Sopenharmony_ci status += MXL_ControlWrite(fe, 370562306a36Sopenharmony_ci CHCAL_FRAC_MOD_RF, 229376); 370662306a36Sopenharmony_ci } 370762306a36Sopenharmony_ci } 370862306a36Sopenharmony_ci 370962306a36Sopenharmony_ci if (VCO_Range == 2) { 371062306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFSYN_EN_DIV, 1); 371162306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFSYN_EN_OUTMUX, 0); 371262306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFSYN_SEL_DIVM, 0); 371362306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFSYN_DIVM, 1); 371462306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_OUT, 1); 371562306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFSYN_RF_DIV_BIAS, 1); 371662306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DN_SEL_FREQ, 0); 371762306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 1); 371862306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFSYN_VCO_BIAS, 40); 371962306a36Sopenharmony_ci status += MXL_ControlWrite(fe, CHCAL_INT_MOD_RF, 41); 372062306a36Sopenharmony_ci if (state->Mode == 0 && state->IF_Mode == 1) { 372162306a36Sopenharmony_ci /* Analog Low IF Mode */ 372262306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 1); 372362306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFSYN_VCO_BIAS, 40); 372462306a36Sopenharmony_ci status += MXL_ControlWrite(fe, CHCAL_INT_MOD_RF, 42); 372562306a36Sopenharmony_ci status += MXL_ControlWrite(fe, 372662306a36Sopenharmony_ci CHCAL_FRAC_MOD_RF, 206438); 372762306a36Sopenharmony_ci } 372862306a36Sopenharmony_ci if (state->Mode == 0 && state->IF_Mode == 0) { 372962306a36Sopenharmony_ci /* Analog Zero IF Mode */ 373062306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 1); 373162306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFSYN_VCO_BIAS, 40); 373262306a36Sopenharmony_ci status += MXL_ControlWrite(fe, CHCAL_INT_MOD_RF, 42); 373362306a36Sopenharmony_ci status += MXL_ControlWrite(fe, 373462306a36Sopenharmony_ci CHCAL_FRAC_MOD_RF, 206438); 373562306a36Sopenharmony_ci } 373662306a36Sopenharmony_ci if (state->Mode == 1) /* Digital Mode */ { 373762306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 1); 373862306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFSYN_VCO_BIAS, 40); 373962306a36Sopenharmony_ci status += MXL_ControlWrite(fe, CHCAL_INT_MOD_RF, 41); 374062306a36Sopenharmony_ci status += MXL_ControlWrite(fe, 374162306a36Sopenharmony_ci CHCAL_FRAC_MOD_RF, 16384); 374262306a36Sopenharmony_ci } 374362306a36Sopenharmony_ci } 374462306a36Sopenharmony_ci 374562306a36Sopenharmony_ci if (VCO_Range == 3) { 374662306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFSYN_EN_DIV, 1); 374762306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFSYN_EN_OUTMUX, 0); 374862306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFSYN_SEL_DIVM, 0); 374962306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFSYN_DIVM, 1); 375062306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_OUT, 1); 375162306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFSYN_RF_DIV_BIAS, 1); 375262306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DN_SEL_FREQ, 0); 375362306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 0); 375462306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFSYN_VCO_BIAS, 8); 375562306a36Sopenharmony_ci status += MXL_ControlWrite(fe, CHCAL_INT_MOD_RF, 42); 375662306a36Sopenharmony_ci if (state->Mode == 0 && state->IF_Mode == 1) { 375762306a36Sopenharmony_ci /* Analog Low IF Mode */ 375862306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 0); 375962306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFSYN_VCO_BIAS, 8); 376062306a36Sopenharmony_ci status += MXL_ControlWrite(fe, CHCAL_INT_MOD_RF, 44); 376162306a36Sopenharmony_ci status += MXL_ControlWrite(fe, 376262306a36Sopenharmony_ci CHCAL_FRAC_MOD_RF, 173670); 376362306a36Sopenharmony_ci } 376462306a36Sopenharmony_ci if (state->Mode == 0 && state->IF_Mode == 0) { 376562306a36Sopenharmony_ci /* Analog Zero IF Mode */ 376662306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 0); 376762306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFSYN_VCO_BIAS, 8); 376862306a36Sopenharmony_ci status += MXL_ControlWrite(fe, CHCAL_INT_MOD_RF, 44); 376962306a36Sopenharmony_ci status += MXL_ControlWrite(fe, 377062306a36Sopenharmony_ci CHCAL_FRAC_MOD_RF, 173670); 377162306a36Sopenharmony_ci } 377262306a36Sopenharmony_ci if (state->Mode == 1) /* Digital Mode */ { 377362306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 0); 377462306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFSYN_VCO_BIAS, 8); 377562306a36Sopenharmony_ci status += MXL_ControlWrite(fe, CHCAL_INT_MOD_RF, 42); 377662306a36Sopenharmony_ci status += MXL_ControlWrite(fe, 377762306a36Sopenharmony_ci CHCAL_FRAC_MOD_RF, 245760); 377862306a36Sopenharmony_ci } 377962306a36Sopenharmony_ci } 378062306a36Sopenharmony_ci 378162306a36Sopenharmony_ci if (VCO_Range == 4) { 378262306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFSYN_EN_DIV, 1); 378362306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFSYN_EN_OUTMUX, 0); 378462306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFSYN_SEL_DIVM, 0); 378562306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFSYN_DIVM, 1); 378662306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_OUT, 1); 378762306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFSYN_RF_DIV_BIAS, 1); 378862306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DN_SEL_FREQ, 0); 378962306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 0); 379062306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFSYN_VCO_BIAS, 40); 379162306a36Sopenharmony_ci status += MXL_ControlWrite(fe, CHCAL_INT_MOD_RF, 27); 379262306a36Sopenharmony_ci if (state->Mode == 0 && state->IF_Mode == 1) { 379362306a36Sopenharmony_ci /* Analog Low IF Mode */ 379462306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 0); 379562306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFSYN_VCO_BIAS, 40); 379662306a36Sopenharmony_ci status += MXL_ControlWrite(fe, CHCAL_INT_MOD_RF, 27); 379762306a36Sopenharmony_ci status += MXL_ControlWrite(fe, 379862306a36Sopenharmony_ci CHCAL_FRAC_MOD_RF, 206438); 379962306a36Sopenharmony_ci } 380062306a36Sopenharmony_ci if (state->Mode == 0 && state->IF_Mode == 0) { 380162306a36Sopenharmony_ci /* Analog Zero IF Mode */ 380262306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 0); 380362306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFSYN_VCO_BIAS, 40); 380462306a36Sopenharmony_ci status += MXL_ControlWrite(fe, CHCAL_INT_MOD_RF, 27); 380562306a36Sopenharmony_ci status += MXL_ControlWrite(fe, 380662306a36Sopenharmony_ci CHCAL_FRAC_MOD_RF, 206438); 380762306a36Sopenharmony_ci } 380862306a36Sopenharmony_ci if (state->Mode == 1) /* Digital Mode */ { 380962306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 0); 381062306a36Sopenharmony_ci status += MXL_ControlWrite(fe, RFSYN_VCO_BIAS, 40); 381162306a36Sopenharmony_ci status += MXL_ControlWrite(fe, CHCAL_INT_MOD_RF, 27); 381262306a36Sopenharmony_ci status += MXL_ControlWrite(fe, 381362306a36Sopenharmony_ci CHCAL_FRAC_MOD_RF, 212992); 381462306a36Sopenharmony_ci } 381562306a36Sopenharmony_ci } 381662306a36Sopenharmony_ci 381762306a36Sopenharmony_ci return status; 381862306a36Sopenharmony_ci} 381962306a36Sopenharmony_ci 382062306a36Sopenharmony_cistatic u16 MXL_Hystersis_Test(struct dvb_frontend *fe, int Hystersis) 382162306a36Sopenharmony_ci{ 382262306a36Sopenharmony_ci struct mxl5005s_state *state = fe->tuner_priv; 382362306a36Sopenharmony_ci u16 status = 0; 382462306a36Sopenharmony_ci 382562306a36Sopenharmony_ci if (Hystersis == 1) 382662306a36Sopenharmony_ci status += MXL_ControlWrite(fe, DN_BYPASS_AGC_I2C, 1); 382762306a36Sopenharmony_ci 382862306a36Sopenharmony_ci return status; 382962306a36Sopenharmony_ci} 383062306a36Sopenharmony_ci#endif 383162306a36Sopenharmony_ci/* End: Reference driver code found in the Realtek driver that 383262306a36Sopenharmony_ci * is copyright MaxLinear */ 383362306a36Sopenharmony_ci 383462306a36Sopenharmony_ci/* ---------------------------------------------------------------- 383562306a36Sopenharmony_ci * Begin: Everything after here is new code to adapt the 383662306a36Sopenharmony_ci * proprietary Realtek driver into a Linux API tuner. 383762306a36Sopenharmony_ci * Copyright (C) 2008 Steven Toth <stoth@linuxtv.org> 383862306a36Sopenharmony_ci */ 383962306a36Sopenharmony_cistatic int mxl5005s_reset(struct dvb_frontend *fe) 384062306a36Sopenharmony_ci{ 384162306a36Sopenharmony_ci struct mxl5005s_state *state = fe->tuner_priv; 384262306a36Sopenharmony_ci int ret = 0; 384362306a36Sopenharmony_ci 384462306a36Sopenharmony_ci u8 buf[2] = { 0xff, 0x00 }; 384562306a36Sopenharmony_ci struct i2c_msg msg = { .addr = state->config->i2c_address, .flags = 0, 384662306a36Sopenharmony_ci .buf = buf, .len = 2 }; 384762306a36Sopenharmony_ci 384862306a36Sopenharmony_ci dprintk(2, "%s()\n", __func__); 384962306a36Sopenharmony_ci 385062306a36Sopenharmony_ci if (fe->ops.i2c_gate_ctrl) 385162306a36Sopenharmony_ci fe->ops.i2c_gate_ctrl(fe, 1); 385262306a36Sopenharmony_ci 385362306a36Sopenharmony_ci if (i2c_transfer(state->i2c, &msg, 1) != 1) { 385462306a36Sopenharmony_ci printk(KERN_WARNING "mxl5005s I2C reset failed\n"); 385562306a36Sopenharmony_ci ret = -EREMOTEIO; 385662306a36Sopenharmony_ci } 385762306a36Sopenharmony_ci 385862306a36Sopenharmony_ci if (fe->ops.i2c_gate_ctrl) 385962306a36Sopenharmony_ci fe->ops.i2c_gate_ctrl(fe, 0); 386062306a36Sopenharmony_ci 386162306a36Sopenharmony_ci return ret; 386262306a36Sopenharmony_ci} 386362306a36Sopenharmony_ci 386462306a36Sopenharmony_ci/* Write a single byte to a single reg, latch the value if required by 386562306a36Sopenharmony_ci * following the transaction with the latch byte. 386662306a36Sopenharmony_ci */ 386762306a36Sopenharmony_cistatic int mxl5005s_writereg(struct dvb_frontend *fe, u8 reg, u8 val, int latch) 386862306a36Sopenharmony_ci{ 386962306a36Sopenharmony_ci struct mxl5005s_state *state = fe->tuner_priv; 387062306a36Sopenharmony_ci u8 buf[3] = { reg, val, MXL5005S_LATCH_BYTE }; 387162306a36Sopenharmony_ci struct i2c_msg msg = { .addr = state->config->i2c_address, .flags = 0, 387262306a36Sopenharmony_ci .buf = buf, .len = 3 }; 387362306a36Sopenharmony_ci 387462306a36Sopenharmony_ci if (latch == 0) 387562306a36Sopenharmony_ci msg.len = 2; 387662306a36Sopenharmony_ci 387762306a36Sopenharmony_ci dprintk(2, "%s(0x%x, 0x%x, 0x%x)\n", __func__, reg, val, msg.addr); 387862306a36Sopenharmony_ci 387962306a36Sopenharmony_ci if (i2c_transfer(state->i2c, &msg, 1) != 1) { 388062306a36Sopenharmony_ci printk(KERN_WARNING "mxl5005s I2C write failed\n"); 388162306a36Sopenharmony_ci return -EREMOTEIO; 388262306a36Sopenharmony_ci } 388362306a36Sopenharmony_ci return 0; 388462306a36Sopenharmony_ci} 388562306a36Sopenharmony_ci 388662306a36Sopenharmony_cistatic int mxl5005s_writeregs(struct dvb_frontend *fe, u8 *addrtable, 388762306a36Sopenharmony_ci u8 *datatable, u8 len) 388862306a36Sopenharmony_ci{ 388962306a36Sopenharmony_ci int ret = 0, i; 389062306a36Sopenharmony_ci 389162306a36Sopenharmony_ci if (fe->ops.i2c_gate_ctrl) 389262306a36Sopenharmony_ci fe->ops.i2c_gate_ctrl(fe, 1); 389362306a36Sopenharmony_ci 389462306a36Sopenharmony_ci for (i = 0 ; i < len-1; i++) { 389562306a36Sopenharmony_ci ret = mxl5005s_writereg(fe, addrtable[i], datatable[i], 0); 389662306a36Sopenharmony_ci if (ret < 0) 389762306a36Sopenharmony_ci break; 389862306a36Sopenharmony_ci } 389962306a36Sopenharmony_ci 390062306a36Sopenharmony_ci ret = mxl5005s_writereg(fe, addrtable[i], datatable[i], 1); 390162306a36Sopenharmony_ci 390262306a36Sopenharmony_ci if (fe->ops.i2c_gate_ctrl) 390362306a36Sopenharmony_ci fe->ops.i2c_gate_ctrl(fe, 0); 390462306a36Sopenharmony_ci 390562306a36Sopenharmony_ci return ret; 390662306a36Sopenharmony_ci} 390762306a36Sopenharmony_ci 390862306a36Sopenharmony_cistatic int mxl5005s_init(struct dvb_frontend *fe) 390962306a36Sopenharmony_ci{ 391062306a36Sopenharmony_ci struct mxl5005s_state *state = fe->tuner_priv; 391162306a36Sopenharmony_ci 391262306a36Sopenharmony_ci dprintk(1, "%s()\n", __func__); 391362306a36Sopenharmony_ci state->current_mode = MXL_QAM; 391462306a36Sopenharmony_ci return mxl5005s_reconfigure(fe, MXL_QAM, MXL5005S_BANDWIDTH_6MHZ); 391562306a36Sopenharmony_ci} 391662306a36Sopenharmony_ci 391762306a36Sopenharmony_cistatic int mxl5005s_reconfigure(struct dvb_frontend *fe, u32 mod_type, 391862306a36Sopenharmony_ci u32 bandwidth) 391962306a36Sopenharmony_ci{ 392062306a36Sopenharmony_ci struct mxl5005s_state *state = fe->tuner_priv; 392162306a36Sopenharmony_ci u8 *AddrTable; 392262306a36Sopenharmony_ci u8 *ByteTable; 392362306a36Sopenharmony_ci int TableLen; 392462306a36Sopenharmony_ci 392562306a36Sopenharmony_ci dprintk(1, "%s(type=%d, bw=%d)\n", __func__, mod_type, bandwidth); 392662306a36Sopenharmony_ci 392762306a36Sopenharmony_ci mxl5005s_reset(fe); 392862306a36Sopenharmony_ci 392962306a36Sopenharmony_ci AddrTable = kcalloc(MXL5005S_REG_WRITING_TABLE_LEN_MAX, sizeof(u8), 393062306a36Sopenharmony_ci GFP_KERNEL); 393162306a36Sopenharmony_ci if (!AddrTable) 393262306a36Sopenharmony_ci return -ENOMEM; 393362306a36Sopenharmony_ci 393462306a36Sopenharmony_ci ByteTable = kcalloc(MXL5005S_REG_WRITING_TABLE_LEN_MAX, sizeof(u8), 393562306a36Sopenharmony_ci GFP_KERNEL); 393662306a36Sopenharmony_ci if (!ByteTable) { 393762306a36Sopenharmony_ci kfree(AddrTable); 393862306a36Sopenharmony_ci return -ENOMEM; 393962306a36Sopenharmony_ci } 394062306a36Sopenharmony_ci 394162306a36Sopenharmony_ci /* Tuner initialization stage 0 */ 394262306a36Sopenharmony_ci MXL_GetMasterControl(ByteTable, MC_SYNTH_RESET); 394362306a36Sopenharmony_ci AddrTable[0] = MASTER_CONTROL_ADDR; 394462306a36Sopenharmony_ci ByteTable[0] |= state->config->AgcMasterByte; 394562306a36Sopenharmony_ci 394662306a36Sopenharmony_ci mxl5005s_writeregs(fe, AddrTable, ByteTable, 1); 394762306a36Sopenharmony_ci 394862306a36Sopenharmony_ci mxl5005s_AssignTunerMode(fe, mod_type, bandwidth); 394962306a36Sopenharmony_ci 395062306a36Sopenharmony_ci /* Tuner initialization stage 1 */ 395162306a36Sopenharmony_ci MXL_GetInitRegister(fe, AddrTable, ByteTable, &TableLen); 395262306a36Sopenharmony_ci 395362306a36Sopenharmony_ci mxl5005s_writeregs(fe, AddrTable, ByteTable, TableLen); 395462306a36Sopenharmony_ci 395562306a36Sopenharmony_ci kfree(AddrTable); 395662306a36Sopenharmony_ci kfree(ByteTable); 395762306a36Sopenharmony_ci 395862306a36Sopenharmony_ci return 0; 395962306a36Sopenharmony_ci} 396062306a36Sopenharmony_ci 396162306a36Sopenharmony_cistatic int mxl5005s_AssignTunerMode(struct dvb_frontend *fe, u32 mod_type, 396262306a36Sopenharmony_ci u32 bandwidth) 396362306a36Sopenharmony_ci{ 396462306a36Sopenharmony_ci struct mxl5005s_state *state = fe->tuner_priv; 396562306a36Sopenharmony_ci struct mxl5005s_config *c = state->config; 396662306a36Sopenharmony_ci 396762306a36Sopenharmony_ci InitTunerControls(fe); 396862306a36Sopenharmony_ci 396962306a36Sopenharmony_ci /* Set MxL5005S parameters. */ 397062306a36Sopenharmony_ci MXL5005_TunerConfig( 397162306a36Sopenharmony_ci fe, 397262306a36Sopenharmony_ci c->mod_mode, 397362306a36Sopenharmony_ci c->if_mode, 397462306a36Sopenharmony_ci bandwidth, 397562306a36Sopenharmony_ci c->if_freq, 397662306a36Sopenharmony_ci c->xtal_freq, 397762306a36Sopenharmony_ci c->agc_mode, 397862306a36Sopenharmony_ci c->top, 397962306a36Sopenharmony_ci c->output_load, 398062306a36Sopenharmony_ci c->clock_out, 398162306a36Sopenharmony_ci c->div_out, 398262306a36Sopenharmony_ci c->cap_select, 398362306a36Sopenharmony_ci c->rssi_enable, 398462306a36Sopenharmony_ci mod_type, 398562306a36Sopenharmony_ci c->tracking_filter); 398662306a36Sopenharmony_ci 398762306a36Sopenharmony_ci return 0; 398862306a36Sopenharmony_ci} 398962306a36Sopenharmony_ci 399062306a36Sopenharmony_cistatic int mxl5005s_set_params(struct dvb_frontend *fe) 399162306a36Sopenharmony_ci{ 399262306a36Sopenharmony_ci struct mxl5005s_state *state = fe->tuner_priv; 399362306a36Sopenharmony_ci struct dtv_frontend_properties *c = &fe->dtv_property_cache; 399462306a36Sopenharmony_ci u32 delsys = c->delivery_system; 399562306a36Sopenharmony_ci u32 bw = c->bandwidth_hz; 399662306a36Sopenharmony_ci u32 req_mode, req_bw = 0; 399762306a36Sopenharmony_ci int ret; 399862306a36Sopenharmony_ci 399962306a36Sopenharmony_ci dprintk(1, "%s()\n", __func__); 400062306a36Sopenharmony_ci 400162306a36Sopenharmony_ci switch (delsys) { 400262306a36Sopenharmony_ci case SYS_ATSC: 400362306a36Sopenharmony_ci req_mode = MXL_ATSC; 400462306a36Sopenharmony_ci req_bw = MXL5005S_BANDWIDTH_6MHZ; 400562306a36Sopenharmony_ci break; 400662306a36Sopenharmony_ci case SYS_DVBC_ANNEX_B: 400762306a36Sopenharmony_ci req_mode = MXL_QAM; 400862306a36Sopenharmony_ci req_bw = MXL5005S_BANDWIDTH_6MHZ; 400962306a36Sopenharmony_ci break; 401062306a36Sopenharmony_ci default: /* Assume DVB-T */ 401162306a36Sopenharmony_ci req_mode = MXL_DVBT; 401262306a36Sopenharmony_ci switch (bw) { 401362306a36Sopenharmony_ci case 6000000: 401462306a36Sopenharmony_ci req_bw = MXL5005S_BANDWIDTH_6MHZ; 401562306a36Sopenharmony_ci break; 401662306a36Sopenharmony_ci case 7000000: 401762306a36Sopenharmony_ci req_bw = MXL5005S_BANDWIDTH_7MHZ; 401862306a36Sopenharmony_ci break; 401962306a36Sopenharmony_ci case 8000000: 402062306a36Sopenharmony_ci case 0: 402162306a36Sopenharmony_ci req_bw = MXL5005S_BANDWIDTH_8MHZ; 402262306a36Sopenharmony_ci break; 402362306a36Sopenharmony_ci default: 402462306a36Sopenharmony_ci return -EINVAL; 402562306a36Sopenharmony_ci } 402662306a36Sopenharmony_ci } 402762306a36Sopenharmony_ci 402862306a36Sopenharmony_ci /* Change tuner for new modulation type if reqd */ 402962306a36Sopenharmony_ci if (req_mode != state->current_mode || 403062306a36Sopenharmony_ci req_bw != state->Chan_Bandwidth) { 403162306a36Sopenharmony_ci state->current_mode = req_mode; 403262306a36Sopenharmony_ci ret = mxl5005s_reconfigure(fe, req_mode, req_bw); 403362306a36Sopenharmony_ci 403462306a36Sopenharmony_ci } else 403562306a36Sopenharmony_ci ret = 0; 403662306a36Sopenharmony_ci 403762306a36Sopenharmony_ci if (ret == 0) { 403862306a36Sopenharmony_ci dprintk(1, "%s() freq=%d\n", __func__, c->frequency); 403962306a36Sopenharmony_ci ret = mxl5005s_SetRfFreqHz(fe, c->frequency); 404062306a36Sopenharmony_ci } 404162306a36Sopenharmony_ci 404262306a36Sopenharmony_ci return ret; 404362306a36Sopenharmony_ci} 404462306a36Sopenharmony_ci 404562306a36Sopenharmony_cistatic int mxl5005s_get_frequency(struct dvb_frontend *fe, u32 *frequency) 404662306a36Sopenharmony_ci{ 404762306a36Sopenharmony_ci struct mxl5005s_state *state = fe->tuner_priv; 404862306a36Sopenharmony_ci dprintk(1, "%s()\n", __func__); 404962306a36Sopenharmony_ci 405062306a36Sopenharmony_ci *frequency = state->RF_IN; 405162306a36Sopenharmony_ci 405262306a36Sopenharmony_ci return 0; 405362306a36Sopenharmony_ci} 405462306a36Sopenharmony_ci 405562306a36Sopenharmony_cistatic int mxl5005s_get_bandwidth(struct dvb_frontend *fe, u32 *bandwidth) 405662306a36Sopenharmony_ci{ 405762306a36Sopenharmony_ci struct mxl5005s_state *state = fe->tuner_priv; 405862306a36Sopenharmony_ci dprintk(1, "%s()\n", __func__); 405962306a36Sopenharmony_ci 406062306a36Sopenharmony_ci *bandwidth = state->Chan_Bandwidth; 406162306a36Sopenharmony_ci 406262306a36Sopenharmony_ci return 0; 406362306a36Sopenharmony_ci} 406462306a36Sopenharmony_ci 406562306a36Sopenharmony_cistatic int mxl5005s_get_if_frequency(struct dvb_frontend *fe, u32 *frequency) 406662306a36Sopenharmony_ci{ 406762306a36Sopenharmony_ci struct mxl5005s_state *state = fe->tuner_priv; 406862306a36Sopenharmony_ci dprintk(1, "%s()\n", __func__); 406962306a36Sopenharmony_ci 407062306a36Sopenharmony_ci *frequency = state->IF_OUT; 407162306a36Sopenharmony_ci 407262306a36Sopenharmony_ci return 0; 407362306a36Sopenharmony_ci} 407462306a36Sopenharmony_ci 407562306a36Sopenharmony_cistatic void mxl5005s_release(struct dvb_frontend *fe) 407662306a36Sopenharmony_ci{ 407762306a36Sopenharmony_ci dprintk(1, "%s()\n", __func__); 407862306a36Sopenharmony_ci kfree(fe->tuner_priv); 407962306a36Sopenharmony_ci fe->tuner_priv = NULL; 408062306a36Sopenharmony_ci} 408162306a36Sopenharmony_ci 408262306a36Sopenharmony_cistatic const struct dvb_tuner_ops mxl5005s_tuner_ops = { 408362306a36Sopenharmony_ci .info = { 408462306a36Sopenharmony_ci .name = "MaxLinear MXL5005S", 408562306a36Sopenharmony_ci .frequency_min_hz = 48 * MHz, 408662306a36Sopenharmony_ci .frequency_max_hz = 860 * MHz, 408762306a36Sopenharmony_ci .frequency_step_hz = 50 * kHz, 408862306a36Sopenharmony_ci }, 408962306a36Sopenharmony_ci 409062306a36Sopenharmony_ci .release = mxl5005s_release, 409162306a36Sopenharmony_ci .init = mxl5005s_init, 409262306a36Sopenharmony_ci 409362306a36Sopenharmony_ci .set_params = mxl5005s_set_params, 409462306a36Sopenharmony_ci .get_frequency = mxl5005s_get_frequency, 409562306a36Sopenharmony_ci .get_bandwidth = mxl5005s_get_bandwidth, 409662306a36Sopenharmony_ci .get_if_frequency = mxl5005s_get_if_frequency, 409762306a36Sopenharmony_ci}; 409862306a36Sopenharmony_ci 409962306a36Sopenharmony_cistruct dvb_frontend *mxl5005s_attach(struct dvb_frontend *fe, 410062306a36Sopenharmony_ci struct i2c_adapter *i2c, 410162306a36Sopenharmony_ci struct mxl5005s_config *config) 410262306a36Sopenharmony_ci{ 410362306a36Sopenharmony_ci struct mxl5005s_state *state = NULL; 410462306a36Sopenharmony_ci dprintk(1, "%s()\n", __func__); 410562306a36Sopenharmony_ci 410662306a36Sopenharmony_ci state = kzalloc(sizeof(struct mxl5005s_state), GFP_KERNEL); 410762306a36Sopenharmony_ci if (state == NULL) 410862306a36Sopenharmony_ci return NULL; 410962306a36Sopenharmony_ci 411062306a36Sopenharmony_ci state->frontend = fe; 411162306a36Sopenharmony_ci state->config = config; 411262306a36Sopenharmony_ci state->i2c = i2c; 411362306a36Sopenharmony_ci 411462306a36Sopenharmony_ci printk(KERN_INFO "MXL5005S: Attached at address 0x%02x\n", 411562306a36Sopenharmony_ci config->i2c_address); 411662306a36Sopenharmony_ci 411762306a36Sopenharmony_ci memcpy(&fe->ops.tuner_ops, &mxl5005s_tuner_ops, 411862306a36Sopenharmony_ci sizeof(struct dvb_tuner_ops)); 411962306a36Sopenharmony_ci 412062306a36Sopenharmony_ci fe->tuner_priv = state; 412162306a36Sopenharmony_ci return fe; 412262306a36Sopenharmony_ci} 412362306a36Sopenharmony_ciEXPORT_SYMBOL_GPL(mxl5005s_attach); 412462306a36Sopenharmony_ci 412562306a36Sopenharmony_ciMODULE_DESCRIPTION("MaxLinear MXL5005S silicon tuner driver"); 412662306a36Sopenharmony_ciMODULE_AUTHOR("Steven Toth"); 412762306a36Sopenharmony_ciMODULE_LICENSE("GPL"); 4128