diff options
-rw-r--r-- | linux/drivers/media/dvb/frontends/mt312.c | 82 | ||||
-rw-r--r-- | linux/drivers/media/dvb/frontends/mt312.h | 2 |
2 files changed, 64 insertions, 20 deletions
diff --git a/linux/drivers/media/dvb/frontends/mt312.c b/linux/drivers/media/dvb/frontends/mt312.c index 6033a879c..218869da0 100644 --- a/linux/drivers/media/dvb/frontends/mt312.c +++ b/linux/drivers/media/dvb/frontends/mt312.c @@ -34,6 +34,7 @@ #define I2C_ADDR_MT312 0x0e #define I2C_ADDR_SL1935 0x61 +#define I2C_ADDR_TSA5059 0x61 #define MT312_DEBUG 0 @@ -131,7 +132,7 @@ static int mt312_write(struct dvb_i2c_bus *i2c, } static inline int mt312_readreg(struct dvb_i2c_bus *i2c, - const enum mt312_reg_addr reg, u8 * val) + const enum mt312_reg_addr reg, u8 *val) { return mt312_read(i2c, reg, val, 1); } @@ -207,18 +208,50 @@ static int sl1935_set_tv_freq(struct dvb_i2c_bus *i2c, u32 freq, u32 sr) return mt312_pll_write(i2c, I2C_ADDR_SL1935, buf, sizeof(buf)); } +static int tsa5059_set_tv_freq(struct dvb_i2c_bus *i2c, u32 freq, u32 sr) +{ + u8 buf[4]; + + u32 ref = mt312_div(freq, 125); + + buf[0] = (ref >> 8) & 0x7f; + buf[1] = (ref >> 0) & 0xff; + buf[2] = 0x84 | ((ref >> 10) & 0x60); + buf[3] = 0x80; + + if (freq < 1550000) + buf[3] |= 0x02; + + printk(KERN_INFO "synth dword = %02x%02x%02x%02x\n", buf[0], + buf[1], buf[2], buf[3]); + + return mt312_pll_write(i2c, I2C_ADDR_TSA5059, buf, sizeof(buf)); +} + static int mt312_reset(struct dvb_i2c_bus *i2c, const u8 full) { return mt312_writereg(i2c, RESET, full ? 0x80 : 0x40); } -static int mt312_init(struct dvb_i2c_bus *i2c) +static int mt312_init(struct dvb_i2c_bus *i2c, const long id) { int ret; u8 buf[2]; + u8 config; + + switch (id) { + case ID_VP310: + config = 0x88; + break; + case ID_MT312: + config = 0x8c; + break; + default: + return -EINVAL; + } /* wake up */ - if ((ret = mt312_writereg(i2c, CONFIG, 0x8c)) < 0) + if ((ret = mt312_writereg(i2c, CONFIG, config)) < 0) return ret; /* wait at least 150 usec */ @@ -343,7 +376,7 @@ static int mt312_set_voltage(struct dvb_i2c_bus *i2c, const fe_sec_voltage_t v) return mt312_writereg(i2c, DISEQC_MODE, volt_tab[v]); } -static int mt312_read_status(struct dvb_i2c_bus *i2c, fe_status_t * s) +static int mt312_read_status(struct dvb_i2c_bus *i2c, fe_status_t *s) { int ret; u8 status[3]; @@ -367,7 +400,7 @@ static int mt312_read_status(struct dvb_i2c_bus *i2c, fe_status_t * s) return 0; } -static int mt312_read_bercnt(struct dvb_i2c_bus *i2c, u32 * ber) +static int mt312_read_bercnt(struct dvb_i2c_bus *i2c, u32 *ber) { int ret; u8 buf[3]; @@ -380,7 +413,7 @@ static int mt312_read_bercnt(struct dvb_i2c_bus *i2c, u32 * ber) return 0; } -static int mt312_read_agc(struct dvb_i2c_bus *i2c, u16 * signal_strength) +static int mt312_read_agc(struct dvb_i2c_bus *i2c, u16 *signal_strength) { int ret; u8 buf[3]; @@ -400,7 +433,7 @@ static int mt312_read_agc(struct dvb_i2c_bus *i2c, u16 * signal_strength) return 0; } -static int mt312_read_snr(struct dvb_i2c_bus *i2c, u16 * snr) +static int mt312_read_snr(struct dvb_i2c_bus *i2c, u16 *snr) { int ret; u8 buf[2]; @@ -413,7 +446,7 @@ static int mt312_read_snr(struct dvb_i2c_bus *i2c, u16 * snr) return 0; } -static int mt312_read_ubc(struct dvb_i2c_bus *i2c, u32 * ubc) +static int mt312_read_ubc(struct dvb_i2c_bus *i2c, u32 *ubc) { int ret; u8 buf[2]; @@ -427,7 +460,8 @@ static int mt312_read_ubc(struct dvb_i2c_bus *i2c, u32 * ubc) } static int mt312_set_frontend(struct dvb_i2c_bus *i2c, - const struct dvb_frontend_parameters *p) + const struct dvb_frontend_parameters *p, + const long id) { int ret; u8 buf[5]; @@ -437,6 +471,8 @@ static int mt312_set_frontend(struct dvb_i2c_bus *i2c, { 0x00, 0x01, 0x02, 0x04, 0x3f, 0x08, 0x10, 0x20, 0x3f, 0x3f }; const u8 inv_tab[3] = { 0x00, 0x40, 0x80 }; + int (*set_tv_freq)(struct dvb_i2c_bus *i2c, u32 freq, u32 sr); + if ((p->frequency < mt312_info.frequency_min) || (p->frequency > mt312_info.frequency_max)) return -EINVAL; @@ -457,8 +493,18 @@ static int mt312_set_frontend(struct dvb_i2c_bus *i2c, || (p->u.qpsk.fec_inner == FEC_8_9)) return -EINVAL; - if ((ret = - sl1935_set_tv_freq(i2c, p->frequency, p->u.qpsk.symbol_rate)) < 0) + switch (id) { + case ID_VP310: + set_tv_freq = tsa5059_set_tv_freq; + break; + case ID_MT312: + set_tv_freq = sl1935_set_tv_freq; + break; + default: + return -EINVAL; + } + + if ((ret = set_tv_freq(i2c, p->frequency, p->u.qpsk.symbol_rate)) < 0) return ret; /* sr = (u16)(sr * 256.0 / 1000000.0) */ @@ -487,7 +533,7 @@ static int mt312_set_frontend(struct dvb_i2c_bus *i2c, } static int mt312_get_inversion(struct dvb_i2c_bus *i2c, - fe_spectral_inversion_t * i) + fe_spectral_inversion_t *i) { int ret; u8 vit_mode; @@ -501,7 +547,7 @@ static int mt312_get_inversion(struct dvb_i2c_bus *i2c, return 0; } -static int mt312_get_symbol_rate(struct dvb_i2c_bus *i2c, u32 * sr) +static int mt312_get_symbol_rate(struct dvb_i2c_bus *i2c, u32 *sr) { int ret; u8 sym_rate_h; @@ -548,13 +594,11 @@ static int mt312_get_symbol_rate(struct dvb_i2c_bus *i2c, u32 * sr) return 0; } -static int mt312_get_code_rate(struct dvb_i2c_bus *i2c, fe_code_rate_t * cr) +static int mt312_get_code_rate(struct dvb_i2c_bus *i2c, fe_code_rate_t *cr) { const fe_code_rate_t fec_tab[8] = { FEC_1_2, FEC_2_3, FEC_3_4, FEC_5_6, FEC_6_7, FEC_7_8, - FEC_AUTO, - FEC_AUTO - }; + FEC_AUTO, FEC_AUTO }; int ret; u8 fec_status; @@ -652,7 +696,7 @@ static int mt312_ioctl(struct dvb_frontend *fe, unsigned int cmd, void *arg) return mt312_read_ubc(i2c, arg); case FE_SET_FRONTEND: - return mt312_set_frontend(i2c, arg); + return mt312_set_frontend(i2c, arg, (long) fe->data); case FE_GET_FRONTEND: return mt312_get_frontend(i2c, arg); @@ -664,7 +708,7 @@ static int mt312_ioctl(struct dvb_frontend *fe, unsigned int cmd, void *arg) return mt312_sleep(i2c); case FE_INIT: - return mt312_init(i2c); + return mt312_init(i2c, (long) fe->data); case FE_RESET: return mt312_reset(i2c, 0); diff --git a/linux/drivers/media/dvb/frontends/mt312.h b/linux/drivers/media/dvb/frontends/mt312.h index a0d0b153e..dd24b184e 100644 --- a/linux/drivers/media/dvb/frontends/mt312.h +++ b/linux/drivers/media/dvb/frontends/mt312.h @@ -23,7 +23,7 @@ #ifndef _DVB_FRONTENDS_MT312 #define _DVB_FRONTENDS_MT312 -typedef enum mt312_reg_addr { +enum mt312_reg_addr { QPSK_INT_H = 0, QPSK_INT_M = 1, QPSK_INT_L = 2, |