提交 dcd52d20 编写于 作者: M Mauro Carvalho Chehab

[media] mt2063: Use state for the state structure

Signed-off-by: NMauro Carvalho Chehab <mchehab@redhat.com>
上级 51f0f7b3
...@@ -415,12 +415,12 @@ struct mt2063_state { ...@@ -415,12 +415,12 @@ struct mt2063_state {
/* Prototypes */ /* Prototypes */
static void MT2063_AddExclZone(struct MT2063_AvoidSpursData_t *pAS_Info, static void MT2063_AddExclZone(struct MT2063_AvoidSpursData_t *pAS_Info,
u32 f_min, u32 f_max); u32 f_min, u32 f_max);
static u32 MT2063_ReInit(struct mt2063_state *pInfo); static u32 MT2063_ReInit(struct mt2063_state *state);
static u32 MT2063_Close(struct mt2063_state *pInfo); static u32 MT2063_Close(struct mt2063_state *state);
static u32 MT2063_GetReg(struct mt2063_state *pInfo, u8 reg, u8 * val); static u32 MT2063_GetReg(struct mt2063_state *state, u8 reg, u8 * val);
static u32 MT2063_GetParam(struct mt2063_state *pInfo, enum MT2063_Param param, u32 * pValue); static u32 MT2063_GetParam(struct mt2063_state *state, enum MT2063_Param param, u32 * pValue);
static u32 MT2063_SetReg(struct mt2063_state *pInfo, u8 reg, u8 val); static u32 MT2063_SetReg(struct mt2063_state *state, u8 reg, u8 val);
static u32 MT2063_SetParam(struct mt2063_state *pInfo, enum MT2063_Param param, static u32 MT2063_SetParam(struct mt2063_state *state, enum MT2063_Param param,
enum MT2063_DNC_Output_Enable nValue); enum MT2063_DNC_Output_Enable nValue);
/*****************/ /*****************/
...@@ -1980,7 +1980,7 @@ static u32 MT2063_Close(struct mt2063_state *state) ...@@ -1980,7 +1980,7 @@ static u32 MT2063_Close(struct mt2063_state *state)
** 138 06-19-2007 DAD Ver 1.00: Initial, derived from mt2067_b. ** 138 06-19-2007 DAD Ver 1.00: Initial, derived from mt2067_b.
** **
****************************************************************************/ ****************************************************************************/
static u32 MT2063_GetLocked(struct mt2063_state *pInfo) static u32 MT2063_GetLocked(struct mt2063_state *state)
{ {
const u32 nMaxWait = 100; /* wait a maximum of 100 msec */ const u32 nMaxWait = 100; /* wait a maximum of 100 msec */
const u32 nPollRate = 2; /* poll status bits every 2 ms */ const u32 nPollRate = 2; /* poll status bits every 2 ms */
...@@ -1991,19 +1991,19 @@ static u32 MT2063_GetLocked(struct mt2063_state *pInfo) ...@@ -1991,19 +1991,19 @@ static u32 MT2063_GetLocked(struct mt2063_state *pInfo)
u32 nDelays = 0; u32 nDelays = 0;
/* LO2 Lock bit was in a different place for B0 version */ /* LO2 Lock bit was in a different place for B0 version */
if (pInfo->tuner_id == MT2063_B0) if (state->tuner_id == MT2063_B0)
LO2LK = 0x40; LO2LK = 0x40;
do { do {
status |= status |=
MT2063_ReadSub(pInfo, MT2063_ReadSub(state,
MT2063_REG_LO_STATUS, MT2063_REG_LO_STATUS,
&pInfo->reg[MT2063_REG_LO_STATUS], 1); &state->reg[MT2063_REG_LO_STATUS], 1);
if (status < 0) if (status < 0)
return (status); return (status);
if ((pInfo->reg[MT2063_REG_LO_STATUS] & (LO1LK | LO2LK)) == if ((state->reg[MT2063_REG_LO_STATUS] & (LO1LK | LO2LK)) ==
(LO1LK | LO2LK)) { (LO1LK | LO2LK)) {
return (status); return (status);
} }
...@@ -2011,9 +2011,9 @@ static u32 MT2063_GetLocked(struct mt2063_state *pInfo) ...@@ -2011,9 +2011,9 @@ static u32 MT2063_GetLocked(struct mt2063_state *pInfo)
} }
while (++nDelays < nMaxLoops); while (++nDelays < nMaxLoops);
if ((pInfo->reg[MT2063_REG_LO_STATUS] & LO1LK) == 0x00) if ((state->reg[MT2063_REG_LO_STATUS] & LO1LK) == 0x00)
status |= MT2063_UPC_UNLOCK; status |= MT2063_UPC_UNLOCK;
if ((pInfo->reg[MT2063_REG_LO_STATUS] & LO2LK) == 0x00) if ((state->reg[MT2063_REG_LO_STATUS] & LO2LK) == 0x00)
status |= MT2063_DNC_UNLOCK; status |= MT2063_DNC_UNLOCK;
return (status); return (status);
...@@ -2111,7 +2111,7 @@ static u32 MT2063_GetLocked(struct mt2063_state *pInfo) ...@@ -2111,7 +2111,7 @@ static u32 MT2063_GetLocked(struct mt2063_state *pInfo)
** 06-24-2008 PINZ Ver 1.18: Add Get/SetParam CTFILT_SW ** 06-24-2008 PINZ Ver 1.18: Add Get/SetParam CTFILT_SW
** **
****************************************************************************/ ****************************************************************************/
static u32 MT2063_GetParam(struct mt2063_state *pInfo, enum MT2063_Param param, u32 *pValue) static u32 MT2063_GetParam(struct mt2063_state *state, enum MT2063_Param param, u32 *pValue)
{ {
u32 status = 0; /* Status to be returned */ u32 status = 0; /* Status to be returned */
u32 Div; u32 Div;
...@@ -2123,7 +2123,7 @@ static u32 MT2063_GetParam(struct mt2063_state *pInfo, enum MT2063_Param param, ...@@ -2123,7 +2123,7 @@ static u32 MT2063_GetParam(struct mt2063_state *pInfo, enum MT2063_Param param,
switch (param) { switch (param) {
/* Serial Bus address of this tuner */ /* Serial Bus address of this tuner */
case MT2063_IC_ADDR: case MT2063_IC_ADDR:
*pValue = pInfo->config->tuner_address; *pValue = state->config->tuner_address;
break; break;
/* Max # of MT2063's allowed to be open */ /* Max # of MT2063's allowed to be open */
...@@ -2138,17 +2138,17 @@ static u32 MT2063_GetParam(struct mt2063_state *pInfo, enum MT2063_Param param, ...@@ -2138,17 +2138,17 @@ static u32 MT2063_GetParam(struct mt2063_state *pInfo, enum MT2063_Param param,
/* crystal frequency */ /* crystal frequency */
case MT2063_SRO_FREQ: case MT2063_SRO_FREQ:
*pValue = pInfo->AS_Data.f_ref; *pValue = state->AS_Data.f_ref;
break; break;
/* minimum tuning step size */ /* minimum tuning step size */
case MT2063_STEPSIZE: case MT2063_STEPSIZE:
*pValue = pInfo->AS_Data.f_LO2_Step; *pValue = state->AS_Data.f_LO2_Step;
break; break;
/* input center frequency */ /* input center frequency */
case MT2063_INPUT_FREQ: case MT2063_INPUT_FREQ:
*pValue = pInfo->AS_Data.f_in; *pValue = state->AS_Data.f_in;
break; break;
/* LO1 Frequency */ /* LO1 Frequency */
...@@ -2156,53 +2156,53 @@ static u32 MT2063_GetParam(struct mt2063_state *pInfo, enum MT2063_Param param, ...@@ -2156,53 +2156,53 @@ static u32 MT2063_GetParam(struct mt2063_state *pInfo, enum MT2063_Param param,
{ {
/* read the actual tuner register values for LO1C_1 and LO1C_2 */ /* read the actual tuner register values for LO1C_1 and LO1C_2 */
status |= status |=
MT2063_ReadSub(pInfo, MT2063_ReadSub(state,
MT2063_REG_LO1C_1, MT2063_REG_LO1C_1,
&pInfo-> &state->
reg[MT2063_REG_LO1C_1], 2); reg[MT2063_REG_LO1C_1], 2);
Div = pInfo->reg[MT2063_REG_LO1C_1]; Div = state->reg[MT2063_REG_LO1C_1];
Num = pInfo->reg[MT2063_REG_LO1C_2] & 0x3F; Num = state->reg[MT2063_REG_LO1C_2] & 0x3F;
pInfo->AS_Data.f_LO1 = state->AS_Data.f_LO1 =
(pInfo->AS_Data.f_ref * Div) + (state->AS_Data.f_ref * Div) +
MT2063_fLO_FractionalTerm(pInfo->AS_Data. MT2063_fLO_FractionalTerm(state->AS_Data.
f_ref, Num, 64); f_ref, Num, 64);
} }
*pValue = pInfo->AS_Data.f_LO1; *pValue = state->AS_Data.f_LO1;
break; break;
/* LO1 minimum step size */ /* LO1 minimum step size */
case MT2063_LO1_STEPSIZE: case MT2063_LO1_STEPSIZE:
*pValue = pInfo->AS_Data.f_LO1_Step; *pValue = state->AS_Data.f_LO1_Step;
break; break;
/* LO1 FracN keep-out region */ /* LO1 FracN keep-out region */
case MT2063_LO1_FRACN_AVOID_PARAM: case MT2063_LO1_FRACN_AVOID_PARAM:
*pValue = pInfo->AS_Data.f_LO1_FracN_Avoid; *pValue = state->AS_Data.f_LO1_FracN_Avoid;
break; break;
/* Current 1st IF in use */ /* Current 1st IF in use */
case MT2063_IF1_ACTUAL: case MT2063_IF1_ACTUAL:
*pValue = pInfo->f_IF1_actual; *pValue = state->f_IF1_actual;
break; break;
/* Requested 1st IF */ /* Requested 1st IF */
case MT2063_IF1_REQUEST: case MT2063_IF1_REQUEST:
*pValue = pInfo->AS_Data.f_if1_Request; *pValue = state->AS_Data.f_if1_Request;
break; break;
/* Center of 1st IF SAW filter */ /* Center of 1st IF SAW filter */
case MT2063_IF1_CENTER: case MT2063_IF1_CENTER:
*pValue = pInfo->AS_Data.f_if1_Center; *pValue = state->AS_Data.f_if1_Center;
break; break;
/* Bandwidth of 1st IF SAW filter */ /* Bandwidth of 1st IF SAW filter */
case MT2063_IF1_BW: case MT2063_IF1_BW:
*pValue = pInfo->AS_Data.f_if1_bw; *pValue = state->AS_Data.f_if1_bw;
break; break;
/* zero-IF bandwidth */ /* zero-IF bandwidth */
case MT2063_ZIF_BW: case MT2063_ZIF_BW:
*pValue = pInfo->AS_Data.f_zif_bw; *pValue = state->AS_Data.f_zif_bw;
break; break;
/* LO2 Frequency */ /* LO2 Frequency */
...@@ -2210,97 +2210,97 @@ static u32 MT2063_GetParam(struct mt2063_state *pInfo, enum MT2063_Param param, ...@@ -2210,97 +2210,97 @@ static u32 MT2063_GetParam(struct mt2063_state *pInfo, enum MT2063_Param param,
{ {
/* Read the actual tuner register values for LO2C_1, LO2C_2 and LO2C_3 */ /* Read the actual tuner register values for LO2C_1, LO2C_2 and LO2C_3 */
status |= status |=
MT2063_ReadSub(pInfo, MT2063_ReadSub(state,
MT2063_REG_LO2C_1, MT2063_REG_LO2C_1,
&pInfo-> &state->
reg[MT2063_REG_LO2C_1], 3); reg[MT2063_REG_LO2C_1], 3);
Div = Div =
(pInfo->reg[MT2063_REG_LO2C_1] & 0xFE) >> 1; (state->reg[MT2063_REG_LO2C_1] & 0xFE) >> 1;
Num = Num =
((pInfo-> ((state->
reg[MT2063_REG_LO2C_1] & 0x01) << 12) | reg[MT2063_REG_LO2C_1] & 0x01) << 12) |
(pInfo-> (state->
reg[MT2063_REG_LO2C_2] << 4) | (pInfo-> reg[MT2063_REG_LO2C_2] << 4) | (state->
reg reg
[MT2063_REG_LO2C_3] [MT2063_REG_LO2C_3]
& 0x00F); & 0x00F);
pInfo->AS_Data.f_LO2 = state->AS_Data.f_LO2 =
(pInfo->AS_Data.f_ref * Div) + (state->AS_Data.f_ref * Div) +
MT2063_fLO_FractionalTerm(pInfo->AS_Data. MT2063_fLO_FractionalTerm(state->AS_Data.
f_ref, Num, 8191); f_ref, Num, 8191);
} }
*pValue = pInfo->AS_Data.f_LO2; *pValue = state->AS_Data.f_LO2;
break; break;
/* LO2 minimum step size */ /* LO2 minimum step size */
case MT2063_LO2_STEPSIZE: case MT2063_LO2_STEPSIZE:
*pValue = pInfo->AS_Data.f_LO2_Step; *pValue = state->AS_Data.f_LO2_Step;
break; break;
/* LO2 FracN keep-out region */ /* LO2 FracN keep-out region */
case MT2063_LO2_FRACN_AVOID: case MT2063_LO2_FRACN_AVOID:
*pValue = pInfo->AS_Data.f_LO2_FracN_Avoid; *pValue = state->AS_Data.f_LO2_FracN_Avoid;
break; break;
/* output center frequency */ /* output center frequency */
case MT2063_OUTPUT_FREQ: case MT2063_OUTPUT_FREQ:
*pValue = pInfo->AS_Data.f_out; *pValue = state->AS_Data.f_out;
break; break;
/* output bandwidth */ /* output bandwidth */
case MT2063_OUTPUT_BW: case MT2063_OUTPUT_BW:
*pValue = pInfo->AS_Data.f_out_bw - 750000; *pValue = state->AS_Data.f_out_bw - 750000;
break; break;
/* min inter-tuner LO separation */ /* min inter-tuner LO separation */
case MT2063_LO_SEPARATION: case MT2063_LO_SEPARATION:
*pValue = pInfo->AS_Data.f_min_LO_Separation; *pValue = state->AS_Data.f_min_LO_Separation;
break; break;
/* ID of avoid-spurs algorithm in use */ /* ID of avoid-spurs algorithm in use */
case MT2063_AS_ALG: case MT2063_AS_ALG:
*pValue = pInfo->AS_Data.nAS_Algorithm; *pValue = state->AS_Data.nAS_Algorithm;
break; break;
/* max # of intra-tuner harmonics */ /* max # of intra-tuner harmonics */
case MT2063_MAX_HARM1: case MT2063_MAX_HARM1:
*pValue = pInfo->AS_Data.maxH1; *pValue = state->AS_Data.maxH1;
break; break;
/* max # of inter-tuner harmonics */ /* max # of inter-tuner harmonics */
case MT2063_MAX_HARM2: case MT2063_MAX_HARM2:
*pValue = pInfo->AS_Data.maxH2; *pValue = state->AS_Data.maxH2;
break; break;
/* # of 1st IF exclusion zones */ /* # of 1st IF exclusion zones */
case MT2063_EXCL_ZONES: case MT2063_EXCL_ZONES:
*pValue = pInfo->AS_Data.nZones; *pValue = state->AS_Data.nZones;
break; break;
/* # of spurs found/avoided */ /* # of spurs found/avoided */
case MT2063_NUM_SPURS: case MT2063_NUM_SPURS:
*pValue = pInfo->AS_Data.nSpursFound; *pValue = state->AS_Data.nSpursFound;
break; break;
/* >0 spurs avoided */ /* >0 spurs avoided */
case MT2063_SPUR_AVOIDED: case MT2063_SPUR_AVOIDED:
*pValue = pInfo->AS_Data.bSpurAvoided; *pValue = state->AS_Data.bSpurAvoided;
break; break;
/* >0 spurs in output (mathematically) */ /* >0 spurs in output (mathematically) */
case MT2063_SPUR_PRESENT: case MT2063_SPUR_PRESENT:
*pValue = pInfo->AS_Data.bSpurPresent; *pValue = state->AS_Data.bSpurPresent;
break; break;
/* Predefined receiver setup combination */ /* Predefined receiver setup combination */
case MT2063_RCVR_MODE: case MT2063_RCVR_MODE:
*pValue = pInfo->rcvr_mode; *pValue = state->rcvr_mode;
break; break;
case MT2063_PD1: case MT2063_PD1:
case MT2063_PD2: { case MT2063_PD2: {
u8 mask = (param == MT2063_PD1 ? 0x01 : 0x03); /* PD1 vs PD2 */ u8 mask = (param == MT2063_PD1 ? 0x01 : 0x03); /* PD1 vs PD2 */
u8 orig = (pInfo->reg[MT2063_REG_BYP_CTRL]); u8 orig = (state->reg[MT2063_REG_BYP_CTRL]);
u8 reg = (orig & 0xF1) | mask; /* Only set 3 bits (not 5) */ u8 reg = (orig & 0xF1) | mask; /* Only set 3 bits (not 5) */
int i; int i;
...@@ -2309,7 +2309,7 @@ static u32 MT2063_GetParam(struct mt2063_state *pInfo, enum MT2063_Param param, ...@@ -2309,7 +2309,7 @@ static u32 MT2063_GetParam(struct mt2063_state *pInfo, enum MT2063_Param param,
/* Initiate ADC output to reg 0x0A */ /* Initiate ADC output to reg 0x0A */
if (reg != orig) if (reg != orig)
status |= status |=
MT2063_WriteSub(pInfo, MT2063_WriteSub(state,
MT2063_REG_BYP_CTRL, MT2063_REG_BYP_CTRL,
&reg, 1); &reg, 1);
...@@ -2318,16 +2318,16 @@ static u32 MT2063_GetParam(struct mt2063_state *pInfo, enum MT2063_Param param, ...@@ -2318,16 +2318,16 @@ static u32 MT2063_GetParam(struct mt2063_state *pInfo, enum MT2063_Param param,
for (i = 0; i < 8; i++) { for (i = 0; i < 8; i++) {
status |= status |=
MT2063_ReadSub(pInfo, MT2063_ReadSub(state,
MT2063_REG_ADC_OUT, MT2063_REG_ADC_OUT,
&pInfo-> &state->
reg reg
[MT2063_REG_ADC_OUT], [MT2063_REG_ADC_OUT],
1); 1);
if (status >= 0) if (status >= 0)
*pValue += *pValue +=
pInfo-> state->
reg[MT2063_REG_ADC_OUT]; reg[MT2063_REG_ADC_OUT];
else { else {
if (i) if (i)
...@@ -2341,7 +2341,7 @@ static u32 MT2063_GetParam(struct mt2063_state *pInfo, enum MT2063_Param param, ...@@ -2341,7 +2341,7 @@ static u32 MT2063_GetParam(struct mt2063_state *pInfo, enum MT2063_Param param,
/* Restore value of Register BYP_CTRL */ /* Restore value of Register BYP_CTRL */
if (reg != orig) if (reg != orig)
status |= status |=
MT2063_WriteSub(pInfo, MT2063_WriteSub(state,
MT2063_REG_BYP_CTRL, MT2063_REG_BYP_CTRL,
&orig, 1); &orig, 1);
} }
...@@ -2352,7 +2352,7 @@ static u32 MT2063_GetParam(struct mt2063_state *pInfo, enum MT2063_Param param, ...@@ -2352,7 +2352,7 @@ static u32 MT2063_GetParam(struct mt2063_state *pInfo, enum MT2063_Param param,
{ {
u8 val; u8 val;
status |= status |=
MT2063_GetReg(pInfo, MT2063_REG_XO_STATUS, MT2063_GetReg(state, MT2063_REG_XO_STATUS,
&val); &val);
*pValue = val & 0x1f; *pValue = val & 0x1f;
} }
...@@ -2363,7 +2363,7 @@ static u32 MT2063_GetParam(struct mt2063_state *pInfo, enum MT2063_Param param, ...@@ -2363,7 +2363,7 @@ static u32 MT2063_GetParam(struct mt2063_state *pInfo, enum MT2063_Param param,
{ {
u8 val; u8 val;
status |= status |=
MT2063_GetReg(pInfo, MT2063_REG_RF_STATUS, MT2063_GetReg(state, MT2063_REG_RF_STATUS,
&val); &val);
*pValue = val & 0x1f; *pValue = val & 0x1f;
} }
...@@ -2374,7 +2374,7 @@ static u32 MT2063_GetParam(struct mt2063_state *pInfo, enum MT2063_Param param, ...@@ -2374,7 +2374,7 @@ static u32 MT2063_GetParam(struct mt2063_state *pInfo, enum MT2063_Param param,
{ {
u8 val; u8 val;
status |= status |=
MT2063_GetReg(pInfo, MT2063_REG_FIF_STATUS, MT2063_GetReg(state, MT2063_REG_FIF_STATUS,
&val); &val);
*pValue = val & 0x1f; *pValue = val & 0x1f;
} }
...@@ -2385,7 +2385,7 @@ static u32 MT2063_GetParam(struct mt2063_state *pInfo, enum MT2063_Param param, ...@@ -2385,7 +2385,7 @@ static u32 MT2063_GetParam(struct mt2063_state *pInfo, enum MT2063_Param param,
{ {
u8 val; u8 val;
status |= status |=
MT2063_GetReg(pInfo, MT2063_REG_LNA_OV, MT2063_GetReg(state, MT2063_REG_LNA_OV,
&val); &val);
*pValue = val & 0x1f; *pValue = val & 0x1f;
} }
...@@ -2396,7 +2396,7 @@ static u32 MT2063_GetParam(struct mt2063_state *pInfo, enum MT2063_Param param, ...@@ -2396,7 +2396,7 @@ static u32 MT2063_GetParam(struct mt2063_state *pInfo, enum MT2063_Param param,
{ {
u8 val; u8 val;
status |= status |=
MT2063_GetReg(pInfo, MT2063_REG_RF_OV, MT2063_GetReg(state, MT2063_REG_RF_OV,
&val); &val);
*pValue = val & 0x1f; *pValue = val & 0x1f;
} }
...@@ -2407,7 +2407,7 @@ static u32 MT2063_GetParam(struct mt2063_state *pInfo, enum MT2063_Param param, ...@@ -2407,7 +2407,7 @@ static u32 MT2063_GetParam(struct mt2063_state *pInfo, enum MT2063_Param param,
{ {
u8 val; u8 val;
status |= status |=
MT2063_GetReg(pInfo, MT2063_REG_FIF_OV, MT2063_GetReg(state, MT2063_REG_FIF_OV,
&val); &val);
*pValue = val & 0x1f; *pValue = val & 0x1f;
} }
...@@ -2416,8 +2416,8 @@ static u32 MT2063_GetParam(struct mt2063_state *pInfo, enum MT2063_Param param, ...@@ -2416,8 +2416,8 @@ static u32 MT2063_GetParam(struct mt2063_state *pInfo, enum MT2063_Param param,
/* Get current used DNC output */ /* Get current used DNC output */
case MT2063_DNC_OUTPUT_ENABLE: case MT2063_DNC_OUTPUT_ENABLE:
{ {
if ((pInfo->reg[MT2063_REG_DNC_GAIN] & 0x03) == 0x03) { /* if DNC1 is off */ if ((state->reg[MT2063_REG_DNC_GAIN] & 0x03) == 0x03) { /* if DNC1 is off */
if ((pInfo->reg[MT2063_REG_VGA_GAIN] & 0x03) == 0x03) /* if DNC2 is off */ if ((state->reg[MT2063_REG_VGA_GAIN] & 0x03) == 0x03) /* if DNC2 is off */
*pValue = *pValue =
(u32) MT2063_DNC_NONE; (u32) MT2063_DNC_NONE;
else else
...@@ -2425,7 +2425,7 @@ static u32 MT2063_GetParam(struct mt2063_state *pInfo, enum MT2063_Param param, ...@@ -2425,7 +2425,7 @@ static u32 MT2063_GetParam(struct mt2063_state *pInfo, enum MT2063_Param param,
(u32) MT2063_DNC_2; (u32) MT2063_DNC_2;
} else { /* DNC1 is on */ } else { /* DNC1 is on */
if ((pInfo->reg[MT2063_REG_VGA_GAIN] & 0x03) == 0x03) /* if DNC2 is off */ if ((state->reg[MT2063_REG_VGA_GAIN] & 0x03) == 0x03) /* if DNC2 is off */
*pValue = *pValue =
(u32) MT2063_DNC_1; (u32) MT2063_DNC_1;
else else
...@@ -2437,32 +2437,32 @@ static u32 MT2063_GetParam(struct mt2063_state *pInfo, enum MT2063_Param param, ...@@ -2437,32 +2437,32 @@ static u32 MT2063_GetParam(struct mt2063_state *pInfo, enum MT2063_Param param,
/* Get VGA Gain Code */ /* Get VGA Gain Code */
case MT2063_VGAGC: case MT2063_VGAGC:
*pValue = ((pInfo->reg[MT2063_REG_VGA_GAIN] & 0x0C) >> 2); *pValue = ((state->reg[MT2063_REG_VGA_GAIN] & 0x0C) >> 2);
break; break;
/* Get VGA bias current */ /* Get VGA bias current */
case MT2063_VGAOI: case MT2063_VGAOI:
*pValue = (pInfo->reg[MT2063_REG_RSVD_31] & 0x07); *pValue = (state->reg[MT2063_REG_RSVD_31] & 0x07);
break; break;
/* Get TAGC setting */ /* Get TAGC setting */
case MT2063_TAGC: case MT2063_TAGC:
*pValue = (pInfo->reg[MT2063_REG_RSVD_1E] & 0x03); *pValue = (state->reg[MT2063_REG_RSVD_1E] & 0x03);
break; break;
/* Get AMP Gain Code */ /* Get AMP Gain Code */
case MT2063_AMPGC: case MT2063_AMPGC:
*pValue = (pInfo->reg[MT2063_REG_TEMP_SEL] & 0x03); *pValue = (state->reg[MT2063_REG_TEMP_SEL] & 0x03);
break; break;
/* Avoid DECT Frequencies */ /* Avoid DECT Frequencies */
case MT2063_AVOID_DECT: case MT2063_AVOID_DECT:
*pValue = pInfo->AS_Data.avoidDECT; *pValue = state->AS_Data.avoidDECT;
break; break;
/* Cleartune filter selection: 0 - by IC (default), 1 - by software */ /* Cleartune filter selection: 0 - by IC (default), 1 - by software */
case MT2063_CTFILT_SW: case MT2063_CTFILT_SW:
*pValue = pInfo->ctfilt_sw; *pValue = state->ctfilt_sw;
break; break;
case MT2063_EOP: case MT2063_EOP:
...@@ -2501,7 +2501,7 @@ static u32 MT2063_GetParam(struct mt2063_state *pInfo, enum MT2063_Param param, ...@@ -2501,7 +2501,7 @@ static u32 MT2063_GetParam(struct mt2063_state *pInfo, enum MT2063_Param param,
** 138 06-19-2007 DAD Ver 1.00: Initial, derived from mt2067_b. ** 138 06-19-2007 DAD Ver 1.00: Initial, derived from mt2067_b.
** **
****************************************************************************/ ****************************************************************************/
static u32 MT2063_GetReg(struct mt2063_state *pInfo, u8 reg, u8 * val) static u32 MT2063_GetReg(struct mt2063_state *state, u8 reg, u8 * val)
{ {
u32 status = 0; /* Status to be returned */ u32 status = 0; /* Status to be returned */
...@@ -2511,7 +2511,7 @@ static u32 MT2063_GetReg(struct mt2063_state *pInfo, u8 reg, u8 * val) ...@@ -2511,7 +2511,7 @@ static u32 MT2063_GetReg(struct mt2063_state *pInfo, u8 reg, u8 * val)
if (reg >= MT2063_REG_END_REGS) if (reg >= MT2063_REG_END_REGS)
return -ERANGE; return -ERANGE;
status = MT2063_ReadSub(pInfo, reg, &pInfo->reg[reg], 1); status = MT2063_ReadSub(state, reg, &state->reg[reg], 1);
return (status); return (status);
} }
...@@ -2553,7 +2553,7 @@ static u32 MT2063_GetReg(struct mt2063_state *pInfo, u8 reg, u8 * val) ...@@ -2553,7 +2553,7 @@ static u32 MT2063_GetReg(struct mt2063_state *pInfo, u8 reg, u8 * val)
** PD2 Target | 40 | 33 | 42 | 42 | 33 | 42 ** PD2 Target | 40 | 33 | 42 | 42 | 33 | 42
** **
** **
** Parameters: pInfo - ptr to mt2063_state structure ** Parameters: state - ptr to mt2063_state structure
** Mode - desired reciever mode ** Mode - desired reciever mode
** **
** Usage: status = MT2063_SetReceiverMode(hMT2063, Mode); ** Usage: status = MT2063_SetReceiverMode(hMT2063, Mode);
...@@ -2599,7 +2599,7 @@ static u32 MT2063_GetReg(struct mt2063_state *pInfo, u8 reg, u8 * val) ...@@ -2599,7 +2599,7 @@ static u32 MT2063_GetReg(struct mt2063_state *pInfo, u8 reg, u8 * val)
** removed GCUAUTO / BYPATNDN/UP ** removed GCUAUTO / BYPATNDN/UP
** **
******************************************************************************/ ******************************************************************************/
static u32 MT2063_SetReceiverMode(struct mt2063_state *pInfo, static u32 MT2063_SetReceiverMode(struct mt2063_state *state,
enum MT2063_RCVR_MODES Mode) enum MT2063_RCVR_MODES Mode)
{ {
u32 status = 0; /* Status to be returned */ u32 status = 0; /* Status to be returned */
...@@ -2612,104 +2612,104 @@ static u32 MT2063_SetReceiverMode(struct mt2063_state *pInfo, ...@@ -2612,104 +2612,104 @@ static u32 MT2063_SetReceiverMode(struct mt2063_state *pInfo,
/* RFAGCen */ /* RFAGCen */
if (status >= 0) { if (status >= 0) {
val = val =
(pInfo-> (state->
reg[MT2063_REG_PD1_TGT] & (u8) ~ 0x40) | (RFAGCEN[Mode] reg[MT2063_REG_PD1_TGT] & (u8) ~ 0x40) | (RFAGCEN[Mode]
? 0x40 : ? 0x40 :
0x00); 0x00);
if (pInfo->reg[MT2063_REG_PD1_TGT] != val) { if (state->reg[MT2063_REG_PD1_TGT] != val) {
status |= MT2063_SetReg(pInfo, MT2063_REG_PD1_TGT, val); status |= MT2063_SetReg(state, MT2063_REG_PD1_TGT, val);
} }
} }
/* LNARin */ /* LNARin */
if (status >= 0) { if (status >= 0) {
status |= MT2063_SetParam(pInfo, MT2063_LNA_RIN, LNARIN[Mode]); status |= MT2063_SetParam(state, MT2063_LNA_RIN, LNARIN[Mode]);
} }
/* FIFFQEN and FIFFQ */ /* FIFFQEN and FIFFQ */
if (status >= 0) { if (status >= 0) {
val = val =
(pInfo-> (state->
reg[MT2063_REG_FIFF_CTRL2] & (u8) ~ 0xF0) | reg[MT2063_REG_FIFF_CTRL2] & (u8) ~ 0xF0) |
(FIFFQEN[Mode] << 7) | (FIFFQ[Mode] << 4); (FIFFQEN[Mode] << 7) | (FIFFQ[Mode] << 4);
if (pInfo->reg[MT2063_REG_FIFF_CTRL2] != val) { if (state->reg[MT2063_REG_FIFF_CTRL2] != val) {
status |= status |=
MT2063_SetReg(pInfo, MT2063_REG_FIFF_CTRL2, val); MT2063_SetReg(state, MT2063_REG_FIFF_CTRL2, val);
/* trigger FIFF calibration, needed after changing FIFFQ */ /* trigger FIFF calibration, needed after changing FIFFQ */
val = val =
(pInfo->reg[MT2063_REG_FIFF_CTRL] | (u8) 0x01); (state->reg[MT2063_REG_FIFF_CTRL] | (u8) 0x01);
status |= status |=
MT2063_SetReg(pInfo, MT2063_REG_FIFF_CTRL, val); MT2063_SetReg(state, MT2063_REG_FIFF_CTRL, val);
val = val =
(pInfo-> (state->
reg[MT2063_REG_FIFF_CTRL] & (u8) ~ 0x01); reg[MT2063_REG_FIFF_CTRL] & (u8) ~ 0x01);
status |= status |=
MT2063_SetReg(pInfo, MT2063_REG_FIFF_CTRL, val); MT2063_SetReg(state, MT2063_REG_FIFF_CTRL, val);
} }
} }
/* DNC1GC & DNC2GC */ /* DNC1GC & DNC2GC */
status |= MT2063_GetParam(pInfo, MT2063_DNC_OUTPUT_ENABLE, &longval); status |= MT2063_GetParam(state, MT2063_DNC_OUTPUT_ENABLE, &longval);
status |= MT2063_SetParam(pInfo, MT2063_DNC_OUTPUT_ENABLE, longval); status |= MT2063_SetParam(state, MT2063_DNC_OUTPUT_ENABLE, longval);
/* acLNAmax */ /* acLNAmax */
if (status >= 0) { if (status >= 0) {
status |= status |=
MT2063_SetParam(pInfo, MT2063_ACLNA_MAX, ACLNAMAX[Mode]); MT2063_SetParam(state, MT2063_ACLNA_MAX, ACLNAMAX[Mode]);
} }
/* LNATGT */ /* LNATGT */
if (status >= 0) { if (status >= 0) {
status |= MT2063_SetParam(pInfo, MT2063_LNA_TGT, LNATGT[Mode]); status |= MT2063_SetParam(state, MT2063_LNA_TGT, LNATGT[Mode]);
} }
/* ACRF */ /* ACRF */
if (status >= 0) { if (status >= 0) {
status |= status |=
MT2063_SetParam(pInfo, MT2063_ACRF_MAX, ACRFMAX[Mode]); MT2063_SetParam(state, MT2063_ACRF_MAX, ACRFMAX[Mode]);
} }
/* PD1TGT */ /* PD1TGT */
if (status >= 0) { if (status >= 0) {
status |= MT2063_SetParam(pInfo, MT2063_PD1_TGT, PD1TGT[Mode]); status |= MT2063_SetParam(state, MT2063_PD1_TGT, PD1TGT[Mode]);
} }
/* FIFATN */ /* FIFATN */
if (status >= 0) { if (status >= 0) {
status |= status |=
MT2063_SetParam(pInfo, MT2063_ACFIF_MAX, ACFIFMAX[Mode]); MT2063_SetParam(state, MT2063_ACFIF_MAX, ACFIFMAX[Mode]);
} }
/* PD2TGT */ /* PD2TGT */
if (status >= 0) { if (status >= 0) {
status |= MT2063_SetParam(pInfo, MT2063_PD2_TGT, PD2TGT[Mode]); status |= MT2063_SetParam(state, MT2063_PD2_TGT, PD2TGT[Mode]);
} }
/* Ignore ATN Overload */ /* Ignore ATN Overload */
if (status >= 0) { if (status >= 0) {
val = val =
(pInfo-> (state->
reg[MT2063_REG_LNA_TGT] & (u8) ~ 0x80) | (RFOVDIS[Mode] reg[MT2063_REG_LNA_TGT] & (u8) ~ 0x80) | (RFOVDIS[Mode]
? 0x80 : ? 0x80 :
0x00); 0x00);
if (pInfo->reg[MT2063_REG_LNA_TGT] != val) { if (state->reg[MT2063_REG_LNA_TGT] != val) {
status |= MT2063_SetReg(pInfo, MT2063_REG_LNA_TGT, val); status |= MT2063_SetReg(state, MT2063_REG_LNA_TGT, val);
} }
} }
/* Ignore FIF Overload */ /* Ignore FIF Overload */
if (status >= 0) { if (status >= 0) {
val = val =
(pInfo-> (state->
reg[MT2063_REG_PD1_TGT] & (u8) ~ 0x80) | reg[MT2063_REG_PD1_TGT] & (u8) ~ 0x80) |
(FIFOVDIS[Mode] ? 0x80 : 0x00); (FIFOVDIS[Mode] ? 0x80 : 0x00);
if (pInfo->reg[MT2063_REG_PD1_TGT] != val) { if (state->reg[MT2063_REG_PD1_TGT] != val) {
status |= MT2063_SetReg(pInfo, MT2063_REG_PD1_TGT, val); status |= MT2063_SetReg(state, MT2063_REG_PD1_TGT, val);
} }
} }
if (status >= 0) if (status >= 0)
pInfo->rcvr_mode = Mode; state->rcvr_mode = Mode;
return (status); return (status);
} }
...@@ -2748,7 +2748,7 @@ static u32 MT2063_SetReceiverMode(struct mt2063_state *pInfo, ...@@ -2748,7 +2748,7 @@ static u32 MT2063_SetReceiverMode(struct mt2063_state *pInfo,
** 06-24-2008 PINZ Ver 1.18: Add Get/SetParam CTFILT_SW ** 06-24-2008 PINZ Ver 1.18: Add Get/SetParam CTFILT_SW
** **
******************************************************************************/ ******************************************************************************/
static u32 MT2063_ReInit(struct mt2063_state *pInfo) static u32 MT2063_ReInit(struct mt2063_state *state)
{ {
u8 all_resets = 0xF0; /* reset/load bits */ u8 all_resets = 0xF0; /* reset/load bits */
u32 status = 0; /* Status to be returned */ u32 status = 0; /* Status to be returned */
...@@ -2816,33 +2816,33 @@ static u32 MT2063_ReInit(struct mt2063_state *pInfo) ...@@ -2816,33 +2816,33 @@ static u32 MT2063_ReInit(struct mt2063_state *pInfo)
}; };
/* Read the Part/Rev code from the tuner */ /* Read the Part/Rev code from the tuner */
status = MT2063_ReadSub(pInfo, MT2063_REG_PART_REV, pInfo->reg, 1); status = MT2063_ReadSub(state, MT2063_REG_PART_REV, state->reg, 1);
if (status < 0) if (status < 0)
return status; return status;
/* Check the part/rev code */ /* Check the part/rev code */
if (((pInfo->reg[MT2063_REG_PART_REV] != MT2063_B0) /* MT2063 B0 */ if (((state->reg[MT2063_REG_PART_REV] != MT2063_B0) /* MT2063 B0 */
&&(pInfo->reg[MT2063_REG_PART_REV] != MT2063_B1) /* MT2063 B1 */ &&(state->reg[MT2063_REG_PART_REV] != MT2063_B1) /* MT2063 B1 */
&&(pInfo->reg[MT2063_REG_PART_REV] != MT2063_B3))) /* MT2063 B3 */ &&(state->reg[MT2063_REG_PART_REV] != MT2063_B3))) /* MT2063 B3 */
return -ENODEV; /* Wrong tuner Part/Rev code */ return -ENODEV; /* Wrong tuner Part/Rev code */
/* Check the 2nd byte of the Part/Rev code from the tuner */ /* Check the 2nd byte of the Part/Rev code from the tuner */
status = MT2063_ReadSub(pInfo, status = MT2063_ReadSub(state,
MT2063_REG_RSVD_3B, MT2063_REG_RSVD_3B,
&pInfo->reg[MT2063_REG_RSVD_3B], 1); &state->reg[MT2063_REG_RSVD_3B], 1);
if (status >= 0 if (status >= 0
&&((pInfo->reg[MT2063_REG_RSVD_3B] & 0x80) != 0x00)) /* b7 != 0 ==> NOT MT2063 */ &&((state->reg[MT2063_REG_RSVD_3B] & 0x80) != 0x00)) /* b7 != 0 ==> NOT MT2063 */
return -ENODEV; /* Wrong tuner Part/Rev code */ return -ENODEV; /* Wrong tuner Part/Rev code */
/* Reset the tuner */ /* Reset the tuner */
status = MT2063_WriteSub(pInfo, MT2063_REG_LO2CQ_3, &all_resets, 1); status = MT2063_WriteSub(state, MT2063_REG_LO2CQ_3, &all_resets, 1);
if (status < 0) if (status < 0)
return status; return status;
/* change all of the default values that vary from the HW reset values */ /* change all of the default values that vary from the HW reset values */
/* def = (pInfo->reg[PART_REV] == MT2063_B0) ? MT2063B0_defaults : MT2063B1_defaults; */ /* def = (state->reg[PART_REV] == MT2063_B0) ? MT2063B0_defaults : MT2063B1_defaults; */
switch (pInfo->reg[MT2063_REG_PART_REV]) { switch (state->reg[MT2063_REG_PART_REV]) {
case MT2063_B3: case MT2063_B3:
def = MT2063B3_defaults; def = MT2063B3_defaults;
break; break;
...@@ -2863,7 +2863,7 @@ static u32 MT2063_ReInit(struct mt2063_state *pInfo) ...@@ -2863,7 +2863,7 @@ static u32 MT2063_ReInit(struct mt2063_state *pInfo)
while (status >= 0 && *def) { while (status >= 0 && *def) {
u8 reg = *def++; u8 reg = *def++;
u8 val = *def++; u8 val = *def++;
status = MT2063_WriteSub(pInfo, reg, &val, 1); status = MT2063_WriteSub(state, reg, &val, 1);
} }
if (status < 0) if (status < 0)
return status; return status;
...@@ -2873,116 +2873,116 @@ static u32 MT2063_ReInit(struct mt2063_state *pInfo) ...@@ -2873,116 +2873,116 @@ static u32 MT2063_ReInit(struct mt2063_state *pInfo)
maxReads = 10; maxReads = 10;
while (status >= 0 && (FCRUN != 0) && (maxReads-- > 0)) { while (status >= 0 && (FCRUN != 0) && (maxReads-- > 0)) {
msleep(2); msleep(2);
status = MT2063_ReadSub(pInfo, status = MT2063_ReadSub(state,
MT2063_REG_XO_STATUS, MT2063_REG_XO_STATUS,
&pInfo-> &state->
reg[MT2063_REG_XO_STATUS], 1); reg[MT2063_REG_XO_STATUS], 1);
FCRUN = (pInfo->reg[MT2063_REG_XO_STATUS] & 0x40) >> 6; FCRUN = (state->reg[MT2063_REG_XO_STATUS] & 0x40) >> 6;
} }
if (FCRUN != 0) if (FCRUN != 0)
return -ENODEV; return -ENODEV;
status = MT2063_ReadSub(pInfo, status = MT2063_ReadSub(state,
MT2063_REG_FIFFC, MT2063_REG_FIFFC,
&pInfo->reg[MT2063_REG_FIFFC], 1); &state->reg[MT2063_REG_FIFFC], 1);
if (status < 0) if (status < 0)
return status; return status;
/* Read back all the registers from the tuner */ /* Read back all the registers from the tuner */
status = MT2063_ReadSub(pInfo, status = MT2063_ReadSub(state,
MT2063_REG_PART_REV, MT2063_REG_PART_REV,
pInfo->reg, MT2063_REG_END_REGS); state->reg, MT2063_REG_END_REGS);
if (status < 0) if (status < 0)
return status; return status;
/* Initialize the tuner state. */ /* Initialize the tuner state. */
pInfo->tuner_id = pInfo->reg[MT2063_REG_PART_REV]; state->tuner_id = state->reg[MT2063_REG_PART_REV];
pInfo->AS_Data.f_ref = MT2063_REF_FREQ; state->AS_Data.f_ref = MT2063_REF_FREQ;
pInfo->AS_Data.f_if1_Center = (pInfo->AS_Data.f_ref / 8) * state->AS_Data.f_if1_Center = (state->AS_Data.f_ref / 8) *
((u32) pInfo->reg[MT2063_REG_FIFFC] + 640); ((u32) state->reg[MT2063_REG_FIFFC] + 640);
pInfo->AS_Data.f_if1_bw = MT2063_IF1_BW; state->AS_Data.f_if1_bw = MT2063_IF1_BW;
pInfo->AS_Data.f_out = 43750000UL; state->AS_Data.f_out = 43750000UL;
pInfo->AS_Data.f_out_bw = 6750000UL; state->AS_Data.f_out_bw = 6750000UL;
pInfo->AS_Data.f_zif_bw = MT2063_ZIF_BW; state->AS_Data.f_zif_bw = MT2063_ZIF_BW;
pInfo->AS_Data.f_LO1_Step = pInfo->AS_Data.f_ref / 64; state->AS_Data.f_LO1_Step = state->AS_Data.f_ref / 64;
pInfo->AS_Data.f_LO2_Step = MT2063_TUNE_STEP_SIZE; state->AS_Data.f_LO2_Step = MT2063_TUNE_STEP_SIZE;
pInfo->AS_Data.maxH1 = MT2063_MAX_HARMONICS_1; state->AS_Data.maxH1 = MT2063_MAX_HARMONICS_1;
pInfo->AS_Data.maxH2 = MT2063_MAX_HARMONICS_2; state->AS_Data.maxH2 = MT2063_MAX_HARMONICS_2;
pInfo->AS_Data.f_min_LO_Separation = MT2063_MIN_LO_SEP; state->AS_Data.f_min_LO_Separation = MT2063_MIN_LO_SEP;
pInfo->AS_Data.f_if1_Request = pInfo->AS_Data.f_if1_Center; state->AS_Data.f_if1_Request = state->AS_Data.f_if1_Center;
pInfo->AS_Data.f_LO1 = 2181000000UL; state->AS_Data.f_LO1 = 2181000000UL;
pInfo->AS_Data.f_LO2 = 1486249786UL; state->AS_Data.f_LO2 = 1486249786UL;
pInfo->f_IF1_actual = pInfo->AS_Data.f_if1_Center; state->f_IF1_actual = state->AS_Data.f_if1_Center;
pInfo->AS_Data.f_in = pInfo->AS_Data.f_LO1 - pInfo->f_IF1_actual; state->AS_Data.f_in = state->AS_Data.f_LO1 - state->f_IF1_actual;
pInfo->AS_Data.f_LO1_FracN_Avoid = MT2063_LO1_FRACN_AVOID; state->AS_Data.f_LO1_FracN_Avoid = MT2063_LO1_FRACN_AVOID;
pInfo->AS_Data.f_LO2_FracN_Avoid = MT2063_LO2_FRACN_AVOID; state->AS_Data.f_LO2_FracN_Avoid = MT2063_LO2_FRACN_AVOID;
pInfo->num_regs = MT2063_REG_END_REGS; state->num_regs = MT2063_REG_END_REGS;
pInfo->AS_Data.avoidDECT = MT2063_AVOID_BOTH; state->AS_Data.avoidDECT = MT2063_AVOID_BOTH;
pInfo->ctfilt_sw = 0; state->ctfilt_sw = 0;
pInfo->CTFiltMax[0] = 69230000; state->CTFiltMax[0] = 69230000;
pInfo->CTFiltMax[1] = 105770000; state->CTFiltMax[1] = 105770000;
pInfo->CTFiltMax[2] = 140350000; state->CTFiltMax[2] = 140350000;
pInfo->CTFiltMax[3] = 177110000; state->CTFiltMax[3] = 177110000;
pInfo->CTFiltMax[4] = 212860000; state->CTFiltMax[4] = 212860000;
pInfo->CTFiltMax[5] = 241130000; state->CTFiltMax[5] = 241130000;
pInfo->CTFiltMax[6] = 274370000; state->CTFiltMax[6] = 274370000;
pInfo->CTFiltMax[7] = 309820000; state->CTFiltMax[7] = 309820000;
pInfo->CTFiltMax[8] = 342450000; state->CTFiltMax[8] = 342450000;
pInfo->CTFiltMax[9] = 378870000; state->CTFiltMax[9] = 378870000;
pInfo->CTFiltMax[10] = 416210000; state->CTFiltMax[10] = 416210000;
pInfo->CTFiltMax[11] = 456500000; state->CTFiltMax[11] = 456500000;
pInfo->CTFiltMax[12] = 495790000; state->CTFiltMax[12] = 495790000;
pInfo->CTFiltMax[13] = 534530000; state->CTFiltMax[13] = 534530000;
pInfo->CTFiltMax[14] = 572610000; state->CTFiltMax[14] = 572610000;
pInfo->CTFiltMax[15] = 598970000; state->CTFiltMax[15] = 598970000;
pInfo->CTFiltMax[16] = 635910000; state->CTFiltMax[16] = 635910000;
pInfo->CTFiltMax[17] = 672130000; state->CTFiltMax[17] = 672130000;
pInfo->CTFiltMax[18] = 714840000; state->CTFiltMax[18] = 714840000;
pInfo->CTFiltMax[19] = 739660000; state->CTFiltMax[19] = 739660000;
pInfo->CTFiltMax[20] = 770410000; state->CTFiltMax[20] = 770410000;
pInfo->CTFiltMax[21] = 814660000; state->CTFiltMax[21] = 814660000;
pInfo->CTFiltMax[22] = 846950000; state->CTFiltMax[22] = 846950000;
pInfo->CTFiltMax[23] = 867820000; state->CTFiltMax[23] = 867820000;
pInfo->CTFiltMax[24] = 915980000; state->CTFiltMax[24] = 915980000;
pInfo->CTFiltMax[25] = 947450000; state->CTFiltMax[25] = 947450000;
pInfo->CTFiltMax[26] = 983110000; state->CTFiltMax[26] = 983110000;
pInfo->CTFiltMax[27] = 1021630000; state->CTFiltMax[27] = 1021630000;
pInfo->CTFiltMax[28] = 1061870000; state->CTFiltMax[28] = 1061870000;
pInfo->CTFiltMax[29] = 1098330000; state->CTFiltMax[29] = 1098330000;
pInfo->CTFiltMax[30] = 1138990000; state->CTFiltMax[30] = 1138990000;
/* /*
** Fetch the FCU osc value and use it and the fRef value to ** Fetch the FCU osc value and use it and the fRef value to
** scale all of the Band Max values ** scale all of the Band Max values
*/ */
pInfo->reg[MT2063_REG_CTUNE_CTRL] = 0x0A; state->reg[MT2063_REG_CTUNE_CTRL] = 0x0A;
status = MT2063_WriteSub(pInfo, status = MT2063_WriteSub(state,
MT2063_REG_CTUNE_CTRL, MT2063_REG_CTUNE_CTRL,
&pInfo->reg[MT2063_REG_CTUNE_CTRL], 1); &state->reg[MT2063_REG_CTUNE_CTRL], 1);
if (status < 0) if (status < 0)
return status; return status;
/* Read the ClearTune filter calibration value */ /* Read the ClearTune filter calibration value */
status = MT2063_ReadSub(pInfo, status = MT2063_ReadSub(state,
MT2063_REG_FIFFC, MT2063_REG_FIFFC,
&pInfo->reg[MT2063_REG_FIFFC], 1); &state->reg[MT2063_REG_FIFFC], 1);
if (status < 0) if (status < 0)
return status; return status;
fcu_osc = pInfo->reg[MT2063_REG_FIFFC]; fcu_osc = state->reg[MT2063_REG_FIFFC];
pInfo->reg[MT2063_REG_CTUNE_CTRL] = 0x00; state->reg[MT2063_REG_CTUNE_CTRL] = 0x00;
status = MT2063_WriteSub(pInfo, status = MT2063_WriteSub(state,
MT2063_REG_CTUNE_CTRL, MT2063_REG_CTUNE_CTRL,
&pInfo->reg[MT2063_REG_CTUNE_CTRL], 1); &state->reg[MT2063_REG_CTUNE_CTRL], 1);
if (status < 0) if (status < 0)
return status; return status;
/* Adjust each of the values in the ClearTune filter cross-over table */ /* Adjust each of the values in the ClearTune filter cross-over table */
for (i = 0; i < 31; i++) for (i = 0; i < 31; i++)
pInfo->CTFiltMax[i] =(pInfo->CTFiltMax[i] / 768) * (fcu_osc + 640); state->CTFiltMax[i] =(state->CTFiltMax[i] / 768) * (fcu_osc + 640);
return (status); return (status);
} }
...@@ -3070,7 +3070,7 @@ static u32 MT2063_ReInit(struct mt2063_state *pInfo) ...@@ -3070,7 +3070,7 @@ static u32 MT2063_ReInit(struct mt2063_state *pInfo)
** 06-24-2008 PINZ Ver 1.18: Add Get/SetParam CTFILT_SW ** 06-24-2008 PINZ Ver 1.18: Add Get/SetParam CTFILT_SW
** **
****************************************************************************/ ****************************************************************************/
static u32 MT2063_SetParam(struct mt2063_state *pInfo, static u32 MT2063_SetParam(struct mt2063_state *state,
enum MT2063_Param param, enum MT2063_Param param,
enum MT2063_DNC_Output_Enable nValue) enum MT2063_DNC_Output_Enable nValue)
{ {
...@@ -3080,18 +3080,18 @@ static u32 MT2063_SetParam(struct mt2063_state *pInfo, ...@@ -3080,18 +3080,18 @@ static u32 MT2063_SetParam(struct mt2063_state *pInfo,
switch (param) { switch (param) {
/* crystal frequency */ /* crystal frequency */
case MT2063_SRO_FREQ: case MT2063_SRO_FREQ:
pInfo->AS_Data.f_ref = nValue; state->AS_Data.f_ref = nValue;
pInfo->AS_Data.f_LO1_FracN_Avoid = 0; state->AS_Data.f_LO1_FracN_Avoid = 0;
pInfo->AS_Data.f_LO2_FracN_Avoid = nValue / 80 - 1; state->AS_Data.f_LO2_FracN_Avoid = nValue / 80 - 1;
pInfo->AS_Data.f_LO1_Step = nValue / 64; state->AS_Data.f_LO1_Step = nValue / 64;
pInfo->AS_Data.f_if1_Center = state->AS_Data.f_if1_Center =
(pInfo->AS_Data.f_ref / 8) * (state->AS_Data.f_ref / 8) *
(pInfo->reg[MT2063_REG_FIFFC] + 640); (state->reg[MT2063_REG_FIFFC] + 640);
break; break;
/* minimum tuning step size */ /* minimum tuning step size */
case MT2063_STEPSIZE: case MT2063_STEPSIZE:
pInfo->AS_Data.f_LO2_Step = nValue; state->AS_Data.f_LO2_Step = nValue;
break; break;
/* LO1 frequency */ /* LO1 frequency */
...@@ -3107,11 +3107,11 @@ static u32 MT2063_SetParam(struct mt2063_state *pInfo, ...@@ -3107,11 +3107,11 @@ static u32 MT2063_SetParam(struct mt2063_state *pInfo,
/* Buffer the queue for restoration later and get actual LO2 values. */ /* Buffer the queue for restoration later and get actual LO2 values. */
status |= status |=
MT2063_ReadSub(pInfo, MT2063_ReadSub(state,
MT2063_REG_LO2CQ_1, MT2063_REG_LO2CQ_1,
&(tempLO2CQ[0]), 3); &(tempLO2CQ[0]), 3);
status |= status |=
MT2063_ReadSub(pInfo, MT2063_ReadSub(state,
MT2063_REG_LO2C_1, MT2063_REG_LO2C_1,
&(tempLO2C[0]), 3); &(tempLO2C[0]), 3);
...@@ -3125,17 +3125,17 @@ static u32 MT2063_SetParam(struct mt2063_state *pInfo, ...@@ -3125,17 +3125,17 @@ static u32 MT2063_SetParam(struct mt2063_state *pInfo,
(tempLO2CQ[2] != tempLO2C[2])) { (tempLO2CQ[2] != tempLO2C[2])) {
/* put actual LO2 value into queue (with 0 in one-shot bits) */ /* put actual LO2 value into queue (with 0 in one-shot bits) */
status |= status |=
MT2063_WriteSub(pInfo, MT2063_WriteSub(state,
MT2063_REG_LO2CQ_1, MT2063_REG_LO2CQ_1,
&(tempLO2C[0]), 3); &(tempLO2C[0]), 3);
if (status == 0) { if (status == 0) {
/* cache the bytes just written. */ /* cache the bytes just written. */
pInfo->reg[MT2063_REG_LO2CQ_1] = state->reg[MT2063_REG_LO2CQ_1] =
tempLO2C[0]; tempLO2C[0];
pInfo->reg[MT2063_REG_LO2CQ_2] = state->reg[MT2063_REG_LO2CQ_2] =
tempLO2C[1]; tempLO2C[1];
pInfo->reg[MT2063_REG_LO2CQ_3] = state->reg[MT2063_REG_LO2CQ_3] =
tempLO2C[2]; tempLO2C[2];
} }
restore = 1; restore = 1;
...@@ -3144,23 +3144,23 @@ static u32 MT2063_SetParam(struct mt2063_state *pInfo, ...@@ -3144,23 +3144,23 @@ static u32 MT2063_SetParam(struct mt2063_state *pInfo,
/* Calculate the Divider and Numberator components of LO1 */ /* Calculate the Divider and Numberator components of LO1 */
status = status =
MT2063_CalcLO1Mult(&Div, &FracN, nValue, MT2063_CalcLO1Mult(&Div, &FracN, nValue,
pInfo->AS_Data.f_ref / state->AS_Data.f_ref /
64, 64,
pInfo->AS_Data.f_ref); state->AS_Data.f_ref);
pInfo->reg[MT2063_REG_LO1CQ_1] = state->reg[MT2063_REG_LO1CQ_1] =
(u8) (Div & 0x00FF); (u8) (Div & 0x00FF);
pInfo->reg[MT2063_REG_LO1CQ_2] = state->reg[MT2063_REG_LO1CQ_2] =
(u8) (FracN); (u8) (FracN);
status |= status |=
MT2063_WriteSub(pInfo, MT2063_WriteSub(state,
MT2063_REG_LO1CQ_1, MT2063_REG_LO1CQ_1,
&pInfo-> &state->
reg[MT2063_REG_LO1CQ_1], 2); reg[MT2063_REG_LO1CQ_1], 2);
/* set the one-shot bit to load the pair of LO values */ /* set the one-shot bit to load the pair of LO values */
tmpOneShot = tempLO2CQ[2] | 0xE0; tmpOneShot = tempLO2CQ[2] | 0xE0;
status |= status |=
MT2063_WriteSub(pInfo, MT2063_WriteSub(state,
MT2063_REG_LO2CQ_3, MT2063_REG_LO2CQ_3,
&tmpOneShot, 1); &tmpOneShot, 1);
...@@ -3168,43 +3168,43 @@ static u32 MT2063_SetParam(struct mt2063_state *pInfo, ...@@ -3168,43 +3168,43 @@ static u32 MT2063_SetParam(struct mt2063_state *pInfo,
if (restore) { if (restore) {
/* put actual LO2 value into queue (0 in one-shot bits) */ /* put actual LO2 value into queue (0 in one-shot bits) */
status |= status |=
MT2063_WriteSub(pInfo, MT2063_WriteSub(state,
MT2063_REG_LO2CQ_1, MT2063_REG_LO2CQ_1,
&(tempLO2CQ[0]), 3); &(tempLO2CQ[0]), 3);
/* cache the bytes just written. */ /* cache the bytes just written. */
pInfo->reg[MT2063_REG_LO2CQ_1] = state->reg[MT2063_REG_LO2CQ_1] =
tempLO2CQ[0]; tempLO2CQ[0];
pInfo->reg[MT2063_REG_LO2CQ_2] = state->reg[MT2063_REG_LO2CQ_2] =
tempLO2CQ[1]; tempLO2CQ[1];
pInfo->reg[MT2063_REG_LO2CQ_3] = state->reg[MT2063_REG_LO2CQ_3] =
tempLO2CQ[2]; tempLO2CQ[2];
} }
MT2063_GetParam(pInfo, MT2063_GetParam(state,
MT2063_LO1_FREQ, MT2063_LO1_FREQ,
&pInfo->AS_Data.f_LO1); &state->AS_Data.f_LO1);
} }
break; break;
/* LO1 minimum step size */ /* LO1 minimum step size */
case MT2063_LO1_STEPSIZE: case MT2063_LO1_STEPSIZE:
pInfo->AS_Data.f_LO1_Step = nValue; state->AS_Data.f_LO1_Step = nValue;
break; break;
/* LO1 FracN keep-out region */ /* LO1 FracN keep-out region */
case MT2063_LO1_FRACN_AVOID_PARAM: case MT2063_LO1_FRACN_AVOID_PARAM:
pInfo->AS_Data.f_LO1_FracN_Avoid = nValue; state->AS_Data.f_LO1_FracN_Avoid = nValue;
break; break;
/* Requested 1st IF */ /* Requested 1st IF */
case MT2063_IF1_REQUEST: case MT2063_IF1_REQUEST:
pInfo->AS_Data.f_if1_Request = nValue; state->AS_Data.f_if1_Request = nValue;
break; break;
/* zero-IF bandwidth */ /* zero-IF bandwidth */
case MT2063_ZIF_BW: case MT2063_ZIF_BW:
pInfo->AS_Data.f_zif_bw = nValue; state->AS_Data.f_zif_bw = nValue;
break; break;
/* LO2 frequency */ /* LO2 frequency */
...@@ -3221,11 +3221,11 @@ static u32 MT2063_SetParam(struct mt2063_state *pInfo, ...@@ -3221,11 +3221,11 @@ static u32 MT2063_SetParam(struct mt2063_state *pInfo,
/* Buffer the queue for restoration later and get actual LO2 values. */ /* Buffer the queue for restoration later and get actual LO2 values. */
status |= status |=
MT2063_ReadSub(pInfo, MT2063_ReadSub(state,
MT2063_REG_LO1CQ_1, MT2063_REG_LO1CQ_1,
&(tempLO1CQ[0]), 2); &(tempLO1CQ[0]), 2);
status |= status |=
MT2063_ReadSub(pInfo, MT2063_ReadSub(state,
MT2063_REG_LO1C_1, MT2063_REG_LO1C_1,
&(tempLO1C[0]), 2); &(tempLO1C[0]), 2);
...@@ -3234,14 +3234,14 @@ static u32 MT2063_SetParam(struct mt2063_state *pInfo, ...@@ -3234,14 +3234,14 @@ static u32 MT2063_SetParam(struct mt2063_state *pInfo,
|| (tempLO1CQ[1] != tempLO1C[1])) { || (tempLO1CQ[1] != tempLO1C[1])) {
/* put actual LO1 value into queue */ /* put actual LO1 value into queue */
status |= status |=
MT2063_WriteSub(pInfo, MT2063_WriteSub(state,
MT2063_REG_LO1CQ_1, MT2063_REG_LO1CQ_1,
&(tempLO1C[0]), 2); &(tempLO1C[0]), 2);
/* cache the bytes just written. */ /* cache the bytes just written. */
pInfo->reg[MT2063_REG_LO1CQ_1] = state->reg[MT2063_REG_LO1CQ_1] =
tempLO1C[0]; tempLO1C[0];
pInfo->reg[MT2063_REG_LO1CQ_2] = state->reg[MT2063_REG_LO1CQ_2] =
tempLO1C[1]; tempLO1C[1];
restore = 1; restore = 1;
} }
...@@ -3249,27 +3249,27 @@ static u32 MT2063_SetParam(struct mt2063_state *pInfo, ...@@ -3249,27 +3249,27 @@ static u32 MT2063_SetParam(struct mt2063_state *pInfo,
/* Calculate the Divider and Numberator components of LO2 */ /* Calculate the Divider and Numberator components of LO2 */
status = status =
MT2063_CalcLO2Mult(&Div2, &FracN2, nValue, MT2063_CalcLO2Mult(&Div2, &FracN2, nValue,
pInfo->AS_Data.f_ref / state->AS_Data.f_ref /
8191, 8191,
pInfo->AS_Data.f_ref); state->AS_Data.f_ref);
pInfo->reg[MT2063_REG_LO2CQ_1] = state->reg[MT2063_REG_LO2CQ_1] =
(u8) ((Div2 << 1) | (u8) ((Div2 << 1) |
((FracN2 >> 12) & 0x01)) & 0xFF; ((FracN2 >> 12) & 0x01)) & 0xFF;
pInfo->reg[MT2063_REG_LO2CQ_2] = state->reg[MT2063_REG_LO2CQ_2] =
(u8) ((FracN2 >> 4) & 0xFF); (u8) ((FracN2 >> 4) & 0xFF);
pInfo->reg[MT2063_REG_LO2CQ_3] = state->reg[MT2063_REG_LO2CQ_3] =
(u8) ((FracN2 & 0x0F)); (u8) ((FracN2 & 0x0F));
status |= status |=
MT2063_WriteSub(pInfo, MT2063_WriteSub(state,
MT2063_REG_LO1CQ_1, MT2063_REG_LO1CQ_1,
&pInfo-> &state->
reg[MT2063_REG_LO1CQ_1], 3); reg[MT2063_REG_LO1CQ_1], 3);
/* set the one-shot bit to load the LO values */ /* set the one-shot bit to load the LO values */
tmpOneShot = tmpOneShot =
pInfo->reg[MT2063_REG_LO2CQ_3] | 0xE0; state->reg[MT2063_REG_LO2CQ_3] | 0xE0;
status |= status |=
MT2063_WriteSub(pInfo, MT2063_WriteSub(state,
MT2063_REG_LO2CQ_3, MT2063_REG_LO2CQ_3,
&tmpOneShot, 1); &tmpOneShot, 1);
...@@ -3277,61 +3277,61 @@ static u32 MT2063_SetParam(struct mt2063_state *pInfo, ...@@ -3277,61 +3277,61 @@ static u32 MT2063_SetParam(struct mt2063_state *pInfo,
if (restore) { if (restore) {
/* put previous LO1 queue value back into queue */ /* put previous LO1 queue value back into queue */
status |= status |=
MT2063_WriteSub(pInfo, MT2063_WriteSub(state,
MT2063_REG_LO1CQ_1, MT2063_REG_LO1CQ_1,
&(tempLO1CQ[0]), 2); &(tempLO1CQ[0]), 2);
/* cache the bytes just written. */ /* cache the bytes just written. */
pInfo->reg[MT2063_REG_LO1CQ_1] = state->reg[MT2063_REG_LO1CQ_1] =
tempLO1CQ[0]; tempLO1CQ[0];
pInfo->reg[MT2063_REG_LO1CQ_2] = state->reg[MT2063_REG_LO1CQ_2] =
tempLO1CQ[1]; tempLO1CQ[1];
} }
MT2063_GetParam(pInfo, MT2063_GetParam(state,
MT2063_LO2_FREQ, MT2063_LO2_FREQ,
&pInfo->AS_Data.f_LO2); &state->AS_Data.f_LO2);
} }
break; break;
/* LO2 minimum step size */ /* LO2 minimum step size */
case MT2063_LO2_STEPSIZE: case MT2063_LO2_STEPSIZE:
pInfo->AS_Data.f_LO2_Step = nValue; state->AS_Data.f_LO2_Step = nValue;
break; break;
/* LO2 FracN keep-out region */ /* LO2 FracN keep-out region */
case MT2063_LO2_FRACN_AVOID: case MT2063_LO2_FRACN_AVOID:
pInfo->AS_Data.f_LO2_FracN_Avoid = nValue; state->AS_Data.f_LO2_FracN_Avoid = nValue;
break; break;
/* output center frequency */ /* output center frequency */
case MT2063_OUTPUT_FREQ: case MT2063_OUTPUT_FREQ:
pInfo->AS_Data.f_out = nValue; state->AS_Data.f_out = nValue;
break; break;
/* output bandwidth */ /* output bandwidth */
case MT2063_OUTPUT_BW: case MT2063_OUTPUT_BW:
pInfo->AS_Data.f_out_bw = nValue + 750000; state->AS_Data.f_out_bw = nValue + 750000;
break; break;
/* min inter-tuner LO separation */ /* min inter-tuner LO separation */
case MT2063_LO_SEPARATION: case MT2063_LO_SEPARATION:
pInfo->AS_Data.f_min_LO_Separation = nValue; state->AS_Data.f_min_LO_Separation = nValue;
break; break;
/* max # of intra-tuner harmonics */ /* max # of intra-tuner harmonics */
case MT2063_MAX_HARM1: case MT2063_MAX_HARM1:
pInfo->AS_Data.maxH1 = nValue; state->AS_Data.maxH1 = nValue;
break; break;
/* max # of inter-tuner harmonics */ /* max # of inter-tuner harmonics */
case MT2063_MAX_HARM2: case MT2063_MAX_HARM2:
pInfo->AS_Data.maxH2 = nValue; state->AS_Data.maxH2 = nValue;
break; break;
case MT2063_RCVR_MODE: case MT2063_RCVR_MODE:
status |= status |=
MT2063_SetReceiverMode(pInfo, MT2063_SetReceiverMode(state,
(enum MT2063_RCVR_MODES) (enum MT2063_RCVR_MODES)
nValue); nValue);
break; break;
...@@ -3339,12 +3339,12 @@ static u32 MT2063_SetParam(struct mt2063_state *pInfo, ...@@ -3339,12 +3339,12 @@ static u32 MT2063_SetParam(struct mt2063_state *pInfo,
/* Set LNA Rin -- nValue is desired value */ /* Set LNA Rin -- nValue is desired value */
case MT2063_LNA_RIN: case MT2063_LNA_RIN:
val = val =
(pInfo-> (state->
reg[MT2063_REG_CTRL_2C] & (u8) ~ 0x03) | reg[MT2063_REG_CTRL_2C] & (u8) ~ 0x03) |
(nValue & 0x03); (nValue & 0x03);
if (pInfo->reg[MT2063_REG_CTRL_2C] != val) { if (state->reg[MT2063_REG_CTRL_2C] != val) {
status |= status |=
MT2063_SetReg(pInfo, MT2063_REG_CTRL_2C, MT2063_SetReg(state, MT2063_REG_CTRL_2C,
val); val);
} }
break; break;
...@@ -3352,12 +3352,12 @@ static u32 MT2063_SetParam(struct mt2063_state *pInfo, ...@@ -3352,12 +3352,12 @@ static u32 MT2063_SetParam(struct mt2063_state *pInfo,
/* Set target power level at LNA -- nValue is desired value */ /* Set target power level at LNA -- nValue is desired value */
case MT2063_LNA_TGT: case MT2063_LNA_TGT:
val = val =
(pInfo-> (state->
reg[MT2063_REG_LNA_TGT] & (u8) ~ 0x3F) | reg[MT2063_REG_LNA_TGT] & (u8) ~ 0x3F) |
(nValue & 0x3F); (nValue & 0x3F);
if (pInfo->reg[MT2063_REG_LNA_TGT] != val) { if (state->reg[MT2063_REG_LNA_TGT] != val) {
status |= status |=
MT2063_SetReg(pInfo, MT2063_REG_LNA_TGT, MT2063_SetReg(state, MT2063_REG_LNA_TGT,
val); val);
} }
break; break;
...@@ -3365,12 +3365,12 @@ static u32 MT2063_SetParam(struct mt2063_state *pInfo, ...@@ -3365,12 +3365,12 @@ static u32 MT2063_SetParam(struct mt2063_state *pInfo,
/* Set target power level at PD1 -- nValue is desired value */ /* Set target power level at PD1 -- nValue is desired value */
case MT2063_PD1_TGT: case MT2063_PD1_TGT:
val = val =
(pInfo-> (state->
reg[MT2063_REG_PD1_TGT] & (u8) ~ 0x3F) | reg[MT2063_REG_PD1_TGT] & (u8) ~ 0x3F) |
(nValue & 0x3F); (nValue & 0x3F);
if (pInfo->reg[MT2063_REG_PD1_TGT] != val) { if (state->reg[MT2063_REG_PD1_TGT] != val) {
status |= status |=
MT2063_SetReg(pInfo, MT2063_REG_PD1_TGT, MT2063_SetReg(state, MT2063_REG_PD1_TGT,
val); val);
} }
break; break;
...@@ -3378,12 +3378,12 @@ static u32 MT2063_SetParam(struct mt2063_state *pInfo, ...@@ -3378,12 +3378,12 @@ static u32 MT2063_SetParam(struct mt2063_state *pInfo,
/* Set target power level at PD2 -- nValue is desired value */ /* Set target power level at PD2 -- nValue is desired value */
case MT2063_PD2_TGT: case MT2063_PD2_TGT:
val = val =
(pInfo-> (state->
reg[MT2063_REG_PD2_TGT] & (u8) ~ 0x3F) | reg[MT2063_REG_PD2_TGT] & (u8) ~ 0x3F) |
(nValue & 0x3F); (nValue & 0x3F);
if (pInfo->reg[MT2063_REG_PD2_TGT] != val) { if (state->reg[MT2063_REG_PD2_TGT] != val) {
status |= status |=
MT2063_SetReg(pInfo, MT2063_REG_PD2_TGT, MT2063_SetReg(state, MT2063_REG_PD2_TGT,
val); val);
} }
break; break;
...@@ -3391,13 +3391,13 @@ static u32 MT2063_SetParam(struct mt2063_state *pInfo, ...@@ -3391,13 +3391,13 @@ static u32 MT2063_SetParam(struct mt2063_state *pInfo,
/* Set LNA atten limit -- nValue is desired value */ /* Set LNA atten limit -- nValue is desired value */
case MT2063_ACLNA_MAX: case MT2063_ACLNA_MAX:
val = val =
(pInfo-> (state->
reg[MT2063_REG_LNA_OV] & (u8) ~ 0x1F) | (nValue reg[MT2063_REG_LNA_OV] & (u8) ~ 0x1F) | (nValue
& &
0x1F); 0x1F);
if (pInfo->reg[MT2063_REG_LNA_OV] != val) { if (state->reg[MT2063_REG_LNA_OV] != val) {
status |= status |=
MT2063_SetReg(pInfo, MT2063_REG_LNA_OV, MT2063_SetReg(state, MT2063_REG_LNA_OV,
val); val);
} }
break; break;
...@@ -3405,29 +3405,29 @@ static u32 MT2063_SetParam(struct mt2063_state *pInfo, ...@@ -3405,29 +3405,29 @@ static u32 MT2063_SetParam(struct mt2063_state *pInfo,
/* Set RF atten limit -- nValue is desired value */ /* Set RF atten limit -- nValue is desired value */
case MT2063_ACRF_MAX: case MT2063_ACRF_MAX:
val = val =
(pInfo-> (state->
reg[MT2063_REG_RF_OV] & (u8) ~ 0x1F) | (nValue reg[MT2063_REG_RF_OV] & (u8) ~ 0x1F) | (nValue
& &
0x1F); 0x1F);
if (pInfo->reg[MT2063_REG_RF_OV] != val) { if (state->reg[MT2063_REG_RF_OV] != val) {
status |= status |=
MT2063_SetReg(pInfo, MT2063_REG_RF_OV, val); MT2063_SetReg(state, MT2063_REG_RF_OV, val);
} }
break; break;
/* Set FIF atten limit -- nValue is desired value, max. 5 if no B3 */ /* Set FIF atten limit -- nValue is desired value, max. 5 if no B3 */
case MT2063_ACFIF_MAX: case MT2063_ACFIF_MAX:
if (pInfo->reg[MT2063_REG_PART_REV] != MT2063_B3 if (state->reg[MT2063_REG_PART_REV] != MT2063_B3
&& nValue > 5) && nValue > 5)
nValue = 5; nValue = 5;
val = val =
(pInfo-> (state->
reg[MT2063_REG_FIF_OV] & (u8) ~ 0x1F) | (nValue reg[MT2063_REG_FIF_OV] & (u8) ~ 0x1F) | (nValue
& &
0x1F); 0x1F);
if (pInfo->reg[MT2063_REG_FIF_OV] != val) { if (state->reg[MT2063_REG_FIF_OV] != val) {
status |= status |=
MT2063_SetReg(pInfo, MT2063_REG_FIF_OV, MT2063_SetReg(state, MT2063_REG_FIF_OV,
val); val);
} }
break; break;
...@@ -3437,27 +3437,27 @@ static u32 MT2063_SetParam(struct mt2063_state *pInfo, ...@@ -3437,27 +3437,27 @@ static u32 MT2063_SetParam(struct mt2063_state *pInfo,
switch (nValue) { switch (nValue) {
case MT2063_DNC_NONE: case MT2063_DNC_NONE:
{ {
val = (pInfo->reg[MT2063_REG_DNC_GAIN] & 0xFC) | 0x03; /* Set DNC1GC=3 */ val = (state->reg[MT2063_REG_DNC_GAIN] & 0xFC) | 0x03; /* Set DNC1GC=3 */
if (pInfo->reg[MT2063_REG_DNC_GAIN] != if (state->reg[MT2063_REG_DNC_GAIN] !=
val) val)
status |= status |=
MT2063_SetReg(pInfo, MT2063_SetReg(state,
MT2063_REG_DNC_GAIN, MT2063_REG_DNC_GAIN,
val); val);
val = (pInfo->reg[MT2063_REG_VGA_GAIN] & 0xFC) | 0x03; /* Set DNC2GC=3 */ val = (state->reg[MT2063_REG_VGA_GAIN] & 0xFC) | 0x03; /* Set DNC2GC=3 */
if (pInfo->reg[MT2063_REG_VGA_GAIN] != if (state->reg[MT2063_REG_VGA_GAIN] !=
val) val)
status |= status |=
MT2063_SetReg(pInfo, MT2063_SetReg(state,
MT2063_REG_VGA_GAIN, MT2063_REG_VGA_GAIN,
val); val);
val = (pInfo->reg[MT2063_REG_RSVD_20] & ~0x40); /* Set PD2MUX=0 */ val = (state->reg[MT2063_REG_RSVD_20] & ~0x40); /* Set PD2MUX=0 */
if (pInfo->reg[MT2063_REG_RSVD_20] != if (state->reg[MT2063_REG_RSVD_20] !=
val) val)
status |= status |=
MT2063_SetReg(pInfo, MT2063_SetReg(state,
MT2063_REG_RSVD_20, MT2063_REG_RSVD_20,
val); val);
...@@ -3465,27 +3465,27 @@ static u32 MT2063_SetParam(struct mt2063_state *pInfo, ...@@ -3465,27 +3465,27 @@ static u32 MT2063_SetParam(struct mt2063_state *pInfo,
} }
case MT2063_DNC_1: case MT2063_DNC_1:
{ {
val = (pInfo->reg[MT2063_REG_DNC_GAIN] & 0xFC) | (DNC1GC[pInfo->rcvr_mode] & 0x03); /* Set DNC1GC=x */ val = (state->reg[MT2063_REG_DNC_GAIN] & 0xFC) | (DNC1GC[state->rcvr_mode] & 0x03); /* Set DNC1GC=x */
if (pInfo->reg[MT2063_REG_DNC_GAIN] != if (state->reg[MT2063_REG_DNC_GAIN] !=
val) val)
status |= status |=
MT2063_SetReg(pInfo, MT2063_SetReg(state,
MT2063_REG_DNC_GAIN, MT2063_REG_DNC_GAIN,
val); val);
val = (pInfo->reg[MT2063_REG_VGA_GAIN] & 0xFC) | 0x03; /* Set DNC2GC=3 */ val = (state->reg[MT2063_REG_VGA_GAIN] & 0xFC) | 0x03; /* Set DNC2GC=3 */
if (pInfo->reg[MT2063_REG_VGA_GAIN] != if (state->reg[MT2063_REG_VGA_GAIN] !=
val) val)
status |= status |=
MT2063_SetReg(pInfo, MT2063_SetReg(state,
MT2063_REG_VGA_GAIN, MT2063_REG_VGA_GAIN,
val); val);
val = (pInfo->reg[MT2063_REG_RSVD_20] & ~0x40); /* Set PD2MUX=0 */ val = (state->reg[MT2063_REG_RSVD_20] & ~0x40); /* Set PD2MUX=0 */
if (pInfo->reg[MT2063_REG_RSVD_20] != if (state->reg[MT2063_REG_RSVD_20] !=
val) val)
status |= status |=
MT2063_SetReg(pInfo, MT2063_SetReg(state,
MT2063_REG_RSVD_20, MT2063_REG_RSVD_20,
val); val);
...@@ -3493,27 +3493,27 @@ static u32 MT2063_SetParam(struct mt2063_state *pInfo, ...@@ -3493,27 +3493,27 @@ static u32 MT2063_SetParam(struct mt2063_state *pInfo,
} }
case MT2063_DNC_2: case MT2063_DNC_2:
{ {
val = (pInfo->reg[MT2063_REG_DNC_GAIN] & 0xFC) | 0x03; /* Set DNC1GC=3 */ val = (state->reg[MT2063_REG_DNC_GAIN] & 0xFC) | 0x03; /* Set DNC1GC=3 */
if (pInfo->reg[MT2063_REG_DNC_GAIN] != if (state->reg[MT2063_REG_DNC_GAIN] !=
val) val)
status |= status |=
MT2063_SetReg(pInfo, MT2063_SetReg(state,
MT2063_REG_DNC_GAIN, MT2063_REG_DNC_GAIN,
val); val);
val = (pInfo->reg[MT2063_REG_VGA_GAIN] & 0xFC) | (DNC2GC[pInfo->rcvr_mode] & 0x03); /* Set DNC2GC=x */ val = (state->reg[MT2063_REG_VGA_GAIN] & 0xFC) | (DNC2GC[state->rcvr_mode] & 0x03); /* Set DNC2GC=x */
if (pInfo->reg[MT2063_REG_VGA_GAIN] != if (state->reg[MT2063_REG_VGA_GAIN] !=
val) val)
status |= status |=
MT2063_SetReg(pInfo, MT2063_SetReg(state,
MT2063_REG_VGA_GAIN, MT2063_REG_VGA_GAIN,
val); val);
val = (pInfo->reg[MT2063_REG_RSVD_20] | 0x40); /* Set PD2MUX=1 */ val = (state->reg[MT2063_REG_RSVD_20] | 0x40); /* Set PD2MUX=1 */
if (pInfo->reg[MT2063_REG_RSVD_20] != if (state->reg[MT2063_REG_RSVD_20] !=
val) val)
status |= status |=
MT2063_SetReg(pInfo, MT2063_SetReg(state,
MT2063_REG_RSVD_20, MT2063_REG_RSVD_20,
val); val);
...@@ -3521,27 +3521,27 @@ static u32 MT2063_SetParam(struct mt2063_state *pInfo, ...@@ -3521,27 +3521,27 @@ static u32 MT2063_SetParam(struct mt2063_state *pInfo,
} }
case MT2063_DNC_BOTH: case MT2063_DNC_BOTH:
{ {
val = (pInfo->reg[MT2063_REG_DNC_GAIN] & 0xFC) | (DNC1GC[pInfo->rcvr_mode] & 0x03); /* Set DNC1GC=x */ val = (state->reg[MT2063_REG_DNC_GAIN] & 0xFC) | (DNC1GC[state->rcvr_mode] & 0x03); /* Set DNC1GC=x */
if (pInfo->reg[MT2063_REG_DNC_GAIN] != if (state->reg[MT2063_REG_DNC_GAIN] !=
val) val)
status |= status |=
MT2063_SetReg(pInfo, MT2063_SetReg(state,
MT2063_REG_DNC_GAIN, MT2063_REG_DNC_GAIN,
val); val);
val = (pInfo->reg[MT2063_REG_VGA_GAIN] & 0xFC) | (DNC2GC[pInfo->rcvr_mode] & 0x03); /* Set DNC2GC=x */ val = (state->reg[MT2063_REG_VGA_GAIN] & 0xFC) | (DNC2GC[state->rcvr_mode] & 0x03); /* Set DNC2GC=x */
if (pInfo->reg[MT2063_REG_VGA_GAIN] != if (state->reg[MT2063_REG_VGA_GAIN] !=
val) val)
status |= status |=
MT2063_SetReg(pInfo, MT2063_SetReg(state,
MT2063_REG_VGA_GAIN, MT2063_REG_VGA_GAIN,
val); val);
val = (pInfo->reg[MT2063_REG_RSVD_20] | 0x40); /* Set PD2MUX=1 */ val = (state->reg[MT2063_REG_RSVD_20] | 0x40); /* Set PD2MUX=1 */
if (pInfo->reg[MT2063_REG_RSVD_20] != if (state->reg[MT2063_REG_RSVD_20] !=
val) val)
status |= status |=
MT2063_SetReg(pInfo, MT2063_SetReg(state,
MT2063_REG_RSVD_20, MT2063_REG_RSVD_20,
val); val);
...@@ -3555,12 +3555,12 @@ static u32 MT2063_SetParam(struct mt2063_state *pInfo, ...@@ -3555,12 +3555,12 @@ static u32 MT2063_SetParam(struct mt2063_state *pInfo,
case MT2063_VGAGC: case MT2063_VGAGC:
/* Set VGA gain code */ /* Set VGA gain code */
val = val =
(pInfo-> (state->
reg[MT2063_REG_VGA_GAIN] & (u8) ~ 0x0C) | reg[MT2063_REG_VGA_GAIN] & (u8) ~ 0x0C) |
((nValue & 0x03) << 2); ((nValue & 0x03) << 2);
if (pInfo->reg[MT2063_REG_VGA_GAIN] != val) { if (state->reg[MT2063_REG_VGA_GAIN] != val) {
status |= status |=
MT2063_SetReg(pInfo, MT2063_REG_VGA_GAIN, MT2063_SetReg(state, MT2063_REG_VGA_GAIN,
val); val);
} }
break; break;
...@@ -3568,12 +3568,12 @@ static u32 MT2063_SetParam(struct mt2063_state *pInfo, ...@@ -3568,12 +3568,12 @@ static u32 MT2063_SetParam(struct mt2063_state *pInfo,
case MT2063_VGAOI: case MT2063_VGAOI:
/* Set VGA bias current */ /* Set VGA bias current */
val = val =
(pInfo-> (state->
reg[MT2063_REG_RSVD_31] & (u8) ~ 0x07) | reg[MT2063_REG_RSVD_31] & (u8) ~ 0x07) |
(nValue & 0x07); (nValue & 0x07);
if (pInfo->reg[MT2063_REG_RSVD_31] != val) { if (state->reg[MT2063_REG_RSVD_31] != val) {
status |= status |=
MT2063_SetReg(pInfo, MT2063_REG_RSVD_31, MT2063_SetReg(state, MT2063_REG_RSVD_31,
val); val);
} }
break; break;
...@@ -3581,12 +3581,12 @@ static u32 MT2063_SetParam(struct mt2063_state *pInfo, ...@@ -3581,12 +3581,12 @@ static u32 MT2063_SetParam(struct mt2063_state *pInfo,
case MT2063_TAGC: case MT2063_TAGC:
/* Set TAGC */ /* Set TAGC */
val = val =
(pInfo-> (state->
reg[MT2063_REG_RSVD_1E] & (u8) ~ 0x03) | reg[MT2063_REG_RSVD_1E] & (u8) ~ 0x03) |
(nValue & 0x03); (nValue & 0x03);
if (pInfo->reg[MT2063_REG_RSVD_1E] != val) { if (state->reg[MT2063_REG_RSVD_1E] != val) {
status |= status |=
MT2063_SetReg(pInfo, MT2063_REG_RSVD_1E, MT2063_SetReg(state, MT2063_REG_RSVD_1E,
val); val);
} }
break; break;
...@@ -3594,12 +3594,12 @@ static u32 MT2063_SetParam(struct mt2063_state *pInfo, ...@@ -3594,12 +3594,12 @@ static u32 MT2063_SetParam(struct mt2063_state *pInfo,
case MT2063_AMPGC: case MT2063_AMPGC:
/* Set Amp gain code */ /* Set Amp gain code */
val = val =
(pInfo-> (state->
reg[MT2063_REG_TEMP_SEL] & (u8) ~ 0x03) | reg[MT2063_REG_TEMP_SEL] & (u8) ~ 0x03) |
(nValue & 0x03); (nValue & 0x03);
if (pInfo->reg[MT2063_REG_TEMP_SEL] != val) { if (state->reg[MT2063_REG_TEMP_SEL] != val) {
status |= status |=
MT2063_SetReg(pInfo, MT2063_REG_TEMP_SEL, MT2063_SetReg(state, MT2063_REG_TEMP_SEL,
val); val);
} }
break; break;
...@@ -3612,7 +3612,7 @@ static u32 MT2063_SetParam(struct mt2063_state *pInfo, ...@@ -3612,7 +3612,7 @@ static u32 MT2063_SetParam(struct mt2063_state *pInfo,
if ((newAvoidSetting >= if ((newAvoidSetting >=
MT2063_NO_DECT_AVOIDANCE) MT2063_NO_DECT_AVOIDANCE)
&& (newAvoidSetting <= MT2063_AVOID_BOTH)) { && (newAvoidSetting <= MT2063_AVOID_BOTH)) {
pInfo->AS_Data.avoidDECT = state->AS_Data.avoidDECT =
newAvoidSetting; newAvoidSetting;
} }
} }
...@@ -3620,7 +3620,7 @@ static u32 MT2063_SetParam(struct mt2063_state *pInfo, ...@@ -3620,7 +3620,7 @@ static u32 MT2063_SetParam(struct mt2063_state *pInfo,
/* Cleartune filter selection: 0 - by IC (default), 1 - by software */ /* Cleartune filter selection: 0 - by IC (default), 1 - by software */
case MT2063_CTFILT_SW: case MT2063_CTFILT_SW:
pInfo->ctfilt_sw = (nValue & 0x01); state->ctfilt_sw = (nValue & 0x01);
break; break;
/* These parameters are read-only */ /* These parameters are read-only */
...@@ -3673,24 +3673,24 @@ static u32 MT2063_SetParam(struct mt2063_state *pInfo, ...@@ -3673,24 +3673,24 @@ static u32 MT2063_SetParam(struct mt2063_state *pInfo,
** 138 06-19-2007 DAD Ver 1.00: Initial, derived from mt2067_b. ** 138 06-19-2007 DAD Ver 1.00: Initial, derived from mt2067_b.
** **
****************************************************************************/ ****************************************************************************/
static u32 MT2063_ClearPowerMaskBits(struct mt2063_state *pInfo, enum MT2063_Mask_Bits Bits) static u32 MT2063_ClearPowerMaskBits(struct mt2063_state *state, enum MT2063_Mask_Bits Bits)
{ {
u32 status = 0; /* Status to be returned */ u32 status = 0; /* Status to be returned */
Bits = (enum MT2063_Mask_Bits)(Bits & MT2063_ALL_SD); /* Only valid bits for this tuner */ Bits = (enum MT2063_Mask_Bits)(Bits & MT2063_ALL_SD); /* Only valid bits for this tuner */
if ((Bits & 0xFF00) != 0) { if ((Bits & 0xFF00) != 0) {
pInfo->reg[MT2063_REG_PWR_2] &= ~(u8) (Bits >> 8); state->reg[MT2063_REG_PWR_2] &= ~(u8) (Bits >> 8);
status |= status |=
MT2063_WriteSub(pInfo, MT2063_WriteSub(state,
MT2063_REG_PWR_2, MT2063_REG_PWR_2,
&pInfo->reg[MT2063_REG_PWR_2], 1); &state->reg[MT2063_REG_PWR_2], 1);
} }
if ((Bits & 0xFF) != 0) { if ((Bits & 0xFF) != 0) {
pInfo->reg[MT2063_REG_PWR_1] &= ~(u8) (Bits & 0xFF); state->reg[MT2063_REG_PWR_1] &= ~(u8) (Bits & 0xFF);
status |= status |=
MT2063_WriteSub(pInfo, MT2063_WriteSub(state,
MT2063_REG_PWR_1, MT2063_REG_PWR_1,
&pInfo->reg[MT2063_REG_PWR_1], 1); &state->reg[MT2063_REG_PWR_1], 1);
} }
return (status); return (status);
...@@ -3724,34 +3724,34 @@ static u32 MT2063_ClearPowerMaskBits(struct mt2063_state *pInfo, enum MT2063_Mas ...@@ -3724,34 +3724,34 @@ static u32 MT2063_ClearPowerMaskBits(struct mt2063_state *pInfo, enum MT2063_Mas
** correct wakeup of the LNA ** correct wakeup of the LNA
** **
****************************************************************************/ ****************************************************************************/
static u32 MT2063_SoftwareShutdown(struct mt2063_state *pInfo, u8 Shutdown) static u32 MT2063_SoftwareShutdown(struct mt2063_state *state, u8 Shutdown)
{ {
u32 status = 0; /* Status to be returned */ u32 status = 0; /* Status to be returned */
if (Shutdown == 1) if (Shutdown == 1)
pInfo->reg[MT2063_REG_PWR_1] |= 0x04; /* Turn the bit on */ state->reg[MT2063_REG_PWR_1] |= 0x04; /* Turn the bit on */
else else
pInfo->reg[MT2063_REG_PWR_1] &= ~0x04; /* Turn off the bit */ state->reg[MT2063_REG_PWR_1] &= ~0x04; /* Turn off the bit */
status |= status |=
MT2063_WriteSub(pInfo, MT2063_WriteSub(state,
MT2063_REG_PWR_1, MT2063_REG_PWR_1,
&pInfo->reg[MT2063_REG_PWR_1], 1); &state->reg[MT2063_REG_PWR_1], 1);
if (Shutdown != 1) { if (Shutdown != 1) {
pInfo->reg[MT2063_REG_BYP_CTRL] = state->reg[MT2063_REG_BYP_CTRL] =
(pInfo->reg[MT2063_REG_BYP_CTRL] & 0x9F) | 0x40; (state->reg[MT2063_REG_BYP_CTRL] & 0x9F) | 0x40;
status |= status |=
MT2063_WriteSub(pInfo, MT2063_WriteSub(state,
MT2063_REG_BYP_CTRL, MT2063_REG_BYP_CTRL,
&pInfo->reg[MT2063_REG_BYP_CTRL], &state->reg[MT2063_REG_BYP_CTRL],
1); 1);
pInfo->reg[MT2063_REG_BYP_CTRL] = state->reg[MT2063_REG_BYP_CTRL] =
(pInfo->reg[MT2063_REG_BYP_CTRL] & 0x9F); (state->reg[MT2063_REG_BYP_CTRL] & 0x9F);
status |= status |=
MT2063_WriteSub(pInfo, MT2063_WriteSub(state,
MT2063_REG_BYP_CTRL, MT2063_REG_BYP_CTRL,
&pInfo->reg[MT2063_REG_BYP_CTRL], &state->reg[MT2063_REG_BYP_CTRL],
1); 1);
} }
...@@ -3786,17 +3786,17 @@ static u32 MT2063_SoftwareShutdown(struct mt2063_state *pInfo, u8 Shutdown) ...@@ -3786,17 +3786,17 @@ static u32 MT2063_SoftwareShutdown(struct mt2063_state *pInfo, u8 Shutdown)
** 138 06-19-2007 DAD Ver 1.00: Initial, derived from mt2067_b. ** 138 06-19-2007 DAD Ver 1.00: Initial, derived from mt2067_b.
** **
****************************************************************************/ ****************************************************************************/
static u32 MT2063_SetReg(struct mt2063_state *pInfo, u8 reg, u8 val) static u32 MT2063_SetReg(struct mt2063_state *state, u8 reg, u8 val)
{ {
u32 status = 0; /* Status to be returned */ u32 status = 0; /* Status to be returned */
if (reg >= MT2063_REG_END_REGS) if (reg >= MT2063_REG_END_REGS)
status |= -ERANGE; status |= -ERANGE;
status = MT2063_WriteSub(pInfo, reg, &val, status = MT2063_WriteSub(state, reg, &val,
1); 1);
if (status >= 0) if (status >= 0)
pInfo->reg[reg] = val; state->reg[reg] = val;
return (status); return (status);
} }
...@@ -3942,7 +3942,7 @@ static u32 MT2063_CalcLO2Mult(u32 * Div, ...@@ -3942,7 +3942,7 @@ static u32 MT2063_CalcLO2Mult(u32 * Div,
** Description: Calculate the corrrect ClearTune filter to be used for ** Description: Calculate the corrrect ClearTune filter to be used for
** a given input frequency. ** a given input frequency.
** **
** Parameters: pInfo - ptr to tuner data structure ** Parameters: state - ptr to tuner data structure
** f_in - RF input center frequency (in Hz). ** f_in - RF input center frequency (in Hz).
** **
** Returns: ClearTune filter number (0-31) ** Returns: ClearTune filter number (0-31)
...@@ -3957,7 +3957,7 @@ static u32 MT2063_CalcLO2Mult(u32 * Div, ...@@ -3957,7 +3957,7 @@ static u32 MT2063_CalcLO2Mult(u32 * Div,
** cross-over frequency values. ** cross-over frequency values.
** **
****************************************************************************/ ****************************************************************************/
static u32 FindClearTuneFilter(struct mt2063_state *pInfo, u32 f_in) static u32 FindClearTuneFilter(struct mt2063_state *state, u32 f_in)
{ {
u32 RFBand; u32 RFBand;
u32 idx; /* index loop */ u32 idx; /* index loop */
...@@ -3967,7 +3967,7 @@ static u32 FindClearTuneFilter(struct mt2063_state *pInfo, u32 f_in) ...@@ -3967,7 +3967,7 @@ static u32 FindClearTuneFilter(struct mt2063_state *pInfo, u32 f_in)
*/ */
RFBand = 31; /* def when f_in > all */ RFBand = 31; /* def when f_in > all */
for (idx = 0; idx < 31; ++idx) { for (idx = 0; idx < 31; ++idx) {
if (pInfo->CTFiltMax[idx] >= f_in) { if (state->CTFiltMax[idx] >= f_in) {
RFBand = idx; RFBand = idx;
break; break;
} }
...@@ -4016,7 +4016,7 @@ static u32 FindClearTuneFilter(struct mt2063_state *pInfo, u32 f_in) ...@@ -4016,7 +4016,7 @@ static u32 FindClearTuneFilter(struct mt2063_state *pInfo, u32 f_in)
** 06-24-2008 PINZ Ver 1.18: Add Get/SetParam CTFILT_SW ** 06-24-2008 PINZ Ver 1.18: Add Get/SetParam CTFILT_SW
** **
****************************************************************************/ ****************************************************************************/
static u32 MT2063_Tune(struct mt2063_state *pInfo, u32 f_in) static u32 MT2063_Tune(struct mt2063_state *state, u32 f_in)
{ /* RF input center frequency */ { /* RF input center frequency */
u32 status = 0; /* status of operation */ u32 status = 0; /* status of operation */
...@@ -4038,35 +4038,35 @@ static u32 MT2063_Tune(struct mt2063_state *pInfo, u32 f_in) ...@@ -4038,35 +4038,35 @@ static u32 MT2063_Tune(struct mt2063_state *pInfo, u32 f_in)
if ((f_in < MT2063_MIN_FIN_FREQ) || (f_in > MT2063_MAX_FIN_FREQ)) if ((f_in < MT2063_MIN_FIN_FREQ) || (f_in > MT2063_MAX_FIN_FREQ))
return -EINVAL; return -EINVAL;
if ((pInfo->AS_Data.f_out < MT2063_MIN_FOUT_FREQ) if ((state->AS_Data.f_out < MT2063_MIN_FOUT_FREQ)
|| (pInfo->AS_Data.f_out > MT2063_MAX_FOUT_FREQ)) || (state->AS_Data.f_out > MT2063_MAX_FOUT_FREQ))
return -EINVAL; return -EINVAL;
/* /*
** Save original LO1 and LO2 register values ** Save original LO1 and LO2 register values
*/ */
ofLO1 = pInfo->AS_Data.f_LO1; ofLO1 = state->AS_Data.f_LO1;
ofLO2 = pInfo->AS_Data.f_LO2; ofLO2 = state->AS_Data.f_LO2;
ofin = pInfo->AS_Data.f_in; ofin = state->AS_Data.f_in;
ofout = pInfo->AS_Data.f_out; ofout = state->AS_Data.f_out;
/* /*
** Find and set RF Band setting ** Find and set RF Band setting
*/ */
if (pInfo->ctfilt_sw == 1) { if (state->ctfilt_sw == 1) {
val = (pInfo->reg[MT2063_REG_CTUNE_CTRL] | 0x08); val = (state->reg[MT2063_REG_CTUNE_CTRL] | 0x08);
if (pInfo->reg[MT2063_REG_CTUNE_CTRL] != val) { if (state->reg[MT2063_REG_CTUNE_CTRL] != val) {
status |= status |=
MT2063_SetReg(pInfo, MT2063_REG_CTUNE_CTRL, val); MT2063_SetReg(state, MT2063_REG_CTUNE_CTRL, val);
} }
val = pInfo->reg[MT2063_REG_CTUNE_OV]; val = state->reg[MT2063_REG_CTUNE_OV];
RFBand = FindClearTuneFilter(pInfo, f_in); RFBand = FindClearTuneFilter(state, f_in);
pInfo->reg[MT2063_REG_CTUNE_OV] = state->reg[MT2063_REG_CTUNE_OV] =
(u8) ((pInfo->reg[MT2063_REG_CTUNE_OV] & ~0x1F) (u8) ((state->reg[MT2063_REG_CTUNE_OV] & ~0x1F)
| RFBand); | RFBand);
if (pInfo->reg[MT2063_REG_CTUNE_OV] != val) { if (state->reg[MT2063_REG_CTUNE_OV] != val) {
status |= status |=
MT2063_SetReg(pInfo, MT2063_REG_CTUNE_OV, val); MT2063_SetReg(state, MT2063_REG_CTUNE_OV, val);
} }
} }
...@@ -4075,77 +4075,77 @@ static u32 MT2063_Tune(struct mt2063_state *pInfo, u32 f_in) ...@@ -4075,77 +4075,77 @@ static u32 MT2063_Tune(struct mt2063_state *pInfo, u32 f_in)
*/ */
if (status >= 0) { if (status >= 0) {
status |= status |=
MT2063_ReadSub(pInfo, MT2063_ReadSub(state,
MT2063_REG_FIFFC, MT2063_REG_FIFFC,
&pInfo->reg[MT2063_REG_FIFFC], 1); &state->reg[MT2063_REG_FIFFC], 1);
fiffc = pInfo->reg[MT2063_REG_FIFFC]; fiffc = state->reg[MT2063_REG_FIFFC];
} }
/* /*
** Assign in the requested values ** Assign in the requested values
*/ */
pInfo->AS_Data.f_in = f_in; state->AS_Data.f_in = f_in;
/* Request a 1st IF such that LO1 is on a step size */ /* Request a 1st IF such that LO1 is on a step size */
pInfo->AS_Data.f_if1_Request = state->AS_Data.f_if1_Request =
MT2063_Round_fLO(pInfo->AS_Data.f_if1_Request + f_in, MT2063_Round_fLO(state->AS_Data.f_if1_Request + f_in,
pInfo->AS_Data.f_LO1_Step, state->AS_Data.f_LO1_Step,
pInfo->AS_Data.f_ref) - f_in; state->AS_Data.f_ref) - f_in;
/* /*
** Calculate frequency settings. f_IF1_FREQ + f_in is the ** Calculate frequency settings. f_IF1_FREQ + f_in is the
** desired LO1 frequency ** desired LO1 frequency
*/ */
MT2063_ResetExclZones(&pInfo->AS_Data); MT2063_ResetExclZones(&state->AS_Data);
f_IF1 = MT2063_ChooseFirstIF(&pInfo->AS_Data); f_IF1 = MT2063_ChooseFirstIF(&state->AS_Data);
pInfo->AS_Data.f_LO1 = state->AS_Data.f_LO1 =
MT2063_Round_fLO(f_IF1 + f_in, pInfo->AS_Data.f_LO1_Step, MT2063_Round_fLO(f_IF1 + f_in, state->AS_Data.f_LO1_Step,
pInfo->AS_Data.f_ref); state->AS_Data.f_ref);
pInfo->AS_Data.f_LO2 = state->AS_Data.f_LO2 =
MT2063_Round_fLO(pInfo->AS_Data.f_LO1 - pInfo->AS_Data.f_out - f_in, MT2063_Round_fLO(state->AS_Data.f_LO1 - state->AS_Data.f_out - f_in,
pInfo->AS_Data.f_LO2_Step, pInfo->AS_Data.f_ref); state->AS_Data.f_LO2_Step, state->AS_Data.f_ref);
/* /*
** Check for any LO spurs in the output bandwidth and adjust ** Check for any LO spurs in the output bandwidth and adjust
** the LO settings to avoid them if needed ** the LO settings to avoid them if needed
*/ */
status |= MT2063_AvoidSpurs(pInfo, &pInfo->AS_Data); status |= MT2063_AvoidSpurs(state, &state->AS_Data);
/* /*
** MT_AvoidSpurs spurs may have changed the LO1 & LO2 values. ** MT_AvoidSpurs spurs may have changed the LO1 & LO2 values.
** Recalculate the LO frequencies and the values to be placed ** Recalculate the LO frequencies and the values to be placed
** in the tuning registers. ** in the tuning registers.
*/ */
pInfo->AS_Data.f_LO1 = state->AS_Data.f_LO1 =
MT2063_CalcLO1Mult(&LO1, &Num1, pInfo->AS_Data.f_LO1, MT2063_CalcLO1Mult(&LO1, &Num1, state->AS_Data.f_LO1,
pInfo->AS_Data.f_LO1_Step, pInfo->AS_Data.f_ref); state->AS_Data.f_LO1_Step, state->AS_Data.f_ref);
pInfo->AS_Data.f_LO2 = state->AS_Data.f_LO2 =
MT2063_Round_fLO(pInfo->AS_Data.f_LO1 - pInfo->AS_Data.f_out - f_in, MT2063_Round_fLO(state->AS_Data.f_LO1 - state->AS_Data.f_out - f_in,
pInfo->AS_Data.f_LO2_Step, pInfo->AS_Data.f_ref); state->AS_Data.f_LO2_Step, state->AS_Data.f_ref);
pInfo->AS_Data.f_LO2 = state->AS_Data.f_LO2 =
MT2063_CalcLO2Mult(&LO2, &Num2, pInfo->AS_Data.f_LO2, MT2063_CalcLO2Mult(&LO2, &Num2, state->AS_Data.f_LO2,
pInfo->AS_Data.f_LO2_Step, pInfo->AS_Data.f_ref); state->AS_Data.f_LO2_Step, state->AS_Data.f_ref);
/* /*
** Check the upconverter and downconverter frequency ranges ** Check the upconverter and downconverter frequency ranges
*/ */
if ((pInfo->AS_Data.f_LO1 < MT2063_MIN_UPC_FREQ) if ((state->AS_Data.f_LO1 < MT2063_MIN_UPC_FREQ)
|| (pInfo->AS_Data.f_LO1 > MT2063_MAX_UPC_FREQ)) || (state->AS_Data.f_LO1 > MT2063_MAX_UPC_FREQ))
status |= MT2063_UPC_RANGE; status |= MT2063_UPC_RANGE;
if ((pInfo->AS_Data.f_LO2 < MT2063_MIN_DNC_FREQ) if ((state->AS_Data.f_LO2 < MT2063_MIN_DNC_FREQ)
|| (pInfo->AS_Data.f_LO2 > MT2063_MAX_DNC_FREQ)) || (state->AS_Data.f_LO2 > MT2063_MAX_DNC_FREQ))
status |= MT2063_DNC_RANGE; status |= MT2063_DNC_RANGE;
/* LO2 Lock bit was in a different place for B0 version */ /* LO2 Lock bit was in a different place for B0 version */
if (pInfo->tuner_id == MT2063_B0) if (state->tuner_id == MT2063_B0)
LO2LK = 0x40; LO2LK = 0x40;
/* /*
** If we have the same LO frequencies and we're already locked, ** If we have the same LO frequencies and we're already locked,
** then skip re-programming the LO registers. ** then skip re-programming the LO registers.
*/ */
if ((ofLO1 != pInfo->AS_Data.f_LO1) if ((ofLO1 != state->AS_Data.f_LO1)
|| (ofLO2 != pInfo->AS_Data.f_LO2) || (ofLO2 != state->AS_Data.f_LO2)
|| ((pInfo->reg[MT2063_REG_LO_STATUS] & (LO1LK | LO2LK)) != || ((state->reg[MT2063_REG_LO_STATUS] & (LO1LK | LO2LK)) !=
(LO1LK | LO2LK))) { (LO1LK | LO2LK))) {
/* /*
** Calculate the FIFFOF register value ** Calculate the FIFFOF register value
...@@ -4155,8 +4155,8 @@ static u32 MT2063_Tune(struct mt2063_state *pInfo, u32 f_in) ...@@ -4155,8 +4155,8 @@ static u32 MT2063_Tune(struct mt2063_state *pInfo, u32 f_in)
** f_ref/64 ** f_ref/64
*/ */
fiffof = fiffof =
(pInfo->AS_Data.f_LO1 - (state->AS_Data.f_LO1 -
f_in) / (pInfo->AS_Data.f_ref / 64) - 8 * (u32) fiffc - f_in) / (state->AS_Data.f_ref / 64) - 8 * (u32) fiffc -
4992; 4992;
if (fiffof > 0xFF) if (fiffof > 0xFF)
fiffof = 0xFF; fiffof = 0xFF;
...@@ -4166,32 +4166,32 @@ static u32 MT2063_Tune(struct mt2063_state *pInfo, u32 f_in) ...@@ -4166,32 +4166,32 @@ static u32 MT2063_Tune(struct mt2063_state *pInfo, u32 f_in)
** register fields. ** register fields.
*/ */
if (status >= 0) { if (status >= 0) {
pInfo->reg[MT2063_REG_LO1CQ_1] = (u8) (LO1 & 0xFF); /* DIV1q */ state->reg[MT2063_REG_LO1CQ_1] = (u8) (LO1 & 0xFF); /* DIV1q */
pInfo->reg[MT2063_REG_LO1CQ_2] = (u8) (Num1 & 0x3F); /* NUM1q */ state->reg[MT2063_REG_LO1CQ_2] = (u8) (Num1 & 0x3F); /* NUM1q */
pInfo->reg[MT2063_REG_LO2CQ_1] = (u8) (((LO2 & 0x7F) << 1) /* DIV2q */ state->reg[MT2063_REG_LO2CQ_1] = (u8) (((LO2 & 0x7F) << 1) /* DIV2q */
|(Num2 >> 12)); /* NUM2q (hi) */ |(Num2 >> 12)); /* NUM2q (hi) */
pInfo->reg[MT2063_REG_LO2CQ_2] = (u8) ((Num2 & 0x0FF0) >> 4); /* NUM2q (mid) */ state->reg[MT2063_REG_LO2CQ_2] = (u8) ((Num2 & 0x0FF0) >> 4); /* NUM2q (mid) */
pInfo->reg[MT2063_REG_LO2CQ_3] = (u8) (0xE0 | (Num2 & 0x000F)); /* NUM2q (lo) */ state->reg[MT2063_REG_LO2CQ_3] = (u8) (0xE0 | (Num2 & 0x000F)); /* NUM2q (lo) */
/* /*
** Now write out the computed register values ** Now write out the computed register values
** IMPORTANT: There is a required order for writing ** IMPORTANT: There is a required order for writing
** (0x05 must follow all the others). ** (0x05 must follow all the others).
*/ */
status |= MT2063_WriteSub(pInfo, MT2063_REG_LO1CQ_1, &pInfo->reg[MT2063_REG_LO1CQ_1], 5); /* 0x01 - 0x05 */ status |= MT2063_WriteSub(state, MT2063_REG_LO1CQ_1, &state->reg[MT2063_REG_LO1CQ_1], 5); /* 0x01 - 0x05 */
if (pInfo->tuner_id == MT2063_B0) { if (state->tuner_id == MT2063_B0) {
/* Re-write the one-shot bits to trigger the tune operation */ /* Re-write the one-shot bits to trigger the tune operation */
status |= MT2063_WriteSub(pInfo, MT2063_REG_LO2CQ_3, &pInfo->reg[MT2063_REG_LO2CQ_3], 1); /* 0x05 */ status |= MT2063_WriteSub(state, MT2063_REG_LO2CQ_3, &state->reg[MT2063_REG_LO2CQ_3], 1); /* 0x05 */
} }
/* Write out the FIFF offset only if it's changing */ /* Write out the FIFF offset only if it's changing */
if (pInfo->reg[MT2063_REG_FIFF_OFFSET] != if (state->reg[MT2063_REG_FIFF_OFFSET] !=
(u8) fiffof) { (u8) fiffof) {
pInfo->reg[MT2063_REG_FIFF_OFFSET] = state->reg[MT2063_REG_FIFF_OFFSET] =
(u8) fiffof; (u8) fiffof;
status |= status |=
MT2063_WriteSub(pInfo, MT2063_WriteSub(state,
MT2063_REG_FIFF_OFFSET, MT2063_REG_FIFF_OFFSET,
&pInfo-> &state->
reg[MT2063_REG_FIFF_OFFSET], reg[MT2063_REG_FIFF_OFFSET],
1); 1);
} }
...@@ -4202,13 +4202,13 @@ static u32 MT2063_Tune(struct mt2063_state *pInfo, u32 f_in) ...@@ -4202,13 +4202,13 @@ static u32 MT2063_Tune(struct mt2063_state *pInfo, u32 f_in)
*/ */
if (status >= 0) { if (status >= 0) {
status |= MT2063_GetLocked(pInfo); status |= MT2063_GetLocked(state);
} }
/* /*
** If we locked OK, assign calculated data to mt2063_state structure ** If we locked OK, assign calculated data to mt2063_state structure
*/ */
if (status >= 0) { if (status >= 0) {
pInfo->f_IF1_actual = pInfo->AS_Data.f_LO1 - f_in; state->f_IF1_actual = state->AS_Data.f_LO1 - f_in;
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册