struct mt312_state *state = (struct mt312_state*) fe->demodulator_priv; 
struct mt312_state *state = fe->demodulator_priv; 
static int mt312_set_frontend(struct dvb_frontend* fe,			      struct dvb_frontend_parameters *p){	struct mt312_state *state = (struct mt312_state*) fe->demodulator_priv;	int ret;	u8 buf[5], config_val;	u16 sr;	const u8 fec_tab[10] =	    { 0x00, 0x01, 0x02, 0x04, 0x3f, 0x08, 0x10, 0x20, 0x3f, 0x3f };	const u8 inv_tab[3] = { 0x00, 0x40, 0x80 };	dprintk("%s: Freq %d\n", __FUNCTION__, p->frequency);	if ((p->frequency < fe->ops->info.frequency_min)	    || (p->frequency > fe->ops->info.frequency_max))		return -EINVAL;	if ((p->inversion < INVERSION_OFF)	    || (p->inversion > INVERSION_ON))		return -EINVAL;	if ((p->u.qpsk.symbol_rate < fe->ops->info.symbol_rate_min)	    || (p->u.qpsk.symbol_rate > fe->ops->info.symbol_rate_max))		return -EINVAL;	if ((p->u.qpsk.fec_inner < FEC_NONE)	    || (p->u.qpsk.fec_inner > FEC_AUTO))		return -EINVAL;	if ((p->u.qpsk.fec_inner == FEC_4_5)	    || (p->u.qpsk.fec_inner == FEC_8_9))		return -EINVAL;	switch (state->id) {	case ID_VP310:	// For now we will do this only for the VP310.	// It should be better for the mt312 as well, but tunning will be slower. ACCJr 09/29/03		if ((ret = mt312_readreg(state, CONFIG, &config_val) < 0))			return ret;		if (p->u.qpsk.symbol_rate >= 30000000) //Note that 30MS/s should use 90MHz		{			if ((config_val & 0x0c) == 0x08) { //We are running 60MHz				state->frequency = 90;				if ((ret = mt312_initfe(fe)) < 0)					return ret;			}		}		else		{			if ((config_val & 0x0c) == 0x0C) { //We are running 90MHz				state->frequency = 60;				if ((ret = mt312_initfe(fe)) < 0)					return ret;			}		}		break;	case ID_MT312:		break;	default:		return -EINVAL;	}	mt312_writereg(state, GPP_CTRL, 0x40);	state->config->pll_set(fe, p);	mt312_writereg(state, GPP_CTRL, 0x00);	/* sr = (u16)(sr * 256.0 / 1000000.0) */	sr = mt312_div(p->u.qpsk.symbol_rate * 4, 15625);	/* SYM_RATE */	buf[0] = (sr >> 8) & 0x3f;	buf[1] = (sr >> 0) & 0xff;	/* VIT_MODE */	buf[2] = inv_tab[p->inversion] | fec_tab[p->u.qpsk.fec_inner];	/* QPSK_CTRL */	buf[3] = 0x40;		/* swap I and Q before QPSK demodulation */	if (p->u.qpsk.symbol_rate < 10000000)		buf[3] |= 0x04;	/* use afc mode */	/* GO */	buf[4] = 0x01;	if ((ret = mt312_write(state, SYM_RATE_H, buf, sizeof(buf))) < 0)		return ret;        mt312_reset(state, 0);	return 0;}
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/b8742700f13163ffa00cddce2a3c940b9ab2ab5a/mt312.c/clean/drivers/media/dvb/frontends/mt312.c