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

📄 dib0700_devices.c

📁 trident tm5600的linux驱动
💻 C
📖 第 1 页 / 共 4 页
字号:
	0, // perform_agc_softsplit};static struct dibx000_bandwidth_config stk7700p_pll_config = {	60000, 30000, // internal, sampling	1, 8, 3, 1, 0, // pll_cfg: prediv, ratio, range, reset, bypass	0, 0, 1, 1, 0, // misc: refdiv, bypclk_div, IO_CLK_en_core, ADClkSrc, modulo	(3 << 14) | (1 << 12) | (524 << 0), // sad_cfg: refsel, sel, freq_15k	60258167, // ifreq	20452225, // timf	30000000, // xtal};static struct dib7000m_config stk7700p_dib7000m_config = {	.dvbt_mode = 1,	.output_mpeg2_in_188_bytes = 1,	.quartz_direct = 1,	.agc_config_count = 1,	.agc = &stk7700p_7000m_mt2060_agc_config,	.bw  = &stk7700p_pll_config,	.gpio_dir = DIB7000M_GPIO_DEFAULT_DIRECTIONS,	.gpio_val = DIB7000M_GPIO_DEFAULT_VALUES,	.gpio_pwm_pos = DIB7000M_GPIO_DEFAULT_PWM_POS,};static struct dib7000p_config stk7700p_dib7000p_config = {	.output_mpeg2_in_188_bytes = 1,	.agc_config_count = 1,	.agc = &stk7700p_7000p_mt2060_agc_config,	.bw  = &stk7700p_pll_config,	.gpio_dir = DIB7000M_GPIO_DEFAULT_DIRECTIONS,	.gpio_val = DIB7000M_GPIO_DEFAULT_VALUES,	.gpio_pwm_pos = DIB7000M_GPIO_DEFAULT_PWM_POS,};static int stk7700p_frontend_attach(struct dvb_usb_adapter *adap){	struct dib0700_state *st = adap->dev->priv;	/* unless there is no real power management in DVB - we leave the device on GPIO6 */	dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);	dib0700_set_gpio(adap->dev, GPIO6,  GPIO_OUT, 0); msleep(50);	dib0700_set_gpio(adap->dev, GPIO6,  GPIO_OUT, 1); msleep(10);	dib0700_set_gpio(adap->dev, GPIO9,  GPIO_OUT, 1);	dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0); msleep(10);	dib0700_ctrl_clock(adap->dev, 72, 1);	dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1); msleep(100);	dib0700_set_gpio(adap->dev,  GPIO0, GPIO_OUT, 1);	st->mt2060_if1[0] = 1220;	if (dib7000pc_detection(&adap->dev->i2c_adap)) {		adap->fe = dvb_attach(dib7000p_attach, &adap->dev->i2c_adap, 18, &stk7700p_dib7000p_config);		st->is_dib7000pc = 1;	} else		adap->fe = dvb_attach(dib7000m_attach, &adap->dev->i2c_adap, 18, &stk7700p_dib7000m_config);	return adap->fe == NULL ? -ENODEV : 0;}static struct mt2060_config stk7700p_mt2060_config = {	0x60};static int stk7700p_tuner_attach(struct dvb_usb_adapter *adap){	struct i2c_adapter *prim_i2c = &adap->dev->i2c_adap;	struct dib0700_state *st = adap->dev->priv;	struct i2c_adapter *tun_i2c;	s8 a;	int if1=1220;	if (adap->dev->udev->descriptor.idVendor  == cpu_to_le16(USB_VID_HAUPPAUGE) &&		adap->dev->udev->descriptor.idProduct == cpu_to_le16(USB_PID_HAUPPAUGE_NOVA_T_STICK)) {		if (!eeprom_read(prim_i2c,0x58,&a)) if1=1220+a;	}	if (st->is_dib7000pc)		tun_i2c = dib7000p_get_i2c_master(adap->fe, DIBX000_I2C_INTERFACE_TUNER, 1);	else		tun_i2c = dib7000m_get_i2c_master(adap->fe, DIBX000_I2C_INTERFACE_TUNER, 1);	return dvb_attach(mt2060_attach, adap->fe, tun_i2c, &stk7700p_mt2060_config,		if1) == NULL ? -ENODEV : 0;}/* DIB7070 generic */static struct dibx000_agc_config dib7070_agc_config = {	BAND_UHF | BAND_VHF | BAND_LBAND | BAND_SBAND,	/* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, P_agc_freq_pwm_div=5, P_agc_inv_pwm1=0, P_agc_inv_pwm2=0,	 * P_agc_inh_dc_rv_est=0, P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=5, P_agc_write=0 */	(0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) | (0 << 8) | (3 << 5) | (0 << 4) | (5 << 1) | (0 << 0), // setup	600, // inv_gain	10,  // time_stabiliz	0,  // alpha_level	118,  // thlock	0,     // wbd_inv	3530,  // wbd_ref	1,     // wbd_sel	5,     // wbd_alpha	65535,  // agc1_max		0,  // agc1_min	65535,  // agc2_max	0,      // agc2_min	0,      // agc1_pt1	40,     // agc1_pt2	183,    // agc1_pt3	206,    // agc1_slope1	255,    // agc1_slope2	72,     // agc2_pt1	152,    // agc2_pt2	88,     // agc2_slope1	90,     // agc2_slope2	17,  // alpha_mant	27,  // alpha_exp	23,  // beta_mant	51,  // beta_exp	0,  // perform_agc_softsplit};static int dib7070_tuner_reset(struct dvb_frontend *fe, int onoff){	return dib7000p_set_gpio(fe, 8, 0, !onoff);}static int dib7070_tuner_sleep(struct dvb_frontend *fe, int onoff){	return dib7000p_set_gpio(fe, 9, 0, onoff);}static struct dib0070_config dib7070p_dib0070_config[2] = {	{		.i2c_address = DEFAULT_DIB0070_I2C_ADDRESS,		.reset = dib7070_tuner_reset,		.sleep = dib7070_tuner_sleep,		.clock_khz = 12000,		.clock_pad_drive = 4	}, {		.i2c_address = DEFAULT_DIB0070_I2C_ADDRESS,		.reset = dib7070_tuner_reset,		.sleep = dib7070_tuner_sleep,		.clock_khz = 12000,	}};static int dib7070_set_param_override(struct dvb_frontend *fe, struct dvb_frontend_parameters *fep){	struct dvb_usb_adapter *adap = fe->dvb->priv;	struct dib0700_adapter_state *state = adap->priv;	u16 offset;	u8 band = BAND_OF_FREQUENCY(fep->frequency/1000);	switch (band) {		case BAND_VHF: offset = 950; break;		case BAND_UHF:		default: offset = 550; break;	}	deb_info("WBD for DiB7000P: %d\n", offset + dib0070_wbd_offset(fe));	dib7000p_set_wbd_ref(fe, offset + dib0070_wbd_offset(fe));	return state->set_param_save(fe, fep);}static int dib7070p_tuner_attach(struct dvb_usb_adapter *adap){	struct dib0700_adapter_state *st = adap->priv;	struct i2c_adapter *tun_i2c = dib7000p_get_i2c_master(adap->fe, DIBX000_I2C_INTERFACE_TUNER, 1);	if (adap->id == 0) {		if (dvb_attach(dib0070_attach, adap->fe, tun_i2c, &dib7070p_dib0070_config[0]) == NULL)			return -ENODEV;	} else {		if (dvb_attach(dib0070_attach, adap->fe, tun_i2c, &dib7070p_dib0070_config[1]) == NULL)			return -ENODEV;	}	st->set_param_save = adap->fe->ops.tuner_ops.set_params;	adap->fe->ops.tuner_ops.set_params = dib7070_set_param_override;	return 0;}static struct dibx000_bandwidth_config dib7070_bw_config_12_mhz = {	60000, 15000, // internal, sampling	1, 20, 3, 1, 0, // pll_cfg: prediv, ratio, range, reset, bypass	0, 0, 1, 1, 2, // misc: refdiv, bypclk_div, IO_CLK_en_core, ADClkSrc, modulo	(3 << 14) | (1 << 12) | (524 << 0), // sad_cfg: refsel, sel, freq_15k	(0 << 25) | 0, // ifreq = 0.000000 MHz	20452225, // timf	12000000, // xtal_hz};static struct dib7000p_config dib7070p_dib7000p_config = {	.output_mpeg2_in_188_bytes = 1,	.agc_config_count = 1,	.agc = &dib7070_agc_config,	.bw  = &dib7070_bw_config_12_mhz,	.tuner_is_baseband = 1,	.spur_protect = 1,	.gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,	.gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,	.gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,	.hostbus_diversity = 1,};/* STK7070P */static int stk7070p_frontend_attach(struct dvb_usb_adapter *adap){	struct usb_device_descriptor *p = &adap->dev->udev->descriptor;	if (p->idVendor  == cpu_to_le16(USB_VID_PINNACLE) &&	    p->idProduct == cpu_to_le16(USB_PID_PINNACLE_PCTV72E))		dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0);	else		dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);	msleep(10);	dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);	dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);	dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);	dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);	dib0700_ctrl_clock(adap->dev, 72, 1);	msleep(10);	dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);	msleep(10);	dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);	dib7000p_i2c_enumeration(&adap->dev->i2c_adap, 1, 18,		&dib7070p_dib7000p_config);	adap->fe = dvb_attach(dib7000p_attach, &adap->dev->i2c_adap, 0x80,		&dib7070p_dib7000p_config);	return adap->fe == NULL ? -ENODEV : 0;}/* STK7070PD */static struct dib7000p_config stk7070pd_dib7000p_config[2] = {	{		.output_mpeg2_in_188_bytes = 1,		.agc_config_count = 1,		.agc = &dib7070_agc_config,		.bw  = &dib7070_bw_config_12_mhz,		.tuner_is_baseband = 1,		.spur_protect = 1,		.gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,		.gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,		.gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,		.hostbus_diversity = 1,	}, {		.output_mpeg2_in_188_bytes = 1,		.agc_config_count = 1,		.agc = &dib7070_agc_config,		.bw  = &dib7070_bw_config_12_mhz,		.tuner_is_baseband = 1,		.spur_protect = 1,		.gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,		.gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,		.gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,		.hostbus_diversity = 1,	}};static int stk7070pd_frontend_attach0(struct dvb_usb_adapter *adap){	dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);	msleep(10);	dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);	dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);	dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);	dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);	dib0700_ctrl_clock(adap->dev, 72, 1);	msleep(10);	dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);	msleep(10);	dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);	dib7000p_i2c_enumeration(&adap->dev->i2c_adap, 2, 18, stk7070pd_dib7000p_config);	adap->fe = dvb_attach(dib7000p_attach, &adap->dev->i2c_adap, 0x80, &stk7070pd_dib7000p_config[0]);	return adap->fe == NULL ? -ENODEV : 0;}static int stk7070pd_frontend_attach1(struct dvb_usb_adapter *adap){	adap->fe = dvb_attach(dib7000p_attach, &adap->dev->i2c_adap, 0x82, &stk7070pd_dib7000p_config[1]);	return adap->fe == NULL ? -ENODEV : 0;}/* S5H1411 */static struct s5h1411_config pinnacle_801e_config = {	.output_mode   = S5H1411_PARALLEL_OUTPUT,	.gpio          = S5H1411_GPIO_OFF,	.mpeg_timing   = S5H1411_MPEGTIMING_NONCONTINOUS_NONINVERTING_CLOCK,	.qam_if        = S5H1411_IF_44000,	.vsb_if        = S5H1411_IF_44000,	.inversion     = S5H1411_INVERSION_OFF,	.status_mode   = S5H1411_DEMODLOCKING};/* Pinnacle PCTV HD Pro 801e GPIOs map:   GPIO0  - currently unknown   GPIO1  - xc5000 tuner reset   GPIO2  - CX25843 sleep   GPIO3  - currently unknown   GPIO4  - currently unknown   GPIO6  - currently unknown   GPIO7  - currently unknown   GPIO9  - currently unknown   GPIO10 - CX25843 reset */static int s5h1411_frontend_attach(struct dvb_usb_adapter *adap){	struct dib0700_state *st = adap->dev->priv;	/* Make use of the new i2c functions from FW 1.20 */	st->fw_use_new_i2c_api = 1;	/* The s5h1411 requires the dib0700 to not be in master mode */	st->disable_streaming_master_mode = 1;	/* All msleep values taken from Windows USB trace */	dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 0);	dib0700_set_gpio(adap->dev, GPIO3, GPIO_OUT, 0);	dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);	msleep(400);	dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);	msleep(60);	dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);	msleep(30);	dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);	dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);	dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);	dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);	dib0700_set_gpio(adap->dev, GPIO2, GPIO_OUT, 0);	msleep(30);	/* Put the CX25843 to sleep for now since we're in digital mode */	dib0700_set_gpio(adap->dev, GPIO2, GPIO_OUT, 1);	/* GPIOs are initialized, do the attach */	adap->fe = dvb_attach(s5h1411_attach, &pinnacle_801e_config,			      &adap->dev->i2c_adap);	return adap->fe == NULL ? -ENODEV : 0;}static int dib0700_xc5000_tuner_callback(void *priv, int component,					 int command, int arg){	struct dvb_usb_adapter *adap = priv;	if (command == XC5000_TUNER_RESET) {		/* Reset the tuner */		dib0700_set_gpio(adap->dev, GPIO1, GPIO_OUT, 0);		msleep(330); /* from Windows USB trace */		dib0700_set_gpio(adap->dev, GPIO1, GPIO_OUT, 1);		msleep(330); /* from Windows USB trace */	} else {		err("xc5000: unknown tuner callback command: %d\n", command);		return -EINVAL;	}	return 0;}static struct xc5000_config s5h1411_xc5000_tunerconfig = {	.i2c_address      = 0x64,	.if_khz           = 5380,};static int xc5000_tuner_attach(struct dvb_usb_adapter *adap){	/* FIXME: generalize & move to common area */	adap->fe->callback = dib0700_xc5000_tuner_callback;	return dvb_attach(xc5000_attach, adap->fe, &adap->dev->i2c_adap,			  &s5h1411_xc5000_tunerconfig)		== NULL ? -ENODEV : 0;}/* DVB-USB and USB stuff follows */struct usb_device_id dib0700_usb_id_table[] = {/* 0 */	{ USB_DEVICE(USB_VID_DIBCOM,    USB_PID_DIBCOM_STK7700P) },

⌨️ 快捷键说明

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