Path: blob/master/drivers/media/dvb/dvb-usb/dibusb-mb.c
15112 views
/* DVB USB compliant linux driver for mobile DVB-T USB devices based on1* reference designs made by DiBcom (http://www.dibcom.fr/) (DiB3000M-B)2*3* Copyright (C) 2004-5 Patrick Boettcher ([email protected])4*5* based on GPL code from DiBcom, which has6* Copyright (C) 2004 Amaury Demol for DiBcom ([email protected])7*8* This program is free software; you can redistribute it and/or modify it9* under the terms of the GNU General Public License as published by the Free10* Software Foundation, version 2.11*12* see Documentation/dvb/README.dvb-usb for more information13*/14#include "dibusb.h"1516DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);1718static int dib3000mb_i2c_gate_ctrl(struct dvb_frontend* fe, int enable)19{20struct dvb_usb_adapter *adap = fe->dvb->priv;21struct dibusb_state *st = adap->priv;2223return st->ops.tuner_pass_ctrl(fe, enable, st->tuner_addr);24}2526static int dibusb_dib3000mb_frontend_attach(struct dvb_usb_adapter *adap)27{28struct dib3000_config demod_cfg;29struct dibusb_state *st = adap->priv;3031demod_cfg.demod_address = 0x8;3233if ((adap->fe = dvb_attach(dib3000mb_attach, &demod_cfg,34&adap->dev->i2c_adap, &st->ops)) == NULL)35return -ENODEV;3637adap->fe->ops.i2c_gate_ctrl = dib3000mb_i2c_gate_ctrl;3839return 0;40}4142static int dibusb_thomson_tuner_attach(struct dvb_usb_adapter *adap)43{44struct dibusb_state *st = adap->priv;4546st->tuner_addr = 0x61;4748dvb_attach(dvb_pll_attach, adap->fe, 0x61, &adap->dev->i2c_adap,49DVB_PLL_TUA6010XS);50return 0;51}5253static int dibusb_panasonic_tuner_attach(struct dvb_usb_adapter *adap)54{55struct dibusb_state *st = adap->priv;5657st->tuner_addr = 0x60;5859dvb_attach(dvb_pll_attach, adap->fe, 0x60, &adap->dev->i2c_adap,60DVB_PLL_TDA665X);61return 0;62}6364/* Some of the Artec 1.1 device aren't equipped with the default tuner65* (Thomson Cable), but with a Panasonic ENV77H11D5. This function figures66* this out. */67static int dibusb_tuner_probe_and_attach(struct dvb_usb_adapter *adap)68{69u8 b[2] = { 0,0 }, b2[1];70int ret = 0;71struct i2c_msg msg[2] = {72{ .flags = 0, .buf = b, .len = 2 },73{ .flags = I2C_M_RD, .buf = b2, .len = 1 },74};75struct dibusb_state *st = adap->priv;7677/* the Panasonic sits on I2C addrass 0x60, the Thomson on 0x61 */78msg[0].addr = msg[1].addr = st->tuner_addr = 0x60;7980if (adap->fe->ops.i2c_gate_ctrl)81adap->fe->ops.i2c_gate_ctrl(adap->fe,1);8283if (i2c_transfer(&adap->dev->i2c_adap, msg, 2) != 2) {84err("tuner i2c write failed.");85ret = -EREMOTEIO;86}8788if (adap->fe->ops.i2c_gate_ctrl)89adap->fe->ops.i2c_gate_ctrl(adap->fe,0);9091if (b2[0] == 0xfe) {92info("This device has the Thomson Cable onboard. Which is default.");93ret = dibusb_thomson_tuner_attach(adap);94} else {95info("This device has the Panasonic ENV77H11D5 onboard.");96ret = dibusb_panasonic_tuner_attach(adap);97}9899return ret;100}101102/* USB Driver stuff */103static struct dvb_usb_device_properties dibusb1_1_properties;104static struct dvb_usb_device_properties dibusb1_1_an2235_properties;105static struct dvb_usb_device_properties dibusb2_0b_properties;106static struct dvb_usb_device_properties artec_t1_usb2_properties;107108static int dibusb_probe(struct usb_interface *intf,109const struct usb_device_id *id)110{111if (0 == dvb_usb_device_init(intf, &dibusb1_1_properties,112THIS_MODULE, NULL, adapter_nr) ||1130 == dvb_usb_device_init(intf, &dibusb1_1_an2235_properties,114THIS_MODULE, NULL, adapter_nr) ||1150 == dvb_usb_device_init(intf, &dibusb2_0b_properties,116THIS_MODULE, NULL, adapter_nr) ||1170 == dvb_usb_device_init(intf, &artec_t1_usb2_properties,118THIS_MODULE, NULL, adapter_nr))119return 0;120121return -EINVAL;122}123124/* do not change the order of the ID table */125static struct usb_device_id dibusb_dib3000mb_table [] = {126/* 00 */ { USB_DEVICE(USB_VID_WIDEVIEW, USB_PID_AVERMEDIA_DVBT_USB_COLD) },127/* 01 */ { USB_DEVICE(USB_VID_WIDEVIEW, USB_PID_AVERMEDIA_DVBT_USB_WARM) },128/* 02 */ { USB_DEVICE(USB_VID_COMPRO, USB_PID_COMPRO_DVBU2000_COLD) },129/* 03 */ { USB_DEVICE(USB_VID_COMPRO, USB_PID_COMPRO_DVBU2000_WARM) },130/* 04 */ { USB_DEVICE(USB_VID_COMPRO_UNK, USB_PID_COMPRO_DVBU2000_UNK_COLD) },131/* 05 */ { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_MOD3000_COLD) },132/* 06 */ { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_MOD3000_WARM) },133/* 07 */ { USB_DEVICE(USB_VID_EMPIA, USB_PID_KWORLD_VSTREAM_COLD) },134/* 08 */ { USB_DEVICE(USB_VID_EMPIA, USB_PID_KWORLD_VSTREAM_WARM) },135/* 09 */ { USB_DEVICE(USB_VID_GRANDTEC, USB_PID_GRANDTEC_DVBT_USB_COLD) },136/* 10 */ { USB_DEVICE(USB_VID_GRANDTEC, USB_PID_GRANDTEC_DVBT_USB_WARM) },137/* 11 */ { USB_DEVICE(USB_VID_GRANDTEC, USB_PID_DIBCOM_MOD3000_COLD) },138/* 12 */ { USB_DEVICE(USB_VID_GRANDTEC, USB_PID_DIBCOM_MOD3000_WARM) },139/* 13 */ { USB_DEVICE(USB_VID_HYPER_PALTEK, USB_PID_UNK_HYPER_PALTEK_COLD) },140/* 14 */ { USB_DEVICE(USB_VID_HYPER_PALTEK, USB_PID_UNK_HYPER_PALTEK_WARM) },141/* 15 */ { USB_DEVICE(USB_VID_VISIONPLUS, USB_PID_TWINHAN_VP7041_COLD) },142/* 16 */ { USB_DEVICE(USB_VID_VISIONPLUS, USB_PID_TWINHAN_VP7041_WARM) },143/* 17 */ { USB_DEVICE(USB_VID_TWINHAN, USB_PID_TWINHAN_VP7041_COLD) },144/* 18 */ { USB_DEVICE(USB_VID_TWINHAN, USB_PID_TWINHAN_VP7041_WARM) },145/* 19 */ { USB_DEVICE(USB_VID_ULTIMA_ELECTRONIC, USB_PID_ULTIMA_TVBOX_COLD) },146/* 20 */ { USB_DEVICE(USB_VID_ULTIMA_ELECTRONIC, USB_PID_ULTIMA_TVBOX_WARM) },147/* 21 */ { USB_DEVICE(USB_VID_ULTIMA_ELECTRONIC, USB_PID_ULTIMA_TVBOX_AN2235_COLD) },148/* 22 */ { USB_DEVICE(USB_VID_ULTIMA_ELECTRONIC, USB_PID_ULTIMA_TVBOX_AN2235_WARM) },149/* 23 */ { USB_DEVICE(USB_VID_ADSTECH, USB_PID_ADSTECH_USB2_COLD) },150151/* device ID with default DIBUSB2_0-firmware and with the hacked firmware */152/* 24 */ { USB_DEVICE(USB_VID_ADSTECH, USB_PID_ADSTECH_USB2_WARM) },153/* 25 */ { USB_DEVICE(USB_VID_KYE, USB_PID_KYE_DVB_T_COLD) },154/* 26 */ { USB_DEVICE(USB_VID_KYE, USB_PID_KYE_DVB_T_WARM) },155156/* 27 */ { USB_DEVICE(USB_VID_KWORLD, USB_PID_KWORLD_VSTREAM_COLD) },157158/* 28 */ { USB_DEVICE(USB_VID_ULTIMA_ELECTRONIC, USB_PID_ULTIMA_TVBOX_USB2_COLD) },159/* 29 */ { USB_DEVICE(USB_VID_ULTIMA_ELECTRONIC, USB_PID_ULTIMA_TVBOX_USB2_WARM) },160161/*162* XXX: As Artec just 'forgot' to program the EEPROM on some Artec T1 devices163* we don't catch these faulty IDs (namely 'Cypress FX1 USB controller') that164* have been left on the device. If you don't have such a device but an Artec165* device that's supposed to work with this driver but is not detected by it,166* free to enable CONFIG_DVB_USB_DIBUSB_MB_FAULTY via your kernel config.167*/168169#ifdef CONFIG_DVB_USB_DIBUSB_MB_FAULTY170/* 30 */ { USB_DEVICE(USB_VID_ANCHOR, USB_PID_ULTIMA_TVBOX_ANCHOR_COLD) },171#endif172173{ } /* Terminating entry */174};175MODULE_DEVICE_TABLE (usb, dibusb_dib3000mb_table);176177static struct dvb_usb_device_properties dibusb1_1_properties = {178.caps = DVB_USB_IS_AN_I2C_ADAPTER,179180.usb_ctrl = CYPRESS_AN2135,181182.firmware = "dvb-usb-dibusb-5.0.0.11.fw",183184.num_adapters = 1,185.adapter = {186{187.caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,188.pid_filter_count = 16,189190.streaming_ctrl = dibusb_streaming_ctrl,191.pid_filter = dibusb_pid_filter,192.pid_filter_ctrl = dibusb_pid_filter_ctrl,193.frontend_attach = dibusb_dib3000mb_frontend_attach,194.tuner_attach = dibusb_tuner_probe_and_attach,195196/* parameter for the MPEG2-data transfer */197.stream = {198.type = USB_BULK,199.count = 7,200.endpoint = 0x02,201.u = {202.bulk = {203.buffersize = 4096,204}205}206},207.size_of_priv = sizeof(struct dibusb_state),208}209},210211.power_ctrl = dibusb_power_ctrl,212213.rc.legacy = {214.rc_interval = DEFAULT_RC_INTERVAL,215.rc_map_table = rc_map_dibusb_table,216.rc_map_size = 111, /* wow, that is ugly ... I want to load it to the driver dynamically */217.rc_query = dibusb_rc_query,218},219220.i2c_algo = &dibusb_i2c_algo,221222.generic_bulk_ctrl_endpoint = 0x01,223224.num_device_descs = 9,225.devices = {226{ "AVerMedia AverTV DVBT USB1.1",227{ &dibusb_dib3000mb_table[0], NULL },228{ &dibusb_dib3000mb_table[1], NULL },229},230{ "Compro Videomate DVB-U2000 - DVB-T USB1.1 (please confirm to linux-dvb)",231{ &dibusb_dib3000mb_table[2], &dibusb_dib3000mb_table[4], NULL},232{ &dibusb_dib3000mb_table[3], NULL },233},234{ "DiBcom USB1.1 DVB-T reference design (MOD3000)",235{ &dibusb_dib3000mb_table[5], NULL },236{ &dibusb_dib3000mb_table[6], NULL },237},238{ "KWorld V-Stream XPERT DTV - DVB-T USB1.1",239{ &dibusb_dib3000mb_table[7], NULL },240{ &dibusb_dib3000mb_table[8], NULL },241},242{ "Grandtec USB1.1 DVB-T",243{ &dibusb_dib3000mb_table[9], &dibusb_dib3000mb_table[11], NULL },244{ &dibusb_dib3000mb_table[10], &dibusb_dib3000mb_table[12], NULL },245},246{ "Unknown USB1.1 DVB-T device ???? please report the name to the author",247{ &dibusb_dib3000mb_table[13], NULL },248{ &dibusb_dib3000mb_table[14], NULL },249},250{ "TwinhanDTV USB-Ter USB1.1 / Magic Box I / HAMA USB1.1 DVB-T device",251{ &dibusb_dib3000mb_table[15], &dibusb_dib3000mb_table[17], NULL},252{ &dibusb_dib3000mb_table[16], &dibusb_dib3000mb_table[18], NULL},253},254{ "Artec T1 USB1.1 TVBOX with AN2135",255{ &dibusb_dib3000mb_table[19], NULL },256{ &dibusb_dib3000mb_table[20], NULL },257},258{ "VideoWalker DVB-T USB",259{ &dibusb_dib3000mb_table[25], NULL },260{ &dibusb_dib3000mb_table[26], NULL },261},262}263};264265static struct dvb_usb_device_properties dibusb1_1_an2235_properties = {266.caps = DVB_USB_IS_AN_I2C_ADAPTER,267.usb_ctrl = CYPRESS_AN2235,268269.firmware = "dvb-usb-dibusb-an2235-01.fw",270271.num_adapters = 1,272.adapter = {273{274.caps = DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF | DVB_USB_ADAP_HAS_PID_FILTER,275.pid_filter_count = 16,276277.streaming_ctrl = dibusb_streaming_ctrl,278.pid_filter = dibusb_pid_filter,279.pid_filter_ctrl = dibusb_pid_filter_ctrl,280.frontend_attach = dibusb_dib3000mb_frontend_attach,281.tuner_attach = dibusb_tuner_probe_and_attach,282283/* parameter for the MPEG2-data transfer */284.stream = {285.type = USB_BULK,286.count = 7,287.endpoint = 0x02,288.u = {289.bulk = {290.buffersize = 4096,291}292}293},294.size_of_priv = sizeof(struct dibusb_state),295},296},297.power_ctrl = dibusb_power_ctrl,298299.rc.legacy = {300.rc_interval = DEFAULT_RC_INTERVAL,301.rc_map_table = rc_map_dibusb_table,302.rc_map_size = 111, /* wow, that is ugly ... I want to load it to the driver dynamically */303.rc_query = dibusb_rc_query,304},305306.i2c_algo = &dibusb_i2c_algo,307308.generic_bulk_ctrl_endpoint = 0x01,309310#ifdef CONFIG_DVB_USB_DIBUSB_MB_FAULTY311.num_device_descs = 2,312#else313.num_device_descs = 1,314#endif315.devices = {316{ "Artec T1 USB1.1 TVBOX with AN2235",317{ &dibusb_dib3000mb_table[21], NULL },318{ &dibusb_dib3000mb_table[22], NULL },319},320#ifdef CONFIG_DVB_USB_DIBUSB_MB_FAULTY321{ "Artec T1 USB1.1 TVBOX with AN2235 (faulty USB IDs)",322{ &dibusb_dib3000mb_table[30], NULL },323{ NULL },324},325{ NULL },326#endif327}328};329330static struct dvb_usb_device_properties dibusb2_0b_properties = {331.caps = DVB_USB_IS_AN_I2C_ADAPTER,332333.usb_ctrl = CYPRESS_FX2,334335.firmware = "dvb-usb-adstech-usb2-02.fw",336337.num_adapters = 1,338.adapter = {339{340.caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,341.pid_filter_count = 16,342343.streaming_ctrl = dibusb2_0_streaming_ctrl,344.pid_filter = dibusb_pid_filter,345.pid_filter_ctrl = dibusb_pid_filter_ctrl,346.frontend_attach = dibusb_dib3000mb_frontend_attach,347.tuner_attach = dibusb_thomson_tuner_attach,348349/* parameter for the MPEG2-data transfer */350.stream = {351.type = USB_BULK,352.count = 7,353.endpoint = 0x06,354.u = {355.bulk = {356.buffersize = 4096,357}358}359},360.size_of_priv = sizeof(struct dibusb_state),361}362},363.power_ctrl = dibusb2_0_power_ctrl,364365.rc.legacy = {366.rc_interval = DEFAULT_RC_INTERVAL,367.rc_map_table = rc_map_dibusb_table,368.rc_map_size = 111, /* wow, that is ugly ... I want to load it to the driver dynamically */369.rc_query = dibusb_rc_query,370},371372.i2c_algo = &dibusb_i2c_algo,373374.generic_bulk_ctrl_endpoint = 0x01,375376.num_device_descs = 2,377.devices = {378{ "KWorld/ADSTech Instant DVB-T USB2.0",379{ &dibusb_dib3000mb_table[23], NULL },380{ &dibusb_dib3000mb_table[24], NULL },381},382{ "KWorld Xpert DVB-T USB2.0",383{ &dibusb_dib3000mb_table[27], NULL },384{ NULL }385},386{ NULL },387}388};389390static struct dvb_usb_device_properties artec_t1_usb2_properties = {391.caps = DVB_USB_IS_AN_I2C_ADAPTER,392393.usb_ctrl = CYPRESS_FX2,394395.firmware = "dvb-usb-dibusb-6.0.0.8.fw",396397.num_adapters = 1,398.adapter = {399{400.caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,401.pid_filter_count = 16,402403.streaming_ctrl = dibusb2_0_streaming_ctrl,404.pid_filter = dibusb_pid_filter,405.pid_filter_ctrl = dibusb_pid_filter_ctrl,406.frontend_attach = dibusb_dib3000mb_frontend_attach,407.tuner_attach = dibusb_tuner_probe_and_attach,408/* parameter for the MPEG2-data transfer */409.stream = {410.type = USB_BULK,411.count = 7,412.endpoint = 0x06,413.u = {414.bulk = {415.buffersize = 4096,416}417}418},419.size_of_priv = sizeof(struct dibusb_state),420}421},422.power_ctrl = dibusb2_0_power_ctrl,423424.rc.legacy = {425.rc_interval = DEFAULT_RC_INTERVAL,426.rc_map_table = rc_map_dibusb_table,427.rc_map_size = 111, /* wow, that is ugly ... I want to load it to the driver dynamically */428.rc_query = dibusb_rc_query,429},430431.i2c_algo = &dibusb_i2c_algo,432433.generic_bulk_ctrl_endpoint = 0x01,434435.num_device_descs = 1,436.devices = {437{ "Artec T1 USB2.0",438{ &dibusb_dib3000mb_table[28], NULL },439{ &dibusb_dib3000mb_table[29], NULL },440},441{ NULL },442}443};444445static struct usb_driver dibusb_driver = {446.name = "dvb_usb_dibusb_mb",447.probe = dibusb_probe,448.disconnect = dvb_usb_device_exit,449.id_table = dibusb_dib3000mb_table,450};451452/* module stuff */453static int __init dibusb_module_init(void)454{455int result;456if ((result = usb_register(&dibusb_driver))) {457err("usb_register failed. Error number %d",result);458return result;459}460461return 0;462}463464static void __exit dibusb_module_exit(void)465{466/* deregister this driver from the USB subsystem */467usb_deregister(&dibusb_driver);468}469470module_init (dibusb_module_init);471module_exit (dibusb_module_exit);472473MODULE_AUTHOR("Patrick Boettcher <[email protected]>");474MODULE_DESCRIPTION("Driver for DiBcom USB DVB-T devices (DiB3000M-B based)");475MODULE_VERSION("1.0");476MODULE_LICENSE("GPL");477478479