Commit | Line | Data |
---|---|---|
80619de8 AP |
1 | /* |
2 | * DVB USB Linux driver for Afatech AF9015 DVB-T USB2.0 receiver | |
3 | * | |
4 | * Copyright (C) 2007 Antti Palosaari <crope@iki.fi> | |
5 | * | |
6 | * Thanks to Afatech who kindly provided information. | |
7 | * | |
8 | * This program is free software; you can redistribute it and/or modify | |
9 | * it under the terms of the GNU General Public License as published by | |
10 | * the Free Software Foundation; either version 2 of the License, or | |
11 | * (at your option) any later version. | |
12 | * | |
13 | * This program is distributed in the hope that it will be useful, | |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 | * GNU General Public License for more details. | |
17 | * | |
18 | * You should have received a copy of the GNU General Public License | |
19 | * along with this program; if not, write to the Free Software | |
20 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |
21 | * | |
22 | */ | |
23 | ||
24 | #include "af9015.h" | |
80619de8 | 25 | |
349d042f | 26 | static int dvb_usb_af9015_debug; |
80619de8 AP |
27 | module_param_named(debug, dvb_usb_af9015_debug, int, 0644); |
28 | MODULE_PARM_DESC(debug, "set debugging level" DVB_USB_DEBUG_STATUS); | |
349d042f | 29 | static int dvb_usb_af9015_remote; |
80619de8 AP |
30 | module_param_named(remote, dvb_usb_af9015_remote, int, 0644); |
31 | MODULE_PARM_DESC(remote, "select remote"); | |
80619de8 AP |
32 | DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); |
33 | ||
a3645e54 | 34 | static int af9015_ctrl_msg(struct dvb_usb_device *d, struct req_t *req) |
80619de8 | 35 | { |
06565d7a AP |
36 | #define BUF_LEN 63 |
37 | #define REQ_HDR_LEN 8 /* send header size */ | |
38 | #define ACK_HDR_LEN 2 /* rece header size */ | |
e8089661 | 39 | struct af9015_state *state = d_to_priv(d); |
a3645e54 | 40 | int ret, wlen, rlen; |
06565d7a | 41 | u8 buf[BUF_LEN]; |
80619de8 | 42 | u8 write = 1; |
80619de8 AP |
43 | |
44 | buf[0] = req->cmd; | |
a3645e54 | 45 | buf[1] = state->seq++; |
80619de8 AP |
46 | buf[2] = req->i2c_addr; |
47 | buf[3] = req->addr >> 8; | |
48 | buf[4] = req->addr & 0xff; | |
49 | buf[5] = req->mbox; | |
50 | buf[6] = req->addr_len; | |
51 | buf[7] = req->data_len; | |
52 | ||
53 | switch (req->cmd) { | |
54 | case GET_CONFIG: | |
80619de8 AP |
55 | case READ_MEMORY: |
56 | case RECONNECT_USB: | |
80619de8 AP |
57 | write = 0; |
58 | break; | |
59 | case READ_I2C: | |
60 | write = 0; | |
61 | buf[2] |= 0x01; /* set I2C direction */ | |
62 | case WRITE_I2C: | |
63 | buf[0] = READ_WRITE_I2C; | |
64 | break; | |
65 | case WRITE_MEMORY: | |
66 | if (((req->addr & 0xff00) == 0xff00) || | |
f4e96deb | 67 | ((req->addr & 0xff00) == 0xae00)) |
80619de8 AP |
68 | buf[0] = WRITE_VIRTUAL_MEMORY; |
69 | case WRITE_VIRTUAL_MEMORY: | |
70 | case COPY_FIRMWARE: | |
71 | case DOWNLOAD_FIRMWARE: | |
ba1bc642 | 72 | case BOOT: |
80619de8 AP |
73 | break; |
74 | default: | |
75 | err("unknown command:%d", req->cmd); | |
76 | ret = -1; | |
a3645e54 | 77 | goto error; |
80619de8 AP |
78 | } |
79 | ||
06565d7a AP |
80 | /* buffer overflow check */ |
81 | if ((write && (req->data_len > BUF_LEN - REQ_HDR_LEN)) || | |
82 | (!write && (req->data_len > BUF_LEN - ACK_HDR_LEN))) { | |
83 | err("too much data; cmd:%d len:%d", req->cmd, req->data_len); | |
84 | ret = -EINVAL; | |
a3645e54 | 85 | goto error; |
06565d7a AP |
86 | } |
87 | ||
a3645e54 AP |
88 | /* write receives seq + status = 2 bytes |
89 | read receives seq + status + data = 2 + N bytes */ | |
90 | wlen = REQ_HDR_LEN; | |
91 | rlen = ACK_HDR_LEN; | |
80619de8 | 92 | if (write) { |
a3645e54 | 93 | wlen += req->data_len; |
06565d7a | 94 | memcpy(&buf[REQ_HDR_LEN], req->data, req->data_len); |
a3645e54 AP |
95 | } else { |
96 | rlen += req->data_len; | |
80619de8 | 97 | } |
06565d7a | 98 | |
a3645e54 | 99 | /* no ack for these packets */ |
80619de8 | 100 | if (req->cmd == DOWNLOAD_FIRMWARE || req->cmd == RECONNECT_USB) |
a3645e54 | 101 | rlen = 0; |
80619de8 | 102 | |
1162c7b3 | 103 | ret = dvb_usbv2_generic_rw(d, buf, wlen, buf, rlen); |
a3645e54 AP |
104 | if (ret) |
105 | goto error; | |
80619de8 | 106 | |
80619de8 | 107 | /* check status */ |
a3645e54 | 108 | if (rlen && buf[1]) { |
80619de8 AP |
109 | err("command failed:%d", buf[1]); |
110 | ret = -1; | |
a3645e54 | 111 | goto error; |
80619de8 AP |
112 | } |
113 | ||
114 | /* read request, copy returned data to return buf */ | |
115 | if (!write) | |
06565d7a | 116 | memcpy(req->data, &buf[ACK_HDR_LEN], req->data_len); |
a3645e54 | 117 | error: |
80619de8 AP |
118 | return ret; |
119 | } | |
120 | ||
80619de8 AP |
121 | static int af9015_write_regs(struct dvb_usb_device *d, u16 addr, u8 *val, |
122 | u8 len) | |
123 | { | |
124 | struct req_t req = {WRITE_MEMORY, AF9015_I2C_DEMOD, addr, 0, 0, len, | |
125 | val}; | |
126 | return af9015_ctrl_msg(d, &req); | |
127 | } | |
128 | ||
74c8e3ad | 129 | static int af9015_read_regs(struct dvb_usb_device *d, u16 addr, u8 *val, u8 len) |
80619de8 | 130 | { |
74c8e3ad AP |
131 | struct req_t req = {READ_MEMORY, AF9015_I2C_DEMOD, addr, 0, 0, len, |
132 | val}; | |
80619de8 AP |
133 | return af9015_ctrl_msg(d, &req); |
134 | } | |
135 | ||
a3645e54 AP |
136 | static int af9015_write_reg(struct dvb_usb_device *d, u16 addr, u8 val) |
137 | { | |
138 | return af9015_write_regs(d, addr, &val, 1); | |
139 | } | |
140 | ||
74c8e3ad AP |
141 | static int af9015_read_reg(struct dvb_usb_device *d, u16 addr, u8 *val) |
142 | { | |
143 | return af9015_read_regs(d, addr, val, 1); | |
144 | } | |
145 | ||
80619de8 AP |
146 | static int af9015_write_reg_i2c(struct dvb_usb_device *d, u8 addr, u16 reg, |
147 | u8 val) | |
148 | { | |
e8089661 | 149 | struct af9015_state *state = d_to_priv(d); |
80619de8 AP |
150 | struct req_t req = {WRITE_I2C, addr, reg, 1, 1, 1, &val}; |
151 | ||
a3645e54 AP |
152 | if (addr == state->af9013_config[0].i2c_addr || |
153 | addr == state->af9013_config[1].i2c_addr) | |
80619de8 AP |
154 | req.addr_len = 3; |
155 | ||
156 | return af9015_ctrl_msg(d, &req); | |
157 | } | |
158 | ||
159 | static int af9015_read_reg_i2c(struct dvb_usb_device *d, u8 addr, u16 reg, | |
160 | u8 *val) | |
161 | { | |
e8089661 | 162 | struct af9015_state *state = d_to_priv(d); |
80619de8 AP |
163 | struct req_t req = {READ_I2C, addr, reg, 0, 1, 1, val}; |
164 | ||
a3645e54 AP |
165 | if (addr == state->af9013_config[0].i2c_addr || |
166 | addr == state->af9013_config[1].i2c_addr) | |
80619de8 AP |
167 | req.addr_len = 3; |
168 | ||
169 | return af9015_ctrl_msg(d, &req); | |
170 | } | |
171 | ||
a3645e54 AP |
172 | static int af9015_do_reg_bit(struct dvb_usb_device *d, u16 addr, u8 bit, u8 op) |
173 | { | |
174 | int ret; | |
175 | u8 val, mask = 0x01; | |
176 | ||
177 | ret = af9015_read_reg(d, addr, &val); | |
178 | if (ret) | |
179 | return ret; | |
180 | ||
181 | mask <<= bit; | |
182 | if (op) { | |
183 | /* set bit */ | |
184 | val |= mask; | |
185 | } else { | |
186 | /* clear bit */ | |
187 | mask ^= 0xff; | |
188 | val &= mask; | |
189 | } | |
190 | ||
191 | return af9015_write_reg(d, addr, val); | |
192 | } | |
193 | ||
194 | static int af9015_set_reg_bit(struct dvb_usb_device *d, u16 addr, u8 bit) | |
195 | { | |
196 | return af9015_do_reg_bit(d, addr, bit, 1); | |
197 | } | |
198 | ||
199 | static int af9015_clear_reg_bit(struct dvb_usb_device *d, u16 addr, u8 bit) | |
200 | { | |
201 | return af9015_do_reg_bit(d, addr, bit, 0); | |
202 | } | |
203 | ||
80619de8 AP |
204 | static int af9015_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[], |
205 | int num) | |
206 | { | |
207 | struct dvb_usb_device *d = i2c_get_adapdata(adap); | |
e8089661 | 208 | struct af9015_state *state = d_to_priv(d); |
80619de8 AP |
209 | int ret = 0, i = 0; |
210 | u16 addr; | |
675375d7 | 211 | u8 uninitialized_var(mbox), addr_len; |
80619de8 AP |
212 | struct req_t req; |
213 | ||
bc050e67 | 214 | /* |
80619de8 AP |
215 | The bus lock is needed because there is two tuners both using same I2C-address. |
216 | Due to that the only way to select correct tuner is use demodulator I2C-gate. | |
217 | ||
218 | ................................................ | |
219 | . AF9015 includes integrated AF9013 demodulator. | |
220 | . ____________ ____________ . ____________ | |
221 | .| uC | | demod | . | tuner | | |
222 | .|------------| |------------| . |------------| | |
223 | .| AF9015 | | AF9013/5 | . | MXL5003 | | |
224 | .| |--+----I2C-------|-----/ -----|-.-----I2C-------| | | |
225 | .| | | | addr 0x38 | . | addr 0xc6 | | |
226 | .|____________| | |____________| . |____________| | |
227 | .................|.............................. | |
228 | | ____________ ____________ | |
229 | | | demod | | tuner | | |
230 | | |------------| |------------| | |
231 | | | AF9013 | | MXL5003 | | |
232 | +----I2C-------|-----/ -----|-------I2C-------| | | |
233 | | addr 0x3a | | addr 0xc6 | | |
234 | |____________| |____________| | |
235 | */ | |
236 | if (mutex_lock_interruptible(&d->i2c_mutex) < 0) | |
237 | return -EAGAIN; | |
238 | ||
239 | while (i < num) { | |
a3645e54 AP |
240 | if (msg[i].addr == state->af9013_config[0].i2c_addr || |
241 | msg[i].addr == state->af9013_config[1].i2c_addr) { | |
80619de8 AP |
242 | addr = msg[i].buf[0] << 8; |
243 | addr += msg[i].buf[1]; | |
244 | mbox = msg[i].buf[2]; | |
245 | addr_len = 3; | |
246 | } else { | |
247 | addr = msg[i].buf[0]; | |
248 | addr_len = 1; | |
675375d7 | 249 | /* mbox is don't care in that case */ |
80619de8 AP |
250 | } |
251 | ||
252 | if (num > i + 1 && (msg[i+1].flags & I2C_M_RD)) { | |
709d9208 AP |
253 | if (msg[i].len > 3 || msg[i+1].len > 61) { |
254 | ret = -EOPNOTSUPP; | |
255 | goto error; | |
256 | } | |
a3645e54 | 257 | if (msg[i].addr == state->af9013_config[0].i2c_addr) |
80619de8 AP |
258 | req.cmd = READ_MEMORY; |
259 | else | |
260 | req.cmd = READ_I2C; | |
261 | req.i2c_addr = msg[i].addr; | |
262 | req.addr = addr; | |
263 | req.mbox = mbox; | |
264 | req.addr_len = addr_len; | |
265 | req.data_len = msg[i+1].len; | |
266 | req.data = &msg[i+1].buf[0]; | |
267 | ret = af9015_ctrl_msg(d, &req); | |
268 | i += 2; | |
d5633998 | 269 | } else if (msg[i].flags & I2C_M_RD) { |
709d9208 AP |
270 | if (msg[i].len > 61) { |
271 | ret = -EOPNOTSUPP; | |
272 | goto error; | |
273 | } | |
a3645e54 | 274 | if (msg[i].addr == state->af9013_config[0].i2c_addr) { |
16b2dc2a | 275 | ret = -EINVAL; |
d5633998 | 276 | goto error; |
16b2dc2a AP |
277 | } |
278 | req.cmd = READ_I2C; | |
d5633998 JF |
279 | req.i2c_addr = msg[i].addr; |
280 | req.addr = addr; | |
281 | req.mbox = mbox; | |
282 | req.addr_len = addr_len; | |
283 | req.data_len = msg[i].len; | |
284 | req.data = &msg[i].buf[0]; | |
285 | ret = af9015_ctrl_msg(d, &req); | |
286 | i += 1; | |
80619de8 | 287 | } else { |
709d9208 AP |
288 | if (msg[i].len > 21) { |
289 | ret = -EOPNOTSUPP; | |
290 | goto error; | |
291 | } | |
a3645e54 | 292 | if (msg[i].addr == state->af9013_config[0].i2c_addr) |
80619de8 AP |
293 | req.cmd = WRITE_MEMORY; |
294 | else | |
295 | req.cmd = WRITE_I2C; | |
296 | req.i2c_addr = msg[i].addr; | |
297 | req.addr = addr; | |
298 | req.mbox = mbox; | |
299 | req.addr_len = addr_len; | |
300 | req.data_len = msg[i].len-addr_len; | |
301 | req.data = &msg[i].buf[addr_len]; | |
302 | ret = af9015_ctrl_msg(d, &req); | |
303 | i += 1; | |
304 | } | |
305 | if (ret) | |
306 | goto error; | |
307 | ||
308 | } | |
309 | ret = i; | |
310 | ||
311 | error: | |
312 | mutex_unlock(&d->i2c_mutex); | |
313 | ||
314 | return ret; | |
315 | } | |
316 | ||
317 | static u32 af9015_i2c_func(struct i2c_adapter *adapter) | |
318 | { | |
319 | return I2C_FUNC_I2C; | |
320 | } | |
321 | ||
322 | static struct i2c_algorithm af9015_i2c_algo = { | |
323 | .master_xfer = af9015_i2c_xfer, | |
324 | .functionality = af9015_i2c_func, | |
325 | }; | |
326 | ||
a0921af7 | 327 | static int af9015_identify_state(struct dvb_usb_device *d, const char **name) |
80619de8 AP |
328 | { |
329 | int ret; | |
a3645e54 AP |
330 | u8 reply; |
331 | struct req_t req = {GET_CONFIG, 0, 0, 0, 0, 1, &reply}; | |
80619de8 | 332 | |
a3645e54 | 333 | ret = af9015_ctrl_msg(d, &req); |
80619de8 AP |
334 | if (ret) |
335 | return ret; | |
336 | ||
a3645e54 AP |
337 | deb_info("%s: reply:%02x\n", __func__, reply); |
338 | if (reply == 0x02) | |
339 | ret = WARM; | |
340 | else | |
341 | ret = COLD; | |
80619de8 | 342 | |
a3645e54 | 343 | return ret; |
80619de8 AP |
344 | } |
345 | ||
a3645e54 AP |
346 | static int af9015_download_firmware(struct dvb_usb_device *d, |
347 | const struct firmware *fw) | |
80619de8 | 348 | { |
e8089661 | 349 | struct af9015_state *state = d_to_priv(d); |
a3645e54 AP |
350 | int i, len, remaining, ret; |
351 | struct req_t req = {DOWNLOAD_FIRMWARE, 0, 0, 0, 0, 0, NULL}; | |
352 | u16 checksum = 0; | |
80619de8 | 353 | |
a3645e54 | 354 | deb_info("%s:\n", __func__); |
80619de8 | 355 | |
a3645e54 AP |
356 | /* calc checksum */ |
357 | for (i = 0; i < fw->size; i++) | |
358 | checksum += fw->data[i]; | |
80619de8 | 359 | |
a3645e54 AP |
360 | state->firmware_size = fw->size; |
361 | state->firmware_checksum = checksum; | |
80619de8 | 362 | |
a3645e54 AP |
363 | #define FW_ADDR 0x5100 /* firmware start address */ |
364 | #define LEN_MAX 55 /* max packet size */ | |
365 | for (remaining = fw->size; remaining > 0; remaining -= LEN_MAX) { | |
366 | len = remaining; | |
367 | if (len > LEN_MAX) | |
368 | len = LEN_MAX; | |
80619de8 | 369 | |
a3645e54 AP |
370 | req.data_len = len; |
371 | req.data = (u8 *) &fw->data[fw->size - remaining]; | |
372 | req.addr = FW_ADDR + fw->size - remaining; | |
80619de8 | 373 | |
a3645e54 AP |
374 | ret = af9015_ctrl_msg(d, &req); |
375 | if (ret) { | |
376 | err("firmware download failed:%d", ret); | |
377 | goto error; | |
378 | } | |
80619de8 AP |
379 | } |
380 | ||
a3645e54 AP |
381 | /* firmware loaded, request boot */ |
382 | req.cmd = BOOT; | |
383 | req.data_len = 0; | |
384 | ret = af9015_ctrl_msg(d, &req); | |
385 | if (ret) { | |
386 | err("firmware boot failed:%d", ret); | |
80619de8 | 387 | goto error; |
80619de8 | 388 | } |
a3645e54 AP |
389 | |
390 | error: | |
391 | return ret; | |
392 | } | |
393 | ||
394 | /* hash (and dump) eeprom */ | |
395 | static int af9015_eeprom_hash(struct dvb_usb_device *d) | |
396 | { | |
e8089661 | 397 | struct af9015_state *state = d_to_priv(d); |
a3645e54 AP |
398 | int ret; |
399 | static const unsigned int eeprom_size = 256; | |
400 | unsigned int reg; | |
401 | u8 val, *eeprom; | |
402 | struct req_t req = {READ_I2C, AF9015_I2C_EEPROM, 0, 0, 1, 1, &val}; | |
403 | ||
404 | eeprom = kmalloc(eeprom_size, GFP_KERNEL); | |
405 | if (eeprom == NULL) | |
406 | return -ENOMEM; | |
407 | ||
408 | for (reg = 0; reg < eeprom_size; reg++) { | |
409 | req.addr = reg; | |
410 | ret = af9015_ctrl_msg(d, &req); | |
80619de8 | 411 | if (ret) |
a3645e54 AP |
412 | goto free; |
413 | ||
414 | eeprom[reg] = val; | |
80619de8 | 415 | } |
a3645e54 AP |
416 | |
417 | if (dvb_usb_af9015_debug & 0x01) | |
418 | print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, eeprom, | |
419 | eeprom_size); | |
420 | ||
421 | BUG_ON(eeprom_size % 4); | |
422 | ||
423 | state->eeprom_sum = 0; | |
424 | for (reg = 0; reg < eeprom_size / sizeof(u32); reg++) { | |
425 | state->eeprom_sum *= GOLDEN_RATIO_PRIME_32; | |
426 | state->eeprom_sum += le32_to_cpu(((u32 *)eeprom)[reg]); | |
80619de8 AP |
427 | } |
428 | ||
a3645e54 | 429 | deb_info("%s: eeprom sum=%.8x\n", __func__, state->eeprom_sum); |
1e8750c2 | 430 | |
a3645e54 AP |
431 | ret = 0; |
432 | free: | |
433 | kfree(eeprom); | |
80619de8 AP |
434 | return ret; |
435 | } | |
436 | ||
a3645e54 | 437 | static int af9015_read_config(struct dvb_usb_device *d) |
80619de8 | 438 | { |
e8089661 | 439 | struct af9015_state *state = d_to_priv(d); |
80619de8 | 440 | int ret; |
a3645e54 AP |
441 | u8 val, i, offset = 0; |
442 | struct req_t req = {READ_I2C, AF9015_I2C_EEPROM, 0, 0, 1, 1, &val}; | |
80619de8 | 443 | |
a3645e54 | 444 | deb_info("%s:\n", __func__); |
80619de8 | 445 | |
a3645e54 AP |
446 | /* IR remote controller */ |
447 | req.addr = AF9015_EEPROM_IR_MODE; | |
448 | /* first message will timeout often due to possible hw bug */ | |
449 | for (i = 0; i < 4; i++) { | |
450 | ret = af9015_ctrl_msg(d, &req); | |
451 | if (!ret) | |
452 | break; | |
453 | } | |
454 | if (ret) | |
455 | goto error; | |
80619de8 | 456 | |
a3645e54 | 457 | ret = af9015_eeprom_hash(d); |
80619de8 AP |
458 | if (ret) |
459 | goto error; | |
80619de8 | 460 | |
a3645e54 AP |
461 | deb_info("%s: IR mode=%d\n", __func__, val); |
462 | state->ir_mode = val; | |
80619de8 | 463 | |
a3645e54 AP |
464 | /* TS mode - one or two receivers */ |
465 | req.addr = AF9015_EEPROM_TS_MODE; | |
80619de8 | 466 | ret = af9015_ctrl_msg(d, &req); |
80619de8 AP |
467 | if (ret) |
468 | goto error; | |
6c614044 | 469 | |
a3645e54 AP |
470 | state->dual_mode = val; |
471 | deb_info("%s: TS mode=%d\n", __func__, state->dual_mode); | |
6c614044 | 472 | |
a3645e54 AP |
473 | /* disable 2nd adapter because we don't have PID-filters */ |
474 | if (d->udev->speed == USB_SPEED_FULL) | |
475 | state->dual_mode = 0; | |
80619de8 | 476 | |
a3645e54 | 477 | if (state->dual_mode) { |
80619de8 AP |
478 | /* read 2nd demodulator I2C address */ |
479 | req.addr = AF9015_EEPROM_DEMOD2_I2C; | |
a3645e54 | 480 | ret = af9015_ctrl_msg(d, &req); |
80619de8 AP |
481 | if (ret) |
482 | goto error; | |
80619de8 | 483 | |
a3645e54 | 484 | state->af9013_config[1].i2c_addr = val; |
80619de8 AP |
485 | } |
486 | ||
a3645e54 | 487 | for (i = 0; i < state->dual_mode + 1; i++) { |
80619de8 AP |
488 | if (i == 1) |
489 | offset = AF9015_EEPROM_OFFSET; | |
490 | /* xtal */ | |
491 | req.addr = AF9015_EEPROM_XTAL_TYPE1 + offset; | |
a3645e54 | 492 | ret = af9015_ctrl_msg(d, &req); |
80619de8 AP |
493 | if (ret) |
494 | goto error; | |
495 | switch (val) { | |
496 | case 0: | |
a3645e54 | 497 | state->af9013_config[i].clock = 28800000; |
80619de8 AP |
498 | break; |
499 | case 1: | |
a3645e54 | 500 | state->af9013_config[i].clock = 20480000; |
80619de8 AP |
501 | break; |
502 | case 2: | |
a3645e54 | 503 | state->af9013_config[i].clock = 28000000; |
80619de8 AP |
504 | break; |
505 | case 3: | |
a3645e54 | 506 | state->af9013_config[i].clock = 25000000; |
80619de8 AP |
507 | break; |
508 | }; | |
f571e004 | 509 | deb_info("%s: [%d] xtal=%d set clock=%d\n", __func__, i, |
a3645e54 | 510 | val, state->af9013_config[i].clock); |
80619de8 | 511 | |
f571e004 | 512 | /* IF frequency */ |
80619de8 | 513 | req.addr = AF9015_EEPROM_IF1H + offset; |
a3645e54 | 514 | ret = af9015_ctrl_msg(d, &req); |
80619de8 AP |
515 | if (ret) |
516 | goto error; | |
f571e004 | 517 | |
a3645e54 | 518 | state->af9013_config[i].if_frequency = val << 8; |
f571e004 | 519 | |
80619de8 | 520 | req.addr = AF9015_EEPROM_IF1L + offset; |
a3645e54 | 521 | ret = af9015_ctrl_msg(d, &req); |
80619de8 AP |
522 | if (ret) |
523 | goto error; | |
f571e004 | 524 | |
a3645e54 AP |
525 | state->af9013_config[i].if_frequency += val; |
526 | state->af9013_config[i].if_frequency *= 1000; | |
f571e004 | 527 | deb_info("%s: [%d] IF frequency=%d\n", __func__, i, |
a3645e54 | 528 | state->af9013_config[i].if_frequency); |
80619de8 AP |
529 | |
530 | /* MT2060 IF1 */ | |
531 | req.addr = AF9015_EEPROM_MT2060_IF1H + offset; | |
a3645e54 | 532 | ret = af9015_ctrl_msg(d, &req); |
80619de8 AP |
533 | if (ret) |
534 | goto error; | |
a3645e54 | 535 | state->mt2060_if1[i] = val << 8; |
80619de8 | 536 | req.addr = AF9015_EEPROM_MT2060_IF1L + offset; |
a3645e54 | 537 | ret = af9015_ctrl_msg(d, &req); |
80619de8 AP |
538 | if (ret) |
539 | goto error; | |
a3645e54 | 540 | state->mt2060_if1[i] += val; |
f571e004 | 541 | deb_info("%s: [%d] MT2060 IF1=%d\n", __func__, i, |
a3645e54 | 542 | state->mt2060_if1[i]); |
80619de8 AP |
543 | |
544 | /* tuner */ | |
545 | req.addr = AF9015_EEPROM_TUNER_ID1 + offset; | |
a3645e54 | 546 | ret = af9015_ctrl_msg(d, &req); |
80619de8 AP |
547 | if (ret) |
548 | goto error; | |
549 | switch (val) { | |
550 | case AF9013_TUNER_ENV77H11D5: | |
551 | case AF9013_TUNER_MT2060: | |
80619de8 AP |
552 | case AF9013_TUNER_QT1010: |
553 | case AF9013_TUNER_UNKNOWN: | |
554 | case AF9013_TUNER_MT2060_2: | |
555 | case AF9013_TUNER_TDA18271: | |
556 | case AF9013_TUNER_QT1010A: | |
ee3d440c | 557 | case AF9013_TUNER_TDA18218: |
a3645e54 | 558 | state->af9013_config[i].spec_inv = 1; |
80619de8 AP |
559 | break; |
560 | case AF9013_TUNER_MXL5003D: | |
561 | case AF9013_TUNER_MXL5005D: | |
562 | case AF9013_TUNER_MXL5005R: | |
ab07fdd6 | 563 | case AF9013_TUNER_MXL5007T: |
a3645e54 | 564 | state->af9013_config[i].spec_inv = 0; |
80619de8 | 565 | break; |
d5633998 | 566 | case AF9013_TUNER_MC44S803: |
a3645e54 AP |
567 | state->af9013_config[i].gpio[1] = AF9013_GPIO_LO; |
568 | state->af9013_config[i].spec_inv = 1; | |
d5633998 | 569 | break; |
80619de8 | 570 | default: |
f571e004 | 571 | warn("tuner id=%d not supported, please report!", val); |
80619de8 AP |
572 | return -ENODEV; |
573 | }; | |
574 | ||
a3645e54 | 575 | state->af9013_config[i].tuner = val; |
f571e004 | 576 | deb_info("%s: [%d] tuner id=%d\n", __func__, i, val); |
80619de8 AP |
577 | } |
578 | ||
579 | error: | |
580 | if (ret) | |
f571e004 | 581 | err("eeprom read failed=%d", ret); |
80619de8 | 582 | |
3956fefc | 583 | /* AverMedia AVerTV Volar Black HD (A850) device have bad EEPROM |
8ccdf1ae YM |
584 | content :-( Override some wrong values here. Ditto for the |
585 | AVerTV Red HD+ (A850T) device. */ | |
a3645e54 AP |
586 | if (le16_to_cpu(d->udev->descriptor.idVendor) == USB_VID_AVERMEDIA && |
587 | ((le16_to_cpu(d->udev->descriptor.idProduct) == | |
9a3ecc73 | 588 | USB_PID_AVERMEDIA_A850) || |
a3645e54 | 589 | (le16_to_cpu(d->udev->descriptor.idProduct) == |
9a3ecc73 | 590 | USB_PID_AVERMEDIA_A850T))) { |
3956fefc AP |
591 | deb_info("%s: AverMedia A850: overriding config\n", __func__); |
592 | /* disable dual mode */ | |
a3645e54 | 593 | state->dual_mode = 0; |
3956fefc AP |
594 | |
595 | /* set correct IF */ | |
a3645e54 | 596 | state->af9013_config[0].if_frequency = 4570000; |
3956fefc AP |
597 | } |
598 | ||
80619de8 AP |
599 | return ret; |
600 | } | |
601 | ||
b905a2a1 | 602 | static int af9015_get_stream_config(struct dvb_frontend *fe, u8 *ts_type, |
a3645e54 | 603 | struct usb_data_stream_properties *stream) |
80619de8 | 604 | { |
e8089661 | 605 | deb_info("%s: adap=%d\n", __func__, fe_to_adap(fe)->id); |
d3bb73de | 606 | |
e8089661 | 607 | if (fe_to_d(fe)->udev->speed == USB_SPEED_FULL) |
a3645e54 | 608 | stream->u.bulk.buffersize = TS_USB11_FRAME_SIZE; |
1e8750c2 | 609 | |
a3645e54 AP |
610 | return 0; |
611 | } | |
d3bb73de | 612 | |
a3645e54 AP |
613 | static int af9015_get_adapter_count(struct dvb_usb_device *d) |
614 | { | |
e8089661 | 615 | struct af9015_state *state = d_to_priv(d); |
a3645e54 | 616 | return state->dual_mode + 1; |
80619de8 AP |
617 | } |
618 | ||
e90ab840 | 619 | /* override demod callbacks for resource locking */ |
0009e0e3 | 620 | static int af9015_af9013_set_frontend(struct dvb_frontend *fe) |
e90ab840 AP |
621 | { |
622 | int ret; | |
e8089661 | 623 | struct af9015_state *state = fe_to_priv(fe); |
e90ab840 | 624 | |
a3645e54 | 625 | if (mutex_lock_interruptible(&state->fe_mutex)) |
e90ab840 AP |
626 | return -EAGAIN; |
627 | ||
e8089661 | 628 | ret = state->set_frontend[fe_to_adap(fe)->id](fe); |
e90ab840 | 629 | |
a3645e54 | 630 | mutex_unlock(&state->fe_mutex); |
e90ab840 AP |
631 | |
632 | return ret; | |
633 | } | |
634 | ||
635 | /* override demod callbacks for resource locking */ | |
636 | static int af9015_af9013_read_status(struct dvb_frontend *fe, | |
637 | fe_status_t *status) | |
638 | { | |
639 | int ret; | |
e8089661 | 640 | struct af9015_state *state = fe_to_priv(fe); |
e90ab840 | 641 | |
a3645e54 | 642 | if (mutex_lock_interruptible(&state->fe_mutex)) |
e90ab840 AP |
643 | return -EAGAIN; |
644 | ||
e8089661 | 645 | ret = state->read_status[fe_to_adap(fe)->id](fe, status); |
e90ab840 | 646 | |
a3645e54 | 647 | mutex_unlock(&state->fe_mutex); |
e90ab840 AP |
648 | |
649 | return ret; | |
650 | } | |
651 | ||
652 | /* override demod callbacks for resource locking */ | |
653 | static int af9015_af9013_init(struct dvb_frontend *fe) | |
654 | { | |
655 | int ret; | |
e8089661 | 656 | struct af9015_state *state = fe_to_priv(fe); |
e90ab840 | 657 | |
a3645e54 | 658 | if (mutex_lock_interruptible(&state->fe_mutex)) |
e90ab840 AP |
659 | return -EAGAIN; |
660 | ||
e8089661 | 661 | ret = state->init[fe_to_adap(fe)->id](fe); |
e90ab840 | 662 | |
a3645e54 | 663 | mutex_unlock(&state->fe_mutex); |
e90ab840 AP |
664 | |
665 | return ret; | |
666 | } | |
667 | ||
668 | /* override demod callbacks for resource locking */ | |
669 | static int af9015_af9013_sleep(struct dvb_frontend *fe) | |
670 | { | |
671 | int ret; | |
e8089661 | 672 | struct af9015_state *state = fe_to_priv(fe); |
e90ab840 | 673 | |
a3645e54 | 674 | if (mutex_lock_interruptible(&state->fe_mutex)) |
e90ab840 AP |
675 | return -EAGAIN; |
676 | ||
e8089661 | 677 | ret = state->sleep[fe_to_adap(fe)->id](fe); |
e90ab840 | 678 | |
a3645e54 | 679 | mutex_unlock(&state->fe_mutex); |
e90ab840 AP |
680 | |
681 | return ret; | |
682 | } | |
683 | ||
6d535bd8 AP |
684 | /* override tuner callbacks for resource locking */ |
685 | static int af9015_tuner_init(struct dvb_frontend *fe) | |
686 | { | |
687 | int ret; | |
e8089661 | 688 | struct af9015_state *state = fe_to_priv(fe); |
6d535bd8 | 689 | |
a3645e54 | 690 | if (mutex_lock_interruptible(&state->fe_mutex)) |
6d535bd8 AP |
691 | return -EAGAIN; |
692 | ||
e8089661 | 693 | ret = state->tuner_init[fe_to_adap(fe)->id](fe); |
6d535bd8 | 694 | |
a3645e54 | 695 | mutex_unlock(&state->fe_mutex); |
6d535bd8 AP |
696 | |
697 | return ret; | |
698 | } | |
699 | ||
700 | /* override tuner callbacks for resource locking */ | |
701 | static int af9015_tuner_sleep(struct dvb_frontend *fe) | |
702 | { | |
703 | int ret; | |
e8089661 | 704 | struct af9015_state *state = fe_to_priv(fe); |
6d535bd8 | 705 | |
a3645e54 | 706 | if (mutex_lock_interruptible(&state->fe_mutex)) |
6d535bd8 AP |
707 | return -EAGAIN; |
708 | ||
e8089661 | 709 | ret = state->tuner_sleep[fe_to_adap(fe)->id](fe); |
a3645e54 AP |
710 | |
711 | mutex_unlock(&state->fe_mutex); | |
712 | ||
713 | return ret; | |
714 | } | |
715 | ||
716 | static int af9015_copy_firmware(struct dvb_usb_device *d) | |
717 | { | |
e8089661 | 718 | struct af9015_state *state = d_to_priv(d); |
a3645e54 AP |
719 | int ret; |
720 | u8 fw_params[4]; | |
721 | u8 val, i; | |
722 | struct req_t req = {COPY_FIRMWARE, 0, 0x5100, 0, 0, sizeof(fw_params), | |
723 | fw_params }; | |
724 | deb_info("%s:\n", __func__); | |
725 | ||
726 | fw_params[0] = state->firmware_size >> 8; | |
727 | fw_params[1] = state->firmware_size & 0xff; | |
728 | fw_params[2] = state->firmware_checksum >> 8; | |
729 | fw_params[3] = state->firmware_checksum & 0xff; | |
730 | ||
731 | /* wait 2nd demodulator ready */ | |
732 | msleep(100); | |
733 | ||
734 | ret = af9015_read_reg_i2c(d, state->af9013_config[1].i2c_addr, | |
735 | 0x98be, &val); | |
736 | if (ret) | |
737 | goto error; | |
738 | else | |
739 | deb_info("%s: firmware status:%02x\n", __func__, val); | |
740 | ||
741 | if (val == 0x0c) /* fw is running, no need for download */ | |
742 | goto exit; | |
743 | ||
744 | /* set I2C master clock to fast (to speed up firmware copy) */ | |
745 | ret = af9015_write_reg(d, 0xd416, 0x04); /* 0x04 * 400ns */ | |
746 | if (ret) | |
747 | goto error; | |
748 | ||
749 | msleep(50); | |
750 | ||
751 | /* copy firmware */ | |
752 | ret = af9015_ctrl_msg(d, &req); | |
753 | if (ret) | |
754 | err("firmware copy cmd failed:%d", ret); | |
755 | deb_info("%s: firmware copy done\n", __func__); | |
756 | ||
757 | /* set I2C master clock back to normal */ | |
758 | ret = af9015_write_reg(d, 0xd416, 0x14); /* 0x14 * 400ns */ | |
759 | if (ret) | |
760 | goto error; | |
761 | ||
762 | /* request boot firmware */ | |
763 | ret = af9015_write_reg_i2c(d, state->af9013_config[1].i2c_addr, | |
764 | 0xe205, 1); | |
765 | deb_info("%s: firmware boot cmd status:%d\n", __func__, ret); | |
766 | if (ret) | |
767 | goto error; | |
768 | ||
769 | for (i = 0; i < 15; i++) { | |
770 | msleep(100); | |
6d535bd8 | 771 | |
a3645e54 AP |
772 | /* check firmware status */ |
773 | ret = af9015_read_reg_i2c(d, state->af9013_config[1].i2c_addr, | |
774 | 0x98be, &val); | |
775 | deb_info("%s: firmware status cmd status:%d fw status:%02x\n", | |
776 | __func__, ret, val); | |
777 | if (ret) | |
778 | goto error; | |
6d535bd8 | 779 | |
a3645e54 AP |
780 | if (val == 0x0c || val == 0x04) /* success or fail */ |
781 | break; | |
782 | } | |
783 | ||
784 | if (val == 0x04) { | |
785 | err("firmware did not run"); | |
786 | ret = -1; | |
787 | } else if (val != 0x0c) { | |
788 | err("firmware boot timeout"); | |
789 | ret = -1; | |
790 | } | |
791 | ||
792 | error: | |
793 | exit: | |
6d535bd8 AP |
794 | return ret; |
795 | } | |
796 | ||
80619de8 AP |
797 | static int af9015_af9013_frontend_attach(struct dvb_usb_adapter *adap) |
798 | { | |
799 | int ret; | |
e8089661 | 800 | struct af9015_state *state = adap_to_priv(adap); |
80619de8 | 801 | |
a3645e54 AP |
802 | if (adap->id == 0) { |
803 | state->af9013_config[0].ts_mode = AF9013_TS_USB; | |
804 | memcpy(state->af9013_config[0].api_version, "\x0\x1\x9\x0", 4); | |
805 | state->af9013_config[0].gpio[0] = AF9013_GPIO_HI; | |
806 | state->af9013_config[0].gpio[3] = AF9013_GPIO_TUNER_ON; | |
807 | } else if (adap->id == 1) { | |
808 | state->af9013_config[1].ts_mode = AF9013_TS_SERIAL; | |
809 | memcpy(state->af9013_config[1].api_version, "\x0\x1\x9\x0", 4); | |
810 | state->af9013_config[1].gpio[0] = AF9013_GPIO_TUNER_ON; | |
811 | state->af9013_config[1].gpio[1] = AF9013_GPIO_LO; | |
812 | ||
80619de8 | 813 | /* copy firmware to 2nd demodulator */ |
a3645e54 | 814 | if (state->dual_mode) { |
e8089661 | 815 | ret = af9015_copy_firmware(adap_to_d(adap)); |
80619de8 AP |
816 | if (ret) { |
817 | err("firmware copy to 2nd frontend " \ | |
818 | "failed, will disable it"); | |
a3645e54 | 819 | state->dual_mode = 0; |
80619de8 AP |
820 | return -ENODEV; |
821 | } | |
822 | } else { | |
823 | return -ENODEV; | |
824 | } | |
825 | } | |
826 | ||
827 | /* attach demodulator */ | |
a3645e54 | 828 | adap->fe[0] = dvb_attach(af9013_attach, |
e8089661 | 829 | &state->af9013_config[adap->id], &adap_to_d(adap)->i2c_adap); |
80619de8 | 830 | |
e90ab840 AP |
831 | /* |
832 | * AF9015 firmware does not like if it gets interrupted by I2C adapter | |
833 | * request on some critical phases. During normal operation I2C adapter | |
834 | * is used only 2nd demodulator and tuner on dual tuner devices. | |
835 | * Override demodulator callbacks and use mutex for limit access to | |
836 | * those "critical" paths to keep AF9015 happy. | |
e90ab840 | 837 | */ |
a3645e54 | 838 | if (adap->fe[0]) { |
e90ab840 | 839 | state->set_frontend[adap->id] = |
a3645e54 AP |
840 | adap->fe[0]->ops.set_frontend; |
841 | adap->fe[0]->ops.set_frontend = | |
e90ab840 AP |
842 | af9015_af9013_set_frontend; |
843 | ||
844 | state->read_status[adap->id] = | |
a3645e54 AP |
845 | adap->fe[0]->ops.read_status; |
846 | adap->fe[0]->ops.read_status = | |
e90ab840 AP |
847 | af9015_af9013_read_status; |
848 | ||
a3645e54 AP |
849 | state->init[adap->id] = adap->fe[0]->ops.init; |
850 | adap->fe[0]->ops.init = af9015_af9013_init; | |
e90ab840 | 851 | |
a3645e54 AP |
852 | state->sleep[adap->id] = adap->fe[0]->ops.sleep; |
853 | adap->fe[0]->ops.sleep = af9015_af9013_sleep; | |
e90ab840 AP |
854 | } |
855 | ||
a3645e54 | 856 | return adap->fe[0] == NULL ? -ENODEV : 0; |
80619de8 AP |
857 | } |
858 | ||
859 | static struct mt2060_config af9015_mt2060_config = { | |
860 | .i2c_address = 0xc0, | |
861 | .clock_out = 0, | |
862 | }; | |
863 | ||
864 | static struct qt1010_config af9015_qt1010_config = { | |
865 | .i2c_address = 0xc4, | |
866 | }; | |
867 | ||
868 | static struct tda18271_config af9015_tda18271_config = { | |
869 | .gate = TDA18271_GATE_DIGITAL, | |
7655e594 | 870 | .small_i2c = TDA18271_16_BYTE_CHUNK_INIT, |
80619de8 AP |
871 | }; |
872 | ||
873 | static struct mxl5005s_config af9015_mxl5003_config = { | |
874 | .i2c_address = 0xc6, | |
875 | .if_freq = IF_FREQ_4570000HZ, | |
876 | .xtal_freq = CRYSTAL_FREQ_16000000HZ, | |
877 | .agc_mode = MXL_SINGLE_AGC, | |
878 | .tracking_filter = MXL_TF_DEFAULT, | |
a131077d | 879 | .rssi_enable = MXL_RSSI_ENABLE, |
80619de8 AP |
880 | .cap_select = MXL_CAP_SEL_ENABLE, |
881 | .div_out = MXL_DIV_OUT_4, | |
882 | .clock_out = MXL_CLOCK_OUT_DISABLE, | |
883 | .output_load = MXL5005S_IF_OUTPUT_LOAD_200_OHM, | |
884 | .top = MXL5005S_TOP_25P2, | |
885 | .mod_mode = MXL_DIGITAL_MODE, | |
886 | .if_mode = MXL_ZERO_IF, | |
887 | .AgcMasterByte = 0x00, | |
888 | }; | |
889 | ||
890 | static struct mxl5005s_config af9015_mxl5005_config = { | |
891 | .i2c_address = 0xc6, | |
892 | .if_freq = IF_FREQ_4570000HZ, | |
893 | .xtal_freq = CRYSTAL_FREQ_16000000HZ, | |
894 | .agc_mode = MXL_SINGLE_AGC, | |
895 | .tracking_filter = MXL_TF_OFF, | |
a131077d | 896 | .rssi_enable = MXL_RSSI_ENABLE, |
80619de8 AP |
897 | .cap_select = MXL_CAP_SEL_ENABLE, |
898 | .div_out = MXL_DIV_OUT_4, | |
899 | .clock_out = MXL_CLOCK_OUT_DISABLE, | |
900 | .output_load = MXL5005S_IF_OUTPUT_LOAD_200_OHM, | |
901 | .top = MXL5005S_TOP_25P2, | |
902 | .mod_mode = MXL_DIGITAL_MODE, | |
903 | .if_mode = MXL_ZERO_IF, | |
904 | .AgcMasterByte = 0x00, | |
905 | }; | |
906 | ||
d5633998 JF |
907 | static struct mc44s803_config af9015_mc44s803_config = { |
908 | .i2c_address = 0xc0, | |
909 | .dig_out = 1, | |
910 | }; | |
911 | ||
ee3d440c AP |
912 | static struct tda18218_config af9015_tda18218_config = { |
913 | .i2c_address = 0xc0, | |
914 | .i2c_wr_max = 21, /* max wr bytes AF9015 I2C adap can handle at once */ | |
915 | }; | |
916 | ||
ab07fdd6 AP |
917 | static struct mxl5007t_config af9015_mxl5007t_config = { |
918 | .xtal_freq_hz = MxL_XTAL_24_MHZ, | |
919 | .if_freq_hz = MxL_IF_4_57_MHZ, | |
920 | }; | |
921 | ||
80619de8 AP |
922 | static int af9015_tuner_attach(struct dvb_usb_adapter *adap) |
923 | { | |
e8089661 | 924 | struct af9015_state *state = adap_to_priv(adap); |
a3645e54 | 925 | int ret; |
9a3ecc73 | 926 | deb_info("%s:\n", __func__); |
80619de8 | 927 | |
a3645e54 | 928 | switch (state->af9013_config[adap->id].tuner) { |
80619de8 AP |
929 | case AF9013_TUNER_MT2060: |
930 | case AF9013_TUNER_MT2060_2: | |
a3645e54 | 931 | ret = dvb_attach(mt2060_attach, adap->fe[0], |
e8089661 | 932 | &adap_to_d(adap)->i2c_adap, &af9015_mt2060_config, |
a3645e54 | 933 | state->mt2060_if1[adap->id]) |
80619de8 AP |
934 | == NULL ? -ENODEV : 0; |
935 | break; | |
936 | case AF9013_TUNER_QT1010: | |
937 | case AF9013_TUNER_QT1010A: | |
a3645e54 | 938 | ret = dvb_attach(qt1010_attach, adap->fe[0], |
e8089661 | 939 | &adap_to_d(adap)->i2c_adap, |
80619de8 AP |
940 | &af9015_qt1010_config) == NULL ? -ENODEV : 0; |
941 | break; | |
942 | case AF9013_TUNER_TDA18271: | |
a3645e54 | 943 | ret = dvb_attach(tda18271_attach, adap->fe[0], 0xc0, |
e8089661 | 944 | &adap_to_d(adap)->i2c_adap, |
80619de8 AP |
945 | &af9015_tda18271_config) == NULL ? -ENODEV : 0; |
946 | break; | |
ee3d440c | 947 | case AF9013_TUNER_TDA18218: |
a3645e54 | 948 | ret = dvb_attach(tda18218_attach, adap->fe[0], |
e8089661 | 949 | &adap_to_d(adap)->i2c_adap, |
ee3d440c AP |
950 | &af9015_tda18218_config) == NULL ? -ENODEV : 0; |
951 | break; | |
80619de8 | 952 | case AF9013_TUNER_MXL5003D: |
a3645e54 | 953 | ret = dvb_attach(mxl5005s_attach, adap->fe[0], |
e8089661 | 954 | &adap_to_d(adap)->i2c_adap, |
80619de8 AP |
955 | &af9015_mxl5003_config) == NULL ? -ENODEV : 0; |
956 | break; | |
957 | case AF9013_TUNER_MXL5005D: | |
958 | case AF9013_TUNER_MXL5005R: | |
a3645e54 | 959 | ret = dvb_attach(mxl5005s_attach, adap->fe[0], |
e8089661 | 960 | &adap_to_d(adap)->i2c_adap, |
80619de8 AP |
961 | &af9015_mxl5005_config) == NULL ? -ENODEV : 0; |
962 | break; | |
963 | case AF9013_TUNER_ENV77H11D5: | |
a3645e54 | 964 | ret = dvb_attach(dvb_pll_attach, adap->fe[0], 0xc0, |
e8089661 | 965 | &adap_to_d(adap)->i2c_adap, |
80619de8 AP |
966 | DVB_PLL_TDA665X) == NULL ? -ENODEV : 0; |
967 | break; | |
968 | case AF9013_TUNER_MC44S803: | |
a3645e54 | 969 | ret = dvb_attach(mc44s803_attach, adap->fe[0], |
e8089661 | 970 | &adap_to_d(adap)->i2c_adap, |
d5633998 | 971 | &af9015_mc44s803_config) == NULL ? -ENODEV : 0; |
80619de8 | 972 | break; |
ab07fdd6 | 973 | case AF9013_TUNER_MXL5007T: |
a3645e54 | 974 | ret = dvb_attach(mxl5007t_attach, adap->fe[0], |
e8089661 | 975 | &adap_to_d(adap)->i2c_adap, |
ab07fdd6 AP |
976 | 0xc0, &af9015_mxl5007t_config) == NULL ? -ENODEV : 0; |
977 | break; | |
80619de8 AP |
978 | case AF9013_TUNER_UNKNOWN: |
979 | default: | |
980 | ret = -ENODEV; | |
981 | err("Unknown tuner id:%d", | |
a3645e54 | 982 | state->af9013_config[adap->id].tuner); |
80619de8 | 983 | } |
be4a5e7f | 984 | |
a3645e54 | 985 | if (adap->fe[0]->ops.tuner_ops.init) { |
6d535bd8 | 986 | state->tuner_init[adap->id] = |
a3645e54 AP |
987 | adap->fe[0]->ops.tuner_ops.init; |
988 | adap->fe[0]->ops.tuner_ops.init = af9015_tuner_init; | |
6d535bd8 AP |
989 | } |
990 | ||
a3645e54 | 991 | if (adap->fe[0]->ops.tuner_ops.sleep) { |
6d535bd8 | 992 | state->tuner_sleep[adap->id] = |
a3645e54 AP |
993 | adap->fe[0]->ops.tuner_ops.sleep; |
994 | adap->fe[0]->ops.tuner_ops.sleep = af9015_tuner_sleep; | |
995 | } | |
996 | ||
997 | return ret; | |
998 | } | |
999 | ||
1000 | static int af9015_pid_filter_ctrl(struct dvb_usb_adapter *adap, int onoff) | |
1001 | { | |
1002 | int ret; | |
1003 | deb_info("%s: onoff:%d\n", __func__, onoff); | |
1004 | ||
1005 | if (onoff) | |
e8089661 | 1006 | ret = af9015_set_reg_bit(adap_to_d(adap), 0xd503, 0); |
a3645e54 | 1007 | else |
e8089661 | 1008 | ret = af9015_clear_reg_bit(adap_to_d(adap), 0xd503, 0); |
a3645e54 AP |
1009 | |
1010 | return ret; | |
1011 | } | |
1012 | ||
1013 | static int af9015_pid_filter(struct dvb_usb_adapter *adap, int index, u16 pid, | |
1014 | int onoff) | |
1015 | { | |
1016 | int ret; | |
1017 | u8 idx; | |
1018 | ||
1019 | deb_info("%s: set pid filter, index %d, pid %x, onoff %d\n", | |
1020 | __func__, index, pid, onoff); | |
1021 | ||
e8089661 | 1022 | ret = af9015_write_reg(adap_to_d(adap), 0xd505, (pid & 0xff)); |
a3645e54 AP |
1023 | if (ret) |
1024 | goto error; | |
1025 | ||
e8089661 | 1026 | ret = af9015_write_reg(adap_to_d(adap), 0xd506, (pid >> 8)); |
a3645e54 AP |
1027 | if (ret) |
1028 | goto error; | |
1029 | ||
1030 | idx = ((index & 0x1f) | (1 << 5)); | |
e8089661 | 1031 | ret = af9015_write_reg(adap_to_d(adap), 0xd504, idx); |
a3645e54 AP |
1032 | |
1033 | error: | |
1034 | return ret; | |
1035 | } | |
1036 | ||
1037 | static int af9015_init_endpoint(struct dvb_usb_device *d) | |
1038 | { | |
e8089661 | 1039 | struct af9015_state *state = d_to_priv(d); |
a3645e54 AP |
1040 | int ret; |
1041 | u16 frame_size; | |
1042 | u8 packet_size; | |
1043 | deb_info("%s: USB speed:%d\n", __func__, d->udev->speed); | |
1044 | ||
1045 | if (d->udev->speed == USB_SPEED_FULL) { | |
1046 | frame_size = TS_USB11_FRAME_SIZE/4; | |
1047 | packet_size = TS_USB11_MAX_PACKET_SIZE/4; | |
1048 | } else { | |
1049 | frame_size = TS_USB20_FRAME_SIZE/4; | |
1050 | packet_size = TS_USB20_MAX_PACKET_SIZE/4; | |
1051 | } | |
1052 | ||
1053 | ret = af9015_set_reg_bit(d, 0xd507, 2); /* assert EP4 reset */ | |
1054 | if (ret) | |
1055 | goto error; | |
1056 | ret = af9015_set_reg_bit(d, 0xd50b, 1); /* assert EP5 reset */ | |
1057 | if (ret) | |
1058 | goto error; | |
1059 | ret = af9015_clear_reg_bit(d, 0xdd11, 5); /* disable EP4 */ | |
1060 | if (ret) | |
1061 | goto error; | |
1062 | ret = af9015_clear_reg_bit(d, 0xdd11, 6); /* disable EP5 */ | |
1063 | if (ret) | |
1064 | goto error; | |
1065 | ret = af9015_set_reg_bit(d, 0xdd11, 5); /* enable EP4 */ | |
1066 | if (ret) | |
1067 | goto error; | |
1068 | if (state->dual_mode) { | |
1069 | ret = af9015_set_reg_bit(d, 0xdd11, 6); /* enable EP5 */ | |
1070 | if (ret) | |
1071 | goto error; | |
1072 | } | |
1073 | ret = af9015_clear_reg_bit(d, 0xdd13, 5); /* disable EP4 NAK */ | |
1074 | if (ret) | |
1075 | goto error; | |
1076 | if (state->dual_mode) { | |
1077 | ret = af9015_clear_reg_bit(d, 0xdd13, 6); /* disable EP5 NAK */ | |
1078 | if (ret) | |
1079 | goto error; | |
1080 | } | |
1081 | /* EP4 xfer length */ | |
1082 | ret = af9015_write_reg(d, 0xdd88, frame_size & 0xff); | |
1083 | if (ret) | |
1084 | goto error; | |
1085 | ret = af9015_write_reg(d, 0xdd89, frame_size >> 8); | |
1086 | if (ret) | |
1087 | goto error; | |
1088 | /* EP5 xfer length */ | |
1089 | ret = af9015_write_reg(d, 0xdd8a, frame_size & 0xff); | |
1090 | if (ret) | |
1091 | goto error; | |
1092 | ret = af9015_write_reg(d, 0xdd8b, frame_size >> 8); | |
1093 | if (ret) | |
1094 | goto error; | |
1095 | ret = af9015_write_reg(d, 0xdd0c, packet_size); /* EP4 packet size */ | |
1096 | if (ret) | |
1097 | goto error; | |
1098 | ret = af9015_write_reg(d, 0xdd0d, packet_size); /* EP5 packet size */ | |
1099 | if (ret) | |
1100 | goto error; | |
1101 | ret = af9015_clear_reg_bit(d, 0xd507, 2); /* negate EP4 reset */ | |
1102 | if (ret) | |
1103 | goto error; | |
1104 | if (state->dual_mode) { | |
1105 | ret = af9015_clear_reg_bit(d, 0xd50b, 1); /* negate EP5 reset */ | |
1106 | if (ret) | |
1107 | goto error; | |
6d535bd8 | 1108 | } |
be4a5e7f | 1109 | |
a3645e54 AP |
1110 | /* enable / disable mp2if2 */ |
1111 | if (state->dual_mode) | |
1112 | ret = af9015_set_reg_bit(d, 0xd50b, 0); | |
1113 | else | |
1114 | ret = af9015_clear_reg_bit(d, 0xd50b, 0); | |
1115 | ||
1116 | error: | |
1117 | if (ret) | |
1118 | err("endpoint init failed:%d", ret); | |
1119 | return ret; | |
1120 | } | |
1121 | ||
1122 | static int af9015_init(struct dvb_usb_device *d) | |
1123 | { | |
e8089661 | 1124 | struct af9015_state *state = d_to_priv(d); |
a3645e54 AP |
1125 | int ret; |
1126 | deb_info("%s:\n", __func__); | |
1127 | ||
1128 | mutex_init(&state->fe_mutex); | |
1129 | ||
1130 | /* init RC canary */ | |
1131 | ret = af9015_write_reg(d, 0x98e9, 0xff); | |
1132 | if (ret) | |
1133 | goto error; | |
1134 | ||
1135 | ret = af9015_init_endpoint(d); | |
1136 | if (ret) | |
1137 | goto error; | |
1138 | ||
1139 | error: | |
80619de8 AP |
1140 | return ret; |
1141 | } | |
1142 | ||
a3645e54 AP |
1143 | struct af9015_rc_setup { |
1144 | unsigned int id; | |
1145 | char *rc_codes; | |
d07b901f JN |
1146 | }; |
1147 | ||
a3645e54 AP |
1148 | static char *af9015_rc_setup_match(unsigned int id, |
1149 | const struct af9015_rc_setup *table) | |
1150 | { | |
1151 | for (; table->rc_codes; table++) | |
1152 | if (table->id == id) | |
1153 | return table->rc_codes; | |
1154 | return NULL; | |
1155 | } | |
1156 | ||
1157 | static const struct af9015_rc_setup af9015_rc_setup_modparam[] = { | |
1158 | { AF9015_REMOTE_A_LINK_DTU_M, RC_MAP_ALINK_DTU_M }, | |
1159 | { AF9015_REMOTE_MSI_DIGIVOX_MINI_II_V3, RC_MAP_MSI_DIGIVOX_II }, | |
1160 | { AF9015_REMOTE_MYGICTV_U718, RC_MAP_TOTAL_MEDIA_IN_HAND }, | |
1161 | { AF9015_REMOTE_DIGITTRADE_DVB_T, RC_MAP_DIGITTRADE }, | |
1162 | { AF9015_REMOTE_AVERMEDIA_KS, RC_MAP_AVERMEDIA_RM_KS }, | |
d07b901f | 1163 | { } |
80619de8 | 1164 | }; |
80619de8 | 1165 | |
a3645e54 AP |
1166 | static const struct af9015_rc_setup af9015_rc_setup_hashes[] = { |
1167 | { 0xb8feb708, RC_MAP_MSI_DIGIVOX_II }, | |
1168 | { 0xa3703d00, RC_MAP_ALINK_DTU_M }, | |
1169 | { 0x9b7dc64e, RC_MAP_TOTAL_MEDIA_IN_HAND }, /* MYGICTV U718 */ | |
1170 | { 0x5d49e3db, RC_MAP_DIGITTRADE }, /* LC-Power LC-USB-DVBT */ | |
1171 | { } | |
1172 | }; | |
80619de8 | 1173 | |
a3645e54 AP |
1174 | static int af9015_rc_query(struct dvb_usb_device *d) |
1175 | { | |
e8089661 | 1176 | struct af9015_state *state = d_to_priv(d); |
a3645e54 AP |
1177 | int ret; |
1178 | u8 buf[17]; | |
80619de8 | 1179 | |
a3645e54 | 1180 | deb_info("%s:\n", __func__); |
80619de8 | 1181 | |
a3645e54 AP |
1182 | /* read registers needed to detect remote controller code */ |
1183 | ret = af9015_read_regs(d, 0x98d9, buf, sizeof(buf)); | |
1184 | if (ret) | |
1185 | goto error; | |
80619de8 | 1186 | |
a3645e54 AP |
1187 | /* If any of these are non-zero, assume invalid data */ |
1188 | if (buf[1] || buf[2] || buf[3]) | |
1189 | return ret; | |
80619de8 | 1190 | |
a3645e54 AP |
1191 | /* Check for repeat of previous code */ |
1192 | if ((state->rc_repeat != buf[6] || buf[0]) && | |
1193 | !memcmp(&buf[12], state->rc_last, 4)) { | |
1194 | deb_rc("%s: key repeated\n", __func__); | |
1195 | rc_keydown(d->rc_dev, state->rc_keycode, 0); | |
1196 | state->rc_repeat = buf[6]; | |
1197 | return ret; | |
1198 | } | |
85d7d7ca | 1199 | |
a3645e54 AP |
1200 | /* Only process key if canary killed */ |
1201 | if (buf[16] != 0xff && buf[0] != 0x01) { | |
1d16e6d3 | 1202 | deb_rc("%s: key pressed %*ph\n", __func__, 4, buf + 12); |
85d7d7ca | 1203 | |
a3645e54 AP |
1204 | /* Reset the canary */ |
1205 | ret = af9015_write_reg(d, 0x98e9, 0xff); | |
1206 | if (ret) | |
1207 | goto error; | |
85d7d7ca | 1208 | |
a3645e54 AP |
1209 | /* Remember this key */ |
1210 | memcpy(state->rc_last, &buf[12], 4); | |
1211 | if (buf[14] == (u8) ~buf[15]) { | |
1212 | if (buf[12] == (u8) ~buf[13]) { | |
1213 | /* NEC */ | |
1214 | state->rc_keycode = buf[12] << 8 | buf[14]; | |
1215 | } else { | |
1216 | /* NEC extended*/ | |
1217 | state->rc_keycode = buf[12] << 16 | | |
1218 | buf[13] << 8 | buf[14]; | |
1219 | } | |
1220 | } else { | |
1221 | /* 32 bit NEC */ | |
1222 | state->rc_keycode = buf[12] << 24 | buf[13] << 16 | | |
1223 | buf[14] << 8 | buf[15]; | |
85d7d7ca | 1224 | } |
a3645e54 AP |
1225 | rc_keydown(d->rc_dev, state->rc_keycode, 0); |
1226 | } else { | |
1227 | deb_rc("%s: no key press\n", __func__); | |
1228 | /* Invalidate last keypress */ | |
1229 | /* Not really needed, but helps with debug */ | |
1230 | state->rc_last[2] = state->rc_last[3]; | |
1231 | } | |
1232 | ||
1233 | state->rc_repeat = buf[6]; | |
eb29fbea | 1234 | state->rc_failed = false; |
a3645e54 AP |
1235 | |
1236 | error: | |
eb29fbea | 1237 | if (ret) { |
a3645e54 AP |
1238 | err("%s: failed:%d", __func__, ret); |
1239 | ||
eb29fbea AP |
1240 | /* allow random errors as dvb-usb will stop polling on error */ |
1241 | if (!state->rc_failed) | |
1242 | ret = 0; | |
1243 | ||
1244 | state->rc_failed = true; | |
1245 | } | |
1246 | ||
a3645e54 AP |
1247 | return ret; |
1248 | } | |
80619de8 | 1249 | |
a3645e54 | 1250 | static int af9015_get_rc_config(struct dvb_usb_device *d, struct dvb_usb_rc *rc) |
80619de8 | 1251 | { |
e8089661 | 1252 | struct af9015_state *state = d_to_priv(d); |
a3645e54 AP |
1253 | u16 vid = le16_to_cpu(d->udev->descriptor.idVendor); |
1254 | ||
1255 | if (state->ir_mode == AF9015_IR_MODE_DISABLED) | |
1256 | return 0; | |
1257 | ||
1258 | /* try to load remote based module param */ | |
eb29fbea AP |
1259 | if (!rc->map_name) |
1260 | rc->map_name = af9015_rc_setup_match(dvb_usb_af9015_remote, | |
1261 | af9015_rc_setup_modparam); | |
80619de8 | 1262 | |
a3645e54 AP |
1263 | /* try to load remote based eeprom hash */ |
1264 | if (!rc->map_name) | |
1265 | rc->map_name = af9015_rc_setup_match(state->eeprom_sum, | |
1266 | af9015_rc_setup_hashes); | |
1267 | ||
1268 | /* try to load remote based USB iManufacturer string */ | |
1269 | if (!rc->map_name && vid == USB_VID_AFATECH) { | |
1270 | /* Check USB manufacturer and product strings and try | |
1271 | to determine correct remote in case of chip vendor | |
1272 | reference IDs are used. | |
1273 | DO NOT ADD ANYTHING NEW HERE. Use hashes instead. */ | |
1274 | char manufacturer[10]; | |
1275 | memset(manufacturer, 0, sizeof(manufacturer)); | |
1276 | usb_string(d->udev, d->udev->descriptor.iManufacturer, | |
1277 | manufacturer, sizeof(manufacturer)); | |
1278 | if (!strcmp("MSI", manufacturer)) { | |
1279 | /* iManufacturer 1 MSI | |
1280 | iProduct 2 MSI K-VOX */ | |
1281 | rc->map_name = af9015_rc_setup_match( | |
1282 | AF9015_REMOTE_MSI_DIGIVOX_MINI_II_V3, | |
1283 | af9015_rc_setup_modparam); | |
1284 | } | |
80619de8 AP |
1285 | } |
1286 | ||
de73beee AP |
1287 | /* load empty to enable rc */ |
1288 | if (!rc->map_name) | |
1289 | rc->map_name = RC_MAP_EMPTY; | |
1290 | ||
a3645e54 AP |
1291 | rc->allowed_protos = RC_TYPE_NEC; |
1292 | rc->query = af9015_rc_query; | |
1293 | rc->interval = 500; | |
1294 | ||
1295 | return 0; | |
80619de8 AP |
1296 | } |
1297 | ||
a3645e54 AP |
1298 | /* interface 0 is used by DVB-T receiver and |
1299 | interface 1 is for remote controller (HID) */ | |
1300 | static struct dvb_usb_device_properties af9015_props = { | |
1301 | .driver_name = KBUILD_MODNAME, | |
1302 | .owner = THIS_MODULE, | |
1303 | .adapter_nr = adapter_nr, | |
1304 | .size_of_priv = sizeof(struct af9015_state), | |
1305 | ||
1306 | .generic_bulk_ctrl_endpoint = 0x02, | |
1307 | .generic_bulk_ctrl_endpoint_response = 0x81, | |
1308 | ||
1309 | .identify_state = af9015_identify_state, | |
bab9b4fe | 1310 | .firmware = AF9015_FIRMWARE, |
a3645e54 AP |
1311 | .download_firmware = af9015_download_firmware, |
1312 | ||
a3645e54 | 1313 | .i2c_algo = &af9015_i2c_algo, |
2d2b37c7 AP |
1314 | .read_config = af9015_read_config, |
1315 | .frontend_attach = af9015_af9013_frontend_attach, | |
1316 | .tuner_attach = af9015_tuner_attach, | |
a3645e54 AP |
1317 | .init = af9015_init, |
1318 | .get_rc_config = af9015_get_rc_config, | |
b905a2a1 | 1319 | .get_stream_config = af9015_get_stream_config, |
a3645e54 AP |
1320 | |
1321 | .get_adapter_count = af9015_get_adapter_count, | |
1322 | .adapter = { | |
1323 | { | |
1324 | .caps = DVB_USB_ADAP_HAS_PID_FILTER | | |
1325 | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF, | |
1326 | .pid_filter_count = 32, | |
1327 | .pid_filter = af9015_pid_filter, | |
1328 | .pid_filter_ctrl = af9015_pid_filter_ctrl, | |
1a590010 AP |
1329 | |
1330 | .stream = DVB_USB_STREAM_BULK(0x84, 8, TS_USB20_FRAME_SIZE), | |
1331 | }, { | |
1332 | .stream = DVB_USB_STREAM_BULK(0x85, 8, TS_USB20_FRAME_SIZE), | |
a3645e54 | 1333 | }, |
a3645e54 AP |
1334 | }, |
1335 | }; | |
1336 | ||
1337 | static const struct usb_device_id af9015_id_table[] = { | |
1338 | { DVB_USB_DEVICE(USB_VID_AFATECH, USB_PID_AFATECH_AF9015_9015, | |
1339 | &af9015_props, "Afatech AF9015 reference design", NULL) }, | |
1340 | { DVB_USB_DEVICE(USB_VID_AFATECH, USB_PID_AFATECH_AF9015_9016, | |
1341 | &af9015_props, "Afatech AF9015 reference design", NULL) }, | |
1342 | { DVB_USB_DEVICE(USB_VID_LEADTEK, USB_PID_WINFAST_DTV_DONGLE_GOLD, | |
1343 | &af9015_props, "Leadtek WinFast DTV Dongle Gold", RC_MAP_LEADTEK_Y04G0051) }, | |
1344 | { DVB_USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV71E, | |
1345 | &af9015_props, "Pinnacle PCTV 71e", NULL) }, | |
1346 | { DVB_USB_DEVICE(USB_VID_KWORLD_2, USB_PID_KWORLD_399U, | |
1347 | &af9015_props, "KWorld PlusTV Dual DVB-T Stick (DVB-T 399U)", NULL) }, | |
1348 | { DVB_USB_DEVICE(USB_VID_VISIONPLUS, USB_PID_TINYTWIN, | |
1349 | &af9015_props, "DigitalNow TinyTwin", RC_MAP_AZUREWAVE_AD_TU700) }, | |
1350 | { DVB_USB_DEVICE(USB_VID_VISIONPLUS, USB_PID_AZUREWAVE_AD_TU700, | |
1351 | &af9015_props, "TwinHan AzureWave AD-TU700(704J)", RC_MAP_AZUREWAVE_AD_TU700) }, | |
1352 | { DVB_USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_T_USB_XE_REV2, | |
1353 | &af9015_props, "TerraTec Cinergy T USB XE", NULL) }, | |
1354 | { DVB_USB_DEVICE(USB_VID_KWORLD_2, USB_PID_KWORLD_PC160_2T, | |
1355 | &af9015_props, "KWorld PlusTV Dual DVB-T PCI (DVB-T PC160-2T)", NULL) }, | |
1356 | { DVB_USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_VOLAR_X, | |
1357 | &af9015_props, "AVerMedia AVerTV DVB-T Volar X", RC_MAP_AVERMEDIA_M135A) }, | |
1358 | { DVB_USB_DEVICE(USB_VID_XTENSIONS, USB_PID_XTENSIONS_XD_380, | |
1359 | &af9015_props, "Xtensions XD-380", NULL) }, | |
1360 | { DVB_USB_DEVICE(USB_VID_MSI_2, USB_PID_MSI_DIGIVOX_DUO, | |
1361 | &af9015_props, "MSI DIGIVOX Duo", RC_MAP_MSI_DIGIVOX_III) }, | |
1362 | { DVB_USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_VOLAR_X_2, | |
1363 | &af9015_props, "Fujitsu-Siemens Slim Mobile USB DVB-T", NULL) }, | |
1364 | { DVB_USB_DEVICE(USB_VID_TELESTAR, USB_PID_TELESTAR_STARSTICK_2, | |
1365 | &af9015_props, "Telestar Starstick 2", NULL) }, | |
1366 | { DVB_USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_A309, | |
1367 | &af9015_props, "AVerMedia A309", NULL) }, | |
1368 | { DVB_USB_DEVICE(USB_VID_MSI_2, USB_PID_MSI_DIGI_VOX_MINI_III, | |
1369 | &af9015_props, "MSI Digi VOX mini III", RC_MAP_MSI_DIGIVOX_III) }, | |
1370 | { DVB_USB_DEVICE(USB_VID_KWORLD_2, USB_PID_KWORLD_395U, | |
1371 | &af9015_props, "KWorld USB DVB-T TV Stick II (VS-DVB-T 395U)", NULL) }, | |
1372 | { DVB_USB_DEVICE(USB_VID_KWORLD_2, USB_PID_KWORLD_395U_2, | |
1373 | &af9015_props, "KWorld USB DVB-T TV Stick II (VS-DVB-T 395U)", NULL) }, | |
1374 | { DVB_USB_DEVICE(USB_VID_KWORLD_2, USB_PID_KWORLD_395U_3, | |
1375 | &af9015_props, "KWorld USB DVB-T TV Stick II (VS-DVB-T 395U)", NULL) }, | |
1376 | { DVB_USB_DEVICE(USB_VID_AFATECH, USB_PID_TREKSTOR_DVBT, | |
1377 | &af9015_props, "TrekStor DVB-T USB Stick", RC_MAP_TREKSTOR) }, | |
1378 | { DVB_USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_A850, | |
1379 | &af9015_props, "AverMedia AVerTV Volar Black HD (A850)", NULL) }, | |
1380 | { DVB_USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_A805, | |
1381 | &af9015_props, "AverMedia AVerTV Volar GPS 805 (A805)", NULL) }, | |
1382 | { DVB_USB_DEVICE(USB_VID_KWORLD_2, USB_PID_CONCEPTRONIC_CTVDIGRCU, | |
1383 | &af9015_props, "Conceptronic USB2.0 DVB-T CTVDIGRCU V3.0", NULL) }, | |
1384 | { DVB_USB_DEVICE(USB_VID_KWORLD_2, USB_PID_KWORLD_MC810, | |
1385 | &af9015_props, "KWorld Digial MC-810", NULL) }, | |
1386 | { DVB_USB_DEVICE(USB_VID_KYE, USB_PID_GENIUS_TVGO_DVB_T03, | |
1387 | &af9015_props, "Genius TVGo DVB-T03", NULL) }, | |
1388 | { DVB_USB_DEVICE(USB_VID_KWORLD_2, USB_PID_KWORLD_399U_2, | |
1389 | &af9015_props, "KWorld PlusTV Dual DVB-T Stick (DVB-T 399U)", NULL) }, | |
1390 | { DVB_USB_DEVICE(USB_VID_KWORLD_2, USB_PID_KWORLD_PC160_T, | |
1391 | &af9015_props, "KWorld PlusTV DVB-T PCI Pro Card (DVB-T PC160-T)", NULL) }, | |
1392 | { DVB_USB_DEVICE(USB_VID_KWORLD_2, USB_PID_SVEON_STV20, | |
1393 | &af9015_props, "Sveon STV20 Tuner USB DVB-T HDTV", NULL) }, | |
1394 | { DVB_USB_DEVICE(USB_VID_KWORLD_2, USB_PID_TINYTWIN_2, | |
1395 | &af9015_props, "DigitalNow TinyTwin v2", RC_MAP_DIGITALNOW_TINYTWIN) }, | |
1396 | { DVB_USB_DEVICE(USB_VID_LEADTEK, USB_PID_WINFAST_DTV2000DS, | |
1397 | &af9015_props, "Leadtek WinFast DTV2000DS", RC_MAP_LEADTEK_Y04G0051) }, | |
1398 | { DVB_USB_DEVICE(USB_VID_KWORLD_2, USB_PID_KWORLD_UB383_T, | |
1399 | &af9015_props, "KWorld USB DVB-T Stick Mobile (UB383-T)", NULL) }, | |
1400 | { DVB_USB_DEVICE(USB_VID_KWORLD_2, USB_PID_KWORLD_395U_4, | |
1401 | &af9015_props, "KWorld USB DVB-T TV Stick II (VS-DVB-T 395U)", NULL) }, | |
1402 | { DVB_USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_A815M, | |
1403 | &af9015_props, "AverMedia AVerTV Volar M (A815Mac)", NULL) }, | |
1404 | { DVB_USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_T_STICK_RC, | |
1405 | &af9015_props, "TerraTec Cinergy T Stick RC", RC_MAP_TERRATEC_SLIM_2) }, | |
1406 | { DVB_USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_T_STICK_DUAL_RC, | |
1407 | &af9015_props, "TerraTec Cinergy T Stick Dual RC", RC_MAP_TERRATEC_SLIM) }, | |
1408 | { DVB_USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_A850T, | |
1409 | &af9015_props, "AverMedia AVerTV Red HD+ (A850T)", NULL) }, | |
1410 | { DVB_USB_DEVICE(USB_VID_GTEK, USB_PID_TINYTWIN_3, | |
1411 | &af9015_props, "DigitalNow TinyTwin v3", RC_MAP_DIGITALNOW_TINYTWIN) }, | |
1412 | { DVB_USB_DEVICE(USB_VID_KWORLD_2, USB_PID_SVEON_STV22, | |
1413 | &af9015_props, "Sveon STV22 Dual USB DVB-T Tuner HDTV", RC_MAP_MSI_DIGIVOX_III) }, | |
1414 | { } | |
1415 | }; | |
1416 | MODULE_DEVICE_TABLE(usb, af9015_id_table); | |
1417 | ||
80619de8 AP |
1418 | /* usb specific object needed to register this driver with the usb subsystem */ |
1419 | static struct usb_driver af9015_usb_driver = { | |
a3645e54 | 1420 | .name = KBUILD_MODNAME, |
2d2b37c7 | 1421 | .id_table = af9015_id_table, |
a3645e54 AP |
1422 | .probe = dvb_usbv2_probe, |
1423 | .disconnect = dvb_usbv2_disconnect, | |
53dc194f AP |
1424 | .suspend = dvb_usbv2_suspend, |
1425 | .resume = dvb_usbv2_resume, | |
04966aa8 | 1426 | .reset_resume = dvb_usbv2_reset_resume, |
a3645e54 | 1427 | .no_dynamic_id = 1, |
77f54517 | 1428 | .soft_unbind = 1, |
80619de8 AP |
1429 | }; |
1430 | ||
ecb3b2b3 | 1431 | module_usb_driver(af9015_usb_driver); |
80619de8 AP |
1432 | |
1433 | MODULE_AUTHOR("Antti Palosaari <crope@iki.fi>"); | |
bc050e67 | 1434 | MODULE_DESCRIPTION("Afatech AF9015 driver"); |
80619de8 | 1435 | MODULE_LICENSE("GPL"); |
bab9b4fe | 1436 | MODULE_FIRMWARE(AF9015_FIRMWARE); |