if ((frequency_delta > -minmax) && (frequency_delta < minmax) && (frequency_delta != 0) && (state->fec_inner == p->u.qpsk.fec_inner) && (state->symbol_rate == p->u.qpsk.symbol_rate)) { int Drot_freq = (frequency_delta << 16) / (state->config->mclk / 1000);   stv0299_writeregI(state, 0x22, 0x00); stv0299_writeregI(state, 0x23, 0x00);   stv0299_writeregI(state, 0x22, Drot_freq >> 8); stv0299_writeregI(state, 0x23, Drot_freq); } else { /* A "normal" tune is requested */ stv0299_writeregI(state, 0x05, 0xb5);	/*  enable i2c repeater on stv0299  */ state->config->pll_set(fe, state->i2c, p); stv0299_writeregI(state, 0x05, 0x35);	/*  disable i2c repeater on stv0299  */  stv0299_writeregI(state, 0x32, 0x80); stv0299_writeregI(state, 0x22, 0x00); stv0299_writeregI(state, 0x23, 0x00); stv0299_writeregI(state, 0x32, 0x19); stv0299_set_symbolrate (fe, p->u.qpsk.symbol_rate); stv0299_set_FEC (state, p->u.qpsk.fec_inner); } } else { stv0299_writeregI(state, 0x05, 0xb5);	/*  enable i2c repeater on stv0299  */ state->config->pll_set(fe, state->i2c, p); stv0299_writeregI(state, 0x05, 0x35);	/*  disable i2c repeater on stv0299  */  stv0299_set_FEC (state, p->u.qpsk.fec_inner); stv0299_set_symbolrate (fe, p->u.qpsk.symbol_rate); stv0299_writeregI(state, 0x22, 0x00); stv0299_writeregI(state, 0x23, 0x00); stv0299_readreg (state, 0x23); stv0299_writeregI(state, 0x12, 0xb9); } 
stv0299_set_FEC (state, p->u.qpsk.fec_inner); stv0299_set_symbolrate (fe, p->u.qpsk.symbol_rate); stv0299_writeregI(state, 0x22, 0x00); stv0299_writeregI(state, 0x23, 0x00); stv0299_readreg (state, 0x23); stv0299_writeregI(state, 0x12, 0xb9); 
static int stv0299_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters * p){        struct stv0299_state* state = fe->demodulator_priv;	int invval = 0;	dprintk ("%s : FE_SET_FRONTEND\n", __FUNCTION__);	// set the inversion	if (p->inversion == INVERSION_OFF) invval = 0;	else if (p->inversion == INVERSION_ON) invval = 1;	else {		printk("stv0299 does not support auto-inversion\n");		return -EINVAL;	}	if (state->config->invert) invval = (~invval) & 1;	stv0299_writeregI(state, 0x0c, (stv0299_readreg(state, 0x0c) & 0xfe) | invval);	if (state->config->enhanced_tuning) {		/* check if we should do a finetune */		int frequency_delta = p->frequency - state->tuner_frequency;		int minmax = p->u.qpsk.symbol_rate / 2000;		if (minmax < 5000) minmax = 5000;		if ((frequency_delta > -minmax) && (frequency_delta < minmax) && (frequency_delta != 0) &&		    (state->fec_inner == p->u.qpsk.fec_inner) &&		    (state->symbol_rate == p->u.qpsk.symbol_rate)) {			int Drot_freq = (frequency_delta << 16) / (state->config->mclk / 1000);			// zap the derotator registers first			stv0299_writeregI(state, 0x22, 0x00);			stv0299_writeregI(state, 0x23, 0x00);			// now set them as we want			stv0299_writeregI(state, 0x22, Drot_freq >> 8);			stv0299_writeregI(state, 0x23, Drot_freq);		} else {			/* A "normal" tune is requested */			stv0299_writeregI(state, 0x05, 0xb5);	/*  enable i2c repeater on stv0299  */			state->config->pll_set(fe, state->i2c, p);			stv0299_writeregI(state, 0x05, 0x35);	/*  disable i2c repeater on stv0299  */			stv0299_writeregI(state, 0x32, 0x80);			stv0299_writeregI(state, 0x22, 0x00);			stv0299_writeregI(state, 0x23, 0x00);			stv0299_writeregI(state, 0x32, 0x19);			stv0299_set_symbolrate (fe, p->u.qpsk.symbol_rate);			stv0299_set_FEC (state, p->u.qpsk.fec_inner);		}	} else {		stv0299_writeregI(state, 0x05, 0xb5);	/*  enable i2c repeater on stv0299  */		state->config->pll_set(fe, state->i2c, p);		stv0299_writeregI(state, 0x05, 0x35);	/*  disable i2c repeater on stv0299  */		stv0299_set_FEC (state, p->u.qpsk.fec_inner);		stv0299_set_symbolrate (fe, p->u.qpsk.symbol_rate);		stv0299_writeregI(state, 0x22, 0x00);		stv0299_writeregI(state, 0x23, 0x00);		stv0299_readreg (state, 0x23);		stv0299_writeregI(state, 0x12, 0xb9);	}	state->tuner_frequency = p->frequency;	state->fec_inner = p->u.qpsk.fec_inner;	state->symbol_rate = p->u.qpsk.symbol_rate;	return 0;}
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/3528cc4e731b098b5743f8f91516e2e6c01dd1ce/stv0299.c/buggy/drivers/media/dvb/frontends/stv0299.c