1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * DVB USB Linux driver for Afatech AF9015 DVB-T USB2.0 receiver
5 * Copyright (C) 2007 Antti Palosaari <crope@iki.fi>
7 * Thanks to Afatech who kindly provided information.
12 static int dvb_usb_af9015_remote
;
13 module_param_named(remote
, dvb_usb_af9015_remote
, int, 0644);
14 MODULE_PARM_DESC(remote
, "select remote");
15 DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr
);
17 static int af9015_ctrl_msg(struct dvb_usb_device
*d
, struct req_t
*req
)
19 #define REQ_HDR_LEN 8 /* send header size */
20 #define ACK_HDR_LEN 2 /* rece header size */
21 struct af9015_state
*state
= d_to_priv(d
);
22 struct usb_interface
*intf
= d
->intf
;
26 mutex_lock(&d
->usb_mutex
);
28 state
->buf
[0] = req
->cmd
;
29 state
->buf
[1] = state
->seq
++;
30 state
->buf
[2] = req
->i2c_addr
<< 1;
31 state
->buf
[3] = req
->addr
>> 8;
32 state
->buf
[4] = req
->addr
& 0xff;
33 state
->buf
[5] = req
->mbox
;
34 state
->buf
[6] = req
->addr_len
;
35 state
->buf
[7] = req
->data_len
;
45 state
->buf
[2] |= 0x01; /* set I2C direction */
48 state
->buf
[0] = READ_WRITE_I2C
;
51 if (((req
->addr
& 0xff00) == 0xff00) ||
52 ((req
->addr
& 0xff00) == 0xae00))
53 state
->buf
[0] = WRITE_VIRTUAL_MEMORY
;
55 case WRITE_VIRTUAL_MEMORY
:
57 case DOWNLOAD_FIRMWARE
:
61 dev_err(&intf
->dev
, "unknown cmd %d\n", req
->cmd
);
66 /* Buffer overflow check */
67 if ((write
&& (req
->data_len
> BUF_LEN
- REQ_HDR_LEN
)) ||
68 (!write
&& (req
->data_len
> BUF_LEN
- ACK_HDR_LEN
))) {
69 dev_err(&intf
->dev
, "too much data, cmd %u, len %u\n",
70 req
->cmd
, req
->data_len
);
76 * Write receives seq + status = 2 bytes
77 * Read receives seq + status + data = 2 + N bytes
82 wlen
+= req
->data_len
;
83 memcpy(&state
->buf
[REQ_HDR_LEN
], req
->data
, req
->data_len
);
85 rlen
+= req
->data_len
;
88 /* no ack for these packets */
89 if (req
->cmd
== DOWNLOAD_FIRMWARE
|| req
->cmd
== RECONNECT_USB
)
92 ret
= dvb_usbv2_generic_rw_locked(d
, state
->buf
, wlen
,
98 if (rlen
&& state
->buf
[1]) {
99 dev_err(&intf
->dev
, "cmd failed %u\n", state
->buf
[1]);
104 /* read request, copy returned data to return buf */
106 memcpy(req
->data
, &state
->buf
[ACK_HDR_LEN
], req
->data_len
);
108 mutex_unlock(&d
->usb_mutex
);
113 static int af9015_write_reg_i2c(struct dvb_usb_device
*d
, u8 addr
, u16 reg
,
116 struct af9015_state
*state
= d_to_priv(d
);
117 struct req_t req
= {WRITE_I2C
, addr
, reg
, 1, 1, 1, &val
};
119 if (addr
== state
->af9013_i2c_addr
[0] ||
120 addr
== state
->af9013_i2c_addr
[1])
123 return af9015_ctrl_msg(d
, &req
);
126 static int af9015_read_reg_i2c(struct dvb_usb_device
*d
, u8 addr
, u16 reg
,
129 struct af9015_state
*state
= d_to_priv(d
);
130 struct req_t req
= {READ_I2C
, addr
, reg
, 0, 1, 1, val
};
132 if (addr
== state
->af9013_i2c_addr
[0] ||
133 addr
== state
->af9013_i2c_addr
[1])
136 return af9015_ctrl_msg(d
, &req
);
139 static int af9015_i2c_xfer(struct i2c_adapter
*adap
, struct i2c_msg msg
[],
142 struct dvb_usb_device
*d
= i2c_get_adapdata(adap
);
143 struct af9015_state
*state
= d_to_priv(d
);
144 struct usb_interface
*intf
= d
->intf
;
152 * There could be two tuners, both using same I2C address. Demodulator
153 * I2C-gate is only possibility to select correct tuner.
155 * ...........................................
156 * . AF9015 integrates AF9013 demodulator .
157 * . ____________ ____________ . ____________
158 * .| USB IF | | demod |. | tuner |
159 * .|------------| |------------|. |------------|
160 * .| AF9015 | | AF9013 |. | MXL5003 |
161 * .| |--+--I2C-----|-----/ -----|.----I2C-----| |
162 * .| | | | addr 0x1c |. | addr 0x63 |
163 * .|____________| | |____________|. |____________|
164 * .................|.........................
165 * | ____________ ____________
166 * | | demod | | tuner |
167 * | |------------| |------------|
168 * | | AF9013 | | MXL5003 |
169 * +--I2C-----|-----/ -----|-----I2C-----| |
170 * | addr 0x1d | | addr 0x63 |
171 * |____________| |____________|
174 if (msg
[0].len
== 0 || msg
[0].flags
& I2C_M_RD
) {
178 } else if (msg
[0].len
== 1) {
179 addr
= msg
[0].buf
[0];
182 } else if (msg
[0].len
== 2) {
183 addr
= msg
[0].buf
[0] << 8 | msg
[0].buf
[1] << 0;
187 addr
= msg
[0].buf
[0] << 8 | msg
[0].buf
[1] << 0;
188 mbox
= msg
[0].buf
[2];
192 if (num
== 1 && !(msg
[0].flags
& I2C_M_RD
)) {
194 if (msg
[0].len
> 21) {
198 if (msg
[0].addr
== state
->af9013_i2c_addr
[0])
199 req
.cmd
= WRITE_MEMORY
;
202 req
.i2c_addr
= msg
[0].addr
;
205 req
.addr_len
= addr_len
;
206 req
.data_len
= msg
[0].len
- addr_len
;
207 req
.data
= &msg
[0].buf
[addr_len
];
208 ret
= af9015_ctrl_msg(d
, &req
);
209 } else if (num
== 2 && !(msg
[0].flags
& I2C_M_RD
) &&
210 (msg
[1].flags
& I2C_M_RD
)) {
211 /* i2c write + read */
212 if (msg
[0].len
> 3 || msg
[1].len
> 61) {
216 if (msg
[0].addr
== state
->af9013_i2c_addr
[0])
217 req
.cmd
= READ_MEMORY
;
220 req
.i2c_addr
= msg
[0].addr
;
223 req
.addr_len
= addr_len
;
224 req
.data_len
= msg
[1].len
;
225 req
.data
= &msg
[1].buf
[0];
226 ret
= af9015_ctrl_msg(d
, &req
);
227 } else if (num
== 1 && (msg
[0].flags
& I2C_M_RD
)) {
229 if (msg
[0].len
> 61) {
233 if (msg
[0].addr
== state
->af9013_i2c_addr
[0]) {
238 req
.i2c_addr
= msg
[0].addr
;
241 req
.addr_len
= addr_len
;
242 req
.data_len
= msg
[0].len
;
243 req
.data
= &msg
[0].buf
[0];
244 ret
= af9015_ctrl_msg(d
, &req
);
247 dev_dbg(&intf
->dev
, "unknown msg, num %u\n", num
);
254 dev_dbg(&intf
->dev
, "failed %d\n", ret
);
258 static u32
af9015_i2c_func(struct i2c_adapter
*adapter
)
263 static struct i2c_algorithm af9015_i2c_algo
= {
264 .master_xfer
= af9015_i2c_xfer
,
265 .functionality
= af9015_i2c_func
,
268 static int af9015_identify_state(struct dvb_usb_device
*d
, const char **name
)
270 struct usb_interface
*intf
= d
->intf
;
273 struct req_t req
= {GET_CONFIG
, 0, 0, 0, 0, 1, &reply
};
275 ret
= af9015_ctrl_msg(d
, &req
);
279 dev_dbg(&intf
->dev
, "reply %02x\n", reply
);
289 static int af9015_download_firmware(struct dvb_usb_device
*d
,
290 const struct firmware
*firmware
)
292 struct af9015_state
*state
= d_to_priv(d
);
293 struct usb_interface
*intf
= d
->intf
;
295 struct req_t req
= {DOWNLOAD_FIRMWARE
, 0, 0, 0, 0, 0, NULL
};
298 dev_dbg(&intf
->dev
, "\n");
300 /* Calc checksum, we need it when copy firmware to slave demod */
301 for (i
= 0, checksum
= 0; i
< firmware
->size
; i
++)
302 checksum
+= firmware
->data
[i
];
304 state
->firmware_size
= firmware
->size
;
305 state
->firmware_checksum
= checksum
;
307 #define LEN_MAX (BUF_LEN - REQ_HDR_LEN) /* Max payload size */
308 for (rem
= firmware
->size
; rem
> 0; rem
-= LEN_MAX
) {
309 req
.data_len
= min(LEN_MAX
, rem
);
310 req
.data
= (u8
*)&firmware
->data
[firmware
->size
- rem
];
311 req
.addr
= 0x5100 + firmware
->size
- rem
;
312 ret
= af9015_ctrl_msg(d
, &req
);
314 dev_err(&intf
->dev
, "firmware download failed %d\n",
322 ret
= af9015_ctrl_msg(d
, &req
);
324 dev_err(&intf
->dev
, "firmware boot failed %d\n", ret
);
330 dev_dbg(&intf
->dev
, "failed %d\n", ret
);
334 #define AF9015_EEPROM_SIZE 256
335 /* 2^31 + 2^29 - 2^25 + 2^22 - 2^19 - 2^16 + 1 */
336 #define GOLDEN_RATIO_PRIME_32 0x9e370001UL
338 /* hash (and dump) eeprom */
339 static int af9015_eeprom_hash(struct dvb_usb_device
*d
)
341 struct af9015_state
*state
= d_to_priv(d
);
342 struct usb_interface
*intf
= d
->intf
;
344 u8 buf
[AF9015_EEPROM_SIZE
];
345 struct req_t req
= {READ_I2C
, AF9015_I2C_EEPROM
, 0, 0, 1, 1, NULL
};
348 for (i
= 0; i
< AF9015_EEPROM_SIZE
; i
++) {
351 ret
= af9015_ctrl_msg(d
, &req
);
356 /* calculate checksum */
357 for (i
= 0; i
< AF9015_EEPROM_SIZE
/ sizeof(u32
); i
++) {
358 state
->eeprom_sum
*= GOLDEN_RATIO_PRIME_32
;
359 state
->eeprom_sum
+= le32_to_cpu(((__le32
*)buf
)[i
]);
362 for (i
= 0; i
< AF9015_EEPROM_SIZE
; i
+= 16)
363 dev_dbg(&intf
->dev
, "%*ph\n", 16, buf
+ i
);
365 dev_dbg(&intf
->dev
, "eeprom sum %.8x\n", state
->eeprom_sum
);
368 dev_dbg(&intf
->dev
, "failed %d\n", ret
);
372 static int af9015_read_config(struct dvb_usb_device
*d
)
374 struct af9015_state
*state
= d_to_priv(d
);
375 struct usb_interface
*intf
= d
->intf
;
377 u8 val
, i
, offset
= 0;
378 struct req_t req
= {READ_I2C
, AF9015_I2C_EEPROM
, 0, 0, 1, 1, &val
};
380 dev_dbg(&intf
->dev
, "\n");
382 /* IR remote controller */
383 req
.addr
= AF9015_EEPROM_IR_MODE
;
384 /* first message will timeout often due to possible hw bug */
385 for (i
= 0; i
< 4; i
++) {
386 ret
= af9015_ctrl_msg(d
, &req
);
393 ret
= af9015_eeprom_hash(d
);
397 state
->ir_mode
= val
;
398 dev_dbg(&intf
->dev
, "ir mode %02x\n", val
);
400 /* TS mode - one or two receivers */
401 req
.addr
= AF9015_EEPROM_TS_MODE
;
402 ret
= af9015_ctrl_msg(d
, &req
);
406 state
->dual_mode
= val
;
407 dev_dbg(&intf
->dev
, "ts mode %02x\n", state
->dual_mode
);
409 state
->af9013_i2c_addr
[0] = AF9015_I2C_DEMOD
;
411 if (state
->dual_mode
) {
412 /* read 2nd demodulator I2C address */
413 req
.addr
= AF9015_EEPROM_DEMOD2_I2C
;
414 ret
= af9015_ctrl_msg(d
, &req
);
418 state
->af9013_i2c_addr
[1] = val
>> 1;
421 for (i
= 0; i
< state
->dual_mode
+ 1; i
++) {
423 offset
= AF9015_EEPROM_OFFSET
;
425 req
.addr
= AF9015_EEPROM_XTAL_TYPE1
+ offset
;
426 ret
= af9015_ctrl_msg(d
, &req
);
431 state
->af9013_pdata
[i
].clk
= 28800000;
434 state
->af9013_pdata
[i
].clk
= 20480000;
437 state
->af9013_pdata
[i
].clk
= 28000000;
440 state
->af9013_pdata
[i
].clk
= 25000000;
443 dev_dbg(&intf
->dev
, "[%d] xtal %02x, clk %u\n",
444 i
, val
, state
->af9013_pdata
[i
].clk
);
447 req
.addr
= AF9015_EEPROM_IF1H
+ offset
;
448 ret
= af9015_ctrl_msg(d
, &req
);
452 state
->af9013_pdata
[i
].if_frequency
= val
<< 8;
454 req
.addr
= AF9015_EEPROM_IF1L
+ offset
;
455 ret
= af9015_ctrl_msg(d
, &req
);
459 state
->af9013_pdata
[i
].if_frequency
+= val
;
460 state
->af9013_pdata
[i
].if_frequency
*= 1000;
461 dev_dbg(&intf
->dev
, "[%d] if frequency %u\n",
462 i
, state
->af9013_pdata
[i
].if_frequency
);
465 req
.addr
= AF9015_EEPROM_MT2060_IF1H
+ offset
;
466 ret
= af9015_ctrl_msg(d
, &req
);
469 state
->mt2060_if1
[i
] = val
<< 8;
470 req
.addr
= AF9015_EEPROM_MT2060_IF1L
+ offset
;
471 ret
= af9015_ctrl_msg(d
, &req
);
474 state
->mt2060_if1
[i
] += val
;
475 dev_dbg(&intf
->dev
, "[%d] MT2060 IF1 %u\n",
476 i
, state
->mt2060_if1
[i
]);
479 req
.addr
= AF9015_EEPROM_TUNER_ID1
+ offset
;
480 ret
= af9015_ctrl_msg(d
, &req
);
484 case AF9013_TUNER_ENV77H11D5
:
485 case AF9013_TUNER_MT2060
:
486 case AF9013_TUNER_QT1010
:
487 case AF9013_TUNER_UNKNOWN
:
488 case AF9013_TUNER_MT2060_2
:
489 case AF9013_TUNER_TDA18271
:
490 case AF9013_TUNER_QT1010A
:
491 case AF9013_TUNER_TDA18218
:
492 state
->af9013_pdata
[i
].spec_inv
= 1;
494 case AF9013_TUNER_MXL5003D
:
495 case AF9013_TUNER_MXL5005D
:
496 case AF9013_TUNER_MXL5005R
:
497 case AF9013_TUNER_MXL5007T
:
498 state
->af9013_pdata
[i
].spec_inv
= 0;
500 case AF9013_TUNER_MC44S803
:
501 state
->af9013_pdata
[i
].gpio
[1] = AF9013_GPIO_LO
;
502 state
->af9013_pdata
[i
].spec_inv
= 1;
506 "tuner id %02x not supported, please report!\n",
511 state
->af9013_pdata
[i
].tuner
= val
;
512 dev_dbg(&intf
->dev
, "[%d] tuner id %02x\n", i
, val
);
517 dev_err(&intf
->dev
, "eeprom read failed %d\n", ret
);
520 * AverMedia AVerTV Volar Black HD (A850) device have bad EEPROM
521 * content :-( Override some wrong values here. Ditto for the
522 * AVerTV Red HD+ (A850T) device.
524 if (le16_to_cpu(d
->udev
->descriptor
.idVendor
) == USB_VID_AVERMEDIA
&&
525 ((le16_to_cpu(d
->udev
->descriptor
.idProduct
) == USB_PID_AVERMEDIA_A850
) ||
526 (le16_to_cpu(d
->udev
->descriptor
.idProduct
) == USB_PID_AVERMEDIA_A850T
))) {
527 dev_dbg(&intf
->dev
, "AverMedia A850: overriding config\n");
528 /* disable dual mode */
529 state
->dual_mode
= 0;
532 state
->af9013_pdata
[0].if_frequency
= 4570000;
538 static int af9015_get_stream_config(struct dvb_frontend
*fe
, u8
*ts_type
,
539 struct usb_data_stream_properties
*stream
)
541 struct dvb_usb_device
*d
= fe_to_d(fe
);
542 struct usb_interface
*intf
= d
->intf
;
544 dev_dbg(&intf
->dev
, "adap %u\n", fe_to_adap(fe
)->id
);
546 if (d
->udev
->speed
== USB_SPEED_FULL
)
547 stream
->u
.bulk
.buffersize
= 5 * 188;
552 static int af9015_streaming_ctrl(struct dvb_frontend
*fe
, int onoff
)
554 struct dvb_usb_device
*d
= fe_to_d(fe
);
555 struct af9015_state
*state
= d_to_priv(d
);
556 struct usb_interface
*intf
= d
->intf
;
558 unsigned int utmp1
, utmp2
, reg1
, reg2
;
560 const unsigned int adap_id
= fe_to_adap(fe
)->id
;
562 dev_dbg(&intf
->dev
, "adap id %d, onoff %d\n", adap_id
, onoff
);
564 if (!state
->usb_ts_if_configured
[adap_id
]) {
565 dev_dbg(&intf
->dev
, "set usb and ts interface\n");
567 /* USB IF stream settings */
568 utmp1
= (d
->udev
->speed
== USB_SPEED_FULL
? 5 : 87) * 188 / 4;
569 utmp2
= (d
->udev
->speed
== USB_SPEED_FULL
? 64 : 512) / 4;
571 buf
[0] = (utmp1
>> 0) & 0xff;
572 buf
[1] = (utmp1
>> 8) & 0xff;
574 /* 1st USB IF (EP4) stream settings */
578 /* 2nd USB IF (EP5) stream settings */
582 ret
= regmap_bulk_write(state
->regmap
, reg1
, buf
, 2);
585 ret
= regmap_write(state
->regmap
, reg2
, utmp2
);
590 if (state
->dual_mode
) {
597 ret
= regmap_update_bits(state
->regmap
, 0xd50b, 0x01, utmp1
);
600 ret
= regmap_update_bits(state
->regmap
, 0xd520, 0x10, utmp2
);
604 state
->usb_ts_if_configured
[adap_id
] = true;
607 if (adap_id
== 0 && onoff
) {
608 /* Adapter 0 stream on. EP4: clear NAK, enable, clear reset */
609 ret
= regmap_update_bits(state
->regmap
, 0xdd13, 0x20, 0x00);
612 ret
= regmap_update_bits(state
->regmap
, 0xdd11, 0x20, 0x20);
615 ret
= regmap_update_bits(state
->regmap
, 0xd507, 0x04, 0x00);
618 } else if (adap_id
== 1 && onoff
) {
619 /* Adapter 1 stream on. EP5: clear NAK, enable, clear reset */
620 ret
= regmap_update_bits(state
->regmap
, 0xdd13, 0x40, 0x00);
623 ret
= regmap_update_bits(state
->regmap
, 0xdd11, 0x40, 0x40);
626 ret
= regmap_update_bits(state
->regmap
, 0xd50b, 0x02, 0x00);
629 } else if (adap_id
== 0 && !onoff
) {
630 /* Adapter 0 stream off. EP4: set reset, disable, set NAK */
631 ret
= regmap_update_bits(state
->regmap
, 0xd507, 0x04, 0x04);
634 ret
= regmap_update_bits(state
->regmap
, 0xdd11, 0x20, 0x00);
637 ret
= regmap_update_bits(state
->regmap
, 0xdd13, 0x20, 0x20);
640 } else if (adap_id
== 1 && !onoff
) {
641 /* Adapter 1 stream off. EP5: set reset, disable, set NAK */
642 ret
= regmap_update_bits(state
->regmap
, 0xd50b, 0x02, 0x02);
645 ret
= regmap_update_bits(state
->regmap
, 0xdd11, 0x40, 0x00);
648 ret
= regmap_update_bits(state
->regmap
, 0xdd13, 0x40, 0x40);
655 dev_dbg(&intf
->dev
, "failed %d\n", ret
);
659 static int af9015_get_adapter_count(struct dvb_usb_device
*d
)
661 struct af9015_state
*state
= d_to_priv(d
);
663 return state
->dual_mode
+ 1;
666 /* override demod callbacks for resource locking */
667 static int af9015_af9013_set_frontend(struct dvb_frontend
*fe
)
670 struct af9015_state
*state
= fe_to_priv(fe
);
672 if (mutex_lock_interruptible(&state
->fe_mutex
))
675 ret
= state
->set_frontend
[fe_to_adap(fe
)->id
](fe
);
677 mutex_unlock(&state
->fe_mutex
);
682 /* override demod callbacks for resource locking */
683 static int af9015_af9013_read_status(struct dvb_frontend
*fe
,
684 enum fe_status
*status
)
687 struct af9015_state
*state
= fe_to_priv(fe
);
689 if (mutex_lock_interruptible(&state
->fe_mutex
))
692 ret
= state
->read_status
[fe_to_adap(fe
)->id
](fe
, status
);
694 mutex_unlock(&state
->fe_mutex
);
699 /* override demod callbacks for resource locking */
700 static int af9015_af9013_init(struct dvb_frontend
*fe
)
703 struct af9015_state
*state
= fe_to_priv(fe
);
705 if (mutex_lock_interruptible(&state
->fe_mutex
))
708 ret
= state
->init
[fe_to_adap(fe
)->id
](fe
);
710 mutex_unlock(&state
->fe_mutex
);
715 /* override demod callbacks for resource locking */
716 static int af9015_af9013_sleep(struct dvb_frontend
*fe
)
719 struct af9015_state
*state
= fe_to_priv(fe
);
721 if (mutex_lock_interruptible(&state
->fe_mutex
))
724 ret
= state
->sleep
[fe_to_adap(fe
)->id
](fe
);
726 mutex_unlock(&state
->fe_mutex
);
731 /* override tuner callbacks for resource locking */
732 static int af9015_tuner_init(struct dvb_frontend
*fe
)
735 struct af9015_state
*state
= fe_to_priv(fe
);
737 if (mutex_lock_interruptible(&state
->fe_mutex
))
740 ret
= state
->tuner_init
[fe_to_adap(fe
)->id
](fe
);
742 mutex_unlock(&state
->fe_mutex
);
747 /* override tuner callbacks for resource locking */
748 static int af9015_tuner_sleep(struct dvb_frontend
*fe
)
751 struct af9015_state
*state
= fe_to_priv(fe
);
753 if (mutex_lock_interruptible(&state
->fe_mutex
))
756 ret
= state
->tuner_sleep
[fe_to_adap(fe
)->id
](fe
);
758 mutex_unlock(&state
->fe_mutex
);
763 static int af9015_copy_firmware(struct dvb_usb_device
*d
)
765 struct af9015_state
*state
= d_to_priv(d
);
766 struct usb_interface
*intf
= d
->intf
;
768 unsigned long timeout
;
769 u8 val
, firmware_info
[4];
770 struct req_t req
= {COPY_FIRMWARE
, 0, 0x5100, 0, 0, 4, firmware_info
};
772 dev_dbg(&intf
->dev
, "\n");
774 firmware_info
[0] = (state
->firmware_size
>> 8) & 0xff;
775 firmware_info
[1] = (state
->firmware_size
>> 0) & 0xff;
776 firmware_info
[2] = (state
->firmware_checksum
>> 8) & 0xff;
777 firmware_info
[3] = (state
->firmware_checksum
>> 0) & 0xff;
779 /* Check whether firmware is already running */
780 ret
= af9015_read_reg_i2c(d
, state
->af9013_i2c_addr
[1], 0x98be, &val
);
784 dev_dbg(&intf
->dev
, "firmware status %02x\n", val
);
789 /* Set i2c clock to 625kHz to speed up firmware copy */
790 ret
= regmap_write(state
->regmap
, 0xd416, 0x04);
794 /* Copy firmware from master demod to slave demod */
795 ret
= af9015_ctrl_msg(d
, &req
);
797 dev_err(&intf
->dev
, "firmware copy cmd failed %d\n", ret
);
801 /* Set i2c clock to 125kHz */
802 ret
= regmap_write(state
->regmap
, 0xd416, 0x14);
807 ret
= af9015_write_reg_i2c(d
, state
->af9013_i2c_addr
[1], 0xe205, 0x01);
811 /* Poll firmware ready */
812 for (val
= 0x00, timeout
= jiffies
+ msecs_to_jiffies(1000);
813 !time_after(jiffies
, timeout
) && val
!= 0x0c && val
!= 0x04;) {
816 /* Check firmware status. 0c=OK, 04=fail */
817 ret
= af9015_read_reg_i2c(d
, state
->af9013_i2c_addr
[1],
822 dev_dbg(&intf
->dev
, "firmware status %02x\n", val
);
825 dev_dbg(&intf
->dev
, "firmware boot took %u ms\n",
826 jiffies_to_msecs(jiffies
) - (jiffies_to_msecs(timeout
) - 1000));
830 dev_err(&intf
->dev
, "firmware did not run\n");
832 } else if (val
!= 0x0c) {
834 dev_err(&intf
->dev
, "firmware boot timeout\n");
840 dev_dbg(&intf
->dev
, "failed %d\n", ret
);
844 static int af9015_af9013_frontend_attach(struct dvb_usb_adapter
*adap
)
846 struct af9015_state
*state
= adap_to_priv(adap
);
847 struct dvb_usb_device
*d
= adap_to_d(adap
);
848 struct usb_interface
*intf
= d
->intf
;
849 struct i2c_client
*client
;
852 dev_dbg(&intf
->dev
, "adap id %u\n", adap
->id
);
855 state
->af9013_pdata
[0].ts_mode
= AF9013_TS_MODE_USB
;
856 memcpy(state
->af9013_pdata
[0].api_version
, "\x0\x1\x9\x0", 4);
857 state
->af9013_pdata
[0].gpio
[0] = AF9013_GPIO_HI
;
858 state
->af9013_pdata
[0].gpio
[3] = AF9013_GPIO_TUNER_ON
;
859 } else if (adap
->id
== 1) {
860 state
->af9013_pdata
[1].ts_mode
= AF9013_TS_MODE_SERIAL
;
861 state
->af9013_pdata
[1].ts_output_pin
= 7;
862 memcpy(state
->af9013_pdata
[1].api_version
, "\x0\x1\x9\x0", 4);
863 state
->af9013_pdata
[1].gpio
[0] = AF9013_GPIO_TUNER_ON
;
864 state
->af9013_pdata
[1].gpio
[1] = AF9013_GPIO_LO
;
866 /* copy firmware to 2nd demodulator */
867 if (state
->dual_mode
) {
868 /* Wait 2nd demodulator ready */
871 ret
= af9015_copy_firmware(adap_to_d(adap
));
874 "firmware copy to 2nd frontend failed, will disable it\n");
875 state
->dual_mode
= 0;
885 client
= dvb_module_probe("af9013", NULL
, &d
->i2c_adap
,
886 state
->af9013_i2c_addr
[adap
->id
],
887 &state
->af9013_pdata
[adap
->id
]);
892 adap
->fe
[0] = state
->af9013_pdata
[adap
->id
].get_dvb_frontend(client
);
893 state
->demod_i2c_client
[adap
->id
] = client
;
896 * AF9015 firmware does not like if it gets interrupted by I2C adapter
897 * request on some critical phases. During normal operation I2C adapter
898 * is used only 2nd demodulator and tuner on dual tuner devices.
899 * Override demodulator callbacks and use mutex for limit access to
900 * those "critical" paths to keep AF9015 happy.
903 state
->set_frontend
[adap
->id
] = adap
->fe
[0]->ops
.set_frontend
;
904 adap
->fe
[0]->ops
.set_frontend
= af9015_af9013_set_frontend
;
905 state
->read_status
[adap
->id
] = adap
->fe
[0]->ops
.read_status
;
906 adap
->fe
[0]->ops
.read_status
= af9015_af9013_read_status
;
907 state
->init
[adap
->id
] = adap
->fe
[0]->ops
.init
;
908 adap
->fe
[0]->ops
.init
= af9015_af9013_init
;
909 state
->sleep
[adap
->id
] = adap
->fe
[0]->ops
.sleep
;
910 adap
->fe
[0]->ops
.sleep
= af9015_af9013_sleep
;
915 dev_dbg(&intf
->dev
, "failed %d\n", ret
);
919 static int af9015_frontend_detach(struct dvb_usb_adapter
*adap
)
921 struct af9015_state
*state
= adap_to_priv(adap
);
922 struct dvb_usb_device
*d
= adap_to_d(adap
);
923 struct usb_interface
*intf
= d
->intf
;
924 struct i2c_client
*client
;
926 dev_dbg(&intf
->dev
, "adap id %u\n", adap
->id
);
928 /* Remove I2C demod */
929 client
= state
->demod_i2c_client
[adap
->id
];
930 dvb_module_release(client
);
935 static struct mt2060_config af9015_mt2060_config
= {
940 static struct qt1010_config af9015_qt1010_config
= {
944 static struct tda18271_config af9015_tda18271_config
= {
945 .gate
= TDA18271_GATE_DIGITAL
,
946 .small_i2c
= TDA18271_16_BYTE_CHUNK_INIT
,
949 static struct mxl5005s_config af9015_mxl5003_config
= {
951 .if_freq
= IF_FREQ_4570000HZ
,
952 .xtal_freq
= CRYSTAL_FREQ_16000000HZ
,
953 .agc_mode
= MXL_SINGLE_AGC
,
954 .tracking_filter
= MXL_TF_DEFAULT
,
955 .rssi_enable
= MXL_RSSI_ENABLE
,
956 .cap_select
= MXL_CAP_SEL_ENABLE
,
957 .div_out
= MXL_DIV_OUT_4
,
958 .clock_out
= MXL_CLOCK_OUT_DISABLE
,
959 .output_load
= MXL5005S_IF_OUTPUT_LOAD_200_OHM
,
960 .top
= MXL5005S_TOP_25P2
,
961 .mod_mode
= MXL_DIGITAL_MODE
,
962 .if_mode
= MXL_ZERO_IF
,
963 .AgcMasterByte
= 0x00,
966 static struct mxl5005s_config af9015_mxl5005_config
= {
968 .if_freq
= IF_FREQ_4570000HZ
,
969 .xtal_freq
= CRYSTAL_FREQ_16000000HZ
,
970 .agc_mode
= MXL_SINGLE_AGC
,
971 .tracking_filter
= MXL_TF_OFF
,
972 .rssi_enable
= MXL_RSSI_ENABLE
,
973 .cap_select
= MXL_CAP_SEL_ENABLE
,
974 .div_out
= MXL_DIV_OUT_4
,
975 .clock_out
= MXL_CLOCK_OUT_DISABLE
,
976 .output_load
= MXL5005S_IF_OUTPUT_LOAD_200_OHM
,
977 .top
= MXL5005S_TOP_25P2
,
978 .mod_mode
= MXL_DIGITAL_MODE
,
979 .if_mode
= MXL_ZERO_IF
,
980 .AgcMasterByte
= 0x00,
983 static struct mc44s803_config af9015_mc44s803_config
= {
988 static struct tda18218_config af9015_tda18218_config
= {
990 .i2c_wr_max
= 21, /* max wr bytes AF9015 I2C adap can handle at once */
993 static struct mxl5007t_config af9015_mxl5007t_config
= {
994 .xtal_freq_hz
= MxL_XTAL_24_MHZ
,
995 .if_freq_hz
= MxL_IF_4_57_MHZ
,
998 static int af9015_tuner_attach(struct dvb_usb_adapter
*adap
)
1000 struct dvb_usb_device
*d
= adap_to_d(adap
);
1001 struct af9015_state
*state
= d_to_priv(d
);
1002 struct usb_interface
*intf
= d
->intf
;
1003 struct i2c_client
*client
;
1004 struct i2c_adapter
*adapter
;
1007 dev_dbg(&intf
->dev
, "adap id %u\n", adap
->id
);
1009 client
= state
->demod_i2c_client
[adap
->id
];
1010 adapter
= state
->af9013_pdata
[adap
->id
].get_i2c_adapter(client
);
1012 switch (state
->af9013_pdata
[adap
->id
].tuner
) {
1013 case AF9013_TUNER_MT2060
:
1014 case AF9013_TUNER_MT2060_2
:
1015 ret
= dvb_attach(mt2060_attach
, adap
->fe
[0], adapter
,
1016 &af9015_mt2060_config
,
1017 state
->mt2060_if1
[adap
->id
]) == NULL
? -ENODEV
: 0;
1019 case AF9013_TUNER_QT1010
:
1020 case AF9013_TUNER_QT1010A
:
1021 ret
= dvb_attach(qt1010_attach
, adap
->fe
[0], adapter
,
1022 &af9015_qt1010_config
) == NULL
? -ENODEV
: 0;
1024 case AF9013_TUNER_TDA18271
:
1025 ret
= dvb_attach(tda18271_attach
, adap
->fe
[0], 0x60, adapter
,
1026 &af9015_tda18271_config
) == NULL
? -ENODEV
: 0;
1028 case AF9013_TUNER_TDA18218
:
1029 ret
= dvb_attach(tda18218_attach
, adap
->fe
[0], adapter
,
1030 &af9015_tda18218_config
) == NULL
? -ENODEV
: 0;
1032 case AF9013_TUNER_MXL5003D
:
1033 ret
= dvb_attach(mxl5005s_attach
, adap
->fe
[0], adapter
,
1034 &af9015_mxl5003_config
) == NULL
? -ENODEV
: 0;
1036 case AF9013_TUNER_MXL5005D
:
1037 case AF9013_TUNER_MXL5005R
:
1038 ret
= dvb_attach(mxl5005s_attach
, adap
->fe
[0], adapter
,
1039 &af9015_mxl5005_config
) == NULL
? -ENODEV
: 0;
1041 case AF9013_TUNER_ENV77H11D5
:
1042 ret
= dvb_attach(dvb_pll_attach
, adap
->fe
[0], 0x60, adapter
,
1043 DVB_PLL_TDA665X
) == NULL
? -ENODEV
: 0;
1045 case AF9013_TUNER_MC44S803
:
1046 ret
= dvb_attach(mc44s803_attach
, adap
->fe
[0], adapter
,
1047 &af9015_mc44s803_config
) == NULL
? -ENODEV
: 0;
1049 case AF9013_TUNER_MXL5007T
:
1050 ret
= dvb_attach(mxl5007t_attach
, adap
->fe
[0], adapter
,
1051 0x60, &af9015_mxl5007t_config
) == NULL
? -ENODEV
: 0;
1053 case AF9013_TUNER_UNKNOWN
:
1055 dev_err(&intf
->dev
, "unknown tuner, tuner id %02x\n",
1056 state
->af9013_pdata
[adap
->id
].tuner
);
1060 if (adap
->fe
[0]->ops
.tuner_ops
.init
) {
1061 state
->tuner_init
[adap
->id
] =
1062 adap
->fe
[0]->ops
.tuner_ops
.init
;
1063 adap
->fe
[0]->ops
.tuner_ops
.init
= af9015_tuner_init
;
1066 if (adap
->fe
[0]->ops
.tuner_ops
.sleep
) {
1067 state
->tuner_sleep
[adap
->id
] =
1068 adap
->fe
[0]->ops
.tuner_ops
.sleep
;
1069 adap
->fe
[0]->ops
.tuner_ops
.sleep
= af9015_tuner_sleep
;
1075 static int af9015_pid_filter_ctrl(struct dvb_usb_adapter
*adap
, int onoff
)
1077 struct af9015_state
*state
= adap_to_priv(adap
);
1078 struct af9013_platform_data
*pdata
= &state
->af9013_pdata
[adap
->id
];
1081 mutex_lock(&state
->fe_mutex
);
1082 ret
= pdata
->pid_filter_ctrl(adap
->fe
[0], onoff
);
1083 mutex_unlock(&state
->fe_mutex
);
1088 static int af9015_pid_filter(struct dvb_usb_adapter
*adap
, int index
,
1091 struct af9015_state
*state
= adap_to_priv(adap
);
1092 struct af9013_platform_data
*pdata
= &state
->af9013_pdata
[adap
->id
];
1095 mutex_lock(&state
->fe_mutex
);
1096 ret
= pdata
->pid_filter(adap
->fe
[0], index
, pid
, onoff
);
1097 mutex_unlock(&state
->fe_mutex
);
1102 static int af9015_init(struct dvb_usb_device
*d
)
1104 struct af9015_state
*state
= d_to_priv(d
);
1105 struct usb_interface
*intf
= d
->intf
;
1108 dev_dbg(&intf
->dev
, "\n");
1110 mutex_init(&state
->fe_mutex
);
1112 /* init RC canary */
1113 ret
= regmap_write(state
->regmap
, 0x98e9, 0xff);
1121 #if IS_ENABLED(CONFIG_RC_CORE)
1122 struct af9015_rc_setup
{
1127 static char *af9015_rc_setup_match(unsigned int id
,
1128 const struct af9015_rc_setup
*table
)
1130 for (; table
->rc_codes
; table
++)
1131 if (table
->id
== id
)
1132 return table
->rc_codes
;
1136 static const struct af9015_rc_setup af9015_rc_setup_modparam
[] = {
1137 { AF9015_REMOTE_A_LINK_DTU_M
, RC_MAP_ALINK_DTU_M
},
1138 { AF9015_REMOTE_MSI_DIGIVOX_MINI_II_V3
, RC_MAP_MSI_DIGIVOX_II
},
1139 { AF9015_REMOTE_MYGICTV_U718
, RC_MAP_TOTAL_MEDIA_IN_HAND
},
1140 { AF9015_REMOTE_DIGITTRADE_DVB_T
, RC_MAP_DIGITTRADE
},
1141 { AF9015_REMOTE_AVERMEDIA_KS
, RC_MAP_AVERMEDIA_RM_KS
},
1145 static const struct af9015_rc_setup af9015_rc_setup_hashes
[] = {
1146 { 0xb8feb708, RC_MAP_MSI_DIGIVOX_II
},
1147 { 0xa3703d00, RC_MAP_ALINK_DTU_M
},
1148 { 0x9b7dc64e, RC_MAP_TOTAL_MEDIA_IN_HAND
}, /* MYGICTV U718 */
1149 { 0x5d49e3db, RC_MAP_DIGITTRADE
}, /* LC-Power LC-USB-DVBT */
1153 static int af9015_rc_query(struct dvb_usb_device
*d
)
1155 struct af9015_state
*state
= d_to_priv(d
);
1156 struct usb_interface
*intf
= d
->intf
;
1160 /* read registers needed to detect remote controller code */
1161 ret
= regmap_bulk_read(state
->regmap
, 0x98d9, buf
, sizeof(buf
));
1165 /* If any of these are non-zero, assume invalid data */
1166 if (buf
[1] || buf
[2] || buf
[3]) {
1167 dev_dbg(&intf
->dev
, "invalid data\n");
1171 /* Check for repeat of previous code */
1172 if ((state
->rc_repeat
!= buf
[6] || buf
[0]) &&
1173 !memcmp(&buf
[12], state
->rc_last
, 4)) {
1174 dev_dbg(&intf
->dev
, "key repeated\n");
1175 rc_repeat(d
->rc_dev
);
1176 state
->rc_repeat
= buf
[6];
1180 /* Only process key if canary killed */
1181 if (buf
[16] != 0xff && buf
[0] != 0x01) {
1182 enum rc_proto proto
;
1184 dev_dbg(&intf
->dev
, "key pressed %*ph\n", 4, buf
+ 12);
1186 /* Reset the canary */
1187 ret
= regmap_write(state
->regmap
, 0x98e9, 0xff);
1191 /* Remember this key */
1192 memcpy(state
->rc_last
, &buf
[12], 4);
1193 if (buf
[14] == (u8
)~buf
[15]) {
1194 if (buf
[12] == (u8
)~buf
[13]) {
1196 state
->rc_keycode
= RC_SCANCODE_NEC(buf
[12],
1198 proto
= RC_PROTO_NEC
;
1201 state
->rc_keycode
= RC_SCANCODE_NECX(buf
[12] << 8 |
1204 proto
= RC_PROTO_NECX
;
1208 state
->rc_keycode
= RC_SCANCODE_NEC32(buf
[12] << 24 |
1212 proto
= RC_PROTO_NEC32
;
1214 rc_keydown(d
->rc_dev
, proto
, state
->rc_keycode
, 0);
1216 dev_dbg(&intf
->dev
, "no key press\n");
1217 /* Invalidate last keypress */
1218 /* Not really needed, but helps with debug */
1219 state
->rc_last
[2] = state
->rc_last
[3];
1222 state
->rc_repeat
= buf
[6];
1223 state
->rc_failed
= false;
1227 dev_warn(&intf
->dev
, "rc query failed %d\n", ret
);
1229 /* allow random errors as dvb-usb will stop polling on error */
1230 if (!state
->rc_failed
)
1233 state
->rc_failed
= true;
1239 static int af9015_get_rc_config(struct dvb_usb_device
*d
, struct dvb_usb_rc
*rc
)
1241 struct af9015_state
*state
= d_to_priv(d
);
1242 u16 vid
= le16_to_cpu(d
->udev
->descriptor
.idVendor
);
1244 if (state
->ir_mode
== AF9015_IR_MODE_DISABLED
)
1247 /* try to load remote based module param */
1249 rc
->map_name
= af9015_rc_setup_match(dvb_usb_af9015_remote
,
1250 af9015_rc_setup_modparam
);
1252 /* try to load remote based eeprom hash */
1254 rc
->map_name
= af9015_rc_setup_match(state
->eeprom_sum
,
1255 af9015_rc_setup_hashes
);
1257 /* try to load remote based USB iManufacturer string */
1258 if (!rc
->map_name
&& vid
== USB_VID_AFATECH
) {
1260 * Check USB manufacturer and product strings and try
1261 * to determine correct remote in case of chip vendor
1262 * reference IDs are used.
1263 * DO NOT ADD ANYTHING NEW HERE. Use hashes instead.
1265 char manufacturer
[10];
1267 memset(manufacturer
, 0, sizeof(manufacturer
));
1268 usb_string(d
->udev
, d
->udev
->descriptor
.iManufacturer
,
1269 manufacturer
, sizeof(manufacturer
));
1270 if (!strcmp("MSI", manufacturer
)) {
1272 * iManufacturer 1 MSI
1273 * iProduct 2 MSI K-VOX
1275 rc
->map_name
= af9015_rc_setup_match(AF9015_REMOTE_MSI_DIGIVOX_MINI_II_V3
,
1276 af9015_rc_setup_modparam
);
1280 /* load empty to enable rc */
1282 rc
->map_name
= RC_MAP_EMPTY
;
1284 rc
->allowed_protos
= RC_PROTO_BIT_NEC
| RC_PROTO_BIT_NECX
|
1286 rc
->query
= af9015_rc_query
;
1292 #define af9015_get_rc_config NULL
1295 static int af9015_regmap_write(void *context
, const void *data
, size_t count
)
1297 struct dvb_usb_device
*d
= context
;
1298 struct usb_interface
*intf
= d
->intf
;
1300 u16 reg
= ((u8
*)data
)[0] << 8 | ((u8
*)data
)[1] << 0;
1301 u8
*val
= &((u8
*)data
)[2];
1302 const unsigned int len
= count
- 2;
1303 struct req_t req
= {WRITE_MEMORY
, 0, reg
, 0, 0, len
, val
};
1305 ret
= af9015_ctrl_msg(d
, &req
);
1311 dev_dbg(&intf
->dev
, "failed %d\n", ret
);
1315 static int af9015_regmap_read(void *context
, const void *reg_buf
,
1316 size_t reg_size
, void *val_buf
, size_t val_size
)
1318 struct dvb_usb_device
*d
= context
;
1319 struct usb_interface
*intf
= d
->intf
;
1321 u16 reg
= ((u8
*)reg_buf
)[0] << 8 | ((u8
*)reg_buf
)[1] << 0;
1322 u8
*val
= &((u8
*)val_buf
)[0];
1323 const unsigned int len
= val_size
;
1324 struct req_t req
= {READ_MEMORY
, 0, reg
, 0, 0, len
, val
};
1326 ret
= af9015_ctrl_msg(d
, &req
);
1332 dev_dbg(&intf
->dev
, "failed %d\n", ret
);
1336 static int af9015_probe(struct dvb_usb_device
*d
)
1338 struct af9015_state
*state
= d_to_priv(d
);
1339 struct usb_interface
*intf
= d
->intf
;
1340 struct usb_device
*udev
= interface_to_usbdev(intf
);
1342 char manufacturer
[sizeof("ITE Technologies, Inc.")];
1343 static const struct regmap_config regmap_config
= {
1347 static const struct regmap_bus regmap_bus
= {
1348 .read
= af9015_regmap_read
,
1349 .write
= af9015_regmap_write
,
1352 dev_dbg(&intf
->dev
, "\n");
1354 memset(manufacturer
, 0, sizeof(manufacturer
));
1355 usb_string(udev
, udev
->descriptor
.iManufacturer
,
1356 manufacturer
, sizeof(manufacturer
));
1358 * There is two devices having same ID but different chipset. One uses
1359 * AF9015 and the other IT9135 chipset. Only difference seen on lsusb
1360 * is iManufacturer string.
1362 * idVendor 0x0ccd TerraTec Electronic GmbH
1365 * iManufacturer 1 Afatech
1366 * iProduct 2 DVB-T 2
1368 * idVendor 0x0ccd TerraTec Electronic GmbH
1371 * iManufacturer 1 ITE Technologies, Inc.
1372 * iProduct 2 DVB-T TV Stick
1374 if ((le16_to_cpu(udev
->descriptor
.idVendor
) == USB_VID_TERRATEC
) &&
1375 (le16_to_cpu(udev
->descriptor
.idProduct
) == 0x0099)) {
1376 if (!strcmp("ITE Technologies, Inc.", manufacturer
)) {
1378 dev_dbg(&intf
->dev
, "rejecting device\n");
1383 state
->regmap
= regmap_init(&intf
->dev
, ®map_bus
, d
, ®map_config
);
1384 if (IS_ERR(state
->regmap
)) {
1385 ret
= PTR_ERR(state
->regmap
);
1391 dev_dbg(&intf
->dev
, "failed %d\n", ret
);
1395 static void af9015_disconnect(struct dvb_usb_device
*d
)
1397 struct af9015_state
*state
= d_to_priv(d
);
1398 struct usb_interface
*intf
= d
->intf
;
1400 dev_dbg(&intf
->dev
, "\n");
1402 regmap_exit(state
->regmap
);
1406 * Interface 0 is used by DVB-T receiver and
1407 * interface 1 is for remote controller (HID)
1409 static const struct dvb_usb_device_properties af9015_props
= {
1410 .driver_name
= KBUILD_MODNAME
,
1411 .owner
= THIS_MODULE
,
1412 .adapter_nr
= adapter_nr
,
1413 .size_of_priv
= sizeof(struct af9015_state
),
1415 .generic_bulk_ctrl_endpoint
= 0x02,
1416 .generic_bulk_ctrl_endpoint_response
= 0x81,
1418 .probe
= af9015_probe
,
1419 .disconnect
= af9015_disconnect
,
1420 .identify_state
= af9015_identify_state
,
1421 .firmware
= AF9015_FIRMWARE
,
1422 .download_firmware
= af9015_download_firmware
,
1424 .i2c_algo
= &af9015_i2c_algo
,
1425 .read_config
= af9015_read_config
,
1426 .frontend_attach
= af9015_af9013_frontend_attach
,
1427 .frontend_detach
= af9015_frontend_detach
,
1428 .tuner_attach
= af9015_tuner_attach
,
1429 .init
= af9015_init
,
1430 .get_rc_config
= af9015_get_rc_config
,
1431 .get_stream_config
= af9015_get_stream_config
,
1432 .streaming_ctrl
= af9015_streaming_ctrl
,
1434 .get_adapter_count
= af9015_get_adapter_count
,
1437 .caps
= DVB_USB_ADAP_HAS_PID_FILTER
|
1438 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF
,
1439 .pid_filter_count
= 32,
1440 .pid_filter
= af9015_pid_filter
,
1441 .pid_filter_ctrl
= af9015_pid_filter_ctrl
,
1443 .stream
= DVB_USB_STREAM_BULK(0x84, 6, 87 * 188),
1445 .caps
= DVB_USB_ADAP_HAS_PID_FILTER
|
1446 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF
,
1447 .pid_filter_count
= 32,
1448 .pid_filter
= af9015_pid_filter
,
1449 .pid_filter_ctrl
= af9015_pid_filter_ctrl
,
1451 .stream
= DVB_USB_STREAM_BULK(0x85, 6, 87 * 188),
1456 static const struct usb_device_id af9015_id_table
[] = {
1457 { DVB_USB_DEVICE(USB_VID_AFATECH
, USB_PID_AFATECH_AF9015_9015
,
1458 &af9015_props
, "Afatech AF9015 reference design", NULL
) },
1459 { DVB_USB_DEVICE(USB_VID_AFATECH
, USB_PID_AFATECH_AF9015_9016
,
1460 &af9015_props
, "Afatech AF9015 reference design", NULL
) },
1461 { DVB_USB_DEVICE(USB_VID_LEADTEK
, USB_PID_WINFAST_DTV_DONGLE_GOLD
,
1462 &af9015_props
, "Leadtek WinFast DTV Dongle Gold", RC_MAP_LEADTEK_Y04G0051
) },
1463 { DVB_USB_DEVICE(USB_VID_PINNACLE
, USB_PID_PINNACLE_PCTV71E
,
1464 &af9015_props
, "Pinnacle PCTV 71e", NULL
) },
1465 { DVB_USB_DEVICE(USB_VID_KWORLD_2
, USB_PID_KWORLD_399U
,
1466 &af9015_props
, "KWorld PlusTV Dual DVB-T Stick (DVB-T 399U)", NULL
) },
1467 { DVB_USB_DEVICE(USB_VID_VISIONPLUS
, USB_PID_TINYTWIN
,
1468 &af9015_props
, "DigitalNow TinyTwin", RC_MAP_AZUREWAVE_AD_TU700
) },
1469 { DVB_USB_DEVICE(USB_VID_VISIONPLUS
, USB_PID_AZUREWAVE_AD_TU700
,
1470 &af9015_props
, "TwinHan AzureWave AD-TU700(704J)", RC_MAP_AZUREWAVE_AD_TU700
) },
1471 { DVB_USB_DEVICE(USB_VID_TERRATEC
, USB_PID_TERRATEC_CINERGY_T_USB_XE_REV2
,
1472 &af9015_props
, "TerraTec Cinergy T USB XE", NULL
) },
1473 { DVB_USB_DEVICE(USB_VID_KWORLD_2
, USB_PID_KWORLD_PC160_2T
,
1474 &af9015_props
, "KWorld PlusTV Dual DVB-T PCI (DVB-T PC160-2T)", NULL
) },
1475 { DVB_USB_DEVICE(USB_VID_AVERMEDIA
, USB_PID_AVERMEDIA_VOLAR_X
,
1476 &af9015_props
, "AVerMedia AVerTV DVB-T Volar X", RC_MAP_AVERMEDIA_M135A
) },
1477 { DVB_USB_DEVICE(USB_VID_XTENSIONS
, USB_PID_XTENSIONS_XD_380
,
1478 &af9015_props
, "Xtensions XD-380", NULL
) },
1479 { DVB_USB_DEVICE(USB_VID_MSI_2
, USB_PID_MSI_DIGIVOX_DUO
,
1480 &af9015_props
, "MSI DIGIVOX Duo", RC_MAP_MSI_DIGIVOX_III
) },
1481 { DVB_USB_DEVICE(USB_VID_AVERMEDIA
, USB_PID_AVERMEDIA_VOLAR_X_2
,
1482 &af9015_props
, "Fujitsu-Siemens Slim Mobile USB DVB-T", NULL
) },
1483 { DVB_USB_DEVICE(USB_VID_TELESTAR
, USB_PID_TELESTAR_STARSTICK_2
,
1484 &af9015_props
, "Telestar Starstick 2", NULL
) },
1485 { DVB_USB_DEVICE(USB_VID_AVERMEDIA
, USB_PID_AVERMEDIA_A309
,
1486 &af9015_props
, "AVerMedia A309", NULL
) },
1487 { DVB_USB_DEVICE(USB_VID_MSI_2
, USB_PID_MSI_DIGI_VOX_MINI_III
,
1488 &af9015_props
, "MSI Digi VOX mini III", RC_MAP_MSI_DIGIVOX_III
) },
1489 { DVB_USB_DEVICE(USB_VID_KWORLD_2
, USB_PID_KWORLD_395U
,
1490 &af9015_props
, "KWorld USB DVB-T TV Stick II (VS-DVB-T 395U)", NULL
) },
1491 { DVB_USB_DEVICE(USB_VID_KWORLD_2
, USB_PID_KWORLD_395U_2
,
1492 &af9015_props
, "KWorld USB DVB-T TV Stick II (VS-DVB-T 395U)", NULL
) },
1493 { DVB_USB_DEVICE(USB_VID_KWORLD_2
, USB_PID_KWORLD_395U_3
,
1494 &af9015_props
, "KWorld USB DVB-T TV Stick II (VS-DVB-T 395U)", NULL
) },
1495 { DVB_USB_DEVICE(USB_VID_AFATECH
, USB_PID_TREKSTOR_DVBT
,
1496 &af9015_props
, "TrekStor DVB-T USB Stick", RC_MAP_TREKSTOR
) },
1497 { DVB_USB_DEVICE(USB_VID_AVERMEDIA
, USB_PID_AVERMEDIA_A850
,
1498 &af9015_props
, "AverMedia AVerTV Volar Black HD (A850)", NULL
) },
1499 { DVB_USB_DEVICE(USB_VID_AVERMEDIA
, USB_PID_AVERMEDIA_A805
,
1500 &af9015_props
, "AverMedia AVerTV Volar GPS 805 (A805)", NULL
) },
1501 { DVB_USB_DEVICE(USB_VID_KWORLD_2
, USB_PID_CONCEPTRONIC_CTVDIGRCU
,
1502 &af9015_props
, "Conceptronic USB2.0 DVB-T CTVDIGRCU V3.0", NULL
) },
1503 { DVB_USB_DEVICE(USB_VID_KWORLD_2
, USB_PID_KWORLD_MC810
,
1504 &af9015_props
, "KWorld Digital MC-810", NULL
) },
1505 { DVB_USB_DEVICE(USB_VID_KYE
, USB_PID_GENIUS_TVGO_DVB_T03
,
1506 &af9015_props
, "Genius TVGo DVB-T03", NULL
) },
1507 { DVB_USB_DEVICE(USB_VID_KWORLD_2
, USB_PID_KWORLD_399U_2
,
1508 &af9015_props
, "KWorld PlusTV Dual DVB-T Stick (DVB-T 399U)", NULL
) },
1509 { DVB_USB_DEVICE(USB_VID_KWORLD_2
, USB_PID_KWORLD_PC160_T
,
1510 &af9015_props
, "KWorld PlusTV DVB-T PCI Pro Card (DVB-T PC160-T)", NULL
) },
1511 { DVB_USB_DEVICE(USB_VID_KWORLD_2
, USB_PID_SVEON_STV20
,
1512 &af9015_props
, "Sveon STV20 Tuner USB DVB-T HDTV", NULL
) },
1513 { DVB_USB_DEVICE(USB_VID_KWORLD_2
, USB_PID_TINYTWIN_2
,
1514 &af9015_props
, "DigitalNow TinyTwin v2", RC_MAP_DIGITALNOW_TINYTWIN
) },
1515 { DVB_USB_DEVICE(USB_VID_LEADTEK
, USB_PID_WINFAST_DTV2000DS
,
1516 &af9015_props
, "Leadtek WinFast DTV2000DS", RC_MAP_LEADTEK_Y04G0051
) },
1517 { DVB_USB_DEVICE(USB_VID_KWORLD_2
, USB_PID_KWORLD_UB383_T
,
1518 &af9015_props
, "KWorld USB DVB-T Stick Mobile (UB383-T)", NULL
) },
1519 { DVB_USB_DEVICE(USB_VID_KWORLD_2
, USB_PID_KWORLD_395U_4
,
1520 &af9015_props
, "KWorld USB DVB-T TV Stick II (VS-DVB-T 395U)", NULL
) },
1521 { DVB_USB_DEVICE(USB_VID_AVERMEDIA
, USB_PID_AVERMEDIA_A815M
,
1522 &af9015_props
, "AverMedia AVerTV Volar M (A815Mac)", NULL
) },
1523 { DVB_USB_DEVICE(USB_VID_TERRATEC
, USB_PID_TERRATEC_CINERGY_T_STICK_RC
,
1524 &af9015_props
, "TerraTec Cinergy T Stick RC", RC_MAP_TERRATEC_SLIM_2
) },
1525 /* XXX: that same ID [0ccd:0099] is used by af9035 driver too */
1526 { DVB_USB_DEVICE(USB_VID_TERRATEC
, USB_PID_TERRATEC_CINERGY_T_STICK_DUAL_RC
,
1527 &af9015_props
, "TerraTec Cinergy T Stick Dual RC", RC_MAP_TERRATEC_SLIM
) },
1528 { DVB_USB_DEVICE(USB_VID_AVERMEDIA
, USB_PID_AVERMEDIA_A850T
,
1529 &af9015_props
, "AverMedia AVerTV Red HD+ (A850T)", NULL
) },
1530 { DVB_USB_DEVICE(USB_VID_GTEK
, USB_PID_TINYTWIN_3
,
1531 &af9015_props
, "DigitalNow TinyTwin v3", RC_MAP_DIGITALNOW_TINYTWIN
) },
1532 { DVB_USB_DEVICE(USB_VID_KWORLD_2
, USB_PID_SVEON_STV22
,
1533 &af9015_props
, "Sveon STV22 Dual USB DVB-T Tuner HDTV", RC_MAP_MSI_DIGIVOX_III
) },
1536 MODULE_DEVICE_TABLE(usb
, af9015_id_table
);
1538 /* usb specific object needed to register this driver with the usb subsystem */
1539 static struct usb_driver af9015_usb_driver
= {
1540 .name
= KBUILD_MODNAME
,
1541 .id_table
= af9015_id_table
,
1542 .probe
= dvb_usbv2_probe
,
1543 .disconnect
= dvb_usbv2_disconnect
,
1544 .suspend
= dvb_usbv2_suspend
,
1545 .resume
= dvb_usbv2_resume
,
1546 .reset_resume
= dvb_usbv2_reset_resume
,
1551 module_usb_driver(af9015_usb_driver
);
1553 MODULE_AUTHOR("Antti Palosaari <crope@iki.fi>");
1554 MODULE_DESCRIPTION("Afatech AF9015 driver");
1555 MODULE_LICENSE("GPL");
1556 MODULE_FIRMWARE(AF9015_FIRMWARE
);