blob: d0d23f2c1fe7f71f6fd7577974ef687bf4c7026f [file] [log] [blame]
Antti Palosaari831e0b72011-07-08 23:36:07 -03001/*
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 Mair5cf66312012-05-18 14:47:41 -03006 * Copyright (C) 2012 Thomas Mair <thomas.mair86@googlemail.com>
Antti Palosaari831e0b72011-07-08 23:36:07 -03007 *
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 Mair5cf66312012-05-18 14:47:41 -030026#include "rtl2832.h"
Antti Palosaari831e0b72011-07-08 23:36:07 -030027
28#include "qt1010.h"
29#include "mt2060.h"
30#include "mxl5005s.h"
Thomas Mair5cf66312012-05-18 14:47:41 -030031#include "fc0012.h"
32#include "fc0013.h"
Antti Palosaari542f6a52012-09-01 21:09:22 -030033#include "e4000.h"
Antti Palosaari831e0b72011-07-08 23:36:07 -030034
Antti Palosaari831e0b72011-07-08 23:36:07 -030035DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
36
37static int rtl28xxu_ctrl_msg(struct dvb_usb_device *d, struct rtl28xxu_req *req)
38{
39 int ret;
40 unsigned int pipe;
41 u8 requesttype;
42 u8 *buf;
43
44 buf = kmalloc(req->size, GFP_KERNEL);
45 if (!buf) {
46 ret = -ENOMEM;
47 goto err;
48 }
49
50 if (req->index & CMD_WR_FLAG) {
51 /* write */
52 memcpy(buf, req->data, req->size);
53 requesttype = (USB_TYPE_VENDOR | USB_DIR_OUT);
54 pipe = usb_sndctrlpipe(d->udev, 0);
55 } else {
56 /* read */
57 requesttype = (USB_TYPE_VENDOR | USB_DIR_IN);
58 pipe = usb_rcvctrlpipe(d->udev, 0);
59 }
60
61 ret = usb_control_msg(d->udev, pipe, 0, requesttype, req->value,
Antti Palosaari9935eea2012-01-21 22:26:52 -030062 req->index, buf, req->size, 1000);
Antti Palosaarid89b9362012-08-22 19:42:00 -030063
64 dvb_usb_dbg_usb_control_msg(d->udev, 0, requesttype, req->value,
65 req->index, buf, req->size);
66
Antti Palosaari9935eea2012-01-21 22:26:52 -030067 if (ret > 0)
68 ret = 0;
Antti Palosaari831e0b72011-07-08 23:36:07 -030069
Antti Palosaari831e0b72011-07-08 23:36:07 -030070 /* read request, copy returned data to return buf */
71 if (!ret && requesttype == (USB_TYPE_VENDOR | USB_DIR_IN))
72 memcpy(req->data, buf, req->size);
73
74 kfree(buf);
Antti Palosaari831e0b72011-07-08 23:36:07 -030075
Antti Palosaari9935eea2012-01-21 22:26:52 -030076 if (ret)
77 goto err;
78
79 return ret;
Antti Palosaari831e0b72011-07-08 23:36:07 -030080err:
Antti Palosaaric01a3592012-08-12 22:27:07 -030081 dev_dbg(&d->udev->dev, "%s: failed=%d\n", __func__, ret);
Antti Palosaari831e0b72011-07-08 23:36:07 -030082 return ret;
83}
84
Thomas Mair40a2d3c2012-05-18 14:47:42 -030085static int rtl28xx_wr_regs(struct dvb_usb_device *d, u16 reg, u8 *val, int len)
Antti Palosaari831e0b72011-07-08 23:36:07 -030086{
87 struct rtl28xxu_req req;
88
89 if (reg < 0x3000)
90 req.index = CMD_USB_WR;
Antti Palosaarib5cbaa42011-08-04 13:26:10 -030091 else if (reg < 0x4000)
Antti Palosaari831e0b72011-07-08 23:36:07 -030092 req.index = CMD_SYS_WR;
Antti Palosaarib5cbaa42011-08-04 13:26:10 -030093 else
94 req.index = CMD_IR_WR;
Antti Palosaari831e0b72011-07-08 23:36:07 -030095
96 req.value = reg;
97 req.size = len;
98 req.data = val;
99
100 return rtl28xxu_ctrl_msg(d, &req);
101}
102
103static int rtl2831_rd_regs(struct dvb_usb_device *d, u16 reg, u8 *val, int len)
104{
105 struct rtl28xxu_req req;
106
107 if (reg < 0x3000)
108 req.index = CMD_USB_RD;
Antti Palosaarib5cbaa42011-08-04 13:26:10 -0300109 else if (reg < 0x4000)
Antti Palosaari831e0b72011-07-08 23:36:07 -0300110 req.index = CMD_SYS_RD;
Antti Palosaarib5cbaa42011-08-04 13:26:10 -0300111 else
112 req.index = CMD_IR_RD;
Antti Palosaari831e0b72011-07-08 23:36:07 -0300113
114 req.value = reg;
115 req.size = len;
116 req.data = val;
117
118 return rtl28xxu_ctrl_msg(d, &req);
119}
120
Thomas Mair40a2d3c2012-05-18 14:47:42 -0300121static int rtl28xx_wr_reg(struct dvb_usb_device *d, u16 reg, u8 val)
Antti Palosaari831e0b72011-07-08 23:36:07 -0300122{
Thomas Mair40a2d3c2012-05-18 14:47:42 -0300123 return rtl28xx_wr_regs(d, reg, &val, 1);
Antti Palosaari831e0b72011-07-08 23:36:07 -0300124}
125
Thomas Mair40a2d3c2012-05-18 14:47:42 -0300126static int rtl28xx_rd_reg(struct dvb_usb_device *d, u16 reg, u8 *val)
Antti Palosaari831e0b72011-07-08 23:36:07 -0300127{
128 return rtl2831_rd_regs(d, reg, val, 1);
129}
130
131/* I2C */
132static int rtl28xxu_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[],
133 int num)
134{
135 int ret;
136 struct dvb_usb_device *d = i2c_get_adapdata(adap);
Antti Palosaari34ec2932011-08-04 20:21:16 -0300137 struct rtl28xxu_priv *priv = d->priv;
Antti Palosaari831e0b72011-07-08 23:36:07 -0300138 struct rtl28xxu_req req;
139
140 /*
141 * It is not known which are real I2C bus xfer limits, but testing
142 * with RTL2831U + MT2060 gives max RD 24 and max WR 22 bytes.
Antti Palosaari34ec2932011-08-04 20:21:16 -0300143 * TODO: find out RTL2832U lens
144 */
145
146 /*
147 * I2C adapter logic looks rather complicated due to fact it handles
148 * three different access methods. Those methods are;
149 * 1) integrated demod access
150 * 2) old I2C access
151 * 3) new I2C access
152 *
153 * Used method is selected in order 1, 2, 3. Method 3 can handle all
154 * requests but there is two reasons why not use it always;
155 * 1) It is most expensive, usually two USB messages are needed
156 * 2) At least RTL2831U does not support it
157 *
158 * Method 3 is needed in case of I2C write+read (typical register read)
159 * where write is more than one byte.
Antti Palosaari831e0b72011-07-08 23:36:07 -0300160 */
161
162 if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
163 return -EAGAIN;
164
165 if (num == 2 && !(msg[0].flags & I2C_M_RD) &&
166 (msg[1].flags & I2C_M_RD)) {
Antti Palosaari34ec2932011-08-04 20:21:16 -0300167 if (msg[0].len > 24 || msg[1].len > 24) {
168 /* TODO: check msg[0].len max */
Antti Palosaari831e0b72011-07-08 23:36:07 -0300169 ret = -EOPNOTSUPP;
Antti Palosaari9935eea2012-01-21 22:26:52 -0300170 goto err_mutex_unlock;
Antti Palosaari34ec2932011-08-04 20:21:16 -0300171 } else if (msg[0].addr == 0x10) {
172 /* method 1 - integrated demod */
173 req.value = (msg[0].buf[0] << 8) | (msg[0].addr << 1);
174 req.index = CMD_DEMOD_RD | priv->page;
Antti Palosaari831e0b72011-07-08 23:36:07 -0300175 req.size = msg[1].len;
176 req.data = &msg[1].buf[0];
177 ret = rtl28xxu_ctrl_msg(d, &req);
Antti Palosaari34ec2932011-08-04 20:21:16 -0300178 } else if (msg[0].len < 2) {
179 /* method 2 - old I2C */
Antti Palosaari831e0b72011-07-08 23:36:07 -0300180 req.value = (msg[0].buf[0] << 8) | (msg[0].addr << 1);
181 req.index = CMD_I2C_RD;
182 req.size = msg[1].len;
183 req.data = &msg[1].buf[0];
184 ret = rtl28xxu_ctrl_msg(d, &req);
Antti Palosaari34ec2932011-08-04 20:21:16 -0300185 } else {
186 /* method 3 - new I2C */
187 req.value = (msg[0].addr << 1);
188 req.index = CMD_I2C_DA_WR;
189 req.size = msg[0].len;
190 req.data = msg[0].buf;
191 ret = rtl28xxu_ctrl_msg(d, &req);
192 if (ret)
Antti Palosaari9935eea2012-01-21 22:26:52 -0300193 goto err_mutex_unlock;
Antti Palosaari34ec2932011-08-04 20:21:16 -0300194
195 req.value = (msg[0].addr << 1);
196 req.index = CMD_I2C_DA_RD;
197 req.size = msg[1].len;
198 req.data = msg[1].buf;
199 ret = rtl28xxu_ctrl_msg(d, &req);
Antti Palosaari831e0b72011-07-08 23:36:07 -0300200 }
201 } else if (num == 1 && !(msg[0].flags & I2C_M_RD)) {
202 if (msg[0].len > 22) {
Antti Palosaari34ec2932011-08-04 20:21:16 -0300203 /* TODO: check msg[0].len max */
Antti Palosaari831e0b72011-07-08 23:36:07 -0300204 ret = -EOPNOTSUPP;
Antti Palosaari9935eea2012-01-21 22:26:52 -0300205 goto err_mutex_unlock;
Antti Palosaari34ec2932011-08-04 20:21:16 -0300206 } else if (msg[0].addr == 0x10) {
207 /* method 1 - integrated demod */
208 if (msg[0].buf[0] == 0x00) {
209 /* save demod page for later demod access */
210 priv->page = msg[0].buf[1];
211 ret = 0;
212 } else {
213 req.value = (msg[0].buf[0] << 8) |
214 (msg[0].addr << 1);
215 req.index = CMD_DEMOD_WR | priv->page;
216 req.size = msg[0].len-1;
217 req.data = &msg[0].buf[1];
218 ret = rtl28xxu_ctrl_msg(d, &req);
219 }
220 } else if (msg[0].len < 23) {
221 /* method 2 - old I2C */
Antti Palosaari831e0b72011-07-08 23:36:07 -0300222 req.value = (msg[0].buf[0] << 8) | (msg[0].addr << 1);
223 req.index = CMD_I2C_WR;
224 req.size = msg[0].len-1;
225 req.data = &msg[0].buf[1];
226 ret = rtl28xxu_ctrl_msg(d, &req);
Antti Palosaari34ec2932011-08-04 20:21:16 -0300227 } else {
228 /* method 3 - new I2C */
229 req.value = (msg[0].addr << 1);
230 req.index = CMD_I2C_DA_WR;
231 req.size = msg[0].len;
232 req.data = msg[0].buf;
233 ret = rtl28xxu_ctrl_msg(d, &req);
Antti Palosaari831e0b72011-07-08 23:36:07 -0300234 }
235 } else {
236 ret = -EINVAL;
237 }
238
Antti Palosaari9935eea2012-01-21 22:26:52 -0300239err_mutex_unlock:
Antti Palosaari831e0b72011-07-08 23:36:07 -0300240 mutex_unlock(&d->i2c_mutex);
241
242 return ret ? ret : num;
243}
244
245static u32 rtl28xxu_i2c_func(struct i2c_adapter *adapter)
246{
247 return I2C_FUNC_I2C;
248}
249
250static struct i2c_algorithm rtl28xxu_i2c_algo = {
251 .master_xfer = rtl28xxu_i2c_xfer,
252 .functionality = rtl28xxu_i2c_func,
253};
254
255static struct rtl2830_config rtl28xxu_rtl2830_mt2060_config = {
256 .i2c_addr = 0x10, /* 0x20 */
257 .xtal = 28800000,
258 .ts_mode = 0,
259 .spec_inv = 1,
260 .if_dvbt = 36150000,
261 .vtop = 0x20,
262 .krf = 0x04,
263 .agc_targ_val = 0x2d,
264
265};
266
267static struct rtl2830_config rtl28xxu_rtl2830_qt1010_config = {
268 .i2c_addr = 0x10, /* 0x20 */
269 .xtal = 28800000,
270 .ts_mode = 0,
271 .spec_inv = 1,
272 .if_dvbt = 36125000,
273 .vtop = 0x20,
274 .krf = 0x04,
275 .agc_targ_val = 0x2d,
276};
277
278static struct rtl2830_config rtl28xxu_rtl2830_mxl5005s_config = {
279 .i2c_addr = 0x10, /* 0x20 */
280 .xtal = 28800000,
281 .ts_mode = 0,
282 .spec_inv = 0,
283 .if_dvbt = 4570000,
284 .vtop = 0x3f,
285 .krf = 0x04,
286 .agc_targ_val = 0x3e,
287};
288
Antti Palosaarib5cbaa42011-08-04 13:26:10 -0300289static int rtl2831u_frontend_attach(struct dvb_usb_adapter *adap)
Antti Palosaari831e0b72011-07-08 23:36:07 -0300290{
291 int ret;
Antti Palosaaric01a3592012-08-12 22:27:07 -0300292 struct dvb_usb_device *d = adap_to_d(adap);
293 struct rtl28xxu_priv *priv = d_to_priv(d);
Antti Palosaari831e0b72011-07-08 23:36:07 -0300294 u8 buf[1];
295 struct rtl2830_config *rtl2830_config;
Antti Palosaarib5cbaa42011-08-04 13:26:10 -0300296 /* open RTL2831U/RTL2830 I2C gate */
Antti Palosaari9935eea2012-01-21 22:26:52 -0300297 struct rtl28xxu_req req_gate = { 0x0120, 0x0011, 0x0001, "\x08" };
Antti Palosaari831e0b72011-07-08 23:36:07 -0300298 /* for MT2060 tuner probe */
Antti Palosaari9935eea2012-01-21 22:26:52 -0300299 struct rtl28xxu_req req_mt2060 = { 0x00c0, CMD_I2C_RD, 1, buf };
Antti Palosaari831e0b72011-07-08 23:36:07 -0300300 /* for QT1010 tuner probe */
Antti Palosaari9935eea2012-01-21 22:26:52 -0300301 struct rtl28xxu_req req_qt1010 = { 0x0fc4, CMD_I2C_RD, 1, buf };
Antti Palosaari831e0b72011-07-08 23:36:07 -0300302
Antti Palosaaric01a3592012-08-12 22:27:07 -0300303 dev_dbg(&d->udev->dev, "%s:\n", __func__);
Antti Palosaari831e0b72011-07-08 23:36:07 -0300304
305 /*
306 * RTL2831U GPIOs
307 * =========================================================
308 * GPIO0 | tuner#0 | 0 off | 1 on | MXL5005S (?)
309 * GPIO2 | LED | 0 off | 1 on |
310 * GPIO4 | tuner#1 | 0 on | 1 off | MT2060
311 */
312
313 /* GPIO direction */
Antti Palosaaric01a3592012-08-12 22:27:07 -0300314 ret = rtl28xx_wr_reg(d, SYS_GPIO_DIR, 0x0a);
Antti Palosaari831e0b72011-07-08 23:36:07 -0300315 if (ret)
316 goto err;
317
318 /* enable as output GPIO0, GPIO2, GPIO4 */
Antti Palosaaric01a3592012-08-12 22:27:07 -0300319 ret = rtl28xx_wr_reg(d, SYS_GPIO_OUT_EN, 0x15);
Antti Palosaari831e0b72011-07-08 23:36:07 -0300320 if (ret)
321 goto err;
322
323 /*
324 * Probe used tuner. We need to know used tuner before demod attach
325 * since there is some demod params needed to set according to tuner.
326 */
327
Antti Palosaariccb5cf92012-05-18 16:07:46 -0300328 /* demod needs some time to wake up */
329 msleep(20);
330
Antti Palosaari831e0b72011-07-08 23:36:07 -0300331 /* open demod I2C gate */
Antti Palosaaric01a3592012-08-12 22:27:07 -0300332 ret = rtl28xxu_ctrl_msg(d, &req_gate);
Antti Palosaari831e0b72011-07-08 23:36:07 -0300333 if (ret)
334 goto err;
335
336 /* check QT1010 ID(?) register; reg=0f val=2c */
Antti Palosaaric01a3592012-08-12 22:27:07 -0300337 ret = rtl28xxu_ctrl_msg(d, &req_qt1010);
Antti Palosaari831e0b72011-07-08 23:36:07 -0300338 if (ret == 0 && buf[0] == 0x2c) {
339 priv->tuner = TUNER_RTL2830_QT1010;
340 rtl2830_config = &rtl28xxu_rtl2830_qt1010_config;
Antti Palosaaric01a3592012-08-12 22:27:07 -0300341 dev_dbg(&d->udev->dev, "%s: QT1010\n", __func__);
Antti Palosaari831e0b72011-07-08 23:36:07 -0300342 goto found;
343 } else {
Antti Palosaaric01a3592012-08-12 22:27:07 -0300344 dev_dbg(&d->udev->dev, "%s: QT1010 probe failed=%d - %02x\n",
345 __func__, ret, buf[0]);
Antti Palosaari831e0b72011-07-08 23:36:07 -0300346 }
347
348 /* open demod I2C gate */
Antti Palosaaric01a3592012-08-12 22:27:07 -0300349 ret = rtl28xxu_ctrl_msg(d, &req_gate);
Antti Palosaari831e0b72011-07-08 23:36:07 -0300350 if (ret)
351 goto err;
352
353 /* check MT2060 ID register; reg=00 val=63 */
Antti Palosaaric01a3592012-08-12 22:27:07 -0300354 ret = rtl28xxu_ctrl_msg(d, &req_mt2060);
Antti Palosaari831e0b72011-07-08 23:36:07 -0300355 if (ret == 0 && buf[0] == 0x63) {
356 priv->tuner = TUNER_RTL2830_MT2060;
357 rtl2830_config = &rtl28xxu_rtl2830_mt2060_config;
Antti Palosaaric01a3592012-08-12 22:27:07 -0300358 dev_dbg(&d->udev->dev, "%s: MT2060\n", __func__);
Antti Palosaari831e0b72011-07-08 23:36:07 -0300359 goto found;
360 } else {
Antti Palosaaric01a3592012-08-12 22:27:07 -0300361 dev_dbg(&d->udev->dev, "%s: MT2060 probe failed=%d - %02x\n",
362 __func__, ret, buf[0]);
Antti Palosaari831e0b72011-07-08 23:36:07 -0300363 }
364
365 /* assume MXL5005S */
Antti Palosaarie9320ec2011-08-03 04:35:30 -0300366 ret = 0;
Antti Palosaari831e0b72011-07-08 23:36:07 -0300367 priv->tuner = TUNER_RTL2830_MXL5005S;
368 rtl2830_config = &rtl28xxu_rtl2830_mxl5005s_config;
Antti Palosaaric01a3592012-08-12 22:27:07 -0300369 dev_dbg(&d->udev->dev, "%s: MXL5005S\n", __func__);
Antti Palosaari831e0b72011-07-08 23:36:07 -0300370 goto found;
371
372found:
373 /* attach demodulator */
Antti Palosaaric01a3592012-08-12 22:27:07 -0300374 adap->fe[0] = dvb_attach(rtl2830_attach, rtl2830_config,
375 &d->i2c_adap);
376 if (adap->fe[0] == NULL) {
Antti Palosaari831e0b72011-07-08 23:36:07 -0300377 ret = -ENODEV;
378 goto err;
379 }
380
381 return ret;
382err:
Antti Palosaaric01a3592012-08-12 22:27:07 -0300383 dev_dbg(&d->udev->dev, "%s: failed=%d\n", __func__, ret);
Antti Palosaari831e0b72011-07-08 23:36:07 -0300384 return ret;
385}
386
Thomas Mair5cf66312012-05-18 14:47:41 -0300387static struct rtl2832_config rtl28xxu_rtl2832_fc0012_config = {
388 .i2c_addr = 0x10, /* 0x20 */
389 .xtal = 28800000,
390 .if_dvbt = 0,
391 .tuner = TUNER_RTL2832_FC0012
392};
393
394static struct rtl2832_config rtl28xxu_rtl2832_fc0013_config = {
395 .i2c_addr = 0x10, /* 0x20 */
396 .xtal = 28800000,
397 .if_dvbt = 0,
398 .tuner = TUNER_RTL2832_FC0013
399};
400
401static int rtl2832u_fc0012_tuner_callback(struct dvb_usb_device *d,
402 int cmd, int arg)
403{
404 int ret;
405 u8 val;
406
Antti Palosaaric01a3592012-08-12 22:27:07 -0300407 dev_dbg(&d->udev->dev, "%s: cmd=%d arg=%d\n", __func__, cmd, arg);
408
Thomas Mair5cf66312012-05-18 14:47:41 -0300409 switch (cmd) {
410 case FC_FE_CALLBACK_VHF_ENABLE:
411 /* set output values */
Thomas Mair40a2d3c2012-05-18 14:47:42 -0300412 ret = rtl28xx_rd_reg(d, SYS_GPIO_OUT_VAL, &val);
Thomas Mair5cf66312012-05-18 14:47:41 -0300413 if (ret)
414 goto err;
415
416 if (arg)
417 val &= 0xbf; /* set GPIO6 low */
418 else
419 val |= 0x40; /* set GPIO6 high */
420
421
Thomas Mair40a2d3c2012-05-18 14:47:42 -0300422 ret = rtl28xx_wr_reg(d, SYS_GPIO_OUT_VAL, val);
Thomas Mair5cf66312012-05-18 14:47:41 -0300423 if (ret)
424 goto err;
425 break;
426 default:
427 ret = -EINVAL;
428 goto err;
429 }
430 return 0;
431
432err:
Antti Palosaaric01a3592012-08-12 22:27:07 -0300433 dev_dbg(&d->udev->dev, "%s: failed=%d\n", __func__, ret);
Thomas Mair5cf66312012-05-18 14:47:41 -0300434 return ret;
435}
436
437
438static int rtl2832u_fc0013_tuner_callback(struct dvb_usb_device *d,
439 int cmd, int arg)
440{
441 /* TODO implement*/
442 return 0;
443}
444
445static int rtl2832u_tuner_callback(struct dvb_usb_device *d, int cmd, int arg)
446{
447 struct rtl28xxu_priv *priv = d->priv;
448
449 switch (priv->tuner) {
450 case TUNER_RTL2832_FC0012:
451 return rtl2832u_fc0012_tuner_callback(d, cmd, arg);
452
453 case TUNER_RTL2832_FC0013:
454 return rtl2832u_fc0013_tuner_callback(d, cmd, arg);
455 default:
456 break;
457 }
458
459 return -ENODEV;
460}
461
462static int rtl2832u_frontend_callback(void *adapter_priv, int component,
463 int cmd, int arg)
464{
465 struct i2c_adapter *adap = adapter_priv;
466 struct dvb_usb_device *d = i2c_get_adapdata(adap);
467
468 switch (component) {
469 case DVB_FRONTEND_COMPONENT_TUNER:
470 return rtl2832u_tuner_callback(d, cmd, arg);
471 default:
472 break;
473 }
474
475 return -EINVAL;
476}
477
Antti Palosaarib5cbaa42011-08-04 13:26:10 -0300478static int rtl2832u_frontend_attach(struct dvb_usb_adapter *adap)
479{
480 int ret;
Antti Palosaaric01a3592012-08-12 22:27:07 -0300481 struct dvb_usb_device *d = adap_to_d(adap);
482 struct rtl28xxu_priv *priv = d_to_priv(d);
Thomas Mair5cf66312012-05-18 14:47:41 -0300483 struct rtl2832_config *rtl2832_config;
Thomas Mair5cf66312012-05-18 14:47:41 -0300484 u8 buf[2], val;
Antti Palosaarib5cbaa42011-08-04 13:26:10 -0300485 /* open RTL2832U/RTL2832 I2C gate */
486 struct rtl28xxu_req req_gate_open = {0x0120, 0x0011, 0x0001, "\x18"};
487 /* close RTL2832U/RTL2832 I2C gate */
488 struct rtl28xxu_req req_gate_close = {0x0120, 0x0011, 0x0001, "\x10"};
Thomas Mair5cf66312012-05-18 14:47:41 -0300489 /* for FC0012 tuner probe */
490 struct rtl28xxu_req req_fc0012 = {0x00c6, CMD_I2C_RD, 1, buf};
491 /* for FC0013 tuner probe */
492 struct rtl28xxu_req req_fc0013 = {0x00c6, CMD_I2C_RD, 1, buf};
493 /* for MT2266 tuner probe */
494 struct rtl28xxu_req req_mt2266 = {0x00c0, CMD_I2C_RD, 1, buf};
Antti Palosaarib5cbaa42011-08-04 13:26:10 -0300495 /* for FC2580 tuner probe */
496 struct rtl28xxu_req req_fc2580 = {0x01ac, CMD_I2C_RD, 1, buf};
Thomas Mair5cf66312012-05-18 14:47:41 -0300497 /* for MT2063 tuner probe */
498 struct rtl28xxu_req req_mt2063 = {0x00c0, CMD_I2C_RD, 1, buf};
499 /* for MAX3543 tuner probe */
500 struct rtl28xxu_req req_max3543 = {0x00c0, CMD_I2C_RD, 1, buf};
501 /* for TUA9001 tuner probe */
502 struct rtl28xxu_req req_tua9001 = {0x7ec0, CMD_I2C_RD, 2, buf};
503 /* for MXL5007T tuner probe */
504 struct rtl28xxu_req req_mxl5007t = {0xd9c0, CMD_I2C_RD, 1, buf};
505 /* for E4000 tuner probe */
506 struct rtl28xxu_req req_e4000 = {0x02c8, CMD_I2C_RD, 1, buf};
507 /* for TDA18272 tuner probe */
508 struct rtl28xxu_req req_tda18272 = {0x00c0, CMD_I2C_RD, 2, buf};
Antti Palosaarib5cbaa42011-08-04 13:26:10 -0300509
Antti Palosaaric01a3592012-08-12 22:27:07 -0300510 dev_dbg(&d->udev->dev, "%s:\n", __func__);
Antti Palosaarib5cbaa42011-08-04 13:26:10 -0300511
Antti Palosaaric01a3592012-08-12 22:27:07 -0300512 ret = rtl28xx_rd_reg(d, SYS_GPIO_DIR, &val);
Antti Palosaarib5cbaa42011-08-04 13:26:10 -0300513 if (ret)
514 goto err;
515
Thomas Mair5cf66312012-05-18 14:47:41 -0300516 val &= 0xbf;
517
Antti Palosaaric01a3592012-08-12 22:27:07 -0300518 ret = rtl28xx_wr_reg(d, SYS_GPIO_DIR, val);
Antti Palosaarib5cbaa42011-08-04 13:26:10 -0300519 if (ret)
520 goto err;
521
Thomas Mair5cf66312012-05-18 14:47:41 -0300522 /* enable as output GPIO3 and GPIO6*/
Antti Palosaaric01a3592012-08-12 22:27:07 -0300523 ret = rtl28xx_rd_reg(d, SYS_GPIO_OUT_EN, &val);
Antti Palosaarib5cbaa42011-08-04 13:26:10 -0300524 if (ret)
525 goto err;
526
Thomas Mair5cf66312012-05-18 14:47:41 -0300527 val |= 0x48;
528
Antti Palosaaric01a3592012-08-12 22:27:07 -0300529 ret = rtl28xx_wr_reg(d, SYS_GPIO_OUT_EN, val);
Thomas Mair5cf66312012-05-18 14:47:41 -0300530 if (ret)
531 goto err;
532
Antti Palosaarib5cbaa42011-08-04 13:26:10 -0300533 /*
534 * Probe used tuner. We need to know used tuner before demod attach
535 * since there is some demod params needed to set according to tuner.
536 */
537
538 /* open demod I2C gate */
Antti Palosaaric01a3592012-08-12 22:27:07 -0300539 ret = rtl28xxu_ctrl_msg(d, &req_gate_open);
Antti Palosaarib5cbaa42011-08-04 13:26:10 -0300540 if (ret)
541 goto err;
542
Thomas Mair5cf66312012-05-18 14:47:41 -0300543 priv->tuner = TUNER_NONE;
544
545 /* check FC0012 ID register; reg=00 val=a1 */
Antti Palosaaric01a3592012-08-12 22:27:07 -0300546 ret = rtl28xxu_ctrl_msg(d, &req_fc0012);
Thomas Mair5cf66312012-05-18 14:47:41 -0300547 if (ret == 0 && buf[0] == 0xa1) {
548 priv->tuner = TUNER_RTL2832_FC0012;
549 rtl2832_config = &rtl28xxu_rtl2832_fc0012_config;
Antti Palosaaric01a3592012-08-12 22:27:07 -0300550 dev_info(&d->udev->dev, "%s: FC0012 tuner found",
551 KBUILD_MODNAME);
Thomas Mair5cf66312012-05-18 14:47:41 -0300552 goto found;
553 }
554
555 /* check FC0013 ID register; reg=00 val=a3 */
Antti Palosaaric01a3592012-08-12 22:27:07 -0300556 ret = rtl28xxu_ctrl_msg(d, &req_fc0013);
Thomas Mair5cf66312012-05-18 14:47:41 -0300557 if (ret == 0 && buf[0] == 0xa3) {
558 priv->tuner = TUNER_RTL2832_FC0013;
559 rtl2832_config = &rtl28xxu_rtl2832_fc0013_config;
Antti Palosaaric01a3592012-08-12 22:27:07 -0300560 dev_info(&d->udev->dev, "%s: FC0013 tuner found",
561 KBUILD_MODNAME);
Thomas Mair5cf66312012-05-18 14:47:41 -0300562 goto found;
563 }
564
565 /* check MT2266 ID register; reg=00 val=85 */
Antti Palosaaric01a3592012-08-12 22:27:07 -0300566 ret = rtl28xxu_ctrl_msg(d, &req_mt2266);
Thomas Mair5cf66312012-05-18 14:47:41 -0300567 if (ret == 0 && buf[0] == 0x85) {
568 priv->tuner = TUNER_RTL2832_MT2266;
569 /* TODO implement tuner */
Antti Palosaaric01a3592012-08-12 22:27:07 -0300570 dev_info(&d->udev->dev, "%s: MT2266 tuner found",
571 KBUILD_MODNAME);
Thomas Mair5cf66312012-05-18 14:47:41 -0300572 goto unsupported;
573 }
574
Antti Palosaarib5cbaa42011-08-04 13:26:10 -0300575 /* check FC2580 ID register; reg=01 val=56 */
Antti Palosaaric01a3592012-08-12 22:27:07 -0300576 ret = rtl28xxu_ctrl_msg(d, &req_fc2580);
Antti Palosaarib5cbaa42011-08-04 13:26:10 -0300577 if (ret == 0 && buf[0] == 0x56) {
578 priv->tuner = TUNER_RTL2832_FC2580;
Thomas Mair5cf66312012-05-18 14:47:41 -0300579 /* TODO implement tuner */
Antti Palosaaric01a3592012-08-12 22:27:07 -0300580 dev_info(&d->udev->dev, "%s: FC2580 tuner found",
581 KBUILD_MODNAME);
Thomas Mair5cf66312012-05-18 14:47:41 -0300582 goto unsupported;
Antti Palosaarib5cbaa42011-08-04 13:26:10 -0300583 }
584
Thomas Mair5cf66312012-05-18 14:47:41 -0300585 /* check MT2063 ID register; reg=00 val=9e || 9c */
Antti Palosaaric01a3592012-08-12 22:27:07 -0300586 ret = rtl28xxu_ctrl_msg(d, &req_mt2063);
Thomas Mair5cf66312012-05-18 14:47:41 -0300587 if (ret == 0 && (buf[0] == 0x9e || buf[0] == 0x9c)) {
588 priv->tuner = TUNER_RTL2832_MT2063;
589 /* TODO implement tuner */
Antti Palosaaric01a3592012-08-12 22:27:07 -0300590 dev_info(&d->udev->dev, "%s: MT2063 tuner found",
591 KBUILD_MODNAME);
Thomas Mair5cf66312012-05-18 14:47:41 -0300592 goto unsupported;
593 }
594
595 /* check MAX3543 ID register; reg=00 val=38 */
Antti Palosaaric01a3592012-08-12 22:27:07 -0300596 ret = rtl28xxu_ctrl_msg(d, &req_max3543);
Thomas Mair5cf66312012-05-18 14:47:41 -0300597 if (ret == 0 && buf[0] == 0x38) {
598 priv->tuner = TUNER_RTL2832_MAX3543;
599 /* TODO implement tuner */
Antti Palosaaric01a3592012-08-12 22:27:07 -0300600 dev_info(&d->udev->dev, "%s: MAX3534 tuner found",
601 KBUILD_MODNAME);
Thomas Mair5cf66312012-05-18 14:47:41 -0300602 goto unsupported;
603 }
604
605 /* check TUA9001 ID register; reg=7e val=2328 */
Antti Palosaaric01a3592012-08-12 22:27:07 -0300606 ret = rtl28xxu_ctrl_msg(d, &req_tua9001);
Thomas Mair5cf66312012-05-18 14:47:41 -0300607 if (ret == 0 && buf[0] == 0x23 && buf[1] == 0x28) {
608 priv->tuner = TUNER_RTL2832_TUA9001;
609 /* TODO implement tuner */
Antti Palosaaric01a3592012-08-12 22:27:07 -0300610 dev_info(&d->udev->dev, "%s: TUA9001 tuner found",
611 KBUILD_MODNAME);
Thomas Mair5cf66312012-05-18 14:47:41 -0300612 goto unsupported;
613 }
614
615 /* check MXL5007R ID register; reg=d9 val=14 */
Antti Palosaaric01a3592012-08-12 22:27:07 -0300616 ret = rtl28xxu_ctrl_msg(d, &req_mxl5007t);
Thomas Mair5cf66312012-05-18 14:47:41 -0300617 if (ret == 0 && buf[0] == 0x14) {
618 priv->tuner = TUNER_RTL2832_MXL5007T;
619 /* TODO implement tuner */
Antti Palosaaric01a3592012-08-12 22:27:07 -0300620 dev_info(&d->udev->dev, "%s: MXL5007T tuner found",
621 KBUILD_MODNAME);
Thomas Mair5cf66312012-05-18 14:47:41 -0300622 goto unsupported;
623 }
624
625 /* check E4000 ID register; reg=02 val=40 */
Antti Palosaaric01a3592012-08-12 22:27:07 -0300626 ret = rtl28xxu_ctrl_msg(d, &req_e4000);
Thomas Mair5cf66312012-05-18 14:47:41 -0300627 if (ret == 0 && buf[0] == 0x40) {
628 priv->tuner = TUNER_RTL2832_E4000;
Antti Palosaari542f6a52012-09-01 21:09:22 -0300629 /* FIXME: do not abuse fc0012 settings */
630 rtl2832_config = &rtl28xxu_rtl2832_fc0012_config;
Antti Palosaaric01a3592012-08-12 22:27:07 -0300631 dev_info(&d->udev->dev, "%s: E4000 tuner found",
632 KBUILD_MODNAME);
Antti Palosaari542f6a52012-09-01 21:09:22 -0300633 goto found;
Thomas Mair5cf66312012-05-18 14:47:41 -0300634 }
635
636 /* check TDA18272 ID register; reg=00 val=c760 */
Antti Palosaaric01a3592012-08-12 22:27:07 -0300637 ret = rtl28xxu_ctrl_msg(d, &req_tda18272);
Thomas Mair5cf66312012-05-18 14:47:41 -0300638 if (ret == 0 && (buf[0] == 0xc7 || buf[1] == 0x60)) {
639 priv->tuner = TUNER_RTL2832_TDA18272;
640 /* TODO implement tuner */
Antti Palosaaric01a3592012-08-12 22:27:07 -0300641 dev_info(&d->udev->dev, "%s: TDA18272 tuner found",
642 KBUILD_MODNAME);
Thomas Mair5cf66312012-05-18 14:47:41 -0300643 goto unsupported;
644 }
645
646unsupported:
Antti Palosaarib5cbaa42011-08-04 13:26:10 -0300647 /* close demod I2C gate */
Antti Palosaaric01a3592012-08-12 22:27:07 -0300648 ret = rtl28xxu_ctrl_msg(d, &req_gate_close);
Antti Palosaarib5cbaa42011-08-04 13:26:10 -0300649 if (ret)
650 goto err;
651
652 /* tuner not found */
Antti Palosaaric01a3592012-08-12 22:27:07 -0300653 dev_dbg(&d->udev->dev, "%s: No compatible tuner found\n", __func__);
Antti Palosaarib5cbaa42011-08-04 13:26:10 -0300654 ret = -ENODEV;
Thomas Mair5cf66312012-05-18 14:47:41 -0300655 return ret;
Antti Palosaarib5cbaa42011-08-04 13:26:10 -0300656
657found:
658 /* close demod I2C gate */
Antti Palosaaric01a3592012-08-12 22:27:07 -0300659 ret = rtl28xxu_ctrl_msg(d, &req_gate_close);
Antti Palosaarib5cbaa42011-08-04 13:26:10 -0300660 if (ret)
661 goto err;
662
663 /* attach demodulator */
Antti Palosaaric01a3592012-08-12 22:27:07 -0300664 adap->fe[0] = dvb_attach(rtl2832_attach, rtl2832_config,
665 &d->i2c_adap);
666 if (adap->fe[0] == NULL) {
Thomas Mair5cf66312012-05-18 14:47:41 -0300667 ret = -ENODEV;
668 goto err;
669 }
670
671 /* set fe callbacks */
Antti Palosaaric01a3592012-08-12 22:27:07 -0300672 adap->fe[0]->callback = rtl2832u_frontend_callback;
Antti Palosaarib5cbaa42011-08-04 13:26:10 -0300673
674 return ret;
Thomas Mair5cf66312012-05-18 14:47:41 -0300675
Antti Palosaarib5cbaa42011-08-04 13:26:10 -0300676err:
Antti Palosaaric01a3592012-08-12 22:27:07 -0300677 dev_dbg(&d->udev->dev, "%s: failed=%d\n", __func__, ret);
Antti Palosaarib5cbaa42011-08-04 13:26:10 -0300678 return ret;
679}
680
Antti Palosaari831e0b72011-07-08 23:36:07 -0300681static struct qt1010_config rtl28xxu_qt1010_config = {
682 .i2c_address = 0x62, /* 0xc4 */
683};
684
685static struct mt2060_config rtl28xxu_mt2060_config = {
686 .i2c_address = 0x60, /* 0xc0 */
687 .clock_out = 0,
688};
689
690static struct mxl5005s_config rtl28xxu_mxl5005s_config = {
691 .i2c_address = 0x63, /* 0xc6 */
692 .if_freq = IF_FREQ_4570000HZ,
693 .xtal_freq = CRYSTAL_FREQ_16000000HZ,
694 .agc_mode = MXL_SINGLE_AGC,
695 .tracking_filter = MXL_TF_C_H,
696 .rssi_enable = MXL_RSSI_ENABLE,
697 .cap_select = MXL_CAP_SEL_ENABLE,
698 .div_out = MXL_DIV_OUT_4,
699 .clock_out = MXL_CLOCK_OUT_DISABLE,
700 .output_load = MXL5005S_IF_OUTPUT_LOAD_200_OHM,
701 .top = MXL5005S_TOP_25P2,
702 .mod_mode = MXL_DIGITAL_MODE,
703 .if_mode = MXL_ZERO_IF,
704 .AgcMasterByte = 0x00,
705};
706
Antti Palosaarib5cbaa42011-08-04 13:26:10 -0300707static int rtl2831u_tuner_attach(struct dvb_usb_adapter *adap)
Antti Palosaari831e0b72011-07-08 23:36:07 -0300708{
709 int ret;
Antti Palosaaric01a3592012-08-12 22:27:07 -0300710 struct dvb_usb_device *d = adap_to_d(adap);
711 struct rtl28xxu_priv *priv = d_to_priv(d);
Antti Palosaari831e0b72011-07-08 23:36:07 -0300712 struct i2c_adapter *rtl2830_tuner_i2c;
Antti Palosaari9935eea2012-01-21 22:26:52 -0300713 struct dvb_frontend *fe;
Antti Palosaari831e0b72011-07-08 23:36:07 -0300714
Antti Palosaaric01a3592012-08-12 22:27:07 -0300715 dev_dbg(&d->udev->dev, "%s:\n", __func__);
Antti Palosaari831e0b72011-07-08 23:36:07 -0300716
717 /* use rtl2830 driver I2C adapter, for more info see rtl2830 driver */
Antti Palosaaric01a3592012-08-12 22:27:07 -0300718 rtl2830_tuner_i2c = rtl2830_get_tuner_i2c_adapter(adap->fe[0]);
Antti Palosaari831e0b72011-07-08 23:36:07 -0300719
720 switch (priv->tuner) {
721 case TUNER_RTL2830_QT1010:
Antti Palosaaric01a3592012-08-12 22:27:07 -0300722 fe = dvb_attach(qt1010_attach, adap->fe[0],
Antti Palosaarifba16b12012-01-21 20:28:38 -0300723 rtl2830_tuner_i2c, &rtl28xxu_qt1010_config);
Antti Palosaari831e0b72011-07-08 23:36:07 -0300724 break;
725 case TUNER_RTL2830_MT2060:
Antti Palosaaric01a3592012-08-12 22:27:07 -0300726 fe = dvb_attach(mt2060_attach, adap->fe[0],
Antti Palosaarifba16b12012-01-21 20:28:38 -0300727 rtl2830_tuner_i2c, &rtl28xxu_mt2060_config,
728 1220);
Antti Palosaari831e0b72011-07-08 23:36:07 -0300729 break;
730 case TUNER_RTL2830_MXL5005S:
Antti Palosaaric01a3592012-08-12 22:27:07 -0300731 fe = dvb_attach(mxl5005s_attach, adap->fe[0],
Antti Palosaari9935eea2012-01-21 22:26:52 -0300732 rtl2830_tuner_i2c, &rtl28xxu_mxl5005s_config);
Antti Palosaari831e0b72011-07-08 23:36:07 -0300733 break;
734 default:
Antti Palosaari9935eea2012-01-21 22:26:52 -0300735 fe = NULL;
Antti Palosaaric01a3592012-08-12 22:27:07 -0300736 dev_err(&d->udev->dev, "%s: unknown tuner=%d\n", KBUILD_MODNAME,
737 priv->tuner);
Antti Palosaari831e0b72011-07-08 23:36:07 -0300738 }
739
740 if (fe == NULL) {
741 ret = -ENODEV;
742 goto err;
743 }
744
745 return 0;
746err:
Antti Palosaaric01a3592012-08-12 22:27:07 -0300747 dev_dbg(&d->udev->dev, "%s: failed=%d\n", __func__, ret);
Antti Palosaari831e0b72011-07-08 23:36:07 -0300748 return ret;
749}
750
Antti Palosaari542f6a52012-09-01 21:09:22 -0300751static const struct e4000_config rtl2832u_e4000_config = {
752 .i2c_addr = 0x64,
753 .clock = 28800000,
754};
755
Antti Palosaarib5cbaa42011-08-04 13:26:10 -0300756static int rtl2832u_tuner_attach(struct dvb_usb_adapter *adap)
757{
758 int ret;
Antti Palosaaric01a3592012-08-12 22:27:07 -0300759 struct dvb_usb_device *d = adap_to_d(adap);
760 struct rtl28xxu_priv *priv = d_to_priv(d);
Antti Palosaari9935eea2012-01-21 22:26:52 -0300761 struct dvb_frontend *fe;
Antti Palosaarib5cbaa42011-08-04 13:26:10 -0300762
Antti Palosaaric01a3592012-08-12 22:27:07 -0300763 dev_dbg(&d->udev->dev, "%s:\n", __func__);
Antti Palosaarib5cbaa42011-08-04 13:26:10 -0300764
765 switch (priv->tuner) {
Thomas Mair5cf66312012-05-18 14:47:41 -0300766 case TUNER_RTL2832_FC0012:
Antti Palosaaric01a3592012-08-12 22:27:07 -0300767 fe = dvb_attach(fc0012_attach, adap->fe[0],
768 &d->i2c_adap, 0xc6>>1, 0, FC_XTAL_28_8_MHZ);
Thomas Mair5cf66312012-05-18 14:47:41 -0300769
770 /* since fc0012 includs reading the signal strength delegate
771 * that to the tuner driver */
Antti Palosaaric01a3592012-08-12 22:27:07 -0300772 adap->fe[0]->ops.read_signal_strength =
773 adap->fe[0]->ops.tuner_ops.get_rf_strength;
Thomas Mair5cf66312012-05-18 14:47:41 -0300774 return 0;
Antti Palosaarib5cbaa42011-08-04 13:26:10 -0300775 break;
Thomas Mair5cf66312012-05-18 14:47:41 -0300776 case TUNER_RTL2832_FC0013:
Antti Palosaaric01a3592012-08-12 22:27:07 -0300777 fe = dvb_attach(fc0013_attach, adap->fe[0],
778 &d->i2c_adap, 0xc6>>1, 0, FC_XTAL_28_8_MHZ);
Thomas Mair5cf66312012-05-18 14:47:41 -0300779
780 /* fc0013 also supports signal strength reading */
Antti Palosaaric01a3592012-08-12 22:27:07 -0300781 adap->fe[0]->ops.read_signal_strength =
782 adap->fe[0]->ops.tuner_ops.get_rf_strength;
Thomas Mair5cf66312012-05-18 14:47:41 -0300783 return 0;
Antti Palosaari542f6a52012-09-01 21:09:22 -0300784 case TUNER_RTL2832_E4000:
785 fe = dvb_attach(e4000_attach, adap->fe[0], &d->i2c_adap,
786 &rtl2832u_e4000_config);
787 break;
Antti Palosaarib5cbaa42011-08-04 13:26:10 -0300788 default:
Antti Palosaari9935eea2012-01-21 22:26:52 -0300789 fe = NULL;
Antti Palosaaric01a3592012-08-12 22:27:07 -0300790 dev_err(&d->udev->dev, "%s: unknown tuner=%d\n", KBUILD_MODNAME,
791 priv->tuner);
Antti Palosaarib5cbaa42011-08-04 13:26:10 -0300792 }
793
794 if (fe == NULL) {
795 ret = -ENODEV;
796 goto err;
797 }
798
799 return 0;
800err:
Antti Palosaaric01a3592012-08-12 22:27:07 -0300801 dev_dbg(&d->udev->dev, "%s: failed=%d\n", __func__, ret);
Antti Palosaarib5cbaa42011-08-04 13:26:10 -0300802 return ret;
803}
804
Antti Palosaaric01a3592012-08-12 22:27:07 -0300805static int rtl28xxu_init(struct dvb_usb_device *d)
806{
807 int ret;
808 u8 val;
809
810 dev_dbg(&d->udev->dev, "%s:\n", __func__);
811
812 /* init USB endpoints */
813 ret = rtl28xx_rd_reg(d, USB_SYSCTL_0, &val);
814 if (ret)
815 goto err;
816
817 /* enable DMA and Full Packet Mode*/
818 val |= 0x09;
819 ret = rtl28xx_wr_reg(d, USB_SYSCTL_0, val);
820 if (ret)
821 goto err;
822
823 /* set EPA maximum packet size to 0x0200 */
824 ret = rtl28xx_wr_regs(d, USB_EPA_MAXPKT, "\x00\x02\x00\x00", 4);
825 if (ret)
826 goto err;
827
828 /* change EPA FIFO length */
829 ret = rtl28xx_wr_regs(d, USB_EPA_FIFO_CFG, "\x14\x00\x00\x00", 4);
830 if (ret)
831 goto err;
832
833 return ret;
834err:
835 dev_dbg(&d->udev->dev, "%s: failed=%d\n", __func__, ret);
836 return ret;
837}
838
Thomas Mair5cf66312012-05-18 14:47:41 -0300839static int rtl2831u_power_ctrl(struct dvb_usb_device *d, int onoff)
Antti Palosaari831e0b72011-07-08 23:36:07 -0300840{
841 int ret;
Antti Palosaari8b036632012-09-01 09:54:43 -0300842 u8 gpio, sys0, epa_ctl[2];
Antti Palosaari831e0b72011-07-08 23:36:07 -0300843
Antti Palosaaric01a3592012-08-12 22:27:07 -0300844 dev_dbg(&d->udev->dev, "%s: onoff=%d\n", __func__, onoff);
Antti Palosaari831e0b72011-07-08 23:36:07 -0300845
846 /* demod adc */
Thomas Mair40a2d3c2012-05-18 14:47:42 -0300847 ret = rtl28xx_rd_reg(d, SYS_SYS0, &sys0);
Antti Palosaari831e0b72011-07-08 23:36:07 -0300848 if (ret)
849 goto err;
850
851 /* tuner power, read GPIOs */
Thomas Mair40a2d3c2012-05-18 14:47:42 -0300852 ret = rtl28xx_rd_reg(d, SYS_GPIO_OUT_VAL, &gpio);
Antti Palosaari831e0b72011-07-08 23:36:07 -0300853 if (ret)
854 goto err;
855
Antti Palosaaric01a3592012-08-12 22:27:07 -0300856 dev_dbg(&d->udev->dev, "%s: RD SYS0=%02x GPIO_OUT_VAL=%02x\n", __func__,
857 sys0, gpio);
Antti Palosaari831e0b72011-07-08 23:36:07 -0300858
859 if (onoff) {
860 gpio |= 0x01; /* GPIO0 = 1 */
861 gpio &= (~0x10); /* GPIO4 = 0 */
Antti Palosaari991452a2012-08-12 22:27:08 -0300862 gpio |= 0x04; /* GPIO2 = 1, LED on */
Antti Palosaari831e0b72011-07-08 23:36:07 -0300863 sys0 = sys0 & 0x0f;
864 sys0 |= 0xe0;
Antti Palosaari8b036632012-09-01 09:54:43 -0300865 epa_ctl[0] = 0x00; /* clear stall */
866 epa_ctl[1] = 0x00; /* clear reset */
Antti Palosaari831e0b72011-07-08 23:36:07 -0300867 } else {
Antti Palosaari831e0b72011-07-08 23:36:07 -0300868 gpio &= (~0x01); /* GPIO0 = 0 */
869 gpio |= 0x10; /* GPIO4 = 1 */
Antti Palosaari991452a2012-08-12 22:27:08 -0300870 gpio &= (~0x04); /* GPIO2 = 1, LED off */
Antti Palosaari831e0b72011-07-08 23:36:07 -0300871 sys0 = sys0 & (~0xc0);
Antti Palosaari8b036632012-09-01 09:54:43 -0300872 epa_ctl[0] = 0x10; /* set stall */
873 epa_ctl[1] = 0x02; /* set reset */
Antti Palosaari831e0b72011-07-08 23:36:07 -0300874 }
875
Antti Palosaaric01a3592012-08-12 22:27:07 -0300876 dev_dbg(&d->udev->dev, "%s: WR SYS0=%02x GPIO_OUT_VAL=%02x\n", __func__,
877 sys0, gpio);
Antti Palosaari831e0b72011-07-08 23:36:07 -0300878
879 /* demod adc */
Thomas Mair40a2d3c2012-05-18 14:47:42 -0300880 ret = rtl28xx_wr_reg(d, SYS_SYS0, sys0);
Antti Palosaari831e0b72011-07-08 23:36:07 -0300881 if (ret)
882 goto err;
883
884 /* tuner power, write GPIOs */
Thomas Mair40a2d3c2012-05-18 14:47:42 -0300885 ret = rtl28xx_wr_reg(d, SYS_GPIO_OUT_VAL, gpio);
Antti Palosaari831e0b72011-07-08 23:36:07 -0300886 if (ret)
887 goto err;
888
Antti Palosaari8b036632012-09-01 09:54:43 -0300889 /* streaming EP: stall & reset */
890 ret = rtl28xx_wr_regs(d, USB_EPA_CTL, epa_ctl, 2);
891 if (ret)
892 goto err;
893
894 if (onoff)
895 usb_clear_halt(d->udev, usb_rcvbulkpipe(d->udev, 0x81));
896
Antti Palosaari831e0b72011-07-08 23:36:07 -0300897 return ret;
898err:
Antti Palosaaric01a3592012-08-12 22:27:07 -0300899 dev_dbg(&d->udev->dev, "%s: failed=%d\n", __func__, ret);
Antti Palosaari831e0b72011-07-08 23:36:07 -0300900 return ret;
901}
902
Thomas Mair5cf66312012-05-18 14:47:41 -0300903static int rtl2832u_power_ctrl(struct dvb_usb_device *d, int onoff)
904{
905 int ret;
906 u8 val;
907
Antti Palosaaric01a3592012-08-12 22:27:07 -0300908 dev_dbg(&d->udev->dev, "%s: onoff=%d\n", __func__, onoff);
Thomas Mair5cf66312012-05-18 14:47:41 -0300909
910 if (onoff) {
911 /* set output values */
Thomas Mair40a2d3c2012-05-18 14:47:42 -0300912 ret = rtl28xx_rd_reg(d, SYS_GPIO_OUT_VAL, &val);
Thomas Mair5cf66312012-05-18 14:47:41 -0300913 if (ret)
914 goto err;
915
916 val |= 0x08;
917 val &= 0xef;
918
Thomas Mair40a2d3c2012-05-18 14:47:42 -0300919 ret = rtl28xx_wr_reg(d, SYS_GPIO_OUT_VAL, val);
Thomas Mair5cf66312012-05-18 14:47:41 -0300920 if (ret)
921 goto err;
922
923 /* demod_ctl_1 */
Thomas Mair40a2d3c2012-05-18 14:47:42 -0300924 ret = rtl28xx_rd_reg(d, SYS_DEMOD_CTL1, &val);
Thomas Mair5cf66312012-05-18 14:47:41 -0300925 if (ret)
926 goto err;
927
928 val &= 0xef;
929
Thomas Mair40a2d3c2012-05-18 14:47:42 -0300930 ret = rtl28xx_wr_reg(d, SYS_DEMOD_CTL1, val);
Thomas Mair5cf66312012-05-18 14:47:41 -0300931 if (ret)
932 goto err;
933
934 /* demod control */
935 /* PLL enable */
Thomas Mair40a2d3c2012-05-18 14:47:42 -0300936 ret = rtl28xx_rd_reg(d, SYS_DEMOD_CTL, &val);
Thomas Mair5cf66312012-05-18 14:47:41 -0300937 if (ret)
938 goto err;
939
940 /* bit 7 to 1 */
941 val |= 0x80;
942
Thomas Mair40a2d3c2012-05-18 14:47:42 -0300943 ret = rtl28xx_wr_reg(d, SYS_DEMOD_CTL, val);
Thomas Mair5cf66312012-05-18 14:47:41 -0300944 if (ret)
945 goto err;
946
Thomas Mair40a2d3c2012-05-18 14:47:42 -0300947 ret = rtl28xx_rd_reg(d, SYS_DEMOD_CTL, &val);
Thomas Mair5cf66312012-05-18 14:47:41 -0300948 if (ret)
949 goto err;
950
951 val |= 0x20;
952
Thomas Mair40a2d3c2012-05-18 14:47:42 -0300953 ret = rtl28xx_wr_reg(d, SYS_DEMOD_CTL, val);
Thomas Mair5cf66312012-05-18 14:47:41 -0300954 if (ret)
955 goto err;
956
957 mdelay(5);
958
959 /*enable ADC_Q and ADC_I */
Thomas Mair40a2d3c2012-05-18 14:47:42 -0300960 ret = rtl28xx_rd_reg(d, SYS_DEMOD_CTL, &val);
Thomas Mair5cf66312012-05-18 14:47:41 -0300961 if (ret)
962 goto err;
963
964 val |= 0x48;
965
Thomas Mair40a2d3c2012-05-18 14:47:42 -0300966 ret = rtl28xx_wr_reg(d, SYS_DEMOD_CTL, val);
Thomas Mair5cf66312012-05-18 14:47:41 -0300967 if (ret)
968 goto err;
969
970
Antti Palosaari8b036632012-09-01 09:54:43 -0300971 /* streaming EP: clear stall & reset */
972 ret = rtl28xx_wr_regs(d, USB_EPA_CTL, "\x00\x00", 2);
973 if (ret)
974 goto err;
975
976 ret = usb_clear_halt(d->udev, usb_rcvbulkpipe(d->udev, 0x81));
977 if (ret)
978 goto err;
Thomas Mair5cf66312012-05-18 14:47:41 -0300979 } else {
980 /* demod_ctl_1 */
Thomas Mair40a2d3c2012-05-18 14:47:42 -0300981 ret = rtl28xx_rd_reg(d, SYS_DEMOD_CTL1, &val);
Thomas Mair5cf66312012-05-18 14:47:41 -0300982 if (ret)
983 goto err;
984
985 val |= 0x0c;
986
Thomas Mair40a2d3c2012-05-18 14:47:42 -0300987 ret = rtl28xx_wr_reg(d, SYS_DEMOD_CTL1, val);
Thomas Mair5cf66312012-05-18 14:47:41 -0300988 if (ret)
989 goto err;
990
991 /* set output values */
Thomas Mair40a2d3c2012-05-18 14:47:42 -0300992 ret = rtl28xx_rd_reg(d, SYS_GPIO_OUT_VAL, &val);
Thomas Mair5cf66312012-05-18 14:47:41 -0300993 if (ret)
994 goto err;
995
996 val |= 0x10;
997
Thomas Mair40a2d3c2012-05-18 14:47:42 -0300998 ret = rtl28xx_wr_reg(d, SYS_GPIO_OUT_VAL, val);
Thomas Mair5cf66312012-05-18 14:47:41 -0300999 if (ret)
1000 goto err;
1001
1002 /* demod control */
Thomas Mair40a2d3c2012-05-18 14:47:42 -03001003 ret = rtl28xx_rd_reg(d, SYS_DEMOD_CTL, &val);
Thomas Mair5cf66312012-05-18 14:47:41 -03001004 if (ret)
1005 goto err;
1006
1007 val &= 0x37;
1008
Thomas Mair40a2d3c2012-05-18 14:47:42 -03001009 ret = rtl28xx_wr_reg(d, SYS_DEMOD_CTL, val);
Thomas Mair5cf66312012-05-18 14:47:41 -03001010 if (ret)
1011 goto err;
1012
Antti Palosaari8b036632012-09-01 09:54:43 -03001013 /* streaming EP: set stall & reset */
1014 ret = rtl28xx_wr_regs(d, USB_EPA_CTL, "\x10\x02", 2);
1015 if (ret)
1016 goto err;
Thomas Mair5cf66312012-05-18 14:47:41 -03001017 }
1018
1019 return ret;
1020err:
Antti Palosaaric01a3592012-08-12 22:27:07 -03001021 dev_dbg(&d->udev->dev, "%s: failed=%d\n", __func__, ret);
Thomas Mair5cf66312012-05-18 14:47:41 -03001022 return ret;
1023}
1024
1025
Antti Palosaarib5cbaa42011-08-04 13:26:10 -03001026static int rtl2831u_rc_query(struct dvb_usb_device *d)
Antti Palosaari831e0b72011-07-08 23:36:07 -03001027{
Antti Palosaarib5cbaa42011-08-04 13:26:10 -03001028 int ret, i;
1029 struct rtl28xxu_priv *priv = d->priv;
Antti Palosaari831e0b72011-07-08 23:36:07 -03001030 u8 buf[5];
1031 u32 rc_code;
Antti Palosaarib5cbaa42011-08-04 13:26:10 -03001032 struct rtl28xxu_reg_val rc_nec_tab[] = {
1033 { 0x3033, 0x80 },
1034 { 0x3020, 0x43 },
1035 { 0x3021, 0x16 },
1036 { 0x3022, 0x16 },
1037 { 0x3023, 0x5a },
1038 { 0x3024, 0x2d },
1039 { 0x3025, 0x16 },
1040 { 0x3026, 0x01 },
1041 { 0x3028, 0xb0 },
1042 { 0x3029, 0x04 },
1043 { 0x302c, 0x88 },
1044 { 0x302e, 0x13 },
1045 { 0x3030, 0xdf },
1046 { 0x3031, 0x05 },
1047 };
1048
1049 /* init remote controller */
1050 if (!priv->rc_active) {
1051 for (i = 0; i < ARRAY_SIZE(rc_nec_tab); i++) {
Thomas Mair40a2d3c2012-05-18 14:47:42 -03001052 ret = rtl28xx_wr_reg(d, rc_nec_tab[i].reg,
Antti Palosaari9935eea2012-01-21 22:26:52 -03001053 rc_nec_tab[i].val);
Antti Palosaarib5cbaa42011-08-04 13:26:10 -03001054 if (ret)
1055 goto err;
1056 }
1057 priv->rc_active = true;
1058 }
Antti Palosaari831e0b72011-07-08 23:36:07 -03001059
1060 ret = rtl2831_rd_regs(d, SYS_IRRC_RP, buf, 5);
1061 if (ret)
1062 goto err;
1063
1064 if (buf[4] & 0x01) {
1065 if (buf[2] == (u8) ~buf[3]) {
1066 if (buf[0] == (u8) ~buf[1]) {
1067 /* NEC standard (16 bit) */
1068 rc_code = buf[0] << 8 | buf[2];
1069 } else {
1070 /* NEC extended (24 bit) */
1071 rc_code = buf[0] << 16 |
Antti Palosaari9935eea2012-01-21 22:26:52 -03001072 buf[1] << 8 | buf[2];
Antti Palosaari831e0b72011-07-08 23:36:07 -03001073 }
1074 } else {
1075 /* NEC full (32 bit) */
1076 rc_code = buf[0] << 24 | buf[1] << 16 |
1077 buf[2] << 8 | buf[3];
1078 }
1079
1080 rc_keydown(d->rc_dev, rc_code, 0);
1081
Thomas Mair40a2d3c2012-05-18 14:47:42 -03001082 ret = rtl28xx_wr_reg(d, SYS_IRRC_SR, 1);
Antti Palosaari831e0b72011-07-08 23:36:07 -03001083 if (ret)
1084 goto err;
1085
1086 /* repeated intentionally to avoid extra keypress */
Thomas Mair40a2d3c2012-05-18 14:47:42 -03001087 ret = rtl28xx_wr_reg(d, SYS_IRRC_SR, 1);
Antti Palosaari831e0b72011-07-08 23:36:07 -03001088 if (ret)
1089 goto err;
1090 }
1091
1092 return ret;
1093err:
Antti Palosaaric01a3592012-08-12 22:27:07 -03001094 dev_dbg(&d->udev->dev, "%s: failed=%d\n", __func__, ret);
Antti Palosaari831e0b72011-07-08 23:36:07 -03001095 return ret;
1096}
1097
Antti Palosaaric01a3592012-08-12 22:27:07 -03001098static int rtl2831u_get_rc_config(struct dvb_usb_device *d,
1099 struct dvb_usb_rc *rc)
1100{
1101 rc->map_name = RC_MAP_EMPTY;
1102 rc->allowed_protos = RC_TYPE_NEC;
1103 rc->query = rtl2831u_rc_query;
1104 rc->interval = 400;
1105
1106 return 0;
1107}
1108
Antti Palosaarib5cbaa42011-08-04 13:26:10 -03001109static int rtl2832u_rc_query(struct dvb_usb_device *d)
1110{
1111 int ret, i;
1112 struct rtl28xxu_priv *priv = d->priv;
1113 u8 buf[128];
1114 int len;
1115 struct rtl28xxu_reg_val rc_nec_tab[] = {
Antti Palosaari9935eea2012-01-21 22:26:52 -03001116 { IR_RX_CTRL, 0x20 },
1117 { IR_RX_BUF_CTRL, 0x80 },
1118 { IR_RX_IF, 0xff },
1119 { IR_RX_IE, 0xff },
1120 { IR_MAX_DURATION0, 0xd0 },
1121 { IR_MAX_DURATION1, 0x07 },
1122 { IR_IDLE_LEN0, 0xc0 },
1123 { IR_IDLE_LEN1, 0x00 },
1124 { IR_GLITCH_LEN, 0x03 },
1125 { IR_RX_CLK, 0x09 },
1126 { IR_RX_CFG, 0x1c },
1127 { IR_MAX_H_TOL_LEN, 0x1e },
1128 { IR_MAX_L_TOL_LEN, 0x1e },
1129 { IR_RX_CTRL, 0x80 },
Antti Palosaarib5cbaa42011-08-04 13:26:10 -03001130 };
1131
1132 /* init remote controller */
1133 if (!priv->rc_active) {
1134 for (i = 0; i < ARRAY_SIZE(rc_nec_tab); i++) {
Thomas Mair40a2d3c2012-05-18 14:47:42 -03001135 ret = rtl28xx_wr_reg(d, rc_nec_tab[i].reg,
Antti Palosaari9935eea2012-01-21 22:26:52 -03001136 rc_nec_tab[i].val);
Antti Palosaarib5cbaa42011-08-04 13:26:10 -03001137 if (ret)
1138 goto err;
1139 }
1140 priv->rc_active = true;
1141 }
1142
Thomas Mair40a2d3c2012-05-18 14:47:42 -03001143 ret = rtl28xx_rd_reg(d, IR_RX_IF, &buf[0]);
Antti Palosaarib5cbaa42011-08-04 13:26:10 -03001144 if (ret)
1145 goto err;
1146
1147 if (buf[0] != 0x83)
1148 goto exit;
1149
Thomas Mair40a2d3c2012-05-18 14:47:42 -03001150 ret = rtl28xx_rd_reg(d, IR_RX_BC, &buf[0]);
Antti Palosaarib5cbaa42011-08-04 13:26:10 -03001151 if (ret)
1152 goto err;
1153
1154 len = buf[0];
1155 ret = rtl2831_rd_regs(d, IR_RX_BUF, buf, len);
1156
1157 /* TODO: pass raw IR to Kernel IR decoder */
1158
Thomas Mair40a2d3c2012-05-18 14:47:42 -03001159 ret = rtl28xx_wr_reg(d, IR_RX_IF, 0x03);
1160 ret = rtl28xx_wr_reg(d, IR_RX_BUF_CTRL, 0x80);
1161 ret = rtl28xx_wr_reg(d, IR_RX_CTRL, 0x80);
Antti Palosaarib5cbaa42011-08-04 13:26:10 -03001162
1163exit:
1164 return ret;
1165err:
Antti Palosaaric01a3592012-08-12 22:27:07 -03001166 dev_dbg(&d->udev->dev, "%s: failed=%d\n", __func__, ret);
Antti Palosaarib5cbaa42011-08-04 13:26:10 -03001167 return ret;
1168}
1169
Antti Palosaaric01a3592012-08-12 22:27:07 -03001170static int rtl2832u_get_rc_config(struct dvb_usb_device *d,
1171 struct dvb_usb_rc *rc)
1172{
1173 rc->map_name = RC_MAP_EMPTY;
1174 rc->allowed_protos = RC_TYPE_NEC;
1175 rc->query = rtl2832u_rc_query;
1176 rc->interval = 400;
Antti Palosaarib5cbaa42011-08-04 13:26:10 -03001177
Antti Palosaaric01a3592012-08-12 22:27:07 -03001178 return 0;
1179}
Antti Palosaarib5cbaa42011-08-04 13:26:10 -03001180
Antti Palosaaric01a3592012-08-12 22:27:07 -03001181static const struct dvb_usb_device_properties rtl2831u_props = {
1182 .driver_name = KBUILD_MODNAME,
1183 .owner = THIS_MODULE,
1184 .adapter_nr = adapter_nr,
1185 .size_of_priv = sizeof(struct rtl28xxu_priv),
Antti Palosaari831e0b72011-07-08 23:36:07 -03001186
Antti Palosaaric01a3592012-08-12 22:27:07 -03001187 .power_ctrl = rtl2831u_power_ctrl,
1188 .i2c_algo = &rtl28xxu_i2c_algo,
1189 .frontend_attach = rtl2831u_frontend_attach,
1190 .tuner_attach = rtl2831u_tuner_attach,
1191 .init = rtl28xxu_init,
1192 .get_rc_config = rtl2831u_get_rc_config,
Antti Palosaari831e0b72011-07-08 23:36:07 -03001193
Antti Palosaaric01a3592012-08-12 22:27:07 -03001194 .num_adapters = 1,
1195 .adapter = {
1196 {
1197 .stream = DVB_USB_STREAM_BULK(0x81, 6, 8 * 512),
Antti Palosaari831e0b72011-07-08 23:36:07 -03001198 },
Antti Palosaari831e0b72011-07-08 23:36:07 -03001199 },
Antti Palosaaric01a3592012-08-12 22:27:07 -03001200};
Antti Palosaarib5cbaa42011-08-04 13:26:10 -03001201
Antti Palosaaric01a3592012-08-12 22:27:07 -03001202static const struct dvb_usb_device_properties rtl2832u_props = {
1203 .driver_name = KBUILD_MODNAME,
1204 .owner = THIS_MODULE,
1205 .adapter_nr = adapter_nr,
1206 .size_of_priv = sizeof(struct rtl28xxu_priv),
Antti Palosaarib5cbaa42011-08-04 13:26:10 -03001207
Antti Palosaaric01a3592012-08-12 22:27:07 -03001208 .power_ctrl = rtl2832u_power_ctrl,
1209 .i2c_algo = &rtl28xxu_i2c_algo,
1210 .frontend_attach = rtl2832u_frontend_attach,
1211 .tuner_attach = rtl2832u_tuner_attach,
1212 .init = rtl28xxu_init,
1213 .get_rc_config = rtl2832u_get_rc_config,
Antti Palosaarib5cbaa42011-08-04 13:26:10 -03001214
Antti Palosaaric01a3592012-08-12 22:27:07 -03001215 .num_adapters = 1,
1216 .adapter = {
1217 {
1218 .stream = DVB_USB_STREAM_BULK(0x81, 6, 8 * 512),
Antti Palosaarib5cbaa42011-08-04 13:26:10 -03001219 },
Antti Palosaarib5cbaa42011-08-04 13:26:10 -03001220 },
Antti Palosaari831e0b72011-07-08 23:36:07 -03001221};
1222
Antti Palosaaric01a3592012-08-12 22:27:07 -03001223static const struct usb_device_id rtl28xxu_id_table[] = {
1224 { DVB_USB_DEVICE(USB_VID_REALTEK, USB_PID_REALTEK_RTL2831U,
1225 &rtl2831u_props, "Realtek RTL2831U reference design", NULL) },
1226 { DVB_USB_DEVICE(USB_VID_WIDEVIEW, USB_PID_FREECOM_DVBT,
1227 &rtl2831u_props, "Freecom USB2.0 DVB-T", NULL) },
1228 { DVB_USB_DEVICE(USB_VID_WIDEVIEW, USB_PID_FREECOM_DVBT_2,
1229 &rtl2831u_props, "Freecom USB2.0 DVB-T", NULL) },
Antti Palosaari831e0b72011-07-08 23:36:07 -03001230
Antti Palosaaric01a3592012-08-12 22:27:07 -03001231 { DVB_USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_T_STICK_BLACK_REV1,
1232 &rtl2832u_props, "Terratec Cinergy T Stick Black", NULL) },
1233 { DVB_USB_DEVICE(USB_VID_GTEK, USB_PID_DELOCK_USB2_DVBT,
1234 &rtl2832u_props, "G-Tek Electronics Group Lifeview LV5TDLX DVB-T", NULL) },
1235 { DVB_USB_DEVICE(USB_VID_TERRATEC, USB_PID_NOXON_DAB_STICK,
1236 &rtl2832u_props, "NOXON DAB/DAB+ USB dongle", NULL) },
Antti Palosaari542f6a52012-09-01 21:09:22 -03001237 { DVB_USB_DEVICE(USB_VID_REALTEK, 0x2838,
1238 &rtl2832u_props, "Realtek RTL2832U reference design", NULL) },
Philipp Dreimann6d608052012-09-02 19:30:54 -03001239 { DVB_USB_DEVICE(USB_VID_GTEK, USB_PID_TREKSTOR_TERRES_2_0,
1240 &rtl2832u_props, "Trekstor DVB-T Stick Terres 2.0", NULL) },
Antti Palosaaric01a3592012-08-12 22:27:07 -03001241 { }
1242};
1243MODULE_DEVICE_TABLE(usb, rtl28xxu_id_table);
Antti Palosaari831e0b72011-07-08 23:36:07 -03001244
Antti Palosaaric01a3592012-08-12 22:27:07 -03001245static struct usb_driver rtl28xxu_usb_driver = {
1246 .name = KBUILD_MODNAME,
1247 .id_table = rtl28xxu_id_table,
1248 .probe = dvb_usbv2_probe,
1249 .disconnect = dvb_usbv2_disconnect,
1250 .suspend = dvb_usbv2_suspend,
1251 .resume = dvb_usbv2_resume,
Antti Palosaari78fa5902012-08-14 22:21:09 -03001252 .reset_resume = dvb_usbv2_reset_resume,
Antti Palosaaric01a3592012-08-12 22:27:07 -03001253 .no_dynamic_id = 1,
1254 .soft_unbind = 1,
Antti Palosaari831e0b72011-07-08 23:36:07 -03001255};
1256
Antti Palosaaric01a3592012-08-12 22:27:07 -03001257module_usb_driver(rtl28xxu_usb_driver);
Antti Palosaari831e0b72011-07-08 23:36:07 -03001258
1259MODULE_DESCRIPTION("Realtek RTL28xxU DVB USB driver");
1260MODULE_AUTHOR("Antti Palosaari <crope@iki.fi>");
Thomas Mair5cf66312012-05-18 14:47:41 -03001261MODULE_AUTHOR("Thomas Mair <thomas.mair86@googlemail.com>");
Antti Palosaari831e0b72011-07-08 23:36:07 -03001262MODULE_LICENSE("GPL");