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

📄 cxusb.c

📁 trident tm5600的linux驱动
💻 C
📖 第 1 页 / 共 4 页
字号:
	.inv_gain = 600,	.time_stabiliz = 10,	.alpha_level = 0,	.thlock = 118,	.wbd_inv = 0,	.wbd_ref = 3530,	.wbd_sel = 1,	.wbd_alpha = 5,	.agc1_max = 65535,	.agc1_min = 0,	.agc2_max = 65535,	.agc2_min = 0,	.agc1_pt1 = 0,	.agc1_pt2 = 40,	.agc1_pt3 = 183,	.agc1_slope1 = 206,	.agc1_slope2 = 255,	.agc2_pt1 = 72,	.agc2_pt2 = 152,	.agc2_slope1 = 88,	.agc2_slope2 = 90,	.alpha_mant = 17,	.alpha_exp = 27,	.beta_mant = 23,	.beta_exp = 51,	.perform_agc_softsplit = 0,};static struct dibx000_bandwidth_config dib7070_bw_config_12_mhz = {	.internal = 60000,	.sampling = 15000,	.pll_prediv = 1,	.pll_ratio = 20,	.pll_range = 3,	.pll_reset = 1,	.pll_bypass = 0,	.enable_refdiv = 0,	.bypclk_div = 0,	.IO_CLK_en_core = 1,	.ADClkSrc = 1,	.modulo = 2,	/* refsel, sel, freq_15k */	.sad_cfg = (3 << 14) | (1 << 12) | (524 << 0),	.ifreq = (0 << 25) | 0,	.timf = 20452225,	.xtal_hz = 12000000,};static struct dib7000p_config cxusb_dualdig4_rev2_config = {	.output_mode = OUTMODE_MPEG2_PAR_GATED_CLK,	.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 = 0xfcef,	.gpio_val = 0x0110,	.gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,	.hostbus_diversity = 1,};static int cxusb_dualdig4_rev2_frontend_attach(struct dvb_usb_adapter *adap){	if (usb_set_interface(adap->dev->udev, 0, 1) < 0)		err("set interface failed");	cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0);	cxusb_bluebird_gpio_pulse(adap->dev, 0x02, 1);	dib7000p_i2c_enumeration(&adap->dev->i2c_adap, 1, 18,				 &cxusb_dualdig4_rev2_config);	adap->fe = dvb_attach(dib7000p_attach, &adap->dev->i2c_adap, 0x80,			      &cxusb_dualdig4_rev2_config);	if (adap->fe == NULL)		return -EIO;	return 0;}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 0;}static struct dib0070_config dib7070p_dib0070_config = {	.i2c_address = DEFAULT_DIB0070_I2C_ADDRESS,	.reset = dib7070_tuner_reset,	.sleep = dib7070_tuner_sleep,	.clock_khz = 12000,};struct dib0700_adapter_state {	int (*set_param_save) (struct dvb_frontend *,			       struct dvb_frontend_parameters *);};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;	default:	case BAND_UHF: offset = 550; break;	}	dib7000p_set_wbd_ref(fe, offset + dib0070_wbd_offset(fe));	return state->set_param_save(fe, fep);}static int cxusb_dualdig4_rev2_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 (dvb_attach(dib0070_attach, adap->fe, tun_i2c,	    &dib7070p_dib0070_config) == 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 int cxusb_nano2_frontend_attach(struct dvb_usb_adapter *adap){	if (usb_set_interface(adap->dev->udev, 0, 1) < 0)		err("set interface failed");	cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0);	/* reset the tuner and demodulator */	cxusb_bluebird_gpio_rw(adap->dev, 0x04, 0);	cxusb_bluebird_gpio_pulse(adap->dev, 0x01, 1);	cxusb_bluebird_gpio_pulse(adap->dev, 0x02, 1);	if ((adap->fe = dvb_attach(zl10353_attach,				   &cxusb_zl10353_xc3028_config,				   &adap->dev->i2c_adap)) != NULL)		return 0;	if ((adap->fe = dvb_attach(mt352_attach,				   &cxusb_mt352_xc3028_config,				   &adap->dev->i2c_adap)) != NULL)		return 0;	return -EIO;}static struct lgs8gl5_config lgs8gl5_cfg = {	.demod_address = 0x19,};static int cxusb_d680_dmb_frontend_attach(struct dvb_usb_adapter *adap){	struct dvb_usb_device *d = adap->dev;	int n;	/* Select required USB configuration */	if (usb_set_interface(d->udev, 0, 0) < 0)		err("set interface failed");	/* Unblock all USB pipes */	usb_clear_halt(d->udev,		usb_sndbulkpipe(d->udev, d->props.generic_bulk_ctrl_endpoint));	usb_clear_halt(d->udev,		usb_rcvbulkpipe(d->udev, d->props.generic_bulk_ctrl_endpoint));	usb_clear_halt(d->udev,		usb_rcvbulkpipe(d->udev, d->props.adapter[0].stream.endpoint));	/* Drain USB pipes to avoid hang after reboot */	for (n = 0;  n < 5;  n++) {		cxusb_d680_dmb_drain_message(d);		cxusb_d680_dmb_drain_video(d);		msleep(200);	}	/* Reset the tuner */	if (cxusb_d680_dmb_gpio_tuner(d, 0x07, 0) < 0) {		err("clear tuner gpio failed");		return -EIO;	}	msleep(100);	if (cxusb_d680_dmb_gpio_tuner(d, 0x07, 1) < 0) {		err("set tuner gpio failed");		return -EIO;	}	msleep(100);	/* Attach frontend */	adap->fe = dvb_attach(lgs8gl5_attach, &lgs8gl5_cfg, &d->i2c_adap);	if (adap->fe == NULL)		return -EIO;	return 0;}/* * DViCO has shipped two devices with the same USB ID, but only one of them * needs a firmware download.  Check the device class details to see if they * have non-default values to decide whether the device is actually cold or * not, and forget a match if it turns out we selected the wrong device. */static int bluebird_fx2_identify_state(struct usb_device *udev,				       struct dvb_usb_device_properties *props,				       struct dvb_usb_device_description **desc,				       int *cold){	int wascold = *cold;	*cold = udev->descriptor.bDeviceClass == 0xff &&		udev->descriptor.bDeviceSubClass == 0xff &&		udev->descriptor.bDeviceProtocol == 0xff;	if (*cold && !wascold)		*desc = NULL;	return 0;}/* * DViCO bluebird firmware needs the "warm" product ID to be patched into the * firmware file before download. */static const int dvico_firmware_id_offsets[] = { 6638, 3204 };static int bluebird_patch_dvico_firmware_download(struct usb_device *udev,						  const struct firmware *fw){	int pos;	for (pos = 0; pos < ARRAY_SIZE(dvico_firmware_id_offsets); pos++) {		int idoff = dvico_firmware_id_offsets[pos];		if (fw->size < idoff + 4)			continue;		if (fw->data[idoff] == (USB_VID_DVICO & 0xff) &&		    fw->data[idoff + 1] == USB_VID_DVICO >> 8) {			struct firmware new_fw;			u8 *new_fw_data = vmalloc(fw->size);			int ret;			if (!new_fw_data)				return -ENOMEM;			memcpy(new_fw_data, fw->data, fw->size);			new_fw.size = fw->size;			new_fw.data = new_fw_data;			new_fw_data[idoff + 2] =				le16_to_cpu(udev->descriptor.idProduct) + 1;			new_fw_data[idoff + 3] =				le16_to_cpu(udev->descriptor.idProduct) >> 8;			ret = usb_cypress_load_firmware(udev, &new_fw,							CYPRESS_FX2);			vfree(new_fw_data);			return ret;		}	}	return -EINVAL;}/* DVB USB Driver stuff */static struct dvb_usb_device_properties cxusb_medion_properties;static struct dvb_usb_device_properties cxusb_bluebird_lgh064f_properties;static struct dvb_usb_device_properties cxusb_bluebird_dee1601_properties;static struct dvb_usb_device_properties cxusb_bluebird_lgz201_properties;static struct dvb_usb_device_properties cxusb_bluebird_dtt7579_properties;static struct dvb_usb_device_properties cxusb_bluebird_dualdig4_properties;static struct dvb_usb_device_properties cxusb_bluebird_dualdig4_rev2_properties;static struct dvb_usb_device_properties cxusb_bluebird_nano2_properties;static struct dvb_usb_device_properties cxusb_bluebird_nano2_needsfirmware_properties;static struct dvb_usb_device_properties cxusb_aver_a868r_properties;static struct dvb_usb_device_properties cxusb_d680_dmb_properties;static int cxusb_probe(struct usb_interface *intf,		       const struct usb_device_id *id){	if (0 == dvb_usb_device_init(intf, &cxusb_medion_properties,				     THIS_MODULE, NULL, adapter_nr) ||	    0 == dvb_usb_device_init(intf, &cxusb_bluebird_lgh064f_properties,				     THIS_MODULE, NULL, adapter_nr) ||	    0 == dvb_usb_device_init(intf, &cxusb_bluebird_dee1601_properties,				     THIS_MODULE, NULL, adapter_nr) ||	    0 == dvb_usb_device_init(intf, &cxusb_bluebird_lgz201_properties,				     THIS_MODULE, NULL, adapter_nr) ||	    0 == dvb_usb_device_init(intf, &cxusb_bluebird_dtt7579_properties,				     THIS_MODULE, NULL, adapter_nr) ||	    0 == dvb_usb_device_init(intf, &cxusb_bluebird_dualdig4_properties,				     THIS_MODULE, NULL, adapter_nr) ||	    0 == dvb_usb_device_init(intf, &cxusb_bluebird_nano2_properties,				     THIS_MODULE, NULL, adapter_nr) ||	    0 == dvb_usb_device_init(intf,				&cxusb_bluebird_nano2_needsfirmware_properties,				     THIS_MODULE, NULL, adapter_nr) ||	    0 == dvb_usb_device_init(intf, &cxusb_aver_a868r_properties,				     THIS_MODULE, NULL, adapter_nr) ||	    0 == dvb_usb_device_init(intf,				     &cxusb_bluebird_dualdig4_rev2_properties,				     THIS_MODULE, NULL, adapter_nr) ||	    0 == dvb_usb_device_init(intf, &cxusb_d680_dmb_properties,				     THIS_MODULE, NULL, adapter_nr) ||	    0)		return 0;	return -EINVAL;}static struct usb_device_id cxusb_table [] = {	{ USB_DEVICE(USB_VID_MEDION, USB_PID_MEDION_MD95700) },	{ USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_LG064F_COLD) },	{ USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_LG064F_WARM) },	{ USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_1_COLD) },	{ USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_1_WARM) },	{ USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_LGZ201_COLD) },	{ USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_LGZ201_WARM) },	{ USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_TH7579_COLD) },	{ USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_TH7579_WARM) },	{ USB_DEVICE(USB_VID_DVICO, USB_PID_DIGITALNOW_BLUEBIRD_DUAL_1_COLD) },	{ USB_DEVICE(USB_VID_DVICO, USB_PID_DIGITALNOW_BLUEBIRD_DUAL_1_WARM) },	{ USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_2_COLD) },	{ USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_2_WARM) },	{ USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_4) },	{ USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DVB_T_NANO_2) },	{ USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DVB_T_NANO_2_NFW_WARM) },	{ USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_VOLAR_A868R) },	{ USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_4_REV_2) },	{ USB_DEVICE(USB_VID_CONEXANT, USB_PID_CONEXANT_D680_DMB) },	{}		/* Terminating entry */};MODULE_DEVICE_TABLE (usb, cxusb_table);static struct dvb_usb_device_properties cxusb_medion_properties = {	.caps = DVB_USB_IS_AN_I2C_ADAPTER,	.usb_ctrl = CYPRESS_FX2,	.size_of_priv     = sizeof(struct cxusb_state),	.num_adapters = 1,	.adapter = {		{			.streaming_ctrl   = cxusb_streaming_ctrl,			.frontend_attach  = cxusb_cx22702_frontend_attach,			.tuner_attach     = cxusb_fmd1216me_tuner_attach,			/* parameter for the MPEG2-data transfer */					.stream = {						.type = USB_BULK,				.count = 5,				.endpoint = 0x02,				.u = {					.bulk = {						.buffersize = 8192,					}				}			},		},	},	.power_ctrl       = cxusb_power_ctrl,	.i2c_algo         = &cxusb_i2c_algo,	.generic_bulk_ctrl_endpoint = 0x01,	.num_device_descs = 1,	.devices = {		{   "Medion MD95700 (MDUSBTV-HYBRID)",			{ NULL },			{ &cxusb_table[0], NULL },		},	}};static struct dvb_usb_device_properties cxusb_bluebird_lgh064f_properties = {	.caps = DVB_USB_IS_AN_I2C_ADAPTER,	.usb_ctrl          = DEVICE_SPECIFIC,	.firmware          = "dvb-usb-bluebird-01.fw",	.download_firmware = bluebird_patch_dvico_firmware_download,	/* use usb alt setting 0 for EP4 transfer (dvb-t),	   use usb alt setting 7 for EP2 transfer (atsc) */	.size_of_priv     = sizeof(struct cxusb_state),	.num_adapters = 1,	.adapter = {		{			.streaming_ctrl   = cxusb_streaming_ctrl,			.frontend_attach  = cxusb_lgdt3303_frontend_attach,			.tuner_attach     = cxusb_lgh064f_tuner_attach,			/* parameter for the MPEG2-data transfer */					.stream = {						.type = USB_BULK,				.count = 5,				.endpoint = 0x02,				.u = {					.bulk = {						.buffersize = 8192,					}				}			},		},	},	.power_ctrl       = cxusb_bluebird_power_ctrl,	.i2c_algo         = &cxusb_i2c_algo,	.rc_interval      = 100,	.rc_key_map       = dvico_portable_rc_keys,	.rc_key_map_size  = ARRAY_SIZE(dvico_portable_rc_keys),	.rc_query         = cxusb_rc_query,	.generic_bulk_ctrl_endpoint = 0x01,	.num_device_descs = 1,	.devices = {		{   "DViCO FusionHDTV5 USB Gold",			{ &cxusb_table[1], NULL },			{ &cxusb_table[2], NULL },		},	}};static struct dvb_usb_device_properties cxusb_bluebird_dee1601_properties = {	.caps = DVB_USB_IS_AN_I2C_ADAPTER,	.usb_ctrl          = DEVICE_SPECIFIC,	.firmware          = "dvb-usb-bluebird-01.fw",	.download_firmware = bluebird_patch_dvico_firmware_download,	/* use usb alt setting 0 for EP4 transfer (dvb-t),	   use usb alt setting 7 for EP2 transfer (atsc) */	.size_of_priv     = sizeof(struct cxusb_state),	.num_adapters = 1,	.adapter = {		{			.streaming_ctrl   = cxusb_streaming_ctrl,			.frontend_attach  = cxusb_dee1601_frontend_attach,

⌨️ 快捷键说明

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