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