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

📄 budget-av.c

📁 linux 内核源代码
💻 C
📖 第 1 页 / 共 3 页
字号:
}static int saa7113_setinput(struct budget_av *budget_av, int input){	struct budget *budget = &budget_av->budget;	if (1 != budget_av->has_saa7113)		return -ENODEV;	if (input == 1) {		i2c_writereg(&budget->i2c_adap, 0x4a, 0x02, 0xc7);		i2c_writereg(&budget->i2c_adap, 0x4a, 0x09, 0x80);	} else if (input == 0) {		i2c_writereg(&budget->i2c_adap, 0x4a, 0x02, 0xc0);		i2c_writereg(&budget->i2c_adap, 0x4a, 0x09, 0x00);	} else		return -EINVAL;	budget_av->cur_input = input;	return 0;}static int philips_su1278_ty_ci_set_symbol_rate(struct dvb_frontend *fe, u32 srate, u32 ratio){	u8 aclk = 0;	u8 bclk = 0;	u8 m1;	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;	stv0299_writereg(fe, 0x13, aclk);	stv0299_writereg(fe, 0x14, bclk);	stv0299_writereg(fe, 0x1f, (ratio >> 16) & 0xff);	stv0299_writereg(fe, 0x20, (ratio >> 8) & 0xff);	stv0299_writereg(fe, 0x21, (ratio) & 0xf0);	stv0299_writereg(fe, 0x0f, 0x80 | m1);	return 0;}static int philips_su1278_ty_ci_tuner_set_params(struct dvb_frontend *fe,						 struct dvb_frontend_parameters *params){	u32 div;	u8 buf[4];	struct budget *budget = (struct budget *) fe->dvb->priv;	struct i2c_msg msg = {.addr = 0x61,.flags = 0,.buf = buf,.len = sizeof(buf) };	if ((params->frequency < 950000) || (params->frequency > 2150000))		return -EINVAL;	div = (params->frequency + (125 - 1)) / 125;	// round correctly	buf[0] = (div >> 8) & 0x7f;	buf[1] = div & 0xff;	buf[2] = 0x80 | ((div & 0x18000) >> 10) | 4;	buf[3] = 0x20;	if (params->u.qpsk.symbol_rate < 4000000)		buf[3] |= 1;	if (params->frequency < 1250000)		buf[3] |= 0;	else if (params->frequency < 1550000)		buf[3] |= 0x40;	else if (params->frequency < 2050000)		buf[3] |= 0x80;	else if (params->frequency < 2150000)		buf[3] |= 0xC0;	if (fe->ops.i2c_gate_ctrl)		fe->ops.i2c_gate_ctrl(fe, 1);	if (i2c_transfer(&budget->i2c_adap, &msg, 1) != 1)		return -EIO;	return 0;}static u8 typhoon_cinergy1200s_inittab[] = {	0x01, 0x15,	0x02, 0x30,	0x03, 0x00,	0x04, 0x7d,		/* F22FR = 0x7d, F22 = f_VCO / 128 / 0x7d = 22 kHz */	0x05, 0x35,		/* I2CT = 0, SCLT = 1, SDAT = 1 */	0x06, 0x40,		/* DAC not used, set to high impendance mode */	0x07, 0x00,		/* DAC LSB */	0x08, 0x40,		/* DiSEqC off */	0x09, 0x00,		/* FIFO */	0x0c, 0x51,		/* OP1 ctl = Normal, OP1 val = 1 (LNB Power ON) */	0x0d, 0x82,		/* DC offset compensation = ON, beta_agc1 = 2 */	0x0e, 0x23,		/* alpha_tmg = 2, beta_tmg = 3 */	0x10, 0x3f,		// AGC2  0x3d	0x11, 0x84,	0x12, 0xb9,	0x15, 0xc9,		// lock detector threshold	0x16, 0x00,	0x17, 0x00,	0x18, 0x00,	0x19, 0x00,	0x1a, 0x00,	0x1f, 0x50,	0x20, 0x00,	0x21, 0x00,	0x22, 0x00,	0x23, 0x00,	0x28, 0x00,		// out imp: normal  out type: parallel FEC mode:0	0x29, 0x1e,		// 1/2 threshold	0x2a, 0x14,		// 2/3 threshold	0x2b, 0x0f,		// 3/4 threshold	0x2c, 0x09,		// 5/6 threshold	0x2d, 0x05,		// 7/8 threshold	0x2e, 0x01,	0x31, 0x1f,		// test all FECs	0x32, 0x19,		// viterbi and synchro search	0x33, 0xfc,		// rs control	0x34, 0x93,		// error control	0x0f, 0x92,	0xff, 0xff};static struct stv0299_config typhoon_config = {	.demod_address = 0x68,	.inittab = typhoon_cinergy1200s_inittab,	.mclk = 88000000UL,	.invert = 0,	.skip_reinit = 0,	.lock_output = STV0229_LOCKOUTPUT_1,	.volt13_op0_op1 = STV0299_VOLT13_OP0,	.min_delay_ms = 100,	.set_symbol_rate = philips_su1278_ty_ci_set_symbol_rate,};static struct stv0299_config cinergy_1200s_config = {	.demod_address = 0x68,	.inittab = typhoon_cinergy1200s_inittab,	.mclk = 88000000UL,	.invert = 0,	.skip_reinit = 0,	.lock_output = STV0229_LOCKOUTPUT_0,	.volt13_op0_op1 = STV0299_VOLT13_OP0,	.min_delay_ms = 100,	.set_symbol_rate = philips_su1278_ty_ci_set_symbol_rate,};static struct stv0299_config cinergy_1200s_1894_0010_config = {	.demod_address = 0x68,	.inittab = typhoon_cinergy1200s_inittab,	.mclk = 88000000UL,	.invert = 1,	.skip_reinit = 0,	.lock_output = STV0229_LOCKOUTPUT_1,	.volt13_op0_op1 = STV0299_VOLT13_OP0,	.min_delay_ms = 100,	.set_symbol_rate = philips_su1278_ty_ci_set_symbol_rate,};static int philips_cu1216_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params){	struct budget *budget = (struct budget *) fe->dvb->priv;	u8 buf[6];	struct i2c_msg msg = {.addr = 0x60,.flags = 0,.buf = buf,.len = sizeof(buf) };	int i;#define CU1216_IF 36125000#define TUNER_MUL 62500	u32 div = (params->frequency + CU1216_IF + TUNER_MUL / 2) / TUNER_MUL;	buf[0] = (div >> 8) & 0x7f;	buf[1] = div & 0xff;	buf[2] = 0xce;	buf[3] = (params->frequency < 150000000 ? 0x01 :		  params->frequency < 445000000 ? 0x02 : 0x04);	buf[4] = 0xde;	buf[5] = 0x20;	if (fe->ops.i2c_gate_ctrl)		fe->ops.i2c_gate_ctrl(fe, 1);	if (i2c_transfer(&budget->i2c_adap, &msg, 1) != 1)		return -EIO;	/* wait for the pll lock */	msg.flags = I2C_M_RD;	msg.len = 1;	for (i = 0; i < 20; i++) {		if (fe->ops.i2c_gate_ctrl)			fe->ops.i2c_gate_ctrl(fe, 1);		if (i2c_transfer(&budget->i2c_adap, &msg, 1) == 1 && (buf[0] & 0x40))			break;		msleep(10);	}	/* switch the charge pump to the lower current */	msg.flags = 0;	msg.len = 2;	msg.buf = &buf[2];	buf[2] &= ~0x40;	if (fe->ops.i2c_gate_ctrl)		fe->ops.i2c_gate_ctrl(fe, 1);	if (i2c_transfer(&budget->i2c_adap, &msg, 1) != 1)		return -EIO;	return 0;}static struct tda1002x_config philips_cu1216_config = {	.demod_address = 0x0c,	.invert = 1,};static struct tda1002x_config philips_cu1216_config_altaddress = {	.demod_address = 0x0d,	.invert = 0,};static int philips_tu1216_tuner_init(struct dvb_frontend *fe){	struct budget *budget = (struct budget *) fe->dvb->priv;	static u8 tu1216_init[] = { 0x0b, 0xf5, 0x85, 0xab };	struct i2c_msg tuner_msg = {.addr = 0x60,.flags = 0,.buf = tu1216_init,.len = sizeof(tu1216_init) };	// setup PLL configuration	if (fe->ops.i2c_gate_ctrl)		fe->ops.i2c_gate_ctrl(fe, 1);	if (i2c_transfer(&budget->i2c_adap, &tuner_msg, 1) != 1)		return -EIO;	msleep(1);	return 0;}static int philips_tu1216_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params){	struct budget *budget = (struct budget *) fe->dvb->priv;	u8 tuner_buf[4];	struct i2c_msg tuner_msg = {.addr = 0x60,.flags = 0,.buf = tuner_buf,.len =			sizeof(tuner_buf) };	int tuner_frequency = 0;	u8 band, cp, filter;	// determine charge pump	tuner_frequency = params->frequency + 36166000;	if (tuner_frequency < 87000000)		return -EINVAL;	else if (tuner_frequency < 130000000)		cp = 3;	else if (tuner_frequency < 160000000)		cp = 5;	else if (tuner_frequency < 200000000)		cp = 6;	else if (tuner_frequency < 290000000)		cp = 3;	else if (tuner_frequency < 420000000)		cp = 5;	else if (tuner_frequency < 480000000)		cp = 6;	else if (tuner_frequency < 620000000)		cp = 3;	else if (tuner_frequency < 830000000)		cp = 5;	else if (tuner_frequency < 895000000)		cp = 7;	else		return -EINVAL;	// determine band	if (params->frequency < 49000000)		return -EINVAL;	else if (params->frequency < 161000000)		band = 1;	else if (params->frequency < 444000000)		band = 2;	else if (params->frequency < 861000000)		band = 4;	else		return -EINVAL;	// setup PLL filter	switch (params->u.ofdm.bandwidth) {	case BANDWIDTH_6_MHZ:		filter = 0;		break;	case BANDWIDTH_7_MHZ:		filter = 0;		break;	case BANDWIDTH_8_MHZ:		filter = 1;		break;	default:		return -EINVAL;	}	// calculate divisor	// ((36166000+((1000000/6)/2)) + Finput)/(1000000/6)	tuner_frequency = (((params->frequency / 1000) * 6) + 217496) / 1000;	// setup tuner buffer	tuner_buf[0] = (tuner_frequency >> 8) & 0x7f;	tuner_buf[1] = tuner_frequency & 0xff;	tuner_buf[2] = 0xca;	tuner_buf[3] = (cp << 5) | (filter << 3) | band;	if (fe->ops.i2c_gate_ctrl)		fe->ops.i2c_gate_ctrl(fe, 1);	if (i2c_transfer(&budget->i2c_adap, &tuner_msg, 1) != 1)		return -EIO;	msleep(1);	return 0;}static int philips_tu1216_request_firmware(struct dvb_frontend *fe,					   const struct firmware **fw, char *name){	struct budget *budget = (struct budget *) fe->dvb->priv;	return request_firmware(fw, name, &budget->dev->pci->dev);}static struct tda1004x_config philips_tu1216_config = {	.demod_address = 0x8,	.invert = 1,	.invert_oclk = 1,	.xtal_freq = TDA10046_XTAL_4M,	.agc_config = TDA10046_AGC_DEFAULT,	.if_freq = TDA10046_FREQ_3617,	.request_firmware = philips_tu1216_request_firmware,};static u8 philips_sd1878_inittab[] = {	0x01, 0x15,	0x02, 0x30,	0x03, 0x00,	0x04, 0x7d,	0x05, 0x35,	0x06, 0x40,	0x07, 0x00,	0x08, 0x43,	0x09, 0x02,	0x0C, 0x51,	0x0D, 0x82,	0x0E, 0x23,	0x10, 0x3f,	0x11, 0x84,	0x12, 0xb9,	0x15, 0xc9,	0x16, 0x19,	0x17, 0x8c,	0x18, 0x59,	0x19, 0xf8,	0x1a, 0xfe,	0x1c, 0x7f,	0x1d, 0x00,	0x1e, 0x00,	0x1f, 0x50,	0x20, 0x00,	0x21, 0x00,	0x22, 0x00,	0x23, 0x00,	0x28, 0x00,	0x29, 0x28,	0x2a, 0x14,	0x2b, 0x0f,	0x2c, 0x09,	0x2d, 0x09,	0x31, 0x1f,	0x32, 0x19,	0x33, 0xfc,	0x34, 0x93,	0xff, 0xff};static int philips_sd1878_ci_set_symbol_rate(struct dvb_frontend *fe,		u32 srate, u32 ratio){	u8 aclk = 0;	u8 bclk = 0;	u8 m1;	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;	stv0299_writereg(fe, 0x0e, 0x23);	stv0299_writereg(fe, 0x0f, 0x94);	stv0299_writereg(fe, 0x10, 0x39);	stv0299_writereg(fe, 0x13, aclk);	stv0299_writereg(fe, 0x14, bclk);	stv0299_writereg(fe, 0x15, 0xc9);	stv0299_writereg(fe, 0x1f, (ratio >> 16) & 0xff);	stv0299_writereg(fe, 0x20, (ratio >> 8) & 0xff);	stv0299_writereg(fe, 0x21, (ratio) & 0xf0);	stv0299_writereg(fe, 0x0f, 0x80 | m1);	return 0;}static struct stv0299_config philips_sd1878_config = {	.demod_address = 0x68,     .inittab = philips_sd1878_inittab,	.mclk = 88000000UL,	.invert = 0,	.skip_reinit = 0,	.lock_output = STV0229_LOCKOUTPUT_1,	.volt13_op0_op1 = STV0299_VOLT13_OP0,	.min_delay_ms = 100,	.set_symbol_rate = philips_sd1878_ci_set_symbol_rate,};static u8 read_pwm(struct budget_av *budget_av){	u8 b = 0xff;	u8 pwm;	struct i2c_msg msg[] = { {.addr = 0x50,.flags = 0,.buf = &b,.len = 1},	{.addr = 0x50,.flags = I2C_M_RD,.buf = &pwm,.len = 1}	};

⌨️ 快捷键说明

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