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, S421, S632
5 * Geniatech SU3000, T220 Cards
6 * Copyright (C) 2008-2012 Igor M. Liplianin (liplianin@me.by)
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.
12 * see Documentation/dvb/README.dvb-usb for more information
30 #include "stb6100_proc.h"
31 #include "m88rs2000.h"
35 /* Max transfer size done by I2C transfer functions */
36 #define MAX_XFER_SIZE 64
38 #ifndef USB_PID_DW2102
39 #define USB_PID_DW2102 0x2102
42 #ifndef USB_PID_DW2104
43 #define USB_PID_DW2104 0x2104
46 #ifndef USB_PID_DW3101
47 #define USB_PID_DW3101 0x3101
50 #ifndef USB_PID_CINERGY_S
51 #define USB_PID_CINERGY_S 0x0064
54 #ifndef USB_PID_TEVII_S630
55 #define USB_PID_TEVII_S630 0xd630
58 #ifndef USB_PID_TEVII_S650
59 #define USB_PID_TEVII_S650 0xd650
62 #ifndef USB_PID_TEVII_S660
63 #define USB_PID_TEVII_S660 0xd660
66 #ifndef USB_PID_TEVII_S480_1
67 #define USB_PID_TEVII_S480_1 0xd481
70 #ifndef USB_PID_TEVII_S480_2
71 #define USB_PID_TEVII_S480_2 0xd482
74 #ifndef USB_PID_PROF_1100
75 #define USB_PID_PROF_1100 0xb012
78 #ifndef USB_PID_TEVII_S421
79 #define USB_PID_TEVII_S421 0xd421
82 #ifndef USB_PID_TEVII_S632
83 #define USB_PID_TEVII_S632 0xd632
86 #ifndef USB_PID_GOTVIEW_SAT_HD
87 #define USB_PID_GOTVIEW_SAT_HD 0x5456
90 #define DW210X_READ_MSG 0
91 #define DW210X_WRITE_MSG 1
93 #define REG_1F_SYMBOLRATE_BYTE0 0x1f
94 #define REG_20_SYMBOLRATE_BYTE1 0x20
95 #define REG_21_SYMBOLRATE_BYTE2 0x21
97 #define DW2102_VOLTAGE_CTRL (0x1800)
98 #define SU3000_STREAM_CTRL (0x1900)
99 #define DW2102_RC_QUERY (0x1a00)
100 #define DW2102_LED_CTRL (0x1b00)
102 #define DW2101_FIRMWARE "dvb-usb-dw2101.fw"
103 #define DW2102_FIRMWARE "dvb-usb-dw2102.fw"
104 #define DW2104_FIRMWARE "dvb-usb-dw2104.fw"
105 #define DW3101_FIRMWARE "dvb-usb-dw3101.fw"
106 #define S630_FIRMWARE "dvb-usb-s630.fw"
107 #define S660_FIRMWARE "dvb-usb-s660.fw"
108 #define P1100_FIRMWARE "dvb-usb-p1100.fw"
109 #define P7500_FIRMWARE "dvb-usb-p7500.fw"
111 #define err_str "did not find the firmware file. (%s) " \
112 "Please see linux/Documentation/dvb/ for more details " \
113 "on firmware-problems."
115 struct su3000_state
{
120 int (*old_set_voltage
)(struct dvb_frontend
*f
, fe_sec_voltage_t v
);
124 static int dvb_usb_dw2102_debug
;
125 module_param_named(debug
, dvb_usb_dw2102_debug
, int, 0644);
126 MODULE_PARM_DESC(debug
, "set debugging level (1=info 2=xfer 4=rc(or-able))."
127 DVB_USB_DEBUG_STATUS
);
130 static int demod_probe
= 1;
131 module_param_named(demod
, demod_probe
, int, 0644);
132 MODULE_PARM_DESC(demod
, "demod to probe (1=cx24116 2=stv0903+stv6110 "
133 "4=stv0903+stb6100(or-able)).");
135 DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr
);
137 static int dw210x_op_rw(struct usb_device
*dev
, u8 request
, u16 value
,
138 u16 index
, u8
* data
, u16 len
, int flags
)
142 unsigned int pipe
= (flags
== DW210X_READ_MSG
) ?
143 usb_rcvctrlpipe(dev
, 0) : usb_sndctrlpipe(dev
, 0);
144 u8 request_type
= (flags
== DW210X_READ_MSG
) ? USB_DIR_IN
: USB_DIR_OUT
;
146 u8buf
= kmalloc(len
, GFP_KERNEL
);
151 if (flags
== DW210X_WRITE_MSG
)
152 memcpy(u8buf
, data
, len
);
153 ret
= usb_control_msg(dev
, pipe
, request
, request_type
| USB_TYPE_VENDOR
,
154 value
, index
, u8buf
, len
, 2000);
156 if (flags
== DW210X_READ_MSG
)
157 memcpy(data
, u8buf
, len
);
164 static int dw2102_i2c_transfer(struct i2c_adapter
*adap
, struct i2c_msg msg
[],
167 struct dvb_usb_device
*d
= i2c_get_adapdata(adap
);
169 u8 buf6
[] = {0x2c, 0x05, 0xc0, 0, 0, 0, 0};
174 if (mutex_lock_interruptible(&d
->i2c_mutex
) < 0)
179 /* read stv0299 register */
180 value
= msg
[0].buf
[0];/* register */
181 for (i
= 0; i
< msg
[1].len
; i
++) {
182 dw210x_op_rw(d
->udev
, 0xb5, value
+ i
, 0,
183 buf6
, 2, DW210X_READ_MSG
);
184 msg
[1].buf
[i
] = buf6
[0];
188 switch (msg
[0].addr
) {
190 /* write to stv0299 register */
192 buf6
[1] = msg
[0].buf
[0];
193 buf6
[2] = msg
[0].buf
[1];
194 dw210x_op_rw(d
->udev
, 0xb2, 0, 0,
195 buf6
, 3, DW210X_WRITE_MSG
);
198 if (msg
[0].flags
== 0) {
199 /* write to tuner pll */
203 buf6
[3] = msg
[0].buf
[0];
204 buf6
[4] = msg
[0].buf
[1];
205 buf6
[5] = msg
[0].buf
[2];
206 buf6
[6] = msg
[0].buf
[3];
207 dw210x_op_rw(d
->udev
, 0xb2, 0, 0,
208 buf6
, 7, DW210X_WRITE_MSG
);
210 /* read from tuner */
211 dw210x_op_rw(d
->udev
, 0xb5, 0, 0,
212 buf6
, 1, DW210X_READ_MSG
);
213 msg
[0].buf
[0] = buf6
[0];
216 case (DW2102_RC_QUERY
):
217 dw210x_op_rw(d
->udev
, 0xb8, 0, 0,
218 buf6
, 2, DW210X_READ_MSG
);
219 msg
[0].buf
[0] = buf6
[0];
220 msg
[0].buf
[1] = buf6
[1];
222 case (DW2102_VOLTAGE_CTRL
):
224 buf6
[1] = msg
[0].buf
[0];
225 dw210x_op_rw(d
->udev
, 0xb2, 0, 0,
226 buf6
, 2, DW210X_WRITE_MSG
);
233 mutex_unlock(&d
->i2c_mutex
);
237 static int dw2102_serit_i2c_transfer(struct i2c_adapter
*adap
,
238 struct i2c_msg msg
[], int num
)
240 struct dvb_usb_device
*d
= i2c_get_adapdata(adap
);
241 u8 buf6
[] = {0, 0, 0, 0, 0, 0, 0};
245 if (mutex_lock_interruptible(&d
->i2c_mutex
) < 0)
250 /* read si2109 register by number */
251 buf6
[0] = msg
[0].addr
<< 1;
252 buf6
[1] = msg
[0].len
;
253 buf6
[2] = msg
[0].buf
[0];
254 dw210x_op_rw(d
->udev
, 0xc2, 0, 0,
255 buf6
, msg
[0].len
+ 2, DW210X_WRITE_MSG
);
256 /* read si2109 register */
257 dw210x_op_rw(d
->udev
, 0xc3, 0xd0, 0,
258 buf6
, msg
[1].len
+ 2, DW210X_READ_MSG
);
259 memcpy(msg
[1].buf
, buf6
+ 2, msg
[1].len
);
263 switch (msg
[0].addr
) {
265 /* write to si2109 register */
266 buf6
[0] = msg
[0].addr
<< 1;
267 buf6
[1] = msg
[0].len
;
268 memcpy(buf6
+ 2, msg
[0].buf
, msg
[0].len
);
269 dw210x_op_rw(d
->udev
, 0xc2, 0, 0, buf6
,
270 msg
[0].len
+ 2, DW210X_WRITE_MSG
);
272 case(DW2102_RC_QUERY
):
273 dw210x_op_rw(d
->udev
, 0xb8, 0, 0,
274 buf6
, 2, DW210X_READ_MSG
);
275 msg
[0].buf
[0] = buf6
[0];
276 msg
[0].buf
[1] = buf6
[1];
278 case(DW2102_VOLTAGE_CTRL
):
280 buf6
[1] = msg
[0].buf
[0];
281 dw210x_op_rw(d
->udev
, 0xb2, 0, 0,
282 buf6
, 2, DW210X_WRITE_MSG
);
288 mutex_unlock(&d
->i2c_mutex
);
292 static int dw2102_earda_i2c_transfer(struct i2c_adapter
*adap
, struct i2c_msg msg
[], int num
)
294 struct dvb_usb_device
*d
= i2c_get_adapdata(adap
);
299 if (mutex_lock_interruptible(&d
->i2c_mutex
) < 0)
305 /* first write first register number */
306 u8 ibuf
[MAX_XFER_SIZE
], obuf
[3];
308 if (2 + msg
[1].len
> sizeof(ibuf
)) {
309 warn("i2c rd: len=%d is too big!\n",
315 obuf
[0] = msg
[0].addr
<< 1;
316 obuf
[1] = msg
[0].len
;
317 obuf
[2] = msg
[0].buf
[0];
318 dw210x_op_rw(d
->udev
, 0xc2, 0, 0,
319 obuf
, msg
[0].len
+ 2, DW210X_WRITE_MSG
);
320 /* second read registers */
321 dw210x_op_rw(d
->udev
, 0xc3, 0xd1 , 0,
322 ibuf
, msg
[1].len
+ 2, DW210X_READ_MSG
);
323 memcpy(msg
[1].buf
, ibuf
+ 2, msg
[1].len
);
328 switch (msg
[0].addr
) {
330 /* write to register */
331 u8 obuf
[MAX_XFER_SIZE
];
333 if (2 + msg
[0].len
> sizeof(obuf
)) {
334 warn("i2c wr: len=%d is too big!\n",
340 obuf
[0] = msg
[0].addr
<< 1;
341 obuf
[1] = msg
[0].len
;
342 memcpy(obuf
+ 2, msg
[0].buf
, msg
[0].len
);
343 dw210x_op_rw(d
->udev
, 0xc2, 0, 0,
344 obuf
, msg
[0].len
+ 2, DW210X_WRITE_MSG
);
349 u8 obuf
[MAX_XFER_SIZE
];
351 if (2 + msg
[0].len
> sizeof(obuf
)) {
352 warn("i2c wr: len=%d is too big!\n",
358 obuf
[0] = msg
[0].addr
<< 1;
359 obuf
[1] = msg
[0].len
;
360 memcpy(obuf
+ 2, msg
[0].buf
, msg
[0].len
);
361 dw210x_op_rw(d
->udev
, 0xc2, 0, 0,
362 obuf
, msg
[0].len
+ 2, DW210X_WRITE_MSG
);
365 case(DW2102_RC_QUERY
): {
367 dw210x_op_rw(d
->udev
, 0xb8, 0, 0,
368 ibuf
, 2, DW210X_READ_MSG
);
369 memcpy(msg
[0].buf
, ibuf
, 2);
372 case(DW2102_VOLTAGE_CTRL
): {
375 obuf
[1] = msg
[0].buf
[0];
376 dw210x_op_rw(d
->udev
, 0xb2, 0, 0,
377 obuf
, 2, DW210X_WRITE_MSG
);
387 mutex_unlock(&d
->i2c_mutex
);
391 static int dw2104_i2c_transfer(struct i2c_adapter
*adap
, struct i2c_msg msg
[], int num
)
393 struct dvb_usb_device
*d
= i2c_get_adapdata(adap
);
398 if (mutex_lock_interruptible(&d
->i2c_mutex
) < 0)
401 for (j
= 0; j
< num
; j
++) {
402 switch (msg
[j
].addr
) {
403 case(DW2102_RC_QUERY
): {
405 dw210x_op_rw(d
->udev
, 0xb8, 0, 0,
406 ibuf
, 2, DW210X_READ_MSG
);
407 memcpy(msg
[j
].buf
, ibuf
, 2);
410 case(DW2102_VOLTAGE_CTRL
): {
413 obuf
[1] = msg
[j
].buf
[0];
414 dw210x_op_rw(d
->udev
, 0xb2, 0, 0,
415 obuf
, 2, DW210X_WRITE_MSG
);
420 case 0x68: ds3000, stv0903
421 case 0x60: ts2020, stv6110, stb6100 */
423 if (msg
[j
].flags
== I2C_M_RD
) {
425 u8 ibuf
[MAX_XFER_SIZE
];
427 if (2 + msg
[j
].len
> sizeof(ibuf
)) {
428 warn("i2c rd: len=%d is too big!\n",
434 dw210x_op_rw(d
->udev
, 0xc3,
435 (msg
[j
].addr
<< 1) + 1, 0,
436 ibuf
, msg
[j
].len
+ 2,
438 memcpy(msg
[j
].buf
, ibuf
+ 2, msg
[j
].len
);
440 } else if (((msg
[j
].buf
[0] == 0xb0) &&
441 (msg
[j
].addr
== 0x68)) ||
442 ((msg
[j
].buf
[0] == 0xf7) &&
443 (msg
[j
].addr
== 0x55))) {
446 obuf
[0] = msg
[j
].addr
<< 1;
447 obuf
[1] = (msg
[j
].len
> 15 ? 17 : msg
[j
].len
);
448 obuf
[2] = msg
[j
].buf
[0];
449 len
= msg
[j
].len
- 1;
452 memcpy(obuf
+ 3, msg
[j
].buf
+ i
,
453 (len
> 16 ? 16 : len
));
454 dw210x_op_rw(d
->udev
, 0xc2, 0, 0,
455 obuf
, (len
> 16 ? 16 : len
) + 3,
461 /* write registers */
462 u8 obuf
[MAX_XFER_SIZE
];
464 if (2 + msg
[j
].len
> sizeof(obuf
)) {
465 warn("i2c wr: len=%d is too big!\n",
471 obuf
[0] = msg
[j
].addr
<< 1;
472 obuf
[1] = msg
[j
].len
;
473 memcpy(obuf
+ 2, msg
[j
].buf
, msg
[j
].len
);
474 dw210x_op_rw(d
->udev
, 0xc2, 0, 0,
475 obuf
, msg
[j
].len
+ 2,
486 mutex_unlock(&d
->i2c_mutex
);
490 static int dw3101_i2c_transfer(struct i2c_adapter
*adap
, struct i2c_msg msg
[],
493 struct dvb_usb_device
*d
= i2c_get_adapdata(adap
);
499 if (mutex_lock_interruptible(&d
->i2c_mutex
) < 0)
505 /* first write first register number */
506 u8 ibuf
[MAX_XFER_SIZE
], obuf
[3];
508 if (2 + msg
[1].len
> sizeof(ibuf
)) {
509 warn("i2c rd: len=%d is too big!\n",
514 obuf
[0] = msg
[0].addr
<< 1;
515 obuf
[1] = msg
[0].len
;
516 obuf
[2] = msg
[0].buf
[0];
517 dw210x_op_rw(d
->udev
, 0xc2, 0, 0,
518 obuf
, msg
[0].len
+ 2, DW210X_WRITE_MSG
);
519 /* second read registers */
520 dw210x_op_rw(d
->udev
, 0xc3, 0x19 , 0,
521 ibuf
, msg
[1].len
+ 2, DW210X_READ_MSG
);
522 memcpy(msg
[1].buf
, ibuf
+ 2, msg
[1].len
);
527 switch (msg
[0].addr
) {
530 /* write to register */
531 u8 obuf
[MAX_XFER_SIZE
];
533 if (2 + msg
[0].len
> sizeof(obuf
)) {
534 warn("i2c wr: len=%d is too big!\n",
539 obuf
[0] = msg
[0].addr
<< 1;
540 obuf
[1] = msg
[0].len
;
541 memcpy(obuf
+ 2, msg
[0].buf
, msg
[0].len
);
542 dw210x_op_rw(d
->udev
, 0xc2, 0, 0,
543 obuf
, msg
[0].len
+ 2, DW210X_WRITE_MSG
);
546 case(DW2102_RC_QUERY
): {
548 dw210x_op_rw(d
->udev
, 0xb8, 0, 0,
549 ibuf
, 2, DW210X_READ_MSG
);
550 memcpy(msg
[0].buf
, ibuf
, 2);
558 for (i
= 0; i
< num
; i
++) {
559 deb_xfer("%02x:%02x: %s ", i
, msg
[i
].addr
,
560 msg
[i
].flags
== 0 ? ">>>" : "<<<");
561 debug_dump(msg
[i
].buf
, msg
[i
].len
, deb_xfer
);
566 mutex_unlock(&d
->i2c_mutex
);
570 static int s6x0_i2c_transfer(struct i2c_adapter
*adap
, struct i2c_msg msg
[],
573 struct dvb_usb_device
*d
= i2c_get_adapdata(adap
);
574 struct usb_device
*udev
;
580 if (mutex_lock_interruptible(&d
->i2c_mutex
) < 0)
583 for (j
= 0; j
< num
; j
++) {
584 switch (msg
[j
].addr
) {
585 case (DW2102_RC_QUERY
): {
587 dw210x_op_rw(d
->udev
, 0xb8, 0, 0,
588 ibuf
, 5, DW210X_READ_MSG
);
589 memcpy(msg
[j
].buf
, ibuf
+ 3, 2);
592 case (DW2102_VOLTAGE_CTRL
): {
596 obuf
[1] = msg
[j
].buf
[1];/* off-on */
597 dw210x_op_rw(d
->udev
, 0x8a, 0, 0,
598 obuf
, 2, DW210X_WRITE_MSG
);
600 obuf
[1] = msg
[j
].buf
[0];/* 13v-18v */
601 dw210x_op_rw(d
->udev
, 0x8a, 0, 0,
602 obuf
, 2, DW210X_WRITE_MSG
);
605 case (DW2102_LED_CTRL
): {
609 obuf
[1] = msg
[j
].buf
[0];
610 dw210x_op_rw(d
->udev
, 0x8a, 0, 0,
611 obuf
, 2, DW210X_WRITE_MSG
);
616 case 0x68: ds3000, stv0903, rs2000
617 case 0x60: ts2020, stv6110, stb6100
620 if (msg
[j
].flags
== I2C_M_RD
) {
622 u8 ibuf
[MAX_XFER_SIZE
];
624 if (msg
[j
].len
> sizeof(ibuf
)) {
625 warn("i2c rd: len=%d is too big!\n",
631 dw210x_op_rw(d
->udev
, 0x91, 0, 0,
634 memcpy(msg
[j
].buf
, ibuf
, msg
[j
].len
);
636 } else if ((msg
[j
].buf
[0] == 0xb0) &&
637 (msg
[j
].addr
== 0x68)) {
640 obuf
[0] = (msg
[j
].len
> 16 ?
641 18 : msg
[j
].len
+ 1);
642 obuf
[1] = msg
[j
].addr
<< 1;
643 obuf
[2] = msg
[j
].buf
[0];
644 len
= msg
[j
].len
- 1;
647 memcpy(obuf
+ 3, msg
[j
].buf
+ i
,
648 (len
> 16 ? 16 : len
));
649 dw210x_op_rw(d
->udev
, 0x80, 0, 0,
650 obuf
, (len
> 16 ? 16 : len
) + 3,
655 } else if (j
< (num
- 1)) {
656 /* write register addr before read */
657 u8 obuf
[MAX_XFER_SIZE
];
659 if (2 + msg
[j
].len
> sizeof(obuf
)) {
660 warn("i2c wr: len=%d is too big!\n",
666 obuf
[0] = msg
[j
+ 1].len
;
667 obuf
[1] = (msg
[j
].addr
<< 1);
668 memcpy(obuf
+ 2, msg
[j
].buf
, msg
[j
].len
);
669 dw210x_op_rw(d
->udev
,
670 udev
->descriptor
.idProduct
==
671 0x7500 ? 0x92 : 0x90, 0, 0,
672 obuf
, msg
[j
].len
+ 2,
676 /* write registers */
677 u8 obuf
[MAX_XFER_SIZE
];
679 if (2 + msg
[j
].len
> sizeof(obuf
)) {
680 warn("i2c wr: len=%d is too big!\n",
685 obuf
[0] = msg
[j
].len
+ 1;
686 obuf
[1] = (msg
[j
].addr
<< 1);
687 memcpy(obuf
+ 2, msg
[j
].buf
, msg
[j
].len
);
688 dw210x_op_rw(d
->udev
, 0x80, 0, 0,
689 obuf
, msg
[j
].len
+ 2,
700 mutex_unlock(&d
->i2c_mutex
);
704 static int su3000_i2c_transfer(struct i2c_adapter
*adap
, struct i2c_msg msg
[],
707 struct dvb_usb_device
*d
= i2c_get_adapdata(adap
);
708 u8 obuf
[0x40], ibuf
[0x40];
712 if (mutex_lock_interruptible(&d
->i2c_mutex
) < 0)
717 switch (msg
[0].addr
) {
718 case SU3000_STREAM_CTRL
:
719 obuf
[0] = msg
[0].buf
[0] + 0x36;
722 if (dvb_usb_generic_rw(d
, obuf
, 3, ibuf
, 0, 0) < 0)
723 err("i2c transfer failed.");
725 case DW2102_RC_QUERY
:
727 if (dvb_usb_generic_rw(d
, obuf
, 1, ibuf
, 2, 0) < 0)
728 err("i2c transfer failed.");
729 msg
[0].buf
[1] = ibuf
[0];
730 msg
[0].buf
[0] = ibuf
[1];
733 /* always i2c write*/
735 obuf
[1] = msg
[0].addr
;
736 obuf
[2] = msg
[0].len
;
738 memcpy(&obuf
[3], msg
[0].buf
, msg
[0].len
);
740 if (dvb_usb_generic_rw(d
, obuf
, msg
[0].len
+ 3,
742 err("i2c transfer failed.");
747 /* always i2c read */
749 obuf
[1] = msg
[0].len
;
750 obuf
[2] = msg
[1].len
;
751 obuf
[3] = msg
[0].addr
;
752 memcpy(&obuf
[4], msg
[0].buf
, msg
[0].len
);
754 if (dvb_usb_generic_rw(d
, obuf
, msg
[0].len
+ 4,
755 ibuf
, msg
[1].len
+ 1, 0) < 0)
756 err("i2c transfer failed.");
758 memcpy(msg
[1].buf
, &ibuf
[1], msg
[1].len
);
761 warn("more than 2 i2c messages at a time is not handled yet.");
764 mutex_unlock(&d
->i2c_mutex
);
768 static u32
dw210x_i2c_func(struct i2c_adapter
*adapter
)
773 static struct i2c_algorithm dw2102_i2c_algo
= {
774 .master_xfer
= dw2102_i2c_transfer
,
775 .functionality
= dw210x_i2c_func
,
778 static struct i2c_algorithm dw2102_serit_i2c_algo
= {
779 .master_xfer
= dw2102_serit_i2c_transfer
,
780 .functionality
= dw210x_i2c_func
,
783 static struct i2c_algorithm dw2102_earda_i2c_algo
= {
784 .master_xfer
= dw2102_earda_i2c_transfer
,
785 .functionality
= dw210x_i2c_func
,
788 static struct i2c_algorithm dw2104_i2c_algo
= {
789 .master_xfer
= dw2104_i2c_transfer
,
790 .functionality
= dw210x_i2c_func
,
793 static struct i2c_algorithm dw3101_i2c_algo
= {
794 .master_xfer
= dw3101_i2c_transfer
,
795 .functionality
= dw210x_i2c_func
,
798 static struct i2c_algorithm s6x0_i2c_algo
= {
799 .master_xfer
= s6x0_i2c_transfer
,
800 .functionality
= dw210x_i2c_func
,
803 static struct i2c_algorithm su3000_i2c_algo
= {
804 .master_xfer
= su3000_i2c_transfer
,
805 .functionality
= dw210x_i2c_func
,
808 static int dw210x_read_mac_address(struct dvb_usb_device
*d
, u8 mac
[6])
812 u8 eeprom
[256], eepromline
[16];
814 for (i
= 0; i
< 256; i
++) {
815 if (dw210x_op_rw(d
->udev
, 0xb6, 0xa0 , i
, ibuf
, 2, DW210X_READ_MSG
) < 0) {
816 err("read eeprom failed.");
819 eepromline
[i
%16] = ibuf
[0];
822 if ((i
% 16) == 15) {
823 deb_xfer("%02x: ", i
- 15);
824 debug_dump(eepromline
, 16, deb_xfer
);
828 memcpy(mac
, eeprom
+ 8, 6);
832 static int s6x0_read_mac_address(struct dvb_usb_device
*d
, u8 mac
[6])
835 u8 ibuf
[] = { 0 }, obuf
[] = { 0 };
836 u8 eeprom
[256], eepromline
[16];
837 struct i2c_msg msg
[] = {
851 for (i
= 0; i
< 256; i
++) {
853 ret
= s6x0_i2c_transfer(&d
->i2c_adap
, msg
, 2);
855 err("read eeprom failed.");
858 eepromline
[i
% 16] = ibuf
[0];
862 if ((i
% 16) == 15) {
863 deb_xfer("%02x: ", i
- 15);
864 debug_dump(eepromline
, 16, deb_xfer
);
868 memcpy(mac
, eeprom
+ 16, 6);
872 static int su3000_streaming_ctrl(struct dvb_usb_adapter
*adap
, int onoff
)
874 static u8 command_start
[] = {0x00};
875 static u8 command_stop
[] = {0x01};
876 struct i2c_msg msg
= {
877 .addr
= SU3000_STREAM_CTRL
,
879 .buf
= onoff
? command_start
: command_stop
,
883 i2c_transfer(&adap
->dev
->i2c_adap
, &msg
, 1);
888 static int su3000_power_ctrl(struct dvb_usb_device
*d
, int i
)
890 struct su3000_state
*state
= (struct su3000_state
*)d
->priv
;
891 u8 obuf
[] = {0xde, 0};
893 info("%s: %d, initialized %d\n", __func__
, i
, state
->initialized
);
895 if (i
&& !state
->initialized
) {
896 state
->initialized
= 1;
898 dvb_usb_generic_rw(d
, obuf
, 2, NULL
, 0, 0);
904 static int su3000_read_mac_address(struct dvb_usb_device
*d
, u8 mac
[6])
907 u8 obuf
[] = { 0x1f, 0xf0 };
909 struct i2c_msg msg
[] = {
924 for (i
= 0; i
< 6; i
++) {
926 if (i2c_transfer(&d
->i2c_adap
, msg
, 2) != 2)
931 debug_dump(mac
, 6, printk
);
937 static int su3000_identify_state(struct usb_device
*udev
,
938 struct dvb_usb_device_properties
*props
,
939 struct dvb_usb_device_description
**desc
,
942 info("%s\n", __func__
);
948 static int dw210x_set_voltage(struct dvb_frontend
*fe
, fe_sec_voltage_t voltage
)
950 static u8 command_13v
[] = {0x00, 0x01};
951 static u8 command_18v
[] = {0x01, 0x01};
952 static u8 command_off
[] = {0x00, 0x00};
953 struct i2c_msg msg
= {
954 .addr
= DW2102_VOLTAGE_CTRL
,
960 struct dvb_usb_adapter
*udev_adap
=
961 (struct dvb_usb_adapter
*)(fe
->dvb
->priv
);
962 if (voltage
== SEC_VOLTAGE_18
)
963 msg
.buf
= command_18v
;
964 else if (voltage
== SEC_VOLTAGE_13
)
965 msg
.buf
= command_13v
;
967 i2c_transfer(&udev_adap
->dev
->i2c_adap
, &msg
, 1);
972 static int s660_set_voltage(struct dvb_frontend
*fe
, fe_sec_voltage_t voltage
)
974 struct dvb_usb_adapter
*d
=
975 (struct dvb_usb_adapter
*)(fe
->dvb
->priv
);
976 struct s6x0_state
*st
= (struct s6x0_state
*)d
->dev
->priv
;
978 dw210x_set_voltage(fe
, voltage
);
979 if (st
->old_set_voltage
)
980 st
->old_set_voltage(fe
, voltage
);
985 static void dw210x_led_ctrl(struct dvb_frontend
*fe
, int offon
)
987 static u8 led_off
[] = { 0 };
988 static u8 led_on
[] = { 1 };
989 struct i2c_msg msg
= {
990 .addr
= DW2102_LED_CTRL
,
995 struct dvb_usb_adapter
*udev_adap
=
996 (struct dvb_usb_adapter
*)(fe
->dvb
->priv
);
1000 i2c_transfer(&udev_adap
->dev
->i2c_adap
, &msg
, 1);
1003 static struct stv0299_config sharp_z0194a_config
= {
1004 .demod_address
= 0x68,
1005 .inittab
= sharp_z0194a_inittab
,
1009 .lock_output
= STV0299_LOCKOUTPUT_1
,
1010 .volt13_op0_op1
= STV0299_VOLT13_OP1
,
1011 .min_delay_ms
= 100,
1012 .set_symbol_rate
= sharp_z0194a_set_symbol_rate
,
1015 static struct cx24116_config dw2104_config
= {
1016 .demod_address
= 0x55,
1017 .mpg_clk_pos_pol
= 0x01,
1020 static struct si21xx_config serit_sp1511lhb_config
= {
1021 .demod_address
= 0x68,
1022 .min_delay_ms
= 100,
1026 static struct tda10023_config dw3101_tda10023_config
= {
1027 .demod_address
= 0x0c,
1031 static struct mt312_config zl313_config
= {
1032 .demod_address
= 0x0e,
1035 static struct ds3000_config dw2104_ds3000_config
= {
1036 .demod_address
= 0x68,
1039 static struct ts2020_config dw2104_ts2020_config
= {
1040 .tuner_address
= 0x60,
1042 .frequency_div
= 1060000,
1045 static struct ds3000_config s660_ds3000_config
= {
1046 .demod_address
= 0x68,
1048 .set_lock_led
= dw210x_led_ctrl
,
1051 static struct ts2020_config s660_ts2020_config
= {
1052 .tuner_address
= 0x60,
1054 .frequency_div
= 1146000,
1057 static struct stv0900_config dw2104a_stv0900_config
= {
1058 .demod_address
= 0x6a,
1061 .clkmode
= 3,/* 0-CLKI, 2-XTALI, else AUTO */
1062 .diseqc_mode
= 2,/* 2/3 PWM */
1063 .tun1_maddress
= 0,/* 0x60 */
1064 .tun1_adc
= 0,/* 2 Vpp */
1068 static struct stb6100_config dw2104a_stb6100_config
= {
1069 .tuner_address
= 0x60,
1070 .refclock
= 27000000,
1073 static struct stv0900_config dw2104_stv0900_config
= {
1074 .demod_address
= 0x68,
1080 .tun1_adc
= 1,/* 1 Vpp */
1084 static struct stv6110_config dw2104_stv6110_config
= {
1085 .i2c_address
= 0x60,
1090 static struct stv0900_config prof_7500_stv0900_config
= {
1091 .demod_address
= 0x6a,
1094 .clkmode
= 3,/* 0-CLKI, 2-XTALI, else AUTO */
1095 .diseqc_mode
= 2,/* 2/3 PWM */
1096 .tun1_maddress
= 0,/* 0x60 */
1097 .tun1_adc
= 0,/* 2 Vpp */
1100 .set_lock_led
= dw210x_led_ctrl
,
1103 static struct ds3000_config su3000_ds3000_config
= {
1104 .demod_address
= 0x68,
1106 .set_lock_led
= dw210x_led_ctrl
,
1109 static struct cxd2820r_config cxd2820r_config
= {
1110 .i2c_address
= 0x6c, /* (0xd8 >> 1) */
1114 static struct tda18271_config tda18271_config
= {
1115 .output_opt
= TDA18271_OUTPUT_LT_OFF
,
1116 .gate
= TDA18271_GATE_DIGITAL
,
1119 static u8 m88rs2000_inittab
[] = {
1120 DEMOD_WRITE
, 0x9a, 0x30,
1121 DEMOD_WRITE
, 0x00, 0x01,
1122 WRITE_DELAY
, 0x19, 0x00,
1123 DEMOD_WRITE
, 0x00, 0x00,
1124 DEMOD_WRITE
, 0x9a, 0xb0,
1125 DEMOD_WRITE
, 0x81, 0xc1,
1126 DEMOD_WRITE
, 0x81, 0x81,
1127 DEMOD_WRITE
, 0x86, 0xc6,
1128 DEMOD_WRITE
, 0x9a, 0x30,
1129 DEMOD_WRITE
, 0xf0, 0x80,
1130 DEMOD_WRITE
, 0xf1, 0xbf,
1131 DEMOD_WRITE
, 0xb0, 0x45,
1132 DEMOD_WRITE
, 0xb2, 0x01,
1133 DEMOD_WRITE
, 0x9a, 0xb0,
1137 static struct m88rs2000_config s421_m88rs2000_config
= {
1139 .inittab
= m88rs2000_inittab
,
1142 static int dw2104_frontend_attach(struct dvb_usb_adapter
*d
)
1144 struct dvb_tuner_ops
*tuner_ops
= NULL
;
1146 if (demod_probe
& 4) {
1147 d
->fe_adap
[0].fe
= dvb_attach(stv0900_attach
, &dw2104a_stv0900_config
,
1148 &d
->dev
->i2c_adap
, 0);
1149 if (d
->fe_adap
[0].fe
!= NULL
) {
1150 if (dvb_attach(stb6100_attach
, d
->fe_adap
[0].fe
,
1151 &dw2104a_stb6100_config
,
1152 &d
->dev
->i2c_adap
)) {
1153 tuner_ops
= &d
->fe_adap
[0].fe
->ops
.tuner_ops
;
1154 tuner_ops
->set_frequency
= stb6100_set_freq
;
1155 tuner_ops
->get_frequency
= stb6100_get_freq
;
1156 tuner_ops
->set_bandwidth
= stb6100_set_bandw
;
1157 tuner_ops
->get_bandwidth
= stb6100_get_bandw
;
1158 d
->fe_adap
[0].fe
->ops
.set_voltage
= dw210x_set_voltage
;
1159 info("Attached STV0900+STB6100!\n");
1165 if (demod_probe
& 2) {
1166 d
->fe_adap
[0].fe
= dvb_attach(stv0900_attach
, &dw2104_stv0900_config
,
1167 &d
->dev
->i2c_adap
, 0);
1168 if (d
->fe_adap
[0].fe
!= NULL
) {
1169 if (dvb_attach(stv6110_attach
, d
->fe_adap
[0].fe
,
1170 &dw2104_stv6110_config
,
1171 &d
->dev
->i2c_adap
)) {
1172 d
->fe_adap
[0].fe
->ops
.set_voltage
= dw210x_set_voltage
;
1173 info("Attached STV0900+STV6110A!\n");
1179 if (demod_probe
& 1) {
1180 d
->fe_adap
[0].fe
= dvb_attach(cx24116_attach
, &dw2104_config
,
1182 if (d
->fe_adap
[0].fe
!= NULL
) {
1183 d
->fe_adap
[0].fe
->ops
.set_voltage
= dw210x_set_voltage
;
1184 info("Attached cx24116!\n");
1189 d
->fe_adap
[0].fe
= dvb_attach(ds3000_attach
, &dw2104_ds3000_config
,
1191 if (d
->fe_adap
[0].fe
!= NULL
) {
1192 dvb_attach(ts2020_attach
, d
->fe_adap
[0].fe
,
1193 &dw2104_ts2020_config
, &d
->dev
->i2c_adap
);
1194 d
->fe_adap
[0].fe
->ops
.set_voltage
= dw210x_set_voltage
;
1195 info("Attached DS3000!\n");
1202 static struct dvb_usb_device_properties dw2102_properties
;
1203 static struct dvb_usb_device_properties dw2104_properties
;
1204 static struct dvb_usb_device_properties s6x0_properties
;
1206 static int dw2102_frontend_attach(struct dvb_usb_adapter
*d
)
1208 if (dw2102_properties
.i2c_algo
== &dw2102_serit_i2c_algo
) {
1209 /*dw2102_properties.adapter->tuner_attach = NULL;*/
1210 d
->fe_adap
[0].fe
= dvb_attach(si21xx_attach
, &serit_sp1511lhb_config
,
1212 if (d
->fe_adap
[0].fe
!= NULL
) {
1213 d
->fe_adap
[0].fe
->ops
.set_voltage
= dw210x_set_voltage
;
1214 info("Attached si21xx!\n");
1219 if (dw2102_properties
.i2c_algo
== &dw2102_earda_i2c_algo
) {
1220 d
->fe_adap
[0].fe
= dvb_attach(stv0288_attach
, &earda_config
,
1222 if (d
->fe_adap
[0].fe
!= NULL
) {
1223 if (dvb_attach(stb6000_attach
, d
->fe_adap
[0].fe
, 0x61,
1224 &d
->dev
->i2c_adap
)) {
1225 d
->fe_adap
[0].fe
->ops
.set_voltage
= dw210x_set_voltage
;
1226 info("Attached stv0288!\n");
1232 if (dw2102_properties
.i2c_algo
== &dw2102_i2c_algo
) {
1233 /*dw2102_properties.adapter->tuner_attach = dw2102_tuner_attach;*/
1234 d
->fe_adap
[0].fe
= dvb_attach(stv0299_attach
, &sharp_z0194a_config
,
1236 if (d
->fe_adap
[0].fe
!= NULL
) {
1237 d
->fe_adap
[0].fe
->ops
.set_voltage
= dw210x_set_voltage
;
1238 info("Attached stv0299!\n");
1245 static int dw3101_frontend_attach(struct dvb_usb_adapter
*d
)
1247 d
->fe_adap
[0].fe
= dvb_attach(tda10023_attach
, &dw3101_tda10023_config
,
1248 &d
->dev
->i2c_adap
, 0x48);
1249 if (d
->fe_adap
[0].fe
!= NULL
) {
1250 info("Attached tda10023!\n");
1256 static int zl100313_frontend_attach(struct dvb_usb_adapter
*d
)
1258 d
->fe_adap
[0].fe
= dvb_attach(mt312_attach
, &zl313_config
,
1260 if (d
->fe_adap
[0].fe
!= NULL
) {
1261 if (dvb_attach(zl10039_attach
, d
->fe_adap
[0].fe
, 0x60,
1262 &d
->dev
->i2c_adap
)) {
1263 d
->fe_adap
[0].fe
->ops
.set_voltage
= dw210x_set_voltage
;
1264 info("Attached zl100313+zl10039!\n");
1272 static int stv0288_frontend_attach(struct dvb_usb_adapter
*d
)
1276 d
->fe_adap
[0].fe
= dvb_attach(stv0288_attach
, &earda_config
,
1279 if (d
->fe_adap
[0].fe
== NULL
)
1282 if (NULL
== dvb_attach(stb6000_attach
, d
->fe_adap
[0].fe
, 0x61, &d
->dev
->i2c_adap
))
1285 d
->fe_adap
[0].fe
->ops
.set_voltage
= dw210x_set_voltage
;
1287 dw210x_op_rw(d
->dev
->udev
, 0x8a, 0, 0, obuf
, 2, DW210X_WRITE_MSG
);
1289 info("Attached stv0288+stb6000!\n");
1295 static int ds3000_frontend_attach(struct dvb_usb_adapter
*d
)
1297 struct s6x0_state
*st
= (struct s6x0_state
*)d
->dev
->priv
;
1300 d
->fe_adap
[0].fe
= dvb_attach(ds3000_attach
, &s660_ds3000_config
,
1303 if (d
->fe_adap
[0].fe
== NULL
)
1306 dvb_attach(ts2020_attach
, d
->fe_adap
[0].fe
, &s660_ts2020_config
,
1309 st
->old_set_voltage
= d
->fe_adap
[0].fe
->ops
.set_voltage
;
1310 d
->fe_adap
[0].fe
->ops
.set_voltage
= s660_set_voltage
;
1312 dw210x_op_rw(d
->dev
->udev
, 0x8a, 0, 0, obuf
, 2, DW210X_WRITE_MSG
);
1314 info("Attached ds3000+ts2020!\n");
1319 static int prof_7500_frontend_attach(struct dvb_usb_adapter
*d
)
1323 d
->fe_adap
[0].fe
= dvb_attach(stv0900_attach
, &prof_7500_stv0900_config
,
1324 &d
->dev
->i2c_adap
, 0);
1325 if (d
->fe_adap
[0].fe
== NULL
)
1328 d
->fe_adap
[0].fe
->ops
.set_voltage
= dw210x_set_voltage
;
1330 dw210x_op_rw(d
->dev
->udev
, 0x8a, 0, 0, obuf
, 2, DW210X_WRITE_MSG
);
1332 info("Attached STV0900+STB6100A!\n");
1337 static int su3000_frontend_attach(struct dvb_usb_adapter
*d
)
1339 u8 obuf
[3] = { 0xe, 0x80, 0 };
1342 if (dvb_usb_generic_rw(d
->dev
, obuf
, 3, ibuf
, 1, 0) < 0)
1343 err("command 0x0e transfer failed.");
1349 if (dvb_usb_generic_rw(d
->dev
, obuf
, 3, ibuf
, 1, 0) < 0)
1350 err("command 0x0e transfer failed.");
1357 if (dvb_usb_generic_rw(d
->dev
, obuf
, 3, ibuf
, 1, 0) < 0)
1358 err("command 0x0e transfer failed.");
1364 if (dvb_usb_generic_rw(d
->dev
, obuf
, 3, ibuf
, 1, 0) < 0)
1365 err("command 0x0e transfer failed.");
1369 if (dvb_usb_generic_rw(d
->dev
, obuf
, 1, ibuf
, 1, 0) < 0)
1370 err("command 0x51 transfer failed.");
1372 d
->fe_adap
[0].fe
= dvb_attach(ds3000_attach
, &su3000_ds3000_config
,
1374 if (d
->fe_adap
[0].fe
== NULL
)
1377 if (dvb_attach(ts2020_attach
, d
->fe_adap
[0].fe
,
1378 &dw2104_ts2020_config
,
1379 &d
->dev
->i2c_adap
)) {
1380 info("Attached DS3000/TS2020!\n");
1384 info("Failed to attach DS3000/TS2020!\n");
1388 static int t220_frontend_attach(struct dvb_usb_adapter
*d
)
1390 u8 obuf
[3] = { 0xe, 0x80, 0 };
1393 if (dvb_usb_generic_rw(d
->dev
, obuf
, 3, ibuf
, 1, 0) < 0)
1394 err("command 0x0e transfer failed.");
1400 if (dvb_usb_generic_rw(d
->dev
, obuf
, 3, ibuf
, 1, 0) < 0)
1401 err("command 0x0e transfer failed.");
1409 if (dvb_usb_generic_rw(d
->dev
, obuf
, 3, ibuf
, 1, 0) < 0)
1410 err("command 0x0e transfer failed.");
1414 if (dvb_usb_generic_rw(d
->dev
, obuf
, 1, ibuf
, 1, 0) < 0)
1415 err("command 0x51 transfer failed.");
1417 d
->fe_adap
[0].fe
= dvb_attach(cxd2820r_attach
, &cxd2820r_config
,
1418 &d
->dev
->i2c_adap
, NULL
);
1419 if (d
->fe_adap
[0].fe
!= NULL
) {
1420 if (dvb_attach(tda18271_attach
, d
->fe_adap
[0].fe
, 0x60,
1421 &d
->dev
->i2c_adap
, &tda18271_config
)) {
1422 info("Attached TDA18271HD/CXD2820R!\n");
1427 info("Failed to attach TDA18271HD/CXD2820R!\n");
1431 static int m88rs2000_frontend_attach(struct dvb_usb_adapter
*d
)
1433 u8 obuf
[] = { 0x51 };
1436 if (dvb_usb_generic_rw(d
->dev
, obuf
, 1, ibuf
, 1, 0) < 0)
1437 err("command 0x51 transfer failed.");
1439 d
->fe_adap
[0].fe
= dvb_attach(m88rs2000_attach
, &s421_m88rs2000_config
,
1442 if (d
->fe_adap
[0].fe
== NULL
)
1445 if (dvb_attach(ts2020_attach
, d
->fe_adap
[0].fe
,
1446 &dw2104_ts2020_config
,
1447 &d
->dev
->i2c_adap
)) {
1448 info("Attached RS2000/TS2020!\n");
1452 info("Failed to attach RS2000/TS2020!\n");
1456 static int dw2102_tuner_attach(struct dvb_usb_adapter
*adap
)
1458 dvb_attach(dvb_pll_attach
, adap
->fe_adap
[0].fe
, 0x60,
1459 &adap
->dev
->i2c_adap
, DVB_PLL_OPERA1
);
1463 static int dw3101_tuner_attach(struct dvb_usb_adapter
*adap
)
1465 dvb_attach(dvb_pll_attach
, adap
->fe_adap
[0].fe
, 0x60,
1466 &adap
->dev
->i2c_adap
, DVB_PLL_TUA6034
);
1471 static int dw2102_rc_query(struct dvb_usb_device
*d
)
1474 struct i2c_msg msg
= {
1475 .addr
= DW2102_RC_QUERY
,
1481 if (d
->props
.i2c_algo
->master_xfer(&d
->i2c_adap
, &msg
, 1) == 1) {
1482 if (msg
.buf
[0] != 0xff) {
1483 deb_rc("%s: rc code: %x, %x\n",
1484 __func__
, key
[0], key
[1]);
1485 rc_keydown(d
->rc_dev
, key
[0], 1);
1492 static int prof_rc_query(struct dvb_usb_device
*d
)
1495 struct i2c_msg msg
= {
1496 .addr
= DW2102_RC_QUERY
,
1502 if (d
->props
.i2c_algo
->master_xfer(&d
->i2c_adap
, &msg
, 1) == 1) {
1503 if (msg
.buf
[0] != 0xff) {
1504 deb_rc("%s: rc code: %x, %x\n",
1505 __func__
, key
[0], key
[1]);
1506 rc_keydown(d
->rc_dev
, key
[0]^0xff, 1);
1513 static int su3000_rc_query(struct dvb_usb_device
*d
)
1516 struct i2c_msg msg
= {
1517 .addr
= DW2102_RC_QUERY
,
1523 if (d
->props
.i2c_algo
->master_xfer(&d
->i2c_adap
, &msg
, 1) == 1) {
1524 if (msg
.buf
[0] != 0xff) {
1525 deb_rc("%s: rc code: %x, %x\n",
1526 __func__
, key
[0], key
[1]);
1527 rc_keydown(d
->rc_dev
, key
[1] << 8 | key
[0], 1);
1534 enum dw2102_table_entry
{
1546 TERRATEC_CINERGY_S2
,
1552 TERRATEC_CINERGY_S2_R2
,
1557 static struct usb_device_id dw2102_table
[] = {
1558 [CYPRESS_DW2102
] = {USB_DEVICE(USB_VID_CYPRESS
, USB_PID_DW2102
)},
1559 [CYPRESS_DW2101
] = {USB_DEVICE(USB_VID_CYPRESS
, 0x2101)},
1560 [CYPRESS_DW2104
] = {USB_DEVICE(USB_VID_CYPRESS
, USB_PID_DW2104
)},
1561 [TEVII_S650
] = {USB_DEVICE(0x9022, USB_PID_TEVII_S650
)},
1562 [TERRATEC_CINERGY_S
] = {USB_DEVICE(USB_VID_TERRATEC
, USB_PID_CINERGY_S
)},
1563 [CYPRESS_DW3101
] = {USB_DEVICE(USB_VID_CYPRESS
, USB_PID_DW3101
)},
1564 [TEVII_S630
] = {USB_DEVICE(0x9022, USB_PID_TEVII_S630
)},
1565 [PROF_1100
] = {USB_DEVICE(0x3011, USB_PID_PROF_1100
)},
1566 [TEVII_S660
] = {USB_DEVICE(0x9022, USB_PID_TEVII_S660
)},
1567 [PROF_7500
] = {USB_DEVICE(0x3034, 0x7500)},
1568 [GENIATECH_SU3000
] = {USB_DEVICE(0x1f4d, 0x3000)},
1569 [TERRATEC_CINERGY_S2
] = {USB_DEVICE(USB_VID_TERRATEC
, 0x00a8)},
1570 [TEVII_S480_1
] = {USB_DEVICE(0x9022, USB_PID_TEVII_S480_1
)},
1571 [TEVII_S480_2
] = {USB_DEVICE(0x9022, USB_PID_TEVII_S480_2
)},
1572 [X3M_SPC1400HD
] = {USB_DEVICE(0x1f4d, 0x3100)},
1573 [TEVII_S421
] = {USB_DEVICE(0x9022, USB_PID_TEVII_S421
)},
1574 [TEVII_S632
] = {USB_DEVICE(0x9022, USB_PID_TEVII_S632
)},
1575 [TERRATEC_CINERGY_S2_R2
] = {USB_DEVICE(USB_VID_TERRATEC
, 0x00b0)},
1576 [GOTVIEW_SAT_HD
] = {USB_DEVICE(0x1FE1, USB_PID_GOTVIEW_SAT_HD
)},
1577 [GENIATECH_T220
] = {USB_DEVICE(0x1f4d, 0xD220)},
1581 MODULE_DEVICE_TABLE(usb
, dw2102_table
);
1583 static int dw2102_load_firmware(struct usb_device
*dev
,
1584 const struct firmware
*frmwr
)
1589 u8 reset16
[] = {0, 0, 0, 0, 0, 0, 0};
1590 const struct firmware
*fw
;
1592 switch (dev
->descriptor
.idProduct
) {
1594 ret
= request_firmware(&fw
, DW2101_FIRMWARE
, &dev
->dev
);
1596 err(err_str
, DW2101_FIRMWARE
);
1604 info("start downloading DW210X firmware");
1605 p
= kmalloc(fw
->size
, GFP_KERNEL
);
1608 dw210x_op_rw(dev
, 0xa0, 0x7f92, 0, &reset
, 1, DW210X_WRITE_MSG
);
1609 dw210x_op_rw(dev
, 0xa0, 0xe600, 0, &reset
, 1, DW210X_WRITE_MSG
);
1612 memcpy(p
, fw
->data
, fw
->size
);
1613 for (i
= 0; i
< fw
->size
; i
+= 0x40) {
1615 if (dw210x_op_rw(dev
, 0xa0, i
, 0, b
, 0x40,
1616 DW210X_WRITE_MSG
) != 0x40) {
1617 err("error while transferring firmware");
1622 /* restart the CPU */
1624 if (ret
|| dw210x_op_rw(dev
, 0xa0, 0x7f92, 0, &reset
, 1,
1625 DW210X_WRITE_MSG
) != 1) {
1626 err("could not restart the USB controller CPU.");
1629 if (ret
|| dw210x_op_rw(dev
, 0xa0, 0xe600, 0, &reset
, 1,
1630 DW210X_WRITE_MSG
) != 1) {
1631 err("could not restart the USB controller CPU.");
1634 /* init registers */
1635 switch (dev
->descriptor
.idProduct
) {
1636 case USB_PID_TEVII_S650
:
1637 dw2104_properties
.rc
.core
.rc_codes
= RC_MAP_TEVII_NEC
;
1638 case USB_PID_DW2104
:
1640 dw210x_op_rw(dev
, 0xc4, 0x0000, 0, &reset
, 1,
1642 /* break omitted intentionally */
1643 case USB_PID_DW3101
:
1645 dw210x_op_rw(dev
, 0xbf, 0x0040, 0, &reset
, 0,
1648 case USB_PID_CINERGY_S
:
1649 case USB_PID_DW2102
:
1650 dw210x_op_rw(dev
, 0xbf, 0x0040, 0, &reset
, 0,
1652 dw210x_op_rw(dev
, 0xb9, 0x0000, 0, &reset16
[0], 2,
1654 /* check STV0299 frontend */
1655 dw210x_op_rw(dev
, 0xb5, 0, 0, &reset16
[0], 2,
1657 if ((reset16
[0] == 0xa1) || (reset16
[0] == 0x80)) {
1658 dw2102_properties
.i2c_algo
= &dw2102_i2c_algo
;
1659 dw2102_properties
.adapter
->fe
[0].tuner_attach
= &dw2102_tuner_attach
;
1662 /* check STV0288 frontend */
1666 dw210x_op_rw(dev
, 0xc2, 0, 0, &reset16
[0], 3,
1668 dw210x_op_rw(dev
, 0xc3, 0xd1, 0, &reset16
[0], 3,
1670 if (reset16
[2] == 0x11) {
1671 dw2102_properties
.i2c_algo
= &dw2102_earda_i2c_algo
;
1676 dw210x_op_rw(dev
, 0xbc, 0x0030, 0, &reset16
[0], 2,
1678 dw210x_op_rw(dev
, 0xba, 0x0000, 0, &reset16
[0], 7,
1680 dw210x_op_rw(dev
, 0xba, 0x0000, 0, &reset16
[0], 7,
1682 dw210x_op_rw(dev
, 0xb9, 0x0000, 0, &reset16
[0], 2,
1693 static struct dvb_usb_device_properties dw2102_properties
= {
1694 .caps
= DVB_USB_IS_AN_I2C_ADAPTER
,
1695 .usb_ctrl
= DEVICE_SPECIFIC
,
1696 .firmware
= DW2102_FIRMWARE
,
1699 .i2c_algo
= &dw2102_serit_i2c_algo
,
1703 .rc_codes
= RC_MAP_DM1105_NEC
,
1704 .module_name
= "dw2102",
1705 .allowed_protos
= RC_BIT_NEC
,
1706 .rc_query
= dw2102_rc_query
,
1709 .generic_bulk_ctrl_endpoint
= 0x81,
1710 /* parameter for the MPEG2-data transfer */
1712 .download_firmware
= dw2102_load_firmware
,
1713 .read_mac_address
= dw210x_read_mac_address
,
1718 .frontend_attach
= dw2102_frontend_attach
,
1732 .num_device_descs
= 3,
1734 {"DVBWorld DVB-S 2102 USB2.0",
1735 {&dw2102_table
[CYPRESS_DW2102
], NULL
},
1738 {"DVBWorld DVB-S 2101 USB2.0",
1739 {&dw2102_table
[CYPRESS_DW2101
], NULL
},
1742 {"TerraTec Cinergy S USB",
1743 {&dw2102_table
[TERRATEC_CINERGY_S
], NULL
},
1749 static struct dvb_usb_device_properties dw2104_properties
= {
1750 .caps
= DVB_USB_IS_AN_I2C_ADAPTER
,
1751 .usb_ctrl
= DEVICE_SPECIFIC
,
1752 .firmware
= DW2104_FIRMWARE
,
1755 .i2c_algo
= &dw2104_i2c_algo
,
1758 .rc_codes
= RC_MAP_DM1105_NEC
,
1759 .module_name
= "dw2102",
1760 .allowed_protos
= RC_BIT_NEC
,
1761 .rc_query
= dw2102_rc_query
,
1764 .generic_bulk_ctrl_endpoint
= 0x81,
1765 /* parameter for the MPEG2-data transfer */
1767 .download_firmware
= dw2102_load_firmware
,
1768 .read_mac_address
= dw210x_read_mac_address
,
1773 .frontend_attach
= dw2104_frontend_attach
,
1787 .num_device_descs
= 2,
1789 { "DVBWorld DW2104 USB2.0",
1790 {&dw2102_table
[CYPRESS_DW2104
], NULL
},
1793 { "TeVii S650 USB2.0",
1794 {&dw2102_table
[TEVII_S650
], NULL
},
1800 static struct dvb_usb_device_properties dw3101_properties
= {
1801 .caps
= DVB_USB_IS_AN_I2C_ADAPTER
,
1802 .usb_ctrl
= DEVICE_SPECIFIC
,
1803 .firmware
= DW3101_FIRMWARE
,
1806 .i2c_algo
= &dw3101_i2c_algo
,
1809 .rc_codes
= RC_MAP_DM1105_NEC
,
1810 .module_name
= "dw2102",
1811 .allowed_protos
= RC_BIT_NEC
,
1812 .rc_query
= dw2102_rc_query
,
1815 .generic_bulk_ctrl_endpoint
= 0x81,
1816 /* parameter for the MPEG2-data transfer */
1818 .download_firmware
= dw2102_load_firmware
,
1819 .read_mac_address
= dw210x_read_mac_address
,
1824 .frontend_attach
= dw3101_frontend_attach
,
1825 .tuner_attach
= dw3101_tuner_attach
,
1839 .num_device_descs
= 1,
1841 { "DVBWorld DVB-C 3101 USB2.0",
1842 {&dw2102_table
[CYPRESS_DW3101
], NULL
},
1848 static struct dvb_usb_device_properties s6x0_properties
= {
1849 .caps
= DVB_USB_IS_AN_I2C_ADAPTER
,
1850 .usb_ctrl
= DEVICE_SPECIFIC
,
1851 .size_of_priv
= sizeof(struct s6x0_state
),
1852 .firmware
= S630_FIRMWARE
,
1855 .i2c_algo
= &s6x0_i2c_algo
,
1858 .rc_codes
= RC_MAP_TEVII_NEC
,
1859 .module_name
= "dw2102",
1860 .allowed_protos
= RC_BIT_NEC
,
1861 .rc_query
= dw2102_rc_query
,
1864 .generic_bulk_ctrl_endpoint
= 0x81,
1866 .download_firmware
= dw2102_load_firmware
,
1867 .read_mac_address
= s6x0_read_mac_address
,
1872 .frontend_attach
= zl100313_frontend_attach
,
1886 .num_device_descs
= 1,
1889 {&dw2102_table
[TEVII_S630
], NULL
},
1895 struct dvb_usb_device_properties
*p1100
;
1896 static struct dvb_usb_device_description d1100
= {
1898 {&dw2102_table
[PROF_1100
], NULL
},
1902 struct dvb_usb_device_properties
*s660
;
1903 static struct dvb_usb_device_description d660
= {
1905 {&dw2102_table
[TEVII_S660
], NULL
},
1909 static struct dvb_usb_device_description d480_1
= {
1911 {&dw2102_table
[TEVII_S480_1
], NULL
},
1915 static struct dvb_usb_device_description d480_2
= {
1917 {&dw2102_table
[TEVII_S480_2
], NULL
},
1921 struct dvb_usb_device_properties
*p7500
;
1922 static struct dvb_usb_device_description d7500
= {
1923 "Prof 7500 USB DVB-S2",
1924 {&dw2102_table
[PROF_7500
], NULL
},
1928 struct dvb_usb_device_properties
*s421
;
1929 static struct dvb_usb_device_description d421
= {
1931 {&dw2102_table
[TEVII_S421
], NULL
},
1935 static struct dvb_usb_device_description d632
= {
1937 {&dw2102_table
[TEVII_S632
], NULL
},
1941 static struct dvb_usb_device_properties su3000_properties
= {
1942 .caps
= DVB_USB_IS_AN_I2C_ADAPTER
,
1943 .usb_ctrl
= DEVICE_SPECIFIC
,
1944 .size_of_priv
= sizeof(struct su3000_state
),
1945 .power_ctrl
= su3000_power_ctrl
,
1947 .identify_state
= su3000_identify_state
,
1948 .i2c_algo
= &su3000_i2c_algo
,
1952 .rc_codes
= RC_MAP_SU3000
,
1953 .module_name
= "dw2102",
1954 .allowed_protos
= RC_BIT_RC5
,
1955 .rc_query
= su3000_rc_query
,
1958 .read_mac_address
= su3000_read_mac_address
,
1960 .generic_bulk_ctrl_endpoint
= 0x01,
1966 .streaming_ctrl
= su3000_streaming_ctrl
,
1967 .frontend_attach
= su3000_frontend_attach
,
1981 .num_device_descs
= 5,
1983 { "SU3000HD DVB-S USB2.0",
1984 { &dw2102_table
[GENIATECH_SU3000
], NULL
},
1987 { "Terratec Cinergy S2 USB HD",
1988 { &dw2102_table
[TERRATEC_CINERGY_S2
], NULL
},
1991 { "X3M TV SPC1400HD PCI",
1992 { &dw2102_table
[X3M_SPC1400HD
], NULL
},
1995 { "Terratec Cinergy S2 USB HD Rev.2",
1996 { &dw2102_table
[TERRATEC_CINERGY_S2_R2
], NULL
},
1999 { "GOTVIEW Satellite HD",
2000 { &dw2102_table
[GOTVIEW_SAT_HD
], NULL
},
2006 static struct dvb_usb_device_properties t220_properties
= {
2007 .caps
= DVB_USB_IS_AN_I2C_ADAPTER
,
2008 .usb_ctrl
= DEVICE_SPECIFIC
,
2009 .size_of_priv
= sizeof(struct su3000_state
),
2010 .power_ctrl
= su3000_power_ctrl
,
2012 .identify_state
= su3000_identify_state
,
2013 .i2c_algo
= &su3000_i2c_algo
,
2017 .rc_codes
= RC_MAP_SU3000
,
2018 .module_name
= "dw2102",
2019 .allowed_protos
= RC_BIT_RC5
,
2020 .rc_query
= su3000_rc_query
,
2023 .read_mac_address
= su3000_read_mac_address
,
2025 .generic_bulk_ctrl_endpoint
= 0x01,
2031 .streaming_ctrl
= su3000_streaming_ctrl
,
2032 .frontend_attach
= t220_frontend_attach
,
2046 .num_device_descs
= 1,
2048 { "Geniatech T220 DVB-T/T2 USB2.0",
2049 { &dw2102_table
[GENIATECH_T220
], NULL
},
2055 static int dw2102_probe(struct usb_interface
*intf
,
2056 const struct usb_device_id
*id
)
2058 p1100
= kmemdup(&s6x0_properties
,
2059 sizeof(struct dvb_usb_device_properties
), GFP_KERNEL
);
2062 /* copy default structure */
2063 /* fill only different fields */
2064 p1100
->firmware
= P1100_FIRMWARE
;
2065 p1100
->devices
[0] = d1100
;
2066 p1100
->rc
.core
.rc_query
= prof_rc_query
;
2067 p1100
->rc
.core
.rc_codes
= RC_MAP_TBS_NEC
;
2068 p1100
->adapter
->fe
[0].frontend_attach
= stv0288_frontend_attach
;
2070 s660
= kmemdup(&s6x0_properties
,
2071 sizeof(struct dvb_usb_device_properties
), GFP_KERNEL
);
2076 s660
->firmware
= S660_FIRMWARE
;
2077 s660
->num_device_descs
= 3;
2078 s660
->devices
[0] = d660
;
2079 s660
->devices
[1] = d480_1
;
2080 s660
->devices
[2] = d480_2
;
2081 s660
->adapter
->fe
[0].frontend_attach
= ds3000_frontend_attach
;
2083 p7500
= kmemdup(&s6x0_properties
,
2084 sizeof(struct dvb_usb_device_properties
), GFP_KERNEL
);
2090 p7500
->firmware
= P7500_FIRMWARE
;
2091 p7500
->devices
[0] = d7500
;
2092 p7500
->rc
.core
.rc_query
= prof_rc_query
;
2093 p7500
->rc
.core
.rc_codes
= RC_MAP_TBS_NEC
;
2094 p7500
->adapter
->fe
[0].frontend_attach
= prof_7500_frontend_attach
;
2097 s421
= kmemdup(&su3000_properties
,
2098 sizeof(struct dvb_usb_device_properties
), GFP_KERNEL
);
2105 s421
->num_device_descs
= 2;
2106 s421
->devices
[0] = d421
;
2107 s421
->devices
[1] = d632
;
2108 s421
->adapter
->fe
[0].frontend_attach
= m88rs2000_frontend_attach
;
2110 if (0 == dvb_usb_device_init(intf
, &dw2102_properties
,
2111 THIS_MODULE
, NULL
, adapter_nr
) ||
2112 0 == dvb_usb_device_init(intf
, &dw2104_properties
,
2113 THIS_MODULE
, NULL
, adapter_nr
) ||
2114 0 == dvb_usb_device_init(intf
, &dw3101_properties
,
2115 THIS_MODULE
, NULL
, adapter_nr
) ||
2116 0 == dvb_usb_device_init(intf
, &s6x0_properties
,
2117 THIS_MODULE
, NULL
, adapter_nr
) ||
2118 0 == dvb_usb_device_init(intf
, p1100
,
2119 THIS_MODULE
, NULL
, adapter_nr
) ||
2120 0 == dvb_usb_device_init(intf
, s660
,
2121 THIS_MODULE
, NULL
, adapter_nr
) ||
2122 0 == dvb_usb_device_init(intf
, p7500
,
2123 THIS_MODULE
, NULL
, adapter_nr
) ||
2124 0 == dvb_usb_device_init(intf
, s421
,
2125 THIS_MODULE
, NULL
, adapter_nr
) ||
2126 0 == dvb_usb_device_init(intf
, &su3000_properties
,
2127 THIS_MODULE
, NULL
, adapter_nr
) ||
2128 0 == dvb_usb_device_init(intf
, &t220_properties
,
2129 THIS_MODULE
, NULL
, adapter_nr
))
2135 static struct usb_driver dw2102_driver
= {
2137 .probe
= dw2102_probe
,
2138 .disconnect
= dvb_usb_device_exit
,
2139 .id_table
= dw2102_table
,
2142 module_usb_driver(dw2102_driver
);
2144 MODULE_AUTHOR("Igor M. Liplianin (c) liplianin@me.by");
2145 MODULE_DESCRIPTION("Driver for DVBWorld DVB-S 2101, 2102, DVB-S2 2104,"
2146 " DVB-C 3101 USB2.0,"
2147 " TeVii S600, S630, S650, S660, S480, S421, S632"
2148 " Prof 1100, 7500 USB2.0,"
2149 " Geniatech SU3000, T220 devices");
2150 MODULE_VERSION("0.1");
2151 MODULE_LICENSE("GPL");
2152 MODULE_FIRMWARE(DW2101_FIRMWARE
);
2153 MODULE_FIRMWARE(DW2102_FIRMWARE
);
2154 MODULE_FIRMWARE(DW2104_FIRMWARE
);
2155 MODULE_FIRMWARE(DW3101_FIRMWARE
);
2156 MODULE_FIRMWARE(S630_FIRMWARE
);
2157 MODULE_FIRMWARE(S660_FIRMWARE
);
2158 MODULE_FIRMWARE(P1100_FIRMWARE
);
2159 MODULE_FIRMWARE(P7500_FIRMWARE
);