📄 af9015.c
字号:
keymap[i].data == buf[2]) { *event = keymap[i].event; *state = REMOTE_KEY_PRESSED; break; } } if (!buf[1]) deb_rc("%s: %02x %02x %02x %02x %02x %02x %02x %02x\n", __func__, buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6], buf[7]); return 0;}/* init 2nd I2C adapter */int af9015_i2c_init(struct dvb_usb_device *d){ int ret; struct af9015_state *state = d->priv; deb_info("%s:\n", __func__); strncpy(state->i2c_adap.name, d->desc->name, sizeof(state->i2c_adap.name));#ifdef I2C_ADAP_CLASS_TV_DIGITAL state->i2c_adap.class = I2C_ADAP_CLASS_TV_DIGITAL,#else state->i2c_adap.class = I2C_CLASS_TV_DIGITAL,#endif state->i2c_adap.algo = d->props.i2c_algo; state->i2c_adap.algo_data = NULL; state->i2c_adap.dev.parent = &d->udev->dev; i2c_set_adapdata(&state->i2c_adap, d); ret = i2c_add_adapter(&state->i2c_adap); if (ret < 0) err("could not add i2c adapter"); return ret;}static int af9015_af9013_frontend_attach(struct dvb_usb_adapter *adap){ int ret; struct af9015_state *state = adap->dev->priv; struct i2c_adapter *i2c_adap; if (adap->id == 0) { /* select I2C adapter */ i2c_adap = &adap->dev->i2c_adap; deb_info("%s: init I2C\n", __func__); ret = af9015_i2c_init(adap->dev); /* dump eeprom (debug) */ ret = af9015_eeprom_dump(adap->dev); if (ret) return ret; } else { /* select I2C adapter */ i2c_adap = &state->i2c_adap; /* copy firmware to 2nd demodulator */ if (af9015_config.dual_mode) { ret = af9015_copy_firmware(adap->dev); if (ret) { err("firmware copy to 2nd frontend " \ "failed, will disable it"); af9015_config.dual_mode = 0; return -ENODEV; } } else { return -ENODEV; } } /* attach demodulator */ adap->fe = dvb_attach(af9013_attach, &af9015_af9013_config[adap->id], i2c_adap); return adap->fe == NULL ? -ENODEV : 0;}static struct mt2060_config af9015_mt2060_config = { .i2c_address = 0xc0, .clock_out = 0,};static struct qt1010_config af9015_qt1010_config = { .i2c_address = 0xc4,};static struct tda18271_config af9015_tda18271_config = { .gate = TDA18271_GATE_DIGITAL, .small_i2c = 1,};static struct mxl5005s_config af9015_mxl5003_config = { .i2c_address = 0xc6, .if_freq = IF_FREQ_4570000HZ, .xtal_freq = CRYSTAL_FREQ_16000000HZ, .agc_mode = MXL_SINGLE_AGC, .tracking_filter = MXL_TF_DEFAULT, .rssi_enable = MXL_RSSI_ENABLE, .cap_select = MXL_CAP_SEL_ENABLE, .div_out = MXL_DIV_OUT_4, .clock_out = MXL_CLOCK_OUT_DISABLE, .output_load = MXL5005S_IF_OUTPUT_LOAD_200_OHM, .top = MXL5005S_TOP_25P2, .mod_mode = MXL_DIGITAL_MODE, .if_mode = MXL_ZERO_IF, .AgcMasterByte = 0x00,};static struct mxl5005s_config af9015_mxl5005_config = { .i2c_address = 0xc6, .if_freq = IF_FREQ_4570000HZ, .xtal_freq = CRYSTAL_FREQ_16000000HZ, .agc_mode = MXL_SINGLE_AGC, .tracking_filter = MXL_TF_OFF, .rssi_enable = MXL_RSSI_ENABLE, .cap_select = MXL_CAP_SEL_ENABLE, .div_out = MXL_DIV_OUT_4, .clock_out = MXL_CLOCK_OUT_DISABLE, .output_load = MXL5005S_IF_OUTPUT_LOAD_200_OHM, .top = MXL5005S_TOP_25P2, .mod_mode = MXL_DIGITAL_MODE, .if_mode = MXL_ZERO_IF, .AgcMasterByte = 0x00,};static int af9015_tuner_attach(struct dvb_usb_adapter *adap){ struct af9015_state *state = adap->dev->priv; struct i2c_adapter *i2c_adap; int ret; deb_info("%s: \n", __func__); /* select I2C adapter */ if (adap->id == 0) i2c_adap = &adap->dev->i2c_adap; else i2c_adap = &state->i2c_adap; switch (af9015_af9013_config[adap->id].tuner) { case AF9013_TUNER_MT2060: case AF9013_TUNER_MT2060_2: ret = dvb_attach(mt2060_attach, adap->fe, i2c_adap, &af9015_mt2060_config, af9015_config.mt2060_if1[adap->id]) == NULL ? -ENODEV : 0; break; case AF9013_TUNER_QT1010: case AF9013_TUNER_QT1010A: ret = dvb_attach(qt1010_attach, adap->fe, i2c_adap, &af9015_qt1010_config) == NULL ? -ENODEV : 0; break; case AF9013_TUNER_TDA18271: ret = dvb_attach(tda18271_attach, adap->fe, 0xc0, i2c_adap, &af9015_tda18271_config) == NULL ? -ENODEV : 0; break; case AF9013_TUNER_MXL5003D: ret = dvb_attach(mxl5005s_attach, adap->fe, i2c_adap, &af9015_mxl5003_config) == NULL ? -ENODEV : 0; break; case AF9013_TUNER_MXL5005D: case AF9013_TUNER_MXL5005R: ret = dvb_attach(mxl5005s_attach, adap->fe, i2c_adap, &af9015_mxl5005_config) == NULL ? -ENODEV : 0; break; case AF9013_TUNER_ENV77H11D5: ret = dvb_attach(dvb_pll_attach, adap->fe, 0xc0, i2c_adap, DVB_PLL_TDA665X) == NULL ? -ENODEV : 0; break; case AF9013_TUNER_MC44S803:#if 0 /* keep */ ret = dvb_attach(mc44s80x_attach, adap->fe, i2c_adap) == NULL ? -ENODEV : 0;#else ret = -ENODEV; info("Freescale MC44S803 tuner found but no driver for that" \ "tuner. Look at the Linuxtv.org for tuner driver" \ "status.");#endif break; case AF9013_TUNER_UNKNOWN: default: ret = -ENODEV; err("Unknown tuner id:%d", af9015_af9013_config[adap->id].tuner); } return ret;}static struct usb_device_id af9015_usb_table[] = {/* 0 */{USB_DEVICE(USB_VID_AFATECH, USB_PID_AFATECH_AF9015_9015)}, {USB_DEVICE(USB_VID_AFATECH, USB_PID_AFATECH_AF9015_9016)}, {USB_DEVICE(USB_VID_LEADTEK, USB_PID_WINFAST_DTV_DONGLE_GOLD)}, {USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV71E)}, {USB_DEVICE(USB_VID_KWORLD_2, USB_PID_KWORLD_399U)},/* 5 */{USB_DEVICE(USB_VID_VISIONPLUS, USB_PID_TINYTWIN)}, {USB_DEVICE(USB_VID_VISIONPLUS, USB_PID_AZUREWAVE_AD_TU700)}, {USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_T_USB_XE_REV2)}, {USB_DEVICE(USB_VID_KWORLD_2, USB_PID_KWORLD_PC160_2T)}, {USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_VOLAR_X)},/* 10 */{USB_DEVICE(USB_VID_XTENSIONS, USB_PID_XTENSIONS_XD_380)}, {USB_DEVICE(USB_VID_MSI_2, USB_PID_MSI_DIGIVOX_DUO)}, {USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_VOLAR_X_2)}, {USB_DEVICE(USB_VID_TELESTAR, USB_PID_TELESTAR_STARSTICK_2)}, {USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_A309)},/* 15 */{USB_DEVICE(USB_VID_MSI_2, USB_PID_MSI_DIGI_VOX_MINI_III)}, {0},};MODULE_DEVICE_TABLE(usb, af9015_usb_table);static struct dvb_usb_device_properties af9015_properties[] = { { .caps = DVB_USB_IS_AN_I2C_ADAPTER, .usb_ctrl = DEVICE_SPECIFIC, .download_firmware = af9015_download_firmware, .firmware = "dvb-usb-af9015.fw", .size_of_priv = sizeof(struct af9015_state), \ .num_adapters = 2, .adapter = { { .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF, .pid_filter_count = 32, .pid_filter = af9015_pid_filter, .pid_filter_ctrl = af9015_pid_filter_ctrl, .frontend_attach = af9015_af9013_frontend_attach, .tuner_attach = af9015_tuner_attach, .stream = { .type = USB_BULK, .count = 6, .endpoint = 0x84, }, }, { .frontend_attach = af9015_af9013_frontend_attach, .tuner_attach = af9015_tuner_attach, .stream = { .type = USB_BULK, .count = 6, .endpoint = 0x85, }, } }, .identify_state = af9015_identify_state, .rc_query = af9015_rc_query, .rc_interval = 150, .i2c_algo = &af9015_i2c_algo, .num_device_descs = 9, .devices = { { .name = "Afatech AF9015 DVB-T USB2.0 stick", .cold_ids = {&af9015_usb_table[0], &af9015_usb_table[1], NULL}, .warm_ids = {NULL}, }, { .name = "Leadtek WinFast DTV Dongle Gold", .cold_ids = {&af9015_usb_table[2], NULL}, .warm_ids = {NULL}, }, { .name = "Pinnacle PCTV 71e", .cold_ids = {&af9015_usb_table[3], NULL}, .warm_ids = {NULL}, }, { .name = "KWorld PlusTV Dual DVB-T Stick " \ "(DVB-T 399U)", .cold_ids = {&af9015_usb_table[4], NULL}, .warm_ids = {NULL}, }, { .name = "DigitalNow TinyTwin DVB-T Receiver", .cold_ids = {&af9015_usb_table[5], NULL}, .warm_ids = {NULL}, }, { .name = "TwinHan AzureWave AD-TU700(704J)", .cold_ids = {&af9015_usb_table[6], NULL}, .warm_ids = {NULL}, }, { .name = "TerraTec Cinergy T USB XE", .cold_ids = {&af9015_usb_table[7], NULL}, .warm_ids = {NULL}, }, { .name = "KWorld PlusTV Dual DVB-T PCI " \ "(DVB-T PC160-2T)", .cold_ids = {&af9015_usb_table[8], NULL}, .warm_ids = {NULL}, }, { .name = "AVerMedia AVerTV DVB-T Volar X", .cold_ids = {&af9015_usb_table[9], NULL}, .warm_ids = {NULL}, }, } }, { .caps = DVB_USB_IS_AN_I2C_ADAPTER, .usb_ctrl = DEVICE_SPECIFIC, .download_firmware = af9015_download_firmware, .firmware = "dvb-usb-af9015.fw", .size_of_priv = sizeof(struct af9015_state), \ .num_adapters = 2, .adapter = { { .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF, .pid_filter_count = 32, .pid_filter = af9015_pid_filter, .pid_filter_ctrl = af9015_pid_filter_ctrl, .frontend_attach = af9015_af9013_frontend_attach, .tuner_attach = af9015_tuner_attach, .stream = { .type = USB_BULK, .count = 6, .endpoint = 0x84, }, }, { .frontend_attach = af9015_af9013_frontend_attach, .tuner_attach = af9015_tuner_attach, .stream = { .type = USB_BULK, .count = 6, .endpoint = 0x85, }, } }, .identify_state = af9015_identify_state, .rc_query = af9015_rc_query, .rc_interval = 150, .i2c_algo = &af9015_i2c_algo, .num_device_descs = 6, .devices = { { .name = "Xtensions XD-380", .cold_ids = {&af9015_usb_table[10], NULL}, .warm_ids = {NULL}, }, { .name = "MSI DIGIVOX Duo", .cold_ids = {&af9015_usb_table[11], NULL}, .warm_ids = {NULL}, }, { .name = "Fujitsu-Siemens Slim Mobile USB DVB-T", .cold_ids = {&af9015_usb_table[12], NULL}, .warm_ids = {NULL}, }, { .name = "Telestar Starstick 2", .cold_ids = {&af9015_usb_table[13], NULL}, .warm_ids = {NULL}, }, { .name = "AVerMedia A309", .cold_ids = {&af9015_usb_table[14], NULL}, .warm_ids = {NULL}, }, { .name = "MSI Digi VOX mini III", .cold_ids = {&af9015_usb_table[15], NULL}, .warm_ids = {NULL}, }, } }};static int af9015_usb_probe(struct usb_interface *intf, const struct usb_device_id *id){ int ret = 0; struct dvb_usb_device *d = NULL; struct usb_device *udev = interface_to_usbdev(intf); u8 i; deb_info("%s: interface:%d\n", __func__, intf->cur_altsetting->desc.bInterfaceNumber); /* interface 0 is used by DVB-T receiver and interface 1 is for remote controller (HID) */ if (intf->cur_altsetting->desc.bInterfaceNumber == 0) { ret = af9015_read_config(udev); if (ret) return ret; for (i = 0; i < af9015_properties_count; i++) { ret = dvb_usb_device_init(intf, &af9015_properties[i], THIS_MODULE, &d, adapter_nr); if (!ret) break; if (ret != -ENODEV) return ret; } if (ret) return ret; if (d) ret = af9015_init(d); } return ret;}void af9015_i2c_exit(struct dvb_usb_device *d){ struct af9015_state *state = d->priv; deb_info("%s: \n", __func__); /* remove 2nd I2C adapter */ if (d->state & DVB_USB_STATE_I2C) i2c_del_adapter(&state->i2c_adap);}static void af9015_usb_device_exit(struct usb_interface *intf){ struct dvb_usb_device *d = usb_get_intfdata(intf); deb_info("%s: \n", __func__); /* remove 2nd I2C adapter */ if (d != NULL && d->desc != NULL) af9015_i2c_exit(d); dvb_usb_device_exit(intf);}/* usb specific object needed to register this driver with the usb subsystem */static struct usb_driver af9015_usb_driver = {#if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 15) .owner = THIS_MODULE,#endif .name = "dvb_usb_af9015", .probe = af9015_usb_probe, .disconnect = af9015_usb_device_exit, .id_table = af9015_usb_table,};/* module stuff */static int __init af9015_usb_module_init(void){ int ret; ret = usb_register(&af9015_usb_driver); if (ret) err("module init failed:%d", ret); return ret;}static void __exit af9015_usb_module_exit(void){ /* deregister this driver from the USB subsystem */ usb_deregister(&af9015_usb_driver);}module_init(af9015_usb_module_init);module_exit(af9015_usb_module_exit);MODULE_AUTHOR("Antti Palosaari <crope@iki.fi>");MODULE_DESCRIPTION("Driver for Afatech AF9015 DVB-T");MODULE_LICENSE("GPL");
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -