diff options
author | Andrew de Quincy <devnull@localhost> | 2004-12-18 20:25:12 +0000 |
---|---|---|
committer | Andrew de Quincy <devnull@localhost> | 2004-12-18 20:25:12 +0000 |
commit | 5bdf6b2c3261a02f5b5d6b1cd8b7785461910577 (patch) | |
tree | 8febb2e4795a9d90ff1be08fe16314b9b3cdce76 /linux/drivers/media/dvb/frontends/stv0297.c | |
parent | 390f7f4c541d18a026ee0cc69f086876a93204b6 (diff) | |
download | mediapointer-dvb-s2-5bdf6b2c3261a02f5b5d6b1cd8b7785461910577.tar.gz mediapointer-dvb-s2-5bdf6b2c3261a02f5b5d6b1cd8b7785461910577.tar.bz2 |
Added stuff for initial demod frequency
Diffstat (limited to 'linux/drivers/media/dvb/frontends/stv0297.c')
-rw-r--r-- | linux/drivers/media/dvb/frontends/stv0297.c | 68 |
1 files changed, 43 insertions, 25 deletions
diff --git a/linux/drivers/media/dvb/frontends/stv0297.c b/linux/drivers/media/dvb/frontends/stv0297.c index a15e658ad..cf5bfe290 100644 --- a/linux/drivers/media/dvb/frontends/stv0297.c +++ b/linux/drivers/media/dvb/frontends/stv0297.c @@ -160,8 +160,10 @@ static int stv0297_readreg(struct stv0297_state *state, u8 reg) int ret; u8 b0[] = { reg }; u8 b1[] = { 0 }; - struct i2c_msg msg[] = { {.addr = state->config->demod_address,.flags = 0,.buf = b0,.len = 1}, - {.addr = state->config->demod_address,.flags = I2C_M_RD,.buf = b1,.len = 1} }; + struct i2c_msg msg[] = { {.addr = state->config->demod_address,.flags = 0,.buf = b0,.len = + 1}, + {.addr = state->config->demod_address,.flags = I2C_M_RD,.buf = b1,.len = 1} + }; // this device needs a STOP between the register and data if ((ret = i2c_transfer(state->i2c, &msg[0], 1)) != 1) { @@ -191,8 +193,10 @@ static int stv0297_writereg_mask(struct stv0297_state *state, u8 reg, u8 mask, u static int stv0297_readregs(struct stv0297_state *state, u8 reg1, u8 * b, u8 len) { int ret; - struct i2c_msg msg[] = { {.addr = state->config->demod_address,.flags = 0,.buf = ®1,.len = 1}, - {.addr = state->config->demod_address,.flags = I2C_M_RD,.buf = b,.len = len} }; + struct i2c_msg msg[] = { {.addr = state->config->demod_address,.flags = 0,.buf = + ®1,.len = 1}, + {.addr = state->config->demod_address,.flags = I2C_M_RD,.buf = b,.len = len} + }; // this device needs a STOP between the register and data if ((ret = i2c_transfer(state->i2c, &msg[0], 1)) != 1) { @@ -207,6 +211,21 @@ static int stv0297_readregs(struct stv0297_state *state, u8 reg1, u8 * b, u8 len return 0; } +static u32 stv0297_get_symbolrate(struct stv0297_state *state) +{ + u64 tmp; + + tmp = stv0297_readreg(state, 0x55); + tmp |= stv0297_readreg(state, 0x56) << 8; + tmp |= stv0297_readreg(state, 0x57) << 16; + tmp |= stv0297_readreg(state, 0x58) << 24; + + tmp *= STV0297_CLOCK_KHZ; + tmp >>= 32; + + return (u32) tmp; +} + static void stv0297_set_symbolrate(struct stv0297_state *state, u32 srate) { long tmp; @@ -259,37 +278,36 @@ static void stv0297_set_carrieroffset(struct stv0297_state *state, long offset) static long stv0297_get_carrieroffset(struct stv0297_state *state) { - s32 raw; - long tmp; + s64 tmp; stv0297_writereg(state, 0x6B, 0x00); - raw = stv0297_readreg(state, 0x66); - raw |= (stv0297_readreg(state, 0x67) << 8); - raw |= (stv0297_readreg(state, 0x68) << 16); - raw |= (stv0297_readreg(state, 0x69) & 0x0F) << 24; + tmp = stv0297_readreg(state, 0x66); + tmp |= (stv0297_readreg(state, 0x67) << 8); + tmp |= (stv0297_readreg(state, 0x68) << 16); + tmp |= (stv0297_readreg(state, 0x69) & 0x0F) << 24; - tmp = raw; - tmp /= 26844L; + tmp *= stv0297_get_symbolrate(state); + tmp >>= 28; - return tmp; + return (s32) tmp; } static void stv0297_set_initialdemodfreq(struct stv0297_state *state, long freq) { -/* - s64 tmp; + s32 tmp; - if (freq > 10000) freq -= STV0297_CLOCK_KHZ; + if (freq > 10000) + freq -= STV0297_CLOCK_KHZ; - tmp = freq << 16; - do_div(tmp, STV0297_CLOCK_KHZ); - if (tmp > 0xffff) tmp = 0xffff; // check this calculation + tmp = (STV0297_CLOCK_KHZ * 1000) / (1 << 16); + tmp = (freq * 1000) / tmp; + if (tmp > 0xffff) + tmp = 0xffff; - stv0297_writereg_mask(state, 0x25, 0x80, 0x80); - stv0297_writereg(state, 0x21, tmp >> 8); - stv0297_writereg(state, 0x20, tmp); -*/ + stv0297_writereg_mask(state, 0x25, 0x80, 0x80); + stv0297_writereg(state, 0x21, tmp >> 8); + stv0297_writereg(state, 0x20, tmp); } static int stv0297_set_qam(struct stv0297_state *state, fe_modulation_t modulation) @@ -687,8 +705,8 @@ static int stv0297_get_frontend(struct dvb_frontend *fe, struct dvb_frontend_par p->inversion = (reg_83 & 0x08) ? INVERSION_ON : INVERSION_OFF; if (state->config->invert) p->inversion = (p->inversion == INVERSION_ON) ? INVERSION_OFF : INVERSION_ON; - p->u.qam.symbol_rate = 0; - p->u.qam.fec_inner = 0; + p->u.qam.symbol_rate = stv0297_get_symbolrate(state) * 1000; + p->u.qam.fec_inner = FEC_NONE; switch ((reg_00 >> 4) & 0x7) { case 0: |