Lines Matching full:fe

3     tda18271-fe.c - driver for the Philips / NXP TDA18271 silicon tuner
28 static int tda18271_toggle_output(struct dvb_frontend *fe, int standby) in tda18271_toggle_output() argument
30 struct tda18271_priv *priv = fe->tuner_priv; in tda18271_toggle_output()
32 int ret = tda18271_set_standby_mode(fe, standby ? 1 : 0, in tda18271_toggle_output()
49 static inline int charge_pump_source(struct dvb_frontend *fe, int force) in charge_pump_source() argument
51 struct tda18271_priv *priv = fe->tuner_priv; in charge_pump_source()
52 return tda18271_charge_pump_source(fe, in charge_pump_source()
58 static inline void tda18271_set_if_notch(struct dvb_frontend *fe) in tda18271_set_if_notch() argument
60 struct tda18271_priv *priv = fe->tuner_priv; in tda18271_set_if_notch()
73 static int tda18271_channel_configuration(struct dvb_frontend *fe, in tda18271_channel_configuration() argument
77 struct tda18271_priv *priv = fe->tuner_priv; in tda18271_channel_configuration()
107 ret = tda18271_write_regs(fe, R_EB22, 1); in tda18271_channel_configuration()
121 tda18271_calc_ir_measure(fe, &freq); in tda18271_channel_configuration()
123 tda18271_calc_bp_filter(fe, &freq); in tda18271_channel_configuration()
125 tda18271_calc_rf_band(fe, &freq); in tda18271_channel_configuration()
127 tda18271_calc_gain_taper(fe, &freq); in tda18271_channel_configuration()
148 ret = tda18271_write_regs(fe, R_EB1, 1); in tda18271_channel_configuration()
158 tda18271_calc_main_pll(fe, N); in tda18271_channel_configuration()
159 tda18271_set_if_notch(fe); in tda18271_channel_configuration()
160 tda18271_write_regs(fe, R_MPD, 4); in tda18271_channel_configuration()
163 tda18271_calc_cal_pll(fe, N); in tda18271_channel_configuration()
164 tda18271_write_regs(fe, R_CPD, 4); in tda18271_channel_configuration()
167 tda18271_set_if_notch(fe); in tda18271_channel_configuration()
168 tda18271_write_regs(fe, R_MPD, 1); in tda18271_channel_configuration()
172 ret = tda18271_write_regs(fe, R_TM, 7); in tda18271_channel_configuration()
177 charge_pump_source(fe, 1); in tda18271_channel_configuration()
182 charge_pump_source(fe, 0); in tda18271_channel_configuration()
192 ret = tda18271_write_regs(fe, R_EP3, 1); in tda18271_channel_configuration()
198 static int tda18271_read_thermometer(struct dvb_frontend *fe) in tda18271_read_thermometer() argument
200 struct tda18271_priv *priv = fe->tuner_priv; in tda18271_read_thermometer()
206 tda18271_write_regs(fe, R_TM, 1); in tda18271_read_thermometer()
209 tda18271_read_regs(fe); in tda18271_read_thermometer()
219 tda18271_write_regs(fe, R_TM, 1); in tda18271_read_thermometer()
224 tda18271_read_regs(fe); in tda18271_read_thermometer()
227 tm = tda18271_lookup_thermometer(fe); in tda18271_read_thermometer()
231 tda18271_write_regs(fe, R_TM, 1); in tda18271_read_thermometer()
235 tda18271_write_regs(fe, R_EP4, 1); in tda18271_read_thermometer()
242 static int tda18271c2_rf_tracking_filters_correction(struct dvb_frontend *fe, in tda18271c2_rf_tracking_filters_correction() argument
245 struct tda18271_priv *priv = fe->tuner_priv; in tda18271c2_rf_tracking_filters_correction()
253 ret = tda18271_set_standby_mode(fe, 0, 0, 0); in tda18271c2_rf_tracking_filters_correction()
258 tm_current = tda18271_read_thermometer(fe); in tda18271c2_rf_tracking_filters_correction()
262 tda18271_calc_rf_cal(fe, &freq); in tda18271c2_rf_tracking_filters_correction()
265 i = tda18271_lookup_rf_band(fe, &freq, NULL); in tda18271c2_rf_tracking_filters_correction()
282 tda18271_lookup_map(fe, RF_CAL_DC_OVER_DT, &freq, &dc_over_dt); in tda18271c2_rf_tracking_filters_correction()
288 ret = tda18271_write_regs(fe, R_EB14, 1); in tda18271c2_rf_tracking_filters_correction()
293 static int tda18271_por(struct dvb_frontend *fe) in tda18271_por() argument
295 struct tda18271_priv *priv = fe->tuner_priv; in tda18271_por()
301 ret = tda18271_write_regs(fe, R_EB12, 1); in tda18271_por()
307 ret = tda18271_write_regs(fe, R_EB18, 1); in tda18271_por()
314 ret = tda18271_set_standby_mode(fe, 1, 0, 0); in tda18271_por()
321 ret = tda18271_write_regs(fe, R_EB21, 3); in tda18271_por()
326 static int tda18271_calibrate_rf(struct dvb_frontend *fe, u32 freq) in tda18271_calibrate_rf() argument
328 struct tda18271_priv *priv = fe->tuner_priv; in tda18271_calibrate_rf()
334 tda18271_write_regs(fe, R_EP4, 1); in tda18271_calibrate_rf()
340 tda18271_write_regs(fe, R_EB18, 1); in tda18271_calibrate_rf()
344 tda18271_calc_bp_filter(fe, &freq); in tda18271_calibrate_rf()
345 tda18271_calc_gain_taper(fe, &freq); in tda18271_calibrate_rf()
346 tda18271_calc_rf_band(fe, &freq); in tda18271_calibrate_rf()
347 tda18271_calc_km(fe, &freq); in tda18271_calibrate_rf()
349 tda18271_write_regs(fe, R_EP1, 3); in tda18271_calibrate_rf()
350 tda18271_write_regs(fe, R_EB13, 1); in tda18271_calibrate_rf()
353 tda18271_charge_pump_source(fe, TDA18271_MAIN_PLL, 1); in tda18271_calibrate_rf()
356 tda18271_charge_pump_source(fe, TDA18271_CAL_PLL, 1); in tda18271_calibrate_rf()
360 tda18271_write_regs(fe, R_EB14, 1); in tda18271_calibrate_rf()
364 tda18271_write_regs(fe, R_EB20, 1); in tda18271_calibrate_rf()
368 tda18271_write_regs(fe, R_EP4, 2); in tda18271_calibrate_rf()
375 tda18271_calc_cal_pll(fe, N); in tda18271_calibrate_rf()
376 tda18271_write_regs(fe, R_CPD, 4); in tda18271_calibrate_rf()
381 tda18271_calc_main_pll(fe, N); in tda18271_calibrate_rf()
382 tda18271_write_regs(fe, R_MPD, 4); in tda18271_calibrate_rf()
386 tda18271_write_regs(fe, R_EP2, 1); in tda18271_calibrate_rf()
387 tda18271_write_regs(fe, R_EP1, 1); in tda18271_calibrate_rf()
388 tda18271_write_regs(fe, R_EP2, 1); in tda18271_calibrate_rf()
389 tda18271_write_regs(fe, R_EP1, 1); in tda18271_calibrate_rf()
394 tda18271_charge_pump_source(fe, TDA18271_MAIN_PLL, 0); in tda18271_calibrate_rf()
397 tda18271_charge_pump_source(fe, TDA18271_CAL_PLL, 0); in tda18271_calibrate_rf()
403 tda18271_write_regs(fe, R_EB20, 1); in tda18271_calibrate_rf()
416 tda18271_write_regs(fe, R_EB18, 1); in tda18271_calibrate_rf()
418 tda18271_write_regs(fe, R_EP3, 2); in tda18271_calibrate_rf()
421 tda18271_write_regs(fe, R_EP1, 1); in tda18271_calibrate_rf()
424 tda18271_read_extended(fe); in tda18271_calibrate_rf()
429 static int tda18271_powerscan(struct dvb_frontend *fe, in tda18271_powerscan() argument
432 struct tda18271_priv *priv = fe->tuner_priv; in tda18271_powerscan()
441 tda18271_calc_rf_band(fe, &freq); in tda18271_powerscan()
442 tda18271_calc_rf_cal(fe, &freq); in tda18271_powerscan()
443 tda18271_calc_gain_taper(fe, &freq); in tda18271_powerscan()
444 tda18271_lookup_cid_target(fe, &freq, &cid_target, &count_limit); in tda18271_powerscan()
446 tda18271_write_regs(fe, R_EP2, 1); in tda18271_powerscan()
447 tda18271_write_regs(fe, R_EB14, 1); in tda18271_powerscan()
452 tda18271_calc_main_pll(fe, freq); in tda18271_powerscan()
453 tda18271_write_regs(fe, R_MPD, 4); in tda18271_powerscan()
460 tda18271_write_regs(fe, R_EP4, 1); in tda18271_powerscan()
463 tda18271_write_regs(fe, R_EP2, 1); in tda18271_powerscan()
466 ret = tda18271_read_extended(fe); in tda18271_powerscan()
481 tda18271_calc_main_pll(fe, freq); in tda18271_powerscan()
482 tda18271_write_regs(fe, R_MPD, 4); in tda18271_powerscan()
491 tda18271_write_regs(fe, R_EP2, 1); in tda18271_powerscan()
494 ret = tda18271_read_extended(fe); in tda18271_powerscan()
523 static int tda18271_powerscan_init(struct dvb_frontend *fe) in tda18271_powerscan_init() argument
525 struct tda18271_priv *priv = fe->tuner_priv; in tda18271_powerscan_init()
539 ret = tda18271_write_regs(fe, R_EP3, 2); in tda18271_powerscan_init()
544 ret = tda18271_write_regs(fe, R_EB18, 1); in tda18271_powerscan_init()
554 ret = tda18271_write_regs(fe, R_EB21, 3); in tda18271_powerscan_init()
559 static int tda18271_rf_tracking_filters_init(struct dvb_frontend *fe, u32 freq) in tda18271_rf_tracking_filters_init() argument
561 struct tda18271_priv *priv = fe->tuner_priv; in tda18271_rf_tracking_filters_init()
574 i = tda18271_lookup_rf_band(fe, &freq, NULL); in tda18271_rf_tracking_filters_init()
589 bcal = tda18271_powerscan(fe, &rf_default[rf], &rf_freq[rf]); in tda18271_rf_tracking_filters_init()
593 tda18271_calc_rf_cal(fe, &rf_freq[rf]); in tda18271_rf_tracking_filters_init()
598 (s32)tda18271_calibrate_rf(fe, rf_freq[rf]); in tda18271_rf_tracking_filters_init()
631 static int tda18271_calc_rf_filter_curve(struct dvb_frontend *fe) in tda18271_calc_rf_filter_curve() argument
633 struct tda18271_priv *priv = fe->tuner_priv; in tda18271_calc_rf_filter_curve()
642 ret = tda18271_powerscan_init(fe); in tda18271_calc_rf_filter_curve()
649 tda18271_rf_tracking_filters_init(fe, 1000 * in tda18271_calc_rf_filter_curve()
655 priv->tm_rfcal = tda18271_read_thermometer(fe); in tda18271_calc_rf_filter_curve()
662 static int tda18271c2_rf_cal_init(struct dvb_frontend *fe) in tda18271c2_rf_cal_init() argument
664 struct tda18271_priv *priv = fe->tuner_priv; in tda18271c2_rf_cal_init()
675 ret = tda18271_calc_rf_filter_curve(fe); in tda18271c2_rf_cal_init()
679 ret = tda18271_por(fe); in tda18271c2_rf_cal_init()
693 static int tda18271c1_rf_tracking_filter_calibration(struct dvb_frontend *fe, in tda18271c1_rf_tracking_filter_calibration() argument
696 struct tda18271_priv *priv = fe->tuner_priv; in tda18271c1_rf_tracking_filter_calibration()
702 tda18271_calc_bp_filter(fe, &freq); in tda18271c1_rf_tracking_filter_calibration()
703 tda18271_write_regs(fe, R_EP1, 1); in tda18271c1_rf_tracking_filter_calibration()
707 tda18271_write_regs(fe, R_EB4, 1); in tda18271c1_rf_tracking_filter_calibration()
710 tda18271_write_regs(fe, R_EB7, 1); in tda18271c1_rf_tracking_filter_calibration()
713 tda18271_write_regs(fe, R_EB14, 1); in tda18271c1_rf_tracking_filter_calibration()
716 tda18271_write_regs(fe, R_EB20, 1); in tda18271c1_rf_tracking_filter_calibration()
732 tda18271_calc_cal_pll(fe, N); in tda18271c1_rf_tracking_filter_calibration()
745 tda18271_calc_main_pll(fe, N); in tda18271c1_rf_tracking_filter_calibration()
747 ret = tda18271_write_regs(fe, R_EP3, 11); in tda18271c1_rf_tracking_filter_calibration()
754 tda18271_calc_km(fe, &freq); in tda18271c1_rf_tracking_filter_calibration()
755 tda18271_write_regs(fe, R_EB13, 1); in tda18271c1_rf_tracking_filter_calibration()
758 tda18271_calc_rf_band(fe, &freq); in tda18271c1_rf_tracking_filter_calibration()
761 tda18271_calc_gain_taper(fe, &freq); in tda18271c1_rf_tracking_filter_calibration()
763 tda18271_write_regs(fe, R_EP2, 1); in tda18271c1_rf_tracking_filter_calibration()
764 tda18271_write_regs(fe, R_EP1, 1); in tda18271c1_rf_tracking_filter_calibration()
765 tda18271_write_regs(fe, R_EP2, 1); in tda18271c1_rf_tracking_filter_calibration()
766 tda18271_write_regs(fe, R_EP1, 1); in tda18271c1_rf_tracking_filter_calibration()
770 tda18271_write_regs(fe, R_EB4, 1); in tda18271c1_rf_tracking_filter_calibration()
773 tda18271_write_regs(fe, R_EB7, 1); in tda18271c1_rf_tracking_filter_calibration()
777 tda18271_write_regs(fe, R_EB20, 1); in tda18271c1_rf_tracking_filter_calibration()
781 tda18271_write_regs(fe, R_EP4, 1); in tda18271c1_rf_tracking_filter_calibration()
783 tda18271_write_regs(fe, R_EP1, 1); in tda18271c1_rf_tracking_filter_calibration()
786 if (0 == tda18271_calc_rf_cal(fe, &freq)) in tda18271c1_rf_tracking_filter_calibration()
787 tda18271_write_regs(fe, R_EB14, 1); in tda18271c1_rf_tracking_filter_calibration()
794 static int tda18271_ir_cal_init(struct dvb_frontend *fe) in tda18271_ir_cal_init() argument
796 struct tda18271_priv *priv = fe->tuner_priv; in tda18271_ir_cal_init()
800 ret = tda18271_read_regs(fe); in tda18271_ir_cal_init()
806 ret = tda18271_init_regs(fe); in tda18271_ir_cal_init()
811 static int tda18271_init(struct dvb_frontend *fe) in tda18271_init() argument
813 struct tda18271_priv *priv = fe->tuner_priv; in tda18271_init()
819 ret = tda18271_set_standby_mode(fe, 0, 0, 0); in tda18271_init()
824 ret = tda18271_ir_cal_init(fe); in tda18271_init()
829 tda18271c2_rf_cal_init(fe); in tda18271_init()
836 static int tda18271_sleep(struct dvb_frontend *fe) in tda18271_sleep() argument
838 struct tda18271_priv *priv = fe->tuner_priv; in tda18271_sleep()
844 ret = tda18271_toggle_output(fe, 1); in tda18271_sleep()
853 static int tda18271_agc(struct dvb_frontend *fe) in tda18271_agc() argument
855 struct tda18271_priv *priv = fe->tuner_priv; in tda18271_agc()
867 if (fe->callback) in tda18271_agc()
868 ret = fe->callback(priv->i2c_props.adap->algo_data, in tda18271_agc()
884 static int tda18271_tune(struct dvb_frontend *fe, in tda18271_tune() argument
887 struct tda18271_priv *priv = fe->tuner_priv; in tda18271_tune()
893 ret = tda18271_agc(fe); in tda18271_tune()
897 ret = tda18271_init(fe); in tda18271_tune()
905 tda18271c1_rf_tracking_filter_calibration(fe, freq, bw); in tda18271_tune()
908 tda18271c2_rf_tracking_filters_correction(fe, freq); in tda18271_tune()
911 ret = tda18271_channel_configuration(fe, map, freq, bw); in tda18271_tune()
920 static int tda18271_set_params(struct dvb_frontend *fe) in tda18271_set_params() argument
922 struct dtv_frontend_properties *c = &fe->dtv_property_cache; in tda18271_set_params()
926 struct tda18271_priv *priv = fe->tuner_priv; in tda18271_set_params()
968 if (fe->ops.analog_ops.standby) in tda18271_set_params()
969 fe->ops.analog_ops.standby(fe); in tda18271_set_params()
971 ret = tda18271_tune(fe, map, freq, bw); in tda18271_set_params()
983 static int tda18271_set_analog_params(struct dvb_frontend *fe, in tda18271_set_analog_params() argument
986 struct tda18271_priv *priv = fe->tuner_priv; in tda18271_set_analog_params()
1027 ret = tda18271_tune(fe, map, freq, 0); in tda18271_set_analog_params()
1039 static void tda18271_release(struct dvb_frontend *fe) in tda18271_release() argument
1041 struct tda18271_priv *priv = fe->tuner_priv; in tda18271_release()
1050 fe->tuner_priv = NULL; in tda18271_release()
1053 static int tda18271_get_frequency(struct dvb_frontend *fe, u32 *frequency) in tda18271_get_frequency() argument
1055 struct tda18271_priv *priv = fe->tuner_priv; in tda18271_get_frequency()
1060 static int tda18271_get_bandwidth(struct dvb_frontend *fe, u32 *bandwidth) in tda18271_get_bandwidth() argument
1062 struct tda18271_priv *priv = fe->tuner_priv; in tda18271_get_bandwidth()
1067 static int tda18271_get_if_frequency(struct dvb_frontend *fe, u32 *frequency) in tda18271_get_if_frequency() argument
1069 struct tda18271_priv *priv = fe->tuner_priv; in tda18271_get_if_frequency()
1093 static int tda18271_dump_std_map(struct dvb_frontend *fe) in tda18271_dump_std_map() argument
1095 struct tda18271_priv *priv = fe->tuner_priv; in tda18271_dump_std_map()
1118 static int tda18271_update_std_map(struct dvb_frontend *fe, in tda18271_update_std_map() argument
1121 struct tda18271_priv *priv = fe->tuner_priv; in tda18271_update_std_map()
1146 static int tda18271_get_id(struct dvb_frontend *fe) in tda18271_get_id() argument
1148 struct tda18271_priv *priv = fe->tuner_priv; in tda18271_get_id()
1154 ret = tda18271_read_regs(fe); in tda18271_get_id()
1186 static int tda18271_setup_configuration(struct dvb_frontend *fe, in tda18271_setup_configuration() argument
1189 struct tda18271_priv *priv = fe->tuner_priv; in tda18271_setup_configuration()
1212 static int tda18271_set_config(struct dvb_frontend *fe, void *priv_cfg) in tda18271_set_config() argument
1216 tda18271_setup_configuration(fe, cfg); in tda18271_set_config()
1219 tda18271_init(fe); in tda18271_set_config()
1223 tda18271_update_std_map(fe, cfg->std_map); in tda18271_set_config()
1246 struct dvb_frontend *tda18271_attach(struct dvb_frontend *fe, u8 addr, in tda18271_attach() argument
1263 fe->tuner_priv = priv; in tda18271_attach()
1265 tda18271_setup_configuration(fe, cfg); in tda18271_attach()
1270 ret = tda18271_get_id(fe); in tda18271_attach()
1274 ret = tda18271_assign_map_layout(fe); in tda18271_attach()
1284 tda18271_init_regs(fe); in tda18271_attach()
1288 tda18271c2_rf_cal_init(fe); in tda18271_attach()
1291 ret = tda18271_toggle_output(fe, 1); in tda18271_attach()
1298 fe->tuner_priv = priv; in tda18271_attach()
1313 tda18271_update_std_map(fe, cfg->std_map); in tda18271_attach()
1316 tda18271_init(fe); in tda18271_attach()
1322 tda18271_update_std_map(fe, cfg->std_map); in tda18271_attach()
1326 memcpy(&fe->ops.tuner_ops, &tda18271_tuner_ops, in tda18271_attach()
1330 tda18271_dump_std_map(fe); in tda18271_attach()
1332 return fe; in tda18271_attach()
1336 tda18271_release(fe); in tda18271_attach()