Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 1 | /* |
| 2 | * Realtek RTL28xxU DVB USB driver |
| 3 | * |
| 4 | * Copyright (C) 2009 Antti Palosaari <crope@iki.fi> |
| 5 | * Copyright (C) 2011 Antti Palosaari <crope@iki.fi> |
Thomas Mair | 5cf6631 | 2012-05-18 14:47:41 -0300 | [diff] [blame] | 6 | * Copyright (C) 2012 Thomas Mair <thomas.mair86@googlemail.com> |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 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 along |
| 19 | * with this program; if not, write to the Free Software Foundation, Inc., |
| 20 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 21 | */ |
| 22 | |
| 23 | #include "rtl28xxu.h" |
| 24 | |
| 25 | #include "rtl2830.h" |
Thomas Mair | 5cf6631 | 2012-05-18 14:47:41 -0300 | [diff] [blame] | 26 | #include "rtl2832.h" |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 27 | |
| 28 | #include "qt1010.h" |
| 29 | #include "mt2060.h" |
| 30 | #include "mxl5005s.h" |
Thomas Mair | 5cf6631 | 2012-05-18 14:47:41 -0300 | [diff] [blame] | 31 | #include "fc0012.h" |
| 32 | #include "fc0013.h" |
Antti Palosaari | 542f6a5 | 2012-09-01 21:09:22 -0300 | [diff] [blame] | 33 | #include "e4000.h" |
Antti Palosaari | 384df49 | 2012-09-08 22:07:25 -0300 | [diff] [blame] | 34 | #include "fc2580.h" |
Antti Palosaari | 5be6572 | 2012-09-11 22:27:09 -0300 | [diff] [blame] | 35 | #include "tua9001.h" |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 36 | |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 37 | DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); |
| 38 | |
| 39 | static int rtl28xxu_ctrl_msg(struct dvb_usb_device *d, struct rtl28xxu_req *req) |
| 40 | { |
| 41 | int ret; |
| 42 | unsigned int pipe; |
| 43 | u8 requesttype; |
| 44 | u8 *buf; |
| 45 | |
| 46 | buf = kmalloc(req->size, GFP_KERNEL); |
| 47 | if (!buf) { |
| 48 | ret = -ENOMEM; |
| 49 | goto err; |
| 50 | } |
| 51 | |
| 52 | if (req->index & CMD_WR_FLAG) { |
| 53 | /* write */ |
| 54 | memcpy(buf, req->data, req->size); |
| 55 | requesttype = (USB_TYPE_VENDOR | USB_DIR_OUT); |
| 56 | pipe = usb_sndctrlpipe(d->udev, 0); |
| 57 | } else { |
| 58 | /* read */ |
| 59 | requesttype = (USB_TYPE_VENDOR | USB_DIR_IN); |
| 60 | pipe = usb_rcvctrlpipe(d->udev, 0); |
| 61 | } |
| 62 | |
| 63 | ret = usb_control_msg(d->udev, pipe, 0, requesttype, req->value, |
Antti Palosaari | 9935eea | 2012-01-21 22:26:52 -0300 | [diff] [blame] | 64 | req->index, buf, req->size, 1000); |
Antti Palosaari | d89b936 | 2012-08-22 19:42:00 -0300 | [diff] [blame] | 65 | |
| 66 | dvb_usb_dbg_usb_control_msg(d->udev, 0, requesttype, req->value, |
| 67 | req->index, buf, req->size); |
| 68 | |
Antti Palosaari | 9935eea | 2012-01-21 22:26:52 -0300 | [diff] [blame] | 69 | if (ret > 0) |
| 70 | ret = 0; |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 71 | |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 72 | /* read request, copy returned data to return buf */ |
| 73 | if (!ret && requesttype == (USB_TYPE_VENDOR | USB_DIR_IN)) |
| 74 | memcpy(req->data, buf, req->size); |
| 75 | |
| 76 | kfree(buf); |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 77 | |
Antti Palosaari | 9935eea | 2012-01-21 22:26:52 -0300 | [diff] [blame] | 78 | if (ret) |
| 79 | goto err; |
| 80 | |
| 81 | return ret; |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 82 | err: |
Antti Palosaari | c01a359 | 2012-08-12 22:27:07 -0300 | [diff] [blame] | 83 | dev_dbg(&d->udev->dev, "%s: failed=%d\n", __func__, ret); |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 84 | return ret; |
| 85 | } |
| 86 | |
Thomas Mair | 40a2d3c | 2012-05-18 14:47:42 -0300 | [diff] [blame] | 87 | static int rtl28xx_wr_regs(struct dvb_usb_device *d, u16 reg, u8 *val, int len) |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 88 | { |
| 89 | struct rtl28xxu_req req; |
| 90 | |
| 91 | if (reg < 0x3000) |
| 92 | req.index = CMD_USB_WR; |
Antti Palosaari | b5cbaa4 | 2011-08-04 13:26:10 -0300 | [diff] [blame] | 93 | else if (reg < 0x4000) |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 94 | req.index = CMD_SYS_WR; |
Antti Palosaari | b5cbaa4 | 2011-08-04 13:26:10 -0300 | [diff] [blame] | 95 | else |
| 96 | req.index = CMD_IR_WR; |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 97 | |
| 98 | req.value = reg; |
| 99 | req.size = len; |
| 100 | req.data = val; |
| 101 | |
| 102 | return rtl28xxu_ctrl_msg(d, &req); |
| 103 | } |
| 104 | |
| 105 | static int rtl2831_rd_regs(struct dvb_usb_device *d, u16 reg, u8 *val, int len) |
| 106 | { |
| 107 | struct rtl28xxu_req req; |
| 108 | |
| 109 | if (reg < 0x3000) |
| 110 | req.index = CMD_USB_RD; |
Antti Palosaari | b5cbaa4 | 2011-08-04 13:26:10 -0300 | [diff] [blame] | 111 | else if (reg < 0x4000) |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 112 | req.index = CMD_SYS_RD; |
Antti Palosaari | b5cbaa4 | 2011-08-04 13:26:10 -0300 | [diff] [blame] | 113 | else |
| 114 | req.index = CMD_IR_RD; |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 115 | |
| 116 | req.value = reg; |
| 117 | req.size = len; |
| 118 | req.data = val; |
| 119 | |
| 120 | return rtl28xxu_ctrl_msg(d, &req); |
| 121 | } |
| 122 | |
Thomas Mair | 40a2d3c | 2012-05-18 14:47:42 -0300 | [diff] [blame] | 123 | static int rtl28xx_wr_reg(struct dvb_usb_device *d, u16 reg, u8 val) |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 124 | { |
Thomas Mair | 40a2d3c | 2012-05-18 14:47:42 -0300 | [diff] [blame] | 125 | return rtl28xx_wr_regs(d, reg, &val, 1); |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 126 | } |
| 127 | |
Thomas Mair | 40a2d3c | 2012-05-18 14:47:42 -0300 | [diff] [blame] | 128 | static int rtl28xx_rd_reg(struct dvb_usb_device *d, u16 reg, u8 *val) |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 129 | { |
| 130 | return rtl2831_rd_regs(d, reg, val, 1); |
| 131 | } |
| 132 | |
| 133 | /* I2C */ |
| 134 | static int rtl28xxu_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[], |
| 135 | int num) |
| 136 | { |
| 137 | int ret; |
| 138 | struct dvb_usb_device *d = i2c_get_adapdata(adap); |
Antti Palosaari | 34ec293 | 2011-08-04 20:21:16 -0300 | [diff] [blame] | 139 | struct rtl28xxu_priv *priv = d->priv; |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 140 | struct rtl28xxu_req req; |
| 141 | |
| 142 | /* |
| 143 | * It is not known which are real I2C bus xfer limits, but testing |
| 144 | * with RTL2831U + MT2060 gives max RD 24 and max WR 22 bytes. |
Antti Palosaari | 34ec293 | 2011-08-04 20:21:16 -0300 | [diff] [blame] | 145 | * TODO: find out RTL2832U lens |
| 146 | */ |
| 147 | |
| 148 | /* |
| 149 | * I2C adapter logic looks rather complicated due to fact it handles |
| 150 | * three different access methods. Those methods are; |
| 151 | * 1) integrated demod access |
| 152 | * 2) old I2C access |
| 153 | * 3) new I2C access |
| 154 | * |
| 155 | * Used method is selected in order 1, 2, 3. Method 3 can handle all |
| 156 | * requests but there is two reasons why not use it always; |
| 157 | * 1) It is most expensive, usually two USB messages are needed |
| 158 | * 2) At least RTL2831U does not support it |
| 159 | * |
| 160 | * Method 3 is needed in case of I2C write+read (typical register read) |
| 161 | * where write is more than one byte. |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 162 | */ |
| 163 | |
| 164 | if (mutex_lock_interruptible(&d->i2c_mutex) < 0) |
| 165 | return -EAGAIN; |
| 166 | |
| 167 | if (num == 2 && !(msg[0].flags & I2C_M_RD) && |
| 168 | (msg[1].flags & I2C_M_RD)) { |
Antti Palosaari | 34ec293 | 2011-08-04 20:21:16 -0300 | [diff] [blame] | 169 | if (msg[0].len > 24 || msg[1].len > 24) { |
| 170 | /* TODO: check msg[0].len max */ |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 171 | ret = -EOPNOTSUPP; |
Antti Palosaari | 9935eea | 2012-01-21 22:26:52 -0300 | [diff] [blame] | 172 | goto err_mutex_unlock; |
Antti Palosaari | 34ec293 | 2011-08-04 20:21:16 -0300 | [diff] [blame] | 173 | } else if (msg[0].addr == 0x10) { |
| 174 | /* method 1 - integrated demod */ |
| 175 | req.value = (msg[0].buf[0] << 8) | (msg[0].addr << 1); |
| 176 | req.index = CMD_DEMOD_RD | priv->page; |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 177 | req.size = msg[1].len; |
| 178 | req.data = &msg[1].buf[0]; |
| 179 | ret = rtl28xxu_ctrl_msg(d, &req); |
Antti Palosaari | 34ec293 | 2011-08-04 20:21:16 -0300 | [diff] [blame] | 180 | } else if (msg[0].len < 2) { |
| 181 | /* method 2 - old I2C */ |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 182 | req.value = (msg[0].buf[0] << 8) | (msg[0].addr << 1); |
| 183 | req.index = CMD_I2C_RD; |
| 184 | req.size = msg[1].len; |
| 185 | req.data = &msg[1].buf[0]; |
| 186 | ret = rtl28xxu_ctrl_msg(d, &req); |
Antti Palosaari | 34ec293 | 2011-08-04 20:21:16 -0300 | [diff] [blame] | 187 | } else { |
| 188 | /* method 3 - new I2C */ |
| 189 | req.value = (msg[0].addr << 1); |
| 190 | req.index = CMD_I2C_DA_WR; |
| 191 | req.size = msg[0].len; |
| 192 | req.data = msg[0].buf; |
| 193 | ret = rtl28xxu_ctrl_msg(d, &req); |
| 194 | if (ret) |
Antti Palosaari | 9935eea | 2012-01-21 22:26:52 -0300 | [diff] [blame] | 195 | goto err_mutex_unlock; |
Antti Palosaari | 34ec293 | 2011-08-04 20:21:16 -0300 | [diff] [blame] | 196 | |
| 197 | req.value = (msg[0].addr << 1); |
| 198 | req.index = CMD_I2C_DA_RD; |
| 199 | req.size = msg[1].len; |
| 200 | req.data = msg[1].buf; |
| 201 | ret = rtl28xxu_ctrl_msg(d, &req); |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 202 | } |
| 203 | } else if (num == 1 && !(msg[0].flags & I2C_M_RD)) { |
| 204 | if (msg[0].len > 22) { |
Antti Palosaari | 34ec293 | 2011-08-04 20:21:16 -0300 | [diff] [blame] | 205 | /* TODO: check msg[0].len max */ |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 206 | ret = -EOPNOTSUPP; |
Antti Palosaari | 9935eea | 2012-01-21 22:26:52 -0300 | [diff] [blame] | 207 | goto err_mutex_unlock; |
Antti Palosaari | 34ec293 | 2011-08-04 20:21:16 -0300 | [diff] [blame] | 208 | } else if (msg[0].addr == 0x10) { |
| 209 | /* method 1 - integrated demod */ |
| 210 | if (msg[0].buf[0] == 0x00) { |
| 211 | /* save demod page for later demod access */ |
| 212 | priv->page = msg[0].buf[1]; |
| 213 | ret = 0; |
| 214 | } else { |
| 215 | req.value = (msg[0].buf[0] << 8) | |
| 216 | (msg[0].addr << 1); |
| 217 | req.index = CMD_DEMOD_WR | priv->page; |
| 218 | req.size = msg[0].len-1; |
| 219 | req.data = &msg[0].buf[1]; |
| 220 | ret = rtl28xxu_ctrl_msg(d, &req); |
| 221 | } |
| 222 | } else if (msg[0].len < 23) { |
| 223 | /* method 2 - old I2C */ |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 224 | req.value = (msg[0].buf[0] << 8) | (msg[0].addr << 1); |
| 225 | req.index = CMD_I2C_WR; |
| 226 | req.size = msg[0].len-1; |
| 227 | req.data = &msg[0].buf[1]; |
| 228 | ret = rtl28xxu_ctrl_msg(d, &req); |
Antti Palosaari | 34ec293 | 2011-08-04 20:21:16 -0300 | [diff] [blame] | 229 | } else { |
| 230 | /* method 3 - new I2C */ |
| 231 | req.value = (msg[0].addr << 1); |
| 232 | req.index = CMD_I2C_DA_WR; |
| 233 | req.size = msg[0].len; |
| 234 | req.data = msg[0].buf; |
| 235 | ret = rtl28xxu_ctrl_msg(d, &req); |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 236 | } |
| 237 | } else { |
| 238 | ret = -EINVAL; |
| 239 | } |
| 240 | |
Antti Palosaari | 9935eea | 2012-01-21 22:26:52 -0300 | [diff] [blame] | 241 | err_mutex_unlock: |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 242 | mutex_unlock(&d->i2c_mutex); |
| 243 | |
| 244 | return ret ? ret : num; |
| 245 | } |
| 246 | |
| 247 | static u32 rtl28xxu_i2c_func(struct i2c_adapter *adapter) |
| 248 | { |
| 249 | return I2C_FUNC_I2C; |
| 250 | } |
| 251 | |
| 252 | static struct i2c_algorithm rtl28xxu_i2c_algo = { |
| 253 | .master_xfer = rtl28xxu_i2c_xfer, |
| 254 | .functionality = rtl28xxu_i2c_func, |
| 255 | }; |
| 256 | |
Antti Palosaari | ef37be1 | 2012-09-17 14:01:35 -0300 | [diff] [blame^] | 257 | static int rtl2832u_read_config(struct dvb_usb_device *d) |
| 258 | { |
| 259 | struct rtl28xxu_priv *priv = d_to_priv(d); |
| 260 | int ret; |
| 261 | u8 buf[2], val; |
| 262 | /* open RTL2832U/RTL2832 I2C gate */ |
| 263 | struct rtl28xxu_req req_gate_open = {0x0120, 0x0011, 0x0001, "\x18"}; |
| 264 | /* close RTL2832U/RTL2832 I2C gate */ |
| 265 | struct rtl28xxu_req req_gate_close = {0x0120, 0x0011, 0x0001, "\x10"}; |
| 266 | /* tuner probes */ |
| 267 | struct rtl28xxu_req req_fc0012 = {0x00c6, CMD_I2C_RD, 1, buf}; |
| 268 | struct rtl28xxu_req req_fc0013 = {0x00c6, CMD_I2C_RD, 1, buf}; |
| 269 | struct rtl28xxu_req req_mt2266 = {0x00c0, CMD_I2C_RD, 1, buf}; |
| 270 | struct rtl28xxu_req req_fc2580 = {0x01ac, CMD_I2C_RD, 1, buf}; |
| 271 | struct rtl28xxu_req req_mt2063 = {0x00c0, CMD_I2C_RD, 1, buf}; |
| 272 | struct rtl28xxu_req req_max3543 = {0x00c0, CMD_I2C_RD, 1, buf}; |
| 273 | struct rtl28xxu_req req_tua9001 = {0x7ec0, CMD_I2C_RD, 2, buf}; |
| 274 | struct rtl28xxu_req req_mxl5007t = {0xd9c0, CMD_I2C_RD, 1, buf}; |
| 275 | struct rtl28xxu_req req_e4000 = {0x02c8, CMD_I2C_RD, 1, buf}; |
| 276 | struct rtl28xxu_req req_tda18272 = {0x00c0, CMD_I2C_RD, 2, buf}; |
| 277 | |
| 278 | dev_dbg(&d->udev->dev, "%s:\n", __func__); |
| 279 | |
| 280 | ret = rtl28xx_rd_reg(d, SYS_GPIO_DIR, &val); |
| 281 | if (ret) |
| 282 | goto err; |
| 283 | |
| 284 | val &= 0xbf; |
| 285 | |
| 286 | ret = rtl28xx_wr_reg(d, SYS_GPIO_DIR, val); |
| 287 | if (ret) |
| 288 | goto err; |
| 289 | |
| 290 | /* enable as output GPIO3 and GPIO6 */ |
| 291 | ret = rtl28xx_rd_reg(d, SYS_GPIO_OUT_EN, &val); |
| 292 | if (ret) |
| 293 | goto err; |
| 294 | |
| 295 | val |= 0x48; |
| 296 | |
| 297 | ret = rtl28xx_wr_reg(d, SYS_GPIO_OUT_EN, val); |
| 298 | if (ret) |
| 299 | goto err; |
| 300 | |
| 301 | /* |
| 302 | * Probe used tuner. We need to know used tuner before demod attach |
| 303 | * since there is some demod params needed to set according to tuner. |
| 304 | */ |
| 305 | |
| 306 | /* open demod I2C gate */ |
| 307 | ret = rtl28xxu_ctrl_msg(d, &req_gate_open); |
| 308 | if (ret) |
| 309 | goto err; |
| 310 | |
| 311 | priv->tuner_name = "NONE"; |
| 312 | |
| 313 | /* check FC0012 ID register; reg=00 val=a1 */ |
| 314 | ret = rtl28xxu_ctrl_msg(d, &req_fc0012); |
| 315 | if (ret == 0 && buf[0] == 0xa1) { |
| 316 | priv->tuner = TUNER_RTL2832_FC0012; |
| 317 | priv->tuner_name = "FC0012"; |
| 318 | goto found; |
| 319 | } |
| 320 | |
| 321 | /* check FC0013 ID register; reg=00 val=a3 */ |
| 322 | ret = rtl28xxu_ctrl_msg(d, &req_fc0013); |
| 323 | if (ret == 0 && buf[0] == 0xa3) { |
| 324 | priv->tuner = TUNER_RTL2832_FC0013; |
| 325 | priv->tuner_name = "FC0013"; |
| 326 | goto found; |
| 327 | } |
| 328 | |
| 329 | /* check MT2266 ID register; reg=00 val=85 */ |
| 330 | ret = rtl28xxu_ctrl_msg(d, &req_mt2266); |
| 331 | if (ret == 0 && buf[0] == 0x85) { |
| 332 | priv->tuner = TUNER_RTL2832_MT2266; |
| 333 | priv->tuner_name = "MT2266"; |
| 334 | goto found; |
| 335 | } |
| 336 | |
| 337 | /* check FC2580 ID register; reg=01 val=56 */ |
| 338 | ret = rtl28xxu_ctrl_msg(d, &req_fc2580); |
| 339 | if (ret == 0 && buf[0] == 0x56) { |
| 340 | priv->tuner = TUNER_RTL2832_FC2580; |
| 341 | priv->tuner_name = "FC2580"; |
| 342 | goto found; |
| 343 | } |
| 344 | |
| 345 | /* check MT2063 ID register; reg=00 val=9e || 9c */ |
| 346 | ret = rtl28xxu_ctrl_msg(d, &req_mt2063); |
| 347 | if (ret == 0 && (buf[0] == 0x9e || buf[0] == 0x9c)) { |
| 348 | priv->tuner = TUNER_RTL2832_MT2063; |
| 349 | priv->tuner_name = "MT2063"; |
| 350 | goto found; |
| 351 | } |
| 352 | |
| 353 | /* check MAX3543 ID register; reg=00 val=38 */ |
| 354 | ret = rtl28xxu_ctrl_msg(d, &req_max3543); |
| 355 | if (ret == 0 && buf[0] == 0x38) { |
| 356 | priv->tuner = TUNER_RTL2832_MAX3543; |
| 357 | priv->tuner_name = "MAX3543"; |
| 358 | goto found; |
| 359 | } |
| 360 | |
| 361 | /* check TUA9001 ID register; reg=7e val=2328 */ |
| 362 | ret = rtl28xxu_ctrl_msg(d, &req_tua9001); |
| 363 | if (ret == 0 && buf[0] == 0x23 && buf[1] == 0x28) { |
| 364 | priv->tuner = TUNER_RTL2832_TUA9001; |
| 365 | priv->tuner_name = "TUA9001"; |
| 366 | goto found; |
| 367 | } |
| 368 | |
| 369 | /* check MXL5007R ID register; reg=d9 val=14 */ |
| 370 | ret = rtl28xxu_ctrl_msg(d, &req_mxl5007t); |
| 371 | if (ret == 0 && buf[0] == 0x14) { |
| 372 | priv->tuner = TUNER_RTL2832_MXL5007T; |
| 373 | priv->tuner_name = "MXL5007T"; |
| 374 | goto found; |
| 375 | } |
| 376 | |
| 377 | /* check E4000 ID register; reg=02 val=40 */ |
| 378 | ret = rtl28xxu_ctrl_msg(d, &req_e4000); |
| 379 | if (ret == 0 && buf[0] == 0x40) { |
| 380 | priv->tuner = TUNER_RTL2832_E4000; |
| 381 | priv->tuner_name = "E4000"; |
| 382 | goto found; |
| 383 | } |
| 384 | |
| 385 | /* check TDA18272 ID register; reg=00 val=c760 */ |
| 386 | ret = rtl28xxu_ctrl_msg(d, &req_tda18272); |
| 387 | if (ret == 0 && (buf[0] == 0xc7 || buf[1] == 0x60)) { |
| 388 | priv->tuner = TUNER_RTL2832_TDA18272; |
| 389 | priv->tuner_name = "TDA18272"; |
| 390 | goto found; |
| 391 | } |
| 392 | |
| 393 | found: |
| 394 | dev_dbg(&d->udev->dev, "%s: tuner=%s\n", __func__, priv->tuner_name); |
| 395 | |
| 396 | /* close demod I2C gate */ |
| 397 | ret = rtl28xxu_ctrl_msg(d, &req_gate_close); |
| 398 | if (ret < 0) |
| 399 | goto err; |
| 400 | |
| 401 | return 0; |
| 402 | err: |
| 403 | dev_dbg(&d->udev->dev, "%s: failed=%d\n", __func__, ret); |
| 404 | return ret; |
| 405 | } |
| 406 | |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 407 | static struct rtl2830_config rtl28xxu_rtl2830_mt2060_config = { |
| 408 | .i2c_addr = 0x10, /* 0x20 */ |
| 409 | .xtal = 28800000, |
| 410 | .ts_mode = 0, |
| 411 | .spec_inv = 1, |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 412 | .vtop = 0x20, |
| 413 | .krf = 0x04, |
| 414 | .agc_targ_val = 0x2d, |
| 415 | |
| 416 | }; |
| 417 | |
| 418 | static struct rtl2830_config rtl28xxu_rtl2830_qt1010_config = { |
| 419 | .i2c_addr = 0x10, /* 0x20 */ |
| 420 | .xtal = 28800000, |
| 421 | .ts_mode = 0, |
| 422 | .spec_inv = 1, |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 423 | .vtop = 0x20, |
| 424 | .krf = 0x04, |
| 425 | .agc_targ_val = 0x2d, |
| 426 | }; |
| 427 | |
| 428 | static struct rtl2830_config rtl28xxu_rtl2830_mxl5005s_config = { |
| 429 | .i2c_addr = 0x10, /* 0x20 */ |
| 430 | .xtal = 28800000, |
| 431 | .ts_mode = 0, |
| 432 | .spec_inv = 0, |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 433 | .vtop = 0x3f, |
| 434 | .krf = 0x04, |
| 435 | .agc_targ_val = 0x3e, |
| 436 | }; |
| 437 | |
Antti Palosaari | b5cbaa4 | 2011-08-04 13:26:10 -0300 | [diff] [blame] | 438 | static int rtl2831u_frontend_attach(struct dvb_usb_adapter *adap) |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 439 | { |
| 440 | int ret; |
Antti Palosaari | c01a359 | 2012-08-12 22:27:07 -0300 | [diff] [blame] | 441 | struct dvb_usb_device *d = adap_to_d(adap); |
| 442 | struct rtl28xxu_priv *priv = d_to_priv(d); |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 443 | u8 buf[1]; |
| 444 | struct rtl2830_config *rtl2830_config; |
Antti Palosaari | b5cbaa4 | 2011-08-04 13:26:10 -0300 | [diff] [blame] | 445 | /* open RTL2831U/RTL2830 I2C gate */ |
Antti Palosaari | 9935eea | 2012-01-21 22:26:52 -0300 | [diff] [blame] | 446 | struct rtl28xxu_req req_gate = { 0x0120, 0x0011, 0x0001, "\x08" }; |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 447 | /* for MT2060 tuner probe */ |
Antti Palosaari | 9935eea | 2012-01-21 22:26:52 -0300 | [diff] [blame] | 448 | struct rtl28xxu_req req_mt2060 = { 0x00c0, CMD_I2C_RD, 1, buf }; |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 449 | /* for QT1010 tuner probe */ |
Antti Palosaari | 9935eea | 2012-01-21 22:26:52 -0300 | [diff] [blame] | 450 | struct rtl28xxu_req req_qt1010 = { 0x0fc4, CMD_I2C_RD, 1, buf }; |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 451 | |
Antti Palosaari | c01a359 | 2012-08-12 22:27:07 -0300 | [diff] [blame] | 452 | dev_dbg(&d->udev->dev, "%s:\n", __func__); |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 453 | |
| 454 | /* |
| 455 | * RTL2831U GPIOs |
| 456 | * ========================================================= |
| 457 | * GPIO0 | tuner#0 | 0 off | 1 on | MXL5005S (?) |
| 458 | * GPIO2 | LED | 0 off | 1 on | |
| 459 | * GPIO4 | tuner#1 | 0 on | 1 off | MT2060 |
| 460 | */ |
| 461 | |
| 462 | /* GPIO direction */ |
Antti Palosaari | c01a359 | 2012-08-12 22:27:07 -0300 | [diff] [blame] | 463 | ret = rtl28xx_wr_reg(d, SYS_GPIO_DIR, 0x0a); |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 464 | if (ret) |
| 465 | goto err; |
| 466 | |
| 467 | /* enable as output GPIO0, GPIO2, GPIO4 */ |
Antti Palosaari | c01a359 | 2012-08-12 22:27:07 -0300 | [diff] [blame] | 468 | ret = rtl28xx_wr_reg(d, SYS_GPIO_OUT_EN, 0x15); |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 469 | if (ret) |
| 470 | goto err; |
| 471 | |
| 472 | /* |
| 473 | * Probe used tuner. We need to know used tuner before demod attach |
| 474 | * since there is some demod params needed to set according to tuner. |
| 475 | */ |
| 476 | |
Antti Palosaari | ccb5cf9 | 2012-05-18 16:07:46 -0300 | [diff] [blame] | 477 | /* demod needs some time to wake up */ |
| 478 | msleep(20); |
| 479 | |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 480 | /* open demod I2C gate */ |
Antti Palosaari | c01a359 | 2012-08-12 22:27:07 -0300 | [diff] [blame] | 481 | ret = rtl28xxu_ctrl_msg(d, &req_gate); |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 482 | if (ret) |
| 483 | goto err; |
| 484 | |
| 485 | /* check QT1010 ID(?) register; reg=0f val=2c */ |
Antti Palosaari | c01a359 | 2012-08-12 22:27:07 -0300 | [diff] [blame] | 486 | ret = rtl28xxu_ctrl_msg(d, &req_qt1010); |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 487 | if (ret == 0 && buf[0] == 0x2c) { |
| 488 | priv->tuner = TUNER_RTL2830_QT1010; |
| 489 | rtl2830_config = &rtl28xxu_rtl2830_qt1010_config; |
Antti Palosaari | c01a359 | 2012-08-12 22:27:07 -0300 | [diff] [blame] | 490 | dev_dbg(&d->udev->dev, "%s: QT1010\n", __func__); |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 491 | goto found; |
| 492 | } else { |
Antti Palosaari | c01a359 | 2012-08-12 22:27:07 -0300 | [diff] [blame] | 493 | dev_dbg(&d->udev->dev, "%s: QT1010 probe failed=%d - %02x\n", |
| 494 | __func__, ret, buf[0]); |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 495 | } |
| 496 | |
| 497 | /* open demod I2C gate */ |
Antti Palosaari | c01a359 | 2012-08-12 22:27:07 -0300 | [diff] [blame] | 498 | ret = rtl28xxu_ctrl_msg(d, &req_gate); |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 499 | if (ret) |
| 500 | goto err; |
| 501 | |
| 502 | /* check MT2060 ID register; reg=00 val=63 */ |
Antti Palosaari | c01a359 | 2012-08-12 22:27:07 -0300 | [diff] [blame] | 503 | ret = rtl28xxu_ctrl_msg(d, &req_mt2060); |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 504 | if (ret == 0 && buf[0] == 0x63) { |
| 505 | priv->tuner = TUNER_RTL2830_MT2060; |
| 506 | rtl2830_config = &rtl28xxu_rtl2830_mt2060_config; |
Antti Palosaari | c01a359 | 2012-08-12 22:27:07 -0300 | [diff] [blame] | 507 | dev_dbg(&d->udev->dev, "%s: MT2060\n", __func__); |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 508 | goto found; |
| 509 | } else { |
Antti Palosaari | c01a359 | 2012-08-12 22:27:07 -0300 | [diff] [blame] | 510 | dev_dbg(&d->udev->dev, "%s: MT2060 probe failed=%d - %02x\n", |
| 511 | __func__, ret, buf[0]); |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 512 | } |
| 513 | |
| 514 | /* assume MXL5005S */ |
Antti Palosaari | e9320ec | 2011-08-03 04:35:30 -0300 | [diff] [blame] | 515 | ret = 0; |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 516 | priv->tuner = TUNER_RTL2830_MXL5005S; |
| 517 | rtl2830_config = &rtl28xxu_rtl2830_mxl5005s_config; |
Antti Palosaari | c01a359 | 2012-08-12 22:27:07 -0300 | [diff] [blame] | 518 | dev_dbg(&d->udev->dev, "%s: MXL5005S\n", __func__); |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 519 | goto found; |
| 520 | |
| 521 | found: |
| 522 | /* attach demodulator */ |
Antti Palosaari | c01a359 | 2012-08-12 22:27:07 -0300 | [diff] [blame] | 523 | adap->fe[0] = dvb_attach(rtl2830_attach, rtl2830_config, |
| 524 | &d->i2c_adap); |
| 525 | if (adap->fe[0] == NULL) { |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 526 | ret = -ENODEV; |
| 527 | goto err; |
| 528 | } |
| 529 | |
| 530 | return ret; |
| 531 | err: |
Antti Palosaari | c01a359 | 2012-08-12 22:27:07 -0300 | [diff] [blame] | 532 | dev_dbg(&d->udev->dev, "%s: failed=%d\n", __func__, ret); |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 533 | return ret; |
| 534 | } |
| 535 | |
Thomas Mair | 5cf6631 | 2012-05-18 14:47:41 -0300 | [diff] [blame] | 536 | static struct rtl2832_config rtl28xxu_rtl2832_fc0012_config = { |
| 537 | .i2c_addr = 0x10, /* 0x20 */ |
| 538 | .xtal = 28800000, |
| 539 | .if_dvbt = 0, |
| 540 | .tuner = TUNER_RTL2832_FC0012 |
| 541 | }; |
| 542 | |
| 543 | static struct rtl2832_config rtl28xxu_rtl2832_fc0013_config = { |
| 544 | .i2c_addr = 0x10, /* 0x20 */ |
| 545 | .xtal = 28800000, |
| 546 | .if_dvbt = 0, |
| 547 | .tuner = TUNER_RTL2832_FC0013 |
| 548 | }; |
| 549 | |
Antti Palosaari | 5be6572 | 2012-09-11 22:27:09 -0300 | [diff] [blame] | 550 | static struct rtl2832_config rtl28xxu_rtl2832_tua9001_config = { |
| 551 | .i2c_addr = 0x10, /* 0x20 */ |
| 552 | .xtal = 28800000, |
| 553 | .tuner = TUNER_RTL2832_TUA9001, |
| 554 | }; |
| 555 | |
Thomas Mair | 5cf6631 | 2012-05-18 14:47:41 -0300 | [diff] [blame] | 556 | static int rtl2832u_fc0012_tuner_callback(struct dvb_usb_device *d, |
| 557 | int cmd, int arg) |
| 558 | { |
| 559 | int ret; |
| 560 | u8 val; |
| 561 | |
Antti Palosaari | c01a359 | 2012-08-12 22:27:07 -0300 | [diff] [blame] | 562 | dev_dbg(&d->udev->dev, "%s: cmd=%d arg=%d\n", __func__, cmd, arg); |
| 563 | |
Thomas Mair | 5cf6631 | 2012-05-18 14:47:41 -0300 | [diff] [blame] | 564 | switch (cmd) { |
| 565 | case FC_FE_CALLBACK_VHF_ENABLE: |
| 566 | /* set output values */ |
Thomas Mair | 40a2d3c | 2012-05-18 14:47:42 -0300 | [diff] [blame] | 567 | ret = rtl28xx_rd_reg(d, SYS_GPIO_OUT_VAL, &val); |
Thomas Mair | 5cf6631 | 2012-05-18 14:47:41 -0300 | [diff] [blame] | 568 | if (ret) |
| 569 | goto err; |
| 570 | |
| 571 | if (arg) |
| 572 | val &= 0xbf; /* set GPIO6 low */ |
| 573 | else |
| 574 | val |= 0x40; /* set GPIO6 high */ |
| 575 | |
| 576 | |
Thomas Mair | 40a2d3c | 2012-05-18 14:47:42 -0300 | [diff] [blame] | 577 | ret = rtl28xx_wr_reg(d, SYS_GPIO_OUT_VAL, val); |
Thomas Mair | 5cf6631 | 2012-05-18 14:47:41 -0300 | [diff] [blame] | 578 | if (ret) |
| 579 | goto err; |
| 580 | break; |
| 581 | default: |
| 582 | ret = -EINVAL; |
| 583 | goto err; |
| 584 | } |
| 585 | return 0; |
| 586 | |
| 587 | err: |
Antti Palosaari | c01a359 | 2012-08-12 22:27:07 -0300 | [diff] [blame] | 588 | dev_dbg(&d->udev->dev, "%s: failed=%d\n", __func__, ret); |
Thomas Mair | 5cf6631 | 2012-05-18 14:47:41 -0300 | [diff] [blame] | 589 | return ret; |
| 590 | } |
| 591 | |
| 592 | |
| 593 | static int rtl2832u_fc0013_tuner_callback(struct dvb_usb_device *d, |
| 594 | int cmd, int arg) |
| 595 | { |
| 596 | /* TODO implement*/ |
| 597 | return 0; |
| 598 | } |
| 599 | |
Antti Palosaari | 5be6572 | 2012-09-11 22:27:09 -0300 | [diff] [blame] | 600 | static int rtl2832u_tua9001_tuner_callback(struct dvb_usb_device *d, |
| 601 | int cmd, int arg) |
| 602 | { |
| 603 | int ret; |
| 604 | u8 val; |
| 605 | |
| 606 | dev_dbg(&d->udev->dev, "%s: cmd=%d arg=%d\n", __func__, cmd, arg); |
| 607 | |
| 608 | /* |
| 609 | * CEN always enabled by hardware wiring |
| 610 | * RESETN GPIO4 |
| 611 | * RXEN GPIO1 |
| 612 | */ |
| 613 | |
| 614 | ret = rtl28xx_rd_reg(d, SYS_GPIO_OUT_VAL, &val); |
| 615 | if (ret < 0) |
| 616 | goto err; |
| 617 | |
| 618 | switch (cmd) { |
| 619 | case TUA9001_CMD_RESETN: |
| 620 | if (arg) |
| 621 | val |= (1 << 4); |
| 622 | else |
| 623 | val &= ~(1 << 4); |
| 624 | |
| 625 | ret = rtl28xx_wr_reg(d, SYS_GPIO_OUT_VAL, val); |
| 626 | if (ret < 0) |
| 627 | goto err; |
| 628 | break; |
| 629 | case TUA9001_CMD_RXEN: |
| 630 | if (arg) |
| 631 | val |= (1 << 1); |
| 632 | else |
| 633 | val &= ~(1 << 1); |
| 634 | |
| 635 | ret = rtl28xx_wr_reg(d, SYS_GPIO_OUT_VAL, val); |
| 636 | if (ret < 0) |
| 637 | goto err; |
| 638 | break; |
| 639 | } |
| 640 | |
| 641 | return 0; |
| 642 | |
| 643 | err: |
| 644 | dev_dbg(&d->udev->dev, "%s: failed=%d\n", __func__, ret); |
| 645 | return ret; |
| 646 | } |
| 647 | |
Thomas Mair | 5cf6631 | 2012-05-18 14:47:41 -0300 | [diff] [blame] | 648 | static int rtl2832u_tuner_callback(struct dvb_usb_device *d, int cmd, int arg) |
| 649 | { |
| 650 | struct rtl28xxu_priv *priv = d->priv; |
| 651 | |
| 652 | switch (priv->tuner) { |
| 653 | case TUNER_RTL2832_FC0012: |
| 654 | return rtl2832u_fc0012_tuner_callback(d, cmd, arg); |
| 655 | |
| 656 | case TUNER_RTL2832_FC0013: |
| 657 | return rtl2832u_fc0013_tuner_callback(d, cmd, arg); |
Antti Palosaari | 5be6572 | 2012-09-11 22:27:09 -0300 | [diff] [blame] | 658 | |
| 659 | case TUNER_RTL2832_TUA9001: |
| 660 | return rtl2832u_tua9001_tuner_callback(d, cmd, arg); |
Thomas Mair | 5cf6631 | 2012-05-18 14:47:41 -0300 | [diff] [blame] | 661 | default: |
| 662 | break; |
| 663 | } |
| 664 | |
| 665 | return -ENODEV; |
| 666 | } |
| 667 | |
| 668 | static int rtl2832u_frontend_callback(void *adapter_priv, int component, |
| 669 | int cmd, int arg) |
| 670 | { |
| 671 | struct i2c_adapter *adap = adapter_priv; |
| 672 | struct dvb_usb_device *d = i2c_get_adapdata(adap); |
| 673 | |
| 674 | switch (component) { |
| 675 | case DVB_FRONTEND_COMPONENT_TUNER: |
| 676 | return rtl2832u_tuner_callback(d, cmd, arg); |
| 677 | default: |
| 678 | break; |
| 679 | } |
| 680 | |
| 681 | return -EINVAL; |
| 682 | } |
| 683 | |
Antti Palosaari | b5cbaa4 | 2011-08-04 13:26:10 -0300 | [diff] [blame] | 684 | static int rtl2832u_frontend_attach(struct dvb_usb_adapter *adap) |
| 685 | { |
| 686 | int ret; |
Antti Palosaari | c01a359 | 2012-08-12 22:27:07 -0300 | [diff] [blame] | 687 | struct dvb_usb_device *d = adap_to_d(adap); |
| 688 | struct rtl28xxu_priv *priv = d_to_priv(d); |
Thomas Mair | 5cf6631 | 2012-05-18 14:47:41 -0300 | [diff] [blame] | 689 | struct rtl2832_config *rtl2832_config; |
Antti Palosaari | b5cbaa4 | 2011-08-04 13:26:10 -0300 | [diff] [blame] | 690 | |
Antti Palosaari | c01a359 | 2012-08-12 22:27:07 -0300 | [diff] [blame] | 691 | dev_dbg(&d->udev->dev, "%s:\n", __func__); |
Antti Palosaari | b5cbaa4 | 2011-08-04 13:26:10 -0300 | [diff] [blame] | 692 | |
Antti Palosaari | ef37be1 | 2012-09-17 14:01:35 -0300 | [diff] [blame^] | 693 | switch (priv->tuner) { |
| 694 | case TUNER_RTL2832_FC0012: |
Thomas Mair | 5cf6631 | 2012-05-18 14:47:41 -0300 | [diff] [blame] | 695 | rtl2832_config = &rtl28xxu_rtl2832_fc0012_config; |
Antti Palosaari | ef37be1 | 2012-09-17 14:01:35 -0300 | [diff] [blame^] | 696 | break; |
| 697 | case TUNER_RTL2832_FC0013: |
Thomas Mair | 5cf6631 | 2012-05-18 14:47:41 -0300 | [diff] [blame] | 698 | rtl2832_config = &rtl28xxu_rtl2832_fc0013_config; |
Antti Palosaari | ef37be1 | 2012-09-17 14:01:35 -0300 | [diff] [blame^] | 699 | break; |
| 700 | case TUNER_RTL2832_FC2580: |
Antti Palosaari | 384df49 | 2012-09-08 22:07:25 -0300 | [diff] [blame] | 701 | /* FIXME: do not abuse fc0012 settings */ |
| 702 | rtl2832_config = &rtl28xxu_rtl2832_fc0012_config; |
Antti Palosaari | ef37be1 | 2012-09-17 14:01:35 -0300 | [diff] [blame^] | 703 | break; |
| 704 | case TUNER_RTL2832_TUA9001: |
Antti Palosaari | 5be6572 | 2012-09-11 22:27:09 -0300 | [diff] [blame] | 705 | rtl2832_config = &rtl28xxu_rtl2832_tua9001_config; |
Antti Palosaari | ef37be1 | 2012-09-17 14:01:35 -0300 | [diff] [blame^] | 706 | break; |
| 707 | case TUNER_RTL2832_E4000: |
Antti Palosaari | 542f6a5 | 2012-09-01 21:09:22 -0300 | [diff] [blame] | 708 | /* FIXME: do not abuse fc0012 settings */ |
| 709 | rtl2832_config = &rtl28xxu_rtl2832_fc0012_config; |
Antti Palosaari | ef37be1 | 2012-09-17 14:01:35 -0300 | [diff] [blame^] | 710 | break; |
| 711 | default: |
| 712 | dev_err(&d->udev->dev, "%s: unknown tuner=%s\n", |
| 713 | KBUILD_MODNAME, priv->tuner_name); |
| 714 | ret = -ENODEV; |
Antti Palosaari | b5cbaa4 | 2011-08-04 13:26:10 -0300 | [diff] [blame] | 715 | goto err; |
Antti Palosaari | ef37be1 | 2012-09-17 14:01:35 -0300 | [diff] [blame^] | 716 | } |
Antti Palosaari | b5cbaa4 | 2011-08-04 13:26:10 -0300 | [diff] [blame] | 717 | |
| 718 | /* attach demodulator */ |
Antti Palosaari | ef37be1 | 2012-09-17 14:01:35 -0300 | [diff] [blame^] | 719 | adap->fe[0] = dvb_attach(rtl2832_attach, rtl2832_config, &d->i2c_adap); |
| 720 | if (!adap->fe[0]) { |
| 721 | ret = -ENODEV; |
| 722 | goto err; |
| 723 | } |
Thomas Mair | 5cf6631 | 2012-05-18 14:47:41 -0300 | [diff] [blame] | 724 | |
Antti Palosaari | ef37be1 | 2012-09-17 14:01:35 -0300 | [diff] [blame^] | 725 | /* set fe callback */ |
Antti Palosaari | c01a359 | 2012-08-12 22:27:07 -0300 | [diff] [blame] | 726 | adap->fe[0]->callback = rtl2832u_frontend_callback; |
Antti Palosaari | b5cbaa4 | 2011-08-04 13:26:10 -0300 | [diff] [blame] | 727 | |
Antti Palosaari | ef37be1 | 2012-09-17 14:01:35 -0300 | [diff] [blame^] | 728 | return 0; |
Antti Palosaari | b5cbaa4 | 2011-08-04 13:26:10 -0300 | [diff] [blame] | 729 | err: |
Antti Palosaari | c01a359 | 2012-08-12 22:27:07 -0300 | [diff] [blame] | 730 | dev_dbg(&d->udev->dev, "%s: failed=%d\n", __func__, ret); |
Antti Palosaari | b5cbaa4 | 2011-08-04 13:26:10 -0300 | [diff] [blame] | 731 | return ret; |
| 732 | } |
| 733 | |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 734 | static struct qt1010_config rtl28xxu_qt1010_config = { |
| 735 | .i2c_address = 0x62, /* 0xc4 */ |
| 736 | }; |
| 737 | |
| 738 | static struct mt2060_config rtl28xxu_mt2060_config = { |
| 739 | .i2c_address = 0x60, /* 0xc0 */ |
| 740 | .clock_out = 0, |
| 741 | }; |
| 742 | |
| 743 | static struct mxl5005s_config rtl28xxu_mxl5005s_config = { |
| 744 | .i2c_address = 0x63, /* 0xc6 */ |
| 745 | .if_freq = IF_FREQ_4570000HZ, |
| 746 | .xtal_freq = CRYSTAL_FREQ_16000000HZ, |
| 747 | .agc_mode = MXL_SINGLE_AGC, |
| 748 | .tracking_filter = MXL_TF_C_H, |
| 749 | .rssi_enable = MXL_RSSI_ENABLE, |
| 750 | .cap_select = MXL_CAP_SEL_ENABLE, |
| 751 | .div_out = MXL_DIV_OUT_4, |
| 752 | .clock_out = MXL_CLOCK_OUT_DISABLE, |
| 753 | .output_load = MXL5005S_IF_OUTPUT_LOAD_200_OHM, |
| 754 | .top = MXL5005S_TOP_25P2, |
| 755 | .mod_mode = MXL_DIGITAL_MODE, |
| 756 | .if_mode = MXL_ZERO_IF, |
| 757 | .AgcMasterByte = 0x00, |
| 758 | }; |
| 759 | |
Antti Palosaari | b5cbaa4 | 2011-08-04 13:26:10 -0300 | [diff] [blame] | 760 | static int rtl2831u_tuner_attach(struct dvb_usb_adapter *adap) |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 761 | { |
| 762 | int ret; |
Antti Palosaari | c01a359 | 2012-08-12 22:27:07 -0300 | [diff] [blame] | 763 | struct dvb_usb_device *d = adap_to_d(adap); |
| 764 | struct rtl28xxu_priv *priv = d_to_priv(d); |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 765 | struct i2c_adapter *rtl2830_tuner_i2c; |
Antti Palosaari | 9935eea | 2012-01-21 22:26:52 -0300 | [diff] [blame] | 766 | struct dvb_frontend *fe; |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 767 | |
Antti Palosaari | c01a359 | 2012-08-12 22:27:07 -0300 | [diff] [blame] | 768 | dev_dbg(&d->udev->dev, "%s:\n", __func__); |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 769 | |
| 770 | /* use rtl2830 driver I2C adapter, for more info see rtl2830 driver */ |
Antti Palosaari | c01a359 | 2012-08-12 22:27:07 -0300 | [diff] [blame] | 771 | rtl2830_tuner_i2c = rtl2830_get_tuner_i2c_adapter(adap->fe[0]); |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 772 | |
| 773 | switch (priv->tuner) { |
| 774 | case TUNER_RTL2830_QT1010: |
Antti Palosaari | c01a359 | 2012-08-12 22:27:07 -0300 | [diff] [blame] | 775 | fe = dvb_attach(qt1010_attach, adap->fe[0], |
Antti Palosaari | fba16b1 | 2012-01-21 20:28:38 -0300 | [diff] [blame] | 776 | rtl2830_tuner_i2c, &rtl28xxu_qt1010_config); |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 777 | break; |
| 778 | case TUNER_RTL2830_MT2060: |
Antti Palosaari | c01a359 | 2012-08-12 22:27:07 -0300 | [diff] [blame] | 779 | fe = dvb_attach(mt2060_attach, adap->fe[0], |
Antti Palosaari | fba16b1 | 2012-01-21 20:28:38 -0300 | [diff] [blame] | 780 | rtl2830_tuner_i2c, &rtl28xxu_mt2060_config, |
| 781 | 1220); |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 782 | break; |
| 783 | case TUNER_RTL2830_MXL5005S: |
Antti Palosaari | c01a359 | 2012-08-12 22:27:07 -0300 | [diff] [blame] | 784 | fe = dvb_attach(mxl5005s_attach, adap->fe[0], |
Antti Palosaari | 9935eea | 2012-01-21 22:26:52 -0300 | [diff] [blame] | 785 | rtl2830_tuner_i2c, &rtl28xxu_mxl5005s_config); |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 786 | break; |
| 787 | default: |
Antti Palosaari | 9935eea | 2012-01-21 22:26:52 -0300 | [diff] [blame] | 788 | fe = NULL; |
Antti Palosaari | c01a359 | 2012-08-12 22:27:07 -0300 | [diff] [blame] | 789 | dev_err(&d->udev->dev, "%s: unknown tuner=%d\n", KBUILD_MODNAME, |
| 790 | priv->tuner); |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 791 | } |
| 792 | |
| 793 | if (fe == NULL) { |
| 794 | ret = -ENODEV; |
| 795 | goto err; |
| 796 | } |
| 797 | |
| 798 | return 0; |
| 799 | err: |
Antti Palosaari | c01a359 | 2012-08-12 22:27:07 -0300 | [diff] [blame] | 800 | dev_dbg(&d->udev->dev, "%s: failed=%d\n", __func__, ret); |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 801 | return ret; |
| 802 | } |
| 803 | |
Antti Palosaari | 542f6a5 | 2012-09-01 21:09:22 -0300 | [diff] [blame] | 804 | static const struct e4000_config rtl2832u_e4000_config = { |
| 805 | .i2c_addr = 0x64, |
| 806 | .clock = 28800000, |
| 807 | }; |
| 808 | |
Antti Palosaari | 384df49 | 2012-09-08 22:07:25 -0300 | [diff] [blame] | 809 | static const struct fc2580_config rtl2832u_fc2580_config = { |
| 810 | .i2c_addr = 0x56, |
| 811 | .clock = 16384000, |
| 812 | }; |
| 813 | |
Antti Palosaari | 5be6572 | 2012-09-11 22:27:09 -0300 | [diff] [blame] | 814 | static struct tua9001_config rtl2832u_tua9001_config = { |
| 815 | .i2c_addr = 0x60, |
| 816 | }; |
| 817 | |
Antti Palosaari | b5cbaa4 | 2011-08-04 13:26:10 -0300 | [diff] [blame] | 818 | static int rtl2832u_tuner_attach(struct dvb_usb_adapter *adap) |
| 819 | { |
| 820 | int ret; |
Antti Palosaari | c01a359 | 2012-08-12 22:27:07 -0300 | [diff] [blame] | 821 | struct dvb_usb_device *d = adap_to_d(adap); |
| 822 | struct rtl28xxu_priv *priv = d_to_priv(d); |
Antti Palosaari | 9935eea | 2012-01-21 22:26:52 -0300 | [diff] [blame] | 823 | struct dvb_frontend *fe; |
Antti Palosaari | 5be6572 | 2012-09-11 22:27:09 -0300 | [diff] [blame] | 824 | u8 val; |
Antti Palosaari | b5cbaa4 | 2011-08-04 13:26:10 -0300 | [diff] [blame] | 825 | |
Antti Palosaari | c01a359 | 2012-08-12 22:27:07 -0300 | [diff] [blame] | 826 | dev_dbg(&d->udev->dev, "%s:\n", __func__); |
Antti Palosaari | b5cbaa4 | 2011-08-04 13:26:10 -0300 | [diff] [blame] | 827 | |
| 828 | switch (priv->tuner) { |
Thomas Mair | 5cf6631 | 2012-05-18 14:47:41 -0300 | [diff] [blame] | 829 | case TUNER_RTL2832_FC0012: |
Antti Palosaari | c01a359 | 2012-08-12 22:27:07 -0300 | [diff] [blame] | 830 | fe = dvb_attach(fc0012_attach, adap->fe[0], |
| 831 | &d->i2c_adap, 0xc6>>1, 0, FC_XTAL_28_8_MHZ); |
Thomas Mair | 5cf6631 | 2012-05-18 14:47:41 -0300 | [diff] [blame] | 832 | |
| 833 | /* since fc0012 includs reading the signal strength delegate |
| 834 | * that to the tuner driver */ |
Antti Palosaari | c01a359 | 2012-08-12 22:27:07 -0300 | [diff] [blame] | 835 | adap->fe[0]->ops.read_signal_strength = |
| 836 | adap->fe[0]->ops.tuner_ops.get_rf_strength; |
Thomas Mair | 5cf6631 | 2012-05-18 14:47:41 -0300 | [diff] [blame] | 837 | return 0; |
Antti Palosaari | b5cbaa4 | 2011-08-04 13:26:10 -0300 | [diff] [blame] | 838 | break; |
Thomas Mair | 5cf6631 | 2012-05-18 14:47:41 -0300 | [diff] [blame] | 839 | case TUNER_RTL2832_FC0013: |
Antti Palosaari | c01a359 | 2012-08-12 22:27:07 -0300 | [diff] [blame] | 840 | fe = dvb_attach(fc0013_attach, adap->fe[0], |
| 841 | &d->i2c_adap, 0xc6>>1, 0, FC_XTAL_28_8_MHZ); |
Thomas Mair | 5cf6631 | 2012-05-18 14:47:41 -0300 | [diff] [blame] | 842 | |
| 843 | /* fc0013 also supports signal strength reading */ |
Antti Palosaari | c01a359 | 2012-08-12 22:27:07 -0300 | [diff] [blame] | 844 | adap->fe[0]->ops.read_signal_strength = |
| 845 | adap->fe[0]->ops.tuner_ops.get_rf_strength; |
Thomas Mair | 5cf6631 | 2012-05-18 14:47:41 -0300 | [diff] [blame] | 846 | return 0; |
Antti Palosaari | 542f6a5 | 2012-09-01 21:09:22 -0300 | [diff] [blame] | 847 | case TUNER_RTL2832_E4000: |
| 848 | fe = dvb_attach(e4000_attach, adap->fe[0], &d->i2c_adap, |
| 849 | &rtl2832u_e4000_config); |
| 850 | break; |
Antti Palosaari | 384df49 | 2012-09-08 22:07:25 -0300 | [diff] [blame] | 851 | case TUNER_RTL2832_FC2580: |
| 852 | fe = dvb_attach(fc2580_attach, adap->fe[0], &d->i2c_adap, |
| 853 | &rtl2832u_fc2580_config); |
| 854 | break; |
Antti Palosaari | 5be6572 | 2012-09-11 22:27:09 -0300 | [diff] [blame] | 855 | case TUNER_RTL2832_TUA9001: |
| 856 | /* enable GPIO1 and GPIO4 as output */ |
| 857 | ret = rtl28xx_rd_reg(d, SYS_GPIO_DIR, &val); |
| 858 | if (ret < 0) |
| 859 | goto err; |
| 860 | |
| 861 | val &= ~(1 << 1); |
| 862 | val &= ~(1 << 4); |
| 863 | |
| 864 | ret = rtl28xx_wr_reg(d, SYS_GPIO_DIR, val); |
| 865 | if (ret < 0) |
| 866 | goto err; |
| 867 | |
| 868 | ret = rtl28xx_rd_reg(d, SYS_GPIO_OUT_EN, &val); |
| 869 | if (ret < 0) |
| 870 | goto err; |
| 871 | |
| 872 | val |= (1 << 1); |
| 873 | val |= (1 << 4); |
| 874 | |
| 875 | ret = rtl28xx_wr_reg(d, SYS_GPIO_OUT_EN, val); |
| 876 | if (ret < 0) |
| 877 | goto err; |
| 878 | |
| 879 | fe = dvb_attach(tua9001_attach, adap->fe[0], &d->i2c_adap, |
| 880 | &rtl2832u_tua9001_config); |
| 881 | break; |
Antti Palosaari | b5cbaa4 | 2011-08-04 13:26:10 -0300 | [diff] [blame] | 882 | default: |
Antti Palosaari | 9935eea | 2012-01-21 22:26:52 -0300 | [diff] [blame] | 883 | fe = NULL; |
Antti Palosaari | c01a359 | 2012-08-12 22:27:07 -0300 | [diff] [blame] | 884 | dev_err(&d->udev->dev, "%s: unknown tuner=%d\n", KBUILD_MODNAME, |
| 885 | priv->tuner); |
Antti Palosaari | b5cbaa4 | 2011-08-04 13:26:10 -0300 | [diff] [blame] | 886 | } |
| 887 | |
| 888 | if (fe == NULL) { |
| 889 | ret = -ENODEV; |
| 890 | goto err; |
| 891 | } |
| 892 | |
| 893 | return 0; |
| 894 | err: |
Antti Palosaari | c01a359 | 2012-08-12 22:27:07 -0300 | [diff] [blame] | 895 | dev_dbg(&d->udev->dev, "%s: failed=%d\n", __func__, ret); |
Antti Palosaari | b5cbaa4 | 2011-08-04 13:26:10 -0300 | [diff] [blame] | 896 | return ret; |
| 897 | } |
| 898 | |
Antti Palosaari | c01a359 | 2012-08-12 22:27:07 -0300 | [diff] [blame] | 899 | static int rtl28xxu_init(struct dvb_usb_device *d) |
| 900 | { |
| 901 | int ret; |
| 902 | u8 val; |
| 903 | |
| 904 | dev_dbg(&d->udev->dev, "%s:\n", __func__); |
| 905 | |
| 906 | /* init USB endpoints */ |
| 907 | ret = rtl28xx_rd_reg(d, USB_SYSCTL_0, &val); |
| 908 | if (ret) |
| 909 | goto err; |
| 910 | |
| 911 | /* enable DMA and Full Packet Mode*/ |
| 912 | val |= 0x09; |
| 913 | ret = rtl28xx_wr_reg(d, USB_SYSCTL_0, val); |
| 914 | if (ret) |
| 915 | goto err; |
| 916 | |
| 917 | /* set EPA maximum packet size to 0x0200 */ |
| 918 | ret = rtl28xx_wr_regs(d, USB_EPA_MAXPKT, "\x00\x02\x00\x00", 4); |
| 919 | if (ret) |
| 920 | goto err; |
| 921 | |
| 922 | /* change EPA FIFO length */ |
| 923 | ret = rtl28xx_wr_regs(d, USB_EPA_FIFO_CFG, "\x14\x00\x00\x00", 4); |
| 924 | if (ret) |
| 925 | goto err; |
| 926 | |
| 927 | return ret; |
| 928 | err: |
| 929 | dev_dbg(&d->udev->dev, "%s: failed=%d\n", __func__, ret); |
| 930 | return ret; |
| 931 | } |
| 932 | |
Thomas Mair | 5cf6631 | 2012-05-18 14:47:41 -0300 | [diff] [blame] | 933 | static int rtl2831u_power_ctrl(struct dvb_usb_device *d, int onoff) |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 934 | { |
| 935 | int ret; |
Antti Palosaari | 8b03663 | 2012-09-01 09:54:43 -0300 | [diff] [blame] | 936 | u8 gpio, sys0, epa_ctl[2]; |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 937 | |
Antti Palosaari | c01a359 | 2012-08-12 22:27:07 -0300 | [diff] [blame] | 938 | dev_dbg(&d->udev->dev, "%s: onoff=%d\n", __func__, onoff); |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 939 | |
| 940 | /* demod adc */ |
Thomas Mair | 40a2d3c | 2012-05-18 14:47:42 -0300 | [diff] [blame] | 941 | ret = rtl28xx_rd_reg(d, SYS_SYS0, &sys0); |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 942 | if (ret) |
| 943 | goto err; |
| 944 | |
| 945 | /* tuner power, read GPIOs */ |
Thomas Mair | 40a2d3c | 2012-05-18 14:47:42 -0300 | [diff] [blame] | 946 | ret = rtl28xx_rd_reg(d, SYS_GPIO_OUT_VAL, &gpio); |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 947 | if (ret) |
| 948 | goto err; |
| 949 | |
Antti Palosaari | c01a359 | 2012-08-12 22:27:07 -0300 | [diff] [blame] | 950 | dev_dbg(&d->udev->dev, "%s: RD SYS0=%02x GPIO_OUT_VAL=%02x\n", __func__, |
| 951 | sys0, gpio); |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 952 | |
| 953 | if (onoff) { |
| 954 | gpio |= 0x01; /* GPIO0 = 1 */ |
| 955 | gpio &= (~0x10); /* GPIO4 = 0 */ |
Antti Palosaari | 991452a | 2012-08-12 22:27:08 -0300 | [diff] [blame] | 956 | gpio |= 0x04; /* GPIO2 = 1, LED on */ |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 957 | sys0 = sys0 & 0x0f; |
| 958 | sys0 |= 0xe0; |
Antti Palosaari | 8b03663 | 2012-09-01 09:54:43 -0300 | [diff] [blame] | 959 | epa_ctl[0] = 0x00; /* clear stall */ |
| 960 | epa_ctl[1] = 0x00; /* clear reset */ |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 961 | } else { |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 962 | gpio &= (~0x01); /* GPIO0 = 0 */ |
| 963 | gpio |= 0x10; /* GPIO4 = 1 */ |
Antti Palosaari | 991452a | 2012-08-12 22:27:08 -0300 | [diff] [blame] | 964 | gpio &= (~0x04); /* GPIO2 = 1, LED off */ |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 965 | sys0 = sys0 & (~0xc0); |
Antti Palosaari | 8b03663 | 2012-09-01 09:54:43 -0300 | [diff] [blame] | 966 | epa_ctl[0] = 0x10; /* set stall */ |
| 967 | epa_ctl[1] = 0x02; /* set reset */ |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 968 | } |
| 969 | |
Antti Palosaari | c01a359 | 2012-08-12 22:27:07 -0300 | [diff] [blame] | 970 | dev_dbg(&d->udev->dev, "%s: WR SYS0=%02x GPIO_OUT_VAL=%02x\n", __func__, |
| 971 | sys0, gpio); |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 972 | |
| 973 | /* demod adc */ |
Thomas Mair | 40a2d3c | 2012-05-18 14:47:42 -0300 | [diff] [blame] | 974 | ret = rtl28xx_wr_reg(d, SYS_SYS0, sys0); |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 975 | if (ret) |
| 976 | goto err; |
| 977 | |
| 978 | /* tuner power, write GPIOs */ |
Thomas Mair | 40a2d3c | 2012-05-18 14:47:42 -0300 | [diff] [blame] | 979 | ret = rtl28xx_wr_reg(d, SYS_GPIO_OUT_VAL, gpio); |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 980 | if (ret) |
| 981 | goto err; |
| 982 | |
Antti Palosaari | 8b03663 | 2012-09-01 09:54:43 -0300 | [diff] [blame] | 983 | /* streaming EP: stall & reset */ |
| 984 | ret = rtl28xx_wr_regs(d, USB_EPA_CTL, epa_ctl, 2); |
| 985 | if (ret) |
| 986 | goto err; |
| 987 | |
| 988 | if (onoff) |
| 989 | usb_clear_halt(d->udev, usb_rcvbulkpipe(d->udev, 0x81)); |
| 990 | |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 991 | return ret; |
| 992 | err: |
Antti Palosaari | c01a359 | 2012-08-12 22:27:07 -0300 | [diff] [blame] | 993 | dev_dbg(&d->udev->dev, "%s: failed=%d\n", __func__, ret); |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 994 | return ret; |
| 995 | } |
| 996 | |
Thomas Mair | 5cf6631 | 2012-05-18 14:47:41 -0300 | [diff] [blame] | 997 | static int rtl2832u_power_ctrl(struct dvb_usb_device *d, int onoff) |
| 998 | { |
| 999 | int ret; |
| 1000 | u8 val; |
| 1001 | |
Antti Palosaari | c01a359 | 2012-08-12 22:27:07 -0300 | [diff] [blame] | 1002 | dev_dbg(&d->udev->dev, "%s: onoff=%d\n", __func__, onoff); |
Thomas Mair | 5cf6631 | 2012-05-18 14:47:41 -0300 | [diff] [blame] | 1003 | |
| 1004 | if (onoff) { |
| 1005 | /* set output values */ |
Thomas Mair | 40a2d3c | 2012-05-18 14:47:42 -0300 | [diff] [blame] | 1006 | ret = rtl28xx_rd_reg(d, SYS_GPIO_OUT_VAL, &val); |
Thomas Mair | 5cf6631 | 2012-05-18 14:47:41 -0300 | [diff] [blame] | 1007 | if (ret) |
| 1008 | goto err; |
| 1009 | |
| 1010 | val |= 0x08; |
| 1011 | val &= 0xef; |
| 1012 | |
Thomas Mair | 40a2d3c | 2012-05-18 14:47:42 -0300 | [diff] [blame] | 1013 | ret = rtl28xx_wr_reg(d, SYS_GPIO_OUT_VAL, val); |
Thomas Mair | 5cf6631 | 2012-05-18 14:47:41 -0300 | [diff] [blame] | 1014 | if (ret) |
| 1015 | goto err; |
| 1016 | |
| 1017 | /* demod_ctl_1 */ |
Thomas Mair | 40a2d3c | 2012-05-18 14:47:42 -0300 | [diff] [blame] | 1018 | ret = rtl28xx_rd_reg(d, SYS_DEMOD_CTL1, &val); |
Thomas Mair | 5cf6631 | 2012-05-18 14:47:41 -0300 | [diff] [blame] | 1019 | if (ret) |
| 1020 | goto err; |
| 1021 | |
| 1022 | val &= 0xef; |
| 1023 | |
Thomas Mair | 40a2d3c | 2012-05-18 14:47:42 -0300 | [diff] [blame] | 1024 | ret = rtl28xx_wr_reg(d, SYS_DEMOD_CTL1, val); |
Thomas Mair | 5cf6631 | 2012-05-18 14:47:41 -0300 | [diff] [blame] | 1025 | if (ret) |
| 1026 | goto err; |
| 1027 | |
| 1028 | /* demod control */ |
| 1029 | /* PLL enable */ |
Thomas Mair | 40a2d3c | 2012-05-18 14:47:42 -0300 | [diff] [blame] | 1030 | ret = rtl28xx_rd_reg(d, SYS_DEMOD_CTL, &val); |
Thomas Mair | 5cf6631 | 2012-05-18 14:47:41 -0300 | [diff] [blame] | 1031 | if (ret) |
| 1032 | goto err; |
| 1033 | |
| 1034 | /* bit 7 to 1 */ |
| 1035 | val |= 0x80; |
| 1036 | |
Thomas Mair | 40a2d3c | 2012-05-18 14:47:42 -0300 | [diff] [blame] | 1037 | ret = rtl28xx_wr_reg(d, SYS_DEMOD_CTL, val); |
Thomas Mair | 5cf6631 | 2012-05-18 14:47:41 -0300 | [diff] [blame] | 1038 | if (ret) |
| 1039 | goto err; |
| 1040 | |
Thomas Mair | 40a2d3c | 2012-05-18 14:47:42 -0300 | [diff] [blame] | 1041 | ret = rtl28xx_rd_reg(d, SYS_DEMOD_CTL, &val); |
Thomas Mair | 5cf6631 | 2012-05-18 14:47:41 -0300 | [diff] [blame] | 1042 | if (ret) |
| 1043 | goto err; |
| 1044 | |
| 1045 | val |= 0x20; |
| 1046 | |
Thomas Mair | 40a2d3c | 2012-05-18 14:47:42 -0300 | [diff] [blame] | 1047 | ret = rtl28xx_wr_reg(d, SYS_DEMOD_CTL, val); |
Thomas Mair | 5cf6631 | 2012-05-18 14:47:41 -0300 | [diff] [blame] | 1048 | if (ret) |
| 1049 | goto err; |
| 1050 | |
| 1051 | mdelay(5); |
| 1052 | |
| 1053 | /*enable ADC_Q and ADC_I */ |
Thomas Mair | 40a2d3c | 2012-05-18 14:47:42 -0300 | [diff] [blame] | 1054 | ret = rtl28xx_rd_reg(d, SYS_DEMOD_CTL, &val); |
Thomas Mair | 5cf6631 | 2012-05-18 14:47:41 -0300 | [diff] [blame] | 1055 | if (ret) |
| 1056 | goto err; |
| 1057 | |
| 1058 | val |= 0x48; |
| 1059 | |
Thomas Mair | 40a2d3c | 2012-05-18 14:47:42 -0300 | [diff] [blame] | 1060 | ret = rtl28xx_wr_reg(d, SYS_DEMOD_CTL, val); |
Thomas Mair | 5cf6631 | 2012-05-18 14:47:41 -0300 | [diff] [blame] | 1061 | if (ret) |
| 1062 | goto err; |
| 1063 | |
Antti Palosaari | 8b03663 | 2012-09-01 09:54:43 -0300 | [diff] [blame] | 1064 | /* streaming EP: clear stall & reset */ |
| 1065 | ret = rtl28xx_wr_regs(d, USB_EPA_CTL, "\x00\x00", 2); |
| 1066 | if (ret) |
| 1067 | goto err; |
| 1068 | |
| 1069 | ret = usb_clear_halt(d->udev, usb_rcvbulkpipe(d->udev, 0x81)); |
| 1070 | if (ret) |
| 1071 | goto err; |
Thomas Mair | 5cf6631 | 2012-05-18 14:47:41 -0300 | [diff] [blame] | 1072 | } else { |
| 1073 | /* demod_ctl_1 */ |
Thomas Mair | 40a2d3c | 2012-05-18 14:47:42 -0300 | [diff] [blame] | 1074 | ret = rtl28xx_rd_reg(d, SYS_DEMOD_CTL1, &val); |
Thomas Mair | 5cf6631 | 2012-05-18 14:47:41 -0300 | [diff] [blame] | 1075 | if (ret) |
| 1076 | goto err; |
| 1077 | |
| 1078 | val |= 0x0c; |
| 1079 | |
Thomas Mair | 40a2d3c | 2012-05-18 14:47:42 -0300 | [diff] [blame] | 1080 | ret = rtl28xx_wr_reg(d, SYS_DEMOD_CTL1, val); |
Thomas Mair | 5cf6631 | 2012-05-18 14:47:41 -0300 | [diff] [blame] | 1081 | if (ret) |
| 1082 | goto err; |
| 1083 | |
| 1084 | /* set output values */ |
Thomas Mair | 40a2d3c | 2012-05-18 14:47:42 -0300 | [diff] [blame] | 1085 | ret = rtl28xx_rd_reg(d, SYS_GPIO_OUT_VAL, &val); |
Thomas Mair | 5cf6631 | 2012-05-18 14:47:41 -0300 | [diff] [blame] | 1086 | if (ret) |
| 1087 | goto err; |
| 1088 | |
| 1089 | val |= 0x10; |
| 1090 | |
Thomas Mair | 40a2d3c | 2012-05-18 14:47:42 -0300 | [diff] [blame] | 1091 | ret = rtl28xx_wr_reg(d, SYS_GPIO_OUT_VAL, val); |
Thomas Mair | 5cf6631 | 2012-05-18 14:47:41 -0300 | [diff] [blame] | 1092 | if (ret) |
| 1093 | goto err; |
| 1094 | |
| 1095 | /* demod control */ |
Thomas Mair | 40a2d3c | 2012-05-18 14:47:42 -0300 | [diff] [blame] | 1096 | ret = rtl28xx_rd_reg(d, SYS_DEMOD_CTL, &val); |
Thomas Mair | 5cf6631 | 2012-05-18 14:47:41 -0300 | [diff] [blame] | 1097 | if (ret) |
| 1098 | goto err; |
| 1099 | |
| 1100 | val &= 0x37; |
| 1101 | |
Thomas Mair | 40a2d3c | 2012-05-18 14:47:42 -0300 | [diff] [blame] | 1102 | ret = rtl28xx_wr_reg(d, SYS_DEMOD_CTL, val); |
Thomas Mair | 5cf6631 | 2012-05-18 14:47:41 -0300 | [diff] [blame] | 1103 | if (ret) |
| 1104 | goto err; |
| 1105 | |
Antti Palosaari | 8b03663 | 2012-09-01 09:54:43 -0300 | [diff] [blame] | 1106 | /* streaming EP: set stall & reset */ |
| 1107 | ret = rtl28xx_wr_regs(d, USB_EPA_CTL, "\x10\x02", 2); |
| 1108 | if (ret) |
| 1109 | goto err; |
Thomas Mair | 5cf6631 | 2012-05-18 14:47:41 -0300 | [diff] [blame] | 1110 | } |
| 1111 | |
| 1112 | return ret; |
| 1113 | err: |
Antti Palosaari | c01a359 | 2012-08-12 22:27:07 -0300 | [diff] [blame] | 1114 | dev_dbg(&d->udev->dev, "%s: failed=%d\n", __func__, ret); |
Thomas Mair | 5cf6631 | 2012-05-18 14:47:41 -0300 | [diff] [blame] | 1115 | return ret; |
| 1116 | } |
| 1117 | |
| 1118 | |
Antti Palosaari | b5cbaa4 | 2011-08-04 13:26:10 -0300 | [diff] [blame] | 1119 | static int rtl2831u_rc_query(struct dvb_usb_device *d) |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 1120 | { |
Antti Palosaari | b5cbaa4 | 2011-08-04 13:26:10 -0300 | [diff] [blame] | 1121 | int ret, i; |
| 1122 | struct rtl28xxu_priv *priv = d->priv; |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 1123 | u8 buf[5]; |
| 1124 | u32 rc_code; |
Antti Palosaari | b5cbaa4 | 2011-08-04 13:26:10 -0300 | [diff] [blame] | 1125 | struct rtl28xxu_reg_val rc_nec_tab[] = { |
| 1126 | { 0x3033, 0x80 }, |
| 1127 | { 0x3020, 0x43 }, |
| 1128 | { 0x3021, 0x16 }, |
| 1129 | { 0x3022, 0x16 }, |
| 1130 | { 0x3023, 0x5a }, |
| 1131 | { 0x3024, 0x2d }, |
| 1132 | { 0x3025, 0x16 }, |
| 1133 | { 0x3026, 0x01 }, |
| 1134 | { 0x3028, 0xb0 }, |
| 1135 | { 0x3029, 0x04 }, |
| 1136 | { 0x302c, 0x88 }, |
| 1137 | { 0x302e, 0x13 }, |
| 1138 | { 0x3030, 0xdf }, |
| 1139 | { 0x3031, 0x05 }, |
| 1140 | }; |
| 1141 | |
| 1142 | /* init remote controller */ |
| 1143 | if (!priv->rc_active) { |
| 1144 | for (i = 0; i < ARRAY_SIZE(rc_nec_tab); i++) { |
Thomas Mair | 40a2d3c | 2012-05-18 14:47:42 -0300 | [diff] [blame] | 1145 | ret = rtl28xx_wr_reg(d, rc_nec_tab[i].reg, |
Antti Palosaari | 9935eea | 2012-01-21 22:26:52 -0300 | [diff] [blame] | 1146 | rc_nec_tab[i].val); |
Antti Palosaari | b5cbaa4 | 2011-08-04 13:26:10 -0300 | [diff] [blame] | 1147 | if (ret) |
| 1148 | goto err; |
| 1149 | } |
| 1150 | priv->rc_active = true; |
| 1151 | } |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 1152 | |
| 1153 | ret = rtl2831_rd_regs(d, SYS_IRRC_RP, buf, 5); |
| 1154 | if (ret) |
| 1155 | goto err; |
| 1156 | |
| 1157 | if (buf[4] & 0x01) { |
| 1158 | if (buf[2] == (u8) ~buf[3]) { |
| 1159 | if (buf[0] == (u8) ~buf[1]) { |
| 1160 | /* NEC standard (16 bit) */ |
| 1161 | rc_code = buf[0] << 8 | buf[2]; |
| 1162 | } else { |
| 1163 | /* NEC extended (24 bit) */ |
| 1164 | rc_code = buf[0] << 16 | |
Antti Palosaari | 9935eea | 2012-01-21 22:26:52 -0300 | [diff] [blame] | 1165 | buf[1] << 8 | buf[2]; |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 1166 | } |
| 1167 | } else { |
| 1168 | /* NEC full (32 bit) */ |
| 1169 | rc_code = buf[0] << 24 | buf[1] << 16 | |
| 1170 | buf[2] << 8 | buf[3]; |
| 1171 | } |
| 1172 | |
| 1173 | rc_keydown(d->rc_dev, rc_code, 0); |
| 1174 | |
Thomas Mair | 40a2d3c | 2012-05-18 14:47:42 -0300 | [diff] [blame] | 1175 | ret = rtl28xx_wr_reg(d, SYS_IRRC_SR, 1); |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 1176 | if (ret) |
| 1177 | goto err; |
| 1178 | |
| 1179 | /* repeated intentionally to avoid extra keypress */ |
Thomas Mair | 40a2d3c | 2012-05-18 14:47:42 -0300 | [diff] [blame] | 1180 | ret = rtl28xx_wr_reg(d, SYS_IRRC_SR, 1); |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 1181 | if (ret) |
| 1182 | goto err; |
| 1183 | } |
| 1184 | |
| 1185 | return ret; |
| 1186 | err: |
Antti Palosaari | c01a359 | 2012-08-12 22:27:07 -0300 | [diff] [blame] | 1187 | dev_dbg(&d->udev->dev, "%s: failed=%d\n", __func__, ret); |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 1188 | return ret; |
| 1189 | } |
| 1190 | |
Antti Palosaari | c01a359 | 2012-08-12 22:27:07 -0300 | [diff] [blame] | 1191 | static int rtl2831u_get_rc_config(struct dvb_usb_device *d, |
| 1192 | struct dvb_usb_rc *rc) |
| 1193 | { |
| 1194 | rc->map_name = RC_MAP_EMPTY; |
| 1195 | rc->allowed_protos = RC_TYPE_NEC; |
| 1196 | rc->query = rtl2831u_rc_query; |
| 1197 | rc->interval = 400; |
| 1198 | |
| 1199 | return 0; |
| 1200 | } |
| 1201 | |
Antti Palosaari | b5cbaa4 | 2011-08-04 13:26:10 -0300 | [diff] [blame] | 1202 | static int rtl2832u_rc_query(struct dvb_usb_device *d) |
| 1203 | { |
| 1204 | int ret, i; |
| 1205 | struct rtl28xxu_priv *priv = d->priv; |
| 1206 | u8 buf[128]; |
| 1207 | int len; |
| 1208 | struct rtl28xxu_reg_val rc_nec_tab[] = { |
Antti Palosaari | 9935eea | 2012-01-21 22:26:52 -0300 | [diff] [blame] | 1209 | { IR_RX_CTRL, 0x20 }, |
| 1210 | { IR_RX_BUF_CTRL, 0x80 }, |
| 1211 | { IR_RX_IF, 0xff }, |
| 1212 | { IR_RX_IE, 0xff }, |
| 1213 | { IR_MAX_DURATION0, 0xd0 }, |
| 1214 | { IR_MAX_DURATION1, 0x07 }, |
| 1215 | { IR_IDLE_LEN0, 0xc0 }, |
| 1216 | { IR_IDLE_LEN1, 0x00 }, |
| 1217 | { IR_GLITCH_LEN, 0x03 }, |
| 1218 | { IR_RX_CLK, 0x09 }, |
| 1219 | { IR_RX_CFG, 0x1c }, |
| 1220 | { IR_MAX_H_TOL_LEN, 0x1e }, |
| 1221 | { IR_MAX_L_TOL_LEN, 0x1e }, |
| 1222 | { IR_RX_CTRL, 0x80 }, |
Antti Palosaari | b5cbaa4 | 2011-08-04 13:26:10 -0300 | [diff] [blame] | 1223 | }; |
| 1224 | |
| 1225 | /* init remote controller */ |
| 1226 | if (!priv->rc_active) { |
| 1227 | for (i = 0; i < ARRAY_SIZE(rc_nec_tab); i++) { |
Thomas Mair | 40a2d3c | 2012-05-18 14:47:42 -0300 | [diff] [blame] | 1228 | ret = rtl28xx_wr_reg(d, rc_nec_tab[i].reg, |
Antti Palosaari | 9935eea | 2012-01-21 22:26:52 -0300 | [diff] [blame] | 1229 | rc_nec_tab[i].val); |
Antti Palosaari | b5cbaa4 | 2011-08-04 13:26:10 -0300 | [diff] [blame] | 1230 | if (ret) |
| 1231 | goto err; |
| 1232 | } |
| 1233 | priv->rc_active = true; |
| 1234 | } |
| 1235 | |
Thomas Mair | 40a2d3c | 2012-05-18 14:47:42 -0300 | [diff] [blame] | 1236 | ret = rtl28xx_rd_reg(d, IR_RX_IF, &buf[0]); |
Antti Palosaari | b5cbaa4 | 2011-08-04 13:26:10 -0300 | [diff] [blame] | 1237 | if (ret) |
| 1238 | goto err; |
| 1239 | |
| 1240 | if (buf[0] != 0x83) |
| 1241 | goto exit; |
| 1242 | |
Thomas Mair | 40a2d3c | 2012-05-18 14:47:42 -0300 | [diff] [blame] | 1243 | ret = rtl28xx_rd_reg(d, IR_RX_BC, &buf[0]); |
Antti Palosaari | b5cbaa4 | 2011-08-04 13:26:10 -0300 | [diff] [blame] | 1244 | if (ret) |
| 1245 | goto err; |
| 1246 | |
| 1247 | len = buf[0]; |
| 1248 | ret = rtl2831_rd_regs(d, IR_RX_BUF, buf, len); |
| 1249 | |
| 1250 | /* TODO: pass raw IR to Kernel IR decoder */ |
| 1251 | |
Thomas Mair | 40a2d3c | 2012-05-18 14:47:42 -0300 | [diff] [blame] | 1252 | ret = rtl28xx_wr_reg(d, IR_RX_IF, 0x03); |
| 1253 | ret = rtl28xx_wr_reg(d, IR_RX_BUF_CTRL, 0x80); |
| 1254 | ret = rtl28xx_wr_reg(d, IR_RX_CTRL, 0x80); |
Antti Palosaari | b5cbaa4 | 2011-08-04 13:26:10 -0300 | [diff] [blame] | 1255 | |
| 1256 | exit: |
| 1257 | return ret; |
| 1258 | err: |
Antti Palosaari | c01a359 | 2012-08-12 22:27:07 -0300 | [diff] [blame] | 1259 | dev_dbg(&d->udev->dev, "%s: failed=%d\n", __func__, ret); |
Antti Palosaari | b5cbaa4 | 2011-08-04 13:26:10 -0300 | [diff] [blame] | 1260 | return ret; |
| 1261 | } |
| 1262 | |
Antti Palosaari | c01a359 | 2012-08-12 22:27:07 -0300 | [diff] [blame] | 1263 | static int rtl2832u_get_rc_config(struct dvb_usb_device *d, |
| 1264 | struct dvb_usb_rc *rc) |
| 1265 | { |
| 1266 | rc->map_name = RC_MAP_EMPTY; |
| 1267 | rc->allowed_protos = RC_TYPE_NEC; |
| 1268 | rc->query = rtl2832u_rc_query; |
| 1269 | rc->interval = 400; |
Antti Palosaari | b5cbaa4 | 2011-08-04 13:26:10 -0300 | [diff] [blame] | 1270 | |
Antti Palosaari | c01a359 | 2012-08-12 22:27:07 -0300 | [diff] [blame] | 1271 | return 0; |
| 1272 | } |
Antti Palosaari | b5cbaa4 | 2011-08-04 13:26:10 -0300 | [diff] [blame] | 1273 | |
Antti Palosaari | c01a359 | 2012-08-12 22:27:07 -0300 | [diff] [blame] | 1274 | static const struct dvb_usb_device_properties rtl2831u_props = { |
| 1275 | .driver_name = KBUILD_MODNAME, |
| 1276 | .owner = THIS_MODULE, |
| 1277 | .adapter_nr = adapter_nr, |
| 1278 | .size_of_priv = sizeof(struct rtl28xxu_priv), |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 1279 | |
Antti Palosaari | c01a359 | 2012-08-12 22:27:07 -0300 | [diff] [blame] | 1280 | .power_ctrl = rtl2831u_power_ctrl, |
| 1281 | .i2c_algo = &rtl28xxu_i2c_algo, |
| 1282 | .frontend_attach = rtl2831u_frontend_attach, |
| 1283 | .tuner_attach = rtl2831u_tuner_attach, |
| 1284 | .init = rtl28xxu_init, |
| 1285 | .get_rc_config = rtl2831u_get_rc_config, |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 1286 | |
Antti Palosaari | c01a359 | 2012-08-12 22:27:07 -0300 | [diff] [blame] | 1287 | .num_adapters = 1, |
| 1288 | .adapter = { |
| 1289 | { |
| 1290 | .stream = DVB_USB_STREAM_BULK(0x81, 6, 8 * 512), |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 1291 | }, |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 1292 | }, |
Antti Palosaari | c01a359 | 2012-08-12 22:27:07 -0300 | [diff] [blame] | 1293 | }; |
Antti Palosaari | b5cbaa4 | 2011-08-04 13:26:10 -0300 | [diff] [blame] | 1294 | |
Antti Palosaari | c01a359 | 2012-08-12 22:27:07 -0300 | [diff] [blame] | 1295 | static const struct dvb_usb_device_properties rtl2832u_props = { |
| 1296 | .driver_name = KBUILD_MODNAME, |
| 1297 | .owner = THIS_MODULE, |
| 1298 | .adapter_nr = adapter_nr, |
| 1299 | .size_of_priv = sizeof(struct rtl28xxu_priv), |
Antti Palosaari | b5cbaa4 | 2011-08-04 13:26:10 -0300 | [diff] [blame] | 1300 | |
Antti Palosaari | c01a359 | 2012-08-12 22:27:07 -0300 | [diff] [blame] | 1301 | .power_ctrl = rtl2832u_power_ctrl, |
| 1302 | .i2c_algo = &rtl28xxu_i2c_algo, |
Antti Palosaari | ef37be1 | 2012-09-17 14:01:35 -0300 | [diff] [blame^] | 1303 | .read_config = rtl2832u_read_config, |
Antti Palosaari | c01a359 | 2012-08-12 22:27:07 -0300 | [diff] [blame] | 1304 | .frontend_attach = rtl2832u_frontend_attach, |
| 1305 | .tuner_attach = rtl2832u_tuner_attach, |
| 1306 | .init = rtl28xxu_init, |
| 1307 | .get_rc_config = rtl2832u_get_rc_config, |
Antti Palosaari | b5cbaa4 | 2011-08-04 13:26:10 -0300 | [diff] [blame] | 1308 | |
Antti Palosaari | c01a359 | 2012-08-12 22:27:07 -0300 | [diff] [blame] | 1309 | .num_adapters = 1, |
| 1310 | .adapter = { |
| 1311 | { |
| 1312 | .stream = DVB_USB_STREAM_BULK(0x81, 6, 8 * 512), |
Antti Palosaari | b5cbaa4 | 2011-08-04 13:26:10 -0300 | [diff] [blame] | 1313 | }, |
Antti Palosaari | b5cbaa4 | 2011-08-04 13:26:10 -0300 | [diff] [blame] | 1314 | }, |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 1315 | }; |
| 1316 | |
Antti Palosaari | c01a359 | 2012-08-12 22:27:07 -0300 | [diff] [blame] | 1317 | static const struct usb_device_id rtl28xxu_id_table[] = { |
| 1318 | { DVB_USB_DEVICE(USB_VID_REALTEK, USB_PID_REALTEK_RTL2831U, |
| 1319 | &rtl2831u_props, "Realtek RTL2831U reference design", NULL) }, |
| 1320 | { DVB_USB_DEVICE(USB_VID_WIDEVIEW, USB_PID_FREECOM_DVBT, |
| 1321 | &rtl2831u_props, "Freecom USB2.0 DVB-T", NULL) }, |
| 1322 | { DVB_USB_DEVICE(USB_VID_WIDEVIEW, USB_PID_FREECOM_DVBT_2, |
| 1323 | &rtl2831u_props, "Freecom USB2.0 DVB-T", NULL) }, |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 1324 | |
Antti Palosaari | 254ee2e | 2012-09-18 10:27:05 -0300 | [diff] [blame] | 1325 | { DVB_USB_DEVICE(USB_VID_REALTEK, 0x2832, |
| 1326 | &rtl2832u_props, "Realtek RTL2832U reference design", NULL) }, |
| 1327 | { DVB_USB_DEVICE(USB_VID_REALTEK, 0x2838, |
| 1328 | &rtl2832u_props, "Realtek RTL2832U reference design", NULL) }, |
Antti Palosaari | c01a359 | 2012-08-12 22:27:07 -0300 | [diff] [blame] | 1329 | { DVB_USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_T_STICK_BLACK_REV1, |
| 1330 | &rtl2832u_props, "Terratec Cinergy T Stick Black", NULL) }, |
| 1331 | { DVB_USB_DEVICE(USB_VID_GTEK, USB_PID_DELOCK_USB2_DVBT, |
| 1332 | &rtl2832u_props, "G-Tek Electronics Group Lifeview LV5TDLX DVB-T", NULL) }, |
| 1333 | { DVB_USB_DEVICE(USB_VID_TERRATEC, USB_PID_NOXON_DAB_STICK, |
| 1334 | &rtl2832u_props, "NOXON DAB/DAB+ USB dongle", NULL) }, |
Philipp Dreimann | 6d60805 | 2012-09-02 19:30:54 -0300 | [diff] [blame] | 1335 | { DVB_USB_DEVICE(USB_VID_GTEK, USB_PID_TREKSTOR_TERRES_2_0, |
| 1336 | &rtl2832u_props, "Trekstor DVB-T Stick Terres 2.0", NULL) }, |
Antti Palosaari | c2d246d1 | 2012-09-08 22:07:26 -0300 | [diff] [blame] | 1337 | { DVB_USB_DEVICE(USB_VID_DEXATEK, 0x1101, |
| 1338 | &rtl2832u_props, "Dexatek DK DVB-T Dongle", NULL) }, |
Antti Palosaari | c01a359 | 2012-08-12 22:27:07 -0300 | [diff] [blame] | 1339 | { } |
| 1340 | }; |
| 1341 | MODULE_DEVICE_TABLE(usb, rtl28xxu_id_table); |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 1342 | |
Antti Palosaari | c01a359 | 2012-08-12 22:27:07 -0300 | [diff] [blame] | 1343 | static struct usb_driver rtl28xxu_usb_driver = { |
| 1344 | .name = KBUILD_MODNAME, |
| 1345 | .id_table = rtl28xxu_id_table, |
| 1346 | .probe = dvb_usbv2_probe, |
| 1347 | .disconnect = dvb_usbv2_disconnect, |
| 1348 | .suspend = dvb_usbv2_suspend, |
| 1349 | .resume = dvb_usbv2_resume, |
Antti Palosaari | 78fa590 | 2012-08-14 22:21:09 -0300 | [diff] [blame] | 1350 | .reset_resume = dvb_usbv2_reset_resume, |
Antti Palosaari | c01a359 | 2012-08-12 22:27:07 -0300 | [diff] [blame] | 1351 | .no_dynamic_id = 1, |
| 1352 | .soft_unbind = 1, |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 1353 | }; |
| 1354 | |
Antti Palosaari | c01a359 | 2012-08-12 22:27:07 -0300 | [diff] [blame] | 1355 | module_usb_driver(rtl28xxu_usb_driver); |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 1356 | |
| 1357 | MODULE_DESCRIPTION("Realtek RTL28xxU DVB USB driver"); |
| 1358 | MODULE_AUTHOR("Antti Palosaari <crope@iki.fi>"); |
Thomas Mair | 5cf6631 | 2012-05-18 14:47:41 -0300 | [diff] [blame] | 1359 | MODULE_AUTHOR("Thomas Mair <thomas.mair86@googlemail.com>"); |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 1360 | MODULE_LICENSE("GPL"); |