⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 l64781.c

📁 trident tm5600的linux驱动
💻 C
📖 第 1 页 / 共 2 页
字号:
	case 4:		param->u.ofdm.code_rate_LP = FEC_7_8;		break;	default:		printk("Unexpected value for code_rate_LP\n");	}	tmp = l64781_readreg(state, 0x06);	switch(tmp & 3) {	case 0:		param->u.ofdm.constellation = QPSK;		break;	case 1:		param->u.ofdm.constellation = QAM_16;		break;	case 2:		param->u.ofdm.constellation = QAM_64;		break;	default:		printk("Unexpected value for constellation\n");	}	switch((tmp >> 2) & 7) {	case 0:		param->u.ofdm.hierarchy_information = HIERARCHY_NONE;		break;	case 1:		param->u.ofdm.hierarchy_information = HIERARCHY_1;		break;	case 2:		param->u.ofdm.hierarchy_information = HIERARCHY_2;		break;	case 3:		param->u.ofdm.hierarchy_information = HIERARCHY_4;		break;	default:		printk("Unexpected value for hierarchy\n");	}	tmp = l64781_readreg (state, 0x1d);	param->inversion = (tmp & 0x80) ? INVERSION_ON : INVERSION_OFF;	tmp = (int) (l64781_readreg (state, 0x08) |		     (l64781_readreg (state, 0x09) << 8) |		     (l64781_readreg (state, 0x0a) << 16));	param->frequency += tmp;	return 0;}static int l64781_read_status(struct dvb_frontend* fe, fe_status_t* status){	struct l64781_state* state = fe->demodulator_priv;	int sync = l64781_readreg (state, 0x32);	int gain = l64781_readreg (state, 0x0e);	l64781_readreg (state, 0x00);  /*  clear interrupt registers... */	l64781_readreg (state, 0x01);  /*  dto. */	*status = 0;	if (gain > 5)		*status |= FE_HAS_SIGNAL;	if (sync & 0x02) /* VCXO locked, this criteria should be ok */		*status |= FE_HAS_CARRIER;	if (sync & 0x20)		*status |= FE_HAS_VITERBI;	if (sync & 0x40)		*status |= FE_HAS_SYNC;	if (sync == 0x7f)		*status |= FE_HAS_LOCK;	return 0;}static int l64781_read_ber(struct dvb_frontend* fe, u32* ber){	struct l64781_state* state = fe->demodulator_priv;	/*   XXX FIXME: set up counting period (reg 0x26...0x28)	 */	*ber = l64781_readreg (state, 0x39)	    | (l64781_readreg (state, 0x3a) << 8);	return 0;}static int l64781_read_signal_strength(struct dvb_frontend* fe, u16* signal_strength){	struct l64781_state* state = fe->demodulator_priv;	u8 gain = l64781_readreg (state, 0x0e);	*signal_strength = (gain << 8) | gain;	return 0;}static int l64781_read_snr(struct dvb_frontend* fe, u16* snr){	struct l64781_state* state = fe->demodulator_priv;	u8 avg_quality = 0xff - l64781_readreg (state, 0x33);	*snr = (avg_quality << 8) | avg_quality; /* not exact, but...*/	return 0;}static int l64781_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks){	struct l64781_state* state = fe->demodulator_priv;	*ucblocks = l64781_readreg (state, 0x37)	   | (l64781_readreg (state, 0x38) << 8);	return 0;}static int l64781_sleep(struct dvb_frontend* fe){	struct l64781_state* state = fe->demodulator_priv;	/* Power down */	return l64781_writereg (state, 0x3e, 0x5a);}static int l64781_init(struct dvb_frontend* fe){	struct l64781_state* state = fe->demodulator_priv;	reset_and_configure (state);	/* Power up */	l64781_writereg (state, 0x3e, 0xa5);	/* Reset hard */	l64781_writereg (state, 0x2a, 0x04);	l64781_writereg (state, 0x2a, 0x00);	/* Set tuner specific things */	/* AFC_POL, set also in reset_afc */	l64781_writereg (state, 0x07, 0x8e);	/* Use internal ADC */	l64781_writereg (state, 0x0b, 0x81);	/* AGC loop gain, and polarity is positive */	l64781_writereg (state, 0x0c, 0x84);	/* Internal ADC outputs two's complement */	l64781_writereg (state, 0x0d, 0x8c);	/* With ppm=8000, it seems the DTR_SENSITIVITY will result in	   value of 2 with all possible bandwidths and guard	   intervals, which is the initial value anyway. */	/*l64781_writereg (state, 0x19, 0x92);*/	/* Everything is two's complement, soft bit and CSI_OUT too */	l64781_writereg (state, 0x1e, 0x09);	/* delay a bit after first init attempt */	if (state->first) {		state->first = 0;		msleep(200);	}	return 0;}static int l64781_get_tune_settings(struct dvb_frontend* fe,				    struct dvb_frontend_tune_settings* fesettings){	fesettings->min_delay_ms = 4000;	fesettings->step_size = 0;	fesettings->max_drift = 0;	return 0;}static void l64781_release(struct dvb_frontend* fe){	struct l64781_state* state = fe->demodulator_priv;	kfree(state);}static struct dvb_frontend_ops l64781_ops;struct dvb_frontend* l64781_attach(const struct l64781_config* config,				   struct i2c_adapter* i2c){	struct l64781_state* state = NULL;	int reg0x3e = -1;	u8 b0 [] = { 0x1a };	u8 b1 [] = { 0x00 };	struct i2c_msg msg [] = { { .addr = config->demod_address, .flags = 0, .buf = b0, .len = 1 },			   { .addr = config->demod_address, .flags = I2C_M_RD, .buf = b1, .len = 1 } };	/* allocate memory for the internal state */	state = kmalloc(sizeof(struct l64781_state), GFP_KERNEL);	if (state == NULL) goto error;	/* setup the state */	state->config = config;	state->i2c = i2c;	state->first = 1;	/**	 *  the L64781 won't show up before we send the reset_and_configure()	 *  broadcast. If nothing responds there is no L64781 on the bus...	 */	if (reset_and_configure(state) < 0) {		dprintk("No response to reset and configure broadcast...\n");		goto error;	}	/* The chip always responds to reads */	if (i2c_transfer(state->i2c, msg, 2) != 2) {		dprintk("No response to read on I2C bus\n");		goto error;	}	/* Save current register contents for bailout */	reg0x3e = l64781_readreg(state, 0x3e);	/* Reading the POWER_DOWN register always returns 0 */	if (reg0x3e != 0) {		dprintk("Device doesn't look like L64781\n");		goto error;	}	/* Turn the chip off */	l64781_writereg (state, 0x3e, 0x5a);	/* Responds to all reads with 0 */	if (l64781_readreg(state, 0x1a) != 0) {		dprintk("Read 1 returned unexpcted value\n");		goto error;	}	/* Turn the chip on */	l64781_writereg (state, 0x3e, 0xa5);	/* Responds with register default value */	if (l64781_readreg(state, 0x1a) != 0xa1) {		dprintk("Read 2 returned unexpcted value\n");		goto error;	}	/* create dvb_frontend */	memcpy(&state->frontend.ops, &l64781_ops, sizeof(struct dvb_frontend_ops));	state->frontend.demodulator_priv = state;	return &state->frontend;error:	if (reg0x3e >= 0)		l64781_writereg (state, 0x3e, reg0x3e);  /* restore reg 0x3e */	kfree(state);	return NULL;}static struct dvb_frontend_ops l64781_ops = {	.info = {		.name = "LSI L64781 DVB-T",		.type = FE_OFDM,	/*	.frequency_min = ???,*/	/*	.frequency_max = ???,*/		.frequency_stepsize = 166666,	/*      .frequency_tolerance = ???,*/	/*      .symbol_rate_tolerance = ???,*/		.caps = FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |		      FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 |		      FE_CAN_QPSK | FE_CAN_QAM_16 | FE_CAN_QAM_64 |		      FE_CAN_MUTE_TS	},	.release = l64781_release,	.init = l64781_init,	.sleep = l64781_sleep,	.set_frontend = apply_frontend_param,	.get_frontend = get_frontend,	.get_tune_settings = l64781_get_tune_settings,	.read_status = l64781_read_status,	.read_ber = l64781_read_ber,	.read_signal_strength = l64781_read_signal_strength,	.read_snr = l64781_read_snr,	.read_ucblocks = l64781_read_ucblocks,};MODULE_DESCRIPTION("LSI L64781 DVB-T Demodulator driver");MODULE_AUTHOR("Holger Waechtler, Marko Kohtala");MODULE_LICENSE("GPL");EXPORT_SYMBOL(l64781_attach);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -