diff options
author | Florian Schirmer <devnull@localhost> | 2003-01-27 12:32:42 +0000 |
---|---|---|
committer | Florian Schirmer <devnull@localhost> | 2003-01-27 12:32:42 +0000 |
commit | b2ef05a28fa6389d764f88fdd64ad2f6c2952d79 (patch) | |
tree | 2b2f0a1bd023f813b5620d48625164d4bb5f740c /linux/drivers/media/dvb/frontends/nxt6000.c | |
parent | 0edc076629716ec567c3de5b922f880b5c0fd459 (diff) | |
download | mediapointer-dvb-s2-b2ef05a28fa6389d764f88fdd64ad2f6c2952d79.tar.gz mediapointer-dvb-s2-b2ef05a28fa6389d764f88fdd64ad2f6c2952d79.tar.bz2 |
Lots of bugfixes and new features
Diffstat (limited to 'linux/drivers/media/dvb/frontends/nxt6000.c')
-rw-r--r-- | linux/drivers/media/dvb/frontends/nxt6000.c | 442 |
1 files changed, 393 insertions, 49 deletions
diff --git a/linux/drivers/media/dvb/frontends/nxt6000.c b/linux/drivers/media/dvb/frontends/nxt6000.c index 984f065f7..5822f262d 100644 --- a/linux/drivers/media/dvb/frontends/nxt6000.c +++ b/linux/drivers/media/dvb/frontends/nxt6000.c @@ -67,7 +67,7 @@ static int nxt6000_writereg(struct dvb_i2c_bus *i2c, u8 reg, u8 data) { u8 buf[] = {reg, data}; - struct i2c_msg msg = {addr: 0x14 >> 1, flags: 0, buf: buf, len: 2}; + struct i2c_msg msg = {addr: 0x18 >> 1, flags: 0, buf: buf, len: 2}; int ret; if ((ret = i2c->xfer(i2c, &msg, 1)) != 1) @@ -83,8 +83,8 @@ static u8 nxt6000_readreg(struct dvb_i2c_bus *i2c, u8 reg) u8 b0[] = {reg}; u8 b1[] = {0}; - struct i2c_msg msgs[] = {{addr: 0x14 >> 1, flags: 0, buf: b0, len: 1}, - {addr: 0x14 >> 1, flags: I2C_M_RD, buf: b1, len: 1}}; + struct i2c_msg msgs[] = {{addr: 0x18 >> 1, flags: 0, buf: b0, len: 1}, + {addr: 0x18 >> 1, flags: I2C_M_RD, buf: b1, len: 1}}; ret = i2c->xfer(i2c, msgs, 2); @@ -144,7 +144,8 @@ static int alp510_set_tv_freq(struct dvb_i2c_bus *i2c, u32 freq) buf[0] = (FREQ2DIV(freq) >> 8) & 0x7F; buf[1] = FREQ2DIV(freq) & 0xFF; buf[2] = 0x85; - + +#if 0 if ((freq >= 47000000) && (freq < 153000000)) buf[3] = 0x01; else if ((freq >= 153000000) && (freq < 430000000)) @@ -155,39 +156,117 @@ static int alp510_set_tv_freq(struct dvb_i2c_bus *i2c, u32 freq) buf[3] = 0x88; else return -EINVAL; - - // Enable 8K SAW BW mode - buf[3] |= (1 << 2); +#else + if ((freq >= 47000000) && (freq < 153000000)) + buf[3] = 0x01; + else if ((freq >= 153000000) && (freq < 430000000)) + buf[3] = 0x02; + else if ((freq >= 430000000) && (freq < 824000000)) + buf[3] = 0x0C; + else if ((freq >= 824000000) && (freq < 863000000)) + buf[3] = 0x8C; + else + return -EINVAL; +#endif return pll_write(i2c, 0xC0, buf, 4); } -#if 0 -static int SetInversion(struct dvb_i2c_bus *i2c, int inversion) +static void nxt6000_reset(struct dvb_i2c_bus *i2c) { + u8 val; + + val = nxt6000_readreg(i2c, OFDM_COR_CTL); + + nxt6000_writereg(i2c, OFDM_COR_CTL, val & ~COREACT); + nxt6000_writereg(i2c, OFDM_COR_CTL, val | COREACT); + +} + +static int nxt6000_set_guard_interval(struct dvb_i2c_bus *i2c, fe_guard_interval_t guard_interval) +{ + + switch(guard_interval) { - if (inversion == stv->inv) - return 0; - stv->inv=inversion; - switch (inversion) { - case INVERSION_AUTO: // Hmm, return EINVAL or leave it like this? - default: - case INVERSION_OFF: - val=0x01; - break; - case INVERSION_ON: - val=0x00; - break; + case GUARD_INTERVAL_1_32: + + return nxt6000_writereg(i2c, OFDM_COR_MODEGUARD, 0x00 | (nxt6000_readreg(i2c, OFDM_COR_MODEGUARD) & ~0x03)); + + case GUARD_INTERVAL_1_16: + + return nxt6000_writereg(i2c, OFDM_COR_MODEGUARD, 0x01 | (nxt6000_readreg(i2c, OFDM_COR_MODEGUARD) & ~0x03)); + + case GUARD_INTERVAL_AUTO: + case GUARD_INTERVAL_1_8: + + return nxt6000_writereg(i2c, OFDM_COR_MODEGUARD, 0x02 | (nxt6000_readreg(i2c, OFDM_COR_MODEGUARD) & ~0x03)); + + case GUARD_INTERVAL_1_4: + + return nxt6000_writereg(i2c, OFDM_COR_MODEGUARD, 0x03 | (nxt6000_readreg(i2c, OFDM_COR_MODEGUARD) & ~0x03)); + + default: + + return -EINVAL; + } - writereg(client, 0x0c, - (readreg(client, 0x0c)&0xfe)|val); - return 0; + } -#endif -static void nxt6000_reset(struct dvb_i2c_bus *i2c) +static int nxt6000_set_inversion(struct dvb_i2c_bus *i2c, fe_spectral_inversion_t inversion) +{ + + switch(inversion) { + + case INVERSION_OFF: + + return nxt6000_writereg(i2c, OFDM_ITB_CTL, 0x00); + + case INVERSION_ON: + + return nxt6000_writereg(i2c, OFDM_ITB_CTL, ITBINV); + + default: + + return -EINVAL; + + } + +} + +static int nxt6000_set_transmission_mode(struct dvb_i2c_bus *i2c, fe_transmit_mode_t transmission_mode) +{ + + int result; + + switch(transmission_mode) { + + case TRANSMISSION_MODE_2K: + + if ((result = nxt6000_writereg(i2c, EN_DMD_RACQ, 0x00 | (nxt6000_readreg(i2c, EN_DMD_RACQ) & ~0x03))) < 0) + return result; + + return nxt6000_writereg(i2c, OFDM_COR_MODEGUARD, (0x00 << 2) | (nxt6000_readreg(i2c, OFDM_COR_MODEGUARD) & ~0x04)); + + case TRANSMISSION_MODE_8K: + case TRANSMISSION_MODE_AUTO: + + if ((result = nxt6000_writereg(i2c, EN_DMD_RACQ, 0x02 | (nxt6000_readreg(i2c, EN_DMD_RACQ) & ~0x03))) < 0) + return result; + + return nxt6000_writereg(i2c, OFDM_COR_MODEGUARD, (0x01 << 2) | (nxt6000_readreg(i2c, OFDM_COR_MODEGUARD) & ~0x04)); + + default: + + return -EINVAL; + + } + +} + +static void nxt6000_setup(struct dvb_i2c_bus *i2c) { nxt6000_writereg(i2c, RS_COR_SYNC_PARAM, SYNC_PARAM); @@ -195,44 +274,293 @@ static void nxt6000_reset(struct dvb_i2c_bus *i2c) nxt6000_writereg(i2c, VIT_COR_CTL, (1 << 7) | (1 << 1)); // VIT_BER_TIMER_? nxt6000_writereg(i2c, OFDM_COR_CTL, (1 << 5) | (nxt6000_readreg(i2c, OFDM_COR_CTL) & 0x0F)); - // Auto mode with MODE8K & 1/8 guard as default - nxt6000_writereg(i2c, OFDM_COR_MODEGUARD, (1 << 2) | 2); + nxt6000_writereg(i2c, OFDM_COR_MODEGUARD, FORCEMODE8K | 2); // OFDM_AGC_CTL tune zap time +// nxt6000_writereg(i2c, OFDM_AGC_CTL, ); nxt6000_writereg(i2c, OFDM_ITB_FREQ_1, 0x06); nxt6000_writereg(i2c, OFDM_ITB_FREQ_2, 0x31); -// CAS_FREQ + nxt6000_writereg(i2c, OFDM_CAS_CTL, (0x01 << 7) | (0x02 << 3) | 0x02); + nxt6000_writereg(i2c, CAS_FREQ, 0xBB); // CHECK nxt6000_writereg(i2c, OFDM_SYR_CTL, 1 << 2); nxt6000_writereg(i2c, OFDM_PPM_CTL_1, PPM256); - nxt6000_writereg(i2c, OFDM_TRL_NOMINALRATE_1, 0x49); - nxt6000_writereg(i2c, OFDM_TRL_NOMINALRATE_2, 0x72); + nxt6000_writereg(i2c, OFDM_TRL_NOMINALRATE_1, 0x49); // Hardcoded for 8K (fixme) + nxt6000_writereg(i2c, OFDM_TRL_NOMINALRATE_2, 0x72); // Hardcoded for 8K (fixme) nxt6000_writereg(i2c, ANALOG_CONTROL_0, 1 << 5); nxt6000_writereg(i2c, EN_DMD_RACQ, (1 << 7) | (3 << 4) | 2); nxt6000_writereg(i2c, DIAG_CONFIG, TB_SET); - nxt6000_writereg(i2c, SUB_DIAG_MODE_SEL, 0); +// nxt6000_writereg(i2c, SUB_DIAG_MODE_SEL, 0); nxt6000_writereg(i2c, SUB_DIAG_MODE_SEL, CLKINVERSION); nxt6000_writereg(i2c, TS_FORMAT, 0); -// nxt6000_writereg(i2c, TS_FORMAT, GATED_CLOCK); } -#if 1 static void nxt6000_dump_status(struct dvb_i2c_bus *i2c) { - printk("RS_COR_STAT: 0x%02X\n", nxt6000_readreg(i2c, RS_COR_STAT)); - printk("VIT_SYNC_STATUS: 0x%02X\n", nxt6000_readreg(i2c, VIT_SYNC_STATUS)); - printk("OFDM_COR_STAT: 0x%02X\n", nxt6000_readreg(i2c, OFDM_COR_STAT)); - printk("OFDM_SYR_STAT: 0x%02X\n", nxt6000_readreg(i2c, OFDM_SYR_STAT)); - printk("OFDM_TPS_RCVD_1: 0x%02X\n", nxt6000_readreg(i2c, OFDM_TPS_RCVD_1)); + u8 val; + +// printk("RS_COR_STAT: 0x%02X\n", nxt6000_readreg(i2c, RS_COR_STAT)); +// printk("VIT_SYNC_STATUS: 0x%02X\n", nxt6000_readreg(i2c, VIT_SYNC_STATUS)); +// printk("OFDM_COR_STAT: 0x%02X\n", nxt6000_readreg(i2c, OFDM_COR_STAT)); +// printk("OFDM_SYR_STAT: 0x%02X\n", nxt6000_readreg(i2c, OFDM_SYR_STAT)); +// printk("OFDM_TPS_RCVD_1: 0x%02X\n", nxt6000_readreg(i2c, OFDM_TPS_RCVD_1)); // printk("OFDM_TPS_RCVD_2: 0x%02X\n", nxt6000_readreg(i2c, OFDM_TPS_RCVD_2)); // printk("OFDM_TPS_RCVD_3: 0x%02X\n", nxt6000_readreg(i2c, OFDM_TPS_RCVD_3)); // printk("OFDM_TPS_RCVD_4: 0x%02X\n", nxt6000_readreg(i2c, OFDM_TPS_RCVD_4)); // printk("OFDM_TPS_RESERVED_1: 0x%02X\n", nxt6000_readreg(i2c, OFDM_TPS_RESERVED_1)); // printk("OFDM_TPS_RESERVED_2: 0x%02X\n", nxt6000_readreg(i2c, OFDM_TPS_RESERVED_2)); -// printk("RF_AGC_STATUS: 0x%02X\n", nxt6000_readreg(i2c, RF_AGC_STATUS)); + printk("NXT6000 status:"); + + val = nxt6000_readreg(i2c, RS_COR_STAT); + + printk(" DATA DESCR LOCK: %d,", val & 0x01); + printk(" DATA SYNC LOCK: %d,", (val >> 1) & 0x01); + + val = nxt6000_readreg(i2c, VIT_SYNC_STATUS); + + printk(" VITERBI LOCK: %d,", (val >> 7) & 0x01); + + switch((val >> 4) & 0x07) { + + case 0x00: + + printk(" VITERBI CODERATE: 1/2,"); + + break; + + case 0x01: + + printk(" VITERBI CODERATE: 2/3,"); + + break; + + case 0x02: + + printk(" VITERBI CODERATE: 3/4,"); + + break; + + case 0x03: + + printk(" VITERBI CODERATE: 5/6,"); + + case 0x04: + + printk(" VITERBI CODERATE: 7/8,"); + + break; + + default: + + printk(" VITERBI CODERATE: Reserved,"); + + } + + val = nxt6000_readreg(i2c, OFDM_COR_STAT); + + printk(" CHCTrack: %d,", (val >> 7) & 0x01); + printk(" TPSLock: %d,", (val >> 6) & 0x01); + printk(" SYRLock: %d,", (val >> 5) & 0x01); + printk(" AGCLock: %d,", (val >> 4) & 0x01); + + switch((val >> 4) & 0x07) { + + case 0x00: + + printk(" CoreState: IDLE,"); + + break; + + case 0x02: + + printk(" CoreState: WAIT_AGC,"); + + break; + + case 0x03: + + printk(" CoreState: WAIT_SYR,"); + + break; + + case 0x04: + + printk(" CoreState: WAIT_PPM,"); + + case 0x01: + + printk(" CoreState: WAIT_TRL,"); + + break; + + case 0x05: + + printk(" CoreState: WAIT_TPS,"); + + break; + + case 0x06: + + printk(" CoreState: MONITOR_TPS,"); + + break; + + default: + + printk(" CoreState: Reserved,"); + + } + + val = nxt6000_readreg(i2c, OFDM_SYR_STAT); + + printk(" SYRLock: %d,", (val >> 4) & 0x01); + printk(" SYRMode: %s,", (val >> 2) & 0x01 ? "8K" : "2K"); + + switch((val >> 4) & 0x03) { + + case 0x00: + + printk(" SYRGuard: 1/32,"); + + break; + + case 0x01: + + printk(" SYRGuard: 1/16,"); + + break; + + case 0x02: + + printk(" SYRGuard: 1/8,"); + + break; + + case 0x03: + + printk(" SYRGuard: 1/4,"); + + break; + + } + + val = nxt6000_readreg(i2c, OFDM_TPS_RCVD_3); + + switch((val >> 4) & 0x07) { + + case 0x00: + + printk(" TPSLP: 1/2,"); + + break; + + case 0x01: + + printk(" TPSLP: 2/3,"); + + break; + + case 0x02: + + printk(" TPSLP: 3/4,"); + + break; + + case 0x03: + + printk(" TPSLP: 5/6,"); + + case 0x04: + + printk(" TPSLP: 7/8,"); + + break; + + default: + + printk(" TPSLP: Reserved,"); + + } + + switch(val & 0x07) { + + case 0x00: + + printk(" TPSHP: 1/2,"); + + break; + + case 0x01: + + printk(" TPSHP: 2/3,"); + + break; + + case 0x02: + + printk(" TPSHP: 3/4,"); + + break; + + case 0x03: + + printk(" TPSHP: 5/6,"); + + case 0x04: + + printk(" TPSHP: 7/8,"); + + break; + + default: + + printk(" TPSHP: Reserved,"); + + } + + val = nxt6000_readreg(i2c, OFDM_TPS_RCVD_4); + + printk(" TPSMode: %s,", val & 0x01 ? "8K" : "2K"); + + switch((val >> 4) & 0x03) { + + case 0x00: + + printk(" TPSGuard: 1/32,"); + + break; + + case 0x01: + + printk(" TPSGuard: 1/16,"); + + break; + + case 0x02: + + printk(" TPSGuard: 1/8,"); + + break; + + case 0x03: + + printk(" TPSGuard: 1/4,"); + + break; + + } + + // Strange magic required to gain access to RF_AGC_STATUS + nxt6000_readreg(i2c, RF_AGC_VAL_1); + val = nxt6000_readreg(i2c, RF_AGC_STATUS); + val = nxt6000_readreg(i2c, RF_AGC_STATUS); + + printk(" RF AGC LOCK: %d,", (val >> 4) & 0x01); + + printk("\n"); + } -#endif static int nxt6000_ioctl(struct dvb_frontend *fe, unsigned int cmd, void *arg) { @@ -248,8 +576,9 @@ static int nxt6000_ioctl(struct dvb_frontend *fe, unsigned int cmd, void *arg) case FE_READ_STATUS: { fe_status_t *status = (fe_status_t *)arg; -#if 0 + u8 core_status; + nxt6000_dump_status(fe->i2c); *status = 0; @@ -270,8 +599,6 @@ static int nxt6000_ioctl(struct dvb_frontend *fe, unsigned int cmd, void *arg) if (core_status & TPSLOCKED) *status |= FE_HAS_LOCK; -#endif - *status = FE_HAS_LOCK; return 0; @@ -319,7 +646,7 @@ static int nxt6000_ioctl(struct dvb_frontend *fe, unsigned int cmd, void *arg) case FE_INIT: case FE_RESET: - nxt6000_reset(fe->i2c); + //nxt6000_setup(fe->i2c); break; @@ -327,10 +654,13 @@ static int nxt6000_ioctl(struct dvb_frontend *fe, unsigned int cmd, void *arg) { struct dvb_frontend_parameters *param = (struct dvb_frontend_parameters *)arg; - //SetInversion(client, param->Inversion); - //SetFEC(client, param->u.qpsk.FEC_inner); - //SetSymbolrate(client, param->u.qpsk.SymbolRate); alp510_set_tv_freq(fe->i2c, param->frequency); + + nxt6000_set_guard_interval(fe->i2c, param->u.ofdm.guard_interval); + nxt6000_set_transmission_mode(fe->i2c, param->u.ofdm.transmission_mode); + nxt6000_set_inversion(fe->i2c, param->inversion); + + nxt6000_reset(fe->i2c); break; } @@ -379,7 +709,21 @@ static int nxt6000_attach(struct dvb_i2c_bus *i2c) printk("nxt6000: attached at %d:%d\n", i2c->adapter->num, i2c->id); nxt6000_reset(i2c); - alp510_set_tv_freq(i2c, 658000000); + nxt6000_setup(i2c); + +// alp510_set_tv_freq(i2c, 177500000); +// alp510_set_tv_freq(i2c, 602000000); + alp510_set_tv_freq(i2c, 650000000); // NOK +// alp510_set_tv_freq(i2c, 658000000); // OK + alp510_set_tv_freq(i2c, 778000000); // OK + nxt6000_set_guard_interval(i2c, GUARD_INTERVAL_1_8); +// nxt6000_set_transmission_mode(i2c, TRANSMISSION_MODE_8K); + nxt6000_set_transmission_mode(i2c, TRANSMISSION_MODE_2K); + nxt6000_set_inversion(i2c, INVERSION_OFF); +// nxt6000_set_inversion(i2c, INVERSION_ON); + + nxt6000_reset(i2c); + nxt6000_dump_status(i2c); return dvb_register_frontend(nxt6000_ioctl, i2c, NULL, &nxt6000_info); |