aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/dvb-frontends/rtl2832.c
diff options
context:
space:
mode:
authorAntti Palosaari <crope@iki.fi>2012-09-11 21:27:04 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2012-09-23 16:31:57 -0400
commit832cc7cdfb8ba78e03cf5c8c0ad9701ed0e20fb6 (patch)
treea4c64c9fdf4096557ead4e655c1eb153cc555b61 /drivers/media/dvb-frontends/rtl2832.c
parentc2d246d1f0302fb4b390c06b73ca4f0ec6553bc6 (diff)
[media] rtl2832: separate tuner specific init from general
It is first step closer to support multiple tuners. Signed-off-by: Antti Palosaari <crope@iki.fi> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/dvb-frontends/rtl2832.c')
-rw-r--r--drivers/media/dvb-frontends/rtl2832.c58
1 files changed, 23 insertions, 35 deletions
diff --git a/drivers/media/dvb-frontends/rtl2832.c b/drivers/media/dvb-frontends/rtl2832.c
index 4d40b4f42a1f..d670fe76860d 100644
--- a/drivers/media/dvb-frontends/rtl2832.c
+++ b/drivers/media/dvb-frontends/rtl2832.c
@@ -382,10 +382,10 @@ err:
382static int rtl2832_init(struct dvb_frontend *fe) 382static int rtl2832_init(struct dvb_frontend *fe)
383{ 383{
384 struct rtl2832_priv *priv = fe->demodulator_priv; 384 struct rtl2832_priv *priv = fe->demodulator_priv;
385 int i, ret; 385 int i, ret, len;
386
387 u8 en_bbin; 386 u8 en_bbin;
388 u64 pset_iffreq; 387 u64 pset_iffreq;
388 const struct rtl2832_reg_value *init;
389 389
390 /* initialization values for the demodulator registers */ 390 /* initialization values for the demodulator registers */
391 struct rtl2832_reg_value rtl2832_initial_regs[] = { 391 struct rtl2832_reg_value rtl2832_initial_regs[] = {
@@ -432,39 +432,8 @@ static int rtl2832_init(struct dvb_frontend *fe)
432 {DVBT_TRK_KC_I2, 0x5}, 432 {DVBT_TRK_KC_I2, 0x5},
433 {DVBT_CR_THD_SET2, 0x1}, 433 {DVBT_CR_THD_SET2, 0x1},
434 {DVBT_SPEC_INV, 0x0}, 434 {DVBT_SPEC_INV, 0x0},
435 {DVBT_DAGC_TRG_VAL, 0x5a},
436 {DVBT_AGC_TARG_VAL_0, 0x0},
437 {DVBT_AGC_TARG_VAL_8_1, 0x5a},
438 {DVBT_AAGC_LOOP_GAIN, 0x16},
439 {DVBT_LOOP_GAIN2_3_0, 0x6},
440 {DVBT_LOOP_GAIN2_4, 0x1},
441 {DVBT_LOOP_GAIN3, 0x16},
442 {DVBT_VTOP1, 0x35},
443 {DVBT_VTOP2, 0x21},
444 {DVBT_VTOP3, 0x21},
445 {DVBT_KRF1, 0x0},
446 {DVBT_KRF2, 0x40},
447 {DVBT_KRF3, 0x10},
448 {DVBT_KRF4, 0x10},
449 {DVBT_IF_AGC_MIN, 0x80},
450 {DVBT_IF_AGC_MAX, 0x7f},
451 {DVBT_RF_AGC_MIN, 0x80},
452 {DVBT_RF_AGC_MAX, 0x7f},
453 {DVBT_POLAR_RF_AGC, 0x0},
454 {DVBT_POLAR_IF_AGC, 0x0},
455 {DVBT_AD7_SETTING, 0xe9bf},
456 {DVBT_EN_GI_PGA, 0x0},
457 {DVBT_THD_LOCK_UP, 0x0},
458 {DVBT_THD_LOCK_DW, 0x0},
459 {DVBT_THD_UP1, 0x11},
460 {DVBT_THD_DW1, 0xef},
461 {DVBT_INTER_CNT_LEN, 0xc},
462 {DVBT_GI_PGA_STATE, 0x0},
463 {DVBT_EN_AGC_PGA, 0x1},
464 {DVBT_IF_AGC_MAN, 0x0},
465 }; 435 };
466 436
467
468 dbg("%s", __func__); 437 dbg("%s", __func__);
469 438
470 en_bbin = (priv->cfg.if_dvbt == 0 ? 0x1 : 0x0); 439 en_bbin = (priv->cfg.if_dvbt == 0 ? 0x1 : 0x0);
@@ -478,8 +447,6 @@ static int rtl2832_init(struct dvb_frontend *fe)
478 pset_iffreq = div_u64(pset_iffreq, priv->cfg.xtal); 447 pset_iffreq = div_u64(pset_iffreq, priv->cfg.xtal);
479 pset_iffreq = pset_iffreq & 0x3fffff; 448 pset_iffreq = pset_iffreq & 0x3fffff;
480 449
481
482
483 for (i = 0; i < ARRAY_SIZE(rtl2832_initial_regs); i++) { 450 for (i = 0; i < ARRAY_SIZE(rtl2832_initial_regs); i++) {
484 ret = rtl2832_wr_demod_reg(priv, rtl2832_initial_regs[i].reg, 451 ret = rtl2832_wr_demod_reg(priv, rtl2832_initial_regs[i].reg,
485 rtl2832_initial_regs[i].value); 452 rtl2832_initial_regs[i].value);
@@ -487,6 +454,27 @@ static int rtl2832_init(struct dvb_frontend *fe)
487 goto err; 454 goto err;
488 } 455 }
489 456
457 /* load tuner specific settings */
458 dbg("%s: load settings for tuner=%02x", __func__, priv->cfg.tuner);
459 switch (priv->cfg.tuner) {
460 case RTL2832_TUNER_FC0012:
461 case RTL2832_TUNER_FC0013:
462 len = ARRAY_SIZE(rtl2832_tuner_init_fc0012);
463 init = rtl2832_tuner_init_fc0012;
464 break;
465 default:
466 ret = -EINVAL;
467 goto err;
468 }
469
470 for (i = 0; i < len; i++) {
471 ret = rtl2832_wr_demod_reg(priv,
472 rtl2832_tuner_init_fc0012[i].reg,
473 rtl2832_tuner_init_fc0012[i].value);
474 if (ret)
475 goto err;
476 }
477
490 /* if frequency settings */ 478 /* if frequency settings */
491 ret = rtl2832_wr_demod_reg(priv, DVBT_EN_BBIN, en_bbin); 479 ret = rtl2832_wr_demod_reg(priv, DVBT_EN_BBIN, en_bbin);
492 if (ret) 480 if (ret)