X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=drivers%2Fmedia%2Fdvb%2Ffrontends%2Fstv0297.c;fp=drivers%2Fmedia%2Fdvb%2Ffrontends%2Fstv0297.c;h=eb15676d374f1fd4aadee45345163cd094ab56c3;hb=43bc926fffd92024b46cafaf7350d669ba9ca884;hp=e681263bf07986bb4252402c185069bf4960aaa3;hpb=cee37fe97739d85991964371c1f3a745c00dd236;p=linux-2.6.git diff --git a/drivers/media/dvb/frontends/stv0297.c b/drivers/media/dvb/frontends/stv0297.c index e681263bf..eb15676d3 100644 --- a/drivers/media/dvb/frontends/stv0297.c +++ b/drivers/media/dvb/frontends/stv0297.c @@ -24,6 +24,8 @@ #include #include #include +#include +#include #include "dvb_frontend.h" #include "stv0297.h" @@ -35,7 +37,6 @@ struct stv0297_state { struct dvb_frontend frontend; unsigned long base_freq; - u8 pwm; }; #if 1 @@ -46,94 +47,6 @@ struct stv0297_state { #define STV0297_CLOCK_KHZ 28900 -static u8 init_tab[] = { - 0x00, 0x09, - 0x01, 0x69, - 0x03, 0x00, - 0x04, 0x00, - 0x07, 0x00, - 0x08, 0x00, - 0x20, 0x00, - 0x21, 0x40, - 0x22, 0x00, - 0x23, 0x00, - 0x24, 0x40, - 0x25, 0x88, - 0x30, 0xff, - 0x31, 0x00, - 0x32, 0xff, - 0x33, 0x00, - 0x34, 0x50, - 0x35, 0x7f, - 0x36, 0x00, - 0x37, 0x20, - 0x38, 0x00, - 0x40, 0x1c, - 0x41, 0xff, - 0x42, 0x29, - 0x43, 0x00, - 0x44, 0xff, - 0x45, 0x00, - 0x46, 0x00, - 0x49, 0x04, - 0x4a, 0xff, - 0x4b, 0x7f, - 0x52, 0x30, - 0x55, 0xae, - 0x56, 0x47, - 0x57, 0xe1, - 0x58, 0x3a, - 0x5a, 0x1e, - 0x5b, 0x34, - 0x60, 0x00, - 0x63, 0x00, - 0x64, 0x00, - 0x65, 0x00, - 0x66, 0x00, - 0x67, 0x00, - 0x68, 0x00, - 0x69, 0x00, - 0x6a, 0x02, - 0x6b, 0x00, - 0x70, 0xff, - 0x71, 0x00, - 0x72, 0x00, - 0x73, 0x00, - 0x74, 0x0c, - 0x80, 0x00, - 0x81, 0x00, - 0x82, 0x00, - 0x83, 0x00, - 0x84, 0x04, - 0x85, 0x80, - 0x86, 0x24, - 0x87, 0x78, - 0x88, 0x00, - 0x89, 0x00, - 0x90, 0x01, - 0x91, 0x01, - 0xa0, 0x00, - 0xa1, 0x00, - 0xa2, 0x00, - 0xb0, 0x91, - 0xb1, 0x0b, - 0xc0, 0x53, - 0xc1, 0x70, - 0xc2, 0x12, - 0xd0, 0x00, - 0xd1, 0x00, - 0xd2, 0x00, - 0xd3, 0x00, - 0xd4, 0x00, - 0xd5, 0x00, - 0xde, 0x00, - 0xdf, 0x00, - 0x61, 0x49, - 0x62, 0x0b, - 0x53, 0x08, - 0x59, 0x08, -}; - static int stv0297_writereg(struct stv0297_state *state, u8 reg, u8 data) { @@ -378,34 +291,9 @@ static int stv0297_init(struct dvb_frontend *fe) struct stv0297_state *state = fe->demodulator_priv; int i; - /* soft reset */ - stv0297_writereg_mask(state, 0x80, 1, 1); - stv0297_writereg_mask(state, 0x80, 1, 0); - - /* reset deinterleaver */ - stv0297_writereg_mask(state, 0x81, 1, 1); - stv0297_writereg_mask(state, 0x81, 1, 0); - /* load init table */ - for (i = 0; i < sizeof(init_tab); i += 2) { - stv0297_writereg(state, init_tab[i], init_tab[i + 1]); - } - - /* set a dummy symbol rate */ - stv0297_set_symbolrate(state, 6900); - - /* invert AGC1 polarity */ - stv0297_writereg_mask(state, 0x88, 0x10, 0x10); - - /* setup bit error counting */ - stv0297_writereg_mask(state, 0xA0, 0x80, 0x00); - stv0297_writereg_mask(state, 0xA0, 0x10, 0x00); - stv0297_writereg_mask(state, 0xA0, 0x08, 0x00); - stv0297_writereg_mask(state, 0xA0, 0x07, 0x04); - - /* min + max PWM */ - stv0297_writereg(state, 0x4a, 0x00); - stv0297_writereg(state, 0x4b, state->pwm); + for (i=0; !(state->config->inittab[i] == 0xff && state->config->inittab[i+1] == 0xff); i+=2) + stv0297_writereg(state, state->config->inittab[i], state->config->inittab[i+1]); msleep(200); if (state->config->pll_init) @@ -505,10 +393,6 @@ static int stv0297_set_frontend(struct dvb_frontend *fe, struct dvb_frontend_par break; case QAM_128: - delay = 150; - sweeprate = 1000; - break; - case QAM_256: delay = 200; sweeprate = 500; @@ -606,7 +490,13 @@ static int stv0297_set_frontend(struct dvb_frontend *fe, struct dvb_frontend_par stv0297_set_inversion(state, inversion); /* kick off lock */ - stv0297_writereg_mask(state, 0x88, 0x08, 0x08); + /* Disable corner detection for higher QAMs */ + if (p->u.qam.modulation == QAM_128 || + p->u.qam.modulation == QAM_256) + stv0297_writereg_mask(state, 0x88, 0x08, 0x00); + else + stv0297_writereg_mask(state, 0x88, 0x08, 0x08); + stv0297_writereg_mask(state, 0x5a, 0x20, 0x00); stv0297_writereg_mask(state, 0x6a, 0x01, 0x01); stv0297_writereg_mask(state, 0x43, 0x40, 0x40); @@ -617,7 +507,7 @@ static int stv0297_set_frontend(struct dvb_frontend *fe, struct dvb_frontend_par /* wait for WGAGC lock */ starttime = jiffies; - timeout = jiffies + (200 * HZ) / 1000; + timeout = jiffies + msecs_to_jiffies(2000); while (time_before(jiffies, timeout)) { msleep(10); if (stv0297_readreg(state, 0x43) & 0x08) @@ -629,7 +519,7 @@ static int stv0297_set_frontend(struct dvb_frontend *fe, struct dvb_frontend_par msleep(20); /* wait for equaliser partial convergence */ - timeout = jiffies + (50 * HZ) / 1000; + timeout = jiffies + msecs_to_jiffies(500); while (time_before(jiffies, timeout)) { msleep(10); @@ -642,7 +532,7 @@ static int stv0297_set_frontend(struct dvb_frontend *fe, struct dvb_frontend_par } /* wait for equaliser full convergence */ - timeout = jiffies + (delay * HZ) / 1000; + timeout = jiffies + msecs_to_jiffies(delay); while (time_before(jiffies, timeout)) { msleep(10); @@ -659,7 +549,7 @@ static int stv0297_set_frontend(struct dvb_frontend *fe, struct dvb_frontend_par stv0297_writereg_mask(state, 0x88, 8, 0); /* wait for main lock */ - timeout = jiffies + (20 * HZ) / 1000; + timeout = jiffies + msecs_to_jiffies(20); while (time_before(jiffies, timeout)) { msleep(10); @@ -732,7 +622,7 @@ static void stv0297_release(struct dvb_frontend *fe) static struct dvb_frontend_ops stv0297_ops; struct dvb_frontend *stv0297_attach(const struct stv0297_config *config, - struct i2c_adapter *i2c, int pwm) + struct i2c_adapter *i2c) { struct stv0297_state *state = NULL; @@ -746,7 +636,6 @@ struct dvb_frontend *stv0297_attach(const struct stv0297_config *config, state->i2c = i2c; memcpy(&state->ops, &stv0297_ops, sizeof(struct dvb_frontend_ops)); state->base_freq = 0; - state->pwm = pwm; /* check if the demod is there */ if ((stv0297_readreg(state, 0x80) & 0x70) != 0x20)