Index: driver/dvb_frontend.c =================================================================== RCS file: /cvs/linuxtv/DVB/driver/dvb_frontend.c,v retrieving revision 1.40 diff -u -r1.40 dvb_frontend.c --- driver/dvb_frontend.c 2 Jan 2003 11:27:46 -0000 1.40 +++ driver/dvb_frontend.c 6 Jan 2003 22:15:13 -0000 @@ -318,6 +318,10 @@ __FUNCTION__, param->frequency, fe->lnb_drift); param->frequency += fe->lnb_drift + fe->bending; + printk ("%i:%i: drift: %c%u.%06u, bending: %c%u.%06u\n", + fe->frontend.i2c->adapter->num, fe->frontend.i2c->id, + fe->lnb_drift < 0 ? '-' : '+', abs(fe->lnb_drift) / 1000000, abs(fe->lnb_drift) % 1000000, + fe->bending < 0 ? '-' : '+', abs(fe->bending) / 1000000, abs(fe->bending) % 1000000); err = dvb_frontend_internal_ioctl (frontend, FE_SET_FRONTEND, param); param->frequency -= fe->lnb_drift + fe->bending; @@ -359,7 +363,7 @@ #define LNB_DRIFT 1024 /* max. tolerated LNB drift, XXX FIXME: adjust! */ -#define TIMEOUT 2*HZ +#define TIMEOUT 4*HZ /** * here we only come when we have lost the lock bit, @@ -389,18 +393,20 @@ */ { int j = fe->lost_sync_count; - int stepsize; + int stepsize = 0; if (fe->info->type == FE_QPSK) stepsize = fe->parameters.u.qpsk.symbol_rate / 16000; + else if (fe->info->type == FE_QAM) + stepsize = fe->info->frequency_stepsize; else stepsize = fe->info->frequency_stepsize * 2; - if (j % 32 == 0) { + if (j % 64 == 0 || fe->info->type == FE_QAM && j % 16 == 0) { fe->lnb_drift = 0; - } else { + } else if (j % 2) { fe->lnb_drift = -fe->lnb_drift; - if (j % 2) + if (j % 4) fe->lnb_drift += stepsize; } @@ -452,6 +458,8 @@ while (!dvb_frontend_is_exiting (fe)) { up (&fe->sem); /* is locked when we enter the thread... */ + if (fe->lost_sync_count > 0) + printk ("%i:%i: delay: %d.%06ds\n", fe->frontend.i2c->adapter->num, fe->frontend.i2c->id, delay / HZ, (delay % HZ) * 1000000/HZ); interruptible_sleep_on_timeout (&fe->wait_queue, delay); if (down_interruptible (&fe->sem)) { @@ -464,6 +472,8 @@ if (dvb_frontend_is_exiting (fe)) break; + if (-1 == fe->lost_sync_count) + continue; dvb_frontend_internal_ioctl (&fe->frontend, FE_READ_STATUS, &s); @@ -479,8 +489,13 @@ if (!(fe->info->caps & FE_CAN_CLEAN_SETUP)) if (fe->lost_sync_count < 10) continue; - dvb_frontend_recover (fe); + if (fe->lost_sync_count > 1) { + printk ("%i:%i: call recover\n", fe->frontend.i2c->adapter->num, fe->frontend.i2c->id); + dvb_frontend_recover (fe); + } delay = HZ/5; + //if (fe->info->type == FE_QAM) + // delay = HZ; if (jiffies - fe->lost_sync_jiffies > TIMEOUT) { s |= FE_TIMEDOUT; if ((fe->status & FE_TIMEDOUT) == 0) @@ -951,3 +966,6 @@ MODULE_PARM_DESC(dvb_frontend_debug, "enable verbose debug messages"); MODULE_PARM_DESC(dvb_shutdown_timeout, "wait seconds after close() before suspending hardware"); +// Local variables: +// c-basic-offset: 8 +// End: Index: driver/frontends/ves1820.c =================================================================== RCS file: /cvs/linuxtv/DVB/driver/frontends/ves1820.c,v retrieving revision 1.15 diff -u -r1.15 ves1820.c --- driver/frontends/ves1820.c 27 Nov 2002 11:24:20 -0000 1.15 +++ driver/frontends/ves1820.c 6 Jan 2003 22:15:14 -0000 @@ -27,7 +27,7 @@ #include "dvb_frontend.h" -#if 0 +#if 1 #define dprintk(x...) printk(x) #else #define dprintk(x...) @@ -168,9 +168,27 @@ * set up the downconverter frequency divisor for a * reference clock comparision frequency of 62.5 kHz. */ + +/* + * Tuner Mitel SP5659 (tuner_type==1) + * buf[2]: 1 2^16 2^15 PE R3 R2 R1 R0 + * 1 0 0 0 0 1 0 1 + * PE = prescaler, enables 2.7GHz operation. Not needed, set to 0 + * 2^16, 2^15 = high bits of divider + * R3..0 = division ratio, 0101 = 64, corresponds to comp. freq 62.5kHz + * with 4MHz external reference. + * buf[3]: C1 C0 RE RTS P3 P2/TS2 P1/TS1 P0/TS0 + * 1 0 0 0 0 1 0 0 + * C1,0 = charge pump current, 10 = +-555ľA + * RE = REF/COMP output enable + * RTS = 0=REF output, 1=COMP output. (RE,RTS)=(0,0) = normal operation. + * TS2..0 = test mode control bits + * P3..0 = port P3..0 output, 1000 (<174MHz), 0100 (<470MHz), 0001 (>470MHz) + */ static int tuner_set_tv_freq (struct dvb_frontend *fe, u32 freq) { + static const u32 ifreq = 35937500; u32 div; static u8 addr [] = { 0x61, 0x62 }; static u8 byte3 [] = { 0x8e, 0x85 }; @@ -180,7 +198,7 @@ if (tuner_type == 0xff) /* PLL not reachable over i2c ... */ return 0; - div = (freq + 36250000 + 31250) / 62500; + div = (freq + ifreq + 31250) / 62500; buf[0] = (div >> 8) & 0x7f; buf[1] = div & 0xff; buf[2] = byte3[tuner_type]; @@ -194,6 +212,11 @@ freq < 454000000 ? 0x92 : 0x34); } + dprintk ("%s: tuning to %u.%06u MHz\n", + __FILE__, + (div * 62500 - ifreq) / 1000000, + (div * 62500 - ifreq) % 1000000); + return tuner_write (fe->i2c, addr[tuner_type], buf); } @@ -202,10 +225,13 @@ int ves1820_setup_reg0 (struct dvb_frontend *fe, u8 reg0) { reg0 |= GET_REG0(fe->data) & 0x62; + + reg0 |= 0x20; ves1820_writereg (fe, 0x00, reg0 & 0xfe); ves1820_writereg (fe, 0x00, reg0 | 0x01); +#if 0 /** * check lock and toggle inversion bit if required... */ @@ -217,6 +243,7 @@ ves1820_writereg (fe, 0x00, reg0 | 0x01); } } +#endif SET_REG0(fe->data, reg0); @@ -306,7 +333,7 @@ struct dvb_frontend_parameters *p) { static const u8 reg0x00 [] = { 0x00, 0x04, 0x08, 0x0c, 0x10 }; - static const u8 reg0x01 [] = { 140, 140, 106, 120, 92 }; + static const u8 reg0x01 [] = { 140, 140, 106, 100, 92 }; static const u8 reg0x05 [] = { 135, 100, 70, 54, 38 }; static const u8 reg0x08 [] = { 162, 116, 67, 52, 35 }; static const u8 reg0x09 [] = { 145, 150, 106, 126, 107 }; @@ -388,6 +415,13 @@ break; } + case FE_READ_AFC: + { + s8 offset = ves1820_readreg(fe, 0x19); + *((s32*) arg) = (s32)offset; + break; + } + case FE_READ_UNCORRECTED_BLOCKS: *((u32*) arg) = ves1820_readreg (fe, 0x13) & 0x7f; if (*((u32*) arg) == 0x7f) @@ -544,3 +578,7 @@ MODULE_AUTHOR("Ralph Metzler, Holger Waechtler"); MODULE_LICENSE("GPL"); + +// Local variables: +// c-basic-offset: 8 +// End: Index: include/linux/dvb/frontend.h =================================================================== RCS file: /cvs/linuxtv/DVB/include/linux/dvb/frontend.h,v retrieving revision 1.5 diff -u -r1.5 frontend.h --- include/linux/dvb/frontend.h 18 Nov 2002 22:00:27 -0000 1.5 +++ include/linux/dvb/frontend.h 6 Jan 2003 22:15:15 -0000 @@ -257,6 +257,30 @@ #define FE_GET_FRONTEND _IOR('o', 77, struct dvb_frontend_parameters) #define FE_GET_EVENT _IOR('o', 78, struct dvb_frontend_event) +struct dvb_qam_setting { + fe_modulation_t QAM_Mode; + int NoOfSym; + uint8_t Reg1; + uint8_t Reg5; + uint8_t Reg8; + uint8_t Reg9; +}; + +#define FE_SET_QAM _IOW('o', 79, struct dvb_qam_setting) +#define FE_SET_FREQ _IOW('o', 80, uint32_t) +#define FE_RESET_PWM _IO('o', 81) +#define FE_READ_AFC _IOR('o', 82, int32_t) + +/* dvb_frontend.h has these for private use */ +#ifndef FE_SLEEP +#define FE_SLEEP _IO('v', 80) +#endif +#ifndef FE_INIT +#define FE_INIT _IO('v', 81) +#endif +#ifndef FE_RESET +#define FE_RESET _IO('v', 82) +#endif #endif /*_FRONTEND_H_*/