1 /* DVB USB framework compliant Linux driver for the
2 * DVBWorld DVB-S 2101, 2102, DVB-S2 2104, DVB-C 3101,
3 * TeVii S600, S630, S650, S660, S480,
4 * Prof 1100, 7500,
5 * Geniatech SU3000 Cards
6 * 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 */
14 #include "dw2102.h"
15 #include "si21xx.h"
16 #include "stv0299.h"
17 #include "z0194a.h"
18 #include "stv0288.h"
19 #include "stb6000.h"
20 #include "eds1547.h"
21 #include "cx24116.h"
22 #include "tda1002x.h"
23 #include "mt312.h"
24 #include "zl10039.h"
25 #include "ds3000.h"
26 #include "stv0900.h"
27 #include "stv6110.h"
28 #include "stb6100.h"
29 #include "stb6100_proc.h"
30
31 #ifndef USB_PID_DW2102
32 #define USB_PID_DW2102 0x2102
33 #endif
34
35 #ifndef USB_PID_DW2104
36 #define USB_PID_DW2104 0x2104
37 #endif
38
39 #ifndef USB_PID_DW3101
40 #define USB_PID_DW3101 0x3101
41 #endif
42
43 #ifndef USB_PID_CINERGY_S
44 #define USB_PID_CINERGY_S 0x0064
45 #endif
46
47 #ifndef USB_PID_TEVII_S630
48 #define USB_PID_TEVII_S630 0xd630
49 #endif
50
51 #ifndef USB_PID_TEVII_S650
52 #define USB_PID_TEVII_S650 0xd650
53 #endif
54
55 #ifndef USB_PID_TEVII_S660
56 #define USB_PID_TEVII_S660 0xd660
57 #endif
58
59 #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
67 #ifndef USB_PID_PROF_1100
68 #define USB_PID_PROF_1100 0xb012
69 #endif
70
71 #define DW210X_READ_MSG 0
72 #define DW210X_WRITE_MSG 1
73
74 #define REG_1F_SYMBOLRATE_BYTE0 0x1f
75 #define REG_20_SYMBOLRATE_BYTE1 0x20
76 #define REG_21_SYMBOLRATE_BYTE2 0x21
77 /* on my own*/
78 #define DW2102_VOLTAGE_CTRL (0x1800)
79 #define SU3000_STREAM_CTRL (0x1900)
80 #define DW2102_RC_QUERY (0x1a00)
81 #define DW2102_LED_CTRL (0x1b00)
82
83 #define err_str "did not find the firmware file. (%s) " \
84 "Please see linux/Documentation/dvb/ for more details " \
85 "on firmware-problems."
86
87 struct rc_map_dvb_usb_table_table {
88 struct rc_map_table *rc_keys;
89 int rc_keys_size;
90 };
91
92 struct su3000_state {
93 u8 initialized;
94 };
95
96 struct s6x0_state {
97 int (*old_set_voltage)(struct dvb_frontend *f, fe_sec_voltage_t v);
98 };
99
100 /* debug */
101 static int dvb_usb_dw2102_debug;
102 module_param_named(debug, dvb_usb_dw2102_debug, int, 0644);
103 MODULE_PARM_DESC(debug, "set debugging level (1=info 2=xfer 4=rc(or-able))."
104 DVB_USB_DEBUG_STATUS);
105
106 /* keymaps */
107 static int ir_keymap;
108 module_param_named(keymap, ir_keymap, int, 0644);
109 MODULE_PARM_DESC(keymap, "set keymap 0=default 1=dvbworld 2=tevii 3=tbs ..."
110 " 256=none");
111
112 /* demod probe */
113 static int demod_probe = 1;
114 module_param_named(demod, demod_probe, int, 0644);
115 MODULE_PARM_DESC(demod, "demod to probe (1=cx24116 2=stv0903+stv6110 "
116 "4=stv0903+stb6100(or-able)).");
117
118 DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
119
dw210x_op_rw(struct usb_device * dev,u8 request,u16 value,u16 index,u8 * data,u16 len,int flags)120 static int dw210x_op_rw(struct usb_device *dev, u8 request, u16 value,
121 u16 index, u8 * data, u16 len, int flags)
122 {
123 int ret;
124 u8 *u8buf;
125 unsigned int pipe = (flags == DW210X_READ_MSG) ?
126 usb_rcvctrlpipe(dev, 0) : usb_sndctrlpipe(dev, 0);
127 u8 request_type = (flags == DW210X_READ_MSG) ? USB_DIR_IN : USB_DIR_OUT;
128
129 u8buf = kmalloc(len, GFP_KERNEL);
130 if (!u8buf)
131 return -ENOMEM;
132
133
134 if (flags == DW210X_WRITE_MSG)
135 memcpy(u8buf, data, len);
136 ret = usb_control_msg(dev, pipe, request, request_type | USB_TYPE_VENDOR,
137 value, index , u8buf, len, 2000);
138
139 if (flags == DW210X_READ_MSG)
140 memcpy(data, u8buf, len);
141
142 kfree(u8buf);
143 return ret;
144 }
145
146 /* I2C */
dw2102_i2c_transfer(struct i2c_adapter * adap,struct i2c_msg msg[],int num)147 static int dw2102_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],
148 int num)
149 {
150 struct dvb_usb_device *d = i2c_get_adapdata(adap);
151 int i = 0, ret = 0;
152 u8 buf6[] = {0x2c, 0x05, 0xc0, 0, 0, 0, 0};
153 u16 value;
154
155 if (!d)
156 return -ENODEV;
157 if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
158 return -EAGAIN;
159
160 switch (num) {
161 case 2:
162 /* read stv0299 register */
163 value = msg[0].buf[0];/* register */
164 for (i = 0; i < msg[1].len; i++) {
165 ret = dw210x_op_rw(d->udev, 0xb5, value + i, 0,
166 buf6, 2, DW210X_READ_MSG);
167 msg[1].buf[i] = buf6[0];
168 }
169 break;
170 case 1:
171 switch (msg[0].addr) {
172 case 0x68:
173 /* write to stv0299 register */
174 buf6[0] = 0x2a;
175 buf6[1] = msg[0].buf[0];
176 buf6[2] = msg[0].buf[1];
177 ret = dw210x_op_rw(d->udev, 0xb2, 0, 0,
178 buf6, 3, DW210X_WRITE_MSG);
179 break;
180 case 0x60:
181 if (msg[0].flags == 0) {
182 /* write to tuner pll */
183 buf6[0] = 0x2c;
184 buf6[1] = 5;
185 buf6[2] = 0xc0;
186 buf6[3] = msg[0].buf[0];
187 buf6[4] = msg[0].buf[1];
188 buf6[5] = msg[0].buf[2];
189 buf6[6] = msg[0].buf[3];
190 ret = dw210x_op_rw(d->udev, 0xb2, 0, 0,
191 buf6, 7, DW210X_WRITE_MSG);
192 } else {
193 /* read from tuner */
194 ret = dw210x_op_rw(d->udev, 0xb5, 0, 0,
195 buf6, 1, DW210X_READ_MSG);
196 msg[0].buf[0] = buf6[0];
197 }
198 break;
199 case (DW2102_RC_QUERY):
200 ret = dw210x_op_rw(d->udev, 0xb8, 0, 0,
201 buf6, 2, DW210X_READ_MSG);
202 msg[0].buf[0] = buf6[0];
203 msg[0].buf[1] = buf6[1];
204 break;
205 case (DW2102_VOLTAGE_CTRL):
206 buf6[0] = 0x30;
207 buf6[1] = msg[0].buf[0];
208 ret = dw210x_op_rw(d->udev, 0xb2, 0, 0,
209 buf6, 2, DW210X_WRITE_MSG);
210 break;
211 }
212
213 break;
214 }
215
216 mutex_unlock(&d->i2c_mutex);
217 return num;
218 }
219
dw2102_serit_i2c_transfer(struct i2c_adapter * adap,struct i2c_msg msg[],int num)220 static int dw2102_serit_i2c_transfer(struct i2c_adapter *adap,
221 struct i2c_msg msg[], int num)
222 {
223 struct dvb_usb_device *d = i2c_get_adapdata(adap);
224 int ret = 0;
225 u8 buf6[] = {0, 0, 0, 0, 0, 0, 0};
226
227 if (!d)
228 return -ENODEV;
229 if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
230 return -EAGAIN;
231
232 switch (num) {
233 case 2:
234 /* read si2109 register by number */
235 buf6[0] = msg[0].addr << 1;
236 buf6[1] = msg[0].len;
237 buf6[2] = msg[0].buf[0];
238 ret = dw210x_op_rw(d->udev, 0xc2, 0, 0,
239 buf6, msg[0].len + 2, DW210X_WRITE_MSG);
240 /* read si2109 register */
241 ret = dw210x_op_rw(d->udev, 0xc3, 0xd0, 0,
242 buf6, msg[1].len + 2, DW210X_READ_MSG);
243 memcpy(msg[1].buf, buf6 + 2, msg[1].len);
244
245 break;
246 case 1:
247 switch (msg[0].addr) {
248 case 0x68:
249 /* write to si2109 register */
250 buf6[0] = msg[0].addr << 1;
251 buf6[1] = msg[0].len;
252 memcpy(buf6 + 2, msg[0].buf, msg[0].len);
253 ret = dw210x_op_rw(d->udev, 0xc2, 0, 0, buf6,
254 msg[0].len + 2, DW210X_WRITE_MSG);
255 break;
256 case(DW2102_RC_QUERY):
257 ret = dw210x_op_rw(d->udev, 0xb8, 0, 0,
258 buf6, 2, DW210X_READ_MSG);
259 msg[0].buf[0] = buf6[0];
260 msg[0].buf[1] = buf6[1];
261 break;
262 case(DW2102_VOLTAGE_CTRL):
263 buf6[0] = 0x30;
264 buf6[1] = msg[0].buf[0];
265 ret = dw210x_op_rw(d->udev, 0xb2, 0, 0,
266 buf6, 2, DW210X_WRITE_MSG);
267 break;
268 }
269 break;
270 }
271
272 mutex_unlock(&d->i2c_mutex);
273 return num;
274 }
275
dw2102_earda_i2c_transfer(struct i2c_adapter * adap,struct i2c_msg msg[],int num)276 static int dw2102_earda_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], int num)
277 {
278 struct dvb_usb_device *d = i2c_get_adapdata(adap);
279 int ret = 0;
280
281 if (!d)
282 return -ENODEV;
283 if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
284 return -EAGAIN;
285
286 switch (num) {
287 case 2: {
288 /* read */
289 /* first write first register number */
290 u8 ibuf[msg[1].len + 2], obuf[3];
291 obuf[0] = msg[0].addr << 1;
292 obuf[1] = msg[0].len;
293 obuf[2] = msg[0].buf[0];
294 ret = dw210x_op_rw(d->udev, 0xc2, 0, 0,
295 obuf, msg[0].len + 2, DW210X_WRITE_MSG);
296 /* second read registers */
297 ret = dw210x_op_rw(d->udev, 0xc3, 0xd1 , 0,
298 ibuf, msg[1].len + 2, DW210X_READ_MSG);
299 memcpy(msg[1].buf, ibuf + 2, msg[1].len);
300
301 break;
302 }
303 case 1:
304 switch (msg[0].addr) {
305 case 0x68: {
306 /* write to register */
307 u8 obuf[msg[0].len + 2];
308 obuf[0] = msg[0].addr << 1;
309 obuf[1] = msg[0].len;
310 memcpy(obuf + 2, msg[0].buf, msg[0].len);
311 ret = dw210x_op_rw(d->udev, 0xc2, 0, 0,
312 obuf, msg[0].len + 2, DW210X_WRITE_MSG);
313 break;
314 }
315 case 0x61: {
316 /* write to tuner */
317 u8 obuf[msg[0].len + 2];
318 obuf[0] = msg[0].addr << 1;
319 obuf[1] = msg[0].len;
320 memcpy(obuf + 2, msg[0].buf, msg[0].len);
321 ret = dw210x_op_rw(d->udev, 0xc2, 0, 0,
322 obuf, msg[0].len + 2, DW210X_WRITE_MSG);
323 break;
324 }
325 case(DW2102_RC_QUERY): {
326 u8 ibuf[2];
327 ret = dw210x_op_rw(d->udev, 0xb8, 0, 0,
328 ibuf, 2, DW210X_READ_MSG);
329 memcpy(msg[0].buf, ibuf , 2);
330 break;
331 }
332 case(DW2102_VOLTAGE_CTRL): {
333 u8 obuf[2];
334 obuf[0] = 0x30;
335 obuf[1] = msg[0].buf[0];
336 ret = dw210x_op_rw(d->udev, 0xb2, 0, 0,
337 obuf, 2, DW210X_WRITE_MSG);
338 break;
339 }
340 }
341
342 break;
343 }
344
345 mutex_unlock(&d->i2c_mutex);
346 return num;
347 }
348
dw2104_i2c_transfer(struct i2c_adapter * adap,struct i2c_msg msg[],int num)349 static int dw2104_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], int num)
350 {
351 struct dvb_usb_device *d = i2c_get_adapdata(adap);
352 int ret = 0;
353 int len, i, j;
354
355 if (!d)
356 return -ENODEV;
357 if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
358 return -EAGAIN;
359
360 for (j = 0; j < num; j++) {
361 switch (msg[j].addr) {
362 case(DW2102_RC_QUERY): {
363 u8 ibuf[2];
364 ret = dw210x_op_rw(d->udev, 0xb8, 0, 0,
365 ibuf, 2, DW210X_READ_MSG);
366 memcpy(msg[j].buf, ibuf , 2);
367 break;
368 }
369 case(DW2102_VOLTAGE_CTRL): {
370 u8 obuf[2];
371 obuf[0] = 0x30;
372 obuf[1] = msg[j].buf[0];
373 ret = dw210x_op_rw(d->udev, 0xb2, 0, 0,
374 obuf, 2, DW210X_WRITE_MSG);
375 break;
376 }
377 /*case 0x55: cx24116
378 case 0x6a: stv0903
379 case 0x68: ds3000, stv0903
380 case 0x60: ts2020, stv6110, stb6100 */
381 default: {
382 if (msg[j].flags == I2C_M_RD) {
383 /* read registers */
384 u8 ibuf[msg[j].len + 2];
385 ret = dw210x_op_rw(d->udev, 0xc3,
386 (msg[j].addr << 1) + 1, 0,
387 ibuf, msg[j].len + 2,
388 DW210X_READ_MSG);
389 memcpy(msg[j].buf, ibuf + 2, msg[j].len);
390 mdelay(10);
391 } else if (((msg[j].buf[0] == 0xb0) &&
392 (msg[j].addr == 0x68)) ||
393 ((msg[j].buf[0] == 0xf7) &&
394 (msg[j].addr == 0x55))) {
395 /* write firmware */
396 u8 obuf[19];
397 obuf[0] = msg[j].addr << 1;
398 obuf[1] = (msg[j].len > 15 ? 17 : msg[j].len);
399 obuf[2] = msg[j].buf[0];
400 len = msg[j].len - 1;
401 i = 1;
402 do {
403 memcpy(obuf + 3, msg[j].buf + i,
404 (len > 16 ? 16 : len));
405 ret = dw210x_op_rw(d->udev, 0xc2, 0, 0,
406 obuf, (len > 16 ? 16 : len) + 3,
407 DW210X_WRITE_MSG);
408 i += 16;
409 len -= 16;
410 } while (len > 0);
411 } else {
412 /* write registers */
413 u8 obuf[msg[j].len + 2];
414 obuf[0] = msg[j].addr << 1;
415 obuf[1] = msg[j].len;
416 memcpy(obuf + 2, msg[j].buf, msg[j].len);
417 ret = dw210x_op_rw(d->udev, 0xc2, 0, 0,
418 obuf, msg[j].len + 2,
419 DW210X_WRITE_MSG);
420 }
421 break;
422 }
423 }
424
425 }
426
427 mutex_unlock(&d->i2c_mutex);
428 return num;
429 }
430
dw3101_i2c_transfer(struct i2c_adapter * adap,struct i2c_msg msg[],int num)431 static int dw3101_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],
432 int num)
433 {
434 struct dvb_usb_device *d = i2c_get_adapdata(adap);
435 int ret = 0, i;
436
437 if (!d)
438 return -ENODEV;
439 if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
440 return -EAGAIN;
441
442 switch (num) {
443 case 2: {
444 /* read */
445 /* first write first register number */
446 u8 ibuf[msg[1].len + 2], obuf[3];
447 obuf[0] = msg[0].addr << 1;
448 obuf[1] = msg[0].len;
449 obuf[2] = msg[0].buf[0];
450 ret = dw210x_op_rw(d->udev, 0xc2, 0, 0,
451 obuf, msg[0].len + 2, DW210X_WRITE_MSG);
452 /* second read registers */
453 ret = dw210x_op_rw(d->udev, 0xc3, 0x19 , 0,
454 ibuf, msg[1].len + 2, DW210X_READ_MSG);
455 memcpy(msg[1].buf, ibuf + 2, msg[1].len);
456
457 break;
458 }
459 case 1:
460 switch (msg[0].addr) {
461 case 0x60:
462 case 0x0c: {
463 /* write to register */
464 u8 obuf[msg[0].len + 2];
465 obuf[0] = msg[0].addr << 1;
466 obuf[1] = msg[0].len;
467 memcpy(obuf + 2, msg[0].buf, msg[0].len);
468 ret = dw210x_op_rw(d->udev, 0xc2, 0, 0,
469 obuf, msg[0].len + 2, DW210X_WRITE_MSG);
470 break;
471 }
472 case(DW2102_RC_QUERY): {
473 u8 ibuf[2];
474 ret = dw210x_op_rw(d->udev, 0xb8, 0, 0,
475 ibuf, 2, DW210X_READ_MSG);
476 memcpy(msg[0].buf, ibuf , 2);
477 break;
478 }
479 }
480
481 break;
482 }
483
484 for (i = 0; i < num; i++) {
485 deb_xfer("%02x:%02x: %s ", i, msg[i].addr,
486 msg[i].flags == 0 ? ">>>" : "<<<");
487 debug_dump(msg[i].buf, msg[i].len, deb_xfer);
488 }
489
490 mutex_unlock(&d->i2c_mutex);
491 return num;
492 }
493
s6x0_i2c_transfer(struct i2c_adapter * adap,struct i2c_msg msg[],int num)494 static int s6x0_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],
495 int num)
496 {
497 struct dvb_usb_device *d = i2c_get_adapdata(adap);
498 struct usb_device *udev;
499 int ret = 0;
500 int len, i, j;
501
502 if (!d)
503 return -ENODEV;
504 udev = d->udev;
505 if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
506 return -EAGAIN;
507
508 for (j = 0; j < num; j++) {
509 switch (msg[j].addr) {
510 case (DW2102_RC_QUERY): {
511 u8 ibuf[5];
512 ret = dw210x_op_rw(d->udev, 0xb8, 0, 0,
513 ibuf, 5, DW210X_READ_MSG);
514 memcpy(msg[j].buf, ibuf + 3, 2);
515 break;
516 }
517 case (DW2102_VOLTAGE_CTRL): {
518 u8 obuf[2];
519
520 obuf[0] = 1;
521 obuf[1] = msg[j].buf[1];/* off-on */
522 ret = dw210x_op_rw(d->udev, 0x8a, 0, 0,
523 obuf, 2, DW210X_WRITE_MSG);
524 obuf[0] = 3;
525 obuf[1] = msg[j].buf[0];/* 13v-18v */
526 ret = dw210x_op_rw(d->udev, 0x8a, 0, 0,
527 obuf, 2, DW210X_WRITE_MSG);
528 break;
529 }
530 case (DW2102_LED_CTRL): {
531 u8 obuf[2];
532
533 obuf[0] = 5;
534 obuf[1] = msg[j].buf[0];
535 ret = dw210x_op_rw(d->udev, 0x8a, 0, 0,
536 obuf, 2, DW210X_WRITE_MSG);
537 break;
538 }
539 /*case 0x55: cx24116
540 case 0x6a: stv0903
541 case 0x68: ds3000, stv0903
542 case 0x60: ts2020, stv6110, stb6100
543 case 0xa0: eeprom */
544 default: {
545 if (msg[j].flags == I2C_M_RD) {
546 /* read registers */
547 u8 ibuf[msg[j].len];
548 ret = dw210x_op_rw(d->udev, 0x91, 0, 0,
549 ibuf, msg[j].len,
550 DW210X_READ_MSG);
551 memcpy(msg[j].buf, ibuf, msg[j].len);
552 break;
553 } else if ((msg[j].buf[0] == 0xb0) &&
554 (msg[j].addr == 0x68)) {
555 /* write firmware */
556 u8 obuf[19];
557 obuf[0] = (msg[j].len > 16 ?
558 18 : msg[j].len + 1);
559 obuf[1] = msg[j].addr << 1;
560 obuf[2] = msg[j].buf[0];
561 len = msg[j].len - 1;
562 i = 1;
563 do {
564 memcpy(obuf + 3, msg[j].buf + i,
565 (len > 16 ? 16 : len));
566 ret = dw210x_op_rw(d->udev, 0x80, 0, 0,
567 obuf, (len > 16 ? 16 : len) + 3,
568 DW210X_WRITE_MSG);
569 i += 16;
570 len -= 16;
571 } while (len > 0);
572 } else if (j < (num - 1)) {
573 /* write register addr before read */
574 u8 obuf[msg[j].len + 2];
575 obuf[0] = msg[j + 1].len;
576 obuf[1] = (msg[j].addr << 1);
577 memcpy(obuf + 2, msg[j].buf, msg[j].len);
578 ret = dw210x_op_rw(d->udev,
579 udev->descriptor.idProduct ==
580 0x7500 ? 0x92 : 0x90, 0, 0,
581 obuf, msg[j].len + 2,
582 DW210X_WRITE_MSG);
583 break;
584 } else {
585 /* write registers */
586 u8 obuf[msg[j].len + 2];
587 obuf[0] = msg[j].len + 1;
588 obuf[1] = (msg[j].addr << 1);
589 memcpy(obuf + 2, msg[j].buf, msg[j].len);
590 ret = dw210x_op_rw(d->udev, 0x80, 0, 0,
591 obuf, msg[j].len + 2,
592 DW210X_WRITE_MSG);
593 break;
594 }
595 break;
596 }
597 }
598 }
599
600 mutex_unlock(&d->i2c_mutex);
601 return num;
602 }
603
su3000_i2c_transfer(struct i2c_adapter * adap,struct i2c_msg msg[],int num)604 static int su3000_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],
605 int num)
606 {
607 struct dvb_usb_device *d = i2c_get_adapdata(adap);
608 u8 obuf[0x40], ibuf[0x40];
609
610 if (!d)
611 return -ENODEV;
612 if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
613 return -EAGAIN;
614
615 switch (num) {
616 case 1:
617 switch (msg[0].addr) {
618 case SU3000_STREAM_CTRL:
619 obuf[0] = msg[0].buf[0] + 0x36;
620 obuf[1] = 3;
621 obuf[2] = 0;
622 if (dvb_usb_generic_rw(d, obuf, 3, ibuf, 0, 0) < 0)
623 err("i2c transfer failed.");
624 break;
625 case DW2102_RC_QUERY:
626 obuf[0] = 0x10;
627 if (dvb_usb_generic_rw(d, obuf, 1, ibuf, 2, 0) < 0)
628 err("i2c transfer failed.");
629 msg[0].buf[1] = ibuf[0];
630 msg[0].buf[0] = ibuf[1];
631 break;
632 default:
633 /* always i2c write*/
634 obuf[0] = 0x08;
635 obuf[1] = msg[0].addr;
636 obuf[2] = msg[0].len;
637
638 memcpy(&obuf[3], msg[0].buf, msg[0].len);
639
640 if (dvb_usb_generic_rw(d, obuf, msg[0].len + 3,
641 ibuf, 1, 0) < 0)
642 err("i2c transfer failed.");
643
644 }
645 break;
646 case 2:
647 /* always i2c read */
648 obuf[0] = 0x09;
649 obuf[1] = msg[0].len;
650 obuf[2] = msg[1].len;
651 obuf[3] = msg[0].addr;
652 memcpy(&obuf[4], msg[0].buf, msg[0].len);
653
654 if (dvb_usb_generic_rw(d, obuf, msg[0].len + 4,
655 ibuf, msg[1].len + 1, 0) < 0)
656 err("i2c transfer failed.");
657
658 memcpy(msg[1].buf, &ibuf[1], msg[1].len);
659 break;
660 default:
661 warn("more than 2 i2c messages at a time is not handled yet.");
662 break;
663 }
664 mutex_unlock(&d->i2c_mutex);
665 return num;
666 }
667
dw210x_i2c_func(struct i2c_adapter * adapter)668 static u32 dw210x_i2c_func(struct i2c_adapter *adapter)
669 {
670 return I2C_FUNC_I2C;
671 }
672
673 static struct i2c_algorithm dw2102_i2c_algo = {
674 .master_xfer = dw2102_i2c_transfer,
675 .functionality = dw210x_i2c_func,
676 };
677
678 static struct i2c_algorithm dw2102_serit_i2c_algo = {
679 .master_xfer = dw2102_serit_i2c_transfer,
680 .functionality = dw210x_i2c_func,
681 };
682
683 static struct i2c_algorithm dw2102_earda_i2c_algo = {
684 .master_xfer = dw2102_earda_i2c_transfer,
685 .functionality = dw210x_i2c_func,
686 };
687
688 static struct i2c_algorithm dw2104_i2c_algo = {
689 .master_xfer = dw2104_i2c_transfer,
690 .functionality = dw210x_i2c_func,
691 };
692
693 static struct i2c_algorithm dw3101_i2c_algo = {
694 .master_xfer = dw3101_i2c_transfer,
695 .functionality = dw210x_i2c_func,
696 };
697
698 static struct i2c_algorithm s6x0_i2c_algo = {
699 .master_xfer = s6x0_i2c_transfer,
700 .functionality = dw210x_i2c_func,
701 };
702
703 static struct i2c_algorithm su3000_i2c_algo = {
704 .master_xfer = su3000_i2c_transfer,
705 .functionality = dw210x_i2c_func,
706 };
707
dw210x_read_mac_address(struct dvb_usb_device * d,u8 mac[6])708 static int dw210x_read_mac_address(struct dvb_usb_device *d, u8 mac[6])
709 {
710 int i;
711 u8 ibuf[] = {0, 0};
712 u8 eeprom[256], eepromline[16];
713
714 for (i = 0; i < 256; i++) {
715 if (dw210x_op_rw(d->udev, 0xb6, 0xa0 , i, ibuf, 2, DW210X_READ_MSG) < 0) {
716 err("read eeprom failed.");
717 return -1;
718 } else {
719 eepromline[i%16] = ibuf[0];
720 eeprom[i] = ibuf[0];
721 }
722 if ((i % 16) == 15) {
723 deb_xfer("%02x: ", i - 15);
724 debug_dump(eepromline, 16, deb_xfer);
725 }
726 }
727
728 memcpy(mac, eeprom + 8, 6);
729 return 0;
730 };
731
s6x0_read_mac_address(struct dvb_usb_device * d,u8 mac[6])732 static int s6x0_read_mac_address(struct dvb_usb_device *d, u8 mac[6])
733 {
734 int i, ret;
735 u8 ibuf[] = { 0 }, obuf[] = { 0 };
736 u8 eeprom[256], eepromline[16];
737 struct i2c_msg msg[] = {
738 {
739 .addr = 0xa0 >> 1,
740 .flags = 0,
741 .buf = obuf,
742 .len = 1,
743 }, {
744 .addr = 0xa0 >> 1,
745 .flags = I2C_M_RD,
746 .buf = ibuf,
747 .len = 1,
748 }
749 };
750
751 for (i = 0; i < 256; i++) {
752 obuf[0] = i;
753 ret = s6x0_i2c_transfer(&d->i2c_adap, msg, 2);
754 if (ret != 2) {
755 err("read eeprom failed.");
756 return -1;
757 } else {
758 eepromline[i % 16] = ibuf[0];
759 eeprom[i] = ibuf[0];
760 }
761
762 if ((i % 16) == 15) {
763 deb_xfer("%02x: ", i - 15);
764 debug_dump(eepromline, 16, deb_xfer);
765 }
766 }
767
768 memcpy(mac, eeprom + 16, 6);
769 return 0;
770 };
771
su3000_streaming_ctrl(struct dvb_usb_adapter * adap,int onoff)772 static int su3000_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff)
773 {
774 static u8 command_start[] = {0x00};
775 static u8 command_stop[] = {0x01};
776 struct i2c_msg msg = {
777 .addr = SU3000_STREAM_CTRL,
778 .flags = 0,
779 .buf = onoff ? command_start : command_stop,
780 .len = 1
781 };
782
783 i2c_transfer(&adap->dev->i2c_adap, &msg, 1);
784
785 return 0;
786 }
787
su3000_power_ctrl(struct dvb_usb_device * d,int i)788 static int su3000_power_ctrl(struct dvb_usb_device *d, int i)
789 {
790 struct su3000_state *state = (struct su3000_state *)d->priv;
791 u8 obuf[] = {0xde, 0};
792
793 info("%s: %d, initialized %d\n", __func__, i, state->initialized);
794
795 if (i && !state->initialized) {
796 state->initialized = 1;
797 /* reset board */
798 dvb_usb_generic_rw(d, obuf, 2, NULL, 0, 0);
799 }
800
801 return 0;
802 }
803
su3000_read_mac_address(struct dvb_usb_device * d,u8 mac[6])804 static int su3000_read_mac_address(struct dvb_usb_device *d, u8 mac[6])
805 {
806 int i;
807 u8 obuf[] = { 0x1f, 0xf0 };
808 u8 ibuf[] = { 0 };
809 struct i2c_msg msg[] = {
810 {
811 .addr = 0x51,
812 .flags = 0,
813 .buf = obuf,
814 .len = 2,
815 }, {
816 .addr = 0x51,
817 .flags = I2C_M_RD,
818 .buf = ibuf,
819 .len = 1,
820
821 }
822 };
823
824 for (i = 0; i < 6; i++) {
825 obuf[1] = 0xf0 + i;
826 if (i2c_transfer(&d->i2c_adap, msg, 2) != 2)
827 break;
828 else
829 mac[i] = ibuf[0];
830
831 debug_dump(mac, 6, printk);
832 }
833
834 return 0;
835 }
836
su3000_identify_state(struct usb_device * udev,struct dvb_usb_device_properties * props,struct dvb_usb_device_description ** desc,int * cold)837 static int su3000_identify_state(struct usb_device *udev,
838 struct dvb_usb_device_properties *props,
839 struct dvb_usb_device_description **desc,
840 int *cold)
841 {
842 info("%s\n", __func__);
843
844 *cold = 0;
845 return 0;
846 }
847
dw210x_set_voltage(struct dvb_frontend * fe,fe_sec_voltage_t voltage)848 static int dw210x_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
849 {
850 static u8 command_13v[] = {0x00, 0x01};
851 static u8 command_18v[] = {0x01, 0x01};
852 static u8 command_off[] = {0x00, 0x00};
853 struct i2c_msg msg = {
854 .addr = DW2102_VOLTAGE_CTRL,
855 .flags = 0,
856 .buf = command_off,
857 .len = 2,
858 };
859
860 struct dvb_usb_adapter *udev_adap =
861 (struct dvb_usb_adapter *)(fe->dvb->priv);
862 if (voltage == SEC_VOLTAGE_18)
863 msg.buf = command_18v;
864 else if (voltage == SEC_VOLTAGE_13)
865 msg.buf = command_13v;
866
867 i2c_transfer(&udev_adap->dev->i2c_adap, &msg, 1);
868
869 return 0;
870 }
871
s660_set_voltage(struct dvb_frontend * fe,fe_sec_voltage_t voltage)872 static int s660_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
873 {
874 struct dvb_usb_adapter *d =
875 (struct dvb_usb_adapter *)(fe->dvb->priv);
876 struct s6x0_state *st = (struct s6x0_state *)d->dev->priv;
877
878 dw210x_set_voltage(fe, voltage);
879 if (st->old_set_voltage)
880 st->old_set_voltage(fe, voltage);
881
882 return 0;
883 }
884
dw210x_led_ctrl(struct dvb_frontend * fe,int offon)885 static void dw210x_led_ctrl(struct dvb_frontend *fe, int offon)
886 {
887 static u8 led_off[] = { 0 };
888 static u8 led_on[] = { 1 };
889 struct i2c_msg msg = {
890 .addr = DW2102_LED_CTRL,
891 .flags = 0,
892 .buf = led_off,
893 .len = 1
894 };
895 struct dvb_usb_adapter *udev_adap =
896 (struct dvb_usb_adapter *)(fe->dvb->priv);
897
898 if (offon)
899 msg.buf = led_on;
900 i2c_transfer(&udev_adap->dev->i2c_adap, &msg, 1);
901 }
902
903 static struct stv0299_config sharp_z0194a_config = {
904 .demod_address = 0x68,
905 .inittab = sharp_z0194a_inittab,
906 .mclk = 88000000UL,
907 .invert = 1,
908 .skip_reinit = 0,
909 .lock_output = STV0299_LOCKOUTPUT_1,
910 .volt13_op0_op1 = STV0299_VOLT13_OP1,
911 .min_delay_ms = 100,
912 .set_symbol_rate = sharp_z0194a_set_symbol_rate,
913 };
914
915 static struct cx24116_config dw2104_config = {
916 .demod_address = 0x55,
917 .mpg_clk_pos_pol = 0x01,
918 };
919
920 static struct si21xx_config serit_sp1511lhb_config = {
921 .demod_address = 0x68,
922 .min_delay_ms = 100,
923
924 };
925
926 static struct tda10023_config dw3101_tda10023_config = {
927 .demod_address = 0x0c,
928 .invert = 1,
929 };
930
931 static struct mt312_config zl313_config = {
932 .demod_address = 0x0e,
933 };
934
935 static struct ds3000_config dw2104_ds3000_config = {
936 .demod_address = 0x68,
937 };
938
939 static struct stv0900_config dw2104a_stv0900_config = {
940 .demod_address = 0x6a,
941 .demod_mode = 0,
942 .xtal = 27000000,
943 .clkmode = 3,/* 0-CLKI, 2-XTALI, else AUTO */
944 .diseqc_mode = 2,/* 2/3 PWM */
945 .tun1_maddress = 0,/* 0x60 */
946 .tun1_adc = 0,/* 2 Vpp */
947 .path1_mode = 3,
948 };
949
950 static struct stb6100_config dw2104a_stb6100_config = {
951 .tuner_address = 0x60,
952 .refclock = 27000000,
953 };
954
955 static struct stv0900_config dw2104_stv0900_config = {
956 .demod_address = 0x68,
957 .demod_mode = 0,
958 .xtal = 8000000,
959 .clkmode = 3,
960 .diseqc_mode = 2,
961 .tun1_maddress = 0,
962 .tun1_adc = 1,/* 1 Vpp */
963 .path1_mode = 3,
964 };
965
966 static struct stv6110_config dw2104_stv6110_config = {
967 .i2c_address = 0x60,
968 .mclk = 16000000,
969 .clk_div = 1,
970 };
971
972 static struct stv0900_config prof_7500_stv0900_config = {
973 .demod_address = 0x6a,
974 .demod_mode = 0,
975 .xtal = 27000000,
976 .clkmode = 3,/* 0-CLKI, 2-XTALI, else AUTO */
977 .diseqc_mode = 2,/* 2/3 PWM */
978 .tun1_maddress = 0,/* 0x60 */
979 .tun1_adc = 0,/* 2 Vpp */
980 .path1_mode = 3,
981 .tun1_type = 3,
982 .set_lock_led = dw210x_led_ctrl,
983 };
984
985 static struct ds3000_config su3000_ds3000_config = {
986 .demod_address = 0x68,
987 .ci_mode = 1,
988 };
989
dw2104_frontend_attach(struct dvb_usb_adapter * d)990 static int dw2104_frontend_attach(struct dvb_usb_adapter *d)
991 {
992 struct dvb_tuner_ops *tuner_ops = NULL;
993
994 if (demod_probe & 4) {
995 d->fe_adap[0].fe = dvb_attach(stv0900_attach, &dw2104a_stv0900_config,
996 &d->dev->i2c_adap, 0);
997 if (d->fe_adap[0].fe != NULL) {
998 if (dvb_attach(stb6100_attach, d->fe_adap[0].fe,
999 &dw2104a_stb6100_config,
1000 &d->dev->i2c_adap)) {
1001 tuner_ops = &d->fe_adap[0].fe->ops.tuner_ops;
1002 tuner_ops->set_frequency = stb6100_set_freq;
1003 tuner_ops->get_frequency = stb6100_get_freq;
1004 tuner_ops->set_bandwidth = stb6100_set_bandw;
1005 tuner_ops->get_bandwidth = stb6100_get_bandw;
1006 d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage;
1007 info("Attached STV0900+STB6100!\n");
1008 return 0;
1009 }
1010 }
1011 }
1012
1013 if (demod_probe & 2) {
1014 d->fe_adap[0].fe = dvb_attach(stv0900_attach, &dw2104_stv0900_config,
1015 &d->dev->i2c_adap, 0);
1016 if (d->fe_adap[0].fe != NULL) {
1017 if (dvb_attach(stv6110_attach, d->fe_adap[0].fe,
1018 &dw2104_stv6110_config,
1019 &d->dev->i2c_adap)) {
1020 d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage;
1021 info("Attached STV0900+STV6110A!\n");
1022 return 0;
1023 }
1024 }
1025 }
1026
1027 if (demod_probe & 1) {
1028 d->fe_adap[0].fe = dvb_attach(cx24116_attach, &dw2104_config,
1029 &d->dev->i2c_adap);
1030 if (d->fe_adap[0].fe != NULL) {
1031 d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage;
1032 info("Attached cx24116!\n");
1033 return 0;
1034 }
1035 }
1036
1037 d->fe_adap[0].fe = dvb_attach(ds3000_attach, &dw2104_ds3000_config,
1038 &d->dev->i2c_adap);
1039 if (d->fe_adap[0].fe != NULL) {
1040 d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage;
1041 info("Attached DS3000!\n");
1042 return 0;
1043 }
1044
1045 return -EIO;
1046 }
1047
1048 static struct dvb_usb_device_properties dw2102_properties;
1049 static struct dvb_usb_device_properties dw2104_properties;
1050 static struct dvb_usb_device_properties s6x0_properties;
1051
dw2102_frontend_attach(struct dvb_usb_adapter * d)1052 static int dw2102_frontend_attach(struct dvb_usb_adapter *d)
1053 {
1054 if (dw2102_properties.i2c_algo == &dw2102_serit_i2c_algo) {
1055 /*dw2102_properties.adapter->tuner_attach = NULL;*/
1056 d->fe_adap[0].fe = dvb_attach(si21xx_attach, &serit_sp1511lhb_config,
1057 &d->dev->i2c_adap);
1058 if (d->fe_adap[0].fe != NULL) {
1059 d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage;
1060 info("Attached si21xx!\n");
1061 return 0;
1062 }
1063 }
1064
1065 if (dw2102_properties.i2c_algo == &dw2102_earda_i2c_algo) {
1066 d->fe_adap[0].fe = dvb_attach(stv0288_attach, &earda_config,
1067 &d->dev->i2c_adap);
1068 if (d->fe_adap[0].fe != NULL) {
1069 if (dvb_attach(stb6000_attach, d->fe_adap[0].fe, 0x61,
1070 &d->dev->i2c_adap)) {
1071 d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage;
1072 info("Attached stv0288!\n");
1073 return 0;
1074 }
1075 }
1076 }
1077
1078 if (dw2102_properties.i2c_algo == &dw2102_i2c_algo) {
1079 /*dw2102_properties.adapter->tuner_attach = dw2102_tuner_attach;*/
1080 d->fe_adap[0].fe = dvb_attach(stv0299_attach, &sharp_z0194a_config,
1081 &d->dev->i2c_adap);
1082 if (d->fe_adap[0].fe != NULL) {
1083 d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage;
1084 info("Attached stv0299!\n");
1085 return 0;
1086 }
1087 }
1088 return -EIO;
1089 }
1090
dw3101_frontend_attach(struct dvb_usb_adapter * d)1091 static int dw3101_frontend_attach(struct dvb_usb_adapter *d)
1092 {
1093 d->fe_adap[0].fe = dvb_attach(tda10023_attach, &dw3101_tda10023_config,
1094 &d->dev->i2c_adap, 0x48);
1095 if (d->fe_adap[0].fe != NULL) {
1096 info("Attached tda10023!\n");
1097 return 0;
1098 }
1099 return -EIO;
1100 }
1101
zl100313_frontend_attach(struct dvb_usb_adapter * d)1102 static int zl100313_frontend_attach(struct dvb_usb_adapter *d)
1103 {
1104 d->fe_adap[0].fe = dvb_attach(mt312_attach, &zl313_config,
1105 &d->dev->i2c_adap);
1106 if (d->fe_adap[0].fe != NULL) {
1107 if (dvb_attach(zl10039_attach, d->fe_adap[0].fe, 0x60,
1108 &d->dev->i2c_adap)) {
1109 d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage;
1110 info("Attached zl100313+zl10039!\n");
1111 return 0;
1112 }
1113 }
1114
1115 return -EIO;
1116 }
1117
stv0288_frontend_attach(struct dvb_usb_adapter * d)1118 static int stv0288_frontend_attach(struct dvb_usb_adapter *d)
1119 {
1120 u8 obuf[] = {7, 1};
1121
1122 d->fe_adap[0].fe = dvb_attach(stv0288_attach, &earda_config,
1123 &d->dev->i2c_adap);
1124
1125 if (d->fe_adap[0].fe == NULL)
1126 return -EIO;
1127
1128 if (NULL == dvb_attach(stb6000_attach, d->fe_adap[0].fe, 0x61, &d->dev->i2c_adap))
1129 return -EIO;
1130
1131 d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage;
1132
1133 dw210x_op_rw(d->dev->udev, 0x8a, 0, 0, obuf, 2, DW210X_WRITE_MSG);
1134
1135 info("Attached stv0288+stb6000!\n");
1136
1137 return 0;
1138
1139 }
1140
ds3000_frontend_attach(struct dvb_usb_adapter * d)1141 static int ds3000_frontend_attach(struct dvb_usb_adapter *d)
1142 {
1143 struct s6x0_state *st = (struct s6x0_state *)d->dev->priv;
1144 u8 obuf[] = {7, 1};
1145
1146 d->fe_adap[0].fe = dvb_attach(ds3000_attach, &dw2104_ds3000_config,
1147 &d->dev->i2c_adap);
1148
1149 if (d->fe_adap[0].fe == NULL)
1150 return -EIO;
1151
1152 st->old_set_voltage = d->fe_adap[0].fe->ops.set_voltage;
1153 d->fe_adap[0].fe->ops.set_voltage = s660_set_voltage;
1154
1155 dw210x_op_rw(d->dev->udev, 0x8a, 0, 0, obuf, 2, DW210X_WRITE_MSG);
1156
1157 info("Attached ds3000+ds2020!\n");
1158
1159 return 0;
1160 }
1161
prof_7500_frontend_attach(struct dvb_usb_adapter * d)1162 static int prof_7500_frontend_attach(struct dvb_usb_adapter *d)
1163 {
1164 u8 obuf[] = {7, 1};
1165
1166 d->fe_adap[0].fe = dvb_attach(stv0900_attach, &prof_7500_stv0900_config,
1167 &d->dev->i2c_adap, 0);
1168 if (d->fe_adap[0].fe == NULL)
1169 return -EIO;
1170
1171 d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage;
1172
1173 dw210x_op_rw(d->dev->udev, 0x8a, 0, 0, obuf, 2, DW210X_WRITE_MSG);
1174
1175 info("Attached STV0900+STB6100A!\n");
1176
1177 return 0;
1178 }
1179
su3000_frontend_attach(struct dvb_usb_adapter * d)1180 static int su3000_frontend_attach(struct dvb_usb_adapter *d)
1181 {
1182 u8 obuf[3] = { 0xe, 0x80, 0 };
1183 u8 ibuf[] = { 0 };
1184
1185 if (dvb_usb_generic_rw(d->dev, obuf, 3, ibuf, 1, 0) < 0)
1186 err("command 0x0e transfer failed.");
1187
1188 obuf[0] = 0xe;
1189 obuf[1] = 0x83;
1190 obuf[2] = 0;
1191
1192 if (dvb_usb_generic_rw(d->dev, obuf, 3, ibuf, 1, 0) < 0)
1193 err("command 0x0e transfer failed.");
1194
1195 obuf[0] = 0xe;
1196 obuf[1] = 0x83;
1197 obuf[2] = 1;
1198
1199 if (dvb_usb_generic_rw(d->dev, obuf, 3, ibuf, 1, 0) < 0)
1200 err("command 0x0e transfer failed.");
1201
1202 obuf[0] = 0x51;
1203
1204 if (dvb_usb_generic_rw(d->dev, obuf, 1, ibuf, 1, 0) < 0)
1205 err("command 0x51 transfer failed.");
1206
1207 d->fe_adap[0].fe = dvb_attach(ds3000_attach, &su3000_ds3000_config,
1208 &d->dev->i2c_adap);
1209 if (d->fe_adap[0].fe == NULL)
1210 return -EIO;
1211
1212 info("Attached DS3000!\n");
1213
1214 return 0;
1215 }
1216
dw2102_tuner_attach(struct dvb_usb_adapter * adap)1217 static int dw2102_tuner_attach(struct dvb_usb_adapter *adap)
1218 {
1219 dvb_attach(dvb_pll_attach, adap->fe_adap[0].fe, 0x60,
1220 &adap->dev->i2c_adap, DVB_PLL_OPERA1);
1221 return 0;
1222 }
1223
dw3101_tuner_attach(struct dvb_usb_adapter * adap)1224 static int dw3101_tuner_attach(struct dvb_usb_adapter *adap)
1225 {
1226 dvb_attach(dvb_pll_attach, adap->fe_adap[0].fe, 0x60,
1227 &adap->dev->i2c_adap, DVB_PLL_TUA6034);
1228
1229 return 0;
1230 }
1231
1232 static struct rc_map_table rc_map_dw210x_table[] = {
1233 { 0xf80a, KEY_POWER2 }, /*power*/
1234 { 0xf80c, KEY_MUTE }, /*mute*/
1235 { 0xf811, KEY_1 },
1236 { 0xf812, KEY_2 },
1237 { 0xf813, KEY_3 },
1238 { 0xf814, KEY_4 },
1239 { 0xf815, KEY_5 },
1240 { 0xf816, KEY_6 },
1241 { 0xf817, KEY_7 },
1242 { 0xf818, KEY_8 },
1243 { 0xf819, KEY_9 },
1244 { 0xf810, KEY_0 },
1245 { 0xf81c, KEY_CHANNELUP }, /*ch+*/
1246 { 0xf80f, KEY_CHANNELDOWN }, /*ch-*/
1247 { 0xf81a, KEY_VOLUMEUP }, /*vol+*/
1248 { 0xf80e, KEY_VOLUMEDOWN }, /*vol-*/
1249 { 0xf804, KEY_RECORD }, /*rec*/
1250 { 0xf809, KEY_FAVORITES }, /*fav*/
1251 { 0xf808, KEY_REWIND }, /*rewind*/
1252 { 0xf807, KEY_FASTFORWARD }, /*fast*/
1253 { 0xf80b, KEY_PAUSE }, /*pause*/
1254 { 0xf802, KEY_ESC }, /*cancel*/
1255 { 0xf803, KEY_TAB }, /*tab*/
1256 { 0xf800, KEY_UP }, /*up*/
1257 { 0xf81f, KEY_OK }, /*ok*/
1258 { 0xf801, KEY_DOWN }, /*down*/
1259 { 0xf805, KEY_CAMERA }, /*cap*/
1260 { 0xf806, KEY_STOP }, /*stop*/
1261 { 0xf840, KEY_ZOOM }, /*full*/
1262 { 0xf81e, KEY_TV }, /*tvmode*/
1263 { 0xf81b, KEY_LAST }, /*recall*/
1264 };
1265
1266 static struct rc_map_table rc_map_tevii_table[] = {
1267 { 0xf80a, KEY_POWER },
1268 { 0xf80c, KEY_MUTE },
1269 { 0xf811, KEY_1 },
1270 { 0xf812, KEY_2 },
1271 { 0xf813, KEY_3 },
1272 { 0xf814, KEY_4 },
1273 { 0xf815, KEY_5 },
1274 { 0xf816, KEY_6 },
1275 { 0xf817, KEY_7 },
1276 { 0xf818, KEY_8 },
1277 { 0xf819, KEY_9 },
1278 { 0xf810, KEY_0 },
1279 { 0xf81c, KEY_MENU },
1280 { 0xf80f, KEY_VOLUMEDOWN },
1281 { 0xf81a, KEY_LAST },
1282 { 0xf80e, KEY_OPEN },
1283 { 0xf804, KEY_RECORD },
1284 { 0xf809, KEY_VOLUMEUP },
1285 { 0xf808, KEY_CHANNELUP },
1286 { 0xf807, KEY_PVR },
1287 { 0xf80b, KEY_TIME },
1288 { 0xf802, KEY_RIGHT },
1289 { 0xf803, KEY_LEFT },
1290 { 0xf800, KEY_UP },
1291 { 0xf81f, KEY_OK },
1292 { 0xf801, KEY_DOWN },
1293 { 0xf805, KEY_TUNER },
1294 { 0xf806, KEY_CHANNELDOWN },
1295 { 0xf840, KEY_PLAYPAUSE },
1296 { 0xf81e, KEY_REWIND },
1297 { 0xf81b, KEY_FAVORITES },
1298 { 0xf81d, KEY_BACK },
1299 { 0xf84d, KEY_FASTFORWARD },
1300 { 0xf844, KEY_EPG },
1301 { 0xf84c, KEY_INFO },
1302 { 0xf841, KEY_AB },
1303 { 0xf843, KEY_AUDIO },
1304 { 0xf845, KEY_SUBTITLE },
1305 { 0xf84a, KEY_LIST },
1306 { 0xf846, KEY_F1 },
1307 { 0xf847, KEY_F2 },
1308 { 0xf85e, KEY_F3 },
1309 { 0xf85c, KEY_F4 },
1310 { 0xf852, KEY_F5 },
1311 { 0xf85a, KEY_F6 },
1312 { 0xf856, KEY_MODE },
1313 { 0xf858, KEY_SWITCHVIDEOMODE },
1314 };
1315
1316 static struct rc_map_table rc_map_tbs_table[] = {
1317 { 0xf884, KEY_POWER },
1318 { 0xf894, KEY_MUTE },
1319 { 0xf887, KEY_1 },
1320 { 0xf886, KEY_2 },
1321 { 0xf885, KEY_3 },
1322 { 0xf88b, KEY_4 },
1323 { 0xf88a, KEY_5 },
1324 { 0xf889, KEY_6 },
1325 { 0xf88f, KEY_7 },
1326 { 0xf88e, KEY_8 },
1327 { 0xf88d, KEY_9 },
1328 { 0xf892, KEY_0 },
1329 { 0xf896, KEY_CHANNELUP },
1330 { 0xf891, KEY_CHANNELDOWN },
1331 { 0xf893, KEY_VOLUMEUP },
1332 { 0xf88c, KEY_VOLUMEDOWN },
1333 { 0xf883, KEY_RECORD },
1334 { 0xf898, KEY_PAUSE },
1335 { 0xf899, KEY_OK },
1336 { 0xf89a, KEY_SHUFFLE },
1337 { 0xf881, KEY_UP },
1338 { 0xf890, KEY_LEFT },
1339 { 0xf882, KEY_RIGHT },
1340 { 0xf888, KEY_DOWN },
1341 { 0xf895, KEY_FAVORITES },
1342 { 0xf897, KEY_SUBTITLE },
1343 { 0xf89d, KEY_ZOOM },
1344 { 0xf89f, KEY_EXIT },
1345 { 0xf89e, KEY_MENU },
1346 { 0xf89c, KEY_EPG },
1347 { 0xf880, KEY_PREVIOUS },
1348 { 0xf89b, KEY_MODE }
1349 };
1350
1351 static struct rc_map_table rc_map_su3000_table[] = {
1352 { 0x25, KEY_POWER }, /* right-bottom Red */
1353 { 0x0a, KEY_MUTE }, /* -/-- */
1354 { 0x01, KEY_1 },
1355 { 0x02, KEY_2 },
1356 { 0x03, KEY_3 },
1357 { 0x04, KEY_4 },
1358 { 0x05, KEY_5 },
1359 { 0x06, KEY_6 },
1360 { 0x07, KEY_7 },
1361 { 0x08, KEY_8 },
1362 { 0x09, KEY_9 },
1363 { 0x00, KEY_0 },
1364 { 0x20, KEY_UP }, /* CH+ */
1365 { 0x21, KEY_DOWN }, /* CH+ */
1366 { 0x12, KEY_VOLUMEUP }, /* Brightness Up */
1367 { 0x13, KEY_VOLUMEDOWN },/* Brightness Down */
1368 { 0x1f, KEY_RECORD },
1369 { 0x17, KEY_PLAY },
1370 { 0x16, KEY_PAUSE },
1371 { 0x0b, KEY_STOP },
1372 { 0x27, KEY_FASTFORWARD },/* >> */
1373 { 0x26, KEY_REWIND }, /* << */
1374 { 0x0d, KEY_OK }, /* Mute */
1375 { 0x11, KEY_LEFT }, /* VOL- */
1376 { 0x10, KEY_RIGHT }, /* VOL+ */
1377 { 0x29, KEY_BACK }, /* button under 9 */
1378 { 0x2c, KEY_MENU }, /* TTX */
1379 { 0x2b, KEY_EPG }, /* EPG */
1380 { 0x1e, KEY_RED }, /* OSD */
1381 { 0x0e, KEY_GREEN }, /* Window */
1382 { 0x2d, KEY_YELLOW }, /* button under << */
1383 { 0x0f, KEY_BLUE }, /* bottom yellow button */
1384 { 0x14, KEY_AUDIO }, /* Snapshot */
1385 { 0x38, KEY_TV }, /* TV/Radio */
1386 { 0x0c, KEY_ESC } /* upper Red button */
1387 };
1388
1389 static struct rc_map_dvb_usb_table_table keys_tables[] = {
1390 { rc_map_dw210x_table, ARRAY_SIZE(rc_map_dw210x_table) },
1391 { rc_map_tevii_table, ARRAY_SIZE(rc_map_tevii_table) },
1392 { rc_map_tbs_table, ARRAY_SIZE(rc_map_tbs_table) },
1393 { rc_map_su3000_table, ARRAY_SIZE(rc_map_su3000_table) },
1394 };
1395
dw2102_rc_query(struct dvb_usb_device * d,u32 * event,int * state)1396 static int dw2102_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
1397 {
1398 struct rc_map_table *keymap = d->props.rc.legacy.rc_map_table;
1399 int keymap_size = d->props.rc.legacy.rc_map_size;
1400 u8 key[2];
1401 struct i2c_msg msg = {
1402 .addr = DW2102_RC_QUERY,
1403 .flags = I2C_M_RD,
1404 .buf = key,
1405 .len = 2
1406 };
1407 int i;
1408 /* override keymap */
1409 if ((ir_keymap > 0) && (ir_keymap <= ARRAY_SIZE(keys_tables))) {
1410 keymap = keys_tables[ir_keymap - 1].rc_keys ;
1411 keymap_size = keys_tables[ir_keymap - 1].rc_keys_size;
1412 } else if (ir_keymap > ARRAY_SIZE(keys_tables))
1413 return 0; /* none */
1414
1415 *state = REMOTE_NO_KEY_PRESSED;
1416 if (d->props.i2c_algo->master_xfer(&d->i2c_adap, &msg, 1) == 1) {
1417 for (i = 0; i < keymap_size ; i++) {
1418 if (rc5_data(&keymap[i]) == msg.buf[0]) {
1419 *state = REMOTE_KEY_PRESSED;
1420 *event = keymap[i].keycode;
1421 break;
1422 }
1423
1424 }
1425
1426 if ((*state) == REMOTE_KEY_PRESSED)
1427 deb_rc("%s: found rc key: %x, %x, event: %x\n",
1428 __func__, key[0], key[1], (*event));
1429 else if (key[0] != 0xff)
1430 deb_rc("%s: unknown rc key: %x, %x\n",
1431 __func__, key[0], key[1]);
1432
1433 }
1434
1435 return 0;
1436 }
1437
1438 enum dw2102_table_entry {
1439 CYPRESS_DW2102,
1440 CYPRESS_DW2101,
1441 CYPRESS_DW2104,
1442 TEVII_S650,
1443 TERRATEC_CINERGY_S,
1444 CYPRESS_DW3101,
1445 TEVII_S630,
1446 PROF_1100,
1447 TEVII_S660,
1448 PROF_7500,
1449 GENIATECH_SU3000,
1450 TERRATEC_CINERGY_S2,
1451 TEVII_S480_1,
1452 TEVII_S480_2,
1453 X3M_SPC1400HD,
1454 };
1455
1456 static struct usb_device_id dw2102_table[] = {
1457 [CYPRESS_DW2102] = {USB_DEVICE(USB_VID_CYPRESS, USB_PID_DW2102)},
1458 [CYPRESS_DW2101] = {USB_DEVICE(USB_VID_CYPRESS, 0x2101)},
1459 [CYPRESS_DW2104] = {USB_DEVICE(USB_VID_CYPRESS, USB_PID_DW2104)},
1460 [TEVII_S650] = {USB_DEVICE(0x9022, USB_PID_TEVII_S650)},
1461 [TERRATEC_CINERGY_S] = {USB_DEVICE(USB_VID_TERRATEC, USB_PID_CINERGY_S)},
1462 [CYPRESS_DW3101] = {USB_DEVICE(USB_VID_CYPRESS, USB_PID_DW3101)},
1463 [TEVII_S630] = {USB_DEVICE(0x9022, USB_PID_TEVII_S630)},
1464 [PROF_1100] = {USB_DEVICE(0x3011, USB_PID_PROF_1100)},
1465 [TEVII_S660] = {USB_DEVICE(0x9022, USB_PID_TEVII_S660)},
1466 [PROF_7500] = {USB_DEVICE(0x3034, 0x7500)},
1467 [GENIATECH_SU3000] = {USB_DEVICE(0x1f4d, 0x3000)},
1468 [TERRATEC_CINERGY_S2] = {USB_DEVICE(USB_VID_TERRATEC, 0x00a8)},
1469 [TEVII_S480_1] = {USB_DEVICE(0x9022, USB_PID_TEVII_S480_1)},
1470 [TEVII_S480_2] = {USB_DEVICE(0x9022, USB_PID_TEVII_S480_2)},
1471 [X3M_SPC1400HD] = {USB_DEVICE(0x1f4d, 0x3100)},
1472 { }
1473 };
1474
1475 MODULE_DEVICE_TABLE(usb, dw2102_table);
1476
dw2102_load_firmware(struct usb_device * dev,const struct firmware * frmwr)1477 static int dw2102_load_firmware(struct usb_device *dev,
1478 const struct firmware *frmwr)
1479 {
1480 u8 *b, *p;
1481 int ret = 0, i;
1482 u8 reset;
1483 u8 reset16[] = {0, 0, 0, 0, 0, 0, 0};
1484 const struct firmware *fw;
1485 const char *fw_2101 = "dvb-usb-dw2101.fw";
1486
1487 switch (dev->descriptor.idProduct) {
1488 case 0x2101:
1489 ret = request_firmware(&fw, fw_2101, &dev->dev);
1490 if (ret != 0) {
1491 err(err_str, fw_2101);
1492 return ret;
1493 }
1494 break;
1495 default:
1496 fw = frmwr;
1497 break;
1498 }
1499 info("start downloading DW210X firmware");
1500 p = kmalloc(fw->size, GFP_KERNEL);
1501 reset = 1;
1502 /*stop the CPU*/
1503 dw210x_op_rw(dev, 0xa0, 0x7f92, 0, &reset, 1, DW210X_WRITE_MSG);
1504 dw210x_op_rw(dev, 0xa0, 0xe600, 0, &reset, 1, DW210X_WRITE_MSG);
1505
1506 if (p != NULL) {
1507 memcpy(p, fw->data, fw->size);
1508 for (i = 0; i < fw->size; i += 0x40) {
1509 b = (u8 *) p + i;
1510 if (dw210x_op_rw(dev, 0xa0, i, 0, b , 0x40,
1511 DW210X_WRITE_MSG) != 0x40) {
1512 err("error while transferring firmware");
1513 ret = -EINVAL;
1514 break;
1515 }
1516 }
1517 /* restart the CPU */
1518 reset = 0;
1519 if (ret || dw210x_op_rw(dev, 0xa0, 0x7f92, 0, &reset, 1,
1520 DW210X_WRITE_MSG) != 1) {
1521 err("could not restart the USB controller CPU.");
1522 ret = -EINVAL;
1523 }
1524 if (ret || dw210x_op_rw(dev, 0xa0, 0xe600, 0, &reset, 1,
1525 DW210X_WRITE_MSG) != 1) {
1526 err("could not restart the USB controller CPU.");
1527 ret = -EINVAL;
1528 }
1529 /* init registers */
1530 switch (dev->descriptor.idProduct) {
1531 case USB_PID_TEVII_S650:
1532 dw2104_properties.rc.legacy.rc_map_table = rc_map_tevii_table;
1533 dw2104_properties.rc.legacy.rc_map_size =
1534 ARRAY_SIZE(rc_map_tevii_table);
1535 case USB_PID_DW2104:
1536 reset = 1;
1537 dw210x_op_rw(dev, 0xc4, 0x0000, 0, &reset, 1,
1538 DW210X_WRITE_MSG);
1539 /* break omitted intentionally */
1540 case USB_PID_DW3101:
1541 reset = 0;
1542 dw210x_op_rw(dev, 0xbf, 0x0040, 0, &reset, 0,
1543 DW210X_WRITE_MSG);
1544 break;
1545 case USB_PID_CINERGY_S:
1546 case USB_PID_DW2102:
1547 dw210x_op_rw(dev, 0xbf, 0x0040, 0, &reset, 0,
1548 DW210X_WRITE_MSG);
1549 dw210x_op_rw(dev, 0xb9, 0x0000, 0, &reset16[0], 2,
1550 DW210X_READ_MSG);
1551 /* check STV0299 frontend */
1552 dw210x_op_rw(dev, 0xb5, 0, 0, &reset16[0], 2,
1553 DW210X_READ_MSG);
1554 if ((reset16[0] == 0xa1) || (reset16[0] == 0x80)) {
1555 dw2102_properties.i2c_algo = &dw2102_i2c_algo;
1556 dw2102_properties.adapter->fe[0].tuner_attach = &dw2102_tuner_attach;
1557 break;
1558 } else {
1559 /* check STV0288 frontend */
1560 reset16[0] = 0xd0;
1561 reset16[1] = 1;
1562 reset16[2] = 0;
1563 dw210x_op_rw(dev, 0xc2, 0, 0, &reset16[0], 3,
1564 DW210X_WRITE_MSG);
1565 dw210x_op_rw(dev, 0xc3, 0xd1, 0, &reset16[0], 3,
1566 DW210X_READ_MSG);
1567 if (reset16[2] == 0x11) {
1568 dw2102_properties.i2c_algo = &dw2102_earda_i2c_algo;
1569 break;
1570 }
1571 }
1572 case 0x2101:
1573 dw210x_op_rw(dev, 0xbc, 0x0030, 0, &reset16[0], 2,
1574 DW210X_READ_MSG);
1575 dw210x_op_rw(dev, 0xba, 0x0000, 0, &reset16[0], 7,
1576 DW210X_READ_MSG);
1577 dw210x_op_rw(dev, 0xba, 0x0000, 0, &reset16[0], 7,
1578 DW210X_READ_MSG);
1579 dw210x_op_rw(dev, 0xb9, 0x0000, 0, &reset16[0], 2,
1580 DW210X_READ_MSG);
1581 break;
1582 }
1583
1584 msleep(100);
1585 kfree(p);
1586 }
1587 return ret;
1588 }
1589
1590 static struct dvb_usb_device_properties dw2102_properties = {
1591 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1592 .usb_ctrl = DEVICE_SPECIFIC,
1593 .firmware = "dvb-usb-dw2102.fw",
1594 .no_reconnect = 1,
1595
1596 .i2c_algo = &dw2102_serit_i2c_algo,
1597
1598 .rc.legacy = {
1599 .rc_map_table = rc_map_dw210x_table,
1600 .rc_map_size = ARRAY_SIZE(rc_map_dw210x_table),
1601 .rc_interval = 150,
1602 .rc_query = dw2102_rc_query,
1603 },
1604
1605 .generic_bulk_ctrl_endpoint = 0x81,
1606 /* parameter for the MPEG2-data transfer */
1607 .num_adapters = 1,
1608 .download_firmware = dw2102_load_firmware,
1609 .read_mac_address = dw210x_read_mac_address,
1610 .adapter = {
1611 {
1612 .num_frontends = 1,
1613 .fe = {{
1614 .frontend_attach = dw2102_frontend_attach,
1615 .stream = {
1616 .type = USB_BULK,
1617 .count = 8,
1618 .endpoint = 0x82,
1619 .u = {
1620 .bulk = {
1621 .buffersize = 4096,
1622 }
1623 }
1624 },
1625 }},
1626 }
1627 },
1628 .num_device_descs = 3,
1629 .devices = {
1630 {"DVBWorld DVB-S 2102 USB2.0",
1631 {&dw2102_table[CYPRESS_DW2102], NULL},
1632 {NULL},
1633 },
1634 {"DVBWorld DVB-S 2101 USB2.0",
1635 {&dw2102_table[CYPRESS_DW2101], NULL},
1636 {NULL},
1637 },
1638 {"TerraTec Cinergy S USB",
1639 {&dw2102_table[TERRATEC_CINERGY_S], NULL},
1640 {NULL},
1641 },
1642 }
1643 };
1644
1645 static struct dvb_usb_device_properties dw2104_properties = {
1646 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1647 .usb_ctrl = DEVICE_SPECIFIC,
1648 .firmware = "dvb-usb-dw2104.fw",
1649 .no_reconnect = 1,
1650
1651 .i2c_algo = &dw2104_i2c_algo,
1652 .rc.legacy = {
1653 .rc_map_table = rc_map_dw210x_table,
1654 .rc_map_size = ARRAY_SIZE(rc_map_dw210x_table),
1655 .rc_interval = 150,
1656 .rc_query = dw2102_rc_query,
1657 },
1658
1659 .generic_bulk_ctrl_endpoint = 0x81,
1660 /* parameter for the MPEG2-data transfer */
1661 .num_adapters = 1,
1662 .download_firmware = dw2102_load_firmware,
1663 .read_mac_address = dw210x_read_mac_address,
1664 .adapter = {
1665 {
1666 .num_frontends = 1,
1667 .fe = {{
1668 .frontend_attach = dw2104_frontend_attach,
1669 .stream = {
1670 .type = USB_BULK,
1671 .count = 8,
1672 .endpoint = 0x82,
1673 .u = {
1674 .bulk = {
1675 .buffersize = 4096,
1676 }
1677 }
1678 },
1679 }},
1680 }
1681 },
1682 .num_device_descs = 2,
1683 .devices = {
1684 { "DVBWorld DW2104 USB2.0",
1685 {&dw2102_table[CYPRESS_DW2104], NULL},
1686 {NULL},
1687 },
1688 { "TeVii S650 USB2.0",
1689 {&dw2102_table[TEVII_S650], NULL},
1690 {NULL},
1691 },
1692 }
1693 };
1694
1695 static struct dvb_usb_device_properties dw3101_properties = {
1696 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1697 .usb_ctrl = DEVICE_SPECIFIC,
1698 .firmware = "dvb-usb-dw3101.fw",
1699 .no_reconnect = 1,
1700
1701 .i2c_algo = &dw3101_i2c_algo,
1702 .rc.legacy = {
1703 .rc_map_table = rc_map_dw210x_table,
1704 .rc_map_size = ARRAY_SIZE(rc_map_dw210x_table),
1705 .rc_interval = 150,
1706 .rc_query = dw2102_rc_query,
1707 },
1708
1709 .generic_bulk_ctrl_endpoint = 0x81,
1710 /* parameter for the MPEG2-data transfer */
1711 .num_adapters = 1,
1712 .download_firmware = dw2102_load_firmware,
1713 .read_mac_address = dw210x_read_mac_address,
1714 .adapter = {
1715 {
1716 .num_frontends = 1,
1717 .fe = {{
1718 .frontend_attach = dw3101_frontend_attach,
1719 .tuner_attach = dw3101_tuner_attach,
1720 .stream = {
1721 .type = USB_BULK,
1722 .count = 8,
1723 .endpoint = 0x82,
1724 .u = {
1725 .bulk = {
1726 .buffersize = 4096,
1727 }
1728 }
1729 },
1730 }},
1731 }
1732 },
1733 .num_device_descs = 1,
1734 .devices = {
1735 { "DVBWorld DVB-C 3101 USB2.0",
1736 {&dw2102_table[CYPRESS_DW3101], NULL},
1737 {NULL},
1738 },
1739 }
1740 };
1741
1742 static struct dvb_usb_device_properties s6x0_properties = {
1743 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1744 .usb_ctrl = DEVICE_SPECIFIC,
1745 .size_of_priv = sizeof(struct s6x0_state),
1746 .firmware = "dvb-usb-s630.fw",
1747 .no_reconnect = 1,
1748
1749 .i2c_algo = &s6x0_i2c_algo,
1750 .rc.legacy = {
1751 .rc_map_table = rc_map_tevii_table,
1752 .rc_map_size = ARRAY_SIZE(rc_map_tevii_table),
1753 .rc_interval = 150,
1754 .rc_query = dw2102_rc_query,
1755 },
1756
1757 .generic_bulk_ctrl_endpoint = 0x81,
1758 .num_adapters = 1,
1759 .download_firmware = dw2102_load_firmware,
1760 .read_mac_address = s6x0_read_mac_address,
1761 .adapter = {
1762 {
1763 .num_frontends = 1,
1764 .fe = {{
1765 .frontend_attach = zl100313_frontend_attach,
1766 .stream = {
1767 .type = USB_BULK,
1768 .count = 8,
1769 .endpoint = 0x82,
1770 .u = {
1771 .bulk = {
1772 .buffersize = 4096,
1773 }
1774 }
1775 },
1776 }},
1777 }
1778 },
1779 .num_device_descs = 1,
1780 .devices = {
1781 {"TeVii S630 USB",
1782 {&dw2102_table[TEVII_S630], NULL},
1783 {NULL},
1784 },
1785 }
1786 };
1787
1788 struct dvb_usb_device_properties *p1100;
1789 static struct dvb_usb_device_description d1100 = {
1790 "Prof 1100 USB ",
1791 {&dw2102_table[PROF_1100], NULL},
1792 {NULL},
1793 };
1794
1795 struct dvb_usb_device_properties *s660;
1796 static struct dvb_usb_device_description d660 = {
1797 "TeVii S660 USB",
1798 {&dw2102_table[TEVII_S660], NULL},
1799 {NULL},
1800 };
1801
1802 static struct dvb_usb_device_description d480_1 = {
1803 "TeVii S480.1 USB",
1804 {&dw2102_table[TEVII_S480_1], NULL},
1805 {NULL},
1806 };
1807
1808 static struct dvb_usb_device_description d480_2 = {
1809 "TeVii S480.2 USB",
1810 {&dw2102_table[TEVII_S480_2], NULL},
1811 {NULL},
1812 };
1813
1814 struct dvb_usb_device_properties *p7500;
1815 static struct dvb_usb_device_description d7500 = {
1816 "Prof 7500 USB DVB-S2",
1817 {&dw2102_table[PROF_7500], NULL},
1818 {NULL},
1819 };
1820
1821 static struct dvb_usb_device_properties su3000_properties = {
1822 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1823 .usb_ctrl = DEVICE_SPECIFIC,
1824 .size_of_priv = sizeof(struct su3000_state),
1825 .power_ctrl = su3000_power_ctrl,
1826 .num_adapters = 1,
1827 .identify_state = su3000_identify_state,
1828 .i2c_algo = &su3000_i2c_algo,
1829
1830 .rc.legacy = {
1831 .rc_map_table = rc_map_su3000_table,
1832 .rc_map_size = ARRAY_SIZE(rc_map_su3000_table),
1833 .rc_interval = 150,
1834 .rc_query = dw2102_rc_query,
1835 },
1836
1837 .read_mac_address = su3000_read_mac_address,
1838
1839 .generic_bulk_ctrl_endpoint = 0x01,
1840
1841 .adapter = {
1842 {
1843 .num_frontends = 1,
1844 .fe = {{
1845 .streaming_ctrl = su3000_streaming_ctrl,
1846 .frontend_attach = su3000_frontend_attach,
1847 .stream = {
1848 .type = USB_BULK,
1849 .count = 8,
1850 .endpoint = 0x82,
1851 .u = {
1852 .bulk = {
1853 .buffersize = 4096,
1854 }
1855 }
1856 }
1857 }},
1858 }
1859 },
1860 .num_device_descs = 3,
1861 .devices = {
1862 { "SU3000HD DVB-S USB2.0",
1863 { &dw2102_table[GENIATECH_SU3000], NULL },
1864 { NULL },
1865 },
1866 { "Terratec Cinergy S2 USB HD",
1867 { &dw2102_table[TERRATEC_CINERGY_S2], NULL },
1868 { NULL },
1869 },
1870 { "X3M TV SPC1400HD PCI",
1871 { &dw2102_table[X3M_SPC1400HD], NULL },
1872 { NULL },
1873 },
1874 }
1875 };
1876
dw2102_probe(struct usb_interface * intf,const struct usb_device_id * id)1877 static int dw2102_probe(struct usb_interface *intf,
1878 const struct usb_device_id *id)
1879 {
1880 p1100 = kmemdup(&s6x0_properties,
1881 sizeof(struct dvb_usb_device_properties), GFP_KERNEL);
1882 if (!p1100)
1883 return -ENOMEM;
1884 /* copy default structure */
1885 /* fill only different fields */
1886 p1100->firmware = "dvb-usb-p1100.fw";
1887 p1100->devices[0] = d1100;
1888 p1100->rc.legacy.rc_map_table = rc_map_tbs_table;
1889 p1100->rc.legacy.rc_map_size = ARRAY_SIZE(rc_map_tbs_table);
1890 p1100->adapter->fe[0].frontend_attach = stv0288_frontend_attach;
1891
1892 s660 = kmemdup(&s6x0_properties,
1893 sizeof(struct dvb_usb_device_properties), GFP_KERNEL);
1894 if (!s660) {
1895 kfree(p1100);
1896 return -ENOMEM;
1897 }
1898 s660->firmware = "dvb-usb-s660.fw";
1899 s660->num_device_descs = 3;
1900 s660->devices[0] = d660;
1901 s660->devices[1] = d480_1;
1902 s660->devices[2] = d480_2;
1903 s660->adapter->fe[0].frontend_attach = ds3000_frontend_attach;
1904
1905 p7500 = kmemdup(&s6x0_properties,
1906 sizeof(struct dvb_usb_device_properties), GFP_KERNEL);
1907 if (!p7500) {
1908 kfree(p1100);
1909 kfree(s660);
1910 return -ENOMEM;
1911 }
1912 p7500->firmware = "dvb-usb-p7500.fw";
1913 p7500->devices[0] = d7500;
1914 p7500->rc.legacy.rc_map_table = rc_map_tbs_table;
1915 p7500->rc.legacy.rc_map_size = ARRAY_SIZE(rc_map_tbs_table);
1916 p7500->adapter->fe[0].frontend_attach = prof_7500_frontend_attach;
1917
1918 if (0 == dvb_usb_device_init(intf, &dw2102_properties,
1919 THIS_MODULE, NULL, adapter_nr) ||
1920 0 == dvb_usb_device_init(intf, &dw2104_properties,
1921 THIS_MODULE, NULL, adapter_nr) ||
1922 0 == dvb_usb_device_init(intf, &dw3101_properties,
1923 THIS_MODULE, NULL, adapter_nr) ||
1924 0 == dvb_usb_device_init(intf, &s6x0_properties,
1925 THIS_MODULE, NULL, adapter_nr) ||
1926 0 == dvb_usb_device_init(intf, p1100,
1927 THIS_MODULE, NULL, adapter_nr) ||
1928 0 == dvb_usb_device_init(intf, s660,
1929 THIS_MODULE, NULL, adapter_nr) ||
1930 0 == dvb_usb_device_init(intf, p7500,
1931 THIS_MODULE, NULL, adapter_nr) ||
1932 0 == dvb_usb_device_init(intf, &su3000_properties,
1933 THIS_MODULE, NULL, adapter_nr))
1934 return 0;
1935
1936 return -ENODEV;
1937 }
1938
1939 static struct usb_driver dw2102_driver = {
1940 .name = "dw2102",
1941 .probe = dw2102_probe,
1942 .disconnect = dvb_usb_device_exit,
1943 .id_table = dw2102_table,
1944 };
1945
1946 module_usb_driver(dw2102_driver);
1947
1948 MODULE_AUTHOR("Igor M. Liplianin (c) liplianin@me.by");
1949 MODULE_DESCRIPTION("Driver for DVBWorld DVB-S 2101, 2102, DVB-S2 2104,"
1950 " DVB-C 3101 USB2.0,"
1951 " TeVii S600, S630, S650, S660, S480,"
1952 " Prof 1100, 7500 USB2.0,"
1953 " Geniatech SU3000 devices");
1954 MODULE_VERSION("0.1");
1955 MODULE_LICENSE("GPL");
1956