diff options
author | Andrew de Quincy <devnull@localhost> | 2003-11-12 10:50:01 +0000 |
---|---|---|
committer | Andrew de Quincy <devnull@localhost> | 2003-11-12 10:50:01 +0000 |
commit | e2b69f7d865cfe51af90a9696595de9866951aa4 (patch) | |
tree | c594161278b124c9da35587aa610abf024290f22 /linux/drivers/media | |
parent | c3f54ed700c21351fee99146a7807336039926ae (diff) | |
download | mediapointer-dvb-s2-e2b69f7d865cfe51af90a9696595de9866951aa4.tar.gz mediapointer-dvb-s2-e2b69f7d865cfe51af90a9696595de9866951aa4.tar.bz2 |
Added modifications based on the recommended settings in the SU1278
datasheet.
Cleaned up some tabbing problems.
Diffstat (limited to 'linux/drivers/media')
-rw-r--r-- | linux/drivers/media/dvb/frontends/stv0299.c | 120 |
1 files changed, 81 insertions, 39 deletions
diff --git a/linux/drivers/media/dvb/frontends/stv0299.c b/linux/drivers/media/dvb/frontends/stv0299.c index c99c1abf6..0e36585c8 100644 --- a/linux/drivers/media/dvb/frontends/stv0299.c +++ b/linux/drivers/media/dvb/frontends/stv0299.c @@ -287,21 +287,47 @@ static int sl1935_set_tv_freq (struct dvb_i2c_bus *i2c, u32 freq, int ftype) * set up the downconverter frequency divisor for a * reference clock comparision frequency of 125 kHz. */ -static int tsa5059_set_tv_freq (struct dvb_i2c_bus *i2c, u32 freq, int ftype) +static int tsa5059_set_tv_freq (struct dvb_i2c_bus *i2c, u32 freq, int ftype, int srate) { - u8 addr = (ftype == PHILIPS_SU1278SH) ? 0x60 : 0x61; - u32 div = freq / 125; - u8 buf[4] = { (div >> 8) & 0x7f, div & 0xff, 0x84 }; + u8 addr; + u32 div; + u8 buf[4]; dprintk ("%s: freq %i, ftype %i\n", __FUNCTION__, freq, ftype); - if (ftype == PHILIPS_SU1278SH) - /* activate f_xtal/f_comp signal output */ - /* charge pump current C0/C1 = 00 */ - buf[3] = 0x20; - else - buf[3] = freq > 1530000 ? 0xc0 : 0xc4; + if ((freq < 950000) || (freq > 2150000)) return -EINVAL; + + // setup frequency divisor + div = freq / 1000; + buf[0] = (div >> 8) & 0x7f; + buf[1] = div & 0xff; + buf[2] = 0x81 | ((div & 0x18000) >> 10); + buf[3] = 0; + + // tuner-specific settings + switch(ftype) { + case PHILIPS_SU1278SH: + addr = 0x60; + buf[3] |= 0x20; + + if (srate < 4000000) buf[3] |= 1; + + if (freq <= 1250000) buf[3] |= 0; + else if (freq <= 1550000) buf[3] |= 0x40; + else if (freq <= 2050000) buf[3] |= 0x80; + else if (freq <= 2150000) buf[3] |= 0xC0; + break; + case ALPS_BSRU6: + addr = 0x61; + buf[3] |= 0xC0; + break; + + default: + return -EINVAL; + } + + // charge pump return pll_write (i2c, addr, buf, sizeof(buf)); } @@ -441,7 +467,7 @@ static int pll_set_tv_freq (struct dvb_i2c_bus *i2c, u32 freq, int ftype, int sr else if (ftype == PHILIPS_SU1278) return tua6100_set_tv_freq(i2c, freq, ftype, srate); else - return tsa5059_set_tv_freq(i2c, freq, ftype); + return tsa5059_set_tv_freq(i2c, freq, ftype, srate); } #if 0 @@ -474,16 +500,16 @@ static int stv0299_init (struct dvb_i2c_bus *i2c, int ftype) if(ftype == SAMSUNG_TBMU24112IMB) { - dprintk("%s: init stv0299 chip for Samsung TBMU24112IMB\n", __FUNCTION__); + dprintk("%s: init stv0299 chip for Samsung TBMU24112IMB\n", __FUNCTION__); - for (i=0; i<sizeof(init_tab_samsung); i+=2) - { - dprintk("%s: reg == 0x%02x, val == 0x%02x\n", __FUNCTION__, init_tab_samsung[i], init_tab_samsung[i+1]); + for (i=0; i<sizeof(init_tab_samsung); i+=2) + { + dprintk("%s: reg == 0x%02x, val == 0x%02x\n", __FUNCTION__, init_tab_samsung[i], init_tab_samsung[i+1]); - stv0299_writereg (i2c, init_tab_samsung[i], init_tab_samsung[i+1]); - } + stv0299_writereg (i2c, init_tab_samsung[i], init_tab_samsung[i+1]); + } - return 0; + return 0; } stv0299_writereg (i2c, 0x01, 0x15); @@ -495,9 +521,9 @@ static int stv0299_init (struct dvb_i2c_bus *i2c, int ftype) /* AGC1 reference register setup */ if (ftype == PHILIPS_SU1278SH) - stv0299_writereg (i2c, 0x0f, 0xd2); /* Iagc = Inverse, m1 = 18 */ + stv0299_writereg (i2c, 0x0f, 0x92); /* Iagc = Inverse, m1 = 18 */ else if (ftype == PHILIPS_SU1278) - stv0299_writereg (i2c, 0x0f, 0x94); /* Iagc = Inverse, m1 = 18 */ + stv0299_writereg (i2c, 0x0f, 0x94); /* Iagc = Inverse, m1 = 20 */ else stv0299_writereg (i2c, 0x0f, 0x52); /* Iagc = Normal, m1 = 18 */ @@ -747,26 +773,39 @@ static int stv0299_set_voltage (struct dvb_i2c_bus *i2c, fe_sec_voltage_t voltag } -static int stv0299_set_symbolrate (struct dvb_i2c_bus *i2c, u32 srate) +static int stv0299_set_symbolrate (struct dvb_i2c_bus *i2c, u32 srate, int tuner_type) { u64 big = srate; u32 ratio; - - u8 aclk = 0xb4, bclk = 0x51; - - if (srate > M_CLK) - srate = M_CLK; - if (srate < 500000) - srate = 500000; - - if (srate < 30000000) { aclk = 0xb6; bclk = 0x53; } - if (srate < 14000000) { aclk = 0xb7; bclk = 0x53; } - if (srate < 7000000) { aclk = 0xb7; bclk = 0x4f; } - if (srate < 3000000) { aclk = 0xb7; bclk = 0x4b; } - if (srate < 1500000) { aclk = 0xb7; bclk = 0x47; } - - stv0299_writereg (i2c, 0x13, aclk); - stv0299_writereg (i2c, 0x14, bclk); + u8 aclk = 0; + u8 bclk = 0; + u8 m1; + + if ((srate < 1000000) || (srate > 45000000)) return -EINVAL; + switch(tuner_type) { + case PHILIPS_SU1278SH: + aclk = 0xb5; + if (srate < 2000000) bclk = 0x86; + else if (srate < 5000000) bclk = 0x89; + else if (srate < 15000000) bclk = 0x8f; + else if (srate < 45000000) bclk = 0x95; + + m1 = 0x14; + if (srate < 4000000) m1 = 0x10; + break; + + case ALPS_BSRU6: + default: + if (srate <= 1500000) { aclk = 0xb7; bclk = 0x87; } + else if (srate <= 3000000) { aclk = 0xb7; bclk = 0x8b; } + else if (srate <= 7000000) { aclk = 0xb7; bclk = 0x8f; } + else if (srate <= 14000000) { aclk = 0xb7; bclk = 0x93; } + else if (srate <= 30000000) { aclk = 0xb6; bclk = 0x93; } + else if (srate <= 45000000) { aclk = 0xb4; bclk = 0x91; } + + m1 = 0x12; + break; + } dprintk("%s : big = 0x%08x%08x\n", __FUNCTION__, (int) ((big>>32) & 0xffffffff), (int) (big & 0xffffffff) ); @@ -781,10 +820,13 @@ static int stv0299_set_symbolrate (struct dvb_i2c_bus *i2c, u32 srate) ratio = big << 4; dprintk("%s : ratio = %i\n", __FUNCTION__, ratio); - + + stv0299_writereg (i2c, 0x13, aclk); + stv0299_writereg (i2c, 0x14, bclk); stv0299_writereg (i2c, 0x1f, (ratio >> 16) & 0xff); stv0299_writereg (i2c, 0x20, (ratio >> 8) & 0xff); stv0299_writereg (i2c, 0x21, (ratio ) & 0xf0); + stv0299_writereg (i2c, 0x0f, (stv0299_readreg(i2c, 0x0f) & 0xc0) | m1); return 0; } @@ -906,7 +948,7 @@ static int uni0299_ioctl (struct dvb_frontend *fe, unsigned int cmd, void *arg) p->u.qpsk.symbol_rate); stv0299_set_FEC (i2c, p->u.qpsk.fec_inner); - stv0299_set_symbolrate (i2c, p->u.qpsk.symbol_rate); + stv0299_set_symbolrate (i2c, p->u.qpsk.symbol_rate, tuner_type); stv0299_writereg (i2c, 0x22, 0x00); stv0299_writereg (i2c, 0x23, 0x00); stv0299_readreg (i2c, 0x23); |