1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Afatech AF9035 DVB USB driver
5 * Copyright (C) 2009 Antti Palosaari <crope@iki.fi>
6 * Copyright (C) 2012 Antti Palosaari <crope@iki.fi>
11 /* Max transfer size done by I2C transfer functions */
12 #define MAX_XFER_SIZE 64
14 DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr
);
16 static u16
af9035_checksum(const u8
*buf
, size_t len
)
21 for (i
= 1; i
< len
; i
++) {
23 checksum
+= buf
[i
] << 8;
32 static int af9035_ctrl_msg(struct dvb_usb_device
*d
, struct usb_req
*req
)
34 #define REQ_HDR_LEN 4 /* send header size */
35 #define ACK_HDR_LEN 3 /* rece header size */
36 #define CHECKSUM_LEN 2
37 #define USB_TIMEOUT 2000
38 struct state
*state
= d_to_priv(d
);
39 struct usb_interface
*intf
= d
->intf
;
41 u16 checksum
, tmp_checksum
;
43 mutex_lock(&d
->usb_mutex
);
45 /* buffer overflow check */
46 if (req
->wlen
> (BUF_LEN
- REQ_HDR_LEN
- CHECKSUM_LEN
) ||
47 req
->rlen
> (BUF_LEN
- ACK_HDR_LEN
- CHECKSUM_LEN
)) {
48 dev_err(&intf
->dev
, "too much data wlen=%d rlen=%d\n",
49 req
->wlen
, req
->rlen
);
54 state
->buf
[0] = REQ_HDR_LEN
+ req
->wlen
+ CHECKSUM_LEN
- 1;
55 state
->buf
[1] = req
->mbox
;
56 state
->buf
[2] = req
->cmd
;
57 state
->buf
[3] = state
->seq
++;
58 memcpy(&state
->buf
[REQ_HDR_LEN
], req
->wbuf
, req
->wlen
);
60 wlen
= REQ_HDR_LEN
+ req
->wlen
+ CHECKSUM_LEN
;
61 rlen
= ACK_HDR_LEN
+ req
->rlen
+ CHECKSUM_LEN
;
63 /* calc and add checksum */
64 checksum
= af9035_checksum(state
->buf
, state
->buf
[0] - 1);
65 state
->buf
[state
->buf
[0] - 1] = (checksum
>> 8);
66 state
->buf
[state
->buf
[0] - 0] = (checksum
& 0xff);
68 /* no ack for these packets */
69 if (req
->cmd
== CMD_FW_DL
)
72 ret
= dvb_usbv2_generic_rw_locked(d
,
73 state
->buf
, wlen
, state
->buf
, rlen
);
77 /* no ack for those packets */
78 if (req
->cmd
== CMD_FW_DL
)
82 checksum
= af9035_checksum(state
->buf
, rlen
- 2);
83 tmp_checksum
= (state
->buf
[rlen
- 2] << 8) | state
->buf
[rlen
- 1];
84 if (tmp_checksum
!= checksum
) {
85 dev_err(&intf
->dev
, "command=%02x checksum mismatch (%04x != %04x)\n",
86 req
->cmd
, tmp_checksum
, checksum
);
93 /* fw returns status 1 when IR code was not received */
94 if (req
->cmd
== CMD_IR_GET
|| state
->buf
[2] == 1) {
99 dev_dbg(&intf
->dev
, "command=%02x failed fw error=%d\n",
100 req
->cmd
, state
->buf
[2]);
105 /* read request, copy returned data to return buf */
107 memcpy(req
->rbuf
, &state
->buf
[ACK_HDR_LEN
], req
->rlen
);
109 mutex_unlock(&d
->usb_mutex
);
113 /* write multiple registers */
114 static int af9035_wr_regs(struct dvb_usb_device
*d
, u32 reg
, u8
*val
, int len
)
116 struct usb_interface
*intf
= d
->intf
;
117 u8 wbuf
[MAX_XFER_SIZE
];
118 u8 mbox
= (reg
>> 16) & 0xff;
119 struct usb_req req
= { CMD_MEM_WR
, mbox
, 6 + len
, wbuf
, 0, NULL
};
121 if (6 + len
> sizeof(wbuf
)) {
122 dev_warn(&intf
->dev
, "i2c wr: len=%d is too big!\n", len
);
130 wbuf
[4] = (reg
>> 8) & 0xff;
131 wbuf
[5] = (reg
>> 0) & 0xff;
132 memcpy(&wbuf
[6], val
, len
);
134 return af9035_ctrl_msg(d
, &req
);
137 /* read multiple registers */
138 static int af9035_rd_regs(struct dvb_usb_device
*d
, u32 reg
, u8
*val
, int len
)
140 u8 wbuf
[] = { len
, 2, 0, 0, (reg
>> 8) & 0xff, reg
& 0xff };
141 u8 mbox
= (reg
>> 16) & 0xff;
142 struct usb_req req
= { CMD_MEM_RD
, mbox
, sizeof(wbuf
), wbuf
, len
, val
};
144 return af9035_ctrl_msg(d
, &req
);
147 /* write single register */
148 static int af9035_wr_reg(struct dvb_usb_device
*d
, u32 reg
, u8 val
)
150 return af9035_wr_regs(d
, reg
, &val
, 1);
153 /* read single register */
154 static int af9035_rd_reg(struct dvb_usb_device
*d
, u32 reg
, u8
*val
)
156 return af9035_rd_regs(d
, reg
, val
, 1);
159 /* write single register with mask */
160 static int af9035_wr_reg_mask(struct dvb_usb_device
*d
, u32 reg
, u8 val
,
166 /* no need for read if whole reg is written */
168 ret
= af9035_rd_regs(d
, reg
, &tmp
, 1);
177 return af9035_wr_regs(d
, reg
, &val
, 1);
180 static int af9035_add_i2c_dev(struct dvb_usb_device
*d
, const char *type
,
181 u8 addr
, void *platform_data
, struct i2c_adapter
*adapter
)
184 struct state
*state
= d_to_priv(d
);
185 struct usb_interface
*intf
= d
->intf
;
186 struct i2c_client
*client
;
187 struct i2c_board_info board_info
= {
189 .platform_data
= platform_data
,
192 strscpy(board_info
.type
, type
, I2C_NAME_SIZE
);
194 /* find first free client */
195 for (num
= 0; num
< AF9035_I2C_CLIENT_MAX
; num
++) {
196 if (state
->i2c_client
[num
] == NULL
)
200 dev_dbg(&intf
->dev
, "num=%d\n", num
);
202 if (num
== AF9035_I2C_CLIENT_MAX
) {
203 dev_err(&intf
->dev
, "I2C client out of index\n");
208 request_module("%s", board_info
.type
);
210 /* register I2C device */
211 client
= i2c_new_client_device(adapter
, &board_info
);
212 if (!i2c_client_has_driver(client
)) {
217 /* increase I2C driver usage count */
218 if (!try_module_get(client
->dev
.driver
->owner
)) {
219 i2c_unregister_device(client
);
224 state
->i2c_client
[num
] = client
;
227 dev_dbg(&intf
->dev
, "failed=%d\n", ret
);
231 static void af9035_del_i2c_dev(struct dvb_usb_device
*d
)
234 struct state
*state
= d_to_priv(d
);
235 struct usb_interface
*intf
= d
->intf
;
236 struct i2c_client
*client
;
238 /* find last used client */
239 num
= AF9035_I2C_CLIENT_MAX
;
241 if (state
->i2c_client
[num
] != NULL
)
245 dev_dbg(&intf
->dev
, "num=%d\n", num
);
248 dev_err(&intf
->dev
, "I2C client out of index\n");
252 client
= state
->i2c_client
[num
];
254 /* decrease I2C driver usage count */
255 module_put(client
->dev
.driver
->owner
);
257 /* unregister I2C device */
258 i2c_unregister_device(client
);
260 state
->i2c_client
[num
] = NULL
;
263 dev_dbg(&intf
->dev
, "failed\n");
266 static int af9035_i2c_master_xfer(struct i2c_adapter
*adap
,
267 struct i2c_msg msg
[], int num
)
269 struct dvb_usb_device
*d
= i2c_get_adapdata(adap
);
270 struct state
*state
= d_to_priv(d
);
273 if (mutex_lock_interruptible(&d
->i2c_mutex
) < 0)
277 * AF9035 I2C sub header is 5 bytes long. Meaning of those bytes are:
281 * byte 3 and 4 can be used as reg addr
283 * used when reg addr len is set to 2
285 * used when reg addr len is set to 1 or 2
287 * For the simplify we do not use register addr at all.
288 * NOTE: As a firmware knows tuner type there is very small possibility
289 * there could be some tuner I2C hacks done by firmware and this may
290 * lead problems if firmware expects those bytes are used.
292 * TODO: Here is few hacks. AF9035 chip integrates AF9033 demodulator.
293 * IT9135 chip integrates AF9033 demodulator and RF tuner. For dual
294 * tuner devices, there is also external AF9033 demodulator connected
295 * via external I2C bus. All AF9033 demod I2C traffic, both single and
296 * dual tuner configuration, is covered by firmware - actual USB IO
297 * looks just like a memory access.
298 * In case of IT913x chip, there is own tuner driver. It is implemented
299 * currently as a I2C driver, even tuner IP block is likely build
300 * directly into the demodulator memory space and there is no own I2C
301 * bus. I2C subsystem does not allow register multiple devices to same
302 * bus, having same slave address. Due to that we reuse demod address,
303 * shifted by one bit, on that case.
305 * For IT930x we use a different command and the sub header is
308 * 1: I2C bus (0x03 seems to be only value used)
311 #define AF9035_IS_I2C_XFER_WRITE_READ(_msg, _num) \
312 (_num == 2 && !(_msg[0].flags & I2C_M_RD) && (_msg[1].flags & I2C_M_RD))
313 #define AF9035_IS_I2C_XFER_WRITE(_msg, _num) \
314 (_num == 1 && !(_msg[0].flags & I2C_M_RD))
315 #define AF9035_IS_I2C_XFER_READ(_msg, _num) \
316 (_num == 1 && (_msg[0].flags & I2C_M_RD))
318 if (AF9035_IS_I2C_XFER_WRITE_READ(msg
, num
)) {
319 if (msg
[0].len
> 40 || msg
[1].len
> 40) {
320 /* TODO: correct limits > 40 */
322 } else if ((msg
[0].addr
== state
->af9033_i2c_addr
[0]) ||
323 (msg
[0].addr
== state
->af9033_i2c_addr
[1])) {
324 /* demod access via firmware interface */
325 u32 reg
= msg
[0].buf
[0] << 16 | msg
[0].buf
[1] << 8 |
328 if (msg
[0].addr
== state
->af9033_i2c_addr
[1])
331 ret
= af9035_rd_regs(d
, reg
, &msg
[1].buf
[0],
333 } else if (state
->no_read
) {
334 memset(msg
[1].buf
, 0, msg
[1].len
);
337 /* I2C write + read */
338 u8 buf
[MAX_XFER_SIZE
];
339 struct usb_req req
= { CMD_I2C_RD
, 0, 5 + msg
[0].len
,
340 buf
, msg
[1].len
, msg
[1].buf
};
342 if (state
->chip_type
== 0x9306) {
343 req
.cmd
= CMD_GENERIC_I2C_RD
;
344 req
.wlen
= 3 + msg
[0].len
;
346 req
.mbox
|= ((msg
[0].addr
& 0x80) >> 3);
349 if (state
->chip_type
== 0x9306) {
350 buf
[1] = 0x03; /* I2C bus */
351 buf
[2] = msg
[0].addr
<< 1;
352 memcpy(&buf
[3], msg
[0].buf
, msg
[0].len
);
354 buf
[1] = msg
[0].addr
<< 1;
355 buf
[3] = 0x00; /* reg addr MSB */
356 buf
[4] = 0x00; /* reg addr LSB */
358 /* Keep prev behavior for write req len > 2*/
359 if (msg
[0].len
> 2) {
360 buf
[2] = 0x00; /* reg addr len */
361 memcpy(&buf
[5], msg
[0].buf
, msg
[0].len
);
363 /* Use reg addr fields if write req len <= 2 */
367 if (msg
[0].len
== 2) {
368 buf
[3] = msg
[0].buf
[0];
369 buf
[4] = msg
[0].buf
[1];
370 } else if (msg
[0].len
== 1) {
371 buf
[4] = msg
[0].buf
[0];
375 ret
= af9035_ctrl_msg(d
, &req
);
377 } else if (AF9035_IS_I2C_XFER_WRITE(msg
, num
)) {
378 if (msg
[0].len
> 40) {
379 /* TODO: correct limits > 40 */
381 } else if ((msg
[0].addr
== state
->af9033_i2c_addr
[0]) ||
382 (msg
[0].addr
== state
->af9033_i2c_addr
[1])) {
383 /* demod access via firmware interface */
384 u32 reg
= msg
[0].buf
[0] << 16 | msg
[0].buf
[1] << 8 |
387 if (msg
[0].addr
== state
->af9033_i2c_addr
[1])
390 ret
= (msg
[0].len
>= 3) ? af9035_wr_regs(d
, reg
,
396 u8 buf
[MAX_XFER_SIZE
];
397 struct usb_req req
= { CMD_I2C_WR
, 0, 5 + msg
[0].len
,
400 if (state
->chip_type
== 0x9306) {
401 req
.cmd
= CMD_GENERIC_I2C_WR
;
402 req
.wlen
= 3 + msg
[0].len
;
405 req
.mbox
|= ((msg
[0].addr
& 0x80) >> 3);
407 if (state
->chip_type
== 0x9306) {
408 buf
[1] = 0x03; /* I2C bus */
409 buf
[2] = msg
[0].addr
<< 1;
410 memcpy(&buf
[3], msg
[0].buf
, msg
[0].len
);
412 buf
[1] = msg
[0].addr
<< 1;
413 buf
[2] = 0x00; /* reg addr len */
414 buf
[3] = 0x00; /* reg addr MSB */
415 buf
[4] = 0x00; /* reg addr LSB */
416 memcpy(&buf
[5], msg
[0].buf
, msg
[0].len
);
418 ret
= af9035_ctrl_msg(d
, &req
);
420 } else if (AF9035_IS_I2C_XFER_READ(msg
, num
)) {
421 if (msg
[0].len
> 40) {
422 /* TODO: correct limits > 40 */
424 } else if (state
->no_read
) {
425 memset(msg
[0].buf
, 0, msg
[0].len
);
430 struct usb_req req
= { CMD_I2C_RD
, 0, sizeof(buf
),
431 buf
, msg
[0].len
, msg
[0].buf
};
433 if (state
->chip_type
== 0x9306) {
434 req
.cmd
= CMD_GENERIC_I2C_RD
;
437 req
.mbox
|= ((msg
[0].addr
& 0x80) >> 3);
439 if (state
->chip_type
== 0x9306) {
440 buf
[1] = 0x03; /* I2C bus */
441 buf
[2] = msg
[0].addr
<< 1;
443 buf
[1] = msg
[0].addr
<< 1;
444 buf
[2] = 0x00; /* reg addr len */
445 buf
[3] = 0x00; /* reg addr MSB */
446 buf
[4] = 0x00; /* reg addr LSB */
448 ret
= af9035_ctrl_msg(d
, &req
);
452 * We support only three kind of I2C transactions:
453 * 1) 1 x write + 1 x read (repeated start)
460 mutex_unlock(&d
->i2c_mutex
);
468 static u32
af9035_i2c_functionality(struct i2c_adapter
*adapter
)
473 static struct i2c_algorithm af9035_i2c_algo
= {
474 .master_xfer
= af9035_i2c_master_xfer
,
475 .functionality
= af9035_i2c_functionality
,
478 static int af9035_identify_state(struct dvb_usb_device
*d
, const char **name
)
480 struct state
*state
= d_to_priv(d
);
481 struct usb_interface
*intf
= d
->intf
;
482 int ret
, i
, ts_mode_invalid
;
483 unsigned int utmp
, eeprom_addr
;
487 struct usb_req req
= { CMD_FW_QUERYINFO
, 0, sizeof(wbuf
), wbuf
,
488 sizeof(rbuf
), rbuf
};
490 ret
= af9035_rd_regs(d
, 0x1222, rbuf
, 3);
494 state
->chip_version
= rbuf
[0];
495 state
->chip_type
= rbuf
[2] << 8 | rbuf
[1] << 0;
497 ret
= af9035_rd_reg(d
, 0x384f, &state
->prechip_version
);
501 dev_info(&intf
->dev
, "prechip_version=%02x chip_version=%02x chip_type=%04x\n",
502 state
->prechip_version
, state
->chip_version
, state
->chip_type
);
504 if (state
->chip_type
== 0x9135) {
505 if (state
->chip_version
== 0x02) {
506 *name
= AF9035_FIRMWARE_IT9135_V2
;
509 *name
= AF9035_FIRMWARE_IT9135_V1
;
513 /* Check if eeprom exists */
514 ret
= af9035_rd_reg(d
, utmp
, &tmp
);
519 dev_dbg(&intf
->dev
, "no eeprom\n");
520 state
->no_eeprom
= true;
521 goto check_firmware_status
;
524 eeprom_addr
= EEPROM_BASE_IT9135
;
525 } else if (state
->chip_type
== 0x9306) {
526 *name
= AF9035_FIRMWARE_IT9303
;
527 state
->no_eeprom
= true;
528 goto check_firmware_status
;
530 *name
= AF9035_FIRMWARE_AF9035
;
531 eeprom_addr
= EEPROM_BASE_AF9035
;
534 /* Read and store eeprom */
535 for (i
= 0; i
< 256; i
+= 32) {
536 ret
= af9035_rd_regs(d
, eeprom_addr
+ i
, &state
->eeprom
[i
], 32);
541 dev_dbg(&intf
->dev
, "eeprom dump:\n");
542 for (i
= 0; i
< 256; i
+= 16)
543 dev_dbg(&intf
->dev
, "%*ph\n", 16, &state
->eeprom
[i
]);
545 /* check for dual tuner mode */
546 tmp
= state
->eeprom
[EEPROM_TS_MODE
];
553 state
->dual_mode
= true;
556 if (state
->chip_type
!= 0x9135 && state
->chip_type
!= 0x9306)
557 state
->dual_mode
= true; /* AF9035 */
565 dev_dbg(&intf
->dev
, "ts mode=%d dual mode=%d\n", tmp
, state
->dual_mode
);
568 dev_info(&intf
->dev
, "ts mode=%d not supported, defaulting to single tuner mode!", tmp
);
570 check_firmware_status
:
571 ret
= af9035_ctrl_msg(d
, &req
);
575 dev_dbg(&intf
->dev
, "reply=%*ph\n", 4, rbuf
);
576 if (rbuf
[0] || rbuf
[1] || rbuf
[2] || rbuf
[3])
584 dev_dbg(&intf
->dev
, "failed=%d\n", ret
);
589 static int af9035_download_firmware_old(struct dvb_usb_device
*d
,
590 const struct firmware
*fw
)
592 struct usb_interface
*intf
= d
->intf
;
595 struct usb_req req
= { 0, 0, 0, NULL
, 0, NULL
};
596 struct usb_req req_fw_dl
= { CMD_FW_DL
, 0, 0, wbuf
, 0, NULL
};
598 u16 hdr_addr
, hdr_data_len
, hdr_checksum
;
603 * Thanks to Daniel Glöckner <daniel-gl@gmx.net> about that info!
605 * byte 0: MCS 51 core
606 * There are two inside the AF9035 (1=Link and 2=OFDM) with separate
608 * byte 1-2: Big endian destination address
609 * byte 3-4: Big endian number of data bytes following the header
610 * byte 5-6: Big endian header checksum, apparently ignored by the chip
611 * Calculated as ~(h[0]*256+h[1]+h[2]*256+h[3]+h[4]*256)
614 for (i
= fw
->size
; i
> HDR_SIZE
;) {
615 hdr_core
= fw
->data
[fw
->size
- i
+ 0];
616 hdr_addr
= fw
->data
[fw
->size
- i
+ 1] << 8;
617 hdr_addr
|= fw
->data
[fw
->size
- i
+ 2] << 0;
618 hdr_data_len
= fw
->data
[fw
->size
- i
+ 3] << 8;
619 hdr_data_len
|= fw
->data
[fw
->size
- i
+ 4] << 0;
620 hdr_checksum
= fw
->data
[fw
->size
- i
+ 5] << 8;
621 hdr_checksum
|= fw
->data
[fw
->size
- i
+ 6] << 0;
623 dev_dbg(&intf
->dev
, "core=%d addr=%04x data_len=%d checksum=%04x\n",
624 hdr_core
, hdr_addr
, hdr_data_len
, hdr_checksum
);
626 if (((hdr_core
!= 1) && (hdr_core
!= 2)) ||
627 (hdr_data_len
> i
)) {
628 dev_dbg(&intf
->dev
, "bad firmware\n");
632 /* download begin packet */
633 req
.cmd
= CMD_FW_DL_BEGIN
;
634 ret
= af9035_ctrl_msg(d
, &req
);
638 /* download firmware packet(s) */
639 for (j
= HDR_SIZE
+ hdr_data_len
; j
> 0; j
-= MAX_DATA
) {
643 req_fw_dl
.wlen
= len
;
644 req_fw_dl
.wbuf
= (u8
*) &fw
->data
[fw
->size
- i
+
645 HDR_SIZE
+ hdr_data_len
- j
];
646 ret
= af9035_ctrl_msg(d
, &req_fw_dl
);
651 /* download end packet */
652 req
.cmd
= CMD_FW_DL_END
;
653 ret
= af9035_ctrl_msg(d
, &req
);
657 i
-= hdr_data_len
+ HDR_SIZE
;
659 dev_dbg(&intf
->dev
, "data uploaded=%zu\n", fw
->size
- i
);
662 /* print warn if firmware is bad, continue and see what happens */
664 dev_warn(&intf
->dev
, "bad firmware\n");
669 dev_dbg(&intf
->dev
, "failed=%d\n", ret
);
674 static int af9035_download_firmware_new(struct dvb_usb_device
*d
,
675 const struct firmware
*fw
)
677 struct usb_interface
*intf
= d
->intf
;
679 struct usb_req req_fw_dl
= { CMD_FW_SCATTER_WR
, 0, 0, NULL
, 0, NULL
};
683 * There seems to be following firmware header. Meaning of bytes 0-3
692 * 6: count of data bytes ?
694 for (i
= HDR_SIZE
, i_prev
= 0; i
<= fw
->size
; i
++) {
696 (fw
->data
[i
+ 0] == 0x03 &&
697 (fw
->data
[i
+ 1] == 0x00 ||
698 fw
->data
[i
+ 1] == 0x01) &&
699 fw
->data
[i
+ 2] == 0x00)) {
700 req_fw_dl
.wlen
= i
- i_prev
;
701 req_fw_dl
.wbuf
= (u8
*) &fw
->data
[i_prev
];
703 ret
= af9035_ctrl_msg(d
, &req_fw_dl
);
707 dev_dbg(&intf
->dev
, "data uploaded=%d\n", i
);
714 dev_dbg(&intf
->dev
, "failed=%d\n", ret
);
719 static int af9035_download_firmware(struct dvb_usb_device
*d
,
720 const struct firmware
*fw
)
722 struct usb_interface
*intf
= d
->intf
;
723 struct state
*state
= d_to_priv(d
);
728 struct usb_req req
= { 0, 0, 0, NULL
, 0, NULL
};
729 struct usb_req req_fw_ver
= { CMD_FW_QUERYINFO
, 0, 1, wbuf
, 4, rbuf
};
731 dev_dbg(&intf
->dev
, "\n");
734 * In case of dual tuner configuration we need to do some extra
735 * initialization in order to download firmware to slave demod too,
736 * which is done by master demod.
737 * Master feeds also clock and controls power via GPIO.
739 if (state
->dual_mode
) {
740 /* configure gpioh1, reset & power slave demod */
741 ret
= af9035_wr_reg_mask(d
, 0x00d8b0, 0x01, 0x01);
745 ret
= af9035_wr_reg_mask(d
, 0x00d8b1, 0x01, 0x01);
749 ret
= af9035_wr_reg_mask(d
, 0x00d8af, 0x00, 0x01);
753 usleep_range(10000, 50000);
755 ret
= af9035_wr_reg_mask(d
, 0x00d8af, 0x01, 0x01);
759 /* tell the slave I2C address */
760 tmp
= state
->eeprom
[EEPROM_2ND_DEMOD_ADDR
];
762 /* Use default I2C address if eeprom has no address set */
764 tmp
= 0x1d << 1; /* 8-bit format used by chip */
766 if ((state
->chip_type
== 0x9135) ||
767 (state
->chip_type
== 0x9306)) {
768 ret
= af9035_wr_reg(d
, 0x004bfb, tmp
);
772 ret
= af9035_wr_reg(d
, 0x00417f, tmp
);
776 /* enable clock out */
777 ret
= af9035_wr_reg_mask(d
, 0x00d81a, 0x01, 0x01);
783 if (fw
->data
[0] == 0x01)
784 ret
= af9035_download_firmware_old(d
, fw
);
786 ret
= af9035_download_firmware_new(d
, fw
);
790 /* firmware loaded, request boot */
791 req
.cmd
= CMD_FW_BOOT
;
792 ret
= af9035_ctrl_msg(d
, &req
);
796 /* ensure firmware starts */
798 ret
= af9035_ctrl_msg(d
, &req_fw_ver
);
802 if (!(rbuf
[0] || rbuf
[1] || rbuf
[2] || rbuf
[3])) {
803 dev_err(&intf
->dev
, "firmware did not run\n");
808 dev_info(&intf
->dev
, "firmware version=%d.%d.%d.%d",
809 rbuf
[0], rbuf
[1], rbuf
[2], rbuf
[3]);
814 dev_dbg(&intf
->dev
, "failed=%d\n", ret
);
819 static int af9035_read_config(struct dvb_usb_device
*d
)
821 struct usb_interface
*intf
= d
->intf
;
822 struct state
*state
= d_to_priv(d
);
827 /* Demod I2C address */
828 state
->af9033_i2c_addr
[0] = 0x1c;
829 state
->af9033_i2c_addr
[1] = 0x1d;
830 state
->af9033_config
[0].adc_multiplier
= AF9033_ADC_MULTIPLIER_2X
;
831 state
->af9033_config
[1].adc_multiplier
= AF9033_ADC_MULTIPLIER_2X
;
832 state
->af9033_config
[0].ts_mode
= AF9033_TS_MODE_USB
;
833 state
->af9033_config
[1].ts_mode
= AF9033_TS_MODE_SERIAL
;
834 state
->it930x_addresses
= 0;
836 if (state
->chip_type
== 0x9135) {
837 /* feed clock for integrated RF tuner */
838 state
->af9033_config
[0].dyn0_clk
= true;
839 state
->af9033_config
[1].dyn0_clk
= true;
841 if (state
->chip_version
== 0x02) {
842 state
->af9033_config
[0].tuner
= AF9033_TUNER_IT9135_60
;
843 state
->af9033_config
[1].tuner
= AF9033_TUNER_IT9135_60
;
845 state
->af9033_config
[0].tuner
= AF9033_TUNER_IT9135_38
;
846 state
->af9033_config
[1].tuner
= AF9033_TUNER_IT9135_38
;
849 if (state
->no_eeprom
) {
850 /* Remote controller to NEC polling by default */
851 state
->ir_mode
= 0x05;
852 state
->ir_type
= 0x00;
856 } else if (state
->chip_type
== 0x9306) {
858 * IT930x is an USB bridge, only single demod-single tuner
859 * configurations seen so far.
861 if ((le16_to_cpu(d
->udev
->descriptor
.idVendor
) == USB_VID_AVERMEDIA
) &&
862 (le16_to_cpu(d
->udev
->descriptor
.idProduct
) == USB_PID_AVERMEDIA_TD310
)) {
863 state
->it930x_addresses
= 1;
868 /* Remote controller */
869 state
->ir_mode
= state
->eeprom
[EEPROM_IR_MODE
];
870 state
->ir_type
= state
->eeprom
[EEPROM_IR_TYPE
];
872 if (state
->dual_mode
) {
873 /* Read 2nd demodulator I2C address. 8-bit format on eeprom */
874 tmp
= state
->eeprom
[EEPROM_2ND_DEMOD_ADDR
];
876 state
->af9033_i2c_addr
[1] = tmp
>> 1;
878 dev_dbg(&intf
->dev
, "2nd demod I2C addr=%02x\n",
879 state
->af9033_i2c_addr
[1]);
882 for (i
= 0; i
< state
->dual_mode
+ 1; i
++) {
883 unsigned int eeprom_offset
= 0;
886 tmp
= state
->eeprom
[EEPROM_1_TUNER_ID
+ eeprom_offset
];
887 dev_dbg(&intf
->dev
, "[%d]tuner=%02x\n", i
, tmp
);
889 /* tuner sanity check */
890 if (state
->chip_type
== 0x9135) {
891 if (state
->chip_version
== 0x02) {
894 case AF9033_TUNER_IT9135_60
:
895 case AF9033_TUNER_IT9135_61
:
896 case AF9033_TUNER_IT9135_62
:
897 state
->af9033_config
[i
].tuner
= tmp
;
903 case AF9033_TUNER_IT9135_38
:
904 case AF9033_TUNER_IT9135_51
:
905 case AF9033_TUNER_IT9135_52
:
906 state
->af9033_config
[i
].tuner
= tmp
;
912 state
->af9033_config
[i
].tuner
= tmp
;
915 if (state
->af9033_config
[i
].tuner
!= tmp
) {
916 dev_info(&intf
->dev
, "[%d] overriding tuner from %02x to %02x\n",
917 i
, tmp
, state
->af9033_config
[i
].tuner
);
920 switch (state
->af9033_config
[i
].tuner
) {
921 case AF9033_TUNER_TUA9001
:
922 case AF9033_TUNER_FC0011
:
923 case AF9033_TUNER_MXL5007T
:
924 case AF9033_TUNER_TDA18218
:
925 case AF9033_TUNER_FC2580
:
926 case AF9033_TUNER_FC0012
:
927 state
->af9033_config
[i
].spec_inv
= 1;
929 case AF9033_TUNER_IT9135_38
:
930 case AF9033_TUNER_IT9135_51
:
931 case AF9033_TUNER_IT9135_52
:
932 case AF9033_TUNER_IT9135_60
:
933 case AF9033_TUNER_IT9135_61
:
934 case AF9033_TUNER_IT9135_62
:
937 dev_warn(&intf
->dev
, "tuner id=%02x not supported, please report!",
941 /* disable dual mode if driver does not support it */
943 switch (state
->af9033_config
[i
].tuner
) {
944 case AF9033_TUNER_FC0012
:
945 case AF9033_TUNER_IT9135_38
:
946 case AF9033_TUNER_IT9135_51
:
947 case AF9033_TUNER_IT9135_52
:
948 case AF9033_TUNER_IT9135_60
:
949 case AF9033_TUNER_IT9135_61
:
950 case AF9033_TUNER_IT9135_62
:
951 case AF9033_TUNER_MXL5007T
:
954 state
->dual_mode
= false;
955 dev_info(&intf
->dev
, "driver does not support 2nd tuner and will disable it");
958 /* tuner IF frequency */
959 tmp
= state
->eeprom
[EEPROM_1_IF_L
+ eeprom_offset
];
961 tmp
= state
->eeprom
[EEPROM_1_IF_H
+ eeprom_offset
];
963 dev_dbg(&intf
->dev
, "[%d]IF=%d\n", i
, tmp16
);
965 eeprom_offset
+= 0x10; /* shift for the 2nd tuner params */
969 /* get demod clock */
970 ret
= af9035_rd_reg(d
, 0x00d800, &tmp
);
974 tmp
= (tmp
>> 0) & 0x0f;
976 for (i
= 0; i
< ARRAY_SIZE(state
->af9033_config
); i
++) {
977 if (state
->chip_type
== 0x9135)
978 state
->af9033_config
[i
].clock
= clock_lut_it9135
[tmp
];
980 state
->af9033_config
[i
].clock
= clock_lut_af9035
[tmp
];
983 state
->no_read
= false;
984 /* Some MXL5007T devices cannot properly handle tuner I2C read ops. */
985 if (state
->af9033_config
[0].tuner
== AF9033_TUNER_MXL5007T
&&
986 le16_to_cpu(d
->udev
->descriptor
.idVendor
) == USB_VID_AVERMEDIA
)
988 switch (le16_to_cpu(d
->udev
->descriptor
.idProduct
)) {
989 case USB_PID_AVERMEDIA_A867
:
990 case USB_PID_AVERMEDIA_TWINSTAR
:
992 "Device may have issues with I2C read operations. Enabling fix.\n");
993 state
->no_read
= true;
1000 dev_dbg(&intf
->dev
, "failed=%d\n", ret
);
1005 static int af9035_tua9001_tuner_callback(struct dvb_usb_device
*d
,
1008 struct usb_interface
*intf
= d
->intf
;
1012 dev_dbg(&intf
->dev
, "cmd=%d arg=%d\n", cmd
, arg
);
1015 * CEN always enabled by hardware wiring
1021 case TUA9001_CMD_RESETN
:
1027 ret
= af9035_wr_reg_mask(d
, 0x00d8e7, val
, 0x01);
1031 case TUA9001_CMD_RXEN
:
1037 ret
= af9035_wr_reg_mask(d
, 0x00d8eb, val
, 0x01);
1046 dev_dbg(&intf
->dev
, "failed=%d\n", ret
);
1052 static int af9035_fc0011_tuner_callback(struct dvb_usb_device
*d
,
1055 struct usb_interface
*intf
= d
->intf
;
1059 case FC0011_FE_CALLBACK_POWER
:
1061 ret
= af9035_wr_reg_mask(d
, 0xd8eb, 1, 1);
1065 ret
= af9035_wr_reg_mask(d
, 0xd8ec, 1, 1);
1069 ret
= af9035_wr_reg_mask(d
, 0xd8ed, 1, 1);
1074 ret
= af9035_wr_reg_mask(d
, 0xd8d0, 1, 1);
1078 ret
= af9035_wr_reg_mask(d
, 0xd8d1, 1, 1);
1082 usleep_range(10000, 50000);
1084 case FC0011_FE_CALLBACK_RESET
:
1085 ret
= af9035_wr_reg(d
, 0xd8e9, 1);
1089 ret
= af9035_wr_reg(d
, 0xd8e8, 1);
1093 ret
= af9035_wr_reg(d
, 0xd8e7, 1);
1097 usleep_range(10000, 20000);
1099 ret
= af9035_wr_reg(d
, 0xd8e7, 0);
1103 usleep_range(10000, 20000);
1113 dev_dbg(&intf
->dev
, "failed=%d\n", ret
);
1118 static int af9035_tuner_callback(struct dvb_usb_device
*d
, int cmd
, int arg
)
1120 struct state
*state
= d_to_priv(d
);
1122 switch (state
->af9033_config
[0].tuner
) {
1123 case AF9033_TUNER_FC0011
:
1124 return af9035_fc0011_tuner_callback(d
, cmd
, arg
);
1125 case AF9033_TUNER_TUA9001
:
1126 return af9035_tua9001_tuner_callback(d
, cmd
, arg
);
1134 static int af9035_frontend_callback(void *adapter_priv
, int component
,
1137 struct i2c_adapter
*adap
= adapter_priv
;
1138 struct dvb_usb_device
*d
= i2c_get_adapdata(adap
);
1139 struct usb_interface
*intf
= d
->intf
;
1141 dev_dbg(&intf
->dev
, "component=%d cmd=%d arg=%d\n",
1142 component
, cmd
, arg
);
1144 switch (component
) {
1145 case DVB_FRONTEND_COMPONENT_TUNER
:
1146 return af9035_tuner_callback(d
, cmd
, arg
);
1154 static int af9035_get_adapter_count(struct dvb_usb_device
*d
)
1156 struct state
*state
= d_to_priv(d
);
1158 return state
->dual_mode
+ 1;
1161 static int af9035_frontend_attach(struct dvb_usb_adapter
*adap
)
1163 struct state
*state
= adap_to_priv(adap
);
1164 struct dvb_usb_device
*d
= adap_to_d(adap
);
1165 struct usb_interface
*intf
= d
->intf
;
1168 dev_dbg(&intf
->dev
, "adap->id=%d\n", adap
->id
);
1170 if (!state
->af9033_config
[adap
->id
].tuner
) {
1171 /* unsupported tuner */
1176 state
->af9033_config
[adap
->id
].fe
= &adap
->fe
[0];
1177 state
->af9033_config
[adap
->id
].ops
= &state
->ops
;
1178 ret
= af9035_add_i2c_dev(d
, "af9033", state
->af9033_i2c_addr
[adap
->id
],
1179 &state
->af9033_config
[adap
->id
], &d
->i2c_adap
);
1183 if (adap
->fe
[0] == NULL
) {
1188 /* disable I2C-gate */
1189 adap
->fe
[0]->ops
.i2c_gate_ctrl
= NULL
;
1190 adap
->fe
[0]->callback
= af9035_frontend_callback
;
1195 dev_dbg(&intf
->dev
, "failed=%d\n", ret
);
1201 * The I2C speed register is calculated with:
1202 * I2C speed register = (1000000000 / (24.4 * 16 * I2C_speed))
1204 * The default speed register for it930x is 7, with means a
1205 * speed of ~366 kbps
1207 #define I2C_SPEED_366K 7
1209 static int it930x_frontend_attach(struct dvb_usb_adapter
*adap
)
1211 struct state
*state
= adap_to_priv(adap
);
1212 struct dvb_usb_device
*d
= adap_to_d(adap
);
1213 struct usb_interface
*intf
= d
->intf
;
1215 struct si2168_config si2168_config
;
1216 struct i2c_adapter
*adapter
;
1218 dev_dbg(&intf
->dev
, "adap->id=%d\n", adap
->id
);
1220 /* I2C master bus 2 clock speed 366k */
1221 ret
= af9035_wr_reg(d
, 0x00f6a7, I2C_SPEED_366K
);
1225 /* I2C master bus 1,3 clock speed 366k */
1226 ret
= af9035_wr_reg(d
, 0x00f103, I2C_SPEED_366K
);
1230 /* set gpio11 low */
1231 ret
= af9035_wr_reg_mask(d
, 0xd8d4, 0x01, 0x01);
1235 ret
= af9035_wr_reg_mask(d
, 0xd8d5, 0x01, 0x01);
1239 ret
= af9035_wr_reg_mask(d
, 0xd8d3, 0x01, 0x01);
1243 /* Tuner enable using gpiot2_en, gpiot2_on and gpiot2_o (reset) */
1244 ret
= af9035_wr_reg_mask(d
, 0xd8b8, 0x01, 0x01);
1248 ret
= af9035_wr_reg_mask(d
, 0xd8b9, 0x01, 0x01);
1252 ret
= af9035_wr_reg_mask(d
, 0xd8b7, 0x00, 0x01);
1258 ret
= af9035_wr_reg_mask(d
, 0xd8b7, 0x01, 0x01);
1262 memset(&si2168_config
, 0, sizeof(si2168_config
));
1263 si2168_config
.i2c_adapter
= &adapter
;
1264 si2168_config
.fe
= &adap
->fe
[0];
1265 si2168_config
.ts_mode
= SI2168_TS_SERIAL
;
1267 state
->af9033_config
[adap
->id
].fe
= &adap
->fe
[0];
1268 state
->af9033_config
[adap
->id
].ops
= &state
->ops
;
1269 ret
= af9035_add_i2c_dev(d
, "si2168",
1270 it930x_addresses_table
[state
->it930x_addresses
].frontend_i2c_addr
,
1271 &si2168_config
, &d
->i2c_adap
);
1275 if (adap
->fe
[0] == NULL
) {
1279 state
->i2c_adapter_demod
= adapter
;
1284 dev_dbg(&intf
->dev
, "failed=%d\n", ret
);
1289 static int af9035_frontend_detach(struct dvb_usb_adapter
*adap
)
1291 struct state
*state
= adap_to_priv(adap
);
1292 struct dvb_usb_device
*d
= adap_to_d(adap
);
1293 struct usb_interface
*intf
= d
->intf
;
1295 dev_dbg(&intf
->dev
, "adap->id=%d\n", adap
->id
);
1297 if (adap
->id
== 1) {
1298 if (state
->i2c_client
[1])
1299 af9035_del_i2c_dev(d
);
1300 } else if (adap
->id
== 0) {
1301 if (state
->i2c_client
[0])
1302 af9035_del_i2c_dev(d
);
1308 static const struct fc0011_config af9035_fc0011_config
= {
1309 .i2c_address
= 0x60,
1312 static struct mxl5007t_config af9035_mxl5007t_config
[] = {
1314 .xtal_freq_hz
= MxL_XTAL_24_MHZ
,
1315 .if_freq_hz
= MxL_IF_4_57_MHZ
,
1317 .loop_thru_enable
= 0,
1318 .clk_out_enable
= 0,
1319 .clk_out_amp
= MxL_CLKOUT_AMP_0_94V
,
1321 .xtal_freq_hz
= MxL_XTAL_24_MHZ
,
1322 .if_freq_hz
= MxL_IF_4_57_MHZ
,
1324 .loop_thru_enable
= 1,
1325 .clk_out_enable
= 1,
1326 .clk_out_amp
= MxL_CLKOUT_AMP_0_94V
,
1330 static struct tda18218_config af9035_tda18218_config
= {
1331 .i2c_address
= 0x60,
1335 static const struct fc0012_config af9035_fc0012_config
[] = {
1337 .i2c_address
= 0x63,
1338 .xtal_freq
= FC_XTAL_36_MHZ
,
1339 .dual_master
= true,
1340 .loop_through
= true,
1343 .i2c_address
= 0x63 | 0x80, /* I2C bus select hack */
1344 .xtal_freq
= FC_XTAL_36_MHZ
,
1345 .dual_master
= true,
1349 static int af9035_tuner_attach(struct dvb_usb_adapter
*adap
)
1351 struct state
*state
= adap_to_priv(adap
);
1352 struct dvb_usb_device
*d
= adap_to_d(adap
);
1353 struct usb_interface
*intf
= d
->intf
;
1355 struct dvb_frontend
*fe
;
1356 struct i2c_msg msg
[1];
1359 dev_dbg(&intf
->dev
, "adap->id=%d\n", adap
->id
);
1362 * XXX: Hack used in that function: we abuse unused I2C address bit [7]
1363 * to carry info about used I2C bus for dual tuner configuration.
1366 switch (state
->af9033_config
[adap
->id
].tuner
) {
1367 case AF9033_TUNER_TUA9001
: {
1368 struct tua9001_platform_data tua9001_pdata
= {
1369 .dvb_frontend
= adap
->fe
[0],
1373 * AF9035 gpiot3 = TUA9001 RESETN
1374 * AF9035 gpiot2 = TUA9001 RXEN
1377 /* configure gpiot2 and gpiot2 as output */
1378 ret
= af9035_wr_reg_mask(d
, 0x00d8ec, 0x01, 0x01);
1382 ret
= af9035_wr_reg_mask(d
, 0x00d8ed, 0x01, 0x01);
1386 ret
= af9035_wr_reg_mask(d
, 0x00d8e8, 0x01, 0x01);
1390 ret
= af9035_wr_reg_mask(d
, 0x00d8e9, 0x01, 0x01);
1395 ret
= af9035_add_i2c_dev(d
, "tua9001", 0x60, &tua9001_pdata
,
1403 case AF9033_TUNER_FC0011
:
1404 fe
= dvb_attach(fc0011_attach
, adap
->fe
[0],
1405 &d
->i2c_adap
, &af9035_fc0011_config
);
1407 case AF9033_TUNER_MXL5007T
:
1408 if (adap
->id
== 0) {
1409 ret
= af9035_wr_reg(d
, 0x00d8e0, 1);
1413 ret
= af9035_wr_reg(d
, 0x00d8e1, 1);
1417 ret
= af9035_wr_reg(d
, 0x00d8df, 0);
1423 ret
= af9035_wr_reg(d
, 0x00d8df, 1);
1429 ret
= af9035_wr_reg(d
, 0x00d8c0, 1);
1433 ret
= af9035_wr_reg(d
, 0x00d8c1, 1);
1437 ret
= af9035_wr_reg(d
, 0x00d8bf, 0);
1441 ret
= af9035_wr_reg(d
, 0x00d8b4, 1);
1445 ret
= af9035_wr_reg(d
, 0x00d8b5, 1);
1449 ret
= af9035_wr_reg(d
, 0x00d8b3, 1);
1455 tuner_addr
= 0x60 | 0x80; /* I2C bus hack */
1459 fe
= dvb_attach(mxl5007t_attach
, adap
->fe
[0], &d
->i2c_adap
,
1460 tuner_addr
, &af9035_mxl5007t_config
[adap
->id
]);
1462 case AF9033_TUNER_TDA18218
:
1464 fe
= dvb_attach(tda18218_attach
, adap
->fe
[0],
1465 &d
->i2c_adap
, &af9035_tda18218_config
);
1467 case AF9033_TUNER_FC2580
: {
1468 struct fc2580_platform_data fc2580_pdata
= {
1469 .dvb_frontend
= adap
->fe
[0],
1472 /* Tuner enable using gpiot2_o, gpiot2_en and gpiot2_on */
1473 ret
= af9035_wr_reg_mask(d
, 0xd8eb, 0x01, 0x01);
1477 ret
= af9035_wr_reg_mask(d
, 0xd8ec, 0x01, 0x01);
1481 ret
= af9035_wr_reg_mask(d
, 0xd8ed, 0x01, 0x01);
1485 usleep_range(10000, 50000);
1487 ret
= af9035_add_i2c_dev(d
, "fc2580", 0x56, &fc2580_pdata
,
1495 case AF9033_TUNER_FC0012
:
1497 * AF9035 gpiot2 = FC0012 enable
1498 * XXX: there seems to be something on gpioh8 too, but on my
1499 * my test I didn't find any difference.
1502 if (adap
->id
== 0) {
1503 /* configure gpiot2 as output and high */
1504 ret
= af9035_wr_reg_mask(d
, 0xd8eb, 0x01, 0x01);
1508 ret
= af9035_wr_reg_mask(d
, 0xd8ec, 0x01, 0x01);
1512 ret
= af9035_wr_reg_mask(d
, 0xd8ed, 0x01, 0x01);
1517 * FIXME: That belongs for the FC0012 driver.
1518 * Write 02 to FC0012 master tuner register 0d directly
1519 * in order to make slave tuner working.
1524 msg
[0].buf
= "\x0d\x02";
1525 ret
= i2c_transfer(&d
->i2c_adap
, msg
, 1);
1530 usleep_range(10000, 50000);
1532 fe
= dvb_attach(fc0012_attach
, adap
->fe
[0], &d
->i2c_adap
,
1533 &af9035_fc0012_config
[adap
->id
]);
1535 case AF9033_TUNER_IT9135_38
:
1536 case AF9033_TUNER_IT9135_51
:
1537 case AF9033_TUNER_IT9135_52
:
1538 case AF9033_TUNER_IT9135_60
:
1539 case AF9033_TUNER_IT9135_61
:
1540 case AF9033_TUNER_IT9135_62
:
1542 struct platform_device
*pdev
;
1544 struct it913x_platform_data it913x_pdata
= {
1545 .regmap
= state
->af9033_config
[adap
->id
].regmap
,
1549 switch (state
->af9033_config
[adap
->id
].tuner
) {
1550 case AF9033_TUNER_IT9135_38
:
1551 case AF9033_TUNER_IT9135_51
:
1552 case AF9033_TUNER_IT9135_52
:
1553 name
= "it9133ax-tuner";
1555 case AF9033_TUNER_IT9135_60
:
1556 case AF9033_TUNER_IT9135_61
:
1557 case AF9033_TUNER_IT9135_62
:
1558 name
= "it9133bx-tuner";
1565 if (state
->dual_mode
) {
1567 it913x_pdata
.role
= IT913X_ROLE_DUAL_MASTER
;
1569 it913x_pdata
.role
= IT913X_ROLE_DUAL_SLAVE
;
1571 it913x_pdata
.role
= IT913X_ROLE_SINGLE
;
1574 request_module("%s", "it913x");
1575 pdev
= platform_device_register_data(&d
->intf
->dev
, name
,
1576 PLATFORM_DEVID_AUTO
,
1578 sizeof(it913x_pdata
));
1579 if (IS_ERR(pdev
) || !pdev
->dev
.driver
) {
1583 if (!try_module_get(pdev
->dev
.driver
->owner
)) {
1584 platform_device_unregister(pdev
);
1589 state
->platform_device_tuner
[adap
->id
] = pdev
;
1605 dev_dbg(&intf
->dev
, "failed=%d\n", ret
);
1610 static int it930x_tuner_attach(struct dvb_usb_adapter
*adap
)
1612 struct state
*state
= adap_to_priv(adap
);
1613 struct dvb_usb_device
*d
= adap_to_d(adap
);
1614 struct usb_interface
*intf
= d
->intf
;
1616 struct si2157_config si2157_config
;
1618 dev_dbg(&intf
->dev
, "adap->id=%d\n", adap
->id
);
1620 memset(&si2157_config
, 0, sizeof(si2157_config
));
1621 si2157_config
.fe
= adap
->fe
[0];
1624 * HACK: The Logilink VG0022A and TerraTec TC2 Stick have
1625 * a bug: when the si2157 firmware that came with the device
1626 * is replaced by a new one, the I2C transfers to the tuner
1627 * will return just 0xff.
1629 * Probably, the vendor firmware has some patch specifically
1630 * designed for this device. So, we can't replace by the
1631 * generic firmware. The right solution would be to extract
1632 * the si2157 firmware from the original driver and ask the
1633 * driver to load the specifically designed firmware, but,
1634 * while we don't have that, the next best solution is to just
1635 * keep the original firmware at the device.
1637 if ((le16_to_cpu(d
->udev
->descriptor
.idVendor
) == USB_VID_DEXATEK
&&
1638 le16_to_cpu(d
->udev
->descriptor
.idProduct
) == 0x0100) ||
1639 (le16_to_cpu(d
->udev
->descriptor
.idVendor
) == USB_VID_TERRATEC
&&
1640 le16_to_cpu(d
->udev
->descriptor
.idProduct
) == USB_PID_TERRATEC_CINERGY_TC2_STICK
))
1641 si2157_config
.dont_load_firmware
= true;
1643 si2157_config
.if_port
= it930x_addresses_table
[state
->it930x_addresses
].tuner_if_port
;
1644 ret
= af9035_add_i2c_dev(d
, "si2157",
1645 it930x_addresses_table
[state
->it930x_addresses
].tuner_i2c_addr
,
1646 &si2157_config
, state
->i2c_adapter_demod
);
1653 dev_dbg(&intf
->dev
, "failed=%d\n", ret
);
1659 static int it930x_tuner_detach(struct dvb_usb_adapter
*adap
)
1661 struct state
*state
= adap_to_priv(adap
);
1662 struct dvb_usb_device
*d
= adap_to_d(adap
);
1663 struct usb_interface
*intf
= d
->intf
;
1665 dev_dbg(&intf
->dev
, "adap->id=%d\n", adap
->id
);
1667 if (adap
->id
== 1) {
1668 if (state
->i2c_client
[3])
1669 af9035_del_i2c_dev(d
);
1670 } else if (adap
->id
== 0) {
1671 if (state
->i2c_client
[1])
1672 af9035_del_i2c_dev(d
);
1679 static int af9035_tuner_detach(struct dvb_usb_adapter
*adap
)
1681 struct state
*state
= adap_to_priv(adap
);
1682 struct dvb_usb_device
*d
= adap_to_d(adap
);
1683 struct usb_interface
*intf
= d
->intf
;
1685 dev_dbg(&intf
->dev
, "adap->id=%d\n", adap
->id
);
1687 switch (state
->af9033_config
[adap
->id
].tuner
) {
1688 case AF9033_TUNER_TUA9001
:
1689 case AF9033_TUNER_FC2580
:
1690 if (adap
->id
== 1) {
1691 if (state
->i2c_client
[3])
1692 af9035_del_i2c_dev(d
);
1693 } else if (adap
->id
== 0) {
1694 if (state
->i2c_client
[1])
1695 af9035_del_i2c_dev(d
);
1698 case AF9033_TUNER_IT9135_38
:
1699 case AF9033_TUNER_IT9135_51
:
1700 case AF9033_TUNER_IT9135_52
:
1701 case AF9033_TUNER_IT9135_60
:
1702 case AF9033_TUNER_IT9135_61
:
1703 case AF9033_TUNER_IT9135_62
:
1705 struct platform_device
*pdev
;
1707 pdev
= state
->platform_device_tuner
[adap
->id
];
1709 module_put(pdev
->dev
.driver
->owner
);
1710 platform_device_unregister(pdev
);
1719 static int af9035_init(struct dvb_usb_device
*d
)
1721 struct state
*state
= d_to_priv(d
);
1722 struct usb_interface
*intf
= d
->intf
;
1724 u16 frame_size
= (d
->udev
->speed
== USB_SPEED_FULL
? 5 : 87) * 188 / 4;
1725 u8 packet_size
= (d
->udev
->speed
== USB_SPEED_FULL
? 64 : 512) / 4;
1726 struct reg_val_mask tab
[] = {
1727 { 0x80f99d, 0x01, 0x01 },
1728 { 0x80f9a4, 0x01, 0x01 },
1729 { 0x00dd11, 0x00, 0x20 },
1730 { 0x00dd11, 0x00, 0x40 },
1731 { 0x00dd13, 0x00, 0x20 },
1732 { 0x00dd13, 0x00, 0x40 },
1733 { 0x00dd11, 0x20, 0x20 },
1734 { 0x00dd88, (frame_size
>> 0) & 0xff, 0xff},
1735 { 0x00dd89, (frame_size
>> 8) & 0xff, 0xff},
1736 { 0x00dd0c, packet_size
, 0xff},
1737 { 0x00dd11, state
->dual_mode
<< 6, 0x40 },
1738 { 0x00dd8a, (frame_size
>> 0) & 0xff, 0xff},
1739 { 0x00dd8b, (frame_size
>> 8) & 0xff, 0xff},
1740 { 0x00dd0d, packet_size
, 0xff },
1741 { 0x80f9a3, state
->dual_mode
, 0x01 },
1742 { 0x80f9cd, state
->dual_mode
, 0x01 },
1743 { 0x80f99d, 0x00, 0x01 },
1744 { 0x80f9a4, 0x00, 0x01 },
1747 dev_dbg(&intf
->dev
, "USB speed=%d frame_size=%04x packet_size=%02x\n",
1748 d
->udev
->speed
, frame_size
, packet_size
);
1750 /* init endpoints */
1751 for (i
= 0; i
< ARRAY_SIZE(tab
); i
++) {
1752 ret
= af9035_wr_reg_mask(d
, tab
[i
].reg
, tab
[i
].val
,
1761 dev_dbg(&intf
->dev
, "failed=%d\n", ret
);
1766 static int it930x_init(struct dvb_usb_device
*d
)
1768 struct state
*state
= d_to_priv(d
);
1769 struct usb_interface
*intf
= d
->intf
;
1771 u16 frame_size
= (d
->udev
->speed
== USB_SPEED_FULL
? 5 : 816) * 188 / 4;
1772 u8 packet_size
= (d
->udev
->speed
== USB_SPEED_FULL
? 64 : 512) / 4;
1773 struct reg_val_mask tab
[] = {
1774 { 0x00da1a, 0x00, 0x01 }, /* ignore_sync_byte */
1775 { 0x00f41f, 0x04, 0x04 }, /* dvbt_inten */
1776 { 0x00da10, 0x00, 0x01 }, /* mpeg_full_speed */
1777 { 0x00f41a, 0x01, 0x01 }, /* dvbt_en */
1778 { 0x00da1d, 0x01, 0x01 }, /* mp2_sw_rst, reset EP4 */
1779 { 0x00dd11, 0x00, 0x20 }, /* ep4_tx_en, disable EP4 */
1780 { 0x00dd13, 0x00, 0x20 }, /* ep4_tx_nak, disable EP4 NAK */
1781 { 0x00dd11, 0x20, 0x20 }, /* ep4_tx_en, enable EP4 */
1782 { 0x00dd11, 0x00, 0x40 }, /* ep5_tx_en, disable EP5 */
1783 { 0x00dd13, 0x00, 0x40 }, /* ep5_tx_nak, disable EP5 NAK */
1784 { 0x00dd11, state
->dual_mode
<< 6, 0x40 }, /* enable EP5 */
1785 { 0x00dd88, (frame_size
>> 0) & 0xff, 0xff},
1786 { 0x00dd89, (frame_size
>> 8) & 0xff, 0xff},
1787 { 0x00dd0c, packet_size
, 0xff},
1788 { 0x00dd8a, (frame_size
>> 0) & 0xff, 0xff},
1789 { 0x00dd8b, (frame_size
>> 8) & 0xff, 0xff},
1790 { 0x00dd0d, packet_size
, 0xff },
1791 { 0x00da1d, 0x00, 0x01 }, /* mp2_sw_rst, disable */
1792 { 0x00d833, 0x01, 0xff }, /* slew rate ctrl: slew rate boosts */
1793 { 0x00d830, 0x00, 0xff }, /* Bit 0 of output driving control */
1794 { 0x00d831, 0x01, 0xff }, /* Bit 1 of output driving control */
1795 { 0x00d832, 0x00, 0xff }, /* Bit 2 of output driving control */
1797 /* suspend gpio1 for TS-C */
1798 { 0x00d8b0, 0x01, 0xff }, /* gpio1 */
1799 { 0x00d8b1, 0x01, 0xff }, /* gpio1 */
1800 { 0x00d8af, 0x00, 0xff }, /* gpio1 */
1802 /* suspend gpio7 for TS-D */
1803 { 0x00d8c4, 0x01, 0xff }, /* gpio7 */
1804 { 0x00d8c5, 0x01, 0xff }, /* gpio7 */
1805 { 0x00d8c3, 0x00, 0xff }, /* gpio7 */
1807 /* suspend gpio13 for TS-B */
1808 { 0x00d8dc, 0x01, 0xff }, /* gpio13 */
1809 { 0x00d8dd, 0x01, 0xff }, /* gpio13 */
1810 { 0x00d8db, 0x00, 0xff }, /* gpio13 */
1812 /* suspend gpio14 for TS-E */
1813 { 0x00d8e4, 0x01, 0xff }, /* gpio14 */
1814 { 0x00d8e5, 0x01, 0xff }, /* gpio14 */
1815 { 0x00d8e3, 0x00, 0xff }, /* gpio14 */
1817 /* suspend gpio15 for TS-A */
1818 { 0x00d8e8, 0x01, 0xff }, /* gpio15 */
1819 { 0x00d8e9, 0x01, 0xff }, /* gpio15 */
1820 { 0x00d8e7, 0x00, 0xff }, /* gpio15 */
1822 { 0x00da58, 0x00, 0x01 }, /* ts_in_src, serial */
1823 { 0x00da73, 0x01, 0xff }, /* ts0_aggre_mode */
1824 { 0x00da78, 0x47, 0xff }, /* ts0_sync_byte */
1825 { 0x00da4c, 0x01, 0xff }, /* ts0_en */
1826 { 0x00da5a, 0x1f, 0xff }, /* ts_fail_ignore */
1829 dev_dbg(&intf
->dev
, "USB speed=%d frame_size=%04x packet_size=%02x\n",
1830 d
->udev
->speed
, frame_size
, packet_size
);
1832 /* init endpoints */
1833 for (i
= 0; i
< ARRAY_SIZE(tab
); i
++) {
1834 ret
= af9035_wr_reg_mask(d
, tab
[i
].reg
,
1835 tab
[i
].val
, tab
[i
].mask
);
1843 dev_dbg(&intf
->dev
, "failed=%d\n", ret
);
1849 #if IS_ENABLED(CONFIG_RC_CORE)
1850 static int af9035_rc_query(struct dvb_usb_device
*d
)
1852 struct usb_interface
*intf
= d
->intf
;
1854 enum rc_proto proto
;
1857 struct usb_req req
= { CMD_IR_GET
, 0, 0, NULL
, 4, buf
};
1859 ret
= af9035_ctrl_msg(d
, &req
);
1865 if ((buf
[2] + buf
[3]) == 0xff) {
1866 if ((buf
[0] + buf
[1]) == 0xff) {
1867 /* NEC standard 16bit */
1868 key
= RC_SCANCODE_NEC(buf
[0], buf
[2]);
1869 proto
= RC_PROTO_NEC
;
1871 /* NEC extended 24bit */
1872 key
= RC_SCANCODE_NECX(buf
[0] << 8 | buf
[1], buf
[2]);
1873 proto
= RC_PROTO_NECX
;
1876 /* NEC full code 32bit */
1877 key
= RC_SCANCODE_NEC32(buf
[0] << 24 | buf
[1] << 16 |
1878 buf
[2] << 8 | buf
[3]);
1879 proto
= RC_PROTO_NEC32
;
1882 dev_dbg(&intf
->dev
, "%*ph\n", 4, buf
);
1884 rc_keydown(d
->rc_dev
, proto
, key
, 0);
1889 dev_dbg(&intf
->dev
, "failed=%d\n", ret
);
1894 static int af9035_get_rc_config(struct dvb_usb_device
*d
, struct dvb_usb_rc
*rc
)
1896 struct state
*state
= d_to_priv(d
);
1897 struct usb_interface
*intf
= d
->intf
;
1899 dev_dbg(&intf
->dev
, "ir_mode=%02x ir_type=%02x\n",
1900 state
->ir_mode
, state
->ir_type
);
1902 /* don't activate rc if in HID mode or if not available */
1903 if (state
->ir_mode
== 0x05) {
1904 switch (state
->ir_type
) {
1907 rc
->allowed_protos
= RC_PROTO_BIT_NEC
|
1908 RC_PROTO_BIT_NECX
| RC_PROTO_BIT_NEC32
;
1911 rc
->allowed_protos
= RC_PROTO_BIT_RC6_MCE
;
1915 rc
->query
= af9035_rc_query
;
1918 /* load empty to enable rc */
1920 rc
->map_name
= RC_MAP_EMPTY
;
1926 #define af9035_get_rc_config NULL
1929 static int af9035_get_stream_config(struct dvb_frontend
*fe
, u8
*ts_type
,
1930 struct usb_data_stream_properties
*stream
)
1932 struct dvb_usb_device
*d
= fe_to_d(fe
);
1933 struct usb_interface
*intf
= d
->intf
;
1935 dev_dbg(&intf
->dev
, "adap=%d\n", fe_to_adap(fe
)->id
);
1937 if (d
->udev
->speed
== USB_SPEED_FULL
)
1938 stream
->u
.bulk
.buffersize
= 5 * 188;
1943 static int af9035_pid_filter_ctrl(struct dvb_usb_adapter
*adap
, int onoff
)
1945 struct state
*state
= adap_to_priv(adap
);
1947 return state
->ops
.pid_filter_ctrl(adap
->fe
[0], onoff
);
1950 static int af9035_pid_filter(struct dvb_usb_adapter
*adap
, int index
, u16 pid
,
1953 struct state
*state
= adap_to_priv(adap
);
1955 return state
->ops
.pid_filter(adap
->fe
[0], index
, pid
, onoff
);
1958 static int af9035_probe(struct usb_interface
*intf
,
1959 const struct usb_device_id
*id
)
1961 struct usb_device
*udev
= interface_to_usbdev(intf
);
1962 char manufacturer
[sizeof("Afatech")];
1964 memset(manufacturer
, 0, sizeof(manufacturer
));
1965 usb_string(udev
, udev
->descriptor
.iManufacturer
,
1966 manufacturer
, sizeof(manufacturer
));
1968 * There is two devices having same ID but different chipset. One uses
1969 * AF9015 and the other IT9135 chipset. Only difference seen on lsusb
1970 * is iManufacturer string.
1972 * idVendor 0x0ccd TerraTec Electronic GmbH
1975 * iManufacturer 1 Afatech
1976 * iProduct 2 DVB-T 2
1978 * idVendor 0x0ccd TerraTec Electronic GmbH
1981 * iManufacturer 1 ITE Technologies, Inc.
1982 * iProduct 2 DVB-T TV Stick
1984 if ((le16_to_cpu(udev
->descriptor
.idVendor
) == USB_VID_TERRATEC
) &&
1985 (le16_to_cpu(udev
->descriptor
.idProduct
) == 0x0099)) {
1986 if (!strcmp("Afatech", manufacturer
)) {
1987 dev_dbg(&udev
->dev
, "rejecting device\n");
1992 return dvb_usbv2_probe(intf
, id
);
1995 /* interface 0 is used by DVB-T receiver and
1996 interface 1 is for remote controller (HID) */
1997 static const struct dvb_usb_device_properties af9035_props
= {
1998 .driver_name
= KBUILD_MODNAME
,
1999 .owner
= THIS_MODULE
,
2000 .adapter_nr
= adapter_nr
,
2001 .size_of_priv
= sizeof(struct state
),
2003 .generic_bulk_ctrl_endpoint
= 0x02,
2004 .generic_bulk_ctrl_endpoint_response
= 0x81,
2006 .identify_state
= af9035_identify_state
,
2007 .download_firmware
= af9035_download_firmware
,
2009 .i2c_algo
= &af9035_i2c_algo
,
2010 .read_config
= af9035_read_config
,
2011 .frontend_attach
= af9035_frontend_attach
,
2012 .frontend_detach
= af9035_frontend_detach
,
2013 .tuner_attach
= af9035_tuner_attach
,
2014 .tuner_detach
= af9035_tuner_detach
,
2015 .init
= af9035_init
,
2016 .get_rc_config
= af9035_get_rc_config
,
2017 .get_stream_config
= af9035_get_stream_config
,
2019 .get_adapter_count
= af9035_get_adapter_count
,
2022 .caps
= DVB_USB_ADAP_HAS_PID_FILTER
|
2023 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF
,
2025 .pid_filter_count
= 32,
2026 .pid_filter_ctrl
= af9035_pid_filter_ctrl
,
2027 .pid_filter
= af9035_pid_filter
,
2029 .stream
= DVB_USB_STREAM_BULK(0x84, 6, 87 * 188),
2031 .caps
= DVB_USB_ADAP_HAS_PID_FILTER
|
2032 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF
,
2034 .pid_filter_count
= 32,
2035 .pid_filter_ctrl
= af9035_pid_filter_ctrl
,
2036 .pid_filter
= af9035_pid_filter
,
2038 .stream
= DVB_USB_STREAM_BULK(0x85, 6, 87 * 188),
2043 static const struct dvb_usb_device_properties it930x_props
= {
2044 .driver_name
= KBUILD_MODNAME
,
2045 .owner
= THIS_MODULE
,
2046 .adapter_nr
= adapter_nr
,
2047 .size_of_priv
= sizeof(struct state
),
2049 .generic_bulk_ctrl_endpoint
= 0x02,
2050 .generic_bulk_ctrl_endpoint_response
= 0x81,
2052 .identify_state
= af9035_identify_state
,
2053 .download_firmware
= af9035_download_firmware
,
2055 .i2c_algo
= &af9035_i2c_algo
,
2056 .read_config
= af9035_read_config
,
2057 .frontend_attach
= it930x_frontend_attach
,
2058 .frontend_detach
= af9035_frontend_detach
,
2059 .tuner_attach
= it930x_tuner_attach
,
2060 .tuner_detach
= it930x_tuner_detach
,
2061 .init
= it930x_init
,
2062 .get_stream_config
= af9035_get_stream_config
,
2064 .get_adapter_count
= af9035_get_adapter_count
,
2067 .stream
= DVB_USB_STREAM_BULK(0x84, 4, 816 * 188),
2069 .stream
= DVB_USB_STREAM_BULK(0x85, 4, 816 * 188),
2074 static const struct usb_device_id af9035_id_table
[] = {
2075 /* AF9035 devices */
2076 { DVB_USB_DEVICE(USB_VID_AFATECH
, USB_PID_AFATECH_AF9035_9035
,
2077 &af9035_props
, "Afatech AF9035 reference design", NULL
) },
2078 { DVB_USB_DEVICE(USB_VID_AFATECH
, USB_PID_AFATECH_AF9035_1000
,
2079 &af9035_props
, "Afatech AF9035 reference design", NULL
) },
2080 { DVB_USB_DEVICE(USB_VID_AFATECH
, USB_PID_AFATECH_AF9035_1001
,
2081 &af9035_props
, "Afatech AF9035 reference design", NULL
) },
2082 { DVB_USB_DEVICE(USB_VID_AFATECH
, USB_PID_AFATECH_AF9035_1002
,
2083 &af9035_props
, "Afatech AF9035 reference design", NULL
) },
2084 { DVB_USB_DEVICE(USB_VID_AFATECH
, USB_PID_AFATECH_AF9035_1003
,
2085 &af9035_props
, "Afatech AF9035 reference design", NULL
) },
2086 { DVB_USB_DEVICE(USB_VID_TERRATEC
, USB_PID_TERRATEC_CINERGY_T_STICK
,
2087 &af9035_props
, "TerraTec Cinergy T Stick", NULL
) },
2088 { DVB_USB_DEVICE(USB_VID_AVERMEDIA
, USB_PID_AVERMEDIA_A835
,
2089 &af9035_props
, "AVerMedia AVerTV Volar HD/PRO (A835)", NULL
) },
2090 { DVB_USB_DEVICE(USB_VID_AVERMEDIA
, USB_PID_AVERMEDIA_B835
,
2091 &af9035_props
, "AVerMedia AVerTV Volar HD/PRO (A835)", NULL
) },
2092 { DVB_USB_DEVICE(USB_VID_AVERMEDIA
, USB_PID_AVERMEDIA_1867
,
2093 &af9035_props
, "AVerMedia HD Volar (A867)", NULL
) },
2094 { DVB_USB_DEVICE(USB_VID_AVERMEDIA
, USB_PID_AVERMEDIA_A867
,
2095 &af9035_props
, "AVerMedia HD Volar (A867)", NULL
) },
2096 { DVB_USB_DEVICE(USB_VID_AVERMEDIA
, USB_PID_AVERMEDIA_TWINSTAR
,
2097 &af9035_props
, "AVerMedia Twinstar (A825)", NULL
) },
2098 { DVB_USB_DEVICE(USB_VID_ASUS
, USB_PID_ASUS_U3100MINI_PLUS
,
2099 &af9035_props
, "Asus U3100Mini Plus", NULL
) },
2100 { DVB_USB_DEVICE(USB_VID_TERRATEC
, 0x00aa,
2101 &af9035_props
, "TerraTec Cinergy T Stick (rev. 2)", NULL
) },
2102 { DVB_USB_DEVICE(USB_VID_AVERMEDIA
, 0x0337,
2103 &af9035_props
, "AVerMedia HD Volar (A867)", NULL
) },
2104 { DVB_USB_DEVICE(USB_VID_GTEK
, USB_PID_EVOLVEO_XTRATV_STICK
,
2105 &af9035_props
, "EVOLVEO XtraTV stick", NULL
) },
2107 /* IT9135 devices */
2108 { DVB_USB_DEVICE(USB_VID_ITETECH
, USB_PID_ITETECH_IT9135
,
2109 &af9035_props
, "ITE 9135 Generic", RC_MAP_IT913X_V1
) },
2110 { DVB_USB_DEVICE(USB_VID_ITETECH
, USB_PID_ITETECH_IT9135_9005
,
2111 &af9035_props
, "ITE 9135(9005) Generic", RC_MAP_IT913X_V2
) },
2112 { DVB_USB_DEVICE(USB_VID_ITETECH
, USB_PID_ITETECH_IT9135_9006
,
2113 &af9035_props
, "ITE 9135(9006) Generic", RC_MAP_IT913X_V1
) },
2114 { DVB_USB_DEVICE(USB_VID_AVERMEDIA
, USB_PID_AVERMEDIA_A835B_1835
,
2115 &af9035_props
, "Avermedia A835B(1835)", RC_MAP_IT913X_V2
) },
2116 { DVB_USB_DEVICE(USB_VID_AVERMEDIA
, USB_PID_AVERMEDIA_A835B_2835
,
2117 &af9035_props
, "Avermedia A835B(2835)", RC_MAP_IT913X_V2
) },
2118 { DVB_USB_DEVICE(USB_VID_AVERMEDIA
, USB_PID_AVERMEDIA_A835B_3835
,
2119 &af9035_props
, "Avermedia A835B(3835)", RC_MAP_IT913X_V2
) },
2120 { DVB_USB_DEVICE(USB_VID_AVERMEDIA
, USB_PID_AVERMEDIA_A835B_4835
,
2121 &af9035_props
, "Avermedia A835B(4835)", RC_MAP_IT913X_V2
) },
2122 { DVB_USB_DEVICE(USB_VID_AVERMEDIA
, USB_PID_AVERMEDIA_TD110
,
2123 &af9035_props
, "Avermedia AverTV Volar HD 2 (TD110)", RC_MAP_AVERMEDIA_RM_KS
) },
2124 { DVB_USB_DEVICE(USB_VID_AVERMEDIA
, USB_PID_AVERMEDIA_H335
,
2125 &af9035_props
, "Avermedia H335", RC_MAP_IT913X_V2
) },
2126 { DVB_USB_DEVICE(USB_VID_KWORLD_2
, USB_PID_KWORLD_UB499_2T_T09
,
2127 &af9035_props
, "Kworld UB499-2T T09", RC_MAP_IT913X_V1
) },
2128 { DVB_USB_DEVICE(USB_VID_KWORLD_2
, USB_PID_SVEON_STV22_IT9137
,
2129 &af9035_props
, "Sveon STV22 Dual DVB-T HDTV",
2130 RC_MAP_IT913X_V1
) },
2131 { DVB_USB_DEVICE(USB_VID_KWORLD_2
, USB_PID_CTVDIGDUAL_V2
,
2132 &af9035_props
, "Digital Dual TV Receiver CTVDIGDUAL_V2",
2133 RC_MAP_IT913X_V1
) },
2134 { DVB_USB_DEVICE(USB_VID_TERRATEC
, USB_PID_TERRATEC_T1
,
2135 &af9035_props
, "TerraTec T1", RC_MAP_IT913X_V1
) },
2136 /* XXX: that same ID [0ccd:0099] is used by af9015 driver too */
2137 { DVB_USB_DEVICE(USB_VID_TERRATEC
, 0x0099,
2138 &af9035_props
, "TerraTec Cinergy T Stick Dual RC (rev. 2)",
2140 { DVB_USB_DEVICE(USB_VID_LEADTEK
, 0x6a05,
2141 &af9035_props
, "Leadtek WinFast DTV Dongle Dual", NULL
) },
2142 { DVB_USB_DEVICE(USB_VID_HAUPPAUGE
, 0xf900,
2143 &af9035_props
, "Hauppauge WinTV-MiniStick 2", NULL
) },
2144 { DVB_USB_DEVICE(USB_VID_PCTV
, USB_PID_PCTV_78E
,
2145 &af9035_props
, "PCTV AndroiDTV (78e)", RC_MAP_IT913X_V1
) },
2146 { DVB_USB_DEVICE(USB_VID_PCTV
, USB_PID_PCTV_79E
,
2147 &af9035_props
, "PCTV microStick (79e)", RC_MAP_IT913X_V2
) },
2149 /* IT930x devices */
2150 { DVB_USB_DEVICE(USB_VID_ITETECH
, USB_PID_ITETECH_IT9303
,
2151 &it930x_props
, "ITE 9303 Generic", NULL
) },
2152 { DVB_USB_DEVICE(USB_VID_AVERMEDIA
, USB_PID_AVERMEDIA_TD310
,
2153 &it930x_props
, "AVerMedia TD310 DVB-T2", NULL
) },
2154 { DVB_USB_DEVICE(USB_VID_DEXATEK
, 0x0100,
2155 &it930x_props
, "Logilink VG0022A", NULL
) },
2156 { DVB_USB_DEVICE(USB_VID_TERRATEC
, USB_PID_TERRATEC_CINERGY_TC2_STICK
,
2157 &it930x_props
, "TerraTec Cinergy TC2 Stick", NULL
) },
2160 MODULE_DEVICE_TABLE(usb
, af9035_id_table
);
2162 static struct usb_driver af9035_usb_driver
= {
2163 .name
= KBUILD_MODNAME
,
2164 .id_table
= af9035_id_table
,
2165 .probe
= af9035_probe
,
2166 .disconnect
= dvb_usbv2_disconnect
,
2167 .suspend
= dvb_usbv2_suspend
,
2168 .resume
= dvb_usbv2_resume
,
2169 .reset_resume
= dvb_usbv2_reset_resume
,
2174 module_usb_driver(af9035_usb_driver
);
2176 MODULE_AUTHOR("Antti Palosaari <crope@iki.fi>");
2177 MODULE_DESCRIPTION("Afatech AF9035 driver");
2178 MODULE_LICENSE("GPL");
2179 MODULE_FIRMWARE(AF9035_FIRMWARE_AF9035
);
2180 MODULE_FIRMWARE(AF9035_FIRMWARE_IT9135_V1
);
2181 MODULE_FIRMWARE(AF9035_FIRMWARE_IT9135_V2
);
2182 MODULE_FIRMWARE(AF9035_FIRMWARE_IT9303
);