On Sat, 25 Oct 2003 23:28:41 +0100 Andrew de Quincey <[EMAIL PROTECTED]> wrote:
> This isn't the final patch; I still have to write the frequency divisor > selection code as suggested by Robert Schlabbach. I'll commit the final > version to CVS myself, once I've had some feedback (assuming its +ve > feedback that is :) I did a backport to the "DVB" tree (attached). Reception is still not perfect but did improve in most situations. Please do some more tweaking! :) +++++ unpatched *** CARD0 - V card 0, tp tp104, pid 255: 0 errors in TS *** CARD1 - V card 1, tp tp104, pid 255: 11 errors in TS *** CARD0 - H card 0, tp tp89, pid 163: 0 errors in TS *** CARD1 - H card 1, tp tp89, pid 163: 0 errors in TS *** CARD0 - V, CARD1 - V card 0, tp tp104, pid 255: 408 errors in TS card 1, tp tp104, pid 255: 101 errors in TS *** CARD0 - H, CARD1 - H card 0, tp tp89, pid 163: 0 errors in TS card 1, tp tp89, pid 163: 0 errors in TS *** CARD0 - V, CARD1 - H card 0, tp tp104, pid 255: 2 errors in TS card 1, tp tp89, pid 163: 0 errors in TS *** CARD0 - H, CARD1 - V card 0, tp tp89, pid 163: 0 errors in TS card 1, tp tp104, pid 255: 18 errors in TS +++++ patched *** CARD0 - V card 0, tp tp104, pid 255: 0 errors in TS *** CARD1 - V card 1, tp tp104, pid 255: 0 errors in TS *** CARD0 - H card 0, tp tp89, pid 163: 0 errors in TS *** CARD1 - H card 1, tp tp89, pid 163: 0 errors in TS *** CARD0 - V, CARD1 - V card 0, tp tp104, pid 255: 0 errors in TS card 1, tp tp104, pid 255: 0 errors in TS *** CARD0 - H, CARD1 - H card 0, tp tp89, pid 163: 0 errors in TS card 1, tp tp89, pid 163: 0 errors in TS *** CARD0 - V, CARD1 - H card 0, tp tp104, pid 255: 4 errors in TS card 1, tp tp89, pid 163: 0 errors in TS *** CARD0 - H, CARD1 - V card 0, tp tp89, pid 163: 0 errors in TS card 1, tp tp104, pid 255: 181 errors in TS (sampling time 40s) Regards, -- Steffen Beyer <[EMAIL PROTECTED]> GnuPG key fingerprint: 6C9B 2844 AF75 AC7A C38C 9FFD 06CB A788 398B D2D9 Public key available upon request or at http://wwwkeys.pgp.net
--- DVB-cvs/driver/frontends/stv0299.c 2003-08-01 01:15:45.000000000 +0200
+++ DVB-cvs-adqpatch/driver/frontends/stv0299.c 2003-10-26 05:06:44.000000000 +0100
@@ -303,31 +303,53 @@
* reference clock comparision frequency of 125 kHz.
*/
static
-int tsa5059_set_tv_freq (struct dvb_i2c_bus *i2c, u32 freq, int ftype)
+int tsa5059_set_tv_freq (struct dvb_i2c_bus *i2c, u32 freq, int ftype, int srate)
{
- u32 div = freq / 125;
+ u32 div;
+ u8 buf[4];
- u8 buf[4] = { (div >> 8) & 0x7f, div & 0xff, 0x84 };
-
- 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:
+ 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:
+ buf[3] |= 0xC0;
+ break;
+
+ default:
+ return -EINVAL;
+ }
+
dprintk ("%s\n", __FUNCTION__);
return pll_write (i2c, buf, ftype);
}
static
-int pll_set_tv_freq (struct dvb_i2c_bus *i2c, u32 freq, int ftype)
+int pll_set_tv_freq (struct dvb_i2c_bus *i2c, u32 freq, int ftype, int srate)
{
if (ftype == LG_TDQF_S001F)
return sl1935_set_tv_freq(i2c, freq, ftype);
else
- return tsa5059_set_tv_freq(i2c, freq, ftype);
+ return tsa5059_set_tv_freq(i2c, freq, ftype, srate);
}
#if 0
@@ -365,7 +387,7 @@
/* 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
stv0299_writereg (i2c, 0x0f, 0x52); /* Iagc = Normal, m1 = 18 */
@@ -593,22 +615,41 @@
static
-int stv0299_set_symbolrate (struct dvb_i2c_bus *i2c, u32 srate)
+int stv0299_set_symbolrate (struct dvb_i2c_bus *i2c, u32 srate, int ftype)
{
u32 ratio;
u32 tmp;
- u8 aclk = 0xb4, bclk = 0x51;
+ u8 aclk = 0;
+ u8 bclk = 0;
+ u8 m1;
+
+ if ((srate < 1000000) || (srate > 45000000)) return -EINVAL;
+
+ switch (ftype) {
+ 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;
+ }
- 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; }
#define FIN (M_CLK >> 4)
@@ -626,6 +667,7 @@
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;
}
@@ -740,9 +782,9 @@
{
struct dvb_frontend_parameters *p = arg;
- pll_set_tv_freq (i2c, p->frequency, tuner_type);
+ pll_set_tv_freq (i2c, p->frequency, tuner_type, 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);
pgp00000.pgp
Description: PGP signature
