diff options
author | Florian Schirmer <devnull@localhost> | 2003-01-28 22:57:57 +0000 |
---|---|---|
committer | Florian Schirmer <devnull@localhost> | 2003-01-28 22:57:57 +0000 |
commit | e95fe489b5c7266afde9bf223dd26621a8e4eeba (patch) | |
tree | 2534f5b5f51016de685608f86f2d5490dd442572 /linux/drivers/media/dvb/frontends/nxt6000.c | |
parent | ee79ec2d099201f693a5fac14995c064e3a97712 (diff) | |
download | mediapointer-dvb-s2-e95fe489b5c7266afde9bf223dd26621a8e4eeba.tar.gz mediapointer-dvb-s2-e95fe489b5c7266afde9bf223dd26621a8e4eeba.tar.bz2 |
- Removed some debug stuff
- Bugfixes
- Setup clock polarity properly
Diffstat (limited to 'linux/drivers/media/dvb/frontends/nxt6000.c')
-rw-r--r-- | linux/drivers/media/dvb/frontends/nxt6000.c | 109 |
1 files changed, 59 insertions, 50 deletions
diff --git a/linux/drivers/media/dvb/frontends/nxt6000.c b/linux/drivers/media/dvb/frontends/nxt6000.c index c6b46a943..8e31721de 100644 --- a/linux/drivers/media/dvb/frontends/nxt6000.c +++ b/linux/drivers/media/dvb/frontends/nxt6000.c @@ -36,9 +36,12 @@ #include "dvb_frontend.h" #include "nxt6000.h" +static int debug = 0; + MODULE_DESCRIPTION("NxtWave NXT6000 DVB demodulator driver"); MODULE_AUTHOR("Florian Schirmer"); MODULE_LICENSE("GPL"); +MODULE_PARM(debug, "i"); static struct dvb_frontend_info nxt6000_info = { @@ -69,15 +72,19 @@ struct nxt6000_config { u8 demod_addr; u8 tuner_addr; u8 tuner_type; - u8 reserved; + u8 clock_inversion; }; #pragma pack() +#define TUNER_TYPE_ALP510 0 +#define TUNER_TYPE_SP5659 1 + #define FE2NXT(fe) ((struct nxt6000_config *)&(fe->data)) #define FREQ2DIV(freq) ((freq + 36166667) / 166667) +#define dprintk if (debug) printk static int nxt6000_write(struct dvb_i2c_bus *i2c, u8 addr, u8 reg, u8 data) { @@ -87,7 +94,7 @@ static int nxt6000_write(struct dvb_i2c_bus *i2c, u8 addr, u8 reg, u8 data) int ret; if ((ret = i2c->xfer(i2c, &msg, 1)) != 1) - printk("nxt6000: nxt6000_write error (addr: 0x%02X, reg: 0x%02X, data: 0x%02X, ret: %d)\n", addr, reg, data, ret); + dprintk("nxt6000: nxt6000_write error (addr: 0x%02X, reg: 0x%02X, data: 0x%02X, ret: %d)\n", addr, reg, data, ret); return (ret != 1) ? -EFAULT : 0; @@ -114,7 +121,7 @@ static u8 nxt6000_read(struct dvb_i2c_bus *i2c, u8 addr, u8 reg) ret = i2c->xfer(i2c, msgs, 2); if (ret != 2) - printk("nxt6000: nxt6000_read error (addr: 0x%02X, reg: 0x%02X, ret: %d)\n", addr, reg, ret); + dprintk("nxt6000: nxt6000_read error (addr: 0x%02X, reg: 0x%02X, ret: %d)\n", addr, reg, ret); return b1[0]; @@ -140,7 +147,7 @@ static int pll_write(struct dvb_i2c_bus *i2c, u8 demod_addr, u8 tuner_addr, u8 * nxt6000_write(i2c, demod_addr, ENABLE_TUNER_IIC, 0x00); /* close i2c bus switch */ if (ret != 1) - printk("nxt6000: pll_write error %d\n", ret); + dprintk("nxt6000: pll_write error %d\n", ret); return (ret != 1) ? -EFAULT : 0; @@ -342,25 +349,31 @@ static int nxt6000_set_transmission_mode(struct dvb_frontend *fe, fe_transmit_mo static void nxt6000_setup(struct dvb_frontend *fe) { + struct nxt6000_config *nxt = FE2NXT(fe); + nxt6000_writereg(fe, RS_COR_SYNC_PARAM, SYNC_PARAM); nxt6000_writereg(fe, BER_CTRL, /*(1 << 2) |*/ (0x01 << 1) | 0x01); nxt6000_writereg(fe, VIT_COR_CTL, VIT_COR_RESYNC); nxt6000_writereg(fe, OFDM_COR_CTL, (0x01 << 5) | (nxt6000_readreg(fe, OFDM_COR_CTL) & 0x0F)); nxt6000_writereg(fe, OFDM_COR_MODEGUARD, FORCEMODE8K | 0x02); - nxt6000_writereg(fe, OFDM_AGC_CTL, AGCLAST | INITIAL_AGC_BW); // CHECKME + nxt6000_writereg(fe, OFDM_AGC_CTL, AGCLAST | INITIAL_AGC_BW); nxt6000_writereg(fe, OFDM_ITB_FREQ_1, 0x06); nxt6000_writereg(fe, OFDM_ITB_FREQ_2, 0x31); nxt6000_writereg(fe, OFDM_CAS_CTL, (0x01 << 7) | (0x02 << 3) | 0x04); nxt6000_writereg(fe, CAS_FREQ, 0xBB); // CHECKME nxt6000_writereg(fe, OFDM_SYR_CTL, 1 << 2); nxt6000_writereg(fe, OFDM_PPM_CTL_1, PPM256); - nxt6000_writereg(fe, OFDM_TRL_NOMINALRATE_1, 0x49); // Hardcoded for 8MHz (fixme) - nxt6000_writereg(fe, OFDM_TRL_NOMINALRATE_2, 0x72); // Hardcoded for 8MHz (fixme) + nxt6000_writereg(fe, OFDM_TRL_NOMINALRATE_1, 0x49); + nxt6000_writereg(fe, OFDM_TRL_NOMINALRATE_2, 0x72); nxt6000_writereg(fe, ANALOG_CONTROL_0, 1 << 5); nxt6000_writereg(fe, EN_DMD_RACQ, (1 << 7) | (3 << 4) | 2); nxt6000_writereg(fe, DIAG_CONFIG, TB_SET); -// nxt6000_writereg(fe, SUB_DIAG_MODE_SEL, 0); - nxt6000_writereg(fe, SUB_DIAG_MODE_SEL, CLKINVERSION); + + if (nxt->clock_inversion) + nxt6000_writereg(fe, SUB_DIAG_MODE_SEL, CLKINVERSION); + else + nxt6000_writereg(fe, SUB_DIAG_MODE_SEL, 0); + nxt6000_writereg(fe, TS_FORMAT, 0); } @@ -650,8 +663,6 @@ static int nxt6000_ioctl(struct dvb_frontend *fe, unsigned int cmd, void *arg) u8 core_status; - nxt6000_dump_status(fe); - *status = 0; core_status = nxt6000_readreg(fe, OFDM_COR_STAT); @@ -670,6 +681,9 @@ static int nxt6000_ioctl(struct dvb_frontend *fe, unsigned int cmd, void *arg) if ((core_status & TPSLOCKED) && (*status == (FE_HAS_SIGNAL | FE_HAS_CARRIER | FE_HAS_VITERBI | FE_HAS_SYNC))) *status |= FE_HAS_LOCK; + + if (debug) + nxt6000_dump_status(fe); return 0; @@ -720,34 +734,35 @@ static int nxt6000_ioctl(struct dvb_frontend *fe, unsigned int cmd, void *arg) nxt6000_reset(fe); nxt6000_setup(fe); -// alp510_set_tv_freq(fe, 177500000); // OK -// alp510_set_tv_freq(fe, 602000000); // NOK - alp510_set_tv_freq(fe, 650000000); // NOK -// alp510_set_tv_freq(fe, 658000000); // NOK - alp510_set_tv_freq(fe, 778000000); // OK - - nxt6000_set_bandwidth(fe, BANDWIDTH_8_MHZ); - nxt6000_set_guard_interval(fe, GUARD_INTERVAL_1_8); - nxt6000_set_transmission_mode(fe, TRANSMISSION_MODE_8K); -// nxt6000_set_transmission_mode(fe, TRANSMISSION_MODE_2K); - nxt6000_set_inversion(fe, INVERSION_OFF); -// nxt6000_set_inversion(fe, INVERSION_ON); - - nxt6000_reset(fe); - - nxt6000_dump_status(fe); - break; case FE_SET_FRONTEND: { + struct nxt6000_config *nxt = FE2NXT(fe); struct dvb_frontend_parameters *param = (struct dvb_frontend_parameters *)arg; int result; - printk("nxt6000: params: fre=%d inv=%d\n", param->frequency, param->inversion); + switch(nxt->tuner_type) { + + case TUNER_TYPE_ALP510: + + if ((result = alp510_set_tv_freq(fe, param->frequency)) < 0) + return result; + + break; - if ((result = alp510_set_tv_freq(fe, param->frequency)) < 0) - return result; + case TUNER_TYPE_SP5659: + + if ((result = sp5659_set_tv_freq(fe, param->frequency)) < 0) + return result; + + break; + + default: + + return -EFAULT; + + } if ((result = nxt6000_set_bandwidth(fe, param->u.ofdm.bandwidth)) < 0) return result; @@ -758,10 +773,6 @@ static int nxt6000_ioctl(struct dvb_frontend *fe, unsigned int cmd, void *arg) if ((result = nxt6000_set_inversion(fe, param->inversion)) < 0) return result; - printk("nxt6000: param check ok\n"); - - nxt6000_reset(fe); - break; } @@ -783,10 +794,8 @@ static int nxt6000_attach(struct dvb_i2c_bus *i2c) u8 addr_nr; u8 fe_count = 0; struct nxt6000_config nxt; - u8 tuner_addr; - u8 tuner_type; - printk("nxt6000: attach\n"); + dprintk("nxt6000: attach\n"); for (addr_nr = 0; addr_nr < sizeof(demod_addr_tbl); addr_nr++) { @@ -795,17 +804,19 @@ static int nxt6000_attach(struct dvb_i2c_bus *i2c) if (pll_write(i2c, demod_addr_tbl[addr_nr], 0xC0, NULL, 0) == 0) { - tuner_addr = 0xC0; - tuner_type = 1; + nxt.tuner_addr = 0xC0; + nxt.tuner_type = TUNER_TYPE_ALP510; + nxt.clock_inversion = 1; - printk("nxt6000: detected TI ALP510 tuner at 0x%02X\n", tuner_addr); + dprintk("nxt6000: detected TI ALP510 tuner at 0x%02X\n", nxt.tuner_addr); } else if (pll_write(i2c, demod_addr_tbl[addr_nr], 0xC2, NULL, 0) == 0) { - tuner_addr = 0xC0; - tuner_type = 2; + nxt.tuner_addr = 0xC2; + nxt.tuner_type = TUNER_TYPE_SP5659; + nxt.clock_inversion = 0; - printk("nxt6000: detected MITEL SP5659 tuner at 0x%02X\n", tuner_addr); + dprintk("nxt6000: detected MITEL SP5659 tuner at 0x%02X\n", nxt.tuner_addr); } else { @@ -816,10 +827,8 @@ static int nxt6000_attach(struct dvb_i2c_bus *i2c) } nxt.demod_addr = demod_addr_tbl[addr_nr]; - nxt.tuner_addr = tuner_addr; - nxt.tuner_type = tuner_type; - printk("nxt6000: attached at %d:%d\n", i2c->adapter->num, i2c->id); + dprintk("nxt6000: attached at %d:%d\n", i2c->adapter->num, i2c->id); dvb_register_frontend(nxt6000_ioctl, i2c, (void *)(*((u32 *)&nxt)), &nxt6000_info); @@ -832,7 +841,7 @@ static int nxt6000_attach(struct dvb_i2c_bus *i2c) static void nxt6000_detach(struct dvb_i2c_bus *i2c) { - printk("nxt6000: detach\n"); + dprintk("nxt6000: detach\n"); dvb_unregister_frontend(nxt6000_ioctl, i2c); @@ -841,7 +850,7 @@ static void nxt6000_detach(struct dvb_i2c_bus *i2c) static __init int nxt6000_init(void) { - printk("nxt6000: init\n"); + dprintk("nxt6000: init\n"); return dvb_register_i2c_device(THIS_MODULE, nxt6000_attach, nxt6000_detach); @@ -850,7 +859,7 @@ static __init int nxt6000_init(void) static __exit void nxt6000_exit(void) { - printk("nxt6000: cleanup\n"); + dprintk("nxt6000: cleanup\n"); dvb_unregister_i2c_device(nxt6000_attach); |