diff options
author | Antti Palosaari <crope@iki.fi> | 2012-09-11 21:27:04 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2012-09-23 16:31:57 -0400 |
commit | 832cc7cdfb8ba78e03cf5c8c0ad9701ed0e20fb6 (patch) | |
tree | a4c64c9fdf4096557ead4e655c1eb153cc555b61 /drivers/media | |
parent | c2d246d1f0302fb4b390c06b73ca4f0ec6553bc6 (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')
-rw-r--r-- | drivers/media/dvb-frontends/rtl2832.c | 58 | ||||
-rw-r--r-- | drivers/media/dvb-frontends/rtl2832.h | 5 | ||||
-rw-r--r-- | drivers/media/dvb-frontends/rtl2832_priv.h | 33 | ||||
-rw-r--r-- | drivers/media/usb/dvb-usb-v2/rtl28xxu.h | 5 |
4 files changed, 63 insertions, 38 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: | |||
382 | static int rtl2832_init(struct dvb_frontend *fe) | 382 | static 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) |
diff --git a/drivers/media/dvb-frontends/rtl2832.h b/drivers/media/dvb-frontends/rtl2832.h index d94dc9a3fa62..5da0cc4a0446 100644 --- a/drivers/media/dvb-frontends/rtl2832.h +++ b/drivers/media/dvb-frontends/rtl2832.h | |||
@@ -44,11 +44,14 @@ struct rtl2832_config { | |||
44 | u32 if_dvbt; | 44 | u32 if_dvbt; |
45 | 45 | ||
46 | /* | 46 | /* |
47 | * tuner | ||
48 | * XXX: This must be keep sync with dvb_usb_rtl28xxu demod driver. | ||
47 | */ | 49 | */ |
50 | #define RTL2832_TUNER_FC0012 0x26 | ||
51 | #define RTL2832_TUNER_FC0013 0x29 | ||
48 | u8 tuner; | 52 | u8 tuner; |
49 | }; | 53 | }; |
50 | 54 | ||
51 | |||
52 | #if defined(CONFIG_DVB_RTL2832) || \ | 55 | #if defined(CONFIG_DVB_RTL2832) || \ |
53 | (defined(CONFIG_DVB_RTL2832_MODULE) && defined(MODULE)) | 56 | (defined(CONFIG_DVB_RTL2832_MODULE) && defined(MODULE)) |
54 | extern struct dvb_frontend *rtl2832_attach( | 57 | extern struct dvb_frontend *rtl2832_attach( |
diff --git a/drivers/media/dvb-frontends/rtl2832_priv.h b/drivers/media/dvb-frontends/rtl2832_priv.h index 0ce9502da8ba..65dd62a65684 100644 --- a/drivers/media/dvb-frontends/rtl2832_priv.h +++ b/drivers/media/dvb-frontends/rtl2832_priv.h | |||
@@ -257,4 +257,37 @@ enum DVBT_REG_BIT_NAME { | |||
257 | DVBT_REG_BIT_NAME_ITEM_TERMINATOR, | 257 | DVBT_REG_BIT_NAME_ITEM_TERMINATOR, |
258 | }; | 258 | }; |
259 | 259 | ||
260 | static const struct rtl2832_reg_value rtl2832_tuner_init_fc0012[] = { | ||
261 | {DVBT_DAGC_TRG_VAL, 0x5a}, | ||
262 | {DVBT_AGC_TARG_VAL_0, 0x0}, | ||
263 | {DVBT_AGC_TARG_VAL_8_1, 0x5a}, | ||
264 | {DVBT_AAGC_LOOP_GAIN, 0x16}, | ||
265 | {DVBT_LOOP_GAIN2_3_0, 0x6}, | ||
266 | {DVBT_LOOP_GAIN2_4, 0x1}, | ||
267 | {DVBT_LOOP_GAIN3, 0x16}, | ||
268 | {DVBT_VTOP1, 0x35}, | ||
269 | {DVBT_VTOP2, 0x21}, | ||
270 | {DVBT_VTOP3, 0x21}, | ||
271 | {DVBT_KRF1, 0x0}, | ||
272 | {DVBT_KRF2, 0x40}, | ||
273 | {DVBT_KRF3, 0x10}, | ||
274 | {DVBT_KRF4, 0x10}, | ||
275 | {DVBT_IF_AGC_MIN, 0x80}, | ||
276 | {DVBT_IF_AGC_MAX, 0x7f}, | ||
277 | {DVBT_RF_AGC_MIN, 0x80}, | ||
278 | {DVBT_RF_AGC_MAX, 0x7f}, | ||
279 | {DVBT_POLAR_RF_AGC, 0x0}, | ||
280 | {DVBT_POLAR_IF_AGC, 0x0}, | ||
281 | {DVBT_AD7_SETTING, 0xe9bf}, | ||
282 | {DVBT_EN_GI_PGA, 0x0}, | ||
283 | {DVBT_THD_LOCK_UP, 0x0}, | ||
284 | {DVBT_THD_LOCK_DW, 0x0}, | ||
285 | {DVBT_THD_UP1, 0x11}, | ||
286 | {DVBT_THD_DW1, 0xef}, | ||
287 | {DVBT_INTER_CNT_LEN, 0xc}, | ||
288 | {DVBT_GI_PGA_STATE, 0x0}, | ||
289 | {DVBT_EN_AGC_PGA, 0x1}, | ||
290 | {DVBT_IF_AGC_MAN, 0x0}, | ||
291 | }; | ||
292 | |||
260 | #endif /* RTL2832_PRIV_H */ | 293 | #endif /* RTL2832_PRIV_H */ |
diff --git a/drivers/media/usb/dvb-usb-v2/rtl28xxu.h b/drivers/media/usb/dvb-usb-v2/rtl28xxu.h index 035a9c890ce5..c6c8a4fe0b32 100644 --- a/drivers/media/usb/dvb-usb-v2/rtl28xxu.h +++ b/drivers/media/usb/dvb-usb-v2/rtl28xxu.h | |||
@@ -63,14 +63,15 @@ enum rtl28xxu_chip_id { | |||
63 | CHIP_ID_RTL2832U, | 63 | CHIP_ID_RTL2832U, |
64 | }; | 64 | }; |
65 | 65 | ||
66 | /* XXX: Hack. This must be keep sync with rtl2832 demod driver. */ | ||
66 | enum rtl28xxu_tuner { | 67 | enum rtl28xxu_tuner { |
67 | TUNER_NONE, | 68 | TUNER_NONE, |
68 | 69 | ||
69 | TUNER_RTL2830_QT1010, | 70 | TUNER_RTL2830_QT1010 = 0x10, |
70 | TUNER_RTL2830_MT2060, | 71 | TUNER_RTL2830_MT2060, |
71 | TUNER_RTL2830_MXL5005S, | 72 | TUNER_RTL2830_MXL5005S, |
72 | 73 | ||
73 | TUNER_RTL2832_MT2266, | 74 | TUNER_RTL2832_MT2266 = 0x20, |
74 | TUNER_RTL2832_FC2580, | 75 | TUNER_RTL2832_FC2580, |
75 | TUNER_RTL2832_MT2063, | 76 | TUNER_RTL2832_MT2063, |
76 | TUNER_RTL2832_MAX3543, | 77 | TUNER_RTL2832_MAX3543, |