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