18c2ecf20Sopenharmony_ci/*
28c2ecf20Sopenharmony_ci    MaxLinear MXL5005S VSB/QAM/DVBT tuner driver
38c2ecf20Sopenharmony_ci
48c2ecf20Sopenharmony_ci    Copyright (C) 2008 MaxLinear
58c2ecf20Sopenharmony_ci    Copyright (C) 2006 Steven Toth <stoth@linuxtv.org>
68c2ecf20Sopenharmony_ci      Functions:
78c2ecf20Sopenharmony_ci	mxl5005s_reset()
88c2ecf20Sopenharmony_ci	mxl5005s_writereg()
98c2ecf20Sopenharmony_ci	mxl5005s_writeregs()
108c2ecf20Sopenharmony_ci	mxl5005s_init()
118c2ecf20Sopenharmony_ci	mxl5005s_reconfigure()
128c2ecf20Sopenharmony_ci	mxl5005s_AssignTunerMode()
138c2ecf20Sopenharmony_ci	mxl5005s_set_params()
148c2ecf20Sopenharmony_ci	mxl5005s_get_frequency()
158c2ecf20Sopenharmony_ci	mxl5005s_get_bandwidth()
168c2ecf20Sopenharmony_ci	mxl5005s_release()
178c2ecf20Sopenharmony_ci	mxl5005s_attach()
188c2ecf20Sopenharmony_ci
198c2ecf20Sopenharmony_ci    Copyright (C) 2008 Realtek
208c2ecf20Sopenharmony_ci    Copyright (C) 2008 Jan Hoogenraad
218c2ecf20Sopenharmony_ci      Functions:
228c2ecf20Sopenharmony_ci	mxl5005s_SetRfFreqHz()
238c2ecf20Sopenharmony_ci
248c2ecf20Sopenharmony_ci    This program is free software; you can redistribute it and/or modify
258c2ecf20Sopenharmony_ci    it under the terms of the GNU General Public License as published by
268c2ecf20Sopenharmony_ci    the Free Software Foundation; either version 2 of the License, or
278c2ecf20Sopenharmony_ci    (at your option) any later version.
288c2ecf20Sopenharmony_ci
298c2ecf20Sopenharmony_ci    This program is distributed in the hope that it will be useful,
308c2ecf20Sopenharmony_ci    but WITHOUT ANY WARRANTY; without even the implied warranty of
318c2ecf20Sopenharmony_ci    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
328c2ecf20Sopenharmony_ci    GNU General Public License for more details.
338c2ecf20Sopenharmony_ci
348c2ecf20Sopenharmony_ci    You should have received a copy of the GNU General Public License
358c2ecf20Sopenharmony_ci    along with this program; if not, write to the Free Software
368c2ecf20Sopenharmony_ci    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
378c2ecf20Sopenharmony_ci
388c2ecf20Sopenharmony_ci*/
398c2ecf20Sopenharmony_ci
408c2ecf20Sopenharmony_ci/*
418c2ecf20Sopenharmony_ci    History of this driver (Steven Toth):
428c2ecf20Sopenharmony_ci      I was given a public release of a linux driver that included
438c2ecf20Sopenharmony_ci      support for the MaxLinear MXL5005S silicon tuner. Analysis of
448c2ecf20Sopenharmony_ci      the tuner driver showed clearly three things.
458c2ecf20Sopenharmony_ci
468c2ecf20Sopenharmony_ci      1. The tuner driver didn't support the LinuxTV tuner API
478c2ecf20Sopenharmony_ci	 so the code Realtek added had to be removed.
488c2ecf20Sopenharmony_ci
498c2ecf20Sopenharmony_ci      2. A significant amount of the driver is reference driver code
508c2ecf20Sopenharmony_ci	 from MaxLinear, I felt it was important to identify and
518c2ecf20Sopenharmony_ci	 preserve this.
528c2ecf20Sopenharmony_ci
538c2ecf20Sopenharmony_ci      3. New code has to be added to interface correctly with the
548c2ecf20Sopenharmony_ci	 LinuxTV API, as a regular kernel module.
558c2ecf20Sopenharmony_ci
568c2ecf20Sopenharmony_ci      Other than the reference driver enum's, I've clearly marked
578c2ecf20Sopenharmony_ci      sections of the code and retained the copyright of the
588c2ecf20Sopenharmony_ci      respective owners.
598c2ecf20Sopenharmony_ci*/
608c2ecf20Sopenharmony_ci#include <linux/kernel.h>
618c2ecf20Sopenharmony_ci#include <linux/init.h>
628c2ecf20Sopenharmony_ci#include <linux/module.h>
638c2ecf20Sopenharmony_ci#include <linux/string.h>
648c2ecf20Sopenharmony_ci#include <linux/slab.h>
658c2ecf20Sopenharmony_ci#include <linux/delay.h>
668c2ecf20Sopenharmony_ci#include <media/dvb_frontend.h>
678c2ecf20Sopenharmony_ci#include "mxl5005s.h"
688c2ecf20Sopenharmony_ci
698c2ecf20Sopenharmony_cistatic int debug;
708c2ecf20Sopenharmony_ci
718c2ecf20Sopenharmony_ci#define dprintk(level, arg...) do {    \
728c2ecf20Sopenharmony_ci	if (level <= debug)            \
738c2ecf20Sopenharmony_ci		printk(arg);    \
748c2ecf20Sopenharmony_ci	} while (0)
758c2ecf20Sopenharmony_ci
768c2ecf20Sopenharmony_ci#define TUNER_REGS_NUM          104
778c2ecf20Sopenharmony_ci#define INITCTRL_NUM            40
788c2ecf20Sopenharmony_ci
798c2ecf20Sopenharmony_ci#ifdef _MXL_PRODUCTION
808c2ecf20Sopenharmony_ci#define CHCTRL_NUM              39
818c2ecf20Sopenharmony_ci#else
828c2ecf20Sopenharmony_ci#define CHCTRL_NUM              36
838c2ecf20Sopenharmony_ci#endif
848c2ecf20Sopenharmony_ci
858c2ecf20Sopenharmony_ci#define MXLCTRL_NUM             189
868c2ecf20Sopenharmony_ci#define MASTER_CONTROL_ADDR     9
878c2ecf20Sopenharmony_ci
888c2ecf20Sopenharmony_ci/* Enumeration of Master Control Register State */
898c2ecf20Sopenharmony_cienum master_control_state {
908c2ecf20Sopenharmony_ci	MC_LOAD_START = 1,
918c2ecf20Sopenharmony_ci	MC_POWER_DOWN,
928c2ecf20Sopenharmony_ci	MC_SYNTH_RESET,
938c2ecf20Sopenharmony_ci	MC_SEQ_OFF
948c2ecf20Sopenharmony_ci};
958c2ecf20Sopenharmony_ci
968c2ecf20Sopenharmony_ci/* Enumeration of MXL5005 Tuner Modulation Type */
978c2ecf20Sopenharmony_cienum {
988c2ecf20Sopenharmony_ci	MXL_DEFAULT_MODULATION = 0,
998c2ecf20Sopenharmony_ci	MXL_DVBT,
1008c2ecf20Sopenharmony_ci	MXL_ATSC,
1018c2ecf20Sopenharmony_ci	MXL_QAM,
1028c2ecf20Sopenharmony_ci	MXL_ANALOG_CABLE,
1038c2ecf20Sopenharmony_ci	MXL_ANALOG_OTA
1048c2ecf20Sopenharmony_ci};
1058c2ecf20Sopenharmony_ci
1068c2ecf20Sopenharmony_ci/* MXL5005 Tuner Register Struct */
1078c2ecf20Sopenharmony_cistruct TunerReg {
1088c2ecf20Sopenharmony_ci	u16 Reg_Num;	/* Tuner Register Address */
1098c2ecf20Sopenharmony_ci	u16 Reg_Val;	/* Current sw programmed value waiting to be written */
1108c2ecf20Sopenharmony_ci};
1118c2ecf20Sopenharmony_ci
1128c2ecf20Sopenharmony_cienum {
1138c2ecf20Sopenharmony_ci	/* Initialization Control Names */
1148c2ecf20Sopenharmony_ci	DN_IQTN_AMP_CUT = 1,       /* 1 */
1158c2ecf20Sopenharmony_ci	BB_MODE,                   /* 2 */
1168c2ecf20Sopenharmony_ci	BB_BUF,                    /* 3 */
1178c2ecf20Sopenharmony_ci	BB_BUF_OA,                 /* 4 */
1188c2ecf20Sopenharmony_ci	BB_ALPF_BANDSELECT,        /* 5 */
1198c2ecf20Sopenharmony_ci	BB_IQSWAP,                 /* 6 */
1208c2ecf20Sopenharmony_ci	BB_DLPF_BANDSEL,           /* 7 */
1218c2ecf20Sopenharmony_ci	RFSYN_CHP_GAIN,            /* 8 */
1228c2ecf20Sopenharmony_ci	RFSYN_EN_CHP_HIGAIN,       /* 9 */
1238c2ecf20Sopenharmony_ci	AGC_IF,                    /* 10 */
1248c2ecf20Sopenharmony_ci	AGC_RF,                    /* 11 */
1258c2ecf20Sopenharmony_ci	IF_DIVVAL,                 /* 12 */
1268c2ecf20Sopenharmony_ci	IF_VCO_BIAS,               /* 13 */
1278c2ecf20Sopenharmony_ci	CHCAL_INT_MOD_IF,          /* 14 */
1288c2ecf20Sopenharmony_ci	CHCAL_FRAC_MOD_IF,         /* 15 */
1298c2ecf20Sopenharmony_ci	DRV_RES_SEL,               /* 16 */
1308c2ecf20Sopenharmony_ci	I_DRIVER,                  /* 17 */
1318c2ecf20Sopenharmony_ci	EN_AAF,                    /* 18 */
1328c2ecf20Sopenharmony_ci	EN_3P,                     /* 19 */
1338c2ecf20Sopenharmony_ci	EN_AUX_3P,                 /* 20 */
1348c2ecf20Sopenharmony_ci	SEL_AAF_BAND,              /* 21 */
1358c2ecf20Sopenharmony_ci	SEQ_ENCLK16_CLK_OUT,       /* 22 */
1368c2ecf20Sopenharmony_ci	SEQ_SEL4_16B,              /* 23 */
1378c2ecf20Sopenharmony_ci	XTAL_CAPSELECT,            /* 24 */
1388c2ecf20Sopenharmony_ci	IF_SEL_DBL,                /* 25 */
1398c2ecf20Sopenharmony_ci	RFSYN_R_DIV,               /* 26 */
1408c2ecf20Sopenharmony_ci	SEQ_EXTSYNTHCALIF,         /* 27 */
1418c2ecf20Sopenharmony_ci	SEQ_EXTDCCAL,              /* 28 */
1428c2ecf20Sopenharmony_ci	AGC_EN_RSSI,               /* 29 */
1438c2ecf20Sopenharmony_ci	RFA_ENCLKRFAGC,            /* 30 */
1448c2ecf20Sopenharmony_ci	RFA_RSSI_REFH,             /* 31 */
1458c2ecf20Sopenharmony_ci	RFA_RSSI_REF,              /* 32 */
1468c2ecf20Sopenharmony_ci	RFA_RSSI_REFL,             /* 33 */
1478c2ecf20Sopenharmony_ci	RFA_FLR,                   /* 34 */
1488c2ecf20Sopenharmony_ci	RFA_CEIL,                  /* 35 */
1498c2ecf20Sopenharmony_ci	SEQ_EXTIQFSMPULSE,         /* 36 */
1508c2ecf20Sopenharmony_ci	OVERRIDE_1,                /* 37 */
1518c2ecf20Sopenharmony_ci	BB_INITSTATE_DLPF_TUNE,    /* 38 */
1528c2ecf20Sopenharmony_ci	TG_R_DIV,                  /* 39 */
1538c2ecf20Sopenharmony_ci	EN_CHP_LIN_B,              /* 40 */
1548c2ecf20Sopenharmony_ci
1558c2ecf20Sopenharmony_ci	/* Channel Change Control Names */
1568c2ecf20Sopenharmony_ci	DN_POLY = 51,              /* 51 */
1578c2ecf20Sopenharmony_ci	DN_RFGAIN,                 /* 52 */
1588c2ecf20Sopenharmony_ci	DN_CAP_RFLPF,              /* 53 */
1598c2ecf20Sopenharmony_ci	DN_EN_VHFUHFBAR,           /* 54 */
1608c2ecf20Sopenharmony_ci	DN_GAIN_ADJUST,            /* 55 */
1618c2ecf20Sopenharmony_ci	DN_IQTNBUF_AMP,            /* 56 */
1628c2ecf20Sopenharmony_ci	DN_IQTNGNBFBIAS_BST,       /* 57 */
1638c2ecf20Sopenharmony_ci	RFSYN_EN_OUTMUX,           /* 58 */
1648c2ecf20Sopenharmony_ci	RFSYN_SEL_VCO_OUT,         /* 59 */
1658c2ecf20Sopenharmony_ci	RFSYN_SEL_VCO_HI,          /* 60 */
1668c2ecf20Sopenharmony_ci	RFSYN_SEL_DIVM,            /* 61 */
1678c2ecf20Sopenharmony_ci	RFSYN_RF_DIV_BIAS,         /* 62 */
1688c2ecf20Sopenharmony_ci	DN_SEL_FREQ,               /* 63 */
1698c2ecf20Sopenharmony_ci	RFSYN_VCO_BIAS,            /* 64 */
1708c2ecf20Sopenharmony_ci	CHCAL_INT_MOD_RF,          /* 65 */
1718c2ecf20Sopenharmony_ci	CHCAL_FRAC_MOD_RF,         /* 66 */
1728c2ecf20Sopenharmony_ci	RFSYN_LPF_R,               /* 67 */
1738c2ecf20Sopenharmony_ci	CHCAL_EN_INT_RF,           /* 68 */
1748c2ecf20Sopenharmony_ci	TG_LO_DIVVAL,              /* 69 */
1758c2ecf20Sopenharmony_ci	TG_LO_SELVAL,              /* 70 */
1768c2ecf20Sopenharmony_ci	TG_DIV_VAL,                /* 71 */
1778c2ecf20Sopenharmony_ci	TG_VCO_BIAS,               /* 72 */
1788c2ecf20Sopenharmony_ci	SEQ_EXTPOWERUP,            /* 73 */
1798c2ecf20Sopenharmony_ci	OVERRIDE_2,                /* 74 */
1808c2ecf20Sopenharmony_ci	OVERRIDE_3,                /* 75 */
1818c2ecf20Sopenharmony_ci	OVERRIDE_4,                /* 76 */
1828c2ecf20Sopenharmony_ci	SEQ_FSM_PULSE,             /* 77 */
1838c2ecf20Sopenharmony_ci	GPIO_4B,                   /* 78 */
1848c2ecf20Sopenharmony_ci	GPIO_3B,                   /* 79 */
1858c2ecf20Sopenharmony_ci	GPIO_4,                    /* 80 */
1868c2ecf20Sopenharmony_ci	GPIO_3,                    /* 81 */
1878c2ecf20Sopenharmony_ci	GPIO_1B,                   /* 82 */
1888c2ecf20Sopenharmony_ci	DAC_A_ENABLE,              /* 83 */
1898c2ecf20Sopenharmony_ci	DAC_B_ENABLE,              /* 84 */
1908c2ecf20Sopenharmony_ci	DAC_DIN_A,                 /* 85 */
1918c2ecf20Sopenharmony_ci	DAC_DIN_B,                 /* 86 */
1928c2ecf20Sopenharmony_ci#ifdef _MXL_PRODUCTION
1938c2ecf20Sopenharmony_ci	RFSYN_EN_DIV,              /* 87 */
1948c2ecf20Sopenharmony_ci	RFSYN_DIVM,                /* 88 */
1958c2ecf20Sopenharmony_ci	DN_BYPASS_AGC_I2C          /* 89 */
1968c2ecf20Sopenharmony_ci#endif
1978c2ecf20Sopenharmony_ci};
1988c2ecf20Sopenharmony_ci
1998c2ecf20Sopenharmony_ci/*
2008c2ecf20Sopenharmony_ci * The following context is source code provided by MaxLinear.
2018c2ecf20Sopenharmony_ci * MaxLinear source code - Common_MXL.h (?)
2028c2ecf20Sopenharmony_ci */
2038c2ecf20Sopenharmony_ci
2048c2ecf20Sopenharmony_ci/* Constants */
2058c2ecf20Sopenharmony_ci#define MXL5005S_REG_WRITING_TABLE_LEN_MAX	104
2068c2ecf20Sopenharmony_ci#define MXL5005S_LATCH_BYTE			0xfe
2078c2ecf20Sopenharmony_ci
2088c2ecf20Sopenharmony_ci/* Register address, MSB, and LSB */
2098c2ecf20Sopenharmony_ci#define MXL5005S_BB_IQSWAP_ADDR			59
2108c2ecf20Sopenharmony_ci#define MXL5005S_BB_IQSWAP_MSB			0
2118c2ecf20Sopenharmony_ci#define MXL5005S_BB_IQSWAP_LSB			0
2128c2ecf20Sopenharmony_ci
2138c2ecf20Sopenharmony_ci#define MXL5005S_BB_DLPF_BANDSEL_ADDR		53
2148c2ecf20Sopenharmony_ci#define MXL5005S_BB_DLPF_BANDSEL_MSB		4
2158c2ecf20Sopenharmony_ci#define MXL5005S_BB_DLPF_BANDSEL_LSB		3
2168c2ecf20Sopenharmony_ci
2178c2ecf20Sopenharmony_ci/* Standard modes */
2188c2ecf20Sopenharmony_cienum {
2198c2ecf20Sopenharmony_ci	MXL5005S_STANDARD_DVBT,
2208c2ecf20Sopenharmony_ci	MXL5005S_STANDARD_ATSC,
2218c2ecf20Sopenharmony_ci};
2228c2ecf20Sopenharmony_ci#define MXL5005S_STANDARD_MODE_NUM		2
2238c2ecf20Sopenharmony_ci
2248c2ecf20Sopenharmony_ci/* Bandwidth modes */
2258c2ecf20Sopenharmony_cienum {
2268c2ecf20Sopenharmony_ci	MXL5005S_BANDWIDTH_6MHZ = 6000000,
2278c2ecf20Sopenharmony_ci	MXL5005S_BANDWIDTH_7MHZ = 7000000,
2288c2ecf20Sopenharmony_ci	MXL5005S_BANDWIDTH_8MHZ = 8000000,
2298c2ecf20Sopenharmony_ci};
2308c2ecf20Sopenharmony_ci#define MXL5005S_BANDWIDTH_MODE_NUM		3
2318c2ecf20Sopenharmony_ci
2328c2ecf20Sopenharmony_ci/* MXL5005 Tuner Control Struct */
2338c2ecf20Sopenharmony_cistruct TunerControl {
2348c2ecf20Sopenharmony_ci	u16 Ctrl_Num;	/* Control Number */
2358c2ecf20Sopenharmony_ci	u16 size;	/* Number of bits to represent Value */
2368c2ecf20Sopenharmony_ci	u16 addr[25];	/* Array of Tuner Register Address for each bit pos */
2378c2ecf20Sopenharmony_ci	u16 bit[25];	/* Array of bit pos in Reg Addr for each bit pos */
2388c2ecf20Sopenharmony_ci	u16 val[25];	/* Binary representation of Value */
2398c2ecf20Sopenharmony_ci};
2408c2ecf20Sopenharmony_ci
2418c2ecf20Sopenharmony_ci/* MXL5005 Tuner Struct */
2428c2ecf20Sopenharmony_cistruct mxl5005s_state {
2438c2ecf20Sopenharmony_ci	u8	Mode;		/* 0: Analog Mode ; 1: Digital Mode */
2448c2ecf20Sopenharmony_ci	u8	IF_Mode;	/* for Analog Mode, 0: zero IF; 1: low IF */
2458c2ecf20Sopenharmony_ci	u32	Chan_Bandwidth;	/* filter  channel bandwidth (6, 7, 8) */
2468c2ecf20Sopenharmony_ci	u32	IF_OUT;		/* Desired IF Out Frequency */
2478c2ecf20Sopenharmony_ci	u16	IF_OUT_LOAD;	/* IF Out Load Resistor (200/300 Ohms) */
2488c2ecf20Sopenharmony_ci	u32	RF_IN;		/* RF Input Frequency */
2498c2ecf20Sopenharmony_ci	u32	Fxtal;		/* XTAL Frequency */
2508c2ecf20Sopenharmony_ci	u8	AGC_Mode;	/* AGC Mode 0: Dual AGC; 1: Single AGC */
2518c2ecf20Sopenharmony_ci	u16	TOP;		/* Value: take over point */
2528c2ecf20Sopenharmony_ci	u8	CLOCK_OUT;	/* 0: turn off clk out; 1: turn on clock out */
2538c2ecf20Sopenharmony_ci	u8	DIV_OUT;	/* 4MHz or 16MHz */
2548c2ecf20Sopenharmony_ci	u8	CAPSELECT;	/* 0: disable On-Chip pulling cap; 1: enable */
2558c2ecf20Sopenharmony_ci	u8	EN_RSSI;	/* 0: disable RSSI; 1: enable RSSI */
2568c2ecf20Sopenharmony_ci
2578c2ecf20Sopenharmony_ci	/* Modulation Type; */
2588c2ecf20Sopenharmony_ci	/* 0 - Default;	1 - DVB-T; 2 - ATSC; 3 - QAM; 4 - Analog Cable */
2598c2ecf20Sopenharmony_ci	u8	Mod_Type;
2608c2ecf20Sopenharmony_ci
2618c2ecf20Sopenharmony_ci	/* Tracking Filter Type */
2628c2ecf20Sopenharmony_ci	/* 0 - Default; 1 - Off; 2 - Type C; 3 - Type C-H */
2638c2ecf20Sopenharmony_ci	u8	TF_Type;
2648c2ecf20Sopenharmony_ci
2658c2ecf20Sopenharmony_ci	/* Calculated Settings */
2668c2ecf20Sopenharmony_ci	u32	RF_LO;		/* Synth RF LO Frequency */
2678c2ecf20Sopenharmony_ci	u32	IF_LO;		/* Synth IF LO Frequency */
2688c2ecf20Sopenharmony_ci	u32	TG_LO;		/* Synth TG_LO Frequency */
2698c2ecf20Sopenharmony_ci
2708c2ecf20Sopenharmony_ci	/* Pointers to ControlName Arrays */
2718c2ecf20Sopenharmony_ci	u16	Init_Ctrl_Num;		/* Number of INIT Control Names */
2728c2ecf20Sopenharmony_ci	struct TunerControl
2738c2ecf20Sopenharmony_ci		Init_Ctrl[INITCTRL_NUM]; /* INIT Control Names Array Pointer */
2748c2ecf20Sopenharmony_ci
2758c2ecf20Sopenharmony_ci	u16	CH_Ctrl_Num;		/* Number of CH Control Names */
2768c2ecf20Sopenharmony_ci	struct TunerControl
2778c2ecf20Sopenharmony_ci		CH_Ctrl[CHCTRL_NUM];	/* CH Control Name Array Pointer */
2788c2ecf20Sopenharmony_ci
2798c2ecf20Sopenharmony_ci	u16	MXL_Ctrl_Num;		/* Number of MXL Control Names */
2808c2ecf20Sopenharmony_ci	struct TunerControl
2818c2ecf20Sopenharmony_ci		MXL_Ctrl[MXLCTRL_NUM];	/* MXL Control Name Array Pointer */
2828c2ecf20Sopenharmony_ci
2838c2ecf20Sopenharmony_ci	/* Pointer to Tuner Register Array */
2848c2ecf20Sopenharmony_ci	u16	TunerRegs_Num;		/* Number of Tuner Registers */
2858c2ecf20Sopenharmony_ci	struct TunerReg
2868c2ecf20Sopenharmony_ci		TunerRegs[TUNER_REGS_NUM]; /* Tuner Register Array Pointer */
2878c2ecf20Sopenharmony_ci
2888c2ecf20Sopenharmony_ci	/* Linux driver framework specific */
2898c2ecf20Sopenharmony_ci	struct mxl5005s_config *config;
2908c2ecf20Sopenharmony_ci	struct dvb_frontend *frontend;
2918c2ecf20Sopenharmony_ci	struct i2c_adapter *i2c;
2928c2ecf20Sopenharmony_ci
2938c2ecf20Sopenharmony_ci	/* Cache values */
2948c2ecf20Sopenharmony_ci	u32 current_mode;
2958c2ecf20Sopenharmony_ci
2968c2ecf20Sopenharmony_ci};
2978c2ecf20Sopenharmony_ci
2988c2ecf20Sopenharmony_cistatic u16 MXL_GetMasterControl(u8 *MasterReg, int state);
2998c2ecf20Sopenharmony_cistatic u16 MXL_ControlWrite(struct dvb_frontend *fe, u16 ControlNum, u32 value);
3008c2ecf20Sopenharmony_cistatic u16 MXL_ControlRead(struct dvb_frontend *fe, u16 controlNum, u32 *value);
3018c2ecf20Sopenharmony_cistatic void MXL_RegWriteBit(struct dvb_frontend *fe, u8 address, u8 bit,
3028c2ecf20Sopenharmony_ci	u8 bitVal);
3038c2ecf20Sopenharmony_cistatic u16 MXL_GetCHRegister(struct dvb_frontend *fe, u8 *RegNum,
3048c2ecf20Sopenharmony_ci	u8 *RegVal, int *count);
3058c2ecf20Sopenharmony_cistatic u32 MXL_Ceiling(u32 value, u32 resolution);
3068c2ecf20Sopenharmony_cistatic u16 MXL_RegRead(struct dvb_frontend *fe, u8 RegNum, u8 *RegVal);
3078c2ecf20Sopenharmony_cistatic u16 MXL_ControlWrite_Group(struct dvb_frontend *fe, u16 controlNum,
3088c2ecf20Sopenharmony_ci	u32 value, u16 controlGroup);
3098c2ecf20Sopenharmony_cistatic u16 MXL_SetGPIO(struct dvb_frontend *fe, u8 GPIO_Num, u8 GPIO_Val);
3108c2ecf20Sopenharmony_cistatic u16 MXL_GetInitRegister(struct dvb_frontend *fe, u8 *RegNum,
3118c2ecf20Sopenharmony_ci	u8 *RegVal, int *count);
3128c2ecf20Sopenharmony_cistatic u16 MXL_TuneRF(struct dvb_frontend *fe, u32 RF_Freq);
3138c2ecf20Sopenharmony_cistatic void MXL_SynthIFLO_Calc(struct dvb_frontend *fe);
3148c2ecf20Sopenharmony_cistatic void MXL_SynthRFTGLO_Calc(struct dvb_frontend *fe);
3158c2ecf20Sopenharmony_cistatic u16 MXL_GetCHRegister_ZeroIF(struct dvb_frontend *fe, u8 *RegNum,
3168c2ecf20Sopenharmony_ci	u8 *RegVal, int *count);
3178c2ecf20Sopenharmony_cistatic int mxl5005s_writeregs(struct dvb_frontend *fe, u8 *addrtable,
3188c2ecf20Sopenharmony_ci	u8 *datatable, u8 len);
3198c2ecf20Sopenharmony_cistatic u16 MXL_IFSynthInit(struct dvb_frontend *fe);
3208c2ecf20Sopenharmony_cistatic int mxl5005s_AssignTunerMode(struct dvb_frontend *fe, u32 mod_type,
3218c2ecf20Sopenharmony_ci	u32 bandwidth);
3228c2ecf20Sopenharmony_cistatic int mxl5005s_reconfigure(struct dvb_frontend *fe, u32 mod_type,
3238c2ecf20Sopenharmony_ci	u32 bandwidth);
3248c2ecf20Sopenharmony_ci
3258c2ecf20Sopenharmony_ci/* ----------------------------------------------------------------
3268c2ecf20Sopenharmony_ci * Begin: Custom code salvaged from the Realtek driver.
3278c2ecf20Sopenharmony_ci * Copyright (C) 2008 Realtek
3288c2ecf20Sopenharmony_ci * Copyright (C) 2008 Jan Hoogenraad
3298c2ecf20Sopenharmony_ci * This code is placed under the terms of the GNU General Public License
3308c2ecf20Sopenharmony_ci *
3318c2ecf20Sopenharmony_ci * Released by Realtek under GPLv2.
3328c2ecf20Sopenharmony_ci * Thanks to Realtek for a lot of support we received !
3338c2ecf20Sopenharmony_ci *
3348c2ecf20Sopenharmony_ci *  Revision: 080314 - original version
3358c2ecf20Sopenharmony_ci */
3368c2ecf20Sopenharmony_ci
3378c2ecf20Sopenharmony_cistatic int mxl5005s_SetRfFreqHz(struct dvb_frontend *fe, unsigned long RfFreqHz)
3388c2ecf20Sopenharmony_ci{
3398c2ecf20Sopenharmony_ci	struct mxl5005s_state *state = fe->tuner_priv;
3408c2ecf20Sopenharmony_ci	unsigned char AddrTable[MXL5005S_REG_WRITING_TABLE_LEN_MAX];
3418c2ecf20Sopenharmony_ci	unsigned char ByteTable[MXL5005S_REG_WRITING_TABLE_LEN_MAX];
3428c2ecf20Sopenharmony_ci	int TableLen;
3438c2ecf20Sopenharmony_ci
3448c2ecf20Sopenharmony_ci	u32 IfDivval = 0;
3458c2ecf20Sopenharmony_ci	unsigned char MasterControlByte;
3468c2ecf20Sopenharmony_ci
3478c2ecf20Sopenharmony_ci	dprintk(1, "%s() freq=%ld\n", __func__, RfFreqHz);
3488c2ecf20Sopenharmony_ci
3498c2ecf20Sopenharmony_ci	/* Set MxL5005S tuner RF frequency according to example code. */
3508c2ecf20Sopenharmony_ci
3518c2ecf20Sopenharmony_ci	/* Tuner RF frequency setting stage 0 */
3528c2ecf20Sopenharmony_ci	MXL_GetMasterControl(ByteTable, MC_SYNTH_RESET);
3538c2ecf20Sopenharmony_ci	AddrTable[0] = MASTER_CONTROL_ADDR;
3548c2ecf20Sopenharmony_ci	ByteTable[0] |= state->config->AgcMasterByte;
3558c2ecf20Sopenharmony_ci
3568c2ecf20Sopenharmony_ci	mxl5005s_writeregs(fe, AddrTable, ByteTable, 1);
3578c2ecf20Sopenharmony_ci
3588c2ecf20Sopenharmony_ci	/* Tuner RF frequency setting stage 1 */
3598c2ecf20Sopenharmony_ci	MXL_TuneRF(fe, RfFreqHz);
3608c2ecf20Sopenharmony_ci
3618c2ecf20Sopenharmony_ci	MXL_ControlRead(fe, IF_DIVVAL, &IfDivval);
3628c2ecf20Sopenharmony_ci
3638c2ecf20Sopenharmony_ci	MXL_ControlWrite(fe, SEQ_FSM_PULSE, 0);
3648c2ecf20Sopenharmony_ci	MXL_ControlWrite(fe, SEQ_EXTPOWERUP, 1);
3658c2ecf20Sopenharmony_ci	MXL_ControlWrite(fe, IF_DIVVAL, 8);
3668c2ecf20Sopenharmony_ci	MXL_GetCHRegister(fe, AddrTable, ByteTable, &TableLen);
3678c2ecf20Sopenharmony_ci
3688c2ecf20Sopenharmony_ci	MXL_GetMasterControl(&MasterControlByte, MC_LOAD_START);
3698c2ecf20Sopenharmony_ci	AddrTable[TableLen] = MASTER_CONTROL_ADDR ;
3708c2ecf20Sopenharmony_ci	ByteTable[TableLen] = MasterControlByte |
3718c2ecf20Sopenharmony_ci		state->config->AgcMasterByte;
3728c2ecf20Sopenharmony_ci	TableLen += 1;
3738c2ecf20Sopenharmony_ci
3748c2ecf20Sopenharmony_ci	mxl5005s_writeregs(fe, AddrTable, ByteTable, TableLen);
3758c2ecf20Sopenharmony_ci
3768c2ecf20Sopenharmony_ci	/* Wait 30 ms. */
3778c2ecf20Sopenharmony_ci	msleep(150);
3788c2ecf20Sopenharmony_ci
3798c2ecf20Sopenharmony_ci	/* Tuner RF frequency setting stage 2 */
3808c2ecf20Sopenharmony_ci	MXL_ControlWrite(fe, SEQ_FSM_PULSE, 1);
3818c2ecf20Sopenharmony_ci	MXL_ControlWrite(fe, IF_DIVVAL, IfDivval);
3828c2ecf20Sopenharmony_ci	MXL_GetCHRegister_ZeroIF(fe, AddrTable, ByteTable, &TableLen);
3838c2ecf20Sopenharmony_ci
3848c2ecf20Sopenharmony_ci	MXL_GetMasterControl(&MasterControlByte, MC_LOAD_START);
3858c2ecf20Sopenharmony_ci	AddrTable[TableLen] = MASTER_CONTROL_ADDR ;
3868c2ecf20Sopenharmony_ci	ByteTable[TableLen] = MasterControlByte |
3878c2ecf20Sopenharmony_ci		state->config->AgcMasterByte ;
3888c2ecf20Sopenharmony_ci	TableLen += 1;
3898c2ecf20Sopenharmony_ci
3908c2ecf20Sopenharmony_ci	mxl5005s_writeregs(fe, AddrTable, ByteTable, TableLen);
3918c2ecf20Sopenharmony_ci
3928c2ecf20Sopenharmony_ci	msleep(100);
3938c2ecf20Sopenharmony_ci
3948c2ecf20Sopenharmony_ci	return 0;
3958c2ecf20Sopenharmony_ci}
3968c2ecf20Sopenharmony_ci/* End: Custom code taken from the Realtek driver */
3978c2ecf20Sopenharmony_ci
3988c2ecf20Sopenharmony_ci/* ----------------------------------------------------------------
3998c2ecf20Sopenharmony_ci * Begin: Reference driver code found in the Realtek driver.
4008c2ecf20Sopenharmony_ci * Copyright (C) 2008 MaxLinear
4018c2ecf20Sopenharmony_ci */
4028c2ecf20Sopenharmony_cistatic u16 MXL5005_RegisterInit(struct dvb_frontend *fe)
4038c2ecf20Sopenharmony_ci{
4048c2ecf20Sopenharmony_ci	struct mxl5005s_state *state = fe->tuner_priv;
4058c2ecf20Sopenharmony_ci	state->TunerRegs_Num = TUNER_REGS_NUM ;
4068c2ecf20Sopenharmony_ci
4078c2ecf20Sopenharmony_ci	state->TunerRegs[0].Reg_Num = 9 ;
4088c2ecf20Sopenharmony_ci	state->TunerRegs[0].Reg_Val = 0x40 ;
4098c2ecf20Sopenharmony_ci
4108c2ecf20Sopenharmony_ci	state->TunerRegs[1].Reg_Num = 11 ;
4118c2ecf20Sopenharmony_ci	state->TunerRegs[1].Reg_Val = 0x19 ;
4128c2ecf20Sopenharmony_ci
4138c2ecf20Sopenharmony_ci	state->TunerRegs[2].Reg_Num = 12 ;
4148c2ecf20Sopenharmony_ci	state->TunerRegs[2].Reg_Val = 0x60 ;
4158c2ecf20Sopenharmony_ci
4168c2ecf20Sopenharmony_ci	state->TunerRegs[3].Reg_Num = 13 ;
4178c2ecf20Sopenharmony_ci	state->TunerRegs[3].Reg_Val = 0x00 ;
4188c2ecf20Sopenharmony_ci
4198c2ecf20Sopenharmony_ci	state->TunerRegs[4].Reg_Num = 14 ;
4208c2ecf20Sopenharmony_ci	state->TunerRegs[4].Reg_Val = 0x00 ;
4218c2ecf20Sopenharmony_ci
4228c2ecf20Sopenharmony_ci	state->TunerRegs[5].Reg_Num = 15 ;
4238c2ecf20Sopenharmony_ci	state->TunerRegs[5].Reg_Val = 0xC0 ;
4248c2ecf20Sopenharmony_ci
4258c2ecf20Sopenharmony_ci	state->TunerRegs[6].Reg_Num = 16 ;
4268c2ecf20Sopenharmony_ci	state->TunerRegs[6].Reg_Val = 0x00 ;
4278c2ecf20Sopenharmony_ci
4288c2ecf20Sopenharmony_ci	state->TunerRegs[7].Reg_Num = 17 ;
4298c2ecf20Sopenharmony_ci	state->TunerRegs[7].Reg_Val = 0x00 ;
4308c2ecf20Sopenharmony_ci
4318c2ecf20Sopenharmony_ci	state->TunerRegs[8].Reg_Num = 18 ;
4328c2ecf20Sopenharmony_ci	state->TunerRegs[8].Reg_Val = 0x00 ;
4338c2ecf20Sopenharmony_ci
4348c2ecf20Sopenharmony_ci	state->TunerRegs[9].Reg_Num = 19 ;
4358c2ecf20Sopenharmony_ci	state->TunerRegs[9].Reg_Val = 0x34 ;
4368c2ecf20Sopenharmony_ci
4378c2ecf20Sopenharmony_ci	state->TunerRegs[10].Reg_Num = 21 ;
4388c2ecf20Sopenharmony_ci	state->TunerRegs[10].Reg_Val = 0x00 ;
4398c2ecf20Sopenharmony_ci
4408c2ecf20Sopenharmony_ci	state->TunerRegs[11].Reg_Num = 22 ;
4418c2ecf20Sopenharmony_ci	state->TunerRegs[11].Reg_Val = 0x6B ;
4428c2ecf20Sopenharmony_ci
4438c2ecf20Sopenharmony_ci	state->TunerRegs[12].Reg_Num = 23 ;
4448c2ecf20Sopenharmony_ci	state->TunerRegs[12].Reg_Val = 0x35 ;
4458c2ecf20Sopenharmony_ci
4468c2ecf20Sopenharmony_ci	state->TunerRegs[13].Reg_Num = 24 ;
4478c2ecf20Sopenharmony_ci	state->TunerRegs[13].Reg_Val = 0x70 ;
4488c2ecf20Sopenharmony_ci
4498c2ecf20Sopenharmony_ci	state->TunerRegs[14].Reg_Num = 25 ;
4508c2ecf20Sopenharmony_ci	state->TunerRegs[14].Reg_Val = 0x3E ;
4518c2ecf20Sopenharmony_ci
4528c2ecf20Sopenharmony_ci	state->TunerRegs[15].Reg_Num = 26 ;
4538c2ecf20Sopenharmony_ci	state->TunerRegs[15].Reg_Val = 0x82 ;
4548c2ecf20Sopenharmony_ci
4558c2ecf20Sopenharmony_ci	state->TunerRegs[16].Reg_Num = 31 ;
4568c2ecf20Sopenharmony_ci	state->TunerRegs[16].Reg_Val = 0x00 ;
4578c2ecf20Sopenharmony_ci
4588c2ecf20Sopenharmony_ci	state->TunerRegs[17].Reg_Num = 32 ;
4598c2ecf20Sopenharmony_ci	state->TunerRegs[17].Reg_Val = 0x40 ;
4608c2ecf20Sopenharmony_ci
4618c2ecf20Sopenharmony_ci	state->TunerRegs[18].Reg_Num = 33 ;
4628c2ecf20Sopenharmony_ci	state->TunerRegs[18].Reg_Val = 0x53 ;
4638c2ecf20Sopenharmony_ci
4648c2ecf20Sopenharmony_ci	state->TunerRegs[19].Reg_Num = 34 ;
4658c2ecf20Sopenharmony_ci	state->TunerRegs[19].Reg_Val = 0x81 ;
4668c2ecf20Sopenharmony_ci
4678c2ecf20Sopenharmony_ci	state->TunerRegs[20].Reg_Num = 35 ;
4688c2ecf20Sopenharmony_ci	state->TunerRegs[20].Reg_Val = 0xC9 ;
4698c2ecf20Sopenharmony_ci
4708c2ecf20Sopenharmony_ci	state->TunerRegs[21].Reg_Num = 36 ;
4718c2ecf20Sopenharmony_ci	state->TunerRegs[21].Reg_Val = 0x01 ;
4728c2ecf20Sopenharmony_ci
4738c2ecf20Sopenharmony_ci	state->TunerRegs[22].Reg_Num = 37 ;
4748c2ecf20Sopenharmony_ci	state->TunerRegs[22].Reg_Val = 0x00 ;
4758c2ecf20Sopenharmony_ci
4768c2ecf20Sopenharmony_ci	state->TunerRegs[23].Reg_Num = 41 ;
4778c2ecf20Sopenharmony_ci	state->TunerRegs[23].Reg_Val = 0x00 ;
4788c2ecf20Sopenharmony_ci
4798c2ecf20Sopenharmony_ci	state->TunerRegs[24].Reg_Num = 42 ;
4808c2ecf20Sopenharmony_ci	state->TunerRegs[24].Reg_Val = 0xF8 ;
4818c2ecf20Sopenharmony_ci
4828c2ecf20Sopenharmony_ci	state->TunerRegs[25].Reg_Num = 43 ;
4838c2ecf20Sopenharmony_ci	state->TunerRegs[25].Reg_Val = 0x43 ;
4848c2ecf20Sopenharmony_ci
4858c2ecf20Sopenharmony_ci	state->TunerRegs[26].Reg_Num = 44 ;
4868c2ecf20Sopenharmony_ci	state->TunerRegs[26].Reg_Val = 0x20 ;
4878c2ecf20Sopenharmony_ci
4888c2ecf20Sopenharmony_ci	state->TunerRegs[27].Reg_Num = 45 ;
4898c2ecf20Sopenharmony_ci	state->TunerRegs[27].Reg_Val = 0x80 ;
4908c2ecf20Sopenharmony_ci
4918c2ecf20Sopenharmony_ci	state->TunerRegs[28].Reg_Num = 46 ;
4928c2ecf20Sopenharmony_ci	state->TunerRegs[28].Reg_Val = 0x88 ;
4938c2ecf20Sopenharmony_ci
4948c2ecf20Sopenharmony_ci	state->TunerRegs[29].Reg_Num = 47 ;
4958c2ecf20Sopenharmony_ci	state->TunerRegs[29].Reg_Val = 0x86 ;
4968c2ecf20Sopenharmony_ci
4978c2ecf20Sopenharmony_ci	state->TunerRegs[30].Reg_Num = 48 ;
4988c2ecf20Sopenharmony_ci	state->TunerRegs[30].Reg_Val = 0x00 ;
4998c2ecf20Sopenharmony_ci
5008c2ecf20Sopenharmony_ci	state->TunerRegs[31].Reg_Num = 49 ;
5018c2ecf20Sopenharmony_ci	state->TunerRegs[31].Reg_Val = 0x00 ;
5028c2ecf20Sopenharmony_ci
5038c2ecf20Sopenharmony_ci	state->TunerRegs[32].Reg_Num = 53 ;
5048c2ecf20Sopenharmony_ci	state->TunerRegs[32].Reg_Val = 0x94 ;
5058c2ecf20Sopenharmony_ci
5068c2ecf20Sopenharmony_ci	state->TunerRegs[33].Reg_Num = 54 ;
5078c2ecf20Sopenharmony_ci	state->TunerRegs[33].Reg_Val = 0xFA ;
5088c2ecf20Sopenharmony_ci
5098c2ecf20Sopenharmony_ci	state->TunerRegs[34].Reg_Num = 55 ;
5108c2ecf20Sopenharmony_ci	state->TunerRegs[34].Reg_Val = 0x92 ;
5118c2ecf20Sopenharmony_ci
5128c2ecf20Sopenharmony_ci	state->TunerRegs[35].Reg_Num = 56 ;
5138c2ecf20Sopenharmony_ci	state->TunerRegs[35].Reg_Val = 0x80 ;
5148c2ecf20Sopenharmony_ci
5158c2ecf20Sopenharmony_ci	state->TunerRegs[36].Reg_Num = 57 ;
5168c2ecf20Sopenharmony_ci	state->TunerRegs[36].Reg_Val = 0x41 ;
5178c2ecf20Sopenharmony_ci
5188c2ecf20Sopenharmony_ci	state->TunerRegs[37].Reg_Num = 58 ;
5198c2ecf20Sopenharmony_ci	state->TunerRegs[37].Reg_Val = 0xDB ;
5208c2ecf20Sopenharmony_ci
5218c2ecf20Sopenharmony_ci	state->TunerRegs[38].Reg_Num = 59 ;
5228c2ecf20Sopenharmony_ci	state->TunerRegs[38].Reg_Val = 0x00 ;
5238c2ecf20Sopenharmony_ci
5248c2ecf20Sopenharmony_ci	state->TunerRegs[39].Reg_Num = 60 ;
5258c2ecf20Sopenharmony_ci	state->TunerRegs[39].Reg_Val = 0x00 ;
5268c2ecf20Sopenharmony_ci
5278c2ecf20Sopenharmony_ci	state->TunerRegs[40].Reg_Num = 61 ;
5288c2ecf20Sopenharmony_ci	state->TunerRegs[40].Reg_Val = 0x00 ;
5298c2ecf20Sopenharmony_ci
5308c2ecf20Sopenharmony_ci	state->TunerRegs[41].Reg_Num = 62 ;
5318c2ecf20Sopenharmony_ci	state->TunerRegs[41].Reg_Val = 0x00 ;
5328c2ecf20Sopenharmony_ci
5338c2ecf20Sopenharmony_ci	state->TunerRegs[42].Reg_Num = 65 ;
5348c2ecf20Sopenharmony_ci	state->TunerRegs[42].Reg_Val = 0xF8 ;
5358c2ecf20Sopenharmony_ci
5368c2ecf20Sopenharmony_ci	state->TunerRegs[43].Reg_Num = 66 ;
5378c2ecf20Sopenharmony_ci	state->TunerRegs[43].Reg_Val = 0xE4 ;
5388c2ecf20Sopenharmony_ci
5398c2ecf20Sopenharmony_ci	state->TunerRegs[44].Reg_Num = 67 ;
5408c2ecf20Sopenharmony_ci	state->TunerRegs[44].Reg_Val = 0x90 ;
5418c2ecf20Sopenharmony_ci
5428c2ecf20Sopenharmony_ci	state->TunerRegs[45].Reg_Num = 68 ;
5438c2ecf20Sopenharmony_ci	state->TunerRegs[45].Reg_Val = 0xC0 ;
5448c2ecf20Sopenharmony_ci
5458c2ecf20Sopenharmony_ci	state->TunerRegs[46].Reg_Num = 69 ;
5468c2ecf20Sopenharmony_ci	state->TunerRegs[46].Reg_Val = 0x01 ;
5478c2ecf20Sopenharmony_ci
5488c2ecf20Sopenharmony_ci	state->TunerRegs[47].Reg_Num = 70 ;
5498c2ecf20Sopenharmony_ci	state->TunerRegs[47].Reg_Val = 0x50 ;
5508c2ecf20Sopenharmony_ci
5518c2ecf20Sopenharmony_ci	state->TunerRegs[48].Reg_Num = 71 ;
5528c2ecf20Sopenharmony_ci	state->TunerRegs[48].Reg_Val = 0x06 ;
5538c2ecf20Sopenharmony_ci
5548c2ecf20Sopenharmony_ci	state->TunerRegs[49].Reg_Num = 72 ;
5558c2ecf20Sopenharmony_ci	state->TunerRegs[49].Reg_Val = 0x00 ;
5568c2ecf20Sopenharmony_ci
5578c2ecf20Sopenharmony_ci	state->TunerRegs[50].Reg_Num = 73 ;
5588c2ecf20Sopenharmony_ci	state->TunerRegs[50].Reg_Val = 0x20 ;
5598c2ecf20Sopenharmony_ci
5608c2ecf20Sopenharmony_ci	state->TunerRegs[51].Reg_Num = 76 ;
5618c2ecf20Sopenharmony_ci	state->TunerRegs[51].Reg_Val = 0xBB ;
5628c2ecf20Sopenharmony_ci
5638c2ecf20Sopenharmony_ci	state->TunerRegs[52].Reg_Num = 77 ;
5648c2ecf20Sopenharmony_ci	state->TunerRegs[52].Reg_Val = 0x13 ;
5658c2ecf20Sopenharmony_ci
5668c2ecf20Sopenharmony_ci	state->TunerRegs[53].Reg_Num = 81 ;
5678c2ecf20Sopenharmony_ci	state->TunerRegs[53].Reg_Val = 0x04 ;
5688c2ecf20Sopenharmony_ci
5698c2ecf20Sopenharmony_ci	state->TunerRegs[54].Reg_Num = 82 ;
5708c2ecf20Sopenharmony_ci	state->TunerRegs[54].Reg_Val = 0x75 ;
5718c2ecf20Sopenharmony_ci
5728c2ecf20Sopenharmony_ci	state->TunerRegs[55].Reg_Num = 83 ;
5738c2ecf20Sopenharmony_ci	state->TunerRegs[55].Reg_Val = 0x00 ;
5748c2ecf20Sopenharmony_ci
5758c2ecf20Sopenharmony_ci	state->TunerRegs[56].Reg_Num = 84 ;
5768c2ecf20Sopenharmony_ci	state->TunerRegs[56].Reg_Val = 0x00 ;
5778c2ecf20Sopenharmony_ci
5788c2ecf20Sopenharmony_ci	state->TunerRegs[57].Reg_Num = 85 ;
5798c2ecf20Sopenharmony_ci	state->TunerRegs[57].Reg_Val = 0x00 ;
5808c2ecf20Sopenharmony_ci
5818c2ecf20Sopenharmony_ci	state->TunerRegs[58].Reg_Num = 91 ;
5828c2ecf20Sopenharmony_ci	state->TunerRegs[58].Reg_Val = 0x70 ;
5838c2ecf20Sopenharmony_ci
5848c2ecf20Sopenharmony_ci	state->TunerRegs[59].Reg_Num = 92 ;
5858c2ecf20Sopenharmony_ci	state->TunerRegs[59].Reg_Val = 0x00 ;
5868c2ecf20Sopenharmony_ci
5878c2ecf20Sopenharmony_ci	state->TunerRegs[60].Reg_Num = 93 ;
5888c2ecf20Sopenharmony_ci	state->TunerRegs[60].Reg_Val = 0x00 ;
5898c2ecf20Sopenharmony_ci
5908c2ecf20Sopenharmony_ci	state->TunerRegs[61].Reg_Num = 94 ;
5918c2ecf20Sopenharmony_ci	state->TunerRegs[61].Reg_Val = 0x00 ;
5928c2ecf20Sopenharmony_ci
5938c2ecf20Sopenharmony_ci	state->TunerRegs[62].Reg_Num = 95 ;
5948c2ecf20Sopenharmony_ci	state->TunerRegs[62].Reg_Val = 0x0C ;
5958c2ecf20Sopenharmony_ci
5968c2ecf20Sopenharmony_ci	state->TunerRegs[63].Reg_Num = 96 ;
5978c2ecf20Sopenharmony_ci	state->TunerRegs[63].Reg_Val = 0x00 ;
5988c2ecf20Sopenharmony_ci
5998c2ecf20Sopenharmony_ci	state->TunerRegs[64].Reg_Num = 97 ;
6008c2ecf20Sopenharmony_ci	state->TunerRegs[64].Reg_Val = 0x00 ;
6018c2ecf20Sopenharmony_ci
6028c2ecf20Sopenharmony_ci	state->TunerRegs[65].Reg_Num = 98 ;
6038c2ecf20Sopenharmony_ci	state->TunerRegs[65].Reg_Val = 0xE2 ;
6048c2ecf20Sopenharmony_ci
6058c2ecf20Sopenharmony_ci	state->TunerRegs[66].Reg_Num = 99 ;
6068c2ecf20Sopenharmony_ci	state->TunerRegs[66].Reg_Val = 0x00 ;
6078c2ecf20Sopenharmony_ci
6088c2ecf20Sopenharmony_ci	state->TunerRegs[67].Reg_Num = 100 ;
6098c2ecf20Sopenharmony_ci	state->TunerRegs[67].Reg_Val = 0x00 ;
6108c2ecf20Sopenharmony_ci
6118c2ecf20Sopenharmony_ci	state->TunerRegs[68].Reg_Num = 101 ;
6128c2ecf20Sopenharmony_ci	state->TunerRegs[68].Reg_Val = 0x12 ;
6138c2ecf20Sopenharmony_ci
6148c2ecf20Sopenharmony_ci	state->TunerRegs[69].Reg_Num = 102 ;
6158c2ecf20Sopenharmony_ci	state->TunerRegs[69].Reg_Val = 0x80 ;
6168c2ecf20Sopenharmony_ci
6178c2ecf20Sopenharmony_ci	state->TunerRegs[70].Reg_Num = 103 ;
6188c2ecf20Sopenharmony_ci	state->TunerRegs[70].Reg_Val = 0x32 ;
6198c2ecf20Sopenharmony_ci
6208c2ecf20Sopenharmony_ci	state->TunerRegs[71].Reg_Num = 104 ;
6218c2ecf20Sopenharmony_ci	state->TunerRegs[71].Reg_Val = 0xB4 ;
6228c2ecf20Sopenharmony_ci
6238c2ecf20Sopenharmony_ci	state->TunerRegs[72].Reg_Num = 105 ;
6248c2ecf20Sopenharmony_ci	state->TunerRegs[72].Reg_Val = 0x60 ;
6258c2ecf20Sopenharmony_ci
6268c2ecf20Sopenharmony_ci	state->TunerRegs[73].Reg_Num = 106 ;
6278c2ecf20Sopenharmony_ci	state->TunerRegs[73].Reg_Val = 0x83 ;
6288c2ecf20Sopenharmony_ci
6298c2ecf20Sopenharmony_ci	state->TunerRegs[74].Reg_Num = 107 ;
6308c2ecf20Sopenharmony_ci	state->TunerRegs[74].Reg_Val = 0x84 ;
6318c2ecf20Sopenharmony_ci
6328c2ecf20Sopenharmony_ci	state->TunerRegs[75].Reg_Num = 108 ;
6338c2ecf20Sopenharmony_ci	state->TunerRegs[75].Reg_Val = 0x9C ;
6348c2ecf20Sopenharmony_ci
6358c2ecf20Sopenharmony_ci	state->TunerRegs[76].Reg_Num = 109 ;
6368c2ecf20Sopenharmony_ci	state->TunerRegs[76].Reg_Val = 0x02 ;
6378c2ecf20Sopenharmony_ci
6388c2ecf20Sopenharmony_ci	state->TunerRegs[77].Reg_Num = 110 ;
6398c2ecf20Sopenharmony_ci	state->TunerRegs[77].Reg_Val = 0x81 ;
6408c2ecf20Sopenharmony_ci
6418c2ecf20Sopenharmony_ci	state->TunerRegs[78].Reg_Num = 111 ;
6428c2ecf20Sopenharmony_ci	state->TunerRegs[78].Reg_Val = 0xC0 ;
6438c2ecf20Sopenharmony_ci
6448c2ecf20Sopenharmony_ci	state->TunerRegs[79].Reg_Num = 112 ;
6458c2ecf20Sopenharmony_ci	state->TunerRegs[79].Reg_Val = 0x10 ;
6468c2ecf20Sopenharmony_ci
6478c2ecf20Sopenharmony_ci	state->TunerRegs[80].Reg_Num = 131 ;
6488c2ecf20Sopenharmony_ci	state->TunerRegs[80].Reg_Val = 0x8A ;
6498c2ecf20Sopenharmony_ci
6508c2ecf20Sopenharmony_ci	state->TunerRegs[81].Reg_Num = 132 ;
6518c2ecf20Sopenharmony_ci	state->TunerRegs[81].Reg_Val = 0x10 ;
6528c2ecf20Sopenharmony_ci
6538c2ecf20Sopenharmony_ci	state->TunerRegs[82].Reg_Num = 133 ;
6548c2ecf20Sopenharmony_ci	state->TunerRegs[82].Reg_Val = 0x24 ;
6558c2ecf20Sopenharmony_ci
6568c2ecf20Sopenharmony_ci	state->TunerRegs[83].Reg_Num = 134 ;
6578c2ecf20Sopenharmony_ci	state->TunerRegs[83].Reg_Val = 0x00 ;
6588c2ecf20Sopenharmony_ci
6598c2ecf20Sopenharmony_ci	state->TunerRegs[84].Reg_Num = 135 ;
6608c2ecf20Sopenharmony_ci	state->TunerRegs[84].Reg_Val = 0x00 ;
6618c2ecf20Sopenharmony_ci
6628c2ecf20Sopenharmony_ci	state->TunerRegs[85].Reg_Num = 136 ;
6638c2ecf20Sopenharmony_ci	state->TunerRegs[85].Reg_Val = 0x7E ;
6648c2ecf20Sopenharmony_ci
6658c2ecf20Sopenharmony_ci	state->TunerRegs[86].Reg_Num = 137 ;
6668c2ecf20Sopenharmony_ci	state->TunerRegs[86].Reg_Val = 0x40 ;
6678c2ecf20Sopenharmony_ci
6688c2ecf20Sopenharmony_ci	state->TunerRegs[87].Reg_Num = 138 ;
6698c2ecf20Sopenharmony_ci	state->TunerRegs[87].Reg_Val = 0x38 ;
6708c2ecf20Sopenharmony_ci
6718c2ecf20Sopenharmony_ci	state->TunerRegs[88].Reg_Num = 146 ;
6728c2ecf20Sopenharmony_ci	state->TunerRegs[88].Reg_Val = 0xF6 ;
6738c2ecf20Sopenharmony_ci
6748c2ecf20Sopenharmony_ci	state->TunerRegs[89].Reg_Num = 147 ;
6758c2ecf20Sopenharmony_ci	state->TunerRegs[89].Reg_Val = 0x1A ;
6768c2ecf20Sopenharmony_ci
6778c2ecf20Sopenharmony_ci	state->TunerRegs[90].Reg_Num = 148 ;
6788c2ecf20Sopenharmony_ci	state->TunerRegs[90].Reg_Val = 0x62 ;
6798c2ecf20Sopenharmony_ci
6808c2ecf20Sopenharmony_ci	state->TunerRegs[91].Reg_Num = 149 ;
6818c2ecf20Sopenharmony_ci	state->TunerRegs[91].Reg_Val = 0x33 ;
6828c2ecf20Sopenharmony_ci
6838c2ecf20Sopenharmony_ci	state->TunerRegs[92].Reg_Num = 150 ;
6848c2ecf20Sopenharmony_ci	state->TunerRegs[92].Reg_Val = 0x80 ;
6858c2ecf20Sopenharmony_ci
6868c2ecf20Sopenharmony_ci	state->TunerRegs[93].Reg_Num = 156 ;
6878c2ecf20Sopenharmony_ci	state->TunerRegs[93].Reg_Val = 0x56 ;
6888c2ecf20Sopenharmony_ci
6898c2ecf20Sopenharmony_ci	state->TunerRegs[94].Reg_Num = 157 ;
6908c2ecf20Sopenharmony_ci	state->TunerRegs[94].Reg_Val = 0x17 ;
6918c2ecf20Sopenharmony_ci
6928c2ecf20Sopenharmony_ci	state->TunerRegs[95].Reg_Num = 158 ;
6938c2ecf20Sopenharmony_ci	state->TunerRegs[95].Reg_Val = 0xA9 ;
6948c2ecf20Sopenharmony_ci
6958c2ecf20Sopenharmony_ci	state->TunerRegs[96].Reg_Num = 159 ;
6968c2ecf20Sopenharmony_ci	state->TunerRegs[96].Reg_Val = 0x00 ;
6978c2ecf20Sopenharmony_ci
6988c2ecf20Sopenharmony_ci	state->TunerRegs[97].Reg_Num = 160 ;
6998c2ecf20Sopenharmony_ci	state->TunerRegs[97].Reg_Val = 0x00 ;
7008c2ecf20Sopenharmony_ci
7018c2ecf20Sopenharmony_ci	state->TunerRegs[98].Reg_Num = 161 ;
7028c2ecf20Sopenharmony_ci	state->TunerRegs[98].Reg_Val = 0x00 ;
7038c2ecf20Sopenharmony_ci
7048c2ecf20Sopenharmony_ci	state->TunerRegs[99].Reg_Num = 162 ;
7058c2ecf20Sopenharmony_ci	state->TunerRegs[99].Reg_Val = 0x40 ;
7068c2ecf20Sopenharmony_ci
7078c2ecf20Sopenharmony_ci	state->TunerRegs[100].Reg_Num = 166 ;
7088c2ecf20Sopenharmony_ci	state->TunerRegs[100].Reg_Val = 0xAE ;
7098c2ecf20Sopenharmony_ci
7108c2ecf20Sopenharmony_ci	state->TunerRegs[101].Reg_Num = 167 ;
7118c2ecf20Sopenharmony_ci	state->TunerRegs[101].Reg_Val = 0x1B ;
7128c2ecf20Sopenharmony_ci
7138c2ecf20Sopenharmony_ci	state->TunerRegs[102].Reg_Num = 168 ;
7148c2ecf20Sopenharmony_ci	state->TunerRegs[102].Reg_Val = 0xF2 ;
7158c2ecf20Sopenharmony_ci
7168c2ecf20Sopenharmony_ci	state->TunerRegs[103].Reg_Num = 195 ;
7178c2ecf20Sopenharmony_ci	state->TunerRegs[103].Reg_Val = 0x00 ;
7188c2ecf20Sopenharmony_ci
7198c2ecf20Sopenharmony_ci	return 0 ;
7208c2ecf20Sopenharmony_ci}
7218c2ecf20Sopenharmony_ci
7228c2ecf20Sopenharmony_cistatic u16 MXL5005_ControlInit(struct dvb_frontend *fe)
7238c2ecf20Sopenharmony_ci{
7248c2ecf20Sopenharmony_ci	struct mxl5005s_state *state = fe->tuner_priv;
7258c2ecf20Sopenharmony_ci	state->Init_Ctrl_Num = INITCTRL_NUM;
7268c2ecf20Sopenharmony_ci
7278c2ecf20Sopenharmony_ci	state->Init_Ctrl[0].Ctrl_Num = DN_IQTN_AMP_CUT ;
7288c2ecf20Sopenharmony_ci	state->Init_Ctrl[0].size = 1 ;
7298c2ecf20Sopenharmony_ci	state->Init_Ctrl[0].addr[0] = 73;
7308c2ecf20Sopenharmony_ci	state->Init_Ctrl[0].bit[0] = 7;
7318c2ecf20Sopenharmony_ci	state->Init_Ctrl[0].val[0] = 0;
7328c2ecf20Sopenharmony_ci
7338c2ecf20Sopenharmony_ci	state->Init_Ctrl[1].Ctrl_Num = BB_MODE ;
7348c2ecf20Sopenharmony_ci	state->Init_Ctrl[1].size = 1 ;
7358c2ecf20Sopenharmony_ci	state->Init_Ctrl[1].addr[0] = 53;
7368c2ecf20Sopenharmony_ci	state->Init_Ctrl[1].bit[0] = 2;
7378c2ecf20Sopenharmony_ci	state->Init_Ctrl[1].val[0] = 1;
7388c2ecf20Sopenharmony_ci
7398c2ecf20Sopenharmony_ci	state->Init_Ctrl[2].Ctrl_Num = BB_BUF ;
7408c2ecf20Sopenharmony_ci	state->Init_Ctrl[2].size = 2 ;
7418c2ecf20Sopenharmony_ci	state->Init_Ctrl[2].addr[0] = 53;
7428c2ecf20Sopenharmony_ci	state->Init_Ctrl[2].bit[0] = 1;
7438c2ecf20Sopenharmony_ci	state->Init_Ctrl[2].val[0] = 0;
7448c2ecf20Sopenharmony_ci	state->Init_Ctrl[2].addr[1] = 57;
7458c2ecf20Sopenharmony_ci	state->Init_Ctrl[2].bit[1] = 0;
7468c2ecf20Sopenharmony_ci	state->Init_Ctrl[2].val[1] = 1;
7478c2ecf20Sopenharmony_ci
7488c2ecf20Sopenharmony_ci	state->Init_Ctrl[3].Ctrl_Num = BB_BUF_OA ;
7498c2ecf20Sopenharmony_ci	state->Init_Ctrl[3].size = 1 ;
7508c2ecf20Sopenharmony_ci	state->Init_Ctrl[3].addr[0] = 53;
7518c2ecf20Sopenharmony_ci	state->Init_Ctrl[3].bit[0] = 0;
7528c2ecf20Sopenharmony_ci	state->Init_Ctrl[3].val[0] = 0;
7538c2ecf20Sopenharmony_ci
7548c2ecf20Sopenharmony_ci	state->Init_Ctrl[4].Ctrl_Num = BB_ALPF_BANDSELECT ;
7558c2ecf20Sopenharmony_ci	state->Init_Ctrl[4].size = 3 ;
7568c2ecf20Sopenharmony_ci	state->Init_Ctrl[4].addr[0] = 53;
7578c2ecf20Sopenharmony_ci	state->Init_Ctrl[4].bit[0] = 5;
7588c2ecf20Sopenharmony_ci	state->Init_Ctrl[4].val[0] = 0;
7598c2ecf20Sopenharmony_ci	state->Init_Ctrl[4].addr[1] = 53;
7608c2ecf20Sopenharmony_ci	state->Init_Ctrl[4].bit[1] = 6;
7618c2ecf20Sopenharmony_ci	state->Init_Ctrl[4].val[1] = 0;
7628c2ecf20Sopenharmony_ci	state->Init_Ctrl[4].addr[2] = 53;
7638c2ecf20Sopenharmony_ci	state->Init_Ctrl[4].bit[2] = 7;
7648c2ecf20Sopenharmony_ci	state->Init_Ctrl[4].val[2] = 1;
7658c2ecf20Sopenharmony_ci
7668c2ecf20Sopenharmony_ci	state->Init_Ctrl[5].Ctrl_Num = BB_IQSWAP ;
7678c2ecf20Sopenharmony_ci	state->Init_Ctrl[5].size = 1 ;
7688c2ecf20Sopenharmony_ci	state->Init_Ctrl[5].addr[0] = 59;
7698c2ecf20Sopenharmony_ci	state->Init_Ctrl[5].bit[0] = 0;
7708c2ecf20Sopenharmony_ci	state->Init_Ctrl[5].val[0] = 0;
7718c2ecf20Sopenharmony_ci
7728c2ecf20Sopenharmony_ci	state->Init_Ctrl[6].Ctrl_Num = BB_DLPF_BANDSEL ;
7738c2ecf20Sopenharmony_ci	state->Init_Ctrl[6].size = 2 ;
7748c2ecf20Sopenharmony_ci	state->Init_Ctrl[6].addr[0] = 53;
7758c2ecf20Sopenharmony_ci	state->Init_Ctrl[6].bit[0] = 3;
7768c2ecf20Sopenharmony_ci	state->Init_Ctrl[6].val[0] = 0;
7778c2ecf20Sopenharmony_ci	state->Init_Ctrl[6].addr[1] = 53;
7788c2ecf20Sopenharmony_ci	state->Init_Ctrl[6].bit[1] = 4;
7798c2ecf20Sopenharmony_ci	state->Init_Ctrl[6].val[1] = 1;
7808c2ecf20Sopenharmony_ci
7818c2ecf20Sopenharmony_ci	state->Init_Ctrl[7].Ctrl_Num = RFSYN_CHP_GAIN ;
7828c2ecf20Sopenharmony_ci	state->Init_Ctrl[7].size = 4 ;
7838c2ecf20Sopenharmony_ci	state->Init_Ctrl[7].addr[0] = 22;
7848c2ecf20Sopenharmony_ci	state->Init_Ctrl[7].bit[0] = 4;
7858c2ecf20Sopenharmony_ci	state->Init_Ctrl[7].val[0] = 0;
7868c2ecf20Sopenharmony_ci	state->Init_Ctrl[7].addr[1] = 22;
7878c2ecf20Sopenharmony_ci	state->Init_Ctrl[7].bit[1] = 5;
7888c2ecf20Sopenharmony_ci	state->Init_Ctrl[7].val[1] = 1;
7898c2ecf20Sopenharmony_ci	state->Init_Ctrl[7].addr[2] = 22;
7908c2ecf20Sopenharmony_ci	state->Init_Ctrl[7].bit[2] = 6;
7918c2ecf20Sopenharmony_ci	state->Init_Ctrl[7].val[2] = 1;
7928c2ecf20Sopenharmony_ci	state->Init_Ctrl[7].addr[3] = 22;
7938c2ecf20Sopenharmony_ci	state->Init_Ctrl[7].bit[3] = 7;
7948c2ecf20Sopenharmony_ci	state->Init_Ctrl[7].val[3] = 0;
7958c2ecf20Sopenharmony_ci
7968c2ecf20Sopenharmony_ci	state->Init_Ctrl[8].Ctrl_Num = RFSYN_EN_CHP_HIGAIN ;
7978c2ecf20Sopenharmony_ci	state->Init_Ctrl[8].size = 1 ;
7988c2ecf20Sopenharmony_ci	state->Init_Ctrl[8].addr[0] = 22;
7998c2ecf20Sopenharmony_ci	state->Init_Ctrl[8].bit[0] = 2;
8008c2ecf20Sopenharmony_ci	state->Init_Ctrl[8].val[0] = 0;
8018c2ecf20Sopenharmony_ci
8028c2ecf20Sopenharmony_ci	state->Init_Ctrl[9].Ctrl_Num = AGC_IF ;
8038c2ecf20Sopenharmony_ci	state->Init_Ctrl[9].size = 4 ;
8048c2ecf20Sopenharmony_ci	state->Init_Ctrl[9].addr[0] = 76;
8058c2ecf20Sopenharmony_ci	state->Init_Ctrl[9].bit[0] = 0;
8068c2ecf20Sopenharmony_ci	state->Init_Ctrl[9].val[0] = 1;
8078c2ecf20Sopenharmony_ci	state->Init_Ctrl[9].addr[1] = 76;
8088c2ecf20Sopenharmony_ci	state->Init_Ctrl[9].bit[1] = 1;
8098c2ecf20Sopenharmony_ci	state->Init_Ctrl[9].val[1] = 1;
8108c2ecf20Sopenharmony_ci	state->Init_Ctrl[9].addr[2] = 76;
8118c2ecf20Sopenharmony_ci	state->Init_Ctrl[9].bit[2] = 2;
8128c2ecf20Sopenharmony_ci	state->Init_Ctrl[9].val[2] = 0;
8138c2ecf20Sopenharmony_ci	state->Init_Ctrl[9].addr[3] = 76;
8148c2ecf20Sopenharmony_ci	state->Init_Ctrl[9].bit[3] = 3;
8158c2ecf20Sopenharmony_ci	state->Init_Ctrl[9].val[3] = 1;
8168c2ecf20Sopenharmony_ci
8178c2ecf20Sopenharmony_ci	state->Init_Ctrl[10].Ctrl_Num = AGC_RF ;
8188c2ecf20Sopenharmony_ci	state->Init_Ctrl[10].size = 4 ;
8198c2ecf20Sopenharmony_ci	state->Init_Ctrl[10].addr[0] = 76;
8208c2ecf20Sopenharmony_ci	state->Init_Ctrl[10].bit[0] = 4;
8218c2ecf20Sopenharmony_ci	state->Init_Ctrl[10].val[0] = 1;
8228c2ecf20Sopenharmony_ci	state->Init_Ctrl[10].addr[1] = 76;
8238c2ecf20Sopenharmony_ci	state->Init_Ctrl[10].bit[1] = 5;
8248c2ecf20Sopenharmony_ci	state->Init_Ctrl[10].val[1] = 1;
8258c2ecf20Sopenharmony_ci	state->Init_Ctrl[10].addr[2] = 76;
8268c2ecf20Sopenharmony_ci	state->Init_Ctrl[10].bit[2] = 6;
8278c2ecf20Sopenharmony_ci	state->Init_Ctrl[10].val[2] = 0;
8288c2ecf20Sopenharmony_ci	state->Init_Ctrl[10].addr[3] = 76;
8298c2ecf20Sopenharmony_ci	state->Init_Ctrl[10].bit[3] = 7;
8308c2ecf20Sopenharmony_ci	state->Init_Ctrl[10].val[3] = 1;
8318c2ecf20Sopenharmony_ci
8328c2ecf20Sopenharmony_ci	state->Init_Ctrl[11].Ctrl_Num = IF_DIVVAL ;
8338c2ecf20Sopenharmony_ci	state->Init_Ctrl[11].size = 5 ;
8348c2ecf20Sopenharmony_ci	state->Init_Ctrl[11].addr[0] = 43;
8358c2ecf20Sopenharmony_ci	state->Init_Ctrl[11].bit[0] = 3;
8368c2ecf20Sopenharmony_ci	state->Init_Ctrl[11].val[0] = 0;
8378c2ecf20Sopenharmony_ci	state->Init_Ctrl[11].addr[1] = 43;
8388c2ecf20Sopenharmony_ci	state->Init_Ctrl[11].bit[1] = 4;
8398c2ecf20Sopenharmony_ci	state->Init_Ctrl[11].val[1] = 0;
8408c2ecf20Sopenharmony_ci	state->Init_Ctrl[11].addr[2] = 43;
8418c2ecf20Sopenharmony_ci	state->Init_Ctrl[11].bit[2] = 5;
8428c2ecf20Sopenharmony_ci	state->Init_Ctrl[11].val[2] = 0;
8438c2ecf20Sopenharmony_ci	state->Init_Ctrl[11].addr[3] = 43;
8448c2ecf20Sopenharmony_ci	state->Init_Ctrl[11].bit[3] = 6;
8458c2ecf20Sopenharmony_ci	state->Init_Ctrl[11].val[3] = 1;
8468c2ecf20Sopenharmony_ci	state->Init_Ctrl[11].addr[4] = 43;
8478c2ecf20Sopenharmony_ci	state->Init_Ctrl[11].bit[4] = 7;
8488c2ecf20Sopenharmony_ci	state->Init_Ctrl[11].val[4] = 0;
8498c2ecf20Sopenharmony_ci
8508c2ecf20Sopenharmony_ci	state->Init_Ctrl[12].Ctrl_Num = IF_VCO_BIAS ;
8518c2ecf20Sopenharmony_ci	state->Init_Ctrl[12].size = 6 ;
8528c2ecf20Sopenharmony_ci	state->Init_Ctrl[12].addr[0] = 44;
8538c2ecf20Sopenharmony_ci	state->Init_Ctrl[12].bit[0] = 2;
8548c2ecf20Sopenharmony_ci	state->Init_Ctrl[12].val[0] = 0;
8558c2ecf20Sopenharmony_ci	state->Init_Ctrl[12].addr[1] = 44;
8568c2ecf20Sopenharmony_ci	state->Init_Ctrl[12].bit[1] = 3;
8578c2ecf20Sopenharmony_ci	state->Init_Ctrl[12].val[1] = 0;
8588c2ecf20Sopenharmony_ci	state->Init_Ctrl[12].addr[2] = 44;
8598c2ecf20Sopenharmony_ci	state->Init_Ctrl[12].bit[2] = 4;
8608c2ecf20Sopenharmony_ci	state->Init_Ctrl[12].val[2] = 0;
8618c2ecf20Sopenharmony_ci	state->Init_Ctrl[12].addr[3] = 44;
8628c2ecf20Sopenharmony_ci	state->Init_Ctrl[12].bit[3] = 5;
8638c2ecf20Sopenharmony_ci	state->Init_Ctrl[12].val[3] = 1;
8648c2ecf20Sopenharmony_ci	state->Init_Ctrl[12].addr[4] = 44;
8658c2ecf20Sopenharmony_ci	state->Init_Ctrl[12].bit[4] = 6;
8668c2ecf20Sopenharmony_ci	state->Init_Ctrl[12].val[4] = 0;
8678c2ecf20Sopenharmony_ci	state->Init_Ctrl[12].addr[5] = 44;
8688c2ecf20Sopenharmony_ci	state->Init_Ctrl[12].bit[5] = 7;
8698c2ecf20Sopenharmony_ci	state->Init_Ctrl[12].val[5] = 0;
8708c2ecf20Sopenharmony_ci
8718c2ecf20Sopenharmony_ci	state->Init_Ctrl[13].Ctrl_Num = CHCAL_INT_MOD_IF ;
8728c2ecf20Sopenharmony_ci	state->Init_Ctrl[13].size = 7 ;
8738c2ecf20Sopenharmony_ci	state->Init_Ctrl[13].addr[0] = 11;
8748c2ecf20Sopenharmony_ci	state->Init_Ctrl[13].bit[0] = 0;
8758c2ecf20Sopenharmony_ci	state->Init_Ctrl[13].val[0] = 1;
8768c2ecf20Sopenharmony_ci	state->Init_Ctrl[13].addr[1] = 11;
8778c2ecf20Sopenharmony_ci	state->Init_Ctrl[13].bit[1] = 1;
8788c2ecf20Sopenharmony_ci	state->Init_Ctrl[13].val[1] = 0;
8798c2ecf20Sopenharmony_ci	state->Init_Ctrl[13].addr[2] = 11;
8808c2ecf20Sopenharmony_ci	state->Init_Ctrl[13].bit[2] = 2;
8818c2ecf20Sopenharmony_ci	state->Init_Ctrl[13].val[2] = 0;
8828c2ecf20Sopenharmony_ci	state->Init_Ctrl[13].addr[3] = 11;
8838c2ecf20Sopenharmony_ci	state->Init_Ctrl[13].bit[3] = 3;
8848c2ecf20Sopenharmony_ci	state->Init_Ctrl[13].val[3] = 1;
8858c2ecf20Sopenharmony_ci	state->Init_Ctrl[13].addr[4] = 11;
8868c2ecf20Sopenharmony_ci	state->Init_Ctrl[13].bit[4] = 4;
8878c2ecf20Sopenharmony_ci	state->Init_Ctrl[13].val[4] = 1;
8888c2ecf20Sopenharmony_ci	state->Init_Ctrl[13].addr[5] = 11;
8898c2ecf20Sopenharmony_ci	state->Init_Ctrl[13].bit[5] = 5;
8908c2ecf20Sopenharmony_ci	state->Init_Ctrl[13].val[5] = 0;
8918c2ecf20Sopenharmony_ci	state->Init_Ctrl[13].addr[6] = 11;
8928c2ecf20Sopenharmony_ci	state->Init_Ctrl[13].bit[6] = 6;
8938c2ecf20Sopenharmony_ci	state->Init_Ctrl[13].val[6] = 0;
8948c2ecf20Sopenharmony_ci
8958c2ecf20Sopenharmony_ci	state->Init_Ctrl[14].Ctrl_Num = CHCAL_FRAC_MOD_IF ;
8968c2ecf20Sopenharmony_ci	state->Init_Ctrl[14].size = 16 ;
8978c2ecf20Sopenharmony_ci	state->Init_Ctrl[14].addr[0] = 13;
8988c2ecf20Sopenharmony_ci	state->Init_Ctrl[14].bit[0] = 0;
8998c2ecf20Sopenharmony_ci	state->Init_Ctrl[14].val[0] = 0;
9008c2ecf20Sopenharmony_ci	state->Init_Ctrl[14].addr[1] = 13;
9018c2ecf20Sopenharmony_ci	state->Init_Ctrl[14].bit[1] = 1;
9028c2ecf20Sopenharmony_ci	state->Init_Ctrl[14].val[1] = 0;
9038c2ecf20Sopenharmony_ci	state->Init_Ctrl[14].addr[2] = 13;
9048c2ecf20Sopenharmony_ci	state->Init_Ctrl[14].bit[2] = 2;
9058c2ecf20Sopenharmony_ci	state->Init_Ctrl[14].val[2] = 0;
9068c2ecf20Sopenharmony_ci	state->Init_Ctrl[14].addr[3] = 13;
9078c2ecf20Sopenharmony_ci	state->Init_Ctrl[14].bit[3] = 3;
9088c2ecf20Sopenharmony_ci	state->Init_Ctrl[14].val[3] = 0;
9098c2ecf20Sopenharmony_ci	state->Init_Ctrl[14].addr[4] = 13;
9108c2ecf20Sopenharmony_ci	state->Init_Ctrl[14].bit[4] = 4;
9118c2ecf20Sopenharmony_ci	state->Init_Ctrl[14].val[4] = 0;
9128c2ecf20Sopenharmony_ci	state->Init_Ctrl[14].addr[5] = 13;
9138c2ecf20Sopenharmony_ci	state->Init_Ctrl[14].bit[5] = 5;
9148c2ecf20Sopenharmony_ci	state->Init_Ctrl[14].val[5] = 0;
9158c2ecf20Sopenharmony_ci	state->Init_Ctrl[14].addr[6] = 13;
9168c2ecf20Sopenharmony_ci	state->Init_Ctrl[14].bit[6] = 6;
9178c2ecf20Sopenharmony_ci	state->Init_Ctrl[14].val[6] = 0;
9188c2ecf20Sopenharmony_ci	state->Init_Ctrl[14].addr[7] = 13;
9198c2ecf20Sopenharmony_ci	state->Init_Ctrl[14].bit[7] = 7;
9208c2ecf20Sopenharmony_ci	state->Init_Ctrl[14].val[7] = 0;
9218c2ecf20Sopenharmony_ci	state->Init_Ctrl[14].addr[8] = 12;
9228c2ecf20Sopenharmony_ci	state->Init_Ctrl[14].bit[8] = 0;
9238c2ecf20Sopenharmony_ci	state->Init_Ctrl[14].val[8] = 0;
9248c2ecf20Sopenharmony_ci	state->Init_Ctrl[14].addr[9] = 12;
9258c2ecf20Sopenharmony_ci	state->Init_Ctrl[14].bit[9] = 1;
9268c2ecf20Sopenharmony_ci	state->Init_Ctrl[14].val[9] = 0;
9278c2ecf20Sopenharmony_ci	state->Init_Ctrl[14].addr[10] = 12;
9288c2ecf20Sopenharmony_ci	state->Init_Ctrl[14].bit[10] = 2;
9298c2ecf20Sopenharmony_ci	state->Init_Ctrl[14].val[10] = 0;
9308c2ecf20Sopenharmony_ci	state->Init_Ctrl[14].addr[11] = 12;
9318c2ecf20Sopenharmony_ci	state->Init_Ctrl[14].bit[11] = 3;
9328c2ecf20Sopenharmony_ci	state->Init_Ctrl[14].val[11] = 0;
9338c2ecf20Sopenharmony_ci	state->Init_Ctrl[14].addr[12] = 12;
9348c2ecf20Sopenharmony_ci	state->Init_Ctrl[14].bit[12] = 4;
9358c2ecf20Sopenharmony_ci	state->Init_Ctrl[14].val[12] = 0;
9368c2ecf20Sopenharmony_ci	state->Init_Ctrl[14].addr[13] = 12;
9378c2ecf20Sopenharmony_ci	state->Init_Ctrl[14].bit[13] = 5;
9388c2ecf20Sopenharmony_ci	state->Init_Ctrl[14].val[13] = 1;
9398c2ecf20Sopenharmony_ci	state->Init_Ctrl[14].addr[14] = 12;
9408c2ecf20Sopenharmony_ci	state->Init_Ctrl[14].bit[14] = 6;
9418c2ecf20Sopenharmony_ci	state->Init_Ctrl[14].val[14] = 1;
9428c2ecf20Sopenharmony_ci	state->Init_Ctrl[14].addr[15] = 12;
9438c2ecf20Sopenharmony_ci	state->Init_Ctrl[14].bit[15] = 7;
9448c2ecf20Sopenharmony_ci	state->Init_Ctrl[14].val[15] = 0;
9458c2ecf20Sopenharmony_ci
9468c2ecf20Sopenharmony_ci	state->Init_Ctrl[15].Ctrl_Num = DRV_RES_SEL ;
9478c2ecf20Sopenharmony_ci	state->Init_Ctrl[15].size = 3 ;
9488c2ecf20Sopenharmony_ci	state->Init_Ctrl[15].addr[0] = 147;
9498c2ecf20Sopenharmony_ci	state->Init_Ctrl[15].bit[0] = 2;
9508c2ecf20Sopenharmony_ci	state->Init_Ctrl[15].val[0] = 0;
9518c2ecf20Sopenharmony_ci	state->Init_Ctrl[15].addr[1] = 147;
9528c2ecf20Sopenharmony_ci	state->Init_Ctrl[15].bit[1] = 3;
9538c2ecf20Sopenharmony_ci	state->Init_Ctrl[15].val[1] = 1;
9548c2ecf20Sopenharmony_ci	state->Init_Ctrl[15].addr[2] = 147;
9558c2ecf20Sopenharmony_ci	state->Init_Ctrl[15].bit[2] = 4;
9568c2ecf20Sopenharmony_ci	state->Init_Ctrl[15].val[2] = 1;
9578c2ecf20Sopenharmony_ci
9588c2ecf20Sopenharmony_ci	state->Init_Ctrl[16].Ctrl_Num = I_DRIVER ;
9598c2ecf20Sopenharmony_ci	state->Init_Ctrl[16].size = 2 ;
9608c2ecf20Sopenharmony_ci	state->Init_Ctrl[16].addr[0] = 147;
9618c2ecf20Sopenharmony_ci	state->Init_Ctrl[16].bit[0] = 0;
9628c2ecf20Sopenharmony_ci	state->Init_Ctrl[16].val[0] = 0;
9638c2ecf20Sopenharmony_ci	state->Init_Ctrl[16].addr[1] = 147;
9648c2ecf20Sopenharmony_ci	state->Init_Ctrl[16].bit[1] = 1;
9658c2ecf20Sopenharmony_ci	state->Init_Ctrl[16].val[1] = 1;
9668c2ecf20Sopenharmony_ci
9678c2ecf20Sopenharmony_ci	state->Init_Ctrl[17].Ctrl_Num = EN_AAF ;
9688c2ecf20Sopenharmony_ci	state->Init_Ctrl[17].size = 1 ;
9698c2ecf20Sopenharmony_ci	state->Init_Ctrl[17].addr[0] = 147;
9708c2ecf20Sopenharmony_ci	state->Init_Ctrl[17].bit[0] = 7;
9718c2ecf20Sopenharmony_ci	state->Init_Ctrl[17].val[0] = 0;
9728c2ecf20Sopenharmony_ci
9738c2ecf20Sopenharmony_ci	state->Init_Ctrl[18].Ctrl_Num = EN_3P ;
9748c2ecf20Sopenharmony_ci	state->Init_Ctrl[18].size = 1 ;
9758c2ecf20Sopenharmony_ci	state->Init_Ctrl[18].addr[0] = 147;
9768c2ecf20Sopenharmony_ci	state->Init_Ctrl[18].bit[0] = 6;
9778c2ecf20Sopenharmony_ci	state->Init_Ctrl[18].val[0] = 0;
9788c2ecf20Sopenharmony_ci
9798c2ecf20Sopenharmony_ci	state->Init_Ctrl[19].Ctrl_Num = EN_AUX_3P ;
9808c2ecf20Sopenharmony_ci	state->Init_Ctrl[19].size = 1 ;
9818c2ecf20Sopenharmony_ci	state->Init_Ctrl[19].addr[0] = 156;
9828c2ecf20Sopenharmony_ci	state->Init_Ctrl[19].bit[0] = 0;
9838c2ecf20Sopenharmony_ci	state->Init_Ctrl[19].val[0] = 0;
9848c2ecf20Sopenharmony_ci
9858c2ecf20Sopenharmony_ci	state->Init_Ctrl[20].Ctrl_Num = SEL_AAF_BAND ;
9868c2ecf20Sopenharmony_ci	state->Init_Ctrl[20].size = 1 ;
9878c2ecf20Sopenharmony_ci	state->Init_Ctrl[20].addr[0] = 147;
9888c2ecf20Sopenharmony_ci	state->Init_Ctrl[20].bit[0] = 5;
9898c2ecf20Sopenharmony_ci	state->Init_Ctrl[20].val[0] = 0;
9908c2ecf20Sopenharmony_ci
9918c2ecf20Sopenharmony_ci	state->Init_Ctrl[21].Ctrl_Num = SEQ_ENCLK16_CLK_OUT ;
9928c2ecf20Sopenharmony_ci	state->Init_Ctrl[21].size = 1 ;
9938c2ecf20Sopenharmony_ci	state->Init_Ctrl[21].addr[0] = 137;
9948c2ecf20Sopenharmony_ci	state->Init_Ctrl[21].bit[0] = 4;
9958c2ecf20Sopenharmony_ci	state->Init_Ctrl[21].val[0] = 0;
9968c2ecf20Sopenharmony_ci
9978c2ecf20Sopenharmony_ci	state->Init_Ctrl[22].Ctrl_Num = SEQ_SEL4_16B ;
9988c2ecf20Sopenharmony_ci	state->Init_Ctrl[22].size = 1 ;
9998c2ecf20Sopenharmony_ci	state->Init_Ctrl[22].addr[0] = 137;
10008c2ecf20Sopenharmony_ci	state->Init_Ctrl[22].bit[0] = 7;
10018c2ecf20Sopenharmony_ci	state->Init_Ctrl[22].val[0] = 0;
10028c2ecf20Sopenharmony_ci
10038c2ecf20Sopenharmony_ci	state->Init_Ctrl[23].Ctrl_Num = XTAL_CAPSELECT ;
10048c2ecf20Sopenharmony_ci	state->Init_Ctrl[23].size = 1 ;
10058c2ecf20Sopenharmony_ci	state->Init_Ctrl[23].addr[0] = 91;
10068c2ecf20Sopenharmony_ci	state->Init_Ctrl[23].bit[0] = 5;
10078c2ecf20Sopenharmony_ci	state->Init_Ctrl[23].val[0] = 1;
10088c2ecf20Sopenharmony_ci
10098c2ecf20Sopenharmony_ci	state->Init_Ctrl[24].Ctrl_Num = IF_SEL_DBL ;
10108c2ecf20Sopenharmony_ci	state->Init_Ctrl[24].size = 1 ;
10118c2ecf20Sopenharmony_ci	state->Init_Ctrl[24].addr[0] = 43;
10128c2ecf20Sopenharmony_ci	state->Init_Ctrl[24].bit[0] = 0;
10138c2ecf20Sopenharmony_ci	state->Init_Ctrl[24].val[0] = 1;
10148c2ecf20Sopenharmony_ci
10158c2ecf20Sopenharmony_ci	state->Init_Ctrl[25].Ctrl_Num = RFSYN_R_DIV ;
10168c2ecf20Sopenharmony_ci	state->Init_Ctrl[25].size = 2 ;
10178c2ecf20Sopenharmony_ci	state->Init_Ctrl[25].addr[0] = 22;
10188c2ecf20Sopenharmony_ci	state->Init_Ctrl[25].bit[0] = 0;
10198c2ecf20Sopenharmony_ci	state->Init_Ctrl[25].val[0] = 1;
10208c2ecf20Sopenharmony_ci	state->Init_Ctrl[25].addr[1] = 22;
10218c2ecf20Sopenharmony_ci	state->Init_Ctrl[25].bit[1] = 1;
10228c2ecf20Sopenharmony_ci	state->Init_Ctrl[25].val[1] = 1;
10238c2ecf20Sopenharmony_ci
10248c2ecf20Sopenharmony_ci	state->Init_Ctrl[26].Ctrl_Num = SEQ_EXTSYNTHCALIF ;
10258c2ecf20Sopenharmony_ci	state->Init_Ctrl[26].size = 1 ;
10268c2ecf20Sopenharmony_ci	state->Init_Ctrl[26].addr[0] = 134;
10278c2ecf20Sopenharmony_ci	state->Init_Ctrl[26].bit[0] = 2;
10288c2ecf20Sopenharmony_ci	state->Init_Ctrl[26].val[0] = 0;
10298c2ecf20Sopenharmony_ci
10308c2ecf20Sopenharmony_ci	state->Init_Ctrl[27].Ctrl_Num = SEQ_EXTDCCAL ;
10318c2ecf20Sopenharmony_ci	state->Init_Ctrl[27].size = 1 ;
10328c2ecf20Sopenharmony_ci	state->Init_Ctrl[27].addr[0] = 137;
10338c2ecf20Sopenharmony_ci	state->Init_Ctrl[27].bit[0] = 3;
10348c2ecf20Sopenharmony_ci	state->Init_Ctrl[27].val[0] = 0;
10358c2ecf20Sopenharmony_ci
10368c2ecf20Sopenharmony_ci	state->Init_Ctrl[28].Ctrl_Num = AGC_EN_RSSI ;
10378c2ecf20Sopenharmony_ci	state->Init_Ctrl[28].size = 1 ;
10388c2ecf20Sopenharmony_ci	state->Init_Ctrl[28].addr[0] = 77;
10398c2ecf20Sopenharmony_ci	state->Init_Ctrl[28].bit[0] = 7;
10408c2ecf20Sopenharmony_ci	state->Init_Ctrl[28].val[0] = 0;
10418c2ecf20Sopenharmony_ci
10428c2ecf20Sopenharmony_ci	state->Init_Ctrl[29].Ctrl_Num = RFA_ENCLKRFAGC ;
10438c2ecf20Sopenharmony_ci	state->Init_Ctrl[29].size = 1 ;
10448c2ecf20Sopenharmony_ci	state->Init_Ctrl[29].addr[0] = 166;
10458c2ecf20Sopenharmony_ci	state->Init_Ctrl[29].bit[0] = 7;
10468c2ecf20Sopenharmony_ci	state->Init_Ctrl[29].val[0] = 1;
10478c2ecf20Sopenharmony_ci
10488c2ecf20Sopenharmony_ci	state->Init_Ctrl[30].Ctrl_Num = RFA_RSSI_REFH ;
10498c2ecf20Sopenharmony_ci	state->Init_Ctrl[30].size = 3 ;
10508c2ecf20Sopenharmony_ci	state->Init_Ctrl[30].addr[0] = 166;
10518c2ecf20Sopenharmony_ci	state->Init_Ctrl[30].bit[0] = 0;
10528c2ecf20Sopenharmony_ci	state->Init_Ctrl[30].val[0] = 0;
10538c2ecf20Sopenharmony_ci	state->Init_Ctrl[30].addr[1] = 166;
10548c2ecf20Sopenharmony_ci	state->Init_Ctrl[30].bit[1] = 1;
10558c2ecf20Sopenharmony_ci	state->Init_Ctrl[30].val[1] = 1;
10568c2ecf20Sopenharmony_ci	state->Init_Ctrl[30].addr[2] = 166;
10578c2ecf20Sopenharmony_ci	state->Init_Ctrl[30].bit[2] = 2;
10588c2ecf20Sopenharmony_ci	state->Init_Ctrl[30].val[2] = 1;
10598c2ecf20Sopenharmony_ci
10608c2ecf20Sopenharmony_ci	state->Init_Ctrl[31].Ctrl_Num = RFA_RSSI_REF ;
10618c2ecf20Sopenharmony_ci	state->Init_Ctrl[31].size = 3 ;
10628c2ecf20Sopenharmony_ci	state->Init_Ctrl[31].addr[0] = 166;
10638c2ecf20Sopenharmony_ci	state->Init_Ctrl[31].bit[0] = 3;
10648c2ecf20Sopenharmony_ci	state->Init_Ctrl[31].val[0] = 1;
10658c2ecf20Sopenharmony_ci	state->Init_Ctrl[31].addr[1] = 166;
10668c2ecf20Sopenharmony_ci	state->Init_Ctrl[31].bit[1] = 4;
10678c2ecf20Sopenharmony_ci	state->Init_Ctrl[31].val[1] = 0;
10688c2ecf20Sopenharmony_ci	state->Init_Ctrl[31].addr[2] = 166;
10698c2ecf20Sopenharmony_ci	state->Init_Ctrl[31].bit[2] = 5;
10708c2ecf20Sopenharmony_ci	state->Init_Ctrl[31].val[2] = 1;
10718c2ecf20Sopenharmony_ci
10728c2ecf20Sopenharmony_ci	state->Init_Ctrl[32].Ctrl_Num = RFA_RSSI_REFL ;
10738c2ecf20Sopenharmony_ci	state->Init_Ctrl[32].size = 3 ;
10748c2ecf20Sopenharmony_ci	state->Init_Ctrl[32].addr[0] = 167;
10758c2ecf20Sopenharmony_ci	state->Init_Ctrl[32].bit[0] = 0;
10768c2ecf20Sopenharmony_ci	state->Init_Ctrl[32].val[0] = 1;
10778c2ecf20Sopenharmony_ci	state->Init_Ctrl[32].addr[1] = 167;
10788c2ecf20Sopenharmony_ci	state->Init_Ctrl[32].bit[1] = 1;
10798c2ecf20Sopenharmony_ci	state->Init_Ctrl[32].val[1] = 1;
10808c2ecf20Sopenharmony_ci	state->Init_Ctrl[32].addr[2] = 167;
10818c2ecf20Sopenharmony_ci	state->Init_Ctrl[32].bit[2] = 2;
10828c2ecf20Sopenharmony_ci	state->Init_Ctrl[32].val[2] = 0;
10838c2ecf20Sopenharmony_ci
10848c2ecf20Sopenharmony_ci	state->Init_Ctrl[33].Ctrl_Num = RFA_FLR ;
10858c2ecf20Sopenharmony_ci	state->Init_Ctrl[33].size = 4 ;
10868c2ecf20Sopenharmony_ci	state->Init_Ctrl[33].addr[0] = 168;
10878c2ecf20Sopenharmony_ci	state->Init_Ctrl[33].bit[0] = 0;
10888c2ecf20Sopenharmony_ci	state->Init_Ctrl[33].val[0] = 0;
10898c2ecf20Sopenharmony_ci	state->Init_Ctrl[33].addr[1] = 168;
10908c2ecf20Sopenharmony_ci	state->Init_Ctrl[33].bit[1] = 1;
10918c2ecf20Sopenharmony_ci	state->Init_Ctrl[33].val[1] = 1;
10928c2ecf20Sopenharmony_ci	state->Init_Ctrl[33].addr[2] = 168;
10938c2ecf20Sopenharmony_ci	state->Init_Ctrl[33].bit[2] = 2;
10948c2ecf20Sopenharmony_ci	state->Init_Ctrl[33].val[2] = 0;
10958c2ecf20Sopenharmony_ci	state->Init_Ctrl[33].addr[3] = 168;
10968c2ecf20Sopenharmony_ci	state->Init_Ctrl[33].bit[3] = 3;
10978c2ecf20Sopenharmony_ci	state->Init_Ctrl[33].val[3] = 0;
10988c2ecf20Sopenharmony_ci
10998c2ecf20Sopenharmony_ci	state->Init_Ctrl[34].Ctrl_Num = RFA_CEIL ;
11008c2ecf20Sopenharmony_ci	state->Init_Ctrl[34].size = 4 ;
11018c2ecf20Sopenharmony_ci	state->Init_Ctrl[34].addr[0] = 168;
11028c2ecf20Sopenharmony_ci	state->Init_Ctrl[34].bit[0] = 4;
11038c2ecf20Sopenharmony_ci	state->Init_Ctrl[34].val[0] = 1;
11048c2ecf20Sopenharmony_ci	state->Init_Ctrl[34].addr[1] = 168;
11058c2ecf20Sopenharmony_ci	state->Init_Ctrl[34].bit[1] = 5;
11068c2ecf20Sopenharmony_ci	state->Init_Ctrl[34].val[1] = 1;
11078c2ecf20Sopenharmony_ci	state->Init_Ctrl[34].addr[2] = 168;
11088c2ecf20Sopenharmony_ci	state->Init_Ctrl[34].bit[2] = 6;
11098c2ecf20Sopenharmony_ci	state->Init_Ctrl[34].val[2] = 1;
11108c2ecf20Sopenharmony_ci	state->Init_Ctrl[34].addr[3] = 168;
11118c2ecf20Sopenharmony_ci	state->Init_Ctrl[34].bit[3] = 7;
11128c2ecf20Sopenharmony_ci	state->Init_Ctrl[34].val[3] = 1;
11138c2ecf20Sopenharmony_ci
11148c2ecf20Sopenharmony_ci	state->Init_Ctrl[35].Ctrl_Num = SEQ_EXTIQFSMPULSE ;
11158c2ecf20Sopenharmony_ci	state->Init_Ctrl[35].size = 1 ;
11168c2ecf20Sopenharmony_ci	state->Init_Ctrl[35].addr[0] = 135;
11178c2ecf20Sopenharmony_ci	state->Init_Ctrl[35].bit[0] = 0;
11188c2ecf20Sopenharmony_ci	state->Init_Ctrl[35].val[0] = 0;
11198c2ecf20Sopenharmony_ci
11208c2ecf20Sopenharmony_ci	state->Init_Ctrl[36].Ctrl_Num = OVERRIDE_1 ;
11218c2ecf20Sopenharmony_ci	state->Init_Ctrl[36].size = 1 ;
11228c2ecf20Sopenharmony_ci	state->Init_Ctrl[36].addr[0] = 56;
11238c2ecf20Sopenharmony_ci	state->Init_Ctrl[36].bit[0] = 3;
11248c2ecf20Sopenharmony_ci	state->Init_Ctrl[36].val[0] = 0;
11258c2ecf20Sopenharmony_ci
11268c2ecf20Sopenharmony_ci	state->Init_Ctrl[37].Ctrl_Num = BB_INITSTATE_DLPF_TUNE ;
11278c2ecf20Sopenharmony_ci	state->Init_Ctrl[37].size = 7 ;
11288c2ecf20Sopenharmony_ci	state->Init_Ctrl[37].addr[0] = 59;
11298c2ecf20Sopenharmony_ci	state->Init_Ctrl[37].bit[0] = 1;
11308c2ecf20Sopenharmony_ci	state->Init_Ctrl[37].val[0] = 0;
11318c2ecf20Sopenharmony_ci	state->Init_Ctrl[37].addr[1] = 59;
11328c2ecf20Sopenharmony_ci	state->Init_Ctrl[37].bit[1] = 2;
11338c2ecf20Sopenharmony_ci	state->Init_Ctrl[37].val[1] = 0;
11348c2ecf20Sopenharmony_ci	state->Init_Ctrl[37].addr[2] = 59;
11358c2ecf20Sopenharmony_ci	state->Init_Ctrl[37].bit[2] = 3;
11368c2ecf20Sopenharmony_ci	state->Init_Ctrl[37].val[2] = 0;
11378c2ecf20Sopenharmony_ci	state->Init_Ctrl[37].addr[3] = 59;
11388c2ecf20Sopenharmony_ci	state->Init_Ctrl[37].bit[3] = 4;
11398c2ecf20Sopenharmony_ci	state->Init_Ctrl[37].val[3] = 0;
11408c2ecf20Sopenharmony_ci	state->Init_Ctrl[37].addr[4] = 59;
11418c2ecf20Sopenharmony_ci	state->Init_Ctrl[37].bit[4] = 5;
11428c2ecf20Sopenharmony_ci	state->Init_Ctrl[37].val[4] = 0;
11438c2ecf20Sopenharmony_ci	state->Init_Ctrl[37].addr[5] = 59;
11448c2ecf20Sopenharmony_ci	state->Init_Ctrl[37].bit[5] = 6;
11458c2ecf20Sopenharmony_ci	state->Init_Ctrl[37].val[5] = 0;
11468c2ecf20Sopenharmony_ci	state->Init_Ctrl[37].addr[6] = 59;
11478c2ecf20Sopenharmony_ci	state->Init_Ctrl[37].bit[6] = 7;
11488c2ecf20Sopenharmony_ci	state->Init_Ctrl[37].val[6] = 0;
11498c2ecf20Sopenharmony_ci
11508c2ecf20Sopenharmony_ci	state->Init_Ctrl[38].Ctrl_Num = TG_R_DIV ;
11518c2ecf20Sopenharmony_ci	state->Init_Ctrl[38].size = 6 ;
11528c2ecf20Sopenharmony_ci	state->Init_Ctrl[38].addr[0] = 32;
11538c2ecf20Sopenharmony_ci	state->Init_Ctrl[38].bit[0] = 2;
11548c2ecf20Sopenharmony_ci	state->Init_Ctrl[38].val[0] = 0;
11558c2ecf20Sopenharmony_ci	state->Init_Ctrl[38].addr[1] = 32;
11568c2ecf20Sopenharmony_ci	state->Init_Ctrl[38].bit[1] = 3;
11578c2ecf20Sopenharmony_ci	state->Init_Ctrl[38].val[1] = 0;
11588c2ecf20Sopenharmony_ci	state->Init_Ctrl[38].addr[2] = 32;
11598c2ecf20Sopenharmony_ci	state->Init_Ctrl[38].bit[2] = 4;
11608c2ecf20Sopenharmony_ci	state->Init_Ctrl[38].val[2] = 0;
11618c2ecf20Sopenharmony_ci	state->Init_Ctrl[38].addr[3] = 32;
11628c2ecf20Sopenharmony_ci	state->Init_Ctrl[38].bit[3] = 5;
11638c2ecf20Sopenharmony_ci	state->Init_Ctrl[38].val[3] = 0;
11648c2ecf20Sopenharmony_ci	state->Init_Ctrl[38].addr[4] = 32;
11658c2ecf20Sopenharmony_ci	state->Init_Ctrl[38].bit[4] = 6;
11668c2ecf20Sopenharmony_ci	state->Init_Ctrl[38].val[4] = 1;
11678c2ecf20Sopenharmony_ci	state->Init_Ctrl[38].addr[5] = 32;
11688c2ecf20Sopenharmony_ci	state->Init_Ctrl[38].bit[5] = 7;
11698c2ecf20Sopenharmony_ci	state->Init_Ctrl[38].val[5] = 0;
11708c2ecf20Sopenharmony_ci
11718c2ecf20Sopenharmony_ci	state->Init_Ctrl[39].Ctrl_Num = EN_CHP_LIN_B ;
11728c2ecf20Sopenharmony_ci	state->Init_Ctrl[39].size = 1 ;
11738c2ecf20Sopenharmony_ci	state->Init_Ctrl[39].addr[0] = 25;
11748c2ecf20Sopenharmony_ci	state->Init_Ctrl[39].bit[0] = 3;
11758c2ecf20Sopenharmony_ci	state->Init_Ctrl[39].val[0] = 1;
11768c2ecf20Sopenharmony_ci
11778c2ecf20Sopenharmony_ci
11788c2ecf20Sopenharmony_ci	state->CH_Ctrl_Num = CHCTRL_NUM ;
11798c2ecf20Sopenharmony_ci
11808c2ecf20Sopenharmony_ci	state->CH_Ctrl[0].Ctrl_Num = DN_POLY ;
11818c2ecf20Sopenharmony_ci	state->CH_Ctrl[0].size = 2 ;
11828c2ecf20Sopenharmony_ci	state->CH_Ctrl[0].addr[0] = 68;
11838c2ecf20Sopenharmony_ci	state->CH_Ctrl[0].bit[0] = 6;
11848c2ecf20Sopenharmony_ci	state->CH_Ctrl[0].val[0] = 1;
11858c2ecf20Sopenharmony_ci	state->CH_Ctrl[0].addr[1] = 68;
11868c2ecf20Sopenharmony_ci	state->CH_Ctrl[0].bit[1] = 7;
11878c2ecf20Sopenharmony_ci	state->CH_Ctrl[0].val[1] = 1;
11888c2ecf20Sopenharmony_ci
11898c2ecf20Sopenharmony_ci	state->CH_Ctrl[1].Ctrl_Num = DN_RFGAIN ;
11908c2ecf20Sopenharmony_ci	state->CH_Ctrl[1].size = 2 ;
11918c2ecf20Sopenharmony_ci	state->CH_Ctrl[1].addr[0] = 70;
11928c2ecf20Sopenharmony_ci	state->CH_Ctrl[1].bit[0] = 6;
11938c2ecf20Sopenharmony_ci	state->CH_Ctrl[1].val[0] = 1;
11948c2ecf20Sopenharmony_ci	state->CH_Ctrl[1].addr[1] = 70;
11958c2ecf20Sopenharmony_ci	state->CH_Ctrl[1].bit[1] = 7;
11968c2ecf20Sopenharmony_ci	state->CH_Ctrl[1].val[1] = 0;
11978c2ecf20Sopenharmony_ci
11988c2ecf20Sopenharmony_ci	state->CH_Ctrl[2].Ctrl_Num = DN_CAP_RFLPF ;
11998c2ecf20Sopenharmony_ci	state->CH_Ctrl[2].size = 9 ;
12008c2ecf20Sopenharmony_ci	state->CH_Ctrl[2].addr[0] = 69;
12018c2ecf20Sopenharmony_ci	state->CH_Ctrl[2].bit[0] = 5;
12028c2ecf20Sopenharmony_ci	state->CH_Ctrl[2].val[0] = 0;
12038c2ecf20Sopenharmony_ci	state->CH_Ctrl[2].addr[1] = 69;
12048c2ecf20Sopenharmony_ci	state->CH_Ctrl[2].bit[1] = 6;
12058c2ecf20Sopenharmony_ci	state->CH_Ctrl[2].val[1] = 0;
12068c2ecf20Sopenharmony_ci	state->CH_Ctrl[2].addr[2] = 69;
12078c2ecf20Sopenharmony_ci	state->CH_Ctrl[2].bit[2] = 7;
12088c2ecf20Sopenharmony_ci	state->CH_Ctrl[2].val[2] = 0;
12098c2ecf20Sopenharmony_ci	state->CH_Ctrl[2].addr[3] = 68;
12108c2ecf20Sopenharmony_ci	state->CH_Ctrl[2].bit[3] = 0;
12118c2ecf20Sopenharmony_ci	state->CH_Ctrl[2].val[3] = 0;
12128c2ecf20Sopenharmony_ci	state->CH_Ctrl[2].addr[4] = 68;
12138c2ecf20Sopenharmony_ci	state->CH_Ctrl[2].bit[4] = 1;
12148c2ecf20Sopenharmony_ci	state->CH_Ctrl[2].val[4] = 0;
12158c2ecf20Sopenharmony_ci	state->CH_Ctrl[2].addr[5] = 68;
12168c2ecf20Sopenharmony_ci	state->CH_Ctrl[2].bit[5] = 2;
12178c2ecf20Sopenharmony_ci	state->CH_Ctrl[2].val[5] = 0;
12188c2ecf20Sopenharmony_ci	state->CH_Ctrl[2].addr[6] = 68;
12198c2ecf20Sopenharmony_ci	state->CH_Ctrl[2].bit[6] = 3;
12208c2ecf20Sopenharmony_ci	state->CH_Ctrl[2].val[6] = 0;
12218c2ecf20Sopenharmony_ci	state->CH_Ctrl[2].addr[7] = 68;
12228c2ecf20Sopenharmony_ci	state->CH_Ctrl[2].bit[7] = 4;
12238c2ecf20Sopenharmony_ci	state->CH_Ctrl[2].val[7] = 0;
12248c2ecf20Sopenharmony_ci	state->CH_Ctrl[2].addr[8] = 68;
12258c2ecf20Sopenharmony_ci	state->CH_Ctrl[2].bit[8] = 5;
12268c2ecf20Sopenharmony_ci	state->CH_Ctrl[2].val[8] = 0;
12278c2ecf20Sopenharmony_ci
12288c2ecf20Sopenharmony_ci	state->CH_Ctrl[3].Ctrl_Num = DN_EN_VHFUHFBAR ;
12298c2ecf20Sopenharmony_ci	state->CH_Ctrl[3].size = 1 ;
12308c2ecf20Sopenharmony_ci	state->CH_Ctrl[3].addr[0] = 70;
12318c2ecf20Sopenharmony_ci	state->CH_Ctrl[3].bit[0] = 5;
12328c2ecf20Sopenharmony_ci	state->CH_Ctrl[3].val[0] = 0;
12338c2ecf20Sopenharmony_ci
12348c2ecf20Sopenharmony_ci	state->CH_Ctrl[4].Ctrl_Num = DN_GAIN_ADJUST ;
12358c2ecf20Sopenharmony_ci	state->CH_Ctrl[4].size = 3 ;
12368c2ecf20Sopenharmony_ci	state->CH_Ctrl[4].addr[0] = 73;
12378c2ecf20Sopenharmony_ci	state->CH_Ctrl[4].bit[0] = 4;
12388c2ecf20Sopenharmony_ci	state->CH_Ctrl[4].val[0] = 0;
12398c2ecf20Sopenharmony_ci	state->CH_Ctrl[4].addr[1] = 73;
12408c2ecf20Sopenharmony_ci	state->CH_Ctrl[4].bit[1] = 5;
12418c2ecf20Sopenharmony_ci	state->CH_Ctrl[4].val[1] = 1;
12428c2ecf20Sopenharmony_ci	state->CH_Ctrl[4].addr[2] = 73;
12438c2ecf20Sopenharmony_ci	state->CH_Ctrl[4].bit[2] = 6;
12448c2ecf20Sopenharmony_ci	state->CH_Ctrl[4].val[2] = 0;
12458c2ecf20Sopenharmony_ci
12468c2ecf20Sopenharmony_ci	state->CH_Ctrl[5].Ctrl_Num = DN_IQTNBUF_AMP ;
12478c2ecf20Sopenharmony_ci	state->CH_Ctrl[5].size = 4 ;
12488c2ecf20Sopenharmony_ci	state->CH_Ctrl[5].addr[0] = 70;
12498c2ecf20Sopenharmony_ci	state->CH_Ctrl[5].bit[0] = 0;
12508c2ecf20Sopenharmony_ci	state->CH_Ctrl[5].val[0] = 0;
12518c2ecf20Sopenharmony_ci	state->CH_Ctrl[5].addr[1] = 70;
12528c2ecf20Sopenharmony_ci	state->CH_Ctrl[5].bit[1] = 1;
12538c2ecf20Sopenharmony_ci	state->CH_Ctrl[5].val[1] = 0;
12548c2ecf20Sopenharmony_ci	state->CH_Ctrl[5].addr[2] = 70;
12558c2ecf20Sopenharmony_ci	state->CH_Ctrl[5].bit[2] = 2;
12568c2ecf20Sopenharmony_ci	state->CH_Ctrl[5].val[2] = 0;
12578c2ecf20Sopenharmony_ci	state->CH_Ctrl[5].addr[3] = 70;
12588c2ecf20Sopenharmony_ci	state->CH_Ctrl[5].bit[3] = 3;
12598c2ecf20Sopenharmony_ci	state->CH_Ctrl[5].val[3] = 0;
12608c2ecf20Sopenharmony_ci
12618c2ecf20Sopenharmony_ci	state->CH_Ctrl[6].Ctrl_Num = DN_IQTNGNBFBIAS_BST ;
12628c2ecf20Sopenharmony_ci	state->CH_Ctrl[6].size = 1 ;
12638c2ecf20Sopenharmony_ci	state->CH_Ctrl[6].addr[0] = 70;
12648c2ecf20Sopenharmony_ci	state->CH_Ctrl[6].bit[0] = 4;
12658c2ecf20Sopenharmony_ci	state->CH_Ctrl[6].val[0] = 1;
12668c2ecf20Sopenharmony_ci
12678c2ecf20Sopenharmony_ci	state->CH_Ctrl[7].Ctrl_Num = RFSYN_EN_OUTMUX ;
12688c2ecf20Sopenharmony_ci	state->CH_Ctrl[7].size = 1 ;
12698c2ecf20Sopenharmony_ci	state->CH_Ctrl[7].addr[0] = 111;
12708c2ecf20Sopenharmony_ci	state->CH_Ctrl[7].bit[0] = 4;
12718c2ecf20Sopenharmony_ci	state->CH_Ctrl[7].val[0] = 0;
12728c2ecf20Sopenharmony_ci
12738c2ecf20Sopenharmony_ci	state->CH_Ctrl[8].Ctrl_Num = RFSYN_SEL_VCO_OUT ;
12748c2ecf20Sopenharmony_ci	state->CH_Ctrl[8].size = 1 ;
12758c2ecf20Sopenharmony_ci	state->CH_Ctrl[8].addr[0] = 111;
12768c2ecf20Sopenharmony_ci	state->CH_Ctrl[8].bit[0] = 7;
12778c2ecf20Sopenharmony_ci	state->CH_Ctrl[8].val[0] = 1;
12788c2ecf20Sopenharmony_ci
12798c2ecf20Sopenharmony_ci	state->CH_Ctrl[9].Ctrl_Num = RFSYN_SEL_VCO_HI ;
12808c2ecf20Sopenharmony_ci	state->CH_Ctrl[9].size = 1 ;
12818c2ecf20Sopenharmony_ci	state->CH_Ctrl[9].addr[0] = 111;
12828c2ecf20Sopenharmony_ci	state->CH_Ctrl[9].bit[0] = 6;
12838c2ecf20Sopenharmony_ci	state->CH_Ctrl[9].val[0] = 1;
12848c2ecf20Sopenharmony_ci
12858c2ecf20Sopenharmony_ci	state->CH_Ctrl[10].Ctrl_Num = RFSYN_SEL_DIVM ;
12868c2ecf20Sopenharmony_ci	state->CH_Ctrl[10].size = 1 ;
12878c2ecf20Sopenharmony_ci	state->CH_Ctrl[10].addr[0] = 111;
12888c2ecf20Sopenharmony_ci	state->CH_Ctrl[10].bit[0] = 5;
12898c2ecf20Sopenharmony_ci	state->CH_Ctrl[10].val[0] = 0;
12908c2ecf20Sopenharmony_ci
12918c2ecf20Sopenharmony_ci	state->CH_Ctrl[11].Ctrl_Num = RFSYN_RF_DIV_BIAS ;
12928c2ecf20Sopenharmony_ci	state->CH_Ctrl[11].size = 2 ;
12938c2ecf20Sopenharmony_ci	state->CH_Ctrl[11].addr[0] = 110;
12948c2ecf20Sopenharmony_ci	state->CH_Ctrl[11].bit[0] = 0;
12958c2ecf20Sopenharmony_ci	state->CH_Ctrl[11].val[0] = 1;
12968c2ecf20Sopenharmony_ci	state->CH_Ctrl[11].addr[1] = 110;
12978c2ecf20Sopenharmony_ci	state->CH_Ctrl[11].bit[1] = 1;
12988c2ecf20Sopenharmony_ci	state->CH_Ctrl[11].val[1] = 0;
12998c2ecf20Sopenharmony_ci
13008c2ecf20Sopenharmony_ci	state->CH_Ctrl[12].Ctrl_Num = DN_SEL_FREQ ;
13018c2ecf20Sopenharmony_ci	state->CH_Ctrl[12].size = 3 ;
13028c2ecf20Sopenharmony_ci	state->CH_Ctrl[12].addr[0] = 69;
13038c2ecf20Sopenharmony_ci	state->CH_Ctrl[12].bit[0] = 2;
13048c2ecf20Sopenharmony_ci	state->CH_Ctrl[12].val[0] = 0;
13058c2ecf20Sopenharmony_ci	state->CH_Ctrl[12].addr[1] = 69;
13068c2ecf20Sopenharmony_ci	state->CH_Ctrl[12].bit[1] = 3;
13078c2ecf20Sopenharmony_ci	state->CH_Ctrl[12].val[1] = 0;
13088c2ecf20Sopenharmony_ci	state->CH_Ctrl[12].addr[2] = 69;
13098c2ecf20Sopenharmony_ci	state->CH_Ctrl[12].bit[2] = 4;
13108c2ecf20Sopenharmony_ci	state->CH_Ctrl[12].val[2] = 0;
13118c2ecf20Sopenharmony_ci
13128c2ecf20Sopenharmony_ci	state->CH_Ctrl[13].Ctrl_Num = RFSYN_VCO_BIAS ;
13138c2ecf20Sopenharmony_ci	state->CH_Ctrl[13].size = 6 ;
13148c2ecf20Sopenharmony_ci	state->CH_Ctrl[13].addr[0] = 110;
13158c2ecf20Sopenharmony_ci	state->CH_Ctrl[13].bit[0] = 2;
13168c2ecf20Sopenharmony_ci	state->CH_Ctrl[13].val[0] = 0;
13178c2ecf20Sopenharmony_ci	state->CH_Ctrl[13].addr[1] = 110;
13188c2ecf20Sopenharmony_ci	state->CH_Ctrl[13].bit[1] = 3;
13198c2ecf20Sopenharmony_ci	state->CH_Ctrl[13].val[1] = 0;
13208c2ecf20Sopenharmony_ci	state->CH_Ctrl[13].addr[2] = 110;
13218c2ecf20Sopenharmony_ci	state->CH_Ctrl[13].bit[2] = 4;
13228c2ecf20Sopenharmony_ci	state->CH_Ctrl[13].val[2] = 0;
13238c2ecf20Sopenharmony_ci	state->CH_Ctrl[13].addr[3] = 110;
13248c2ecf20Sopenharmony_ci	state->CH_Ctrl[13].bit[3] = 5;
13258c2ecf20Sopenharmony_ci	state->CH_Ctrl[13].val[3] = 0;
13268c2ecf20Sopenharmony_ci	state->CH_Ctrl[13].addr[4] = 110;
13278c2ecf20Sopenharmony_ci	state->CH_Ctrl[13].bit[4] = 6;
13288c2ecf20Sopenharmony_ci	state->CH_Ctrl[13].val[4] = 0;
13298c2ecf20Sopenharmony_ci	state->CH_Ctrl[13].addr[5] = 110;
13308c2ecf20Sopenharmony_ci	state->CH_Ctrl[13].bit[5] = 7;
13318c2ecf20Sopenharmony_ci	state->CH_Ctrl[13].val[5] = 1;
13328c2ecf20Sopenharmony_ci
13338c2ecf20Sopenharmony_ci	state->CH_Ctrl[14].Ctrl_Num = CHCAL_INT_MOD_RF ;
13348c2ecf20Sopenharmony_ci	state->CH_Ctrl[14].size = 7 ;
13358c2ecf20Sopenharmony_ci	state->CH_Ctrl[14].addr[0] = 14;
13368c2ecf20Sopenharmony_ci	state->CH_Ctrl[14].bit[0] = 0;
13378c2ecf20Sopenharmony_ci	state->CH_Ctrl[14].val[0] = 0;
13388c2ecf20Sopenharmony_ci	state->CH_Ctrl[14].addr[1] = 14;
13398c2ecf20Sopenharmony_ci	state->CH_Ctrl[14].bit[1] = 1;
13408c2ecf20Sopenharmony_ci	state->CH_Ctrl[14].val[1] = 0;
13418c2ecf20Sopenharmony_ci	state->CH_Ctrl[14].addr[2] = 14;
13428c2ecf20Sopenharmony_ci	state->CH_Ctrl[14].bit[2] = 2;
13438c2ecf20Sopenharmony_ci	state->CH_Ctrl[14].val[2] = 0;
13448c2ecf20Sopenharmony_ci	state->CH_Ctrl[14].addr[3] = 14;
13458c2ecf20Sopenharmony_ci	state->CH_Ctrl[14].bit[3] = 3;
13468c2ecf20Sopenharmony_ci	state->CH_Ctrl[14].val[3] = 0;
13478c2ecf20Sopenharmony_ci	state->CH_Ctrl[14].addr[4] = 14;
13488c2ecf20Sopenharmony_ci	state->CH_Ctrl[14].bit[4] = 4;
13498c2ecf20Sopenharmony_ci	state->CH_Ctrl[14].val[4] = 0;
13508c2ecf20Sopenharmony_ci	state->CH_Ctrl[14].addr[5] = 14;
13518c2ecf20Sopenharmony_ci	state->CH_Ctrl[14].bit[5] = 5;
13528c2ecf20Sopenharmony_ci	state->CH_Ctrl[14].val[5] = 0;
13538c2ecf20Sopenharmony_ci	state->CH_Ctrl[14].addr[6] = 14;
13548c2ecf20Sopenharmony_ci	state->CH_Ctrl[14].bit[6] = 6;
13558c2ecf20Sopenharmony_ci	state->CH_Ctrl[14].val[6] = 0;
13568c2ecf20Sopenharmony_ci
13578c2ecf20Sopenharmony_ci	state->CH_Ctrl[15].Ctrl_Num = CHCAL_FRAC_MOD_RF ;
13588c2ecf20Sopenharmony_ci	state->CH_Ctrl[15].size = 18 ;
13598c2ecf20Sopenharmony_ci	state->CH_Ctrl[15].addr[0] = 17;
13608c2ecf20Sopenharmony_ci	state->CH_Ctrl[15].bit[0] = 6;
13618c2ecf20Sopenharmony_ci	state->CH_Ctrl[15].val[0] = 0;
13628c2ecf20Sopenharmony_ci	state->CH_Ctrl[15].addr[1] = 17;
13638c2ecf20Sopenharmony_ci	state->CH_Ctrl[15].bit[1] = 7;
13648c2ecf20Sopenharmony_ci	state->CH_Ctrl[15].val[1] = 0;
13658c2ecf20Sopenharmony_ci	state->CH_Ctrl[15].addr[2] = 16;
13668c2ecf20Sopenharmony_ci	state->CH_Ctrl[15].bit[2] = 0;
13678c2ecf20Sopenharmony_ci	state->CH_Ctrl[15].val[2] = 0;
13688c2ecf20Sopenharmony_ci	state->CH_Ctrl[15].addr[3] = 16;
13698c2ecf20Sopenharmony_ci	state->CH_Ctrl[15].bit[3] = 1;
13708c2ecf20Sopenharmony_ci	state->CH_Ctrl[15].val[3] = 0;
13718c2ecf20Sopenharmony_ci	state->CH_Ctrl[15].addr[4] = 16;
13728c2ecf20Sopenharmony_ci	state->CH_Ctrl[15].bit[4] = 2;
13738c2ecf20Sopenharmony_ci	state->CH_Ctrl[15].val[4] = 0;
13748c2ecf20Sopenharmony_ci	state->CH_Ctrl[15].addr[5] = 16;
13758c2ecf20Sopenharmony_ci	state->CH_Ctrl[15].bit[5] = 3;
13768c2ecf20Sopenharmony_ci	state->CH_Ctrl[15].val[5] = 0;
13778c2ecf20Sopenharmony_ci	state->CH_Ctrl[15].addr[6] = 16;
13788c2ecf20Sopenharmony_ci	state->CH_Ctrl[15].bit[6] = 4;
13798c2ecf20Sopenharmony_ci	state->CH_Ctrl[15].val[6] = 0;
13808c2ecf20Sopenharmony_ci	state->CH_Ctrl[15].addr[7] = 16;
13818c2ecf20Sopenharmony_ci	state->CH_Ctrl[15].bit[7] = 5;
13828c2ecf20Sopenharmony_ci	state->CH_Ctrl[15].val[7] = 0;
13838c2ecf20Sopenharmony_ci	state->CH_Ctrl[15].addr[8] = 16;
13848c2ecf20Sopenharmony_ci	state->CH_Ctrl[15].bit[8] = 6;
13858c2ecf20Sopenharmony_ci	state->CH_Ctrl[15].val[8] = 0;
13868c2ecf20Sopenharmony_ci	state->CH_Ctrl[15].addr[9] = 16;
13878c2ecf20Sopenharmony_ci	state->CH_Ctrl[15].bit[9] = 7;
13888c2ecf20Sopenharmony_ci	state->CH_Ctrl[15].val[9] = 0;
13898c2ecf20Sopenharmony_ci	state->CH_Ctrl[15].addr[10] = 15;
13908c2ecf20Sopenharmony_ci	state->CH_Ctrl[15].bit[10] = 0;
13918c2ecf20Sopenharmony_ci	state->CH_Ctrl[15].val[10] = 0;
13928c2ecf20Sopenharmony_ci	state->CH_Ctrl[15].addr[11] = 15;
13938c2ecf20Sopenharmony_ci	state->CH_Ctrl[15].bit[11] = 1;
13948c2ecf20Sopenharmony_ci	state->CH_Ctrl[15].val[11] = 0;
13958c2ecf20Sopenharmony_ci	state->CH_Ctrl[15].addr[12] = 15;
13968c2ecf20Sopenharmony_ci	state->CH_Ctrl[15].bit[12] = 2;
13978c2ecf20Sopenharmony_ci	state->CH_Ctrl[15].val[12] = 0;
13988c2ecf20Sopenharmony_ci	state->CH_Ctrl[15].addr[13] = 15;
13998c2ecf20Sopenharmony_ci	state->CH_Ctrl[15].bit[13] = 3;
14008c2ecf20Sopenharmony_ci	state->CH_Ctrl[15].val[13] = 0;
14018c2ecf20Sopenharmony_ci	state->CH_Ctrl[15].addr[14] = 15;
14028c2ecf20Sopenharmony_ci	state->CH_Ctrl[15].bit[14] = 4;
14038c2ecf20Sopenharmony_ci	state->CH_Ctrl[15].val[14] = 0;
14048c2ecf20Sopenharmony_ci	state->CH_Ctrl[15].addr[15] = 15;
14058c2ecf20Sopenharmony_ci	state->CH_Ctrl[15].bit[15] = 5;
14068c2ecf20Sopenharmony_ci	state->CH_Ctrl[15].val[15] = 0;
14078c2ecf20Sopenharmony_ci	state->CH_Ctrl[15].addr[16] = 15;
14088c2ecf20Sopenharmony_ci	state->CH_Ctrl[15].bit[16] = 6;
14098c2ecf20Sopenharmony_ci	state->CH_Ctrl[15].val[16] = 1;
14108c2ecf20Sopenharmony_ci	state->CH_Ctrl[15].addr[17] = 15;
14118c2ecf20Sopenharmony_ci	state->CH_Ctrl[15].bit[17] = 7;
14128c2ecf20Sopenharmony_ci	state->CH_Ctrl[15].val[17] = 1;
14138c2ecf20Sopenharmony_ci
14148c2ecf20Sopenharmony_ci	state->CH_Ctrl[16].Ctrl_Num = RFSYN_LPF_R ;
14158c2ecf20Sopenharmony_ci	state->CH_Ctrl[16].size = 5 ;
14168c2ecf20Sopenharmony_ci	state->CH_Ctrl[16].addr[0] = 112;
14178c2ecf20Sopenharmony_ci	state->CH_Ctrl[16].bit[0] = 0;
14188c2ecf20Sopenharmony_ci	state->CH_Ctrl[16].val[0] = 0;
14198c2ecf20Sopenharmony_ci	state->CH_Ctrl[16].addr[1] = 112;
14208c2ecf20Sopenharmony_ci	state->CH_Ctrl[16].bit[1] = 1;
14218c2ecf20Sopenharmony_ci	state->CH_Ctrl[16].val[1] = 0;
14228c2ecf20Sopenharmony_ci	state->CH_Ctrl[16].addr[2] = 112;
14238c2ecf20Sopenharmony_ci	state->CH_Ctrl[16].bit[2] = 2;
14248c2ecf20Sopenharmony_ci	state->CH_Ctrl[16].val[2] = 0;
14258c2ecf20Sopenharmony_ci	state->CH_Ctrl[16].addr[3] = 112;
14268c2ecf20Sopenharmony_ci	state->CH_Ctrl[16].bit[3] = 3;
14278c2ecf20Sopenharmony_ci	state->CH_Ctrl[16].val[3] = 0;
14288c2ecf20Sopenharmony_ci	state->CH_Ctrl[16].addr[4] = 112;
14298c2ecf20Sopenharmony_ci	state->CH_Ctrl[16].bit[4] = 4;
14308c2ecf20Sopenharmony_ci	state->CH_Ctrl[16].val[4] = 1;
14318c2ecf20Sopenharmony_ci
14328c2ecf20Sopenharmony_ci	state->CH_Ctrl[17].Ctrl_Num = CHCAL_EN_INT_RF ;
14338c2ecf20Sopenharmony_ci	state->CH_Ctrl[17].size = 1 ;
14348c2ecf20Sopenharmony_ci	state->CH_Ctrl[17].addr[0] = 14;
14358c2ecf20Sopenharmony_ci	state->CH_Ctrl[17].bit[0] = 7;
14368c2ecf20Sopenharmony_ci	state->CH_Ctrl[17].val[0] = 0;
14378c2ecf20Sopenharmony_ci
14388c2ecf20Sopenharmony_ci	state->CH_Ctrl[18].Ctrl_Num = TG_LO_DIVVAL ;
14398c2ecf20Sopenharmony_ci	state->CH_Ctrl[18].size = 4 ;
14408c2ecf20Sopenharmony_ci	state->CH_Ctrl[18].addr[0] = 107;
14418c2ecf20Sopenharmony_ci	state->CH_Ctrl[18].bit[0] = 3;
14428c2ecf20Sopenharmony_ci	state->CH_Ctrl[18].val[0] = 0;
14438c2ecf20Sopenharmony_ci	state->CH_Ctrl[18].addr[1] = 107;
14448c2ecf20Sopenharmony_ci	state->CH_Ctrl[18].bit[1] = 4;
14458c2ecf20Sopenharmony_ci	state->CH_Ctrl[18].val[1] = 0;
14468c2ecf20Sopenharmony_ci	state->CH_Ctrl[18].addr[2] = 107;
14478c2ecf20Sopenharmony_ci	state->CH_Ctrl[18].bit[2] = 5;
14488c2ecf20Sopenharmony_ci	state->CH_Ctrl[18].val[2] = 0;
14498c2ecf20Sopenharmony_ci	state->CH_Ctrl[18].addr[3] = 107;
14508c2ecf20Sopenharmony_ci	state->CH_Ctrl[18].bit[3] = 6;
14518c2ecf20Sopenharmony_ci	state->CH_Ctrl[18].val[3] = 0;
14528c2ecf20Sopenharmony_ci
14538c2ecf20Sopenharmony_ci	state->CH_Ctrl[19].Ctrl_Num = TG_LO_SELVAL ;
14548c2ecf20Sopenharmony_ci	state->CH_Ctrl[19].size = 3 ;
14558c2ecf20Sopenharmony_ci	state->CH_Ctrl[19].addr[0] = 107;
14568c2ecf20Sopenharmony_ci	state->CH_Ctrl[19].bit[0] = 7;
14578c2ecf20Sopenharmony_ci	state->CH_Ctrl[19].val[0] = 1;
14588c2ecf20Sopenharmony_ci	state->CH_Ctrl[19].addr[1] = 106;
14598c2ecf20Sopenharmony_ci	state->CH_Ctrl[19].bit[1] = 0;
14608c2ecf20Sopenharmony_ci	state->CH_Ctrl[19].val[1] = 1;
14618c2ecf20Sopenharmony_ci	state->CH_Ctrl[19].addr[2] = 106;
14628c2ecf20Sopenharmony_ci	state->CH_Ctrl[19].bit[2] = 1;
14638c2ecf20Sopenharmony_ci	state->CH_Ctrl[19].val[2] = 1;
14648c2ecf20Sopenharmony_ci
14658c2ecf20Sopenharmony_ci	state->CH_Ctrl[20].Ctrl_Num = TG_DIV_VAL ;
14668c2ecf20Sopenharmony_ci	state->CH_Ctrl[20].size = 11 ;
14678c2ecf20Sopenharmony_ci	state->CH_Ctrl[20].addr[0] = 109;
14688c2ecf20Sopenharmony_ci	state->CH_Ctrl[20].bit[0] = 2;
14698c2ecf20Sopenharmony_ci	state->CH_Ctrl[20].val[0] = 0;
14708c2ecf20Sopenharmony_ci	state->CH_Ctrl[20].addr[1] = 109;
14718c2ecf20Sopenharmony_ci	state->CH_Ctrl[20].bit[1] = 3;
14728c2ecf20Sopenharmony_ci	state->CH_Ctrl[20].val[1] = 0;
14738c2ecf20Sopenharmony_ci	state->CH_Ctrl[20].addr[2] = 109;
14748c2ecf20Sopenharmony_ci	state->CH_Ctrl[20].bit[2] = 4;
14758c2ecf20Sopenharmony_ci	state->CH_Ctrl[20].val[2] = 0;
14768c2ecf20Sopenharmony_ci	state->CH_Ctrl[20].addr[3] = 109;
14778c2ecf20Sopenharmony_ci	state->CH_Ctrl[20].bit[3] = 5;
14788c2ecf20Sopenharmony_ci	state->CH_Ctrl[20].val[3] = 0;
14798c2ecf20Sopenharmony_ci	state->CH_Ctrl[20].addr[4] = 109;
14808c2ecf20Sopenharmony_ci	state->CH_Ctrl[20].bit[4] = 6;
14818c2ecf20Sopenharmony_ci	state->CH_Ctrl[20].val[4] = 0;
14828c2ecf20Sopenharmony_ci	state->CH_Ctrl[20].addr[5] = 109;
14838c2ecf20Sopenharmony_ci	state->CH_Ctrl[20].bit[5] = 7;
14848c2ecf20Sopenharmony_ci	state->CH_Ctrl[20].val[5] = 0;
14858c2ecf20Sopenharmony_ci	state->CH_Ctrl[20].addr[6] = 108;
14868c2ecf20Sopenharmony_ci	state->CH_Ctrl[20].bit[6] = 0;
14878c2ecf20Sopenharmony_ci	state->CH_Ctrl[20].val[6] = 0;
14888c2ecf20Sopenharmony_ci	state->CH_Ctrl[20].addr[7] = 108;
14898c2ecf20Sopenharmony_ci	state->CH_Ctrl[20].bit[7] = 1;
14908c2ecf20Sopenharmony_ci	state->CH_Ctrl[20].val[7] = 0;
14918c2ecf20Sopenharmony_ci	state->CH_Ctrl[20].addr[8] = 108;
14928c2ecf20Sopenharmony_ci	state->CH_Ctrl[20].bit[8] = 2;
14938c2ecf20Sopenharmony_ci	state->CH_Ctrl[20].val[8] = 1;
14948c2ecf20Sopenharmony_ci	state->CH_Ctrl[20].addr[9] = 108;
14958c2ecf20Sopenharmony_ci	state->CH_Ctrl[20].bit[9] = 3;
14968c2ecf20Sopenharmony_ci	state->CH_Ctrl[20].val[9] = 1;
14978c2ecf20Sopenharmony_ci	state->CH_Ctrl[20].addr[10] = 108;
14988c2ecf20Sopenharmony_ci	state->CH_Ctrl[20].bit[10] = 4;
14998c2ecf20Sopenharmony_ci	state->CH_Ctrl[20].val[10] = 1;
15008c2ecf20Sopenharmony_ci
15018c2ecf20Sopenharmony_ci	state->CH_Ctrl[21].Ctrl_Num = TG_VCO_BIAS ;
15028c2ecf20Sopenharmony_ci	state->CH_Ctrl[21].size = 6 ;
15038c2ecf20Sopenharmony_ci	state->CH_Ctrl[21].addr[0] = 106;
15048c2ecf20Sopenharmony_ci	state->CH_Ctrl[21].bit[0] = 2;
15058c2ecf20Sopenharmony_ci	state->CH_Ctrl[21].val[0] = 0;
15068c2ecf20Sopenharmony_ci	state->CH_Ctrl[21].addr[1] = 106;
15078c2ecf20Sopenharmony_ci	state->CH_Ctrl[21].bit[1] = 3;
15088c2ecf20Sopenharmony_ci	state->CH_Ctrl[21].val[1] = 0;
15098c2ecf20Sopenharmony_ci	state->CH_Ctrl[21].addr[2] = 106;
15108c2ecf20Sopenharmony_ci	state->CH_Ctrl[21].bit[2] = 4;
15118c2ecf20Sopenharmony_ci	state->CH_Ctrl[21].val[2] = 0;
15128c2ecf20Sopenharmony_ci	state->CH_Ctrl[21].addr[3] = 106;
15138c2ecf20Sopenharmony_ci	state->CH_Ctrl[21].bit[3] = 5;
15148c2ecf20Sopenharmony_ci	state->CH_Ctrl[21].val[3] = 0;
15158c2ecf20Sopenharmony_ci	state->CH_Ctrl[21].addr[4] = 106;
15168c2ecf20Sopenharmony_ci	state->CH_Ctrl[21].bit[4] = 6;
15178c2ecf20Sopenharmony_ci	state->CH_Ctrl[21].val[4] = 0;
15188c2ecf20Sopenharmony_ci	state->CH_Ctrl[21].addr[5] = 106;
15198c2ecf20Sopenharmony_ci	state->CH_Ctrl[21].bit[5] = 7;
15208c2ecf20Sopenharmony_ci	state->CH_Ctrl[21].val[5] = 1;
15218c2ecf20Sopenharmony_ci
15228c2ecf20Sopenharmony_ci	state->CH_Ctrl[22].Ctrl_Num = SEQ_EXTPOWERUP ;
15238c2ecf20Sopenharmony_ci	state->CH_Ctrl[22].size = 1 ;
15248c2ecf20Sopenharmony_ci	state->CH_Ctrl[22].addr[0] = 138;
15258c2ecf20Sopenharmony_ci	state->CH_Ctrl[22].bit[0] = 4;
15268c2ecf20Sopenharmony_ci	state->CH_Ctrl[22].val[0] = 1;
15278c2ecf20Sopenharmony_ci
15288c2ecf20Sopenharmony_ci	state->CH_Ctrl[23].Ctrl_Num = OVERRIDE_2 ;
15298c2ecf20Sopenharmony_ci	state->CH_Ctrl[23].size = 1 ;
15308c2ecf20Sopenharmony_ci	state->CH_Ctrl[23].addr[0] = 17;
15318c2ecf20Sopenharmony_ci	state->CH_Ctrl[23].bit[0] = 5;
15328c2ecf20Sopenharmony_ci	state->CH_Ctrl[23].val[0] = 0;
15338c2ecf20Sopenharmony_ci
15348c2ecf20Sopenharmony_ci	state->CH_Ctrl[24].Ctrl_Num = OVERRIDE_3 ;
15358c2ecf20Sopenharmony_ci	state->CH_Ctrl[24].size = 1 ;
15368c2ecf20Sopenharmony_ci	state->CH_Ctrl[24].addr[0] = 111;
15378c2ecf20Sopenharmony_ci	state->CH_Ctrl[24].bit[0] = 3;
15388c2ecf20Sopenharmony_ci	state->CH_Ctrl[24].val[0] = 0;
15398c2ecf20Sopenharmony_ci
15408c2ecf20Sopenharmony_ci	state->CH_Ctrl[25].Ctrl_Num = OVERRIDE_4 ;
15418c2ecf20Sopenharmony_ci	state->CH_Ctrl[25].size = 1 ;
15428c2ecf20Sopenharmony_ci	state->CH_Ctrl[25].addr[0] = 112;
15438c2ecf20Sopenharmony_ci	state->CH_Ctrl[25].bit[0] = 7;
15448c2ecf20Sopenharmony_ci	state->CH_Ctrl[25].val[0] = 0;
15458c2ecf20Sopenharmony_ci
15468c2ecf20Sopenharmony_ci	state->CH_Ctrl[26].Ctrl_Num = SEQ_FSM_PULSE ;
15478c2ecf20Sopenharmony_ci	state->CH_Ctrl[26].size = 1 ;
15488c2ecf20Sopenharmony_ci	state->CH_Ctrl[26].addr[0] = 136;
15498c2ecf20Sopenharmony_ci	state->CH_Ctrl[26].bit[0] = 7;
15508c2ecf20Sopenharmony_ci	state->CH_Ctrl[26].val[0] = 0;
15518c2ecf20Sopenharmony_ci
15528c2ecf20Sopenharmony_ci	state->CH_Ctrl[27].Ctrl_Num = GPIO_4B ;
15538c2ecf20Sopenharmony_ci	state->CH_Ctrl[27].size = 1 ;
15548c2ecf20Sopenharmony_ci	state->CH_Ctrl[27].addr[0] = 149;
15558c2ecf20Sopenharmony_ci	state->CH_Ctrl[27].bit[0] = 7;
15568c2ecf20Sopenharmony_ci	state->CH_Ctrl[27].val[0] = 0;
15578c2ecf20Sopenharmony_ci
15588c2ecf20Sopenharmony_ci	state->CH_Ctrl[28].Ctrl_Num = GPIO_3B ;
15598c2ecf20Sopenharmony_ci	state->CH_Ctrl[28].size = 1 ;
15608c2ecf20Sopenharmony_ci	state->CH_Ctrl[28].addr[0] = 149;
15618c2ecf20Sopenharmony_ci	state->CH_Ctrl[28].bit[0] = 6;
15628c2ecf20Sopenharmony_ci	state->CH_Ctrl[28].val[0] = 0;
15638c2ecf20Sopenharmony_ci
15648c2ecf20Sopenharmony_ci	state->CH_Ctrl[29].Ctrl_Num = GPIO_4 ;
15658c2ecf20Sopenharmony_ci	state->CH_Ctrl[29].size = 1 ;
15668c2ecf20Sopenharmony_ci	state->CH_Ctrl[29].addr[0] = 149;
15678c2ecf20Sopenharmony_ci	state->CH_Ctrl[29].bit[0] = 5;
15688c2ecf20Sopenharmony_ci	state->CH_Ctrl[29].val[0] = 1;
15698c2ecf20Sopenharmony_ci
15708c2ecf20Sopenharmony_ci	state->CH_Ctrl[30].Ctrl_Num = GPIO_3 ;
15718c2ecf20Sopenharmony_ci	state->CH_Ctrl[30].size = 1 ;
15728c2ecf20Sopenharmony_ci	state->CH_Ctrl[30].addr[0] = 149;
15738c2ecf20Sopenharmony_ci	state->CH_Ctrl[30].bit[0] = 4;
15748c2ecf20Sopenharmony_ci	state->CH_Ctrl[30].val[0] = 1;
15758c2ecf20Sopenharmony_ci
15768c2ecf20Sopenharmony_ci	state->CH_Ctrl[31].Ctrl_Num = GPIO_1B ;
15778c2ecf20Sopenharmony_ci	state->CH_Ctrl[31].size = 1 ;
15788c2ecf20Sopenharmony_ci	state->CH_Ctrl[31].addr[0] = 149;
15798c2ecf20Sopenharmony_ci	state->CH_Ctrl[31].bit[0] = 3;
15808c2ecf20Sopenharmony_ci	state->CH_Ctrl[31].val[0] = 0;
15818c2ecf20Sopenharmony_ci
15828c2ecf20Sopenharmony_ci	state->CH_Ctrl[32].Ctrl_Num = DAC_A_ENABLE ;
15838c2ecf20Sopenharmony_ci	state->CH_Ctrl[32].size = 1 ;
15848c2ecf20Sopenharmony_ci	state->CH_Ctrl[32].addr[0] = 93;
15858c2ecf20Sopenharmony_ci	state->CH_Ctrl[32].bit[0] = 1;
15868c2ecf20Sopenharmony_ci	state->CH_Ctrl[32].val[0] = 0;
15878c2ecf20Sopenharmony_ci
15888c2ecf20Sopenharmony_ci	state->CH_Ctrl[33].Ctrl_Num = DAC_B_ENABLE ;
15898c2ecf20Sopenharmony_ci	state->CH_Ctrl[33].size = 1 ;
15908c2ecf20Sopenharmony_ci	state->CH_Ctrl[33].addr[0] = 93;
15918c2ecf20Sopenharmony_ci	state->CH_Ctrl[33].bit[0] = 0;
15928c2ecf20Sopenharmony_ci	state->CH_Ctrl[33].val[0] = 0;
15938c2ecf20Sopenharmony_ci
15948c2ecf20Sopenharmony_ci	state->CH_Ctrl[34].Ctrl_Num = DAC_DIN_A ;
15958c2ecf20Sopenharmony_ci	state->CH_Ctrl[34].size = 6 ;
15968c2ecf20Sopenharmony_ci	state->CH_Ctrl[34].addr[0] = 92;
15978c2ecf20Sopenharmony_ci	state->CH_Ctrl[34].bit[0] = 2;
15988c2ecf20Sopenharmony_ci	state->CH_Ctrl[34].val[0] = 0;
15998c2ecf20Sopenharmony_ci	state->CH_Ctrl[34].addr[1] = 92;
16008c2ecf20Sopenharmony_ci	state->CH_Ctrl[34].bit[1] = 3;
16018c2ecf20Sopenharmony_ci	state->CH_Ctrl[34].val[1] = 0;
16028c2ecf20Sopenharmony_ci	state->CH_Ctrl[34].addr[2] = 92;
16038c2ecf20Sopenharmony_ci	state->CH_Ctrl[34].bit[2] = 4;
16048c2ecf20Sopenharmony_ci	state->CH_Ctrl[34].val[2] = 0;
16058c2ecf20Sopenharmony_ci	state->CH_Ctrl[34].addr[3] = 92;
16068c2ecf20Sopenharmony_ci	state->CH_Ctrl[34].bit[3] = 5;
16078c2ecf20Sopenharmony_ci	state->CH_Ctrl[34].val[3] = 0;
16088c2ecf20Sopenharmony_ci	state->CH_Ctrl[34].addr[4] = 92;
16098c2ecf20Sopenharmony_ci	state->CH_Ctrl[34].bit[4] = 6;
16108c2ecf20Sopenharmony_ci	state->CH_Ctrl[34].val[4] = 0;
16118c2ecf20Sopenharmony_ci	state->CH_Ctrl[34].addr[5] = 92;
16128c2ecf20Sopenharmony_ci	state->CH_Ctrl[34].bit[5] = 7;
16138c2ecf20Sopenharmony_ci	state->CH_Ctrl[34].val[5] = 0;
16148c2ecf20Sopenharmony_ci
16158c2ecf20Sopenharmony_ci	state->CH_Ctrl[35].Ctrl_Num = DAC_DIN_B ;
16168c2ecf20Sopenharmony_ci	state->CH_Ctrl[35].size = 6 ;
16178c2ecf20Sopenharmony_ci	state->CH_Ctrl[35].addr[0] = 93;
16188c2ecf20Sopenharmony_ci	state->CH_Ctrl[35].bit[0] = 2;
16198c2ecf20Sopenharmony_ci	state->CH_Ctrl[35].val[0] = 0;
16208c2ecf20Sopenharmony_ci	state->CH_Ctrl[35].addr[1] = 93;
16218c2ecf20Sopenharmony_ci	state->CH_Ctrl[35].bit[1] = 3;
16228c2ecf20Sopenharmony_ci	state->CH_Ctrl[35].val[1] = 0;
16238c2ecf20Sopenharmony_ci	state->CH_Ctrl[35].addr[2] = 93;
16248c2ecf20Sopenharmony_ci	state->CH_Ctrl[35].bit[2] = 4;
16258c2ecf20Sopenharmony_ci	state->CH_Ctrl[35].val[2] = 0;
16268c2ecf20Sopenharmony_ci	state->CH_Ctrl[35].addr[3] = 93;
16278c2ecf20Sopenharmony_ci	state->CH_Ctrl[35].bit[3] = 5;
16288c2ecf20Sopenharmony_ci	state->CH_Ctrl[35].val[3] = 0;
16298c2ecf20Sopenharmony_ci	state->CH_Ctrl[35].addr[4] = 93;
16308c2ecf20Sopenharmony_ci	state->CH_Ctrl[35].bit[4] = 6;
16318c2ecf20Sopenharmony_ci	state->CH_Ctrl[35].val[4] = 0;
16328c2ecf20Sopenharmony_ci	state->CH_Ctrl[35].addr[5] = 93;
16338c2ecf20Sopenharmony_ci	state->CH_Ctrl[35].bit[5] = 7;
16348c2ecf20Sopenharmony_ci	state->CH_Ctrl[35].val[5] = 0;
16358c2ecf20Sopenharmony_ci
16368c2ecf20Sopenharmony_ci#ifdef _MXL_PRODUCTION
16378c2ecf20Sopenharmony_ci	state->CH_Ctrl[36].Ctrl_Num = RFSYN_EN_DIV ;
16388c2ecf20Sopenharmony_ci	state->CH_Ctrl[36].size = 1 ;
16398c2ecf20Sopenharmony_ci	state->CH_Ctrl[36].addr[0] = 109;
16408c2ecf20Sopenharmony_ci	state->CH_Ctrl[36].bit[0] = 1;
16418c2ecf20Sopenharmony_ci	state->CH_Ctrl[36].val[0] = 1;
16428c2ecf20Sopenharmony_ci
16438c2ecf20Sopenharmony_ci	state->CH_Ctrl[37].Ctrl_Num = RFSYN_DIVM ;
16448c2ecf20Sopenharmony_ci	state->CH_Ctrl[37].size = 2 ;
16458c2ecf20Sopenharmony_ci	state->CH_Ctrl[37].addr[0] = 112;
16468c2ecf20Sopenharmony_ci	state->CH_Ctrl[37].bit[0] = 5;
16478c2ecf20Sopenharmony_ci	state->CH_Ctrl[37].val[0] = 0;
16488c2ecf20Sopenharmony_ci	state->CH_Ctrl[37].addr[1] = 112;
16498c2ecf20Sopenharmony_ci	state->CH_Ctrl[37].bit[1] = 6;
16508c2ecf20Sopenharmony_ci	state->CH_Ctrl[37].val[1] = 0;
16518c2ecf20Sopenharmony_ci
16528c2ecf20Sopenharmony_ci	state->CH_Ctrl[38].Ctrl_Num = DN_BYPASS_AGC_I2C ;
16538c2ecf20Sopenharmony_ci	state->CH_Ctrl[38].size = 1 ;
16548c2ecf20Sopenharmony_ci	state->CH_Ctrl[38].addr[0] = 65;
16558c2ecf20Sopenharmony_ci	state->CH_Ctrl[38].bit[0] = 1;
16568c2ecf20Sopenharmony_ci	state->CH_Ctrl[38].val[0] = 0;
16578c2ecf20Sopenharmony_ci#endif
16588c2ecf20Sopenharmony_ci
16598c2ecf20Sopenharmony_ci	return 0 ;
16608c2ecf20Sopenharmony_ci}
16618c2ecf20Sopenharmony_ci
16628c2ecf20Sopenharmony_cistatic void InitTunerControls(struct dvb_frontend *fe)
16638c2ecf20Sopenharmony_ci{
16648c2ecf20Sopenharmony_ci	MXL5005_RegisterInit(fe);
16658c2ecf20Sopenharmony_ci	MXL5005_ControlInit(fe);
16668c2ecf20Sopenharmony_ci#ifdef _MXL_INTERNAL
16678c2ecf20Sopenharmony_ci	MXL5005_MXLControlInit(fe);
16688c2ecf20Sopenharmony_ci#endif
16698c2ecf20Sopenharmony_ci}
16708c2ecf20Sopenharmony_ci
16718c2ecf20Sopenharmony_cistatic u16 MXL5005_TunerConfig(struct dvb_frontend *fe,
16728c2ecf20Sopenharmony_ci	u8	Mode,		/* 0: Analog Mode ; 1: Digital Mode */
16738c2ecf20Sopenharmony_ci	u8	IF_mode,	/* for Analog Mode, 0: zero IF; 1: low IF */
16748c2ecf20Sopenharmony_ci	u32	Bandwidth,	/* filter  channel bandwidth (6, 7, 8) */
16758c2ecf20Sopenharmony_ci	u32	IF_out,		/* Desired IF Out Frequency */
16768c2ecf20Sopenharmony_ci	u32	Fxtal,		/* XTAL Frequency */
16778c2ecf20Sopenharmony_ci	u8	AGC_Mode,	/* AGC Mode - Dual AGC: 0, Single AGC: 1 */
16788c2ecf20Sopenharmony_ci	u16	TOP,		/* 0: Dual AGC; Value: take over point */
16798c2ecf20Sopenharmony_ci	u16	IF_OUT_LOAD,	/* IF Out Load Resistor (200 / 300 Ohms) */
16808c2ecf20Sopenharmony_ci	u8	CLOCK_OUT,	/* 0: turn off clk out; 1: turn on clock out */
16818c2ecf20Sopenharmony_ci	u8	DIV_OUT,	/* 0: Div-1; 1: Div-4 */
16828c2ecf20Sopenharmony_ci	u8	CAPSELECT,	/* 0: disable On-Chip pulling cap; 1: enable */
16838c2ecf20Sopenharmony_ci	u8	EN_RSSI,	/* 0: disable RSSI; 1: enable RSSI */
16848c2ecf20Sopenharmony_ci
16858c2ecf20Sopenharmony_ci	/* Modulation Type; */
16868c2ecf20Sopenharmony_ci	/* 0 - Default;	1 - DVB-T; 2 - ATSC; 3 - QAM; 4 - Analog Cable */
16878c2ecf20Sopenharmony_ci	u8	Mod_Type,
16888c2ecf20Sopenharmony_ci
16898c2ecf20Sopenharmony_ci	/* Tracking Filter */
16908c2ecf20Sopenharmony_ci	/* 0 - Default; 1 - Off; 2 - Type C; 3 - Type C-H */
16918c2ecf20Sopenharmony_ci	u8	TF_Type
16928c2ecf20Sopenharmony_ci	)
16938c2ecf20Sopenharmony_ci{
16948c2ecf20Sopenharmony_ci	struct mxl5005s_state *state = fe->tuner_priv;
16958c2ecf20Sopenharmony_ci
16968c2ecf20Sopenharmony_ci	state->Mode = Mode;
16978c2ecf20Sopenharmony_ci	state->IF_Mode = IF_mode;
16988c2ecf20Sopenharmony_ci	state->Chan_Bandwidth = Bandwidth;
16998c2ecf20Sopenharmony_ci	state->IF_OUT = IF_out;
17008c2ecf20Sopenharmony_ci	state->Fxtal = Fxtal;
17018c2ecf20Sopenharmony_ci	state->AGC_Mode = AGC_Mode;
17028c2ecf20Sopenharmony_ci	state->TOP = TOP;
17038c2ecf20Sopenharmony_ci	state->IF_OUT_LOAD = IF_OUT_LOAD;
17048c2ecf20Sopenharmony_ci	state->CLOCK_OUT = CLOCK_OUT;
17058c2ecf20Sopenharmony_ci	state->DIV_OUT = DIV_OUT;
17068c2ecf20Sopenharmony_ci	state->CAPSELECT = CAPSELECT;
17078c2ecf20Sopenharmony_ci	state->EN_RSSI = EN_RSSI;
17088c2ecf20Sopenharmony_ci	state->Mod_Type = Mod_Type;
17098c2ecf20Sopenharmony_ci	state->TF_Type = TF_Type;
17108c2ecf20Sopenharmony_ci
17118c2ecf20Sopenharmony_ci	/* Initialize all the controls and registers */
17128c2ecf20Sopenharmony_ci	InitTunerControls(fe);
17138c2ecf20Sopenharmony_ci
17148c2ecf20Sopenharmony_ci	/* Synthesizer LO frequency calculation */
17158c2ecf20Sopenharmony_ci	MXL_SynthIFLO_Calc(fe);
17168c2ecf20Sopenharmony_ci
17178c2ecf20Sopenharmony_ci	return 0;
17188c2ecf20Sopenharmony_ci}
17198c2ecf20Sopenharmony_ci
17208c2ecf20Sopenharmony_cistatic void MXL_SynthIFLO_Calc(struct dvb_frontend *fe)
17218c2ecf20Sopenharmony_ci{
17228c2ecf20Sopenharmony_ci	struct mxl5005s_state *state = fe->tuner_priv;
17238c2ecf20Sopenharmony_ci	if (state->Mode == 1) /* Digital Mode */
17248c2ecf20Sopenharmony_ci		state->IF_LO = state->IF_OUT;
17258c2ecf20Sopenharmony_ci	else /* Analog Mode */ {
17268c2ecf20Sopenharmony_ci		if (state->IF_Mode == 0) /* Analog Zero IF mode */
17278c2ecf20Sopenharmony_ci			state->IF_LO = state->IF_OUT + 400000;
17288c2ecf20Sopenharmony_ci		else /* Analog Low IF mode */
17298c2ecf20Sopenharmony_ci			state->IF_LO = state->IF_OUT + state->Chan_Bandwidth/2;
17308c2ecf20Sopenharmony_ci	}
17318c2ecf20Sopenharmony_ci}
17328c2ecf20Sopenharmony_ci
17338c2ecf20Sopenharmony_cistatic void MXL_SynthRFTGLO_Calc(struct dvb_frontend *fe)
17348c2ecf20Sopenharmony_ci{
17358c2ecf20Sopenharmony_ci	struct mxl5005s_state *state = fe->tuner_priv;
17368c2ecf20Sopenharmony_ci
17378c2ecf20Sopenharmony_ci	if (state->Mode == 1) /* Digital Mode */ {
17388c2ecf20Sopenharmony_ci			/* remove 20.48MHz setting for 2.6.10 */
17398c2ecf20Sopenharmony_ci			state->RF_LO = state->RF_IN;
17408c2ecf20Sopenharmony_ci			/* change for 2.6.6 */
17418c2ecf20Sopenharmony_ci			state->TG_LO = state->RF_IN - 750000;
17428c2ecf20Sopenharmony_ci	} else /* Analog Mode */ {
17438c2ecf20Sopenharmony_ci		if (state->IF_Mode == 0) /* Analog Zero IF mode */ {
17448c2ecf20Sopenharmony_ci			state->RF_LO = state->RF_IN - 400000;
17458c2ecf20Sopenharmony_ci			state->TG_LO = state->RF_IN - 1750000;
17468c2ecf20Sopenharmony_ci		} else /* Analog Low IF mode */ {
17478c2ecf20Sopenharmony_ci			state->RF_LO = state->RF_IN - state->Chan_Bandwidth/2;
17488c2ecf20Sopenharmony_ci			state->TG_LO = state->RF_IN -
17498c2ecf20Sopenharmony_ci				state->Chan_Bandwidth + 500000;
17508c2ecf20Sopenharmony_ci		}
17518c2ecf20Sopenharmony_ci	}
17528c2ecf20Sopenharmony_ci}
17538c2ecf20Sopenharmony_ci
17548c2ecf20Sopenharmony_cistatic u16 MXL_OverwriteICDefault(struct dvb_frontend *fe)
17558c2ecf20Sopenharmony_ci{
17568c2ecf20Sopenharmony_ci	u16 status = 0;
17578c2ecf20Sopenharmony_ci
17588c2ecf20Sopenharmony_ci	status += MXL_ControlWrite(fe, OVERRIDE_1, 1);
17598c2ecf20Sopenharmony_ci	status += MXL_ControlWrite(fe, OVERRIDE_2, 1);
17608c2ecf20Sopenharmony_ci	status += MXL_ControlWrite(fe, OVERRIDE_3, 1);
17618c2ecf20Sopenharmony_ci	status += MXL_ControlWrite(fe, OVERRIDE_4, 1);
17628c2ecf20Sopenharmony_ci
17638c2ecf20Sopenharmony_ci	return status;
17648c2ecf20Sopenharmony_ci}
17658c2ecf20Sopenharmony_ci
17668c2ecf20Sopenharmony_cistatic u16 MXL_BlockInit(struct dvb_frontend *fe)
17678c2ecf20Sopenharmony_ci{
17688c2ecf20Sopenharmony_ci	struct mxl5005s_state *state = fe->tuner_priv;
17698c2ecf20Sopenharmony_ci	u16 status = 0;
17708c2ecf20Sopenharmony_ci
17718c2ecf20Sopenharmony_ci	status += MXL_OverwriteICDefault(fe);
17728c2ecf20Sopenharmony_ci
17738c2ecf20Sopenharmony_ci	/* Downconverter Control Dig Ana */
17748c2ecf20Sopenharmony_ci	status += MXL_ControlWrite(fe, DN_IQTN_AMP_CUT, state->Mode ? 1 : 0);
17758c2ecf20Sopenharmony_ci
17768c2ecf20Sopenharmony_ci	/* Filter Control  Dig  Ana */
17778c2ecf20Sopenharmony_ci	status += MXL_ControlWrite(fe, BB_MODE, state->Mode ? 0 : 1);
17788c2ecf20Sopenharmony_ci	status += MXL_ControlWrite(fe, BB_BUF, state->Mode ? 3 : 2);
17798c2ecf20Sopenharmony_ci	status += MXL_ControlWrite(fe, BB_BUF_OA, state->Mode ? 1 : 0);
17808c2ecf20Sopenharmony_ci	status += MXL_ControlWrite(fe, BB_IQSWAP, state->Mode ? 0 : 1);
17818c2ecf20Sopenharmony_ci	status += MXL_ControlWrite(fe, BB_INITSTATE_DLPF_TUNE, 0);
17828c2ecf20Sopenharmony_ci
17838c2ecf20Sopenharmony_ci	/* Initialize Low-Pass Filter */
17848c2ecf20Sopenharmony_ci	if (state->Mode) { /* Digital Mode */
17858c2ecf20Sopenharmony_ci		switch (state->Chan_Bandwidth) {
17868c2ecf20Sopenharmony_ci		case 8000000:
17878c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, BB_DLPF_BANDSEL, 0);
17888c2ecf20Sopenharmony_ci			break;
17898c2ecf20Sopenharmony_ci		case 7000000:
17908c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, BB_DLPF_BANDSEL, 2);
17918c2ecf20Sopenharmony_ci			break;
17928c2ecf20Sopenharmony_ci		case 6000000:
17938c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe,
17948c2ecf20Sopenharmony_ci					BB_DLPF_BANDSEL, 3);
17958c2ecf20Sopenharmony_ci			break;
17968c2ecf20Sopenharmony_ci		}
17978c2ecf20Sopenharmony_ci	} else { /* Analog Mode */
17988c2ecf20Sopenharmony_ci		switch (state->Chan_Bandwidth) {
17998c2ecf20Sopenharmony_ci		case 8000000:	/* Low Zero */
18008c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, BB_ALPF_BANDSELECT,
18018c2ecf20Sopenharmony_ci					(state->IF_Mode ? 0 : 3));
18028c2ecf20Sopenharmony_ci			break;
18038c2ecf20Sopenharmony_ci		case 7000000:
18048c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, BB_ALPF_BANDSELECT,
18058c2ecf20Sopenharmony_ci					(state->IF_Mode ? 1 : 4));
18068c2ecf20Sopenharmony_ci			break;
18078c2ecf20Sopenharmony_ci		case 6000000:
18088c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, BB_ALPF_BANDSELECT,
18098c2ecf20Sopenharmony_ci					(state->IF_Mode ? 2 : 5));
18108c2ecf20Sopenharmony_ci			break;
18118c2ecf20Sopenharmony_ci		}
18128c2ecf20Sopenharmony_ci	}
18138c2ecf20Sopenharmony_ci
18148c2ecf20Sopenharmony_ci	/* Charge Pump Control Dig  Ana */
18158c2ecf20Sopenharmony_ci	status += MXL_ControlWrite(fe, RFSYN_CHP_GAIN, state->Mode ? 5 : 8);
18168c2ecf20Sopenharmony_ci	status += MXL_ControlWrite(fe,
18178c2ecf20Sopenharmony_ci		RFSYN_EN_CHP_HIGAIN, state->Mode ? 1 : 1);
18188c2ecf20Sopenharmony_ci	status += MXL_ControlWrite(fe, EN_CHP_LIN_B, state->Mode ? 0 : 0);
18198c2ecf20Sopenharmony_ci
18208c2ecf20Sopenharmony_ci	/* AGC TOP Control */
18218c2ecf20Sopenharmony_ci	if (state->AGC_Mode == 0) /* Dual AGC */ {
18228c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, AGC_IF, 15);
18238c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, AGC_RF, 15);
18248c2ecf20Sopenharmony_ci	} else /*  Single AGC Mode Dig  Ana */
18258c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, AGC_RF, state->Mode ? 15 : 12);
18268c2ecf20Sopenharmony_ci
18278c2ecf20Sopenharmony_ci	if (state->TOP == 55) /* TOP == 5.5 */
18288c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, AGC_IF, 0x0);
18298c2ecf20Sopenharmony_ci
18308c2ecf20Sopenharmony_ci	if (state->TOP == 72) /* TOP == 7.2 */
18318c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, AGC_IF, 0x1);
18328c2ecf20Sopenharmony_ci
18338c2ecf20Sopenharmony_ci	if (state->TOP == 92) /* TOP == 9.2 */
18348c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, AGC_IF, 0x2);
18358c2ecf20Sopenharmony_ci
18368c2ecf20Sopenharmony_ci	if (state->TOP == 110) /* TOP == 11.0 */
18378c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, AGC_IF, 0x3);
18388c2ecf20Sopenharmony_ci
18398c2ecf20Sopenharmony_ci	if (state->TOP == 129) /* TOP == 12.9 */
18408c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, AGC_IF, 0x4);
18418c2ecf20Sopenharmony_ci
18428c2ecf20Sopenharmony_ci	if (state->TOP == 147) /* TOP == 14.7 */
18438c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, AGC_IF, 0x5);
18448c2ecf20Sopenharmony_ci
18458c2ecf20Sopenharmony_ci	if (state->TOP == 168) /* TOP == 16.8 */
18468c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, AGC_IF, 0x6);
18478c2ecf20Sopenharmony_ci
18488c2ecf20Sopenharmony_ci	if (state->TOP == 194) /* TOP == 19.4 */
18498c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, AGC_IF, 0x7);
18508c2ecf20Sopenharmony_ci
18518c2ecf20Sopenharmony_ci	if (state->TOP == 212) /* TOP == 21.2 */
18528c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, AGC_IF, 0x9);
18538c2ecf20Sopenharmony_ci
18548c2ecf20Sopenharmony_ci	if (state->TOP == 232) /* TOP == 23.2 */
18558c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, AGC_IF, 0xA);
18568c2ecf20Sopenharmony_ci
18578c2ecf20Sopenharmony_ci	if (state->TOP == 252) /* TOP == 25.2 */
18588c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, AGC_IF, 0xB);
18598c2ecf20Sopenharmony_ci
18608c2ecf20Sopenharmony_ci	if (state->TOP == 271) /* TOP == 27.1 */
18618c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, AGC_IF, 0xC);
18628c2ecf20Sopenharmony_ci
18638c2ecf20Sopenharmony_ci	if (state->TOP == 292) /* TOP == 29.2 */
18648c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, AGC_IF, 0xD);
18658c2ecf20Sopenharmony_ci
18668c2ecf20Sopenharmony_ci	if (state->TOP == 317) /* TOP == 31.7 */
18678c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, AGC_IF, 0xE);
18688c2ecf20Sopenharmony_ci
18698c2ecf20Sopenharmony_ci	if (state->TOP == 349) /* TOP == 34.9 */
18708c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, AGC_IF, 0xF);
18718c2ecf20Sopenharmony_ci
18728c2ecf20Sopenharmony_ci	/* IF Synthesizer Control */
18738c2ecf20Sopenharmony_ci	status += MXL_IFSynthInit(fe);
18748c2ecf20Sopenharmony_ci
18758c2ecf20Sopenharmony_ci	/* IF UpConverter Control */
18768c2ecf20Sopenharmony_ci	if (state->IF_OUT_LOAD == 200) {
18778c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, DRV_RES_SEL, 6);
18788c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, I_DRIVER, 2);
18798c2ecf20Sopenharmony_ci	}
18808c2ecf20Sopenharmony_ci	if (state->IF_OUT_LOAD == 300) {
18818c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, DRV_RES_SEL, 4);
18828c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, I_DRIVER, 1);
18838c2ecf20Sopenharmony_ci	}
18848c2ecf20Sopenharmony_ci
18858c2ecf20Sopenharmony_ci	/* Anti-Alias Filtering Control
18868c2ecf20Sopenharmony_ci	 * initialise Anti-Aliasing Filter
18878c2ecf20Sopenharmony_ci	 */
18888c2ecf20Sopenharmony_ci	if (state->Mode) { /* Digital Mode */
18898c2ecf20Sopenharmony_ci		if (state->IF_OUT >= 4000000UL && state->IF_OUT <= 6280000UL) {
18908c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, EN_AAF, 1);
18918c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, EN_3P, 1);
18928c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, EN_AUX_3P, 1);
18938c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, SEL_AAF_BAND, 0);
18948c2ecf20Sopenharmony_ci		}
18958c2ecf20Sopenharmony_ci		if ((state->IF_OUT == 36125000UL) ||
18968c2ecf20Sopenharmony_ci			(state->IF_OUT == 36150000UL)) {
18978c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, EN_AAF, 1);
18988c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, EN_3P, 1);
18998c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, EN_AUX_3P, 1);
19008c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, SEL_AAF_BAND, 1);
19018c2ecf20Sopenharmony_ci		}
19028c2ecf20Sopenharmony_ci		if (state->IF_OUT > 36150000UL) {
19038c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, EN_AAF, 0);
19048c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, EN_3P, 1);
19058c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, EN_AUX_3P, 1);
19068c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, SEL_AAF_BAND, 1);
19078c2ecf20Sopenharmony_ci		}
19088c2ecf20Sopenharmony_ci	} else { /* Analog Mode */
19098c2ecf20Sopenharmony_ci		if (state->IF_OUT >= 4000000UL && state->IF_OUT <= 5000000UL) {
19108c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, EN_AAF, 1);
19118c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, EN_3P, 1);
19128c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, EN_AUX_3P, 1);
19138c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, SEL_AAF_BAND, 0);
19148c2ecf20Sopenharmony_ci		}
19158c2ecf20Sopenharmony_ci		if (state->IF_OUT > 5000000UL) {
19168c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, EN_AAF, 0);
19178c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, EN_3P, 0);
19188c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, EN_AUX_3P, 0);
19198c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, SEL_AAF_BAND, 0);
19208c2ecf20Sopenharmony_ci		}
19218c2ecf20Sopenharmony_ci	}
19228c2ecf20Sopenharmony_ci
19238c2ecf20Sopenharmony_ci	/* Demod Clock Out */
19248c2ecf20Sopenharmony_ci	if (state->CLOCK_OUT)
19258c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, SEQ_ENCLK16_CLK_OUT, 1);
19268c2ecf20Sopenharmony_ci	else
19278c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, SEQ_ENCLK16_CLK_OUT, 0);
19288c2ecf20Sopenharmony_ci
19298c2ecf20Sopenharmony_ci	if (state->DIV_OUT == 1)
19308c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, SEQ_SEL4_16B, 1);
19318c2ecf20Sopenharmony_ci	if (state->DIV_OUT == 0)
19328c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, SEQ_SEL4_16B, 0);
19338c2ecf20Sopenharmony_ci
19348c2ecf20Sopenharmony_ci	/* Crystal Control */
19358c2ecf20Sopenharmony_ci	if (state->CAPSELECT)
19368c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, XTAL_CAPSELECT, 1);
19378c2ecf20Sopenharmony_ci	else
19388c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, XTAL_CAPSELECT, 0);
19398c2ecf20Sopenharmony_ci
19408c2ecf20Sopenharmony_ci	if (state->Fxtal >= 12000000UL && state->Fxtal <= 16000000UL)
19418c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, IF_SEL_DBL, 1);
19428c2ecf20Sopenharmony_ci	if (state->Fxtal > 16000000UL && state->Fxtal <= 32000000UL)
19438c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, IF_SEL_DBL, 0);
19448c2ecf20Sopenharmony_ci
19458c2ecf20Sopenharmony_ci	if (state->Fxtal >= 12000000UL && state->Fxtal <= 22000000UL)
19468c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, RFSYN_R_DIV, 3);
19478c2ecf20Sopenharmony_ci	if (state->Fxtal > 22000000UL && state->Fxtal <= 32000000UL)
19488c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, RFSYN_R_DIV, 0);
19498c2ecf20Sopenharmony_ci
19508c2ecf20Sopenharmony_ci	/* Misc Controls */
19518c2ecf20Sopenharmony_ci	if (state->Mode == 0 && state->IF_Mode == 1) /* Analog LowIF mode */
19528c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, SEQ_EXTIQFSMPULSE, 0);
19538c2ecf20Sopenharmony_ci	else
19548c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, SEQ_EXTIQFSMPULSE, 1);
19558c2ecf20Sopenharmony_ci
19568c2ecf20Sopenharmony_ci	/* status += MXL_ControlRead(fe, IF_DIVVAL, &IF_DIVVAL_Val); */
19578c2ecf20Sopenharmony_ci
19588c2ecf20Sopenharmony_ci	/* Set TG_R_DIV */
19598c2ecf20Sopenharmony_ci	status += MXL_ControlWrite(fe, TG_R_DIV,
19608c2ecf20Sopenharmony_ci		MXL_Ceiling(state->Fxtal, 1000000));
19618c2ecf20Sopenharmony_ci
19628c2ecf20Sopenharmony_ci	/* Apply Default value to BB_INITSTATE_DLPF_TUNE */
19638c2ecf20Sopenharmony_ci
19648c2ecf20Sopenharmony_ci	/* RSSI Control */
19658c2ecf20Sopenharmony_ci	if (state->EN_RSSI) {
19668c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, SEQ_EXTSYNTHCALIF, 1);
19678c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, SEQ_EXTDCCAL, 1);
19688c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, AGC_EN_RSSI, 1);
19698c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, RFA_ENCLKRFAGC, 1);
19708c2ecf20Sopenharmony_ci
19718c2ecf20Sopenharmony_ci		/* RSSI reference point */
19728c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, RFA_RSSI_REF, 2);
19738c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, RFA_RSSI_REFH, 3);
19748c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, RFA_RSSI_REFL, 1);
19758c2ecf20Sopenharmony_ci
19768c2ecf20Sopenharmony_ci		/* TOP point */
19778c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, RFA_FLR, 0);
19788c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, RFA_CEIL, 12);
19798c2ecf20Sopenharmony_ci	}
19808c2ecf20Sopenharmony_ci
19818c2ecf20Sopenharmony_ci	/* Modulation type bit settings
19828c2ecf20Sopenharmony_ci	 * Override the control values preset
19838c2ecf20Sopenharmony_ci	 */
19848c2ecf20Sopenharmony_ci	if (state->Mod_Type == MXL_DVBT) /* DVB-T Mode */ {
19858c2ecf20Sopenharmony_ci		state->AGC_Mode = 1; /* Single AGC Mode */
19868c2ecf20Sopenharmony_ci
19878c2ecf20Sopenharmony_ci		/* Enable RSSI */
19888c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, SEQ_EXTSYNTHCALIF, 1);
19898c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, SEQ_EXTDCCAL, 1);
19908c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, AGC_EN_RSSI, 1);
19918c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, RFA_ENCLKRFAGC, 1);
19928c2ecf20Sopenharmony_ci
19938c2ecf20Sopenharmony_ci		/* RSSI reference point */
19948c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, RFA_RSSI_REF, 3);
19958c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, RFA_RSSI_REFH, 5);
19968c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, RFA_RSSI_REFL, 1);
19978c2ecf20Sopenharmony_ci
19988c2ecf20Sopenharmony_ci		/* TOP point */
19998c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, RFA_FLR, 2);
20008c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, RFA_CEIL, 13);
20018c2ecf20Sopenharmony_ci		if (state->IF_OUT <= 6280000UL)	/* Low IF */
20028c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, BB_IQSWAP, 0);
20038c2ecf20Sopenharmony_ci		else /* High IF */
20048c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, BB_IQSWAP, 1);
20058c2ecf20Sopenharmony_ci
20068c2ecf20Sopenharmony_ci	}
20078c2ecf20Sopenharmony_ci	if (state->Mod_Type == MXL_ATSC) /* ATSC Mode */ {
20088c2ecf20Sopenharmony_ci		state->AGC_Mode = 1;	/* Single AGC Mode */
20098c2ecf20Sopenharmony_ci
20108c2ecf20Sopenharmony_ci		/* Enable RSSI */
20118c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, SEQ_EXTSYNTHCALIF, 1);
20128c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, SEQ_EXTDCCAL, 1);
20138c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, AGC_EN_RSSI, 1);
20148c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, RFA_ENCLKRFAGC, 1);
20158c2ecf20Sopenharmony_ci
20168c2ecf20Sopenharmony_ci		/* RSSI reference point */
20178c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, RFA_RSSI_REF, 2);
20188c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, RFA_RSSI_REFH, 4);
20198c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, RFA_RSSI_REFL, 1);
20208c2ecf20Sopenharmony_ci
20218c2ecf20Sopenharmony_ci		/* TOP point */
20228c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, RFA_FLR, 2);
20238c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, RFA_CEIL, 13);
20248c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, BB_INITSTATE_DLPF_TUNE, 1);
20258c2ecf20Sopenharmony_ci		/* Low Zero */
20268c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, RFSYN_CHP_GAIN, 5);
20278c2ecf20Sopenharmony_ci
20288c2ecf20Sopenharmony_ci		if (state->IF_OUT <= 6280000UL)	/* Low IF */
20298c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, BB_IQSWAP, 0);
20308c2ecf20Sopenharmony_ci		else /* High IF */
20318c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, BB_IQSWAP, 1);
20328c2ecf20Sopenharmony_ci	}
20338c2ecf20Sopenharmony_ci	if (state->Mod_Type == MXL_QAM) /* QAM Mode */ {
20348c2ecf20Sopenharmony_ci		state->Mode = MXL_DIGITAL_MODE;
20358c2ecf20Sopenharmony_ci
20368c2ecf20Sopenharmony_ci		/* state->AGC_Mode = 1; */ /* Single AGC Mode */
20378c2ecf20Sopenharmony_ci
20388c2ecf20Sopenharmony_ci		/* Disable RSSI */	/* change here for v2.6.5 */
20398c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, SEQ_EXTSYNTHCALIF, 1);
20408c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, SEQ_EXTDCCAL, 1);
20418c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, AGC_EN_RSSI, 0);
20428c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, RFA_ENCLKRFAGC, 1);
20438c2ecf20Sopenharmony_ci
20448c2ecf20Sopenharmony_ci		/* RSSI reference point */
20458c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, RFA_RSSI_REFH, 5);
20468c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, RFA_RSSI_REF, 3);
20478c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, RFA_RSSI_REFL, 2);
20488c2ecf20Sopenharmony_ci		/* change here for v2.6.5 */
20498c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, RFSYN_CHP_GAIN, 3);
20508c2ecf20Sopenharmony_ci
20518c2ecf20Sopenharmony_ci		if (state->IF_OUT <= 6280000UL)	/* Low IF */
20528c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, BB_IQSWAP, 0);
20538c2ecf20Sopenharmony_ci		else /* High IF */
20548c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, BB_IQSWAP, 1);
20558c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, RFSYN_CHP_GAIN, 2);
20568c2ecf20Sopenharmony_ci
20578c2ecf20Sopenharmony_ci	}
20588c2ecf20Sopenharmony_ci	if (state->Mod_Type == MXL_ANALOG_CABLE) {
20598c2ecf20Sopenharmony_ci		/* Analog Cable Mode */
20608c2ecf20Sopenharmony_ci		/* state->Mode = MXL_DIGITAL_MODE; */
20618c2ecf20Sopenharmony_ci
20628c2ecf20Sopenharmony_ci		state->AGC_Mode = 1; /* Single AGC Mode */
20638c2ecf20Sopenharmony_ci
20648c2ecf20Sopenharmony_ci		/* Disable RSSI */
20658c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, SEQ_EXTSYNTHCALIF, 1);
20668c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, SEQ_EXTDCCAL, 1);
20678c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, AGC_EN_RSSI, 0);
20688c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, RFA_ENCLKRFAGC, 1);
20698c2ecf20Sopenharmony_ci		/* change for 2.6.3 */
20708c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, AGC_IF, 1);
20718c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, AGC_RF, 15);
20728c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, BB_IQSWAP, 1);
20738c2ecf20Sopenharmony_ci	}
20748c2ecf20Sopenharmony_ci
20758c2ecf20Sopenharmony_ci	if (state->Mod_Type == MXL_ANALOG_OTA) {
20768c2ecf20Sopenharmony_ci		/* Analog OTA Terrestrial mode add for 2.6.7 */
20778c2ecf20Sopenharmony_ci		/* state->Mode = MXL_ANALOG_MODE; */
20788c2ecf20Sopenharmony_ci
20798c2ecf20Sopenharmony_ci		/* Enable RSSI */
20808c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, SEQ_EXTSYNTHCALIF, 1);
20818c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, SEQ_EXTDCCAL, 1);
20828c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, AGC_EN_RSSI, 1);
20838c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, RFA_ENCLKRFAGC, 1);
20848c2ecf20Sopenharmony_ci
20858c2ecf20Sopenharmony_ci		/* RSSI reference point */
20868c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, RFA_RSSI_REFH, 5);
20878c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, RFA_RSSI_REF, 3);
20888c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, RFA_RSSI_REFL, 2);
20898c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, RFSYN_CHP_GAIN, 3);
20908c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, BB_IQSWAP, 1);
20918c2ecf20Sopenharmony_ci	}
20928c2ecf20Sopenharmony_ci
20938c2ecf20Sopenharmony_ci	/* RSSI disable */
20948c2ecf20Sopenharmony_ci	if (state->EN_RSSI == 0) {
20958c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, SEQ_EXTSYNTHCALIF, 1);
20968c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, SEQ_EXTDCCAL, 1);
20978c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, AGC_EN_RSSI, 0);
20988c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, RFA_ENCLKRFAGC, 1);
20998c2ecf20Sopenharmony_ci	}
21008c2ecf20Sopenharmony_ci
21018c2ecf20Sopenharmony_ci	return status;
21028c2ecf20Sopenharmony_ci}
21038c2ecf20Sopenharmony_ci
21048c2ecf20Sopenharmony_cistatic u16 MXL_IFSynthInit(struct dvb_frontend *fe)
21058c2ecf20Sopenharmony_ci{
21068c2ecf20Sopenharmony_ci	struct mxl5005s_state *state = fe->tuner_priv;
21078c2ecf20Sopenharmony_ci	u16 status = 0 ;
21088c2ecf20Sopenharmony_ci	u32	Fref = 0 ;
21098c2ecf20Sopenharmony_ci	u32	Kdbl, intModVal ;
21108c2ecf20Sopenharmony_ci	u32	fracModVal ;
21118c2ecf20Sopenharmony_ci	Kdbl = 2 ;
21128c2ecf20Sopenharmony_ci
21138c2ecf20Sopenharmony_ci	if (state->Fxtal >= 12000000UL && state->Fxtal <= 16000000UL)
21148c2ecf20Sopenharmony_ci		Kdbl = 2 ;
21158c2ecf20Sopenharmony_ci	if (state->Fxtal > 16000000UL && state->Fxtal <= 32000000UL)
21168c2ecf20Sopenharmony_ci		Kdbl = 1 ;
21178c2ecf20Sopenharmony_ci
21188c2ecf20Sopenharmony_ci	/* IF Synthesizer Control */
21198c2ecf20Sopenharmony_ci	if (state->Mode == 0 && state->IF_Mode == 1) /* Analog Low IF mode */ {
21208c2ecf20Sopenharmony_ci		if (state->IF_LO == 41000000UL) {
21218c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, IF_DIVVAL,   0x08);
21228c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x0C);
21238c2ecf20Sopenharmony_ci			Fref = 328000000UL ;
21248c2ecf20Sopenharmony_ci		}
21258c2ecf20Sopenharmony_ci		if (state->IF_LO == 47000000UL) {
21268c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, IF_DIVVAL,   0x08);
21278c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08);
21288c2ecf20Sopenharmony_ci			Fref = 376000000UL ;
21298c2ecf20Sopenharmony_ci		}
21308c2ecf20Sopenharmony_ci		if (state->IF_LO == 54000000UL) {
21318c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, IF_DIVVAL,   0x10);
21328c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x0C);
21338c2ecf20Sopenharmony_ci			Fref = 324000000UL ;
21348c2ecf20Sopenharmony_ci		}
21358c2ecf20Sopenharmony_ci		if (state->IF_LO == 60000000UL) {
21368c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, IF_DIVVAL,   0x10);
21378c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08);
21388c2ecf20Sopenharmony_ci			Fref = 360000000UL ;
21398c2ecf20Sopenharmony_ci		}
21408c2ecf20Sopenharmony_ci		if (state->IF_LO == 39250000UL) {
21418c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, IF_DIVVAL,   0x08);
21428c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x0C);
21438c2ecf20Sopenharmony_ci			Fref = 314000000UL ;
21448c2ecf20Sopenharmony_ci		}
21458c2ecf20Sopenharmony_ci		if (state->IF_LO == 39650000UL) {
21468c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, IF_DIVVAL,   0x08);
21478c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x0C);
21488c2ecf20Sopenharmony_ci			Fref = 317200000UL ;
21498c2ecf20Sopenharmony_ci		}
21508c2ecf20Sopenharmony_ci		if (state->IF_LO == 40150000UL) {
21518c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, IF_DIVVAL,   0x08);
21528c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x0C);
21538c2ecf20Sopenharmony_ci			Fref = 321200000UL ;
21548c2ecf20Sopenharmony_ci		}
21558c2ecf20Sopenharmony_ci		if (state->IF_LO == 40650000UL) {
21568c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, IF_DIVVAL,   0x08);
21578c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x0C);
21588c2ecf20Sopenharmony_ci			Fref = 325200000UL ;
21598c2ecf20Sopenharmony_ci		}
21608c2ecf20Sopenharmony_ci	}
21618c2ecf20Sopenharmony_ci
21628c2ecf20Sopenharmony_ci	if (state->Mode || (state->Mode == 0 && state->IF_Mode == 0)) {
21638c2ecf20Sopenharmony_ci		if (state->IF_LO == 57000000UL) {
21648c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, IF_DIVVAL,   0x10);
21658c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08);
21668c2ecf20Sopenharmony_ci			Fref = 342000000UL ;
21678c2ecf20Sopenharmony_ci		}
21688c2ecf20Sopenharmony_ci		if (state->IF_LO == 44000000UL) {
21698c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, IF_DIVVAL,   0x08);
21708c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08);
21718c2ecf20Sopenharmony_ci			Fref = 352000000UL ;
21728c2ecf20Sopenharmony_ci		}
21738c2ecf20Sopenharmony_ci		if (state->IF_LO == 43750000UL) {
21748c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, IF_DIVVAL,   0x08);
21758c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08);
21768c2ecf20Sopenharmony_ci			Fref = 350000000UL ;
21778c2ecf20Sopenharmony_ci		}
21788c2ecf20Sopenharmony_ci		if (state->IF_LO == 36650000UL) {
21798c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, IF_DIVVAL,   0x04);
21808c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08);
21818c2ecf20Sopenharmony_ci			Fref = 366500000UL ;
21828c2ecf20Sopenharmony_ci		}
21838c2ecf20Sopenharmony_ci		if (state->IF_LO == 36150000UL) {
21848c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, IF_DIVVAL,   0x04);
21858c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08);
21868c2ecf20Sopenharmony_ci			Fref = 361500000UL ;
21878c2ecf20Sopenharmony_ci		}
21888c2ecf20Sopenharmony_ci		if (state->IF_LO == 36000000UL) {
21898c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, IF_DIVVAL,   0x04);
21908c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08);
21918c2ecf20Sopenharmony_ci			Fref = 360000000UL ;
21928c2ecf20Sopenharmony_ci		}
21938c2ecf20Sopenharmony_ci		if (state->IF_LO == 35250000UL) {
21948c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, IF_DIVVAL,   0x04);
21958c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08);
21968c2ecf20Sopenharmony_ci			Fref = 352500000UL ;
21978c2ecf20Sopenharmony_ci		}
21988c2ecf20Sopenharmony_ci		if (state->IF_LO == 34750000UL) {
21998c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, IF_DIVVAL,   0x04);
22008c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08);
22018c2ecf20Sopenharmony_ci			Fref = 347500000UL ;
22028c2ecf20Sopenharmony_ci		}
22038c2ecf20Sopenharmony_ci		if (state->IF_LO == 6280000UL) {
22048c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, IF_DIVVAL,   0x07);
22058c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08);
22068c2ecf20Sopenharmony_ci			Fref = 376800000UL ;
22078c2ecf20Sopenharmony_ci		}
22088c2ecf20Sopenharmony_ci		if (state->IF_LO == 5000000UL) {
22098c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, IF_DIVVAL,   0x09);
22108c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08);
22118c2ecf20Sopenharmony_ci			Fref = 360000000UL ;
22128c2ecf20Sopenharmony_ci		}
22138c2ecf20Sopenharmony_ci		if (state->IF_LO == 4500000UL) {
22148c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, IF_DIVVAL,   0x06);
22158c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08);
22168c2ecf20Sopenharmony_ci			Fref = 360000000UL ;
22178c2ecf20Sopenharmony_ci		}
22188c2ecf20Sopenharmony_ci		if (state->IF_LO == 4570000UL) {
22198c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, IF_DIVVAL,   0x06);
22208c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08);
22218c2ecf20Sopenharmony_ci			Fref = 365600000UL ;
22228c2ecf20Sopenharmony_ci		}
22238c2ecf20Sopenharmony_ci		if (state->IF_LO == 4000000UL) {
22248c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, IF_DIVVAL,   0x05);
22258c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08);
22268c2ecf20Sopenharmony_ci			Fref = 360000000UL ;
22278c2ecf20Sopenharmony_ci		}
22288c2ecf20Sopenharmony_ci		if (state->IF_LO == 57400000UL) {
22298c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, IF_DIVVAL,   0x10);
22308c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08);
22318c2ecf20Sopenharmony_ci			Fref = 344400000UL ;
22328c2ecf20Sopenharmony_ci		}
22338c2ecf20Sopenharmony_ci		if (state->IF_LO == 44400000UL) {
22348c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, IF_DIVVAL,   0x08);
22358c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08);
22368c2ecf20Sopenharmony_ci			Fref = 355200000UL ;
22378c2ecf20Sopenharmony_ci		}
22388c2ecf20Sopenharmony_ci		if (state->IF_LO == 44150000UL) {
22398c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, IF_DIVVAL,   0x08);
22408c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08);
22418c2ecf20Sopenharmony_ci			Fref = 353200000UL ;
22428c2ecf20Sopenharmony_ci		}
22438c2ecf20Sopenharmony_ci		if (state->IF_LO == 37050000UL) {
22448c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, IF_DIVVAL,   0x04);
22458c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08);
22468c2ecf20Sopenharmony_ci			Fref = 370500000UL ;
22478c2ecf20Sopenharmony_ci		}
22488c2ecf20Sopenharmony_ci		if (state->IF_LO == 36550000UL) {
22498c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, IF_DIVVAL,   0x04);
22508c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08);
22518c2ecf20Sopenharmony_ci			Fref = 365500000UL ;
22528c2ecf20Sopenharmony_ci		}
22538c2ecf20Sopenharmony_ci		if (state->IF_LO == 36125000UL) {
22548c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, IF_DIVVAL,   0x04);
22558c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08);
22568c2ecf20Sopenharmony_ci			Fref = 361250000UL ;
22578c2ecf20Sopenharmony_ci		}
22588c2ecf20Sopenharmony_ci		if (state->IF_LO == 6000000UL) {
22598c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, IF_DIVVAL,   0x07);
22608c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08);
22618c2ecf20Sopenharmony_ci			Fref = 360000000UL ;
22628c2ecf20Sopenharmony_ci		}
22638c2ecf20Sopenharmony_ci		if (state->IF_LO == 5400000UL) {
22648c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, IF_DIVVAL,   0x07);
22658c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x0C);
22668c2ecf20Sopenharmony_ci			Fref = 324000000UL ;
22678c2ecf20Sopenharmony_ci		}
22688c2ecf20Sopenharmony_ci		if (state->IF_LO == 5380000UL) {
22698c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, IF_DIVVAL,   0x07);
22708c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x0C);
22718c2ecf20Sopenharmony_ci			Fref = 322800000UL ;
22728c2ecf20Sopenharmony_ci		}
22738c2ecf20Sopenharmony_ci		if (state->IF_LO == 5200000UL) {
22748c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, IF_DIVVAL,   0x09);
22758c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08);
22768c2ecf20Sopenharmony_ci			Fref = 374400000UL ;
22778c2ecf20Sopenharmony_ci		}
22788c2ecf20Sopenharmony_ci		if (state->IF_LO == 4900000UL) {
22798c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, IF_DIVVAL,   0x09);
22808c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08);
22818c2ecf20Sopenharmony_ci			Fref = 352800000UL ;
22828c2ecf20Sopenharmony_ci		}
22838c2ecf20Sopenharmony_ci		if (state->IF_LO == 4400000UL) {
22848c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, IF_DIVVAL,   0x06);
22858c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08);
22868c2ecf20Sopenharmony_ci			Fref = 352000000UL ;
22878c2ecf20Sopenharmony_ci		}
22888c2ecf20Sopenharmony_ci		if (state->IF_LO == 4063000UL)  /* add for 2.6.8 */ {
22898c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, IF_DIVVAL,   0x05);
22908c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08);
22918c2ecf20Sopenharmony_ci			Fref = 365670000UL ;
22928c2ecf20Sopenharmony_ci		}
22938c2ecf20Sopenharmony_ci	}
22948c2ecf20Sopenharmony_ci	/* CHCAL_INT_MOD_IF */
22958c2ecf20Sopenharmony_ci	/* CHCAL_FRAC_MOD_IF */
22968c2ecf20Sopenharmony_ci	intModVal = Fref / (state->Fxtal * Kdbl/2);
22978c2ecf20Sopenharmony_ci	status += MXL_ControlWrite(fe, CHCAL_INT_MOD_IF, intModVal);
22988c2ecf20Sopenharmony_ci
22998c2ecf20Sopenharmony_ci	fracModVal = (2<<15)*(Fref/1000 - (state->Fxtal/1000 * Kdbl/2) *
23008c2ecf20Sopenharmony_ci		intModVal);
23018c2ecf20Sopenharmony_ci
23028c2ecf20Sopenharmony_ci	fracModVal = fracModVal / ((state->Fxtal * Kdbl/2)/1000);
23038c2ecf20Sopenharmony_ci	status += MXL_ControlWrite(fe, CHCAL_FRAC_MOD_IF, fracModVal);
23048c2ecf20Sopenharmony_ci
23058c2ecf20Sopenharmony_ci	return status ;
23068c2ecf20Sopenharmony_ci}
23078c2ecf20Sopenharmony_ci
23088c2ecf20Sopenharmony_cistatic u16 MXL_TuneRF(struct dvb_frontend *fe, u32 RF_Freq)
23098c2ecf20Sopenharmony_ci{
23108c2ecf20Sopenharmony_ci	struct mxl5005s_state *state = fe->tuner_priv;
23118c2ecf20Sopenharmony_ci	u16 status = 0;
23128c2ecf20Sopenharmony_ci	u32 divider_val, E3, E4, E5, E5A;
23138c2ecf20Sopenharmony_ci	u32 Fmax, Fmin, FmaxBin, FminBin;
23148c2ecf20Sopenharmony_ci	u32 Kdbl_RF = 2;
23158c2ecf20Sopenharmony_ci	u32 tg_divval;
23168c2ecf20Sopenharmony_ci	u32 tg_lo;
23178c2ecf20Sopenharmony_ci
23188c2ecf20Sopenharmony_ci	u32 Fref_TG;
23198c2ecf20Sopenharmony_ci	u32 Fvco;
23208c2ecf20Sopenharmony_ci
23218c2ecf20Sopenharmony_ci	state->RF_IN = RF_Freq;
23228c2ecf20Sopenharmony_ci
23238c2ecf20Sopenharmony_ci	MXL_SynthRFTGLO_Calc(fe);
23248c2ecf20Sopenharmony_ci
23258c2ecf20Sopenharmony_ci	if (state->Fxtal >= 12000000UL && state->Fxtal <= 22000000UL)
23268c2ecf20Sopenharmony_ci		Kdbl_RF = 2;
23278c2ecf20Sopenharmony_ci	if (state->Fxtal > 22000000 && state->Fxtal <= 32000000)
23288c2ecf20Sopenharmony_ci		Kdbl_RF = 1;
23298c2ecf20Sopenharmony_ci
23308c2ecf20Sopenharmony_ci	/* Downconverter Controls
23318c2ecf20Sopenharmony_ci	 * Look-Up Table Implementation for:
23328c2ecf20Sopenharmony_ci	 *	DN_POLY
23338c2ecf20Sopenharmony_ci	 *	DN_RFGAIN
23348c2ecf20Sopenharmony_ci	 *	DN_CAP_RFLPF
23358c2ecf20Sopenharmony_ci	 *	DN_EN_VHFUHFBAR
23368c2ecf20Sopenharmony_ci	 *	DN_GAIN_ADJUST
23378c2ecf20Sopenharmony_ci	 *  Change the boundary reference from RF_IN to RF_LO
23388c2ecf20Sopenharmony_ci	 */
23398c2ecf20Sopenharmony_ci	if (state->RF_LO < 40000000UL)
23408c2ecf20Sopenharmony_ci		return -1;
23418c2ecf20Sopenharmony_ci
23428c2ecf20Sopenharmony_ci	if (state->RF_LO >= 40000000UL && state->RF_LO <= 75000000UL) {
23438c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, DN_POLY,              2);
23448c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, DN_RFGAIN,            3);
23458c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, DN_CAP_RFLPF,         423);
23468c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, DN_EN_VHFUHFBAR,      1);
23478c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, DN_GAIN_ADJUST,       1);
23488c2ecf20Sopenharmony_ci	}
23498c2ecf20Sopenharmony_ci	if (state->RF_LO > 75000000UL && state->RF_LO <= 100000000UL) {
23508c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, DN_POLY,              3);
23518c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, DN_RFGAIN,            3);
23528c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, DN_CAP_RFLPF,         222);
23538c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, DN_EN_VHFUHFBAR,      1);
23548c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, DN_GAIN_ADJUST,       1);
23558c2ecf20Sopenharmony_ci	}
23568c2ecf20Sopenharmony_ci	if (state->RF_LO > 100000000UL && state->RF_LO <= 150000000UL) {
23578c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, DN_POLY,              3);
23588c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, DN_RFGAIN,            3);
23598c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, DN_CAP_RFLPF,         147);
23608c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, DN_EN_VHFUHFBAR,      1);
23618c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, DN_GAIN_ADJUST,       2);
23628c2ecf20Sopenharmony_ci	}
23638c2ecf20Sopenharmony_ci	if (state->RF_LO > 150000000UL && state->RF_LO <= 200000000UL) {
23648c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, DN_POLY,              3);
23658c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, DN_RFGAIN,            3);
23668c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, DN_CAP_RFLPF,         9);
23678c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, DN_EN_VHFUHFBAR,      1);
23688c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, DN_GAIN_ADJUST,       2);
23698c2ecf20Sopenharmony_ci	}
23708c2ecf20Sopenharmony_ci	if (state->RF_LO > 200000000UL && state->RF_LO <= 300000000UL) {
23718c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, DN_POLY,              3);
23728c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, DN_RFGAIN,            3);
23738c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, DN_CAP_RFLPF,         0);
23748c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, DN_EN_VHFUHFBAR,      1);
23758c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, DN_GAIN_ADJUST,       3);
23768c2ecf20Sopenharmony_ci	}
23778c2ecf20Sopenharmony_ci	if (state->RF_LO > 300000000UL && state->RF_LO <= 650000000UL) {
23788c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, DN_POLY,              3);
23798c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, DN_RFGAIN,            1);
23808c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, DN_CAP_RFLPF,         0);
23818c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, DN_EN_VHFUHFBAR,      0);
23828c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, DN_GAIN_ADJUST,       3);
23838c2ecf20Sopenharmony_ci	}
23848c2ecf20Sopenharmony_ci	if (state->RF_LO > 650000000UL && state->RF_LO <= 900000000UL) {
23858c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, DN_POLY,              3);
23868c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, DN_RFGAIN,            2);
23878c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, DN_CAP_RFLPF,         0);
23888c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, DN_EN_VHFUHFBAR,      0);
23898c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, DN_GAIN_ADJUST,       3);
23908c2ecf20Sopenharmony_ci	}
23918c2ecf20Sopenharmony_ci	if (state->RF_LO > 900000000UL)
23928c2ecf20Sopenharmony_ci		return -1;
23938c2ecf20Sopenharmony_ci
23948c2ecf20Sopenharmony_ci	/*	DN_IQTNBUF_AMP */
23958c2ecf20Sopenharmony_ci	/*	DN_IQTNGNBFBIAS_BST */
23968c2ecf20Sopenharmony_ci	if (state->RF_LO >= 40000000UL && state->RF_LO <= 75000000UL) {
23978c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, DN_IQTNBUF_AMP,       1);
23988c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, DN_IQTNGNBFBIAS_BST,  0);
23998c2ecf20Sopenharmony_ci	}
24008c2ecf20Sopenharmony_ci	if (state->RF_LO > 75000000UL && state->RF_LO <= 100000000UL) {
24018c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, DN_IQTNBUF_AMP,       1);
24028c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, DN_IQTNGNBFBIAS_BST,  0);
24038c2ecf20Sopenharmony_ci	}
24048c2ecf20Sopenharmony_ci	if (state->RF_LO > 100000000UL && state->RF_LO <= 150000000UL) {
24058c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, DN_IQTNBUF_AMP,       1);
24068c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, DN_IQTNGNBFBIAS_BST,  0);
24078c2ecf20Sopenharmony_ci	}
24088c2ecf20Sopenharmony_ci	if (state->RF_LO > 150000000UL && state->RF_LO <= 200000000UL) {
24098c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, DN_IQTNBUF_AMP,       1);
24108c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, DN_IQTNGNBFBIAS_BST,  0);
24118c2ecf20Sopenharmony_ci	}
24128c2ecf20Sopenharmony_ci	if (state->RF_LO > 200000000UL && state->RF_LO <= 300000000UL) {
24138c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, DN_IQTNBUF_AMP,       1);
24148c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, DN_IQTNGNBFBIAS_BST,  0);
24158c2ecf20Sopenharmony_ci	}
24168c2ecf20Sopenharmony_ci	if (state->RF_LO > 300000000UL && state->RF_LO <= 400000000UL) {
24178c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, DN_IQTNBUF_AMP,       1);
24188c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, DN_IQTNGNBFBIAS_BST,  0);
24198c2ecf20Sopenharmony_ci	}
24208c2ecf20Sopenharmony_ci	if (state->RF_LO > 400000000UL && state->RF_LO <= 450000000UL) {
24218c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, DN_IQTNBUF_AMP,       1);
24228c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, DN_IQTNGNBFBIAS_BST,  0);
24238c2ecf20Sopenharmony_ci	}
24248c2ecf20Sopenharmony_ci	if (state->RF_LO > 450000000UL && state->RF_LO <= 500000000UL) {
24258c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, DN_IQTNBUF_AMP,       1);
24268c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, DN_IQTNGNBFBIAS_BST,  0);
24278c2ecf20Sopenharmony_ci	}
24288c2ecf20Sopenharmony_ci	if (state->RF_LO > 500000000UL && state->RF_LO <= 550000000UL) {
24298c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, DN_IQTNBUF_AMP,       1);
24308c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, DN_IQTNGNBFBIAS_BST,  0);
24318c2ecf20Sopenharmony_ci	}
24328c2ecf20Sopenharmony_ci	if (state->RF_LO > 550000000UL && state->RF_LO <= 600000000UL) {
24338c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, DN_IQTNBUF_AMP,       1);
24348c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, DN_IQTNGNBFBIAS_BST,  0);
24358c2ecf20Sopenharmony_ci	}
24368c2ecf20Sopenharmony_ci	if (state->RF_LO > 600000000UL && state->RF_LO <= 650000000UL) {
24378c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, DN_IQTNBUF_AMP,       1);
24388c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, DN_IQTNGNBFBIAS_BST,  0);
24398c2ecf20Sopenharmony_ci	}
24408c2ecf20Sopenharmony_ci	if (state->RF_LO > 650000000UL && state->RF_LO <= 700000000UL) {
24418c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, DN_IQTNBUF_AMP,       1);
24428c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, DN_IQTNGNBFBIAS_BST,  0);
24438c2ecf20Sopenharmony_ci	}
24448c2ecf20Sopenharmony_ci	if (state->RF_LO > 700000000UL && state->RF_LO <= 750000000UL) {
24458c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, DN_IQTNBUF_AMP,       1);
24468c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, DN_IQTNGNBFBIAS_BST,  0);
24478c2ecf20Sopenharmony_ci	}
24488c2ecf20Sopenharmony_ci	if (state->RF_LO > 750000000UL && state->RF_LO <= 800000000UL) {
24498c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, DN_IQTNBUF_AMP,       1);
24508c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, DN_IQTNGNBFBIAS_BST,  0);
24518c2ecf20Sopenharmony_ci	}
24528c2ecf20Sopenharmony_ci	if (state->RF_LO > 800000000UL && state->RF_LO <= 850000000UL) {
24538c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, DN_IQTNBUF_AMP,       10);
24548c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, DN_IQTNGNBFBIAS_BST,  1);
24558c2ecf20Sopenharmony_ci	}
24568c2ecf20Sopenharmony_ci	if (state->RF_LO > 850000000UL && state->RF_LO <= 900000000UL) {
24578c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, DN_IQTNBUF_AMP,       10);
24588c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, DN_IQTNGNBFBIAS_BST,  1);
24598c2ecf20Sopenharmony_ci	}
24608c2ecf20Sopenharmony_ci
24618c2ecf20Sopenharmony_ci	/*
24628c2ecf20Sopenharmony_ci	 * Set RF Synth and LO Path Control
24638c2ecf20Sopenharmony_ci	 *
24648c2ecf20Sopenharmony_ci	 * Look-Up table implementation for:
24658c2ecf20Sopenharmony_ci	 *	RFSYN_EN_OUTMUX
24668c2ecf20Sopenharmony_ci	 *	RFSYN_SEL_VCO_OUT
24678c2ecf20Sopenharmony_ci	 *	RFSYN_SEL_VCO_HI
24688c2ecf20Sopenharmony_ci	 *  RFSYN_SEL_DIVM
24698c2ecf20Sopenharmony_ci	 *	RFSYN_RF_DIV_BIAS
24708c2ecf20Sopenharmony_ci	 *	DN_SEL_FREQ
24718c2ecf20Sopenharmony_ci	 *
24728c2ecf20Sopenharmony_ci	 * Set divider_val, Fmax, Fmix to use in Equations
24738c2ecf20Sopenharmony_ci	 */
24748c2ecf20Sopenharmony_ci	FminBin = 28000000UL ;
24758c2ecf20Sopenharmony_ci	FmaxBin = 42500000UL ;
24768c2ecf20Sopenharmony_ci	if (state->RF_LO >= 40000000UL && state->RF_LO <= FmaxBin) {
24778c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, RFSYN_EN_OUTMUX,     1);
24788c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_OUT,   0);
24798c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI,    0);
24808c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, RFSYN_SEL_DIVM,      0);
24818c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, RFSYN_RF_DIV_BIAS,   1);
24828c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, DN_SEL_FREQ,         1);
24838c2ecf20Sopenharmony_ci		divider_val = 64 ;
24848c2ecf20Sopenharmony_ci		Fmax = FmaxBin ;
24858c2ecf20Sopenharmony_ci		Fmin = FminBin ;
24868c2ecf20Sopenharmony_ci	}
24878c2ecf20Sopenharmony_ci	FminBin = 42500000UL ;
24888c2ecf20Sopenharmony_ci	FmaxBin = 56000000UL ;
24898c2ecf20Sopenharmony_ci	if (state->RF_LO > FminBin && state->RF_LO <= FmaxBin) {
24908c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, RFSYN_EN_OUTMUX,     1);
24918c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_OUT,   0);
24928c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI,    1);
24938c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, RFSYN_SEL_DIVM,      0);
24948c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, RFSYN_RF_DIV_BIAS,   1);
24958c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, DN_SEL_FREQ,         1);
24968c2ecf20Sopenharmony_ci		divider_val = 64 ;
24978c2ecf20Sopenharmony_ci		Fmax = FmaxBin ;
24988c2ecf20Sopenharmony_ci		Fmin = FminBin ;
24998c2ecf20Sopenharmony_ci	}
25008c2ecf20Sopenharmony_ci	FminBin = 56000000UL ;
25018c2ecf20Sopenharmony_ci	FmaxBin = 85000000UL ;
25028c2ecf20Sopenharmony_ci	if (state->RF_LO > FminBin && state->RF_LO <= FmaxBin) {
25038c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, RFSYN_EN_OUTMUX,     0);
25048c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_OUT,   1);
25058c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI,    0);
25068c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, RFSYN_SEL_DIVM,      0);
25078c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, RFSYN_RF_DIV_BIAS,   1);
25088c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, DN_SEL_FREQ,         1);
25098c2ecf20Sopenharmony_ci		divider_val = 32 ;
25108c2ecf20Sopenharmony_ci		Fmax = FmaxBin ;
25118c2ecf20Sopenharmony_ci		Fmin = FminBin ;
25128c2ecf20Sopenharmony_ci	}
25138c2ecf20Sopenharmony_ci	FminBin = 85000000UL ;
25148c2ecf20Sopenharmony_ci	FmaxBin = 112000000UL ;
25158c2ecf20Sopenharmony_ci	if (state->RF_LO > FminBin && state->RF_LO <= FmaxBin) {
25168c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, RFSYN_EN_OUTMUX,     0);
25178c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_OUT,   1);
25188c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI,    1);
25198c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, RFSYN_SEL_DIVM,      0);
25208c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, RFSYN_RF_DIV_BIAS,   1);
25218c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, DN_SEL_FREQ,         1);
25228c2ecf20Sopenharmony_ci		divider_val = 32 ;
25238c2ecf20Sopenharmony_ci		Fmax = FmaxBin ;
25248c2ecf20Sopenharmony_ci		Fmin = FminBin ;
25258c2ecf20Sopenharmony_ci	}
25268c2ecf20Sopenharmony_ci	FminBin = 112000000UL ;
25278c2ecf20Sopenharmony_ci	FmaxBin = 170000000UL ;
25288c2ecf20Sopenharmony_ci	if (state->RF_LO > FminBin && state->RF_LO <= FmaxBin) {
25298c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, RFSYN_EN_OUTMUX,     0);
25308c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_OUT,   1);
25318c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI,    0);
25328c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, RFSYN_SEL_DIVM,      0);
25338c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, RFSYN_RF_DIV_BIAS,   1);
25348c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, DN_SEL_FREQ,         2);
25358c2ecf20Sopenharmony_ci		divider_val = 16 ;
25368c2ecf20Sopenharmony_ci		Fmax = FmaxBin ;
25378c2ecf20Sopenharmony_ci		Fmin = FminBin ;
25388c2ecf20Sopenharmony_ci	}
25398c2ecf20Sopenharmony_ci	FminBin = 170000000UL ;
25408c2ecf20Sopenharmony_ci	FmaxBin = 225000000UL ;
25418c2ecf20Sopenharmony_ci	if (state->RF_LO > FminBin && state->RF_LO <= FmaxBin) {
25428c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, RFSYN_EN_OUTMUX,     0);
25438c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_OUT,   1);
25448c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI,    1);
25458c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, RFSYN_SEL_DIVM,      0);
25468c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, RFSYN_RF_DIV_BIAS,   1);
25478c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, DN_SEL_FREQ,         2);
25488c2ecf20Sopenharmony_ci		divider_val = 16 ;
25498c2ecf20Sopenharmony_ci		Fmax = FmaxBin ;
25508c2ecf20Sopenharmony_ci		Fmin = FminBin ;
25518c2ecf20Sopenharmony_ci	}
25528c2ecf20Sopenharmony_ci	FminBin = 225000000UL ;
25538c2ecf20Sopenharmony_ci	FmaxBin = 300000000UL ;
25548c2ecf20Sopenharmony_ci	if (state->RF_LO > FminBin && state->RF_LO <= FmaxBin) {
25558c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, RFSYN_EN_OUTMUX,     0);
25568c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_OUT,   1);
25578c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI,    0);
25588c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, RFSYN_SEL_DIVM,      0);
25598c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, RFSYN_RF_DIV_BIAS,   1);
25608c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, DN_SEL_FREQ,         4);
25618c2ecf20Sopenharmony_ci		divider_val = 8 ;
25628c2ecf20Sopenharmony_ci		Fmax = 340000000UL ;
25638c2ecf20Sopenharmony_ci		Fmin = FminBin ;
25648c2ecf20Sopenharmony_ci	}
25658c2ecf20Sopenharmony_ci	FminBin = 300000000UL ;
25668c2ecf20Sopenharmony_ci	FmaxBin = 340000000UL ;
25678c2ecf20Sopenharmony_ci	if (state->RF_LO > FminBin && state->RF_LO <= FmaxBin) {
25688c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, RFSYN_EN_OUTMUX,     1);
25698c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_OUT,   0);
25708c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI,    0);
25718c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, RFSYN_SEL_DIVM,      0);
25728c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, RFSYN_RF_DIV_BIAS,   1);
25738c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, DN_SEL_FREQ,         0);
25748c2ecf20Sopenharmony_ci		divider_val = 8 ;
25758c2ecf20Sopenharmony_ci		Fmax = FmaxBin ;
25768c2ecf20Sopenharmony_ci		Fmin = 225000000UL ;
25778c2ecf20Sopenharmony_ci	}
25788c2ecf20Sopenharmony_ci	FminBin = 340000000UL ;
25798c2ecf20Sopenharmony_ci	FmaxBin = 450000000UL ;
25808c2ecf20Sopenharmony_ci	if (state->RF_LO > FminBin && state->RF_LO <= FmaxBin) {
25818c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, RFSYN_EN_OUTMUX,     1);
25828c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_OUT,   0);
25838c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI,    1);
25848c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, RFSYN_SEL_DIVM,      0);
25858c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, RFSYN_RF_DIV_BIAS,   2);
25868c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, DN_SEL_FREQ,         0);
25878c2ecf20Sopenharmony_ci		divider_val = 8 ;
25888c2ecf20Sopenharmony_ci		Fmax = FmaxBin ;
25898c2ecf20Sopenharmony_ci		Fmin = FminBin ;
25908c2ecf20Sopenharmony_ci	}
25918c2ecf20Sopenharmony_ci	FminBin = 450000000UL ;
25928c2ecf20Sopenharmony_ci	FmaxBin = 680000000UL ;
25938c2ecf20Sopenharmony_ci	if (state->RF_LO > FminBin && state->RF_LO <= FmaxBin) {
25948c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, RFSYN_EN_OUTMUX,     0);
25958c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_OUT,   1);
25968c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI,    0);
25978c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, RFSYN_SEL_DIVM,      1);
25988c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, RFSYN_RF_DIV_BIAS,   1);
25998c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, DN_SEL_FREQ,         0);
26008c2ecf20Sopenharmony_ci		divider_val = 4 ;
26018c2ecf20Sopenharmony_ci		Fmax = FmaxBin ;
26028c2ecf20Sopenharmony_ci		Fmin = FminBin ;
26038c2ecf20Sopenharmony_ci	}
26048c2ecf20Sopenharmony_ci	FminBin = 680000000UL ;
26058c2ecf20Sopenharmony_ci	FmaxBin = 900000000UL ;
26068c2ecf20Sopenharmony_ci	if (state->RF_LO > FminBin && state->RF_LO <= FmaxBin) {
26078c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, RFSYN_EN_OUTMUX,     0);
26088c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_OUT,   1);
26098c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI,    1);
26108c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, RFSYN_SEL_DIVM,      1);
26118c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, RFSYN_RF_DIV_BIAS,   1);
26128c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, DN_SEL_FREQ,         0);
26138c2ecf20Sopenharmony_ci		divider_val = 4 ;
26148c2ecf20Sopenharmony_ci		Fmax = FmaxBin ;
26158c2ecf20Sopenharmony_ci		Fmin = FminBin ;
26168c2ecf20Sopenharmony_ci	}
26178c2ecf20Sopenharmony_ci
26188c2ecf20Sopenharmony_ci	/*	CHCAL_INT_MOD_RF
26198c2ecf20Sopenharmony_ci	 *	CHCAL_FRAC_MOD_RF
26208c2ecf20Sopenharmony_ci	 *	RFSYN_LPF_R
26218c2ecf20Sopenharmony_ci	 *	CHCAL_EN_INT_RF
26228c2ecf20Sopenharmony_ci	 */
26238c2ecf20Sopenharmony_ci	/* Equation E3 RFSYN_VCO_BIAS */
26248c2ecf20Sopenharmony_ci	E3 = (((Fmax-state->RF_LO)/1000)*32)/((Fmax-Fmin)/1000) + 8 ;
26258c2ecf20Sopenharmony_ci	status += MXL_ControlWrite(fe, RFSYN_VCO_BIAS, E3);
26268c2ecf20Sopenharmony_ci
26278c2ecf20Sopenharmony_ci	/* Equation E4 CHCAL_INT_MOD_RF */
26288c2ecf20Sopenharmony_ci	E4 = (state->RF_LO*divider_val/1000)/(2*state->Fxtal*Kdbl_RF/1000);
26298c2ecf20Sopenharmony_ci	MXL_ControlWrite(fe, CHCAL_INT_MOD_RF, E4);
26308c2ecf20Sopenharmony_ci
26318c2ecf20Sopenharmony_ci	/* Equation E5 CHCAL_FRAC_MOD_RF CHCAL_EN_INT_RF */
26328c2ecf20Sopenharmony_ci	E5 = ((2<<17)*(state->RF_LO/10000*divider_val -
26338c2ecf20Sopenharmony_ci		(E4*(2*state->Fxtal*Kdbl_RF)/10000))) /
26348c2ecf20Sopenharmony_ci		(2*state->Fxtal*Kdbl_RF/10000);
26358c2ecf20Sopenharmony_ci
26368c2ecf20Sopenharmony_ci	status += MXL_ControlWrite(fe, CHCAL_FRAC_MOD_RF, E5);
26378c2ecf20Sopenharmony_ci
26388c2ecf20Sopenharmony_ci	/* Equation E5A RFSYN_LPF_R */
26398c2ecf20Sopenharmony_ci	E5A = (((Fmax - state->RF_LO)/1000)*4/((Fmax-Fmin)/1000)) + 1 ;
26408c2ecf20Sopenharmony_ci	status += MXL_ControlWrite(fe, RFSYN_LPF_R, E5A);
26418c2ecf20Sopenharmony_ci
26428c2ecf20Sopenharmony_ci	/* Euqation E5B CHCAL_EN_INIT_RF */
26438c2ecf20Sopenharmony_ci	status += MXL_ControlWrite(fe, CHCAL_EN_INT_RF, ((E5 == 0) ? 1 : 0));
26448c2ecf20Sopenharmony_ci	/*if (E5 == 0)
26458c2ecf20Sopenharmony_ci	 *	status += MXL_ControlWrite(fe, CHCAL_EN_INT_RF, 1);
26468c2ecf20Sopenharmony_ci	 *else
26478c2ecf20Sopenharmony_ci	 *	status += MXL_ControlWrite(fe, CHCAL_FRAC_MOD_RF, E5);
26488c2ecf20Sopenharmony_ci	 */
26498c2ecf20Sopenharmony_ci
26508c2ecf20Sopenharmony_ci	/*
26518c2ecf20Sopenharmony_ci	 * Set TG Synth
26528c2ecf20Sopenharmony_ci	 *
26538c2ecf20Sopenharmony_ci	 * Look-Up table implementation for:
26548c2ecf20Sopenharmony_ci	 *	TG_LO_DIVVAL
26558c2ecf20Sopenharmony_ci	 *	TG_LO_SELVAL
26568c2ecf20Sopenharmony_ci	 *
26578c2ecf20Sopenharmony_ci	 * Set divider_val, Fmax, Fmix to use in Equations
26588c2ecf20Sopenharmony_ci	 */
26598c2ecf20Sopenharmony_ci	if (state->TG_LO < 33000000UL)
26608c2ecf20Sopenharmony_ci		return -1;
26618c2ecf20Sopenharmony_ci
26628c2ecf20Sopenharmony_ci	FminBin = 33000000UL ;
26638c2ecf20Sopenharmony_ci	FmaxBin = 50000000UL ;
26648c2ecf20Sopenharmony_ci	if (state->TG_LO >= FminBin && state->TG_LO <= FmaxBin) {
26658c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, TG_LO_DIVVAL,	0x6);
26668c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, TG_LO_SELVAL,	0x0);
26678c2ecf20Sopenharmony_ci		divider_val = 36 ;
26688c2ecf20Sopenharmony_ci		Fmax = FmaxBin ;
26698c2ecf20Sopenharmony_ci		Fmin = FminBin ;
26708c2ecf20Sopenharmony_ci	}
26718c2ecf20Sopenharmony_ci	FminBin = 50000000UL ;
26728c2ecf20Sopenharmony_ci	FmaxBin = 67000000UL ;
26738c2ecf20Sopenharmony_ci	if (state->TG_LO > FminBin && state->TG_LO <= FmaxBin) {
26748c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, TG_LO_DIVVAL,	0x1);
26758c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, TG_LO_SELVAL,	0x0);
26768c2ecf20Sopenharmony_ci		divider_val = 24 ;
26778c2ecf20Sopenharmony_ci		Fmax = FmaxBin ;
26788c2ecf20Sopenharmony_ci		Fmin = FminBin ;
26798c2ecf20Sopenharmony_ci	}
26808c2ecf20Sopenharmony_ci	FminBin = 67000000UL ;
26818c2ecf20Sopenharmony_ci	FmaxBin = 100000000UL ;
26828c2ecf20Sopenharmony_ci	if (state->TG_LO > FminBin && state->TG_LO <= FmaxBin) {
26838c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, TG_LO_DIVVAL,	0xC);
26848c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, TG_LO_SELVAL,	0x2);
26858c2ecf20Sopenharmony_ci		divider_val = 18 ;
26868c2ecf20Sopenharmony_ci		Fmax = FmaxBin ;
26878c2ecf20Sopenharmony_ci		Fmin = FminBin ;
26888c2ecf20Sopenharmony_ci	}
26898c2ecf20Sopenharmony_ci	FminBin = 100000000UL ;
26908c2ecf20Sopenharmony_ci	FmaxBin = 150000000UL ;
26918c2ecf20Sopenharmony_ci	if (state->TG_LO > FminBin && state->TG_LO <= FmaxBin) {
26928c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, TG_LO_DIVVAL,	0x8);
26938c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, TG_LO_SELVAL,	0x2);
26948c2ecf20Sopenharmony_ci		divider_val = 12 ;
26958c2ecf20Sopenharmony_ci		Fmax = FmaxBin ;
26968c2ecf20Sopenharmony_ci		Fmin = FminBin ;
26978c2ecf20Sopenharmony_ci	}
26988c2ecf20Sopenharmony_ci	FminBin = 150000000UL ;
26998c2ecf20Sopenharmony_ci	FmaxBin = 200000000UL ;
27008c2ecf20Sopenharmony_ci	if (state->TG_LO > FminBin && state->TG_LO <= FmaxBin) {
27018c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, TG_LO_DIVVAL,	0x0);
27028c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, TG_LO_SELVAL,	0x2);
27038c2ecf20Sopenharmony_ci		divider_val = 8 ;
27048c2ecf20Sopenharmony_ci		Fmax = FmaxBin ;
27058c2ecf20Sopenharmony_ci		Fmin = FminBin ;
27068c2ecf20Sopenharmony_ci	}
27078c2ecf20Sopenharmony_ci	FminBin = 200000000UL ;
27088c2ecf20Sopenharmony_ci	FmaxBin = 300000000UL ;
27098c2ecf20Sopenharmony_ci	if (state->TG_LO > FminBin && state->TG_LO <= FmaxBin) {
27108c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, TG_LO_DIVVAL,	0x8);
27118c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, TG_LO_SELVAL,	0x3);
27128c2ecf20Sopenharmony_ci		divider_val = 6 ;
27138c2ecf20Sopenharmony_ci		Fmax = FmaxBin ;
27148c2ecf20Sopenharmony_ci		Fmin = FminBin ;
27158c2ecf20Sopenharmony_ci	}
27168c2ecf20Sopenharmony_ci	FminBin = 300000000UL ;
27178c2ecf20Sopenharmony_ci	FmaxBin = 400000000UL ;
27188c2ecf20Sopenharmony_ci	if (state->TG_LO > FminBin && state->TG_LO <= FmaxBin) {
27198c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, TG_LO_DIVVAL,	0x0);
27208c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, TG_LO_SELVAL,	0x3);
27218c2ecf20Sopenharmony_ci		divider_val = 4 ;
27228c2ecf20Sopenharmony_ci		Fmax = FmaxBin ;
27238c2ecf20Sopenharmony_ci		Fmin = FminBin ;
27248c2ecf20Sopenharmony_ci	}
27258c2ecf20Sopenharmony_ci	FminBin = 400000000UL ;
27268c2ecf20Sopenharmony_ci	FmaxBin = 600000000UL ;
27278c2ecf20Sopenharmony_ci	if (state->TG_LO > FminBin && state->TG_LO <= FmaxBin) {
27288c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, TG_LO_DIVVAL,	0x8);
27298c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, TG_LO_SELVAL,	0x7);
27308c2ecf20Sopenharmony_ci		divider_val = 3 ;
27318c2ecf20Sopenharmony_ci		Fmax = FmaxBin ;
27328c2ecf20Sopenharmony_ci		Fmin = FminBin ;
27338c2ecf20Sopenharmony_ci	}
27348c2ecf20Sopenharmony_ci	FminBin = 600000000UL ;
27358c2ecf20Sopenharmony_ci	FmaxBin = 900000000UL ;
27368c2ecf20Sopenharmony_ci	if (state->TG_LO > FminBin && state->TG_LO <= FmaxBin) {
27378c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, TG_LO_DIVVAL,	0x0);
27388c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, TG_LO_SELVAL,	0x7);
27398c2ecf20Sopenharmony_ci		divider_val = 2 ;
27408c2ecf20Sopenharmony_ci	}
27418c2ecf20Sopenharmony_ci
27428c2ecf20Sopenharmony_ci	/* TG_DIV_VAL */
27438c2ecf20Sopenharmony_ci	tg_divval = (state->TG_LO*divider_val/100000) *
27448c2ecf20Sopenharmony_ci		(MXL_Ceiling(state->Fxtal, 1000000) * 100) /
27458c2ecf20Sopenharmony_ci		(state->Fxtal/1000);
27468c2ecf20Sopenharmony_ci
27478c2ecf20Sopenharmony_ci	status += MXL_ControlWrite(fe, TG_DIV_VAL, tg_divval);
27488c2ecf20Sopenharmony_ci
27498c2ecf20Sopenharmony_ci	if (state->TG_LO > 600000000UL)
27508c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, TG_DIV_VAL, tg_divval + 1);
27518c2ecf20Sopenharmony_ci
27528c2ecf20Sopenharmony_ci	Fmax = 1800000000UL ;
27538c2ecf20Sopenharmony_ci	Fmin = 1200000000UL ;
27548c2ecf20Sopenharmony_ci
27558c2ecf20Sopenharmony_ci	/* prevent overflow of 32 bit unsigned integer, use
27568c2ecf20Sopenharmony_ci	 * following equation. Edit for v2.6.4
27578c2ecf20Sopenharmony_ci	 */
27588c2ecf20Sopenharmony_ci	/* Fref_TF = Fref_TG * 1000 */
27598c2ecf20Sopenharmony_ci	Fref_TG = (state->Fxtal/1000) / MXL_Ceiling(state->Fxtal, 1000000);
27608c2ecf20Sopenharmony_ci
27618c2ecf20Sopenharmony_ci	/* Fvco = Fvco/10 */
27628c2ecf20Sopenharmony_ci	Fvco = (state->TG_LO/10000) * divider_val * Fref_TG;
27638c2ecf20Sopenharmony_ci
27648c2ecf20Sopenharmony_ci	tg_lo = (((Fmax/10 - Fvco)/100)*32) / ((Fmax-Fmin)/1000)+8;
27658c2ecf20Sopenharmony_ci
27668c2ecf20Sopenharmony_ci	/* below equation is same as above but much harder to debug.
27678c2ecf20Sopenharmony_ci	 *
27688c2ecf20Sopenharmony_ci	 * static u32 MXL_GetXtalInt(u32 Xtal_Freq)
27698c2ecf20Sopenharmony_ci	 * {
27708c2ecf20Sopenharmony_ci	 *	if ((Xtal_Freq % 1000000) == 0)
27718c2ecf20Sopenharmony_ci	 *		return (Xtal_Freq / 10000);
27728c2ecf20Sopenharmony_ci	 *	else
27738c2ecf20Sopenharmony_ci	 *		return (((Xtal_Freq / 1000000) + 1)*100);
27748c2ecf20Sopenharmony_ci	 * }
27758c2ecf20Sopenharmony_ci	 *
27768c2ecf20Sopenharmony_ci	 * u32 Xtal_Int = MXL_GetXtalInt(state->Fxtal);
27778c2ecf20Sopenharmony_ci	 * tg_lo = ( ((Fmax/10000 * Xtal_Int)/100) -
27788c2ecf20Sopenharmony_ci	 * ((state->TG_LO/10000)*divider_val *
27798c2ecf20Sopenharmony_ci	 * (state->Fxtal/10000)/100) )*32/((Fmax-Fmin)/10000 *
27808c2ecf20Sopenharmony_ci	 * Xtal_Int/100) + 8;
27818c2ecf20Sopenharmony_ci	 */
27828c2ecf20Sopenharmony_ci
27838c2ecf20Sopenharmony_ci	status += MXL_ControlWrite(fe, TG_VCO_BIAS , tg_lo);
27848c2ecf20Sopenharmony_ci
27858c2ecf20Sopenharmony_ci	/* add for 2.6.5 Special setting for QAM */
27868c2ecf20Sopenharmony_ci	if (state->Mod_Type == MXL_QAM) {
27878c2ecf20Sopenharmony_ci		if (state->config->qam_gain != 0)
27888c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, RFSYN_CHP_GAIN,
27898c2ecf20Sopenharmony_ci						   state->config->qam_gain);
27908c2ecf20Sopenharmony_ci		else if (state->RF_IN < 680000000)
27918c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, RFSYN_CHP_GAIN, 3);
27928c2ecf20Sopenharmony_ci		else
27938c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, RFSYN_CHP_GAIN, 2);
27948c2ecf20Sopenharmony_ci	}
27958c2ecf20Sopenharmony_ci
27968c2ecf20Sopenharmony_ci	/* Off Chip Tracking Filter Control */
27978c2ecf20Sopenharmony_ci	if (state->TF_Type == MXL_TF_OFF) {
27988c2ecf20Sopenharmony_ci		/* Tracking Filter Off State; turn off all the banks */
27998c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, DAC_A_ENABLE, 0);
28008c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0);
28018c2ecf20Sopenharmony_ci		status += MXL_SetGPIO(fe, 3, 1); /* Bank1 Off */
28028c2ecf20Sopenharmony_ci		status += MXL_SetGPIO(fe, 1, 1); /* Bank2 Off */
28038c2ecf20Sopenharmony_ci		status += MXL_SetGPIO(fe, 4, 1); /* Bank3 Off */
28048c2ecf20Sopenharmony_ci	}
28058c2ecf20Sopenharmony_ci
28068c2ecf20Sopenharmony_ci	if (state->TF_Type == MXL_TF_C) /* Tracking Filter type C */ {
28078c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, DAC_B_ENABLE, 1);
28088c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, DAC_DIN_A, 0);
28098c2ecf20Sopenharmony_ci
28108c2ecf20Sopenharmony_ci		if (state->RF_IN >= 43000000 && state->RF_IN < 150000000) {
28118c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, DAC_A_ENABLE, 0);
28128c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, DAC_DIN_B, 0);
28138c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 3, 0);
28148c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 1, 1);
28158c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 4, 1);
28168c2ecf20Sopenharmony_ci		}
28178c2ecf20Sopenharmony_ci		if (state->RF_IN >= 150000000 && state->RF_IN < 280000000) {
28188c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, DAC_A_ENABLE, 0);
28198c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, DAC_DIN_B, 0);
28208c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 3, 1);
28218c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 1, 0);
28228c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 4, 1);
28238c2ecf20Sopenharmony_ci		}
28248c2ecf20Sopenharmony_ci		if (state->RF_IN >= 280000000 && state->RF_IN < 360000000) {
28258c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, DAC_A_ENABLE, 0);
28268c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, DAC_DIN_B, 0);
28278c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 3, 1);
28288c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 1, 0);
28298c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 4, 0);
28308c2ecf20Sopenharmony_ci		}
28318c2ecf20Sopenharmony_ci		if (state->RF_IN >= 360000000 && state->RF_IN < 560000000) {
28328c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, DAC_A_ENABLE, 0);
28338c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, DAC_DIN_B, 0);
28348c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 3, 1);
28358c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 1, 1);
28368c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 4, 0);
28378c2ecf20Sopenharmony_ci		}
28388c2ecf20Sopenharmony_ci		if (state->RF_IN >= 560000000 && state->RF_IN < 580000000) {
28398c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, DAC_A_ENABLE, 1);
28408c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, DAC_DIN_B, 29);
28418c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 3, 1);
28428c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 1, 1);
28438c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 4, 0);
28448c2ecf20Sopenharmony_ci		}
28458c2ecf20Sopenharmony_ci		if (state->RF_IN >= 580000000 && state->RF_IN < 630000000) {
28468c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, DAC_A_ENABLE, 1);
28478c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, DAC_DIN_B, 0);
28488c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 3, 1);
28498c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 1, 1);
28508c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 4, 0);
28518c2ecf20Sopenharmony_ci		}
28528c2ecf20Sopenharmony_ci		if (state->RF_IN >= 630000000 && state->RF_IN < 700000000) {
28538c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, DAC_A_ENABLE, 1);
28548c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, DAC_DIN_B, 16);
28558c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 3, 1);
28568c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 1, 1);
28578c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 4, 1);
28588c2ecf20Sopenharmony_ci		}
28598c2ecf20Sopenharmony_ci		if (state->RF_IN >= 700000000 && state->RF_IN < 760000000) {
28608c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, DAC_A_ENABLE, 1);
28618c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, DAC_DIN_B, 7);
28628c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 3, 1);
28638c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 1, 1);
28648c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 4, 1);
28658c2ecf20Sopenharmony_ci		}
28668c2ecf20Sopenharmony_ci		if (state->RF_IN >= 760000000 && state->RF_IN <= 900000000) {
28678c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, DAC_A_ENABLE, 1);
28688c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, DAC_DIN_B, 0);
28698c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 3, 1);
28708c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 1, 1);
28718c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 4, 1);
28728c2ecf20Sopenharmony_ci		}
28738c2ecf20Sopenharmony_ci	}
28748c2ecf20Sopenharmony_ci
28758c2ecf20Sopenharmony_ci	if (state->TF_Type == MXL_TF_C_H) {
28768c2ecf20Sopenharmony_ci
28778c2ecf20Sopenharmony_ci		/* Tracking Filter type C-H for Hauppauge only */
28788c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, DAC_DIN_A, 0);
28798c2ecf20Sopenharmony_ci
28808c2ecf20Sopenharmony_ci		if (state->RF_IN >= 43000000 && state->RF_IN < 150000000) {
28818c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, DAC_A_ENABLE, 0);
28828c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 4, 0);
28838c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 3, 1);
28848c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 1, 1);
28858c2ecf20Sopenharmony_ci		}
28868c2ecf20Sopenharmony_ci		if (state->RF_IN >= 150000000 && state->RF_IN < 280000000) {
28878c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, DAC_A_ENABLE, 0);
28888c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 4, 1);
28898c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 3, 0);
28908c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 1, 1);
28918c2ecf20Sopenharmony_ci		}
28928c2ecf20Sopenharmony_ci		if (state->RF_IN >= 280000000 && state->RF_IN < 360000000) {
28938c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, DAC_A_ENABLE, 0);
28948c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 4, 1);
28958c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 3, 0);
28968c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 1, 0);
28978c2ecf20Sopenharmony_ci		}
28988c2ecf20Sopenharmony_ci		if (state->RF_IN >= 360000000 && state->RF_IN < 560000000) {
28998c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, DAC_A_ENABLE, 0);
29008c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 4, 1);
29018c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 3, 1);
29028c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 1, 0);
29038c2ecf20Sopenharmony_ci		}
29048c2ecf20Sopenharmony_ci		if (state->RF_IN >= 560000000 && state->RF_IN < 580000000) {
29058c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, DAC_A_ENABLE, 1);
29068c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 4, 1);
29078c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 3, 1);
29088c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 1, 0);
29098c2ecf20Sopenharmony_ci		}
29108c2ecf20Sopenharmony_ci		if (state->RF_IN >= 580000000 && state->RF_IN < 630000000) {
29118c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, DAC_A_ENABLE, 1);
29128c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 4, 1);
29138c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 3, 1);
29148c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 1, 0);
29158c2ecf20Sopenharmony_ci		}
29168c2ecf20Sopenharmony_ci		if (state->RF_IN >= 630000000 && state->RF_IN < 700000000) {
29178c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, DAC_A_ENABLE, 1);
29188c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 4, 1);
29198c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 3, 1);
29208c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 1, 1);
29218c2ecf20Sopenharmony_ci		}
29228c2ecf20Sopenharmony_ci		if (state->RF_IN >= 700000000 && state->RF_IN < 760000000) {
29238c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, DAC_A_ENABLE, 1);
29248c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 4, 1);
29258c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 3, 1);
29268c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 1, 1);
29278c2ecf20Sopenharmony_ci		}
29288c2ecf20Sopenharmony_ci		if (state->RF_IN >= 760000000 && state->RF_IN <= 900000000) {
29298c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, DAC_A_ENABLE, 1);
29308c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 4, 1);
29318c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 3, 1);
29328c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 1, 1);
29338c2ecf20Sopenharmony_ci		}
29348c2ecf20Sopenharmony_ci	}
29358c2ecf20Sopenharmony_ci
29368c2ecf20Sopenharmony_ci	if (state->TF_Type == MXL_TF_D) { /* Tracking Filter type D */
29378c2ecf20Sopenharmony_ci
29388c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, DAC_DIN_B, 0);
29398c2ecf20Sopenharmony_ci
29408c2ecf20Sopenharmony_ci		if (state->RF_IN >= 43000000 && state->RF_IN < 174000000) {
29418c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0);
29428c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 4, 0);
29438c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 1, 1);
29448c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 3, 1);
29458c2ecf20Sopenharmony_ci		}
29468c2ecf20Sopenharmony_ci		if (state->RF_IN >= 174000000 && state->RF_IN < 250000000) {
29478c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0);
29488c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 4, 0);
29498c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 1, 0);
29508c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 3, 1);
29518c2ecf20Sopenharmony_ci		}
29528c2ecf20Sopenharmony_ci		if (state->RF_IN >= 250000000 && state->RF_IN < 310000000) {
29538c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0);
29548c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 4, 1);
29558c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 1, 0);
29568c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 3, 1);
29578c2ecf20Sopenharmony_ci		}
29588c2ecf20Sopenharmony_ci		if (state->RF_IN >= 310000000 && state->RF_IN < 360000000) {
29598c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0);
29608c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 4, 1);
29618c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 1, 0);
29628c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 3, 0);
29638c2ecf20Sopenharmony_ci		}
29648c2ecf20Sopenharmony_ci		if (state->RF_IN >= 360000000 && state->RF_IN < 470000000) {
29658c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0);
29668c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 4, 1);
29678c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 1, 1);
29688c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 3, 0);
29698c2ecf20Sopenharmony_ci		}
29708c2ecf20Sopenharmony_ci		if (state->RF_IN >= 470000000 && state->RF_IN < 640000000) {
29718c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, DAC_B_ENABLE, 1);
29728c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 4, 1);
29738c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 1, 1);
29748c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 3, 0);
29758c2ecf20Sopenharmony_ci		}
29768c2ecf20Sopenharmony_ci		if (state->RF_IN >= 640000000 && state->RF_IN <= 900000000) {
29778c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, DAC_B_ENABLE, 1);
29788c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 4, 1);
29798c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 1, 1);
29808c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 3, 1);
29818c2ecf20Sopenharmony_ci		}
29828c2ecf20Sopenharmony_ci	}
29838c2ecf20Sopenharmony_ci
29848c2ecf20Sopenharmony_ci	if (state->TF_Type == MXL_TF_D_L) {
29858c2ecf20Sopenharmony_ci
29868c2ecf20Sopenharmony_ci		/* Tracking Filter type D-L for Lumanate ONLY change 2.6.3 */
29878c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, DAC_DIN_A, 0);
29888c2ecf20Sopenharmony_ci
29898c2ecf20Sopenharmony_ci		/* if UHF and terrestrial => Turn off Tracking Filter */
29908c2ecf20Sopenharmony_ci		if (state->RF_IN >= 471000000 &&
29918c2ecf20Sopenharmony_ci			(state->RF_IN - 471000000)%6000000 != 0) {
29928c2ecf20Sopenharmony_ci			/* Turn off all the banks */
29938c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 3, 1);
29948c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 1, 1);
29958c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 4, 1);
29968c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, DAC_A_ENABLE, 0);
29978c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, AGC_IF, 10);
29988c2ecf20Sopenharmony_ci		} else {
29998c2ecf20Sopenharmony_ci			/* if VHF or cable => Turn on Tracking Filter */
30008c2ecf20Sopenharmony_ci			if (state->RF_IN >= 43000000 &&
30018c2ecf20Sopenharmony_ci				state->RF_IN < 140000000) {
30028c2ecf20Sopenharmony_ci
30038c2ecf20Sopenharmony_ci				status += MXL_ControlWrite(fe, DAC_A_ENABLE, 0);
30048c2ecf20Sopenharmony_ci				status += MXL_SetGPIO(fe, 4, 1);
30058c2ecf20Sopenharmony_ci				status += MXL_SetGPIO(fe, 1, 1);
30068c2ecf20Sopenharmony_ci				status += MXL_SetGPIO(fe, 3, 0);
30078c2ecf20Sopenharmony_ci			}
30088c2ecf20Sopenharmony_ci			if (state->RF_IN >= 140000000 &&
30098c2ecf20Sopenharmony_ci				state->RF_IN < 240000000) {
30108c2ecf20Sopenharmony_ci				status += MXL_ControlWrite(fe, DAC_A_ENABLE, 0);
30118c2ecf20Sopenharmony_ci				status += MXL_SetGPIO(fe, 4, 1);
30128c2ecf20Sopenharmony_ci				status += MXL_SetGPIO(fe, 1, 0);
30138c2ecf20Sopenharmony_ci				status += MXL_SetGPIO(fe, 3, 0);
30148c2ecf20Sopenharmony_ci			}
30158c2ecf20Sopenharmony_ci			if (state->RF_IN >= 240000000 &&
30168c2ecf20Sopenharmony_ci				state->RF_IN < 340000000) {
30178c2ecf20Sopenharmony_ci				status += MXL_ControlWrite(fe, DAC_A_ENABLE, 0);
30188c2ecf20Sopenharmony_ci				status += MXL_SetGPIO(fe, 4, 0);
30198c2ecf20Sopenharmony_ci				status += MXL_SetGPIO(fe, 1, 1);
30208c2ecf20Sopenharmony_ci				status += MXL_SetGPIO(fe, 3, 0);
30218c2ecf20Sopenharmony_ci			}
30228c2ecf20Sopenharmony_ci			if (state->RF_IN >= 340000000 &&
30238c2ecf20Sopenharmony_ci				state->RF_IN < 430000000) {
30248c2ecf20Sopenharmony_ci				status += MXL_ControlWrite(fe, DAC_A_ENABLE, 0);
30258c2ecf20Sopenharmony_ci				status += MXL_SetGPIO(fe, 4, 0);
30268c2ecf20Sopenharmony_ci				status += MXL_SetGPIO(fe, 1, 0);
30278c2ecf20Sopenharmony_ci				status += MXL_SetGPIO(fe, 3, 1);
30288c2ecf20Sopenharmony_ci			}
30298c2ecf20Sopenharmony_ci			if (state->RF_IN >= 430000000 &&
30308c2ecf20Sopenharmony_ci				state->RF_IN < 470000000) {
30318c2ecf20Sopenharmony_ci				status += MXL_ControlWrite(fe, DAC_A_ENABLE, 1);
30328c2ecf20Sopenharmony_ci				status += MXL_SetGPIO(fe, 4, 1);
30338c2ecf20Sopenharmony_ci				status += MXL_SetGPIO(fe, 1, 0);
30348c2ecf20Sopenharmony_ci				status += MXL_SetGPIO(fe, 3, 1);
30358c2ecf20Sopenharmony_ci			}
30368c2ecf20Sopenharmony_ci			if (state->RF_IN >= 470000000 &&
30378c2ecf20Sopenharmony_ci				state->RF_IN < 570000000) {
30388c2ecf20Sopenharmony_ci				status += MXL_ControlWrite(fe, DAC_A_ENABLE, 1);
30398c2ecf20Sopenharmony_ci				status += MXL_SetGPIO(fe, 4, 0);
30408c2ecf20Sopenharmony_ci				status += MXL_SetGPIO(fe, 1, 0);
30418c2ecf20Sopenharmony_ci				status += MXL_SetGPIO(fe, 3, 1);
30428c2ecf20Sopenharmony_ci			}
30438c2ecf20Sopenharmony_ci			if (state->RF_IN >= 570000000 &&
30448c2ecf20Sopenharmony_ci				state->RF_IN < 620000000) {
30458c2ecf20Sopenharmony_ci				status += MXL_ControlWrite(fe, DAC_A_ENABLE, 0);
30468c2ecf20Sopenharmony_ci				status += MXL_SetGPIO(fe, 4, 0);
30478c2ecf20Sopenharmony_ci				status += MXL_SetGPIO(fe, 1, 1);
30488c2ecf20Sopenharmony_ci				status += MXL_SetGPIO(fe, 3, 1);
30498c2ecf20Sopenharmony_ci			}
30508c2ecf20Sopenharmony_ci			if (state->RF_IN >= 620000000 &&
30518c2ecf20Sopenharmony_ci				state->RF_IN < 760000000) {
30528c2ecf20Sopenharmony_ci				status += MXL_ControlWrite(fe, DAC_A_ENABLE, 1);
30538c2ecf20Sopenharmony_ci				status += MXL_SetGPIO(fe, 4, 0);
30548c2ecf20Sopenharmony_ci				status += MXL_SetGPIO(fe, 1, 1);
30558c2ecf20Sopenharmony_ci				status += MXL_SetGPIO(fe, 3, 1);
30568c2ecf20Sopenharmony_ci			}
30578c2ecf20Sopenharmony_ci			if (state->RF_IN >= 760000000 &&
30588c2ecf20Sopenharmony_ci				state->RF_IN <= 900000000) {
30598c2ecf20Sopenharmony_ci				status += MXL_ControlWrite(fe, DAC_A_ENABLE, 1);
30608c2ecf20Sopenharmony_ci				status += MXL_SetGPIO(fe, 4, 1);
30618c2ecf20Sopenharmony_ci				status += MXL_SetGPIO(fe, 1, 1);
30628c2ecf20Sopenharmony_ci				status += MXL_SetGPIO(fe, 3, 1);
30638c2ecf20Sopenharmony_ci			}
30648c2ecf20Sopenharmony_ci		}
30658c2ecf20Sopenharmony_ci	}
30668c2ecf20Sopenharmony_ci
30678c2ecf20Sopenharmony_ci	if (state->TF_Type == MXL_TF_E) /* Tracking Filter type E */ {
30688c2ecf20Sopenharmony_ci
30698c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, DAC_DIN_B, 0);
30708c2ecf20Sopenharmony_ci
30718c2ecf20Sopenharmony_ci		if (state->RF_IN >= 43000000 && state->RF_IN < 174000000) {
30728c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0);
30738c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 4, 0);
30748c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 1, 1);
30758c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 3, 1);
30768c2ecf20Sopenharmony_ci		}
30778c2ecf20Sopenharmony_ci		if (state->RF_IN >= 174000000 && state->RF_IN < 250000000) {
30788c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0);
30798c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 4, 0);
30808c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 1, 0);
30818c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 3, 1);
30828c2ecf20Sopenharmony_ci		}
30838c2ecf20Sopenharmony_ci		if (state->RF_IN >= 250000000 && state->RF_IN < 310000000) {
30848c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0);
30858c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 4, 1);
30868c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 1, 0);
30878c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 3, 1);
30888c2ecf20Sopenharmony_ci		}
30898c2ecf20Sopenharmony_ci		if (state->RF_IN >= 310000000 && state->RF_IN < 360000000) {
30908c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0);
30918c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 4, 1);
30928c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 1, 0);
30938c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 3, 0);
30948c2ecf20Sopenharmony_ci		}
30958c2ecf20Sopenharmony_ci		if (state->RF_IN >= 360000000 && state->RF_IN < 470000000) {
30968c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0);
30978c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 4, 1);
30988c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 1, 1);
30998c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 3, 0);
31008c2ecf20Sopenharmony_ci		}
31018c2ecf20Sopenharmony_ci		if (state->RF_IN >= 470000000 && state->RF_IN < 640000000) {
31028c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, DAC_B_ENABLE, 1);
31038c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 4, 1);
31048c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 1, 1);
31058c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 3, 0);
31068c2ecf20Sopenharmony_ci		}
31078c2ecf20Sopenharmony_ci		if (state->RF_IN >= 640000000 && state->RF_IN <= 900000000) {
31088c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, DAC_B_ENABLE, 1);
31098c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 4, 1);
31108c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 1, 1);
31118c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 3, 1);
31128c2ecf20Sopenharmony_ci		}
31138c2ecf20Sopenharmony_ci	}
31148c2ecf20Sopenharmony_ci
31158c2ecf20Sopenharmony_ci	if (state->TF_Type == MXL_TF_F) {
31168c2ecf20Sopenharmony_ci
31178c2ecf20Sopenharmony_ci		/* Tracking Filter type F */
31188c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, DAC_DIN_B, 0);
31198c2ecf20Sopenharmony_ci
31208c2ecf20Sopenharmony_ci		if (state->RF_IN >= 43000000 && state->RF_IN < 160000000) {
31218c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0);
31228c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 4, 0);
31238c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 1, 1);
31248c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 3, 1);
31258c2ecf20Sopenharmony_ci		}
31268c2ecf20Sopenharmony_ci		if (state->RF_IN >= 160000000 && state->RF_IN < 210000000) {
31278c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0);
31288c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 4, 0);
31298c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 1, 0);
31308c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 3, 1);
31318c2ecf20Sopenharmony_ci		}
31328c2ecf20Sopenharmony_ci		if (state->RF_IN >= 210000000 && state->RF_IN < 300000000) {
31338c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0);
31348c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 4, 1);
31358c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 1, 0);
31368c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 3, 1);
31378c2ecf20Sopenharmony_ci		}
31388c2ecf20Sopenharmony_ci		if (state->RF_IN >= 300000000 && state->RF_IN < 390000000) {
31398c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0);
31408c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 4, 1);
31418c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 1, 0);
31428c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 3, 0);
31438c2ecf20Sopenharmony_ci		}
31448c2ecf20Sopenharmony_ci		if (state->RF_IN >= 390000000 && state->RF_IN < 515000000) {
31458c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0);
31468c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 4, 1);
31478c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 1, 1);
31488c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 3, 0);
31498c2ecf20Sopenharmony_ci		}
31508c2ecf20Sopenharmony_ci		if (state->RF_IN >= 515000000 && state->RF_IN < 650000000) {
31518c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, DAC_B_ENABLE, 1);
31528c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 4, 1);
31538c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 1, 1);
31548c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 3, 0);
31558c2ecf20Sopenharmony_ci		}
31568c2ecf20Sopenharmony_ci		if (state->RF_IN >= 650000000 && state->RF_IN <= 900000000) {
31578c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, DAC_B_ENABLE, 1);
31588c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 4, 1);
31598c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 1, 1);
31608c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 3, 1);
31618c2ecf20Sopenharmony_ci		}
31628c2ecf20Sopenharmony_ci	}
31638c2ecf20Sopenharmony_ci
31648c2ecf20Sopenharmony_ci	if (state->TF_Type == MXL_TF_E_2) {
31658c2ecf20Sopenharmony_ci
31668c2ecf20Sopenharmony_ci		/* Tracking Filter type E_2 */
31678c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, DAC_DIN_B, 0);
31688c2ecf20Sopenharmony_ci
31698c2ecf20Sopenharmony_ci		if (state->RF_IN >= 43000000 && state->RF_IN < 174000000) {
31708c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0);
31718c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 4, 0);
31728c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 1, 1);
31738c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 3, 1);
31748c2ecf20Sopenharmony_ci		}
31758c2ecf20Sopenharmony_ci		if (state->RF_IN >= 174000000 && state->RF_IN < 250000000) {
31768c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0);
31778c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 4, 0);
31788c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 1, 0);
31798c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 3, 1);
31808c2ecf20Sopenharmony_ci		}
31818c2ecf20Sopenharmony_ci		if (state->RF_IN >= 250000000 && state->RF_IN < 350000000) {
31828c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0);
31838c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 4, 1);
31848c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 1, 0);
31858c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 3, 1);
31868c2ecf20Sopenharmony_ci		}
31878c2ecf20Sopenharmony_ci		if (state->RF_IN >= 350000000 && state->RF_IN < 400000000) {
31888c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0);
31898c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 4, 1);
31908c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 1, 0);
31918c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 3, 0);
31928c2ecf20Sopenharmony_ci		}
31938c2ecf20Sopenharmony_ci		if (state->RF_IN >= 400000000 && state->RF_IN < 570000000) {
31948c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0);
31958c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 4, 1);
31968c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 1, 1);
31978c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 3, 0);
31988c2ecf20Sopenharmony_ci		}
31998c2ecf20Sopenharmony_ci		if (state->RF_IN >= 570000000 && state->RF_IN < 770000000) {
32008c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, DAC_B_ENABLE, 1);
32018c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 4, 1);
32028c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 1, 1);
32038c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 3, 0);
32048c2ecf20Sopenharmony_ci		}
32058c2ecf20Sopenharmony_ci		if (state->RF_IN >= 770000000 && state->RF_IN <= 900000000) {
32068c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, DAC_B_ENABLE, 1);
32078c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 4, 1);
32088c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 1, 1);
32098c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 3, 1);
32108c2ecf20Sopenharmony_ci		}
32118c2ecf20Sopenharmony_ci	}
32128c2ecf20Sopenharmony_ci
32138c2ecf20Sopenharmony_ci	if (state->TF_Type == MXL_TF_G) {
32148c2ecf20Sopenharmony_ci
32158c2ecf20Sopenharmony_ci		/* Tracking Filter type G add for v2.6.8 */
32168c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, DAC_DIN_B, 0);
32178c2ecf20Sopenharmony_ci
32188c2ecf20Sopenharmony_ci		if (state->RF_IN >= 50000000 && state->RF_IN < 190000000) {
32198c2ecf20Sopenharmony_ci
32208c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0);
32218c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 4, 0);
32228c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 1, 1);
32238c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 3, 1);
32248c2ecf20Sopenharmony_ci		}
32258c2ecf20Sopenharmony_ci		if (state->RF_IN >= 190000000 && state->RF_IN < 280000000) {
32268c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0);
32278c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 4, 0);
32288c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 1, 0);
32298c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 3, 1);
32308c2ecf20Sopenharmony_ci		}
32318c2ecf20Sopenharmony_ci		if (state->RF_IN >= 280000000 && state->RF_IN < 350000000) {
32328c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0);
32338c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 4, 1);
32348c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 1, 0);
32358c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 3, 1);
32368c2ecf20Sopenharmony_ci		}
32378c2ecf20Sopenharmony_ci		if (state->RF_IN >= 350000000 && state->RF_IN < 400000000) {
32388c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0);
32398c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 4, 1);
32408c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 1, 0);
32418c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 3, 0);
32428c2ecf20Sopenharmony_ci		}
32438c2ecf20Sopenharmony_ci		if (state->RF_IN >= 400000000 && state->RF_IN < 470000000) {
32448c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, DAC_B_ENABLE, 1);
32458c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 4, 1);
32468c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 1, 0);
32478c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 3, 1);
32488c2ecf20Sopenharmony_ci		}
32498c2ecf20Sopenharmony_ci		if (state->RF_IN >= 470000000 && state->RF_IN < 640000000) {
32508c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0);
32518c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 4, 1);
32528c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 1, 1);
32538c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 3, 0);
32548c2ecf20Sopenharmony_ci		}
32558c2ecf20Sopenharmony_ci		if (state->RF_IN >= 640000000 && state->RF_IN < 820000000) {
32568c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, DAC_B_ENABLE, 1);
32578c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 4, 1);
32588c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 1, 1);
32598c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 3, 0);
32608c2ecf20Sopenharmony_ci		}
32618c2ecf20Sopenharmony_ci		if (state->RF_IN >= 820000000 && state->RF_IN <= 900000000) {
32628c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, DAC_B_ENABLE, 1);
32638c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 4, 1);
32648c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 1, 1);
32658c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 3, 1);
32668c2ecf20Sopenharmony_ci		}
32678c2ecf20Sopenharmony_ci	}
32688c2ecf20Sopenharmony_ci
32698c2ecf20Sopenharmony_ci	if (state->TF_Type == MXL_TF_E_NA) {
32708c2ecf20Sopenharmony_ci
32718c2ecf20Sopenharmony_ci		/* Tracking Filter type E-NA for Empia ONLY change for 2.6.8 */
32728c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, DAC_DIN_B, 0);
32738c2ecf20Sopenharmony_ci
32748c2ecf20Sopenharmony_ci		/* if UHF and terrestrial=> Turn off Tracking Filter */
32758c2ecf20Sopenharmony_ci		if (state->RF_IN >= 471000000 &&
32768c2ecf20Sopenharmony_ci			(state->RF_IN - 471000000)%6000000 != 0) {
32778c2ecf20Sopenharmony_ci
32788c2ecf20Sopenharmony_ci			/* Turn off all the banks */
32798c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 3, 1);
32808c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 1, 1);
32818c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 4, 1);
32828c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0);
32838c2ecf20Sopenharmony_ci
32848c2ecf20Sopenharmony_ci			/* 2.6.12 Turn on RSSI */
32858c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, SEQ_EXTSYNTHCALIF, 1);
32868c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, SEQ_EXTDCCAL, 1);
32878c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, AGC_EN_RSSI, 1);
32888c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, RFA_ENCLKRFAGC, 1);
32898c2ecf20Sopenharmony_ci
32908c2ecf20Sopenharmony_ci			/* RSSI reference point */
32918c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, RFA_RSSI_REFH, 5);
32928c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, RFA_RSSI_REF, 3);
32938c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, RFA_RSSI_REFL, 2);
32948c2ecf20Sopenharmony_ci
32958c2ecf20Sopenharmony_ci			/* following parameter is from analog OTA mode,
32968c2ecf20Sopenharmony_ci			 * can be change to seek better performance */
32978c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, RFSYN_CHP_GAIN, 3);
32988c2ecf20Sopenharmony_ci		} else {
32998c2ecf20Sopenharmony_ci		/* if VHF or Cable =>  Turn on Tracking Filter */
33008c2ecf20Sopenharmony_ci
33018c2ecf20Sopenharmony_ci		/* 2.6.12 Turn off RSSI */
33028c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, AGC_EN_RSSI, 0);
33038c2ecf20Sopenharmony_ci
33048c2ecf20Sopenharmony_ci		/* change back from above condition */
33058c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, RFSYN_CHP_GAIN, 5);
33068c2ecf20Sopenharmony_ci
33078c2ecf20Sopenharmony_ci
33088c2ecf20Sopenharmony_ci		if (state->RF_IN >= 43000000 && state->RF_IN < 174000000) {
33098c2ecf20Sopenharmony_ci
33108c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0);
33118c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 4, 0);
33128c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 1, 1);
33138c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 3, 1);
33148c2ecf20Sopenharmony_ci		}
33158c2ecf20Sopenharmony_ci		if (state->RF_IN >= 174000000 && state->RF_IN < 250000000) {
33168c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0);
33178c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 4, 0);
33188c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 1, 0);
33198c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 3, 1);
33208c2ecf20Sopenharmony_ci		}
33218c2ecf20Sopenharmony_ci		if (state->RF_IN >= 250000000 && state->RF_IN < 350000000) {
33228c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0);
33238c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 4, 1);
33248c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 1, 0);
33258c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 3, 1);
33268c2ecf20Sopenharmony_ci		}
33278c2ecf20Sopenharmony_ci		if (state->RF_IN >= 350000000 && state->RF_IN < 400000000) {
33288c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0);
33298c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 4, 1);
33308c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 1, 0);
33318c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 3, 0);
33328c2ecf20Sopenharmony_ci		}
33338c2ecf20Sopenharmony_ci		if (state->RF_IN >= 400000000 && state->RF_IN < 570000000) {
33348c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0);
33358c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 4, 1);
33368c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 1, 1);
33378c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 3, 0);
33388c2ecf20Sopenharmony_ci		}
33398c2ecf20Sopenharmony_ci		if (state->RF_IN >= 570000000 && state->RF_IN < 770000000) {
33408c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, DAC_B_ENABLE, 1);
33418c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 4, 1);
33428c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 1, 1);
33438c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 3, 0);
33448c2ecf20Sopenharmony_ci		}
33458c2ecf20Sopenharmony_ci		if (state->RF_IN >= 770000000 && state->RF_IN <= 900000000) {
33468c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, DAC_B_ENABLE, 1);
33478c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 4, 1);
33488c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 1, 1);
33498c2ecf20Sopenharmony_ci			status += MXL_SetGPIO(fe, 3, 1);
33508c2ecf20Sopenharmony_ci		}
33518c2ecf20Sopenharmony_ci		}
33528c2ecf20Sopenharmony_ci	}
33538c2ecf20Sopenharmony_ci	return status ;
33548c2ecf20Sopenharmony_ci}
33558c2ecf20Sopenharmony_ci
33568c2ecf20Sopenharmony_cistatic u16 MXL_SetGPIO(struct dvb_frontend *fe, u8 GPIO_Num, u8 GPIO_Val)
33578c2ecf20Sopenharmony_ci{
33588c2ecf20Sopenharmony_ci	u16 status = 0;
33598c2ecf20Sopenharmony_ci
33608c2ecf20Sopenharmony_ci	if (GPIO_Num == 1)
33618c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, GPIO_1B, GPIO_Val ? 0 : 1);
33628c2ecf20Sopenharmony_ci
33638c2ecf20Sopenharmony_ci	/* GPIO2 is not available */
33648c2ecf20Sopenharmony_ci
33658c2ecf20Sopenharmony_ci	if (GPIO_Num == 3) {
33668c2ecf20Sopenharmony_ci		if (GPIO_Val == 1) {
33678c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, GPIO_3, 0);
33688c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, GPIO_3B, 0);
33698c2ecf20Sopenharmony_ci		}
33708c2ecf20Sopenharmony_ci		if (GPIO_Val == 0) {
33718c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, GPIO_3, 1);
33728c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, GPIO_3B, 1);
33738c2ecf20Sopenharmony_ci		}
33748c2ecf20Sopenharmony_ci		if (GPIO_Val == 3) { /* tri-state */
33758c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, GPIO_3, 0);
33768c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, GPIO_3B, 1);
33778c2ecf20Sopenharmony_ci		}
33788c2ecf20Sopenharmony_ci	}
33798c2ecf20Sopenharmony_ci	if (GPIO_Num == 4) {
33808c2ecf20Sopenharmony_ci		if (GPIO_Val == 1) {
33818c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, GPIO_4, 0);
33828c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, GPIO_4B, 0);
33838c2ecf20Sopenharmony_ci		}
33848c2ecf20Sopenharmony_ci		if (GPIO_Val == 0) {
33858c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, GPIO_4, 1);
33868c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, GPIO_4B, 1);
33878c2ecf20Sopenharmony_ci		}
33888c2ecf20Sopenharmony_ci		if (GPIO_Val == 3) { /* tri-state */
33898c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, GPIO_4, 0);
33908c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, GPIO_4B, 1);
33918c2ecf20Sopenharmony_ci		}
33928c2ecf20Sopenharmony_ci	}
33938c2ecf20Sopenharmony_ci
33948c2ecf20Sopenharmony_ci	return status;
33958c2ecf20Sopenharmony_ci}
33968c2ecf20Sopenharmony_ci
33978c2ecf20Sopenharmony_cistatic u16 MXL_ControlWrite(struct dvb_frontend *fe, u16 ControlNum, u32 value)
33988c2ecf20Sopenharmony_ci{
33998c2ecf20Sopenharmony_ci	u16 status = 0;
34008c2ecf20Sopenharmony_ci
34018c2ecf20Sopenharmony_ci	/* Will write ALL Matching Control Name */
34028c2ecf20Sopenharmony_ci	/* Write Matching INIT Control */
34038c2ecf20Sopenharmony_ci	status += MXL_ControlWrite_Group(fe, ControlNum, value, 1);
34048c2ecf20Sopenharmony_ci	/* Write Matching CH Control */
34058c2ecf20Sopenharmony_ci	status += MXL_ControlWrite_Group(fe, ControlNum, value, 2);
34068c2ecf20Sopenharmony_ci#ifdef _MXL_INTERNAL
34078c2ecf20Sopenharmony_ci	/* Write Matching MXL Control */
34088c2ecf20Sopenharmony_ci	status += MXL_ControlWrite_Group(fe, ControlNum, value, 3);
34098c2ecf20Sopenharmony_ci#endif
34108c2ecf20Sopenharmony_ci	return status;
34118c2ecf20Sopenharmony_ci}
34128c2ecf20Sopenharmony_ci
34138c2ecf20Sopenharmony_cistatic u16 MXL_ControlWrite_Group(struct dvb_frontend *fe, u16 controlNum,
34148c2ecf20Sopenharmony_ci	u32 value, u16 controlGroup)
34158c2ecf20Sopenharmony_ci{
34168c2ecf20Sopenharmony_ci	struct mxl5005s_state *state = fe->tuner_priv;
34178c2ecf20Sopenharmony_ci	u16 i, j, k;
34188c2ecf20Sopenharmony_ci	u32 highLimit;
34198c2ecf20Sopenharmony_ci	u32 ctrlVal;
34208c2ecf20Sopenharmony_ci
34218c2ecf20Sopenharmony_ci	if (controlGroup == 1) /* Initial Control */ {
34228c2ecf20Sopenharmony_ci
34238c2ecf20Sopenharmony_ci		for (i = 0; i < state->Init_Ctrl_Num; i++) {
34248c2ecf20Sopenharmony_ci
34258c2ecf20Sopenharmony_ci			if (controlNum == state->Init_Ctrl[i].Ctrl_Num) {
34268c2ecf20Sopenharmony_ci
34278c2ecf20Sopenharmony_ci				highLimit = 1 << state->Init_Ctrl[i].size;
34288c2ecf20Sopenharmony_ci				if (value < highLimit) {
34298c2ecf20Sopenharmony_ci					for (j = 0; j < state->Init_Ctrl[i].size; j++) {
34308c2ecf20Sopenharmony_ci						state->Init_Ctrl[i].val[j] = (u8)((value >> j) & 0x01);
34318c2ecf20Sopenharmony_ci						MXL_RegWriteBit(fe, (u8)(state->Init_Ctrl[i].addr[j]),
34328c2ecf20Sopenharmony_ci							(u8)(state->Init_Ctrl[i].bit[j]),
34338c2ecf20Sopenharmony_ci							(u8)((value>>j) & 0x01));
34348c2ecf20Sopenharmony_ci					}
34358c2ecf20Sopenharmony_ci					ctrlVal = 0;
34368c2ecf20Sopenharmony_ci					for (k = 0; k < state->Init_Ctrl[i].size; k++)
34378c2ecf20Sopenharmony_ci						ctrlVal += state->Init_Ctrl[i].val[k] * (1 << k);
34388c2ecf20Sopenharmony_ci				} else
34398c2ecf20Sopenharmony_ci					return -1;
34408c2ecf20Sopenharmony_ci			}
34418c2ecf20Sopenharmony_ci		}
34428c2ecf20Sopenharmony_ci	}
34438c2ecf20Sopenharmony_ci	if (controlGroup == 2) /* Chan change Control */ {
34448c2ecf20Sopenharmony_ci
34458c2ecf20Sopenharmony_ci		for (i = 0; i < state->CH_Ctrl_Num; i++) {
34468c2ecf20Sopenharmony_ci
34478c2ecf20Sopenharmony_ci			if (controlNum == state->CH_Ctrl[i].Ctrl_Num) {
34488c2ecf20Sopenharmony_ci
34498c2ecf20Sopenharmony_ci				highLimit = 1 << state->CH_Ctrl[i].size;
34508c2ecf20Sopenharmony_ci				if (value < highLimit) {
34518c2ecf20Sopenharmony_ci					for (j = 0; j < state->CH_Ctrl[i].size; j++) {
34528c2ecf20Sopenharmony_ci						state->CH_Ctrl[i].val[j] = (u8)((value >> j) & 0x01);
34538c2ecf20Sopenharmony_ci						MXL_RegWriteBit(fe, (u8)(state->CH_Ctrl[i].addr[j]),
34548c2ecf20Sopenharmony_ci							(u8)(state->CH_Ctrl[i].bit[j]),
34558c2ecf20Sopenharmony_ci							(u8)((value>>j) & 0x01));
34568c2ecf20Sopenharmony_ci					}
34578c2ecf20Sopenharmony_ci					ctrlVal = 0;
34588c2ecf20Sopenharmony_ci					for (k = 0; k < state->CH_Ctrl[i].size; k++)
34598c2ecf20Sopenharmony_ci						ctrlVal += state->CH_Ctrl[i].val[k] * (1 << k);
34608c2ecf20Sopenharmony_ci				} else
34618c2ecf20Sopenharmony_ci					return -1;
34628c2ecf20Sopenharmony_ci			}
34638c2ecf20Sopenharmony_ci		}
34648c2ecf20Sopenharmony_ci	}
34658c2ecf20Sopenharmony_ci#ifdef _MXL_INTERNAL
34668c2ecf20Sopenharmony_ci	if (controlGroup == 3) /* Maxlinear Control */ {
34678c2ecf20Sopenharmony_ci
34688c2ecf20Sopenharmony_ci		for (i = 0; i < state->MXL_Ctrl_Num; i++) {
34698c2ecf20Sopenharmony_ci
34708c2ecf20Sopenharmony_ci			if (controlNum == state->MXL_Ctrl[i].Ctrl_Num) {
34718c2ecf20Sopenharmony_ci
34728c2ecf20Sopenharmony_ci				highLimit = (1 << state->MXL_Ctrl[i].size);
34738c2ecf20Sopenharmony_ci				if (value < highLimit) {
34748c2ecf20Sopenharmony_ci					for (j = 0; j < state->MXL_Ctrl[i].size; j++) {
34758c2ecf20Sopenharmony_ci						state->MXL_Ctrl[i].val[j] = (u8)((value >> j) & 0x01);
34768c2ecf20Sopenharmony_ci						MXL_RegWriteBit(fe, (u8)(state->MXL_Ctrl[i].addr[j]),
34778c2ecf20Sopenharmony_ci							(u8)(state->MXL_Ctrl[i].bit[j]),
34788c2ecf20Sopenharmony_ci							(u8)((value>>j) & 0x01));
34798c2ecf20Sopenharmony_ci					}
34808c2ecf20Sopenharmony_ci					ctrlVal = 0;
34818c2ecf20Sopenharmony_ci					for (k = 0; k < state->MXL_Ctrl[i].size; k++)
34828c2ecf20Sopenharmony_ci						ctrlVal += state->
34838c2ecf20Sopenharmony_ci							MXL_Ctrl[i].val[k] *
34848c2ecf20Sopenharmony_ci							(1 << k);
34858c2ecf20Sopenharmony_ci				} else
34868c2ecf20Sopenharmony_ci					return -1;
34878c2ecf20Sopenharmony_ci			}
34888c2ecf20Sopenharmony_ci		}
34898c2ecf20Sopenharmony_ci	}
34908c2ecf20Sopenharmony_ci#endif
34918c2ecf20Sopenharmony_ci	return 0 ; /* successful return */
34928c2ecf20Sopenharmony_ci}
34938c2ecf20Sopenharmony_ci
34948c2ecf20Sopenharmony_cistatic u16 MXL_RegRead(struct dvb_frontend *fe, u8 RegNum, u8 *RegVal)
34958c2ecf20Sopenharmony_ci{
34968c2ecf20Sopenharmony_ci	struct mxl5005s_state *state = fe->tuner_priv;
34978c2ecf20Sopenharmony_ci	int i ;
34988c2ecf20Sopenharmony_ci
34998c2ecf20Sopenharmony_ci	for (i = 0; i < 104; i++) {
35008c2ecf20Sopenharmony_ci		if (RegNum == state->TunerRegs[i].Reg_Num) {
35018c2ecf20Sopenharmony_ci			*RegVal = (u8)(state->TunerRegs[i].Reg_Val);
35028c2ecf20Sopenharmony_ci			return 0;
35038c2ecf20Sopenharmony_ci		}
35048c2ecf20Sopenharmony_ci	}
35058c2ecf20Sopenharmony_ci
35068c2ecf20Sopenharmony_ci	return 1;
35078c2ecf20Sopenharmony_ci}
35088c2ecf20Sopenharmony_ci
35098c2ecf20Sopenharmony_cistatic u16 MXL_ControlRead(struct dvb_frontend *fe, u16 controlNum, u32 *value)
35108c2ecf20Sopenharmony_ci{
35118c2ecf20Sopenharmony_ci	struct mxl5005s_state *state = fe->tuner_priv;
35128c2ecf20Sopenharmony_ci	u32 ctrlVal ;
35138c2ecf20Sopenharmony_ci	u16 i, k ;
35148c2ecf20Sopenharmony_ci
35158c2ecf20Sopenharmony_ci	for (i = 0; i < state->Init_Ctrl_Num ; i++) {
35168c2ecf20Sopenharmony_ci
35178c2ecf20Sopenharmony_ci		if (controlNum == state->Init_Ctrl[i].Ctrl_Num) {
35188c2ecf20Sopenharmony_ci
35198c2ecf20Sopenharmony_ci			ctrlVal = 0;
35208c2ecf20Sopenharmony_ci			for (k = 0; k < state->Init_Ctrl[i].size; k++)
35218c2ecf20Sopenharmony_ci				ctrlVal += state->Init_Ctrl[i].val[k] * (1<<k);
35228c2ecf20Sopenharmony_ci			*value = ctrlVal;
35238c2ecf20Sopenharmony_ci			return 0;
35248c2ecf20Sopenharmony_ci		}
35258c2ecf20Sopenharmony_ci	}
35268c2ecf20Sopenharmony_ci
35278c2ecf20Sopenharmony_ci	for (i = 0; i < state->CH_Ctrl_Num ; i++) {
35288c2ecf20Sopenharmony_ci
35298c2ecf20Sopenharmony_ci		if (controlNum == state->CH_Ctrl[i].Ctrl_Num) {
35308c2ecf20Sopenharmony_ci
35318c2ecf20Sopenharmony_ci			ctrlVal = 0;
35328c2ecf20Sopenharmony_ci			for (k = 0; k < state->CH_Ctrl[i].size; k++)
35338c2ecf20Sopenharmony_ci				ctrlVal += state->CH_Ctrl[i].val[k] * (1 << k);
35348c2ecf20Sopenharmony_ci			*value = ctrlVal;
35358c2ecf20Sopenharmony_ci			return 0;
35368c2ecf20Sopenharmony_ci
35378c2ecf20Sopenharmony_ci		}
35388c2ecf20Sopenharmony_ci	}
35398c2ecf20Sopenharmony_ci
35408c2ecf20Sopenharmony_ci#ifdef _MXL_INTERNAL
35418c2ecf20Sopenharmony_ci	for (i = 0; i < state->MXL_Ctrl_Num ; i++) {
35428c2ecf20Sopenharmony_ci
35438c2ecf20Sopenharmony_ci		if (controlNum == state->MXL_Ctrl[i].Ctrl_Num) {
35448c2ecf20Sopenharmony_ci
35458c2ecf20Sopenharmony_ci			ctrlVal = 0;
35468c2ecf20Sopenharmony_ci			for (k = 0; k < state->MXL_Ctrl[i].size; k++)
35478c2ecf20Sopenharmony_ci				ctrlVal += state->MXL_Ctrl[i].val[k] * (1<<k);
35488c2ecf20Sopenharmony_ci			*value = ctrlVal;
35498c2ecf20Sopenharmony_ci			return 0;
35508c2ecf20Sopenharmony_ci
35518c2ecf20Sopenharmony_ci		}
35528c2ecf20Sopenharmony_ci	}
35538c2ecf20Sopenharmony_ci#endif
35548c2ecf20Sopenharmony_ci	return 1;
35558c2ecf20Sopenharmony_ci}
35568c2ecf20Sopenharmony_ci
35578c2ecf20Sopenharmony_cistatic void MXL_RegWriteBit(struct dvb_frontend *fe, u8 address, u8 bit,
35588c2ecf20Sopenharmony_ci	u8 bitVal)
35598c2ecf20Sopenharmony_ci{
35608c2ecf20Sopenharmony_ci	struct mxl5005s_state *state = fe->tuner_priv;
35618c2ecf20Sopenharmony_ci	int i ;
35628c2ecf20Sopenharmony_ci
35638c2ecf20Sopenharmony_ci	const u8 AND_MAP[8] = {
35648c2ecf20Sopenharmony_ci		0xFE, 0xFD, 0xFB, 0xF7,
35658c2ecf20Sopenharmony_ci		0xEF, 0xDF, 0xBF, 0x7F } ;
35668c2ecf20Sopenharmony_ci
35678c2ecf20Sopenharmony_ci	const u8 OR_MAP[8] = {
35688c2ecf20Sopenharmony_ci		0x01, 0x02, 0x04, 0x08,
35698c2ecf20Sopenharmony_ci		0x10, 0x20, 0x40, 0x80 } ;
35708c2ecf20Sopenharmony_ci
35718c2ecf20Sopenharmony_ci	for (i = 0; i < state->TunerRegs_Num; i++) {
35728c2ecf20Sopenharmony_ci		if (state->TunerRegs[i].Reg_Num == address) {
35738c2ecf20Sopenharmony_ci			if (bitVal)
35748c2ecf20Sopenharmony_ci				state->TunerRegs[i].Reg_Val |= OR_MAP[bit];
35758c2ecf20Sopenharmony_ci			else
35768c2ecf20Sopenharmony_ci				state->TunerRegs[i].Reg_Val &= AND_MAP[bit];
35778c2ecf20Sopenharmony_ci			break ;
35788c2ecf20Sopenharmony_ci		}
35798c2ecf20Sopenharmony_ci	}
35808c2ecf20Sopenharmony_ci}
35818c2ecf20Sopenharmony_ci
35828c2ecf20Sopenharmony_cistatic u32 MXL_Ceiling(u32 value, u32 resolution)
35838c2ecf20Sopenharmony_ci{
35848c2ecf20Sopenharmony_ci	return value / resolution + (value % resolution > 0 ? 1 : 0);
35858c2ecf20Sopenharmony_ci}
35868c2ecf20Sopenharmony_ci
35878c2ecf20Sopenharmony_ci/* Retrieve the Initialization Registers */
35888c2ecf20Sopenharmony_cistatic u16 MXL_GetInitRegister(struct dvb_frontend *fe, u8 *RegNum,
35898c2ecf20Sopenharmony_ci	u8 *RegVal, int *count)
35908c2ecf20Sopenharmony_ci{
35918c2ecf20Sopenharmony_ci	u16 status = 0;
35928c2ecf20Sopenharmony_ci	int i ;
35938c2ecf20Sopenharmony_ci
35948c2ecf20Sopenharmony_ci	static const u8 RegAddr[] = {
35958c2ecf20Sopenharmony_ci		11, 12, 13, 22, 32, 43, 44, 53, 56, 59, 73,
35968c2ecf20Sopenharmony_ci		76, 77, 91, 134, 135, 137, 147,
35978c2ecf20Sopenharmony_ci		156, 166, 167, 168, 25
35988c2ecf20Sopenharmony_ci	};
35998c2ecf20Sopenharmony_ci
36008c2ecf20Sopenharmony_ci	*count = ARRAY_SIZE(RegAddr);
36018c2ecf20Sopenharmony_ci
36028c2ecf20Sopenharmony_ci	status += MXL_BlockInit(fe);
36038c2ecf20Sopenharmony_ci
36048c2ecf20Sopenharmony_ci	for (i = 0 ; i < *count; i++) {
36058c2ecf20Sopenharmony_ci		RegNum[i] = RegAddr[i];
36068c2ecf20Sopenharmony_ci		status += MXL_RegRead(fe, RegNum[i], &RegVal[i]);
36078c2ecf20Sopenharmony_ci	}
36088c2ecf20Sopenharmony_ci
36098c2ecf20Sopenharmony_ci	return status;
36108c2ecf20Sopenharmony_ci}
36118c2ecf20Sopenharmony_ci
36128c2ecf20Sopenharmony_cistatic u16 MXL_GetCHRegister(struct dvb_frontend *fe, u8 *RegNum, u8 *RegVal,
36138c2ecf20Sopenharmony_ci	int *count)
36148c2ecf20Sopenharmony_ci{
36158c2ecf20Sopenharmony_ci	u16 status = 0;
36168c2ecf20Sopenharmony_ci	int i ;
36178c2ecf20Sopenharmony_ci
36188c2ecf20Sopenharmony_ci/* add 77, 166, 167, 168 register for 2.6.12 */
36198c2ecf20Sopenharmony_ci#ifdef _MXL_PRODUCTION
36208c2ecf20Sopenharmony_ci	static const u8 RegAddr[] = {
36218c2ecf20Sopenharmony_ci		14, 15, 16, 17, 22, 43, 65, 68, 69, 70, 73, 92, 93, 106,
36228c2ecf20Sopenharmony_ci		107, 108, 109, 110, 111, 112, 136, 138, 149, 77, 166, 167, 168
36238c2ecf20Sopenharmony_ci	};
36248c2ecf20Sopenharmony_ci#else
36258c2ecf20Sopenharmony_ci	static const u8 RegAddr[] = {
36268c2ecf20Sopenharmony_ci		14, 15, 16, 17, 22, 43, 68, 69, 70, 73, 92, 93, 106,
36278c2ecf20Sopenharmony_ci		107, 108, 109, 110, 111, 112, 136, 138, 149, 77, 166, 167, 168
36288c2ecf20Sopenharmony_ci	};
36298c2ecf20Sopenharmony_ci	/*
36308c2ecf20Sopenharmony_ci	u8 RegAddr[171];
36318c2ecf20Sopenharmony_ci	for (i = 0; i <= 170; i++)
36328c2ecf20Sopenharmony_ci		RegAddr[i] = i;
36338c2ecf20Sopenharmony_ci	*/
36348c2ecf20Sopenharmony_ci#endif
36358c2ecf20Sopenharmony_ci
36368c2ecf20Sopenharmony_ci	*count = ARRAY_SIZE(RegAddr);
36378c2ecf20Sopenharmony_ci
36388c2ecf20Sopenharmony_ci	for (i = 0 ; i < *count; i++) {
36398c2ecf20Sopenharmony_ci		RegNum[i] = RegAddr[i];
36408c2ecf20Sopenharmony_ci		status += MXL_RegRead(fe, RegNum[i], &RegVal[i]);
36418c2ecf20Sopenharmony_ci	}
36428c2ecf20Sopenharmony_ci
36438c2ecf20Sopenharmony_ci	return status;
36448c2ecf20Sopenharmony_ci}
36458c2ecf20Sopenharmony_ci
36468c2ecf20Sopenharmony_cistatic u16 MXL_GetCHRegister_ZeroIF(struct dvb_frontend *fe, u8 *RegNum,
36478c2ecf20Sopenharmony_ci	u8 *RegVal, int *count)
36488c2ecf20Sopenharmony_ci{
36498c2ecf20Sopenharmony_ci	u16 status = 0;
36508c2ecf20Sopenharmony_ci	int i;
36518c2ecf20Sopenharmony_ci
36528c2ecf20Sopenharmony_ci	u8 RegAddr[] = {43, 136};
36538c2ecf20Sopenharmony_ci
36548c2ecf20Sopenharmony_ci	*count = ARRAY_SIZE(RegAddr);
36558c2ecf20Sopenharmony_ci
36568c2ecf20Sopenharmony_ci	for (i = 0; i < *count; i++) {
36578c2ecf20Sopenharmony_ci		RegNum[i] = RegAddr[i];
36588c2ecf20Sopenharmony_ci		status += MXL_RegRead(fe, RegNum[i], &RegVal[i]);
36598c2ecf20Sopenharmony_ci	}
36608c2ecf20Sopenharmony_ci
36618c2ecf20Sopenharmony_ci	return status;
36628c2ecf20Sopenharmony_ci}
36638c2ecf20Sopenharmony_ci
36648c2ecf20Sopenharmony_cistatic u16 MXL_GetMasterControl(u8 *MasterReg, int state)
36658c2ecf20Sopenharmony_ci{
36668c2ecf20Sopenharmony_ci	if (state == 1) /* Load_Start */
36678c2ecf20Sopenharmony_ci		*MasterReg = 0xF3;
36688c2ecf20Sopenharmony_ci	if (state == 2) /* Power_Down */
36698c2ecf20Sopenharmony_ci		*MasterReg = 0x41;
36708c2ecf20Sopenharmony_ci	if (state == 3) /* Synth_Reset */
36718c2ecf20Sopenharmony_ci		*MasterReg = 0xB1;
36728c2ecf20Sopenharmony_ci	if (state == 4) /* Seq_Off */
36738c2ecf20Sopenharmony_ci		*MasterReg = 0xF1;
36748c2ecf20Sopenharmony_ci
36758c2ecf20Sopenharmony_ci	return 0;
36768c2ecf20Sopenharmony_ci}
36778c2ecf20Sopenharmony_ci
36788c2ecf20Sopenharmony_ci#ifdef _MXL_PRODUCTION
36798c2ecf20Sopenharmony_cistatic u16 MXL_VCORange_Test(struct dvb_frontend *fe, int VCO_Range)
36808c2ecf20Sopenharmony_ci{
36818c2ecf20Sopenharmony_ci	struct mxl5005s_state *state = fe->tuner_priv;
36828c2ecf20Sopenharmony_ci	u16 status = 0 ;
36838c2ecf20Sopenharmony_ci
36848c2ecf20Sopenharmony_ci	if (VCO_Range == 1) {
36858c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, RFSYN_EN_DIV, 1);
36868c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, RFSYN_EN_OUTMUX, 0);
36878c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, RFSYN_SEL_DIVM, 0);
36888c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, RFSYN_DIVM, 1);
36898c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_OUT, 1);
36908c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, RFSYN_RF_DIV_BIAS, 1);
36918c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, DN_SEL_FREQ, 0);
36928c2ecf20Sopenharmony_ci		if (state->Mode == 0 && state->IF_Mode == 1) {
36938c2ecf20Sopenharmony_ci			/* Analog Low IF Mode */
36948c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 1);
36958c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, RFSYN_VCO_BIAS, 8);
36968c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, CHCAL_INT_MOD_RF, 56);
36978c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe,
36988c2ecf20Sopenharmony_ci				CHCAL_FRAC_MOD_RF, 180224);
36998c2ecf20Sopenharmony_ci		}
37008c2ecf20Sopenharmony_ci		if (state->Mode == 0 && state->IF_Mode == 0) {
37018c2ecf20Sopenharmony_ci			/* Analog Zero IF Mode */
37028c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 1);
37038c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, RFSYN_VCO_BIAS, 8);
37048c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, CHCAL_INT_MOD_RF, 56);
37058c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe,
37068c2ecf20Sopenharmony_ci				CHCAL_FRAC_MOD_RF, 222822);
37078c2ecf20Sopenharmony_ci		}
37088c2ecf20Sopenharmony_ci		if (state->Mode == 1) /* Digital Mode */ {
37098c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 1);
37108c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, RFSYN_VCO_BIAS, 8);
37118c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, CHCAL_INT_MOD_RF, 56);
37128c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe,
37138c2ecf20Sopenharmony_ci				CHCAL_FRAC_MOD_RF, 229376);
37148c2ecf20Sopenharmony_ci		}
37158c2ecf20Sopenharmony_ci	}
37168c2ecf20Sopenharmony_ci
37178c2ecf20Sopenharmony_ci	if (VCO_Range == 2) {
37188c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, RFSYN_EN_DIV, 1);
37198c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, RFSYN_EN_OUTMUX, 0);
37208c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, RFSYN_SEL_DIVM, 0);
37218c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, RFSYN_DIVM, 1);
37228c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_OUT, 1);
37238c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, RFSYN_RF_DIV_BIAS, 1);
37248c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, DN_SEL_FREQ, 0);
37258c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 1);
37268c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, RFSYN_VCO_BIAS, 40);
37278c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, CHCAL_INT_MOD_RF, 41);
37288c2ecf20Sopenharmony_ci		if (state->Mode == 0 && state->IF_Mode == 1) {
37298c2ecf20Sopenharmony_ci			/* Analog Low IF Mode */
37308c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 1);
37318c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, RFSYN_VCO_BIAS, 40);
37328c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, CHCAL_INT_MOD_RF, 42);
37338c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe,
37348c2ecf20Sopenharmony_ci				CHCAL_FRAC_MOD_RF, 206438);
37358c2ecf20Sopenharmony_ci		}
37368c2ecf20Sopenharmony_ci		if (state->Mode == 0 && state->IF_Mode == 0) {
37378c2ecf20Sopenharmony_ci			/* Analog Zero IF Mode */
37388c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 1);
37398c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, RFSYN_VCO_BIAS, 40);
37408c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, CHCAL_INT_MOD_RF, 42);
37418c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe,
37428c2ecf20Sopenharmony_ci				CHCAL_FRAC_MOD_RF, 206438);
37438c2ecf20Sopenharmony_ci		}
37448c2ecf20Sopenharmony_ci		if (state->Mode == 1) /* Digital Mode */ {
37458c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 1);
37468c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, RFSYN_VCO_BIAS, 40);
37478c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, CHCAL_INT_MOD_RF, 41);
37488c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe,
37498c2ecf20Sopenharmony_ci				CHCAL_FRAC_MOD_RF, 16384);
37508c2ecf20Sopenharmony_ci		}
37518c2ecf20Sopenharmony_ci	}
37528c2ecf20Sopenharmony_ci
37538c2ecf20Sopenharmony_ci	if (VCO_Range == 3) {
37548c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, RFSYN_EN_DIV, 1);
37558c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, RFSYN_EN_OUTMUX, 0);
37568c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, RFSYN_SEL_DIVM, 0);
37578c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, RFSYN_DIVM, 1);
37588c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_OUT, 1);
37598c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, RFSYN_RF_DIV_BIAS, 1);
37608c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, DN_SEL_FREQ, 0);
37618c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 0);
37628c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, RFSYN_VCO_BIAS, 8);
37638c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, CHCAL_INT_MOD_RF, 42);
37648c2ecf20Sopenharmony_ci		if (state->Mode == 0 && state->IF_Mode == 1) {
37658c2ecf20Sopenharmony_ci			/* Analog Low IF Mode */
37668c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 0);
37678c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, RFSYN_VCO_BIAS, 8);
37688c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, CHCAL_INT_MOD_RF, 44);
37698c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe,
37708c2ecf20Sopenharmony_ci				CHCAL_FRAC_MOD_RF, 173670);
37718c2ecf20Sopenharmony_ci		}
37728c2ecf20Sopenharmony_ci		if (state->Mode == 0 && state->IF_Mode == 0) {
37738c2ecf20Sopenharmony_ci			/* Analog Zero IF Mode */
37748c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 0);
37758c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, RFSYN_VCO_BIAS, 8);
37768c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, CHCAL_INT_MOD_RF, 44);
37778c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe,
37788c2ecf20Sopenharmony_ci				CHCAL_FRAC_MOD_RF, 173670);
37798c2ecf20Sopenharmony_ci		}
37808c2ecf20Sopenharmony_ci		if (state->Mode == 1) /* Digital Mode */ {
37818c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 0);
37828c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, RFSYN_VCO_BIAS, 8);
37838c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, CHCAL_INT_MOD_RF, 42);
37848c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe,
37858c2ecf20Sopenharmony_ci				CHCAL_FRAC_MOD_RF, 245760);
37868c2ecf20Sopenharmony_ci		}
37878c2ecf20Sopenharmony_ci	}
37888c2ecf20Sopenharmony_ci
37898c2ecf20Sopenharmony_ci	if (VCO_Range == 4) {
37908c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, RFSYN_EN_DIV, 1);
37918c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, RFSYN_EN_OUTMUX, 0);
37928c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, RFSYN_SEL_DIVM, 0);
37938c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, RFSYN_DIVM, 1);
37948c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_OUT, 1);
37958c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, RFSYN_RF_DIV_BIAS, 1);
37968c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, DN_SEL_FREQ, 0);
37978c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 0);
37988c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, RFSYN_VCO_BIAS, 40);
37998c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, CHCAL_INT_MOD_RF, 27);
38008c2ecf20Sopenharmony_ci		if (state->Mode == 0 && state->IF_Mode == 1) {
38018c2ecf20Sopenharmony_ci			/* Analog Low IF Mode */
38028c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 0);
38038c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, RFSYN_VCO_BIAS, 40);
38048c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, CHCAL_INT_MOD_RF, 27);
38058c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe,
38068c2ecf20Sopenharmony_ci				CHCAL_FRAC_MOD_RF, 206438);
38078c2ecf20Sopenharmony_ci		}
38088c2ecf20Sopenharmony_ci		if (state->Mode == 0 && state->IF_Mode == 0) {
38098c2ecf20Sopenharmony_ci			/* Analog Zero IF Mode */
38108c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 0);
38118c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, RFSYN_VCO_BIAS, 40);
38128c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, CHCAL_INT_MOD_RF, 27);
38138c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe,
38148c2ecf20Sopenharmony_ci				CHCAL_FRAC_MOD_RF, 206438);
38158c2ecf20Sopenharmony_ci		}
38168c2ecf20Sopenharmony_ci		if (state->Mode == 1) /* Digital Mode */ {
38178c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 0);
38188c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, RFSYN_VCO_BIAS, 40);
38198c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe, CHCAL_INT_MOD_RF, 27);
38208c2ecf20Sopenharmony_ci			status += MXL_ControlWrite(fe,
38218c2ecf20Sopenharmony_ci				CHCAL_FRAC_MOD_RF, 212992);
38228c2ecf20Sopenharmony_ci		}
38238c2ecf20Sopenharmony_ci	}
38248c2ecf20Sopenharmony_ci
38258c2ecf20Sopenharmony_ci	return status;
38268c2ecf20Sopenharmony_ci}
38278c2ecf20Sopenharmony_ci
38288c2ecf20Sopenharmony_cistatic u16 MXL_Hystersis_Test(struct dvb_frontend *fe, int Hystersis)
38298c2ecf20Sopenharmony_ci{
38308c2ecf20Sopenharmony_ci	struct mxl5005s_state *state = fe->tuner_priv;
38318c2ecf20Sopenharmony_ci	u16 status = 0;
38328c2ecf20Sopenharmony_ci
38338c2ecf20Sopenharmony_ci	if (Hystersis == 1)
38348c2ecf20Sopenharmony_ci		status += MXL_ControlWrite(fe, DN_BYPASS_AGC_I2C, 1);
38358c2ecf20Sopenharmony_ci
38368c2ecf20Sopenharmony_ci	return status;
38378c2ecf20Sopenharmony_ci}
38388c2ecf20Sopenharmony_ci#endif
38398c2ecf20Sopenharmony_ci/* End: Reference driver code found in the Realtek driver that
38408c2ecf20Sopenharmony_ci * is copyright MaxLinear */
38418c2ecf20Sopenharmony_ci
38428c2ecf20Sopenharmony_ci/* ----------------------------------------------------------------
38438c2ecf20Sopenharmony_ci * Begin: Everything after here is new code to adapt the
38448c2ecf20Sopenharmony_ci * proprietary Realtek driver into a Linux API tuner.
38458c2ecf20Sopenharmony_ci * Copyright (C) 2008 Steven Toth <stoth@linuxtv.org>
38468c2ecf20Sopenharmony_ci */
38478c2ecf20Sopenharmony_cistatic int mxl5005s_reset(struct dvb_frontend *fe)
38488c2ecf20Sopenharmony_ci{
38498c2ecf20Sopenharmony_ci	struct mxl5005s_state *state = fe->tuner_priv;
38508c2ecf20Sopenharmony_ci	int ret = 0;
38518c2ecf20Sopenharmony_ci
38528c2ecf20Sopenharmony_ci	u8 buf[2] = { 0xff, 0x00 };
38538c2ecf20Sopenharmony_ci	struct i2c_msg msg = { .addr = state->config->i2c_address, .flags = 0,
38548c2ecf20Sopenharmony_ci			       .buf = buf, .len = 2 };
38558c2ecf20Sopenharmony_ci
38568c2ecf20Sopenharmony_ci	dprintk(2, "%s()\n", __func__);
38578c2ecf20Sopenharmony_ci
38588c2ecf20Sopenharmony_ci	if (fe->ops.i2c_gate_ctrl)
38598c2ecf20Sopenharmony_ci		fe->ops.i2c_gate_ctrl(fe, 1);
38608c2ecf20Sopenharmony_ci
38618c2ecf20Sopenharmony_ci	if (i2c_transfer(state->i2c, &msg, 1) != 1) {
38628c2ecf20Sopenharmony_ci		printk(KERN_WARNING "mxl5005s I2C reset failed\n");
38638c2ecf20Sopenharmony_ci		ret = -EREMOTEIO;
38648c2ecf20Sopenharmony_ci	}
38658c2ecf20Sopenharmony_ci
38668c2ecf20Sopenharmony_ci	if (fe->ops.i2c_gate_ctrl)
38678c2ecf20Sopenharmony_ci		fe->ops.i2c_gate_ctrl(fe, 0);
38688c2ecf20Sopenharmony_ci
38698c2ecf20Sopenharmony_ci	return ret;
38708c2ecf20Sopenharmony_ci}
38718c2ecf20Sopenharmony_ci
38728c2ecf20Sopenharmony_ci/* Write a single byte to a single reg, latch the value if required by
38738c2ecf20Sopenharmony_ci * following the transaction with the latch byte.
38748c2ecf20Sopenharmony_ci */
38758c2ecf20Sopenharmony_cistatic int mxl5005s_writereg(struct dvb_frontend *fe, u8 reg, u8 val, int latch)
38768c2ecf20Sopenharmony_ci{
38778c2ecf20Sopenharmony_ci	struct mxl5005s_state *state = fe->tuner_priv;
38788c2ecf20Sopenharmony_ci	u8 buf[3] = { reg, val, MXL5005S_LATCH_BYTE };
38798c2ecf20Sopenharmony_ci	struct i2c_msg msg = { .addr = state->config->i2c_address, .flags = 0,
38808c2ecf20Sopenharmony_ci			       .buf = buf, .len = 3 };
38818c2ecf20Sopenharmony_ci
38828c2ecf20Sopenharmony_ci	if (latch == 0)
38838c2ecf20Sopenharmony_ci		msg.len = 2;
38848c2ecf20Sopenharmony_ci
38858c2ecf20Sopenharmony_ci	dprintk(2, "%s(0x%x, 0x%x, 0x%x)\n", __func__, reg, val, msg.addr);
38868c2ecf20Sopenharmony_ci
38878c2ecf20Sopenharmony_ci	if (i2c_transfer(state->i2c, &msg, 1) != 1) {
38888c2ecf20Sopenharmony_ci		printk(KERN_WARNING "mxl5005s I2C write failed\n");
38898c2ecf20Sopenharmony_ci		return -EREMOTEIO;
38908c2ecf20Sopenharmony_ci	}
38918c2ecf20Sopenharmony_ci	return 0;
38928c2ecf20Sopenharmony_ci}
38938c2ecf20Sopenharmony_ci
38948c2ecf20Sopenharmony_cistatic int mxl5005s_writeregs(struct dvb_frontend *fe, u8 *addrtable,
38958c2ecf20Sopenharmony_ci	u8 *datatable, u8 len)
38968c2ecf20Sopenharmony_ci{
38978c2ecf20Sopenharmony_ci	int ret = 0, i;
38988c2ecf20Sopenharmony_ci
38998c2ecf20Sopenharmony_ci	if (fe->ops.i2c_gate_ctrl)
39008c2ecf20Sopenharmony_ci		fe->ops.i2c_gate_ctrl(fe, 1);
39018c2ecf20Sopenharmony_ci
39028c2ecf20Sopenharmony_ci	for (i = 0 ; i < len-1; i++) {
39038c2ecf20Sopenharmony_ci		ret = mxl5005s_writereg(fe, addrtable[i], datatable[i], 0);
39048c2ecf20Sopenharmony_ci		if (ret < 0)
39058c2ecf20Sopenharmony_ci			break;
39068c2ecf20Sopenharmony_ci	}
39078c2ecf20Sopenharmony_ci
39088c2ecf20Sopenharmony_ci	ret = mxl5005s_writereg(fe, addrtable[i], datatable[i], 1);
39098c2ecf20Sopenharmony_ci
39108c2ecf20Sopenharmony_ci	if (fe->ops.i2c_gate_ctrl)
39118c2ecf20Sopenharmony_ci		fe->ops.i2c_gate_ctrl(fe, 0);
39128c2ecf20Sopenharmony_ci
39138c2ecf20Sopenharmony_ci	return ret;
39148c2ecf20Sopenharmony_ci}
39158c2ecf20Sopenharmony_ci
39168c2ecf20Sopenharmony_cistatic int mxl5005s_init(struct dvb_frontend *fe)
39178c2ecf20Sopenharmony_ci{
39188c2ecf20Sopenharmony_ci	struct mxl5005s_state *state = fe->tuner_priv;
39198c2ecf20Sopenharmony_ci
39208c2ecf20Sopenharmony_ci	dprintk(1, "%s()\n", __func__);
39218c2ecf20Sopenharmony_ci	state->current_mode = MXL_QAM;
39228c2ecf20Sopenharmony_ci	return mxl5005s_reconfigure(fe, MXL_QAM, MXL5005S_BANDWIDTH_6MHZ);
39238c2ecf20Sopenharmony_ci}
39248c2ecf20Sopenharmony_ci
39258c2ecf20Sopenharmony_cistatic int mxl5005s_reconfigure(struct dvb_frontend *fe, u32 mod_type,
39268c2ecf20Sopenharmony_ci	u32 bandwidth)
39278c2ecf20Sopenharmony_ci{
39288c2ecf20Sopenharmony_ci	struct mxl5005s_state *state = fe->tuner_priv;
39298c2ecf20Sopenharmony_ci
39308c2ecf20Sopenharmony_ci	u8 AddrTable[MXL5005S_REG_WRITING_TABLE_LEN_MAX];
39318c2ecf20Sopenharmony_ci	u8 ByteTable[MXL5005S_REG_WRITING_TABLE_LEN_MAX];
39328c2ecf20Sopenharmony_ci	int TableLen;
39338c2ecf20Sopenharmony_ci
39348c2ecf20Sopenharmony_ci	dprintk(1, "%s(type=%d, bw=%d)\n", __func__, mod_type, bandwidth);
39358c2ecf20Sopenharmony_ci
39368c2ecf20Sopenharmony_ci	mxl5005s_reset(fe);
39378c2ecf20Sopenharmony_ci
39388c2ecf20Sopenharmony_ci	/* Tuner initialization stage 0 */
39398c2ecf20Sopenharmony_ci	MXL_GetMasterControl(ByteTable, MC_SYNTH_RESET);
39408c2ecf20Sopenharmony_ci	AddrTable[0] = MASTER_CONTROL_ADDR;
39418c2ecf20Sopenharmony_ci	ByteTable[0] |= state->config->AgcMasterByte;
39428c2ecf20Sopenharmony_ci
39438c2ecf20Sopenharmony_ci	mxl5005s_writeregs(fe, AddrTable, ByteTable, 1);
39448c2ecf20Sopenharmony_ci
39458c2ecf20Sopenharmony_ci	mxl5005s_AssignTunerMode(fe, mod_type, bandwidth);
39468c2ecf20Sopenharmony_ci
39478c2ecf20Sopenharmony_ci	/* Tuner initialization stage 1 */
39488c2ecf20Sopenharmony_ci	MXL_GetInitRegister(fe, AddrTable, ByteTable, &TableLen);
39498c2ecf20Sopenharmony_ci
39508c2ecf20Sopenharmony_ci	mxl5005s_writeregs(fe, AddrTable, ByteTable, TableLen);
39518c2ecf20Sopenharmony_ci
39528c2ecf20Sopenharmony_ci	return 0;
39538c2ecf20Sopenharmony_ci}
39548c2ecf20Sopenharmony_ci
39558c2ecf20Sopenharmony_cistatic int mxl5005s_AssignTunerMode(struct dvb_frontend *fe, u32 mod_type,
39568c2ecf20Sopenharmony_ci	u32 bandwidth)
39578c2ecf20Sopenharmony_ci{
39588c2ecf20Sopenharmony_ci	struct mxl5005s_state *state = fe->tuner_priv;
39598c2ecf20Sopenharmony_ci	struct mxl5005s_config *c = state->config;
39608c2ecf20Sopenharmony_ci
39618c2ecf20Sopenharmony_ci	InitTunerControls(fe);
39628c2ecf20Sopenharmony_ci
39638c2ecf20Sopenharmony_ci	/* Set MxL5005S parameters. */
39648c2ecf20Sopenharmony_ci	MXL5005_TunerConfig(
39658c2ecf20Sopenharmony_ci		fe,
39668c2ecf20Sopenharmony_ci		c->mod_mode,
39678c2ecf20Sopenharmony_ci		c->if_mode,
39688c2ecf20Sopenharmony_ci		bandwidth,
39698c2ecf20Sopenharmony_ci		c->if_freq,
39708c2ecf20Sopenharmony_ci		c->xtal_freq,
39718c2ecf20Sopenharmony_ci		c->agc_mode,
39728c2ecf20Sopenharmony_ci		c->top,
39738c2ecf20Sopenharmony_ci		c->output_load,
39748c2ecf20Sopenharmony_ci		c->clock_out,
39758c2ecf20Sopenharmony_ci		c->div_out,
39768c2ecf20Sopenharmony_ci		c->cap_select,
39778c2ecf20Sopenharmony_ci		c->rssi_enable,
39788c2ecf20Sopenharmony_ci		mod_type,
39798c2ecf20Sopenharmony_ci		c->tracking_filter);
39808c2ecf20Sopenharmony_ci
39818c2ecf20Sopenharmony_ci	return 0;
39828c2ecf20Sopenharmony_ci}
39838c2ecf20Sopenharmony_ci
39848c2ecf20Sopenharmony_cistatic int mxl5005s_set_params(struct dvb_frontend *fe)
39858c2ecf20Sopenharmony_ci{
39868c2ecf20Sopenharmony_ci	struct mxl5005s_state *state = fe->tuner_priv;
39878c2ecf20Sopenharmony_ci	struct dtv_frontend_properties *c = &fe->dtv_property_cache;
39888c2ecf20Sopenharmony_ci	u32 delsys = c->delivery_system;
39898c2ecf20Sopenharmony_ci	u32 bw = c->bandwidth_hz;
39908c2ecf20Sopenharmony_ci	u32 req_mode, req_bw = 0;
39918c2ecf20Sopenharmony_ci	int ret;
39928c2ecf20Sopenharmony_ci
39938c2ecf20Sopenharmony_ci	dprintk(1, "%s()\n", __func__);
39948c2ecf20Sopenharmony_ci
39958c2ecf20Sopenharmony_ci	switch (delsys) {
39968c2ecf20Sopenharmony_ci	case SYS_ATSC:
39978c2ecf20Sopenharmony_ci		req_mode = MXL_ATSC;
39988c2ecf20Sopenharmony_ci		req_bw  = MXL5005S_BANDWIDTH_6MHZ;
39998c2ecf20Sopenharmony_ci		break;
40008c2ecf20Sopenharmony_ci	case SYS_DVBC_ANNEX_B:
40018c2ecf20Sopenharmony_ci		req_mode = MXL_QAM;
40028c2ecf20Sopenharmony_ci		req_bw  = MXL5005S_BANDWIDTH_6MHZ;
40038c2ecf20Sopenharmony_ci		break;
40048c2ecf20Sopenharmony_ci	default:	/* Assume DVB-T */
40058c2ecf20Sopenharmony_ci		req_mode = MXL_DVBT;
40068c2ecf20Sopenharmony_ci		switch (bw) {
40078c2ecf20Sopenharmony_ci		case 6000000:
40088c2ecf20Sopenharmony_ci			req_bw = MXL5005S_BANDWIDTH_6MHZ;
40098c2ecf20Sopenharmony_ci			break;
40108c2ecf20Sopenharmony_ci		case 7000000:
40118c2ecf20Sopenharmony_ci			req_bw = MXL5005S_BANDWIDTH_7MHZ;
40128c2ecf20Sopenharmony_ci			break;
40138c2ecf20Sopenharmony_ci		case 8000000:
40148c2ecf20Sopenharmony_ci		case 0:
40158c2ecf20Sopenharmony_ci			req_bw = MXL5005S_BANDWIDTH_8MHZ;
40168c2ecf20Sopenharmony_ci			break;
40178c2ecf20Sopenharmony_ci		default:
40188c2ecf20Sopenharmony_ci			return -EINVAL;
40198c2ecf20Sopenharmony_ci		}
40208c2ecf20Sopenharmony_ci	}
40218c2ecf20Sopenharmony_ci
40228c2ecf20Sopenharmony_ci	/* Change tuner for new modulation type if reqd */
40238c2ecf20Sopenharmony_ci	if (req_mode != state->current_mode ||
40248c2ecf20Sopenharmony_ci	    req_bw != state->Chan_Bandwidth) {
40258c2ecf20Sopenharmony_ci		state->current_mode = req_mode;
40268c2ecf20Sopenharmony_ci		ret = mxl5005s_reconfigure(fe, req_mode, req_bw);
40278c2ecf20Sopenharmony_ci
40288c2ecf20Sopenharmony_ci	} else
40298c2ecf20Sopenharmony_ci		ret = 0;
40308c2ecf20Sopenharmony_ci
40318c2ecf20Sopenharmony_ci	if (ret == 0) {
40328c2ecf20Sopenharmony_ci		dprintk(1, "%s() freq=%d\n", __func__, c->frequency);
40338c2ecf20Sopenharmony_ci		ret = mxl5005s_SetRfFreqHz(fe, c->frequency);
40348c2ecf20Sopenharmony_ci	}
40358c2ecf20Sopenharmony_ci
40368c2ecf20Sopenharmony_ci	return ret;
40378c2ecf20Sopenharmony_ci}
40388c2ecf20Sopenharmony_ci
40398c2ecf20Sopenharmony_cistatic int mxl5005s_get_frequency(struct dvb_frontend *fe, u32 *frequency)
40408c2ecf20Sopenharmony_ci{
40418c2ecf20Sopenharmony_ci	struct mxl5005s_state *state = fe->tuner_priv;
40428c2ecf20Sopenharmony_ci	dprintk(1, "%s()\n", __func__);
40438c2ecf20Sopenharmony_ci
40448c2ecf20Sopenharmony_ci	*frequency = state->RF_IN;
40458c2ecf20Sopenharmony_ci
40468c2ecf20Sopenharmony_ci	return 0;
40478c2ecf20Sopenharmony_ci}
40488c2ecf20Sopenharmony_ci
40498c2ecf20Sopenharmony_cistatic int mxl5005s_get_bandwidth(struct dvb_frontend *fe, u32 *bandwidth)
40508c2ecf20Sopenharmony_ci{
40518c2ecf20Sopenharmony_ci	struct mxl5005s_state *state = fe->tuner_priv;
40528c2ecf20Sopenharmony_ci	dprintk(1, "%s()\n", __func__);
40538c2ecf20Sopenharmony_ci
40548c2ecf20Sopenharmony_ci	*bandwidth = state->Chan_Bandwidth;
40558c2ecf20Sopenharmony_ci
40568c2ecf20Sopenharmony_ci	return 0;
40578c2ecf20Sopenharmony_ci}
40588c2ecf20Sopenharmony_ci
40598c2ecf20Sopenharmony_cistatic int mxl5005s_get_if_frequency(struct dvb_frontend *fe, u32 *frequency)
40608c2ecf20Sopenharmony_ci{
40618c2ecf20Sopenharmony_ci	struct mxl5005s_state *state = fe->tuner_priv;
40628c2ecf20Sopenharmony_ci	dprintk(1, "%s()\n", __func__);
40638c2ecf20Sopenharmony_ci
40648c2ecf20Sopenharmony_ci	*frequency = state->IF_OUT;
40658c2ecf20Sopenharmony_ci
40668c2ecf20Sopenharmony_ci	return 0;
40678c2ecf20Sopenharmony_ci}
40688c2ecf20Sopenharmony_ci
40698c2ecf20Sopenharmony_cistatic void mxl5005s_release(struct dvb_frontend *fe)
40708c2ecf20Sopenharmony_ci{
40718c2ecf20Sopenharmony_ci	dprintk(1, "%s()\n", __func__);
40728c2ecf20Sopenharmony_ci	kfree(fe->tuner_priv);
40738c2ecf20Sopenharmony_ci	fe->tuner_priv = NULL;
40748c2ecf20Sopenharmony_ci}
40758c2ecf20Sopenharmony_ci
40768c2ecf20Sopenharmony_cistatic const struct dvb_tuner_ops mxl5005s_tuner_ops = {
40778c2ecf20Sopenharmony_ci	.info = {
40788c2ecf20Sopenharmony_ci		.name              = "MaxLinear MXL5005S",
40798c2ecf20Sopenharmony_ci		.frequency_min_hz  =  48 * MHz,
40808c2ecf20Sopenharmony_ci		.frequency_max_hz  = 860 * MHz,
40818c2ecf20Sopenharmony_ci		.frequency_step_hz =  50 * kHz,
40828c2ecf20Sopenharmony_ci	},
40838c2ecf20Sopenharmony_ci
40848c2ecf20Sopenharmony_ci	.release       = mxl5005s_release,
40858c2ecf20Sopenharmony_ci	.init          = mxl5005s_init,
40868c2ecf20Sopenharmony_ci
40878c2ecf20Sopenharmony_ci	.set_params    = mxl5005s_set_params,
40888c2ecf20Sopenharmony_ci	.get_frequency = mxl5005s_get_frequency,
40898c2ecf20Sopenharmony_ci	.get_bandwidth = mxl5005s_get_bandwidth,
40908c2ecf20Sopenharmony_ci	.get_if_frequency = mxl5005s_get_if_frequency,
40918c2ecf20Sopenharmony_ci};
40928c2ecf20Sopenharmony_ci
40938c2ecf20Sopenharmony_cistruct dvb_frontend *mxl5005s_attach(struct dvb_frontend *fe,
40948c2ecf20Sopenharmony_ci				     struct i2c_adapter *i2c,
40958c2ecf20Sopenharmony_ci				     struct mxl5005s_config *config)
40968c2ecf20Sopenharmony_ci{
40978c2ecf20Sopenharmony_ci	struct mxl5005s_state *state = NULL;
40988c2ecf20Sopenharmony_ci	dprintk(1, "%s()\n", __func__);
40998c2ecf20Sopenharmony_ci
41008c2ecf20Sopenharmony_ci	state = kzalloc(sizeof(struct mxl5005s_state), GFP_KERNEL);
41018c2ecf20Sopenharmony_ci	if (state == NULL)
41028c2ecf20Sopenharmony_ci		return NULL;
41038c2ecf20Sopenharmony_ci
41048c2ecf20Sopenharmony_ci	state->frontend = fe;
41058c2ecf20Sopenharmony_ci	state->config = config;
41068c2ecf20Sopenharmony_ci	state->i2c = i2c;
41078c2ecf20Sopenharmony_ci
41088c2ecf20Sopenharmony_ci	printk(KERN_INFO "MXL5005S: Attached at address 0x%02x\n",
41098c2ecf20Sopenharmony_ci		config->i2c_address);
41108c2ecf20Sopenharmony_ci
41118c2ecf20Sopenharmony_ci	memcpy(&fe->ops.tuner_ops, &mxl5005s_tuner_ops,
41128c2ecf20Sopenharmony_ci		sizeof(struct dvb_tuner_ops));
41138c2ecf20Sopenharmony_ci
41148c2ecf20Sopenharmony_ci	fe->tuner_priv = state;
41158c2ecf20Sopenharmony_ci	return fe;
41168c2ecf20Sopenharmony_ci}
41178c2ecf20Sopenharmony_ciEXPORT_SYMBOL_GPL(mxl5005s_attach);
41188c2ecf20Sopenharmony_ci
41198c2ecf20Sopenharmony_ciMODULE_DESCRIPTION("MaxLinear MXL5005S silicon tuner driver");
41208c2ecf20Sopenharmony_ciMODULE_AUTHOR("Steven Toth");
41218c2ecf20Sopenharmony_ciMODULE_LICENSE("GPL");
4122