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()
480 tda18271_calc_main_pll(fe, freq); in tda18271_powerscan()
481 tda18271_write_regs(fe, R_MPD, 4); in tda18271_powerscan()
490 tda18271_write_regs(fe, R_EP2, 1); in tda18271_powerscan()
493 ret = tda18271_read_extended(fe); in tda18271_powerscan()
522 static int tda18271_powerscan_init(struct dvb_frontend *fe) in tda18271_powerscan_init() argument
524 struct tda18271_priv *priv = fe->tuner_priv; in tda18271_powerscan_init()
538 ret = tda18271_write_regs(fe, R_EP3, 2); in tda18271_powerscan_init()
543 ret = tda18271_write_regs(fe, R_EB18, 1); in tda18271_powerscan_init()
553 ret = tda18271_write_regs(fe, R_EB21, 3); in tda18271_powerscan_init()
558 static int tda18271_rf_tracking_filters_init(struct dvb_frontend *fe, u32 freq) in tda18271_rf_tracking_filters_init() argument
560 struct tda18271_priv *priv = fe->tuner_priv; in tda18271_rf_tracking_filters_init()
573 i = tda18271_lookup_rf_band(fe, &freq, NULL); in tda18271_rf_tracking_filters_init()
588 bcal = tda18271_powerscan(fe, &rf_default[rf], &rf_freq[rf]); in tda18271_rf_tracking_filters_init()
592 tda18271_calc_rf_cal(fe, &rf_freq[rf]); in tda18271_rf_tracking_filters_init()
597 (s32)tda18271_calibrate_rf(fe, rf_freq[rf]); in tda18271_rf_tracking_filters_init()
630 static int tda18271_calc_rf_filter_curve(struct dvb_frontend *fe) in tda18271_calc_rf_filter_curve() argument
632 struct tda18271_priv *priv = fe->tuner_priv; in tda18271_calc_rf_filter_curve()
641 ret = tda18271_powerscan_init(fe); in tda18271_calc_rf_filter_curve()
648 tda18271_rf_tracking_filters_init(fe, 1000 * in tda18271_calc_rf_filter_curve()
654 priv->tm_rfcal = tda18271_read_thermometer(fe); in tda18271_calc_rf_filter_curve()
661 static int tda18271c2_rf_cal_init(struct dvb_frontend *fe) in tda18271c2_rf_cal_init() argument
663 struct tda18271_priv *priv = fe->tuner_priv; in tda18271c2_rf_cal_init()
674 ret = tda18271_calc_rf_filter_curve(fe); in tda18271c2_rf_cal_init()
678 ret = tda18271_por(fe); in tda18271c2_rf_cal_init()
692 static int tda18271c1_rf_tracking_filter_calibration(struct dvb_frontend *fe, in tda18271c1_rf_tracking_filter_calibration() argument
695 struct tda18271_priv *priv = fe->tuner_priv; in tda18271c1_rf_tracking_filter_calibration()
701 tda18271_calc_bp_filter(fe, &freq); in tda18271c1_rf_tracking_filter_calibration()
702 tda18271_write_regs(fe, R_EP1, 1); in tda18271c1_rf_tracking_filter_calibration()
706 tda18271_write_regs(fe, R_EB4, 1); in tda18271c1_rf_tracking_filter_calibration()
709 tda18271_write_regs(fe, R_EB7, 1); in tda18271c1_rf_tracking_filter_calibration()
712 tda18271_write_regs(fe, R_EB14, 1); in tda18271c1_rf_tracking_filter_calibration()
715 tda18271_write_regs(fe, R_EB20, 1); in tda18271c1_rf_tracking_filter_calibration()
731 tda18271_calc_cal_pll(fe, N); in tda18271c1_rf_tracking_filter_calibration()
744 tda18271_calc_main_pll(fe, N); in tda18271c1_rf_tracking_filter_calibration()
746 ret = tda18271_write_regs(fe, R_EP3, 11); in tda18271c1_rf_tracking_filter_calibration()
753 tda18271_calc_km(fe, &freq); in tda18271c1_rf_tracking_filter_calibration()
754 tda18271_write_regs(fe, R_EB13, 1); in tda18271c1_rf_tracking_filter_calibration()
757 tda18271_calc_rf_band(fe, &freq); in tda18271c1_rf_tracking_filter_calibration()
760 tda18271_calc_gain_taper(fe, &freq); in tda18271c1_rf_tracking_filter_calibration()
762 tda18271_write_regs(fe, R_EP2, 1); in tda18271c1_rf_tracking_filter_calibration()
763 tda18271_write_regs(fe, R_EP1, 1); in tda18271c1_rf_tracking_filter_calibration()
764 tda18271_write_regs(fe, R_EP2, 1); in tda18271c1_rf_tracking_filter_calibration()
765 tda18271_write_regs(fe, R_EP1, 1); in tda18271c1_rf_tracking_filter_calibration()
769 tda18271_write_regs(fe, R_EB4, 1); in tda18271c1_rf_tracking_filter_calibration()
772 tda18271_write_regs(fe, R_EB7, 1); in tda18271c1_rf_tracking_filter_calibration()
776 tda18271_write_regs(fe, R_EB20, 1); in tda18271c1_rf_tracking_filter_calibration()
780 tda18271_write_regs(fe, R_EP4, 1); in tda18271c1_rf_tracking_filter_calibration()
782 tda18271_write_regs(fe, R_EP1, 1); in tda18271c1_rf_tracking_filter_calibration()
785 if (0 == tda18271_calc_rf_cal(fe, &freq)) in tda18271c1_rf_tracking_filter_calibration()
786 tda18271_write_regs(fe, R_EB14, 1); in tda18271c1_rf_tracking_filter_calibration()
793 static int tda18271_ir_cal_init(struct dvb_frontend *fe) in tda18271_ir_cal_init() argument
795 struct tda18271_priv *priv = fe->tuner_priv; in tda18271_ir_cal_init()
799 ret = tda18271_read_regs(fe); in tda18271_ir_cal_init()
805 ret = tda18271_init_regs(fe); in tda18271_ir_cal_init()
810 static int tda18271_init(struct dvb_frontend *fe) in tda18271_init() argument
812 struct tda18271_priv *priv = fe->tuner_priv; in tda18271_init()
818 ret = tda18271_set_standby_mode(fe, 0, 0, 0); in tda18271_init()
823 ret = tda18271_ir_cal_init(fe); in tda18271_init()
828 tda18271c2_rf_cal_init(fe); in tda18271_init()
835 static int tda18271_sleep(struct dvb_frontend *fe) in tda18271_sleep() argument
837 struct tda18271_priv *priv = fe->tuner_priv; in tda18271_sleep()
843 ret = tda18271_toggle_output(fe, 1); in tda18271_sleep()
852 static int tda18271_agc(struct dvb_frontend *fe) in tda18271_agc() argument
854 struct tda18271_priv *priv = fe->tuner_priv; in tda18271_agc()
866 if (fe->callback) in tda18271_agc()
867 ret = fe->callback(priv->i2c_props.adap->algo_data, in tda18271_agc()
883 static int tda18271_tune(struct dvb_frontend *fe, in tda18271_tune() argument
886 struct tda18271_priv *priv = fe->tuner_priv; in tda18271_tune()
892 ret = tda18271_agc(fe); in tda18271_tune()
896 ret = tda18271_init(fe); in tda18271_tune()
904 tda18271c1_rf_tracking_filter_calibration(fe, freq, bw); in tda18271_tune()
907 tda18271c2_rf_tracking_filters_correction(fe, freq); in tda18271_tune()
910 ret = tda18271_channel_configuration(fe, map, freq, bw); in tda18271_tune()
919 static int tda18271_set_params(struct dvb_frontend *fe) in tda18271_set_params() argument
921 struct dtv_frontend_properties *c = &fe->dtv_property_cache; in tda18271_set_params()
925 struct tda18271_priv *priv = fe->tuner_priv; in tda18271_set_params()
967 if (fe->ops.analog_ops.standby) in tda18271_set_params()
968 fe->ops.analog_ops.standby(fe); in tda18271_set_params()
970 ret = tda18271_tune(fe, map, freq, bw); in tda18271_set_params()
982 static int tda18271_set_analog_params(struct dvb_frontend *fe, in tda18271_set_analog_params() argument
985 struct tda18271_priv *priv = fe->tuner_priv; in tda18271_set_analog_params()
1026 ret = tda18271_tune(fe, map, freq, 0); in tda18271_set_analog_params()
1038 static void tda18271_release(struct dvb_frontend *fe) in tda18271_release() argument
1040 struct tda18271_priv *priv = fe->tuner_priv; in tda18271_release()
1049 fe->tuner_priv = NULL; in tda18271_release()
1052 static int tda18271_get_frequency(struct dvb_frontend *fe, u32 *frequency) in tda18271_get_frequency() argument
1054 struct tda18271_priv *priv = fe->tuner_priv; in tda18271_get_frequency()
1059 static int tda18271_get_bandwidth(struct dvb_frontend *fe, u32 *bandwidth) in tda18271_get_bandwidth() argument
1061 struct tda18271_priv *priv = fe->tuner_priv; in tda18271_get_bandwidth()
1066 static int tda18271_get_if_frequency(struct dvb_frontend *fe, u32 *frequency) in tda18271_get_if_frequency() argument
1068 struct tda18271_priv *priv = fe->tuner_priv; in tda18271_get_if_frequency()
1092 static int tda18271_dump_std_map(struct dvb_frontend *fe) in tda18271_dump_std_map() argument
1094 struct tda18271_priv *priv = fe->tuner_priv; in tda18271_dump_std_map()
1117 static int tda18271_update_std_map(struct dvb_frontend *fe, in tda18271_update_std_map() argument
1120 struct tda18271_priv *priv = fe->tuner_priv; in tda18271_update_std_map()
1145 static int tda18271_get_id(struct dvb_frontend *fe) in tda18271_get_id() argument
1147 struct tda18271_priv *priv = fe->tuner_priv; in tda18271_get_id()
1153 ret = tda18271_read_regs(fe); in tda18271_get_id()
1185 static int tda18271_setup_configuration(struct dvb_frontend *fe, in tda18271_setup_configuration() argument
1188 struct tda18271_priv *priv = fe->tuner_priv; in tda18271_setup_configuration()
1211 static int tda18271_set_config(struct dvb_frontend *fe, void *priv_cfg) in tda18271_set_config() argument
1215 tda18271_setup_configuration(fe, cfg); in tda18271_set_config()
1218 tda18271_init(fe); in tda18271_set_config()
1222 tda18271_update_std_map(fe, cfg->std_map); in tda18271_set_config()
1245 struct dvb_frontend *tda18271_attach(struct dvb_frontend *fe, u8 addr, in tda18271_attach() argument
1262 fe->tuner_priv = priv; in tda18271_attach()
1264 tda18271_setup_configuration(fe, cfg); in tda18271_attach()
1269 ret = tda18271_get_id(fe); in tda18271_attach()
1273 ret = tda18271_assign_map_layout(fe); in tda18271_attach()
1283 tda18271_init_regs(fe); in tda18271_attach()
1287 tda18271c2_rf_cal_init(fe); in tda18271_attach()
1290 ret = tda18271_toggle_output(fe, 1); in tda18271_attach()
1297 fe->tuner_priv = priv; in tda18271_attach()
1312 tda18271_update_std_map(fe, cfg->std_map); in tda18271_attach()
1315 tda18271_init(fe); in tda18271_attach()
1321 tda18271_update_std_map(fe, cfg->std_map); in tda18271_attach()
1325 memcpy(&fe->ops.tuner_ops, &tda18271_tuner_ops, in tda18271_attach()
1329 tda18271_dump_std_map(fe); in tda18271_attach()
1331 return fe; in tda18271_attach()
1335 tda18271_release(fe); in tda18271_attach()