2 * DVB USB Linux driver for Afatech AF9015 DVB-T USB2.0 receiver
4 * Copyright (C) 2007 Antti Palosaari <crope@iki.fi>
6 * Thanks to Afatech who kindly provided information.
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 #include <linux/hash.h>
25 #include <linux/slab.h>
37 static int dvb_usb_af9015_debug;
38 module_param_named(debug, dvb_usb_af9015_debug, int, 0644);
39 MODULE_PARM_DESC(debug, "set debugging level" DVB_USB_DEBUG_STATUS);
40 static int dvb_usb_af9015_remote;
41 module_param_named(remote, dvb_usb_af9015_remote, int, 0644);
42 MODULE_PARM_DESC(remote, "select remote");
43 DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
45 static DEFINE_MUTEX(af9015_usb_mutex);
47 static struct af9015_config af9015_config;
48 static struct dvb_usb_device_properties af9015_properties[3];
49 static int af9015_properties_count = ARRAY_SIZE(af9015_properties);
51 static struct af9013_config af9015_af9013_config[] = {
53 .demod_address = AF9015_I2C_DEMOD,
54 .output_mode = AF9013_OUTPUT_MODE_USB,
55 .api_version = { 0, 1, 9, 0 },
56 .gpio[0] = AF9013_GPIO_HI,
57 .gpio[3] = AF9013_GPIO_TUNER_ON,
60 .output_mode = AF9013_OUTPUT_MODE_SERIAL,
61 .api_version = { 0, 1, 9, 0 },
62 .gpio[0] = AF9013_GPIO_TUNER_ON,
63 .gpio[1] = AF9013_GPIO_LO,
67 static int af9015_rw_udev(struct usb_device *udev, struct req_t *req)
70 #define REQ_HDR_LEN 8 /* send header size */
71 #define ACK_HDR_LEN 2 /* rece header size */
75 u8 msg_len = REQ_HDR_LEN;
76 static u8 seq; /* packet sequence number */
78 if (mutex_lock_interruptible(&af9015_usb_mutex) < 0)
83 buf[2] = req->i2c_addr;
84 buf[3] = req->addr >> 8;
85 buf[4] = req->addr & 0xff;
87 buf[6] = req->addr_len;
88 buf[7] = req->data_len;
98 buf[2] |= 0x01; /* set I2C direction */
100 buf[0] = READ_WRITE_I2C;
103 if (((req->addr & 0xff00) == 0xff00) ||
104 ((req->addr & 0xff00) == 0xae00))
105 buf[0] = WRITE_VIRTUAL_MEMORY;
106 case WRITE_VIRTUAL_MEMORY:
108 case DOWNLOAD_FIRMWARE:
112 err("unknown command:%d", req->cmd);
117 /* buffer overflow check */
118 if ((write && (req->data_len > BUF_LEN - REQ_HDR_LEN)) ||
119 (!write && (req->data_len > BUF_LEN - ACK_HDR_LEN))) {
120 err("too much data; cmd:%d len:%d", req->cmd, req->data_len);
125 /* write requested */
127 memcpy(&buf[REQ_HDR_LEN], req->data, req->data_len);
128 msg_len += req->data_len;
132 debug_dump(buf, msg_len, deb_xfer);
135 ret = usb_bulk_msg(udev, usb_sndbulkpipe(udev, 0x02), buf, msg_len,
136 &act_len, AF9015_USB_TIMEOUT);
138 err("bulk message failed:%d (%d/%d)", ret, msg_len, act_len);
140 if (act_len != msg_len)
141 ret = -1; /* all data is not send */
145 /* no ack for those packets */
146 if (req->cmd == DOWNLOAD_FIRMWARE || req->cmd == RECONNECT_USB)
149 /* write receives seq + status = 2 bytes
150 read receives seq + status + data = 2 + N bytes */
151 msg_len = ACK_HDR_LEN;
153 msg_len += req->data_len;
155 ret = usb_bulk_msg(udev, usb_rcvbulkpipe(udev, 0x81), buf, msg_len,
156 &act_len, AF9015_USB_TIMEOUT);
158 err("recv bulk message failed:%d", ret);
164 debug_dump(buf, act_len, deb_xfer);
168 err("command failed:%d", buf[1]);
173 /* read request, copy returned data to return buf */
175 memcpy(req->data, &buf[ACK_HDR_LEN], req->data_len);
179 mutex_unlock(&af9015_usb_mutex);
184 static int af9015_ctrl_msg(struct dvb_usb_device *d, struct req_t *req)
186 return af9015_rw_udev(d->udev, req);
189 static int af9015_write_regs(struct dvb_usb_device *d, u16 addr, u8 *val,
192 struct req_t req = {WRITE_MEMORY, AF9015_I2C_DEMOD, addr, 0, 0, len,
194 return af9015_ctrl_msg(d, &req);
197 static int af9015_write_reg(struct dvb_usb_device *d, u16 addr, u8 val)
199 return af9015_write_regs(d, addr, &val, 1);
202 static int af9015_read_regs(struct dvb_usb_device *d, u16 addr, u8 *val, u8 len)
204 struct req_t req = {READ_MEMORY, AF9015_I2C_DEMOD, addr, 0, 0, len,
206 return af9015_ctrl_msg(d, &req);
209 static int af9015_read_reg(struct dvb_usb_device *d, u16 addr, u8 *val)
211 return af9015_read_regs(d, addr, val, 1);
214 static int af9015_write_reg_i2c(struct dvb_usb_device *d, u8 addr, u16 reg,
217 struct req_t req = {WRITE_I2C, addr, reg, 1, 1, 1, &val};
219 if (addr == af9015_af9013_config[0].demod_address ||
220 addr == af9015_af9013_config[1].demod_address)
223 return af9015_ctrl_msg(d, &req);
226 static int af9015_read_reg_i2c(struct dvb_usb_device *d, u8 addr, u16 reg,
229 struct req_t req = {READ_I2C, addr, reg, 0, 1, 1, val};
231 if (addr == af9015_af9013_config[0].demod_address ||
232 addr == af9015_af9013_config[1].demod_address)
235 return af9015_ctrl_msg(d, &req);
238 static int af9015_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[],
241 struct dvb_usb_device *d = i2c_get_adapdata(adap);
244 u8 uninitialized_var(mbox), addr_len;
247 /* TODO: implement bus lock
249 The bus lock is needed because there is two tuners both using same I2C-address.
250 Due to that the only way to select correct tuner is use demodulator I2C-gate.
252 ................................................
253 . AF9015 includes integrated AF9013 demodulator.
254 . ____________ ____________ . ____________
255 .| uC | | demod | . | tuner |
256 .|------------| |------------| . |------------|
257 .| AF9015 | | AF9013/5 | . | MXL5003 |
258 .| |--+----I2C-------|-----/ -----|-.-----I2C-------| |
259 .| | | | addr 0x38 | . | addr 0xc6 |
260 .|____________| | |____________| . |____________|
261 .................|..............................
262 | ____________ ____________
263 | | demod | | tuner |
264 | |------------| |------------|
265 | | AF9013 | | MXL5003 |
266 +----I2C-------|-----/ -----|-------I2C-------| |
267 | addr 0x3a | | addr 0xc6 |
268 |____________| |____________|
270 if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
274 if (msg[i].addr == af9015_af9013_config[0].demod_address ||
275 msg[i].addr == af9015_af9013_config[1].demod_address) {
276 addr = msg[i].buf[0] << 8;
277 addr += msg[i].buf[1];
278 mbox = msg[i].buf[2];
281 addr = msg[i].buf[0];
283 /* mbox is don't care in that case */
286 if (num > i + 1 && (msg[i+1].flags & I2C_M_RD)) {
287 if (msg[i].len > 3 || msg[i+1].len > 61) {
292 af9015_af9013_config[0].demod_address)
293 req.cmd = READ_MEMORY;
296 req.i2c_addr = msg[i].addr;
299 req.addr_len = addr_len;
300 req.data_len = msg[i+1].len;
301 req.data = &msg[i+1].buf[0];
302 ret = af9015_ctrl_msg(d, &req);
304 } else if (msg[i].flags & I2C_M_RD) {
305 if (msg[i].len > 61) {
310 af9015_af9013_config[0].demod_address) {
315 req.i2c_addr = msg[i].addr;
318 req.addr_len = addr_len;
319 req.data_len = msg[i].len;
320 req.data = &msg[i].buf[0];
321 ret = af9015_ctrl_msg(d, &req);
324 if (msg[i].len > 21) {
329 af9015_af9013_config[0].demod_address)
330 req.cmd = WRITE_MEMORY;
333 req.i2c_addr = msg[i].addr;
336 req.addr_len = addr_len;
337 req.data_len = msg[i].len-addr_len;
338 req.data = &msg[i].buf[addr_len];
339 ret = af9015_ctrl_msg(d, &req);
349 mutex_unlock(&d->i2c_mutex);
354 static u32 af9015_i2c_func(struct i2c_adapter *adapter)
359 static struct i2c_algorithm af9015_i2c_algo = {
360 .master_xfer = af9015_i2c_xfer,
361 .functionality = af9015_i2c_func,
364 static int af9015_do_reg_bit(struct dvb_usb_device *d, u16 addr, u8 bit, u8 op)
369 ret = af9015_read_reg(d, addr, &val);
383 return af9015_write_reg(d, addr, val);
386 static int af9015_set_reg_bit(struct dvb_usb_device *d, u16 addr, u8 bit)
388 return af9015_do_reg_bit(d, addr, bit, 1);
391 static int af9015_clear_reg_bit(struct dvb_usb_device *d, u16 addr, u8 bit)
393 return af9015_do_reg_bit(d, addr, bit, 0);
396 static int af9015_init_endpoint(struct dvb_usb_device *d)
401 deb_info("%s: USB speed:%d\n", __func__, d->udev->speed);
403 /* Windows driver uses packet count 21 for USB1.1 and 348 for USB2.0.
404 We use smaller - about 1/4 from the original, 5 and 87. */
405 #define TS_PACKET_SIZE 188
407 #define TS_USB20_PACKET_COUNT 87
408 #define TS_USB20_FRAME_SIZE (TS_PACKET_SIZE*TS_USB20_PACKET_COUNT)
410 #define TS_USB11_PACKET_COUNT 5
411 #define TS_USB11_FRAME_SIZE (TS_PACKET_SIZE*TS_USB11_PACKET_COUNT)
413 #define TS_USB20_MAX_PACKET_SIZE 512
414 #define TS_USB11_MAX_PACKET_SIZE 64
416 if (d->udev->speed == USB_SPEED_FULL) {
417 frame_size = TS_USB11_FRAME_SIZE/4;
418 packet_size = TS_USB11_MAX_PACKET_SIZE/4;
420 frame_size = TS_USB20_FRAME_SIZE/4;
421 packet_size = TS_USB20_MAX_PACKET_SIZE/4;
424 ret = af9015_set_reg_bit(d, 0xd507, 2); /* assert EP4 reset */
427 ret = af9015_set_reg_bit(d, 0xd50b, 1); /* assert EP5 reset */
430 ret = af9015_clear_reg_bit(d, 0xdd11, 5); /* disable EP4 */
433 ret = af9015_clear_reg_bit(d, 0xdd11, 6); /* disable EP5 */
436 ret = af9015_set_reg_bit(d, 0xdd11, 5); /* enable EP4 */
439 if (af9015_config.dual_mode) {
440 ret = af9015_set_reg_bit(d, 0xdd11, 6); /* enable EP5 */
444 ret = af9015_clear_reg_bit(d, 0xdd13, 5); /* disable EP4 NAK */
447 if (af9015_config.dual_mode) {
448 ret = af9015_clear_reg_bit(d, 0xdd13, 6); /* disable EP5 NAK */
452 /* EP4 xfer length */
453 ret = af9015_write_reg(d, 0xdd88, frame_size & 0xff);
456 ret = af9015_write_reg(d, 0xdd89, frame_size >> 8);
459 /* EP5 xfer length */
460 ret = af9015_write_reg(d, 0xdd8a, frame_size & 0xff);
463 ret = af9015_write_reg(d, 0xdd8b, frame_size >> 8);
466 ret = af9015_write_reg(d, 0xdd0c, packet_size); /* EP4 packet size */
469 ret = af9015_write_reg(d, 0xdd0d, packet_size); /* EP5 packet size */
472 ret = af9015_clear_reg_bit(d, 0xd507, 2); /* negate EP4 reset */
475 if (af9015_config.dual_mode) {
476 ret = af9015_clear_reg_bit(d, 0xd50b, 1); /* negate EP5 reset */
481 /* enable / disable mp2if2 */
482 if (af9015_config.dual_mode)
483 ret = af9015_set_reg_bit(d, 0xd50b, 0);
485 ret = af9015_clear_reg_bit(d, 0xd50b, 0);
489 err("endpoint init failed:%d", ret);
493 static int af9015_copy_firmware(struct dvb_usb_device *d)
498 struct req_t req = {COPY_FIRMWARE, 0, 0x5100, 0, 0, sizeof(fw_params),
500 deb_info("%s:\n", __func__);
502 fw_params[0] = af9015_config.firmware_size >> 8;
503 fw_params[1] = af9015_config.firmware_size & 0xff;
504 fw_params[2] = af9015_config.firmware_checksum >> 8;
505 fw_params[3] = af9015_config.firmware_checksum & 0xff;
507 /* wait 2nd demodulator ready */
510 ret = af9015_read_reg_i2c(d,
511 af9015_af9013_config[1].demod_address, 0x98be, &val);
515 deb_info("%s: firmware status:%02x\n", __func__, val);
517 if (val == 0x0c) /* fw is running, no need for download */
520 /* set I2C master clock to fast (to speed up firmware copy) */
521 ret = af9015_write_reg(d, 0xd416, 0x04); /* 0x04 * 400ns */
528 ret = af9015_ctrl_msg(d, &req);
530 err("firmware copy cmd failed:%d", ret);
531 deb_info("%s: firmware copy done\n", __func__);
533 /* set I2C master clock back to normal */
534 ret = af9015_write_reg(d, 0xd416, 0x14); /* 0x14 * 400ns */
538 /* request boot firmware */
539 ret = af9015_write_reg_i2c(d, af9015_af9013_config[1].demod_address,
541 deb_info("%s: firmware boot cmd status:%d\n", __func__, ret);
545 for (i = 0; i < 15; i++) {
548 /* check firmware status */
549 ret = af9015_read_reg_i2c(d,
550 af9015_af9013_config[1].demod_address, 0x98be, &val);
551 deb_info("%s: firmware status cmd status:%d fw status:%02x\n",
556 if (val == 0x0c || val == 0x04) /* success or fail */
561 err("firmware did not run");
563 } else if (val != 0x0c) {
564 err("firmware boot timeout");
573 /* hash (and dump) eeprom */
574 static int af9015_eeprom_hash(struct usb_device *udev)
576 static const unsigned int eeprom_size = 256;
580 struct req_t req = {READ_I2C, AF9015_I2C_EEPROM, 0, 0, 1, 1, &val};
582 eeprom = kmalloc(eeprom_size, GFP_KERNEL);
586 for (reg = 0; reg < eeprom_size; reg++) {
588 ret = af9015_rw_udev(udev, &req);
594 if (dvb_usb_af9015_debug & 0x01)
595 print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, eeprom,
598 BUG_ON(eeprom_size % 4);
600 af9015_config.eeprom_sum = 0;
601 for (reg = 0; reg < eeprom_size / sizeof(u32); reg++) {
602 af9015_config.eeprom_sum *= GOLDEN_RATIO_PRIME_32;
603 af9015_config.eeprom_sum += le32_to_cpu(((u32 *)eeprom)[reg]);
606 deb_info("%s: eeprom sum=%.8x\n", __func__, af9015_config.eeprom_sum);
614 static int af9015_init(struct dvb_usb_device *d)
617 deb_info("%s:\n", __func__);
620 ret = af9015_write_reg(d, 0x98e9, 0xff);
624 ret = af9015_init_endpoint(d);
632 static int af9015_pid_filter_ctrl(struct dvb_usb_adapter *adap, int onoff)
635 deb_info("%s: onoff:%d\n", __func__, onoff);
638 ret = af9015_set_reg_bit(adap->dev, 0xd503, 0);
640 ret = af9015_clear_reg_bit(adap->dev, 0xd503, 0);
645 static int af9015_pid_filter(struct dvb_usb_adapter *adap, int index, u16 pid,
651 deb_info("%s: set pid filter, index %d, pid %x, onoff %d\n",
652 __func__, index, pid, onoff);
654 ret = af9015_write_reg(adap->dev, 0xd505, (pid & 0xff));
658 ret = af9015_write_reg(adap->dev, 0xd506, (pid >> 8));
662 idx = ((index & 0x1f) | (1 << 5));
663 ret = af9015_write_reg(adap->dev, 0xd504, idx);
669 static int af9015_download_firmware(struct usb_device *udev,
670 const struct firmware *fw)
672 int i, len, remaining, ret;
673 struct req_t req = {DOWNLOAD_FIRMWARE, 0, 0, 0, 0, 0, NULL};
676 deb_info("%s:\n", __func__);
679 for (i = 0; i < fw->size; i++)
680 checksum += fw->data[i];
682 af9015_config.firmware_size = fw->size;
683 af9015_config.firmware_checksum = checksum;
685 #define FW_ADDR 0x5100 /* firmware start address */
686 #define LEN_MAX 55 /* max packet size */
687 for (remaining = fw->size; remaining > 0; remaining -= LEN_MAX) {
693 req.data = (u8 *) &fw->data[fw->size - remaining];
694 req.addr = FW_ADDR + fw->size - remaining;
696 ret = af9015_rw_udev(udev, &req);
698 err("firmware download failed:%d", ret);
703 /* firmware loaded, request boot */
705 ret = af9015_rw_udev(udev, &req);
707 err("firmware boot failed:%d", ret);
715 struct af9015_rc_setup {
720 static char *af9015_rc_setup_match(unsigned int id,
721 const struct af9015_rc_setup *table)
723 for (; table->rc_codes; table++)
725 return table->rc_codes;
729 static const struct af9015_rc_setup af9015_rc_setup_modparam[] = {
730 { AF9015_REMOTE_A_LINK_DTU_M, RC_MAP_ALINK_DTU_M },
731 { AF9015_REMOTE_MSI_DIGIVOX_MINI_II_V3, RC_MAP_MSI_DIGIVOX_II },
732 { AF9015_REMOTE_MYGICTV_U718, RC_MAP_TOTAL_MEDIA_IN_HAND },
733 { AF9015_REMOTE_DIGITTRADE_DVB_T, RC_MAP_DIGITTRADE },
734 { AF9015_REMOTE_AVERMEDIA_KS, RC_MAP_AVERMEDIA_RM_KS },
738 static const struct af9015_rc_setup af9015_rc_setup_hashes[] = {
739 { 0xb8feb708, RC_MAP_MSI_DIGIVOX_II },
740 { 0xa3703d00, RC_MAP_ALINK_DTU_M },
741 { 0x9b7dc64e, RC_MAP_TOTAL_MEDIA_IN_HAND }, /* MYGICTV U718 */
742 { 0x5d49e3db, RC_MAP_DIGITTRADE }, /* LC-Power LC-USB-DVBT */
746 static const struct af9015_rc_setup af9015_rc_setup_usbids[] = {
747 { (USB_VID_TERRATEC << 16) | USB_PID_TERRATEC_CINERGY_T_STICK_RC,
748 RC_MAP_TERRATEC_SLIM_2 },
749 { (USB_VID_TERRATEC << 16) | USB_PID_TERRATEC_CINERGY_T_STICK_DUAL_RC,
750 RC_MAP_TERRATEC_SLIM },
751 { (USB_VID_VISIONPLUS << 16) | USB_PID_AZUREWAVE_AD_TU700,
752 RC_MAP_AZUREWAVE_AD_TU700 },
753 { (USB_VID_VISIONPLUS << 16) | USB_PID_TINYTWIN,
754 RC_MAP_AZUREWAVE_AD_TU700 },
755 { (USB_VID_MSI_2 << 16) | USB_PID_MSI_DIGI_VOX_MINI_III,
756 RC_MAP_MSI_DIGIVOX_III },
757 { (USB_VID_MSI_2 << 16) | USB_PID_MSI_DIGIVOX_DUO,
758 RC_MAP_MSI_DIGIVOX_III },
759 { (USB_VID_LEADTEK << 16) | USB_PID_WINFAST_DTV_DONGLE_GOLD,
760 RC_MAP_LEADTEK_Y04G0051 },
761 { (USB_VID_LEADTEK << 16) | USB_PID_WINFAST_DTV2000DS,
762 RC_MAP_LEADTEK_Y04G0051 },
763 { (USB_VID_AVERMEDIA << 16) | USB_PID_AVERMEDIA_VOLAR_X,
764 RC_MAP_AVERMEDIA_M135A },
765 { (USB_VID_AFATECH << 16) | USB_PID_TREKSTOR_DVBT,
767 { (USB_VID_KWORLD_2 << 16) | USB_PID_TINYTWIN_2,
768 RC_MAP_DIGITALNOW_TINYTWIN },
769 { (USB_VID_GTEK << 16) | USB_PID_TINYTWIN_3,
770 RC_MAP_DIGITALNOW_TINYTWIN },
771 { (USB_VID_KWORLD_2 << 16) | USB_PID_SVEON_STV22,
772 RC_MAP_MSI_DIGIVOX_III },
776 static void af9015_set_remote_config(struct usb_device *udev,
777 struct dvb_usb_device_properties *props)
779 u16 vid = le16_to_cpu(udev->descriptor.idVendor);
780 u16 pid = le16_to_cpu(udev->descriptor.idProduct);
782 /* try to load remote based module param */
783 props->rc.core.rc_codes = af9015_rc_setup_match(
784 dvb_usb_af9015_remote, af9015_rc_setup_modparam);
786 /* try to load remote based eeprom hash */
787 if (!props->rc.core.rc_codes)
788 props->rc.core.rc_codes = af9015_rc_setup_match(
789 af9015_config.eeprom_sum, af9015_rc_setup_hashes);
791 /* try to load remote based USB ID */
792 if (!props->rc.core.rc_codes)
793 props->rc.core.rc_codes = af9015_rc_setup_match(
794 (vid << 16) + pid, af9015_rc_setup_usbids);
796 /* try to load remote based USB iManufacturer string */
797 if (!props->rc.core.rc_codes && vid == USB_VID_AFATECH) {
798 /* Check USB manufacturer and product strings and try
799 to determine correct remote in case of chip vendor
800 reference IDs are used.
801 DO NOT ADD ANYTHING NEW HERE. Use hashes instead. */
802 char manufacturer[10];
803 memset(manufacturer, 0, sizeof(manufacturer));
804 usb_string(udev, udev->descriptor.iManufacturer,
805 manufacturer, sizeof(manufacturer));
806 if (!strcmp("MSI", manufacturer)) {
807 /* iManufacturer 1 MSI
808 iProduct 2 MSI K-VOX */
809 props->rc.core.rc_codes = af9015_rc_setup_match(
810 AF9015_REMOTE_MSI_DIGIVOX_MINI_II_V3,
811 af9015_rc_setup_modparam);
815 /* finally load "empty" just for leaving IR receiver enabled */
816 if (!props->rc.core.rc_codes)
817 props->rc.core.rc_codes = RC_MAP_EMPTY;
822 static int af9015_read_config(struct usb_device *udev)
825 u8 val, i, offset = 0;
826 struct req_t req = {READ_I2C, AF9015_I2C_EEPROM, 0, 0, 1, 1, &val};
828 /* IR remote controller */
829 req.addr = AF9015_EEPROM_IR_MODE;
830 /* first message will timeout often due to possible hw bug */
831 for (i = 0; i < 4; i++) {
832 ret = af9015_rw_udev(udev, &req);
839 ret = af9015_eeprom_hash(udev);
843 deb_info("%s: IR mode:%d\n", __func__, val);
844 for (i = 0; i < af9015_properties_count; i++) {
845 if (val == AF9015_IR_MODE_DISABLED)
846 af9015_properties[i].rc.core.rc_codes = NULL;
848 af9015_set_remote_config(udev, &af9015_properties[i]);
851 /* TS mode - one or two receivers */
852 req.addr = AF9015_EEPROM_TS_MODE;
853 ret = af9015_rw_udev(udev, &req);
856 af9015_config.dual_mode = val;
857 deb_info("%s: TS mode:%d\n", __func__, af9015_config.dual_mode);
859 /* Set adapter0 buffer size according to USB port speed, adapter1 buffer
860 size can be static because it is enabled only USB2.0 */
861 for (i = 0; i < af9015_properties_count; i++) {
862 /* USB1.1 set smaller buffersize and disable 2nd adapter */
863 if (udev->speed == USB_SPEED_FULL) {
864 af9015_properties[i].adapter[0].fe[0].stream.u.bulk.buffersize
865 = TS_USB11_FRAME_SIZE;
866 /* disable 2nd adapter because we don't have
868 af9015_config.dual_mode = 0;
870 af9015_properties[i].adapter[0].fe[0].stream.u.bulk.buffersize
871 = TS_USB20_FRAME_SIZE;
875 if (af9015_config.dual_mode) {
876 /* read 2nd demodulator I2C address */
877 req.addr = AF9015_EEPROM_DEMOD2_I2C;
878 ret = af9015_rw_udev(udev, &req);
881 af9015_af9013_config[1].demod_address = val;
883 /* enable 2nd adapter */
884 for (i = 0; i < af9015_properties_count; i++)
885 af9015_properties[i].num_adapters = 2;
888 /* disable 2nd adapter */
889 for (i = 0; i < af9015_properties_count; i++)
890 af9015_properties[i].num_adapters = 1;
893 for (i = 0; i < af9015_properties[0].num_adapters; i++) {
895 offset = AF9015_EEPROM_OFFSET;
897 req.addr = AF9015_EEPROM_XTAL_TYPE1 + offset;
898 ret = af9015_rw_udev(udev, &req);
903 af9015_af9013_config[i].adc_clock = 28800;
906 af9015_af9013_config[i].adc_clock = 20480;
909 af9015_af9013_config[i].adc_clock = 28000;
912 af9015_af9013_config[i].adc_clock = 25000;
915 deb_info("%s: [%d] xtal:%d set adc_clock:%d\n", __func__, i,
916 val, af9015_af9013_config[i].adc_clock);
919 req.addr = AF9015_EEPROM_IF1H + offset;
920 ret = af9015_rw_udev(udev, &req);
923 af9015_af9013_config[i].tuner_if = val << 8;
924 req.addr = AF9015_EEPROM_IF1L + offset;
925 ret = af9015_rw_udev(udev, &req);
928 af9015_af9013_config[i].tuner_if += val;
929 deb_info("%s: [%d] IF1:%d\n", __func__, i,
930 af9015_af9013_config[0].tuner_if);
933 req.addr = AF9015_EEPROM_MT2060_IF1H + offset;
934 ret = af9015_rw_udev(udev, &req);
937 af9015_config.mt2060_if1[i] = val << 8;
938 req.addr = AF9015_EEPROM_MT2060_IF1L + offset;
939 ret = af9015_rw_udev(udev, &req);
942 af9015_config.mt2060_if1[i] += val;
943 deb_info("%s: [%d] MT2060 IF1:%d\n", __func__, i,
944 af9015_config.mt2060_if1[i]);
947 req.addr = AF9015_EEPROM_TUNER_ID1 + offset;
948 ret = af9015_rw_udev(udev, &req);
952 case AF9013_TUNER_ENV77H11D5:
953 case AF9013_TUNER_MT2060:
954 case AF9013_TUNER_QT1010:
955 case AF9013_TUNER_UNKNOWN:
956 case AF9013_TUNER_MT2060_2:
957 case AF9013_TUNER_TDA18271:
958 case AF9013_TUNER_QT1010A:
959 case AF9013_TUNER_TDA18218:
960 af9015_af9013_config[i].rf_spec_inv = 1;
962 case AF9013_TUNER_MXL5003D:
963 case AF9013_TUNER_MXL5005D:
964 case AF9013_TUNER_MXL5005R:
965 case AF9013_TUNER_MXL5007T:
966 af9015_af9013_config[i].rf_spec_inv = 0;
968 case AF9013_TUNER_MC44S803:
969 af9015_af9013_config[i].gpio[1] = AF9013_GPIO_LO;
970 af9015_af9013_config[i].rf_spec_inv = 1;
973 warn("tuner id:%d not supported, please report!", val);
977 af9015_af9013_config[i].tuner = val;
978 deb_info("%s: [%d] tuner id:%d\n", __func__, i, val);
983 err("eeprom read failed:%d", ret);
985 /* AverMedia AVerTV Volar Black HD (A850) device have bad EEPROM
986 content :-( Override some wrong values here. Ditto for the
987 AVerTV Red HD+ (A850T) device. */
988 if (le16_to_cpu(udev->descriptor.idVendor) == USB_VID_AVERMEDIA &&
989 ((le16_to_cpu(udev->descriptor.idProduct) ==
990 USB_PID_AVERMEDIA_A850) ||
991 (le16_to_cpu(udev->descriptor.idProduct) ==
992 USB_PID_AVERMEDIA_A850T))) {
993 deb_info("%s: AverMedia A850: overriding config\n", __func__);
994 /* disable dual mode */
995 af9015_config.dual_mode = 0;
996 /* disable 2nd adapter */
997 for (i = 0; i < af9015_properties_count; i++)
998 af9015_properties[i].num_adapters = 1;
1000 /* set correct IF */
1001 af9015_af9013_config[0].tuner_if = 4570;
1007 static int af9015_identify_state(struct usb_device *udev,
1008 struct dvb_usb_device_properties *props,
1009 struct dvb_usb_device_description **desc,
1014 struct req_t req = {GET_CONFIG, 0, 0, 0, 0, 1, &reply};
1016 ret = af9015_rw_udev(udev, &req);
1020 deb_info("%s: reply:%02x\n", __func__, reply);
1029 static int af9015_rc_query(struct dvb_usb_device *d)
1031 struct af9015_state *priv = d->priv;
1035 /* read registers needed to detect remote controller code */
1036 ret = af9015_read_regs(d, 0x98d9, buf, sizeof(buf));
1040 /* If any of these are non-zero, assume invalid data */
1041 if (buf[1] || buf[2] || buf[3])
1044 /* Check for repeat of previous code */
1045 if ((priv->rc_repeat != buf[6] || buf[0]) &&
1046 !memcmp(&buf[12], priv->rc_last, 4)) {
1047 deb_rc("%s: key repeated\n", __func__);
1048 rc_keydown(d->rc_dev, priv->rc_keycode, 0);
1049 priv->rc_repeat = buf[6];
1053 /* Only process key if canary killed */
1054 if (buf[16] != 0xff && buf[0] != 0x01) {
1055 deb_rc("%s: key pressed %02x %02x %02x %02x\n", __func__,
1056 buf[12], buf[13], buf[14], buf[15]);
1058 /* Reset the canary */
1059 ret = af9015_write_reg(d, 0x98e9, 0xff);
1063 /* Remember this key */
1064 memcpy(priv->rc_last, &buf[12], 4);
1065 if (buf[14] == (u8) ~buf[15]) {
1066 if (buf[12] == (u8) ~buf[13]) {
1068 priv->rc_keycode = buf[12] << 8 | buf[14];
1071 priv->rc_keycode = buf[12] << 16 |
1072 buf[13] << 8 | buf[14];
1076 priv->rc_keycode = buf[12] << 24 | buf[13] << 16 |
1077 buf[14] << 8 | buf[15];
1079 rc_keydown(d->rc_dev, priv->rc_keycode, 0);
1081 deb_rc("%s: no key press\n", __func__);
1082 /* Invalidate last keypress */
1083 /* Not really needed, but helps with debug */
1084 priv->rc_last[2] = priv->rc_last[3];
1087 priv->rc_repeat = buf[6];
1091 err("%s: failed:%d", __func__, ret);
1096 static int af9015_af9013_frontend_attach(struct dvb_usb_adapter *adap)
1100 if (adap->id == 1) {
1101 /* copy firmware to 2nd demodulator */
1102 if (af9015_config.dual_mode) {
1103 ret = af9015_copy_firmware(adap->dev);
1105 err("firmware copy to 2nd frontend " \
1106 "failed, will disable it");
1107 af9015_config.dual_mode = 0;
1115 /* attach demodulator */
1116 adap->fe_adap[0].fe = dvb_attach(af9013_attach, &af9015_af9013_config[adap->id],
1117 &adap->dev->i2c_adap);
1119 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
1122 static struct mt2060_config af9015_mt2060_config = {
1123 .i2c_address = 0xc0,
1127 static struct qt1010_config af9015_qt1010_config = {
1128 .i2c_address = 0xc4,
1131 static struct tda18271_config af9015_tda18271_config = {
1132 .gate = TDA18271_GATE_DIGITAL,
1133 .small_i2c = TDA18271_16_BYTE_CHUNK_INIT,
1136 static struct mxl5005s_config af9015_mxl5003_config = {
1137 .i2c_address = 0xc6,
1138 .if_freq = IF_FREQ_4570000HZ,
1139 .xtal_freq = CRYSTAL_FREQ_16000000HZ,
1140 .agc_mode = MXL_SINGLE_AGC,
1141 .tracking_filter = MXL_TF_DEFAULT,
1142 .rssi_enable = MXL_RSSI_ENABLE,
1143 .cap_select = MXL_CAP_SEL_ENABLE,
1144 .div_out = MXL_DIV_OUT_4,
1145 .clock_out = MXL_CLOCK_OUT_DISABLE,
1146 .output_load = MXL5005S_IF_OUTPUT_LOAD_200_OHM,
1147 .top = MXL5005S_TOP_25P2,
1148 .mod_mode = MXL_DIGITAL_MODE,
1149 .if_mode = MXL_ZERO_IF,
1150 .AgcMasterByte = 0x00,
1153 static struct mxl5005s_config af9015_mxl5005_config = {
1154 .i2c_address = 0xc6,
1155 .if_freq = IF_FREQ_4570000HZ,
1156 .xtal_freq = CRYSTAL_FREQ_16000000HZ,
1157 .agc_mode = MXL_SINGLE_AGC,
1158 .tracking_filter = MXL_TF_OFF,
1159 .rssi_enable = MXL_RSSI_ENABLE,
1160 .cap_select = MXL_CAP_SEL_ENABLE,
1161 .div_out = MXL_DIV_OUT_4,
1162 .clock_out = MXL_CLOCK_OUT_DISABLE,
1163 .output_load = MXL5005S_IF_OUTPUT_LOAD_200_OHM,
1164 .top = MXL5005S_TOP_25P2,
1165 .mod_mode = MXL_DIGITAL_MODE,
1166 .if_mode = MXL_ZERO_IF,
1167 .AgcMasterByte = 0x00,
1170 static struct mc44s803_config af9015_mc44s803_config = {
1171 .i2c_address = 0xc0,
1175 static struct tda18218_config af9015_tda18218_config = {
1176 .i2c_address = 0xc0,
1177 .i2c_wr_max = 21, /* max wr bytes AF9015 I2C adap can handle at once */
1180 static struct mxl5007t_config af9015_mxl5007t_config = {
1181 .xtal_freq_hz = MxL_XTAL_24_MHZ,
1182 .if_freq_hz = MxL_IF_4_57_MHZ,
1185 static int af9015_tuner_attach(struct dvb_usb_adapter *adap)
1188 deb_info("%s:\n", __func__);
1190 switch (af9015_af9013_config[adap->id].tuner) {
1191 case AF9013_TUNER_MT2060:
1192 case AF9013_TUNER_MT2060_2:
1193 ret = dvb_attach(mt2060_attach, adap->fe_adap[0].fe, &adap->dev->i2c_adap,
1194 &af9015_mt2060_config,
1195 af9015_config.mt2060_if1[adap->id])
1196 == NULL ? -ENODEV : 0;
1198 case AF9013_TUNER_QT1010:
1199 case AF9013_TUNER_QT1010A:
1200 ret = dvb_attach(qt1010_attach, adap->fe_adap[0].fe, &adap->dev->i2c_adap,
1201 &af9015_qt1010_config) == NULL ? -ENODEV : 0;
1203 case AF9013_TUNER_TDA18271:
1204 ret = dvb_attach(tda18271_attach, adap->fe_adap[0].fe, 0xc0,
1205 &adap->dev->i2c_adap,
1206 &af9015_tda18271_config) == NULL ? -ENODEV : 0;
1208 case AF9013_TUNER_TDA18218:
1209 ret = dvb_attach(tda18218_attach, adap->fe_adap[0].fe,
1210 &adap->dev->i2c_adap,
1211 &af9015_tda18218_config) == NULL ? -ENODEV : 0;
1213 case AF9013_TUNER_MXL5003D:
1214 ret = dvb_attach(mxl5005s_attach, adap->fe_adap[0].fe,
1215 &adap->dev->i2c_adap,
1216 &af9015_mxl5003_config) == NULL ? -ENODEV : 0;
1218 case AF9013_TUNER_MXL5005D:
1219 case AF9013_TUNER_MXL5005R:
1220 ret = dvb_attach(mxl5005s_attach, adap->fe_adap[0].fe,
1221 &adap->dev->i2c_adap,
1222 &af9015_mxl5005_config) == NULL ? -ENODEV : 0;
1224 case AF9013_TUNER_ENV77H11D5:
1225 ret = dvb_attach(dvb_pll_attach, adap->fe_adap[0].fe, 0xc0,
1226 &adap->dev->i2c_adap,
1227 DVB_PLL_TDA665X) == NULL ? -ENODEV : 0;
1229 case AF9013_TUNER_MC44S803:
1230 ret = dvb_attach(mc44s803_attach, adap->fe_adap[0].fe,
1231 &adap->dev->i2c_adap,
1232 &af9015_mc44s803_config) == NULL ? -ENODEV : 0;
1234 case AF9013_TUNER_MXL5007T:
1235 ret = dvb_attach(mxl5007t_attach, adap->fe_adap[0].fe,
1236 &adap->dev->i2c_adap,
1237 0xc0, &af9015_mxl5007t_config) == NULL ? -ENODEV : 0;
1239 case AF9013_TUNER_UNKNOWN:
1242 err("Unknown tuner id:%d",
1243 af9015_af9013_config[adap->id].tuner);
1248 static struct usb_device_id af9015_usb_table[] = {
1249 /* 0 */{USB_DEVICE(USB_VID_AFATECH, USB_PID_AFATECH_AF9015_9015)},
1250 {USB_DEVICE(USB_VID_AFATECH, USB_PID_AFATECH_AF9015_9016)},
1251 {USB_DEVICE(USB_VID_LEADTEK, USB_PID_WINFAST_DTV_DONGLE_GOLD)},
1252 {USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV71E)},
1253 {USB_DEVICE(USB_VID_KWORLD_2, USB_PID_KWORLD_399U)},
1254 /* 5 */{USB_DEVICE(USB_VID_VISIONPLUS,
1256 {USB_DEVICE(USB_VID_VISIONPLUS,
1257 USB_PID_AZUREWAVE_AD_TU700)},
1258 {USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_T_USB_XE_REV2)},
1259 {USB_DEVICE(USB_VID_KWORLD_2, USB_PID_KWORLD_PC160_2T)},
1260 {USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_VOLAR_X)},
1261 /* 10 */{USB_DEVICE(USB_VID_XTENSIONS, USB_PID_XTENSIONS_XD_380)},
1262 {USB_DEVICE(USB_VID_MSI_2, USB_PID_MSI_DIGIVOX_DUO)},
1263 {USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_VOLAR_X_2)},
1264 {USB_DEVICE(USB_VID_TELESTAR, USB_PID_TELESTAR_STARSTICK_2)},
1265 {USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_A309)},
1266 /* 15 */{USB_DEVICE(USB_VID_MSI_2, USB_PID_MSI_DIGI_VOX_MINI_III)},
1267 {USB_DEVICE(USB_VID_KWORLD_2, USB_PID_KWORLD_395U)},
1268 {USB_DEVICE(USB_VID_KWORLD_2, USB_PID_KWORLD_395U_2)},
1269 {USB_DEVICE(USB_VID_KWORLD_2, USB_PID_KWORLD_395U_3)},
1270 {USB_DEVICE(USB_VID_AFATECH, USB_PID_TREKSTOR_DVBT)},
1271 /* 20 */{USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_A850)},
1272 {USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_A805)},
1273 {USB_DEVICE(USB_VID_KWORLD_2, USB_PID_CONCEPTRONIC_CTVDIGRCU)},
1274 {USB_DEVICE(USB_VID_KWORLD_2, USB_PID_KWORLD_MC810)},
1275 {USB_DEVICE(USB_VID_KYE, USB_PID_GENIUS_TVGO_DVB_T03)},
1276 /* 25 */{USB_DEVICE(USB_VID_KWORLD_2, USB_PID_KWORLD_399U_2)},
1277 {USB_DEVICE(USB_VID_KWORLD_2, USB_PID_KWORLD_PC160_T)},
1278 {USB_DEVICE(USB_VID_KWORLD_2, USB_PID_SVEON_STV20)},
1279 {USB_DEVICE(USB_VID_KWORLD_2, USB_PID_TINYTWIN_2)},
1280 {USB_DEVICE(USB_VID_LEADTEK, USB_PID_WINFAST_DTV2000DS)},
1281 /* 30 */{USB_DEVICE(USB_VID_KWORLD_2, USB_PID_KWORLD_UB383_T)},
1282 {USB_DEVICE(USB_VID_KWORLD_2, USB_PID_KWORLD_395U_4)},
1283 {USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_A815M)},
1284 {USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_T_STICK_RC)},
1285 {USB_DEVICE(USB_VID_TERRATEC,
1286 USB_PID_TERRATEC_CINERGY_T_STICK_DUAL_RC)},
1287 /* 35 */{USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_A850T)},
1288 {USB_DEVICE(USB_VID_GTEK, USB_PID_TINYTWIN_3)},
1289 {USB_DEVICE(USB_VID_KWORLD_2, USB_PID_SVEON_STV22)},
1292 MODULE_DEVICE_TABLE(usb, af9015_usb_table);
1294 #define AF9015_RC_INTERVAL 500
1295 static struct dvb_usb_device_properties af9015_properties[] = {
1297 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1299 .usb_ctrl = DEVICE_SPECIFIC,
1300 .download_firmware = af9015_download_firmware,
1301 .firmware = "dvb-usb-af9015.fw",
1304 .size_of_priv = sizeof(struct af9015_state),
1311 .caps = DVB_USB_ADAP_HAS_PID_FILTER |
1312 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
1314 .pid_filter_count = 32,
1315 .pid_filter = af9015_pid_filter,
1316 .pid_filter_ctrl = af9015_pid_filter_ctrl,
1319 af9015_af9013_frontend_attach,
1320 .tuner_attach = af9015_tuner_attach,
1332 af9015_af9013_frontend_attach,
1333 .tuner_attach = af9015_tuner_attach,
1341 TS_USB20_FRAME_SIZE,
1349 .identify_state = af9015_identify_state,
1352 .protocol = RC_TYPE_NEC,
1353 .module_name = "af9015",
1354 .rc_query = af9015_rc_query,
1355 .rc_interval = AF9015_RC_INTERVAL,
1356 .allowed_protos = RC_TYPE_NEC,
1359 .i2c_algo = &af9015_i2c_algo,
1361 .num_device_descs = 12, /* check max from dvb-usb.h */
1364 .name = "Afatech AF9015 DVB-T USB2.0 stick",
1365 .cold_ids = {&af9015_usb_table[0],
1366 &af9015_usb_table[1], NULL},
1370 .name = "Leadtek WinFast DTV Dongle Gold",
1371 .cold_ids = {&af9015_usb_table[2], NULL},
1375 .name = "Pinnacle PCTV 71e",
1376 .cold_ids = {&af9015_usb_table[3], NULL},
1380 .name = "KWorld PlusTV Dual DVB-T Stick " \
1382 .cold_ids = {&af9015_usb_table[4],
1383 &af9015_usb_table[25], NULL},
1387 .name = "DigitalNow TinyTwin DVB-T Receiver",
1388 .cold_ids = {&af9015_usb_table[5],
1389 &af9015_usb_table[28],
1390 &af9015_usb_table[36], NULL},
1394 .name = "TwinHan AzureWave AD-TU700(704J)",
1395 .cold_ids = {&af9015_usb_table[6], NULL},
1399 .name = "TerraTec Cinergy T USB XE",
1400 .cold_ids = {&af9015_usb_table[7], NULL},
1404 .name = "KWorld PlusTV Dual DVB-T PCI " \
1406 .cold_ids = {&af9015_usb_table[8], NULL},
1410 .name = "AVerMedia AVerTV DVB-T Volar X",
1411 .cold_ids = {&af9015_usb_table[9], NULL},
1415 .name = "TerraTec Cinergy T Stick RC",
1416 .cold_ids = {&af9015_usb_table[33], NULL},
1420 .name = "TerraTec Cinergy T Stick Dual RC",
1421 .cold_ids = {&af9015_usb_table[34], NULL},
1425 .name = "AverMedia AVerTV Red HD+ (A850T)",
1426 .cold_ids = {&af9015_usb_table[35], NULL},
1431 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1433 .usb_ctrl = DEVICE_SPECIFIC,
1434 .download_firmware = af9015_download_firmware,
1435 .firmware = "dvb-usb-af9015.fw",
1438 .size_of_priv = sizeof(struct af9015_state),
1445 .caps = DVB_USB_ADAP_HAS_PID_FILTER |
1446 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
1448 .pid_filter_count = 32,
1449 .pid_filter = af9015_pid_filter,
1450 .pid_filter_ctrl = af9015_pid_filter_ctrl,
1453 af9015_af9013_frontend_attach,
1454 .tuner_attach = af9015_tuner_attach,
1466 af9015_af9013_frontend_attach,
1467 .tuner_attach = af9015_tuner_attach,
1475 TS_USB20_FRAME_SIZE,
1483 .identify_state = af9015_identify_state,
1486 .protocol = RC_TYPE_NEC,
1487 .module_name = "af9015",
1488 .rc_query = af9015_rc_query,
1489 .rc_interval = AF9015_RC_INTERVAL,
1490 .allowed_protos = RC_TYPE_NEC,
1493 .i2c_algo = &af9015_i2c_algo,
1495 .num_device_descs = 10, /* check max from dvb-usb.h */
1498 .name = "Xtensions XD-380",
1499 .cold_ids = {&af9015_usb_table[10], NULL},
1503 .name = "MSI DIGIVOX Duo",
1504 .cold_ids = {&af9015_usb_table[11], NULL},
1508 .name = "Fujitsu-Siemens Slim Mobile USB DVB-T",
1509 .cold_ids = {&af9015_usb_table[12], NULL},
1513 .name = "Telestar Starstick 2",
1514 .cold_ids = {&af9015_usb_table[13], NULL},
1518 .name = "AVerMedia A309",
1519 .cold_ids = {&af9015_usb_table[14], NULL},
1523 .name = "MSI Digi VOX mini III",
1524 .cold_ids = {&af9015_usb_table[15], NULL},
1528 .name = "KWorld USB DVB-T TV Stick II " \
1530 .cold_ids = {&af9015_usb_table[16],
1531 &af9015_usb_table[17],
1532 &af9015_usb_table[18],
1533 &af9015_usb_table[31], NULL},
1537 .name = "TrekStor DVB-T USB Stick",
1538 .cold_ids = {&af9015_usb_table[19], NULL},
1542 .name = "AverMedia AVerTV Volar Black HD " \
1544 .cold_ids = {&af9015_usb_table[20], NULL},
1548 .name = "Sveon STV22 Dual USB DVB-T Tuner HDTV",
1549 .cold_ids = {&af9015_usb_table[37], NULL},
1554 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1556 .usb_ctrl = DEVICE_SPECIFIC,
1557 .download_firmware = af9015_download_firmware,
1558 .firmware = "dvb-usb-af9015.fw",
1561 .size_of_priv = sizeof(struct af9015_state),
1568 .caps = DVB_USB_ADAP_HAS_PID_FILTER |
1569 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
1571 .pid_filter_count = 32,
1572 .pid_filter = af9015_pid_filter,
1573 .pid_filter_ctrl = af9015_pid_filter_ctrl,
1576 af9015_af9013_frontend_attach,
1577 .tuner_attach = af9015_tuner_attach,
1589 af9015_af9013_frontend_attach,
1590 .tuner_attach = af9015_tuner_attach,
1598 TS_USB20_FRAME_SIZE,
1606 .identify_state = af9015_identify_state,
1609 .protocol = RC_TYPE_NEC,
1610 .module_name = "af9015",
1611 .rc_query = af9015_rc_query,
1612 .rc_interval = AF9015_RC_INTERVAL,
1613 .allowed_protos = RC_TYPE_NEC,
1616 .i2c_algo = &af9015_i2c_algo,
1618 .num_device_descs = 9, /* check max from dvb-usb.h */
1621 .name = "AverMedia AVerTV Volar GPS 805 (A805)",
1622 .cold_ids = {&af9015_usb_table[21], NULL},
1626 .name = "Conceptronic USB2.0 DVB-T CTVDIGRCU " \
1628 .cold_ids = {&af9015_usb_table[22], NULL},
1632 .name = "KWorld Digial MC-810",
1633 .cold_ids = {&af9015_usb_table[23], NULL},
1637 .name = "Genius TVGo DVB-T03",
1638 .cold_ids = {&af9015_usb_table[24], NULL},
1642 .name = "KWorld PlusTV DVB-T PCI Pro Card " \
1644 .cold_ids = {&af9015_usb_table[26], NULL},
1648 .name = "Sveon STV20 Tuner USB DVB-T HDTV",
1649 .cold_ids = {&af9015_usb_table[27], NULL},
1653 .name = "Leadtek WinFast DTV2000DS",
1654 .cold_ids = {&af9015_usb_table[29], NULL},
1658 .name = "KWorld USB DVB-T Stick Mobile " \
1660 .cold_ids = {&af9015_usb_table[30], NULL},
1664 .name = "AverMedia AVerTV Volar M (A815Mac)",
1665 .cold_ids = {&af9015_usb_table[32], NULL},
1672 static int af9015_usb_probe(struct usb_interface *intf,
1673 const struct usb_device_id *id)
1676 struct dvb_usb_device *d = NULL;
1677 struct usb_device *udev = interface_to_usbdev(intf);
1680 deb_info("%s: interface:%d\n", __func__,
1681 intf->cur_altsetting->desc.bInterfaceNumber);
1683 /* interface 0 is used by DVB-T receiver and
1684 interface 1 is for remote controller (HID) */
1685 if (intf->cur_altsetting->desc.bInterfaceNumber == 0) {
1686 ret = af9015_read_config(udev);
1690 for (i = 0; i < af9015_properties_count; i++) {
1691 ret = dvb_usb_device_init(intf, &af9015_properties[i],
1692 THIS_MODULE, &d, adapter_nr);
1702 ret = af9015_init(d);
1708 /* usb specific object needed to register this driver with the usb subsystem */
1709 static struct usb_driver af9015_usb_driver = {
1710 .name = "dvb_usb_af9015",
1711 .probe = af9015_usb_probe,
1712 .disconnect = dvb_usb_device_exit,
1713 .id_table = af9015_usb_table,
1717 static int __init af9015_usb_module_init(void)
1720 ret = usb_register(&af9015_usb_driver);
1722 err("module init failed:%d", ret);
1727 static void __exit af9015_usb_module_exit(void)
1729 /* deregister this driver from the USB subsystem */
1730 usb_deregister(&af9015_usb_driver);
1733 module_init(af9015_usb_module_init);
1734 module_exit(af9015_usb_module_exit);
1736 MODULE_AUTHOR("Antti Palosaari <crope@iki.fi>");
1737 MODULE_DESCRIPTION("Driver for Afatech AF9015 DVB-T");
1738 MODULE_LICENSE("GPL");