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