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

📄 dvb-dibusb-fe-i2c.c

📁 h内核
💻 C
📖 第 1 页 / 共 2 页
字号:
		p4321  = 1; // BW selected for VHF low	else if (freq < 470000000) 		p4321  = 2; // BW selected for VHF high E5 to E12	else // if (freq < 862000000) 		p4321  = 4; // BW selection for UHF E21 to E69	pllbuf[0] = (tfreq >> 8) & 0xff;	pllbuf[1] = (tfreq >> 0) & 0xff;	pllbuf[2] = 0xff & ctrl1;	pllbuf[3] =  (cp210 << 5) | (p4321);	return 0;}/* *            	            7	6		5	4	3	2	1	0 * Address Byte             1	1		0	0	0	MA1	MA0	R/~W=0 * * Program divider byte 1   0	n14		n13	n12	n11	n10	n9	n8 * Program divider byte 2	n7	n6		n5	n4	n3	n2	n1	n0 * * Control byte 1           1	T/A=1	T2	T1	T0	R2	R1	R0 *                          1	T/A=0	0	0	ATC	AL2	AL1	AL0 *  * Control byte 2           CP2	CP1		CP0	BS5	BS4	BS3	BS2	BS1 *  * MA0/1 = programmable address bits * R/~W  = read/write bit (0 for writing) * N14-0 = programmable LO frequency *  * T/A   = test AGC bit (0 = next 6 bits AGC setting,  *                       1 = next 6 bits test and reference divider ratio settings) * T2-0  = test bits * R2-0  = reference divider ratio and programmable frequency step * ATC   = AGC current setting and time constant *         ATC = 0: AGC current = 220nA, AGC time constant = 2s *         ATC = 1: AGC current = 9uA, AGC time constant = 50ms * AL2-0 = AGC take-over point bits * CP2-0 = charge pump current * BS5-1 = PMOS ports control bits; *             BSn = 0 corresponding port is off, high-impedance state (at power-on) *             BSn = 1 corresponding port is on */static int panasonic_cofdm_env77h11d5_tda6650_init(struct dvb_frontend *fe, u8 pllbuf[4]){	pllbuf[0] = 0x0b;	pllbuf[1] = 0xf5;	pllbuf[2] = 0x85;	pllbuf[3] = 0xab;	return 0;}static int panasonic_cofdm_env77h11d5_tda6650_set (struct dvb_frontend_parameters *fep,u8 pllbuf[4]){	int tuner_frequency = 0;	u8 band, cp, filter;	// determine charge pump	tuner_frequency = fep->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 (fep->frequency < 49000000)		return -EINVAL;	else if (fep->frequency < 161000000)		band = 1;	else if (fep->frequency < 444000000)		band = 2;	else if (fep->frequency < 861000000)		band = 4;	else		return -EINVAL;	// setup PLL filter	switch (fep->u.ofdm.bandwidth) {		case BANDWIDTH_6_MHZ:		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 = (((fep->frequency / 1000) * 6) + 217496) / 1000;	// setup tuner buffer	pllbuf[0] = (tuner_frequency >> 8) & 0x7f;	pllbuf[1] = tuner_frequency & 0xff;	pllbuf[2] = 0xca;	pllbuf[3] = (cp << 5) | (filter << 3) | band;	return 0;}/* *            	            7	6	5	4	3	2	1	0 * Address Byte             1	1	0	0	0	MA1	MA0	R/~W=0 * * Program divider byte 1   0	n14	n13	n12	n11	n10	n9	n8 * Program divider byte 2	n7	n6	n5	n4	n3	n2	n1	n0 * * Control byte             1	CP	T2	T1	T0	RSA	RSB	OS *  * Band Switch byte         X	X	X	P4	P3	P2	P1	P0 * * Auxiliary byte           ATC	AL2	AL1	AL0	0	0	0	0 * * Address: MA1	MA0	Address *          0	0	c0 *          0	1	c2 (always valid) *          1	0	c4 *          1	1	c6 * * *  */static int lg_tdtp_e102p_tua6034(struct dvb_frontend_parameters* fep, u8 pllbuf[4]) {	u32 div;	u8 p3210, p4;#define TUNER_MUL 62500	div = (fep->frequency + 36125000 + TUNER_MUL / 2) / TUNER_MUL;	if (fep->frequency < 174500000) 		p3210 = 1; // not supported by the tdtp_e102p	else if (fep->frequency < 230000000) // VHF		p3210 = 2;	else 		p3210 = 4;	if (fep->u.ofdm.bandwidth == BANDWIDTH_7_MHZ)		p4 = 0;	else 		p4 = 1;			pllbuf[0] = (div >> 8) & 0x7f;	pllbuf[1] = div & 0xff;	pllbuf[2] = 0xce;	pllbuf[3] = (p4 << 4) | p3210;	return 0;}static int lg_tdtp_e102p_mt352_demod_init(struct dvb_frontend *fe){	static u8 mt352_clock_config[] = { 0x89, 0xb0, 0x2d };	static u8 mt352_reset[] = { 0x50, 0x80 };	static u8 mt352_mclk_ratio[] = { 0x8b, 0x00 };	static u8 mt352_adc_ctl_1_cfg[] = { 0x8E, 0x40 };	static u8 mt352_agc_cfg[] = { 0x67, 0x14, 0x22 };	static u8 mt352_sec_agc_cfg[] = { 0x69, 0x00, 0xff, 0xff, 0x00, 0xff, 0x00, 0x40, 0x40 };	static u8 mt352_unk [] = { 0xb5, 0x7a };	static u8 mt352_acq_ctl[] = { 0x53, 0x5f };	static u8 mt352_input_freq_1[] = { 0x56, 0xf1, 0x05 };	//	static u8 mt352_capt_range_cfg[] = { 0x75, 0x32 };	mt352_write(fe, mt352_clock_config, sizeof(mt352_clock_config));	udelay(2000);	mt352_write(fe, mt352_reset, sizeof(mt352_reset));	mt352_write(fe, mt352_mclk_ratio, sizeof(mt352_mclk_ratio));		mt352_write(fe, mt352_adc_ctl_1_cfg, sizeof(mt352_adc_ctl_1_cfg));	mt352_write(fe, mt352_agc_cfg, sizeof(mt352_agc_cfg));	mt352_write(fe, mt352_sec_agc_cfg, sizeof(mt352_sec_agc_cfg));	mt352_write(fe, mt352_unk, sizeof(mt352_unk));		mt352_write(fe, mt352_acq_ctl, sizeof(mt352_acq_ctl));	mt352_write(fe, mt352_input_freq_1, sizeof(mt352_input_freq_1));	//	mt352_write(fe, mt352_capt_range_cfg, sizeof(mt352_capt_range_cfg));	return 0;}static int dibusb_general_demod_init(struct dvb_frontend *fe){	struct usb_dibusb* dib = (struct usb_dibusb*) fe->dvb->priv;	switch (dib->dibdev->dev_cl->id) {		case UMT2_0:			return lg_tdtp_e102p_mt352_demod_init(fe);		default: /* other device classes do not have device specific demod inits */			break;	}	return 0;}static u8 dibusb_general_pll_addr(struct dvb_frontend *fe){	struct usb_dibusb* dib = (struct usb_dibusb*) fe->dvb->priv;	return dib->tuner->pll_addr;}static int dibusb_pll_i2c_helper(struct usb_dibusb *dib, u8 pll_buf[5], u8 buf[4]){	if (pll_buf == NULL) {		struct i2c_msg msg = { 			.addr = dib->tuner->pll_addr, 			.flags = 0, 			.buf = buf, 			.len = sizeof(buf) 		};		if (i2c_transfer (&dib->i2c_adap, &msg, 1) != 1)			return -EIO;		msleep(1);	} else {		pll_buf[0] = dib->tuner->pll_addr << 1;		memcpy(&pll_buf[1],buf,4);	}	return 0;}static int dibusb_general_pll_init(struct dvb_frontend *fe, 		u8 pll_buf[5]){	struct usb_dibusb* dib = (struct usb_dibusb*) fe->dvb->priv;	u8 buf[4];	int ret=0;	switch (dib->tuner->id) {		case DIBUSB_TUNER_COFDM_PANASONIC_ENV77H11D5:			ret = panasonic_cofdm_env77h11d5_tda6650_init(fe,buf);			break;		default:			break;	}		if (ret)		return ret;	return dibusb_pll_i2c_helper(dib,pll_buf,buf);}static int dibusb_general_pll_set(struct dvb_frontend *fe, 		struct dvb_frontend_parameters *fep, u8 pll_buf[5]){	struct usb_dibusb* dib = (struct usb_dibusb*) fe->dvb->priv;	u8 buf[4];	int ret=0;	switch (dib->tuner->id) {		case DIBUSB_TUNER_CABLE_THOMSON: 			ret = thomson_cable_eu_pll_set(fep, buf); 			break;		case DIBUSB_TUNER_COFDM_PANASONIC_ENV57H1XD5:			ret = panasonic_cofdm_env57h1xd5_pll_set(fep, buf);			break;		case DIBUSB_TUNER_CABLE_LG_TDTP_E102P:			ret = lg_tdtp_e102p_tua6034(fep, buf); 			break;		case DIBUSB_TUNER_COFDM_PANASONIC_ENV77H11D5:			ret = panasonic_cofdm_env77h11d5_tda6650_set(fep,buf);			break;		default:			warn("no pll programming routine found for tuner %d.\n",dib->tuner->id);			ret = -ENODEV;			break;	}		if (ret)		return ret;		return dibusb_pll_i2c_helper(dib,pll_buf,buf);}

⌨️ 快捷键说明

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