Antti Palosaari | 80619de | 2008-09-15 17:18:09 -0300 | [diff] [blame] | 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" |
| 25 | #include "af9013.h" |
| 26 | #include "mt2060.h" |
| 27 | #include "qt1010.h" |
| 28 | #include "tda18271.h" |
| 29 | #include "mxl5005s.h" |
Jochen Friedrich | d563399 | 2009-02-02 14:59:50 -0300 | [diff] [blame] | 30 | #include "mc44s803.h" |
Antti Palosaari | 80619de | 2008-09-15 17:18:09 -0300 | [diff] [blame] | 31 | |
Antti Palosaari | 349d042 | 2008-11-05 16:31:24 -0300 | [diff] [blame] | 32 | static int dvb_usb_af9015_debug; |
Antti Palosaari | 80619de | 2008-09-15 17:18:09 -0300 | [diff] [blame] | 33 | module_param_named(debug, dvb_usb_af9015_debug, int, 0644); |
| 34 | MODULE_PARM_DESC(debug, "set debugging level" DVB_USB_DEBUG_STATUS); |
Antti Palosaari | 349d042 | 2008-11-05 16:31:24 -0300 | [diff] [blame] | 35 | static int dvb_usb_af9015_remote; |
Antti Palosaari | 80619de | 2008-09-15 17:18:09 -0300 | [diff] [blame] | 36 | module_param_named(remote, dvb_usb_af9015_remote, int, 0644); |
| 37 | MODULE_PARM_DESC(remote, "select remote"); |
Antti Palosaari | 80619de | 2008-09-15 17:18:09 -0300 | [diff] [blame] | 38 | DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); |
| 39 | |
| 40 | static DEFINE_MUTEX(af9015_usb_mutex); |
| 41 | |
| 42 | static struct af9015_config af9015_config; |
Antti Palosaari | 85d7d7c | 2009-04-09 09:16:12 -0300 | [diff] [blame] | 43 | static struct dvb_usb_device_properties af9015_properties[3]; |
Antti Palosaari | 349d042 | 2008-11-05 16:31:24 -0300 | [diff] [blame] | 44 | static int af9015_properties_count = ARRAY_SIZE(af9015_properties); |
Antti Palosaari | 80619de | 2008-09-15 17:18:09 -0300 | [diff] [blame] | 45 | |
| 46 | static struct af9013_config af9015_af9013_config[] = { |
| 47 | { |
| 48 | .demod_address = AF9015_I2C_DEMOD, |
| 49 | .output_mode = AF9013_OUTPUT_MODE_USB, |
| 50 | .api_version = { 0, 1, 9, 0 }, |
| 51 | .gpio[0] = AF9013_GPIO_HI, |
Antti Palosaari | 80619de | 2008-09-15 17:18:09 -0300 | [diff] [blame] | 52 | .gpio[3] = AF9013_GPIO_TUNER_ON, |
| 53 | |
| 54 | }, { |
| 55 | .output_mode = AF9013_OUTPUT_MODE_SERIAL, |
| 56 | .api_version = { 0, 1, 9, 0 }, |
| 57 | .gpio[0] = AF9013_GPIO_TUNER_ON, |
| 58 | .gpio[1] = AF9013_GPIO_LO, |
| 59 | } |
| 60 | }; |
| 61 | |
| 62 | static int af9015_rw_udev(struct usb_device *udev, struct req_t *req) |
| 63 | { |
Antti Palosaari | 06565d7 | 2009-09-12 20:46:30 -0300 | [diff] [blame] | 64 | #define BUF_LEN 63 |
| 65 | #define REQ_HDR_LEN 8 /* send header size */ |
| 66 | #define ACK_HDR_LEN 2 /* rece header size */ |
Antti Palosaari | 80619de | 2008-09-15 17:18:09 -0300 | [diff] [blame] | 67 | int act_len, ret; |
Antti Palosaari | 06565d7 | 2009-09-12 20:46:30 -0300 | [diff] [blame] | 68 | u8 buf[BUF_LEN]; |
Antti Palosaari | 80619de | 2008-09-15 17:18:09 -0300 | [diff] [blame] | 69 | u8 write = 1; |
Antti Palosaari | 06565d7 | 2009-09-12 20:46:30 -0300 | [diff] [blame] | 70 | u8 msg_len = REQ_HDR_LEN; |
Antti Palosaari | 80619de | 2008-09-15 17:18:09 -0300 | [diff] [blame] | 71 | static u8 seq; /* packet sequence number */ |
| 72 | |
| 73 | if (mutex_lock_interruptible(&af9015_usb_mutex) < 0) |
| 74 | return -EAGAIN; |
| 75 | |
| 76 | buf[0] = req->cmd; |
| 77 | buf[1] = seq++; |
| 78 | buf[2] = req->i2c_addr; |
| 79 | buf[3] = req->addr >> 8; |
| 80 | buf[4] = req->addr & 0xff; |
| 81 | buf[5] = req->mbox; |
| 82 | buf[6] = req->addr_len; |
| 83 | buf[7] = req->data_len; |
| 84 | |
| 85 | switch (req->cmd) { |
| 86 | case GET_CONFIG: |
Antti Palosaari | 80619de | 2008-09-15 17:18:09 -0300 | [diff] [blame] | 87 | case READ_MEMORY: |
| 88 | case RECONNECT_USB: |
| 89 | case GET_IR_CODE: |
| 90 | write = 0; |
| 91 | break; |
| 92 | case READ_I2C: |
| 93 | write = 0; |
| 94 | buf[2] |= 0x01; /* set I2C direction */ |
| 95 | case WRITE_I2C: |
| 96 | buf[0] = READ_WRITE_I2C; |
| 97 | break; |
| 98 | case WRITE_MEMORY: |
| 99 | if (((req->addr & 0xff00) == 0xff00) || |
Antti Palosaari | f4e96de | 2009-09-12 21:25:59 -0300 | [diff] [blame] | 100 | ((req->addr & 0xff00) == 0xae00)) |
Antti Palosaari | 80619de | 2008-09-15 17:18:09 -0300 | [diff] [blame] | 101 | buf[0] = WRITE_VIRTUAL_MEMORY; |
| 102 | case WRITE_VIRTUAL_MEMORY: |
| 103 | case COPY_FIRMWARE: |
| 104 | case DOWNLOAD_FIRMWARE: |
Nils Kassube | ba1bc64 | 2009-07-28 11:54:52 -0300 | [diff] [blame] | 105 | case BOOT: |
Antti Palosaari | 80619de | 2008-09-15 17:18:09 -0300 | [diff] [blame] | 106 | break; |
| 107 | default: |
| 108 | err("unknown command:%d", req->cmd); |
| 109 | ret = -1; |
| 110 | goto error_unlock; |
| 111 | } |
| 112 | |
Antti Palosaari | 06565d7 | 2009-09-12 20:46:30 -0300 | [diff] [blame] | 113 | /* buffer overflow check */ |
| 114 | if ((write && (req->data_len > BUF_LEN - REQ_HDR_LEN)) || |
| 115 | (!write && (req->data_len > BUF_LEN - ACK_HDR_LEN))) { |
| 116 | err("too much data; cmd:%d len:%d", req->cmd, req->data_len); |
| 117 | ret = -EINVAL; |
| 118 | goto error_unlock; |
| 119 | } |
| 120 | |
Antti Palosaari | 80619de | 2008-09-15 17:18:09 -0300 | [diff] [blame] | 121 | /* write requested */ |
| 122 | if (write) { |
Antti Palosaari | 06565d7 | 2009-09-12 20:46:30 -0300 | [diff] [blame] | 123 | memcpy(&buf[REQ_HDR_LEN], req->data, req->data_len); |
Antti Palosaari | 80619de | 2008-09-15 17:18:09 -0300 | [diff] [blame] | 124 | msg_len += req->data_len; |
| 125 | } |
Antti Palosaari | 06565d7 | 2009-09-12 20:46:30 -0300 | [diff] [blame] | 126 | |
Antti Palosaari | 80619de | 2008-09-15 17:18:09 -0300 | [diff] [blame] | 127 | deb_xfer(">>> "); |
| 128 | debug_dump(buf, msg_len, deb_xfer); |
| 129 | |
| 130 | /* send req */ |
| 131 | ret = usb_bulk_msg(udev, usb_sndbulkpipe(udev, 0x02), buf, msg_len, |
Antti Palosaari | 06565d7 | 2009-09-12 20:46:30 -0300 | [diff] [blame] | 132 | &act_len, AF9015_USB_TIMEOUT); |
Antti Palosaari | 80619de | 2008-09-15 17:18:09 -0300 | [diff] [blame] | 133 | if (ret) |
| 134 | err("bulk message failed:%d (%d/%d)", ret, msg_len, act_len); |
| 135 | else |
| 136 | if (act_len != msg_len) |
| 137 | ret = -1; /* all data is not send */ |
| 138 | if (ret) |
| 139 | goto error_unlock; |
| 140 | |
| 141 | /* no ack for those packets */ |
| 142 | if (req->cmd == DOWNLOAD_FIRMWARE || req->cmd == RECONNECT_USB) |
| 143 | goto exit_unlock; |
| 144 | |
Antti Palosaari | 06565d7 | 2009-09-12 20:46:30 -0300 | [diff] [blame] | 145 | /* write receives seq + status = 2 bytes |
| 146 | read receives seq + status + data = 2 + N bytes */ |
| 147 | msg_len = ACK_HDR_LEN; |
| 148 | if (!write) |
| 149 | msg_len += req->data_len; |
| 150 | |
Antti Palosaari | 80619de | 2008-09-15 17:18:09 -0300 | [diff] [blame] | 151 | ret = usb_bulk_msg(udev, usb_rcvbulkpipe(udev, 0x81), buf, msg_len, |
Antti Palosaari | 06565d7 | 2009-09-12 20:46:30 -0300 | [diff] [blame] | 152 | &act_len, AF9015_USB_TIMEOUT); |
Antti Palosaari | 80619de | 2008-09-15 17:18:09 -0300 | [diff] [blame] | 153 | if (ret) { |
| 154 | err("recv bulk message failed:%d", ret); |
| 155 | ret = -1; |
| 156 | goto error_unlock; |
| 157 | } |
| 158 | |
| 159 | deb_xfer("<<< "); |
| 160 | debug_dump(buf, act_len, deb_xfer); |
| 161 | |
| 162 | /* remote controller query status is 1 if remote code is not received */ |
| 163 | if (req->cmd == GET_IR_CODE && buf[1] == 1) { |
| 164 | buf[1] = 0; /* clear command "error" status */ |
| 165 | memset(&buf[2], 0, req->data_len); |
| 166 | buf[3] = 1; /* no remote code received mark */ |
| 167 | } |
| 168 | |
| 169 | /* check status */ |
| 170 | if (buf[1]) { |
| 171 | err("command failed:%d", buf[1]); |
| 172 | ret = -1; |
| 173 | goto error_unlock; |
| 174 | } |
| 175 | |
| 176 | /* read request, copy returned data to return buf */ |
| 177 | if (!write) |
Antti Palosaari | 06565d7 | 2009-09-12 20:46:30 -0300 | [diff] [blame] | 178 | memcpy(req->data, &buf[ACK_HDR_LEN], req->data_len); |
Antti Palosaari | 80619de | 2008-09-15 17:18:09 -0300 | [diff] [blame] | 179 | |
| 180 | error_unlock: |
| 181 | exit_unlock: |
| 182 | mutex_unlock(&af9015_usb_mutex); |
| 183 | |
| 184 | return ret; |
| 185 | } |
| 186 | |
| 187 | static int af9015_ctrl_msg(struct dvb_usb_device *d, struct req_t *req) |
| 188 | { |
| 189 | return af9015_rw_udev(d->udev, req); |
| 190 | } |
| 191 | |
| 192 | static int af9015_write_regs(struct dvb_usb_device *d, u16 addr, u8 *val, |
| 193 | u8 len) |
| 194 | { |
| 195 | struct req_t req = {WRITE_MEMORY, AF9015_I2C_DEMOD, addr, 0, 0, len, |
| 196 | val}; |
| 197 | return af9015_ctrl_msg(d, &req); |
| 198 | } |
| 199 | |
| 200 | static int af9015_write_reg(struct dvb_usb_device *d, u16 addr, u8 val) |
| 201 | { |
| 202 | return af9015_write_regs(d, addr, &val, 1); |
| 203 | } |
| 204 | |
| 205 | static int af9015_read_reg(struct dvb_usb_device *d, u16 addr, u8 *val) |
| 206 | { |
| 207 | struct req_t req = {READ_MEMORY, AF9015_I2C_DEMOD, addr, 0, 0, 1, val}; |
| 208 | return af9015_ctrl_msg(d, &req); |
| 209 | } |
| 210 | |
| 211 | static int af9015_write_reg_i2c(struct dvb_usb_device *d, u8 addr, u16 reg, |
| 212 | u8 val) |
| 213 | { |
| 214 | struct req_t req = {WRITE_I2C, addr, reg, 1, 1, 1, &val}; |
| 215 | |
| 216 | if (addr == af9015_af9013_config[0].demod_address || |
| 217 | addr == af9015_af9013_config[1].demod_address) |
| 218 | req.addr_len = 3; |
| 219 | |
| 220 | return af9015_ctrl_msg(d, &req); |
| 221 | } |
| 222 | |
| 223 | static int af9015_read_reg_i2c(struct dvb_usb_device *d, u8 addr, u16 reg, |
| 224 | u8 *val) |
| 225 | { |
| 226 | struct req_t req = {READ_I2C, addr, reg, 0, 1, 1, val}; |
| 227 | |
| 228 | if (addr == af9015_af9013_config[0].demod_address || |
| 229 | addr == af9015_af9013_config[1].demod_address) |
| 230 | req.addr_len = 3; |
| 231 | |
| 232 | return af9015_ctrl_msg(d, &req); |
| 233 | } |
| 234 | |
| 235 | static int af9015_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[], |
| 236 | int num) |
| 237 | { |
| 238 | struct dvb_usb_device *d = i2c_get_adapdata(adap); |
| 239 | int ret = 0, i = 0; |
| 240 | u16 addr; |
| 241 | u8 mbox, addr_len; |
| 242 | struct req_t req; |
| 243 | |
| 244 | /* TODO: implement bus lock |
| 245 | |
| 246 | The bus lock is needed because there is two tuners both using same I2C-address. |
| 247 | Due to that the only way to select correct tuner is use demodulator I2C-gate. |
| 248 | |
| 249 | ................................................ |
| 250 | . AF9015 includes integrated AF9013 demodulator. |
| 251 | . ____________ ____________ . ____________ |
| 252 | .| uC | | demod | . | tuner | |
| 253 | .|------------| |------------| . |------------| |
| 254 | .| AF9015 | | AF9013/5 | . | MXL5003 | |
| 255 | .| |--+----I2C-------|-----/ -----|-.-----I2C-------| | |
| 256 | .| | | | addr 0x38 | . | addr 0xc6 | |
| 257 | .|____________| | |____________| . |____________| |
| 258 | .................|.............................. |
| 259 | | ____________ ____________ |
| 260 | | | demod | | tuner | |
| 261 | | |------------| |------------| |
| 262 | | | AF9013 | | MXL5003 | |
| 263 | +----I2C-------|-----/ -----|-------I2C-------| | |
| 264 | | addr 0x3a | | addr 0xc6 | |
| 265 | |____________| |____________| |
| 266 | */ |
| 267 | if (mutex_lock_interruptible(&d->i2c_mutex) < 0) |
| 268 | return -EAGAIN; |
| 269 | |
| 270 | while (i < num) { |
| 271 | if (msg[i].addr == af9015_af9013_config[0].demod_address || |
| 272 | msg[i].addr == af9015_af9013_config[1].demod_address) { |
| 273 | addr = msg[i].buf[0] << 8; |
| 274 | addr += msg[i].buf[1]; |
| 275 | mbox = msg[i].buf[2]; |
| 276 | addr_len = 3; |
| 277 | } else { |
| 278 | addr = msg[i].buf[0]; |
| 279 | addr_len = 1; |
| 280 | mbox = 0; |
| 281 | } |
| 282 | |
| 283 | if (num > i + 1 && (msg[i+1].flags & I2C_M_RD)) { |
| 284 | if (msg[i].addr == |
| 285 | af9015_af9013_config[0].demod_address) |
| 286 | req.cmd = READ_MEMORY; |
| 287 | else |
| 288 | req.cmd = READ_I2C; |
| 289 | req.i2c_addr = msg[i].addr; |
| 290 | req.addr = addr; |
| 291 | req.mbox = mbox; |
| 292 | req.addr_len = addr_len; |
| 293 | req.data_len = msg[i+1].len; |
| 294 | req.data = &msg[i+1].buf[0]; |
| 295 | ret = af9015_ctrl_msg(d, &req); |
| 296 | i += 2; |
Jochen Friedrich | d563399 | 2009-02-02 14:59:50 -0300 | [diff] [blame] | 297 | } else if (msg[i].flags & I2C_M_RD) { |
| 298 | ret = -EINVAL; |
| 299 | if (msg[i].addr == |
| 300 | af9015_af9013_config[0].demod_address) |
| 301 | goto error; |
| 302 | else |
| 303 | req.cmd = READ_I2C; |
| 304 | req.i2c_addr = msg[i].addr; |
| 305 | req.addr = addr; |
| 306 | req.mbox = mbox; |
| 307 | req.addr_len = addr_len; |
| 308 | req.data_len = msg[i].len; |
| 309 | req.data = &msg[i].buf[0]; |
| 310 | ret = af9015_ctrl_msg(d, &req); |
| 311 | i += 1; |
Antti Palosaari | 80619de | 2008-09-15 17:18:09 -0300 | [diff] [blame] | 312 | } else { |
| 313 | if (msg[i].addr == |
| 314 | af9015_af9013_config[0].demod_address) |
| 315 | req.cmd = WRITE_MEMORY; |
| 316 | else |
| 317 | req.cmd = WRITE_I2C; |
| 318 | req.i2c_addr = msg[i].addr; |
| 319 | req.addr = addr; |
| 320 | req.mbox = mbox; |
| 321 | req.addr_len = addr_len; |
| 322 | req.data_len = msg[i].len-addr_len; |
| 323 | req.data = &msg[i].buf[addr_len]; |
| 324 | ret = af9015_ctrl_msg(d, &req); |
| 325 | i += 1; |
| 326 | } |
| 327 | if (ret) |
| 328 | goto error; |
| 329 | |
| 330 | } |
| 331 | ret = i; |
| 332 | |
| 333 | error: |
| 334 | mutex_unlock(&d->i2c_mutex); |
| 335 | |
| 336 | return ret; |
| 337 | } |
| 338 | |
| 339 | static u32 af9015_i2c_func(struct i2c_adapter *adapter) |
| 340 | { |
| 341 | return I2C_FUNC_I2C; |
| 342 | } |
| 343 | |
| 344 | static struct i2c_algorithm af9015_i2c_algo = { |
| 345 | .master_xfer = af9015_i2c_xfer, |
| 346 | .functionality = af9015_i2c_func, |
| 347 | }; |
| 348 | |
| 349 | static int af9015_do_reg_bit(struct dvb_usb_device *d, u16 addr, u8 bit, u8 op) |
| 350 | { |
| 351 | int ret; |
| 352 | u8 val, mask = 0x01; |
| 353 | |
| 354 | ret = af9015_read_reg(d, addr, &val); |
| 355 | if (ret) |
| 356 | return ret; |
| 357 | |
| 358 | mask <<= bit; |
| 359 | if (op) { |
| 360 | /* set bit */ |
| 361 | val |= mask; |
| 362 | } else { |
| 363 | /* clear bit */ |
| 364 | mask ^= 0xff; |
| 365 | val &= mask; |
| 366 | } |
| 367 | |
| 368 | return af9015_write_reg(d, addr, val); |
| 369 | } |
| 370 | |
| 371 | static int af9015_set_reg_bit(struct dvb_usb_device *d, u16 addr, u8 bit) |
| 372 | { |
| 373 | return af9015_do_reg_bit(d, addr, bit, 1); |
| 374 | } |
| 375 | |
| 376 | static int af9015_clear_reg_bit(struct dvb_usb_device *d, u16 addr, u8 bit) |
| 377 | { |
| 378 | return af9015_do_reg_bit(d, addr, bit, 0); |
| 379 | } |
| 380 | |
| 381 | static int af9015_init_endpoint(struct dvb_usb_device *d) |
| 382 | { |
| 383 | int ret; |
| 384 | u16 frame_size; |
| 385 | u8 packet_size; |
| 386 | deb_info("%s: USB speed:%d\n", __func__, d->udev->speed); |
| 387 | |
Antti Palosaari | 9c86327 | 2009-09-12 13:35:29 -0300 | [diff] [blame] | 388 | /* Windows driver uses packet count 21 for USB1.1 and 348 for USB2.0. |
| 389 | We use smaller - about 1/4 from the original, 5 and 87. */ |
Antti Palosaari | 80619de | 2008-09-15 17:18:09 -0300 | [diff] [blame] | 390 | #define TS_PACKET_SIZE 188 |
| 391 | |
Antti Palosaari | 9c86327 | 2009-09-12 13:35:29 -0300 | [diff] [blame] | 392 | #define TS_USB20_PACKET_COUNT 87 |
Antti Palosaari | 80619de | 2008-09-15 17:18:09 -0300 | [diff] [blame] | 393 | #define TS_USB20_FRAME_SIZE (TS_PACKET_SIZE*TS_USB20_PACKET_COUNT) |
| 394 | |
Antti Palosaari | 9c86327 | 2009-09-12 13:35:29 -0300 | [diff] [blame] | 395 | #define TS_USB11_PACKET_COUNT 5 |
Antti Palosaari | 80619de | 2008-09-15 17:18:09 -0300 | [diff] [blame] | 396 | #define TS_USB11_FRAME_SIZE (TS_PACKET_SIZE*TS_USB11_PACKET_COUNT) |
| 397 | |
| 398 | #define TS_USB20_MAX_PACKET_SIZE 512 |
| 399 | #define TS_USB11_MAX_PACKET_SIZE 64 |
| 400 | |
| 401 | if (d->udev->speed == USB_SPEED_FULL) { |
| 402 | frame_size = TS_USB11_FRAME_SIZE/4; |
| 403 | packet_size = TS_USB11_MAX_PACKET_SIZE/4; |
| 404 | } else { |
| 405 | frame_size = TS_USB20_FRAME_SIZE/4; |
| 406 | packet_size = TS_USB20_MAX_PACKET_SIZE/4; |
| 407 | } |
| 408 | |
| 409 | ret = af9015_set_reg_bit(d, 0xd507, 2); /* assert EP4 reset */ |
| 410 | if (ret) |
| 411 | goto error; |
| 412 | ret = af9015_set_reg_bit(d, 0xd50b, 1); /* assert EP5 reset */ |
| 413 | if (ret) |
| 414 | goto error; |
| 415 | ret = af9015_clear_reg_bit(d, 0xdd11, 5); /* disable EP4 */ |
| 416 | if (ret) |
| 417 | goto error; |
| 418 | ret = af9015_clear_reg_bit(d, 0xdd11, 6); /* disable EP5 */ |
| 419 | if (ret) |
| 420 | goto error; |
| 421 | ret = af9015_set_reg_bit(d, 0xdd11, 5); /* enable EP4 */ |
| 422 | if (ret) |
| 423 | goto error; |
| 424 | if (af9015_config.dual_mode) { |
| 425 | ret = af9015_set_reg_bit(d, 0xdd11, 6); /* enable EP5 */ |
| 426 | if (ret) |
| 427 | goto error; |
| 428 | } |
| 429 | ret = af9015_clear_reg_bit(d, 0xdd13, 5); /* disable EP4 NAK */ |
| 430 | if (ret) |
| 431 | goto error; |
| 432 | if (af9015_config.dual_mode) { |
| 433 | ret = af9015_clear_reg_bit(d, 0xdd13, 6); /* disable EP5 NAK */ |
| 434 | if (ret) |
| 435 | goto error; |
| 436 | } |
| 437 | /* EP4 xfer length */ |
| 438 | ret = af9015_write_reg(d, 0xdd88, frame_size & 0xff); |
| 439 | if (ret) |
| 440 | goto error; |
| 441 | ret = af9015_write_reg(d, 0xdd89, frame_size >> 8); |
| 442 | if (ret) |
| 443 | goto error; |
| 444 | /* EP5 xfer length */ |
| 445 | ret = af9015_write_reg(d, 0xdd8a, frame_size & 0xff); |
| 446 | if (ret) |
| 447 | goto error; |
| 448 | ret = af9015_write_reg(d, 0xdd8b, frame_size >> 8); |
| 449 | if (ret) |
| 450 | goto error; |
| 451 | ret = af9015_write_reg(d, 0xdd0c, packet_size); /* EP4 packet size */ |
| 452 | if (ret) |
| 453 | goto error; |
| 454 | ret = af9015_write_reg(d, 0xdd0d, packet_size); /* EP5 packet size */ |
| 455 | if (ret) |
| 456 | goto error; |
| 457 | ret = af9015_clear_reg_bit(d, 0xd507, 2); /* negate EP4 reset */ |
| 458 | if (ret) |
| 459 | goto error; |
| 460 | if (af9015_config.dual_mode) { |
| 461 | ret = af9015_clear_reg_bit(d, 0xd50b, 1); /* negate EP5 reset */ |
| 462 | if (ret) |
| 463 | goto error; |
| 464 | } |
| 465 | |
| 466 | /* enable / disable mp2if2 */ |
| 467 | if (af9015_config.dual_mode) |
| 468 | ret = af9015_set_reg_bit(d, 0xd50b, 0); |
| 469 | else |
| 470 | ret = af9015_clear_reg_bit(d, 0xd50b, 0); |
| 471 | error: |
| 472 | if (ret) |
| 473 | err("endpoint init failed:%d", ret); |
| 474 | return ret; |
| 475 | } |
| 476 | |
| 477 | static int af9015_copy_firmware(struct dvb_usb_device *d) |
| 478 | { |
| 479 | int ret; |
| 480 | u8 fw_params[4]; |
| 481 | u8 val, i; |
| 482 | struct req_t req = {COPY_FIRMWARE, 0, 0x5100, 0, 0, sizeof(fw_params), |
| 483 | fw_params }; |
| 484 | deb_info("%s:\n", __func__); |
| 485 | |
| 486 | fw_params[0] = af9015_config.firmware_size >> 8; |
| 487 | fw_params[1] = af9015_config.firmware_size & 0xff; |
| 488 | fw_params[2] = af9015_config.firmware_checksum >> 8; |
| 489 | fw_params[3] = af9015_config.firmware_checksum & 0xff; |
| 490 | |
| 491 | /* wait 2nd demodulator ready */ |
| 492 | msleep(100); |
| 493 | |
| 494 | ret = af9015_read_reg_i2c(d, 0x3a, 0x98be, &val); |
| 495 | if (ret) |
| 496 | goto error; |
| 497 | else |
| 498 | deb_info("%s: firmware status:%02x\n", __func__, val); |
| 499 | |
| 500 | if (val == 0x0c) /* fw is running, no need for download */ |
| 501 | goto exit; |
| 502 | |
| 503 | /* set I2C master clock to fast (to speed up firmware copy) */ |
| 504 | ret = af9015_write_reg(d, 0xd416, 0x04); /* 0x04 * 400ns */ |
| 505 | if (ret) |
| 506 | goto error; |
| 507 | |
| 508 | msleep(50); |
| 509 | |
| 510 | /* copy firmware */ |
| 511 | ret = af9015_ctrl_msg(d, &req); |
| 512 | if (ret) |
| 513 | err("firmware copy cmd failed:%d", ret); |
| 514 | deb_info("%s: firmware copy done\n", __func__); |
| 515 | |
| 516 | /* set I2C master clock back to normal */ |
| 517 | ret = af9015_write_reg(d, 0xd416, 0x14); /* 0x14 * 400ns */ |
| 518 | if (ret) |
| 519 | goto error; |
| 520 | |
| 521 | /* request boot firmware */ |
| 522 | ret = af9015_write_reg_i2c(d, af9015_af9013_config[1].demod_address, |
| 523 | 0xe205, 1); |
| 524 | deb_info("%s: firmware boot cmd status:%d\n", __func__, ret); |
| 525 | if (ret) |
| 526 | goto error; |
| 527 | |
| 528 | for (i = 0; i < 15; i++) { |
| 529 | msleep(100); |
| 530 | |
| 531 | /* check firmware status */ |
| 532 | ret = af9015_read_reg_i2c(d, |
| 533 | af9015_af9013_config[1].demod_address, 0x98be, &val); |
| 534 | deb_info("%s: firmware status cmd status:%d fw status:%02x\n", |
| 535 | __func__, ret, val); |
| 536 | if (ret) |
| 537 | goto error; |
| 538 | |
| 539 | if (val == 0x0c || val == 0x04) /* success or fail */ |
| 540 | break; |
| 541 | } |
| 542 | |
| 543 | if (val == 0x04) { |
| 544 | err("firmware did not run"); |
| 545 | ret = -1; |
| 546 | } else if (val != 0x0c) { |
| 547 | err("firmware boot timeout"); |
| 548 | ret = -1; |
| 549 | } |
| 550 | |
| 551 | error: |
| 552 | exit: |
| 553 | return ret; |
| 554 | } |
| 555 | |
| 556 | /* dump eeprom */ |
| 557 | static int af9015_eeprom_dump(struct dvb_usb_device *d) |
| 558 | { |
Antti Palosaari | 80619de | 2008-09-15 17:18:09 -0300 | [diff] [blame] | 559 | u8 reg, val; |
| 560 | |
| 561 | for (reg = 0; ; reg++) { |
| 562 | if (reg % 16 == 0) { |
| 563 | if (reg) |
Jan Nikitenko | 43f8de7 | 2009-07-27 19:05:19 -0300 | [diff] [blame] | 564 | deb_info(KERN_CONT "\n"); |
| 565 | deb_info(KERN_DEBUG "%02x:", reg); |
Antti Palosaari | 80619de | 2008-09-15 17:18:09 -0300 | [diff] [blame] | 566 | } |
| 567 | if (af9015_read_reg_i2c(d, AF9015_I2C_EEPROM, reg, &val) == 0) |
Jan Nikitenko | 43f8de7 | 2009-07-27 19:05:19 -0300 | [diff] [blame] | 568 | deb_info(KERN_CONT " %02x", val); |
Antti Palosaari | 80619de | 2008-09-15 17:18:09 -0300 | [diff] [blame] | 569 | else |
Jan Nikitenko | 43f8de7 | 2009-07-27 19:05:19 -0300 | [diff] [blame] | 570 | deb_info(KERN_CONT " --"); |
Antti Palosaari | 80619de | 2008-09-15 17:18:09 -0300 | [diff] [blame] | 571 | if (reg == 0xff) |
| 572 | break; |
| 573 | } |
Jan Nikitenko | 43f8de7 | 2009-07-27 19:05:19 -0300 | [diff] [blame] | 574 | deb_info(KERN_CONT "\n"); |
Antti Palosaari | 80619de | 2008-09-15 17:18:09 -0300 | [diff] [blame] | 575 | return 0; |
| 576 | } |
| 577 | |
Antti Palosaari | 349d042 | 2008-11-05 16:31:24 -0300 | [diff] [blame] | 578 | static int af9015_download_ir_table(struct dvb_usb_device *d) |
Antti Palosaari | 80619de | 2008-09-15 17:18:09 -0300 | [diff] [blame] | 579 | { |
| 580 | int i, packets = 0, ret; |
| 581 | u16 addr = 0x9a56; /* ir-table start address */ |
| 582 | struct req_t req = {WRITE_MEMORY, 0, 0, 0, 0, 1, NULL}; |
| 583 | u8 *data = NULL; |
| 584 | deb_info("%s:\n", __func__); |
| 585 | |
| 586 | data = af9015_config.ir_table; |
| 587 | packets = af9015_config.ir_table_size; |
| 588 | |
| 589 | /* no remote */ |
| 590 | if (!packets) |
| 591 | goto exit; |
| 592 | |
| 593 | /* load remote ir-table */ |
| 594 | for (i = 0; i < packets; i++) { |
| 595 | req.addr = addr + i; |
| 596 | req.data = &data[i]; |
| 597 | ret = af9015_ctrl_msg(d, &req); |
| 598 | if (ret) { |
| 599 | err("ir-table download failed at packet %d with " \ |
| 600 | "code %d", i, ret); |
| 601 | return ret; |
| 602 | } |
| 603 | } |
| 604 | |
| 605 | exit: |
| 606 | return 0; |
| 607 | } |
| 608 | |
| 609 | static int af9015_init(struct dvb_usb_device *d) |
| 610 | { |
| 611 | int ret; |
| 612 | deb_info("%s:\n", __func__); |
| 613 | |
| 614 | ret = af9015_init_endpoint(d); |
| 615 | if (ret) |
| 616 | goto error; |
| 617 | |
| 618 | ret = af9015_download_ir_table(d); |
| 619 | if (ret) |
| 620 | goto error; |
| 621 | |
| 622 | error: |
| 623 | return ret; |
| 624 | } |
| 625 | |
| 626 | static int af9015_pid_filter_ctrl(struct dvb_usb_adapter *adap, int onoff) |
| 627 | { |
| 628 | int ret; |
| 629 | deb_info("%s: onoff:%d\n", __func__, onoff); |
| 630 | |
| 631 | if (onoff) |
| 632 | ret = af9015_set_reg_bit(adap->dev, 0xd503, 0); |
| 633 | else |
| 634 | ret = af9015_clear_reg_bit(adap->dev, 0xd503, 0); |
| 635 | |
| 636 | return ret; |
| 637 | } |
| 638 | |
| 639 | static int af9015_pid_filter(struct dvb_usb_adapter *adap, int index, u16 pid, |
| 640 | int onoff) |
| 641 | { |
| 642 | int ret; |
| 643 | u8 idx; |
| 644 | |
| 645 | deb_info("%s: set pid filter, index %d, pid %x, onoff %d\n", |
| 646 | __func__, index, pid, onoff); |
| 647 | |
| 648 | ret = af9015_write_reg(adap->dev, 0xd505, (pid & 0xff)); |
| 649 | if (ret) |
| 650 | goto error; |
| 651 | |
| 652 | ret = af9015_write_reg(adap->dev, 0xd506, (pid >> 8)); |
| 653 | if (ret) |
| 654 | goto error; |
| 655 | |
| 656 | idx = ((index & 0x1f) | (1 << 5)); |
| 657 | ret = af9015_write_reg(adap->dev, 0xd504, idx); |
| 658 | |
| 659 | error: |
| 660 | return ret; |
| 661 | } |
| 662 | |
| 663 | static int af9015_download_firmware(struct usb_device *udev, |
| 664 | const struct firmware *fw) |
| 665 | { |
| 666 | int i, len, packets, remainder, ret; |
| 667 | struct req_t req = {DOWNLOAD_FIRMWARE, 0, 0, 0, 0, 0, NULL}; |
| 668 | u16 addr = 0x5100; /* firmware start address */ |
| 669 | u16 checksum = 0; |
| 670 | |
| 671 | deb_info("%s:\n", __func__); |
| 672 | |
| 673 | /* calc checksum */ |
| 674 | for (i = 0; i < fw->size; i++) |
| 675 | checksum += fw->data[i]; |
| 676 | |
| 677 | af9015_config.firmware_size = fw->size; |
| 678 | af9015_config.firmware_checksum = checksum; |
| 679 | |
| 680 | #define FW_PACKET_MAX_DATA 55 |
| 681 | |
| 682 | packets = fw->size / FW_PACKET_MAX_DATA; |
| 683 | remainder = fw->size % FW_PACKET_MAX_DATA; |
| 684 | len = FW_PACKET_MAX_DATA; |
| 685 | for (i = 0; i <= packets; i++) { |
| 686 | if (i == packets) /* set size of the last packet */ |
| 687 | len = remainder; |
| 688 | |
| 689 | req.data_len = len; |
Antti Palosaari | 541dfa8 | 2008-10-06 13:57:45 -0300 | [diff] [blame] | 690 | req.data = (u8 *)(fw->data + i * FW_PACKET_MAX_DATA); |
Antti Palosaari | 80619de | 2008-09-15 17:18:09 -0300 | [diff] [blame] | 691 | req.addr = addr; |
| 692 | addr += FW_PACKET_MAX_DATA; |
| 693 | |
| 694 | ret = af9015_rw_udev(udev, &req); |
| 695 | if (ret) { |
| 696 | err("firmware download failed at packet %d with " \ |
| 697 | "code %d", i, ret); |
| 698 | goto error; |
| 699 | } |
| 700 | } |
Antti Palosaari | 80619de | 2008-09-15 17:18:09 -0300 | [diff] [blame] | 701 | |
| 702 | /* firmware loaded, request boot */ |
| 703 | req.cmd = BOOT; |
| 704 | ret = af9015_rw_udev(udev, &req); |
| 705 | if (ret) { |
| 706 | err("firmware boot failed:%d", ret); |
| 707 | goto error; |
| 708 | } |
| 709 | |
Antti Palosaari | 80619de | 2008-09-15 17:18:09 -0300 | [diff] [blame] | 710 | error: |
| 711 | return ret; |
| 712 | } |
| 713 | |
| 714 | static int af9015_read_config(struct usb_device *udev) |
| 715 | { |
| 716 | int ret; |
| 717 | u8 val, i, offset = 0; |
| 718 | struct req_t req = {READ_I2C, AF9015_I2C_EEPROM, 0, 0, 1, 1, &val}; |
| 719 | char manufacturer[10]; |
| 720 | |
| 721 | /* IR remote controller */ |
| 722 | req.addr = AF9015_EEPROM_IR_MODE; |
Antti Palosaari | d1a470f | 2009-01-20 14:56:20 -0300 | [diff] [blame] | 723 | /* first message will timeout often due to possible hw bug */ |
| 724 | for (i = 0; i < 4; i++) { |
| 725 | ret = af9015_rw_udev(udev, &req); |
| 726 | if (!ret) |
| 727 | break; |
| 728 | } |
Antti Palosaari | 80619de | 2008-09-15 17:18:09 -0300 | [diff] [blame] | 729 | if (ret) |
| 730 | goto error; |
| 731 | deb_info("%s: IR mode:%d\n", __func__, val); |
| 732 | for (i = 0; i < af9015_properties_count; i++) { |
| 733 | if (val == AF9015_IR_MODE_DISABLED || val == 0x04) { |
| 734 | af9015_properties[i].rc_key_map = NULL; |
| 735 | af9015_properties[i].rc_key_map_size = 0; |
| 736 | } else if (dvb_usb_af9015_remote) { |
| 737 | /* load remote defined as module param */ |
| 738 | switch (dvb_usb_af9015_remote) { |
| 739 | case AF9015_REMOTE_A_LINK_DTU_M: |
| 740 | af9015_properties[i].rc_key_map = |
| 741 | af9015_rc_keys_a_link; |
| 742 | af9015_properties[i].rc_key_map_size = |
| 743 | ARRAY_SIZE(af9015_rc_keys_a_link); |
| 744 | af9015_config.ir_table = af9015_ir_table_a_link; |
| 745 | af9015_config.ir_table_size = |
| 746 | ARRAY_SIZE(af9015_ir_table_a_link); |
| 747 | break; |
| 748 | case AF9015_REMOTE_MSI_DIGIVOX_MINI_II_V3: |
| 749 | af9015_properties[i].rc_key_map = |
| 750 | af9015_rc_keys_msi; |
| 751 | af9015_properties[i].rc_key_map_size = |
| 752 | ARRAY_SIZE(af9015_rc_keys_msi); |
| 753 | af9015_config.ir_table = af9015_ir_table_msi; |
| 754 | af9015_config.ir_table_size = |
| 755 | ARRAY_SIZE(af9015_ir_table_msi); |
| 756 | break; |
| 757 | case AF9015_REMOTE_MYGICTV_U718: |
| 758 | af9015_properties[i].rc_key_map = |
| 759 | af9015_rc_keys_mygictv; |
| 760 | af9015_properties[i].rc_key_map_size = |
| 761 | ARRAY_SIZE(af9015_rc_keys_mygictv); |
| 762 | af9015_config.ir_table = |
| 763 | af9015_ir_table_mygictv; |
| 764 | af9015_config.ir_table_size = |
| 765 | ARRAY_SIZE(af9015_ir_table_mygictv); |
| 766 | break; |
Alain Kalker | 0537156 | 2008-11-17 17:20:38 -0300 | [diff] [blame] | 767 | case AF9015_REMOTE_DIGITTRADE_DVB_T: |
| 768 | af9015_properties[i].rc_key_map = |
| 769 | af9015_rc_keys_digittrade; |
| 770 | af9015_properties[i].rc_key_map_size = |
| 771 | ARRAY_SIZE(af9015_rc_keys_digittrade); |
| 772 | af9015_config.ir_table = |
| 773 | af9015_ir_table_digittrade; |
| 774 | af9015_config.ir_table_size = |
| 775 | ARRAY_SIZE(af9015_ir_table_digittrade); |
| 776 | break; |
Jose Alberto Reguero | 90b0f69 | 2009-01-23 19:23:23 -0300 | [diff] [blame] | 777 | case AF9015_REMOTE_AVERMEDIA_KS: |
| 778 | af9015_properties[i].rc_key_map = |
| 779 | af9015_rc_keys_avermedia; |
| 780 | af9015_properties[i].rc_key_map_size = |
| 781 | ARRAY_SIZE(af9015_rc_keys_avermedia); |
| 782 | af9015_config.ir_table = |
| 783 | af9015_ir_table_avermedia_ks; |
| 784 | af9015_config.ir_table_size = |
| 785 | ARRAY_SIZE(af9015_ir_table_avermedia_ks); |
| 786 | break; |
Antti Palosaari | 80619de | 2008-09-15 17:18:09 -0300 | [diff] [blame] | 787 | } |
| 788 | } else { |
Hans Verkuil | c58701b | 2008-11-20 05:37:05 -0300 | [diff] [blame] | 789 | switch (le16_to_cpu(udev->descriptor.idVendor)) { |
| 790 | case USB_VID_LEADTEK: |
Antti Palosaari | 80619de | 2008-09-15 17:18:09 -0300 | [diff] [blame] | 791 | af9015_properties[i].rc_key_map = |
| 792 | af9015_rc_keys_leadtek; |
| 793 | af9015_properties[i].rc_key_map_size = |
| 794 | ARRAY_SIZE(af9015_rc_keys_leadtek); |
| 795 | af9015_config.ir_table = |
| 796 | af9015_ir_table_leadtek; |
| 797 | af9015_config.ir_table_size = |
| 798 | ARRAY_SIZE(af9015_ir_table_leadtek); |
| 799 | break; |
Hans Verkuil | c58701b | 2008-11-20 05:37:05 -0300 | [diff] [blame] | 800 | case USB_VID_VISIONPLUS: |
Stuart Hall | 6252d25 | 2009-04-02 05:25:09 -0300 | [diff] [blame] | 801 | af9015_properties[i].rc_key_map = |
| 802 | af9015_rc_keys_twinhan; |
| 803 | af9015_properties[i].rc_key_map_size = |
| 804 | ARRAY_SIZE(af9015_rc_keys_twinhan); |
| 805 | af9015_config.ir_table = |
| 806 | af9015_ir_table_twinhan; |
| 807 | af9015_config.ir_table_size = |
| 808 | ARRAY_SIZE(af9015_ir_table_twinhan); |
Antti Palosaari | 80619de | 2008-09-15 17:18:09 -0300 | [diff] [blame] | 809 | break; |
Hans Verkuil | c58701b | 2008-11-20 05:37:05 -0300 | [diff] [blame] | 810 | case USB_VID_KWORLD_2: |
Antti Palosaari | 80619de | 2008-09-15 17:18:09 -0300 | [diff] [blame] | 811 | /* TODO: use correct rc keys */ |
| 812 | af9015_properties[i].rc_key_map = |
| 813 | af9015_rc_keys_twinhan; |
| 814 | af9015_properties[i].rc_key_map_size = |
| 815 | ARRAY_SIZE(af9015_rc_keys_twinhan); |
| 816 | af9015_config.ir_table = af9015_ir_table_kworld; |
| 817 | af9015_config.ir_table_size = |
| 818 | ARRAY_SIZE(af9015_ir_table_kworld); |
| 819 | break; |
| 820 | /* Check USB manufacturer and product strings and try |
| 821 | to determine correct remote in case of chip vendor |
| 822 | reference IDs are used. */ |
Hans Verkuil | c58701b | 2008-11-20 05:37:05 -0300 | [diff] [blame] | 823 | case USB_VID_AFATECH: |
Antti Palosaari | 80619de | 2008-09-15 17:18:09 -0300 | [diff] [blame] | 824 | memset(manufacturer, 0, sizeof(manufacturer)); |
| 825 | usb_string(udev, udev->descriptor.iManufacturer, |
| 826 | manufacturer, sizeof(manufacturer)); |
| 827 | if (!strcmp("Geniatech", manufacturer)) { |
| 828 | /* iManufacturer 1 Geniatech |
| 829 | iProduct 2 AF9015 */ |
| 830 | af9015_properties[i].rc_key_map = |
| 831 | af9015_rc_keys_mygictv; |
| 832 | af9015_properties[i].rc_key_map_size = |
| 833 | ARRAY_SIZE(af9015_rc_keys_mygictv); |
| 834 | af9015_config.ir_table = |
| 835 | af9015_ir_table_mygictv; |
| 836 | af9015_config.ir_table_size = |
| 837 | ARRAY_SIZE(af9015_ir_table_mygictv); |
| 838 | } else if (!strcmp("MSI", manufacturer)) { |
| 839 | /* iManufacturer 1 MSI |
| 840 | iProduct 2 MSI K-VOX */ |
| 841 | af9015_properties[i].rc_key_map = |
| 842 | af9015_rc_keys_msi; |
| 843 | af9015_properties[i].rc_key_map_size = |
| 844 | ARRAY_SIZE(af9015_rc_keys_msi); |
| 845 | af9015_config.ir_table = |
| 846 | af9015_ir_table_msi; |
| 847 | af9015_config.ir_table_size = |
| 848 | ARRAY_SIZE(af9015_ir_table_msi); |
Marc Schneider | 2614484 | 2009-03-26 21:07:18 -0300 | [diff] [blame] | 849 | } else if (udev->descriptor.idProduct == |
| 850 | cpu_to_le16(USB_PID_TREKSTOR_DVBT)) { |
| 851 | af9015_properties[i].rc_key_map = |
| 852 | af9015_rc_keys_trekstor; |
| 853 | af9015_properties[i].rc_key_map_size = |
| 854 | ARRAY_SIZE(af9015_rc_keys_trekstor); |
| 855 | af9015_config.ir_table = |
| 856 | af9015_ir_table_trekstor; |
| 857 | af9015_config.ir_table_size = |
| 858 | ARRAY_SIZE(af9015_ir_table_trekstor); |
Antti Palosaari | 80619de | 2008-09-15 17:18:09 -0300 | [diff] [blame] | 859 | } |
| 860 | break; |
Hans Verkuil | c58701b | 2008-11-20 05:37:05 -0300 | [diff] [blame] | 861 | case USB_VID_AVERMEDIA: |
Jose Alberto Reguero | c78de71 | 2008-11-04 11:38:01 -0300 | [diff] [blame] | 862 | af9015_properties[i].rc_key_map = |
| 863 | af9015_rc_keys_avermedia; |
| 864 | af9015_properties[i].rc_key_map_size = |
| 865 | ARRAY_SIZE(af9015_rc_keys_avermedia); |
| 866 | af9015_config.ir_table = |
| 867 | af9015_ir_table_avermedia; |
| 868 | af9015_config.ir_table_size = |
| 869 | ARRAY_SIZE(af9015_ir_table_avermedia); |
| 870 | break; |
Antti Palosaari | 80619de | 2008-09-15 17:18:09 -0300 | [diff] [blame] | 871 | } |
| 872 | } |
| 873 | } |
| 874 | |
| 875 | /* TS mode - one or two receivers */ |
| 876 | req.addr = AF9015_EEPROM_TS_MODE; |
| 877 | ret = af9015_rw_udev(udev, &req); |
| 878 | if (ret) |
| 879 | goto error; |
| 880 | af9015_config.dual_mode = val; |
| 881 | deb_info("%s: TS mode:%d\n", __func__, af9015_config.dual_mode); |
Antti Palosaari | 80619de | 2008-09-15 17:18:09 -0300 | [diff] [blame] | 882 | |
Antti Palosaari | f0830eb | 2009-01-13 13:08:29 -0300 | [diff] [blame] | 883 | /* Set adapter0 buffer size according to USB port speed, adapter1 buffer |
| 884 | size can be static because it is enabled only USB2.0 */ |
Antti Palosaari | 80619de | 2008-09-15 17:18:09 -0300 | [diff] [blame] | 885 | for (i = 0; i < af9015_properties_count; i++) { |
| 886 | /* USB1.1 set smaller buffersize and disable 2nd adapter */ |
| 887 | if (udev->speed == USB_SPEED_FULL) { |
Antti Palosaari | f0830eb | 2009-01-13 13:08:29 -0300 | [diff] [blame] | 888 | af9015_properties[i].adapter[0].stream.u.bulk.buffersize |
Antti Palosaari | 9c86327 | 2009-09-12 13:35:29 -0300 | [diff] [blame] | 889 | = TS_USB11_FRAME_SIZE; |
Antti Palosaari | 80619de | 2008-09-15 17:18:09 -0300 | [diff] [blame] | 890 | /* disable 2nd adapter because we don't have |
| 891 | PID-filters */ |
| 892 | af9015_config.dual_mode = 0; |
| 893 | } else { |
Antti Palosaari | f0830eb | 2009-01-13 13:08:29 -0300 | [diff] [blame] | 894 | af9015_properties[i].adapter[0].stream.u.bulk.buffersize |
Jose Alberto Reguero | 353330c | 2009-09-12 09:51:36 -0300 | [diff] [blame] | 895 | = TS_USB20_FRAME_SIZE; |
Antti Palosaari | 80619de | 2008-09-15 17:18:09 -0300 | [diff] [blame] | 896 | } |
| 897 | } |
| 898 | |
| 899 | if (af9015_config.dual_mode) { |
| 900 | /* read 2nd demodulator I2C address */ |
| 901 | req.addr = AF9015_EEPROM_DEMOD2_I2C; |
| 902 | ret = af9015_rw_udev(udev, &req); |
| 903 | if (ret) |
| 904 | goto error; |
| 905 | af9015_af9013_config[1].demod_address = val; |
| 906 | |
| 907 | /* enable 2nd adapter */ |
| 908 | for (i = 0; i < af9015_properties_count; i++) |
| 909 | af9015_properties[i].num_adapters = 2; |
| 910 | |
| 911 | } else { |
| 912 | /* disable 2nd adapter */ |
| 913 | for (i = 0; i < af9015_properties_count; i++) |
| 914 | af9015_properties[i].num_adapters = 1; |
| 915 | } |
| 916 | |
| 917 | for (i = 0; i < af9015_properties[0].num_adapters; i++) { |
| 918 | if (i == 1) |
| 919 | offset = AF9015_EEPROM_OFFSET; |
| 920 | /* xtal */ |
| 921 | req.addr = AF9015_EEPROM_XTAL_TYPE1 + offset; |
| 922 | ret = af9015_rw_udev(udev, &req); |
| 923 | if (ret) |
| 924 | goto error; |
| 925 | switch (val) { |
| 926 | case 0: |
| 927 | af9015_af9013_config[i].adc_clock = 28800; |
| 928 | break; |
| 929 | case 1: |
| 930 | af9015_af9013_config[i].adc_clock = 20480; |
| 931 | break; |
| 932 | case 2: |
| 933 | af9015_af9013_config[i].adc_clock = 28000; |
| 934 | break; |
| 935 | case 3: |
| 936 | af9015_af9013_config[i].adc_clock = 25000; |
| 937 | break; |
| 938 | }; |
| 939 | deb_info("%s: [%d] xtal:%d set adc_clock:%d\n", __func__, i, |
| 940 | val, af9015_af9013_config[i].adc_clock); |
| 941 | |
| 942 | /* tuner IF */ |
| 943 | req.addr = AF9015_EEPROM_IF1H + offset; |
| 944 | ret = af9015_rw_udev(udev, &req); |
| 945 | if (ret) |
| 946 | goto error; |
| 947 | af9015_af9013_config[i].tuner_if = val << 8; |
| 948 | req.addr = AF9015_EEPROM_IF1L + offset; |
| 949 | ret = af9015_rw_udev(udev, &req); |
| 950 | if (ret) |
| 951 | goto error; |
| 952 | af9015_af9013_config[i].tuner_if += val; |
| 953 | deb_info("%s: [%d] IF1:%d\n", __func__, i, |
| 954 | af9015_af9013_config[0].tuner_if); |
| 955 | |
| 956 | /* MT2060 IF1 */ |
| 957 | req.addr = AF9015_EEPROM_MT2060_IF1H + offset; |
| 958 | ret = af9015_rw_udev(udev, &req); |
| 959 | if (ret) |
| 960 | goto error; |
| 961 | af9015_config.mt2060_if1[i] = val << 8; |
| 962 | req.addr = AF9015_EEPROM_MT2060_IF1L + offset; |
| 963 | ret = af9015_rw_udev(udev, &req); |
| 964 | if (ret) |
| 965 | goto error; |
| 966 | af9015_config.mt2060_if1[i] += val; |
| 967 | deb_info("%s: [%d] MT2060 IF1:%d\n", __func__, i, |
| 968 | af9015_config.mt2060_if1[i]); |
| 969 | |
| 970 | /* tuner */ |
| 971 | req.addr = AF9015_EEPROM_TUNER_ID1 + offset; |
| 972 | ret = af9015_rw_udev(udev, &req); |
| 973 | if (ret) |
| 974 | goto error; |
| 975 | switch (val) { |
| 976 | case AF9013_TUNER_ENV77H11D5: |
| 977 | case AF9013_TUNER_MT2060: |
Antti Palosaari | 80619de | 2008-09-15 17:18:09 -0300 | [diff] [blame] | 978 | case AF9013_TUNER_QT1010: |
| 979 | case AF9013_TUNER_UNKNOWN: |
| 980 | case AF9013_TUNER_MT2060_2: |
| 981 | case AF9013_TUNER_TDA18271: |
| 982 | case AF9013_TUNER_QT1010A: |
| 983 | af9015_af9013_config[i].rf_spec_inv = 1; |
| 984 | break; |
| 985 | case AF9013_TUNER_MXL5003D: |
| 986 | case AF9013_TUNER_MXL5005D: |
| 987 | case AF9013_TUNER_MXL5005R: |
| 988 | af9015_af9013_config[i].rf_spec_inv = 0; |
| 989 | break; |
Jochen Friedrich | d563399 | 2009-02-02 14:59:50 -0300 | [diff] [blame] | 990 | case AF9013_TUNER_MC44S803: |
| 991 | af9015_af9013_config[i].gpio[1] = AF9013_GPIO_LO; |
| 992 | af9015_af9013_config[i].rf_spec_inv = 1; |
| 993 | break; |
Antti Palosaari | 80619de | 2008-09-15 17:18:09 -0300 | [diff] [blame] | 994 | default: |
| 995 | warn("tuner id:%d not supported, please report!", val); |
| 996 | return -ENODEV; |
| 997 | }; |
| 998 | |
| 999 | af9015_af9013_config[i].tuner = val; |
| 1000 | deb_info("%s: [%d] tuner id:%d\n", __func__, i, val); |
| 1001 | } |
| 1002 | |
| 1003 | error: |
| 1004 | if (ret) |
| 1005 | err("eeprom read failed:%d", ret); |
| 1006 | |
Antti Palosaari | 3956fef | 2009-03-31 17:01:02 -0300 | [diff] [blame] | 1007 | /* AverMedia AVerTV Volar Black HD (A850) device have bad EEPROM |
| 1008 | content :-( Override some wrong values here. */ |
| 1009 | if (le16_to_cpu(udev->descriptor.idVendor) == USB_VID_AVERMEDIA && |
| 1010 | le16_to_cpu(udev->descriptor.idProduct) == USB_PID_AVERMEDIA_A850) { |
| 1011 | deb_info("%s: AverMedia A850: overriding config\n", __func__); |
| 1012 | /* disable dual mode */ |
| 1013 | af9015_config.dual_mode = 0; |
| 1014 | /* disable 2nd adapter */ |
| 1015 | for (i = 0; i < af9015_properties_count; i++) |
| 1016 | af9015_properties[i].num_adapters = 1; |
| 1017 | |
| 1018 | /* set correct IF */ |
| 1019 | af9015_af9013_config[0].tuner_if = 4570; |
| 1020 | } |
| 1021 | |
Antti Palosaari | 80619de | 2008-09-15 17:18:09 -0300 | [diff] [blame] | 1022 | return ret; |
| 1023 | } |
| 1024 | |
| 1025 | static int af9015_identify_state(struct usb_device *udev, |
| 1026 | struct dvb_usb_device_properties *props, |
| 1027 | struct dvb_usb_device_description **desc, |
| 1028 | int *cold) |
| 1029 | { |
| 1030 | int ret; |
| 1031 | u8 reply; |
| 1032 | struct req_t req = {GET_CONFIG, 0, 0, 0, 0, 1, &reply}; |
| 1033 | |
| 1034 | ret = af9015_rw_udev(udev, &req); |
| 1035 | if (ret) |
| 1036 | return ret; |
| 1037 | |
| 1038 | deb_info("%s: reply:%02x\n", __func__, reply); |
| 1039 | if (reply == 0x02) |
| 1040 | *cold = 0; |
| 1041 | else |
| 1042 | *cold = 1; |
| 1043 | |
| 1044 | return ret; |
| 1045 | } |
| 1046 | |
| 1047 | static int af9015_rc_query(struct dvb_usb_device *d, u32 *event, int *state) |
| 1048 | { |
| 1049 | u8 buf[8]; |
| 1050 | struct req_t req = {GET_IR_CODE, 0, 0, 0, 0, sizeof(buf), buf}; |
| 1051 | struct dvb_usb_rc_key *keymap = d->props.rc_key_map; |
| 1052 | int i, ret; |
| 1053 | |
| 1054 | memset(buf, 0, sizeof(buf)); |
| 1055 | |
| 1056 | ret = af9015_ctrl_msg(d, &req); |
| 1057 | if (ret) |
| 1058 | return ret; |
| 1059 | |
| 1060 | *event = 0; |
| 1061 | *state = REMOTE_NO_KEY_PRESSED; |
| 1062 | |
| 1063 | for (i = 0; i < d->props.rc_key_map_size; i++) { |
Mauro Carvalho Chehab | 2e36588 | 2009-08-29 15:19:31 -0300 | [diff] [blame] | 1064 | if (!buf[1] && rc5_custom(&keymap[i]) == buf[0] && |
| 1065 | rc5_data(&keymap[i]) == buf[2]) { |
Antti Palosaari | 80619de | 2008-09-15 17:18:09 -0300 | [diff] [blame] | 1066 | *event = keymap[i].event; |
| 1067 | *state = REMOTE_KEY_PRESSED; |
| 1068 | break; |
| 1069 | } |
| 1070 | } |
| 1071 | if (!buf[1]) |
| 1072 | deb_rc("%s: %02x %02x %02x %02x %02x %02x %02x %02x\n", |
| 1073 | __func__, buf[0], buf[1], buf[2], buf[3], buf[4], |
| 1074 | buf[5], buf[6], buf[7]); |
| 1075 | |
| 1076 | return 0; |
| 1077 | } |
| 1078 | |
| 1079 | /* init 2nd I2C adapter */ |
Antti Palosaari | 349d042 | 2008-11-05 16:31:24 -0300 | [diff] [blame] | 1080 | static int af9015_i2c_init(struct dvb_usb_device *d) |
Antti Palosaari | 80619de | 2008-09-15 17:18:09 -0300 | [diff] [blame] | 1081 | { |
| 1082 | int ret; |
| 1083 | struct af9015_state *state = d->priv; |
| 1084 | deb_info("%s:\n", __func__); |
| 1085 | |
| 1086 | strncpy(state->i2c_adap.name, d->desc->name, |
| 1087 | sizeof(state->i2c_adap.name)); |
| 1088 | #ifdef I2C_ADAP_CLASS_TV_DIGITAL |
| 1089 | state->i2c_adap.class = I2C_ADAP_CLASS_TV_DIGITAL, |
| 1090 | #else |
| 1091 | state->i2c_adap.class = I2C_CLASS_TV_DIGITAL, |
| 1092 | #endif |
| 1093 | state->i2c_adap.algo = d->props.i2c_algo; |
| 1094 | state->i2c_adap.algo_data = NULL; |
| 1095 | state->i2c_adap.dev.parent = &d->udev->dev; |
| 1096 | |
| 1097 | i2c_set_adapdata(&state->i2c_adap, d); |
| 1098 | |
| 1099 | ret = i2c_add_adapter(&state->i2c_adap); |
| 1100 | if (ret < 0) |
| 1101 | err("could not add i2c adapter"); |
| 1102 | |
| 1103 | return ret; |
| 1104 | } |
| 1105 | |
| 1106 | static int af9015_af9013_frontend_attach(struct dvb_usb_adapter *adap) |
| 1107 | { |
| 1108 | int ret; |
| 1109 | struct af9015_state *state = adap->dev->priv; |
| 1110 | struct i2c_adapter *i2c_adap; |
| 1111 | |
| 1112 | if (adap->id == 0) { |
| 1113 | /* select I2C adapter */ |
| 1114 | i2c_adap = &adap->dev->i2c_adap; |
| 1115 | |
| 1116 | deb_info("%s: init I2C\n", __func__); |
| 1117 | ret = af9015_i2c_init(adap->dev); |
| 1118 | |
| 1119 | /* dump eeprom (debug) */ |
| 1120 | ret = af9015_eeprom_dump(adap->dev); |
| 1121 | if (ret) |
| 1122 | return ret; |
| 1123 | } else { |
| 1124 | /* select I2C adapter */ |
| 1125 | i2c_adap = &state->i2c_adap; |
| 1126 | |
| 1127 | /* copy firmware to 2nd demodulator */ |
| 1128 | if (af9015_config.dual_mode) { |
| 1129 | ret = af9015_copy_firmware(adap->dev); |
| 1130 | if (ret) { |
| 1131 | err("firmware copy to 2nd frontend " \ |
| 1132 | "failed, will disable it"); |
| 1133 | af9015_config.dual_mode = 0; |
| 1134 | return -ENODEV; |
| 1135 | } |
| 1136 | } else { |
| 1137 | return -ENODEV; |
| 1138 | } |
| 1139 | } |
| 1140 | |
| 1141 | /* attach demodulator */ |
| 1142 | adap->fe = dvb_attach(af9013_attach, &af9015_af9013_config[adap->id], |
| 1143 | i2c_adap); |
| 1144 | |
| 1145 | return adap->fe == NULL ? -ENODEV : 0; |
| 1146 | } |
| 1147 | |
| 1148 | static struct mt2060_config af9015_mt2060_config = { |
| 1149 | .i2c_address = 0xc0, |
| 1150 | .clock_out = 0, |
| 1151 | }; |
| 1152 | |
| 1153 | static struct qt1010_config af9015_qt1010_config = { |
| 1154 | .i2c_address = 0xc4, |
| 1155 | }; |
| 1156 | |
| 1157 | static struct tda18271_config af9015_tda18271_config = { |
| 1158 | .gate = TDA18271_GATE_DIGITAL, |
| 1159 | .small_i2c = 1, |
| 1160 | }; |
| 1161 | |
| 1162 | static struct mxl5005s_config af9015_mxl5003_config = { |
| 1163 | .i2c_address = 0xc6, |
| 1164 | .if_freq = IF_FREQ_4570000HZ, |
| 1165 | .xtal_freq = CRYSTAL_FREQ_16000000HZ, |
| 1166 | .agc_mode = MXL_SINGLE_AGC, |
| 1167 | .tracking_filter = MXL_TF_DEFAULT, |
Antti Palosaari | a131077 | 2008-09-22 13:59:25 -0300 | [diff] [blame] | 1168 | .rssi_enable = MXL_RSSI_ENABLE, |
Antti Palosaari | 80619de | 2008-09-15 17:18:09 -0300 | [diff] [blame] | 1169 | .cap_select = MXL_CAP_SEL_ENABLE, |
| 1170 | .div_out = MXL_DIV_OUT_4, |
| 1171 | .clock_out = MXL_CLOCK_OUT_DISABLE, |
| 1172 | .output_load = MXL5005S_IF_OUTPUT_LOAD_200_OHM, |
| 1173 | .top = MXL5005S_TOP_25P2, |
| 1174 | .mod_mode = MXL_DIGITAL_MODE, |
| 1175 | .if_mode = MXL_ZERO_IF, |
| 1176 | .AgcMasterByte = 0x00, |
| 1177 | }; |
| 1178 | |
| 1179 | static struct mxl5005s_config af9015_mxl5005_config = { |
| 1180 | .i2c_address = 0xc6, |
| 1181 | .if_freq = IF_FREQ_4570000HZ, |
| 1182 | .xtal_freq = CRYSTAL_FREQ_16000000HZ, |
| 1183 | .agc_mode = MXL_SINGLE_AGC, |
| 1184 | .tracking_filter = MXL_TF_OFF, |
Antti Palosaari | a131077 | 2008-09-22 13:59:25 -0300 | [diff] [blame] | 1185 | .rssi_enable = MXL_RSSI_ENABLE, |
Antti Palosaari | 80619de | 2008-09-15 17:18:09 -0300 | [diff] [blame] | 1186 | .cap_select = MXL_CAP_SEL_ENABLE, |
| 1187 | .div_out = MXL_DIV_OUT_4, |
| 1188 | .clock_out = MXL_CLOCK_OUT_DISABLE, |
| 1189 | .output_load = MXL5005S_IF_OUTPUT_LOAD_200_OHM, |
| 1190 | .top = MXL5005S_TOP_25P2, |
| 1191 | .mod_mode = MXL_DIGITAL_MODE, |
| 1192 | .if_mode = MXL_ZERO_IF, |
| 1193 | .AgcMasterByte = 0x00, |
| 1194 | }; |
| 1195 | |
Jochen Friedrich | d563399 | 2009-02-02 14:59:50 -0300 | [diff] [blame] | 1196 | static struct mc44s803_config af9015_mc44s803_config = { |
| 1197 | .i2c_address = 0xc0, |
| 1198 | .dig_out = 1, |
| 1199 | }; |
| 1200 | |
Antti Palosaari | 80619de | 2008-09-15 17:18:09 -0300 | [diff] [blame] | 1201 | static int af9015_tuner_attach(struct dvb_usb_adapter *adap) |
| 1202 | { |
| 1203 | struct af9015_state *state = adap->dev->priv; |
| 1204 | struct i2c_adapter *i2c_adap; |
| 1205 | int ret; |
| 1206 | deb_info("%s: \n", __func__); |
| 1207 | |
| 1208 | /* select I2C adapter */ |
| 1209 | if (adap->id == 0) |
| 1210 | i2c_adap = &adap->dev->i2c_adap; |
| 1211 | else |
| 1212 | i2c_adap = &state->i2c_adap; |
| 1213 | |
| 1214 | switch (af9015_af9013_config[adap->id].tuner) { |
| 1215 | case AF9013_TUNER_MT2060: |
| 1216 | case AF9013_TUNER_MT2060_2: |
| 1217 | ret = dvb_attach(mt2060_attach, adap->fe, i2c_adap, |
| 1218 | &af9015_mt2060_config, |
| 1219 | af9015_config.mt2060_if1[adap->id]) |
| 1220 | == NULL ? -ENODEV : 0; |
| 1221 | break; |
| 1222 | case AF9013_TUNER_QT1010: |
| 1223 | case AF9013_TUNER_QT1010A: |
| 1224 | ret = dvb_attach(qt1010_attach, adap->fe, i2c_adap, |
| 1225 | &af9015_qt1010_config) == NULL ? -ENODEV : 0; |
| 1226 | break; |
| 1227 | case AF9013_TUNER_TDA18271: |
| 1228 | ret = dvb_attach(tda18271_attach, adap->fe, 0xc0, i2c_adap, |
| 1229 | &af9015_tda18271_config) == NULL ? -ENODEV : 0; |
| 1230 | break; |
| 1231 | case AF9013_TUNER_MXL5003D: |
| 1232 | ret = dvb_attach(mxl5005s_attach, adap->fe, i2c_adap, |
| 1233 | &af9015_mxl5003_config) == NULL ? -ENODEV : 0; |
| 1234 | break; |
| 1235 | case AF9013_TUNER_MXL5005D: |
| 1236 | case AF9013_TUNER_MXL5005R: |
| 1237 | ret = dvb_attach(mxl5005s_attach, adap->fe, i2c_adap, |
| 1238 | &af9015_mxl5005_config) == NULL ? -ENODEV : 0; |
| 1239 | break; |
| 1240 | case AF9013_TUNER_ENV77H11D5: |
| 1241 | ret = dvb_attach(dvb_pll_attach, adap->fe, 0xc0, i2c_adap, |
| 1242 | DVB_PLL_TDA665X) == NULL ? -ENODEV : 0; |
| 1243 | break; |
| 1244 | case AF9013_TUNER_MC44S803: |
Jochen Friedrich | d563399 | 2009-02-02 14:59:50 -0300 | [diff] [blame] | 1245 | ret = dvb_attach(mc44s803_attach, adap->fe, i2c_adap, |
| 1246 | &af9015_mc44s803_config) == NULL ? -ENODEV : 0; |
Antti Palosaari | 80619de | 2008-09-15 17:18:09 -0300 | [diff] [blame] | 1247 | break; |
| 1248 | case AF9013_TUNER_UNKNOWN: |
| 1249 | default: |
| 1250 | ret = -ENODEV; |
| 1251 | err("Unknown tuner id:%d", |
| 1252 | af9015_af9013_config[adap->id].tuner); |
| 1253 | } |
| 1254 | return ret; |
| 1255 | } |
| 1256 | |
| 1257 | static struct usb_device_id af9015_usb_table[] = { |
| 1258 | /* 0 */{USB_DEVICE(USB_VID_AFATECH, USB_PID_AFATECH_AF9015_9015)}, |
| 1259 | {USB_DEVICE(USB_VID_AFATECH, USB_PID_AFATECH_AF9015_9016)}, |
| 1260 | {USB_DEVICE(USB_VID_LEADTEK, USB_PID_WINFAST_DTV_DONGLE_GOLD)}, |
| 1261 | {USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV71E)}, |
| 1262 | {USB_DEVICE(USB_VID_KWORLD_2, USB_PID_KWORLD_399U)}, |
| 1263 | /* 5 */{USB_DEVICE(USB_VID_VISIONPLUS, |
| 1264 | USB_PID_TINYTWIN)}, |
| 1265 | {USB_DEVICE(USB_VID_VISIONPLUS, |
| 1266 | USB_PID_AZUREWAVE_AD_TU700)}, |
| 1267 | {USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_T_USB_XE_REV2)}, |
| 1268 | {USB_DEVICE(USB_VID_KWORLD_2, USB_PID_KWORLD_PC160_2T)}, |
| 1269 | {USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_VOLAR_X)}, |
| 1270 | /* 10 */{USB_DEVICE(USB_VID_XTENSIONS, USB_PID_XTENSIONS_XD_380)}, |
| 1271 | {USB_DEVICE(USB_VID_MSI_2, USB_PID_MSI_DIGIVOX_DUO)}, |
| 1272 | {USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_VOLAR_X_2)}, |
Antti Palosaari | a376588 | 2008-09-19 18:34:06 -0300 | [diff] [blame] | 1273 | {USB_DEVICE(USB_VID_TELESTAR, USB_PID_TELESTAR_STARSTICK_2)}, |
Antti Palosaari | 05c1cab | 2008-09-22 12:32:37 -0300 | [diff] [blame] | 1274 | {USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_A309)}, |
Herbert Graeber | 641015a | 2008-10-07 10:06:36 -0300 | [diff] [blame] | 1275 | /* 15 */{USB_DEVICE(USB_VID_MSI_2, USB_PID_MSI_DIGI_VOX_MINI_III)}, |
Antti Palosaari | 163e9cd | 2008-11-04 12:57:47 -0300 | [diff] [blame] | 1276 | {USB_DEVICE(USB_VID_KWORLD_2, USB_PID_KWORLD_395U)}, |
Antti Palosaari | 71bf2e0 | 2009-01-13 12:47:28 -0300 | [diff] [blame] | 1277 | {USB_DEVICE(USB_VID_KWORLD_2, USB_PID_KWORLD_395U_2)}, |
Antti Palosaari | 58fe159 | 2009-03-26 20:41:05 -0300 | [diff] [blame] | 1278 | {USB_DEVICE(USB_VID_KWORLD_2, USB_PID_KWORLD_395U_3)}, |
Marc Schneider | 2614484 | 2009-03-26 21:07:18 -0300 | [diff] [blame] | 1279 | {USB_DEVICE(USB_VID_AFATECH, USB_PID_TREKSTOR_DVBT)}, |
Antti Palosaari | 1ed5fad | 2009-04-09 15:14:18 -0300 | [diff] [blame] | 1280 | /* 20 */{USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_A850)}, |
| 1281 | {USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_A805)}, |
Marcel Jueling | 734dd23 | 2009-04-09 17:16:41 -0300 | [diff] [blame] | 1282 | {USB_DEVICE(USB_VID_KWORLD_2, USB_PID_CONCEPTRONIC_CTVDIGRCU)}, |
Wen-chien Jesse Sung | 6e9c1a2 | 2009-04-28 01:11:22 -0300 | [diff] [blame] | 1283 | {USB_DEVICE(USB_VID_KWORLD_2, USB_PID_KWORLD_MC810)}, |
Antti Palosaari | 22d4645 | 2009-05-31 17:07:01 -0300 | [diff] [blame] | 1284 | {USB_DEVICE(USB_VID_KYE, USB_PID_GENIUS_TVGO_DVB_T03)}, |
Mart Raudsepp | c92f056 | 2009-07-24 13:45:41 -0300 | [diff] [blame] | 1285 | /* 25 */{USB_DEVICE(USB_VID_KWORLD_2, USB_PID_KWORLD_399U_2)}, |
Antti Palosaari | 486ba12 | 2009-09-18 13:37:57 -0300 | [diff] [blame] | 1286 | {USB_DEVICE(USB_VID_KWORLD_2, USB_PID_KWORLD_PC160_T)}, |
Antti Palosaari | 80619de | 2008-09-15 17:18:09 -0300 | [diff] [blame] | 1287 | {0}, |
| 1288 | }; |
| 1289 | MODULE_DEVICE_TABLE(usb, af9015_usb_table); |
| 1290 | |
| 1291 | static struct dvb_usb_device_properties af9015_properties[] = { |
| 1292 | { |
| 1293 | .caps = DVB_USB_IS_AN_I2C_ADAPTER, |
| 1294 | |
| 1295 | .usb_ctrl = DEVICE_SPECIFIC, |
| 1296 | .download_firmware = af9015_download_firmware, |
| 1297 | .firmware = "dvb-usb-af9015.fw", |
Jose Alberto Reguero | cce2571 | 2008-11-13 14:14:18 -0300 | [diff] [blame] | 1298 | .no_reconnect = 1, |
Antti Palosaari | 80619de | 2008-09-15 17:18:09 -0300 | [diff] [blame] | 1299 | |
Antti Palosaari | 0254294 | 2009-09-16 20:33:03 -0300 | [diff] [blame^] | 1300 | .size_of_priv = sizeof(struct af9015_state), |
Antti Palosaari | 80619de | 2008-09-15 17:18:09 -0300 | [diff] [blame] | 1301 | |
| 1302 | .num_adapters = 2, |
| 1303 | .adapter = { |
| 1304 | { |
| 1305 | .caps = DVB_USB_ADAP_HAS_PID_FILTER | |
| 1306 | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF, |
| 1307 | |
| 1308 | .pid_filter_count = 32, |
| 1309 | .pid_filter = af9015_pid_filter, |
| 1310 | .pid_filter_ctrl = af9015_pid_filter_ctrl, |
| 1311 | |
| 1312 | .frontend_attach = |
| 1313 | af9015_af9013_frontend_attach, |
| 1314 | .tuner_attach = af9015_tuner_attach, |
| 1315 | .stream = { |
| 1316 | .type = USB_BULK, |
| 1317 | .count = 6, |
| 1318 | .endpoint = 0x84, |
| 1319 | }, |
| 1320 | }, |
| 1321 | { |
| 1322 | .frontend_attach = |
| 1323 | af9015_af9013_frontend_attach, |
| 1324 | .tuner_attach = af9015_tuner_attach, |
| 1325 | .stream = { |
| 1326 | .type = USB_BULK, |
| 1327 | .count = 6, |
| 1328 | .endpoint = 0x85, |
Antti Palosaari | f0830eb | 2009-01-13 13:08:29 -0300 | [diff] [blame] | 1329 | .u = { |
| 1330 | .bulk = { |
| 1331 | .buffersize = |
Jose Alberto Reguero | 353330c | 2009-09-12 09:51:36 -0300 | [diff] [blame] | 1332 | TS_USB20_FRAME_SIZE, |
Antti Palosaari | f0830eb | 2009-01-13 13:08:29 -0300 | [diff] [blame] | 1333 | } |
| 1334 | } |
Antti Palosaari | 80619de | 2008-09-15 17:18:09 -0300 | [diff] [blame] | 1335 | }, |
| 1336 | } |
| 1337 | }, |
| 1338 | |
| 1339 | .identify_state = af9015_identify_state, |
| 1340 | |
| 1341 | .rc_query = af9015_rc_query, |
| 1342 | .rc_interval = 150, |
| 1343 | |
| 1344 | .i2c_algo = &af9015_i2c_algo, |
| 1345 | |
Antti Palosaari | 85d7d7c | 2009-04-09 09:16:12 -0300 | [diff] [blame] | 1346 | .num_device_descs = 9, /* max 9 */ |
Antti Palosaari | 80619de | 2008-09-15 17:18:09 -0300 | [diff] [blame] | 1347 | .devices = { |
| 1348 | { |
| 1349 | .name = "Afatech AF9015 DVB-T USB2.0 stick", |
| 1350 | .cold_ids = {&af9015_usb_table[0], |
| 1351 | &af9015_usb_table[1], NULL}, |
| 1352 | .warm_ids = {NULL}, |
| 1353 | }, |
| 1354 | { |
| 1355 | .name = "Leadtek WinFast DTV Dongle Gold", |
| 1356 | .cold_ids = {&af9015_usb_table[2], NULL}, |
| 1357 | .warm_ids = {NULL}, |
| 1358 | }, |
| 1359 | { |
| 1360 | .name = "Pinnacle PCTV 71e", |
| 1361 | .cold_ids = {&af9015_usb_table[3], NULL}, |
| 1362 | .warm_ids = {NULL}, |
| 1363 | }, |
| 1364 | { |
| 1365 | .name = "KWorld PlusTV Dual DVB-T Stick " \ |
| 1366 | "(DVB-T 399U)", |
Mart Raudsepp | c92f056 | 2009-07-24 13:45:41 -0300 | [diff] [blame] | 1367 | .cold_ids = {&af9015_usb_table[4], |
| 1368 | &af9015_usb_table[25], NULL}, |
Antti Palosaari | 80619de | 2008-09-15 17:18:09 -0300 | [diff] [blame] | 1369 | .warm_ids = {NULL}, |
| 1370 | }, |
| 1371 | { |
| 1372 | .name = "DigitalNow TinyTwin DVB-T Receiver", |
| 1373 | .cold_ids = {&af9015_usb_table[5], NULL}, |
| 1374 | .warm_ids = {NULL}, |
| 1375 | }, |
| 1376 | { |
| 1377 | .name = "TwinHan AzureWave AD-TU700(704J)", |
| 1378 | .cold_ids = {&af9015_usb_table[6], NULL}, |
| 1379 | .warm_ids = {NULL}, |
| 1380 | }, |
| 1381 | { |
| 1382 | .name = "TerraTec Cinergy T USB XE", |
| 1383 | .cold_ids = {&af9015_usb_table[7], NULL}, |
| 1384 | .warm_ids = {NULL}, |
| 1385 | }, |
| 1386 | { |
| 1387 | .name = "KWorld PlusTV Dual DVB-T PCI " \ |
| 1388 | "(DVB-T PC160-2T)", |
| 1389 | .cold_ids = {&af9015_usb_table[8], NULL}, |
| 1390 | .warm_ids = {NULL}, |
| 1391 | }, |
| 1392 | { |
| 1393 | .name = "AVerMedia AVerTV DVB-T Volar X", |
| 1394 | .cold_ids = {&af9015_usb_table[9], NULL}, |
| 1395 | .warm_ids = {NULL}, |
| 1396 | }, |
| 1397 | } |
| 1398 | }, { |
| 1399 | .caps = DVB_USB_IS_AN_I2C_ADAPTER, |
| 1400 | |
| 1401 | .usb_ctrl = DEVICE_SPECIFIC, |
| 1402 | .download_firmware = af9015_download_firmware, |
| 1403 | .firmware = "dvb-usb-af9015.fw", |
Jose Alberto Reguero | cce2571 | 2008-11-13 14:14:18 -0300 | [diff] [blame] | 1404 | .no_reconnect = 1, |
Antti Palosaari | 80619de | 2008-09-15 17:18:09 -0300 | [diff] [blame] | 1405 | |
Antti Palosaari | 0254294 | 2009-09-16 20:33:03 -0300 | [diff] [blame^] | 1406 | .size_of_priv = sizeof(struct af9015_state), |
Antti Palosaari | 80619de | 2008-09-15 17:18:09 -0300 | [diff] [blame] | 1407 | |
| 1408 | .num_adapters = 2, |
| 1409 | .adapter = { |
| 1410 | { |
| 1411 | .caps = DVB_USB_ADAP_HAS_PID_FILTER | |
| 1412 | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF, |
| 1413 | |
| 1414 | .pid_filter_count = 32, |
| 1415 | .pid_filter = af9015_pid_filter, |
| 1416 | .pid_filter_ctrl = af9015_pid_filter_ctrl, |
| 1417 | |
| 1418 | .frontend_attach = |
| 1419 | af9015_af9013_frontend_attach, |
| 1420 | .tuner_attach = af9015_tuner_attach, |
| 1421 | .stream = { |
| 1422 | .type = USB_BULK, |
| 1423 | .count = 6, |
| 1424 | .endpoint = 0x84, |
| 1425 | }, |
| 1426 | }, |
| 1427 | { |
| 1428 | .frontend_attach = |
| 1429 | af9015_af9013_frontend_attach, |
| 1430 | .tuner_attach = af9015_tuner_attach, |
| 1431 | .stream = { |
| 1432 | .type = USB_BULK, |
| 1433 | .count = 6, |
| 1434 | .endpoint = 0x85, |
Antti Palosaari | f0830eb | 2009-01-13 13:08:29 -0300 | [diff] [blame] | 1435 | .u = { |
| 1436 | .bulk = { |
| 1437 | .buffersize = |
Jose Alberto Reguero | 353330c | 2009-09-12 09:51:36 -0300 | [diff] [blame] | 1438 | TS_USB20_FRAME_SIZE, |
Antti Palosaari | f0830eb | 2009-01-13 13:08:29 -0300 | [diff] [blame] | 1439 | } |
| 1440 | } |
Antti Palosaari | 80619de | 2008-09-15 17:18:09 -0300 | [diff] [blame] | 1441 | }, |
| 1442 | } |
| 1443 | }, |
| 1444 | |
| 1445 | .identify_state = af9015_identify_state, |
| 1446 | |
| 1447 | .rc_query = af9015_rc_query, |
| 1448 | .rc_interval = 150, |
| 1449 | |
| 1450 | .i2c_algo = &af9015_i2c_algo, |
| 1451 | |
Antti Palosaari | 85d7d7c | 2009-04-09 09:16:12 -0300 | [diff] [blame] | 1452 | .num_device_descs = 9, /* max 9 */ |
Antti Palosaari | 80619de | 2008-09-15 17:18:09 -0300 | [diff] [blame] | 1453 | .devices = { |
| 1454 | { |
| 1455 | .name = "Xtensions XD-380", |
| 1456 | .cold_ids = {&af9015_usb_table[10], NULL}, |
| 1457 | .warm_ids = {NULL}, |
| 1458 | }, |
| 1459 | { |
| 1460 | .name = "MSI DIGIVOX Duo", |
| 1461 | .cold_ids = {&af9015_usb_table[11], NULL}, |
| 1462 | .warm_ids = {NULL}, |
| 1463 | }, |
| 1464 | { |
| 1465 | .name = "Fujitsu-Siemens Slim Mobile USB DVB-T", |
| 1466 | .cold_ids = {&af9015_usb_table[12], NULL}, |
| 1467 | .warm_ids = {NULL}, |
| 1468 | }, |
Mikko Ohtamaa | 111f9ec | 2008-09-19 18:26:05 -0300 | [diff] [blame] | 1469 | { |
Antti Palosaari | a376588 | 2008-09-19 18:34:06 -0300 | [diff] [blame] | 1470 | .name = "Telestar Starstick 2", |
Mikko Ohtamaa | 111f9ec | 2008-09-19 18:26:05 -0300 | [diff] [blame] | 1471 | .cold_ids = {&af9015_usb_table[13], NULL}, |
| 1472 | .warm_ids = {NULL}, |
| 1473 | }, |
Antti Palosaari | 05c1cab | 2008-09-22 12:32:37 -0300 | [diff] [blame] | 1474 | { |
| 1475 | .name = "AVerMedia A309", |
| 1476 | .cold_ids = {&af9015_usb_table[14], NULL}, |
| 1477 | .warm_ids = {NULL}, |
| 1478 | }, |
Herbert Graeber | 641015a | 2008-10-07 10:06:36 -0300 | [diff] [blame] | 1479 | { |
| 1480 | .name = "MSI Digi VOX mini III", |
| 1481 | .cold_ids = {&af9015_usb_table[15], NULL}, |
| 1482 | .warm_ids = {NULL}, |
| 1483 | }, |
Antti Palosaari | 163e9cd | 2008-11-04 12:57:47 -0300 | [diff] [blame] | 1484 | { |
| 1485 | .name = "KWorld USB DVB-T TV Stick II " \ |
| 1486 | "(VS-DVB-T 395U)", |
Antti Palosaari | 71bf2e0 | 2009-01-13 12:47:28 -0300 | [diff] [blame] | 1487 | .cold_ids = {&af9015_usb_table[16], |
Antti Palosaari | 58fe159 | 2009-03-26 20:41:05 -0300 | [diff] [blame] | 1488 | &af9015_usb_table[17], |
| 1489 | &af9015_usb_table[18], NULL}, |
Antti Palosaari | 163e9cd | 2008-11-04 12:57:47 -0300 | [diff] [blame] | 1490 | .warm_ids = {NULL}, |
| 1491 | }, |
Marc Schneider | 2614484 | 2009-03-26 21:07:18 -0300 | [diff] [blame] | 1492 | { |
| 1493 | .name = "TrekStor DVB-T USB Stick", |
| 1494 | .cold_ids = {&af9015_usb_table[19], NULL}, |
| 1495 | .warm_ids = {NULL}, |
| 1496 | }, |
Antti Palosaari | 3956fef | 2009-03-31 17:01:02 -0300 | [diff] [blame] | 1497 | { |
| 1498 | .name = "AverMedia AVerTV Volar Black HD " \ |
| 1499 | "(A850)", |
| 1500 | .cold_ids = {&af9015_usb_table[20], NULL}, |
| 1501 | .warm_ids = {NULL}, |
| 1502 | }, |
Antti Palosaari | 80619de | 2008-09-15 17:18:09 -0300 | [diff] [blame] | 1503 | } |
Antti Palosaari | 85d7d7c | 2009-04-09 09:16:12 -0300 | [diff] [blame] | 1504 | }, { |
| 1505 | .caps = DVB_USB_IS_AN_I2C_ADAPTER, |
| 1506 | |
| 1507 | .usb_ctrl = DEVICE_SPECIFIC, |
| 1508 | .download_firmware = af9015_download_firmware, |
| 1509 | .firmware = "dvb-usb-af9015.fw", |
| 1510 | .no_reconnect = 1, |
| 1511 | |
Antti Palosaari | 0254294 | 2009-09-16 20:33:03 -0300 | [diff] [blame^] | 1512 | .size_of_priv = sizeof(struct af9015_state), |
Antti Palosaari | 85d7d7c | 2009-04-09 09:16:12 -0300 | [diff] [blame] | 1513 | |
| 1514 | .num_adapters = 2, |
| 1515 | .adapter = { |
| 1516 | { |
| 1517 | .caps = DVB_USB_ADAP_HAS_PID_FILTER | |
| 1518 | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF, |
| 1519 | |
| 1520 | .pid_filter_count = 32, |
| 1521 | .pid_filter = af9015_pid_filter, |
| 1522 | .pid_filter_ctrl = af9015_pid_filter_ctrl, |
| 1523 | |
| 1524 | .frontend_attach = |
| 1525 | af9015_af9013_frontend_attach, |
| 1526 | .tuner_attach = af9015_tuner_attach, |
| 1527 | .stream = { |
| 1528 | .type = USB_BULK, |
| 1529 | .count = 6, |
| 1530 | .endpoint = 0x84, |
| 1531 | }, |
| 1532 | }, |
| 1533 | { |
| 1534 | .frontend_attach = |
| 1535 | af9015_af9013_frontend_attach, |
| 1536 | .tuner_attach = af9015_tuner_attach, |
| 1537 | .stream = { |
| 1538 | .type = USB_BULK, |
| 1539 | .count = 6, |
| 1540 | .endpoint = 0x85, |
| 1541 | .u = { |
| 1542 | .bulk = { |
| 1543 | .buffersize = |
Jose Alberto Reguero | 353330c | 2009-09-12 09:51:36 -0300 | [diff] [blame] | 1544 | TS_USB20_FRAME_SIZE, |
Antti Palosaari | 85d7d7c | 2009-04-09 09:16:12 -0300 | [diff] [blame] | 1545 | } |
| 1546 | } |
| 1547 | }, |
| 1548 | } |
| 1549 | }, |
| 1550 | |
| 1551 | .identify_state = af9015_identify_state, |
| 1552 | |
| 1553 | .rc_query = af9015_rc_query, |
| 1554 | .rc_interval = 150, |
| 1555 | |
| 1556 | .i2c_algo = &af9015_i2c_algo, |
| 1557 | |
Antti Palosaari | 486ba12 | 2009-09-18 13:37:57 -0300 | [diff] [blame] | 1558 | .num_device_descs = 5, /* max 9 */ |
Antti Palosaari | 85d7d7c | 2009-04-09 09:16:12 -0300 | [diff] [blame] | 1559 | .devices = { |
Antti Palosaari | 1ed5fad | 2009-04-09 15:14:18 -0300 | [diff] [blame] | 1560 | { |
| 1561 | .name = "AverMedia AVerTV Volar GPS 805 (A805)", |
| 1562 | .cold_ids = {&af9015_usb_table[21], NULL}, |
| 1563 | .warm_ids = {NULL}, |
| 1564 | }, |
Marcel Jueling | 734dd23 | 2009-04-09 17:16:41 -0300 | [diff] [blame] | 1565 | { |
| 1566 | .name = "Conceptronic USB2.0 DVB-T CTVDIGRCU " \ |
| 1567 | "V3.0", |
| 1568 | .cold_ids = {&af9015_usb_table[22], NULL}, |
| 1569 | .warm_ids = {NULL}, |
| 1570 | }, |
Wen-chien Jesse Sung | 6e9c1a2 | 2009-04-28 01:11:22 -0300 | [diff] [blame] | 1571 | { |
| 1572 | .name = "KWorld Digial MC-810", |
| 1573 | .cold_ids = {&af9015_usb_table[23], NULL}, |
| 1574 | .warm_ids = {NULL}, |
| 1575 | }, |
Antti Palosaari | 22d4645 | 2009-05-31 17:07:01 -0300 | [diff] [blame] | 1576 | { |
| 1577 | .name = "Genius TVGo DVB-T03", |
| 1578 | .cold_ids = {&af9015_usb_table[24], NULL}, |
| 1579 | .warm_ids = {NULL}, |
| 1580 | }, |
Antti Palosaari | 486ba12 | 2009-09-18 13:37:57 -0300 | [diff] [blame] | 1581 | { |
| 1582 | .name = "KWorld PlusTV DVB-T PCI Pro Card " \ |
| 1583 | "(DVB-T PC160-T)", |
| 1584 | .cold_ids = {&af9015_usb_table[26], NULL}, |
| 1585 | .warm_ids = {NULL}, |
| 1586 | }, |
Antti Palosaari | 85d7d7c | 2009-04-09 09:16:12 -0300 | [diff] [blame] | 1587 | } |
| 1588 | }, |
Antti Palosaari | 80619de | 2008-09-15 17:18:09 -0300 | [diff] [blame] | 1589 | }; |
Antti Palosaari | 80619de | 2008-09-15 17:18:09 -0300 | [diff] [blame] | 1590 | |
| 1591 | static int af9015_usb_probe(struct usb_interface *intf, |
| 1592 | const struct usb_device_id *id) |
| 1593 | { |
| 1594 | int ret = 0; |
| 1595 | struct dvb_usb_device *d = NULL; |
| 1596 | struct usb_device *udev = interface_to_usbdev(intf); |
| 1597 | u8 i; |
| 1598 | |
| 1599 | deb_info("%s: interface:%d\n", __func__, |
| 1600 | intf->cur_altsetting->desc.bInterfaceNumber); |
| 1601 | |
| 1602 | /* interface 0 is used by DVB-T receiver and |
| 1603 | interface 1 is for remote controller (HID) */ |
| 1604 | if (intf->cur_altsetting->desc.bInterfaceNumber == 0) { |
| 1605 | ret = af9015_read_config(udev); |
| 1606 | if (ret) |
| 1607 | return ret; |
| 1608 | |
| 1609 | for (i = 0; i < af9015_properties_count; i++) { |
| 1610 | ret = dvb_usb_device_init(intf, &af9015_properties[i], |
| 1611 | THIS_MODULE, &d, adapter_nr); |
| 1612 | if (!ret) |
| 1613 | break; |
| 1614 | if (ret != -ENODEV) |
| 1615 | return ret; |
| 1616 | } |
| 1617 | if (ret) |
| 1618 | return ret; |
| 1619 | |
| 1620 | if (d) |
| 1621 | ret = af9015_init(d); |
| 1622 | } |
| 1623 | |
| 1624 | return ret; |
| 1625 | } |
| 1626 | |
Antti Palosaari | 349d042 | 2008-11-05 16:31:24 -0300 | [diff] [blame] | 1627 | static void af9015_i2c_exit(struct dvb_usb_device *d) |
Antti Palosaari | 80619de | 2008-09-15 17:18:09 -0300 | [diff] [blame] | 1628 | { |
| 1629 | struct af9015_state *state = d->priv; |
| 1630 | deb_info("%s: \n", __func__); |
| 1631 | |
| 1632 | /* remove 2nd I2C adapter */ |
| 1633 | if (d->state & DVB_USB_STATE_I2C) |
| 1634 | i2c_del_adapter(&state->i2c_adap); |
| 1635 | } |
| 1636 | |
| 1637 | static void af9015_usb_device_exit(struct usb_interface *intf) |
| 1638 | { |
| 1639 | struct dvb_usb_device *d = usb_get_intfdata(intf); |
| 1640 | deb_info("%s: \n", __func__); |
| 1641 | |
| 1642 | /* remove 2nd I2C adapter */ |
| 1643 | if (d != NULL && d->desc != NULL) |
| 1644 | af9015_i2c_exit(d); |
| 1645 | |
| 1646 | dvb_usb_device_exit(intf); |
| 1647 | } |
| 1648 | |
| 1649 | /* usb specific object needed to register this driver with the usb subsystem */ |
| 1650 | static struct usb_driver af9015_usb_driver = { |
| 1651 | .name = "dvb_usb_af9015", |
| 1652 | .probe = af9015_usb_probe, |
| 1653 | .disconnect = af9015_usb_device_exit, |
| 1654 | .id_table = af9015_usb_table, |
| 1655 | }; |
| 1656 | |
| 1657 | /* module stuff */ |
| 1658 | static int __init af9015_usb_module_init(void) |
| 1659 | { |
| 1660 | int ret; |
| 1661 | ret = usb_register(&af9015_usb_driver); |
| 1662 | if (ret) |
| 1663 | err("module init failed:%d", ret); |
| 1664 | |
| 1665 | return ret; |
| 1666 | } |
| 1667 | |
| 1668 | static void __exit af9015_usb_module_exit(void) |
| 1669 | { |
| 1670 | /* deregister this driver from the USB subsystem */ |
| 1671 | usb_deregister(&af9015_usb_driver); |
| 1672 | } |
| 1673 | |
| 1674 | module_init(af9015_usb_module_init); |
| 1675 | module_exit(af9015_usb_module_exit); |
| 1676 | |
| 1677 | MODULE_AUTHOR("Antti Palosaari <crope@iki.fi>"); |
| 1678 | MODULE_DESCRIPTION("Driver for Afatech AF9015 DVB-T"); |
| 1679 | MODULE_LICENSE("GPL"); |