blob: 9578a6761f1bc72230eaed6a8b35500898ffb972 [file] [log] [blame]
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001/* DVB USB framework compliant Linux driver for the
Igor M. Liplianin2f30fb42011-02-25 18:41:23 -03002 * DVBWorld DVB-S 2101, 2102, DVB-S2 2104, DVB-C 3101,
Igor M. Liplianin955d00a2012-05-08 03:53:17 -03003 * TeVii S600, S630, S650, S660, S480, S421, S632
Igor M. Liplianin2f30fb42011-02-25 18:41:23 -03004 * Prof 1100, 7500,
Igor M. Liplianind2ffc442011-02-25 18:41:22 -03005 * Geniatech SU3000 Cards
Igor M. Liplianin955d00a2012-05-08 03:53:17 -03006 * Copyright (C) 2008-2012 Igor M. Liplianin (liplianin@me.by)
Igor M. Liplianin2f30fb42011-02-25 18:41:23 -03007 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation, version 2.
11 *
12 * see Documentation/dvb/README.dvb-usb for more information
13 */
Igor M Liplianin7fd48282008-07-20 08:05:50 -030014#include "dw2102.h"
Igor M. Liplianin21b007b2008-09-17 19:19:19 -030015#include "si21xx.h"
Igor M Liplianin7fd48282008-07-20 08:05:50 -030016#include "stv0299.h"
17#include "z0194a.h"
Igor M. Liplianin8a4949b2008-10-05 09:11:21 -030018#include "stv0288.h"
19#include "stb6000.h"
20#include "eds1547.h"
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -030021#include "cx24116.h"
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -030022#include "tda1002x.h"
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -030023#include "mt312.h"
24#include "zl10039.h"
Konstantin Dimitrov73f0af42012-12-23 19:25:38 -030025#include "ts2020.h"
Igor M. Liplianin141cc352009-11-27 14:37:35 -030026#include "ds3000.h"
27#include "stv0900.h"
28#include "stv6110.h"
29#include "stb6100.h"
30#include "stb6100_proc.h"
Igor M. Liplianin955d00a2012-05-08 03:53:17 -030031#include "m88rs2000.h"
Igor M. Liplianinb858c332012-12-28 19:40:33 -030032#include "ts2020.h"
Igor M Liplianin7fd48282008-07-20 08:05:50 -030033
34#ifndef USB_PID_DW2102
35#define USB_PID_DW2102 0x2102
36#endif
37
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -030038#ifndef USB_PID_DW2104
39#define USB_PID_DW2104 0x2104
40#endif
41
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -030042#ifndef USB_PID_DW3101
43#define USB_PID_DW3101 0x3101
44#endif
45
Igor M. Liplianin4cc0edf2008-11-05 22:12:56 -030046#ifndef USB_PID_CINERGY_S
47#define USB_PID_CINERGY_S 0x0064
48#endif
49
Igor M. Liplianin141cc352009-11-27 14:37:35 -030050#ifndef USB_PID_TEVII_S630
51#define USB_PID_TEVII_S630 0xd630
52#endif
53
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -030054#ifndef USB_PID_TEVII_S650
55#define USB_PID_TEVII_S650 0xd650
56#endif
57
Igor M. Liplianin141cc352009-11-27 14:37:35 -030058#ifndef USB_PID_TEVII_S660
59#define USB_PID_TEVII_S660 0xd660
60#endif
61
Igor M. Liplianine8f50552011-02-25 18:41:23 -030062#ifndef USB_PID_TEVII_S480_1
63#define USB_PID_TEVII_S480_1 0xd481
64#endif
65
66#ifndef USB_PID_TEVII_S480_2
67#define USB_PID_TEVII_S480_2 0xd482
68#endif
69
Igor M. Liplianin141cc352009-11-27 14:37:35 -030070#ifndef USB_PID_PROF_1100
71#define USB_PID_PROF_1100 0xb012
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -030072#endif
73
Igor M. Liplianin955d00a2012-05-08 03:53:17 -030074#ifndef USB_PID_TEVII_S421
75#define USB_PID_TEVII_S421 0xd421
76#endif
77
78#ifndef USB_PID_TEVII_S632
79#define USB_PID_TEVII_S632 0xd632
80#endif
81
Igor M. Liplianin21b007b2008-09-17 19:19:19 -030082#define DW210X_READ_MSG 0
83#define DW210X_WRITE_MSG 1
Igor M Liplianin7fd48282008-07-20 08:05:50 -030084
85#define REG_1F_SYMBOLRATE_BYTE0 0x1f
86#define REG_20_SYMBOLRATE_BYTE1 0x20
87#define REG_21_SYMBOLRATE_BYTE2 0x21
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -030088/* on my own*/
Igor M Liplianin7fd48282008-07-20 08:05:50 -030089#define DW2102_VOLTAGE_CTRL (0x1800)
Igor M. Liplianind2ffc442011-02-25 18:41:22 -030090#define SU3000_STREAM_CTRL (0x1900)
Igor M Liplianin7fd48282008-07-20 08:05:50 -030091#define DW2102_RC_QUERY (0x1a00)
Igor M. Liplianinfa8bae12011-02-25 18:41:22 -030092#define DW2102_LED_CTRL (0x1b00)
Igor M Liplianin7fd48282008-07-20 08:05:50 -030093
Rémi Cardona68236272012-09-28 08:59:32 -030094#define DW2101_FIRMWARE "dvb-usb-dw2101.fw"
95#define DW2102_FIRMWARE "dvb-usb-dw2102.fw"
96#define DW2104_FIRMWARE "dvb-usb-dw2104.fw"
97#define DW3101_FIRMWARE "dvb-usb-dw3101.fw"
98#define S630_FIRMWARE "dvb-usb-s630.fw"
99#define S660_FIRMWARE "dvb-usb-s660.fw"
100#define P1100_FIRMWARE "dvb-usb-p1100.fw"
101#define P7500_FIRMWARE "dvb-usb-p7500.fw"
102
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300103#define err_str "did not find the firmware file. (%s) " \
104 "Please see linux/Documentation/dvb/ for more details " \
105 "on firmware-problems."
106
Mauro Carvalho Chehab2f4f58d2010-11-17 15:46:09 -0300107struct rc_map_dvb_usb_table_table {
108 struct rc_map_table *rc_keys;
Igor M. Liplianinb42e1d72009-06-14 19:41:22 -0300109 int rc_keys_size;
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300110};
111
Igor M. Liplianind2ffc442011-02-25 18:41:22 -0300112struct su3000_state {
113 u8 initialized;
114};
115
Igor M. Liplianin52c506e2011-02-25 18:41:23 -0300116struct s6x0_state {
117 int (*old_set_voltage)(struct dvb_frontend *f, fe_sec_voltage_t v);
118};
119
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300120/* debug */
121static int dvb_usb_dw2102_debug;
122module_param_named(debug, dvb_usb_dw2102_debug, int, 0644);
Igor M. Liplianin8a8dad72009-06-13 08:10:24 -0300123MODULE_PARM_DESC(debug, "set debugging level (1=info 2=xfer 4=rc(or-able))."
124 DVB_USB_DEBUG_STATUS);
125
Igor M. Liplianinb42e1d72009-06-14 19:41:22 -0300126/* keymaps */
127static int ir_keymap;
128module_param_named(keymap, ir_keymap, int, 0644);
Igor M. Liplianinfeb16e92011-02-25 18:41:22 -0300129MODULE_PARM_DESC(keymap, "set keymap 0=default 1=dvbworld 2=tevii 3=tbs ..."
130 " 256=none");
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300131
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300132/* demod probe */
133static int demod_probe = 1;
134module_param_named(demod, demod_probe, int, 0644);
135MODULE_PARM_DESC(demod, "demod to probe (1=cx24116 2=stv0903+stv6110 "
136 "4=stv0903+stb6100(or-able)).");
137
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300138DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
139
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300140static int dw210x_op_rw(struct usb_device *dev, u8 request, u16 value,
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300141 u16 index, u8 * data, u16 len, int flags)
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300142{
143 int ret;
Florian Micklerb47b8502011-03-21 15:33:44 -0300144 u8 *u8buf;
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300145 unsigned int pipe = (flags == DW210X_READ_MSG) ?
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300146 usb_rcvctrlpipe(dev, 0) : usb_sndctrlpipe(dev, 0);
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300147 u8 request_type = (flags == DW210X_READ_MSG) ? USB_DIR_IN : USB_DIR_OUT;
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300148
Florian Micklerb47b8502011-03-21 15:33:44 -0300149 u8buf = kmalloc(len, GFP_KERNEL);
150 if (!u8buf)
151 return -ENOMEM;
152
153
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300154 if (flags == DW210X_WRITE_MSG)
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300155 memcpy(u8buf, data, len);
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300156 ret = usb_control_msg(dev, pipe, request, request_type | USB_TYPE_VENDOR,
157 value, index , u8buf, len, 2000);
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300158
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300159 if (flags == DW210X_READ_MSG)
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300160 memcpy(data, u8buf, len);
Florian Micklerb47b8502011-03-21 15:33:44 -0300161
162 kfree(u8buf);
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300163 return ret;
164}
165
166/* I2C */
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300167static int dw2102_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],
168 int num)
169{
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -0300170 struct dvb_usb_device *d = i2c_get_adapdata(adap);
Hans Verkuild51dbec2012-04-20 03:30:11 -0300171 int i = 0;
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300172 u8 buf6[] = {0x2c, 0x05, 0xc0, 0, 0, 0, 0};
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300173 u16 value;
174
175 if (!d)
176 return -ENODEV;
177 if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
178 return -EAGAIN;
179
180 switch (num) {
181 case 2:
182 /* read stv0299 register */
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300183 value = msg[0].buf[0];/* register */
184 for (i = 0; i < msg[1].len; i++) {
Hans Verkuild51dbec2012-04-20 03:30:11 -0300185 dw210x_op_rw(d->udev, 0xb5, value + i, 0,
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300186 buf6, 2, DW210X_READ_MSG);
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300187 msg[1].buf[i] = buf6[0];
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300188 }
189 break;
190 case 1:
191 switch (msg[0].addr) {
192 case 0x68:
193 /* write to stv0299 register */
194 buf6[0] = 0x2a;
195 buf6[1] = msg[0].buf[0];
196 buf6[2] = msg[0].buf[1];
Hans Verkuild51dbec2012-04-20 03:30:11 -0300197 dw210x_op_rw(d->udev, 0xb2, 0, 0,
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300198 buf6, 3, DW210X_WRITE_MSG);
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300199 break;
200 case 0x60:
201 if (msg[0].flags == 0) {
202 /* write to tuner pll */
203 buf6[0] = 0x2c;
204 buf6[1] = 5;
205 buf6[2] = 0xc0;
206 buf6[3] = msg[0].buf[0];
207 buf6[4] = msg[0].buf[1];
208 buf6[5] = msg[0].buf[2];
209 buf6[6] = msg[0].buf[3];
Hans Verkuild51dbec2012-04-20 03:30:11 -0300210 dw210x_op_rw(d->udev, 0xb2, 0, 0,
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300211 buf6, 7, DW210X_WRITE_MSG);
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300212 } else {
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300213 /* read from tuner */
Hans Verkuild51dbec2012-04-20 03:30:11 -0300214 dw210x_op_rw(d->udev, 0xb5, 0, 0,
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300215 buf6, 1, DW210X_READ_MSG);
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300216 msg[0].buf[0] = buf6[0];
217 }
218 break;
219 case (DW2102_RC_QUERY):
Hans Verkuild51dbec2012-04-20 03:30:11 -0300220 dw210x_op_rw(d->udev, 0xb8, 0, 0,
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300221 buf6, 2, DW210X_READ_MSG);
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300222 msg[0].buf[0] = buf6[0];
223 msg[0].buf[1] = buf6[1];
224 break;
225 case (DW2102_VOLTAGE_CTRL):
226 buf6[0] = 0x30;
227 buf6[1] = msg[0].buf[0];
Hans Verkuild51dbec2012-04-20 03:30:11 -0300228 dw210x_op_rw(d->udev, 0xb2, 0, 0,
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300229 buf6, 2, DW210X_WRITE_MSG);
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300230 break;
231 }
232
233 break;
234 }
235
236 mutex_unlock(&d->i2c_mutex);
237 return num;
238}
239
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300240static int dw2102_serit_i2c_transfer(struct i2c_adapter *adap,
241 struct i2c_msg msg[], int num)
242{
243 struct dvb_usb_device *d = i2c_get_adapdata(adap);
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300244 u8 buf6[] = {0, 0, 0, 0, 0, 0, 0};
245
246 if (!d)
247 return -ENODEV;
248 if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
249 return -EAGAIN;
250
251 switch (num) {
252 case 2:
253 /* read si2109 register by number */
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300254 buf6[0] = msg[0].addr << 1;
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300255 buf6[1] = msg[0].len;
256 buf6[2] = msg[0].buf[0];
Hans Verkuild51dbec2012-04-20 03:30:11 -0300257 dw210x_op_rw(d->udev, 0xc2, 0, 0,
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300258 buf6, msg[0].len + 2, DW210X_WRITE_MSG);
259 /* read si2109 register */
Hans Verkuild51dbec2012-04-20 03:30:11 -0300260 dw210x_op_rw(d->udev, 0xc3, 0xd0, 0,
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300261 buf6, msg[1].len + 2, DW210X_READ_MSG);
262 memcpy(msg[1].buf, buf6 + 2, msg[1].len);
263
264 break;
265 case 1:
266 switch (msg[0].addr) {
267 case 0x68:
268 /* write to si2109 register */
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300269 buf6[0] = msg[0].addr << 1;
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300270 buf6[1] = msg[0].len;
271 memcpy(buf6 + 2, msg[0].buf, msg[0].len);
Hans Verkuild51dbec2012-04-20 03:30:11 -0300272 dw210x_op_rw(d->udev, 0xc2, 0, 0, buf6,
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300273 msg[0].len + 2, DW210X_WRITE_MSG);
274 break;
275 case(DW2102_RC_QUERY):
Hans Verkuild51dbec2012-04-20 03:30:11 -0300276 dw210x_op_rw(d->udev, 0xb8, 0, 0,
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300277 buf6, 2, DW210X_READ_MSG);
278 msg[0].buf[0] = buf6[0];
279 msg[0].buf[1] = buf6[1];
280 break;
281 case(DW2102_VOLTAGE_CTRL):
282 buf6[0] = 0x30;
283 buf6[1] = msg[0].buf[0];
Hans Verkuild51dbec2012-04-20 03:30:11 -0300284 dw210x_op_rw(d->udev, 0xb2, 0, 0,
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300285 buf6, 2, DW210X_WRITE_MSG);
286 break;
287 }
288 break;
289 }
290
291 mutex_unlock(&d->i2c_mutex);
292 return num;
293}
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -0300294
Igor M. Liplianin8a4949b2008-10-05 09:11:21 -0300295static int dw2102_earda_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], int num)
296{
297 struct dvb_usb_device *d = i2c_get_adapdata(adap);
Igor M. Liplianin8a4949b2008-10-05 09:11:21 -0300298
299 if (!d)
300 return -ENODEV;
301 if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
302 return -EAGAIN;
303
304 switch (num) {
305 case 2: {
306 /* read */
307 /* first write first register number */
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -0300308 u8 ibuf[msg[1].len + 2], obuf[3];
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300309 obuf[0] = msg[0].addr << 1;
Igor M. Liplianin8a4949b2008-10-05 09:11:21 -0300310 obuf[1] = msg[0].len;
311 obuf[2] = msg[0].buf[0];
Hans Verkuild51dbec2012-04-20 03:30:11 -0300312 dw210x_op_rw(d->udev, 0xc2, 0, 0,
Igor M. Liplianin8a4949b2008-10-05 09:11:21 -0300313 obuf, msg[0].len + 2, DW210X_WRITE_MSG);
314 /* second read registers */
Hans Verkuild51dbec2012-04-20 03:30:11 -0300315 dw210x_op_rw(d->udev, 0xc3, 0xd1 , 0,
Igor M. Liplianin8a4949b2008-10-05 09:11:21 -0300316 ibuf, msg[1].len + 2, DW210X_READ_MSG);
317 memcpy(msg[1].buf, ibuf + 2, msg[1].len);
318
319 break;
320 }
321 case 1:
322 switch (msg[0].addr) {
323 case 0x68: {
324 /* write to register */
325 u8 obuf[msg[0].len + 2];
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300326 obuf[0] = msg[0].addr << 1;
Igor M. Liplianin8a4949b2008-10-05 09:11:21 -0300327 obuf[1] = msg[0].len;
328 memcpy(obuf + 2, msg[0].buf, msg[0].len);
Hans Verkuild51dbec2012-04-20 03:30:11 -0300329 dw210x_op_rw(d->udev, 0xc2, 0, 0,
Igor M. Liplianin8a4949b2008-10-05 09:11:21 -0300330 obuf, msg[0].len + 2, DW210X_WRITE_MSG);
331 break;
332 }
333 case 0x61: {
334 /* write to tuner */
335 u8 obuf[msg[0].len + 2];
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300336 obuf[0] = msg[0].addr << 1;
Igor M. Liplianin8a4949b2008-10-05 09:11:21 -0300337 obuf[1] = msg[0].len;
338 memcpy(obuf + 2, msg[0].buf, msg[0].len);
Hans Verkuild51dbec2012-04-20 03:30:11 -0300339 dw210x_op_rw(d->udev, 0xc2, 0, 0,
Igor M. Liplianin8a4949b2008-10-05 09:11:21 -0300340 obuf, msg[0].len + 2, DW210X_WRITE_MSG);
341 break;
342 }
343 case(DW2102_RC_QUERY): {
344 u8 ibuf[2];
Hans Verkuild51dbec2012-04-20 03:30:11 -0300345 dw210x_op_rw(d->udev, 0xb8, 0, 0,
Igor M. Liplianin8a4949b2008-10-05 09:11:21 -0300346 ibuf, 2, DW210X_READ_MSG);
347 memcpy(msg[0].buf, ibuf , 2);
348 break;
349 }
350 case(DW2102_VOLTAGE_CTRL): {
351 u8 obuf[2];
352 obuf[0] = 0x30;
353 obuf[1] = msg[0].buf[0];
Hans Verkuild51dbec2012-04-20 03:30:11 -0300354 dw210x_op_rw(d->udev, 0xb2, 0, 0,
Igor M. Liplianin8a4949b2008-10-05 09:11:21 -0300355 obuf, 2, DW210X_WRITE_MSG);
356 break;
357 }
358 }
359
360 break;
361 }
362
363 mutex_unlock(&d->i2c_mutex);
364 return num;
365}
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300366
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300367static int dw2104_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], int num)
368{
369 struct dvb_usb_device *d = i2c_get_adapdata(adap);
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300370 int len, i, j;
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300371
372 if (!d)
373 return -ENODEV;
374 if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
375 return -EAGAIN;
376
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300377 for (j = 0; j < num; j++) {
378 switch (msg[j].addr) {
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300379 case(DW2102_RC_QUERY): {
380 u8 ibuf[2];
Hans Verkuild51dbec2012-04-20 03:30:11 -0300381 dw210x_op_rw(d->udev, 0xb8, 0, 0,
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300382 ibuf, 2, DW210X_READ_MSG);
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300383 memcpy(msg[j].buf, ibuf , 2);
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300384 break;
385 }
386 case(DW2102_VOLTAGE_CTRL): {
387 u8 obuf[2];
388 obuf[0] = 0x30;
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300389 obuf[1] = msg[j].buf[0];
Hans Verkuild51dbec2012-04-20 03:30:11 -0300390 dw210x_op_rw(d->udev, 0xb2, 0, 0,
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300391 obuf, 2, DW210X_WRITE_MSG);
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300392 break;
393 }
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300394 /*case 0x55: cx24116
395 case 0x6a: stv0903
396 case 0x68: ds3000, stv0903
397 case 0x60: ts2020, stv6110, stb6100 */
398 default: {
399 if (msg[j].flags == I2C_M_RD) {
400 /* read registers */
401 u8 ibuf[msg[j].len + 2];
Hans Verkuild51dbec2012-04-20 03:30:11 -0300402 dw210x_op_rw(d->udev, 0xc3,
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300403 (msg[j].addr << 1) + 1, 0,
404 ibuf, msg[j].len + 2,
405 DW210X_READ_MSG);
406 memcpy(msg[j].buf, ibuf + 2, msg[j].len);
407 mdelay(10);
408 } else if (((msg[j].buf[0] == 0xb0) &&
409 (msg[j].addr == 0x68)) ||
410 ((msg[j].buf[0] == 0xf7) &&
411 (msg[j].addr == 0x55))) {
412 /* write firmware */
413 u8 obuf[19];
414 obuf[0] = msg[j].addr << 1;
415 obuf[1] = (msg[j].len > 15 ? 17 : msg[j].len);
416 obuf[2] = msg[j].buf[0];
417 len = msg[j].len - 1;
418 i = 1;
419 do {
420 memcpy(obuf + 3, msg[j].buf + i,
421 (len > 16 ? 16 : len));
Hans Verkuild51dbec2012-04-20 03:30:11 -0300422 dw210x_op_rw(d->udev, 0xc2, 0, 0,
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300423 obuf, (len > 16 ? 16 : len) + 3,
424 DW210X_WRITE_MSG);
425 i += 16;
426 len -= 16;
427 } while (len > 0);
428 } else {
429 /* write registers */
430 u8 obuf[msg[j].len + 2];
431 obuf[0] = msg[j].addr << 1;
432 obuf[1] = msg[j].len;
433 memcpy(obuf + 2, msg[j].buf, msg[j].len);
Hans Verkuild51dbec2012-04-20 03:30:11 -0300434 dw210x_op_rw(d->udev, 0xc2, 0, 0,
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300435 obuf, msg[j].len + 2,
436 DW210X_WRITE_MSG);
437 }
438 break;
439 }
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300440 }
441
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300442 }
443
444 mutex_unlock(&d->i2c_mutex);
445 return num;
446}
447
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -0300448static int dw3101_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],
449 int num)
450{
451 struct dvb_usb_device *d = i2c_get_adapdata(adap);
Hans Verkuild51dbec2012-04-20 03:30:11 -0300452 int i;
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -0300453
454 if (!d)
455 return -ENODEV;
456 if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
457 return -EAGAIN;
458
459 switch (num) {
460 case 2: {
461 /* read */
462 /* first write first register number */
463 u8 ibuf[msg[1].len + 2], obuf[3];
464 obuf[0] = msg[0].addr << 1;
465 obuf[1] = msg[0].len;
466 obuf[2] = msg[0].buf[0];
Hans Verkuild51dbec2012-04-20 03:30:11 -0300467 dw210x_op_rw(d->udev, 0xc2, 0, 0,
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -0300468 obuf, msg[0].len + 2, DW210X_WRITE_MSG);
469 /* second read registers */
Hans Verkuild51dbec2012-04-20 03:30:11 -0300470 dw210x_op_rw(d->udev, 0xc3, 0x19 , 0,
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -0300471 ibuf, msg[1].len + 2, DW210X_READ_MSG);
472 memcpy(msg[1].buf, ibuf + 2, msg[1].len);
473
474 break;
475 }
476 case 1:
477 switch (msg[0].addr) {
478 case 0x60:
479 case 0x0c: {
480 /* write to register */
481 u8 obuf[msg[0].len + 2];
482 obuf[0] = msg[0].addr << 1;
483 obuf[1] = msg[0].len;
484 memcpy(obuf + 2, msg[0].buf, msg[0].len);
Hans Verkuild51dbec2012-04-20 03:30:11 -0300485 dw210x_op_rw(d->udev, 0xc2, 0, 0,
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -0300486 obuf, msg[0].len + 2, DW210X_WRITE_MSG);
487 break;
488 }
489 case(DW2102_RC_QUERY): {
490 u8 ibuf[2];
Hans Verkuild51dbec2012-04-20 03:30:11 -0300491 dw210x_op_rw(d->udev, 0xb8, 0, 0,
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -0300492 ibuf, 2, DW210X_READ_MSG);
493 memcpy(msg[0].buf, ibuf , 2);
494 break;
495 }
496 }
497
498 break;
499 }
500
501 for (i = 0; i < num; i++) {
502 deb_xfer("%02x:%02x: %s ", i, msg[i].addr,
503 msg[i].flags == 0 ? ">>>" : "<<<");
504 debug_dump(msg[i].buf, msg[i].len, deb_xfer);
505 }
506
507 mutex_unlock(&d->i2c_mutex);
508 return num;
509}
510
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300511static int s6x0_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300512 int num)
513{
514 struct dvb_usb_device *d = i2c_get_adapdata(adap);
Julia Lawall21ead032009-12-22 18:00:07 -0300515 struct usb_device *udev;
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300516 int len, i, j;
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300517
518 if (!d)
519 return -ENODEV;
Julia Lawall21ead032009-12-22 18:00:07 -0300520 udev = d->udev;
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300521 if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
522 return -EAGAIN;
523
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300524 for (j = 0; j < num; j++) {
525 switch (msg[j].addr) {
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300526 case (DW2102_RC_QUERY): {
Igor M. Liplianin5a530cb2011-02-25 18:41:23 -0300527 u8 ibuf[5];
Hans Verkuild51dbec2012-04-20 03:30:11 -0300528 dw210x_op_rw(d->udev, 0xb8, 0, 0,
Igor M. Liplianin5a530cb2011-02-25 18:41:23 -0300529 ibuf, 5, DW210X_READ_MSG);
530 memcpy(msg[j].buf, ibuf + 3, 2);
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300531 break;
532 }
533 case (DW2102_VOLTAGE_CTRL): {
534 u8 obuf[2];
Igor M. Liplianincd79d332009-12-14 20:24:56 -0300535
536 obuf[0] = 1;
537 obuf[1] = msg[j].buf[1];/* off-on */
Hans Verkuild51dbec2012-04-20 03:30:11 -0300538 dw210x_op_rw(d->udev, 0x8a, 0, 0,
Igor M. Liplianincd79d332009-12-14 20:24:56 -0300539 obuf, 2, DW210X_WRITE_MSG);
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300540 obuf[0] = 3;
Igor M. Liplianincd79d332009-12-14 20:24:56 -0300541 obuf[1] = msg[j].buf[0];/* 13v-18v */
Hans Verkuild51dbec2012-04-20 03:30:11 -0300542 dw210x_op_rw(d->udev, 0x8a, 0, 0,
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300543 obuf, 2, DW210X_WRITE_MSG);
544 break;
545 }
Igor M. Liplianinfa8bae12011-02-25 18:41:22 -0300546 case (DW2102_LED_CTRL): {
547 u8 obuf[2];
548
549 obuf[0] = 5;
550 obuf[1] = msg[j].buf[0];
Hans Verkuild51dbec2012-04-20 03:30:11 -0300551 dw210x_op_rw(d->udev, 0x8a, 0, 0,
Igor M. Liplianinfa8bae12011-02-25 18:41:22 -0300552 obuf, 2, DW210X_WRITE_MSG);
553 break;
554 }
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300555 /*case 0x55: cx24116
556 case 0x6a: stv0903
Igor M. Liplianin955d00a2012-05-08 03:53:17 -0300557 case 0x68: ds3000, stv0903, rs2000
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300558 case 0x60: ts2020, stv6110, stb6100
559 case 0xa0: eeprom */
560 default: {
561 if (msg[j].flags == I2C_M_RD) {
562 /* read registers */
563 u8 ibuf[msg[j].len];
Hans Verkuild51dbec2012-04-20 03:30:11 -0300564 dw210x_op_rw(d->udev, 0x91, 0, 0,
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300565 ibuf, msg[j].len,
566 DW210X_READ_MSG);
567 memcpy(msg[j].buf, ibuf, msg[j].len);
568 break;
569 } else if ((msg[j].buf[0] == 0xb0) &&
570 (msg[j].addr == 0x68)) {
571 /* write firmware */
572 u8 obuf[19];
573 obuf[0] = (msg[j].len > 16 ?
574 18 : msg[j].len + 1);
575 obuf[1] = msg[j].addr << 1;
576 obuf[2] = msg[j].buf[0];
577 len = msg[j].len - 1;
578 i = 1;
579 do {
580 memcpy(obuf + 3, msg[j].buf + i,
581 (len > 16 ? 16 : len));
Hans Verkuild51dbec2012-04-20 03:30:11 -0300582 dw210x_op_rw(d->udev, 0x80, 0, 0,
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300583 obuf, (len > 16 ? 16 : len) + 3,
584 DW210X_WRITE_MSG);
585 i += 16;
586 len -= 16;
587 } while (len > 0);
Igor M. Liplianina84adf42011-02-27 16:18:38 -0300588 } else if (j < (num - 1)) {
Igor M. Liplianincd79d332009-12-14 20:24:56 -0300589 /* write register addr before read */
590 u8 obuf[msg[j].len + 2];
591 obuf[0] = msg[j + 1].len;
592 obuf[1] = (msg[j].addr << 1);
593 memcpy(obuf + 2, msg[j].buf, msg[j].len);
Hans Verkuild51dbec2012-04-20 03:30:11 -0300594 dw210x_op_rw(d->udev,
Igor M. Liplianina84adf42011-02-27 16:18:38 -0300595 udev->descriptor.idProduct ==
596 0x7500 ? 0x92 : 0x90, 0, 0,
Igor M. Liplianincd79d332009-12-14 20:24:56 -0300597 obuf, msg[j].len + 2,
598 DW210X_WRITE_MSG);
599 break;
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300600 } else {
601 /* write registers */
602 u8 obuf[msg[j].len + 2];
603 obuf[0] = msg[j].len + 1;
604 obuf[1] = (msg[j].addr << 1);
605 memcpy(obuf + 2, msg[j].buf, msg[j].len);
Hans Verkuild51dbec2012-04-20 03:30:11 -0300606 dw210x_op_rw(d->udev, 0x80, 0, 0,
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300607 obuf, msg[j].len + 2,
608 DW210X_WRITE_MSG);
609 break;
610 }
611 break;
612 }
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300613 }
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300614 }
615
616 mutex_unlock(&d->i2c_mutex);
617 return num;
618}
619
Igor M. Liplianind2ffc442011-02-25 18:41:22 -0300620static int su3000_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],
621 int num)
622{
623 struct dvb_usb_device *d = i2c_get_adapdata(adap);
624 u8 obuf[0x40], ibuf[0x40];
625
626 if (!d)
627 return -ENODEV;
628 if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
629 return -EAGAIN;
630
631 switch (num) {
632 case 1:
633 switch (msg[0].addr) {
634 case SU3000_STREAM_CTRL:
635 obuf[0] = msg[0].buf[0] + 0x36;
636 obuf[1] = 3;
637 obuf[2] = 0;
638 if (dvb_usb_generic_rw(d, obuf, 3, ibuf, 0, 0) < 0)
639 err("i2c transfer failed.");
640 break;
641 case DW2102_RC_QUERY:
642 obuf[0] = 0x10;
643 if (dvb_usb_generic_rw(d, obuf, 1, ibuf, 2, 0) < 0)
644 err("i2c transfer failed.");
645 msg[0].buf[1] = ibuf[0];
646 msg[0].buf[0] = ibuf[1];
647 break;
648 default:
649 /* always i2c write*/
650 obuf[0] = 0x08;
651 obuf[1] = msg[0].addr;
652 obuf[2] = msg[0].len;
653
654 memcpy(&obuf[3], msg[0].buf, msg[0].len);
655
656 if (dvb_usb_generic_rw(d, obuf, msg[0].len + 3,
657 ibuf, 1, 0) < 0)
658 err("i2c transfer failed.");
659
660 }
661 break;
662 case 2:
663 /* always i2c read */
664 obuf[0] = 0x09;
665 obuf[1] = msg[0].len;
666 obuf[2] = msg[1].len;
667 obuf[3] = msg[0].addr;
668 memcpy(&obuf[4], msg[0].buf, msg[0].len);
669
670 if (dvb_usb_generic_rw(d, obuf, msg[0].len + 4,
671 ibuf, msg[1].len + 1, 0) < 0)
672 err("i2c transfer failed.");
673
674 memcpy(msg[1].buf, &ibuf[1], msg[1].len);
675 break;
676 default:
677 warn("more than 2 i2c messages at a time is not handled yet.");
678 break;
679 }
680 mutex_unlock(&d->i2c_mutex);
681 return num;
682}
683
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300684static u32 dw210x_i2c_func(struct i2c_adapter *adapter)
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300685{
686 return I2C_FUNC_I2C;
687}
688
689static struct i2c_algorithm dw2102_i2c_algo = {
690 .master_xfer = dw2102_i2c_transfer,
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300691 .functionality = dw210x_i2c_func,
692};
693
694static struct i2c_algorithm dw2102_serit_i2c_algo = {
695 .master_xfer = dw2102_serit_i2c_transfer,
696 .functionality = dw210x_i2c_func,
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300697};
698
Igor M. Liplianin8a4949b2008-10-05 09:11:21 -0300699static struct i2c_algorithm dw2102_earda_i2c_algo = {
700 .master_xfer = dw2102_earda_i2c_transfer,
701 .functionality = dw210x_i2c_func,
702};
703
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300704static struct i2c_algorithm dw2104_i2c_algo = {
705 .master_xfer = dw2104_i2c_transfer,
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300706 .functionality = dw210x_i2c_func,
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300707};
708
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -0300709static struct i2c_algorithm dw3101_i2c_algo = {
710 .master_xfer = dw3101_i2c_transfer,
711 .functionality = dw210x_i2c_func,
712};
713
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300714static struct i2c_algorithm s6x0_i2c_algo = {
715 .master_xfer = s6x0_i2c_transfer,
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300716 .functionality = dw210x_i2c_func,
717};
718
Igor M. Liplianind2ffc442011-02-25 18:41:22 -0300719static struct i2c_algorithm su3000_i2c_algo = {
720 .master_xfer = su3000_i2c_transfer,
721 .functionality = dw210x_i2c_func,
722};
723
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300724static int dw210x_read_mac_address(struct dvb_usb_device *d, u8 mac[6])
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300725{
726 int i;
727 u8 ibuf[] = {0, 0};
728 u8 eeprom[256], eepromline[16];
729
730 for (i = 0; i < 256; i++) {
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300731 if (dw210x_op_rw(d->udev, 0xb6, 0xa0 , i, ibuf, 2, DW210X_READ_MSG) < 0) {
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300732 err("read eeprom failed.");
733 return -1;
734 } else {
735 eepromline[i%16] = ibuf[0];
736 eeprom[i] = ibuf[0];
737 }
738 if ((i % 16) == 15) {
739 deb_xfer("%02x: ", i - 15);
740 debug_dump(eepromline, 16, deb_xfer);
741 }
742 }
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -0300743
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300744 memcpy(mac, eeprom + 8, 6);
745 return 0;
746};
747
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300748static int s6x0_read_mac_address(struct dvb_usb_device *d, u8 mac[6])
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300749{
750 int i, ret;
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300751 u8 ibuf[] = { 0 }, obuf[] = { 0 };
752 u8 eeprom[256], eepromline[16];
753 struct i2c_msg msg[] = {
754 {
755 .addr = 0xa0 >> 1,
756 .flags = 0,
757 .buf = obuf,
758 .len = 1,
759 }, {
760 .addr = 0xa0 >> 1,
761 .flags = I2C_M_RD,
762 .buf = ibuf,
763 .len = 1,
764 }
765 };
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300766
767 for (i = 0; i < 256; i++) {
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300768 obuf[0] = i;
769 ret = s6x0_i2c_transfer(&d->i2c_adap, msg, 2);
770 if (ret != 2) {
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300771 err("read eeprom failed.");
772 return -1;
773 } else {
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300774 eepromline[i % 16] = ibuf[0];
775 eeprom[i] = ibuf[0];
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300776 }
777
778 if ((i % 16) == 15) {
779 deb_xfer("%02x: ", i - 15);
780 debug_dump(eepromline, 16, deb_xfer);
781 }
782 }
783
784 memcpy(mac, eeprom + 16, 6);
785 return 0;
786};
787
Igor M. Liplianind2ffc442011-02-25 18:41:22 -0300788static int su3000_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff)
789{
790 static u8 command_start[] = {0x00};
791 static u8 command_stop[] = {0x01};
792 struct i2c_msg msg = {
793 .addr = SU3000_STREAM_CTRL,
794 .flags = 0,
795 .buf = onoff ? command_start : command_stop,
796 .len = 1
797 };
798
799 i2c_transfer(&adap->dev->i2c_adap, &msg, 1);
800
801 return 0;
802}
803
804static int su3000_power_ctrl(struct dvb_usb_device *d, int i)
805{
806 struct su3000_state *state = (struct su3000_state *)d->priv;
807 u8 obuf[] = {0xde, 0};
808
809 info("%s: %d, initialized %d\n", __func__, i, state->initialized);
810
811 if (i && !state->initialized) {
812 state->initialized = 1;
813 /* reset board */
814 dvb_usb_generic_rw(d, obuf, 2, NULL, 0, 0);
815 }
816
817 return 0;
818}
819
820static int su3000_read_mac_address(struct dvb_usb_device *d, u8 mac[6])
821{
822 int i;
823 u8 obuf[] = { 0x1f, 0xf0 };
824 u8 ibuf[] = { 0 };
825 struct i2c_msg msg[] = {
826 {
827 .addr = 0x51,
828 .flags = 0,
829 .buf = obuf,
830 .len = 2,
831 }, {
832 .addr = 0x51,
833 .flags = I2C_M_RD,
834 .buf = ibuf,
835 .len = 1,
836
837 }
838 };
839
840 for (i = 0; i < 6; i++) {
841 obuf[1] = 0xf0 + i;
842 if (i2c_transfer(&d->i2c_adap, msg, 2) != 2)
843 break;
844 else
845 mac[i] = ibuf[0];
846
847 debug_dump(mac, 6, printk);
848 }
849
850 return 0;
851}
852
853static int su3000_identify_state(struct usb_device *udev,
854 struct dvb_usb_device_properties *props,
855 struct dvb_usb_device_description **desc,
856 int *cold)
857{
858 info("%s\n", __func__);
859
860 *cold = 0;
861 return 0;
862}
863
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300864static int dw210x_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300865{
Igor M. Liplianincd79d332009-12-14 20:24:56 -0300866 static u8 command_13v[] = {0x00, 0x01};
867 static u8 command_18v[] = {0x01, 0x01};
868 static u8 command_off[] = {0x00, 0x00};
869 struct i2c_msg msg = {
870 .addr = DW2102_VOLTAGE_CTRL,
871 .flags = 0,
872 .buf = command_off,
873 .len = 2,
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300874 };
875
876 struct dvb_usb_adapter *udev_adap =
877 (struct dvb_usb_adapter *)(fe->dvb->priv);
878 if (voltage == SEC_VOLTAGE_18)
Igor M. Liplianincd79d332009-12-14 20:24:56 -0300879 msg.buf = command_18v;
880 else if (voltage == SEC_VOLTAGE_13)
881 msg.buf = command_13v;
882
883 i2c_transfer(&udev_adap->dev->i2c_adap, &msg, 1);
884
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300885 return 0;
886}
887
Igor M. Liplianin52c506e2011-02-25 18:41:23 -0300888static int s660_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
889{
890 struct dvb_usb_adapter *d =
891 (struct dvb_usb_adapter *)(fe->dvb->priv);
892 struct s6x0_state *st = (struct s6x0_state *)d->dev->priv;
893
894 dw210x_set_voltage(fe, voltage);
895 if (st->old_set_voltage)
896 st->old_set_voltage(fe, voltage);
897
898 return 0;
899}
900
Igor M. Liplianinfa8bae12011-02-25 18:41:22 -0300901static void dw210x_led_ctrl(struct dvb_frontend *fe, int offon)
902{
903 static u8 led_off[] = { 0 };
904 static u8 led_on[] = { 1 };
905 struct i2c_msg msg = {
906 .addr = DW2102_LED_CTRL,
907 .flags = 0,
908 .buf = led_off,
909 .len = 1
910 };
911 struct dvb_usb_adapter *udev_adap =
912 (struct dvb_usb_adapter *)(fe->dvb->priv);
913
914 if (offon)
915 msg.buf = led_on;
916 i2c_transfer(&udev_adap->dev->i2c_adap, &msg, 1);
917}
918
Igor M. Liplianind4305c62008-10-17 13:45:55 -0300919static struct stv0299_config sharp_z0194a_config = {
920 .demod_address = 0x68,
921 .inittab = sharp_z0194a_inittab,
922 .mclk = 88000000UL,
923 .invert = 1,
924 .skip_reinit = 0,
925 .lock_output = STV0299_LOCKOUTPUT_1,
926 .volt13_op0_op1 = STV0299_VOLT13_OP1,
927 .min_delay_ms = 100,
928 .set_symbol_rate = sharp_z0194a_set_symbol_rate,
929};
930
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300931static struct cx24116_config dw2104_config = {
932 .demod_address = 0x55,
Igor M. Liplianincc8c4f32008-09-09 13:57:47 -0300933 .mpg_clk_pos_pol = 0x01,
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300934};
935
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300936static struct si21xx_config serit_sp1511lhb_config = {
937 .demod_address = 0x68,
938 .min_delay_ms = 100,
939
940};
941
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -0300942static struct tda10023_config dw3101_tda10023_config = {
943 .demod_address = 0x0c,
944 .invert = 1,
945};
946
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300947static struct mt312_config zl313_config = {
948 .demod_address = 0x0e,
949};
950
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300951static struct ds3000_config dw2104_ds3000_config = {
952 .demod_address = 0x68,
953};
954
Konstantin Dimitrov73f0af42012-12-23 19:25:38 -0300955static struct ts2020_config dw2104_ts2020_config = {
956 .tuner_address = 0x60,
Igor M. Liplianinb858c332012-12-28 19:40:33 -0300957 .clk_out_div = 1,
Konstantin Dimitrov73f0af42012-12-23 19:25:38 -0300958};
959
Igor M. Liplianin43385c82012-12-28 19:40:24 -0300960static struct ds3000_config s660_ds3000_config = {
961 .demod_address = 0x68,
Igor M. Liplianinb858c332012-12-28 19:40:33 -0300962 .ci_mode = 1,
Igor M. Liplianin43385c82012-12-28 19:40:24 -0300963 .set_lock_led = dw210x_led_ctrl,
964};
965
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300966static struct stv0900_config dw2104a_stv0900_config = {
967 .demod_address = 0x6a,
968 .demod_mode = 0,
969 .xtal = 27000000,
970 .clkmode = 3,/* 0-CLKI, 2-XTALI, else AUTO */
971 .diseqc_mode = 2,/* 2/3 PWM */
972 .tun1_maddress = 0,/* 0x60 */
973 .tun1_adc = 0,/* 2 Vpp */
974 .path1_mode = 3,
975};
976
977static struct stb6100_config dw2104a_stb6100_config = {
978 .tuner_address = 0x60,
979 .refclock = 27000000,
980};
981
982static struct stv0900_config dw2104_stv0900_config = {
983 .demod_address = 0x68,
984 .demod_mode = 0,
985 .xtal = 8000000,
986 .clkmode = 3,
987 .diseqc_mode = 2,
988 .tun1_maddress = 0,
989 .tun1_adc = 1,/* 1 Vpp */
990 .path1_mode = 3,
991};
992
993static struct stv6110_config dw2104_stv6110_config = {
994 .i2c_address = 0x60,
995 .mclk = 16000000,
996 .clk_div = 1,
997};
998
Igor M. Liplianincd79d332009-12-14 20:24:56 -0300999static struct stv0900_config prof_7500_stv0900_config = {
1000 .demod_address = 0x6a,
1001 .demod_mode = 0,
1002 .xtal = 27000000,
1003 .clkmode = 3,/* 0-CLKI, 2-XTALI, else AUTO */
1004 .diseqc_mode = 2,/* 2/3 PWM */
1005 .tun1_maddress = 0,/* 0x60 */
1006 .tun1_adc = 0,/* 2 Vpp */
1007 .path1_mode = 3,
1008 .tun1_type = 3,
Igor M. Liplianinfa8bae12011-02-25 18:41:22 -03001009 .set_lock_led = dw210x_led_ctrl,
Igor M. Liplianincd79d332009-12-14 20:24:56 -03001010};
1011
Igor M. Liplianind2ffc442011-02-25 18:41:22 -03001012static struct ds3000_config su3000_ds3000_config = {
1013 .demod_address = 0x68,
1014 .ci_mode = 1,
Igor M. Liplianinb858c332012-12-28 19:40:33 -03001015 .set_lock_led = dw210x_led_ctrl,
Konstantin Dimitrov73f0af42012-12-23 19:25:38 -03001016};
1017
Igor M. Liplianin955d00a2012-05-08 03:53:17 -03001018static u8 m88rs2000_inittab[] = {
1019 DEMOD_WRITE, 0x9a, 0x30,
1020 DEMOD_WRITE, 0x00, 0x01,
1021 WRITE_DELAY, 0x19, 0x00,
1022 DEMOD_WRITE, 0x00, 0x00,
1023 DEMOD_WRITE, 0x9a, 0xb0,
1024 DEMOD_WRITE, 0x81, 0xc1,
Igor M. Liplianin955d00a2012-05-08 03:53:17 -03001025 DEMOD_WRITE, 0x81, 0x81,
1026 DEMOD_WRITE, 0x86, 0xc6,
1027 DEMOD_WRITE, 0x9a, 0x30,
1028 DEMOD_WRITE, 0xf0, 0x80,
1029 DEMOD_WRITE, 0xf1, 0xbf,
1030 DEMOD_WRITE, 0xb0, 0x45,
1031 DEMOD_WRITE, 0xb2, 0x01,
1032 DEMOD_WRITE, 0x9a, 0xb0,
1033 0xff, 0xaa, 0xff
1034};
1035
1036static struct m88rs2000_config s421_m88rs2000_config = {
1037 .demod_addr = 0x68,
Igor M. Liplianin955d00a2012-05-08 03:53:17 -03001038 .inittab = m88rs2000_inittab,
1039};
1040
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001041static int dw2104_frontend_attach(struct dvb_usb_adapter *d)
1042{
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001043 struct dvb_tuner_ops *tuner_ops = NULL;
1044
1045 if (demod_probe & 4) {
Michael Krufky77eed212011-09-06 09:31:57 -03001046 d->fe_adap[0].fe = dvb_attach(stv0900_attach, &dw2104a_stv0900_config,
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001047 &d->dev->i2c_adap, 0);
Michael Krufky77eed212011-09-06 09:31:57 -03001048 if (d->fe_adap[0].fe != NULL) {
1049 if (dvb_attach(stb6100_attach, d->fe_adap[0].fe,
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001050 &dw2104a_stb6100_config,
1051 &d->dev->i2c_adap)) {
Michael Krufky77eed212011-09-06 09:31:57 -03001052 tuner_ops = &d->fe_adap[0].fe->ops.tuner_ops;
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001053 tuner_ops->set_frequency = stb6100_set_freq;
1054 tuner_ops->get_frequency = stb6100_get_freq;
1055 tuner_ops->set_bandwidth = stb6100_set_bandw;
1056 tuner_ops->get_bandwidth = stb6100_get_bandw;
Michael Krufky77eed212011-09-06 09:31:57 -03001057 d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage;
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001058 info("Attached STV0900+STB6100!\n");
1059 return 0;
1060 }
1061 }
1062 }
1063
1064 if (demod_probe & 2) {
Michael Krufky77eed212011-09-06 09:31:57 -03001065 d->fe_adap[0].fe = dvb_attach(stv0900_attach, &dw2104_stv0900_config,
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001066 &d->dev->i2c_adap, 0);
Michael Krufky77eed212011-09-06 09:31:57 -03001067 if (d->fe_adap[0].fe != NULL) {
1068 if (dvb_attach(stv6110_attach, d->fe_adap[0].fe,
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001069 &dw2104_stv6110_config,
1070 &d->dev->i2c_adap)) {
Michael Krufky77eed212011-09-06 09:31:57 -03001071 d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage;
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001072 info("Attached STV0900+STV6110A!\n");
1073 return 0;
1074 }
1075 }
1076 }
1077
1078 if (demod_probe & 1) {
Michael Krufky77eed212011-09-06 09:31:57 -03001079 d->fe_adap[0].fe = dvb_attach(cx24116_attach, &dw2104_config,
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001080 &d->dev->i2c_adap);
Michael Krufky77eed212011-09-06 09:31:57 -03001081 if (d->fe_adap[0].fe != NULL) {
1082 d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage;
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001083 info("Attached cx24116!\n");
1084 return 0;
1085 }
1086 }
1087
Michael Krufky77eed212011-09-06 09:31:57 -03001088 d->fe_adap[0].fe = dvb_attach(ds3000_attach, &dw2104_ds3000_config,
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001089 &d->dev->i2c_adap);
Michael Krufky77eed212011-09-06 09:31:57 -03001090 if (d->fe_adap[0].fe != NULL) {
Konstantin Dimitrov73f0af42012-12-23 19:25:38 -03001091 dvb_attach(ts2020_attach, d->fe_adap[0].fe,
1092 &dw2104_ts2020_config, &d->dev->i2c_adap);
Michael Krufky77eed212011-09-06 09:31:57 -03001093 d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage;
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001094 info("Attached DS3000!\n");
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001095 return 0;
1096 }
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001097
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001098 return -EIO;
1099}
1100
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001101static struct dvb_usb_device_properties dw2102_properties;
Igor M. Liplianinb42e1d72009-06-14 19:41:22 -03001102static struct dvb_usb_device_properties dw2104_properties;
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001103static struct dvb_usb_device_properties s6x0_properties;
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001104
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001105static int dw2102_frontend_attach(struct dvb_usb_adapter *d)
1106{
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001107 if (dw2102_properties.i2c_algo == &dw2102_serit_i2c_algo) {
1108 /*dw2102_properties.adapter->tuner_attach = NULL;*/
Michael Krufky77eed212011-09-06 09:31:57 -03001109 d->fe_adap[0].fe = dvb_attach(si21xx_attach, &serit_sp1511lhb_config,
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001110 &d->dev->i2c_adap);
Michael Krufky77eed212011-09-06 09:31:57 -03001111 if (d->fe_adap[0].fe != NULL) {
1112 d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage;
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001113 info("Attached si21xx!\n");
1114 return 0;
1115 }
1116 }
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001117
Igor M. Liplianin8a4949b2008-10-05 09:11:21 -03001118 if (dw2102_properties.i2c_algo == &dw2102_earda_i2c_algo) {
Michael Krufky77eed212011-09-06 09:31:57 -03001119 d->fe_adap[0].fe = dvb_attach(stv0288_attach, &earda_config,
Igor M. Liplianin8a4949b2008-10-05 09:11:21 -03001120 &d->dev->i2c_adap);
Michael Krufky77eed212011-09-06 09:31:57 -03001121 if (d->fe_adap[0].fe != NULL) {
1122 if (dvb_attach(stb6000_attach, d->fe_adap[0].fe, 0x61,
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001123 &d->dev->i2c_adap)) {
Michael Krufky77eed212011-09-06 09:31:57 -03001124 d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage;
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001125 info("Attached stv0288!\n");
1126 return 0;
1127 }
Igor M. Liplianin8a4949b2008-10-05 09:11:21 -03001128 }
1129 }
1130
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001131 if (dw2102_properties.i2c_algo == &dw2102_i2c_algo) {
1132 /*dw2102_properties.adapter->tuner_attach = dw2102_tuner_attach;*/
Michael Krufky77eed212011-09-06 09:31:57 -03001133 d->fe_adap[0].fe = dvb_attach(stv0299_attach, &sharp_z0194a_config,
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001134 &d->dev->i2c_adap);
Michael Krufky77eed212011-09-06 09:31:57 -03001135 if (d->fe_adap[0].fe != NULL) {
1136 d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage;
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001137 info("Attached stv0299!\n");
1138 return 0;
1139 }
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001140 }
1141 return -EIO;
1142}
1143
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001144static int dw3101_frontend_attach(struct dvb_usb_adapter *d)
1145{
Michael Krufky77eed212011-09-06 09:31:57 -03001146 d->fe_adap[0].fe = dvb_attach(tda10023_attach, &dw3101_tda10023_config,
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001147 &d->dev->i2c_adap, 0x48);
Michael Krufky77eed212011-09-06 09:31:57 -03001148 if (d->fe_adap[0].fe != NULL) {
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001149 info("Attached tda10023!\n");
1150 return 0;
1151 }
1152 return -EIO;
1153}
1154
Igor M. Liplianin195288d2011-02-25 18:41:22 -03001155static int zl100313_frontend_attach(struct dvb_usb_adapter *d)
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -03001156{
Michael Krufky77eed212011-09-06 09:31:57 -03001157 d->fe_adap[0].fe = dvb_attach(mt312_attach, &zl313_config,
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001158 &d->dev->i2c_adap);
Michael Krufky77eed212011-09-06 09:31:57 -03001159 if (d->fe_adap[0].fe != NULL) {
1160 if (dvb_attach(zl10039_attach, d->fe_adap[0].fe, 0x60,
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001161 &d->dev->i2c_adap)) {
Michael Krufky77eed212011-09-06 09:31:57 -03001162 d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage;
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001163 info("Attached zl100313+zl10039!\n");
1164 return 0;
1165 }
1166 }
1167
Igor M. Liplianin195288d2011-02-25 18:41:22 -03001168 return -EIO;
1169}
1170
1171static int stv0288_frontend_attach(struct dvb_usb_adapter *d)
1172{
Igor M. Liplianinfd5466d2011-02-27 16:22:52 -03001173 u8 obuf[] = {7, 1};
1174
Michael Krufky77eed212011-09-06 09:31:57 -03001175 d->fe_adap[0].fe = dvb_attach(stv0288_attach, &earda_config,
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001176 &d->dev->i2c_adap);
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001177
Michael Krufky77eed212011-09-06 09:31:57 -03001178 if (d->fe_adap[0].fe == NULL)
Igor M. Liplianinfd5466d2011-02-27 16:22:52 -03001179 return -EIO;
1180
Michael Krufky77eed212011-09-06 09:31:57 -03001181 if (NULL == dvb_attach(stb6000_attach, d->fe_adap[0].fe, 0x61, &d->dev->i2c_adap))
Igor M. Liplianinfd5466d2011-02-27 16:22:52 -03001182 return -EIO;
1183
Michael Krufky77eed212011-09-06 09:31:57 -03001184 d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage;
Igor M. Liplianinfd5466d2011-02-27 16:22:52 -03001185
1186 dw210x_op_rw(d->dev->udev, 0x8a, 0, 0, obuf, 2, DW210X_WRITE_MSG);
1187
1188 info("Attached stv0288+stb6000!\n");
1189
1190 return 0;
1191
Igor M. Liplianin195288d2011-02-25 18:41:22 -03001192}
1193
1194static int ds3000_frontend_attach(struct dvb_usb_adapter *d)
1195{
Igor M. Liplianin52c506e2011-02-25 18:41:23 -03001196 struct s6x0_state *st = (struct s6x0_state *)d->dev->priv;
Igor M. Liplianin5a530cb2011-02-25 18:41:23 -03001197 u8 obuf[] = {7, 1};
Igor M. Liplianin52c506e2011-02-25 18:41:23 -03001198
Igor M. Liplianin43385c82012-12-28 19:40:24 -03001199 d->fe_adap[0].fe = dvb_attach(ds3000_attach, &s660_ds3000_config,
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001200 &d->dev->i2c_adap);
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001201
Michael Krufky77eed212011-09-06 09:31:57 -03001202 if (d->fe_adap[0].fe == NULL)
Igor M. Liplianin52c506e2011-02-25 18:41:23 -03001203 return -EIO;
1204
Konstantin Dimitrov73f0af42012-12-23 19:25:38 -03001205 dvb_attach(ts2020_attach, d->fe_adap[0].fe, &dw2104_ts2020_config,
1206 &d->dev->i2c_adap);
1207
Michael Krufky77eed212011-09-06 09:31:57 -03001208 st->old_set_voltage = d->fe_adap[0].fe->ops.set_voltage;
1209 d->fe_adap[0].fe->ops.set_voltage = s660_set_voltage;
Igor M. Liplianin5a530cb2011-02-25 18:41:23 -03001210
1211 dw210x_op_rw(d->dev->udev, 0x8a, 0, 0, obuf, 2, DW210X_WRITE_MSG);
1212
Igor M. Liplianin52c506e2011-02-25 18:41:23 -03001213 info("Attached ds3000+ds2020!\n");
1214
1215 return 0;
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -03001216}
1217
Igor M. Liplianincd79d332009-12-14 20:24:56 -03001218static int prof_7500_frontend_attach(struct dvb_usb_adapter *d)
1219{
Igor M. Liplianin4e59df82011-02-25 18:41:23 -03001220 u8 obuf[] = {7, 1};
1221
Michael Krufky77eed212011-09-06 09:31:57 -03001222 d->fe_adap[0].fe = dvb_attach(stv0900_attach, &prof_7500_stv0900_config,
Igor M. Liplianincd79d332009-12-14 20:24:56 -03001223 &d->dev->i2c_adap, 0);
Michael Krufky77eed212011-09-06 09:31:57 -03001224 if (d->fe_adap[0].fe == NULL)
Igor M. Liplianincd79d332009-12-14 20:24:56 -03001225 return -EIO;
Igor M. Liplianin4e59df82011-02-25 18:41:23 -03001226
Michael Krufky77eed212011-09-06 09:31:57 -03001227 d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage;
Igor M. Liplianincd79d332009-12-14 20:24:56 -03001228
Igor M. Liplianin4e59df82011-02-25 18:41:23 -03001229 dw210x_op_rw(d->dev->udev, 0x8a, 0, 0, obuf, 2, DW210X_WRITE_MSG);
1230
Igor M. Liplianincd79d332009-12-14 20:24:56 -03001231 info("Attached STV0900+STB6100A!\n");
1232
1233 return 0;
1234}
1235
Igor M. Liplianind2ffc442011-02-25 18:41:22 -03001236static int su3000_frontend_attach(struct dvb_usb_adapter *d)
1237{
1238 u8 obuf[3] = { 0xe, 0x80, 0 };
1239 u8 ibuf[] = { 0 };
1240
1241 if (dvb_usb_generic_rw(d->dev, obuf, 3, ibuf, 1, 0) < 0)
1242 err("command 0x0e transfer failed.");
1243
1244 obuf[0] = 0xe;
Igor M. Liplianinb858c332012-12-28 19:40:33 -03001245 obuf[1] = 0x02;
1246 obuf[2] = 1;
1247
1248 if (dvb_usb_generic_rw(d->dev, obuf, 3, ibuf, 1, 0) < 0)
1249 err("command 0x0e transfer failed.");
1250 msleep(300);
1251
1252 obuf[0] = 0xe;
Igor M. Liplianind2ffc442011-02-25 18:41:22 -03001253 obuf[1] = 0x83;
1254 obuf[2] = 0;
1255
1256 if (dvb_usb_generic_rw(d->dev, obuf, 3, ibuf, 1, 0) < 0)
1257 err("command 0x0e transfer failed.");
1258
1259 obuf[0] = 0xe;
1260 obuf[1] = 0x83;
1261 obuf[2] = 1;
1262
1263 if (dvb_usb_generic_rw(d->dev, obuf, 3, ibuf, 1, 0) < 0)
1264 err("command 0x0e transfer failed.");
1265
1266 obuf[0] = 0x51;
1267
1268 if (dvb_usb_generic_rw(d->dev, obuf, 1, ibuf, 1, 0) < 0)
1269 err("command 0x51 transfer failed.");
1270
Michael Krufky77eed212011-09-06 09:31:57 -03001271 d->fe_adap[0].fe = dvb_attach(ds3000_attach, &su3000_ds3000_config,
Igor M. Liplianind2ffc442011-02-25 18:41:22 -03001272 &d->dev->i2c_adap);
Michael Krufky77eed212011-09-06 09:31:57 -03001273 if (d->fe_adap[0].fe == NULL)
Igor M. Liplianind2ffc442011-02-25 18:41:22 -03001274 return -EIO;
1275
Igor M. Liplianinb858c332012-12-28 19:40:33 -03001276 if (dvb_attach(ts2020_attach, d->fe_adap[0].fe,
1277 &dw2104_ts2020_config,
1278 &d->dev->i2c_adap)) {
1279 info("Attached DS3000/TS2020!\n");
1280 return 0;
1281 }
Konstantin Dimitrov73f0af42012-12-23 19:25:38 -03001282
Igor M. Liplianinb858c332012-12-28 19:40:33 -03001283 info("Failed to attach DS3000/TS2020!\n");
1284 return -EIO;
Igor M. Liplianind2ffc442011-02-25 18:41:22 -03001285}
1286
Igor M. Liplianin955d00a2012-05-08 03:53:17 -03001287static int m88rs2000_frontend_attach(struct dvb_usb_adapter *d)
1288{
1289 u8 obuf[] = { 0x51 };
1290 u8 ibuf[] = { 0 };
1291
1292 if (dvb_usb_generic_rw(d->dev, obuf, 1, ibuf, 1, 0) < 0)
1293 err("command 0x51 transfer failed.");
1294
1295 d->fe_adap[0].fe = dvb_attach(m88rs2000_attach, &s421_m88rs2000_config,
1296 &d->dev->i2c_adap);
Igor M. Liplianinb858c332012-12-28 19:40:33 -03001297
Igor M. Liplianin955d00a2012-05-08 03:53:17 -03001298 if (d->fe_adap[0].fe == NULL)
1299 return -EIO;
1300
Igor M. Liplianinb858c332012-12-28 19:40:33 -03001301 if (dvb_attach(ts2020_attach, d->fe_adap[0].fe,
1302 &dw2104_ts2020_config,
1303 &d->dev->i2c_adap)) {
1304 info("Attached RS2000/TS2020!\n");
1305 return 0;
1306 }
Igor M. Liplianin955d00a2012-05-08 03:53:17 -03001307
Igor M. Liplianinb858c332012-12-28 19:40:33 -03001308 info("Failed to attach RS2000/TS2020!\n");
1309 return -EIO;
Igor M. Liplianin955d00a2012-05-08 03:53:17 -03001310}
1311
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001312static int dw2102_tuner_attach(struct dvb_usb_adapter *adap)
1313{
Michael Krufky77eed212011-09-06 09:31:57 -03001314 dvb_attach(dvb_pll_attach, adap->fe_adap[0].fe, 0x60,
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001315 &adap->dev->i2c_adap, DVB_PLL_OPERA1);
1316 return 0;
1317}
1318
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001319static int dw3101_tuner_attach(struct dvb_usb_adapter *adap)
1320{
Michael Krufky77eed212011-09-06 09:31:57 -03001321 dvb_attach(dvb_pll_attach, adap->fe_adap[0].fe, 0x60,
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001322 &adap->dev->i2c_adap, DVB_PLL_TUA6034);
1323
1324 return 0;
1325}
1326
Mauro Carvalho Chehab2f4f58d2010-11-17 15:46:09 -03001327static struct rc_map_table rc_map_dw210x_table[] = {
Mauro Carvalho Chehab991bd3c2011-01-24 12:18:40 -03001328 { 0xf80a, KEY_POWER2 }, /*power*/
1329 { 0xf80c, KEY_MUTE }, /*mute*/
Mauro Carvalho Chehab2e365882009-08-29 15:19:31 -03001330 { 0xf811, KEY_1 },
1331 { 0xf812, KEY_2 },
1332 { 0xf813, KEY_3 },
1333 { 0xf814, KEY_4 },
1334 { 0xf815, KEY_5 },
1335 { 0xf816, KEY_6 },
1336 { 0xf817, KEY_7 },
1337 { 0xf818, KEY_8 },
1338 { 0xf819, KEY_9 },
1339 { 0xf810, KEY_0 },
Mauro Carvalho Chehab991bd3c2011-01-24 12:18:40 -03001340 { 0xf81c, KEY_CHANNELUP }, /*ch+*/
1341 { 0xf80f, KEY_CHANNELDOWN }, /*ch-*/
1342 { 0xf81a, KEY_VOLUMEUP }, /*vol+*/
1343 { 0xf80e, KEY_VOLUMEDOWN }, /*vol-*/
1344 { 0xf804, KEY_RECORD }, /*rec*/
1345 { 0xf809, KEY_FAVORITES }, /*fav*/
1346 { 0xf808, KEY_REWIND }, /*rewind*/
1347 { 0xf807, KEY_FASTFORWARD }, /*fast*/
1348 { 0xf80b, KEY_PAUSE }, /*pause*/
1349 { 0xf802, KEY_ESC }, /*cancel*/
1350 { 0xf803, KEY_TAB }, /*tab*/
Mauro Carvalho Chehab2e365882009-08-29 15:19:31 -03001351 { 0xf800, KEY_UP }, /*up*/
Mauro Carvalho Chehab991bd3c2011-01-24 12:18:40 -03001352 { 0xf81f, KEY_OK }, /*ok*/
1353 { 0xf801, KEY_DOWN }, /*down*/
1354 { 0xf805, KEY_CAMERA }, /*cap*/
1355 { 0xf806, KEY_STOP }, /*stop*/
1356 { 0xf840, KEY_ZOOM }, /*full*/
1357 { 0xf81e, KEY_TV }, /*tvmode*/
1358 { 0xf81b, KEY_LAST }, /*recall*/
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001359};
1360
Mauro Carvalho Chehab2f4f58d2010-11-17 15:46:09 -03001361static struct rc_map_table rc_map_tevii_table[] = {
Mauro Carvalho Chehab2e365882009-08-29 15:19:31 -03001362 { 0xf80a, KEY_POWER },
1363 { 0xf80c, KEY_MUTE },
1364 { 0xf811, KEY_1 },
1365 { 0xf812, KEY_2 },
1366 { 0xf813, KEY_3 },
1367 { 0xf814, KEY_4 },
1368 { 0xf815, KEY_5 },
1369 { 0xf816, KEY_6 },
1370 { 0xf817, KEY_7 },
1371 { 0xf818, KEY_8 },
1372 { 0xf819, KEY_9 },
1373 { 0xf810, KEY_0 },
1374 { 0xf81c, KEY_MENU },
1375 { 0xf80f, KEY_VOLUMEDOWN },
1376 { 0xf81a, KEY_LAST },
1377 { 0xf80e, KEY_OPEN },
1378 { 0xf804, KEY_RECORD },
1379 { 0xf809, KEY_VOLUMEUP },
1380 { 0xf808, KEY_CHANNELUP },
1381 { 0xf807, KEY_PVR },
1382 { 0xf80b, KEY_TIME },
1383 { 0xf802, KEY_RIGHT },
1384 { 0xf803, KEY_LEFT },
1385 { 0xf800, KEY_UP },
1386 { 0xf81f, KEY_OK },
1387 { 0xf801, KEY_DOWN },
1388 { 0xf805, KEY_TUNER },
1389 { 0xf806, KEY_CHANNELDOWN },
1390 { 0xf840, KEY_PLAYPAUSE },
1391 { 0xf81e, KEY_REWIND },
1392 { 0xf81b, KEY_FAVORITES },
1393 { 0xf81d, KEY_BACK },
1394 { 0xf84d, KEY_FASTFORWARD },
1395 { 0xf844, KEY_EPG },
1396 { 0xf84c, KEY_INFO },
1397 { 0xf841, KEY_AB },
1398 { 0xf843, KEY_AUDIO },
1399 { 0xf845, KEY_SUBTITLE },
1400 { 0xf84a, KEY_LIST },
1401 { 0xf846, KEY_F1 },
1402 { 0xf847, KEY_F2 },
1403 { 0xf85e, KEY_F3 },
1404 { 0xf85c, KEY_F4 },
1405 { 0xf852, KEY_F5 },
1406 { 0xf85a, KEY_F6 },
1407 { 0xf856, KEY_MODE },
1408 { 0xf858, KEY_SWITCHVIDEOMODE },
Igor M. Liplianinb42e1d72009-06-14 19:41:22 -03001409};
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001410
Mauro Carvalho Chehab2f4f58d2010-11-17 15:46:09 -03001411static struct rc_map_table rc_map_tbs_table[] = {
Mauro Carvalho Chehab2e365882009-08-29 15:19:31 -03001412 { 0xf884, KEY_POWER },
1413 { 0xf894, KEY_MUTE },
1414 { 0xf887, KEY_1 },
1415 { 0xf886, KEY_2 },
1416 { 0xf885, KEY_3 },
1417 { 0xf88b, KEY_4 },
1418 { 0xf88a, KEY_5 },
1419 { 0xf889, KEY_6 },
1420 { 0xf88f, KEY_7 },
1421 { 0xf88e, KEY_8 },
1422 { 0xf88d, KEY_9 },
1423 { 0xf892, KEY_0 },
1424 { 0xf896, KEY_CHANNELUP },
1425 { 0xf891, KEY_CHANNELDOWN },
1426 { 0xf893, KEY_VOLUMEUP },
1427 { 0xf88c, KEY_VOLUMEDOWN },
1428 { 0xf883, KEY_RECORD },
1429 { 0xf898, KEY_PAUSE },
1430 { 0xf899, KEY_OK },
1431 { 0xf89a, KEY_SHUFFLE },
1432 { 0xf881, KEY_UP },
1433 { 0xf890, KEY_LEFT },
1434 { 0xf882, KEY_RIGHT },
1435 { 0xf888, KEY_DOWN },
1436 { 0xf895, KEY_FAVORITES },
1437 { 0xf897, KEY_SUBTITLE },
1438 { 0xf89d, KEY_ZOOM },
1439 { 0xf89f, KEY_EXIT },
1440 { 0xf89e, KEY_MENU },
1441 { 0xf89c, KEY_EPG },
1442 { 0xf880, KEY_PREVIOUS },
1443 { 0xf89b, KEY_MODE }
Igor M. Liplianinb42e1d72009-06-14 19:41:22 -03001444};
1445
Igor M. Liplianind2ffc442011-02-25 18:41:22 -03001446static struct rc_map_table rc_map_su3000_table[] = {
1447 { 0x25, KEY_POWER }, /* right-bottom Red */
1448 { 0x0a, KEY_MUTE }, /* -/-- */
1449 { 0x01, KEY_1 },
1450 { 0x02, KEY_2 },
1451 { 0x03, KEY_3 },
1452 { 0x04, KEY_4 },
1453 { 0x05, KEY_5 },
1454 { 0x06, KEY_6 },
1455 { 0x07, KEY_7 },
1456 { 0x08, KEY_8 },
1457 { 0x09, KEY_9 },
1458 { 0x00, KEY_0 },
1459 { 0x20, KEY_UP }, /* CH+ */
1460 { 0x21, KEY_DOWN }, /* CH+ */
1461 { 0x12, KEY_VOLUMEUP }, /* Brightness Up */
1462 { 0x13, KEY_VOLUMEDOWN },/* Brightness Down */
1463 { 0x1f, KEY_RECORD },
1464 { 0x17, KEY_PLAY },
1465 { 0x16, KEY_PAUSE },
1466 { 0x0b, KEY_STOP },
1467 { 0x27, KEY_FASTFORWARD },/* >> */
1468 { 0x26, KEY_REWIND }, /* << */
1469 { 0x0d, KEY_OK }, /* Mute */
1470 { 0x11, KEY_LEFT }, /* VOL- */
1471 { 0x10, KEY_RIGHT }, /* VOL+ */
1472 { 0x29, KEY_BACK }, /* button under 9 */
1473 { 0x2c, KEY_MENU }, /* TTX */
1474 { 0x2b, KEY_EPG }, /* EPG */
1475 { 0x1e, KEY_RED }, /* OSD */
1476 { 0x0e, KEY_GREEN }, /* Window */
1477 { 0x2d, KEY_YELLOW }, /* button under << */
1478 { 0x0f, KEY_BLUE }, /* bottom yellow button */
1479 { 0x14, KEY_AUDIO }, /* Snapshot */
1480 { 0x38, KEY_TV }, /* TV/Radio */
Justin P. Mattock70f23fd2011-05-10 10:16:21 +02001481 { 0x0c, KEY_ESC } /* upper Red button */
Igor M. Liplianind2ffc442011-02-25 18:41:22 -03001482};
1483
Mauro Carvalho Chehab2f4f58d2010-11-17 15:46:09 -03001484static struct rc_map_dvb_usb_table_table keys_tables[] = {
1485 { rc_map_dw210x_table, ARRAY_SIZE(rc_map_dw210x_table) },
1486 { rc_map_tevii_table, ARRAY_SIZE(rc_map_tevii_table) },
1487 { rc_map_tbs_table, ARRAY_SIZE(rc_map_tbs_table) },
Igor M. Liplianind2ffc442011-02-25 18:41:22 -03001488 { rc_map_su3000_table, ARRAY_SIZE(rc_map_su3000_table) },
Igor M. Liplianinb42e1d72009-06-14 19:41:22 -03001489};
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001490
1491static int dw2102_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
1492{
Mauro Carvalho Chehab2f4f58d2010-11-17 15:46:09 -03001493 struct rc_map_table *keymap = d->props.rc.legacy.rc_map_table;
1494 int keymap_size = d->props.rc.legacy.rc_map_size;
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001495 u8 key[2];
Igor M. Liplianin8a8dad72009-06-13 08:10:24 -03001496 struct i2c_msg msg = {
1497 .addr = DW2102_RC_QUERY,
1498 .flags = I2C_M_RD,
1499 .buf = key,
1500 .len = 2
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001501 };
1502 int i;
Igor M. Liplianinb42e1d72009-06-14 19:41:22 -03001503 /* override keymap */
1504 if ((ir_keymap > 0) && (ir_keymap <= ARRAY_SIZE(keys_tables))) {
1505 keymap = keys_tables[ir_keymap - 1].rc_keys ;
1506 keymap_size = keys_tables[ir_keymap - 1].rc_keys_size;
Igor M. Liplianinfeb16e92011-02-25 18:41:22 -03001507 } else if (ir_keymap > ARRAY_SIZE(keys_tables))
1508 return 0; /* none */
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001509
1510 *state = REMOTE_NO_KEY_PRESSED;
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -03001511 if (d->props.i2c_algo->master_xfer(&d->i2c_adap, &msg, 1) == 1) {
Igor M. Liplianinb42e1d72009-06-14 19:41:22 -03001512 for (i = 0; i < keymap_size ; i++) {
Mauro Carvalho Chehab2e365882009-08-29 15:19:31 -03001513 if (rc5_data(&keymap[i]) == msg.buf[0]) {
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001514 *state = REMOTE_KEY_PRESSED;
Mauro Carvalho Chehab34abf212010-07-31 11:24:57 -03001515 *event = keymap[i].keycode;
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001516 break;
1517 }
Igor M. Liplianin8a8dad72009-06-13 08:10:24 -03001518
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001519 }
Igor M. Liplianin8a8dad72009-06-13 08:10:24 -03001520
1521 if ((*state) == REMOTE_KEY_PRESSED)
1522 deb_rc("%s: found rc key: %x, %x, event: %x\n",
1523 __func__, key[0], key[1], (*event));
1524 else if (key[0] != 0xff)
1525 deb_rc("%s: unknown rc key: %x, %x\n",
1526 __func__, key[0], key[1]);
1527
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001528 }
Igor M. Liplianin8a8dad72009-06-13 08:10:24 -03001529
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001530 return 0;
1531}
1532
Jonathan Nieder27351b12011-12-23 19:00:45 -03001533enum dw2102_table_entry {
1534 CYPRESS_DW2102,
1535 CYPRESS_DW2101,
1536 CYPRESS_DW2104,
1537 TEVII_S650,
1538 TERRATEC_CINERGY_S,
1539 CYPRESS_DW3101,
1540 TEVII_S630,
1541 PROF_1100,
1542 TEVII_S660,
1543 PROF_7500,
1544 GENIATECH_SU3000,
1545 TERRATEC_CINERGY_S2,
1546 TEVII_S480_1,
1547 TEVII_S480_2,
1548 X3M_SPC1400HD,
Igor M. Liplianin955d00a2012-05-08 03:53:17 -03001549 TEVII_S421,
1550 TEVII_S632,
Jonathan Nieder27351b12011-12-23 19:00:45 -03001551};
1552
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001553static struct usb_device_id dw2102_table[] = {
Jonathan Nieder27351b12011-12-23 19:00:45 -03001554 [CYPRESS_DW2102] = {USB_DEVICE(USB_VID_CYPRESS, USB_PID_DW2102)},
1555 [CYPRESS_DW2101] = {USB_DEVICE(USB_VID_CYPRESS, 0x2101)},
1556 [CYPRESS_DW2104] = {USB_DEVICE(USB_VID_CYPRESS, USB_PID_DW2104)},
1557 [TEVII_S650] = {USB_DEVICE(0x9022, USB_PID_TEVII_S650)},
1558 [TERRATEC_CINERGY_S] = {USB_DEVICE(USB_VID_TERRATEC, USB_PID_CINERGY_S)},
1559 [CYPRESS_DW3101] = {USB_DEVICE(USB_VID_CYPRESS, USB_PID_DW3101)},
1560 [TEVII_S630] = {USB_DEVICE(0x9022, USB_PID_TEVII_S630)},
1561 [PROF_1100] = {USB_DEVICE(0x3011, USB_PID_PROF_1100)},
1562 [TEVII_S660] = {USB_DEVICE(0x9022, USB_PID_TEVII_S660)},
1563 [PROF_7500] = {USB_DEVICE(0x3034, 0x7500)},
1564 [GENIATECH_SU3000] = {USB_DEVICE(0x1f4d, 0x3000)},
1565 [TERRATEC_CINERGY_S2] = {USB_DEVICE(USB_VID_TERRATEC, 0x00a8)},
1566 [TEVII_S480_1] = {USB_DEVICE(0x9022, USB_PID_TEVII_S480_1)},
1567 [TEVII_S480_2] = {USB_DEVICE(0x9022, USB_PID_TEVII_S480_2)},
1568 [X3M_SPC1400HD] = {USB_DEVICE(0x1f4d, 0x3100)},
Igor M. Liplianin955d00a2012-05-08 03:53:17 -03001569 [TEVII_S421] = {USB_DEVICE(0x9022, USB_PID_TEVII_S421)},
1570 [TEVII_S632] = {USB_DEVICE(0x9022, USB_PID_TEVII_S632)},
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001571 { }
1572};
1573
1574MODULE_DEVICE_TABLE(usb, dw2102_table);
1575
1576static int dw2102_load_firmware(struct usb_device *dev,
1577 const struct firmware *frmwr)
1578{
1579 u8 *b, *p;
1580 int ret = 0, i;
1581 u8 reset;
Igor M. Liplianin8a4949b2008-10-05 09:11:21 -03001582 u8 reset16[] = {0, 0, 0, 0, 0, 0, 0};
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001583 const struct firmware *fw;
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -03001584
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001585 switch (dev->descriptor.idProduct) {
1586 case 0x2101:
Rémi Cardona68236272012-09-28 08:59:32 -03001587 ret = request_firmware(&fw, DW2101_FIRMWARE, &dev->dev);
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001588 if (ret != 0) {
Rémi Cardona68236272012-09-28 08:59:32 -03001589 err(err_str, DW2101_FIRMWARE);
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001590 return ret;
1591 }
1592 break;
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001593 default:
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001594 fw = frmwr;
1595 break;
1596 }
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001597 info("start downloading DW210X firmware");
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001598 p = kmalloc(fw->size, GFP_KERNEL);
1599 reset = 1;
1600 /*stop the CPU*/
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001601 dw210x_op_rw(dev, 0xa0, 0x7f92, 0, &reset, 1, DW210X_WRITE_MSG);
1602 dw210x_op_rw(dev, 0xa0, 0xe600, 0, &reset, 1, DW210X_WRITE_MSG);
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001603
1604 if (p != NULL) {
1605 memcpy(p, fw->data, fw->size);
1606 for (i = 0; i < fw->size; i += 0x40) {
1607 b = (u8 *) p + i;
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001608 if (dw210x_op_rw(dev, 0xa0, i, 0, b , 0x40,
1609 DW210X_WRITE_MSG) != 0x40) {
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001610 err("error while transferring firmware");
1611 ret = -EINVAL;
1612 break;
1613 }
1614 }
1615 /* restart the CPU */
1616 reset = 0;
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001617 if (ret || dw210x_op_rw(dev, 0xa0, 0x7f92, 0, &reset, 1,
1618 DW210X_WRITE_MSG) != 1) {
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001619 err("could not restart the USB controller CPU.");
1620 ret = -EINVAL;
1621 }
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001622 if (ret || dw210x_op_rw(dev, 0xa0, 0xe600, 0, &reset, 1,
1623 DW210X_WRITE_MSG) != 1) {
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001624 err("could not restart the USB controller CPU.");
1625 ret = -EINVAL;
1626 }
1627 /* init registers */
1628 switch (dev->descriptor.idProduct) {
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001629 case USB_PID_TEVII_S650:
Mauro Carvalho Chehab2f4f58d2010-11-17 15:46:09 -03001630 dw2104_properties.rc.legacy.rc_map_table = rc_map_tevii_table;
1631 dw2104_properties.rc.legacy.rc_map_size =
1632 ARRAY_SIZE(rc_map_tevii_table);
Igor M. Liplianinb42e1d72009-06-14 19:41:22 -03001633 case USB_PID_DW2104:
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001634 reset = 1;
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001635 dw210x_op_rw(dev, 0xc4, 0x0000, 0, &reset, 1,
1636 DW210X_WRITE_MSG);
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001637 /* break omitted intentionally */
1638 case USB_PID_DW3101:
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001639 reset = 0;
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001640 dw210x_op_rw(dev, 0xbf, 0x0040, 0, &reset, 0,
1641 DW210X_WRITE_MSG);
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001642 break;
Igor M. Liplianin4cc0edf2008-11-05 22:12:56 -03001643 case USB_PID_CINERGY_S:
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001644 case USB_PID_DW2102:
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001645 dw210x_op_rw(dev, 0xbf, 0x0040, 0, &reset, 0,
1646 DW210X_WRITE_MSG);
1647 dw210x_op_rw(dev, 0xb9, 0x0000, 0, &reset16[0], 2,
1648 DW210X_READ_MSG);
1649 /* check STV0299 frontend */
1650 dw210x_op_rw(dev, 0xb5, 0, 0, &reset16[0], 2,
1651 DW210X_READ_MSG);
Igor M. Liplianinea023df2008-12-04 12:49:23 -03001652 if ((reset16[0] == 0xa1) || (reset16[0] == 0x80)) {
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001653 dw2102_properties.i2c_algo = &dw2102_i2c_algo;
Michael Krufky77eed212011-09-06 09:31:57 -03001654 dw2102_properties.adapter->fe[0].tuner_attach = &dw2102_tuner_attach;
Igor M. Liplianin8a4949b2008-10-05 09:11:21 -03001655 break;
1656 } else {
1657 /* check STV0288 frontend */
1658 reset16[0] = 0xd0;
1659 reset16[1] = 1;
1660 reset16[2] = 0;
1661 dw210x_op_rw(dev, 0xc2, 0, 0, &reset16[0], 3,
1662 DW210X_WRITE_MSG);
1663 dw210x_op_rw(dev, 0xc3, 0xd1, 0, &reset16[0], 3,
1664 DW210X_READ_MSG);
1665 if (reset16[2] == 0x11) {
1666 dw2102_properties.i2c_algo = &dw2102_earda_i2c_algo;
Igor M. Liplianin8a4949b2008-10-05 09:11:21 -03001667 break;
1668 }
1669 }
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001670 case 0x2101:
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001671 dw210x_op_rw(dev, 0xbc, 0x0030, 0, &reset16[0], 2,
1672 DW210X_READ_MSG);
1673 dw210x_op_rw(dev, 0xba, 0x0000, 0, &reset16[0], 7,
1674 DW210X_READ_MSG);
1675 dw210x_op_rw(dev, 0xba, 0x0000, 0, &reset16[0], 7,
1676 DW210X_READ_MSG);
1677 dw210x_op_rw(dev, 0xb9, 0x0000, 0, &reset16[0], 2,
1678 DW210X_READ_MSG);
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001679 break;
1680 }
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001681
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001682 msleep(100);
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001683 kfree(p);
1684 }
1685 return ret;
1686}
1687
1688static struct dvb_usb_device_properties dw2102_properties = {
1689 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1690 .usb_ctrl = DEVICE_SPECIFIC,
Rémi Cardona68236272012-09-28 08:59:32 -03001691 .firmware = DW2102_FIRMWARE,
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001692 .no_reconnect = 1,
1693
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001694 .i2c_algo = &dw2102_serit_i2c_algo,
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03001695
1696 .rc.legacy = {
Mauro Carvalho Chehab2f4f58d2010-11-17 15:46:09 -03001697 .rc_map_table = rc_map_dw210x_table,
1698 .rc_map_size = ARRAY_SIZE(rc_map_dw210x_table),
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03001699 .rc_interval = 150,
1700 .rc_query = dw2102_rc_query,
1701 },
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001702
1703 .generic_bulk_ctrl_endpoint = 0x81,
1704 /* parameter for the MPEG2-data transfer */
1705 .num_adapters = 1,
1706 .download_firmware = dw2102_load_firmware,
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001707 .read_mac_address = dw210x_read_mac_address,
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001708 .adapter = {
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001709 {
Michael Krufky77eed212011-09-06 09:31:57 -03001710 .num_frontends = 1,
1711 .fe = {{
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001712 .frontend_attach = dw2102_frontend_attach,
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001713 .stream = {
1714 .type = USB_BULK,
1715 .count = 8,
1716 .endpoint = 0x82,
1717 .u = {
1718 .bulk = {
1719 .buffersize = 4096,
1720 }
1721 }
1722 },
Michael Krufky77eed212011-09-06 09:31:57 -03001723 }},
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001724 }
1725 },
Igor M. Liplianin4cc0edf2008-11-05 22:12:56 -03001726 .num_device_descs = 3,
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001727 .devices = {
1728 {"DVBWorld DVB-S 2102 USB2.0",
Jonathan Nieder27351b12011-12-23 19:00:45 -03001729 {&dw2102_table[CYPRESS_DW2102], NULL},
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001730 {NULL},
1731 },
1732 {"DVBWorld DVB-S 2101 USB2.0",
Jonathan Nieder27351b12011-12-23 19:00:45 -03001733 {&dw2102_table[CYPRESS_DW2101], NULL},
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001734 {NULL},
1735 },
Igor M. Liplianin4cc0edf2008-11-05 22:12:56 -03001736 {"TerraTec Cinergy S USB",
Jonathan Nieder27351b12011-12-23 19:00:45 -03001737 {&dw2102_table[TERRATEC_CINERGY_S], NULL},
Igor M. Liplianin4cc0edf2008-11-05 22:12:56 -03001738 {NULL},
1739 },
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001740 }
1741};
1742
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001743static struct dvb_usb_device_properties dw2104_properties = {
1744 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1745 .usb_ctrl = DEVICE_SPECIFIC,
Rémi Cardona68236272012-09-28 08:59:32 -03001746 .firmware = DW2104_FIRMWARE,
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001747 .no_reconnect = 1,
1748
1749 .i2c_algo = &dw2104_i2c_algo,
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03001750 .rc.legacy = {
Mauro Carvalho Chehab2f4f58d2010-11-17 15:46:09 -03001751 .rc_map_table = rc_map_dw210x_table,
1752 .rc_map_size = ARRAY_SIZE(rc_map_dw210x_table),
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03001753 .rc_interval = 150,
1754 .rc_query = dw2102_rc_query,
1755 },
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001756
1757 .generic_bulk_ctrl_endpoint = 0x81,
1758 /* parameter for the MPEG2-data transfer */
1759 .num_adapters = 1,
1760 .download_firmware = dw2102_load_firmware,
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001761 .read_mac_address = dw210x_read_mac_address,
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001762 .adapter = {
1763 {
Michael Krufky77eed212011-09-06 09:31:57 -03001764 .num_frontends = 1,
1765 .fe = {{
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001766 .frontend_attach = dw2104_frontend_attach,
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001767 .stream = {
1768 .type = USB_BULK,
1769 .count = 8,
1770 .endpoint = 0x82,
1771 .u = {
1772 .bulk = {
1773 .buffersize = 4096,
1774 }
1775 }
1776 },
Michael Krufky77eed212011-09-06 09:31:57 -03001777 }},
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001778 }
1779 },
1780 .num_device_descs = 2,
1781 .devices = {
1782 { "DVBWorld DW2104 USB2.0",
Jonathan Nieder27351b12011-12-23 19:00:45 -03001783 {&dw2102_table[CYPRESS_DW2104], NULL},
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001784 {NULL},
1785 },
1786 { "TeVii S650 USB2.0",
Jonathan Nieder27351b12011-12-23 19:00:45 -03001787 {&dw2102_table[TEVII_S650], NULL},
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001788 {NULL},
1789 },
1790 }
1791};
1792
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001793static struct dvb_usb_device_properties dw3101_properties = {
1794 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1795 .usb_ctrl = DEVICE_SPECIFIC,
Rémi Cardona68236272012-09-28 08:59:32 -03001796 .firmware = DW3101_FIRMWARE,
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001797 .no_reconnect = 1,
1798
1799 .i2c_algo = &dw3101_i2c_algo,
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03001800 .rc.legacy = {
Mauro Carvalho Chehab2f4f58d2010-11-17 15:46:09 -03001801 .rc_map_table = rc_map_dw210x_table,
1802 .rc_map_size = ARRAY_SIZE(rc_map_dw210x_table),
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03001803 .rc_interval = 150,
1804 .rc_query = dw2102_rc_query,
1805 },
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001806
1807 .generic_bulk_ctrl_endpoint = 0x81,
1808 /* parameter for the MPEG2-data transfer */
1809 .num_adapters = 1,
1810 .download_firmware = dw2102_load_firmware,
1811 .read_mac_address = dw210x_read_mac_address,
1812 .adapter = {
1813 {
Michael Krufky77eed212011-09-06 09:31:57 -03001814 .num_frontends = 1,
1815 .fe = {{
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001816 .frontend_attach = dw3101_frontend_attach,
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001817 .tuner_attach = dw3101_tuner_attach,
1818 .stream = {
1819 .type = USB_BULK,
1820 .count = 8,
1821 .endpoint = 0x82,
1822 .u = {
1823 .bulk = {
1824 .buffersize = 4096,
1825 }
1826 }
1827 },
Michael Krufky77eed212011-09-06 09:31:57 -03001828 }},
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001829 }
1830 },
1831 .num_device_descs = 1,
1832 .devices = {
1833 { "DVBWorld DVB-C 3101 USB2.0",
Jonathan Nieder27351b12011-12-23 19:00:45 -03001834 {&dw2102_table[CYPRESS_DW3101], NULL},
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001835 {NULL},
1836 },
1837 }
1838};
1839
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001840static struct dvb_usb_device_properties s6x0_properties = {
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -03001841 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1842 .usb_ctrl = DEVICE_SPECIFIC,
Igor M. Liplianin52c506e2011-02-25 18:41:23 -03001843 .size_of_priv = sizeof(struct s6x0_state),
Rémi Cardona68236272012-09-28 08:59:32 -03001844 .firmware = S630_FIRMWARE,
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -03001845 .no_reconnect = 1,
1846
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001847 .i2c_algo = &s6x0_i2c_algo,
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03001848 .rc.legacy = {
Mauro Carvalho Chehab2f4f58d2010-11-17 15:46:09 -03001849 .rc_map_table = rc_map_tevii_table,
1850 .rc_map_size = ARRAY_SIZE(rc_map_tevii_table),
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03001851 .rc_interval = 150,
1852 .rc_query = dw2102_rc_query,
1853 },
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -03001854
1855 .generic_bulk_ctrl_endpoint = 0x81,
1856 .num_adapters = 1,
1857 .download_firmware = dw2102_load_firmware,
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001858 .read_mac_address = s6x0_read_mac_address,
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -03001859 .adapter = {
1860 {
Michael Krufky77eed212011-09-06 09:31:57 -03001861 .num_frontends = 1,
1862 .fe = {{
Igor M. Liplianin195288d2011-02-25 18:41:22 -03001863 .frontend_attach = zl100313_frontend_attach,
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -03001864 .stream = {
1865 .type = USB_BULK,
1866 .count = 8,
1867 .endpoint = 0x82,
1868 .u = {
1869 .bulk = {
1870 .buffersize = 4096,
1871 }
1872 }
1873 },
Michael Krufky77eed212011-09-06 09:31:57 -03001874 }},
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -03001875 }
1876 },
Igor M. Liplianin195288d2011-02-25 18:41:22 -03001877 .num_device_descs = 1,
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -03001878 .devices = {
1879 {"TeVii S630 USB",
Jonathan Nieder27351b12011-12-23 19:00:45 -03001880 {&dw2102_table[TEVII_S630], NULL},
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -03001881 {NULL},
1882 },
1883 }
1884};
1885
Igor M. Liplianin195288d2011-02-25 18:41:22 -03001886struct dvb_usb_device_properties *p1100;
1887static struct dvb_usb_device_description d1100 = {
1888 "Prof 1100 USB ",
Jonathan Nieder27351b12011-12-23 19:00:45 -03001889 {&dw2102_table[PROF_1100], NULL},
Igor M. Liplianin195288d2011-02-25 18:41:22 -03001890 {NULL},
1891};
1892
1893struct dvb_usb_device_properties *s660;
1894static struct dvb_usb_device_description d660 = {
1895 "TeVii S660 USB",
Jonathan Nieder27351b12011-12-23 19:00:45 -03001896 {&dw2102_table[TEVII_S660], NULL},
Igor M. Liplianin195288d2011-02-25 18:41:22 -03001897 {NULL},
1898};
1899
Igor M. Liplianine8f50552011-02-25 18:41:23 -03001900static struct dvb_usb_device_description d480_1 = {
1901 "TeVii S480.1 USB",
Jonathan Nieder27351b12011-12-23 19:00:45 -03001902 {&dw2102_table[TEVII_S480_1], NULL},
Igor M. Liplianine8f50552011-02-25 18:41:23 -03001903 {NULL},
1904};
1905
1906static struct dvb_usb_device_description d480_2 = {
1907 "TeVii S480.2 USB",
Jonathan Nieder27351b12011-12-23 19:00:45 -03001908 {&dw2102_table[TEVII_S480_2], NULL},
Igor M. Liplianine8f50552011-02-25 18:41:23 -03001909 {NULL},
1910};
1911
Igor M. Liplianincd79d332009-12-14 20:24:56 -03001912struct dvb_usb_device_properties *p7500;
1913static struct dvb_usb_device_description d7500 = {
1914 "Prof 7500 USB DVB-S2",
Jonathan Nieder27351b12011-12-23 19:00:45 -03001915 {&dw2102_table[PROF_7500], NULL},
Igor M. Liplianincd79d332009-12-14 20:24:56 -03001916 {NULL},
1917};
1918
Igor M. Liplianin955d00a2012-05-08 03:53:17 -03001919struct dvb_usb_device_properties *s421;
1920static struct dvb_usb_device_description d421 = {
1921 "TeVii S421 PCI",
1922 {&dw2102_table[TEVII_S421], NULL},
1923 {NULL},
1924};
1925
1926static struct dvb_usb_device_description d632 = {
1927 "TeVii S632 USB",
1928 {&dw2102_table[TEVII_S632], NULL},
1929 {NULL},
1930};
1931
Igor M. Liplianind2ffc442011-02-25 18:41:22 -03001932static struct dvb_usb_device_properties su3000_properties = {
1933 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1934 .usb_ctrl = DEVICE_SPECIFIC,
1935 .size_of_priv = sizeof(struct su3000_state),
1936 .power_ctrl = su3000_power_ctrl,
1937 .num_adapters = 1,
1938 .identify_state = su3000_identify_state,
1939 .i2c_algo = &su3000_i2c_algo,
1940
1941 .rc.legacy = {
1942 .rc_map_table = rc_map_su3000_table,
1943 .rc_map_size = ARRAY_SIZE(rc_map_su3000_table),
1944 .rc_interval = 150,
1945 .rc_query = dw2102_rc_query,
1946 },
1947
1948 .read_mac_address = su3000_read_mac_address,
1949
1950 .generic_bulk_ctrl_endpoint = 0x01,
1951
1952 .adapter = {
1953 {
Michael Krufky77eed212011-09-06 09:31:57 -03001954 .num_frontends = 1,
1955 .fe = {{
Igor M. Liplianind2ffc442011-02-25 18:41:22 -03001956 .streaming_ctrl = su3000_streaming_ctrl,
1957 .frontend_attach = su3000_frontend_attach,
1958 .stream = {
1959 .type = USB_BULK,
1960 .count = 8,
1961 .endpoint = 0x82,
1962 .u = {
1963 .bulk = {
1964 .buffersize = 4096,
1965 }
1966 }
1967 }
Michael Krufky77eed212011-09-06 09:31:57 -03001968 }},
Igor M. Liplianind2ffc442011-02-25 18:41:22 -03001969 }
1970 },
Mauro Carvalho Chehabb7e38632012-07-07 00:19:20 -03001971 .num_device_descs = 3,
Igor M. Liplianind2ffc442011-02-25 18:41:22 -03001972 .devices = {
1973 { "SU3000HD DVB-S USB2.0",
Jonathan Nieder27351b12011-12-23 19:00:45 -03001974 { &dw2102_table[GENIATECH_SU3000], NULL },
Igor M. Liplianind2ffc442011-02-25 18:41:22 -03001975 { NULL },
1976 },
Igor M. Liplianin2adc5912011-02-25 18:41:22 -03001977 { "Terratec Cinergy S2 USB HD",
Jonathan Nieder27351b12011-12-23 19:00:45 -03001978 { &dw2102_table[TERRATEC_CINERGY_S2], NULL },
Igor M. Liplianin2adc5912011-02-25 18:41:22 -03001979 { NULL },
1980 },
Igor M. Liplianin5265ea52011-02-27 16:17:25 -03001981 { "X3M TV SPC1400HD PCI",
Jonathan Nieder27351b12011-12-23 19:00:45 -03001982 { &dw2102_table[X3M_SPC1400HD], NULL },
Igor M. Liplianin5265ea52011-02-27 16:17:25 -03001983 { NULL },
1984 },
Igor M. Liplianind2ffc442011-02-25 18:41:22 -03001985 }
1986};
1987
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001988static int dw2102_probe(struct usb_interface *intf,
1989 const struct usb_device_id *id)
1990{
Thomas Meyer68dd9dd2011-11-17 18:43:40 -03001991 p1100 = kmemdup(&s6x0_properties,
1992 sizeof(struct dvb_usb_device_properties), GFP_KERNEL);
Igor M. Liplianin195288d2011-02-25 18:41:22 -03001993 if (!p1100)
Igor M. Liplianincd79d332009-12-14 20:24:56 -03001994 return -ENOMEM;
1995 /* copy default structure */
Igor M. Liplianincd79d332009-12-14 20:24:56 -03001996 /* fill only different fields */
Rémi Cardona68236272012-09-28 08:59:32 -03001997 p1100->firmware = P1100_FIRMWARE;
Igor M. Liplianin195288d2011-02-25 18:41:22 -03001998 p1100->devices[0] = d1100;
1999 p1100->rc.legacy.rc_map_table = rc_map_tbs_table;
2000 p1100->rc.legacy.rc_map_size = ARRAY_SIZE(rc_map_tbs_table);
Michael Krufky77eed212011-09-06 09:31:57 -03002001 p1100->adapter->fe[0].frontend_attach = stv0288_frontend_attach;
Igor M. Liplianin195288d2011-02-25 18:41:22 -03002002
Thomas Meyer68dd9dd2011-11-17 18:43:40 -03002003 s660 = kmemdup(&s6x0_properties,
2004 sizeof(struct dvb_usb_device_properties), GFP_KERNEL);
Igor M. Liplianin195288d2011-02-25 18:41:22 -03002005 if (!s660) {
2006 kfree(p1100);
2007 return -ENOMEM;
2008 }
Rémi Cardona68236272012-09-28 08:59:32 -03002009 s660->firmware = S660_FIRMWARE;
Igor M. Liplianine8f50552011-02-25 18:41:23 -03002010 s660->num_device_descs = 3;
Igor M. Liplianin195288d2011-02-25 18:41:22 -03002011 s660->devices[0] = d660;
Igor M. Liplianine8f50552011-02-25 18:41:23 -03002012 s660->devices[1] = d480_1;
2013 s660->devices[2] = d480_2;
Michael Krufky77eed212011-09-06 09:31:57 -03002014 s660->adapter->fe[0].frontend_attach = ds3000_frontend_attach;
Igor M. Liplianin195288d2011-02-25 18:41:22 -03002015
Thomas Meyer68dd9dd2011-11-17 18:43:40 -03002016 p7500 = kmemdup(&s6x0_properties,
2017 sizeof(struct dvb_usb_device_properties), GFP_KERNEL);
Igor M. Liplianin195288d2011-02-25 18:41:22 -03002018 if (!p7500) {
2019 kfree(p1100);
2020 kfree(s660);
2021 return -ENOMEM;
2022 }
Rémi Cardona68236272012-09-28 08:59:32 -03002023 p7500->firmware = P7500_FIRMWARE;
Igor M. Liplianincd79d332009-12-14 20:24:56 -03002024 p7500->devices[0] = d7500;
Mauro Carvalho Chehab2f4f58d2010-11-17 15:46:09 -03002025 p7500->rc.legacy.rc_map_table = rc_map_tbs_table;
2026 p7500->rc.legacy.rc_map_size = ARRAY_SIZE(rc_map_tbs_table);
Michael Krufky77eed212011-09-06 09:31:57 -03002027 p7500->adapter->fe[0].frontend_attach = prof_7500_frontend_attach;
Igor M. Liplianincd79d332009-12-14 20:24:56 -03002028
Igor M. Liplianin955d00a2012-05-08 03:53:17 -03002029
2030 s421 = kmemdup(&su3000_properties,
2031 sizeof(struct dvb_usb_device_properties), GFP_KERNEL);
2032 if (!s421) {
2033 kfree(p1100);
2034 kfree(s660);
2035 kfree(p7500);
2036 return -ENOMEM;
2037 }
2038 s421->num_device_descs = 2;
2039 s421->devices[0] = d421;
2040 s421->devices[1] = d632;
2041 s421->adapter->fe[0].frontend_attach = m88rs2000_frontend_attach;
2042
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03002043 if (0 == dvb_usb_device_init(intf, &dw2102_properties,
2044 THIS_MODULE, NULL, adapter_nr) ||
2045 0 == dvb_usb_device_init(intf, &dw2104_properties,
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03002046 THIS_MODULE, NULL, adapter_nr) ||
2047 0 == dvb_usb_device_init(intf, &dw3101_properties,
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -03002048 THIS_MODULE, NULL, adapter_nr) ||
Igor M. Liplianin141cc352009-11-27 14:37:35 -03002049 0 == dvb_usb_device_init(intf, &s6x0_properties,
Igor M. Liplianincd79d332009-12-14 20:24:56 -03002050 THIS_MODULE, NULL, adapter_nr) ||
Igor M. Liplianin195288d2011-02-25 18:41:22 -03002051 0 == dvb_usb_device_init(intf, p1100,
2052 THIS_MODULE, NULL, adapter_nr) ||
2053 0 == dvb_usb_device_init(intf, s660,
2054 THIS_MODULE, NULL, adapter_nr) ||
Igor M. Liplianincd79d332009-12-14 20:24:56 -03002055 0 == dvb_usb_device_init(intf, p7500,
Igor M. Liplianind2ffc442011-02-25 18:41:22 -03002056 THIS_MODULE, NULL, adapter_nr) ||
Igor M. Liplianin955d00a2012-05-08 03:53:17 -03002057 0 == dvb_usb_device_init(intf, s421,
2058 THIS_MODULE, NULL, adapter_nr) ||
Igor M. Liplianind2ffc442011-02-25 18:41:22 -03002059 0 == dvb_usb_device_init(intf, &su3000_properties,
2060 THIS_MODULE, NULL, adapter_nr))
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03002061 return 0;
Igor M. Liplianin141cc352009-11-27 14:37:35 -03002062
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03002063 return -ENODEV;
Igor M Liplianin7fd48282008-07-20 08:05:50 -03002064}
2065
2066static struct usb_driver dw2102_driver = {
2067 .name = "dw2102",
2068 .probe = dw2102_probe,
2069 .disconnect = dvb_usb_device_exit,
2070 .id_table = dw2102_table,
2071};
2072
Greg Kroah-Hartmanecb3b2b2011-11-18 09:46:12 -08002073module_usb_driver(dw2102_driver);
Igor M Liplianin7fd48282008-07-20 08:05:50 -03002074
2075MODULE_AUTHOR("Igor M. Liplianin (c) liplianin@me.by");
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03002076MODULE_DESCRIPTION("Driver for DVBWorld DVB-S 2101, 2102, DVB-S2 2104,"
Igor M. Liplianin955d00a2012-05-08 03:53:17 -03002077 " DVB-C 3101 USB2.0,"
2078 " TeVii S600, S630, S650, S660, S480, S421, S632"
2079 " Prof 1100, 7500 USB2.0,"
2080 " Geniatech SU3000 devices");
Igor M Liplianin7fd48282008-07-20 08:05:50 -03002081MODULE_VERSION("0.1");
2082MODULE_LICENSE("GPL");
Rémi Cardona68236272012-09-28 08:59:32 -03002083MODULE_FIRMWARE(DW2101_FIRMWARE);
2084MODULE_FIRMWARE(DW2102_FIRMWARE);
2085MODULE_FIRMWARE(DW2104_FIRMWARE);
2086MODULE_FIRMWARE(DW3101_FIRMWARE);
2087MODULE_FIRMWARE(S630_FIRMWARE);
2088MODULE_FIRMWARE(S660_FIRMWARE);
2089MODULE_FIRMWARE(P1100_FIRMWARE);
2090MODULE_FIRMWARE(P7500_FIRMWARE);