blob: 2889d32bec253165593c07ae61e67a7d66f95804 [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,
3 * TeVii S600, S630, S650, S660, S480,
4 * Prof 1100, 7500,
Igor M. Liplianind2ffc442011-02-25 18:41:22 -03005 * Geniatech SU3000 Cards
Igor M. Liplianin2f30fb42011-02-25 18:41:23 -03006 * Copyright (C) 2008-2011 Igor M. Liplianin (liplianin@me.by)
7 *
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"
Igor M. Liplianin141cc352009-11-27 14:37:35 -030025#include "ds3000.h"
26#include "stv0900.h"
27#include "stv6110.h"
28#include "stb6100.h"
29#include "stb6100_proc.h"
Igor M Liplianin7fd48282008-07-20 08:05:50 -030030
31#ifndef USB_PID_DW2102
32#define USB_PID_DW2102 0x2102
33#endif
34
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -030035#ifndef USB_PID_DW2104
36#define USB_PID_DW2104 0x2104
37#endif
38
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -030039#ifndef USB_PID_DW3101
40#define USB_PID_DW3101 0x3101
41#endif
42
Igor M. Liplianin4cc0edf2008-11-05 22:12:56 -030043#ifndef USB_PID_CINERGY_S
44#define USB_PID_CINERGY_S 0x0064
45#endif
46
Igor M. Liplianin141cc352009-11-27 14:37:35 -030047#ifndef USB_PID_TEVII_S630
48#define USB_PID_TEVII_S630 0xd630
49#endif
50
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -030051#ifndef USB_PID_TEVII_S650
52#define USB_PID_TEVII_S650 0xd650
53#endif
54
Igor M. Liplianin141cc352009-11-27 14:37:35 -030055#ifndef USB_PID_TEVII_S660
56#define USB_PID_TEVII_S660 0xd660
57#endif
58
Igor M. Liplianine8f50552011-02-25 18:41:23 -030059#ifndef USB_PID_TEVII_S480_1
60#define USB_PID_TEVII_S480_1 0xd481
61#endif
62
63#ifndef USB_PID_TEVII_S480_2
64#define USB_PID_TEVII_S480_2 0xd482
65#endif
66
Igor M. Liplianin141cc352009-11-27 14:37:35 -030067#ifndef USB_PID_PROF_1100
68#define USB_PID_PROF_1100 0xb012
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -030069#endif
70
Igor M. Liplianin21b007b2008-09-17 19:19:19 -030071#define DW210X_READ_MSG 0
72#define DW210X_WRITE_MSG 1
Igor M Liplianin7fd48282008-07-20 08:05:50 -030073
74#define REG_1F_SYMBOLRATE_BYTE0 0x1f
75#define REG_20_SYMBOLRATE_BYTE1 0x20
76#define REG_21_SYMBOLRATE_BYTE2 0x21
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -030077/* on my own*/
Igor M Liplianin7fd48282008-07-20 08:05:50 -030078#define DW2102_VOLTAGE_CTRL (0x1800)
Igor M. Liplianind2ffc442011-02-25 18:41:22 -030079#define SU3000_STREAM_CTRL (0x1900)
Igor M Liplianin7fd48282008-07-20 08:05:50 -030080#define DW2102_RC_QUERY (0x1a00)
Igor M. Liplianinfa8bae12011-02-25 18:41:22 -030081#define DW2102_LED_CTRL (0x1b00)
Igor M Liplianin7fd48282008-07-20 08:05:50 -030082
Igor M. Liplianin141cc352009-11-27 14:37:35 -030083#define err_str "did not find the firmware file. (%s) " \
84 "Please see linux/Documentation/dvb/ for more details " \
85 "on firmware-problems."
86
Mauro Carvalho Chehab2f4f58d2010-11-17 15:46:09 -030087struct rc_map_dvb_usb_table_table {
88 struct rc_map_table *rc_keys;
Igor M. Liplianinb42e1d72009-06-14 19:41:22 -030089 int rc_keys_size;
Igor M Liplianin7fd48282008-07-20 08:05:50 -030090};
91
Igor M. Liplianind2ffc442011-02-25 18:41:22 -030092struct su3000_state {
93 u8 initialized;
94};
95
Igor M. Liplianin52c506e2011-02-25 18:41:23 -030096struct s6x0_state {
97 int (*old_set_voltage)(struct dvb_frontend *f, fe_sec_voltage_t v);
98};
99
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300100/* debug */
101static int dvb_usb_dw2102_debug;
102module_param_named(debug, dvb_usb_dw2102_debug, int, 0644);
Igor M. Liplianin8a8dad72009-06-13 08:10:24 -0300103MODULE_PARM_DESC(debug, "set debugging level (1=info 2=xfer 4=rc(or-able))."
104 DVB_USB_DEBUG_STATUS);
105
Igor M. Liplianinb42e1d72009-06-14 19:41:22 -0300106/* keymaps */
107static int ir_keymap;
108module_param_named(keymap, ir_keymap, int, 0644);
Igor M. Liplianinfeb16e92011-02-25 18:41:22 -0300109MODULE_PARM_DESC(keymap, "set keymap 0=default 1=dvbworld 2=tevii 3=tbs ..."
110 " 256=none");
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300111
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300112/* demod probe */
113static int demod_probe = 1;
114module_param_named(demod, demod_probe, int, 0644);
115MODULE_PARM_DESC(demod, "demod to probe (1=cx24116 2=stv0903+stv6110 "
116 "4=stv0903+stb6100(or-able)).");
117
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300118DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
119
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300120static int dw210x_op_rw(struct usb_device *dev, u8 request, u16 value,
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300121 u16 index, u8 * data, u16 len, int flags)
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300122{
123 int ret;
124 u8 u8buf[len];
125
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300126 unsigned int pipe = (flags == DW210X_READ_MSG) ?
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300127 usb_rcvctrlpipe(dev, 0) : usb_sndctrlpipe(dev, 0);
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300128 u8 request_type = (flags == DW210X_READ_MSG) ? USB_DIR_IN : USB_DIR_OUT;
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300129
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300130 if (flags == DW210X_WRITE_MSG)
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300131 memcpy(u8buf, data, len);
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300132 ret = usb_control_msg(dev, pipe, request, request_type | USB_TYPE_VENDOR,
133 value, index , u8buf, len, 2000);
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300134
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300135 if (flags == DW210X_READ_MSG)
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300136 memcpy(data, u8buf, len);
137 return ret;
138}
139
140/* I2C */
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300141static int dw2102_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],
142 int num)
143{
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -0300144 struct dvb_usb_device *d = i2c_get_adapdata(adap);
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300145 int i = 0, ret = 0;
146 u8 buf6[] = {0x2c, 0x05, 0xc0, 0, 0, 0, 0};
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300147 u16 value;
148
149 if (!d)
150 return -ENODEV;
151 if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
152 return -EAGAIN;
153
154 switch (num) {
155 case 2:
156 /* read stv0299 register */
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300157 value = msg[0].buf[0];/* register */
158 for (i = 0; i < msg[1].len; i++) {
Igor M. Liplianinb16af292011-02-27 16:22:57 -0300159 ret = dw210x_op_rw(d->udev, 0xb5, value + i, 0,
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300160 buf6, 2, DW210X_READ_MSG);
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300161 msg[1].buf[i] = buf6[0];
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300162 }
163 break;
164 case 1:
165 switch (msg[0].addr) {
166 case 0x68:
167 /* write to stv0299 register */
168 buf6[0] = 0x2a;
169 buf6[1] = msg[0].buf[0];
170 buf6[2] = msg[0].buf[1];
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300171 ret = dw210x_op_rw(d->udev, 0xb2, 0, 0,
172 buf6, 3, DW210X_WRITE_MSG);
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300173 break;
174 case 0x60:
175 if (msg[0].flags == 0) {
176 /* write to tuner pll */
177 buf6[0] = 0x2c;
178 buf6[1] = 5;
179 buf6[2] = 0xc0;
180 buf6[3] = msg[0].buf[0];
181 buf6[4] = msg[0].buf[1];
182 buf6[5] = msg[0].buf[2];
183 buf6[6] = msg[0].buf[3];
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300184 ret = dw210x_op_rw(d->udev, 0xb2, 0, 0,
185 buf6, 7, DW210X_WRITE_MSG);
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300186 } else {
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300187 /* read from tuner */
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300188 ret = dw210x_op_rw(d->udev, 0xb5, 0, 0,
189 buf6, 1, DW210X_READ_MSG);
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300190 msg[0].buf[0] = buf6[0];
191 }
192 break;
193 case (DW2102_RC_QUERY):
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300194 ret = dw210x_op_rw(d->udev, 0xb8, 0, 0,
195 buf6, 2, DW210X_READ_MSG);
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300196 msg[0].buf[0] = buf6[0];
197 msg[0].buf[1] = buf6[1];
198 break;
199 case (DW2102_VOLTAGE_CTRL):
200 buf6[0] = 0x30;
201 buf6[1] = msg[0].buf[0];
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300202 ret = dw210x_op_rw(d->udev, 0xb2, 0, 0,
203 buf6, 2, DW210X_WRITE_MSG);
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300204 break;
205 }
206
207 break;
208 }
209
210 mutex_unlock(&d->i2c_mutex);
211 return num;
212}
213
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300214static int dw2102_serit_i2c_transfer(struct i2c_adapter *adap,
215 struct i2c_msg msg[], int num)
216{
217 struct dvb_usb_device *d = i2c_get_adapdata(adap);
218 int ret = 0;
219 u8 buf6[] = {0, 0, 0, 0, 0, 0, 0};
220
221 if (!d)
222 return -ENODEV;
223 if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
224 return -EAGAIN;
225
226 switch (num) {
227 case 2:
228 /* read si2109 register by number */
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300229 buf6[0] = msg[0].addr << 1;
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300230 buf6[1] = msg[0].len;
231 buf6[2] = msg[0].buf[0];
232 ret = dw210x_op_rw(d->udev, 0xc2, 0, 0,
233 buf6, msg[0].len + 2, DW210X_WRITE_MSG);
234 /* read si2109 register */
235 ret = dw210x_op_rw(d->udev, 0xc3, 0xd0, 0,
236 buf6, msg[1].len + 2, DW210X_READ_MSG);
237 memcpy(msg[1].buf, buf6 + 2, msg[1].len);
238
239 break;
240 case 1:
241 switch (msg[0].addr) {
242 case 0x68:
243 /* write to si2109 register */
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300244 buf6[0] = msg[0].addr << 1;
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300245 buf6[1] = msg[0].len;
246 memcpy(buf6 + 2, msg[0].buf, msg[0].len);
247 ret = dw210x_op_rw(d->udev, 0xc2, 0, 0, buf6,
248 msg[0].len + 2, DW210X_WRITE_MSG);
249 break;
250 case(DW2102_RC_QUERY):
251 ret = dw210x_op_rw(d->udev, 0xb8, 0, 0,
252 buf6, 2, DW210X_READ_MSG);
253 msg[0].buf[0] = buf6[0];
254 msg[0].buf[1] = buf6[1];
255 break;
256 case(DW2102_VOLTAGE_CTRL):
257 buf6[0] = 0x30;
258 buf6[1] = msg[0].buf[0];
259 ret = dw210x_op_rw(d->udev, 0xb2, 0, 0,
260 buf6, 2, DW210X_WRITE_MSG);
261 break;
262 }
263 break;
264 }
265
266 mutex_unlock(&d->i2c_mutex);
267 return num;
268}
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -0300269
Igor M. Liplianin8a4949b2008-10-05 09:11:21 -0300270static int dw2102_earda_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], int num)
271{
272 struct dvb_usb_device *d = i2c_get_adapdata(adap);
273 int ret = 0;
274
275 if (!d)
276 return -ENODEV;
277 if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
278 return -EAGAIN;
279
280 switch (num) {
281 case 2: {
282 /* read */
283 /* first write first register number */
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -0300284 u8 ibuf[msg[1].len + 2], obuf[3];
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300285 obuf[0] = msg[0].addr << 1;
Igor M. Liplianin8a4949b2008-10-05 09:11:21 -0300286 obuf[1] = msg[0].len;
287 obuf[2] = msg[0].buf[0];
288 ret = dw210x_op_rw(d->udev, 0xc2, 0, 0,
289 obuf, msg[0].len + 2, DW210X_WRITE_MSG);
290 /* second read registers */
291 ret = dw210x_op_rw(d->udev, 0xc3, 0xd1 , 0,
292 ibuf, msg[1].len + 2, DW210X_READ_MSG);
293 memcpy(msg[1].buf, ibuf + 2, msg[1].len);
294
295 break;
296 }
297 case 1:
298 switch (msg[0].addr) {
299 case 0x68: {
300 /* write to register */
301 u8 obuf[msg[0].len + 2];
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300302 obuf[0] = msg[0].addr << 1;
Igor M. Liplianin8a4949b2008-10-05 09:11:21 -0300303 obuf[1] = msg[0].len;
304 memcpy(obuf + 2, msg[0].buf, msg[0].len);
305 ret = dw210x_op_rw(d->udev, 0xc2, 0, 0,
306 obuf, msg[0].len + 2, DW210X_WRITE_MSG);
307 break;
308 }
309 case 0x61: {
310 /* write to tuner */
311 u8 obuf[msg[0].len + 2];
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 memcpy(obuf + 2, msg[0].buf, msg[0].len);
315 ret = dw210x_op_rw(d->udev, 0xc2, 0, 0,
316 obuf, msg[0].len + 2, DW210X_WRITE_MSG);
317 break;
318 }
319 case(DW2102_RC_QUERY): {
320 u8 ibuf[2];
321 ret = dw210x_op_rw(d->udev, 0xb8, 0, 0,
322 ibuf, 2, DW210X_READ_MSG);
323 memcpy(msg[0].buf, ibuf , 2);
324 break;
325 }
326 case(DW2102_VOLTAGE_CTRL): {
327 u8 obuf[2];
328 obuf[0] = 0x30;
329 obuf[1] = msg[0].buf[0];
330 ret = dw210x_op_rw(d->udev, 0xb2, 0, 0,
331 obuf, 2, DW210X_WRITE_MSG);
332 break;
333 }
334 }
335
336 break;
337 }
338
339 mutex_unlock(&d->i2c_mutex);
340 return num;
341}
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300342
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300343static int dw2104_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], int num)
344{
345 struct dvb_usb_device *d = i2c_get_adapdata(adap);
346 int ret = 0;
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300347 int len, i, j;
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300348
349 if (!d)
350 return -ENODEV;
351 if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
352 return -EAGAIN;
353
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300354 for (j = 0; j < num; j++) {
355 switch (msg[j].addr) {
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300356 case(DW2102_RC_QUERY): {
357 u8 ibuf[2];
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300358 ret = dw210x_op_rw(d->udev, 0xb8, 0, 0,
359 ibuf, 2, DW210X_READ_MSG);
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300360 memcpy(msg[j].buf, ibuf , 2);
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300361 break;
362 }
363 case(DW2102_VOLTAGE_CTRL): {
364 u8 obuf[2];
365 obuf[0] = 0x30;
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300366 obuf[1] = msg[j].buf[0];
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300367 ret = dw210x_op_rw(d->udev, 0xb2, 0, 0,
368 obuf, 2, DW210X_WRITE_MSG);
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300369 break;
370 }
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300371 /*case 0x55: cx24116
372 case 0x6a: stv0903
373 case 0x68: ds3000, stv0903
374 case 0x60: ts2020, stv6110, stb6100 */
375 default: {
376 if (msg[j].flags == I2C_M_RD) {
377 /* read registers */
378 u8 ibuf[msg[j].len + 2];
379 ret = dw210x_op_rw(d->udev, 0xc3,
380 (msg[j].addr << 1) + 1, 0,
381 ibuf, msg[j].len + 2,
382 DW210X_READ_MSG);
383 memcpy(msg[j].buf, ibuf + 2, msg[j].len);
384 mdelay(10);
385 } else if (((msg[j].buf[0] == 0xb0) &&
386 (msg[j].addr == 0x68)) ||
387 ((msg[j].buf[0] == 0xf7) &&
388 (msg[j].addr == 0x55))) {
389 /* write firmware */
390 u8 obuf[19];
391 obuf[0] = msg[j].addr << 1;
392 obuf[1] = (msg[j].len > 15 ? 17 : msg[j].len);
393 obuf[2] = msg[j].buf[0];
394 len = msg[j].len - 1;
395 i = 1;
396 do {
397 memcpy(obuf + 3, msg[j].buf + i,
398 (len > 16 ? 16 : len));
399 ret = dw210x_op_rw(d->udev, 0xc2, 0, 0,
400 obuf, (len > 16 ? 16 : len) + 3,
401 DW210X_WRITE_MSG);
402 i += 16;
403 len -= 16;
404 } while (len > 0);
405 } else {
406 /* write registers */
407 u8 obuf[msg[j].len + 2];
408 obuf[0] = msg[j].addr << 1;
409 obuf[1] = msg[j].len;
410 memcpy(obuf + 2, msg[j].buf, msg[j].len);
411 ret = dw210x_op_rw(d->udev, 0xc2, 0, 0,
412 obuf, msg[j].len + 2,
413 DW210X_WRITE_MSG);
414 }
415 break;
416 }
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300417 }
418
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300419 }
420
421 mutex_unlock(&d->i2c_mutex);
422 return num;
423}
424
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -0300425static int dw3101_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],
426 int num)
427{
428 struct dvb_usb_device *d = i2c_get_adapdata(adap);
429 int ret = 0, i;
430
431 if (!d)
432 return -ENODEV;
433 if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
434 return -EAGAIN;
435
436 switch (num) {
437 case 2: {
438 /* read */
439 /* first write first register number */
440 u8 ibuf[msg[1].len + 2], obuf[3];
441 obuf[0] = msg[0].addr << 1;
442 obuf[1] = msg[0].len;
443 obuf[2] = msg[0].buf[0];
444 ret = dw210x_op_rw(d->udev, 0xc2, 0, 0,
445 obuf, msg[0].len + 2, DW210X_WRITE_MSG);
446 /* second read registers */
447 ret = dw210x_op_rw(d->udev, 0xc3, 0x19 , 0,
448 ibuf, msg[1].len + 2, DW210X_READ_MSG);
449 memcpy(msg[1].buf, ibuf + 2, msg[1].len);
450
451 break;
452 }
453 case 1:
454 switch (msg[0].addr) {
455 case 0x60:
456 case 0x0c: {
457 /* write to register */
458 u8 obuf[msg[0].len + 2];
459 obuf[0] = msg[0].addr << 1;
460 obuf[1] = msg[0].len;
461 memcpy(obuf + 2, msg[0].buf, msg[0].len);
462 ret = dw210x_op_rw(d->udev, 0xc2, 0, 0,
463 obuf, msg[0].len + 2, DW210X_WRITE_MSG);
464 break;
465 }
466 case(DW2102_RC_QUERY): {
467 u8 ibuf[2];
468 ret = dw210x_op_rw(d->udev, 0xb8, 0, 0,
469 ibuf, 2, DW210X_READ_MSG);
470 memcpy(msg[0].buf, ibuf , 2);
471 break;
472 }
473 }
474
475 break;
476 }
477
478 for (i = 0; i < num; i++) {
479 deb_xfer("%02x:%02x: %s ", i, msg[i].addr,
480 msg[i].flags == 0 ? ">>>" : "<<<");
481 debug_dump(msg[i].buf, msg[i].len, deb_xfer);
482 }
483
484 mutex_unlock(&d->i2c_mutex);
485 return num;
486}
487
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300488static int s6x0_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300489 int num)
490{
491 struct dvb_usb_device *d = i2c_get_adapdata(adap);
Julia Lawall21ead032009-12-22 18:00:07 -0300492 struct usb_device *udev;
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300493 int ret = 0;
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300494 int len, i, j;
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300495
496 if (!d)
497 return -ENODEV;
Julia Lawall21ead032009-12-22 18:00:07 -0300498 udev = d->udev;
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300499 if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
500 return -EAGAIN;
501
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300502 for (j = 0; j < num; j++) {
503 switch (msg[j].addr) {
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300504 case (DW2102_RC_QUERY): {
Igor M. Liplianin5a530cb2011-02-25 18:41:23 -0300505 u8 ibuf[5];
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300506 ret = dw210x_op_rw(d->udev, 0xb8, 0, 0,
Igor M. Liplianin5a530cb2011-02-25 18:41:23 -0300507 ibuf, 5, DW210X_READ_MSG);
508 memcpy(msg[j].buf, ibuf + 3, 2);
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300509 break;
510 }
511 case (DW2102_VOLTAGE_CTRL): {
512 u8 obuf[2];
Igor M. Liplianincd79d332009-12-14 20:24:56 -0300513
514 obuf[0] = 1;
515 obuf[1] = msg[j].buf[1];/* off-on */
516 ret = dw210x_op_rw(d->udev, 0x8a, 0, 0,
517 obuf, 2, DW210X_WRITE_MSG);
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300518 obuf[0] = 3;
Igor M. Liplianincd79d332009-12-14 20:24:56 -0300519 obuf[1] = msg[j].buf[0];/* 13v-18v */
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300520 ret = dw210x_op_rw(d->udev, 0x8a, 0, 0,
521 obuf, 2, DW210X_WRITE_MSG);
522 break;
523 }
Igor M. Liplianinfa8bae12011-02-25 18:41:22 -0300524 case (DW2102_LED_CTRL): {
525 u8 obuf[2];
526
527 obuf[0] = 5;
528 obuf[1] = msg[j].buf[0];
529 ret = dw210x_op_rw(d->udev, 0x8a, 0, 0,
530 obuf, 2, DW210X_WRITE_MSG);
531 break;
532 }
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300533 /*case 0x55: cx24116
534 case 0x6a: stv0903
535 case 0x68: ds3000, stv0903
536 case 0x60: ts2020, stv6110, stb6100
537 case 0xa0: eeprom */
538 default: {
539 if (msg[j].flags == I2C_M_RD) {
540 /* read registers */
541 u8 ibuf[msg[j].len];
542 ret = dw210x_op_rw(d->udev, 0x91, 0, 0,
543 ibuf, msg[j].len,
544 DW210X_READ_MSG);
545 memcpy(msg[j].buf, ibuf, msg[j].len);
546 break;
547 } else if ((msg[j].buf[0] == 0xb0) &&
548 (msg[j].addr == 0x68)) {
549 /* write firmware */
550 u8 obuf[19];
551 obuf[0] = (msg[j].len > 16 ?
552 18 : msg[j].len + 1);
553 obuf[1] = msg[j].addr << 1;
554 obuf[2] = msg[j].buf[0];
555 len = msg[j].len - 1;
556 i = 1;
557 do {
558 memcpy(obuf + 3, msg[j].buf + i,
559 (len > 16 ? 16 : len));
560 ret = dw210x_op_rw(d->udev, 0x80, 0, 0,
561 obuf, (len > 16 ? 16 : len) + 3,
562 DW210X_WRITE_MSG);
563 i += 16;
564 len -= 16;
565 } while (len > 0);
Igor M. Liplianina84adf42011-02-27 16:18:38 -0300566 } else if (j < (num - 1)) {
Igor M. Liplianincd79d332009-12-14 20:24:56 -0300567 /* write register addr before read */
568 u8 obuf[msg[j].len + 2];
569 obuf[0] = msg[j + 1].len;
570 obuf[1] = (msg[j].addr << 1);
571 memcpy(obuf + 2, msg[j].buf, msg[j].len);
Igor M. Liplianina84adf42011-02-27 16:18:38 -0300572 ret = dw210x_op_rw(d->udev,
573 udev->descriptor.idProduct ==
574 0x7500 ? 0x92 : 0x90, 0, 0,
Igor M. Liplianincd79d332009-12-14 20:24:56 -0300575 obuf, msg[j].len + 2,
576 DW210X_WRITE_MSG);
577 break;
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300578 } else {
579 /* write registers */
580 u8 obuf[msg[j].len + 2];
581 obuf[0] = msg[j].len + 1;
582 obuf[1] = (msg[j].addr << 1);
583 memcpy(obuf + 2, msg[j].buf, msg[j].len);
Igor M. Liplianina84adf42011-02-27 16:18:38 -0300584 ret = dw210x_op_rw(d->udev, 0x80, 0, 0,
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300585 obuf, msg[j].len + 2,
586 DW210X_WRITE_MSG);
587 break;
588 }
589 break;
590 }
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300591 }
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300592 }
593
594 mutex_unlock(&d->i2c_mutex);
595 return num;
596}
597
Igor M. Liplianind2ffc442011-02-25 18:41:22 -0300598static int su3000_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],
599 int num)
600{
601 struct dvb_usb_device *d = i2c_get_adapdata(adap);
602 u8 obuf[0x40], ibuf[0x40];
603
604 if (!d)
605 return -ENODEV;
606 if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
607 return -EAGAIN;
608
609 switch (num) {
610 case 1:
611 switch (msg[0].addr) {
612 case SU3000_STREAM_CTRL:
613 obuf[0] = msg[0].buf[0] + 0x36;
614 obuf[1] = 3;
615 obuf[2] = 0;
616 if (dvb_usb_generic_rw(d, obuf, 3, ibuf, 0, 0) < 0)
617 err("i2c transfer failed.");
618 break;
619 case DW2102_RC_QUERY:
620 obuf[0] = 0x10;
621 if (dvb_usb_generic_rw(d, obuf, 1, ibuf, 2, 0) < 0)
622 err("i2c transfer failed.");
623 msg[0].buf[1] = ibuf[0];
624 msg[0].buf[0] = ibuf[1];
625 break;
626 default:
627 /* always i2c write*/
628 obuf[0] = 0x08;
629 obuf[1] = msg[0].addr;
630 obuf[2] = msg[0].len;
631
632 memcpy(&obuf[3], msg[0].buf, msg[0].len);
633
634 if (dvb_usb_generic_rw(d, obuf, msg[0].len + 3,
635 ibuf, 1, 0) < 0)
636 err("i2c transfer failed.");
637
638 }
639 break;
640 case 2:
641 /* always i2c read */
642 obuf[0] = 0x09;
643 obuf[1] = msg[0].len;
644 obuf[2] = msg[1].len;
645 obuf[3] = msg[0].addr;
646 memcpy(&obuf[4], msg[0].buf, msg[0].len);
647
648 if (dvb_usb_generic_rw(d, obuf, msg[0].len + 4,
649 ibuf, msg[1].len + 1, 0) < 0)
650 err("i2c transfer failed.");
651
652 memcpy(msg[1].buf, &ibuf[1], msg[1].len);
653 break;
654 default:
655 warn("more than 2 i2c messages at a time is not handled yet.");
656 break;
657 }
658 mutex_unlock(&d->i2c_mutex);
659 return num;
660}
661
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300662static u32 dw210x_i2c_func(struct i2c_adapter *adapter)
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300663{
664 return I2C_FUNC_I2C;
665}
666
667static struct i2c_algorithm dw2102_i2c_algo = {
668 .master_xfer = dw2102_i2c_transfer,
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300669 .functionality = dw210x_i2c_func,
670};
671
672static struct i2c_algorithm dw2102_serit_i2c_algo = {
673 .master_xfer = dw2102_serit_i2c_transfer,
674 .functionality = dw210x_i2c_func,
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300675};
676
Igor M. Liplianin8a4949b2008-10-05 09:11:21 -0300677static struct i2c_algorithm dw2102_earda_i2c_algo = {
678 .master_xfer = dw2102_earda_i2c_transfer,
679 .functionality = dw210x_i2c_func,
680};
681
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300682static struct i2c_algorithm dw2104_i2c_algo = {
683 .master_xfer = dw2104_i2c_transfer,
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300684 .functionality = dw210x_i2c_func,
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300685};
686
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -0300687static struct i2c_algorithm dw3101_i2c_algo = {
688 .master_xfer = dw3101_i2c_transfer,
689 .functionality = dw210x_i2c_func,
690};
691
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300692static struct i2c_algorithm s6x0_i2c_algo = {
693 .master_xfer = s6x0_i2c_transfer,
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300694 .functionality = dw210x_i2c_func,
695};
696
Igor M. Liplianind2ffc442011-02-25 18:41:22 -0300697static struct i2c_algorithm su3000_i2c_algo = {
698 .master_xfer = su3000_i2c_transfer,
699 .functionality = dw210x_i2c_func,
700};
701
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300702static int dw210x_read_mac_address(struct dvb_usb_device *d, u8 mac[6])
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300703{
704 int i;
705 u8 ibuf[] = {0, 0};
706 u8 eeprom[256], eepromline[16];
707
708 for (i = 0; i < 256; i++) {
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300709 if (dw210x_op_rw(d->udev, 0xb6, 0xa0 , i, ibuf, 2, DW210X_READ_MSG) < 0) {
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300710 err("read eeprom failed.");
711 return -1;
712 } else {
713 eepromline[i%16] = ibuf[0];
714 eeprom[i] = ibuf[0];
715 }
716 if ((i % 16) == 15) {
717 deb_xfer("%02x: ", i - 15);
718 debug_dump(eepromline, 16, deb_xfer);
719 }
720 }
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -0300721
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300722 memcpy(mac, eeprom + 8, 6);
723 return 0;
724};
725
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300726static int s6x0_read_mac_address(struct dvb_usb_device *d, u8 mac[6])
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300727{
728 int i, ret;
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300729 u8 ibuf[] = { 0 }, obuf[] = { 0 };
730 u8 eeprom[256], eepromline[16];
731 struct i2c_msg msg[] = {
732 {
733 .addr = 0xa0 >> 1,
734 .flags = 0,
735 .buf = obuf,
736 .len = 1,
737 }, {
738 .addr = 0xa0 >> 1,
739 .flags = I2C_M_RD,
740 .buf = ibuf,
741 .len = 1,
742 }
743 };
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300744
745 for (i = 0; i < 256; i++) {
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300746 obuf[0] = i;
747 ret = s6x0_i2c_transfer(&d->i2c_adap, msg, 2);
748 if (ret != 2) {
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300749 err("read eeprom failed.");
750 return -1;
751 } else {
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300752 eepromline[i % 16] = ibuf[0];
753 eeprom[i] = ibuf[0];
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300754 }
755
756 if ((i % 16) == 15) {
757 deb_xfer("%02x: ", i - 15);
758 debug_dump(eepromline, 16, deb_xfer);
759 }
760 }
761
762 memcpy(mac, eeprom + 16, 6);
763 return 0;
764};
765
Igor M. Liplianind2ffc442011-02-25 18:41:22 -0300766static int su3000_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff)
767{
768 static u8 command_start[] = {0x00};
769 static u8 command_stop[] = {0x01};
770 struct i2c_msg msg = {
771 .addr = SU3000_STREAM_CTRL,
772 .flags = 0,
773 .buf = onoff ? command_start : command_stop,
774 .len = 1
775 };
776
777 i2c_transfer(&adap->dev->i2c_adap, &msg, 1);
778
779 return 0;
780}
781
782static int su3000_power_ctrl(struct dvb_usb_device *d, int i)
783{
784 struct su3000_state *state = (struct su3000_state *)d->priv;
785 u8 obuf[] = {0xde, 0};
786
787 info("%s: %d, initialized %d\n", __func__, i, state->initialized);
788
789 if (i && !state->initialized) {
790 state->initialized = 1;
791 /* reset board */
792 dvb_usb_generic_rw(d, obuf, 2, NULL, 0, 0);
793 }
794
795 return 0;
796}
797
798static int su3000_read_mac_address(struct dvb_usb_device *d, u8 mac[6])
799{
800 int i;
801 u8 obuf[] = { 0x1f, 0xf0 };
802 u8 ibuf[] = { 0 };
803 struct i2c_msg msg[] = {
804 {
805 .addr = 0x51,
806 .flags = 0,
807 .buf = obuf,
808 .len = 2,
809 }, {
810 .addr = 0x51,
811 .flags = I2C_M_RD,
812 .buf = ibuf,
813 .len = 1,
814
815 }
816 };
817
818 for (i = 0; i < 6; i++) {
819 obuf[1] = 0xf0 + i;
820 if (i2c_transfer(&d->i2c_adap, msg, 2) != 2)
821 break;
822 else
823 mac[i] = ibuf[0];
824
825 debug_dump(mac, 6, printk);
826 }
827
828 return 0;
829}
830
831static int su3000_identify_state(struct usb_device *udev,
832 struct dvb_usb_device_properties *props,
833 struct dvb_usb_device_description **desc,
834 int *cold)
835{
836 info("%s\n", __func__);
837
838 *cold = 0;
839 return 0;
840}
841
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300842static int dw210x_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300843{
Igor M. Liplianincd79d332009-12-14 20:24:56 -0300844 static u8 command_13v[] = {0x00, 0x01};
845 static u8 command_18v[] = {0x01, 0x01};
846 static u8 command_off[] = {0x00, 0x00};
847 struct i2c_msg msg = {
848 .addr = DW2102_VOLTAGE_CTRL,
849 .flags = 0,
850 .buf = command_off,
851 .len = 2,
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300852 };
853
854 struct dvb_usb_adapter *udev_adap =
855 (struct dvb_usb_adapter *)(fe->dvb->priv);
856 if (voltage == SEC_VOLTAGE_18)
Igor M. Liplianincd79d332009-12-14 20:24:56 -0300857 msg.buf = command_18v;
858 else if (voltage == SEC_VOLTAGE_13)
859 msg.buf = command_13v;
860
861 i2c_transfer(&udev_adap->dev->i2c_adap, &msg, 1);
862
Igor M Liplianin7fd48282008-07-20 08:05:50 -0300863 return 0;
864}
865
Igor M. Liplianin52c506e2011-02-25 18:41:23 -0300866static int s660_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
867{
868 struct dvb_usb_adapter *d =
869 (struct dvb_usb_adapter *)(fe->dvb->priv);
870 struct s6x0_state *st = (struct s6x0_state *)d->dev->priv;
871
872 dw210x_set_voltage(fe, voltage);
873 if (st->old_set_voltage)
874 st->old_set_voltage(fe, voltage);
875
876 return 0;
877}
878
Igor M. Liplianinfa8bae12011-02-25 18:41:22 -0300879static void dw210x_led_ctrl(struct dvb_frontend *fe, int offon)
880{
881 static u8 led_off[] = { 0 };
882 static u8 led_on[] = { 1 };
883 struct i2c_msg msg = {
884 .addr = DW2102_LED_CTRL,
885 .flags = 0,
886 .buf = led_off,
887 .len = 1
888 };
889 struct dvb_usb_adapter *udev_adap =
890 (struct dvb_usb_adapter *)(fe->dvb->priv);
891
892 if (offon)
893 msg.buf = led_on;
894 i2c_transfer(&udev_adap->dev->i2c_adap, &msg, 1);
895}
896
Igor M. Liplianind4305c62008-10-17 13:45:55 -0300897static struct stv0299_config sharp_z0194a_config = {
898 .demod_address = 0x68,
899 .inittab = sharp_z0194a_inittab,
900 .mclk = 88000000UL,
901 .invert = 1,
902 .skip_reinit = 0,
903 .lock_output = STV0299_LOCKOUTPUT_1,
904 .volt13_op0_op1 = STV0299_VOLT13_OP1,
905 .min_delay_ms = 100,
906 .set_symbol_rate = sharp_z0194a_set_symbol_rate,
907};
908
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300909static struct cx24116_config dw2104_config = {
910 .demod_address = 0x55,
Igor M. Liplianincc8c4f32008-09-09 13:57:47 -0300911 .mpg_clk_pos_pol = 0x01,
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300912};
913
Igor M. Liplianin21b007b2008-09-17 19:19:19 -0300914static struct si21xx_config serit_sp1511lhb_config = {
915 .demod_address = 0x68,
916 .min_delay_ms = 100,
917
918};
919
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -0300920static struct tda10023_config dw3101_tda10023_config = {
921 .demod_address = 0x0c,
922 .invert = 1,
923};
924
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -0300925static struct mt312_config zl313_config = {
926 .demod_address = 0x0e,
927};
928
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300929static struct ds3000_config dw2104_ds3000_config = {
930 .demod_address = 0x68,
931};
932
933static struct stv0900_config dw2104a_stv0900_config = {
934 .demod_address = 0x6a,
935 .demod_mode = 0,
936 .xtal = 27000000,
937 .clkmode = 3,/* 0-CLKI, 2-XTALI, else AUTO */
938 .diseqc_mode = 2,/* 2/3 PWM */
939 .tun1_maddress = 0,/* 0x60 */
940 .tun1_adc = 0,/* 2 Vpp */
941 .path1_mode = 3,
942};
943
944static struct stb6100_config dw2104a_stb6100_config = {
945 .tuner_address = 0x60,
946 .refclock = 27000000,
947};
948
949static struct stv0900_config dw2104_stv0900_config = {
950 .demod_address = 0x68,
951 .demod_mode = 0,
952 .xtal = 8000000,
953 .clkmode = 3,
954 .diseqc_mode = 2,
955 .tun1_maddress = 0,
956 .tun1_adc = 1,/* 1 Vpp */
957 .path1_mode = 3,
958};
959
960static struct stv6110_config dw2104_stv6110_config = {
961 .i2c_address = 0x60,
962 .mclk = 16000000,
963 .clk_div = 1,
964};
965
Igor M. Liplianincd79d332009-12-14 20:24:56 -0300966static struct stv0900_config prof_7500_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 .tun1_type = 3,
Igor M. Liplianinfa8bae12011-02-25 18:41:22 -0300976 .set_lock_led = dw210x_led_ctrl,
Igor M. Liplianincd79d332009-12-14 20:24:56 -0300977};
978
Igor M. Liplianind2ffc442011-02-25 18:41:22 -0300979static struct ds3000_config su3000_ds3000_config = {
980 .demod_address = 0x68,
981 .ci_mode = 1,
982};
983
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -0300984static int dw2104_frontend_attach(struct dvb_usb_adapter *d)
985{
Igor M. Liplianin141cc352009-11-27 14:37:35 -0300986 struct dvb_tuner_ops *tuner_ops = NULL;
987
988 if (demod_probe & 4) {
989 d->fe = dvb_attach(stv0900_attach, &dw2104a_stv0900_config,
990 &d->dev->i2c_adap, 0);
991 if (d->fe != NULL) {
992 if (dvb_attach(stb6100_attach, d->fe,
993 &dw2104a_stb6100_config,
994 &d->dev->i2c_adap)) {
995 tuner_ops = &d->fe->ops.tuner_ops;
996 tuner_ops->set_frequency = stb6100_set_freq;
997 tuner_ops->get_frequency = stb6100_get_freq;
998 tuner_ops->set_bandwidth = stb6100_set_bandw;
999 tuner_ops->get_bandwidth = stb6100_get_bandw;
1000 d->fe->ops.set_voltage = dw210x_set_voltage;
1001 info("Attached STV0900+STB6100!\n");
1002 return 0;
1003 }
1004 }
1005 }
1006
1007 if (demod_probe & 2) {
1008 d->fe = dvb_attach(stv0900_attach, &dw2104_stv0900_config,
1009 &d->dev->i2c_adap, 0);
1010 if (d->fe != NULL) {
1011 if (dvb_attach(stv6110_attach, d->fe,
1012 &dw2104_stv6110_config,
1013 &d->dev->i2c_adap)) {
1014 d->fe->ops.set_voltage = dw210x_set_voltage;
1015 info("Attached STV0900+STV6110A!\n");
1016 return 0;
1017 }
1018 }
1019 }
1020
1021 if (demod_probe & 1) {
1022 d->fe = dvb_attach(cx24116_attach, &dw2104_config,
1023 &d->dev->i2c_adap);
1024 if (d->fe != NULL) {
1025 d->fe->ops.set_voltage = dw210x_set_voltage;
1026 info("Attached cx24116!\n");
1027 return 0;
1028 }
1029 }
1030
1031 d->fe = dvb_attach(ds3000_attach, &dw2104_ds3000_config,
1032 &d->dev->i2c_adap);
1033 if (d->fe != NULL) {
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001034 d->fe->ops.set_voltage = dw210x_set_voltage;
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001035 info("Attached DS3000!\n");
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001036 return 0;
1037 }
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001038
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001039 return -EIO;
1040}
1041
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001042static struct dvb_usb_device_properties dw2102_properties;
Igor M. Liplianinb42e1d72009-06-14 19:41:22 -03001043static struct dvb_usb_device_properties dw2104_properties;
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001044static struct dvb_usb_device_properties s6x0_properties;
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001045
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001046static int dw2102_frontend_attach(struct dvb_usb_adapter *d)
1047{
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001048 if (dw2102_properties.i2c_algo == &dw2102_serit_i2c_algo) {
1049 /*dw2102_properties.adapter->tuner_attach = NULL;*/
1050 d->fe = dvb_attach(si21xx_attach, &serit_sp1511lhb_config,
1051 &d->dev->i2c_adap);
1052 if (d->fe != NULL) {
1053 d->fe->ops.set_voltage = dw210x_set_voltage;
1054 info("Attached si21xx!\n");
1055 return 0;
1056 }
1057 }
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001058
Igor M. Liplianin8a4949b2008-10-05 09:11:21 -03001059 if (dw2102_properties.i2c_algo == &dw2102_earda_i2c_algo) {
Igor M. Liplianin8a4949b2008-10-05 09:11:21 -03001060 d->fe = dvb_attach(stv0288_attach, &earda_config,
1061 &d->dev->i2c_adap);
1062 if (d->fe != NULL) {
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001063 if (dvb_attach(stb6000_attach, d->fe, 0x61,
1064 &d->dev->i2c_adap)) {
1065 d->fe->ops.set_voltage = dw210x_set_voltage;
1066 info("Attached stv0288!\n");
1067 return 0;
1068 }
Igor M. Liplianin8a4949b2008-10-05 09:11:21 -03001069 }
1070 }
1071
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001072 if (dw2102_properties.i2c_algo == &dw2102_i2c_algo) {
1073 /*dw2102_properties.adapter->tuner_attach = dw2102_tuner_attach;*/
1074 d->fe = dvb_attach(stv0299_attach, &sharp_z0194a_config,
1075 &d->dev->i2c_adap);
1076 if (d->fe != NULL) {
1077 d->fe->ops.set_voltage = dw210x_set_voltage;
1078 info("Attached stv0299!\n");
1079 return 0;
1080 }
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001081 }
1082 return -EIO;
1083}
1084
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001085static int dw3101_frontend_attach(struct dvb_usb_adapter *d)
1086{
1087 d->fe = dvb_attach(tda10023_attach, &dw3101_tda10023_config,
1088 &d->dev->i2c_adap, 0x48);
1089 if (d->fe != NULL) {
1090 info("Attached tda10023!\n");
1091 return 0;
1092 }
1093 return -EIO;
1094}
1095
Igor M. Liplianin195288d2011-02-25 18:41:22 -03001096static int zl100313_frontend_attach(struct dvb_usb_adapter *d)
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -03001097{
1098 d->fe = dvb_attach(mt312_attach, &zl313_config,
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001099 &d->dev->i2c_adap);
1100 if (d->fe != NULL) {
1101 if (dvb_attach(zl10039_attach, d->fe, 0x60,
1102 &d->dev->i2c_adap)) {
1103 d->fe->ops.set_voltage = dw210x_set_voltage;
1104 info("Attached zl100313+zl10039!\n");
1105 return 0;
1106 }
1107 }
1108
Igor M. Liplianin195288d2011-02-25 18:41:22 -03001109 return -EIO;
1110}
1111
1112static int stv0288_frontend_attach(struct dvb_usb_adapter *d)
1113{
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001114 d->fe = dvb_attach(stv0288_attach, &earda_config,
1115 &d->dev->i2c_adap);
1116 if (d->fe != NULL) {
1117 if (dvb_attach(stb6000_attach, d->fe, 0x61,
1118 &d->dev->i2c_adap)) {
1119 d->fe->ops.set_voltage = dw210x_set_voltage;
1120 info("Attached stv0288+stb6000!\n");
1121 return 0;
1122 }
1123 }
1124
Igor M. Liplianin195288d2011-02-25 18:41:22 -03001125 return -EIO;
1126}
1127
1128static int ds3000_frontend_attach(struct dvb_usb_adapter *d)
1129{
Igor M. Liplianin52c506e2011-02-25 18:41:23 -03001130 struct s6x0_state *st = (struct s6x0_state *)d->dev->priv;
Igor M. Liplianin5a530cb2011-02-25 18:41:23 -03001131 u8 obuf[] = {7, 1};
Igor M. Liplianin52c506e2011-02-25 18:41:23 -03001132
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001133 d->fe = dvb_attach(ds3000_attach, &dw2104_ds3000_config,
1134 &d->dev->i2c_adap);
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001135
Igor M. Liplianin52c506e2011-02-25 18:41:23 -03001136 if (d->fe == NULL)
1137 return -EIO;
1138
1139 st->old_set_voltage = d->fe->ops.set_voltage;
1140 d->fe->ops.set_voltage = s660_set_voltage;
Igor M. Liplianin5a530cb2011-02-25 18:41:23 -03001141
1142 dw210x_op_rw(d->dev->udev, 0x8a, 0, 0, obuf, 2, DW210X_WRITE_MSG);
1143
Igor M. Liplianin52c506e2011-02-25 18:41:23 -03001144 info("Attached ds3000+ds2020!\n");
1145
1146 return 0;
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -03001147}
1148
Igor M. Liplianincd79d332009-12-14 20:24:56 -03001149static int prof_7500_frontend_attach(struct dvb_usb_adapter *d)
1150{
Igor M. Liplianin4e59df82011-02-25 18:41:23 -03001151 u8 obuf[] = {7, 1};
1152
Igor M. Liplianincd79d332009-12-14 20:24:56 -03001153 d->fe = dvb_attach(stv0900_attach, &prof_7500_stv0900_config,
1154 &d->dev->i2c_adap, 0);
1155 if (d->fe == NULL)
1156 return -EIO;
Igor M. Liplianin4e59df82011-02-25 18:41:23 -03001157
Igor M. Liplianincd79d332009-12-14 20:24:56 -03001158 d->fe->ops.set_voltage = dw210x_set_voltage;
1159
Igor M. Liplianin4e59df82011-02-25 18:41:23 -03001160 dw210x_op_rw(d->dev->udev, 0x8a, 0, 0, obuf, 2, DW210X_WRITE_MSG);
1161
Igor M. Liplianincd79d332009-12-14 20:24:56 -03001162 info("Attached STV0900+STB6100A!\n");
1163
1164 return 0;
1165}
1166
Igor M. Liplianind2ffc442011-02-25 18:41:22 -03001167static int su3000_frontend_attach(struct dvb_usb_adapter *d)
1168{
1169 u8 obuf[3] = { 0xe, 0x80, 0 };
1170 u8 ibuf[] = { 0 };
1171
1172 if (dvb_usb_generic_rw(d->dev, obuf, 3, ibuf, 1, 0) < 0)
1173 err("command 0x0e transfer failed.");
1174
1175 obuf[0] = 0xe;
1176 obuf[1] = 0x83;
1177 obuf[2] = 0;
1178
1179 if (dvb_usb_generic_rw(d->dev, obuf, 3, ibuf, 1, 0) < 0)
1180 err("command 0x0e transfer failed.");
1181
1182 obuf[0] = 0xe;
1183 obuf[1] = 0x83;
1184 obuf[2] = 1;
1185
1186 if (dvb_usb_generic_rw(d->dev, obuf, 3, ibuf, 1, 0) < 0)
1187 err("command 0x0e transfer failed.");
1188
1189 obuf[0] = 0x51;
1190
1191 if (dvb_usb_generic_rw(d->dev, obuf, 1, ibuf, 1, 0) < 0)
1192 err("command 0x51 transfer failed.");
1193
1194 d->fe = dvb_attach(ds3000_attach, &su3000_ds3000_config,
1195 &d->dev->i2c_adap);
1196 if (d->fe == NULL)
1197 return -EIO;
1198
1199 info("Attached DS3000!\n");
1200
1201 return 0;
1202}
1203
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001204static int dw2102_tuner_attach(struct dvb_usb_adapter *adap)
1205{
1206 dvb_attach(dvb_pll_attach, adap->fe, 0x60,
1207 &adap->dev->i2c_adap, DVB_PLL_OPERA1);
1208 return 0;
1209}
1210
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001211static int dw3101_tuner_attach(struct dvb_usb_adapter *adap)
1212{
1213 dvb_attach(dvb_pll_attach, adap->fe, 0x60,
1214 &adap->dev->i2c_adap, DVB_PLL_TUA6034);
1215
1216 return 0;
1217}
1218
Mauro Carvalho Chehab2f4f58d2010-11-17 15:46:09 -03001219static struct rc_map_table rc_map_dw210x_table[] = {
Mauro Carvalho Chehab2e365882009-08-29 15:19:31 -03001220 { 0xf80a, KEY_Q }, /*power*/
1221 { 0xf80c, KEY_M }, /*mute*/
1222 { 0xf811, KEY_1 },
1223 { 0xf812, KEY_2 },
1224 { 0xf813, KEY_3 },
1225 { 0xf814, KEY_4 },
1226 { 0xf815, KEY_5 },
1227 { 0xf816, KEY_6 },
1228 { 0xf817, KEY_7 },
1229 { 0xf818, KEY_8 },
1230 { 0xf819, KEY_9 },
1231 { 0xf810, KEY_0 },
1232 { 0xf81c, KEY_PAGEUP }, /*ch+*/
1233 { 0xf80f, KEY_PAGEDOWN }, /*ch-*/
1234 { 0xf81a, KEY_O }, /*vol+*/
1235 { 0xf80e, KEY_Z }, /*vol-*/
1236 { 0xf804, KEY_R }, /*rec*/
1237 { 0xf809, KEY_D }, /*fav*/
1238 { 0xf808, KEY_BACKSPACE }, /*rewind*/
1239 { 0xf807, KEY_A }, /*fast*/
1240 { 0xf80b, KEY_P }, /*pause*/
1241 { 0xf802, KEY_ESC }, /*cancel*/
1242 { 0xf803, KEY_G }, /*tab*/
1243 { 0xf800, KEY_UP }, /*up*/
1244 { 0xf81f, KEY_ENTER }, /*ok*/
1245 { 0xf801, KEY_DOWN }, /*down*/
1246 { 0xf805, KEY_C }, /*cap*/
1247 { 0xf806, KEY_S }, /*stop*/
1248 { 0xf840, KEY_F }, /*full*/
1249 { 0xf81e, KEY_W }, /*tvmode*/
1250 { 0xf81b, KEY_B }, /*recall*/
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001251};
1252
Mauro Carvalho Chehab2f4f58d2010-11-17 15:46:09 -03001253static struct rc_map_table rc_map_tevii_table[] = {
Mauro Carvalho Chehab2e365882009-08-29 15:19:31 -03001254 { 0xf80a, KEY_POWER },
1255 { 0xf80c, KEY_MUTE },
1256 { 0xf811, KEY_1 },
1257 { 0xf812, KEY_2 },
1258 { 0xf813, KEY_3 },
1259 { 0xf814, KEY_4 },
1260 { 0xf815, KEY_5 },
1261 { 0xf816, KEY_6 },
1262 { 0xf817, KEY_7 },
1263 { 0xf818, KEY_8 },
1264 { 0xf819, KEY_9 },
1265 { 0xf810, KEY_0 },
1266 { 0xf81c, KEY_MENU },
1267 { 0xf80f, KEY_VOLUMEDOWN },
1268 { 0xf81a, KEY_LAST },
1269 { 0xf80e, KEY_OPEN },
1270 { 0xf804, KEY_RECORD },
1271 { 0xf809, KEY_VOLUMEUP },
1272 { 0xf808, KEY_CHANNELUP },
1273 { 0xf807, KEY_PVR },
1274 { 0xf80b, KEY_TIME },
1275 { 0xf802, KEY_RIGHT },
1276 { 0xf803, KEY_LEFT },
1277 { 0xf800, KEY_UP },
1278 { 0xf81f, KEY_OK },
1279 { 0xf801, KEY_DOWN },
1280 { 0xf805, KEY_TUNER },
1281 { 0xf806, KEY_CHANNELDOWN },
1282 { 0xf840, KEY_PLAYPAUSE },
1283 { 0xf81e, KEY_REWIND },
1284 { 0xf81b, KEY_FAVORITES },
1285 { 0xf81d, KEY_BACK },
1286 { 0xf84d, KEY_FASTFORWARD },
1287 { 0xf844, KEY_EPG },
1288 { 0xf84c, KEY_INFO },
1289 { 0xf841, KEY_AB },
1290 { 0xf843, KEY_AUDIO },
1291 { 0xf845, KEY_SUBTITLE },
1292 { 0xf84a, KEY_LIST },
1293 { 0xf846, KEY_F1 },
1294 { 0xf847, KEY_F2 },
1295 { 0xf85e, KEY_F3 },
1296 { 0xf85c, KEY_F4 },
1297 { 0xf852, KEY_F5 },
1298 { 0xf85a, KEY_F6 },
1299 { 0xf856, KEY_MODE },
1300 { 0xf858, KEY_SWITCHVIDEOMODE },
Igor M. Liplianinb42e1d72009-06-14 19:41:22 -03001301};
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001302
Mauro Carvalho Chehab2f4f58d2010-11-17 15:46:09 -03001303static struct rc_map_table rc_map_tbs_table[] = {
Mauro Carvalho Chehab2e365882009-08-29 15:19:31 -03001304 { 0xf884, KEY_POWER },
1305 { 0xf894, KEY_MUTE },
1306 { 0xf887, KEY_1 },
1307 { 0xf886, KEY_2 },
1308 { 0xf885, KEY_3 },
1309 { 0xf88b, KEY_4 },
1310 { 0xf88a, KEY_5 },
1311 { 0xf889, KEY_6 },
1312 { 0xf88f, KEY_7 },
1313 { 0xf88e, KEY_8 },
1314 { 0xf88d, KEY_9 },
1315 { 0xf892, KEY_0 },
1316 { 0xf896, KEY_CHANNELUP },
1317 { 0xf891, KEY_CHANNELDOWN },
1318 { 0xf893, KEY_VOLUMEUP },
1319 { 0xf88c, KEY_VOLUMEDOWN },
1320 { 0xf883, KEY_RECORD },
1321 { 0xf898, KEY_PAUSE },
1322 { 0xf899, KEY_OK },
1323 { 0xf89a, KEY_SHUFFLE },
1324 { 0xf881, KEY_UP },
1325 { 0xf890, KEY_LEFT },
1326 { 0xf882, KEY_RIGHT },
1327 { 0xf888, KEY_DOWN },
1328 { 0xf895, KEY_FAVORITES },
1329 { 0xf897, KEY_SUBTITLE },
1330 { 0xf89d, KEY_ZOOM },
1331 { 0xf89f, KEY_EXIT },
1332 { 0xf89e, KEY_MENU },
1333 { 0xf89c, KEY_EPG },
1334 { 0xf880, KEY_PREVIOUS },
1335 { 0xf89b, KEY_MODE }
Igor M. Liplianinb42e1d72009-06-14 19:41:22 -03001336};
1337
Igor M. Liplianind2ffc442011-02-25 18:41:22 -03001338static struct rc_map_table rc_map_su3000_table[] = {
1339 { 0x25, KEY_POWER }, /* right-bottom Red */
1340 { 0x0a, KEY_MUTE }, /* -/-- */
1341 { 0x01, KEY_1 },
1342 { 0x02, KEY_2 },
1343 { 0x03, KEY_3 },
1344 { 0x04, KEY_4 },
1345 { 0x05, KEY_5 },
1346 { 0x06, KEY_6 },
1347 { 0x07, KEY_7 },
1348 { 0x08, KEY_8 },
1349 { 0x09, KEY_9 },
1350 { 0x00, KEY_0 },
1351 { 0x20, KEY_UP }, /* CH+ */
1352 { 0x21, KEY_DOWN }, /* CH+ */
1353 { 0x12, KEY_VOLUMEUP }, /* Brightness Up */
1354 { 0x13, KEY_VOLUMEDOWN },/* Brightness Down */
1355 { 0x1f, KEY_RECORD },
1356 { 0x17, KEY_PLAY },
1357 { 0x16, KEY_PAUSE },
1358 { 0x0b, KEY_STOP },
1359 { 0x27, KEY_FASTFORWARD },/* >> */
1360 { 0x26, KEY_REWIND }, /* << */
1361 { 0x0d, KEY_OK }, /* Mute */
1362 { 0x11, KEY_LEFT }, /* VOL- */
1363 { 0x10, KEY_RIGHT }, /* VOL+ */
1364 { 0x29, KEY_BACK }, /* button under 9 */
1365 { 0x2c, KEY_MENU }, /* TTX */
1366 { 0x2b, KEY_EPG }, /* EPG */
1367 { 0x1e, KEY_RED }, /* OSD */
1368 { 0x0e, KEY_GREEN }, /* Window */
1369 { 0x2d, KEY_YELLOW }, /* button under << */
1370 { 0x0f, KEY_BLUE }, /* bottom yellow button */
1371 { 0x14, KEY_AUDIO }, /* Snapshot */
1372 { 0x38, KEY_TV }, /* TV/Radio */
1373 { 0x0c, KEY_ESC } /* upper Red buttton */
1374};
1375
Mauro Carvalho Chehab2f4f58d2010-11-17 15:46:09 -03001376static struct rc_map_dvb_usb_table_table keys_tables[] = {
1377 { rc_map_dw210x_table, ARRAY_SIZE(rc_map_dw210x_table) },
1378 { rc_map_tevii_table, ARRAY_SIZE(rc_map_tevii_table) },
1379 { rc_map_tbs_table, ARRAY_SIZE(rc_map_tbs_table) },
Igor M. Liplianind2ffc442011-02-25 18:41:22 -03001380 { rc_map_su3000_table, ARRAY_SIZE(rc_map_su3000_table) },
Igor M. Liplianinb42e1d72009-06-14 19:41:22 -03001381};
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001382
1383static int dw2102_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
1384{
Mauro Carvalho Chehab2f4f58d2010-11-17 15:46:09 -03001385 struct rc_map_table *keymap = d->props.rc.legacy.rc_map_table;
1386 int keymap_size = d->props.rc.legacy.rc_map_size;
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001387 u8 key[2];
Igor M. Liplianin8a8dad72009-06-13 08:10:24 -03001388 struct i2c_msg msg = {
1389 .addr = DW2102_RC_QUERY,
1390 .flags = I2C_M_RD,
1391 .buf = key,
1392 .len = 2
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001393 };
1394 int i;
Igor M. Liplianinb42e1d72009-06-14 19:41:22 -03001395 /* override keymap */
1396 if ((ir_keymap > 0) && (ir_keymap <= ARRAY_SIZE(keys_tables))) {
1397 keymap = keys_tables[ir_keymap - 1].rc_keys ;
1398 keymap_size = keys_tables[ir_keymap - 1].rc_keys_size;
Igor M. Liplianinfeb16e92011-02-25 18:41:22 -03001399 } else if (ir_keymap > ARRAY_SIZE(keys_tables))
1400 return 0; /* none */
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001401
1402 *state = REMOTE_NO_KEY_PRESSED;
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -03001403 if (d->props.i2c_algo->master_xfer(&d->i2c_adap, &msg, 1) == 1) {
Igor M. Liplianinb42e1d72009-06-14 19:41:22 -03001404 for (i = 0; i < keymap_size ; i++) {
Mauro Carvalho Chehab2e365882009-08-29 15:19:31 -03001405 if (rc5_data(&keymap[i]) == msg.buf[0]) {
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001406 *state = REMOTE_KEY_PRESSED;
Mauro Carvalho Chehab34abf212010-07-31 11:24:57 -03001407 *event = keymap[i].keycode;
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001408 break;
1409 }
Igor M. Liplianin8a8dad72009-06-13 08:10:24 -03001410
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001411 }
Igor M. Liplianin8a8dad72009-06-13 08:10:24 -03001412
1413 if ((*state) == REMOTE_KEY_PRESSED)
1414 deb_rc("%s: found rc key: %x, %x, event: %x\n",
1415 __func__, key[0], key[1], (*event));
1416 else if (key[0] != 0xff)
1417 deb_rc("%s: unknown rc key: %x, %x\n",
1418 __func__, key[0], key[1]);
1419
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001420 }
Igor M. Liplianin8a8dad72009-06-13 08:10:24 -03001421
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001422 return 0;
1423}
1424
1425static struct usb_device_id dw2102_table[] = {
1426 {USB_DEVICE(USB_VID_CYPRESS, USB_PID_DW2102)},
1427 {USB_DEVICE(USB_VID_CYPRESS, 0x2101)},
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001428 {USB_DEVICE(USB_VID_CYPRESS, USB_PID_DW2104)},
1429 {USB_DEVICE(0x9022, USB_PID_TEVII_S650)},
Igor M. Liplianin4cc0edf2008-11-05 22:12:56 -03001430 {USB_DEVICE(USB_VID_TERRATEC, USB_PID_CINERGY_S)},
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001431 {USB_DEVICE(USB_VID_CYPRESS, USB_PID_DW3101)},
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -03001432 {USB_DEVICE(0x9022, USB_PID_TEVII_S630)},
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001433 {USB_DEVICE(0x3011, USB_PID_PROF_1100)},
1434 {USB_DEVICE(0x9022, USB_PID_TEVII_S660)},
Igor M. Liplianincd79d332009-12-14 20:24:56 -03001435 {USB_DEVICE(0x3034, 0x7500)},
Igor M. Liplianind2ffc442011-02-25 18:41:22 -03001436 {USB_DEVICE(0x1f4d, 0x3000)},
Igor M. Liplianin2adc5912011-02-25 18:41:22 -03001437 {USB_DEVICE(USB_VID_TERRATEC, 0x00a8)},
Igor M. Liplianine8f50552011-02-25 18:41:23 -03001438 {USB_DEVICE(0x9022, USB_PID_TEVII_S480_1)},
1439 {USB_DEVICE(0x9022, USB_PID_TEVII_S480_2)},
Igor M. Liplianin5265ea52011-02-27 16:17:25 -03001440 {USB_DEVICE(0x1f4d, 0x3100)},
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001441 { }
1442};
1443
1444MODULE_DEVICE_TABLE(usb, dw2102_table);
1445
1446static int dw2102_load_firmware(struct usb_device *dev,
1447 const struct firmware *frmwr)
1448{
1449 u8 *b, *p;
1450 int ret = 0, i;
1451 u8 reset;
Igor M. Liplianin8a4949b2008-10-05 09:11:21 -03001452 u8 reset16[] = {0, 0, 0, 0, 0, 0, 0};
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001453 const struct firmware *fw;
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001454 const char *fw_2101 = "dvb-usb-dw2101.fw";
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -03001455
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001456 switch (dev->descriptor.idProduct) {
1457 case 0x2101:
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001458 ret = request_firmware(&fw, fw_2101, &dev->dev);
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001459 if (ret != 0) {
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001460 err(err_str, fw_2101);
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001461 return ret;
1462 }
1463 break;
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001464 default:
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001465 fw = frmwr;
1466 break;
1467 }
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001468 info("start downloading DW210X firmware");
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001469 p = kmalloc(fw->size, GFP_KERNEL);
1470 reset = 1;
1471 /*stop the CPU*/
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001472 dw210x_op_rw(dev, 0xa0, 0x7f92, 0, &reset, 1, DW210X_WRITE_MSG);
1473 dw210x_op_rw(dev, 0xa0, 0xe600, 0, &reset, 1, DW210X_WRITE_MSG);
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001474
1475 if (p != NULL) {
1476 memcpy(p, fw->data, fw->size);
1477 for (i = 0; i < fw->size; i += 0x40) {
1478 b = (u8 *) p + i;
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001479 if (dw210x_op_rw(dev, 0xa0, i, 0, b , 0x40,
1480 DW210X_WRITE_MSG) != 0x40) {
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001481 err("error while transferring firmware");
1482 ret = -EINVAL;
1483 break;
1484 }
1485 }
1486 /* restart the CPU */
1487 reset = 0;
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001488 if (ret || dw210x_op_rw(dev, 0xa0, 0x7f92, 0, &reset, 1,
1489 DW210X_WRITE_MSG) != 1) {
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001490 err("could not restart the USB controller CPU.");
1491 ret = -EINVAL;
1492 }
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001493 if (ret || dw210x_op_rw(dev, 0xa0, 0xe600, 0, &reset, 1,
1494 DW210X_WRITE_MSG) != 1) {
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001495 err("could not restart the USB controller CPU.");
1496 ret = -EINVAL;
1497 }
1498 /* init registers */
1499 switch (dev->descriptor.idProduct) {
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001500 case USB_PID_TEVII_S650:
Mauro Carvalho Chehab2f4f58d2010-11-17 15:46:09 -03001501 dw2104_properties.rc.legacy.rc_map_table = rc_map_tevii_table;
1502 dw2104_properties.rc.legacy.rc_map_size =
1503 ARRAY_SIZE(rc_map_tevii_table);
Igor M. Liplianinb42e1d72009-06-14 19:41:22 -03001504 case USB_PID_DW2104:
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001505 reset = 1;
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001506 dw210x_op_rw(dev, 0xc4, 0x0000, 0, &reset, 1,
1507 DW210X_WRITE_MSG);
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001508 /* break omitted intentionally */
1509 case USB_PID_DW3101:
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001510 reset = 0;
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001511 dw210x_op_rw(dev, 0xbf, 0x0040, 0, &reset, 0,
1512 DW210X_WRITE_MSG);
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001513 break;
Igor M. Liplianin4cc0edf2008-11-05 22:12:56 -03001514 case USB_PID_CINERGY_S:
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001515 case USB_PID_DW2102:
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001516 dw210x_op_rw(dev, 0xbf, 0x0040, 0, &reset, 0,
1517 DW210X_WRITE_MSG);
1518 dw210x_op_rw(dev, 0xb9, 0x0000, 0, &reset16[0], 2,
1519 DW210X_READ_MSG);
1520 /* check STV0299 frontend */
1521 dw210x_op_rw(dev, 0xb5, 0, 0, &reset16[0], 2,
1522 DW210X_READ_MSG);
Igor M. Liplianinea023df2008-12-04 12:49:23 -03001523 if ((reset16[0] == 0xa1) || (reset16[0] == 0x80)) {
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001524 dw2102_properties.i2c_algo = &dw2102_i2c_algo;
Igor M. Liplianin8a4949b2008-10-05 09:11:21 -03001525 dw2102_properties.adapter->tuner_attach = &dw2102_tuner_attach;
1526 break;
1527 } else {
1528 /* check STV0288 frontend */
1529 reset16[0] = 0xd0;
1530 reset16[1] = 1;
1531 reset16[2] = 0;
1532 dw210x_op_rw(dev, 0xc2, 0, 0, &reset16[0], 3,
1533 DW210X_WRITE_MSG);
1534 dw210x_op_rw(dev, 0xc3, 0xd1, 0, &reset16[0], 3,
1535 DW210X_READ_MSG);
1536 if (reset16[2] == 0x11) {
1537 dw2102_properties.i2c_algo = &dw2102_earda_i2c_algo;
Igor M. Liplianin8a4949b2008-10-05 09:11:21 -03001538 break;
1539 }
1540 }
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001541 case 0x2101:
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001542 dw210x_op_rw(dev, 0xbc, 0x0030, 0, &reset16[0], 2,
1543 DW210X_READ_MSG);
1544 dw210x_op_rw(dev, 0xba, 0x0000, 0, &reset16[0], 7,
1545 DW210X_READ_MSG);
1546 dw210x_op_rw(dev, 0xba, 0x0000, 0, &reset16[0], 7,
1547 DW210X_READ_MSG);
1548 dw210x_op_rw(dev, 0xb9, 0x0000, 0, &reset16[0], 2,
1549 DW210X_READ_MSG);
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001550 break;
1551 }
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001552
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001553 msleep(100);
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001554 kfree(p);
1555 }
1556 return ret;
1557}
1558
1559static struct dvb_usb_device_properties dw2102_properties = {
1560 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1561 .usb_ctrl = DEVICE_SPECIFIC,
1562 .firmware = "dvb-usb-dw2102.fw",
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001563 .no_reconnect = 1,
1564
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001565 .i2c_algo = &dw2102_serit_i2c_algo,
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03001566
1567 .rc.legacy = {
Mauro Carvalho Chehab2f4f58d2010-11-17 15:46:09 -03001568 .rc_map_table = rc_map_dw210x_table,
1569 .rc_map_size = ARRAY_SIZE(rc_map_dw210x_table),
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03001570 .rc_interval = 150,
1571 .rc_query = dw2102_rc_query,
1572 },
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001573
1574 .generic_bulk_ctrl_endpoint = 0x81,
1575 /* parameter for the MPEG2-data transfer */
1576 .num_adapters = 1,
1577 .download_firmware = dw2102_load_firmware,
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001578 .read_mac_address = dw210x_read_mac_address,
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001579 .adapter = {
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001580 {
1581 .frontend_attach = dw2102_frontend_attach,
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001582 .stream = {
1583 .type = USB_BULK,
1584 .count = 8,
1585 .endpoint = 0x82,
1586 .u = {
1587 .bulk = {
1588 .buffersize = 4096,
1589 }
1590 }
1591 },
1592 }
1593 },
Igor M. Liplianin4cc0edf2008-11-05 22:12:56 -03001594 .num_device_descs = 3,
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001595 .devices = {
1596 {"DVBWorld DVB-S 2102 USB2.0",
1597 {&dw2102_table[0], NULL},
1598 {NULL},
1599 },
1600 {"DVBWorld DVB-S 2101 USB2.0",
1601 {&dw2102_table[1], NULL},
1602 {NULL},
1603 },
Igor M. Liplianin4cc0edf2008-11-05 22:12:56 -03001604 {"TerraTec Cinergy S USB",
1605 {&dw2102_table[4], NULL},
1606 {NULL},
1607 },
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001608 }
1609};
1610
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001611static struct dvb_usb_device_properties dw2104_properties = {
1612 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1613 .usb_ctrl = DEVICE_SPECIFIC,
1614 .firmware = "dvb-usb-dw2104.fw",
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001615 .no_reconnect = 1,
1616
1617 .i2c_algo = &dw2104_i2c_algo,
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03001618 .rc.legacy = {
Mauro Carvalho Chehab2f4f58d2010-11-17 15:46:09 -03001619 .rc_map_table = rc_map_dw210x_table,
1620 .rc_map_size = ARRAY_SIZE(rc_map_dw210x_table),
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03001621 .rc_interval = 150,
1622 .rc_query = dw2102_rc_query,
1623 },
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001624
1625 .generic_bulk_ctrl_endpoint = 0x81,
1626 /* parameter for the MPEG2-data transfer */
1627 .num_adapters = 1,
1628 .download_firmware = dw2102_load_firmware,
Igor M. Liplianin21b007b2008-09-17 19:19:19 -03001629 .read_mac_address = dw210x_read_mac_address,
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001630 .adapter = {
1631 {
1632 .frontend_attach = dw2104_frontend_attach,
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001633 .stream = {
1634 .type = USB_BULK,
1635 .count = 8,
1636 .endpoint = 0x82,
1637 .u = {
1638 .bulk = {
1639 .buffersize = 4096,
1640 }
1641 }
1642 },
1643 }
1644 },
1645 .num_device_descs = 2,
1646 .devices = {
1647 { "DVBWorld DW2104 USB2.0",
1648 {&dw2102_table[2], NULL},
1649 {NULL},
1650 },
1651 { "TeVii S650 USB2.0",
1652 {&dw2102_table[3], NULL},
1653 {NULL},
1654 },
1655 }
1656};
1657
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001658static struct dvb_usb_device_properties dw3101_properties = {
1659 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1660 .usb_ctrl = DEVICE_SPECIFIC,
1661 .firmware = "dvb-usb-dw3101.fw",
1662 .no_reconnect = 1,
1663
1664 .i2c_algo = &dw3101_i2c_algo,
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03001665 .rc.legacy = {
Mauro Carvalho Chehab2f4f58d2010-11-17 15:46:09 -03001666 .rc_map_table = rc_map_dw210x_table,
1667 .rc_map_size = ARRAY_SIZE(rc_map_dw210x_table),
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03001668 .rc_interval = 150,
1669 .rc_query = dw2102_rc_query,
1670 },
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001671
1672 .generic_bulk_ctrl_endpoint = 0x81,
1673 /* parameter for the MPEG2-data transfer */
1674 .num_adapters = 1,
1675 .download_firmware = dw2102_load_firmware,
1676 .read_mac_address = dw210x_read_mac_address,
1677 .adapter = {
1678 {
1679 .frontend_attach = dw3101_frontend_attach,
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001680 .tuner_attach = dw3101_tuner_attach,
1681 .stream = {
1682 .type = USB_BULK,
1683 .count = 8,
1684 .endpoint = 0x82,
1685 .u = {
1686 .bulk = {
1687 .buffersize = 4096,
1688 }
1689 }
1690 },
1691 }
1692 },
1693 .num_device_descs = 1,
1694 .devices = {
1695 { "DVBWorld DVB-C 3101 USB2.0",
1696 {&dw2102_table[5], NULL},
1697 {NULL},
1698 },
1699 }
1700};
1701
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001702static struct dvb_usb_device_properties s6x0_properties = {
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -03001703 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1704 .usb_ctrl = DEVICE_SPECIFIC,
Igor M. Liplianin52c506e2011-02-25 18:41:23 -03001705 .size_of_priv = sizeof(struct s6x0_state),
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -03001706 .firmware = "dvb-usb-s630.fw",
1707 .no_reconnect = 1,
1708
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001709 .i2c_algo = &s6x0_i2c_algo,
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03001710 .rc.legacy = {
Mauro Carvalho Chehab2f4f58d2010-11-17 15:46:09 -03001711 .rc_map_table = rc_map_tevii_table,
1712 .rc_map_size = ARRAY_SIZE(rc_map_tevii_table),
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -03001713 .rc_interval = 150,
1714 .rc_query = dw2102_rc_query,
1715 },
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -03001716
1717 .generic_bulk_ctrl_endpoint = 0x81,
1718 .num_adapters = 1,
1719 .download_firmware = dw2102_load_firmware,
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001720 .read_mac_address = s6x0_read_mac_address,
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -03001721 .adapter = {
1722 {
Igor M. Liplianin195288d2011-02-25 18:41:22 -03001723 .frontend_attach = zl100313_frontend_attach,
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -03001724 .stream = {
1725 .type = USB_BULK,
1726 .count = 8,
1727 .endpoint = 0x82,
1728 .u = {
1729 .bulk = {
1730 .buffersize = 4096,
1731 }
1732 }
1733 },
1734 }
1735 },
Igor M. Liplianin195288d2011-02-25 18:41:22 -03001736 .num_device_descs = 1,
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -03001737 .devices = {
1738 {"TeVii S630 USB",
1739 {&dw2102_table[6], NULL},
1740 {NULL},
1741 },
1742 }
1743};
1744
Igor M. Liplianin195288d2011-02-25 18:41:22 -03001745struct dvb_usb_device_properties *p1100;
1746static struct dvb_usb_device_description d1100 = {
1747 "Prof 1100 USB ",
1748 {&dw2102_table[7], NULL},
1749 {NULL},
1750};
1751
1752struct dvb_usb_device_properties *s660;
1753static struct dvb_usb_device_description d660 = {
1754 "TeVii S660 USB",
1755 {&dw2102_table[8], NULL},
1756 {NULL},
1757};
1758
Igor M. Liplianine8f50552011-02-25 18:41:23 -03001759static struct dvb_usb_device_description d480_1 = {
1760 "TeVii S480.1 USB",
1761 {&dw2102_table[12], NULL},
1762 {NULL},
1763};
1764
1765static struct dvb_usb_device_description d480_2 = {
1766 "TeVii S480.2 USB",
1767 {&dw2102_table[13], NULL},
1768 {NULL},
1769};
1770
Igor M. Liplianincd79d332009-12-14 20:24:56 -03001771struct dvb_usb_device_properties *p7500;
1772static struct dvb_usb_device_description d7500 = {
1773 "Prof 7500 USB DVB-S2",
1774 {&dw2102_table[9], NULL},
1775 {NULL},
1776};
1777
Igor M. Liplianind2ffc442011-02-25 18:41:22 -03001778static struct dvb_usb_device_properties su3000_properties = {
1779 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1780 .usb_ctrl = DEVICE_SPECIFIC,
1781 .size_of_priv = sizeof(struct su3000_state),
1782 .power_ctrl = su3000_power_ctrl,
1783 .num_adapters = 1,
1784 .identify_state = su3000_identify_state,
1785 .i2c_algo = &su3000_i2c_algo,
1786
1787 .rc.legacy = {
1788 .rc_map_table = rc_map_su3000_table,
1789 .rc_map_size = ARRAY_SIZE(rc_map_su3000_table),
1790 .rc_interval = 150,
1791 .rc_query = dw2102_rc_query,
1792 },
1793
1794 .read_mac_address = su3000_read_mac_address,
1795
1796 .generic_bulk_ctrl_endpoint = 0x01,
1797
1798 .adapter = {
1799 {
1800 .streaming_ctrl = su3000_streaming_ctrl,
1801 .frontend_attach = su3000_frontend_attach,
1802 .stream = {
1803 .type = USB_BULK,
1804 .count = 8,
1805 .endpoint = 0x82,
1806 .u = {
1807 .bulk = {
1808 .buffersize = 4096,
1809 }
1810 }
1811 }
1812 }
1813 },
Igor M. Liplianin5265ea52011-02-27 16:17:25 -03001814 .num_device_descs = 3,
Igor M. Liplianind2ffc442011-02-25 18:41:22 -03001815 .devices = {
1816 { "SU3000HD DVB-S USB2.0",
1817 { &dw2102_table[10], NULL },
1818 { NULL },
1819 },
Igor M. Liplianin2adc5912011-02-25 18:41:22 -03001820 { "Terratec Cinergy S2 USB HD",
1821 { &dw2102_table[11], NULL },
1822 { NULL },
1823 },
Igor M. Liplianin5265ea52011-02-27 16:17:25 -03001824 { "X3M TV SPC1400HD PCI",
1825 { &dw2102_table[14], NULL },
1826 { NULL },
1827 },
Igor M. Liplianind2ffc442011-02-25 18:41:22 -03001828 }
1829};
1830
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001831static int dw2102_probe(struct usb_interface *intf,
1832 const struct usb_device_id *id)
1833{
Igor M. Liplianin195288d2011-02-25 18:41:22 -03001834 p1100 = kzalloc(sizeof(struct dvb_usb_device_properties), GFP_KERNEL);
1835 if (!p1100)
Igor M. Liplianincd79d332009-12-14 20:24:56 -03001836 return -ENOMEM;
1837 /* copy default structure */
Igor M. Liplianin195288d2011-02-25 18:41:22 -03001838 memcpy(p1100, &s6x0_properties,
Igor M. Liplianincd79d332009-12-14 20:24:56 -03001839 sizeof(struct dvb_usb_device_properties));
1840 /* fill only different fields */
Igor M. Liplianin195288d2011-02-25 18:41:22 -03001841 p1100->firmware = "dvb-usb-p1100.fw";
1842 p1100->devices[0] = d1100;
1843 p1100->rc.legacy.rc_map_table = rc_map_tbs_table;
1844 p1100->rc.legacy.rc_map_size = ARRAY_SIZE(rc_map_tbs_table);
1845 p1100->adapter->frontend_attach = stv0288_frontend_attach;
1846
1847 s660 = kzalloc(sizeof(struct dvb_usb_device_properties), GFP_KERNEL);
1848 if (!s660) {
1849 kfree(p1100);
1850 return -ENOMEM;
1851 }
1852 memcpy(s660, &s6x0_properties,
1853 sizeof(struct dvb_usb_device_properties));
1854 s660->firmware = "dvb-usb-s660.fw";
Igor M. Liplianine8f50552011-02-25 18:41:23 -03001855 s660->num_device_descs = 3;
Igor M. Liplianin195288d2011-02-25 18:41:22 -03001856 s660->devices[0] = d660;
Igor M. Liplianine8f50552011-02-25 18:41:23 -03001857 s660->devices[1] = d480_1;
1858 s660->devices[2] = d480_2;
Igor M. Liplianin195288d2011-02-25 18:41:22 -03001859 s660->adapter->frontend_attach = ds3000_frontend_attach;
1860
1861 p7500 = kzalloc(sizeof(struct dvb_usb_device_properties), GFP_KERNEL);
1862 if (!p7500) {
1863 kfree(p1100);
1864 kfree(s660);
1865 return -ENOMEM;
1866 }
1867 memcpy(p7500, &s6x0_properties,
1868 sizeof(struct dvb_usb_device_properties));
Igor M. Liplianincd79d332009-12-14 20:24:56 -03001869 p7500->firmware = "dvb-usb-p7500.fw";
1870 p7500->devices[0] = d7500;
Mauro Carvalho Chehab2f4f58d2010-11-17 15:46:09 -03001871 p7500->rc.legacy.rc_map_table = rc_map_tbs_table;
1872 p7500->rc.legacy.rc_map_size = ARRAY_SIZE(rc_map_tbs_table);
Igor M. Liplianincd79d332009-12-14 20:24:56 -03001873 p7500->adapter->frontend_attach = prof_7500_frontend_attach;
1874
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001875 if (0 == dvb_usb_device_init(intf, &dw2102_properties,
1876 THIS_MODULE, NULL, adapter_nr) ||
1877 0 == dvb_usb_device_init(intf, &dw2104_properties,
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001878 THIS_MODULE, NULL, adapter_nr) ||
1879 0 == dvb_usb_device_init(intf, &dw3101_properties,
Igor M. Liplianind0a1dda2009-06-20 09:54:18 -03001880 THIS_MODULE, NULL, adapter_nr) ||
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001881 0 == dvb_usb_device_init(intf, &s6x0_properties,
Igor M. Liplianincd79d332009-12-14 20:24:56 -03001882 THIS_MODULE, NULL, adapter_nr) ||
Igor M. Liplianin195288d2011-02-25 18:41:22 -03001883 0 == dvb_usb_device_init(intf, p1100,
1884 THIS_MODULE, NULL, adapter_nr) ||
1885 0 == dvb_usb_device_init(intf, s660,
1886 THIS_MODULE, NULL, adapter_nr) ||
Igor M. Liplianincd79d332009-12-14 20:24:56 -03001887 0 == dvb_usb_device_init(intf, p7500,
Igor M. Liplianind2ffc442011-02-25 18:41:22 -03001888 THIS_MODULE, NULL, adapter_nr) ||
1889 0 == dvb_usb_device_init(intf, &su3000_properties,
1890 THIS_MODULE, NULL, adapter_nr))
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001891 return 0;
Igor M. Liplianin141cc352009-11-27 14:37:35 -03001892
Igor M. Liplianinfe03d5e2008-09-08 17:16:40 -03001893 return -ENODEV;
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001894}
1895
1896static struct usb_driver dw2102_driver = {
1897 .name = "dw2102",
1898 .probe = dw2102_probe,
1899 .disconnect = dvb_usb_device_exit,
1900 .id_table = dw2102_table,
1901};
1902
1903static int __init dw2102_module_init(void)
1904{
1905 int ret = usb_register(&dw2102_driver);
1906 if (ret)
1907 err("usb_register failed. Error number %d", ret);
1908
1909 return ret;
1910}
1911
1912static void __exit dw2102_module_exit(void)
1913{
1914 usb_deregister(&dw2102_driver);
1915}
1916
1917module_init(dw2102_module_init);
1918module_exit(dw2102_module_exit);
1919
1920MODULE_AUTHOR("Igor M. Liplianin (c) liplianin@me.by");
Igor M. Liplianin1dac77c2009-06-14 20:51:45 -03001921MODULE_DESCRIPTION("Driver for DVBWorld DVB-S 2101, 2102, DVB-S2 2104,"
1922 " DVB-C 3101 USB2.0,"
Igor M. Liplianine8f50552011-02-25 18:41:23 -03001923 " TeVii S600, S630, S650, S660, S480,"
Igor M. Liplianind2ffc442011-02-25 18:41:22 -03001924 " Prof 1100, 7500 USB2.0,"
1925 " Geniatech SU3000 devices");
Igor M Liplianin7fd48282008-07-20 08:05:50 -03001926MODULE_VERSION("0.1");
1927MODULE_LICENSE("GPL");