diff options
author | Michael Krufky <mkrufky@linuxtv.org> | 2008-01-05 18:00:09 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@infradead.org> | 2008-01-25 16:04:41 -0500 |
commit | 09f83c4fc06b02597ad4458c2a6675b0872f0b5c (patch) | |
tree | 06e4774299e0e380e0931130b67ba1644fb45613 /drivers | |
parent | 98512f7b36ec412ea0461e9aab8f16c882df055d (diff) |
V4L/DVB (6977): tda18271: clean up calibration initialization procedures
Always initialize registers during attach.
Perform IR Calibration during init if needed.
Perform RF Calibration during init if needed for C2, only.
Signed-off-by: Michael Krufky <mkrufky@linuxtv.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/media/dvb/frontends/tda18271-fe.c | 37 | ||||
-rw-r--r-- | drivers/media/dvb/frontends/tda18271-priv.h | 1 |
2 files changed, 23 insertions, 15 deletions
diff --git a/drivers/media/dvb/frontends/tda18271-fe.c b/drivers/media/dvb/frontends/tda18271-fe.c index 55c17fc22275..1a86c9f7a7e4 100644 --- a/drivers/media/dvb/frontends/tda18271-fe.c +++ b/drivers/media/dvb/frontends/tda18271-fe.c | |||
@@ -29,7 +29,7 @@ MODULE_PARM_DESC(debug, "set debug level " | |||
29 | 29 | ||
30 | /*---------------------------------------------------------------------*/ | 30 | /*---------------------------------------------------------------------*/ |
31 | 31 | ||
32 | static int tda18271_init(struct dvb_frontend *fe) | 32 | static int tda18271_ir_cal_init(struct dvb_frontend *fe) |
33 | { | 33 | { |
34 | struct tda18271_priv *priv = fe->tuner_priv; | 34 | struct tda18271_priv *priv = fe->tuner_priv; |
35 | unsigned char *regs = priv->tda18271_regs; | 35 | unsigned char *regs = priv->tda18271_regs; |
@@ -184,7 +184,7 @@ static int tda18271_read_thermometer(struct dvb_frontend *fe) | |||
184 | } | 184 | } |
185 | 185 | ||
186 | static int tda18271_rf_tracking_filters_correction(struct dvb_frontend *fe, | 186 | static int tda18271_rf_tracking_filters_correction(struct dvb_frontend *fe, |
187 | u32 freq, int tm_rfcal) | 187 | u32 freq) |
188 | { | 188 | { |
189 | struct tda18271_priv *priv = fe->tuner_priv; | 189 | struct tda18271_priv *priv = fe->tuner_priv; |
190 | struct tda18271_rf_tracking_filter_cal *map = priv->rf_cal_state; | 190 | struct tda18271_rf_tracking_filter_cal *map = priv->rf_cal_state; |
@@ -224,7 +224,7 @@ static int tda18271_rf_tracking_filters_correction(struct dvb_frontend *fe, | |||
224 | tda18271_lookup_map(fe, RF_CAL_DC_OVER_DT, &freq, &dc_over_dt); | 224 | tda18271_lookup_map(fe, RF_CAL_DC_OVER_DT, &freq, &dc_over_dt); |
225 | 225 | ||
226 | /* calculate temperature compensation */ | 226 | /* calculate temperature compensation */ |
227 | rfcal_comp = dc_over_dt * (tm_current - tm_rfcal); | 227 | rfcal_comp = dc_over_dt * (tm_current - priv->tm_rfcal); |
228 | 228 | ||
229 | regs[R_EB14] = approx + rfcal_comp; | 229 | regs[R_EB14] = approx + rfcal_comp; |
230 | tda18271_write_regs(fe, R_EB14, 1); | 230 | tda18271_write_regs(fe, R_EB14, 1); |
@@ -554,8 +554,7 @@ static int tda18271_rf_tracking_filters_init(struct dvb_frontend *fe, u32 freq) | |||
554 | return 0; | 554 | return 0; |
555 | } | 555 | } |
556 | 556 | ||
557 | static int tda18271_calc_rf_filter_curve(struct dvb_frontend *fe, | 557 | static int tda18271_calc_rf_filter_curve(struct dvb_frontend *fe) |
558 | int *tm_rfcal) | ||
559 | { | 558 | { |
560 | struct tda18271_priv *priv = fe->tuner_priv; | 559 | struct tda18271_priv *priv = fe->tuner_priv; |
561 | unsigned int i; | 560 | unsigned int i; |
@@ -572,24 +571,21 @@ static int tda18271_calc_rf_filter_curve(struct dvb_frontend *fe, | |||
572 | tda18271_rf_tracking_filters_init(fe, 1000 * | 571 | tda18271_rf_tracking_filters_init(fe, 1000 * |
573 | priv->rf_cal_state[i].rfmax); | 572 | priv->rf_cal_state[i].rfmax); |
574 | 573 | ||
575 | *tm_rfcal = tda18271_read_thermometer(fe); | 574 | priv->tm_rfcal = tda18271_read_thermometer(fe); |
576 | 575 | ||
577 | return 0; | 576 | return 0; |
578 | } | 577 | } |
579 | 578 | ||
580 | /* ------------------------------------------------------------------ */ | 579 | /* ------------------------------------------------------------------ */ |
581 | 580 | ||
582 | static int tda18271_init_cal(struct dvb_frontend *fe, int *tm) | 581 | static int tda18271_rf_cal_init(struct dvb_frontend *fe) |
583 | { | 582 | { |
584 | struct tda18271_priv *priv = fe->tuner_priv; | 583 | struct tda18271_priv *priv = fe->tuner_priv; |
585 | 584 | ||
586 | if (priv->cal_initialized) | 585 | if (priv->cal_initialized) |
587 | return 0; | 586 | return 0; |
588 | 587 | ||
589 | /* initialization */ | 588 | tda18271_calc_rf_filter_curve(fe); |
590 | tda18271_init(fe); | ||
591 | |||
592 | tda18271_calc_rf_filter_curve(fe, tm); | ||
593 | 589 | ||
594 | tda18271_por(fe); | 590 | tda18271_por(fe); |
595 | 591 | ||
@@ -598,16 +594,27 @@ static int tda18271_init_cal(struct dvb_frontend *fe, int *tm) | |||
598 | return 0; | 594 | return 0; |
599 | } | 595 | } |
600 | 596 | ||
597 | static int tda18271_init(struct dvb_frontend *fe) | ||
598 | { | ||
599 | struct tda18271_priv *priv = fe->tuner_priv; | ||
600 | |||
601 | /* initialization */ | ||
602 | tda18271_ir_cal_init(fe); | ||
603 | |||
604 | if (priv->id == TDA18271HDC2) | ||
605 | tda18271_rf_cal_init(fe); | ||
606 | |||
607 | return 0; | ||
608 | } | ||
609 | |||
601 | static int tda18271c2_tune(struct dvb_frontend *fe, | 610 | static int tda18271c2_tune(struct dvb_frontend *fe, |
602 | u32 ifc, u32 freq, u32 bw, u8 std) | 611 | u32 ifc, u32 freq, u32 bw, u8 std) |
603 | { | 612 | { |
604 | int tm = 0; | ||
605 | |||
606 | tda_dbg("freq = %d, ifc = %d\n", freq, ifc); | 613 | tda_dbg("freq = %d, ifc = %d\n", freq, ifc); |
607 | 614 | ||
608 | tda18271_init_cal(fe, &tm); | 615 | tda18271_init(fe); |
609 | 616 | ||
610 | tda18271_rf_tracking_filters_correction(fe, freq, tm); | 617 | tda18271_rf_tracking_filters_correction(fe, freq); |
611 | 618 | ||
612 | tda18271_channel_configuration(fe, ifc, freq, bw, std); | 619 | tda18271_channel_configuration(fe, ifc, freq, bw, std); |
613 | 620 | ||
diff --git a/drivers/media/dvb/frontends/tda18271-priv.h b/drivers/media/dvb/frontends/tda18271-priv.h index 6e04258ca6f9..7b06e0599dc5 100644 --- a/drivers/media/dvb/frontends/tda18271-priv.h +++ b/drivers/media/dvb/frontends/tda18271-priv.h | |||
@@ -105,6 +105,7 @@ struct tda18271_priv { | |||
105 | enum tda18271_i2c_gate gate; | 105 | enum tda18271_i2c_gate gate; |
106 | enum tda18271_ver id; | 106 | enum tda18271_ver id; |
107 | 107 | ||
108 | unsigned int tm_rfcal; | ||
108 | unsigned int cal_initialized:1; | 109 | unsigned int cal_initialized:1; |
109 | 110 | ||
110 | struct tda18271_map_layout *maps; | 111 | struct tda18271_map_layout *maps; |