blob: 6e237b6dd0a8d8acb5bba115152e5b060775e680 [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 Liplianin7fd48282008-07-20 08:05:50 -030032
33#ifndef USB_PID_DW2102
34#define USB_PID_DW2102 0x2102
35#endif
36
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -030037#ifndef USB_PID_DW2104
38#define USB_PID_DW2104 0x2104
39#endif
40
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -030041#ifndef USB_PID_DW3101
42#define USB_PID_DW3101 0x3101
43#endif
44
Igor M. Liplianin4cc0edf2008-11-05 22:12:56 -030045#ifndef USB_PID_CINERGY_S
46#define USB_PID_CINERGY_S 0x0064
47#endif
48
Igor M. Liplianin141cc352009-11-27 14:37:35 -030049#ifndef USB_PID_TEVII_S630
50#define USB_PID_TEVII_S630 0xd630
51#endif
52
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -030053#ifndef USB_PID_TEVII_S650
54#define USB_PID_TEVII_S650 0xd650
55#endif
56
Igor M. Liplianin141cc352009-11-27 14:37:35 -030057#ifndef USB_PID_TEVII_S660
58#define USB_PID_TEVII_S660 0xd660
59#endif
60
Igor M. Liplianine8f50552011-02-25 18:41:23 -030061#ifndef USB_PID_TEVII_S480_1
62#define USB_PID_TEVII_S480_1 0xd481
63#endif
64
65#ifndef USB_PID_TEVII_S480_2
66#define USB_PID_TEVII_S480_2 0xd482
67#endif
68
Igor M. Liplianin141cc352009-11-27 14:37:35 -030069#ifndef USB_PID_PROF_1100
70#define USB_PID_PROF_1100 0xb012
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -030071#endif
72
Igor M. Liplianin955d00a2012-05-08 03:53:17 -030073#ifndef USB_PID_TEVII_S421
74#define USB_PID_TEVII_S421 0xd421
75#endif
76
77#ifndef USB_PID_TEVII_S632
78#define USB_PID_TEVII_S632 0xd632
79#endif
80
Andrey Pavlenkof08e9f02013-03-07 09:36:22 -030081#ifndef USB_PID_GOTVIEW_SAT_HD
82#define USB_PID_GOTVIEW_SAT_HD 0x5456
83#endif
84
Igor M. Liplianin21b007b2008-09-17 19:19:19 -030085#define DW210X_READ_MSG 0
86#define DW210X_WRITE_MSG 1
Igor M Liplianin7fd48282008-07-20 08:05:50 -030087
88#define REG_1F_SYMBOLRATE_BYTE0 0x1f
89#define REG_20_SYMBOLRATE_BYTE1 0x20
90#define REG_21_SYMBOLRATE_BYTE2 0x21
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -030091/* on my own*/
Igor M Liplianin7fd48282008-07-20 08:05:50 -030092#define DW2102_VOLTAGE_CTRL (0x1800)
Igor M. Liplianind2ffc442011-02-25 18:41:22 -030093#define SU3000_STREAM_CTRL (0x1900)
Igor M Liplianin7fd48282008-07-20 08:05:50 -030094#define DW2102_RC_QUERY (0x1a00)
Igor M. Liplianinfa8bae12011-02-25 18:41:22 -030095#define DW2102_LED_CTRL (0x1b00)
Igor M Liplianin7fd48282008-07-20 08:05:50 -030096
Rémi Cardona68236272012-09-28 08:59:32 -030097#define DW2101_FIRMWARE "dvb-usb-dw2101.fw"
98#define DW2102_FIRMWARE "dvb-usb-dw2102.fw"
99#define DW2104_FIRMWARE "dvb-usb-dw2104.fw"
100#define DW3101_FIRMWARE "dvb-usb-dw3101.fw"
101#define S630_FIRMWARE "dvb-usb-s630.fw"
102#define S660_FIRMWARE "dvb-usb-s660.fw"
103#define P1100_FIRMWARE "dvb-usb-p1100.fw"
104#define P7500_FIRMWARE "dvb-usb-p7500.fw"
105
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300106#define err_str "did not find the firmware file. (%s) " \
107 "Please see linux/Documentation/dvb/ for more details " \
108 "on firmware-problems."
109
Mauro Carvalho Chehab2f4f58d2010-11-17 15:46:09 -0300110struct rc_map_dvb_usb_table_table {
111 struct rc_map_table *rc_keys;
Igor M. Liplianinb42e1d72009-06-14 19:41:22 -0300112 int rc_keys_size;
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300113};
114
Igor M. Liplianind2ffc442011-02-25 18:41:22 -0300115struct su3000_state {
116 u8 initialized;
117};
118
Igor M. Liplianin52c506e2011-02-25 18:41:23 -0300119struct s6x0_state {
120 int (*old_set_voltage)(struct dvb_frontend *f, fe_sec_voltage_t v);
121};
122
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300123/* debug */
124static int dvb_usb_dw2102_debug;
125module_param_named(debug, dvb_usb_dw2102_debug, int, 0644);
Igor M. Liplianin8a8dad72009-06-13 08:10:24 -0300126MODULE_PARM_DESC(debug, "set debugging level (1=info 2=xfer 4=rc(or-able))."
127 DVB_USB_DEBUG_STATUS);
128
Igor M. Liplianinb42e1d72009-06-14 19:41:22 -0300129/* keymaps */
130static int ir_keymap;
131module_param_named(keymap, ir_keymap, int, 0644);
Igor M. Liplianinfeb16e92011-02-25 18:41:22 -0300132MODULE_PARM_DESC(keymap, "set keymap 0=default 1=dvbworld 2=tevii 3=tbs ..."
133 " 256=none");
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300134
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300135/* demod probe */
136static int demod_probe = 1;
137module_param_named(demod, demod_probe, int, 0644);
138MODULE_PARM_DESC(demod, "demod to probe (1=cx24116 2=stv0903+stv6110 "
139 "4=stv0903+stb6100(or-able)).");
140
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300141DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
142
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300143static int dw210x_op_rw(struct usb_device *dev, u8 request, u16 value,
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300144 u16 index, u8 * data, u16 len, int flags)
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300145{
146 int ret;
Florian Micklerb47b8502011-03-21 15:33:44 -0300147 u8 *u8buf;
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300148 unsigned int pipe = (flags == DW210X_READ_MSG) ?
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300149 usb_rcvctrlpipe(dev, 0) : usb_sndctrlpipe(dev, 0);
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300150 u8 request_type = (flags == DW210X_READ_MSG) ? USB_DIR_IN : USB_DIR_OUT;
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300151
Florian Micklerb47b8502011-03-21 15:33:44 -0300152 u8buf = kmalloc(len, GFP_KERNEL);
153 if (!u8buf)
154 return -ENOMEM;
155
156
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300157 if (flags == DW210X_WRITE_MSG)
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300158 memcpy(u8buf, data, len);
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300159 ret = usb_control_msg(dev, pipe, request, request_type | USB_TYPE_VENDOR,
160 value, index , u8buf, len, 2000);
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300161
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300162 if (flags == DW210X_READ_MSG)
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300163 memcpy(data, u8buf, len);
Florian Micklerb47b8502011-03-21 15:33:44 -0300164
165 kfree(u8buf);
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300166 return ret;
167}
168
169/* I2C */
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300170static int dw2102_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],
171 int num)
172{
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -0300173 struct dvb_usb_device *d = i2c_get_adapdata(adap);
Hans Verkuild51dbec2012-04-20 03:30:11 -0300174 int i = 0;
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300175 u8 buf6[] = {0x2c, 0x05, 0xc0, 0, 0, 0, 0};
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300176 u16 value;
177
178 if (!d)
179 return -ENODEV;
180 if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
181 return -EAGAIN;
182
183 switch (num) {
184 case 2:
185 /* read stv0299 register */
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300186 value = msg[0].buf[0];/* register */
187 for (i = 0; i < msg[1].len; i++) {
Hans Verkuild51dbec2012-04-20 03:30:11 -0300188 dw210x_op_rw(d->udev, 0xb5, value + i, 0,
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300189 buf6, 2, DW210X_READ_MSG);
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300190 msg[1].buf[i] = buf6[0];
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300191 }
192 break;
193 case 1:
194 switch (msg[0].addr) {
195 case 0x68:
196 /* write to stv0299 register */
197 buf6[0] = 0x2a;
198 buf6[1] = msg[0].buf[0];
199 buf6[2] = msg[0].buf[1];
Hans Verkuild51dbec2012-04-20 03:30:11 -0300200 dw210x_op_rw(d->udev, 0xb2, 0, 0,
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300201 buf6, 3, DW210X_WRITE_MSG);
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300202 break;
203 case 0x60:
204 if (msg[0].flags == 0) {
205 /* write to tuner pll */
206 buf6[0] = 0x2c;
207 buf6[1] = 5;
208 buf6[2] = 0xc0;
209 buf6[3] = msg[0].buf[0];
210 buf6[4] = msg[0].buf[1];
211 buf6[5] = msg[0].buf[2];
212 buf6[6] = msg[0].buf[3];
Hans Verkuild51dbec2012-04-20 03:30:11 -0300213 dw210x_op_rw(d->udev, 0xb2, 0, 0,
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300214 buf6, 7, DW210X_WRITE_MSG);
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300215 } else {
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300216 /* read from tuner */
Hans Verkuild51dbec2012-04-20 03:30:11 -0300217 dw210x_op_rw(d->udev, 0xb5, 0, 0,
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300218 buf6, 1, DW210X_READ_MSG);
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300219 msg[0].buf[0] = buf6[0];
220 }
221 break;
222 case (DW2102_RC_QUERY):
Hans Verkuild51dbec2012-04-20 03:30:11 -0300223 dw210x_op_rw(d->udev, 0xb8, 0, 0,
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300224 buf6, 2, DW210X_READ_MSG);
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300225 msg[0].buf[0] = buf6[0];
226 msg[0].buf[1] = buf6[1];
227 break;
228 case (DW2102_VOLTAGE_CTRL):
229 buf6[0] = 0x30;
230 buf6[1] = msg[0].buf[0];
Hans Verkuild51dbec2012-04-20 03:30:11 -0300231 dw210x_op_rw(d->udev, 0xb2, 0, 0,
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300232 buf6, 2, DW210X_WRITE_MSG);
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300233 break;
234 }
235
236 break;
237 }
238
239 mutex_unlock(&d->i2c_mutex);
240 return num;
241}
242
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300243static int dw2102_serit_i2c_transfer(struct i2c_adapter *adap,
244 struct i2c_msg msg[], int num)
245{
246 struct dvb_usb_device *d = i2c_get_adapdata(adap);
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300247 u8 buf6[] = {0, 0, 0, 0, 0, 0, 0};
248
249 if (!d)
250 return -ENODEV;
251 if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
252 return -EAGAIN;
253
254 switch (num) {
255 case 2:
256 /* read si2109 register by number */
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300257 buf6[0] = msg[0].addr << 1;
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300258 buf6[1] = msg[0].len;
259 buf6[2] = msg[0].buf[0];
Hans Verkuild51dbec2012-04-20 03:30:11 -0300260 dw210x_op_rw(d->udev, 0xc2, 0, 0,
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300261 buf6, msg[0].len + 2, DW210X_WRITE_MSG);
262 /* read si2109 register */
Hans Verkuild51dbec2012-04-20 03:30:11 -0300263 dw210x_op_rw(d->udev, 0xc3, 0xd0, 0,
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300264 buf6, msg[1].len + 2, DW210X_READ_MSG);
265 memcpy(msg[1].buf, buf6 + 2, msg[1].len);
266
267 break;
268 case 1:
269 switch (msg[0].addr) {
270 case 0x68:
271 /* write to si2109 register */
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300272 buf6[0] = msg[0].addr << 1;
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300273 buf6[1] = msg[0].len;
274 memcpy(buf6 + 2, msg[0].buf, msg[0].len);
Hans Verkuild51dbec2012-04-20 03:30:11 -0300275 dw210x_op_rw(d->udev, 0xc2, 0, 0, buf6,
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300276 msg[0].len + 2, DW210X_WRITE_MSG);
277 break;
278 case(DW2102_RC_QUERY):
Hans Verkuild51dbec2012-04-20 03:30:11 -0300279 dw210x_op_rw(d->udev, 0xb8, 0, 0,
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300280 buf6, 2, DW210X_READ_MSG);
281 msg[0].buf[0] = buf6[0];
282 msg[0].buf[1] = buf6[1];
283 break;
284 case(DW2102_VOLTAGE_CTRL):
285 buf6[0] = 0x30;
286 buf6[1] = msg[0].buf[0];
Hans Verkuild51dbec2012-04-20 03:30:11 -0300287 dw210x_op_rw(d->udev, 0xb2, 0, 0,
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300288 buf6, 2, DW210X_WRITE_MSG);
289 break;
290 }
291 break;
292 }
293
294 mutex_unlock(&d->i2c_mutex);
295 return num;
296}
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -0300297
Igor M. Liplianin8a4949b2008-10-05 09:11:21 -0300298static int dw2102_earda_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], int num)
299{
300 struct dvb_usb_device *d = i2c_get_adapdata(adap);
Igor M. Liplianin8a4949b2008-10-05 09:11:21 -0300301
302 if (!d)
303 return -ENODEV;
304 if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
305 return -EAGAIN;
306
307 switch (num) {
308 case 2: {
309 /* read */
310 /* first write first register number */
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -0300311 u8 ibuf[msg[1].len + 2], obuf[3];
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300312 obuf[0] = msg[0].addr << 1;
Igor M. Liplianin8a4949b2008-10-05 09:11:21 -0300313 obuf[1] = msg[0].len;
314 obuf[2] = msg[0].buf[0];
Hans Verkuild51dbec2012-04-20 03:30:11 -0300315 dw210x_op_rw(d->udev, 0xc2, 0, 0,
Igor M. Liplianin8a4949b2008-10-05 09:11:21 -0300316 obuf, msg[0].len + 2, DW210X_WRITE_MSG);
317 /* second read registers */
Hans Verkuild51dbec2012-04-20 03:30:11 -0300318 dw210x_op_rw(d->udev, 0xc3, 0xd1 , 0,
Igor M. Liplianin8a4949b2008-10-05 09:11:21 -0300319 ibuf, msg[1].len + 2, DW210X_READ_MSG);
320 memcpy(msg[1].buf, ibuf + 2, msg[1].len);
321
322 break;
323 }
324 case 1:
325 switch (msg[0].addr) {
326 case 0x68: {
327 /* write to register */
328 u8 obuf[msg[0].len + 2];
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300329 obuf[0] = msg[0].addr << 1;
Igor M. Liplianin8a4949b2008-10-05 09:11:21 -0300330 obuf[1] = msg[0].len;
331 memcpy(obuf + 2, msg[0].buf, msg[0].len);
Hans Verkuild51dbec2012-04-20 03:30:11 -0300332 dw210x_op_rw(d->udev, 0xc2, 0, 0,
Igor M. Liplianin8a4949b2008-10-05 09:11:21 -0300333 obuf, msg[0].len + 2, DW210X_WRITE_MSG);
334 break;
335 }
336 case 0x61: {
337 /* write to tuner */
338 u8 obuf[msg[0].len + 2];
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300339 obuf[0] = msg[0].addr << 1;
Igor M. Liplianin8a4949b2008-10-05 09:11:21 -0300340 obuf[1] = msg[0].len;
341 memcpy(obuf + 2, msg[0].buf, msg[0].len);
Hans Verkuild51dbec2012-04-20 03:30:11 -0300342 dw210x_op_rw(d->udev, 0xc2, 0, 0,
Igor M. Liplianin8a4949b2008-10-05 09:11:21 -0300343 obuf, msg[0].len + 2, DW210X_WRITE_MSG);
344 break;
345 }
346 case(DW2102_RC_QUERY): {
347 u8 ibuf[2];
Hans Verkuild51dbec2012-04-20 03:30:11 -0300348 dw210x_op_rw(d->udev, 0xb8, 0, 0,
Igor M. Liplianin8a4949b2008-10-05 09:11:21 -0300349 ibuf, 2, DW210X_READ_MSG);
350 memcpy(msg[0].buf, ibuf , 2);
351 break;
352 }
353 case(DW2102_VOLTAGE_CTRL): {
354 u8 obuf[2];
355 obuf[0] = 0x30;
356 obuf[1] = msg[0].buf[0];
Hans Verkuild51dbec2012-04-20 03:30:11 -0300357 dw210x_op_rw(d->udev, 0xb2, 0, 0,
Igor M. Liplianin8a4949b2008-10-05 09:11:21 -0300358 obuf, 2, DW210X_WRITE_MSG);
359 break;
360 }
361 }
362
363 break;
364 }
365
366 mutex_unlock(&d->i2c_mutex);
367 return num;
368}
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300369
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300370static int dw2104_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], int num)
371{
372 struct dvb_usb_device *d = i2c_get_adapdata(adap);
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300373 int len, i, j;
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300374
375 if (!d)
376 return -ENODEV;
377 if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
378 return -EAGAIN;
379
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300380 for (j = 0; j < num; j++) {
381 switch (msg[j].addr) {
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300382 case(DW2102_RC_QUERY): {
383 u8 ibuf[2];
Hans Verkuild51dbec2012-04-20 03:30:11 -0300384 dw210x_op_rw(d->udev, 0xb8, 0, 0,
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300385 ibuf, 2, DW210X_READ_MSG);
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300386 memcpy(msg[j].buf, ibuf , 2);
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300387 break;
388 }
389 case(DW2102_VOLTAGE_CTRL): {
390 u8 obuf[2];
391 obuf[0] = 0x30;
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300392 obuf[1] = msg[j].buf[0];
Hans Verkuild51dbec2012-04-20 03:30:11 -0300393 dw210x_op_rw(d->udev, 0xb2, 0, 0,
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300394 obuf, 2, DW210X_WRITE_MSG);
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300395 break;
396 }
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300397 /*case 0x55: cx24116
398 case 0x6a: stv0903
399 case 0x68: ds3000, stv0903
400 case 0x60: ts2020, stv6110, stb6100 */
401 default: {
402 if (msg[j].flags == I2C_M_RD) {
403 /* read registers */
404 u8 ibuf[msg[j].len + 2];
Hans Verkuild51dbec2012-04-20 03:30:11 -0300405 dw210x_op_rw(d->udev, 0xc3,
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300406 (msg[j].addr << 1) + 1, 0,
407 ibuf, msg[j].len + 2,
408 DW210X_READ_MSG);
409 memcpy(msg[j].buf, ibuf + 2, msg[j].len);
410 mdelay(10);
411 } else if (((msg[j].buf[0] == 0xb0) &&
412 (msg[j].addr == 0x68)) ||
413 ((msg[j].buf[0] == 0xf7) &&
414 (msg[j].addr == 0x55))) {
415 /* write firmware */
416 u8 obuf[19];
417 obuf[0] = msg[j].addr << 1;
418 obuf[1] = (msg[j].len > 15 ? 17 : msg[j].len);
419 obuf[2] = msg[j].buf[0];
420 len = msg[j].len - 1;
421 i = 1;
422 do {
423 memcpy(obuf + 3, msg[j].buf + i,
424 (len > 16 ? 16 : len));
Hans Verkuild51dbec2012-04-20 03:30:11 -0300425 dw210x_op_rw(d->udev, 0xc2, 0, 0,
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300426 obuf, (len > 16 ? 16 : len) + 3,
427 DW210X_WRITE_MSG);
428 i += 16;
429 len -= 16;
430 } while (len > 0);
431 } else {
432 /* write registers */
433 u8 obuf[msg[j].len + 2];
434 obuf[0] = msg[j].addr << 1;
435 obuf[1] = msg[j].len;
436 memcpy(obuf + 2, msg[j].buf, msg[j].len);
Hans Verkuild51dbec2012-04-20 03:30:11 -0300437 dw210x_op_rw(d->udev, 0xc2, 0, 0,
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300438 obuf, msg[j].len + 2,
439 DW210X_WRITE_MSG);
440 }
441 break;
442 }
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300443 }
444
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300445 }
446
447 mutex_unlock(&d->i2c_mutex);
448 return num;
449}
450
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -0300451static int dw3101_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],
452 int num)
453{
454 struct dvb_usb_device *d = i2c_get_adapdata(adap);
Hans Verkuild51dbec2012-04-20 03:30:11 -0300455 int i;
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -0300456
457 if (!d)
458 return -ENODEV;
459 if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
460 return -EAGAIN;
461
462 switch (num) {
463 case 2: {
464 /* read */
465 /* first write first register number */
466 u8 ibuf[msg[1].len + 2], obuf[3];
467 obuf[0] = msg[0].addr << 1;
468 obuf[1] = msg[0].len;
469 obuf[2] = msg[0].buf[0];
Hans Verkuild51dbec2012-04-20 03:30:11 -0300470 dw210x_op_rw(d->udev, 0xc2, 0, 0,
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -0300471 obuf, msg[0].len + 2, DW210X_WRITE_MSG);
472 /* second read registers */
Hans Verkuild51dbec2012-04-20 03:30:11 -0300473 dw210x_op_rw(d->udev, 0xc3, 0x19 , 0,
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -0300474 ibuf, msg[1].len + 2, DW210X_READ_MSG);
475 memcpy(msg[1].buf, ibuf + 2, msg[1].len);
476
477 break;
478 }
479 case 1:
480 switch (msg[0].addr) {
481 case 0x60:
482 case 0x0c: {
483 /* write to register */
484 u8 obuf[msg[0].len + 2];
485 obuf[0] = msg[0].addr << 1;
486 obuf[1] = msg[0].len;
487 memcpy(obuf + 2, msg[0].buf, msg[0].len);
Hans Verkuild51dbec2012-04-20 03:30:11 -0300488 dw210x_op_rw(d->udev, 0xc2, 0, 0,
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -0300489 obuf, msg[0].len + 2, DW210X_WRITE_MSG);
490 break;
491 }
492 case(DW2102_RC_QUERY): {
493 u8 ibuf[2];
Hans Verkuild51dbec2012-04-20 03:30:11 -0300494 dw210x_op_rw(d->udev, 0xb8, 0, 0,
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -0300495 ibuf, 2, DW210X_READ_MSG);
496 memcpy(msg[0].buf, ibuf , 2);
497 break;
498 }
499 }
500
501 break;
502 }
503
504 for (i = 0; i < num; i++) {
505 deb_xfer("%02x:%02x: %s ", i, msg[i].addr,
506 msg[i].flags == 0 ? ">>>" : "<<<");
507 debug_dump(msg[i].buf, msg[i].len, deb_xfer);
508 }
509
510 mutex_unlock(&d->i2c_mutex);
511 return num;
512}
513
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300514static int s6x0_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300515 int num)
516{
517 struct dvb_usb_device *d = i2c_get_adapdata(adap);
Julia Lawall21ead032009-12-22 18:00:07 -0300518 struct usb_device *udev;
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300519 int len, i, j;
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300520
521 if (!d)
522 return -ENODEV;
Julia Lawall21ead032009-12-22 18:00:07 -0300523 udev = d->udev;
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300524 if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
525 return -EAGAIN;
526
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300527 for (j = 0; j < num; j++) {
528 switch (msg[j].addr) {
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300529 case (DW2102_RC_QUERY): {
Igor M. Liplianin5a530cb2011-02-25 18:41:23 -0300530 u8 ibuf[5];
Hans Verkuild51dbec2012-04-20 03:30:11 -0300531 dw210x_op_rw(d->udev, 0xb8, 0, 0,
Igor M. Liplianin5a530cb2011-02-25 18:41:23 -0300532 ibuf, 5, DW210X_READ_MSG);
533 memcpy(msg[j].buf, ibuf + 3, 2);
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300534 break;
535 }
536 case (DW2102_VOLTAGE_CTRL): {
537 u8 obuf[2];
Igor M. Liplianincd79d332009-12-14 20:24:56 -0300538
539 obuf[0] = 1;
540 obuf[1] = msg[j].buf[1];/* off-on */
Hans Verkuild51dbec2012-04-20 03:30:11 -0300541 dw210x_op_rw(d->udev, 0x8a, 0, 0,
Igor M. Liplianincd79d332009-12-14 20:24:56 -0300542 obuf, 2, DW210X_WRITE_MSG);
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300543 obuf[0] = 3;
Igor M. Liplianincd79d332009-12-14 20:24:56 -0300544 obuf[1] = msg[j].buf[0];/* 13v-18v */
Hans Verkuild51dbec2012-04-20 03:30:11 -0300545 dw210x_op_rw(d->udev, 0x8a, 0, 0,
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300546 obuf, 2, DW210X_WRITE_MSG);
547 break;
548 }
Igor M. Liplianinfa8bae12011-02-25 18:41:22 -0300549 case (DW2102_LED_CTRL): {
550 u8 obuf[2];
551
552 obuf[0] = 5;
553 obuf[1] = msg[j].buf[0];
Hans Verkuild51dbec2012-04-20 03:30:11 -0300554 dw210x_op_rw(d->udev, 0x8a, 0, 0,
Igor M. Liplianinfa8bae12011-02-25 18:41:22 -0300555 obuf, 2, DW210X_WRITE_MSG);
556 break;
557 }
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300558 /*case 0x55: cx24116
559 case 0x6a: stv0903
Igor M. Liplianin955d00a2012-05-08 03:53:17 -0300560 case 0x68: ds3000, stv0903, rs2000
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300561 case 0x60: ts2020, stv6110, stb6100
562 case 0xa0: eeprom */
563 default: {
564 if (msg[j].flags == I2C_M_RD) {
565 /* read registers */
566 u8 ibuf[msg[j].len];
Hans Verkuild51dbec2012-04-20 03:30:11 -0300567 dw210x_op_rw(d->udev, 0x91, 0, 0,
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300568 ibuf, msg[j].len,
569 DW210X_READ_MSG);
570 memcpy(msg[j].buf, ibuf, msg[j].len);
571 break;
572 } else if ((msg[j].buf[0] == 0xb0) &&
573 (msg[j].addr == 0x68)) {
574 /* write firmware */
575 u8 obuf[19];
576 obuf[0] = (msg[j].len > 16 ?
577 18 : msg[j].len + 1);
578 obuf[1] = msg[j].addr << 1;
579 obuf[2] = msg[j].buf[0];
580 len = msg[j].len - 1;
581 i = 1;
582 do {
583 memcpy(obuf + 3, msg[j].buf + i,
584 (len > 16 ? 16 : len));
Hans Verkuild51dbec2012-04-20 03:30:11 -0300585 dw210x_op_rw(d->udev, 0x80, 0, 0,
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300586 obuf, (len > 16 ? 16 : len) + 3,
587 DW210X_WRITE_MSG);
588 i += 16;
589 len -= 16;
590 } while (len > 0);
Igor M. Liplianina84adf42011-02-27 16:18:38 -0300591 } else if (j < (num - 1)) {
Igor M. Liplianincd79d332009-12-14 20:24:56 -0300592 /* write register addr before read */
593 u8 obuf[msg[j].len + 2];
594 obuf[0] = msg[j + 1].len;
595 obuf[1] = (msg[j].addr << 1);
596 memcpy(obuf + 2, msg[j].buf, msg[j].len);
Hans Verkuild51dbec2012-04-20 03:30:11 -0300597 dw210x_op_rw(d->udev,
Igor M. Liplianina84adf42011-02-27 16:18:38 -0300598 udev->descriptor.idProduct ==
599 0x7500 ? 0x92 : 0x90, 0, 0,
Igor M. Liplianincd79d332009-12-14 20:24:56 -0300600 obuf, msg[j].len + 2,
601 DW210X_WRITE_MSG);
602 break;
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300603 } else {
604 /* write registers */
605 u8 obuf[msg[j].len + 2];
606 obuf[0] = msg[j].len + 1;
607 obuf[1] = (msg[j].addr << 1);
608 memcpy(obuf + 2, msg[j].buf, msg[j].len);
Hans Verkuild51dbec2012-04-20 03:30:11 -0300609 dw210x_op_rw(d->udev, 0x80, 0, 0,
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300610 obuf, msg[j].len + 2,
611 DW210X_WRITE_MSG);
612 break;
613 }
614 break;
615 }
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300616 }
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300617 }
618
619 mutex_unlock(&d->i2c_mutex);
620 return num;
621}
622
Igor M. Liplianind2ffc442011-02-25 18:41:22 -0300623static int su3000_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],
624 int num)
625{
626 struct dvb_usb_device *d = i2c_get_adapdata(adap);
627 u8 obuf[0x40], ibuf[0x40];
628
629 if (!d)
630 return -ENODEV;
631 if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
632 return -EAGAIN;
633
634 switch (num) {
635 case 1:
636 switch (msg[0].addr) {
637 case SU3000_STREAM_CTRL:
638 obuf[0] = msg[0].buf[0] + 0x36;
639 obuf[1] = 3;
640 obuf[2] = 0;
641 if (dvb_usb_generic_rw(d, obuf, 3, ibuf, 0, 0) < 0)
642 err("i2c transfer failed.");
643 break;
644 case DW2102_RC_QUERY:
645 obuf[0] = 0x10;
646 if (dvb_usb_generic_rw(d, obuf, 1, ibuf, 2, 0) < 0)
647 err("i2c transfer failed.");
648 msg[0].buf[1] = ibuf[0];
649 msg[0].buf[0] = ibuf[1];
650 break;
651 default:
652 /* always i2c write*/
653 obuf[0] = 0x08;
654 obuf[1] = msg[0].addr;
655 obuf[2] = msg[0].len;
656
657 memcpy(&obuf[3], msg[0].buf, msg[0].len);
658
659 if (dvb_usb_generic_rw(d, obuf, msg[0].len + 3,
660 ibuf, 1, 0) < 0)
661 err("i2c transfer failed.");
662
663 }
664 break;
665 case 2:
666 /* always i2c read */
667 obuf[0] = 0x09;
668 obuf[1] = msg[0].len;
669 obuf[2] = msg[1].len;
670 obuf[3] = msg[0].addr;
671 memcpy(&obuf[4], msg[0].buf, msg[0].len);
672
673 if (dvb_usb_generic_rw(d, obuf, msg[0].len + 4,
674 ibuf, msg[1].len + 1, 0) < 0)
675 err("i2c transfer failed.");
676
677 memcpy(msg[1].buf, &ibuf[1], msg[1].len);
678 break;
679 default:
680 warn("more than 2 i2c messages at a time is not handled yet.");
681 break;
682 }
683 mutex_unlock(&d->i2c_mutex);
684 return num;
685}
686
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300687static u32 dw210x_i2c_func(struct i2c_adapter *adapter)
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300688{
689 return I2C_FUNC_I2C;
690}
691
692static struct i2c_algorithm dw2102_i2c_algo = {
693 .master_xfer = dw2102_i2c_transfer,
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300694 .functionality = dw210x_i2c_func,
695};
696
697static struct i2c_algorithm dw2102_serit_i2c_algo = {
698 .master_xfer = dw2102_serit_i2c_transfer,
699 .functionality = dw210x_i2c_func,
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300700};
701
Igor M. Liplianin8a4949b2008-10-05 09:11:21 -0300702static struct i2c_algorithm dw2102_earda_i2c_algo = {
703 .master_xfer = dw2102_earda_i2c_transfer,
704 .functionality = dw210x_i2c_func,
705};
706
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300707static struct i2c_algorithm dw2104_i2c_algo = {
708 .master_xfer = dw2104_i2c_transfer,
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300709 .functionality = dw210x_i2c_func,
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300710};
711
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -0300712static struct i2c_algorithm dw3101_i2c_algo = {
713 .master_xfer = dw3101_i2c_transfer,
714 .functionality = dw210x_i2c_func,
715};
716
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300717static struct i2c_algorithm s6x0_i2c_algo = {
718 .master_xfer = s6x0_i2c_transfer,
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300719 .functionality = dw210x_i2c_func,
720};
721
Igor M. Liplianind2ffc442011-02-25 18:41:22 -0300722static struct i2c_algorithm su3000_i2c_algo = {
723 .master_xfer = su3000_i2c_transfer,
724 .functionality = dw210x_i2c_func,
725};
726
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300727static int dw210x_read_mac_address(struct dvb_usb_device *d, u8 mac[6])
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300728{
729 int i;
730 u8 ibuf[] = {0, 0};
731 u8 eeprom[256], eepromline[16];
732
733 for (i = 0; i < 256; i++) {
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300734 if (dw210x_op_rw(d->udev, 0xb6, 0xa0 , i, ibuf, 2, DW210X_READ_MSG) < 0) {
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300735 err("read eeprom failed.");
736 return -1;
737 } else {
738 eepromline[i%16] = ibuf[0];
739 eeprom[i] = ibuf[0];
740 }
741 if ((i % 16) == 15) {
742 deb_xfer("%02x: ", i - 15);
743 debug_dump(eepromline, 16, deb_xfer);
744 }
745 }
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -0300746
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300747 memcpy(mac, eeprom + 8, 6);
748 return 0;
749};
750
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300751static int s6x0_read_mac_address(struct dvb_usb_device *d, u8 mac[6])
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300752{
753 int i, ret;
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300754 u8 ibuf[] = { 0 }, obuf[] = { 0 };
755 u8 eeprom[256], eepromline[16];
756 struct i2c_msg msg[] = {
757 {
758 .addr = 0xa0 >> 1,
759 .flags = 0,
760 .buf = obuf,
761 .len = 1,
762 }, {
763 .addr = 0xa0 >> 1,
764 .flags = I2C_M_RD,
765 .buf = ibuf,
766 .len = 1,
767 }
768 };
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300769
770 for (i = 0; i < 256; i++) {
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300771 obuf[0] = i;
772 ret = s6x0_i2c_transfer(&d->i2c_adap, msg, 2);
773 if (ret != 2) {
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300774 err("read eeprom failed.");
775 return -1;
776 } else {
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300777 eepromline[i % 16] = ibuf[0];
778 eeprom[i] = ibuf[0];
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300779 }
780
781 if ((i % 16) == 15) {
782 deb_xfer("%02x: ", i - 15);
783 debug_dump(eepromline, 16, deb_xfer);
784 }
785 }
786
787 memcpy(mac, eeprom + 16, 6);
788 return 0;
789};
790
Igor M. Liplianind2ffc442011-02-25 18:41:22 -0300791static int su3000_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff)
792{
793 static u8 command_start[] = {0x00};
794 static u8 command_stop[] = {0x01};
795 struct i2c_msg msg = {
796 .addr = SU3000_STREAM_CTRL,
797 .flags = 0,
798 .buf = onoff ? command_start : command_stop,
799 .len = 1
800 };
801
802 i2c_transfer(&adap->dev->i2c_adap, &msg, 1);
803
804 return 0;
805}
806
807static int su3000_power_ctrl(struct dvb_usb_device *d, int i)
808{
809 struct su3000_state *state = (struct su3000_state *)d->priv;
810 u8 obuf[] = {0xde, 0};
811
812 info("%s: %d, initialized %d\n", __func__, i, state->initialized);
813
814 if (i && !state->initialized) {
815 state->initialized = 1;
816 /* reset board */
817 dvb_usb_generic_rw(d, obuf, 2, NULL, 0, 0);
818 }
819
820 return 0;
821}
822
823static int su3000_read_mac_address(struct dvb_usb_device *d, u8 mac[6])
824{
825 int i;
826 u8 obuf[] = { 0x1f, 0xf0 };
827 u8 ibuf[] = { 0 };
828 struct i2c_msg msg[] = {
829 {
830 .addr = 0x51,
831 .flags = 0,
832 .buf = obuf,
833 .len = 2,
834 }, {
835 .addr = 0x51,
836 .flags = I2C_M_RD,
837 .buf = ibuf,
838 .len = 1,
839
840 }
841 };
842
843 for (i = 0; i < 6; i++) {
844 obuf[1] = 0xf0 + i;
845 if (i2c_transfer(&d->i2c_adap, msg, 2) != 2)
846 break;
847 else
848 mac[i] = ibuf[0];
849
850 debug_dump(mac, 6, printk);
851 }
852
853 return 0;
854}
855
856static int su3000_identify_state(struct usb_device *udev,
857 struct dvb_usb_device_properties *props,
858 struct dvb_usb_device_description **desc,
859 int *cold)
860{
861 info("%s\n", __func__);
862
863 *cold = 0;
864 return 0;
865}
866
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300867static int dw210x_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300868{
Igor M. Liplianincd79d332009-12-14 20:24:56 -0300869 static u8 command_13v[] = {0x00, 0x01};
870 static u8 command_18v[] = {0x01, 0x01};
871 static u8 command_off[] = {0x00, 0x00};
872 struct i2c_msg msg = {
873 .addr = DW2102_VOLTAGE_CTRL,
874 .flags = 0,
875 .buf = command_off,
876 .len = 2,
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300877 };
878
879 struct dvb_usb_adapter *udev_adap =
880 (struct dvb_usb_adapter *)(fe->dvb->priv);
881 if (voltage == SEC_VOLTAGE_18)
Igor M. Liplianincd79d332009-12-14 20:24:56 -0300882 msg.buf = command_18v;
883 else if (voltage == SEC_VOLTAGE_13)
884 msg.buf = command_13v;
885
886 i2c_transfer(&udev_adap->dev->i2c_adap, &msg, 1);
887
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300888 return 0;
889}
890
Igor M. Liplianin52c506e2011-02-25 18:41:23 -0300891static int s660_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
892{
893 struct dvb_usb_adapter *d =
894 (struct dvb_usb_adapter *)(fe->dvb->priv);
895 struct s6x0_state *st = (struct s6x0_state *)d->dev->priv;
896
897 dw210x_set_voltage(fe, voltage);
898 if (st->old_set_voltage)
899 st->old_set_voltage(fe, voltage);
900
901 return 0;
902}
903
Igor M. Liplianinfa8bae12011-02-25 18:41:22 -0300904static void dw210x_led_ctrl(struct dvb_frontend *fe, int offon)
905{
906 static u8 led_off[] = { 0 };
907 static u8 led_on[] = { 1 };
908 struct i2c_msg msg = {
909 .addr = DW2102_LED_CTRL,
910 .flags = 0,
911 .buf = led_off,
912 .len = 1
913 };
914 struct dvb_usb_adapter *udev_adap =
915 (struct dvb_usb_adapter *)(fe->dvb->priv);
916
917 if (offon)
918 msg.buf = led_on;
919 i2c_transfer(&udev_adap->dev->i2c_adap, &msg, 1);
920}
921
Igor M. Liplianind4305c62008-10-17 13:45:55 -0300922static struct stv0299_config sharp_z0194a_config = {
923 .demod_address = 0x68,
924 .inittab = sharp_z0194a_inittab,
925 .mclk = 88000000UL,
926 .invert = 1,
927 .skip_reinit = 0,
928 .lock_output = STV0299_LOCKOUTPUT_1,
929 .volt13_op0_op1 = STV0299_VOLT13_OP1,
930 .min_delay_ms = 100,
931 .set_symbol_rate = sharp_z0194a_set_symbol_rate,
932};
933
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300934static struct cx24116_config dw2104_config = {
935 .demod_address = 0x55,
Igor M. Liplianincc8c4f32008-09-09 13:57:47 -0300936 .mpg_clk_pos_pol = 0x01,
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300937};
938
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300939static struct si21xx_config serit_sp1511lhb_config = {
940 .demod_address = 0x68,
941 .min_delay_ms = 100,
942
943};
944
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -0300945static struct tda10023_config dw3101_tda10023_config = {
946 .demod_address = 0x0c,
947 .invert = 1,
948};
949
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300950static struct mt312_config zl313_config = {
951 .demod_address = 0x0e,
952};
953
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300954static struct ds3000_config dw2104_ds3000_config = {
955 .demod_address = 0x68,
956};
957
Konstantin Dimitrov73f0af42012-12-23 19:25:38 -0300958static struct ts2020_config dw2104_ts2020_config = {
959 .tuner_address = 0x60,
Igor M. Liplianinb858c332012-12-28 19:40:33 -0300960 .clk_out_div = 1,
Konstantin Dimitrov73f0af42012-12-23 19:25:38 -0300961};
962
Igor M. Liplianin43385c82012-12-28 19:40:24 -0300963static struct ds3000_config s660_ds3000_config = {
964 .demod_address = 0x68,
Igor M. Liplianinb858c332012-12-28 19:40:33 -0300965 .ci_mode = 1,
Igor M. Liplianin43385c82012-12-28 19:40:24 -0300966 .set_lock_led = dw210x_led_ctrl,
967};
968
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300969static struct stv0900_config dw2104a_stv0900_config = {
970 .demod_address = 0x6a,
971 .demod_mode = 0,
972 .xtal = 27000000,
973 .clkmode = 3,/* 0-CLKI, 2-XTALI, else AUTO */
974 .diseqc_mode = 2,/* 2/3 PWM */
975 .tun1_maddress = 0,/* 0x60 */
976 .tun1_adc = 0,/* 2 Vpp */
977 .path1_mode = 3,
978};
979
980static struct stb6100_config dw2104a_stb6100_config = {
981 .tuner_address = 0x60,
982 .refclock = 27000000,
983};
984
985static struct stv0900_config dw2104_stv0900_config = {
986 .demod_address = 0x68,
987 .demod_mode = 0,
988 .xtal = 8000000,
989 .clkmode = 3,
990 .diseqc_mode = 2,
991 .tun1_maddress = 0,
992 .tun1_adc = 1,/* 1 Vpp */
993 .path1_mode = 3,
994};
995
996static struct stv6110_config dw2104_stv6110_config = {
997 .i2c_address = 0x60,
998 .mclk = 16000000,
999 .clk_div = 1,
1000};
1001
Igor M. Liplianincd79d332009-12-14 20:24:56 -03001002static struct stv0900_config prof_7500_stv0900_config = {
1003 .demod_address = 0x6a,
1004 .demod_mode = 0,
1005 .xtal = 27000000,
1006 .clkmode = 3,/* 0-CLKI, 2-XTALI, else AUTO */
1007 .diseqc_mode = 2,/* 2/3 PWM */
1008 .tun1_maddress = 0,/* 0x60 */
1009 .tun1_adc = 0,/* 2 Vpp */
1010 .path1_mode = 3,
1011 .tun1_type = 3,
Igor M. Liplianinfa8bae12011-02-25 18:41:22 -03001012 .set_lock_led = dw210x_led_ctrl,
Igor M. Liplianincd79d332009-12-14 20:24:56 -03001013};
1014
Igor M. Liplianind2ffc442011-02-25 18:41:22 -03001015static struct ds3000_config su3000_ds3000_config = {
1016 .demod_address = 0x68,
1017 .ci_mode = 1,
Igor M. Liplianinb858c332012-12-28 19:40:33 -03001018 .set_lock_led = dw210x_led_ctrl,
Konstantin Dimitrov73f0af42012-12-23 19:25:38 -03001019};
1020
Igor M. Liplianin955d00a2012-05-08 03:53:17 -03001021static u8 m88rs2000_inittab[] = {
1022 DEMOD_WRITE, 0x9a, 0x30,
1023 DEMOD_WRITE, 0x00, 0x01,
1024 WRITE_DELAY, 0x19, 0x00,
1025 DEMOD_WRITE, 0x00, 0x00,
1026 DEMOD_WRITE, 0x9a, 0xb0,
1027 DEMOD_WRITE, 0x81, 0xc1,
Igor M. Liplianin955d00a2012-05-08 03:53:17 -03001028 DEMOD_WRITE, 0x81, 0x81,
1029 DEMOD_WRITE, 0x86, 0xc6,
1030 DEMOD_WRITE, 0x9a, 0x30,
1031 DEMOD_WRITE, 0xf0, 0x80,
1032 DEMOD_WRITE, 0xf1, 0xbf,
1033 DEMOD_WRITE, 0xb0, 0x45,
1034 DEMOD_WRITE, 0xb2, 0x01,
1035 DEMOD_WRITE, 0x9a, 0xb0,
1036 0xff, 0xaa, 0xff
1037};
1038
1039static struct m88rs2000_config s421_m88rs2000_config = {
1040 .demod_addr = 0x68,
Igor M. Liplianin955d00a2012-05-08 03:53:17 -03001041 .inittab = m88rs2000_inittab,
1042};
1043
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001044static int dw2104_frontend_attach(struct dvb_usb_adapter *d)
1045{
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001046 struct dvb_tuner_ops *tuner_ops = NULL;
1047
1048 if (demod_probe & 4) {
Michael Krufky77eed212011-09-06 09:31:57 -03001049 d->fe_adap[0].fe = dvb_attach(stv0900_attach, &dw2104a_stv0900_config,
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001050 &d->dev->i2c_adap, 0);
Michael Krufky77eed212011-09-06 09:31:57 -03001051 if (d->fe_adap[0].fe != NULL) {
1052 if (dvb_attach(stb6100_attach, d->fe_adap[0].fe,
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001053 &dw2104a_stb6100_config,
1054 &d->dev->i2c_adap)) {
Michael Krufky77eed212011-09-06 09:31:57 -03001055 tuner_ops = &d->fe_adap[0].fe->ops.tuner_ops;
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001056 tuner_ops->set_frequency = stb6100_set_freq;
1057 tuner_ops->get_frequency = stb6100_get_freq;
1058 tuner_ops->set_bandwidth = stb6100_set_bandw;
1059 tuner_ops->get_bandwidth = stb6100_get_bandw;
Michael Krufky77eed212011-09-06 09:31:57 -03001060 d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage;
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001061 info("Attached STV0900+STB6100!\n");
1062 return 0;
1063 }
1064 }
1065 }
1066
1067 if (demod_probe & 2) {
Michael Krufky77eed212011-09-06 09:31:57 -03001068 d->fe_adap[0].fe = dvb_attach(stv0900_attach, &dw2104_stv0900_config,
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001069 &d->dev->i2c_adap, 0);
Michael Krufky77eed212011-09-06 09:31:57 -03001070 if (d->fe_adap[0].fe != NULL) {
1071 if (dvb_attach(stv6110_attach, d->fe_adap[0].fe,
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001072 &dw2104_stv6110_config,
1073 &d->dev->i2c_adap)) {
Michael Krufky77eed212011-09-06 09:31:57 -03001074 d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage;
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001075 info("Attached STV0900+STV6110A!\n");
1076 return 0;
1077 }
1078 }
1079 }
1080
1081 if (demod_probe & 1) {
Michael Krufky77eed212011-09-06 09:31:57 -03001082 d->fe_adap[0].fe = dvb_attach(cx24116_attach, &dw2104_config,
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001083 &d->dev->i2c_adap);
Michael Krufky77eed212011-09-06 09:31:57 -03001084 if (d->fe_adap[0].fe != NULL) {
1085 d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage;
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001086 info("Attached cx24116!\n");
1087 return 0;
1088 }
1089 }
1090
Michael Krufky77eed212011-09-06 09:31:57 -03001091 d->fe_adap[0].fe = dvb_attach(ds3000_attach, &dw2104_ds3000_config,
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001092 &d->dev->i2c_adap);
Michael Krufky77eed212011-09-06 09:31:57 -03001093 if (d->fe_adap[0].fe != NULL) {
Konstantin Dimitrov73f0af42012-12-23 19:25:38 -03001094 dvb_attach(ts2020_attach, d->fe_adap[0].fe,
1095 &dw2104_ts2020_config, &d->dev->i2c_adap);
Michael Krufky77eed212011-09-06 09:31:57 -03001096 d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage;
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001097 info("Attached DS3000!\n");
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001098 return 0;
1099 }
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001100
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001101 return -EIO;
1102}
1103
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001104static struct dvb_usb_device_properties dw2102_properties;
Igor M. Liplianinb42e1d72009-06-14 19:41:22 -03001105static struct dvb_usb_device_properties dw2104_properties;
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001106static struct dvb_usb_device_properties s6x0_properties;
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001107
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001108static int dw2102_frontend_attach(struct dvb_usb_adapter *d)
1109{
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001110 if (dw2102_properties.i2c_algo == &dw2102_serit_i2c_algo) {
1111 /*dw2102_properties.adapter->tuner_attach = NULL;*/
Michael Krufky77eed212011-09-06 09:31:57 -03001112 d->fe_adap[0].fe = dvb_attach(si21xx_attach, &serit_sp1511lhb_config,
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001113 &d->dev->i2c_adap);
Michael Krufky77eed212011-09-06 09:31:57 -03001114 if (d->fe_adap[0].fe != NULL) {
1115 d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage;
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001116 info("Attached si21xx!\n");
1117 return 0;
1118 }
1119 }
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001120
Igor M. Liplianin8a4949b2008-10-05 09:11:21 -03001121 if (dw2102_properties.i2c_algo == &dw2102_earda_i2c_algo) {
Michael Krufky77eed212011-09-06 09:31:57 -03001122 d->fe_adap[0].fe = dvb_attach(stv0288_attach, &earda_config,
Igor M. Liplianin8a4949b2008-10-05 09:11:21 -03001123 &d->dev->i2c_adap);
Michael Krufky77eed212011-09-06 09:31:57 -03001124 if (d->fe_adap[0].fe != NULL) {
1125 if (dvb_attach(stb6000_attach, d->fe_adap[0].fe, 0x61,
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001126 &d->dev->i2c_adap)) {
Michael Krufky77eed212011-09-06 09:31:57 -03001127 d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage;
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001128 info("Attached stv0288!\n");
1129 return 0;
1130 }
Igor M. Liplianin8a4949b2008-10-05 09:11:21 -03001131 }
1132 }
1133
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001134 if (dw2102_properties.i2c_algo == &dw2102_i2c_algo) {
1135 /*dw2102_properties.adapter->tuner_attach = dw2102_tuner_attach;*/
Michael Krufky77eed212011-09-06 09:31:57 -03001136 d->fe_adap[0].fe = dvb_attach(stv0299_attach, &sharp_z0194a_config,
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001137 &d->dev->i2c_adap);
Michael Krufky77eed212011-09-06 09:31:57 -03001138 if (d->fe_adap[0].fe != NULL) {
1139 d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage;
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001140 info("Attached stv0299!\n");
1141 return 0;
1142 }
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001143 }
1144 return -EIO;
1145}
1146
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001147static int dw3101_frontend_attach(struct dvb_usb_adapter *d)
1148{
Michael Krufky77eed212011-09-06 09:31:57 -03001149 d->fe_adap[0].fe = dvb_attach(tda10023_attach, &dw3101_tda10023_config,
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001150 &d->dev->i2c_adap, 0x48);
Michael Krufky77eed212011-09-06 09:31:57 -03001151 if (d->fe_adap[0].fe != NULL) {
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001152 info("Attached tda10023!\n");
1153 return 0;
1154 }
1155 return -EIO;
1156}
1157
Igor M. Liplianin195288d2011-02-25 18:41:22 -03001158static int zl100313_frontend_attach(struct dvb_usb_adapter *d)
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -03001159{
Michael Krufky77eed212011-09-06 09:31:57 -03001160 d->fe_adap[0].fe = dvb_attach(mt312_attach, &zl313_config,
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001161 &d->dev->i2c_adap);
Michael Krufky77eed212011-09-06 09:31:57 -03001162 if (d->fe_adap[0].fe != NULL) {
1163 if (dvb_attach(zl10039_attach, d->fe_adap[0].fe, 0x60,
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001164 &d->dev->i2c_adap)) {
Michael Krufky77eed212011-09-06 09:31:57 -03001165 d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage;
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001166 info("Attached zl100313+zl10039!\n");
1167 return 0;
1168 }
1169 }
1170
Igor M. Liplianin195288d2011-02-25 18:41:22 -03001171 return -EIO;
1172}
1173
1174static int stv0288_frontend_attach(struct dvb_usb_adapter *d)
1175{
Igor M. Liplianinfd5466d2011-02-27 16:22:52 -03001176 u8 obuf[] = {7, 1};
1177
Michael Krufky77eed212011-09-06 09:31:57 -03001178 d->fe_adap[0].fe = dvb_attach(stv0288_attach, &earda_config,
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001179 &d->dev->i2c_adap);
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001180
Michael Krufky77eed212011-09-06 09:31:57 -03001181 if (d->fe_adap[0].fe == NULL)
Igor M. Liplianinfd5466d2011-02-27 16:22:52 -03001182 return -EIO;
1183
Michael Krufky77eed212011-09-06 09:31:57 -03001184 if (NULL == dvb_attach(stb6000_attach, d->fe_adap[0].fe, 0x61, &d->dev->i2c_adap))
Igor M. Liplianinfd5466d2011-02-27 16:22:52 -03001185 return -EIO;
1186
Michael Krufky77eed212011-09-06 09:31:57 -03001187 d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage;
Igor M. Liplianinfd5466d2011-02-27 16:22:52 -03001188
1189 dw210x_op_rw(d->dev->udev, 0x8a, 0, 0, obuf, 2, DW210X_WRITE_MSG);
1190
1191 info("Attached stv0288+stb6000!\n");
1192
1193 return 0;
1194
Igor M. Liplianin195288d2011-02-25 18:41:22 -03001195}
1196
1197static int ds3000_frontend_attach(struct dvb_usb_adapter *d)
1198{
Igor M. Liplianin52c506e2011-02-25 18:41:23 -03001199 struct s6x0_state *st = (struct s6x0_state *)d->dev->priv;
Igor M. Liplianin5a530cb2011-02-25 18:41:23 -03001200 u8 obuf[] = {7, 1};
Igor M. Liplianin52c506e2011-02-25 18:41:23 -03001201
Igor M. Liplianin43385c82012-12-28 19:40:24 -03001202 d->fe_adap[0].fe = dvb_attach(ds3000_attach, &s660_ds3000_config,
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001203 &d->dev->i2c_adap);
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001204
Michael Krufky77eed212011-09-06 09:31:57 -03001205 if (d->fe_adap[0].fe == NULL)
Igor M. Liplianin52c506e2011-02-25 18:41:23 -03001206 return -EIO;
1207
Konstantin Dimitrov73f0af42012-12-23 19:25:38 -03001208 dvb_attach(ts2020_attach, d->fe_adap[0].fe, &dw2104_ts2020_config,
1209 &d->dev->i2c_adap);
1210
Michael Krufky77eed212011-09-06 09:31:57 -03001211 st->old_set_voltage = d->fe_adap[0].fe->ops.set_voltage;
1212 d->fe_adap[0].fe->ops.set_voltage = s660_set_voltage;
Igor M. Liplianin5a530cb2011-02-25 18:41:23 -03001213
1214 dw210x_op_rw(d->dev->udev, 0x8a, 0, 0, obuf, 2, DW210X_WRITE_MSG);
1215
Igor M. Liplianin52c506e2011-02-25 18:41:23 -03001216 info("Attached ds3000+ds2020!\n");
1217
1218 return 0;
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -03001219}
1220
Igor M. Liplianincd79d332009-12-14 20:24:56 -03001221static int prof_7500_frontend_attach(struct dvb_usb_adapter *d)
1222{
Igor M. Liplianin4e59df82011-02-25 18:41:23 -03001223 u8 obuf[] = {7, 1};
1224
Michael Krufky77eed212011-09-06 09:31:57 -03001225 d->fe_adap[0].fe = dvb_attach(stv0900_attach, &prof_7500_stv0900_config,
Igor M. Liplianincd79d332009-12-14 20:24:56 -03001226 &d->dev->i2c_adap, 0);
Michael Krufky77eed212011-09-06 09:31:57 -03001227 if (d->fe_adap[0].fe == NULL)
Igor M. Liplianincd79d332009-12-14 20:24:56 -03001228 return -EIO;
Igor M. Liplianin4e59df82011-02-25 18:41:23 -03001229
Michael Krufky77eed212011-09-06 09:31:57 -03001230 d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage;
Igor M. Liplianincd79d332009-12-14 20:24:56 -03001231
Igor M. Liplianin4e59df82011-02-25 18:41:23 -03001232 dw210x_op_rw(d->dev->udev, 0x8a, 0, 0, obuf, 2, DW210X_WRITE_MSG);
1233
Igor M. Liplianincd79d332009-12-14 20:24:56 -03001234 info("Attached STV0900+STB6100A!\n");
1235
1236 return 0;
1237}
1238
Igor M. Liplianind2ffc442011-02-25 18:41:22 -03001239static int su3000_frontend_attach(struct dvb_usb_adapter *d)
1240{
1241 u8 obuf[3] = { 0xe, 0x80, 0 };
1242 u8 ibuf[] = { 0 };
1243
1244 if (dvb_usb_generic_rw(d->dev, obuf, 3, ibuf, 1, 0) < 0)
1245 err("command 0x0e transfer failed.");
1246
1247 obuf[0] = 0xe;
Igor M. Liplianinb858c332012-12-28 19:40:33 -03001248 obuf[1] = 0x02;
1249 obuf[2] = 1;
1250
1251 if (dvb_usb_generic_rw(d->dev, obuf, 3, ibuf, 1, 0) < 0)
1252 err("command 0x0e transfer failed.");
1253 msleep(300);
1254
1255 obuf[0] = 0xe;
Igor M. Liplianind2ffc442011-02-25 18:41:22 -03001256 obuf[1] = 0x83;
1257 obuf[2] = 0;
1258
1259 if (dvb_usb_generic_rw(d->dev, obuf, 3, ibuf, 1, 0) < 0)
1260 err("command 0x0e transfer failed.");
1261
1262 obuf[0] = 0xe;
1263 obuf[1] = 0x83;
1264 obuf[2] = 1;
1265
1266 if (dvb_usb_generic_rw(d->dev, obuf, 3, ibuf, 1, 0) < 0)
1267 err("command 0x0e transfer failed.");
1268
1269 obuf[0] = 0x51;
1270
1271 if (dvb_usb_generic_rw(d->dev, obuf, 1, ibuf, 1, 0) < 0)
1272 err("command 0x51 transfer failed.");
1273
Michael Krufky77eed212011-09-06 09:31:57 -03001274 d->fe_adap[0].fe = dvb_attach(ds3000_attach, &su3000_ds3000_config,
Igor M. Liplianind2ffc442011-02-25 18:41:22 -03001275 &d->dev->i2c_adap);
Michael Krufky77eed212011-09-06 09:31:57 -03001276 if (d->fe_adap[0].fe == NULL)
Igor M. Liplianind2ffc442011-02-25 18:41:22 -03001277 return -EIO;
1278
Igor M. Liplianinb858c332012-12-28 19:40:33 -03001279 if (dvb_attach(ts2020_attach, d->fe_adap[0].fe,
1280 &dw2104_ts2020_config,
1281 &d->dev->i2c_adap)) {
1282 info("Attached DS3000/TS2020!\n");
1283 return 0;
1284 }
Konstantin Dimitrov73f0af42012-12-23 19:25:38 -03001285
Igor M. Liplianinb858c332012-12-28 19:40:33 -03001286 info("Failed to attach DS3000/TS2020!\n");
1287 return -EIO;
Igor M. Liplianind2ffc442011-02-25 18:41:22 -03001288}
1289
Igor M. Liplianin955d00a2012-05-08 03:53:17 -03001290static int m88rs2000_frontend_attach(struct dvb_usb_adapter *d)
1291{
1292 u8 obuf[] = { 0x51 };
1293 u8 ibuf[] = { 0 };
1294
1295 if (dvb_usb_generic_rw(d->dev, obuf, 1, ibuf, 1, 0) < 0)
1296 err("command 0x51 transfer failed.");
1297
1298 d->fe_adap[0].fe = dvb_attach(m88rs2000_attach, &s421_m88rs2000_config,
1299 &d->dev->i2c_adap);
Igor M. Liplianinb858c332012-12-28 19:40:33 -03001300
Igor M. Liplianin955d00a2012-05-08 03:53:17 -03001301 if (d->fe_adap[0].fe == NULL)
1302 return -EIO;
1303
Igor M. Liplianinb858c332012-12-28 19:40:33 -03001304 if (dvb_attach(ts2020_attach, d->fe_adap[0].fe,
1305 &dw2104_ts2020_config,
1306 &d->dev->i2c_adap)) {
1307 info("Attached RS2000/TS2020!\n");
1308 return 0;
1309 }
Igor M. Liplianin955d00a2012-05-08 03:53:17 -03001310
Igor M. Liplianinb858c332012-12-28 19:40:33 -03001311 info("Failed to attach RS2000/TS2020!\n");
1312 return -EIO;
Igor M. Liplianin955d00a2012-05-08 03:53:17 -03001313}
1314
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001315static int dw2102_tuner_attach(struct dvb_usb_adapter *adap)
1316{
Michael Krufky77eed212011-09-06 09:31:57 -03001317 dvb_attach(dvb_pll_attach, adap->fe_adap[0].fe, 0x60,
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001318 &adap->dev->i2c_adap, DVB_PLL_OPERA1);
1319 return 0;
1320}
1321
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001322static int dw3101_tuner_attach(struct dvb_usb_adapter *adap)
1323{
Michael Krufky77eed212011-09-06 09:31:57 -03001324 dvb_attach(dvb_pll_attach, adap->fe_adap[0].fe, 0x60,
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001325 &adap->dev->i2c_adap, DVB_PLL_TUA6034);
1326
1327 return 0;
1328}
1329
Mauro Carvalho Chehab2f4f58d2010-11-17 15:46:09 -03001330static struct rc_map_table rc_map_dw210x_table[] = {
Mauro Carvalho Chehab991bd3c2011-01-24 12:18:40 -03001331 { 0xf80a, KEY_POWER2 }, /*power*/
1332 { 0xf80c, KEY_MUTE }, /*mute*/
Mauro Carvalho Chehab2e365882009-08-29 15:19:31 -03001333 { 0xf811, KEY_1 },
1334 { 0xf812, KEY_2 },
1335 { 0xf813, KEY_3 },
1336 { 0xf814, KEY_4 },
1337 { 0xf815, KEY_5 },
1338 { 0xf816, KEY_6 },
1339 { 0xf817, KEY_7 },
1340 { 0xf818, KEY_8 },
1341 { 0xf819, KEY_9 },
1342 { 0xf810, KEY_0 },
Mauro Carvalho Chehab991bd3c2011-01-24 12:18:40 -03001343 { 0xf81c, KEY_CHANNELUP }, /*ch+*/
1344 { 0xf80f, KEY_CHANNELDOWN }, /*ch-*/
1345 { 0xf81a, KEY_VOLUMEUP }, /*vol+*/
1346 { 0xf80e, KEY_VOLUMEDOWN }, /*vol-*/
1347 { 0xf804, KEY_RECORD }, /*rec*/
1348 { 0xf809, KEY_FAVORITES }, /*fav*/
1349 { 0xf808, KEY_REWIND }, /*rewind*/
1350 { 0xf807, KEY_FASTFORWARD }, /*fast*/
1351 { 0xf80b, KEY_PAUSE }, /*pause*/
1352 { 0xf802, KEY_ESC }, /*cancel*/
1353 { 0xf803, KEY_TAB }, /*tab*/
Mauro Carvalho Chehab2e365882009-08-29 15:19:31 -03001354 { 0xf800, KEY_UP }, /*up*/
Mauro Carvalho Chehab991bd3c2011-01-24 12:18:40 -03001355 { 0xf81f, KEY_OK }, /*ok*/
1356 { 0xf801, KEY_DOWN }, /*down*/
1357 { 0xf805, KEY_CAMERA }, /*cap*/
1358 { 0xf806, KEY_STOP }, /*stop*/
1359 { 0xf840, KEY_ZOOM }, /*full*/
1360 { 0xf81e, KEY_TV }, /*tvmode*/
1361 { 0xf81b, KEY_LAST }, /*recall*/
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001362};
1363
Mauro Carvalho Chehab2f4f58d2010-11-17 15:46:09 -03001364static struct rc_map_table rc_map_tevii_table[] = {
Mauro Carvalho Chehab2e365882009-08-29 15:19:31 -03001365 { 0xf80a, KEY_POWER },
1366 { 0xf80c, KEY_MUTE },
1367 { 0xf811, KEY_1 },
1368 { 0xf812, KEY_2 },
1369 { 0xf813, KEY_3 },
1370 { 0xf814, KEY_4 },
1371 { 0xf815, KEY_5 },
1372 { 0xf816, KEY_6 },
1373 { 0xf817, KEY_7 },
1374 { 0xf818, KEY_8 },
1375 { 0xf819, KEY_9 },
1376 { 0xf810, KEY_0 },
1377 { 0xf81c, KEY_MENU },
1378 { 0xf80f, KEY_VOLUMEDOWN },
1379 { 0xf81a, KEY_LAST },
1380 { 0xf80e, KEY_OPEN },
1381 { 0xf804, KEY_RECORD },
1382 { 0xf809, KEY_VOLUMEUP },
1383 { 0xf808, KEY_CHANNELUP },
1384 { 0xf807, KEY_PVR },
1385 { 0xf80b, KEY_TIME },
1386 { 0xf802, KEY_RIGHT },
1387 { 0xf803, KEY_LEFT },
1388 { 0xf800, KEY_UP },
1389 { 0xf81f, KEY_OK },
1390 { 0xf801, KEY_DOWN },
1391 { 0xf805, KEY_TUNER },
1392 { 0xf806, KEY_CHANNELDOWN },
1393 { 0xf840, KEY_PLAYPAUSE },
1394 { 0xf81e, KEY_REWIND },
1395 { 0xf81b, KEY_FAVORITES },
1396 { 0xf81d, KEY_BACK },
1397 { 0xf84d, KEY_FASTFORWARD },
1398 { 0xf844, KEY_EPG },
1399 { 0xf84c, KEY_INFO },
1400 { 0xf841, KEY_AB },
1401 { 0xf843, KEY_AUDIO },
1402 { 0xf845, KEY_SUBTITLE },
1403 { 0xf84a, KEY_LIST },
1404 { 0xf846, KEY_F1 },
1405 { 0xf847, KEY_F2 },
1406 { 0xf85e, KEY_F3 },
1407 { 0xf85c, KEY_F4 },
1408 { 0xf852, KEY_F5 },
1409 { 0xf85a, KEY_F6 },
1410 { 0xf856, KEY_MODE },
1411 { 0xf858, KEY_SWITCHVIDEOMODE },
Igor M. Liplianinb42e1d72009-06-14 19:41:22 -03001412};
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001413
Mauro Carvalho Chehab2f4f58d2010-11-17 15:46:09 -03001414static struct rc_map_table rc_map_tbs_table[] = {
Mauro Carvalho Chehab2e365882009-08-29 15:19:31 -03001415 { 0xf884, KEY_POWER },
1416 { 0xf894, KEY_MUTE },
1417 { 0xf887, KEY_1 },
1418 { 0xf886, KEY_2 },
1419 { 0xf885, KEY_3 },
1420 { 0xf88b, KEY_4 },
1421 { 0xf88a, KEY_5 },
1422 { 0xf889, KEY_6 },
1423 { 0xf88f, KEY_7 },
1424 { 0xf88e, KEY_8 },
1425 { 0xf88d, KEY_9 },
1426 { 0xf892, KEY_0 },
1427 { 0xf896, KEY_CHANNELUP },
1428 { 0xf891, KEY_CHANNELDOWN },
1429 { 0xf893, KEY_VOLUMEUP },
1430 { 0xf88c, KEY_VOLUMEDOWN },
1431 { 0xf883, KEY_RECORD },
1432 { 0xf898, KEY_PAUSE },
1433 { 0xf899, KEY_OK },
1434 { 0xf89a, KEY_SHUFFLE },
1435 { 0xf881, KEY_UP },
1436 { 0xf890, KEY_LEFT },
1437 { 0xf882, KEY_RIGHT },
1438 { 0xf888, KEY_DOWN },
1439 { 0xf895, KEY_FAVORITES },
1440 { 0xf897, KEY_SUBTITLE },
1441 { 0xf89d, KEY_ZOOM },
1442 { 0xf89f, KEY_EXIT },
1443 { 0xf89e, KEY_MENU },
1444 { 0xf89c, KEY_EPG },
1445 { 0xf880, KEY_PREVIOUS },
1446 { 0xf89b, KEY_MODE }
Igor M. Liplianinb42e1d72009-06-14 19:41:22 -03001447};
1448
Igor M. Liplianind2ffc442011-02-25 18:41:22 -03001449static struct rc_map_table rc_map_su3000_table[] = {
1450 { 0x25, KEY_POWER }, /* right-bottom Red */
1451 { 0x0a, KEY_MUTE }, /* -/-- */
1452 { 0x01, KEY_1 },
1453 { 0x02, KEY_2 },
1454 { 0x03, KEY_3 },
1455 { 0x04, KEY_4 },
1456 { 0x05, KEY_5 },
1457 { 0x06, KEY_6 },
1458 { 0x07, KEY_7 },
1459 { 0x08, KEY_8 },
1460 { 0x09, KEY_9 },
1461 { 0x00, KEY_0 },
1462 { 0x20, KEY_UP }, /* CH+ */
1463 { 0x21, KEY_DOWN }, /* CH+ */
1464 { 0x12, KEY_VOLUMEUP }, /* Brightness Up */
1465 { 0x13, KEY_VOLUMEDOWN },/* Brightness Down */
1466 { 0x1f, KEY_RECORD },
1467 { 0x17, KEY_PLAY },
1468 { 0x16, KEY_PAUSE },
1469 { 0x0b, KEY_STOP },
1470 { 0x27, KEY_FASTFORWARD },/* >> */
1471 { 0x26, KEY_REWIND }, /* << */
1472 { 0x0d, KEY_OK }, /* Mute */
1473 { 0x11, KEY_LEFT }, /* VOL- */
1474 { 0x10, KEY_RIGHT }, /* VOL+ */
1475 { 0x29, KEY_BACK }, /* button under 9 */
1476 { 0x2c, KEY_MENU }, /* TTX */
1477 { 0x2b, KEY_EPG }, /* EPG */
1478 { 0x1e, KEY_RED }, /* OSD */
1479 { 0x0e, KEY_GREEN }, /* Window */
1480 { 0x2d, KEY_YELLOW }, /* button under << */
1481 { 0x0f, KEY_BLUE }, /* bottom yellow button */
1482 { 0x14, KEY_AUDIO }, /* Snapshot */
1483 { 0x38, KEY_TV }, /* TV/Radio */
Justin P. Mattock70f23fd2011-05-10 10:16:21 +02001484 { 0x0c, KEY_ESC } /* upper Red button */
Igor M. Liplianind2ffc442011-02-25 18:41:22 -03001485};
1486
Mauro Carvalho Chehab2f4f58d2010-11-17 15:46:09 -03001487static struct rc_map_dvb_usb_table_table keys_tables[] = {
1488 { rc_map_dw210x_table, ARRAY_SIZE(rc_map_dw210x_table) },
1489 { rc_map_tevii_table, ARRAY_SIZE(rc_map_tevii_table) },
1490 { rc_map_tbs_table, ARRAY_SIZE(rc_map_tbs_table) },
Igor M. Liplianind2ffc442011-02-25 18:41:22 -03001491 { rc_map_su3000_table, ARRAY_SIZE(rc_map_su3000_table) },
Igor M. Liplianinb42e1d72009-06-14 19:41:22 -03001492};
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001493
1494static int dw2102_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
1495{
Mauro Carvalho Chehab2f4f58d2010-11-17 15:46:09 -03001496 struct rc_map_table *keymap = d->props.rc.legacy.rc_map_table;
1497 int keymap_size = d->props.rc.legacy.rc_map_size;
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001498 u8 key[2];
Igor M. Liplianin8a8dad72009-06-13 08:10:24 -03001499 struct i2c_msg msg = {
1500 .addr = DW2102_RC_QUERY,
1501 .flags = I2C_M_RD,
1502 .buf = key,
1503 .len = 2
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001504 };
1505 int i;
Igor M. Liplianinb42e1d72009-06-14 19:41:22 -03001506 /* override keymap */
1507 if ((ir_keymap > 0) && (ir_keymap <= ARRAY_SIZE(keys_tables))) {
1508 keymap = keys_tables[ir_keymap - 1].rc_keys ;
1509 keymap_size = keys_tables[ir_keymap - 1].rc_keys_size;
Igor M. Liplianinfeb16e92011-02-25 18:41:22 -03001510 } else if (ir_keymap > ARRAY_SIZE(keys_tables))
1511 return 0; /* none */
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001512
1513 *state = REMOTE_NO_KEY_PRESSED;
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -03001514 if (d->props.i2c_algo->master_xfer(&d->i2c_adap, &msg, 1) == 1) {
Igor M. Liplianinb42e1d72009-06-14 19:41:22 -03001515 for (i = 0; i < keymap_size ; i++) {
Mauro Carvalho Chehab2e365882009-08-29 15:19:31 -03001516 if (rc5_data(&keymap[i]) == msg.buf[0]) {
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001517 *state = REMOTE_KEY_PRESSED;
Mauro Carvalho Chehab34abf212010-07-31 11:24:57 -03001518 *event = keymap[i].keycode;
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001519 break;
1520 }
Igor M. Liplianin8a8dad72009-06-13 08:10:24 -03001521
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001522 }
Igor M. Liplianin8a8dad72009-06-13 08:10:24 -03001523
1524 if ((*state) == REMOTE_KEY_PRESSED)
1525 deb_rc("%s: found rc key: %x, %x, event: %x\n",
1526 __func__, key[0], key[1], (*event));
1527 else if (key[0] != 0xff)
1528 deb_rc("%s: unknown rc key: %x, %x\n",
1529 __func__, key[0], key[1]);
1530
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001531 }
Igor M. Liplianin8a8dad72009-06-13 08:10:24 -03001532
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001533 return 0;
1534}
1535
Jonathan Nieder27351b12011-12-23 19:00:45 -03001536enum dw2102_table_entry {
1537 CYPRESS_DW2102,
1538 CYPRESS_DW2101,
1539 CYPRESS_DW2104,
1540 TEVII_S650,
1541 TERRATEC_CINERGY_S,
1542 CYPRESS_DW3101,
1543 TEVII_S630,
1544 PROF_1100,
1545 TEVII_S660,
1546 PROF_7500,
1547 GENIATECH_SU3000,
1548 TERRATEC_CINERGY_S2,
1549 TEVII_S480_1,
1550 TEVII_S480_2,
1551 X3M_SPC1400HD,
Igor M. Liplianin955d00a2012-05-08 03:53:17 -03001552 TEVII_S421,
1553 TEVII_S632,
Igor M. Liplianin44122dd2013-02-21 08:11:41 -03001554 TERRATEC_CINERGY_S2_R2,
Andrey Pavlenkof08e9f02013-03-07 09:36:22 -03001555 GOTVIEW_SAT_HD,
Jonathan Nieder27351b12011-12-23 19:00:45 -03001556};
1557
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001558static struct usb_device_id dw2102_table[] = {
Jonathan Nieder27351b12011-12-23 19:00:45 -03001559 [CYPRESS_DW2102] = {USB_DEVICE(USB_VID_CYPRESS, USB_PID_DW2102)},
1560 [CYPRESS_DW2101] = {USB_DEVICE(USB_VID_CYPRESS, 0x2101)},
1561 [CYPRESS_DW2104] = {USB_DEVICE(USB_VID_CYPRESS, USB_PID_DW2104)},
1562 [TEVII_S650] = {USB_DEVICE(0x9022, USB_PID_TEVII_S650)},
1563 [TERRATEC_CINERGY_S] = {USB_DEVICE(USB_VID_TERRATEC, USB_PID_CINERGY_S)},
1564 [CYPRESS_DW3101] = {USB_DEVICE(USB_VID_CYPRESS, USB_PID_DW3101)},
1565 [TEVII_S630] = {USB_DEVICE(0x9022, USB_PID_TEVII_S630)},
1566 [PROF_1100] = {USB_DEVICE(0x3011, USB_PID_PROF_1100)},
1567 [TEVII_S660] = {USB_DEVICE(0x9022, USB_PID_TEVII_S660)},
1568 [PROF_7500] = {USB_DEVICE(0x3034, 0x7500)},
1569 [GENIATECH_SU3000] = {USB_DEVICE(0x1f4d, 0x3000)},
1570 [TERRATEC_CINERGY_S2] = {USB_DEVICE(USB_VID_TERRATEC, 0x00a8)},
1571 [TEVII_S480_1] = {USB_DEVICE(0x9022, USB_PID_TEVII_S480_1)},
1572 [TEVII_S480_2] = {USB_DEVICE(0x9022, USB_PID_TEVII_S480_2)},
1573 [X3M_SPC1400HD] = {USB_DEVICE(0x1f4d, 0x3100)},
Igor M. Liplianin955d00a2012-05-08 03:53:17 -03001574 [TEVII_S421] = {USB_DEVICE(0x9022, USB_PID_TEVII_S421)},
1575 [TEVII_S632] = {USB_DEVICE(0x9022, USB_PID_TEVII_S632)},
Igor M. Liplianin44122dd2013-02-21 08:11:41 -03001576 [TERRATEC_CINERGY_S2_R2] = {USB_DEVICE(USB_VID_TERRATEC, 0x00b0)},
Andrey Pavlenkof08e9f02013-03-07 09:36:22 -03001577 [GOTVIEW_SAT_HD] = {USB_DEVICE(0x1FE1, USB_PID_GOTVIEW_SAT_HD)},
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001578 { }
1579};
1580
1581MODULE_DEVICE_TABLE(usb, dw2102_table);
1582
1583static int dw2102_load_firmware(struct usb_device *dev,
1584 const struct firmware *frmwr)
1585{
1586 u8 *b, *p;
1587 int ret = 0, i;
1588 u8 reset;
Igor M. Liplianin8a4949b2008-10-05 09:11:21 -03001589 u8 reset16[] = {0, 0, 0, 0, 0, 0, 0};
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001590 const struct firmware *fw;
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -03001591
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001592 switch (dev->descriptor.idProduct) {
1593 case 0x2101:
Rémi Cardona68236272012-09-28 08:59:32 -03001594 ret = request_firmware(&fw, DW2101_FIRMWARE, &dev->dev);
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001595 if (ret != 0) {
Rémi Cardona68236272012-09-28 08:59:32 -03001596 err(err_str, DW2101_FIRMWARE);
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001597 return ret;
1598 }
1599 break;
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001600 default:
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001601 fw = frmwr;
1602 break;
1603 }
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001604 info("start downloading DW210X firmware");
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001605 p = kmalloc(fw->size, GFP_KERNEL);
1606 reset = 1;
1607 /*stop the CPU*/
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001608 dw210x_op_rw(dev, 0xa0, 0x7f92, 0, &reset, 1, DW210X_WRITE_MSG);
1609 dw210x_op_rw(dev, 0xa0, 0xe600, 0, &reset, 1, DW210X_WRITE_MSG);
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001610
1611 if (p != NULL) {
1612 memcpy(p, fw->data, fw->size);
1613 for (i = 0; i < fw->size; i += 0x40) {
1614 b = (u8 *) p + i;
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001615 if (dw210x_op_rw(dev, 0xa0, i, 0, b , 0x40,
1616 DW210X_WRITE_MSG) != 0x40) {
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001617 err("error while transferring firmware");
1618 ret = -EINVAL;
1619 break;
1620 }
1621 }
1622 /* restart the CPU */
1623 reset = 0;
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001624 if (ret || dw210x_op_rw(dev, 0xa0, 0x7f92, 0, &reset, 1,
1625 DW210X_WRITE_MSG) != 1) {
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001626 err("could not restart the USB controller CPU.");
1627 ret = -EINVAL;
1628 }
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001629 if (ret || dw210x_op_rw(dev, 0xa0, 0xe600, 0, &reset, 1,
1630 DW210X_WRITE_MSG) != 1) {
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001631 err("could not restart the USB controller CPU.");
1632 ret = -EINVAL;
1633 }
1634 /* init registers */
1635 switch (dev->descriptor.idProduct) {
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001636 case USB_PID_TEVII_S650:
Mauro Carvalho Chehab2f4f58d2010-11-17 15:46:09 -03001637 dw2104_properties.rc.legacy.rc_map_table = rc_map_tevii_table;
1638 dw2104_properties.rc.legacy.rc_map_size =
1639 ARRAY_SIZE(rc_map_tevii_table);
Igor M. Liplianinb42e1d72009-06-14 19:41:22 -03001640 case USB_PID_DW2104:
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001641 reset = 1;
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001642 dw210x_op_rw(dev, 0xc4, 0x0000, 0, &reset, 1,
1643 DW210X_WRITE_MSG);
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001644 /* break omitted intentionally */
1645 case USB_PID_DW3101:
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001646 reset = 0;
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001647 dw210x_op_rw(dev, 0xbf, 0x0040, 0, &reset, 0,
1648 DW210X_WRITE_MSG);
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001649 break;
Igor M. Liplianin4cc0edf2008-11-05 22:12:56 -03001650 case USB_PID_CINERGY_S:
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001651 case USB_PID_DW2102:
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001652 dw210x_op_rw(dev, 0xbf, 0x0040, 0, &reset, 0,
1653 DW210X_WRITE_MSG);
1654 dw210x_op_rw(dev, 0xb9, 0x0000, 0, &reset16[0], 2,
1655 DW210X_READ_MSG);
1656 /* check STV0299 frontend */
1657 dw210x_op_rw(dev, 0xb5, 0, 0, &reset16[0], 2,
1658 DW210X_READ_MSG);
Igor M. Liplianinea023df2008-12-04 12:49:23 -03001659 if ((reset16[0] == 0xa1) || (reset16[0] == 0x80)) {
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001660 dw2102_properties.i2c_algo = &dw2102_i2c_algo;
Michael Krufky77eed212011-09-06 09:31:57 -03001661 dw2102_properties.adapter->fe[0].tuner_attach = &dw2102_tuner_attach;
Igor M. Liplianin8a4949b2008-10-05 09:11:21 -03001662 break;
1663 } else {
1664 /* check STV0288 frontend */
1665 reset16[0] = 0xd0;
1666 reset16[1] = 1;
1667 reset16[2] = 0;
1668 dw210x_op_rw(dev, 0xc2, 0, 0, &reset16[0], 3,
1669 DW210X_WRITE_MSG);
1670 dw210x_op_rw(dev, 0xc3, 0xd1, 0, &reset16[0], 3,
1671 DW210X_READ_MSG);
1672 if (reset16[2] == 0x11) {
1673 dw2102_properties.i2c_algo = &dw2102_earda_i2c_algo;
Igor M. Liplianin8a4949b2008-10-05 09:11:21 -03001674 break;
1675 }
1676 }
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001677 case 0x2101:
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001678 dw210x_op_rw(dev, 0xbc, 0x0030, 0, &reset16[0], 2,
1679 DW210X_READ_MSG);
1680 dw210x_op_rw(dev, 0xba, 0x0000, 0, &reset16[0], 7,
1681 DW210X_READ_MSG);
1682 dw210x_op_rw(dev, 0xba, 0x0000, 0, &reset16[0], 7,
1683 DW210X_READ_MSG);
1684 dw210x_op_rw(dev, 0xb9, 0x0000, 0, &reset16[0], 2,
1685 DW210X_READ_MSG);
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001686 break;
1687 }
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001688
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001689 msleep(100);
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001690 kfree(p);
1691 }
1692 return ret;
1693}
1694
1695static struct dvb_usb_device_properties dw2102_properties = {
1696 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1697 .usb_ctrl = DEVICE_SPECIFIC,
Rémi Cardona68236272012-09-28 08:59:32 -03001698 .firmware = DW2102_FIRMWARE,
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001699 .no_reconnect = 1,
1700
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001701 .i2c_algo = &dw2102_serit_i2c_algo,
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03001702
1703 .rc.legacy = {
Mauro Carvalho Chehab2f4f58d2010-11-17 15:46:09 -03001704 .rc_map_table = rc_map_dw210x_table,
1705 .rc_map_size = ARRAY_SIZE(rc_map_dw210x_table),
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03001706 .rc_interval = 150,
1707 .rc_query = dw2102_rc_query,
1708 },
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001709
1710 .generic_bulk_ctrl_endpoint = 0x81,
1711 /* parameter for the MPEG2-data transfer */
1712 .num_adapters = 1,
1713 .download_firmware = dw2102_load_firmware,
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001714 .read_mac_address = dw210x_read_mac_address,
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001715 .adapter = {
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001716 {
Michael Krufky77eed212011-09-06 09:31:57 -03001717 .num_frontends = 1,
1718 .fe = {{
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001719 .frontend_attach = dw2102_frontend_attach,
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001720 .stream = {
1721 .type = USB_BULK,
1722 .count = 8,
1723 .endpoint = 0x82,
1724 .u = {
1725 .bulk = {
1726 .buffersize = 4096,
1727 }
1728 }
1729 },
Michael Krufky77eed212011-09-06 09:31:57 -03001730 }},
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001731 }
1732 },
Igor M. Liplianin4cc0edf2008-11-05 22:12:56 -03001733 .num_device_descs = 3,
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001734 .devices = {
1735 {"DVBWorld DVB-S 2102 USB2.0",
Jonathan Nieder27351b12011-12-23 19:00:45 -03001736 {&dw2102_table[CYPRESS_DW2102], NULL},
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001737 {NULL},
1738 },
1739 {"DVBWorld DVB-S 2101 USB2.0",
Jonathan Nieder27351b12011-12-23 19:00:45 -03001740 {&dw2102_table[CYPRESS_DW2101], NULL},
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001741 {NULL},
1742 },
Igor M. Liplianin4cc0edf2008-11-05 22:12:56 -03001743 {"TerraTec Cinergy S USB",
Jonathan Nieder27351b12011-12-23 19:00:45 -03001744 {&dw2102_table[TERRATEC_CINERGY_S], NULL},
Igor M. Liplianin4cc0edf2008-11-05 22:12:56 -03001745 {NULL},
1746 },
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001747 }
1748};
1749
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001750static struct dvb_usb_device_properties dw2104_properties = {
1751 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1752 .usb_ctrl = DEVICE_SPECIFIC,
Rémi Cardona68236272012-09-28 08:59:32 -03001753 .firmware = DW2104_FIRMWARE,
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001754 .no_reconnect = 1,
1755
1756 .i2c_algo = &dw2104_i2c_algo,
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03001757 .rc.legacy = {
Mauro Carvalho Chehab2f4f58d2010-11-17 15:46:09 -03001758 .rc_map_table = rc_map_dw210x_table,
1759 .rc_map_size = ARRAY_SIZE(rc_map_dw210x_table),
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03001760 .rc_interval = 150,
1761 .rc_query = dw2102_rc_query,
1762 },
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001763
1764 .generic_bulk_ctrl_endpoint = 0x81,
1765 /* parameter for the MPEG2-data transfer */
1766 .num_adapters = 1,
1767 .download_firmware = dw2102_load_firmware,
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001768 .read_mac_address = dw210x_read_mac_address,
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001769 .adapter = {
1770 {
Michael Krufky77eed212011-09-06 09:31:57 -03001771 .num_frontends = 1,
1772 .fe = {{
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001773 .frontend_attach = dw2104_frontend_attach,
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001774 .stream = {
1775 .type = USB_BULK,
1776 .count = 8,
1777 .endpoint = 0x82,
1778 .u = {
1779 .bulk = {
1780 .buffersize = 4096,
1781 }
1782 }
1783 },
Michael Krufky77eed212011-09-06 09:31:57 -03001784 }},
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001785 }
1786 },
1787 .num_device_descs = 2,
1788 .devices = {
1789 { "DVBWorld DW2104 USB2.0",
Jonathan Nieder27351b12011-12-23 19:00:45 -03001790 {&dw2102_table[CYPRESS_DW2104], NULL},
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001791 {NULL},
1792 },
1793 { "TeVii S650 USB2.0",
Jonathan Nieder27351b12011-12-23 19:00:45 -03001794 {&dw2102_table[TEVII_S650], NULL},
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001795 {NULL},
1796 },
1797 }
1798};
1799
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001800static struct dvb_usb_device_properties dw3101_properties = {
1801 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1802 .usb_ctrl = DEVICE_SPECIFIC,
Rémi Cardona68236272012-09-28 08:59:32 -03001803 .firmware = DW3101_FIRMWARE,
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001804 .no_reconnect = 1,
1805
1806 .i2c_algo = &dw3101_i2c_algo,
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03001807 .rc.legacy = {
Mauro Carvalho Chehab2f4f58d2010-11-17 15:46:09 -03001808 .rc_map_table = rc_map_dw210x_table,
1809 .rc_map_size = ARRAY_SIZE(rc_map_dw210x_table),
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03001810 .rc_interval = 150,
1811 .rc_query = dw2102_rc_query,
1812 },
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001813
1814 .generic_bulk_ctrl_endpoint = 0x81,
1815 /* parameter for the MPEG2-data transfer */
1816 .num_adapters = 1,
1817 .download_firmware = dw2102_load_firmware,
1818 .read_mac_address = dw210x_read_mac_address,
1819 .adapter = {
1820 {
Michael Krufky77eed212011-09-06 09:31:57 -03001821 .num_frontends = 1,
1822 .fe = {{
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001823 .frontend_attach = dw3101_frontend_attach,
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001824 .tuner_attach = dw3101_tuner_attach,
1825 .stream = {
1826 .type = USB_BULK,
1827 .count = 8,
1828 .endpoint = 0x82,
1829 .u = {
1830 .bulk = {
1831 .buffersize = 4096,
1832 }
1833 }
1834 },
Michael Krufky77eed212011-09-06 09:31:57 -03001835 }},
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001836 }
1837 },
1838 .num_device_descs = 1,
1839 .devices = {
1840 { "DVBWorld DVB-C 3101 USB2.0",
Jonathan Nieder27351b12011-12-23 19:00:45 -03001841 {&dw2102_table[CYPRESS_DW3101], NULL},
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001842 {NULL},
1843 },
1844 }
1845};
1846
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001847static struct dvb_usb_device_properties s6x0_properties = {
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -03001848 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1849 .usb_ctrl = DEVICE_SPECIFIC,
Igor M. Liplianin52c506e2011-02-25 18:41:23 -03001850 .size_of_priv = sizeof(struct s6x0_state),
Rémi Cardona68236272012-09-28 08:59:32 -03001851 .firmware = S630_FIRMWARE,
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -03001852 .no_reconnect = 1,
1853
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001854 .i2c_algo = &s6x0_i2c_algo,
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03001855 .rc.legacy = {
Mauro Carvalho Chehab2f4f58d2010-11-17 15:46:09 -03001856 .rc_map_table = rc_map_tevii_table,
1857 .rc_map_size = ARRAY_SIZE(rc_map_tevii_table),
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03001858 .rc_interval = 150,
1859 .rc_query = dw2102_rc_query,
1860 },
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -03001861
1862 .generic_bulk_ctrl_endpoint = 0x81,
1863 .num_adapters = 1,
1864 .download_firmware = dw2102_load_firmware,
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001865 .read_mac_address = s6x0_read_mac_address,
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -03001866 .adapter = {
1867 {
Michael Krufky77eed212011-09-06 09:31:57 -03001868 .num_frontends = 1,
1869 .fe = {{
Igor M. Liplianin195288d2011-02-25 18:41:22 -03001870 .frontend_attach = zl100313_frontend_attach,
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -03001871 .stream = {
1872 .type = USB_BULK,
1873 .count = 8,
1874 .endpoint = 0x82,
1875 .u = {
1876 .bulk = {
1877 .buffersize = 4096,
1878 }
1879 }
1880 },
Michael Krufky77eed212011-09-06 09:31:57 -03001881 }},
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -03001882 }
1883 },
Igor M. Liplianin195288d2011-02-25 18:41:22 -03001884 .num_device_descs = 1,
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -03001885 .devices = {
1886 {"TeVii S630 USB",
Jonathan Nieder27351b12011-12-23 19:00:45 -03001887 {&dw2102_table[TEVII_S630], NULL},
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -03001888 {NULL},
1889 },
1890 }
1891};
1892
Igor M. Liplianin195288d2011-02-25 18:41:22 -03001893struct dvb_usb_device_properties *p1100;
1894static struct dvb_usb_device_description d1100 = {
1895 "Prof 1100 USB ",
Jonathan Nieder27351b12011-12-23 19:00:45 -03001896 {&dw2102_table[PROF_1100], NULL},
Igor M. Liplianin195288d2011-02-25 18:41:22 -03001897 {NULL},
1898};
1899
1900struct dvb_usb_device_properties *s660;
1901static struct dvb_usb_device_description d660 = {
1902 "TeVii S660 USB",
Jonathan Nieder27351b12011-12-23 19:00:45 -03001903 {&dw2102_table[TEVII_S660], NULL},
Igor M. Liplianin195288d2011-02-25 18:41:22 -03001904 {NULL},
1905};
1906
Igor M. Liplianine8f50552011-02-25 18:41:23 -03001907static struct dvb_usb_device_description d480_1 = {
1908 "TeVii S480.1 USB",
Jonathan Nieder27351b12011-12-23 19:00:45 -03001909 {&dw2102_table[TEVII_S480_1], NULL},
Igor M. Liplianine8f50552011-02-25 18:41:23 -03001910 {NULL},
1911};
1912
1913static struct dvb_usb_device_description d480_2 = {
1914 "TeVii S480.2 USB",
Jonathan Nieder27351b12011-12-23 19:00:45 -03001915 {&dw2102_table[TEVII_S480_2], NULL},
Igor M. Liplianine8f50552011-02-25 18:41:23 -03001916 {NULL},
1917};
1918
Igor M. Liplianincd79d332009-12-14 20:24:56 -03001919struct dvb_usb_device_properties *p7500;
1920static struct dvb_usb_device_description d7500 = {
1921 "Prof 7500 USB DVB-S2",
Jonathan Nieder27351b12011-12-23 19:00:45 -03001922 {&dw2102_table[PROF_7500], NULL},
Igor M. Liplianincd79d332009-12-14 20:24:56 -03001923 {NULL},
1924};
1925
Igor M. Liplianin955d00a2012-05-08 03:53:17 -03001926struct dvb_usb_device_properties *s421;
1927static struct dvb_usb_device_description d421 = {
1928 "TeVii S421 PCI",
1929 {&dw2102_table[TEVII_S421], NULL},
1930 {NULL},
1931};
1932
1933static struct dvb_usb_device_description d632 = {
1934 "TeVii S632 USB",
1935 {&dw2102_table[TEVII_S632], NULL},
1936 {NULL},
1937};
1938
Igor M. Liplianind2ffc442011-02-25 18:41:22 -03001939static struct dvb_usb_device_properties su3000_properties = {
1940 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1941 .usb_ctrl = DEVICE_SPECIFIC,
1942 .size_of_priv = sizeof(struct su3000_state),
1943 .power_ctrl = su3000_power_ctrl,
1944 .num_adapters = 1,
1945 .identify_state = su3000_identify_state,
1946 .i2c_algo = &su3000_i2c_algo,
1947
1948 .rc.legacy = {
1949 .rc_map_table = rc_map_su3000_table,
1950 .rc_map_size = ARRAY_SIZE(rc_map_su3000_table),
1951 .rc_interval = 150,
1952 .rc_query = dw2102_rc_query,
1953 },
1954
1955 .read_mac_address = su3000_read_mac_address,
1956
1957 .generic_bulk_ctrl_endpoint = 0x01,
1958
1959 .adapter = {
1960 {
Michael Krufky77eed212011-09-06 09:31:57 -03001961 .num_frontends = 1,
1962 .fe = {{
Igor M. Liplianind2ffc442011-02-25 18:41:22 -03001963 .streaming_ctrl = su3000_streaming_ctrl,
1964 .frontend_attach = su3000_frontend_attach,
1965 .stream = {
1966 .type = USB_BULK,
1967 .count = 8,
1968 .endpoint = 0x82,
1969 .u = {
1970 .bulk = {
1971 .buffersize = 4096,
1972 }
1973 }
1974 }
Michael Krufky77eed212011-09-06 09:31:57 -03001975 }},
Igor M. Liplianind2ffc442011-02-25 18:41:22 -03001976 }
1977 },
Andrey Pavlenkof08e9f02013-03-07 09:36:22 -03001978 .num_device_descs = 5,
Igor M. Liplianind2ffc442011-02-25 18:41:22 -03001979 .devices = {
1980 { "SU3000HD DVB-S USB2.0",
Jonathan Nieder27351b12011-12-23 19:00:45 -03001981 { &dw2102_table[GENIATECH_SU3000], NULL },
Igor M. Liplianind2ffc442011-02-25 18:41:22 -03001982 { NULL },
1983 },
Igor M. Liplianin2adc5912011-02-25 18:41:22 -03001984 { "Terratec Cinergy S2 USB HD",
Jonathan Nieder27351b12011-12-23 19:00:45 -03001985 { &dw2102_table[TERRATEC_CINERGY_S2], NULL },
Igor M. Liplianin2adc5912011-02-25 18:41:22 -03001986 { NULL },
1987 },
Igor M. Liplianin5265ea52011-02-27 16:17:25 -03001988 { "X3M TV SPC1400HD PCI",
Jonathan Nieder27351b12011-12-23 19:00:45 -03001989 { &dw2102_table[X3M_SPC1400HD], NULL },
Igor M. Liplianin5265ea52011-02-27 16:17:25 -03001990 { NULL },
1991 },
Igor M. Liplianin44122dd2013-02-21 08:11:41 -03001992 { "Terratec Cinergy S2 USB HD Rev.2",
1993 { &dw2102_table[TERRATEC_CINERGY_S2_R2], NULL },
1994 { NULL },
1995 },
Andrey Pavlenkof08e9f02013-03-07 09:36:22 -03001996 { "GOTVIEW Satellite HD",
1997 { &dw2102_table[GOTVIEW_SAT_HD], NULL },
1998 { NULL },
1999 },
Igor M. Liplianind2ffc442011-02-25 18:41:22 -03002000 }
2001};
2002
Igor M Liplianin7fd48282008-07-20 08:05:50 -03002003static int dw2102_probe(struct usb_interface *intf,
2004 const struct usb_device_id *id)
2005{
Thomas Meyer68dd9dd2011-11-17 18:43:40 -03002006 p1100 = kmemdup(&s6x0_properties,
2007 sizeof(struct dvb_usb_device_properties), GFP_KERNEL);
Igor M. Liplianin195288d2011-02-25 18:41:22 -03002008 if (!p1100)
Igor M. Liplianincd79d332009-12-14 20:24:56 -03002009 return -ENOMEM;
2010 /* copy default structure */
Igor M. Liplianincd79d332009-12-14 20:24:56 -03002011 /* fill only different fields */
Rémi Cardona68236272012-09-28 08:59:32 -03002012 p1100->firmware = P1100_FIRMWARE;
Igor M. Liplianin195288d2011-02-25 18:41:22 -03002013 p1100->devices[0] = d1100;
2014 p1100->rc.legacy.rc_map_table = rc_map_tbs_table;
2015 p1100->rc.legacy.rc_map_size = ARRAY_SIZE(rc_map_tbs_table);
Michael Krufky77eed212011-09-06 09:31:57 -03002016 p1100->adapter->fe[0].frontend_attach = stv0288_frontend_attach;
Igor M. Liplianin195288d2011-02-25 18:41:22 -03002017
Thomas Meyer68dd9dd2011-11-17 18:43:40 -03002018 s660 = kmemdup(&s6x0_properties,
2019 sizeof(struct dvb_usb_device_properties), GFP_KERNEL);
Igor M. Liplianin195288d2011-02-25 18:41:22 -03002020 if (!s660) {
2021 kfree(p1100);
2022 return -ENOMEM;
2023 }
Rémi Cardona68236272012-09-28 08:59:32 -03002024 s660->firmware = S660_FIRMWARE;
Igor M. Liplianine8f50552011-02-25 18:41:23 -03002025 s660->num_device_descs = 3;
Igor M. Liplianin195288d2011-02-25 18:41:22 -03002026 s660->devices[0] = d660;
Igor M. Liplianine8f50552011-02-25 18:41:23 -03002027 s660->devices[1] = d480_1;
2028 s660->devices[2] = d480_2;
Michael Krufky77eed212011-09-06 09:31:57 -03002029 s660->adapter->fe[0].frontend_attach = ds3000_frontend_attach;
Igor M. Liplianin195288d2011-02-25 18:41:22 -03002030
Thomas Meyer68dd9dd2011-11-17 18:43:40 -03002031 p7500 = kmemdup(&s6x0_properties,
2032 sizeof(struct dvb_usb_device_properties), GFP_KERNEL);
Igor M. Liplianin195288d2011-02-25 18:41:22 -03002033 if (!p7500) {
2034 kfree(p1100);
2035 kfree(s660);
2036 return -ENOMEM;
2037 }
Rémi Cardona68236272012-09-28 08:59:32 -03002038 p7500->firmware = P7500_FIRMWARE;
Igor M. Liplianincd79d332009-12-14 20:24:56 -03002039 p7500->devices[0] = d7500;
Mauro Carvalho Chehab2f4f58d2010-11-17 15:46:09 -03002040 p7500->rc.legacy.rc_map_table = rc_map_tbs_table;
2041 p7500->rc.legacy.rc_map_size = ARRAY_SIZE(rc_map_tbs_table);
Michael Krufky77eed212011-09-06 09:31:57 -03002042 p7500->adapter->fe[0].frontend_attach = prof_7500_frontend_attach;
Igor M. Liplianincd79d332009-12-14 20:24:56 -03002043
Igor M. Liplianin955d00a2012-05-08 03:53:17 -03002044
2045 s421 = kmemdup(&su3000_properties,
2046 sizeof(struct dvb_usb_device_properties), GFP_KERNEL);
2047 if (!s421) {
2048 kfree(p1100);
2049 kfree(s660);
2050 kfree(p7500);
2051 return -ENOMEM;
2052 }
2053 s421->num_device_descs = 2;
2054 s421->devices[0] = d421;
2055 s421->devices[1] = d632;
2056 s421->adapter->fe[0].frontend_attach = m88rs2000_frontend_attach;
2057
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03002058 if (0 == dvb_usb_device_init(intf, &dw2102_properties,
2059 THIS_MODULE, NULL, adapter_nr) ||
2060 0 == dvb_usb_device_init(intf, &dw2104_properties,
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03002061 THIS_MODULE, NULL, adapter_nr) ||
2062 0 == dvb_usb_device_init(intf, &dw3101_properties,
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -03002063 THIS_MODULE, NULL, adapter_nr) ||
Igor M. Liplianin141cc352009-11-27 14:37:35 -03002064 0 == dvb_usb_device_init(intf, &s6x0_properties,
Igor M. Liplianincd79d332009-12-14 20:24:56 -03002065 THIS_MODULE, NULL, adapter_nr) ||
Igor M. Liplianin195288d2011-02-25 18:41:22 -03002066 0 == dvb_usb_device_init(intf, p1100,
2067 THIS_MODULE, NULL, adapter_nr) ||
2068 0 == dvb_usb_device_init(intf, s660,
2069 THIS_MODULE, NULL, adapter_nr) ||
Igor M. Liplianincd79d332009-12-14 20:24:56 -03002070 0 == dvb_usb_device_init(intf, p7500,
Igor M. Liplianind2ffc442011-02-25 18:41:22 -03002071 THIS_MODULE, NULL, adapter_nr) ||
Igor M. Liplianin955d00a2012-05-08 03:53:17 -03002072 0 == dvb_usb_device_init(intf, s421,
2073 THIS_MODULE, NULL, adapter_nr) ||
Igor M. Liplianind2ffc442011-02-25 18:41:22 -03002074 0 == dvb_usb_device_init(intf, &su3000_properties,
2075 THIS_MODULE, NULL, adapter_nr))
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03002076 return 0;
Igor M. Liplianin141cc352009-11-27 14:37:35 -03002077
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03002078 return -ENODEV;
Igor M Liplianin7fd48282008-07-20 08:05:50 -03002079}
2080
2081static struct usb_driver dw2102_driver = {
2082 .name = "dw2102",
2083 .probe = dw2102_probe,
2084 .disconnect = dvb_usb_device_exit,
2085 .id_table = dw2102_table,
2086};
2087
Greg Kroah-Hartmanecb3b2b2011-11-18 09:46:12 -08002088module_usb_driver(dw2102_driver);
Igor M Liplianin7fd48282008-07-20 08:05:50 -03002089
2090MODULE_AUTHOR("Igor M. Liplianin (c) liplianin@me.by");
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03002091MODULE_DESCRIPTION("Driver for DVBWorld DVB-S 2101, 2102, DVB-S2 2104,"
Igor M. Liplianin955d00a2012-05-08 03:53:17 -03002092 " DVB-C 3101 USB2.0,"
2093 " TeVii S600, S630, S650, S660, S480, S421, S632"
2094 " Prof 1100, 7500 USB2.0,"
2095 " Geniatech SU3000 devices");
Igor M Liplianin7fd48282008-07-20 08:05:50 -03002096MODULE_VERSION("0.1");
2097MODULE_LICENSE("GPL");
Rémi Cardona68236272012-09-28 08:59:32 -03002098MODULE_FIRMWARE(DW2101_FIRMWARE);
2099MODULE_FIRMWARE(DW2102_FIRMWARE);
2100MODULE_FIRMWARE(DW2104_FIRMWARE);
2101MODULE_FIRMWARE(DW3101_FIRMWARE);
2102MODULE_FIRMWARE(S630_FIRMWARE);
2103MODULE_FIRMWARE(S660_FIRMWARE);
2104MODULE_FIRMWARE(P1100_FIRMWARE);
2105MODULE_FIRMWARE(P7500_FIRMWARE);