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