Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 1 | /* |
| 2 | * Realtek RTL28xxU DVB USB driver |
| 3 | * |
| 4 | * Copyright (C) 2009 Antti Palosaari <crope@iki.fi> |
| 5 | * Copyright (C) 2011 Antti Palosaari <crope@iki.fi> |
Thomas Mair | 5cf6631 | 2012-05-18 14:47:41 -0300 | [diff] [blame] | 6 | * Copyright (C) 2012 Thomas Mair <thomas.mair86@googlemail.com> |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify |
| 9 | * it under the terms of the GNU General Public License as published by |
| 10 | * the Free Software Foundation; either version 2 of the License, or |
| 11 | * (at your option) any later version. |
| 12 | * |
| 13 | * This program is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | * GNU General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU General Public License along |
| 19 | * with this program; if not, write to the Free Software Foundation, Inc., |
| 20 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 21 | */ |
| 22 | |
| 23 | #include "rtl28xxu.h" |
| 24 | |
| 25 | #include "rtl2830.h" |
Thomas Mair | 5cf6631 | 2012-05-18 14:47:41 -0300 | [diff] [blame] | 26 | #include "rtl2832.h" |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 27 | |
| 28 | #include "qt1010.h" |
| 29 | #include "mt2060.h" |
| 30 | #include "mxl5005s.h" |
Thomas Mair | 5cf6631 | 2012-05-18 14:47:41 -0300 | [diff] [blame] | 31 | #include "fc0012.h" |
| 32 | #include "fc0013.h" |
Antti Palosaari | 542f6a5 | 2012-09-01 21:09:22 -0300 | [diff] [blame] | 33 | #include "e4000.h" |
Antti Palosaari | 384df49 | 2012-09-08 22:07:25 -0300 | [diff] [blame] | 34 | #include "fc2580.h" |
Antti Palosaari | 5be6572 | 2012-09-11 22:27:09 -0300 | [diff] [blame] | 35 | #include "tua9001.h" |
Mauro Carvalho Chehab | 6889ab2 | 2013-04-06 09:40:11 -0300 | [diff] [blame] | 36 | #include "r820t.h" |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 37 | |
Antti Palosaari | 1fd10f9 | 2014-04-09 12:42:35 -0300 | [diff] [blame] | 38 | /* |
| 39 | * RTL2832_SDR module is in staging. That logic is added in order to avoid any |
| 40 | * hard dependency to drivers/staging/ directory as we want compile mainline |
| 41 | * driver even whole staging directory is missing. |
| 42 | */ |
| 43 | #include <media/v4l2-subdev.h> |
| 44 | |
| 45 | #if IS_ENABLED(CONFIG_DVB_RTL2832_SDR) |
| 46 | struct dvb_frontend *rtl2832_sdr_attach(struct dvb_frontend *fe, |
| 47 | struct i2c_adapter *i2c, const struct rtl2832_config *cfg, |
| 48 | struct v4l2_subdev *sd); |
| 49 | #else |
| 50 | static inline struct dvb_frontend *rtl2832_sdr_attach(struct dvb_frontend *fe, |
| 51 | struct i2c_adapter *i2c, const struct rtl2832_config *cfg, |
| 52 | struct v4l2_subdev *sd) |
| 53 | { |
| 54 | return NULL; |
| 55 | } |
| 56 | #endif |
| 57 | |
Antti Palosaari | beab1b5 | 2014-04-09 18:08:37 -0300 | [diff] [blame] | 58 | #ifdef CONFIG_MEDIA_ATTACH |
| 59 | #define dvb_attach_sdr(FUNCTION, ARGS...) ({ \ |
| 60 | void *__r = NULL; \ |
| 61 | typeof(&FUNCTION) __a = symbol_request(FUNCTION); \ |
| 62 | if (__a) { \ |
| 63 | __r = (void *) __a(ARGS); \ |
| 64 | if (__r == NULL) \ |
| 65 | symbol_put(FUNCTION); \ |
| 66 | } \ |
| 67 | __r; \ |
| 68 | }) |
| 69 | |
| 70 | #else |
| 71 | #define dvb_attach_sdr(FUNCTION, ARGS...) ({ \ |
| 72 | FUNCTION(ARGS); \ |
| 73 | }) |
| 74 | |
| 75 | #endif |
| 76 | |
Antti Palosaari | 94b5fa6 | 2013-11-22 14:20:14 -0300 | [diff] [blame] | 77 | static int rtl28xxu_disable_rc; |
| 78 | module_param_named(disable_rc, rtl28xxu_disable_rc, int, 0644); |
| 79 | MODULE_PARM_DESC(disable_rc, "disable RTL2832U remote controller"); |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 80 | DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); |
| 81 | |
| 82 | static int rtl28xxu_ctrl_msg(struct dvb_usb_device *d, struct rtl28xxu_req *req) |
| 83 | { |
| 84 | int ret; |
| 85 | unsigned int pipe; |
| 86 | u8 requesttype; |
| 87 | u8 *buf; |
| 88 | |
| 89 | buf = kmalloc(req->size, GFP_KERNEL); |
| 90 | if (!buf) { |
| 91 | ret = -ENOMEM; |
| 92 | goto err; |
| 93 | } |
| 94 | |
| 95 | if (req->index & CMD_WR_FLAG) { |
| 96 | /* write */ |
| 97 | memcpy(buf, req->data, req->size); |
| 98 | requesttype = (USB_TYPE_VENDOR | USB_DIR_OUT); |
| 99 | pipe = usb_sndctrlpipe(d->udev, 0); |
| 100 | } else { |
| 101 | /* read */ |
| 102 | requesttype = (USB_TYPE_VENDOR | USB_DIR_IN); |
| 103 | pipe = usb_rcvctrlpipe(d->udev, 0); |
| 104 | } |
| 105 | |
| 106 | ret = usb_control_msg(d->udev, pipe, 0, requesttype, req->value, |
Antti Palosaari | 9935eea | 2012-01-21 22:26:52 -0300 | [diff] [blame] | 107 | req->index, buf, req->size, 1000); |
Antti Palosaari | d89b936 | 2012-08-22 19:42:00 -0300 | [diff] [blame] | 108 | |
| 109 | dvb_usb_dbg_usb_control_msg(d->udev, 0, requesttype, req->value, |
| 110 | req->index, buf, req->size); |
| 111 | |
Antti Palosaari | 9935eea | 2012-01-21 22:26:52 -0300 | [diff] [blame] | 112 | if (ret > 0) |
| 113 | ret = 0; |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 114 | |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 115 | /* read request, copy returned data to return buf */ |
| 116 | if (!ret && requesttype == (USB_TYPE_VENDOR | USB_DIR_IN)) |
| 117 | memcpy(req->data, buf, req->size); |
| 118 | |
| 119 | kfree(buf); |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 120 | |
Antti Palosaari | 9935eea | 2012-01-21 22:26:52 -0300 | [diff] [blame] | 121 | if (ret) |
| 122 | goto err; |
| 123 | |
| 124 | return ret; |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 125 | err: |
Antti Palosaari | c01a359 | 2012-08-12 22:27:07 -0300 | [diff] [blame] | 126 | dev_dbg(&d->udev->dev, "%s: failed=%d\n", __func__, ret); |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 127 | return ret; |
| 128 | } |
| 129 | |
Thomas Mair | 40a2d3c | 2012-05-18 14:47:42 -0300 | [diff] [blame] | 130 | 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] | 131 | { |
| 132 | struct rtl28xxu_req req; |
| 133 | |
| 134 | if (reg < 0x3000) |
| 135 | req.index = CMD_USB_WR; |
Antti Palosaari | b5cbaa4 | 2011-08-04 13:26:10 -0300 | [diff] [blame] | 136 | else if (reg < 0x4000) |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 137 | req.index = CMD_SYS_WR; |
Antti Palosaari | b5cbaa4 | 2011-08-04 13:26:10 -0300 | [diff] [blame] | 138 | else |
| 139 | req.index = CMD_IR_WR; |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 140 | |
| 141 | req.value = reg; |
| 142 | req.size = len; |
| 143 | req.data = val; |
| 144 | |
| 145 | return rtl28xxu_ctrl_msg(d, &req); |
| 146 | } |
| 147 | |
| 148 | static int rtl2831_rd_regs(struct dvb_usb_device *d, u16 reg, u8 *val, int len) |
| 149 | { |
| 150 | struct rtl28xxu_req req; |
| 151 | |
| 152 | if (reg < 0x3000) |
| 153 | req.index = CMD_USB_RD; |
Antti Palosaari | b5cbaa4 | 2011-08-04 13:26:10 -0300 | [diff] [blame] | 154 | else if (reg < 0x4000) |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 155 | req.index = CMD_SYS_RD; |
Antti Palosaari | b5cbaa4 | 2011-08-04 13:26:10 -0300 | [diff] [blame] | 156 | else |
| 157 | req.index = CMD_IR_RD; |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 158 | |
| 159 | req.value = reg; |
| 160 | req.size = len; |
| 161 | req.data = val; |
| 162 | |
| 163 | return rtl28xxu_ctrl_msg(d, &req); |
| 164 | } |
| 165 | |
Thomas Mair | 40a2d3c | 2012-05-18 14:47:42 -0300 | [diff] [blame] | 166 | 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] | 167 | { |
Thomas Mair | 40a2d3c | 2012-05-18 14:47:42 -0300 | [diff] [blame] | 168 | return rtl28xx_wr_regs(d, reg, &val, 1); |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 169 | } |
| 170 | |
Thomas Mair | 40a2d3c | 2012-05-18 14:47:42 -0300 | [diff] [blame] | 171 | 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] | 172 | { |
| 173 | return rtl2831_rd_regs(d, reg, val, 1); |
| 174 | } |
| 175 | |
Antti Palosaari | 4005c1a | 2012-09-17 15:43:57 -0300 | [diff] [blame] | 176 | static int rtl28xx_wr_reg_mask(struct dvb_usb_device *d, u16 reg, u8 val, |
| 177 | u8 mask) |
| 178 | { |
| 179 | int ret; |
| 180 | u8 tmp; |
| 181 | |
| 182 | /* no need for read if whole reg is written */ |
| 183 | if (mask != 0xff) { |
| 184 | ret = rtl28xx_rd_reg(d, reg, &tmp); |
| 185 | if (ret) |
| 186 | return ret; |
| 187 | |
| 188 | val &= mask; |
| 189 | tmp &= ~mask; |
| 190 | val |= tmp; |
| 191 | } |
| 192 | |
| 193 | return rtl28xx_wr_reg(d, reg, val); |
| 194 | } |
| 195 | |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 196 | /* I2C */ |
| 197 | static int rtl28xxu_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[], |
| 198 | int num) |
| 199 | { |
| 200 | int ret; |
| 201 | struct dvb_usb_device *d = i2c_get_adapdata(adap); |
Antti Palosaari | 34ec293 | 2011-08-04 20:21:16 -0300 | [diff] [blame] | 202 | struct rtl28xxu_priv *priv = d->priv; |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 203 | struct rtl28xxu_req req; |
| 204 | |
| 205 | /* |
| 206 | * It is not known which are real I2C bus xfer limits, but testing |
| 207 | * with RTL2831U + MT2060 gives max RD 24 and max WR 22 bytes. |
Antti Palosaari | 34ec293 | 2011-08-04 20:21:16 -0300 | [diff] [blame] | 208 | * TODO: find out RTL2832U lens |
| 209 | */ |
| 210 | |
| 211 | /* |
| 212 | * I2C adapter logic looks rather complicated due to fact it handles |
| 213 | * three different access methods. Those methods are; |
| 214 | * 1) integrated demod access |
| 215 | * 2) old I2C access |
| 216 | * 3) new I2C access |
| 217 | * |
| 218 | * Used method is selected in order 1, 2, 3. Method 3 can handle all |
| 219 | * requests but there is two reasons why not use it always; |
| 220 | * 1) It is most expensive, usually two USB messages are needed |
| 221 | * 2) At least RTL2831U does not support it |
| 222 | * |
| 223 | * Method 3 is needed in case of I2C write+read (typical register read) |
| 224 | * where write is more than one byte. |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 225 | */ |
| 226 | |
| 227 | if (mutex_lock_interruptible(&d->i2c_mutex) < 0) |
| 228 | return -EAGAIN; |
| 229 | |
| 230 | if (num == 2 && !(msg[0].flags & I2C_M_RD) && |
| 231 | (msg[1].flags & I2C_M_RD)) { |
Antti Palosaari | 34ec293 | 2011-08-04 20:21:16 -0300 | [diff] [blame] | 232 | if (msg[0].len > 24 || msg[1].len > 24) { |
| 233 | /* TODO: check msg[0].len max */ |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 234 | ret = -EOPNOTSUPP; |
Antti Palosaari | 9935eea | 2012-01-21 22:26:52 -0300 | [diff] [blame] | 235 | goto err_mutex_unlock; |
Antti Palosaari | 34ec293 | 2011-08-04 20:21:16 -0300 | [diff] [blame] | 236 | } else if (msg[0].addr == 0x10) { |
| 237 | /* method 1 - integrated demod */ |
| 238 | req.value = (msg[0].buf[0] << 8) | (msg[0].addr << 1); |
| 239 | req.index = CMD_DEMOD_RD | priv->page; |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 240 | req.size = msg[1].len; |
| 241 | req.data = &msg[1].buf[0]; |
| 242 | ret = rtl28xxu_ctrl_msg(d, &req); |
Antti Palosaari | 34ec293 | 2011-08-04 20:21:16 -0300 | [diff] [blame] | 243 | } else if (msg[0].len < 2) { |
| 244 | /* method 2 - old I2C */ |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 245 | req.value = (msg[0].buf[0] << 8) | (msg[0].addr << 1); |
| 246 | req.index = CMD_I2C_RD; |
| 247 | req.size = msg[1].len; |
| 248 | req.data = &msg[1].buf[0]; |
| 249 | ret = rtl28xxu_ctrl_msg(d, &req); |
Antti Palosaari | 34ec293 | 2011-08-04 20:21:16 -0300 | [diff] [blame] | 250 | } else { |
| 251 | /* method 3 - new I2C */ |
| 252 | req.value = (msg[0].addr << 1); |
| 253 | req.index = CMD_I2C_DA_WR; |
| 254 | req.size = msg[0].len; |
| 255 | req.data = msg[0].buf; |
| 256 | ret = rtl28xxu_ctrl_msg(d, &req); |
| 257 | if (ret) |
Antti Palosaari | 9935eea | 2012-01-21 22:26:52 -0300 | [diff] [blame] | 258 | goto err_mutex_unlock; |
Antti Palosaari | 34ec293 | 2011-08-04 20:21:16 -0300 | [diff] [blame] | 259 | |
| 260 | req.value = (msg[0].addr << 1); |
| 261 | req.index = CMD_I2C_DA_RD; |
| 262 | req.size = msg[1].len; |
| 263 | req.data = msg[1].buf; |
| 264 | ret = rtl28xxu_ctrl_msg(d, &req); |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 265 | } |
| 266 | } else if (num == 1 && !(msg[0].flags & I2C_M_RD)) { |
| 267 | if (msg[0].len > 22) { |
Antti Palosaari | 34ec293 | 2011-08-04 20:21:16 -0300 | [diff] [blame] | 268 | /* TODO: check msg[0].len max */ |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 269 | ret = -EOPNOTSUPP; |
Antti Palosaari | 9935eea | 2012-01-21 22:26:52 -0300 | [diff] [blame] | 270 | goto err_mutex_unlock; |
Antti Palosaari | 34ec293 | 2011-08-04 20:21:16 -0300 | [diff] [blame] | 271 | } else if (msg[0].addr == 0x10) { |
| 272 | /* method 1 - integrated demod */ |
| 273 | if (msg[0].buf[0] == 0x00) { |
| 274 | /* save demod page for later demod access */ |
| 275 | priv->page = msg[0].buf[1]; |
| 276 | ret = 0; |
| 277 | } else { |
| 278 | req.value = (msg[0].buf[0] << 8) | |
| 279 | (msg[0].addr << 1); |
| 280 | req.index = CMD_DEMOD_WR | priv->page; |
| 281 | req.size = msg[0].len-1; |
| 282 | req.data = &msg[0].buf[1]; |
| 283 | ret = rtl28xxu_ctrl_msg(d, &req); |
| 284 | } |
| 285 | } else if (msg[0].len < 23) { |
| 286 | /* method 2 - old I2C */ |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 287 | req.value = (msg[0].buf[0] << 8) | (msg[0].addr << 1); |
| 288 | req.index = CMD_I2C_WR; |
| 289 | req.size = msg[0].len-1; |
| 290 | req.data = &msg[0].buf[1]; |
| 291 | ret = rtl28xxu_ctrl_msg(d, &req); |
Antti Palosaari | 34ec293 | 2011-08-04 20:21:16 -0300 | [diff] [blame] | 292 | } else { |
| 293 | /* method 3 - new I2C */ |
| 294 | req.value = (msg[0].addr << 1); |
| 295 | req.index = CMD_I2C_DA_WR; |
| 296 | req.size = msg[0].len; |
| 297 | req.data = msg[0].buf; |
| 298 | ret = rtl28xxu_ctrl_msg(d, &req); |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 299 | } |
| 300 | } else { |
| 301 | ret = -EINVAL; |
| 302 | } |
| 303 | |
Antti Palosaari | 9935eea | 2012-01-21 22:26:52 -0300 | [diff] [blame] | 304 | err_mutex_unlock: |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 305 | mutex_unlock(&d->i2c_mutex); |
| 306 | |
| 307 | return ret ? ret : num; |
| 308 | } |
| 309 | |
| 310 | static u32 rtl28xxu_i2c_func(struct i2c_adapter *adapter) |
| 311 | { |
| 312 | return I2C_FUNC_I2C; |
| 313 | } |
| 314 | |
| 315 | static struct i2c_algorithm rtl28xxu_i2c_algo = { |
| 316 | .master_xfer = rtl28xxu_i2c_xfer, |
| 317 | .functionality = rtl28xxu_i2c_func, |
| 318 | }; |
| 319 | |
Antti Palosaari | 81347f5 | 2012-09-17 16:50:36 -0300 | [diff] [blame] | 320 | static int rtl2831u_read_config(struct dvb_usb_device *d) |
| 321 | { |
| 322 | struct rtl28xxu_priv *priv = d_to_priv(d); |
| 323 | int ret; |
| 324 | u8 buf[1]; |
| 325 | /* open RTL2831U/RTL2830 I2C gate */ |
| 326 | struct rtl28xxu_req req_gate_open = {0x0120, 0x0011, 0x0001, "\x08"}; |
| 327 | /* tuner probes */ |
| 328 | struct rtl28xxu_req req_mt2060 = {0x00c0, CMD_I2C_RD, 1, buf}; |
| 329 | struct rtl28xxu_req req_qt1010 = {0x0fc4, CMD_I2C_RD, 1, buf}; |
| 330 | |
| 331 | dev_dbg(&d->udev->dev, "%s:\n", __func__); |
| 332 | |
| 333 | /* |
| 334 | * RTL2831U GPIOs |
| 335 | * ========================================================= |
| 336 | * GPIO0 | tuner#0 | 0 off | 1 on | MXL5005S (?) |
| 337 | * GPIO2 | LED | 0 off | 1 on | |
| 338 | * GPIO4 | tuner#1 | 0 on | 1 off | MT2060 |
| 339 | */ |
| 340 | |
| 341 | /* GPIO direction */ |
| 342 | ret = rtl28xx_wr_reg(d, SYS_GPIO_DIR, 0x0a); |
| 343 | if (ret) |
| 344 | goto err; |
| 345 | |
| 346 | /* enable as output GPIO0, GPIO2, GPIO4 */ |
| 347 | ret = rtl28xx_wr_reg(d, SYS_GPIO_OUT_EN, 0x15); |
| 348 | if (ret) |
| 349 | goto err; |
| 350 | |
| 351 | /* |
| 352 | * Probe used tuner. We need to know used tuner before demod attach |
| 353 | * since there is some demod params needed to set according to tuner. |
| 354 | */ |
| 355 | |
| 356 | /* demod needs some time to wake up */ |
| 357 | msleep(20); |
| 358 | |
| 359 | priv->tuner_name = "NONE"; |
| 360 | |
| 361 | /* open demod I2C gate */ |
| 362 | ret = rtl28xxu_ctrl_msg(d, &req_gate_open); |
| 363 | if (ret) |
| 364 | goto err; |
| 365 | |
| 366 | /* check QT1010 ID(?) register; reg=0f val=2c */ |
| 367 | ret = rtl28xxu_ctrl_msg(d, &req_qt1010); |
| 368 | if (ret == 0 && buf[0] == 0x2c) { |
| 369 | priv->tuner = TUNER_RTL2830_QT1010; |
| 370 | priv->tuner_name = "QT1010"; |
| 371 | goto found; |
| 372 | } |
| 373 | |
| 374 | /* open demod I2C gate */ |
| 375 | ret = rtl28xxu_ctrl_msg(d, &req_gate_open); |
| 376 | if (ret) |
| 377 | goto err; |
| 378 | |
| 379 | /* check MT2060 ID register; reg=00 val=63 */ |
| 380 | ret = rtl28xxu_ctrl_msg(d, &req_mt2060); |
| 381 | if (ret == 0 && buf[0] == 0x63) { |
| 382 | priv->tuner = TUNER_RTL2830_MT2060; |
| 383 | priv->tuner_name = "MT2060"; |
| 384 | goto found; |
| 385 | } |
| 386 | |
| 387 | /* assume MXL5005S */ |
| 388 | priv->tuner = TUNER_RTL2830_MXL5005S; |
| 389 | priv->tuner_name = "MXL5005S"; |
| 390 | goto found; |
| 391 | |
| 392 | found: |
| 393 | dev_dbg(&d->udev->dev, "%s: tuner=%s\n", __func__, priv->tuner_name); |
| 394 | |
| 395 | return 0; |
| 396 | err: |
| 397 | dev_dbg(&d->udev->dev, "%s: failed=%d\n", __func__, ret); |
| 398 | return ret; |
| 399 | } |
| 400 | |
Antti Palosaari | ef37be1 | 2012-09-17 14:01:35 -0300 | [diff] [blame] | 401 | static int rtl2832u_read_config(struct dvb_usb_device *d) |
| 402 | { |
| 403 | struct rtl28xxu_priv *priv = d_to_priv(d); |
| 404 | int ret; |
Antti Palosaari | 4005c1a | 2012-09-17 15:43:57 -0300 | [diff] [blame] | 405 | u8 buf[2]; |
Antti Palosaari | ef37be1 | 2012-09-17 14:01:35 -0300 | [diff] [blame] | 406 | /* open RTL2832U/RTL2832 I2C gate */ |
| 407 | struct rtl28xxu_req req_gate_open = {0x0120, 0x0011, 0x0001, "\x18"}; |
| 408 | /* close RTL2832U/RTL2832 I2C gate */ |
| 409 | struct rtl28xxu_req req_gate_close = {0x0120, 0x0011, 0x0001, "\x10"}; |
| 410 | /* tuner probes */ |
| 411 | struct rtl28xxu_req req_fc0012 = {0x00c6, CMD_I2C_RD, 1, buf}; |
| 412 | struct rtl28xxu_req req_fc0013 = {0x00c6, CMD_I2C_RD, 1, buf}; |
| 413 | struct rtl28xxu_req req_mt2266 = {0x00c0, CMD_I2C_RD, 1, buf}; |
| 414 | struct rtl28xxu_req req_fc2580 = {0x01ac, CMD_I2C_RD, 1, buf}; |
| 415 | struct rtl28xxu_req req_mt2063 = {0x00c0, CMD_I2C_RD, 1, buf}; |
| 416 | struct rtl28xxu_req req_max3543 = {0x00c0, CMD_I2C_RD, 1, buf}; |
| 417 | struct rtl28xxu_req req_tua9001 = {0x7ec0, CMD_I2C_RD, 2, buf}; |
| 418 | struct rtl28xxu_req req_mxl5007t = {0xd9c0, CMD_I2C_RD, 1, buf}; |
| 419 | struct rtl28xxu_req req_e4000 = {0x02c8, CMD_I2C_RD, 1, buf}; |
| 420 | struct rtl28xxu_req req_tda18272 = {0x00c0, CMD_I2C_RD, 2, buf}; |
Gianluca Gennari | a908eb9 | 2013-06-02 17:24:24 -0300 | [diff] [blame] | 421 | struct rtl28xxu_req req_r820t = {0x0034, CMD_I2C_RD, 1, buf}; |
Antti Palosaari | 8b4cac1 | 2013-10-30 00:45:38 -0300 | [diff] [blame] | 422 | struct rtl28xxu_req req_r828d = {0x0074, CMD_I2C_RD, 1, buf}; |
Antti Palosaari | ef37be1 | 2012-09-17 14:01:35 -0300 | [diff] [blame] | 423 | |
| 424 | dev_dbg(&d->udev->dev, "%s:\n", __func__); |
| 425 | |
Antti Palosaari | 4005c1a | 2012-09-17 15:43:57 -0300 | [diff] [blame] | 426 | /* enable GPIO3 and GPIO6 as output */ |
| 427 | ret = rtl28xx_wr_reg_mask(d, SYS_GPIO_DIR, 0x00, 0x40); |
Antti Palosaari | ef37be1 | 2012-09-17 14:01:35 -0300 | [diff] [blame] | 428 | if (ret) |
| 429 | goto err; |
| 430 | |
Antti Palosaari | 4005c1a | 2012-09-17 15:43:57 -0300 | [diff] [blame] | 431 | ret = rtl28xx_wr_reg_mask(d, SYS_GPIO_OUT_EN, 0x48, 0x48); |
Antti Palosaari | ef37be1 | 2012-09-17 14:01:35 -0300 | [diff] [blame] | 432 | if (ret) |
| 433 | goto err; |
| 434 | |
| 435 | /* |
| 436 | * Probe used tuner. We need to know used tuner before demod attach |
| 437 | * since there is some demod params needed to set according to tuner. |
| 438 | */ |
| 439 | |
| 440 | /* open demod I2C gate */ |
| 441 | ret = rtl28xxu_ctrl_msg(d, &req_gate_open); |
| 442 | if (ret) |
| 443 | goto err; |
| 444 | |
| 445 | priv->tuner_name = "NONE"; |
| 446 | |
| 447 | /* check FC0012 ID register; reg=00 val=a1 */ |
| 448 | ret = rtl28xxu_ctrl_msg(d, &req_fc0012); |
| 449 | if (ret == 0 && buf[0] == 0xa1) { |
| 450 | priv->tuner = TUNER_RTL2832_FC0012; |
| 451 | priv->tuner_name = "FC0012"; |
| 452 | goto found; |
| 453 | } |
| 454 | |
| 455 | /* check FC0013 ID register; reg=00 val=a3 */ |
| 456 | ret = rtl28xxu_ctrl_msg(d, &req_fc0013); |
| 457 | if (ret == 0 && buf[0] == 0xa3) { |
| 458 | priv->tuner = TUNER_RTL2832_FC0013; |
| 459 | priv->tuner_name = "FC0013"; |
| 460 | goto found; |
| 461 | } |
| 462 | |
| 463 | /* check MT2266 ID register; reg=00 val=85 */ |
| 464 | ret = rtl28xxu_ctrl_msg(d, &req_mt2266); |
| 465 | if (ret == 0 && buf[0] == 0x85) { |
| 466 | priv->tuner = TUNER_RTL2832_MT2266; |
| 467 | priv->tuner_name = "MT2266"; |
| 468 | goto found; |
| 469 | } |
| 470 | |
| 471 | /* check FC2580 ID register; reg=01 val=56 */ |
| 472 | ret = rtl28xxu_ctrl_msg(d, &req_fc2580); |
| 473 | if (ret == 0 && buf[0] == 0x56) { |
| 474 | priv->tuner = TUNER_RTL2832_FC2580; |
| 475 | priv->tuner_name = "FC2580"; |
| 476 | goto found; |
| 477 | } |
| 478 | |
| 479 | /* check MT2063 ID register; reg=00 val=9e || 9c */ |
| 480 | ret = rtl28xxu_ctrl_msg(d, &req_mt2063); |
| 481 | if (ret == 0 && (buf[0] == 0x9e || buf[0] == 0x9c)) { |
| 482 | priv->tuner = TUNER_RTL2832_MT2063; |
| 483 | priv->tuner_name = "MT2063"; |
| 484 | goto found; |
| 485 | } |
| 486 | |
| 487 | /* check MAX3543 ID register; reg=00 val=38 */ |
| 488 | ret = rtl28xxu_ctrl_msg(d, &req_max3543); |
| 489 | if (ret == 0 && buf[0] == 0x38) { |
| 490 | priv->tuner = TUNER_RTL2832_MAX3543; |
| 491 | priv->tuner_name = "MAX3543"; |
| 492 | goto found; |
| 493 | } |
| 494 | |
| 495 | /* check TUA9001 ID register; reg=7e val=2328 */ |
| 496 | ret = rtl28xxu_ctrl_msg(d, &req_tua9001); |
| 497 | if (ret == 0 && buf[0] == 0x23 && buf[1] == 0x28) { |
| 498 | priv->tuner = TUNER_RTL2832_TUA9001; |
| 499 | priv->tuner_name = "TUA9001"; |
| 500 | goto found; |
| 501 | } |
| 502 | |
| 503 | /* check MXL5007R ID register; reg=d9 val=14 */ |
| 504 | ret = rtl28xxu_ctrl_msg(d, &req_mxl5007t); |
| 505 | if (ret == 0 && buf[0] == 0x14) { |
| 506 | priv->tuner = TUNER_RTL2832_MXL5007T; |
| 507 | priv->tuner_name = "MXL5007T"; |
| 508 | goto found; |
| 509 | } |
| 510 | |
| 511 | /* check E4000 ID register; reg=02 val=40 */ |
| 512 | ret = rtl28xxu_ctrl_msg(d, &req_e4000); |
| 513 | if (ret == 0 && buf[0] == 0x40) { |
| 514 | priv->tuner = TUNER_RTL2832_E4000; |
| 515 | priv->tuner_name = "E4000"; |
| 516 | goto found; |
| 517 | } |
| 518 | |
| 519 | /* check TDA18272 ID register; reg=00 val=c760 */ |
| 520 | ret = rtl28xxu_ctrl_msg(d, &req_tda18272); |
| 521 | if (ret == 0 && (buf[0] == 0xc7 || buf[1] == 0x60)) { |
| 522 | priv->tuner = TUNER_RTL2832_TDA18272; |
| 523 | priv->tuner_name = "TDA18272"; |
| 524 | goto found; |
| 525 | } |
| 526 | |
Gianluca Gennari | a908eb9 | 2013-06-02 17:24:24 -0300 | [diff] [blame] | 527 | /* check R820T ID register; reg=00 val=69 */ |
Mauro Carvalho Chehab | 6889ab2 | 2013-04-06 09:40:11 -0300 | [diff] [blame] | 528 | ret = rtl28xxu_ctrl_msg(d, &req_r820t); |
Gianluca Gennari | a908eb9 | 2013-06-02 17:24:24 -0300 | [diff] [blame] | 529 | if (ret == 0 && buf[0] == 0x69) { |
Mauro Carvalho Chehab | 6889ab2 | 2013-04-06 09:40:11 -0300 | [diff] [blame] | 530 | priv->tuner = TUNER_RTL2832_R820T; |
| 531 | priv->tuner_name = "R820T"; |
| 532 | goto found; |
| 533 | } |
| 534 | |
Antti Palosaari | 8b4cac1 | 2013-10-30 00:45:38 -0300 | [diff] [blame] | 535 | /* check R828D ID register; reg=00 val=69 */ |
| 536 | ret = rtl28xxu_ctrl_msg(d, &req_r828d); |
| 537 | if (ret == 0 && buf[0] == 0x69) { |
| 538 | priv->tuner = TUNER_RTL2832_R828D; |
| 539 | priv->tuner_name = "R828D"; |
| 540 | goto found; |
| 541 | } |
| 542 | |
| 543 | |
Antti Palosaari | ef37be1 | 2012-09-17 14:01:35 -0300 | [diff] [blame] | 544 | found: |
| 545 | dev_dbg(&d->udev->dev, "%s: tuner=%s\n", __func__, priv->tuner_name); |
| 546 | |
| 547 | /* close demod I2C gate */ |
| 548 | ret = rtl28xxu_ctrl_msg(d, &req_gate_close); |
| 549 | if (ret < 0) |
| 550 | goto err; |
| 551 | |
| 552 | return 0; |
| 553 | err: |
| 554 | dev_dbg(&d->udev->dev, "%s: failed=%d\n", __func__, ret); |
| 555 | return ret; |
| 556 | } |
| 557 | |
Antti Palosaari | e8b4668 | 2013-10-12 23:35:35 -0300 | [diff] [blame] | 558 | static const struct rtl2830_config rtl28xxu_rtl2830_mt2060_config = { |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 559 | .i2c_addr = 0x10, /* 0x20 */ |
| 560 | .xtal = 28800000, |
| 561 | .ts_mode = 0, |
| 562 | .spec_inv = 1, |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 563 | .vtop = 0x20, |
| 564 | .krf = 0x04, |
| 565 | .agc_targ_val = 0x2d, |
| 566 | |
| 567 | }; |
| 568 | |
Antti Palosaari | e8b4668 | 2013-10-12 23:35:35 -0300 | [diff] [blame] | 569 | static const struct rtl2830_config rtl28xxu_rtl2830_qt1010_config = { |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 570 | .i2c_addr = 0x10, /* 0x20 */ |
| 571 | .xtal = 28800000, |
| 572 | .ts_mode = 0, |
| 573 | .spec_inv = 1, |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 574 | .vtop = 0x20, |
| 575 | .krf = 0x04, |
| 576 | .agc_targ_val = 0x2d, |
| 577 | }; |
| 578 | |
Antti Palosaari | e8b4668 | 2013-10-12 23:35:35 -0300 | [diff] [blame] | 579 | static const struct rtl2830_config rtl28xxu_rtl2830_mxl5005s_config = { |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 580 | .i2c_addr = 0x10, /* 0x20 */ |
| 581 | .xtal = 28800000, |
| 582 | .ts_mode = 0, |
| 583 | .spec_inv = 0, |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 584 | .vtop = 0x3f, |
| 585 | .krf = 0x04, |
| 586 | .agc_targ_val = 0x3e, |
| 587 | }; |
| 588 | |
Antti Palosaari | b5cbaa4 | 2011-08-04 13:26:10 -0300 | [diff] [blame] | 589 | static int rtl2831u_frontend_attach(struct dvb_usb_adapter *adap) |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 590 | { |
Antti Palosaari | c01a359 | 2012-08-12 22:27:07 -0300 | [diff] [blame] | 591 | struct dvb_usb_device *d = adap_to_d(adap); |
| 592 | struct rtl28xxu_priv *priv = d_to_priv(d); |
Antti Palosaari | e8b4668 | 2013-10-12 23:35:35 -0300 | [diff] [blame] | 593 | const struct rtl2830_config *rtl2830_config; |
Antti Palosaari | 81347f5 | 2012-09-17 16:50:36 -0300 | [diff] [blame] | 594 | int ret; |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 595 | |
Antti Palosaari | c01a359 | 2012-08-12 22:27:07 -0300 | [diff] [blame] | 596 | dev_dbg(&d->udev->dev, "%s:\n", __func__); |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 597 | |
Antti Palosaari | 81347f5 | 2012-09-17 16:50:36 -0300 | [diff] [blame] | 598 | switch (priv->tuner) { |
| 599 | case TUNER_RTL2830_QT1010: |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 600 | rtl2830_config = &rtl28xxu_rtl2830_qt1010_config; |
Antti Palosaari | 81347f5 | 2012-09-17 16:50:36 -0300 | [diff] [blame] | 601 | break; |
| 602 | case TUNER_RTL2830_MT2060: |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 603 | rtl2830_config = &rtl28xxu_rtl2830_mt2060_config; |
Antti Palosaari | 81347f5 | 2012-09-17 16:50:36 -0300 | [diff] [blame] | 604 | break; |
| 605 | case TUNER_RTL2830_MXL5005S: |
| 606 | rtl2830_config = &rtl28xxu_rtl2830_mxl5005s_config; |
| 607 | break; |
| 608 | default: |
| 609 | dev_err(&d->udev->dev, "%s: unknown tuner=%s\n", |
| 610 | KBUILD_MODNAME, priv->tuner_name); |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 611 | ret = -ENODEV; |
| 612 | goto err; |
| 613 | } |
| 614 | |
Antti Palosaari | 81347f5 | 2012-09-17 16:50:36 -0300 | [diff] [blame] | 615 | /* attach demodulator */ |
| 616 | adap->fe[0] = dvb_attach(rtl2830_attach, rtl2830_config, &d->i2c_adap); |
| 617 | if (!adap->fe[0]) { |
| 618 | ret = -ENODEV; |
| 619 | goto err; |
| 620 | } |
| 621 | |
| 622 | return 0; |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 623 | err: |
Antti Palosaari | c01a359 | 2012-08-12 22:27:07 -0300 | [diff] [blame] | 624 | dev_dbg(&d->udev->dev, "%s: failed=%d\n", __func__, ret); |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 625 | return ret; |
| 626 | } |
| 627 | |
Antti Palosaari | e8b4668 | 2013-10-12 23:35:35 -0300 | [diff] [blame] | 628 | static const struct rtl2832_config rtl28xxu_rtl2832_fc0012_config = { |
Thomas Mair | 5cf6631 | 2012-05-18 14:47:41 -0300 | [diff] [blame] | 629 | .i2c_addr = 0x10, /* 0x20 */ |
| 630 | .xtal = 28800000, |
Thomas Mair | 5cf6631 | 2012-05-18 14:47:41 -0300 | [diff] [blame] | 631 | .tuner = TUNER_RTL2832_FC0012 |
| 632 | }; |
| 633 | |
Antti Palosaari | e8b4668 | 2013-10-12 23:35:35 -0300 | [diff] [blame] | 634 | static const struct rtl2832_config rtl28xxu_rtl2832_fc0013_config = { |
Thomas Mair | 5cf6631 | 2012-05-18 14:47:41 -0300 | [diff] [blame] | 635 | .i2c_addr = 0x10, /* 0x20 */ |
| 636 | .xtal = 28800000, |
Thomas Mair | 5cf6631 | 2012-05-18 14:47:41 -0300 | [diff] [blame] | 637 | .tuner = TUNER_RTL2832_FC0013 |
| 638 | }; |
| 639 | |
Antti Palosaari | e8b4668 | 2013-10-12 23:35:35 -0300 | [diff] [blame] | 640 | static const struct rtl2832_config rtl28xxu_rtl2832_tua9001_config = { |
Antti Palosaari | 5be6572 | 2012-09-11 22:27:09 -0300 | [diff] [blame] | 641 | .i2c_addr = 0x10, /* 0x20 */ |
| 642 | .xtal = 28800000, |
| 643 | .tuner = TUNER_RTL2832_TUA9001, |
| 644 | }; |
| 645 | |
Antti Palosaari | e8b4668 | 2013-10-12 23:35:35 -0300 | [diff] [blame] | 646 | static const struct rtl2832_config rtl28xxu_rtl2832_e4000_config = { |
Antti Palosaari | 3d8a60d | 2012-09-17 17:54:27 -0300 | [diff] [blame] | 647 | .i2c_addr = 0x10, /* 0x20 */ |
| 648 | .xtal = 28800000, |
| 649 | .tuner = TUNER_RTL2832_E4000, |
| 650 | }; |
| 651 | |
Antti Palosaari | e8b4668 | 2013-10-12 23:35:35 -0300 | [diff] [blame] | 652 | static const struct rtl2832_config rtl28xxu_rtl2832_r820t_config = { |
Mauro Carvalho Chehab | 6889ab2 | 2013-04-06 09:40:11 -0300 | [diff] [blame] | 653 | .i2c_addr = 0x10, |
| 654 | .xtal = 28800000, |
| 655 | .tuner = TUNER_RTL2832_R820T, |
| 656 | }; |
| 657 | |
Thomas Mair | 5cf6631 | 2012-05-18 14:47:41 -0300 | [diff] [blame] | 658 | static int rtl2832u_fc0012_tuner_callback(struct dvb_usb_device *d, |
| 659 | int cmd, int arg) |
| 660 | { |
| 661 | int ret; |
| 662 | u8 val; |
| 663 | |
Antti Palosaari | c01a359 | 2012-08-12 22:27:07 -0300 | [diff] [blame] | 664 | dev_dbg(&d->udev->dev, "%s: cmd=%d arg=%d\n", __func__, cmd, arg); |
| 665 | |
Thomas Mair | 5cf6631 | 2012-05-18 14:47:41 -0300 | [diff] [blame] | 666 | switch (cmd) { |
| 667 | case FC_FE_CALLBACK_VHF_ENABLE: |
| 668 | /* set output values */ |
Thomas Mair | 40a2d3c | 2012-05-18 14:47:42 -0300 | [diff] [blame] | 669 | ret = rtl28xx_rd_reg(d, SYS_GPIO_OUT_VAL, &val); |
Thomas Mair | 5cf6631 | 2012-05-18 14:47:41 -0300 | [diff] [blame] | 670 | if (ret) |
| 671 | goto err; |
| 672 | |
| 673 | if (arg) |
| 674 | val &= 0xbf; /* set GPIO6 low */ |
| 675 | else |
| 676 | val |= 0x40; /* set GPIO6 high */ |
| 677 | |
| 678 | |
Thomas Mair | 40a2d3c | 2012-05-18 14:47:42 -0300 | [diff] [blame] | 679 | ret = rtl28xx_wr_reg(d, SYS_GPIO_OUT_VAL, val); |
Thomas Mair | 5cf6631 | 2012-05-18 14:47:41 -0300 | [diff] [blame] | 680 | if (ret) |
| 681 | goto err; |
| 682 | break; |
| 683 | default: |
| 684 | ret = -EINVAL; |
| 685 | goto err; |
| 686 | } |
| 687 | return 0; |
Thomas Mair | 5cf6631 | 2012-05-18 14:47:41 -0300 | [diff] [blame] | 688 | err: |
Antti Palosaari | c01a359 | 2012-08-12 22:27:07 -0300 | [diff] [blame] | 689 | dev_dbg(&d->udev->dev, "%s: failed=%d\n", __func__, ret); |
Thomas Mair | 5cf6631 | 2012-05-18 14:47:41 -0300 | [diff] [blame] | 690 | return ret; |
| 691 | } |
| 692 | |
Antti Palosaari | 5be6572 | 2012-09-11 22:27:09 -0300 | [diff] [blame] | 693 | static int rtl2832u_tua9001_tuner_callback(struct dvb_usb_device *d, |
| 694 | int cmd, int arg) |
| 695 | { |
| 696 | int ret; |
| 697 | u8 val; |
| 698 | |
| 699 | dev_dbg(&d->udev->dev, "%s: cmd=%d arg=%d\n", __func__, cmd, arg); |
| 700 | |
| 701 | /* |
| 702 | * CEN always enabled by hardware wiring |
| 703 | * RESETN GPIO4 |
| 704 | * RXEN GPIO1 |
| 705 | */ |
| 706 | |
Antti Palosaari | 5be6572 | 2012-09-11 22:27:09 -0300 | [diff] [blame] | 707 | switch (cmd) { |
| 708 | case TUA9001_CMD_RESETN: |
| 709 | if (arg) |
Antti Palosaari | 4005c1a | 2012-09-17 15:43:57 -0300 | [diff] [blame] | 710 | val = (1 << 4); |
Antti Palosaari | 5be6572 | 2012-09-11 22:27:09 -0300 | [diff] [blame] | 711 | else |
Antti Palosaari | 4005c1a | 2012-09-17 15:43:57 -0300 | [diff] [blame] | 712 | val = (0 << 4); |
Antti Palosaari | 5be6572 | 2012-09-11 22:27:09 -0300 | [diff] [blame] | 713 | |
Antti Palosaari | 4005c1a | 2012-09-17 15:43:57 -0300 | [diff] [blame] | 714 | ret = rtl28xx_wr_reg_mask(d, SYS_GPIO_OUT_VAL, val, 0x10); |
| 715 | if (ret) |
Antti Palosaari | 5be6572 | 2012-09-11 22:27:09 -0300 | [diff] [blame] | 716 | goto err; |
| 717 | break; |
| 718 | case TUA9001_CMD_RXEN: |
| 719 | if (arg) |
Antti Palosaari | 4005c1a | 2012-09-17 15:43:57 -0300 | [diff] [blame] | 720 | val = (1 << 1); |
Antti Palosaari | 5be6572 | 2012-09-11 22:27:09 -0300 | [diff] [blame] | 721 | else |
Antti Palosaari | 4005c1a | 2012-09-17 15:43:57 -0300 | [diff] [blame] | 722 | val = (0 << 1); |
Antti Palosaari | 5be6572 | 2012-09-11 22:27:09 -0300 | [diff] [blame] | 723 | |
Antti Palosaari | 4005c1a | 2012-09-17 15:43:57 -0300 | [diff] [blame] | 724 | ret = rtl28xx_wr_reg_mask(d, SYS_GPIO_OUT_VAL, val, 0x02); |
| 725 | if (ret) |
Antti Palosaari | 5be6572 | 2012-09-11 22:27:09 -0300 | [diff] [blame] | 726 | goto err; |
| 727 | break; |
| 728 | } |
| 729 | |
| 730 | return 0; |
Antti Palosaari | 5be6572 | 2012-09-11 22:27:09 -0300 | [diff] [blame] | 731 | err: |
| 732 | dev_dbg(&d->udev->dev, "%s: failed=%d\n", __func__, ret); |
| 733 | return ret; |
| 734 | } |
| 735 | |
Thomas Mair | 5cf6631 | 2012-05-18 14:47:41 -0300 | [diff] [blame] | 736 | static int rtl2832u_tuner_callback(struct dvb_usb_device *d, int cmd, int arg) |
| 737 | { |
| 738 | struct rtl28xxu_priv *priv = d->priv; |
| 739 | |
| 740 | switch (priv->tuner) { |
| 741 | case TUNER_RTL2832_FC0012: |
| 742 | return rtl2832u_fc0012_tuner_callback(d, cmd, arg); |
Antti Palosaari | 5be6572 | 2012-09-11 22:27:09 -0300 | [diff] [blame] | 743 | case TUNER_RTL2832_TUA9001: |
| 744 | return rtl2832u_tua9001_tuner_callback(d, cmd, arg); |
Thomas Mair | 5cf6631 | 2012-05-18 14:47:41 -0300 | [diff] [blame] | 745 | default: |
| 746 | break; |
| 747 | } |
| 748 | |
Antti Palosaari | 97efe78 | 2012-09-17 15:49:54 -0300 | [diff] [blame] | 749 | return 0; |
Thomas Mair | 5cf6631 | 2012-05-18 14:47:41 -0300 | [diff] [blame] | 750 | } |
| 751 | |
| 752 | static int rtl2832u_frontend_callback(void *adapter_priv, int component, |
Antti Palosaari | 8acc91c | 2012-09-17 16:55:39 -0300 | [diff] [blame] | 753 | int cmd, int arg) |
Thomas Mair | 5cf6631 | 2012-05-18 14:47:41 -0300 | [diff] [blame] | 754 | { |
| 755 | struct i2c_adapter *adap = adapter_priv; |
| 756 | struct dvb_usb_device *d = i2c_get_adapdata(adap); |
| 757 | |
Antti Palosaari | 8acc91c | 2012-09-17 16:55:39 -0300 | [diff] [blame] | 758 | dev_dbg(&d->udev->dev, "%s: component=%d cmd=%d arg=%d\n", |
| 759 | __func__, component, cmd, arg); |
| 760 | |
Thomas Mair | 5cf6631 | 2012-05-18 14:47:41 -0300 | [diff] [blame] | 761 | switch (component) { |
| 762 | case DVB_FRONTEND_COMPONENT_TUNER: |
| 763 | return rtl2832u_tuner_callback(d, cmd, arg); |
| 764 | default: |
| 765 | break; |
| 766 | } |
| 767 | |
Antti Palosaari | 97efe78 | 2012-09-17 15:49:54 -0300 | [diff] [blame] | 768 | return 0; |
Thomas Mair | 5cf6631 | 2012-05-18 14:47:41 -0300 | [diff] [blame] | 769 | } |
| 770 | |
Antti Palosaari | b5cbaa4 | 2011-08-04 13:26:10 -0300 | [diff] [blame] | 771 | static int rtl2832u_frontend_attach(struct dvb_usb_adapter *adap) |
| 772 | { |
| 773 | int ret; |
Antti Palosaari | c01a359 | 2012-08-12 22:27:07 -0300 | [diff] [blame] | 774 | struct dvb_usb_device *d = adap_to_d(adap); |
| 775 | struct rtl28xxu_priv *priv = d_to_priv(d); |
Antti Palosaari | e8b4668 | 2013-10-12 23:35:35 -0300 | [diff] [blame] | 776 | const struct rtl2832_config *rtl2832_config; |
Antti Palosaari | b5cbaa4 | 2011-08-04 13:26:10 -0300 | [diff] [blame] | 777 | |
Antti Palosaari | c01a359 | 2012-08-12 22:27:07 -0300 | [diff] [blame] | 778 | dev_dbg(&d->udev->dev, "%s:\n", __func__); |
Antti Palosaari | b5cbaa4 | 2011-08-04 13:26:10 -0300 | [diff] [blame] | 779 | |
Antti Palosaari | ef37be1 | 2012-09-17 14:01:35 -0300 | [diff] [blame] | 780 | switch (priv->tuner) { |
| 781 | case TUNER_RTL2832_FC0012: |
Thomas Mair | 5cf6631 | 2012-05-18 14:47:41 -0300 | [diff] [blame] | 782 | rtl2832_config = &rtl28xxu_rtl2832_fc0012_config; |
Antti Palosaari | ef37be1 | 2012-09-17 14:01:35 -0300 | [diff] [blame] | 783 | break; |
| 784 | case TUNER_RTL2832_FC0013: |
Thomas Mair | 5cf6631 | 2012-05-18 14:47:41 -0300 | [diff] [blame] | 785 | rtl2832_config = &rtl28xxu_rtl2832_fc0013_config; |
Antti Palosaari | ef37be1 | 2012-09-17 14:01:35 -0300 | [diff] [blame] | 786 | break; |
| 787 | case TUNER_RTL2832_FC2580: |
Antti Palosaari | 384df49 | 2012-09-08 22:07:25 -0300 | [diff] [blame] | 788 | /* FIXME: do not abuse fc0012 settings */ |
| 789 | rtl2832_config = &rtl28xxu_rtl2832_fc0012_config; |
Antti Palosaari | ef37be1 | 2012-09-17 14:01:35 -0300 | [diff] [blame] | 790 | break; |
| 791 | case TUNER_RTL2832_TUA9001: |
Antti Palosaari | 5be6572 | 2012-09-11 22:27:09 -0300 | [diff] [blame] | 792 | rtl2832_config = &rtl28xxu_rtl2832_tua9001_config; |
Antti Palosaari | ef37be1 | 2012-09-17 14:01:35 -0300 | [diff] [blame] | 793 | break; |
| 794 | case TUNER_RTL2832_E4000: |
Antti Palosaari | 3d8a60d | 2012-09-17 17:54:27 -0300 | [diff] [blame] | 795 | rtl2832_config = &rtl28xxu_rtl2832_e4000_config; |
Antti Palosaari | ef37be1 | 2012-09-17 14:01:35 -0300 | [diff] [blame] | 796 | break; |
Mauro Carvalho Chehab | 6889ab2 | 2013-04-06 09:40:11 -0300 | [diff] [blame] | 797 | case TUNER_RTL2832_R820T: |
Antti Palosaari | 8b4cac1 | 2013-10-30 00:45:38 -0300 | [diff] [blame] | 798 | case TUNER_RTL2832_R828D: |
Mauro Carvalho Chehab | 6889ab2 | 2013-04-06 09:40:11 -0300 | [diff] [blame] | 799 | rtl2832_config = &rtl28xxu_rtl2832_r820t_config; |
| 800 | break; |
Antti Palosaari | ef37be1 | 2012-09-17 14:01:35 -0300 | [diff] [blame] | 801 | default: |
| 802 | dev_err(&d->udev->dev, "%s: unknown tuner=%s\n", |
| 803 | KBUILD_MODNAME, priv->tuner_name); |
| 804 | ret = -ENODEV; |
Antti Palosaari | b5cbaa4 | 2011-08-04 13:26:10 -0300 | [diff] [blame] | 805 | goto err; |
Antti Palosaari | ef37be1 | 2012-09-17 14:01:35 -0300 | [diff] [blame] | 806 | } |
Antti Palosaari | b5cbaa4 | 2011-08-04 13:26:10 -0300 | [diff] [blame] | 807 | |
| 808 | /* attach demodulator */ |
Antti Palosaari | ef37be1 | 2012-09-17 14:01:35 -0300 | [diff] [blame] | 809 | adap->fe[0] = dvb_attach(rtl2832_attach, rtl2832_config, &d->i2c_adap); |
| 810 | if (!adap->fe[0]) { |
| 811 | ret = -ENODEV; |
| 812 | goto err; |
| 813 | } |
Thomas Mair | 5cf6631 | 2012-05-18 14:47:41 -0300 | [diff] [blame] | 814 | |
Antti Palosaari | ae1f845 | 2014-02-08 04:03:57 -0300 | [diff] [blame] | 815 | /* RTL2832 I2C repeater */ |
| 816 | priv->demod_i2c_adapter = rtl2832_get_i2c_adapter(adap->fe[0]); |
| 817 | |
Antti Palosaari | ef37be1 | 2012-09-17 14:01:35 -0300 | [diff] [blame] | 818 | /* set fe callback */ |
Antti Palosaari | c01a359 | 2012-08-12 22:27:07 -0300 | [diff] [blame] | 819 | adap->fe[0]->callback = rtl2832u_frontend_callback; |
Antti Palosaari | b5cbaa4 | 2011-08-04 13:26:10 -0300 | [diff] [blame] | 820 | |
Antti Palosaari | ef37be1 | 2012-09-17 14:01:35 -0300 | [diff] [blame] | 821 | return 0; |
Antti Palosaari | b5cbaa4 | 2011-08-04 13:26:10 -0300 | [diff] [blame] | 822 | err: |
Antti Palosaari | c01a359 | 2012-08-12 22:27:07 -0300 | [diff] [blame] | 823 | dev_dbg(&d->udev->dev, "%s: failed=%d\n", __func__, ret); |
Antti Palosaari | b5cbaa4 | 2011-08-04 13:26:10 -0300 | [diff] [blame] | 824 | return ret; |
| 825 | } |
| 826 | |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 827 | static struct qt1010_config rtl28xxu_qt1010_config = { |
| 828 | .i2c_address = 0x62, /* 0xc4 */ |
| 829 | }; |
| 830 | |
| 831 | static struct mt2060_config rtl28xxu_mt2060_config = { |
| 832 | .i2c_address = 0x60, /* 0xc0 */ |
| 833 | .clock_out = 0, |
| 834 | }; |
| 835 | |
| 836 | static struct mxl5005s_config rtl28xxu_mxl5005s_config = { |
| 837 | .i2c_address = 0x63, /* 0xc6 */ |
| 838 | .if_freq = IF_FREQ_4570000HZ, |
| 839 | .xtal_freq = CRYSTAL_FREQ_16000000HZ, |
| 840 | .agc_mode = MXL_SINGLE_AGC, |
| 841 | .tracking_filter = MXL_TF_C_H, |
| 842 | .rssi_enable = MXL_RSSI_ENABLE, |
| 843 | .cap_select = MXL_CAP_SEL_ENABLE, |
| 844 | .div_out = MXL_DIV_OUT_4, |
| 845 | .clock_out = MXL_CLOCK_OUT_DISABLE, |
| 846 | .output_load = MXL5005S_IF_OUTPUT_LOAD_200_OHM, |
| 847 | .top = MXL5005S_TOP_25P2, |
| 848 | .mod_mode = MXL_DIGITAL_MODE, |
| 849 | .if_mode = MXL_ZERO_IF, |
| 850 | .AgcMasterByte = 0x00, |
| 851 | }; |
| 852 | |
Antti Palosaari | b5cbaa4 | 2011-08-04 13:26:10 -0300 | [diff] [blame] | 853 | static int rtl2831u_tuner_attach(struct dvb_usb_adapter *adap) |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 854 | { |
| 855 | int ret; |
Antti Palosaari | c01a359 | 2012-08-12 22:27:07 -0300 | [diff] [blame] | 856 | struct dvb_usb_device *d = adap_to_d(adap); |
| 857 | struct rtl28xxu_priv *priv = d_to_priv(d); |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 858 | struct i2c_adapter *rtl2830_tuner_i2c; |
Antti Palosaari | 9935eea | 2012-01-21 22:26:52 -0300 | [diff] [blame] | 859 | struct dvb_frontend *fe; |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 860 | |
Antti Palosaari | c01a359 | 2012-08-12 22:27:07 -0300 | [diff] [blame] | 861 | dev_dbg(&d->udev->dev, "%s:\n", __func__); |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 862 | |
| 863 | /* use rtl2830 driver I2C adapter, for more info see rtl2830 driver */ |
Antti Palosaari | c01a359 | 2012-08-12 22:27:07 -0300 | [diff] [blame] | 864 | rtl2830_tuner_i2c = rtl2830_get_tuner_i2c_adapter(adap->fe[0]); |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 865 | |
| 866 | switch (priv->tuner) { |
| 867 | case TUNER_RTL2830_QT1010: |
Antti Palosaari | c01a359 | 2012-08-12 22:27:07 -0300 | [diff] [blame] | 868 | fe = dvb_attach(qt1010_attach, adap->fe[0], |
Antti Palosaari | fba16b1 | 2012-01-21 20:28:38 -0300 | [diff] [blame] | 869 | rtl2830_tuner_i2c, &rtl28xxu_qt1010_config); |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 870 | break; |
| 871 | case TUNER_RTL2830_MT2060: |
Antti Palosaari | c01a359 | 2012-08-12 22:27:07 -0300 | [diff] [blame] | 872 | fe = dvb_attach(mt2060_attach, adap->fe[0], |
Antti Palosaari | fba16b1 | 2012-01-21 20:28:38 -0300 | [diff] [blame] | 873 | rtl2830_tuner_i2c, &rtl28xxu_mt2060_config, |
| 874 | 1220); |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 875 | break; |
| 876 | case TUNER_RTL2830_MXL5005S: |
Antti Palosaari | c01a359 | 2012-08-12 22:27:07 -0300 | [diff] [blame] | 877 | fe = dvb_attach(mxl5005s_attach, adap->fe[0], |
Antti Palosaari | 9935eea | 2012-01-21 22:26:52 -0300 | [diff] [blame] | 878 | rtl2830_tuner_i2c, &rtl28xxu_mxl5005s_config); |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 879 | break; |
| 880 | default: |
Antti Palosaari | 9935eea | 2012-01-21 22:26:52 -0300 | [diff] [blame] | 881 | fe = NULL; |
Antti Palosaari | c01a359 | 2012-08-12 22:27:07 -0300 | [diff] [blame] | 882 | dev_err(&d->udev->dev, "%s: unknown tuner=%d\n", KBUILD_MODNAME, |
| 883 | priv->tuner); |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 884 | } |
| 885 | |
| 886 | if (fe == NULL) { |
| 887 | ret = -ENODEV; |
| 888 | goto err; |
| 889 | } |
| 890 | |
| 891 | return 0; |
| 892 | err: |
Antti Palosaari | c01a359 | 2012-08-12 22:27:07 -0300 | [diff] [blame] | 893 | dev_dbg(&d->udev->dev, "%s: failed=%d\n", __func__, ret); |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 894 | return ret; |
| 895 | } |
| 896 | |
Antti Palosaari | 384df49 | 2012-09-08 22:07:25 -0300 | [diff] [blame] | 897 | static const struct fc2580_config rtl2832u_fc2580_config = { |
| 898 | .i2c_addr = 0x56, |
| 899 | .clock = 16384000, |
| 900 | }; |
| 901 | |
Antti Palosaari | 5be6572 | 2012-09-11 22:27:09 -0300 | [diff] [blame] | 902 | static struct tua9001_config rtl2832u_tua9001_config = { |
| 903 | .i2c_addr = 0x60, |
| 904 | }; |
| 905 | |
Antti Palosaari | ad3a758 | 2012-12-08 23:27:49 -0300 | [diff] [blame] | 906 | static const struct fc0012_config rtl2832u_fc0012_config = { |
| 907 | .i2c_address = 0x63, /* 0xc6 >> 1 */ |
| 908 | .xtal_freq = FC_XTAL_28_8_MHZ, |
| 909 | }; |
| 910 | |
Mauro Carvalho Chehab | 6889ab2 | 2013-04-06 09:40:11 -0300 | [diff] [blame] | 911 | static const struct r820t_config rtl2832u_r820t_config = { |
| 912 | .i2c_addr = 0x1a, |
| 913 | .xtal = 28800000, |
| 914 | .max_i2c_msg_len = 2, |
| 915 | .rafael_chip = CHIP_R820T, |
| 916 | }; |
| 917 | |
Antti Palosaari | 8b4cac1 | 2013-10-30 00:45:38 -0300 | [diff] [blame] | 918 | static const struct r820t_config rtl2832u_r828d_config = { |
| 919 | .i2c_addr = 0x3a, |
| 920 | .xtal = 16000000, |
| 921 | .max_i2c_msg_len = 2, |
| 922 | .rafael_chip = CHIP_R828D, |
| 923 | }; |
| 924 | |
Antti Palosaari | b5cbaa4 | 2011-08-04 13:26:10 -0300 | [diff] [blame] | 925 | static int rtl2832u_tuner_attach(struct dvb_usb_adapter *adap) |
| 926 | { |
| 927 | int ret; |
Antti Palosaari | c01a359 | 2012-08-12 22:27:07 -0300 | [diff] [blame] | 928 | struct dvb_usb_device *d = adap_to_d(adap); |
| 929 | struct rtl28xxu_priv *priv = d_to_priv(d); |
Antti Palosaari | 28fd31f | 2013-10-15 19:22:45 -0300 | [diff] [blame] | 930 | struct dvb_frontend *fe = NULL; |
| 931 | struct i2c_board_info info; |
| 932 | struct i2c_client *client; |
Antti Palosaari | b5cbaa4 | 2011-08-04 13:26:10 -0300 | [diff] [blame] | 933 | |
Antti Palosaari | c01a359 | 2012-08-12 22:27:07 -0300 | [diff] [blame] | 934 | dev_dbg(&d->udev->dev, "%s:\n", __func__); |
Antti Palosaari | b5cbaa4 | 2011-08-04 13:26:10 -0300 | [diff] [blame] | 935 | |
Antti Palosaari | 28fd31f | 2013-10-15 19:22:45 -0300 | [diff] [blame] | 936 | memset(&info, 0, sizeof(struct i2c_board_info)); |
| 937 | |
Antti Palosaari | b5cbaa4 | 2011-08-04 13:26:10 -0300 | [diff] [blame] | 938 | switch (priv->tuner) { |
Thomas Mair | 5cf6631 | 2012-05-18 14:47:41 -0300 | [diff] [blame] | 939 | case TUNER_RTL2832_FC0012: |
Antti Palosaari | c01a359 | 2012-08-12 22:27:07 -0300 | [diff] [blame] | 940 | fe = dvb_attach(fc0012_attach, adap->fe[0], |
Antti Palosaari | ad3a758 | 2012-12-08 23:27:49 -0300 | [diff] [blame] | 941 | &d->i2c_adap, &rtl2832u_fc0012_config); |
Thomas Mair | 5cf6631 | 2012-05-18 14:47:41 -0300 | [diff] [blame] | 942 | |
| 943 | /* since fc0012 includs reading the signal strength delegate |
| 944 | * that to the tuner driver */ |
Antti Palosaari | c01a359 | 2012-08-12 22:27:07 -0300 | [diff] [blame] | 945 | adap->fe[0]->ops.read_signal_strength = |
| 946 | adap->fe[0]->ops.tuner_ops.get_rf_strength; |
Antti Palosaari | bcf4339 | 2013-09-10 00:13:57 -0300 | [diff] [blame] | 947 | |
| 948 | /* attach SDR */ |
Antti Palosaari | beab1b5 | 2014-04-09 18:08:37 -0300 | [diff] [blame] | 949 | dvb_attach_sdr(rtl2832_sdr_attach, adap->fe[0], &d->i2c_adap, |
Antti Palosaari | bcf4339 | 2013-09-10 00:13:57 -0300 | [diff] [blame] | 950 | &rtl28xxu_rtl2832_fc0012_config, NULL); |
Antti Palosaari | b5cbaa4 | 2011-08-04 13:26:10 -0300 | [diff] [blame] | 951 | break; |
Thomas Mair | 5cf6631 | 2012-05-18 14:47:41 -0300 | [diff] [blame] | 952 | case TUNER_RTL2832_FC0013: |
Antti Palosaari | c01a359 | 2012-08-12 22:27:07 -0300 | [diff] [blame] | 953 | fe = dvb_attach(fc0013_attach, adap->fe[0], |
| 954 | &d->i2c_adap, 0xc6>>1, 0, FC_XTAL_28_8_MHZ); |
Thomas Mair | 5cf6631 | 2012-05-18 14:47:41 -0300 | [diff] [blame] | 955 | |
| 956 | /* fc0013 also supports signal strength reading */ |
Antti Palosaari | c01a359 | 2012-08-12 22:27:07 -0300 | [diff] [blame] | 957 | adap->fe[0]->ops.read_signal_strength = |
| 958 | adap->fe[0]->ops.tuner_ops.get_rf_strength; |
Antti Palosaari | bcf4339 | 2013-09-10 00:13:57 -0300 | [diff] [blame] | 959 | |
| 960 | /* attach SDR */ |
Antti Palosaari | beab1b5 | 2014-04-09 18:08:37 -0300 | [diff] [blame] | 961 | dvb_attach_sdr(rtl2832_sdr_attach, adap->fe[0], &d->i2c_adap, |
Antti Palosaari | bcf4339 | 2013-09-10 00:13:57 -0300 | [diff] [blame] | 962 | &rtl28xxu_rtl2832_fc0013_config, NULL); |
Antti Palosaari | 55cdb7d | 2014-02-03 23:07:21 -0300 | [diff] [blame] | 963 | break; |
Antti Palosaari | 28fd31f | 2013-10-15 19:22:45 -0300 | [diff] [blame] | 964 | case TUNER_RTL2832_E4000: { |
Antti Palosaari | bcf4339 | 2013-09-10 00:13:57 -0300 | [diff] [blame] | 965 | struct v4l2_subdev *sd; |
Antti Palosaari | ae1f845 | 2014-02-08 04:03:57 -0300 | [diff] [blame] | 966 | struct i2c_adapter *i2c_adap_internal = |
| 967 | rtl2832_get_private_i2c_adapter(adap->fe[0]); |
Antti Palosaari | 28fd31f | 2013-10-15 19:22:45 -0300 | [diff] [blame] | 968 | struct e4000_config e4000_config = { |
| 969 | .fe = adap->fe[0], |
| 970 | .clock = 28800000, |
| 971 | }; |
| 972 | |
| 973 | strlcpy(info.type, "e4000", I2C_NAME_SIZE); |
| 974 | info.addr = 0x64; |
| 975 | info.platform_data = &e4000_config; |
| 976 | |
| 977 | request_module(info.type); |
Antti Palosaari | ae1f845 | 2014-02-08 04:03:57 -0300 | [diff] [blame] | 978 | client = i2c_new_device(priv->demod_i2c_adapter, &info); |
Antti Palosaari | 28fd31f | 2013-10-15 19:22:45 -0300 | [diff] [blame] | 979 | if (client == NULL || client->dev.driver == NULL) |
| 980 | break; |
| 981 | |
| 982 | if (!try_module_get(client->dev.driver->owner)) { |
| 983 | i2c_unregister_device(client); |
| 984 | break; |
| 985 | } |
| 986 | |
| 987 | priv->client = client; |
Antti Palosaari | bcf4339 | 2013-09-10 00:13:57 -0300 | [diff] [blame] | 988 | sd = i2c_get_clientdata(client); |
Antti Palosaari | ae1f845 | 2014-02-08 04:03:57 -0300 | [diff] [blame] | 989 | i2c_set_adapdata(i2c_adap_internal, d); |
Antti Palosaari | bcf4339 | 2013-09-10 00:13:57 -0300 | [diff] [blame] | 990 | |
| 991 | /* attach SDR */ |
Antti Palosaari | beab1b5 | 2014-04-09 18:08:37 -0300 | [diff] [blame] | 992 | dvb_attach_sdr(rtl2832_sdr_attach, adap->fe[0], |
Antti Palosaari | ae1f845 | 2014-02-08 04:03:57 -0300 | [diff] [blame] | 993 | i2c_adap_internal, |
Antti Palosaari | bcf4339 | 2013-09-10 00:13:57 -0300 | [diff] [blame] | 994 | &rtl28xxu_rtl2832_e4000_config, sd); |
Antti Palosaari | 28fd31f | 2013-10-15 19:22:45 -0300 | [diff] [blame] | 995 | } |
Antti Palosaari | 542f6a5 | 2012-09-01 21:09:22 -0300 | [diff] [blame] | 996 | break; |
Antti Palosaari | 384df49 | 2012-09-08 22:07:25 -0300 | [diff] [blame] | 997 | case TUNER_RTL2832_FC2580: |
| 998 | fe = dvb_attach(fc2580_attach, adap->fe[0], &d->i2c_adap, |
| 999 | &rtl2832u_fc2580_config); |
| 1000 | break; |
Antti Palosaari | 5be6572 | 2012-09-11 22:27:09 -0300 | [diff] [blame] | 1001 | case TUNER_RTL2832_TUA9001: |
| 1002 | /* enable GPIO1 and GPIO4 as output */ |
Antti Palosaari | 4005c1a | 2012-09-17 15:43:57 -0300 | [diff] [blame] | 1003 | ret = rtl28xx_wr_reg_mask(d, SYS_GPIO_DIR, 0x00, 0x12); |
| 1004 | if (ret) |
Antti Palosaari | 5be6572 | 2012-09-11 22:27:09 -0300 | [diff] [blame] | 1005 | goto err; |
| 1006 | |
Antti Palosaari | 4005c1a | 2012-09-17 15:43:57 -0300 | [diff] [blame] | 1007 | ret = rtl28xx_wr_reg_mask(d, SYS_GPIO_OUT_EN, 0x12, 0x12); |
| 1008 | if (ret) |
Antti Palosaari | 5be6572 | 2012-09-11 22:27:09 -0300 | [diff] [blame] | 1009 | goto err; |
| 1010 | |
| 1011 | fe = dvb_attach(tua9001_attach, adap->fe[0], &d->i2c_adap, |
| 1012 | &rtl2832u_tua9001_config); |
| 1013 | break; |
Mauro Carvalho Chehab | 6889ab2 | 2013-04-06 09:40:11 -0300 | [diff] [blame] | 1014 | case TUNER_RTL2832_R820T: |
| 1015 | fe = dvb_attach(r820t_attach, adap->fe[0], &d->i2c_adap, |
| 1016 | &rtl2832u_r820t_config); |
Mauro Carvalho Chehab | 9e30edd | 2013-04-07 18:57:15 -0300 | [diff] [blame] | 1017 | |
| 1018 | /* Use tuner to get the signal strength */ |
| 1019 | adap->fe[0]->ops.read_signal_strength = |
| 1020 | adap->fe[0]->ops.tuner_ops.get_rf_strength; |
Antti Palosaari | bcf4339 | 2013-09-10 00:13:57 -0300 | [diff] [blame] | 1021 | |
| 1022 | /* attach SDR */ |
Antti Palosaari | beab1b5 | 2014-04-09 18:08:37 -0300 | [diff] [blame] | 1023 | dvb_attach_sdr(rtl2832_sdr_attach, adap->fe[0], &d->i2c_adap, |
Antti Palosaari | bcf4339 | 2013-09-10 00:13:57 -0300 | [diff] [blame] | 1024 | &rtl28xxu_rtl2832_r820t_config, NULL); |
Mauro Carvalho Chehab | 6889ab2 | 2013-04-06 09:40:11 -0300 | [diff] [blame] | 1025 | break; |
Antti Palosaari | 8b4cac1 | 2013-10-30 00:45:38 -0300 | [diff] [blame] | 1026 | case TUNER_RTL2832_R828D: |
| 1027 | /* power off mn88472 demod on GPIO0 */ |
| 1028 | ret = rtl28xx_wr_reg_mask(d, SYS_GPIO_OUT_VAL, 0x00, 0x01); |
| 1029 | if (ret) |
| 1030 | goto err; |
| 1031 | |
| 1032 | ret = rtl28xx_wr_reg_mask(d, SYS_GPIO_DIR, 0x00, 0x01); |
| 1033 | if (ret) |
| 1034 | goto err; |
| 1035 | |
| 1036 | ret = rtl28xx_wr_reg_mask(d, SYS_GPIO_OUT_EN, 0x01, 0x01); |
| 1037 | if (ret) |
| 1038 | goto err; |
| 1039 | |
| 1040 | fe = dvb_attach(r820t_attach, adap->fe[0], &d->i2c_adap, |
| 1041 | &rtl2832u_r828d_config); |
| 1042 | |
| 1043 | /* Use tuner to get the signal strength */ |
| 1044 | adap->fe[0]->ops.read_signal_strength = |
| 1045 | adap->fe[0]->ops.tuner_ops.get_rf_strength; |
| 1046 | break; |
Antti Palosaari | b5cbaa4 | 2011-08-04 13:26:10 -0300 | [diff] [blame] | 1047 | default: |
Antti Palosaari | c01a359 | 2012-08-12 22:27:07 -0300 | [diff] [blame] | 1048 | dev_err(&d->udev->dev, "%s: unknown tuner=%d\n", KBUILD_MODNAME, |
| 1049 | priv->tuner); |
Antti Palosaari | b5cbaa4 | 2011-08-04 13:26:10 -0300 | [diff] [blame] | 1050 | } |
| 1051 | |
Antti Palosaari | 28fd31f | 2013-10-15 19:22:45 -0300 | [diff] [blame] | 1052 | if (fe == NULL && priv->client == NULL) { |
Antti Palosaari | b5cbaa4 | 2011-08-04 13:26:10 -0300 | [diff] [blame] | 1053 | ret = -ENODEV; |
| 1054 | goto err; |
| 1055 | } |
| 1056 | |
| 1057 | return 0; |
| 1058 | err: |
Antti Palosaari | c01a359 | 2012-08-12 22:27:07 -0300 | [diff] [blame] | 1059 | dev_dbg(&d->udev->dev, "%s: failed=%d\n", __func__, ret); |
Antti Palosaari | b5cbaa4 | 2011-08-04 13:26:10 -0300 | [diff] [blame] | 1060 | return ret; |
| 1061 | } |
| 1062 | |
Antti Palosaari | c01a359 | 2012-08-12 22:27:07 -0300 | [diff] [blame] | 1063 | static int rtl28xxu_init(struct dvb_usb_device *d) |
| 1064 | { |
| 1065 | int ret; |
| 1066 | u8 val; |
| 1067 | |
| 1068 | dev_dbg(&d->udev->dev, "%s:\n", __func__); |
| 1069 | |
| 1070 | /* init USB endpoints */ |
| 1071 | ret = rtl28xx_rd_reg(d, USB_SYSCTL_0, &val); |
| 1072 | if (ret) |
| 1073 | goto err; |
| 1074 | |
| 1075 | /* enable DMA and Full Packet Mode*/ |
| 1076 | val |= 0x09; |
| 1077 | ret = rtl28xx_wr_reg(d, USB_SYSCTL_0, val); |
| 1078 | if (ret) |
| 1079 | goto err; |
| 1080 | |
| 1081 | /* set EPA maximum packet size to 0x0200 */ |
| 1082 | ret = rtl28xx_wr_regs(d, USB_EPA_MAXPKT, "\x00\x02\x00\x00", 4); |
| 1083 | if (ret) |
| 1084 | goto err; |
| 1085 | |
| 1086 | /* change EPA FIFO length */ |
| 1087 | ret = rtl28xx_wr_regs(d, USB_EPA_FIFO_CFG, "\x14\x00\x00\x00", 4); |
| 1088 | if (ret) |
| 1089 | goto err; |
| 1090 | |
| 1091 | return ret; |
| 1092 | err: |
| 1093 | dev_dbg(&d->udev->dev, "%s: failed=%d\n", __func__, ret); |
| 1094 | return ret; |
| 1095 | } |
| 1096 | |
Antti Palosaari | 28fd31f | 2013-10-15 19:22:45 -0300 | [diff] [blame] | 1097 | static void rtl28xxu_exit(struct dvb_usb_device *d) |
| 1098 | { |
| 1099 | struct rtl28xxu_priv *priv = d->priv; |
| 1100 | struct i2c_client *client = priv->client; |
| 1101 | |
| 1102 | dev_dbg(&d->udev->dev, "%s:\n", __func__); |
| 1103 | |
| 1104 | /* remove I2C tuner */ |
| 1105 | if (client) { |
| 1106 | module_put(client->dev.driver->owner); |
| 1107 | i2c_unregister_device(client); |
| 1108 | } |
| 1109 | |
| 1110 | return; |
| 1111 | } |
| 1112 | |
Thomas Mair | 5cf6631 | 2012-05-18 14:47:41 -0300 | [diff] [blame] | 1113 | static int rtl2831u_power_ctrl(struct dvb_usb_device *d, int onoff) |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 1114 | { |
| 1115 | int ret; |
Antti Palosaari | 8b03663 | 2012-09-01 09:54:43 -0300 | [diff] [blame] | 1116 | u8 gpio, sys0, epa_ctl[2]; |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 1117 | |
Antti Palosaari | c01a359 | 2012-08-12 22:27:07 -0300 | [diff] [blame] | 1118 | dev_dbg(&d->udev->dev, "%s: onoff=%d\n", __func__, onoff); |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 1119 | |
| 1120 | /* demod adc */ |
Thomas Mair | 40a2d3c | 2012-05-18 14:47:42 -0300 | [diff] [blame] | 1121 | ret = rtl28xx_rd_reg(d, SYS_SYS0, &sys0); |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 1122 | if (ret) |
| 1123 | goto err; |
| 1124 | |
| 1125 | /* tuner power, read GPIOs */ |
Thomas Mair | 40a2d3c | 2012-05-18 14:47:42 -0300 | [diff] [blame] | 1126 | ret = rtl28xx_rd_reg(d, SYS_GPIO_OUT_VAL, &gpio); |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 1127 | if (ret) |
| 1128 | goto err; |
| 1129 | |
Antti Palosaari | c01a359 | 2012-08-12 22:27:07 -0300 | [diff] [blame] | 1130 | dev_dbg(&d->udev->dev, "%s: RD SYS0=%02x GPIO_OUT_VAL=%02x\n", __func__, |
| 1131 | sys0, gpio); |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 1132 | |
| 1133 | if (onoff) { |
| 1134 | gpio |= 0x01; /* GPIO0 = 1 */ |
| 1135 | gpio &= (~0x10); /* GPIO4 = 0 */ |
Antti Palosaari | 991452a | 2012-08-12 22:27:08 -0300 | [diff] [blame] | 1136 | gpio |= 0x04; /* GPIO2 = 1, LED on */ |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 1137 | sys0 = sys0 & 0x0f; |
| 1138 | sys0 |= 0xe0; |
Antti Palosaari | 8b03663 | 2012-09-01 09:54:43 -0300 | [diff] [blame] | 1139 | epa_ctl[0] = 0x00; /* clear stall */ |
| 1140 | epa_ctl[1] = 0x00; /* clear reset */ |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 1141 | } else { |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 1142 | gpio &= (~0x01); /* GPIO0 = 0 */ |
| 1143 | gpio |= 0x10; /* GPIO4 = 1 */ |
Antti Palosaari | 991452a | 2012-08-12 22:27:08 -0300 | [diff] [blame] | 1144 | gpio &= (~0x04); /* GPIO2 = 1, LED off */ |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 1145 | sys0 = sys0 & (~0xc0); |
Antti Palosaari | 8b03663 | 2012-09-01 09:54:43 -0300 | [diff] [blame] | 1146 | epa_ctl[0] = 0x10; /* set stall */ |
| 1147 | epa_ctl[1] = 0x02; /* set reset */ |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 1148 | } |
| 1149 | |
Antti Palosaari | c01a359 | 2012-08-12 22:27:07 -0300 | [diff] [blame] | 1150 | dev_dbg(&d->udev->dev, "%s: WR SYS0=%02x GPIO_OUT_VAL=%02x\n", __func__, |
| 1151 | sys0, gpio); |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 1152 | |
| 1153 | /* demod adc */ |
Thomas Mair | 40a2d3c | 2012-05-18 14:47:42 -0300 | [diff] [blame] | 1154 | ret = rtl28xx_wr_reg(d, SYS_SYS0, sys0); |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 1155 | if (ret) |
| 1156 | goto err; |
| 1157 | |
| 1158 | /* tuner power, write GPIOs */ |
Thomas Mair | 40a2d3c | 2012-05-18 14:47:42 -0300 | [diff] [blame] | 1159 | ret = rtl28xx_wr_reg(d, SYS_GPIO_OUT_VAL, gpio); |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 1160 | if (ret) |
| 1161 | goto err; |
| 1162 | |
Antti Palosaari | 8b03663 | 2012-09-01 09:54:43 -0300 | [diff] [blame] | 1163 | /* streaming EP: stall & reset */ |
| 1164 | ret = rtl28xx_wr_regs(d, USB_EPA_CTL, epa_ctl, 2); |
| 1165 | if (ret) |
| 1166 | goto err; |
| 1167 | |
| 1168 | if (onoff) |
| 1169 | usb_clear_halt(d->udev, usb_rcvbulkpipe(d->udev, 0x81)); |
| 1170 | |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 1171 | return ret; |
| 1172 | err: |
Antti Palosaari | c01a359 | 2012-08-12 22:27:07 -0300 | [diff] [blame] | 1173 | dev_dbg(&d->udev->dev, "%s: failed=%d\n", __func__, ret); |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 1174 | return ret; |
| 1175 | } |
| 1176 | |
Thomas Mair | 5cf6631 | 2012-05-18 14:47:41 -0300 | [diff] [blame] | 1177 | static int rtl2832u_power_ctrl(struct dvb_usb_device *d, int onoff) |
| 1178 | { |
| 1179 | int ret; |
Thomas Mair | 5cf6631 | 2012-05-18 14:47:41 -0300 | [diff] [blame] | 1180 | |
Antti Palosaari | c01a359 | 2012-08-12 22:27:07 -0300 | [diff] [blame] | 1181 | dev_dbg(&d->udev->dev, "%s: onoff=%d\n", __func__, onoff); |
Thomas Mair | 5cf6631 | 2012-05-18 14:47:41 -0300 | [diff] [blame] | 1182 | |
| 1183 | if (onoff) { |
Antti Palosaari | 526ca8d | 2013-06-04 18:26:54 -0300 | [diff] [blame] | 1184 | /* GPIO3=1, GPIO4=0 */ |
| 1185 | ret = rtl28xx_wr_reg_mask(d, SYS_GPIO_OUT_VAL, 0x08, 0x18); |
Thomas Mair | 5cf6631 | 2012-05-18 14:47:41 -0300 | [diff] [blame] | 1186 | if (ret) |
| 1187 | goto err; |
| 1188 | |
Antti Palosaari | 526ca8d | 2013-06-04 18:26:54 -0300 | [diff] [blame] | 1189 | /* suspend? */ |
| 1190 | ret = rtl28xx_wr_reg_mask(d, SYS_DEMOD_CTL1, 0x00, 0x10); |
Thomas Mair | 5cf6631 | 2012-05-18 14:47:41 -0300 | [diff] [blame] | 1191 | if (ret) |
| 1192 | goto err; |
| 1193 | |
Antti Palosaari | 526ca8d | 2013-06-04 18:26:54 -0300 | [diff] [blame] | 1194 | /* enable PLL */ |
| 1195 | ret = rtl28xx_wr_reg_mask(d, SYS_DEMOD_CTL, 0x80, 0x80); |
Thomas Mair | 5cf6631 | 2012-05-18 14:47:41 -0300 | [diff] [blame] | 1196 | if (ret) |
| 1197 | goto err; |
| 1198 | |
Antti Palosaari | 526ca8d | 2013-06-04 18:26:54 -0300 | [diff] [blame] | 1199 | /* disable reset */ |
| 1200 | ret = rtl28xx_wr_reg_mask(d, SYS_DEMOD_CTL, 0x20, 0x20); |
Thomas Mair | 5cf6631 | 2012-05-18 14:47:41 -0300 | [diff] [blame] | 1201 | if (ret) |
| 1202 | goto err; |
| 1203 | |
| 1204 | mdelay(5); |
| 1205 | |
Antti Palosaari | 526ca8d | 2013-06-04 18:26:54 -0300 | [diff] [blame] | 1206 | /* enable ADC */ |
| 1207 | ret = rtl28xx_wr_reg_mask(d, SYS_DEMOD_CTL, 0x48, 0x48); |
Thomas Mair | 5cf6631 | 2012-05-18 14:47:41 -0300 | [diff] [blame] | 1208 | if (ret) |
| 1209 | goto err; |
| 1210 | |
Antti Palosaari | 8b03663 | 2012-09-01 09:54:43 -0300 | [diff] [blame] | 1211 | /* streaming EP: clear stall & reset */ |
| 1212 | ret = rtl28xx_wr_regs(d, USB_EPA_CTL, "\x00\x00", 2); |
| 1213 | if (ret) |
| 1214 | goto err; |
| 1215 | |
| 1216 | ret = usb_clear_halt(d->udev, usb_rcvbulkpipe(d->udev, 0x81)); |
| 1217 | if (ret) |
| 1218 | goto err; |
Thomas Mair | 5cf6631 | 2012-05-18 14:47:41 -0300 | [diff] [blame] | 1219 | } else { |
Antti Palosaari | 526ca8d | 2013-06-04 18:26:54 -0300 | [diff] [blame] | 1220 | /* GPIO4=1 */ |
| 1221 | ret = rtl28xx_wr_reg_mask(d, SYS_GPIO_OUT_VAL, 0x10, 0x10); |
Thomas Mair | 5cf6631 | 2012-05-18 14:47:41 -0300 | [diff] [blame] | 1222 | if (ret) |
| 1223 | goto err; |
| 1224 | |
Antti Palosaari | 526ca8d | 2013-06-04 18:26:54 -0300 | [diff] [blame] | 1225 | /* disable ADC */ |
| 1226 | ret = rtl28xx_wr_reg_mask(d, SYS_DEMOD_CTL, 0x00, 0x48); |
Thomas Mair | 5cf6631 | 2012-05-18 14:47:41 -0300 | [diff] [blame] | 1227 | if (ret) |
| 1228 | goto err; |
| 1229 | |
Antti Palosaari | 526ca8d | 2013-06-04 18:26:54 -0300 | [diff] [blame] | 1230 | /* disable PLL */ |
| 1231 | ret = rtl28xx_wr_reg_mask(d, SYS_DEMOD_CTL, 0x00, 0x80); |
Thomas Mair | 5cf6631 | 2012-05-18 14:47:41 -0300 | [diff] [blame] | 1232 | if (ret) |
| 1233 | goto err; |
| 1234 | |
Antti Palosaari | 8b03663 | 2012-09-01 09:54:43 -0300 | [diff] [blame] | 1235 | /* streaming EP: set stall & reset */ |
| 1236 | ret = rtl28xx_wr_regs(d, USB_EPA_CTL, "\x10\x02", 2); |
| 1237 | if (ret) |
| 1238 | goto err; |
Thomas Mair | 5cf6631 | 2012-05-18 14:47:41 -0300 | [diff] [blame] | 1239 | } |
| 1240 | |
| 1241 | return ret; |
| 1242 | err: |
Antti Palosaari | c01a359 | 2012-08-12 22:27:07 -0300 | [diff] [blame] | 1243 | dev_dbg(&d->udev->dev, "%s: failed=%d\n", __func__, ret); |
Thomas Mair | 5cf6631 | 2012-05-18 14:47:41 -0300 | [diff] [blame] | 1244 | return ret; |
| 1245 | } |
| 1246 | |
Antti Palosaari | 37b44a0 | 2013-01-04 15:21:26 -0300 | [diff] [blame] | 1247 | #if IS_ENABLED(CONFIG_RC_CORE) |
Antti Palosaari | b5cbaa4 | 2011-08-04 13:26:10 -0300 | [diff] [blame] | 1248 | static int rtl2831u_rc_query(struct dvb_usb_device *d) |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 1249 | { |
Antti Palosaari | b5cbaa4 | 2011-08-04 13:26:10 -0300 | [diff] [blame] | 1250 | int ret, i; |
| 1251 | struct rtl28xxu_priv *priv = d->priv; |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 1252 | u8 buf[5]; |
| 1253 | u32 rc_code; |
Antti Palosaari | b5cbaa4 | 2011-08-04 13:26:10 -0300 | [diff] [blame] | 1254 | struct rtl28xxu_reg_val rc_nec_tab[] = { |
| 1255 | { 0x3033, 0x80 }, |
| 1256 | { 0x3020, 0x43 }, |
| 1257 | { 0x3021, 0x16 }, |
| 1258 | { 0x3022, 0x16 }, |
| 1259 | { 0x3023, 0x5a }, |
| 1260 | { 0x3024, 0x2d }, |
| 1261 | { 0x3025, 0x16 }, |
| 1262 | { 0x3026, 0x01 }, |
| 1263 | { 0x3028, 0xb0 }, |
| 1264 | { 0x3029, 0x04 }, |
| 1265 | { 0x302c, 0x88 }, |
| 1266 | { 0x302e, 0x13 }, |
| 1267 | { 0x3030, 0xdf }, |
| 1268 | { 0x3031, 0x05 }, |
| 1269 | }; |
| 1270 | |
| 1271 | /* init remote controller */ |
| 1272 | if (!priv->rc_active) { |
| 1273 | for (i = 0; i < ARRAY_SIZE(rc_nec_tab); i++) { |
Thomas Mair | 40a2d3c | 2012-05-18 14:47:42 -0300 | [diff] [blame] | 1274 | ret = rtl28xx_wr_reg(d, rc_nec_tab[i].reg, |
Antti Palosaari | 9935eea | 2012-01-21 22:26:52 -0300 | [diff] [blame] | 1275 | rc_nec_tab[i].val); |
Antti Palosaari | b5cbaa4 | 2011-08-04 13:26:10 -0300 | [diff] [blame] | 1276 | if (ret) |
| 1277 | goto err; |
| 1278 | } |
| 1279 | priv->rc_active = true; |
| 1280 | } |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 1281 | |
| 1282 | ret = rtl2831_rd_regs(d, SYS_IRRC_RP, buf, 5); |
| 1283 | if (ret) |
| 1284 | goto err; |
| 1285 | |
| 1286 | if (buf[4] & 0x01) { |
| 1287 | if (buf[2] == (u8) ~buf[3]) { |
| 1288 | if (buf[0] == (u8) ~buf[1]) { |
| 1289 | /* NEC standard (16 bit) */ |
| 1290 | rc_code = buf[0] << 8 | buf[2]; |
| 1291 | } else { |
| 1292 | /* NEC extended (24 bit) */ |
| 1293 | rc_code = buf[0] << 16 | |
Antti Palosaari | 9935eea | 2012-01-21 22:26:52 -0300 | [diff] [blame] | 1294 | buf[1] << 8 | buf[2]; |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 1295 | } |
| 1296 | } else { |
| 1297 | /* NEC full (32 bit) */ |
| 1298 | rc_code = buf[0] << 24 | buf[1] << 16 | |
| 1299 | buf[2] << 8 | buf[3]; |
| 1300 | } |
| 1301 | |
| 1302 | rc_keydown(d->rc_dev, rc_code, 0); |
| 1303 | |
Thomas Mair | 40a2d3c | 2012-05-18 14:47:42 -0300 | [diff] [blame] | 1304 | ret = rtl28xx_wr_reg(d, SYS_IRRC_SR, 1); |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 1305 | if (ret) |
| 1306 | goto err; |
| 1307 | |
| 1308 | /* repeated intentionally to avoid extra keypress */ |
Thomas Mair | 40a2d3c | 2012-05-18 14:47:42 -0300 | [diff] [blame] | 1309 | ret = rtl28xx_wr_reg(d, SYS_IRRC_SR, 1); |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 1310 | if (ret) |
| 1311 | goto err; |
| 1312 | } |
| 1313 | |
| 1314 | return ret; |
| 1315 | err: |
Antti Palosaari | c01a359 | 2012-08-12 22:27:07 -0300 | [diff] [blame] | 1316 | dev_dbg(&d->udev->dev, "%s: failed=%d\n", __func__, ret); |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 1317 | return ret; |
| 1318 | } |
| 1319 | |
Antti Palosaari | c01a359 | 2012-08-12 22:27:07 -0300 | [diff] [blame] | 1320 | static int rtl2831u_get_rc_config(struct dvb_usb_device *d, |
| 1321 | struct dvb_usb_rc *rc) |
| 1322 | { |
| 1323 | rc->map_name = RC_MAP_EMPTY; |
David Härdeman | c003ab1 | 2012-10-11 19:11:54 -0300 | [diff] [blame] | 1324 | rc->allowed_protos = RC_BIT_NEC; |
Antti Palosaari | c01a359 | 2012-08-12 22:27:07 -0300 | [diff] [blame] | 1325 | rc->query = rtl2831u_rc_query; |
| 1326 | rc->interval = 400; |
| 1327 | |
| 1328 | return 0; |
| 1329 | } |
| 1330 | |
Antti Palosaari | b5cbaa4 | 2011-08-04 13:26:10 -0300 | [diff] [blame] | 1331 | static int rtl2832u_rc_query(struct dvb_usb_device *d) |
| 1332 | { |
Antti Palosaari | f39fac3 | 2013-06-04 09:17:03 -0300 | [diff] [blame] | 1333 | int ret, i, len; |
Antti Palosaari | b5cbaa4 | 2011-08-04 13:26:10 -0300 | [diff] [blame] | 1334 | struct rtl28xxu_priv *priv = d->priv; |
Antti Palosaari | f39fac3 | 2013-06-04 09:17:03 -0300 | [diff] [blame] | 1335 | struct ir_raw_event ev; |
Antti Palosaari | b5cbaa4 | 2011-08-04 13:26:10 -0300 | [diff] [blame] | 1336 | u8 buf[128]; |
Antti Palosaari | f39fac3 | 2013-06-04 09:17:03 -0300 | [diff] [blame] | 1337 | static const struct rtl28xxu_reg_val_mask refresh_tab[] = { |
| 1338 | {IR_RX_IF, 0x03, 0xff}, |
| 1339 | {IR_RX_BUF_CTRL, 0x80, 0xff}, |
| 1340 | {IR_RX_CTRL, 0x80, 0xff}, |
| 1341 | }; |
Antti Palosaari | b5cbaa4 | 2011-08-04 13:26:10 -0300 | [diff] [blame] | 1342 | |
| 1343 | /* init remote controller */ |
| 1344 | if (!priv->rc_active) { |
Antti Palosaari | f39fac3 | 2013-06-04 09:17:03 -0300 | [diff] [blame] | 1345 | static const struct rtl28xxu_reg_val_mask init_tab[] = { |
| 1346 | {SYS_DEMOD_CTL1, 0x00, 0x04}, |
| 1347 | {SYS_DEMOD_CTL1, 0x00, 0x08}, |
| 1348 | {USB_CTRL, 0x20, 0x20}, |
| 1349 | {SYS_GPIO_DIR, 0x00, 0x08}, |
| 1350 | {SYS_GPIO_OUT_EN, 0x08, 0x08}, |
| 1351 | {SYS_GPIO_OUT_VAL, 0x08, 0x08}, |
| 1352 | {IR_MAX_DURATION0, 0xd0, 0xff}, |
| 1353 | {IR_MAX_DURATION1, 0x07, 0xff}, |
| 1354 | {IR_IDLE_LEN0, 0xc0, 0xff}, |
| 1355 | {IR_IDLE_LEN1, 0x00, 0xff}, |
| 1356 | {IR_GLITCH_LEN, 0x03, 0xff}, |
| 1357 | {IR_RX_CLK, 0x09, 0xff}, |
| 1358 | {IR_RX_CFG, 0x1c, 0xff}, |
| 1359 | {IR_MAX_H_TOL_LEN, 0x1e, 0xff}, |
| 1360 | {IR_MAX_L_TOL_LEN, 0x1e, 0xff}, |
| 1361 | {IR_RX_CTRL, 0x80, 0xff}, |
| 1362 | }; |
| 1363 | |
| 1364 | for (i = 0; i < ARRAY_SIZE(init_tab); i++) { |
| 1365 | ret = rtl28xx_wr_reg_mask(d, init_tab[i].reg, |
| 1366 | init_tab[i].val, init_tab[i].mask); |
Rodrigo Tartajo | 1e41413 | 2013-04-20 20:02:12 -0300 | [diff] [blame] | 1367 | if (ret) |
| 1368 | goto err; |
| 1369 | } |
Antti Palosaari | f39fac3 | 2013-06-04 09:17:03 -0300 | [diff] [blame] | 1370 | |
Antti Palosaari | b5cbaa4 | 2011-08-04 13:26:10 -0300 | [diff] [blame] | 1371 | priv->rc_active = true; |
| 1372 | } |
| 1373 | |
Thomas Mair | 40a2d3c | 2012-05-18 14:47:42 -0300 | [diff] [blame] | 1374 | ret = rtl28xx_rd_reg(d, IR_RX_IF, &buf[0]); |
Antti Palosaari | b5cbaa4 | 2011-08-04 13:26:10 -0300 | [diff] [blame] | 1375 | if (ret) |
| 1376 | goto err; |
| 1377 | |
| 1378 | if (buf[0] != 0x83) |
Antti Palosaari | f39fac3 | 2013-06-04 09:17:03 -0300 | [diff] [blame] | 1379 | goto exit; |
Antti Palosaari | b5cbaa4 | 2011-08-04 13:26:10 -0300 | [diff] [blame] | 1380 | |
Thomas Mair | 40a2d3c | 2012-05-18 14:47:42 -0300 | [diff] [blame] | 1381 | ret = rtl28xx_rd_reg(d, IR_RX_BC, &buf[0]); |
Antti Palosaari | b5cbaa4 | 2011-08-04 13:26:10 -0300 | [diff] [blame] | 1382 | if (ret) |
| 1383 | goto err; |
| 1384 | |
| 1385 | len = buf[0]; |
Antti Palosaari | f39fac3 | 2013-06-04 09:17:03 -0300 | [diff] [blame] | 1386 | |
| 1387 | /* read raw code from hw */ |
Antti Palosaari | b5cbaa4 | 2011-08-04 13:26:10 -0300 | [diff] [blame] | 1388 | ret = rtl2831_rd_regs(d, IR_RX_BUF, buf, len); |
Antti Palosaari | f39fac3 | 2013-06-04 09:17:03 -0300 | [diff] [blame] | 1389 | if (ret) |
| 1390 | goto err; |
Antti Palosaari | b5cbaa4 | 2011-08-04 13:26:10 -0300 | [diff] [blame] | 1391 | |
Antti Palosaari | f39fac3 | 2013-06-04 09:17:03 -0300 | [diff] [blame] | 1392 | /* let hw receive new code */ |
| 1393 | for (i = 0; i < ARRAY_SIZE(refresh_tab); i++) { |
| 1394 | ret = rtl28xx_wr_reg_mask(d, refresh_tab[i].reg, |
| 1395 | refresh_tab[i].val, refresh_tab[i].mask); |
Rodrigo Tartajo | 1e41413 | 2013-04-20 20:02:12 -0300 | [diff] [blame] | 1396 | if (ret) |
| 1397 | goto err; |
| 1398 | } |
Antti Palosaari | b5cbaa4 | 2011-08-04 13:26:10 -0300 | [diff] [blame] | 1399 | |
Antti Palosaari | f39fac3 | 2013-06-04 09:17:03 -0300 | [diff] [blame] | 1400 | /* pass data to Kernel IR decoder */ |
| 1401 | init_ir_raw_event(&ev); |
| 1402 | |
| 1403 | for (i = 0; i < len; i++) { |
| 1404 | ev.pulse = buf[i] >> 7; |
| 1405 | ev.duration = 50800 * (buf[i] & 0x7f); |
| 1406 | ir_raw_event_store_with_filter(d->rc_dev, &ev); |
| 1407 | } |
| 1408 | |
| 1409 | /* 'flush' ir_raw_event_store_with_filter() */ |
| 1410 | ir_raw_event_set_idle(d->rc_dev, true); |
| 1411 | ir_raw_event_handle(d->rc_dev); |
| 1412 | exit: |
Antti Palosaari | b5cbaa4 | 2011-08-04 13:26:10 -0300 | [diff] [blame] | 1413 | return ret; |
| 1414 | err: |
Antti Palosaari | c01a359 | 2012-08-12 22:27:07 -0300 | [diff] [blame] | 1415 | dev_dbg(&d->udev->dev, "%s: failed=%d\n", __func__, ret); |
Antti Palosaari | b5cbaa4 | 2011-08-04 13:26:10 -0300 | [diff] [blame] | 1416 | return ret; |
| 1417 | } |
| 1418 | |
Antti Palosaari | c01a359 | 2012-08-12 22:27:07 -0300 | [diff] [blame] | 1419 | static int rtl2832u_get_rc_config(struct dvb_usb_device *d, |
| 1420 | struct dvb_usb_rc *rc) |
| 1421 | { |
Antti Palosaari | 94b5fa6 | 2013-11-22 14:20:14 -0300 | [diff] [blame] | 1422 | /* disable IR interrupts in order to avoid SDR sample loss */ |
| 1423 | if (rtl28xxu_disable_rc) |
| 1424 | return rtl28xx_wr_reg(d, IR_RX_IE, 0x00); |
| 1425 | |
Antti Palosaari | f39fac3 | 2013-06-04 09:17:03 -0300 | [diff] [blame] | 1426 | /* load empty to enable rc */ |
| 1427 | if (!rc->map_name) |
| 1428 | rc->map_name = RC_MAP_EMPTY; |
Rodrigo Tartajo | 1e41413 | 2013-04-20 20:02:12 -0300 | [diff] [blame] | 1429 | rc->allowed_protos = RC_BIT_ALL; |
Antti Palosaari | f39fac3 | 2013-06-04 09:17:03 -0300 | [diff] [blame] | 1430 | rc->driver_type = RC_DRIVER_IR_RAW; |
Antti Palosaari | c01a359 | 2012-08-12 22:27:07 -0300 | [diff] [blame] | 1431 | rc->query = rtl2832u_rc_query; |
| 1432 | rc->interval = 400; |
Antti Palosaari | b5cbaa4 | 2011-08-04 13:26:10 -0300 | [diff] [blame] | 1433 | |
Antti Palosaari | c01a359 | 2012-08-12 22:27:07 -0300 | [diff] [blame] | 1434 | return 0; |
| 1435 | } |
Antti Palosaari | cedda37 | 2012-12-09 20:06:00 -0300 | [diff] [blame] | 1436 | #else |
Antti Palosaari | 5a18664 | 2013-06-04 16:50:54 -0300 | [diff] [blame] | 1437 | #define rtl2831u_get_rc_config NULL |
| 1438 | #define rtl2832u_get_rc_config NULL |
Antti Palosaari | cedda37 | 2012-12-09 20:06:00 -0300 | [diff] [blame] | 1439 | #endif |
Antti Palosaari | b5cbaa4 | 2011-08-04 13:26:10 -0300 | [diff] [blame] | 1440 | |
Antti Palosaari | c01a359 | 2012-08-12 22:27:07 -0300 | [diff] [blame] | 1441 | static const struct dvb_usb_device_properties rtl2831u_props = { |
| 1442 | .driver_name = KBUILD_MODNAME, |
| 1443 | .owner = THIS_MODULE, |
| 1444 | .adapter_nr = adapter_nr, |
| 1445 | .size_of_priv = sizeof(struct rtl28xxu_priv), |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 1446 | |
Antti Palosaari | c01a359 | 2012-08-12 22:27:07 -0300 | [diff] [blame] | 1447 | .power_ctrl = rtl2831u_power_ctrl, |
| 1448 | .i2c_algo = &rtl28xxu_i2c_algo, |
Antti Palosaari | 81347f5 | 2012-09-17 16:50:36 -0300 | [diff] [blame] | 1449 | .read_config = rtl2831u_read_config, |
Antti Palosaari | c01a359 | 2012-08-12 22:27:07 -0300 | [diff] [blame] | 1450 | .frontend_attach = rtl2831u_frontend_attach, |
| 1451 | .tuner_attach = rtl2831u_tuner_attach, |
| 1452 | .init = rtl28xxu_init, |
| 1453 | .get_rc_config = rtl2831u_get_rc_config, |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 1454 | |
Antti Palosaari | c01a359 | 2012-08-12 22:27:07 -0300 | [diff] [blame] | 1455 | .num_adapters = 1, |
| 1456 | .adapter = { |
| 1457 | { |
| 1458 | .stream = DVB_USB_STREAM_BULK(0x81, 6, 8 * 512), |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 1459 | }, |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 1460 | }, |
Antti Palosaari | c01a359 | 2012-08-12 22:27:07 -0300 | [diff] [blame] | 1461 | }; |
Antti Palosaari | b5cbaa4 | 2011-08-04 13:26:10 -0300 | [diff] [blame] | 1462 | |
Antti Palosaari | c01a359 | 2012-08-12 22:27:07 -0300 | [diff] [blame] | 1463 | static const struct dvb_usb_device_properties rtl2832u_props = { |
| 1464 | .driver_name = KBUILD_MODNAME, |
| 1465 | .owner = THIS_MODULE, |
| 1466 | .adapter_nr = adapter_nr, |
| 1467 | .size_of_priv = sizeof(struct rtl28xxu_priv), |
Antti Palosaari | b5cbaa4 | 2011-08-04 13:26:10 -0300 | [diff] [blame] | 1468 | |
Antti Palosaari | c01a359 | 2012-08-12 22:27:07 -0300 | [diff] [blame] | 1469 | .power_ctrl = rtl2832u_power_ctrl, |
| 1470 | .i2c_algo = &rtl28xxu_i2c_algo, |
Antti Palosaari | ef37be1 | 2012-09-17 14:01:35 -0300 | [diff] [blame] | 1471 | .read_config = rtl2832u_read_config, |
Antti Palosaari | c01a359 | 2012-08-12 22:27:07 -0300 | [diff] [blame] | 1472 | .frontend_attach = rtl2832u_frontend_attach, |
| 1473 | .tuner_attach = rtl2832u_tuner_attach, |
| 1474 | .init = rtl28xxu_init, |
Antti Palosaari | 28fd31f | 2013-10-15 19:22:45 -0300 | [diff] [blame] | 1475 | .exit = rtl28xxu_exit, |
Antti Palosaari | c01a359 | 2012-08-12 22:27:07 -0300 | [diff] [blame] | 1476 | .get_rc_config = rtl2832u_get_rc_config, |
Antti Palosaari | b5cbaa4 | 2011-08-04 13:26:10 -0300 | [diff] [blame] | 1477 | |
Antti Palosaari | c01a359 | 2012-08-12 22:27:07 -0300 | [diff] [blame] | 1478 | .num_adapters = 1, |
| 1479 | .adapter = { |
| 1480 | { |
| 1481 | .stream = DVB_USB_STREAM_BULK(0x81, 6, 8 * 512), |
Antti Palosaari | b5cbaa4 | 2011-08-04 13:26:10 -0300 | [diff] [blame] | 1482 | }, |
Antti Palosaari | b5cbaa4 | 2011-08-04 13:26:10 -0300 | [diff] [blame] | 1483 | }, |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 1484 | }; |
| 1485 | |
Antti Palosaari | c01a359 | 2012-08-12 22:27:07 -0300 | [diff] [blame] | 1486 | static const struct usb_device_id rtl28xxu_id_table[] = { |
Jan Vcelak | 60aa4c6 | 2014-02-26 15:33:40 -0300 | [diff] [blame] | 1487 | /* RTL2831U devices: */ |
Antti Palosaari | c01a359 | 2012-08-12 22:27:07 -0300 | [diff] [blame] | 1488 | { DVB_USB_DEVICE(USB_VID_REALTEK, USB_PID_REALTEK_RTL2831U, |
| 1489 | &rtl2831u_props, "Realtek RTL2831U reference design", NULL) }, |
| 1490 | { DVB_USB_DEVICE(USB_VID_WIDEVIEW, USB_PID_FREECOM_DVBT, |
| 1491 | &rtl2831u_props, "Freecom USB2.0 DVB-T", NULL) }, |
| 1492 | { DVB_USB_DEVICE(USB_VID_WIDEVIEW, USB_PID_FREECOM_DVBT_2, |
| 1493 | &rtl2831u_props, "Freecom USB2.0 DVB-T", NULL) }, |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 1494 | |
Jan Vcelak | 60aa4c6 | 2014-02-26 15:33:40 -0300 | [diff] [blame] | 1495 | /* RTL2832U devices: */ |
Antti Palosaari | 254ee2e | 2012-09-18 10:27:05 -0300 | [diff] [blame] | 1496 | { DVB_USB_DEVICE(USB_VID_REALTEK, 0x2832, |
| 1497 | &rtl2832u_props, "Realtek RTL2832U reference design", NULL) }, |
| 1498 | { DVB_USB_DEVICE(USB_VID_REALTEK, 0x2838, |
| 1499 | &rtl2832u_props, "Realtek RTL2832U reference design", NULL) }, |
Antti Palosaari | c01a359 | 2012-08-12 22:27:07 -0300 | [diff] [blame] | 1500 | { DVB_USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_T_STICK_BLACK_REV1, |
Antti Palosaari | bc6fc53 | 2013-06-04 17:24:06 -0300 | [diff] [blame] | 1501 | &rtl2832u_props, "TerraTec Cinergy T Stick Black", RC_MAP_TERRATEC_SLIM) }, |
Antti Palosaari | c01a359 | 2012-08-12 22:27:07 -0300 | [diff] [blame] | 1502 | { DVB_USB_DEVICE(USB_VID_GTEK, USB_PID_DELOCK_USB2_DVBT, |
| 1503 | &rtl2832u_props, "G-Tek Electronics Group Lifeview LV5TDLX DVB-T", NULL) }, |
| 1504 | { DVB_USB_DEVICE(USB_VID_TERRATEC, USB_PID_NOXON_DAB_STICK, |
Antti Palosaari | 9db1563 | 2013-01-04 18:35:00 -0300 | [diff] [blame] | 1505 | &rtl2832u_props, "TerraTec NOXON DAB Stick", NULL) }, |
Juergen Lock | e9de051 | 2012-11-13 14:09:28 -0300 | [diff] [blame] | 1506 | { DVB_USB_DEVICE(USB_VID_TERRATEC, USB_PID_NOXON_DAB_STICK_REV2, |
Antti Palosaari | 9db1563 | 2013-01-04 18:35:00 -0300 | [diff] [blame] | 1507 | &rtl2832u_props, "TerraTec NOXON DAB Stick (rev 2)", NULL) }, |
Till Dörges | a24bc32 | 2014-02-11 17:27:57 -0300 | [diff] [blame] | 1508 | { DVB_USB_DEVICE(USB_VID_TERRATEC, USB_PID_NOXON_DAB_STICK_REV3, |
| 1509 | &rtl2832u_props, "TerraTec NOXON DAB Stick (rev 3)", NULL) }, |
Philipp Dreimann | 6d60805 | 2012-09-02 19:30:54 -0300 | [diff] [blame] | 1510 | { DVB_USB_DEVICE(USB_VID_GTEK, USB_PID_TREKSTOR_TERRES_2_0, |
| 1511 | &rtl2832u_props, "Trekstor DVB-T Stick Terres 2.0", NULL) }, |
Antti Palosaari | c2d246d1 | 2012-09-08 22:07:26 -0300 | [diff] [blame] | 1512 | { DVB_USB_DEVICE(USB_VID_DEXATEK, 0x1101, |
| 1513 | &rtl2832u_props, "Dexatek DK DVB-T Dongle", NULL) }, |
Antti Palosaari | 3d8866d | 2012-09-20 18:34:50 -0300 | [diff] [blame] | 1514 | { DVB_USB_DEVICE(USB_VID_LEADTEK, 0x6680, |
| 1515 | &rtl2832u_props, "DigitalNow Quad DVB-T Receiver", NULL) }, |
Robert Backhaus | d22d32e | 2013-12-13 09:59:10 -0300 | [diff] [blame] | 1516 | { DVB_USB_DEVICE(USB_VID_LEADTEK, USB_PID_WINFAST_DTV_DONGLE_MINID, |
| 1517 | &rtl2832u_props, "Leadtek Winfast DTV Dongle Mini D", NULL) }, |
Antti Palosaari | a4f6440 | 2012-09-29 15:28:56 -0300 | [diff] [blame] | 1518 | { DVB_USB_DEVICE(USB_VID_TERRATEC, 0x00d3, |
| 1519 | &rtl2832u_props, "TerraTec Cinergy T Stick RC (Rev. 3)", NULL) }, |
Antti Palosaari | 08e5727 | 2012-11-06 16:03:35 -0300 | [diff] [blame] | 1520 | { DVB_USB_DEVICE(USB_VID_DEXATEK, 0x1102, |
| 1521 | &rtl2832u_props, "Dexatek DK mini DVB-T Dongle", NULL) }, |
Andrew Karpow | 86163ad | 2012-11-06 20:01:16 -0300 | [diff] [blame] | 1522 | { DVB_USB_DEVICE(USB_VID_TERRATEC, 0x00d7, |
| 1523 | &rtl2832u_props, "TerraTec Cinergy T Stick+", NULL) }, |
Antti Palosaari | 3971e79 | 2012-12-16 11:47:07 -0300 | [diff] [blame] | 1524 | { DVB_USB_DEVICE(USB_VID_KWORLD_2, 0xd3a8, |
| 1525 | &rtl2832u_props, "ASUS My Cinema-U3100Mini Plus V2", NULL) }, |
Alexander Inyukhin | 78a5e70 | 2013-01-04 18:19:02 -0300 | [diff] [blame] | 1526 | { DVB_USB_DEVICE(USB_VID_KWORLD_2, 0xd393, |
Antti Palosaari | 9db1563 | 2013-01-04 18:35:00 -0300 | [diff] [blame] | 1527 | &rtl2832u_props, "GIGABYTE U7300", NULL) }, |
Eddi De Pieri | 09f9408 | 2013-01-14 18:21:32 -0300 | [diff] [blame] | 1528 | { DVB_USB_DEVICE(USB_VID_DEXATEK, 0x1104, |
Antti Palosaari | 7dc0a01 | 2013-06-04 17:01:25 -0300 | [diff] [blame] | 1529 | &rtl2832u_props, "MSI DIGIVOX Micro HD", NULL) }, |
Alistair Buxton | b9e2aff | 2013-02-12 21:58:47 -0300 | [diff] [blame] | 1530 | { DVB_USB_DEVICE(USB_VID_COMPRO, 0x0620, |
| 1531 | &rtl2832u_props, "Compro VideoMate U620F", NULL) }, |
Fabrizio Gazzato | e6a60d7 | 2013-02-15 18:54:54 -0300 | [diff] [blame] | 1532 | { DVB_USB_DEVICE(USB_VID_KWORLD_2, 0xd394, |
| 1533 | &rtl2832u_props, "MaxMedia HU394-T", NULL) }, |
Miroslav Šustek | 6c5a406 | 2013-05-14 19:42:11 -0300 | [diff] [blame] | 1534 | { DVB_USB_DEVICE(USB_VID_LEADTEK, 0x6a03, |
Antti Palosaari | 7dc0a01 | 2013-06-04 17:01:25 -0300 | [diff] [blame] | 1535 | &rtl2832u_props, "Leadtek WinFast DTV Dongle mini", NULL) }, |
Alessandro Miceli | c6be752 | 2013-06-04 16:10:34 -0300 | [diff] [blame] | 1536 | { DVB_USB_DEVICE(USB_VID_GTEK, USB_PID_CPYTO_REDI_PC50A, |
Antti Palosaari | 7df2725 | 2013-06-04 19:43:30 -0300 | [diff] [blame] | 1537 | &rtl2832u_props, "Crypto ReDi PC 50 A", NULL) }, |
Jan Vcelak | ac298cc | 2014-02-26 15:33:39 -0300 | [diff] [blame] | 1538 | { DVB_USB_DEVICE(USB_VID_KYE, 0x707f, |
| 1539 | &rtl2832u_props, "Genius TVGo DVB-T03", NULL) }, |
Brian Healy | 9ca24ae | 2014-05-04 18:43:39 -0300 | [diff] [blame] | 1540 | { DVB_USB_DEVICE(USB_VID_KWORLD_2, 0xd395, |
| 1541 | &rtl2832u_props, "Peak DVB-T USB", NULL) }, |
Alessandro Miceli | f27f5b0 | 2014-05-04 07:37:15 -0300 | [diff] [blame] | 1542 | { DVB_USB_DEVICE(USB_VID_KWORLD_2, USB_PID_SVEON_STV20_RTL2832U, |
| 1543 | &rtl2832u_props, "Sveon STV20", NULL) }, |
Alessandro Miceli | 74a8627 | 2014-05-04 07:50:31 -0300 | [diff] [blame^] | 1544 | { DVB_USB_DEVICE(USB_VID_KWORLD_2, USB_PID_SVEON_STV27, |
| 1545 | &rtl2832u_props, "Sveon STV27", NULL) }, |
Antti Palosaari | 8fdd33b | 2013-10-30 02:33:42 -0300 | [diff] [blame] | 1546 | |
Jan Vcelak | 60aa4c6 | 2014-02-26 15:33:40 -0300 | [diff] [blame] | 1547 | /* RTL2832P devices: */ |
Antti Palosaari | 8fdd33b | 2013-10-30 02:33:42 -0300 | [diff] [blame] | 1548 | { DVB_USB_DEVICE(USB_VID_HANFTEK, 0x0131, |
| 1549 | &rtl2832u_props, "Astrometa DVB-T2", NULL) }, |
Antti Palosaari | c01a359 | 2012-08-12 22:27:07 -0300 | [diff] [blame] | 1550 | { } |
| 1551 | }; |
| 1552 | MODULE_DEVICE_TABLE(usb, rtl28xxu_id_table); |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 1553 | |
Antti Palosaari | c01a359 | 2012-08-12 22:27:07 -0300 | [diff] [blame] | 1554 | static struct usb_driver rtl28xxu_usb_driver = { |
| 1555 | .name = KBUILD_MODNAME, |
| 1556 | .id_table = rtl28xxu_id_table, |
| 1557 | .probe = dvb_usbv2_probe, |
| 1558 | .disconnect = dvb_usbv2_disconnect, |
| 1559 | .suspend = dvb_usbv2_suspend, |
| 1560 | .resume = dvb_usbv2_resume, |
Antti Palosaari | 78fa590 | 2012-08-14 22:21:09 -0300 | [diff] [blame] | 1561 | .reset_resume = dvb_usbv2_reset_resume, |
Antti Palosaari | c01a359 | 2012-08-12 22:27:07 -0300 | [diff] [blame] | 1562 | .no_dynamic_id = 1, |
| 1563 | .soft_unbind = 1, |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 1564 | }; |
| 1565 | |
Antti Palosaari | c01a359 | 2012-08-12 22:27:07 -0300 | [diff] [blame] | 1566 | module_usb_driver(rtl28xxu_usb_driver); |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 1567 | |
| 1568 | MODULE_DESCRIPTION("Realtek RTL28xxU DVB USB driver"); |
| 1569 | MODULE_AUTHOR("Antti Palosaari <crope@iki.fi>"); |
Thomas Mair | 5cf6631 | 2012-05-18 14:47:41 -0300 | [diff] [blame] | 1570 | MODULE_AUTHOR("Thomas Mair <thomas.mair86@googlemail.com>"); |
Antti Palosaari | 831e0b7 | 2011-07-08 23:36:07 -0300 | [diff] [blame] | 1571 | MODULE_LICENSE("GPL"); |