From 540fd4ba053356cca91429cf4f6bf25fabd2984a Mon Sep 17 00:00:00 2001 From: Hans-Frieder Vogt Date: Mon, 2 Apr 2012 14:18:16 -0300 Subject: [media] af9035: add Avermedia Volar HD (A867R) support Support of AVerMedia AVerTV HD Volar, with tuner MxL5007t. Signed-off-by: Hans-Frieder Vogt Signed-off-by: Antti Palosaari Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb/frontends/af9033.c | 41 ++++++++++++++++++++++++------- drivers/media/dvb/frontends/af9033.h | 1 + drivers/media/dvb/frontends/af9033_priv.h | 35 ++++++++++++++++++++++++++ 3 files changed, 68 insertions(+), 9 deletions(-) (limited to 'drivers/media/dvb/frontends') diff --git a/drivers/media/dvb/frontends/af9033.c b/drivers/media/dvb/frontends/af9033.c index 9eedf93c6384..8c0f4a3ef0f0 100644 --- a/drivers/media/dvb/frontends/af9033.c +++ b/drivers/media/dvb/frontends/af9033.c @@ -301,6 +301,10 @@ static int af9033_init(struct dvb_frontend *fe) len = ARRAY_SIZE(tuner_init_fc0011); init = tuner_init_fc0011; break; + case AF9033_TUNER_MXL5007T: + len = ARRAY_SIZE(tuner_init_mxl5007t); + init = tuner_init_mxl5007t; + break; default: pr_debug("%s: unsupported tuner ID=%d\n", __func__, state->cfg.tuner); @@ -391,9 +395,9 @@ static int af9033_set_frontend(struct dvb_frontend *fe) { struct af9033_state *state = fe->demodulator_priv; struct dtv_frontend_properties *c = &fe->dtv_property_cache; - int ret, i; + int ret, i, spec_inv; u8 tmp, buf[3], bandwidth_reg_val; - u32 if_frequency, freq_cw; + u32 if_frequency, freq_cw, adc_freq; pr_debug("%s: frequency=%d bandwidth_hz=%d\n", __func__, c->frequency, c->bandwidth_hz); @@ -433,22 +437,41 @@ static int af9033_set_frontend(struct dvb_frontend *fe) /* program frequency control */ if (c->bandwidth_hz != state->bandwidth_hz) { + spec_inv = state->cfg.spec_inv ? -1 : 1; + + for (i = 0; i < ARRAY_SIZE(clock_adc_lut); i++) { + if (clock_adc_lut[i].clock == state->cfg.clock) + break; + } + adc_freq = clock_adc_lut[i].adc; + /* get used IF frequency */ if (fe->ops.tuner_ops.get_if_frequency) fe->ops.tuner_ops.get_if_frequency(fe, &if_frequency); else if_frequency = 0; - /* FIXME: we support only Zero-IF currently */ - if (if_frequency != 0) { - pr_debug("%s: only Zero-IF supported currently\n", - __func__); + while (if_frequency > (adc_freq / 2)) + if_frequency -= adc_freq; - ret = -ENODEV; + if (if_frequency >= 0) + spec_inv *= -1; + else + if_frequency *= -1; + + freq_cw = af9033_div(if_frequency, adc_freq, 23ul); + + if (spec_inv == -1) + freq_cw *= -1; + + /* get adc multiplies */ + ret = af9033_rd_reg(state, 0x800045, &tmp); + if (ret < 0) goto err; - } - freq_cw = 0; + if (tmp == 1) + freq_cw /= 2; + buf[0] = (freq_cw >> 0) & 0xff; buf[1] = (freq_cw >> 8) & 0xff; buf[2] = (freq_cw >> 16) & 0x7f; diff --git a/drivers/media/dvb/frontends/af9033.h b/drivers/media/dvb/frontends/af9033.h index af8c1e3e30d0..dcf7e290b6fe 100644 --- a/drivers/media/dvb/frontends/af9033.h +++ b/drivers/media/dvb/frontends/af9033.h @@ -40,6 +40,7 @@ struct af9033_config { */ #define AF9033_TUNER_TUA9001 0x27 /* Infineon TUA 9001 */ #define AF9033_TUNER_FC0011 0x28 /* Fitipower FC0011 */ +#define AF9033_TUNER_MXL5007T 0xa0 /* MaxLinear MxL5007T */ u8 tuner; /* diff --git a/drivers/media/dvb/frontends/af9033_priv.h b/drivers/media/dvb/frontends/af9033_priv.h index 337964257dab..e6041bc7c2fc 100644 --- a/drivers/media/dvb/frontends/af9033_priv.h +++ b/drivers/media/dvb/frontends/af9033_priv.h @@ -397,5 +397,40 @@ static const struct reg_val tuner_init_fc0011[] = { { 0x80F1E6, 0x00 }, }; +/* MaxLinear MxL5007T tuner init + AF9033_TUNER_MXL5007T = 0xa0 */ +static const struct reg_val tuner_init_mxl5007t[] = { + { 0x800046, 0x1b }, + { 0x800057, 0x01 }, + { 0x800058, 0x01 }, + { 0x80005f, 0x00 }, + { 0x800060, 0x00 }, + { 0x800068, 0x96 }, + { 0x800071, 0x05 }, + { 0x800072, 0x02 }, + { 0x800074, 0x01 }, + { 0x800079, 0x01 }, + { 0x800093, 0x00 }, + { 0x800094, 0x00 }, + { 0x800095, 0x00 }, + { 0x800096, 0x00 }, + { 0x8000b3, 0x01 }, + { 0x8000c1, 0x01 }, + { 0x8000c2, 0x00 }, + { 0x80f007, 0x00 }, + { 0x80f00c, 0x19 }, + { 0x80f00d, 0x1a }, + { 0x80f012, 0xda }, + { 0x80f013, 0x00 }, + { 0x80f014, 0x00 }, + { 0x80f015, 0x02 }, + { 0x80f01f, 0x82 }, + { 0x80f020, 0x00 }, + { 0x80f029, 0x82 }, + { 0x80f02a, 0x00 }, + { 0x80f077, 0x02 }, + { 0x80f1e6, 0x00 }, +}; + #endif /* AF9033_PRIV_H */ -- cgit v1.2.2