diff options
author | Oliver Endriss <o.endriss@gmx.de> | 2011-07-03 20:37:31 +0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2011-07-28 00:55:40 +0400 |
commit | 0fe4462930bfe09574494cae04fb029c504f3541 (patch) | |
tree | 3979efbd9bcf72d8319efb12c50caf80bdbef3e5 /drivers/media/dvb/frontends/tda18271c2dd.c | |
parent | e8783950f8a3a240c81c0d8d3becbda4b56c1794 (diff) | |
download | linux-0fe4462930bfe09574494cae04fb029c504f3541.tar.xz |
[media] tda18271c2dd: Lots of coding-style fixes
Signed-off-by: Oliver Endriss <o.endriss@gmx.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/dvb/frontends/tda18271c2dd.c')
-rw-r--r-- | drivers/media/dvb/frontends/tda18271c2dd.c | 727 |
1 files changed, 349 insertions, 378 deletions
diff --git a/drivers/media/dvb/frontends/tda18271c2dd.c b/drivers/media/dvb/frontends/tda18271c2dd.c index b4a23bf00104..a8afc2212728 100644 --- a/drivers/media/dvb/frontends/tda18271c2dd.c +++ b/drivers/media/dvb/frontends/tda18271c2dd.c @@ -64,8 +64,7 @@ struct SRFBandMap { u32 m_RF3_Default; }; -enum ERegister -{ +enum ERegister { ID = 0, TM, PL, @@ -115,13 +114,13 @@ struct tda_state { }; static int PowerScan(struct tda_state *state, - u8 RFBand,u32 RF_in, - u32 * pRF_Out, bool *pbcal); + u8 RFBand, u32 RF_in, + u32 *pRF_Out, bool *pbcal); static int i2c_readn(struct i2c_adapter *adapter, u8 adr, u8 *data, int len) { struct i2c_msg msgs[1] = {{.addr = adr, .flags = I2C_M_RD, - .buf = data, .len = len}}; + .buf = data, .len = len} }; return (i2c_transfer(adapter, msgs, 1) == 1) ? 0 : -1; } @@ -131,7 +130,7 @@ static int i2c_write(struct i2c_adapter *adap, u8 adr, u8 *data, int len) .buf = data, .len = len}; if (i2c_transfer(adap, &msg, 1) != 1) { - printk("i2c_write error\n"); + printk(KERN_ERR "i2c_write error\n"); return -1; } return 0; @@ -147,7 +146,7 @@ static int WriteRegs(struct tda_state *state, return i2c_write(state->i2c, state->adr, data, nRegs+1); } -static int WriteReg(struct tda_state *state, u8 SubAddr,u8 Reg) +static int WriteReg(struct tda_state *state, u8 SubAddr, u8 Reg) { u8 msg[2] = {SubAddr, Reg}; @@ -164,14 +163,14 @@ static int ReadExtented(struct tda_state *state, u8 * Regs) return i2c_readn(state->i2c, state->adr, Regs, NUM_REGS); } -static int UpdateRegs(struct tda_state *state, u8 RegFrom,u8 RegTo) +static int UpdateRegs(struct tda_state *state, u8 RegFrom, u8 RegTo) { return WriteRegs(state, RegFrom, &state->m_Regs[RegFrom], RegTo-RegFrom+1); } static int UpdateReg(struct tda_state *state, u8 Reg) { - return WriteReg(state, Reg,state->m_Regs[Reg]); + return WriteReg(state, Reg, state->m_Regs[Reg]); } #include "tda18271c2dd_maps.h" @@ -186,7 +185,7 @@ static void reset(struct tda_state *state) u32 ulIFLevelDVBC = 7; u32 ulIFLevelDVBT = 6; u32 ulXTOut = 0; - u32 ulStandbyMode = 0x06; // Send in stdb, but leave osc on + u32 ulStandbyMode = 0x06; /* Send in stdb, but leave osc on */ u32 ulSlave = 0; u32 ulFMInput = 0; u32 ulSettlingTime = 100; @@ -199,7 +198,8 @@ static void reset(struct tda_state *state) state->m_IFLevelDVBT = (ulIFLevelDVBT & 0x07) << 2; state->m_EP4 = 0x20; - if( ulXTOut != 0 ) state->m_EP4 |= 0x40; + if (ulXTOut != 0) + state->m_EP4 |= 0x40; state->m_EP3_Standby = ((ulStandbyMode & 0x07) << 5) | 0x0F; state->m_bMaster = (ulSlave == 0); @@ -214,7 +214,7 @@ static bool SearchMap1(struct SMap Map[], { int i = 0; - while ((Map[i].m_Frequency != 0) && (Frequency > Map[i].m_Frequency) ) + while ((Map[i].m_Frequency != 0) && (Frequency > Map[i].m_Frequency)) i += 1; if (Map[i].m_Frequency == 0) return false; @@ -228,7 +228,7 @@ static bool SearchMap2(struct SMapI Map[], int i = 0; while ((Map[i].m_Frequency != 0) && - (Frequency > Map[i].m_Frequency) ) + (Frequency > Map[i].m_Frequency)) i += 1; if (Map[i].m_Frequency == 0) return false; @@ -236,13 +236,13 @@ static bool SearchMap2(struct SMapI Map[], return true; } -static bool SearchMap3(struct SMap2 Map[],u32 Frequency, +static bool SearchMap3(struct SMap2 Map[], u32 Frequency, u8 *pParam1, u8 *pParam2) { int i = 0; while ((Map[i].m_Frequency != 0) && - (Frequency > Map[i].m_Frequency) ) + (Frequency > Map[i].m_Frequency)) i += 1; if (Map[i].m_Frequency == 0) return false; @@ -271,22 +271,23 @@ static int ThermometerRead(struct tda_state *state, u8 *pTM_Value) do { u8 Regs[16]; state->m_Regs[TM] |= 0x10; - CHK_ERROR(UpdateReg(state,TM)); - CHK_ERROR(Read(state,Regs)); - if( ( (Regs[TM] & 0x0F) == 0 && (Regs[TM] & 0x20) == 0x20 ) || - ( (Regs[TM] & 0x0F) == 8 && (Regs[TM] & 0x20) == 0x00 ) ) { + CHK_ERROR(UpdateReg(state, TM)); + CHK_ERROR(Read(state, Regs)); + if (((Regs[TM] & 0x0F) == 0 && (Regs[TM] & 0x20) == 0x20) || + ((Regs[TM] & 0x0F) == 8 && (Regs[TM] & 0x20) == 0x00)) { state->m_Regs[TM] ^= 0x20; - CHK_ERROR(UpdateReg(state,TM)); + CHK_ERROR(UpdateReg(state, TM)); msleep(10); - CHK_ERROR(Read(state,Regs)); + CHK_ERROR(Read(state, Regs)); } - *pTM_Value = (Regs[TM] & 0x20 ) ? m_Thermometer_Map_2[Regs[TM] & 0x0F] : - m_Thermometer_Map_1[Regs[TM] & 0x0F] ; - state->m_Regs[TM] &= ~0x10; // Thermometer off - CHK_ERROR(UpdateReg(state,TM)); - state->m_Regs[EP4] &= ~0x03; // CAL_mode = 0 ????????? - CHK_ERROR(UpdateReg(state,EP4)); - } while(0); + *pTM_Value = (Regs[TM] & 0x20) + ? m_Thermometer_Map_2[Regs[TM] & 0x0F] + : m_Thermometer_Map_1[Regs[TM] & 0x0F] ; + state->m_Regs[TM] &= ~0x10; /* Thermometer off */ + CHK_ERROR(UpdateReg(state, TM)); + state->m_Regs[EP4] &= ~0x03; /* CAL_mode = 0 ????????? */ + CHK_ERROR(UpdateReg(state, EP4)); + } while (0); return status; } @@ -295,16 +296,16 @@ static int StandBy(struct tda_state *state) { int status = 0; do { - state->m_Regs[EB12] &= ~0x20; // PD_AGC1_Det = 0 - CHK_ERROR(UpdateReg(state,EB12)); - state->m_Regs[EB18] &= ~0x83; // AGC1_loop_off = 0, AGC1_Gain = 6 dB - CHK_ERROR(UpdateReg(state,EB18)); - state->m_Regs[EB21] |= 0x03; // AGC2_Gain = -6 dB + state->m_Regs[EB12] &= ~0x20; /* PD_AGC1_Det = 0 */ + CHK_ERROR(UpdateReg(state, EB12)); + state->m_Regs[EB18] &= ~0x83; /* AGC1_loop_off = 0, AGC1_Gain = 6 dB */ + CHK_ERROR(UpdateReg(state, EB18)); + state->m_Regs[EB21] |= 0x03; /* AGC2_Gain = -6 dB */ state->m_Regs[EP3] = state->m_EP3_Standby; - CHK_ERROR(UpdateReg(state,EP3)); - state->m_Regs[EB23] &= ~0x06; // ForceLP_Fc2_En = 0, LP_Fc[2] = 0 - CHK_ERROR(UpdateRegs(state,EB21,EB23)); - } while(0); + CHK_ERROR(UpdateReg(state, EP3)); + state->m_Regs[EB23] &= ~0x06; /* ForceLP_Fc2_En = 0, LP_Fc[2] = 0 */ + CHK_ERROR(UpdateRegs(state, EB21, EB23)); + } while (0); return status; } @@ -316,9 +317,8 @@ static int CalcMainPLL(struct tda_state *state, u32 freq) u64 OscFreq; u32 MainDiv; - if (!SearchMap3(m_Main_PLL_Map, freq, &PostDiv, &Div)) { + if (!SearchMap3(m_Main_PLL_Map, freq, &PostDiv, &Div)) return -EINVAL; - } OscFreq = (u64) freq * (u64) Div; OscFreq *= (u64) 16384; @@ -328,133 +328,122 @@ static int CalcMainPLL(struct tda_state *state, u32 freq) state->m_Regs[MPD] = PostDiv & 0x77; state->m_Regs[MD1] = ((MainDiv >> 16) & 0x7F); state->m_Regs[MD2] = ((MainDiv >> 8) & 0xFF); - state->m_Regs[MD3] = ((MainDiv ) & 0xFF); + state->m_Regs[MD3] = (MainDiv & 0xFF); return UpdateRegs(state, MPD, MD3); } static int CalcCalPLL(struct tda_state *state, u32 freq) { - //KdPrintEx((MSG_TRACE " - " __FUNCTION__ "(%d)\n",freq)); - u8 PostDiv; u8 Div; u64 OscFreq; u32 CalDiv; - if( !SearchMap3(m_Cal_PLL_Map,freq,&PostDiv,&Div) ) - { + if (!SearchMap3(m_Cal_PLL_Map, freq, &PostDiv, &Div)) return -EINVAL; - } OscFreq = (u64)freq * (u64)Div; - //CalDiv = u32( OscFreq * 16384 / 16000000 ); - OscFreq*=(u64)16384; + /* CalDiv = u32( OscFreq * 16384 / 16000000 ); */ + OscFreq *= (u64)16384; do_div(OscFreq, (u64)16000000); - CalDiv=OscFreq; + CalDiv = OscFreq; state->m_Regs[CPD] = PostDiv; state->m_Regs[CD1] = ((CalDiv >> 16) & 0xFF); state->m_Regs[CD2] = ((CalDiv >> 8) & 0xFF); - state->m_Regs[CD3] = ((CalDiv ) & 0xFF); + state->m_Regs[CD3] = (CalDiv & 0xFF); - return UpdateRegs(state,CPD,CD3); + return UpdateRegs(state, CPD, CD3); } static int CalibrateRF(struct tda_state *state, - u8 RFBand,u32 freq, s32 * pCprog) + u8 RFBand, u32 freq, s32 *pCprog) { - //KdPrintEx((MSG_TRACE " - " __FUNCTION__ " ID = %02x\n",state->m_Regs[ID])); int status = 0; u8 Regs[NUM_REGS]; do { - u8 BP_Filter=0; - u8 GainTaper=0; - u8 RFC_K=0; - u8 RFC_M=0; - - state->m_Regs[EP4] &= ~0x03; // CAL_mode = 0 - CHK_ERROR(UpdateReg(state,EP4)); - state->m_Regs[EB18] |= 0x03; // AGC1_Gain = 3 - CHK_ERROR(UpdateReg(state,EB18)); - - // Switching off LT (as datasheet says) causes calibration on C1 to fail - // (Readout of Cprog is allways 255) - if( state->m_Regs[ID] != 0x83 ) // C1: ID == 83, C2: ID == 84 - { - state->m_Regs[EP3] |= 0x40; // SM_LT = 1 - } - - if( ! ( SearchMap1(m_BP_Filter_Map,freq,&BP_Filter) && - SearchMap1(m_GainTaper_Map,freq,&GainTaper) && - SearchMap3(m_KM_Map,freq,&RFC_K,&RFC_M)) ) - { + u8 BP_Filter = 0; + u8 GainTaper = 0; + u8 RFC_K = 0; + u8 RFC_M = 0; + + state->m_Regs[EP4] &= ~0x03; /* CAL_mode = 0 */ + CHK_ERROR(UpdateReg(state, EP4)); + state->m_Regs[EB18] |= 0x03; /* AGC1_Gain = 3 */ + CHK_ERROR(UpdateReg(state, EB18)); + + /* Switching off LT (as datasheet says) causes calibration on C1 to fail */ + /* (Readout of Cprog is allways 255) */ + if (state->m_Regs[ID] != 0x83) /* C1: ID == 83, C2: ID == 84 */ + state->m_Regs[EP3] |= 0x40; /* SM_LT = 1 */ + + if (!(SearchMap1(m_BP_Filter_Map, freq, &BP_Filter) && + SearchMap1(m_GainTaper_Map, freq, &GainTaper) && + SearchMap3(m_KM_Map, freq, &RFC_K, &RFC_M))) return -EINVAL; - } state->m_Regs[EP1] = (state->m_Regs[EP1] & ~0x07) | BP_Filter; state->m_Regs[EP2] = (RFBand << 5) | GainTaper; state->m_Regs[EB13] = (state->m_Regs[EB13] & ~0x7C) | (RFC_K << 4) | (RFC_M << 2); - CHK_ERROR(UpdateRegs(state,EP1,EP3)); - CHK_ERROR(UpdateReg(state,EB13)); + CHK_ERROR(UpdateRegs(state, EP1, EP3)); + CHK_ERROR(UpdateReg(state, EB13)); - state->m_Regs[EB4] |= 0x20; // LO_ForceSrce = 1 - CHK_ERROR(UpdateReg(state,EB4)); + state->m_Regs[EB4] |= 0x20; /* LO_ForceSrce = 1 */ + CHK_ERROR(UpdateReg(state, EB4)); - state->m_Regs[EB7] |= 0x20; // CAL_ForceSrce = 1 - CHK_ERROR(UpdateReg(state,EB7)); + state->m_Regs[EB7] |= 0x20; /* CAL_ForceSrce = 1 */ + CHK_ERROR(UpdateReg(state, EB7)); - state->m_Regs[EB14] = 0; // RFC_Cprog = 0 - CHK_ERROR(UpdateReg(state,EB14)); + state->m_Regs[EB14] = 0; /* RFC_Cprog = 0 */ + CHK_ERROR(UpdateReg(state, EB14)); - state->m_Regs[EB20] &= ~0x20; // ForceLock = 0; - CHK_ERROR(UpdateReg(state,EB20)); + state->m_Regs[EB20] &= ~0x20; /* ForceLock = 0; */ + CHK_ERROR(UpdateReg(state, EB20)); - state->m_Regs[EP4] |= 0x03; // CAL_Mode = 3 - CHK_ERROR(UpdateRegs(state,EP4,EP5)); + state->m_Regs[EP4] |= 0x03; /* CAL_Mode = 3 */ + CHK_ERROR(UpdateRegs(state, EP4, EP5)); - CHK_ERROR(CalcCalPLL(state,freq)); - CHK_ERROR(CalcMainPLL(state,freq + 1000000)); + CHK_ERROR(CalcCalPLL(state, freq)); + CHK_ERROR(CalcMainPLL(state, freq + 1000000)); msleep(5); - CHK_ERROR(UpdateReg(state,EP2)); - CHK_ERROR(UpdateReg(state,EP1)); - CHK_ERROR(UpdateReg(state,EP2)); - CHK_ERROR(UpdateReg(state,EP1)); + CHK_ERROR(UpdateReg(state, EP2)); + CHK_ERROR(UpdateReg(state, EP1)); + CHK_ERROR(UpdateReg(state, EP2)); + CHK_ERROR(UpdateReg(state, EP1)); - state->m_Regs[EB4] &= ~0x20; // LO_ForceSrce = 0 - CHK_ERROR(UpdateReg(state,EB4)); + state->m_Regs[EB4] &= ~0x20; /* LO_ForceSrce = 0 */ + CHK_ERROR(UpdateReg(state, EB4)); - state->m_Regs[EB7] &= ~0x20; // CAL_ForceSrce = 0 - CHK_ERROR(UpdateReg(state,EB7)); + state->m_Regs[EB7] &= ~0x20; /* CAL_ForceSrce = 0 */ + CHK_ERROR(UpdateReg(state, EB7)); msleep(10); - state->m_Regs[EB20] |= 0x20; // ForceLock = 1; - CHK_ERROR(UpdateReg(state,EB20)); + state->m_Regs[EB20] |= 0x20; /* ForceLock = 1; */ + CHK_ERROR(UpdateReg(state, EB20)); msleep(60); - state->m_Regs[EP4] &= ~0x03; // CAL_Mode = 0 - state->m_Regs[EP3] &= ~0x40; // SM_LT = 0 - state->m_Regs[EB18] &= ~0x03; // AGC1_Gain = 0 - CHK_ERROR(UpdateReg(state,EB18)); - CHK_ERROR(UpdateRegs(state,EP3,EP4)); - CHK_ERROR(UpdateReg(state,EP1)); + state->m_Regs[EP4] &= ~0x03; /* CAL_Mode = 0 */ + state->m_Regs[EP3] &= ~0x40; /* SM_LT = 0 */ + state->m_Regs[EB18] &= ~0x03; /* AGC1_Gain = 0 */ + CHK_ERROR(UpdateReg(state, EB18)); + CHK_ERROR(UpdateRegs(state, EP3, EP4)); + CHK_ERROR(UpdateReg(state, EP1)); - CHK_ERROR(ReadExtented(state,Regs)); + CHK_ERROR(ReadExtented(state, Regs)); *pCprog = Regs[EB14]; - //KdPrintEx((MSG_TRACE " - " __FUNCTION__ " Cprog = %d\n",Regs[EB14])); - } while(0); + } while (0); return status; } static int RFTrackingFiltersInit(struct tda_state *state, u8 RFBand) { - //KdPrintEx((MSG_TRACE " - " __FUNCTION__ "\n")); int status = 0; u32 RF1 = m_RF_Band_Map[RFBand].m_RF1_Default; @@ -475,171 +464,161 @@ static int RFTrackingFiltersInit(struct tda_state *state, state->m_RF_B2[RFBand] = 0; do { - CHK_ERROR(PowerScan(state,RFBand,RF1,&RF1,&bcal)); - if( bcal ) { - CHK_ERROR(CalibrateRF(state,RFBand,RF1,&Cprog_cal1)); + CHK_ERROR(PowerScan(state, RFBand, RF1, &RF1, &bcal)); + if (bcal) { + CHK_ERROR(CalibrateRF(state, RFBand, RF1, &Cprog_cal1)); } - SearchMap2(m_RF_Cal_Map,RF1,&Cprog_table1); - if( !bcal ) { + SearchMap2(m_RF_Cal_Map, RF1, &Cprog_table1); + if (!bcal) Cprog_cal1 = Cprog_table1; - } state->m_RF_B1[RFBand] = Cprog_cal1 - Cprog_table1; - //state->m_RF_A1[RF_Band] = ???? + /* state->m_RF_A1[RF_Band] = ???? */ - if( RF2 == 0 ) break; + if (RF2 == 0) + break; - CHK_ERROR(PowerScan(state,RFBand,RF2,&RF2,&bcal)); - if( bcal ) { - CHK_ERROR(CalibrateRF(state,RFBand,RF2,&Cprog_cal2)); + CHK_ERROR(PowerScan(state, RFBand, RF2, &RF2, &bcal)); + if (bcal) { + CHK_ERROR(CalibrateRF(state, RFBand, RF2, &Cprog_cal2)); } - SearchMap2(m_RF_Cal_Map,RF2,&Cprog_table2); - if( !bcal ) - { + SearchMap2(m_RF_Cal_Map, RF2, &Cprog_table2); + if (!bcal) Cprog_cal2 = Cprog_table2; - } state->m_RF_A1[RFBand] = (Cprog_cal2 - Cprog_table2 - Cprog_cal1 + Cprog_table1) / - ((s32)(RF2)-(s32)(RF1)); + ((s32)(RF2) - (s32)(RF1)); - if( RF3 == 0 ) break; + if (RF3 == 0) + break; - CHK_ERROR(PowerScan(state,RFBand,RF3,&RF3,&bcal)); - if( bcal ) - { - CHK_ERROR(CalibrateRF(state,RFBand,RF3,&Cprog_cal3)); + CHK_ERROR(PowerScan(state, RFBand, RF3, &RF3, &bcal)); + if (bcal) { + CHK_ERROR(CalibrateRF(state, RFBand, RF3, &Cprog_cal3)); } - SearchMap2(m_RF_Cal_Map,RF3,&Cprog_table3); - if( !bcal ) - { + SearchMap2(m_RF_Cal_Map, RF3, &Cprog_table3); + if (!bcal) Cprog_cal3 = Cprog_table3; - } - state->m_RF_A2[RFBand] = (Cprog_cal3 - Cprog_table3 - Cprog_cal2 + Cprog_table2) / ((s32)(RF3)-(s32)(RF2)); + state->m_RF_A2[RFBand] = (Cprog_cal3 - Cprog_table3 - Cprog_cal2 + Cprog_table2) / ((s32)(RF3) - (s32)(RF2)); state->m_RF_B2[RFBand] = Cprog_cal2 - Cprog_table2; - } while(0); + } while (0); state->m_RF1[RFBand] = RF1; state->m_RF2[RFBand] = RF2; state->m_RF3[RFBand] = RF3; #if 0 - printk("%s %d RF1 = %d A1 = %d B1 = %d RF2 = %d A2 = %d B2 = %d RF3 = %d\n", __FUNCTION__, - RFBand,RF1,state->m_RF_A1[RFBand],state->m_RF_B1[RFBand],RF2, - state->m_RF_A2[RFBand],state->m_RF_B2[RFBand],RF3); + printk(KERN_ERR "%s %d RF1 = %d A1 = %d B1 = %d RF2 = %d A2 = %d B2 = %d RF3 = %d\n", __func__, + RFBand, RF1, state->m_RF_A1[RFBand], state->m_RF_B1[RFBand], RF2, + state->m_RF_A2[RFBand], state->m_RF_B2[RFBand], RF3); #endif return status; } static int PowerScan(struct tda_state *state, - u8 RFBand,u32 RF_in, u32 * pRF_Out, bool *pbcal) + u8 RFBand, u32 RF_in, u32 *pRF_Out, bool *pbcal) { - //KdPrintEx((MSG_TRACE " - " __FUNCTION__ "(%d,%d)\n",RFBand,RF_in)); - int status = 0; - do { - u8 Gain_Taper=0; - s32 RFC_Cprog=0; - u8 CID_Target=0; - u8 CountLimit=0; - u32 freq_MainPLL; - u8 Regs[NUM_REGS]; - u8 CID_Gain; - s32 Count = 0; - int sign = 1; - bool wait = false; - - if( ! (SearchMap2(m_RF_Cal_Map,RF_in,&RFC_Cprog) && - SearchMap1(m_GainTaper_Map,RF_in,&Gain_Taper) && - SearchMap3(m_CID_Target_Map,RF_in,&CID_Target,&CountLimit) )) { - printk("%s Search map failed\n", __FUNCTION__); - return -EINVAL; - } - - state->m_Regs[EP2] = (RFBand << 5) | Gain_Taper; - state->m_Regs[EB14] = (RFC_Cprog); - CHK_ERROR(UpdateReg(state,EP2)); - CHK_ERROR(UpdateReg(state,EB14)); - - freq_MainPLL = RF_in + 1000000; - CHK_ERROR(CalcMainPLL(state,freq_MainPLL)); - msleep(5); - state->m_Regs[EP4] = (state->m_Regs[EP4] & ~0x03) | 1; // CAL_mode = 1 - CHK_ERROR(UpdateReg(state,EP4)); - CHK_ERROR(UpdateReg(state,EP2)); // Launch power measurement - CHK_ERROR(ReadExtented(state,Regs)); - CID_Gain = Regs[EB10] & 0x3F; - state->m_Regs[ID] = Regs[ID]; // Chip version, (needed for C1 workarround in CalibrateRF ) - - *pRF_Out = RF_in; - - while( CID_Gain < CID_Target ) { - freq_MainPLL = RF_in + sign * Count + 1000000; - CHK_ERROR(CalcMainPLL(state,freq_MainPLL)); - msleep( wait ? 5 : 1 ); - wait = false; - CHK_ERROR(UpdateReg(state,EP2)); // Launch power measurement - CHK_ERROR(ReadExtented(state,Regs)); - CID_Gain = Regs[EB10] & 0x3F; - Count += 200000; - - if( Count < CountLimit * 100000 ) continue; - if( sign < 0 ) break; - - sign = -sign; - Count = 200000; - wait = true; - } - CHK_ERROR(status); - if( CID_Gain >= CID_Target ) - { - *pbcal = true; - *pRF_Out = freq_MainPLL - 1000000; - } - else - { - *pbcal = false; - } - } while(0); - //KdPrintEx((MSG_TRACE " - " __FUNCTION__ " Found = %d RF = %d\n",*pbcal,*pRF_Out)); - return status; + int status = 0; + do { + u8 Gain_Taper = 0; + s32 RFC_Cprog = 0; + u8 CID_Target = 0; + u8 CountLimit = 0; + u32 freq_MainPLL; + u8 Regs[NUM_REGS]; + u8 CID_Gain; + s32 Count = 0; + int sign = 1; + bool wait = false; + + if (!(SearchMap2(m_RF_Cal_Map, RF_in, &RFC_Cprog) && + SearchMap1(m_GainTaper_Map, RF_in, &Gain_Taper) && + SearchMap3(m_CID_Target_Map, RF_in, &CID_Target, &CountLimit))) { + + printk(KERN_ERR "%s Search map failed\n", __func__); + return -EINVAL; + } + + state->m_Regs[EP2] = (RFBand << 5) | Gain_Taper; + state->m_Regs[EB14] = (RFC_Cprog); + CHK_ERROR(UpdateReg(state, EP2)); + CHK_ERROR(UpdateReg(state, EB14)); + + freq_MainPLL = RF_in + 1000000; + CHK_ERROR(CalcMainPLL(state, freq_MainPLL)); + msleep(5); + state->m_Regs[EP4] = (state->m_Regs[EP4] & ~0x03) | 1; /* CAL_mode = 1 */ + CHK_ERROR(UpdateReg(state, EP4)); + CHK_ERROR(UpdateReg(state, EP2)); /* Launch power measurement */ + CHK_ERROR(ReadExtented(state, Regs)); + CID_Gain = Regs[EB10] & 0x3F; + state->m_Regs[ID] = Regs[ID]; /* Chip version, (needed for C1 workarround in CalibrateRF) */ + + *pRF_Out = RF_in; + + while (CID_Gain < CID_Target) { + freq_MainPLL = RF_in + sign * Count + 1000000; + CHK_ERROR(CalcMainPLL(state, freq_MainPLL)); + msleep(wait ? 5 : 1); + wait = false; + CHK_ERROR(UpdateReg(state, EP2)); /* Launch power measurement */ + CHK_ERROR(ReadExtented(state, Regs)); + CID_Gain = Regs[EB10] & 0x3F; + Count += 200000; + + if (Count < CountLimit * 100000) + continue; + if (sign < 0) + break; + + sign = -sign; + Count = 200000; + wait = true; + } + CHK_ERROR(status); + if (CID_Gain >= CID_Target) { + *pbcal = true; + *pRF_Out = freq_MainPLL - 1000000; + } else + *pbcal = false; + } while (0); + + return status; } static int PowerScanInit(struct tda_state *state) { - //KdPrintEx((MSG_TRACE " - " __FUNCTION__ "\n")); int status = 0; - do - { + do { state->m_Regs[EP3] = (state->m_Regs[EP3] & ~0x1F) | 0x12; - state->m_Regs[EP4] = (state->m_Regs[EP4] & ~0x1F); // If level = 0, Cal mode = 0 - CHK_ERROR(UpdateRegs(state,EP3,EP4)); - state->m_Regs[EB18] = (state->m_Regs[EB18] & ~0x03 ); // AGC 1 Gain = 0 - CHK_ERROR(UpdateReg(state,EB18)); - state->m_Regs[EB21] = (state->m_Regs[EB21] & ~0x03 ); // AGC 2 Gain = 0 (Datasheet = 3) - state->m_Regs[EB23] = (state->m_Regs[EB23] | 0x06 ); // ForceLP_Fc2_En = 1, LPFc[2] = 1 - CHK_ERROR(UpdateRegs(state,EB21,EB23)); - } while(0); + state->m_Regs[EP4] = (state->m_Regs[EP4] & ~0x1F); /* If level = 0, Cal mode = 0 */ + CHK_ERROR(UpdateRegs(state, EP3, EP4)); + state->m_Regs[EB18] = (state->m_Regs[EB18] & ~0x03); /* AGC 1 Gain = 0 */ + CHK_ERROR(UpdateReg(state, EB18)); + state->m_Regs[EB21] = (state->m_Regs[EB21] & ~0x03); /* AGC 2 Gain = 0 (Datasheet = 3) */ + state->m_Regs[EB23] = (state->m_Regs[EB23] | 0x06); /* ForceLP_Fc2_En = 1, LPFc[2] = 1 */ + CHK_ERROR(UpdateRegs(state, EB21, EB23)); + } while (0); return status; } static int CalcRFFilterCurve(struct tda_state *state) { - //KdPrintEx((MSG_TRACE " - " __FUNCTION__ "\n")); int status = 0; - do - { - msleep(200); // Temperature stabilisation + do { + msleep(200); /* Temperature stabilisation */ CHK_ERROR(PowerScanInit(state)); - CHK_ERROR(RFTrackingFiltersInit(state,0)); - CHK_ERROR(RFTrackingFiltersInit(state,1)); - CHK_ERROR(RFTrackingFiltersInit(state,2)); - CHK_ERROR(RFTrackingFiltersInit(state,3)); - CHK_ERROR(RFTrackingFiltersInit(state,4)); - CHK_ERROR(RFTrackingFiltersInit(state,5)); - CHK_ERROR(RFTrackingFiltersInit(state,6)); - CHK_ERROR(ThermometerRead(state,&state->m_TMValue_RFCal)); // also switches off Cal mode !!! - } while(0); + CHK_ERROR(RFTrackingFiltersInit(state, 0)); + CHK_ERROR(RFTrackingFiltersInit(state, 1)); + CHK_ERROR(RFTrackingFiltersInit(state, 2)); + CHK_ERROR(RFTrackingFiltersInit(state, 3)); + CHK_ERROR(RFTrackingFiltersInit(state, 4)); + CHK_ERROR(RFTrackingFiltersInit(state, 5)); + CHK_ERROR(RFTrackingFiltersInit(state, 6)); + CHK_ERROR(ThermometerRead(state, &state->m_TMValue_RFCal)); /* also switches off Cal mode !!! */ + } while (0); return status; } @@ -647,33 +626,33 @@ static int CalcRFFilterCurve(struct tda_state *state) static int FixedContentsI2CUpdate(struct tda_state *state) { static u8 InitRegs[] = { - 0x08,0x80,0xC6, - 0xDF,0x16,0x60,0x80, - 0x80,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00, - 0xFC,0x01,0x84,0x41, - 0x01,0x84,0x40,0x07, - 0x00,0x00,0x96,0x3F, - 0xC1,0x00,0x8F,0x00, - 0x00,0x8C,0x00,0x20, - 0xB3,0x48,0xB0, + 0x08, 0x80, 0xC6, + 0xDF, 0x16, 0x60, 0x80, + 0x80, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0xFC, 0x01, 0x84, 0x41, + 0x01, 0x84, 0x40, 0x07, + 0x00, 0x00, 0x96, 0x3F, + 0xC1, 0x00, 0x8F, 0x00, + 0x00, 0x8C, 0x00, 0x20, + 0xB3, 0x48, 0xB0, }; int status = 0; - memcpy(&state->m_Regs[TM],InitRegs,EB23-TM+1); + memcpy(&state->m_Regs[TM], InitRegs, EB23 - TM + 1); do { - CHK_ERROR(UpdateRegs(state,TM,EB23)); + CHK_ERROR(UpdateRegs(state, TM, EB23)); - // AGC1 gain setup + /* AGC1 gain setup */ state->m_Regs[EB17] = 0x00; - CHK_ERROR(UpdateReg(state,EB17)); + CHK_ERROR(UpdateReg(state, EB17)); state->m_Regs[EB17] = 0x03; - CHK_ERROR(UpdateReg(state,EB17)); + CHK_ERROR(UpdateReg(state, EB17)); state->m_Regs[EB17] = 0x43; - CHK_ERROR(UpdateReg(state,EB17)); + CHK_ERROR(UpdateReg(state, EB17)); state->m_Regs[EB17] = 0x4C; - CHK_ERROR(UpdateReg(state,EB17)); + CHK_ERROR(UpdateReg(state, EB17)); - // IRC Cal Low band + /* IRC Cal Low band */ state->m_Regs[EP3] = 0x1F; state->m_Regs[EP4] = 0x66; state->m_Regs[EP5] = 0x81; @@ -685,75 +664,77 @@ static int FixedContentsI2CUpdate(struct tda_state *state) state->m_Regs[MD1] = 0x77; state->m_Regs[MD2] = 0x08; state->m_Regs[MD3] = 0x00; - CHK_ERROR(UpdateRegs(state,EP2,MD3)); // diff between sw and datasheet (ep3-md3) + CHK_ERROR(UpdateRegs(state, EP2, MD3)); /* diff between sw and datasheet (ep3-md3) */ - //state->m_Regs[EB4] = 0x61; // missing in sw - //CHK_ERROR(UpdateReg(state,EB4)); - //msleep(1); - //state->m_Regs[EB4] = 0x41; - //CHK_ERROR(UpdateReg(state,EB4)); +#if 0 + state->m_Regs[EB4] = 0x61; /* missing in sw */ + CHK_ERROR(UpdateReg(state, EB4)); + msleep(1); + state->m_Regs[EB4] = 0x41; + CHK_ERROR(UpdateReg(state, EB4)); +#endif msleep(5); - CHK_ERROR(UpdateReg(state,EP1)); + CHK_ERROR(UpdateReg(state, EP1)); msleep(5); state->m_Regs[EP5] = 0x85; state->m_Regs[CPD] = 0xCB; state->m_Regs[CD1] = 0x66; state->m_Regs[CD2] = 0x70; - CHK_ERROR(UpdateRegs(state,EP3,CD3)); + CHK_ERROR(UpdateRegs(state, EP3, CD3)); msleep(5); - CHK_ERROR(UpdateReg(state,EP2)); + CHK_ERROR(UpdateReg(state, EP2)); msleep(30); - // IRC Cal mid band + /* IRC Cal mid band */ state->m_Regs[EP5] = 0x82; state->m_Regs[CPD] = 0xA8; state->m_Regs[CD2] = 0x00; - state->m_Regs[MPD] = 0xA1; // Datasheet = 0xA9 + state->m_Regs[MPD] = 0xA1; /* Datasheet = 0xA9 */ state->m_Regs[MD1] = 0x73; state->m_Regs[MD2] = 0x1A; - CHK_ERROR(UpdateRegs(state,EP3,MD3)); + CHK_ERROR(UpdateRegs(state, EP3, MD3)); msleep(5); - CHK_ERROR(UpdateReg(state,EP1)); + CHK_ERROR(UpdateReg(state, EP1)); msleep(5); state->m_Regs[EP5] = 0x86; state->m_Regs[CPD] = 0xA8; state->m_Regs[CD1] = 0x66; state->m_Regs[CD2] = 0xA0; - CHK_ERROR(UpdateRegs(state,EP3,CD3)); + CHK_ERROR(UpdateRegs(state, EP3, CD3)); msleep(5); - CHK_ERROR(UpdateReg(state,EP2)); + CHK_ERROR(UpdateReg(state, EP2)); msleep(30); - // IRC Cal high band + /* IRC Cal high band */ state->m_Regs[EP5] = 0x83; state->m_Regs[CPD] = 0x98; state->m_Regs[CD1] = 0x65; state->m_Regs[CD2] = 0x00; - state->m_Regs[MPD] = 0x91; // Datasheet = 0x91 + state->m_Regs[MPD] = 0x91; /* Datasheet = 0x91 */ state->m_Regs[MD1] = 0x71; state->m_Regs[MD2] = 0xCD; - CHK_ERROR(UpdateRegs(state,EP3,MD3)); + CHK_ERROR(UpdateRegs(state, EP3, MD3)); msleep(5); - CHK_ERROR(UpdateReg(state,EP1)); + CHK_ERROR(UpdateReg(state, EP1)); msleep(5); state->m_Regs[EP5] = 0x87; state->m_Regs[CD1] = 0x65; state->m_Regs[CD2] = 0x50; - CHK_ERROR(UpdateRegs(state,EP3,CD3)); + CHK_ERROR(UpdateRegs(state, EP3, CD3)); msleep(5); - CHK_ERROR(UpdateReg(state,EP2)); + CHK_ERROR(UpdateReg(state, EP2)); msleep(30); - // Back to normal + /* Back to normal */ state->m_Regs[EP4] = 0x64; - CHK_ERROR(UpdateReg(state,EP4)); - CHK_ERROR(UpdateReg(state,EP1)); + CHK_ERROR(UpdateReg(state, EP4)); + CHK_ERROR(UpdateReg(state, EP1)); - } while(0); + } while (0); return status; } @@ -761,13 +742,12 @@ static int InitCal(struct tda_state *state) { int status = 0; - do - { + do { CHK_ERROR(FixedContentsI2CUpdate(state)); CHK_ERROR(CalcRFFilterCurve(state)); CHK_ERROR(StandBy(state)); - //m_bInitDone = true; - } while(0); + /* m_bInitDone = true; */ + } while (0); return status; }; @@ -779,15 +759,13 @@ static int RFTrackingFiltersCorrection(struct tda_state *state, u8 RFBand; u8 dCoverdT; - if( !SearchMap2(m_RF_Cal_Map,Frequency,&Cprog_table) || - !SearchMap4(m_RF_Band_Map,Frequency,&RFBand) || - !SearchMap1(m_RF_Cal_DC_Over_DT_Map,Frequency,&dCoverdT) ) - { + if (!SearchMap2(m_RF_Cal_Map, Frequency, &Cprog_table) || + !SearchMap4(m_RF_Band_Map, Frequency, &RFBand) || + !SearchMap1(m_RF_Cal_DC_Over_DT_Map, Frequency, &dCoverdT)) + return -EINVAL; - } - do - { + do { u8 TMValue_Current; u32 RF1 = state->m_RF1[RFBand]; u32 RF2 = state->m_RF1[RFBand]; @@ -799,35 +777,33 @@ static int RFTrackingFiltersCorrection(struct tda_state *state, s32 Capprox = 0; int TComp; - state->m_Regs[EP3] &= ~0xE0; // Power up - CHK_ERROR(UpdateReg(state,EP3)); + state->m_Regs[EP3] &= ~0xE0; /* Power up */ + CHK_ERROR(UpdateReg(state, EP3)); - CHK_ERROR(ThermometerRead(state,&TMValue_Current)); + CHK_ERROR(ThermometerRead(state, &TMValue_Current)); - if( RF3 == 0 || Frequency < RF2 ) - { + if (RF3 == 0 || Frequency < RF2) Capprox = RF_A1 * ((s32)(Frequency) - (s32)(RF1)) + RF_B1 + Cprog_table; - } else - { Capprox = RF_A2 * ((s32)(Frequency) - (s32)(RF2)) + RF_B2 + Cprog_table; - } TComp = (int)(dCoverdT) * ((int)(TMValue_Current) - (int)(state->m_TMValue_RFCal))/1000; Capprox += TComp; - if( Capprox < 0 ) Capprox = 0; - else if( Capprox > 255 ) Capprox = 255; + if (Capprox < 0) + Capprox = 0; + else if (Capprox > 255) + Capprox = 255; - // TODO Temperature compensation. There is defenitely a scale factor - // missing in the datasheet, so leave it out for now. - state->m_Regs[EB14] = (Capprox ); + /* TODO Temperature compensation. There is defenitely a scale factor */ + /* missing in the datasheet, so leave it out for now. */ + state->m_Regs[EB14] = Capprox; - CHK_ERROR(UpdateReg(state,EB14)); + CHK_ERROR(UpdateReg(state, EB14)); - } while(0); + } while (0); return status; } @@ -843,94 +819,96 @@ static int ChannelConfiguration(struct tda_state *state, u8 GainTaper = 0; u8 IR_Meas; - state->IF=IntermediateFrequency; - //printk("%s Freq = %d Standard = %d IF = %d\n",__FUNCTION__,Frequency,Standard,IntermediateFrequency); - // get values from tables + state->IF = IntermediateFrequency; + /* printk("%s Freq = %d Standard = %d IF = %d\n", __func__, Frequency, Standard, IntermediateFrequency); */ + /* get values from tables */ - if(! ( SearchMap1(m_BP_Filter_Map,Frequency,&BP_Filter) && - SearchMap1(m_GainTaper_Map,Frequency,&GainTaper) && - SearchMap1(m_IR_Meas_Map,Frequency,&IR_Meas) && - SearchMap4(m_RF_Band_Map,Frequency,&RF_Band) ) ) - { - printk("%s SearchMap failed\n", __FUNCTION__); + if (!(SearchMap1(m_BP_Filter_Map, Frequency, &BP_Filter) && + SearchMap1(m_GainTaper_Map, Frequency, &GainTaper) && + SearchMap1(m_IR_Meas_Map, Frequency, &IR_Meas) && + SearchMap4(m_RF_Band_Map, Frequency, &RF_Band))) { + + printk(KERN_ERR "%s SearchMap failed\n", __func__); return -EINVAL; } - do - { + do { state->m_Regs[EP3] = (state->m_Regs[EP3] & ~0x1F) | m_StandardTable[Standard].m_EP3_4_0; - state->m_Regs[EP3] &= ~0x04; // switch RFAGC to high speed mode - - // m_EP4 default for XToutOn, CAL_Mode (0) - state->m_Regs[EP4] = state->m_EP4 | ((Standard > HF_AnalogMax )? state->m_IFLevelDigital : state->m_IFLevelAnalog ); - //state->m_Regs[EP4] = state->m_EP4 | state->m_IFLevelDigital; - if( Standard <= HF_AnalogMax ) state->m_Regs[EP4] = state->m_EP4 | state->m_IFLevelAnalog; - else if( Standard <= HF_ATSC ) state->m_Regs[EP4] = state->m_EP4 | state->m_IFLevelDVBT; - else if( Standard <= HF_DVBC ) state->m_Regs[EP4] = state->m_EP4 | state->m_IFLevelDVBC; - else state->m_Regs[EP4] = state->m_EP4 | state->m_IFLevelDigital; + state->m_Regs[EP3] &= ~0x04; /* switch RFAGC to high speed mode */ + + /* m_EP4 default for XToutOn, CAL_Mode (0) */ + state->m_Regs[EP4] = state->m_EP4 | ((Standard > HF_AnalogMax) ? state->m_IFLevelDigital : state->m_IFLevelAnalog); + /* state->m_Regs[EP4] = state->m_EP4 | state->m_IFLevelDigital; */ + if (Standard <= HF_AnalogMax) + state->m_Regs[EP4] = state->m_EP4 | state->m_IFLevelAnalog; + else if (Standard <= HF_ATSC) + state->m_Regs[EP4] = state->m_EP4 | state->m_IFLevelDVBT; + else if (Standard <= HF_DVBC) + state->m_Regs[EP4] = state->m_EP4 | state->m_IFLevelDVBC; + else + state->m_Regs[EP4] = state->m_EP4 | state->m_IFLevelDigital; - if( (Standard == HF_FM_Radio) && state->m_bFMInput ) state->m_Regs[EP4] |= 80; + if ((Standard == HF_FM_Radio) && state->m_bFMInput) + state->m_Regs[EP4] |= 80; state->m_Regs[MPD] &= ~0x80; - if( Standard > HF_AnalogMax ) state->m_Regs[MPD] |= 0x80; // Add IF_notch for digital + if (Standard > HF_AnalogMax) + state->m_Regs[MPD] |= 0x80; /* Add IF_notch for digital */ state->m_Regs[EB22] = m_StandardTable[Standard].m_EB22; - // Note: This is missing from flowchart in TDA18271 specification ( 1.5 MHz cutoff for FM ) - if( Standard == HF_FM_Radio ) state->m_Regs[EB23] |= 0x06; // ForceLP_Fc2_En = 1, LPFc[2] = 1 - else state->m_Regs[EB23] &= ~0x06; // ForceLP_Fc2_En = 0, LPFc[2] = 0 + /* Note: This is missing from flowchart in TDA18271 specification ( 1.5 MHz cutoff for FM ) */ + if (Standard == HF_FM_Radio) + state->m_Regs[EB23] |= 0x06; /* ForceLP_Fc2_En = 1, LPFc[2] = 1 */ + else + state->m_Regs[EB23] &= ~0x06; /* ForceLP_Fc2_En = 0, LPFc[2] = 0 */ - CHK_ERROR(UpdateRegs(state,EB22,EB23)); + CHK_ERROR(UpdateRegs(state, EB22, EB23)); - state->m_Regs[EP1] = (state->m_Regs[EP1] & ~0x07) | 0x40 | BP_Filter; // Dis_Power_level = 1, Filter + state->m_Regs[EP1] = (state->m_Regs[EP1] & ~0x07) | 0x40 | BP_Filter; /* Dis_Power_level = 1, Filter */ state->m_Regs[EP5] = (state->m_Regs[EP5] & ~0x07) | IR_Meas; state->m_Regs[EP2] = (RF_Band << 5) | GainTaper; state->m_Regs[EB1] = (state->m_Regs[EB1] & ~0x07) | - (state->m_bMaster ? 0x04 : 0x00); // CALVCO_FortLOn = MS - // AGC1_always_master = 0 - // AGC_firstn = 0 - CHK_ERROR(UpdateReg(state,EB1)); - - if( state->m_bMaster ) - { - CHK_ERROR(CalcMainPLL(state,Frequency + IntermediateFrequency)); - CHK_ERROR(UpdateRegs(state,TM,EP5)); - state->m_Regs[EB4] |= 0x20; // LO_forceSrce = 1 - CHK_ERROR(UpdateReg(state,EB4)); + (state->m_bMaster ? 0x04 : 0x00); /* CALVCO_FortLOn = MS */ + /* AGC1_always_master = 0 */ + /* AGC_firstn = 0 */ + CHK_ERROR(UpdateReg(state, EB1)); + + if (state->m_bMaster) { + CHK_ERROR(CalcMainPLL(state, Frequency + IntermediateFrequency)); + CHK_ERROR(UpdateRegs(state, TM, EP5)); + state->m_Regs[EB4] |= 0x20; /* LO_forceSrce = 1 */ + CHK_ERROR(UpdateReg(state, EB4)); msleep(1); - state->m_Regs[EB4] &= ~0x20; // LO_forceSrce = 0 - CHK_ERROR(UpdateReg(state,EB4)); - } - else - { + state->m_Regs[EB4] &= ~0x20; /* LO_forceSrce = 0 */ + CHK_ERROR(UpdateReg(state, EB4)); + } else { u8 PostDiv; u8 Div; - CHK_ERROR(CalcCalPLL(state,Frequency + IntermediateFrequency)); + CHK_ERROR(CalcCalPLL(state, Frequency + IntermediateFrequency)); - SearchMap3(m_Cal_PLL_Map,Frequency + IntermediateFrequency,&PostDiv,&Div); + SearchMap3(m_Cal_PLL_Map, Frequency + IntermediateFrequency, &PostDiv, &Div); state->m_Regs[MPD] = (state->m_Regs[MPD] & ~0x7F) | (PostDiv & 0x77); - CHK_ERROR(UpdateReg(state,MPD)); - CHK_ERROR(UpdateRegs(state,TM,EP5)); + CHK_ERROR(UpdateReg(state, MPD)); + CHK_ERROR(UpdateRegs(state, TM, EP5)); - state->m_Regs[EB7] |= 0x20; // CAL_forceSrce = 1 - CHK_ERROR(UpdateReg(state,EB7)); + state->m_Regs[EB7] |= 0x20; /* CAL_forceSrce = 1 */ + CHK_ERROR(UpdateReg(state, EB7)); msleep(1); - state->m_Regs[EB7] &= ~0x20; // CAL_forceSrce = 0 - CHK_ERROR(UpdateReg(state,EB7)); + state->m_Regs[EB7] &= ~0x20; /* CAL_forceSrce = 0 */ + CHK_ERROR(UpdateReg(state, EB7)); } msleep(20); - if( Standard != HF_FM_Radio ) - { - state->m_Regs[EP3] |= 0x04; // RFAGC to normal mode - } - CHK_ERROR(UpdateReg(state,EP3)); + if (Standard != HF_FM_Radio) + state->m_Regs[EP3] |= 0x04; /* RFAGC to normal mode */ + CHK_ERROR(UpdateReg(state, EP3)); - } while(0); + } while (0); return status; } -static int sleep(struct dvb_frontend* fe) +static int sleep(struct dvb_frontend *fe) { struct tda_state *state = fe->tuner_priv; @@ -938,13 +916,12 @@ static int sleep(struct dvb_frontend* fe) return 0; } -static int init(struct dvb_frontend* fe) +static int init(struct dvb_frontend *fe) { - //struct tda_state *state = fe->tuner_priv; return 0; } -static int release(struct dvb_frontend* fe) +static int release(struct dvb_frontend *fe) { kfree(fe->tuner_priv); fe->tuner_priv = NULL; @@ -978,22 +955,22 @@ static int set_params(struct dvb_frontend *fe, } else return -EINVAL; do { - CHK_ERROR(RFTrackingFiltersCorrection(state,params->frequency)); - CHK_ERROR(ChannelConfiguration(state,params->frequency,Standard)); + CHK_ERROR(RFTrackingFiltersCorrection(state, params->frequency)); + CHK_ERROR(ChannelConfiguration(state, params->frequency, Standard)); - msleep(state->m_SettlingTime); // Allow AGC's to settle down - } while(0); + msleep(state->m_SettlingTime); /* Allow AGC's to settle down */ + } while (0); return status; } #if 0 -static int GetSignalStrength(s32 * pSignalStrength,u32 RFAgc,u32 IFAgc) +static int GetSignalStrength(s32 *pSignalStrength, u32 RFAgc, u32 IFAgc) { - if( IFAgc < 500 ) { - // Scale this from 0 to 50000 + if (IFAgc < 500) { + /* Scale this from 0 to 50000 */ *pSignalStrength = IFAgc * 100; } else { - // Scale range 500-1500 to 50000-80000 + /* Scale range 500-1500 to 50000-80000 */ *pSignalStrength = 50000 + (IFAgc - 500) * 30; } @@ -1011,8 +988,8 @@ static int get_frequency(struct dvb_frontend *fe, u32 *frequency) static int get_bandwidth(struct dvb_frontend *fe, u32 *bandwidth) { - //struct tda_state *state = fe->tuner_priv; - //*bandwidth = priv->bandwidth; + /* struct tda_state *state = fe->tuner_priv; */ + /* *bandwidth = priv->bandwidth; */ return 0; } @@ -1050,14 +1027,8 @@ struct dvb_frontend *tda18271c2dd_attach(struct dvb_frontend *fe, return fe; } - EXPORT_SYMBOL_GPL(tda18271c2dd_attach); + MODULE_DESCRIPTION("TDA18271C2 driver"); MODULE_AUTHOR("DD"); MODULE_LICENSE("GPL"); - -/* - * Local variables: - * c-basic-offset: 8 - * End: - */ |