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.
32 static int dvb_usb_af9015_debug
;
33 module_param_named(debug
, dvb_usb_af9015_debug
, int, 0644);
34 MODULE_PARM_DESC(debug
, "set debugging level" DVB_USB_DEBUG_STATUS
);
35 static int dvb_usb_af9015_remote
;
36 module_param_named(remote
, dvb_usb_af9015_remote
, int, 0644);
37 MODULE_PARM_DESC(remote
, "select remote");
38 DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr
);
40 static DEFINE_MUTEX(af9015_usb_mutex
);
42 static struct af9015_config af9015_config
;
43 static struct dvb_usb_device_properties af9015_properties
[3];
44 static int af9015_properties_count
= ARRAY_SIZE(af9015_properties
);
46 static struct af9013_config af9015_af9013_config
[] = {
48 .demod_address
= AF9015_I2C_DEMOD
,
49 .output_mode
= AF9013_OUTPUT_MODE_USB
,
50 .api_version
= { 0, 1, 9, 0 },
51 .gpio
[0] = AF9013_GPIO_HI
,
52 .gpio
[3] = AF9013_GPIO_TUNER_ON
,
55 .output_mode
= AF9013_OUTPUT_MODE_SERIAL
,
56 .api_version
= { 0, 1, 9, 0 },
57 .gpio
[0] = AF9013_GPIO_TUNER_ON
,
58 .gpio
[1] = AF9013_GPIO_LO
,
62 static int af9015_rw_udev(struct usb_device
*udev
, struct req_t
*req
)
68 static u8 seq
; /* packet sequence number */
70 if (mutex_lock_interruptible(&af9015_usb_mutex
) < 0)
75 buf
[2] = req
->i2c_addr
;
76 buf
[3] = req
->addr
>> 8;
77 buf
[4] = req
->addr
& 0xff;
79 buf
[6] = req
->addr_len
;
80 buf
[7] = req
->data_len
;
91 buf
[2] |= 0x01; /* set I2C direction */
93 buf
[0] = READ_WRITE_I2C
;
96 if (((req
->addr
& 0xff00) == 0xff00) ||
97 ((req
->addr
& 0xae00) == 0xae00))
98 buf
[0] = WRITE_VIRTUAL_MEMORY
;
99 case WRITE_VIRTUAL_MEMORY
:
101 case DOWNLOAD_FIRMWARE
:
105 err("unknown command:%d", req
->cmd
);
110 /* write requested */
112 memcpy(&buf
[8], req
->data
, req
->data_len
);
113 msg_len
+= req
->data_len
;
116 debug_dump(buf
, msg_len
, deb_xfer
);
119 ret
= usb_bulk_msg(udev
, usb_sndbulkpipe(udev
, 0x02), buf
, msg_len
,
120 &act_len
, AF9015_USB_TIMEOUT
);
122 err("bulk message failed:%d (%d/%d)", ret
, msg_len
, act_len
);
124 if (act_len
!= msg_len
)
125 ret
= -1; /* all data is not send */
129 /* no ack for those packets */
130 if (req
->cmd
== DOWNLOAD_FIRMWARE
|| req
->cmd
== RECONNECT_USB
)
133 /* receive ack and data if read req */
134 msg_len
= 1 + 1 + req
->data_len
; /* seq + status + data len */
135 ret
= usb_bulk_msg(udev
, usb_rcvbulkpipe(udev
, 0x81), buf
, msg_len
,
136 &act_len
, AF9015_USB_TIMEOUT
);
138 err("recv bulk message failed:%d", ret
);
144 debug_dump(buf
, act_len
, deb_xfer
);
146 /* remote controller query status is 1 if remote code is not received */
147 if (req
->cmd
== GET_IR_CODE
&& buf
[1] == 1) {
148 buf
[1] = 0; /* clear command "error" status */
149 memset(&buf
[2], 0, req
->data_len
);
150 buf
[3] = 1; /* no remote code received mark */
155 err("command failed:%d", buf
[1]);
160 /* read request, copy returned data to return buf */
162 memcpy(req
->data
, &buf
[2], req
->data_len
);
166 mutex_unlock(&af9015_usb_mutex
);
171 static int af9015_ctrl_msg(struct dvb_usb_device
*d
, struct req_t
*req
)
173 return af9015_rw_udev(d
->udev
, req
);
176 static int af9015_write_regs(struct dvb_usb_device
*d
, u16 addr
, u8
*val
,
179 struct req_t req
= {WRITE_MEMORY
, AF9015_I2C_DEMOD
, addr
, 0, 0, len
,
181 return af9015_ctrl_msg(d
, &req
);
184 static int af9015_write_reg(struct dvb_usb_device
*d
, u16 addr
, u8 val
)
186 return af9015_write_regs(d
, addr
, &val
, 1);
189 static int af9015_read_reg(struct dvb_usb_device
*d
, u16 addr
, u8
*val
)
191 struct req_t req
= {READ_MEMORY
, AF9015_I2C_DEMOD
, addr
, 0, 0, 1, val
};
192 return af9015_ctrl_msg(d
, &req
);
195 static int af9015_write_reg_i2c(struct dvb_usb_device
*d
, u8 addr
, u16 reg
,
198 struct req_t req
= {WRITE_I2C
, addr
, reg
, 1, 1, 1, &val
};
200 if (addr
== af9015_af9013_config
[0].demod_address
||
201 addr
== af9015_af9013_config
[1].demod_address
)
204 return af9015_ctrl_msg(d
, &req
);
207 static int af9015_read_reg_i2c(struct dvb_usb_device
*d
, u8 addr
, u16 reg
,
210 struct req_t req
= {READ_I2C
, addr
, reg
, 0, 1, 1, val
};
212 if (addr
== af9015_af9013_config
[0].demod_address
||
213 addr
== af9015_af9013_config
[1].demod_address
)
216 return af9015_ctrl_msg(d
, &req
);
219 static int af9015_i2c_xfer(struct i2c_adapter
*adap
, struct i2c_msg msg
[],
222 struct dvb_usb_device
*d
= i2c_get_adapdata(adap
);
228 /* TODO: implement bus lock
230 The bus lock is needed because there is two tuners both using same I2C-address.
231 Due to that the only way to select correct tuner is use demodulator I2C-gate.
233 ................................................
234 . AF9015 includes integrated AF9013 demodulator.
235 . ____________ ____________ . ____________
236 .| uC | | demod | . | tuner |
237 .|------------| |------------| . |------------|
238 .| AF9015 | | AF9013/5 | . | MXL5003 |
239 .| |--+----I2C-------|-----/ -----|-.-----I2C-------| |
240 .| | | | addr 0x38 | . | addr 0xc6 |
241 .|____________| | |____________| . |____________|
242 .................|..............................
243 | ____________ ____________
244 | | demod | | tuner |
245 | |------------| |------------|
246 | | AF9013 | | MXL5003 |
247 +----I2C-------|-----/ -----|-------I2C-------| |
248 | addr 0x3a | | addr 0xc6 |
249 |____________| |____________|
251 if (mutex_lock_interruptible(&d
->i2c_mutex
) < 0)
255 if (msg
[i
].addr
== af9015_af9013_config
[0].demod_address
||
256 msg
[i
].addr
== af9015_af9013_config
[1].demod_address
) {
257 addr
= msg
[i
].buf
[0] << 8;
258 addr
+= msg
[i
].buf
[1];
259 mbox
= msg
[i
].buf
[2];
262 addr
= msg
[i
].buf
[0];
267 if (num
> i
+ 1 && (msg
[i
+1].flags
& I2C_M_RD
)) {
269 af9015_af9013_config
[0].demod_address
)
270 req
.cmd
= READ_MEMORY
;
273 req
.i2c_addr
= msg
[i
].addr
;
276 req
.addr_len
= addr_len
;
277 req
.data_len
= msg
[i
+1].len
;
278 req
.data
= &msg
[i
+1].buf
[0];
279 ret
= af9015_ctrl_msg(d
, &req
);
281 } else if (msg
[i
].flags
& I2C_M_RD
) {
284 af9015_af9013_config
[0].demod_address
)
288 req
.i2c_addr
= msg
[i
].addr
;
291 req
.addr_len
= addr_len
;
292 req
.data_len
= msg
[i
].len
;
293 req
.data
= &msg
[i
].buf
[0];
294 ret
= af9015_ctrl_msg(d
, &req
);
298 af9015_af9013_config
[0].demod_address
)
299 req
.cmd
= WRITE_MEMORY
;
302 req
.i2c_addr
= msg
[i
].addr
;
305 req
.addr_len
= addr_len
;
306 req
.data_len
= msg
[i
].len
-addr_len
;
307 req
.data
= &msg
[i
].buf
[addr_len
];
308 ret
= af9015_ctrl_msg(d
, &req
);
318 mutex_unlock(&d
->i2c_mutex
);
323 static u32
af9015_i2c_func(struct i2c_adapter
*adapter
)
328 static struct i2c_algorithm af9015_i2c_algo
= {
329 .master_xfer
= af9015_i2c_xfer
,
330 .functionality
= af9015_i2c_func
,
333 static int af9015_do_reg_bit(struct dvb_usb_device
*d
, u16 addr
, u8 bit
, u8 op
)
338 ret
= af9015_read_reg(d
, addr
, &val
);
352 return af9015_write_reg(d
, addr
, val
);
355 static int af9015_set_reg_bit(struct dvb_usb_device
*d
, u16 addr
, u8 bit
)
357 return af9015_do_reg_bit(d
, addr
, bit
, 1);
360 static int af9015_clear_reg_bit(struct dvb_usb_device
*d
, u16 addr
, u8 bit
)
362 return af9015_do_reg_bit(d
, addr
, bit
, 0);
365 static int af9015_init_endpoint(struct dvb_usb_device
*d
)
370 deb_info("%s: USB speed:%d\n", __func__
, d
->udev
->speed
);
372 #define TS_PACKET_SIZE 188
374 #define TS_USB20_PACKET_COUNT 348
375 #define TS_USB20_FRAME_SIZE (TS_PACKET_SIZE*TS_USB20_PACKET_COUNT)
377 #define TS_USB11_PACKET_COUNT 21
378 #define TS_USB11_FRAME_SIZE (TS_PACKET_SIZE*TS_USB11_PACKET_COUNT)
380 #define TS_USB20_MAX_PACKET_SIZE 512
381 #define TS_USB11_MAX_PACKET_SIZE 64
383 if (d
->udev
->speed
== USB_SPEED_FULL
) {
384 frame_size
= TS_USB11_FRAME_SIZE
/4;
385 packet_size
= TS_USB11_MAX_PACKET_SIZE
/4;
387 frame_size
= TS_USB20_FRAME_SIZE
/4;
388 packet_size
= TS_USB20_MAX_PACKET_SIZE
/4;
391 ret
= af9015_set_reg_bit(d
, 0xd507, 2); /* assert EP4 reset */
394 ret
= af9015_set_reg_bit(d
, 0xd50b, 1); /* assert EP5 reset */
397 ret
= af9015_clear_reg_bit(d
, 0xdd11, 5); /* disable EP4 */
400 ret
= af9015_clear_reg_bit(d
, 0xdd11, 6); /* disable EP5 */
403 ret
= af9015_set_reg_bit(d
, 0xdd11, 5); /* enable EP4 */
406 if (af9015_config
.dual_mode
) {
407 ret
= af9015_set_reg_bit(d
, 0xdd11, 6); /* enable EP5 */
411 ret
= af9015_clear_reg_bit(d
, 0xdd13, 5); /* disable EP4 NAK */
414 if (af9015_config
.dual_mode
) {
415 ret
= af9015_clear_reg_bit(d
, 0xdd13, 6); /* disable EP5 NAK */
419 /* EP4 xfer length */
420 ret
= af9015_write_reg(d
, 0xdd88, frame_size
& 0xff);
423 ret
= af9015_write_reg(d
, 0xdd89, frame_size
>> 8);
426 /* EP5 xfer length */
427 ret
= af9015_write_reg(d
, 0xdd8a, frame_size
& 0xff);
430 ret
= af9015_write_reg(d
, 0xdd8b, frame_size
>> 8);
433 ret
= af9015_write_reg(d
, 0xdd0c, packet_size
); /* EP4 packet size */
436 ret
= af9015_write_reg(d
, 0xdd0d, packet_size
); /* EP5 packet size */
439 ret
= af9015_clear_reg_bit(d
, 0xd507, 2); /* negate EP4 reset */
442 if (af9015_config
.dual_mode
) {
443 ret
= af9015_clear_reg_bit(d
, 0xd50b, 1); /* negate EP5 reset */
448 /* enable / disable mp2if2 */
449 if (af9015_config
.dual_mode
)
450 ret
= af9015_set_reg_bit(d
, 0xd50b, 0);
452 ret
= af9015_clear_reg_bit(d
, 0xd50b, 0);
455 err("endpoint init failed:%d", ret
);
459 static int af9015_copy_firmware(struct dvb_usb_device
*d
)
464 struct req_t req
= {COPY_FIRMWARE
, 0, 0x5100, 0, 0, sizeof(fw_params
),
466 deb_info("%s:\n", __func__
);
468 fw_params
[0] = af9015_config
.firmware_size
>> 8;
469 fw_params
[1] = af9015_config
.firmware_size
& 0xff;
470 fw_params
[2] = af9015_config
.firmware_checksum
>> 8;
471 fw_params
[3] = af9015_config
.firmware_checksum
& 0xff;
473 /* wait 2nd demodulator ready */
476 ret
= af9015_read_reg_i2c(d
, 0x3a, 0x98be, &val
);
480 deb_info("%s: firmware status:%02x\n", __func__
, val
);
482 if (val
== 0x0c) /* fw is running, no need for download */
485 /* set I2C master clock to fast (to speed up firmware copy) */
486 ret
= af9015_write_reg(d
, 0xd416, 0x04); /* 0x04 * 400ns */
493 ret
= af9015_ctrl_msg(d
, &req
);
495 err("firmware copy cmd failed:%d", ret
);
496 deb_info("%s: firmware copy done\n", __func__
);
498 /* set I2C master clock back to normal */
499 ret
= af9015_write_reg(d
, 0xd416, 0x14); /* 0x14 * 400ns */
503 /* request boot firmware */
504 ret
= af9015_write_reg_i2c(d
, af9015_af9013_config
[1].demod_address
,
506 deb_info("%s: firmware boot cmd status:%d\n", __func__
, ret
);
510 for (i
= 0; i
< 15; i
++) {
513 /* check firmware status */
514 ret
= af9015_read_reg_i2c(d
,
515 af9015_af9013_config
[1].demod_address
, 0x98be, &val
);
516 deb_info("%s: firmware status cmd status:%d fw status:%02x\n",
521 if (val
== 0x0c || val
== 0x04) /* success or fail */
526 err("firmware did not run");
528 } else if (val
!= 0x0c) {
529 err("firmware boot timeout");
539 static int af9015_eeprom_dump(struct dvb_usb_device
*d
)
543 for (reg
= 0; ; reg
++) {
546 deb_info(KERN_CONT
"\n");
547 deb_info(KERN_DEBUG
"%02x:", reg
);
549 if (af9015_read_reg_i2c(d
, AF9015_I2C_EEPROM
, reg
, &val
) == 0)
550 deb_info(KERN_CONT
" %02x", val
);
552 deb_info(KERN_CONT
" --");
556 deb_info(KERN_CONT
"\n");
560 static int af9015_download_ir_table(struct dvb_usb_device
*d
)
562 int i
, packets
= 0, ret
;
563 u16 addr
= 0x9a56; /* ir-table start address */
564 struct req_t req
= {WRITE_MEMORY
, 0, 0, 0, 0, 1, NULL
};
566 deb_info("%s:\n", __func__
);
568 data
= af9015_config
.ir_table
;
569 packets
= af9015_config
.ir_table_size
;
575 /* load remote ir-table */
576 for (i
= 0; i
< packets
; i
++) {
579 ret
= af9015_ctrl_msg(d
, &req
);
581 err("ir-table download failed at packet %d with " \
591 static int af9015_init(struct dvb_usb_device
*d
)
594 deb_info("%s:\n", __func__
);
596 ret
= af9015_init_endpoint(d
);
600 ret
= af9015_download_ir_table(d
);
608 static int af9015_pid_filter_ctrl(struct dvb_usb_adapter
*adap
, int onoff
)
611 deb_info("%s: onoff:%d\n", __func__
, onoff
);
614 ret
= af9015_set_reg_bit(adap
->dev
, 0xd503, 0);
616 ret
= af9015_clear_reg_bit(adap
->dev
, 0xd503, 0);
621 static int af9015_pid_filter(struct dvb_usb_adapter
*adap
, int index
, u16 pid
,
627 deb_info("%s: set pid filter, index %d, pid %x, onoff %d\n",
628 __func__
, index
, pid
, onoff
);
630 ret
= af9015_write_reg(adap
->dev
, 0xd505, (pid
& 0xff));
634 ret
= af9015_write_reg(adap
->dev
, 0xd506, (pid
>> 8));
638 idx
= ((index
& 0x1f) | (1 << 5));
639 ret
= af9015_write_reg(adap
->dev
, 0xd504, idx
);
645 static int af9015_download_firmware(struct usb_device
*udev
,
646 const struct firmware
*fw
)
648 int i
, len
, packets
, remainder
, ret
;
649 struct req_t req
= {DOWNLOAD_FIRMWARE
, 0, 0, 0, 0, 0, NULL
};
650 u16 addr
= 0x5100; /* firmware start address */
653 deb_info("%s:\n", __func__
);
656 for (i
= 0; i
< fw
->size
; i
++)
657 checksum
+= fw
->data
[i
];
659 af9015_config
.firmware_size
= fw
->size
;
660 af9015_config
.firmware_checksum
= checksum
;
662 #define FW_PACKET_MAX_DATA 55
664 packets
= fw
->size
/ FW_PACKET_MAX_DATA
;
665 remainder
= fw
->size
% FW_PACKET_MAX_DATA
;
666 len
= FW_PACKET_MAX_DATA
;
667 for (i
= 0; i
<= packets
; i
++) {
668 if (i
== packets
) /* set size of the last packet */
672 req
.data
= (u8
*)(fw
->data
+ i
* FW_PACKET_MAX_DATA
);
674 addr
+= FW_PACKET_MAX_DATA
;
676 ret
= af9015_rw_udev(udev
, &req
);
678 err("firmware download failed at packet %d with " \
684 /* firmware loaded, request boot */
686 ret
= af9015_rw_udev(udev
, &req
);
688 err("firmware boot failed:%d", ret
);
696 static int af9015_read_config(struct usb_device
*udev
)
699 u8 val
, i
, offset
= 0;
700 struct req_t req
= {READ_I2C
, AF9015_I2C_EEPROM
, 0, 0, 1, 1, &val
};
701 char manufacturer
[10];
703 /* IR remote controller */
704 req
.addr
= AF9015_EEPROM_IR_MODE
;
705 /* first message will timeout often due to possible hw bug */
706 for (i
= 0; i
< 4; i
++) {
707 ret
= af9015_rw_udev(udev
, &req
);
713 deb_info("%s: IR mode:%d\n", __func__
, val
);
714 for (i
= 0; i
< af9015_properties_count
; i
++) {
715 if (val
== AF9015_IR_MODE_DISABLED
|| val
== 0x04) {
716 af9015_properties
[i
].rc_key_map
= NULL
;
717 af9015_properties
[i
].rc_key_map_size
= 0;
718 } else if (dvb_usb_af9015_remote
) {
719 /* load remote defined as module param */
720 switch (dvb_usb_af9015_remote
) {
721 case AF9015_REMOTE_A_LINK_DTU_M
:
722 af9015_properties
[i
].rc_key_map
=
723 af9015_rc_keys_a_link
;
724 af9015_properties
[i
].rc_key_map_size
=
725 ARRAY_SIZE(af9015_rc_keys_a_link
);
726 af9015_config
.ir_table
= af9015_ir_table_a_link
;
727 af9015_config
.ir_table_size
=
728 ARRAY_SIZE(af9015_ir_table_a_link
);
730 case AF9015_REMOTE_MSI_DIGIVOX_MINI_II_V3
:
731 af9015_properties
[i
].rc_key_map
=
733 af9015_properties
[i
].rc_key_map_size
=
734 ARRAY_SIZE(af9015_rc_keys_msi
);
735 af9015_config
.ir_table
= af9015_ir_table_msi
;
736 af9015_config
.ir_table_size
=
737 ARRAY_SIZE(af9015_ir_table_msi
);
739 case AF9015_REMOTE_MYGICTV_U718
:
740 af9015_properties
[i
].rc_key_map
=
741 af9015_rc_keys_mygictv
;
742 af9015_properties
[i
].rc_key_map_size
=
743 ARRAY_SIZE(af9015_rc_keys_mygictv
);
744 af9015_config
.ir_table
=
745 af9015_ir_table_mygictv
;
746 af9015_config
.ir_table_size
=
747 ARRAY_SIZE(af9015_ir_table_mygictv
);
749 case AF9015_REMOTE_DIGITTRADE_DVB_T
:
750 af9015_properties
[i
].rc_key_map
=
751 af9015_rc_keys_digittrade
;
752 af9015_properties
[i
].rc_key_map_size
=
753 ARRAY_SIZE(af9015_rc_keys_digittrade
);
754 af9015_config
.ir_table
=
755 af9015_ir_table_digittrade
;
756 af9015_config
.ir_table_size
=
757 ARRAY_SIZE(af9015_ir_table_digittrade
);
759 case AF9015_REMOTE_AVERMEDIA_KS
:
760 af9015_properties
[i
].rc_key_map
=
761 af9015_rc_keys_avermedia
;
762 af9015_properties
[i
].rc_key_map_size
=
763 ARRAY_SIZE(af9015_rc_keys_avermedia
);
764 af9015_config
.ir_table
=
765 af9015_ir_table_avermedia_ks
;
766 af9015_config
.ir_table_size
=
767 ARRAY_SIZE(af9015_ir_table_avermedia_ks
);
771 switch (le16_to_cpu(udev
->descriptor
.idVendor
)) {
772 case USB_VID_LEADTEK
:
773 af9015_properties
[i
].rc_key_map
=
774 af9015_rc_keys_leadtek
;
775 af9015_properties
[i
].rc_key_map_size
=
776 ARRAY_SIZE(af9015_rc_keys_leadtek
);
777 af9015_config
.ir_table
=
778 af9015_ir_table_leadtek
;
779 af9015_config
.ir_table_size
=
780 ARRAY_SIZE(af9015_ir_table_leadtek
);
782 case USB_VID_VISIONPLUS
:
783 af9015_properties
[i
].rc_key_map
=
784 af9015_rc_keys_twinhan
;
785 af9015_properties
[i
].rc_key_map_size
=
786 ARRAY_SIZE(af9015_rc_keys_twinhan
);
787 af9015_config
.ir_table
=
788 af9015_ir_table_twinhan
;
789 af9015_config
.ir_table_size
=
790 ARRAY_SIZE(af9015_ir_table_twinhan
);
792 case USB_VID_KWORLD_2
:
793 /* TODO: use correct rc keys */
794 af9015_properties
[i
].rc_key_map
=
795 af9015_rc_keys_twinhan
;
796 af9015_properties
[i
].rc_key_map_size
=
797 ARRAY_SIZE(af9015_rc_keys_twinhan
);
798 af9015_config
.ir_table
= af9015_ir_table_kworld
;
799 af9015_config
.ir_table_size
=
800 ARRAY_SIZE(af9015_ir_table_kworld
);
802 /* Check USB manufacturer and product strings and try
803 to determine correct remote in case of chip vendor
804 reference IDs are used. */
805 case USB_VID_AFATECH
:
806 memset(manufacturer
, 0, sizeof(manufacturer
));
807 usb_string(udev
, udev
->descriptor
.iManufacturer
,
808 manufacturer
, sizeof(manufacturer
));
809 if (!strcmp("Geniatech", manufacturer
)) {
810 /* iManufacturer 1 Geniatech
812 af9015_properties
[i
].rc_key_map
=
813 af9015_rc_keys_mygictv
;
814 af9015_properties
[i
].rc_key_map_size
=
815 ARRAY_SIZE(af9015_rc_keys_mygictv
);
816 af9015_config
.ir_table
=
817 af9015_ir_table_mygictv
;
818 af9015_config
.ir_table_size
=
819 ARRAY_SIZE(af9015_ir_table_mygictv
);
820 } else if (!strcmp("MSI", manufacturer
)) {
821 /* iManufacturer 1 MSI
822 iProduct 2 MSI K-VOX */
823 af9015_properties
[i
].rc_key_map
=
825 af9015_properties
[i
].rc_key_map_size
=
826 ARRAY_SIZE(af9015_rc_keys_msi
);
827 af9015_config
.ir_table
=
829 af9015_config
.ir_table_size
=
830 ARRAY_SIZE(af9015_ir_table_msi
);
831 } else if (udev
->descriptor
.idProduct
==
832 cpu_to_le16(USB_PID_TREKSTOR_DVBT
)) {
833 af9015_properties
[i
].rc_key_map
=
834 af9015_rc_keys_trekstor
;
835 af9015_properties
[i
].rc_key_map_size
=
836 ARRAY_SIZE(af9015_rc_keys_trekstor
);
837 af9015_config
.ir_table
=
838 af9015_ir_table_trekstor
;
839 af9015_config
.ir_table_size
=
840 ARRAY_SIZE(af9015_ir_table_trekstor
);
843 case USB_VID_AVERMEDIA
:
844 af9015_properties
[i
].rc_key_map
=
845 af9015_rc_keys_avermedia
;
846 af9015_properties
[i
].rc_key_map_size
=
847 ARRAY_SIZE(af9015_rc_keys_avermedia
);
848 af9015_config
.ir_table
=
849 af9015_ir_table_avermedia
;
850 af9015_config
.ir_table_size
=
851 ARRAY_SIZE(af9015_ir_table_avermedia
);
857 /* TS mode - one or two receivers */
858 req
.addr
= AF9015_EEPROM_TS_MODE
;
859 ret
= af9015_rw_udev(udev
, &req
);
862 af9015_config
.dual_mode
= val
;
863 deb_info("%s: TS mode:%d\n", __func__
, af9015_config
.dual_mode
);
865 /* Set adapter0 buffer size according to USB port speed, adapter1 buffer
866 size can be static because it is enabled only USB2.0 */
867 for (i
= 0; i
< af9015_properties_count
; i
++) {
868 /* USB1.1 set smaller buffersize and disable 2nd adapter */
869 if (udev
->speed
== USB_SPEED_FULL
) {
870 af9015_properties
[i
].adapter
[0].stream
.u
.bulk
.buffersize
871 = TS_USB11_MAX_PACKET_SIZE
;
872 /* disable 2nd adapter because we don't have
874 af9015_config
.dual_mode
= 0;
876 af9015_properties
[i
].adapter
[0].stream
.u
.bulk
.buffersize
877 = TS_USB20_MAX_PACKET_SIZE
;
881 if (af9015_config
.dual_mode
) {
882 /* read 2nd demodulator I2C address */
883 req
.addr
= AF9015_EEPROM_DEMOD2_I2C
;
884 ret
= af9015_rw_udev(udev
, &req
);
887 af9015_af9013_config
[1].demod_address
= val
;
889 /* enable 2nd adapter */
890 for (i
= 0; i
< af9015_properties_count
; i
++)
891 af9015_properties
[i
].num_adapters
= 2;
894 /* disable 2nd adapter */
895 for (i
= 0; i
< af9015_properties_count
; i
++)
896 af9015_properties
[i
].num_adapters
= 1;
899 for (i
= 0; i
< af9015_properties
[0].num_adapters
; i
++) {
901 offset
= AF9015_EEPROM_OFFSET
;
903 req
.addr
= AF9015_EEPROM_XTAL_TYPE1
+ offset
;
904 ret
= af9015_rw_udev(udev
, &req
);
909 af9015_af9013_config
[i
].adc_clock
= 28800;
912 af9015_af9013_config
[i
].adc_clock
= 20480;
915 af9015_af9013_config
[i
].adc_clock
= 28000;
918 af9015_af9013_config
[i
].adc_clock
= 25000;
921 deb_info("%s: [%d] xtal:%d set adc_clock:%d\n", __func__
, i
,
922 val
, af9015_af9013_config
[i
].adc_clock
);
925 req
.addr
= AF9015_EEPROM_IF1H
+ offset
;
926 ret
= af9015_rw_udev(udev
, &req
);
929 af9015_af9013_config
[i
].tuner_if
= val
<< 8;
930 req
.addr
= AF9015_EEPROM_IF1L
+ offset
;
931 ret
= af9015_rw_udev(udev
, &req
);
934 af9015_af9013_config
[i
].tuner_if
+= val
;
935 deb_info("%s: [%d] IF1:%d\n", __func__
, i
,
936 af9015_af9013_config
[0].tuner_if
);
939 req
.addr
= AF9015_EEPROM_MT2060_IF1H
+ offset
;
940 ret
= af9015_rw_udev(udev
, &req
);
943 af9015_config
.mt2060_if1
[i
] = val
<< 8;
944 req
.addr
= AF9015_EEPROM_MT2060_IF1L
+ offset
;
945 ret
= af9015_rw_udev(udev
, &req
);
948 af9015_config
.mt2060_if1
[i
] += val
;
949 deb_info("%s: [%d] MT2060 IF1:%d\n", __func__
, i
,
950 af9015_config
.mt2060_if1
[i
]);
953 req
.addr
= AF9015_EEPROM_TUNER_ID1
+ offset
;
954 ret
= af9015_rw_udev(udev
, &req
);
958 case AF9013_TUNER_ENV77H11D5
:
959 case AF9013_TUNER_MT2060
:
960 case AF9013_TUNER_QT1010
:
961 case AF9013_TUNER_UNKNOWN
:
962 case AF9013_TUNER_MT2060_2
:
963 case AF9013_TUNER_TDA18271
:
964 case AF9013_TUNER_QT1010A
:
965 af9015_af9013_config
[i
].rf_spec_inv
= 1;
967 case AF9013_TUNER_MXL5003D
:
968 case AF9013_TUNER_MXL5005D
:
969 case AF9013_TUNER_MXL5005R
:
970 af9015_af9013_config
[i
].rf_spec_inv
= 0;
972 case AF9013_TUNER_MC44S803
:
973 af9015_af9013_config
[i
].gpio
[1] = AF9013_GPIO_LO
;
974 af9015_af9013_config
[i
].rf_spec_inv
= 1;
977 warn("tuner id:%d not supported, please report!", val
);
981 af9015_af9013_config
[i
].tuner
= val
;
982 deb_info("%s: [%d] tuner id:%d\n", __func__
, i
, val
);
987 err("eeprom read failed:%d", ret
);
989 /* AverMedia AVerTV Volar Black HD (A850) device have bad EEPROM
990 content :-( Override some wrong values here. */
991 if (le16_to_cpu(udev
->descriptor
.idVendor
) == USB_VID_AVERMEDIA
&&
992 le16_to_cpu(udev
->descriptor
.idProduct
) == USB_PID_AVERMEDIA_A850
) {
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
, u32
*event
, int *state
)
1032 struct req_t req
= {GET_IR_CODE
, 0, 0, 0, 0, sizeof(buf
), buf
};
1033 struct dvb_usb_rc_key
*keymap
= d
->props
.rc_key_map
;
1036 memset(buf
, 0, sizeof(buf
));
1038 ret
= af9015_ctrl_msg(d
, &req
);
1043 *state
= REMOTE_NO_KEY_PRESSED
;
1045 for (i
= 0; i
< d
->props
.rc_key_map_size
; i
++) {
1046 if (!buf
[1] && rc5_custom(&keymap
[i
]) == buf
[0] &&
1047 rc5_data(&keymap
[i
]) == buf
[2]) {
1048 *event
= keymap
[i
].event
;
1049 *state
= REMOTE_KEY_PRESSED
;
1054 deb_rc("%s: %02x %02x %02x %02x %02x %02x %02x %02x\n",
1055 __func__
, buf
[0], buf
[1], buf
[2], buf
[3], buf
[4],
1056 buf
[5], buf
[6], buf
[7]);
1061 /* init 2nd I2C adapter */
1062 static int af9015_i2c_init(struct dvb_usb_device
*d
)
1065 struct af9015_state
*state
= d
->priv
;
1066 deb_info("%s:\n", __func__
);
1068 strncpy(state
->i2c_adap
.name
, d
->desc
->name
,
1069 sizeof(state
->i2c_adap
.name
));
1070 #ifdef I2C_ADAP_CLASS_TV_DIGITAL
1071 state
->i2c_adap
.class = I2C_ADAP_CLASS_TV_DIGITAL
,
1073 state
->i2c_adap
.class = I2C_CLASS_TV_DIGITAL
,
1075 state
->i2c_adap
.algo
= d
->props
.i2c_algo
;
1076 state
->i2c_adap
.algo_data
= NULL
;
1077 state
->i2c_adap
.dev
.parent
= &d
->udev
->dev
;
1079 i2c_set_adapdata(&state
->i2c_adap
, d
);
1081 ret
= i2c_add_adapter(&state
->i2c_adap
);
1083 err("could not add i2c adapter");
1088 static int af9015_af9013_frontend_attach(struct dvb_usb_adapter
*adap
)
1091 struct af9015_state
*state
= adap
->dev
->priv
;
1092 struct i2c_adapter
*i2c_adap
;
1094 if (adap
->id
== 0) {
1095 /* select I2C adapter */
1096 i2c_adap
= &adap
->dev
->i2c_adap
;
1098 deb_info("%s: init I2C\n", __func__
);
1099 ret
= af9015_i2c_init(adap
->dev
);
1101 /* dump eeprom (debug) */
1102 ret
= af9015_eeprom_dump(adap
->dev
);
1106 /* select I2C adapter */
1107 i2c_adap
= &state
->i2c_adap
;
1109 /* copy firmware to 2nd demodulator */
1110 if (af9015_config
.dual_mode
) {
1111 ret
= af9015_copy_firmware(adap
->dev
);
1113 err("firmware copy to 2nd frontend " \
1114 "failed, will disable it");
1115 af9015_config
.dual_mode
= 0;
1123 /* attach demodulator */
1124 adap
->fe
= dvb_attach(af9013_attach
, &af9015_af9013_config
[adap
->id
],
1127 return adap
->fe
== NULL
? -ENODEV
: 0;
1130 static struct mt2060_config af9015_mt2060_config
= {
1131 .i2c_address
= 0xc0,
1135 static struct qt1010_config af9015_qt1010_config
= {
1136 .i2c_address
= 0xc4,
1139 static struct tda18271_config af9015_tda18271_config
= {
1140 .gate
= TDA18271_GATE_DIGITAL
,
1144 static struct mxl5005s_config af9015_mxl5003_config
= {
1145 .i2c_address
= 0xc6,
1146 .if_freq
= IF_FREQ_4570000HZ
,
1147 .xtal_freq
= CRYSTAL_FREQ_16000000HZ
,
1148 .agc_mode
= MXL_SINGLE_AGC
,
1149 .tracking_filter
= MXL_TF_DEFAULT
,
1150 .rssi_enable
= MXL_RSSI_ENABLE
,
1151 .cap_select
= MXL_CAP_SEL_ENABLE
,
1152 .div_out
= MXL_DIV_OUT_4
,
1153 .clock_out
= MXL_CLOCK_OUT_DISABLE
,
1154 .output_load
= MXL5005S_IF_OUTPUT_LOAD_200_OHM
,
1155 .top
= MXL5005S_TOP_25P2
,
1156 .mod_mode
= MXL_DIGITAL_MODE
,
1157 .if_mode
= MXL_ZERO_IF
,
1158 .AgcMasterByte
= 0x00,
1161 static struct mxl5005s_config af9015_mxl5005_config
= {
1162 .i2c_address
= 0xc6,
1163 .if_freq
= IF_FREQ_4570000HZ
,
1164 .xtal_freq
= CRYSTAL_FREQ_16000000HZ
,
1165 .agc_mode
= MXL_SINGLE_AGC
,
1166 .tracking_filter
= MXL_TF_OFF
,
1167 .rssi_enable
= MXL_RSSI_ENABLE
,
1168 .cap_select
= MXL_CAP_SEL_ENABLE
,
1169 .div_out
= MXL_DIV_OUT_4
,
1170 .clock_out
= MXL_CLOCK_OUT_DISABLE
,
1171 .output_load
= MXL5005S_IF_OUTPUT_LOAD_200_OHM
,
1172 .top
= MXL5005S_TOP_25P2
,
1173 .mod_mode
= MXL_DIGITAL_MODE
,
1174 .if_mode
= MXL_ZERO_IF
,
1175 .AgcMasterByte
= 0x00,
1178 static struct mc44s803_config af9015_mc44s803_config
= {
1179 .i2c_address
= 0xc0,
1183 static int af9015_tuner_attach(struct dvb_usb_adapter
*adap
)
1185 struct af9015_state
*state
= adap
->dev
->priv
;
1186 struct i2c_adapter
*i2c_adap
;
1188 deb_info("%s: \n", __func__
);
1190 /* select I2C adapter */
1192 i2c_adap
= &adap
->dev
->i2c_adap
;
1194 i2c_adap
= &state
->i2c_adap
;
1196 switch (af9015_af9013_config
[adap
->id
].tuner
) {
1197 case AF9013_TUNER_MT2060
:
1198 case AF9013_TUNER_MT2060_2
:
1199 ret
= dvb_attach(mt2060_attach
, adap
->fe
, i2c_adap
,
1200 &af9015_mt2060_config
,
1201 af9015_config
.mt2060_if1
[adap
->id
])
1202 == NULL
? -ENODEV
: 0;
1204 case AF9013_TUNER_QT1010
:
1205 case AF9013_TUNER_QT1010A
:
1206 ret
= dvb_attach(qt1010_attach
, adap
->fe
, i2c_adap
,
1207 &af9015_qt1010_config
) == NULL
? -ENODEV
: 0;
1209 case AF9013_TUNER_TDA18271
:
1210 ret
= dvb_attach(tda18271_attach
, adap
->fe
, 0xc0, i2c_adap
,
1211 &af9015_tda18271_config
) == NULL
? -ENODEV
: 0;
1213 case AF9013_TUNER_MXL5003D
:
1214 ret
= dvb_attach(mxl5005s_attach
, adap
->fe
, i2c_adap
,
1215 &af9015_mxl5003_config
) == NULL
? -ENODEV
: 0;
1217 case AF9013_TUNER_MXL5005D
:
1218 case AF9013_TUNER_MXL5005R
:
1219 ret
= dvb_attach(mxl5005s_attach
, adap
->fe
, i2c_adap
,
1220 &af9015_mxl5005_config
) == NULL
? -ENODEV
: 0;
1222 case AF9013_TUNER_ENV77H11D5
:
1223 ret
= dvb_attach(dvb_pll_attach
, adap
->fe
, 0xc0, i2c_adap
,
1224 DVB_PLL_TDA665X
) == NULL
? -ENODEV
: 0;
1226 case AF9013_TUNER_MC44S803
:
1227 ret
= dvb_attach(mc44s803_attach
, adap
->fe
, i2c_adap
,
1228 &af9015_mc44s803_config
) == NULL
? -ENODEV
: 0;
1230 case AF9013_TUNER_UNKNOWN
:
1233 err("Unknown tuner id:%d",
1234 af9015_af9013_config
[adap
->id
].tuner
);
1239 static struct usb_device_id af9015_usb_table
[] = {
1240 /* 0 */{USB_DEVICE(USB_VID_AFATECH
, USB_PID_AFATECH_AF9015_9015
)},
1241 {USB_DEVICE(USB_VID_AFATECH
, USB_PID_AFATECH_AF9015_9016
)},
1242 {USB_DEVICE(USB_VID_LEADTEK
, USB_PID_WINFAST_DTV_DONGLE_GOLD
)},
1243 {USB_DEVICE(USB_VID_PINNACLE
, USB_PID_PINNACLE_PCTV71E
)},
1244 {USB_DEVICE(USB_VID_KWORLD_2
, USB_PID_KWORLD_399U
)},
1245 /* 5 */{USB_DEVICE(USB_VID_VISIONPLUS
,
1247 {USB_DEVICE(USB_VID_VISIONPLUS
,
1248 USB_PID_AZUREWAVE_AD_TU700
)},
1249 {USB_DEVICE(USB_VID_TERRATEC
, USB_PID_TERRATEC_CINERGY_T_USB_XE_REV2
)},
1250 {USB_DEVICE(USB_VID_KWORLD_2
, USB_PID_KWORLD_PC160_2T
)},
1251 {USB_DEVICE(USB_VID_AVERMEDIA
, USB_PID_AVERMEDIA_VOLAR_X
)},
1252 /* 10 */{USB_DEVICE(USB_VID_XTENSIONS
, USB_PID_XTENSIONS_XD_380
)},
1253 {USB_DEVICE(USB_VID_MSI_2
, USB_PID_MSI_DIGIVOX_DUO
)},
1254 {USB_DEVICE(USB_VID_AVERMEDIA
, USB_PID_AVERMEDIA_VOLAR_X_2
)},
1255 {USB_DEVICE(USB_VID_TELESTAR
, USB_PID_TELESTAR_STARSTICK_2
)},
1256 {USB_DEVICE(USB_VID_AVERMEDIA
, USB_PID_AVERMEDIA_A309
)},
1257 /* 15 */{USB_DEVICE(USB_VID_MSI_2
, USB_PID_MSI_DIGI_VOX_MINI_III
)},
1258 {USB_DEVICE(USB_VID_KWORLD_2
, USB_PID_KWORLD_395U
)},
1259 {USB_DEVICE(USB_VID_KWORLD_2
, USB_PID_KWORLD_395U_2
)},
1260 {USB_DEVICE(USB_VID_KWORLD_2
, USB_PID_KWORLD_395U_3
)},
1261 {USB_DEVICE(USB_VID_AFATECH
, USB_PID_TREKSTOR_DVBT
)},
1262 /* 20 */{USB_DEVICE(USB_VID_AVERMEDIA
, USB_PID_AVERMEDIA_A850
)},
1263 {USB_DEVICE(USB_VID_AVERMEDIA
, USB_PID_AVERMEDIA_A805
)},
1264 {USB_DEVICE(USB_VID_KWORLD_2
, USB_PID_CONCEPTRONIC_CTVDIGRCU
)},
1265 {USB_DEVICE(USB_VID_KWORLD_2
, USB_PID_KWORLD_MC810
)},
1266 {USB_DEVICE(USB_VID_KYE
, USB_PID_GENIUS_TVGO_DVB_T03
)},
1267 /* 25 */{USB_DEVICE(USB_VID_KWORLD_2
, USB_PID_KWORLD_399U_2
)},
1270 MODULE_DEVICE_TABLE(usb
, af9015_usb_table
);
1272 static struct dvb_usb_device_properties af9015_properties
[] = {
1274 .caps
= DVB_USB_IS_AN_I2C_ADAPTER
,
1276 .usb_ctrl
= DEVICE_SPECIFIC
,
1277 .download_firmware
= af9015_download_firmware
,
1278 .firmware
= "dvb-usb-af9015.fw",
1281 .size_of_priv
= sizeof(struct af9015_state
), \
1286 .caps
= DVB_USB_ADAP_HAS_PID_FILTER
|
1287 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF
,
1289 .pid_filter_count
= 32,
1290 .pid_filter
= af9015_pid_filter
,
1291 .pid_filter_ctrl
= af9015_pid_filter_ctrl
,
1294 af9015_af9013_frontend_attach
,
1295 .tuner_attach
= af9015_tuner_attach
,
1304 af9015_af9013_frontend_attach
,
1305 .tuner_attach
= af9015_tuner_attach
,
1313 TS_USB20_MAX_PACKET_SIZE
,
1320 .identify_state
= af9015_identify_state
,
1322 .rc_query
= af9015_rc_query
,
1325 .i2c_algo
= &af9015_i2c_algo
,
1327 .num_device_descs
= 9, /* max 9 */
1330 .name
= "Afatech AF9015 DVB-T USB2.0 stick",
1331 .cold_ids
= {&af9015_usb_table
[0],
1332 &af9015_usb_table
[1], NULL
},
1336 .name
= "Leadtek WinFast DTV Dongle Gold",
1337 .cold_ids
= {&af9015_usb_table
[2], NULL
},
1341 .name
= "Pinnacle PCTV 71e",
1342 .cold_ids
= {&af9015_usb_table
[3], NULL
},
1346 .name
= "KWorld PlusTV Dual DVB-T Stick " \
1348 .cold_ids
= {&af9015_usb_table
[4],
1349 &af9015_usb_table
[25], NULL
},
1353 .name
= "DigitalNow TinyTwin DVB-T Receiver",
1354 .cold_ids
= {&af9015_usb_table
[5], NULL
},
1358 .name
= "TwinHan AzureWave AD-TU700(704J)",
1359 .cold_ids
= {&af9015_usb_table
[6], NULL
},
1363 .name
= "TerraTec Cinergy T USB XE",
1364 .cold_ids
= {&af9015_usb_table
[7], NULL
},
1368 .name
= "KWorld PlusTV Dual DVB-T PCI " \
1370 .cold_ids
= {&af9015_usb_table
[8], NULL
},
1374 .name
= "AVerMedia AVerTV DVB-T Volar X",
1375 .cold_ids
= {&af9015_usb_table
[9], NULL
},
1380 .caps
= DVB_USB_IS_AN_I2C_ADAPTER
,
1382 .usb_ctrl
= DEVICE_SPECIFIC
,
1383 .download_firmware
= af9015_download_firmware
,
1384 .firmware
= "dvb-usb-af9015.fw",
1387 .size_of_priv
= sizeof(struct af9015_state
), \
1392 .caps
= DVB_USB_ADAP_HAS_PID_FILTER
|
1393 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF
,
1395 .pid_filter_count
= 32,
1396 .pid_filter
= af9015_pid_filter
,
1397 .pid_filter_ctrl
= af9015_pid_filter_ctrl
,
1400 af9015_af9013_frontend_attach
,
1401 .tuner_attach
= af9015_tuner_attach
,
1410 af9015_af9013_frontend_attach
,
1411 .tuner_attach
= af9015_tuner_attach
,
1419 TS_USB20_MAX_PACKET_SIZE
,
1426 .identify_state
= af9015_identify_state
,
1428 .rc_query
= af9015_rc_query
,
1431 .i2c_algo
= &af9015_i2c_algo
,
1433 .num_device_descs
= 9, /* max 9 */
1436 .name
= "Xtensions XD-380",
1437 .cold_ids
= {&af9015_usb_table
[10], NULL
},
1441 .name
= "MSI DIGIVOX Duo",
1442 .cold_ids
= {&af9015_usb_table
[11], NULL
},
1446 .name
= "Fujitsu-Siemens Slim Mobile USB DVB-T",
1447 .cold_ids
= {&af9015_usb_table
[12], NULL
},
1451 .name
= "Telestar Starstick 2",
1452 .cold_ids
= {&af9015_usb_table
[13], NULL
},
1456 .name
= "AVerMedia A309",
1457 .cold_ids
= {&af9015_usb_table
[14], NULL
},
1461 .name
= "MSI Digi VOX mini III",
1462 .cold_ids
= {&af9015_usb_table
[15], NULL
},
1466 .name
= "KWorld USB DVB-T TV Stick II " \
1468 .cold_ids
= {&af9015_usb_table
[16],
1469 &af9015_usb_table
[17],
1470 &af9015_usb_table
[18], NULL
},
1474 .name
= "TrekStor DVB-T USB Stick",
1475 .cold_ids
= {&af9015_usb_table
[19], NULL
},
1479 .name
= "AverMedia AVerTV Volar Black HD " \
1481 .cold_ids
= {&af9015_usb_table
[20], NULL
},
1486 .caps
= DVB_USB_IS_AN_I2C_ADAPTER
,
1488 .usb_ctrl
= DEVICE_SPECIFIC
,
1489 .download_firmware
= af9015_download_firmware
,
1490 .firmware
= "dvb-usb-af9015.fw",
1493 .size_of_priv
= sizeof(struct af9015_state
), \
1498 .caps
= DVB_USB_ADAP_HAS_PID_FILTER
|
1499 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF
,
1501 .pid_filter_count
= 32,
1502 .pid_filter
= af9015_pid_filter
,
1503 .pid_filter_ctrl
= af9015_pid_filter_ctrl
,
1506 af9015_af9013_frontend_attach
,
1507 .tuner_attach
= af9015_tuner_attach
,
1516 af9015_af9013_frontend_attach
,
1517 .tuner_attach
= af9015_tuner_attach
,
1525 TS_USB20_MAX_PACKET_SIZE
,
1532 .identify_state
= af9015_identify_state
,
1534 .rc_query
= af9015_rc_query
,
1537 .i2c_algo
= &af9015_i2c_algo
,
1539 .num_device_descs
= 4, /* max 9 */
1542 .name
= "AverMedia AVerTV Volar GPS 805 (A805)",
1543 .cold_ids
= {&af9015_usb_table
[21], NULL
},
1547 .name
= "Conceptronic USB2.0 DVB-T CTVDIGRCU " \
1549 .cold_ids
= {&af9015_usb_table
[22], NULL
},
1553 .name
= "KWorld Digial MC-810",
1554 .cold_ids
= {&af9015_usb_table
[23], NULL
},
1558 .name
= "Genius TVGo DVB-T03",
1559 .cold_ids
= {&af9015_usb_table
[24], NULL
},
1566 static int af9015_usb_probe(struct usb_interface
*intf
,
1567 const struct usb_device_id
*id
)
1570 struct dvb_usb_device
*d
= NULL
;
1571 struct usb_device
*udev
= interface_to_usbdev(intf
);
1574 deb_info("%s: interface:%d\n", __func__
,
1575 intf
->cur_altsetting
->desc
.bInterfaceNumber
);
1577 /* interface 0 is used by DVB-T receiver and
1578 interface 1 is for remote controller (HID) */
1579 if (intf
->cur_altsetting
->desc
.bInterfaceNumber
== 0) {
1580 ret
= af9015_read_config(udev
);
1584 for (i
= 0; i
< af9015_properties_count
; i
++) {
1585 ret
= dvb_usb_device_init(intf
, &af9015_properties
[i
],
1586 THIS_MODULE
, &d
, adapter_nr
);
1596 ret
= af9015_init(d
);
1602 static void af9015_i2c_exit(struct dvb_usb_device
*d
)
1604 struct af9015_state
*state
= d
->priv
;
1605 deb_info("%s: \n", __func__
);
1607 /* remove 2nd I2C adapter */
1608 if (d
->state
& DVB_USB_STATE_I2C
)
1609 i2c_del_adapter(&state
->i2c_adap
);
1612 static void af9015_usb_device_exit(struct usb_interface
*intf
)
1614 struct dvb_usb_device
*d
= usb_get_intfdata(intf
);
1615 deb_info("%s: \n", __func__
);
1617 /* remove 2nd I2C adapter */
1618 if (d
!= NULL
&& d
->desc
!= NULL
)
1621 dvb_usb_device_exit(intf
);
1624 /* usb specific object needed to register this driver with the usb subsystem */
1625 static struct usb_driver af9015_usb_driver
= {
1626 .name
= "dvb_usb_af9015",
1627 .probe
= af9015_usb_probe
,
1628 .disconnect
= af9015_usb_device_exit
,
1629 .id_table
= af9015_usb_table
,
1633 static int __init
af9015_usb_module_init(void)
1636 ret
= usb_register(&af9015_usb_driver
);
1638 err("module init failed:%d", ret
);
1643 static void __exit
af9015_usb_module_exit(void)
1645 /* deregister this driver from the USB subsystem */
1646 usb_deregister(&af9015_usb_driver
);
1649 module_init(af9015_usb_module_init
);
1650 module_exit(af9015_usb_module_exit
);
1652 MODULE_AUTHOR("Antti Palosaari <crope@iki.fi>");
1653 MODULE_DESCRIPTION("Driver for Afatech AF9015 DVB-T");
1654 MODULE_LICENSE("GPL");