From 7defb807a53a4d8c71e434e31f73d58cbf195cdc Mon Sep 17 00:00:00 2001 From: Andrew de Quincy Date: Tue, 9 Nov 2004 23:22:58 +0000 Subject: Fixed up init tables --- linux/drivers/media/dvb/frontends/stv0297.c | 136 ++++++++++++++-------------- 1 file changed, 70 insertions(+), 66 deletions(-) (limited to 'linux/drivers/media/dvb') diff --git a/linux/drivers/media/dvb/frontends/stv0297.c b/linux/drivers/media/dvb/frontends/stv0297.c index f488f6c47..4a2ed985c 100644 --- a/linux/drivers/media/dvb/frontends/stv0297.c +++ b/linux/drivers/media/dvb/frontends/stv0297.c @@ -41,7 +41,7 @@ struct stv0297_state { int freq_off; unsigned long base_freq; - + u8 pwm; }; @@ -78,7 +78,7 @@ static u8 init_tab [] = { 0x40, 0x1c, 0x41, 0xff, 0x42, 0x29, - 0x43, 0x00, + 0x43, 0x00,// check 0x44, 0xff, 0x45, 0x00, 0x46, 0x00, @@ -165,31 +165,31 @@ static int stv0297_readreg (struct stv0297_state* state, u8 reg) 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 + // this device needs a STOP between the register and data if ((ret = i2c_transfer (state->i2c, &msg[0], 1)) != 1) { - dprintk("%s: readreg error (reg == 0x%02x, ret == %i)\n", - __FUNCTION__, reg, ret); - return -1; - } + dprintk("%s: readreg error (reg == 0x%02x, ret == %i)\n", + __FUNCTION__, reg, ret); + return -1; + } if ((ret = i2c_transfer (state->i2c, &msg[1], 1)) != 1) { - dprintk("%s: readreg error (reg == 0x%02x, ret == %i)\n", - __FUNCTION__, reg, ret); - return -1; - } + dprintk("%s: readreg error (reg == 0x%02x, ret == %i)\n", + __FUNCTION__, reg, ret); + return -1; + } return b1[0]; } static int stv0297_writereg_mask (struct stv0297_state* state, u8 reg, u8 mask, u8 data) { - int val; + int val; - val = stv0297_readreg(state, reg); - val &= ~mask; - val |= (data & mask); - stv0297_writereg(state, reg, val); + val = stv0297_readreg(state, reg); + val &= ~mask; + val |= (data & mask); + stv0297_writereg(state, reg, val); - return 0; + return 0; } static int stv0297_readregs (struct stv0297_state* state, u8 reg1, u8 *b, u8 len) @@ -198,17 +198,17 @@ static int stv0297_readregs (struct stv0297_state* state, u8 reg1, u8 *b, u8 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 + // this device needs a STOP between the register and data if ((ret = i2c_transfer (state->i2c, &msg[0], 1)) != 1) { - dprintk("%s: readreg error (reg == 0x%02x, ret == %i)\n", - __FUNCTION__, reg1, ret); - return -1; - } + dprintk("%s: readreg error (reg == 0x%02x, ret == %i)\n", + __FUNCTION__, reg1, ret); + return -1; + } if ((ret = i2c_transfer (state->i2c, &msg[1], 1)) != 1) { - dprintk("%s: readreg error (reg == 0x%02x, ret == %i)\n", - __FUNCTION__, reg1, ret); - return -1; - } + dprintk("%s: readreg error (reg == 0x%02x, ret == %i)\n", + __FUNCTION__, reg1, ret); + return -1; + } return 0; } @@ -217,7 +217,7 @@ static int stv0297_set_symbolrate (struct stv0297_state* state, u32 srate) { u64 tmp; - tmp = srate; + tmp = srate; tmp <<= 32; do_div(tmp, STV0297_CLOCK); @@ -260,7 +260,7 @@ static void stv0297_set_sweeprate(struct stv0297_state* state, short fshift) } else { tmp -= 500000; } - do_div(tmp, 1000000); + do_div(tmp, 1000000); stv0297_writereg(state, 0x60, tmp & 0xFF); stv0297_writereg_mask(state, 0x69, 0xF0, (tmp >> 4) & 0xf0); @@ -301,7 +301,7 @@ static long stv0297_get_carrieroffset(struct stv0297_state* state) raw |= (stv0297_readreg(state,0x69) & 0x0F) << 24; // cannot just use a shift here 'cos it is signed - tmp = raw; + tmp = raw; tmp *= symbol_rate; do_div(tmp, 1<<28); @@ -330,32 +330,32 @@ static int stv0297_set_qam(struct stv0297_state* state, fe_modulation_t modulati switch(modulation) { case QAM_16: - val = 0; - break; + val = 0; + break; case QAM_32: - val = 1; - break; + val = 1; + break; case QAM_64: - val = 4; - break; + val = 4; + break; case QAM_128: - val = 2; - break; + val = 2; + break; case QAM_256: - val = 3; - break; + val = 3; + break; - default: - return -EINVAL; + default: + return -EINVAL; } stv0297_writereg_mask(state, 0x00, 0x70, val << 4); - return 0; + return 0; } static int stv0297_set_inversion(struct stv0297_state* state, fe_spectral_inversion_t inversion) @@ -364,20 +364,20 @@ static int stv0297_set_inversion(struct stv0297_state* state, fe_spectral_invers switch(inversion) { case INVERSION_OFF: - val = 0; - break; + val = 0; + break; case INVERSION_ON: - val = 1; - break; + val = 1; + break; - default: - return -EINVAL; + default: + return -EINVAL; } stv0297_writereg_mask(state, 0x83, 0x08, val << 3); - return 0; + return 0; } @@ -407,22 +407,26 @@ static int stv0297_init (struct dvb_frontend* fe) struct stv0297_state* state = (struct stv0297_state*) fe->demodulator_priv; int i; - stv0297_writereg(state, 0x80, stv0297_readreg(state, 0x80) | 1); - stv0297_writereg(state, 0x80, stv0297_readreg(state, 0x80) & 0xfe); - stv0297_writereg(state, 0x81, stv0297_readreg(state, 0x81) | 1); - stv0297_writereg(state, 0x81, stv0297_readreg(state, 0x81) & 0xfe); + stv0297_writereg_mask(state, 0x80, 1, 1); + stv0297_writereg_mask(state, 0x80, 1, 0); + stv0297_writereg_mask(state, 0x81, 1, 1); + stv0297_writereg_mask(state, 0x81, 1, 0); for (i=0; ipwm); + msleep(200); - if (state->config->pll_init) state->config->pll_init(fe); + if (state->config->pll_init) state->config->pll_init(fe); return 0; } @@ -496,8 +500,8 @@ static int stv0297_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_par int locked; int sweeprate; int carrieroffset; - unsigned long starttime; - unsigned long timeout; + unsigned long starttime; + unsigned long timeout; switch(p->u.qam.modulation) { case QAM_16: @@ -523,7 +527,7 @@ static int stv0297_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_par // determine inversion dependant parameters carrieroffset = -330; - switch(p->inversion) { + switch(p->inversion) { case INVERSION_OFF: break; @@ -536,8 +540,8 @@ static int stv0297_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_par return -EINVAL; } - state->config->pll_set(fe, p); - + state->config->pll_set(fe, p); + // reset everything stv0297_writereg_mask(state, 0x82, 0x4, 0x4); stv0297_set_initialdemodfreq(state, state->freq_off + 7250); @@ -661,7 +665,7 @@ static int stv0297_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_par // success!! stv0297_writereg_mask(state, 0x5a, 0x40, 0x00); state->freq_off = stv0297_get_carrieroffset(state); - state->base_freq = p->frequency; + state->base_freq = p->frequency; return 0; timeout: @@ -703,7 +707,7 @@ static struct dvb_frontend_ops stv0297_ops; struct dvb_frontend* stv0297_attach(const struct stv0297_config* config, struct i2c_adapter* i2c, - int pwm) + int pwm) { struct stv0297_state* state = NULL; @@ -717,14 +721,14 @@ struct dvb_frontend* stv0297_attach(const struct stv0297_config* config, memcpy(&state->ops, &stv0297_ops, sizeof(struct dvb_frontend_ops)); state->freq_off = 0; state->base_freq = 0; - state->pwm = pwm; + state->pwm = pwm; /* check if the demod is there */ if ((stv0297_readreg(state, 0x80) & 0x70) != 0x20) goto error; /* create dvb_frontend */ state->frontend.ops = &state->ops; - state->frontend.demodulator_priv = state; + state->frontend.demodulator_priv = state; return &state->frontend; error: -- cgit v1.2.3