1 // SPDX-License-Identifier: GPL-2.0-only
2 /* DVB USB framework compliant Linux driver for the
3 * DVBWorld DVB-S 2101, 2102, DVB-S2 2104, DVB-C 3101,
4 * TeVii S421, S480, S482, S600, S630, S632, S650, S660, S662,
6 * Geniatech SU3000, T220,
8 * Terratec Cinergy S2 cards
9 * Copyright (C) 2008-2012 Igor M. Liplianin (liplianin@me.by)
11 * see Documentation/driver-api/media/drivers/dvb-usb.rst for more information
13 #include <media/dvb-usb-ids.h>
30 #include "stb6100_proc.h"
31 #include "m88rs2000.h"
34 #include "m88ds3103.h"
36 /* Max transfer size done by I2C transfer functions */
37 #define MAX_XFER_SIZE 64
39 #define DW210X_READ_MSG 0
40 #define DW210X_WRITE_MSG 1
42 #define REG_1F_SYMBOLRATE_BYTE0 0x1f
43 #define REG_20_SYMBOLRATE_BYTE1 0x20
44 #define REG_21_SYMBOLRATE_BYTE2 0x21
46 #define DW2102_VOLTAGE_CTRL (0x1800)
47 #define SU3000_STREAM_CTRL (0x1900)
48 #define DW2102_RC_QUERY (0x1a00)
49 #define DW2102_LED_CTRL (0x1b00)
51 #define DW2101_FIRMWARE "dvb-usb-dw2101.fw"
52 #define DW2102_FIRMWARE "dvb-usb-dw2102.fw"
53 #define DW2104_FIRMWARE "dvb-usb-dw2104.fw"
54 #define DW3101_FIRMWARE "dvb-usb-dw3101.fw"
55 #define S630_FIRMWARE "dvb-usb-s630.fw"
56 #define S660_FIRMWARE "dvb-usb-s660.fw"
57 #define P1100_FIRMWARE "dvb-usb-p1100.fw"
58 #define P7500_FIRMWARE "dvb-usb-p7500.fw"
60 #define err_str "did not find the firmware file '%s'. You can use <kernel_dir>/scripts/get_dvb_firmware to get the firmware"
65 u8 data
[MAX_XFER_SIZE
+ 4];
66 struct i2c_client
*i2c_client_demod
;
67 struct i2c_client
*i2c_client_tuner
;
69 /* fe hook functions*/
70 int (*old_set_voltage
)(struct dvb_frontend
*f
, enum fe_sec_voltage v
);
71 int (*fe_read_status
)(struct dvb_frontend
*fe
,
72 enum fe_status
*status
);
76 static int dvb_usb_dw2102_debug
;
77 module_param_named(debug
, dvb_usb_dw2102_debug
, int, 0644);
78 MODULE_PARM_DESC(debug
, "set debugging level (1=info 2=xfer 4=rc(or-able))."
79 DVB_USB_DEBUG_STATUS
);
82 static int demod_probe
= 1;
83 module_param_named(demod
, demod_probe
, int, 0644);
84 MODULE_PARM_DESC(demod
, "demod to probe (1=cx24116 2=stv0903+stv6110 4=stv0903+stb6100(or-able)).");
86 DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr
);
88 static int dw210x_op_rw(struct usb_device
*dev
, u8 request
, u16 value
,
89 u16 index
, u8
*data
, u16 len
, int flags
)
93 unsigned int pipe
= (flags
== DW210X_READ_MSG
) ?
94 usb_rcvctrlpipe(dev
, 0) : usb_sndctrlpipe(dev
, 0);
95 u8 request_type
= (flags
== DW210X_READ_MSG
) ? USB_DIR_IN
: USB_DIR_OUT
;
97 u8buf
= kmalloc(len
, GFP_KERNEL
);
101 if (flags
== DW210X_WRITE_MSG
)
102 memcpy(u8buf
, data
, len
);
103 ret
= usb_control_msg(dev
, pipe
, request
, request_type
| USB_TYPE_VENDOR
,
104 value
, index
, u8buf
, len
, 2000);
106 if (flags
== DW210X_READ_MSG
)
107 memcpy(data
, u8buf
, len
);
114 static int dw2102_i2c_transfer(struct i2c_adapter
*adap
, struct i2c_msg msg
[],
117 struct dvb_usb_device
*d
= i2c_get_adapdata(adap
);
119 u8 buf6
[] = {0x2c, 0x05, 0xc0, 0, 0, 0, 0};
124 if (mutex_lock_interruptible(&d
->i2c_mutex
) < 0)
129 if (msg
[0].len
< 1) {
133 /* read stv0299 register */
134 value
= msg
[0].buf
[0];/* register */
135 for (i
= 0; i
< msg
[1].len
; i
++) {
136 dw210x_op_rw(d
->udev
, 0xb5, value
+ i
, 0,
137 buf6
, 2, DW210X_READ_MSG
);
138 msg
[1].buf
[i
] = buf6
[0];
142 switch (msg
[0].addr
) {
144 if (msg
[0].len
< 2) {
148 /* write to stv0299 register */
150 buf6
[1] = msg
[0].buf
[0];
151 buf6
[2] = msg
[0].buf
[1];
152 dw210x_op_rw(d
->udev
, 0xb2, 0, 0,
153 buf6
, 3, DW210X_WRITE_MSG
);
156 if (msg
[0].flags
== 0) {
157 if (msg
[0].len
< 4) {
161 /* write to tuner pll */
165 buf6
[3] = msg
[0].buf
[0];
166 buf6
[4] = msg
[0].buf
[1];
167 buf6
[5] = msg
[0].buf
[2];
168 buf6
[6] = msg
[0].buf
[3];
169 dw210x_op_rw(d
->udev
, 0xb2, 0, 0,
170 buf6
, 7, DW210X_WRITE_MSG
);
172 if (msg
[0].len
< 1) {
176 /* read from tuner */
177 dw210x_op_rw(d
->udev
, 0xb5, 0, 0,
178 buf6
, 1, DW210X_READ_MSG
);
179 msg
[0].buf
[0] = buf6
[0];
182 case (DW2102_RC_QUERY
):
183 if (msg
[0].len
< 2) {
187 dw210x_op_rw(d
->udev
, 0xb8, 0, 0,
188 buf6
, 2, DW210X_READ_MSG
);
189 msg
[0].buf
[0] = buf6
[0];
190 msg
[0].buf
[1] = buf6
[1];
192 case (DW2102_VOLTAGE_CTRL
):
193 if (msg
[0].len
< 1) {
198 buf6
[1] = msg
[0].buf
[0];
199 dw210x_op_rw(d
->udev
, 0xb2, 0, 0,
200 buf6
, 2, DW210X_WRITE_MSG
);
207 mutex_unlock(&d
->i2c_mutex
);
211 static int dw2102_serit_i2c_transfer(struct i2c_adapter
*adap
,
212 struct i2c_msg msg
[], int num
)
214 struct dvb_usb_device
*d
= i2c_get_adapdata(adap
);
215 u8 buf6
[] = {0, 0, 0, 0, 0, 0, 0};
219 if (mutex_lock_interruptible(&d
->i2c_mutex
) < 0)
224 if (msg
[0].len
!= 1) {
225 warn("i2c rd: len=%d is not 1!\n",
231 if (2 + msg
[1].len
> sizeof(buf6
)) {
232 warn("i2c rd: len=%d is too big!\n",
238 /* read si2109 register by number */
239 buf6
[0] = msg
[0].addr
<< 1;
240 buf6
[1] = msg
[0].len
;
241 buf6
[2] = msg
[0].buf
[0];
242 dw210x_op_rw(d
->udev
, 0xc2, 0, 0,
243 buf6
, msg
[0].len
+ 2, DW210X_WRITE_MSG
);
244 /* read si2109 register */
245 dw210x_op_rw(d
->udev
, 0xc3, 0xd0, 0,
246 buf6
, msg
[1].len
+ 2, DW210X_READ_MSG
);
247 memcpy(msg
[1].buf
, buf6
+ 2, msg
[1].len
);
251 switch (msg
[0].addr
) {
253 if (2 + msg
[0].len
> sizeof(buf6
)) {
254 warn("i2c wr: len=%d is too big!\n",
260 /* write to si2109 register */
261 buf6
[0] = msg
[0].addr
<< 1;
262 buf6
[1] = msg
[0].len
;
263 memcpy(buf6
+ 2, msg
[0].buf
, msg
[0].len
);
264 dw210x_op_rw(d
->udev
, 0xc2, 0, 0, buf6
,
265 msg
[0].len
+ 2, DW210X_WRITE_MSG
);
267 case(DW2102_RC_QUERY
):
268 dw210x_op_rw(d
->udev
, 0xb8, 0, 0,
269 buf6
, 2, DW210X_READ_MSG
);
270 msg
[0].buf
[0] = buf6
[0];
271 msg
[0].buf
[1] = buf6
[1];
273 case(DW2102_VOLTAGE_CTRL
):
275 buf6
[1] = msg
[0].buf
[0];
276 dw210x_op_rw(d
->udev
, 0xb2, 0, 0,
277 buf6
, 2, DW210X_WRITE_MSG
);
283 mutex_unlock(&d
->i2c_mutex
);
287 static int dw2102_earda_i2c_transfer(struct i2c_adapter
*adap
, struct i2c_msg msg
[], int num
)
289 struct dvb_usb_device
*d
= i2c_get_adapdata(adap
);
294 if (mutex_lock_interruptible(&d
->i2c_mutex
) < 0)
300 /* first write first register number */
301 u8 ibuf
[MAX_XFER_SIZE
], obuf
[3];
303 if (2 + msg
[0].len
!= sizeof(obuf
)) {
304 warn("i2c rd: len=%d is not 1!\n",
310 if (2 + msg
[1].len
> sizeof(ibuf
)) {
311 warn("i2c rd: len=%d is too big!\n",
317 obuf
[0] = msg
[0].addr
<< 1;
318 obuf
[1] = msg
[0].len
;
319 obuf
[2] = msg
[0].buf
[0];
320 dw210x_op_rw(d
->udev
, 0xc2, 0, 0,
321 obuf
, msg
[0].len
+ 2, DW210X_WRITE_MSG
);
322 /* second read registers */
323 dw210x_op_rw(d
->udev
, 0xc3, 0xd1, 0,
324 ibuf
, msg
[1].len
+ 2, DW210X_READ_MSG
);
325 memcpy(msg
[1].buf
, ibuf
+ 2, msg
[1].len
);
330 switch (msg
[0].addr
) {
332 /* write to register */
333 u8 obuf
[MAX_XFER_SIZE
];
335 if (2 + msg
[0].len
> sizeof(obuf
)) {
336 warn("i2c wr: len=%d is too big!\n",
342 obuf
[0] = msg
[0].addr
<< 1;
343 obuf
[1] = msg
[0].len
;
344 memcpy(obuf
+ 2, msg
[0].buf
, msg
[0].len
);
345 dw210x_op_rw(d
->udev
, 0xc2, 0, 0,
346 obuf
, msg
[0].len
+ 2, DW210X_WRITE_MSG
);
351 u8 obuf
[MAX_XFER_SIZE
];
353 if (2 + msg
[0].len
> sizeof(obuf
)) {
354 warn("i2c wr: len=%d is too big!\n",
360 obuf
[0] = msg
[0].addr
<< 1;
361 obuf
[1] = msg
[0].len
;
362 memcpy(obuf
+ 2, msg
[0].buf
, msg
[0].len
);
363 dw210x_op_rw(d
->udev
, 0xc2, 0, 0,
364 obuf
, msg
[0].len
+ 2, DW210X_WRITE_MSG
);
367 case(DW2102_RC_QUERY
): {
370 dw210x_op_rw(d
->udev
, 0xb8, 0, 0,
371 ibuf
, 2, DW210X_READ_MSG
);
372 memcpy(msg
[0].buf
, ibuf
, 2);
375 case(DW2102_VOLTAGE_CTRL
): {
379 obuf
[1] = msg
[0].buf
[0];
380 dw210x_op_rw(d
->udev
, 0xb2, 0, 0,
381 obuf
, 2, DW210X_WRITE_MSG
);
391 mutex_unlock(&d
->i2c_mutex
);
395 static int dw2104_i2c_transfer(struct i2c_adapter
*adap
, struct i2c_msg msg
[], int num
)
397 struct dvb_usb_device
*d
= i2c_get_adapdata(adap
);
402 if (mutex_lock_interruptible(&d
->i2c_mutex
) < 0)
405 for (j
= 0; j
< num
; j
++) {
406 switch (msg
[j
].addr
) {
407 case(DW2102_RC_QUERY
): {
410 dw210x_op_rw(d
->udev
, 0xb8, 0, 0,
411 ibuf
, 2, DW210X_READ_MSG
);
412 memcpy(msg
[j
].buf
, ibuf
, 2);
415 case(DW2102_VOLTAGE_CTRL
): {
419 obuf
[1] = msg
[j
].buf
[0];
420 dw210x_op_rw(d
->udev
, 0xb2, 0, 0,
421 obuf
, 2, DW210X_WRITE_MSG
);
424 /* case 0x55: cx24116
426 * case 0x68: ds3000, stv0903
427 * case 0x60: ts2020, stv6110, stb6100
430 if (msg
[j
].flags
== I2C_M_RD
) {
432 u8 ibuf
[MAX_XFER_SIZE
];
434 if (2 + msg
[j
].len
> sizeof(ibuf
)) {
435 warn("i2c rd: len=%d is too big!\n",
441 dw210x_op_rw(d
->udev
, 0xc3,
442 (msg
[j
].addr
<< 1) + 1, 0,
443 ibuf
, msg
[j
].len
+ 2,
445 memcpy(msg
[j
].buf
, ibuf
+ 2, msg
[j
].len
);
447 } else if (((msg
[j
].buf
[0] == 0xb0) && (msg
[j
].addr
== 0x68)) ||
448 ((msg
[j
].buf
[0] == 0xf7) && (msg
[j
].addr
== 0x55))) {
452 obuf
[0] = msg
[j
].addr
<< 1;
453 obuf
[1] = (msg
[j
].len
> 15 ? 17 : msg
[j
].len
);
454 obuf
[2] = msg
[j
].buf
[0];
455 len
= msg
[j
].len
- 1;
458 memcpy(obuf
+ 3, msg
[j
].buf
+ i
,
459 (len
> 16 ? 16 : len
));
460 dw210x_op_rw(d
->udev
, 0xc2, 0, 0,
461 obuf
, (len
> 16 ? 16 : len
) + 3,
467 /* write registers */
468 u8 obuf
[MAX_XFER_SIZE
];
470 if (2 + msg
[j
].len
> sizeof(obuf
)) {
471 warn("i2c wr: len=%d is too big!\n",
477 obuf
[0] = msg
[j
].addr
<< 1;
478 obuf
[1] = msg
[j
].len
;
479 memcpy(obuf
+ 2, msg
[j
].buf
, msg
[j
].len
);
480 dw210x_op_rw(d
->udev
, 0xc2, 0, 0,
481 obuf
, msg
[j
].len
+ 2,
491 mutex_unlock(&d
->i2c_mutex
);
495 static int dw3101_i2c_transfer(struct i2c_adapter
*adap
, struct i2c_msg msg
[],
498 struct dvb_usb_device
*d
= i2c_get_adapdata(adap
);
504 if (mutex_lock_interruptible(&d
->i2c_mutex
) < 0)
510 /* first write first register number */
511 u8 ibuf
[MAX_XFER_SIZE
], obuf
[3];
513 if (2 + msg
[0].len
!= sizeof(obuf
)) {
514 warn("i2c rd: len=%d is not 1!\n",
519 if (2 + msg
[1].len
> sizeof(ibuf
)) {
520 warn("i2c rd: len=%d is too big!\n",
525 obuf
[0] = msg
[0].addr
<< 1;
526 obuf
[1] = msg
[0].len
;
527 obuf
[2] = msg
[0].buf
[0];
528 dw210x_op_rw(d
->udev
, 0xc2, 0, 0,
529 obuf
, msg
[0].len
+ 2, DW210X_WRITE_MSG
);
530 /* second read registers */
531 dw210x_op_rw(d
->udev
, 0xc3, 0x19, 0,
532 ibuf
, msg
[1].len
+ 2, DW210X_READ_MSG
);
533 memcpy(msg
[1].buf
, ibuf
+ 2, msg
[1].len
);
538 switch (msg
[0].addr
) {
541 /* write to register */
542 u8 obuf
[MAX_XFER_SIZE
];
544 if (2 + msg
[0].len
> sizeof(obuf
)) {
545 warn("i2c wr: len=%d is too big!\n",
550 obuf
[0] = msg
[0].addr
<< 1;
551 obuf
[1] = msg
[0].len
;
552 memcpy(obuf
+ 2, msg
[0].buf
, msg
[0].len
);
553 dw210x_op_rw(d
->udev
, 0xc2, 0, 0,
554 obuf
, msg
[0].len
+ 2, DW210X_WRITE_MSG
);
557 case(DW2102_RC_QUERY
): {
560 dw210x_op_rw(d
->udev
, 0xb8, 0, 0,
561 ibuf
, 2, DW210X_READ_MSG
);
562 memcpy(msg
[0].buf
, ibuf
, 2);
570 for (i
= 0; i
< num
; i
++) {
571 deb_xfer("%02x:%02x: %s ", i
, msg
[i
].addr
,
572 msg
[i
].flags
== 0 ? ">>>" : "<<<");
573 debug_dump(msg
[i
].buf
, msg
[i
].len
, deb_xfer
);
578 mutex_unlock(&d
->i2c_mutex
);
582 static int s6x0_i2c_transfer(struct i2c_adapter
*adap
, struct i2c_msg msg
[],
585 struct dvb_usb_device
*d
= i2c_get_adapdata(adap
);
586 struct usb_device
*udev
;
592 if (mutex_lock_interruptible(&d
->i2c_mutex
) < 0)
595 for (j
= 0; j
< num
; j
++) {
596 switch (msg
[j
].addr
) {
597 case (DW2102_RC_QUERY
): {
600 dw210x_op_rw(d
->udev
, 0xb8, 0, 0,
601 ibuf
, 5, DW210X_READ_MSG
);
602 memcpy(msg
[j
].buf
, ibuf
+ 3, 2);
605 case (DW2102_VOLTAGE_CTRL
): {
609 obuf
[1] = msg
[j
].buf
[1];/* off-on */
610 dw210x_op_rw(d
->udev
, 0x8a, 0, 0,
611 obuf
, 2, DW210X_WRITE_MSG
);
613 obuf
[1] = msg
[j
].buf
[0];/* 13v-18v */
614 dw210x_op_rw(d
->udev
, 0x8a, 0, 0,
615 obuf
, 2, DW210X_WRITE_MSG
);
618 case (DW2102_LED_CTRL
): {
622 obuf
[1] = msg
[j
].buf
[0];
623 dw210x_op_rw(d
->udev
, 0x8a, 0, 0,
624 obuf
, 2, DW210X_WRITE_MSG
);
627 /* case 0x55: cx24116
629 * case 0x68: ds3000, stv0903, rs2000
630 * case 0x60: ts2020, stv6110, stb6100
634 if (msg
[j
].flags
== I2C_M_RD
) {
636 u8 ibuf
[MAX_XFER_SIZE
];
638 if (msg
[j
].len
> sizeof(ibuf
)) {
639 warn("i2c rd: len=%d is too big!\n",
645 dw210x_op_rw(d
->udev
, 0x91, 0, 0,
648 memcpy(msg
[j
].buf
, ibuf
, msg
[j
].len
);
650 } else if ((msg
[j
].buf
[0] == 0xb0) && (msg
[j
].addr
== 0x68)) {
654 obuf
[0] = (msg
[j
].len
> 16 ?
655 18 : msg
[j
].len
+ 1);
656 obuf
[1] = msg
[j
].addr
<< 1;
657 obuf
[2] = msg
[j
].buf
[0];
658 len
= msg
[j
].len
- 1;
661 memcpy(obuf
+ 3, msg
[j
].buf
+ i
,
662 (len
> 16 ? 16 : len
));
663 dw210x_op_rw(d
->udev
, 0x80, 0, 0,
664 obuf
, (len
> 16 ? 16 : len
) + 3,
669 } else if (j
< (num
- 1)) {
670 /* write register addr before read */
671 u8 obuf
[MAX_XFER_SIZE
];
673 if (2 + msg
[j
].len
> sizeof(obuf
)) {
674 warn("i2c wr: len=%d is too big!\n",
680 obuf
[0] = msg
[j
+ 1].len
;
681 obuf
[1] = (msg
[j
].addr
<< 1);
682 memcpy(obuf
+ 2, msg
[j
].buf
, msg
[j
].len
);
683 dw210x_op_rw(d
->udev
,
684 le16_to_cpu(udev
->descriptor
.idProduct
) == 0x7500 ? 0x92 : 0x90,
685 0, 0, obuf
, msg
[j
].len
+ 2,
689 /* write registers */
690 u8 obuf
[MAX_XFER_SIZE
];
692 if (2 + msg
[j
].len
> sizeof(obuf
)) {
693 warn("i2c wr: len=%d is too big!\n",
698 obuf
[0] = msg
[j
].len
+ 1;
699 obuf
[1] = (msg
[j
].addr
<< 1);
700 memcpy(obuf
+ 2, msg
[j
].buf
, msg
[j
].len
);
701 dw210x_op_rw(d
->udev
, 0x80, 0, 0,
702 obuf
, msg
[j
].len
+ 2,
713 mutex_unlock(&d
->i2c_mutex
);
717 static int su3000_i2c_transfer(struct i2c_adapter
*adap
, struct i2c_msg msg
[],
720 struct dvb_usb_device
*d
= i2c_get_adapdata(adap
);
721 struct dw2102_state
*state
;
729 if (mutex_lock_interruptible(&d
->i2c_mutex
) < 0)
731 if (mutex_lock_interruptible(&d
->data_mutex
) < 0) {
732 mutex_unlock(&d
->i2c_mutex
);
738 switch (msg
[j
].addr
) {
739 case SU3000_STREAM_CTRL
:
740 state
->data
[0] = msg
[j
].buf
[0] + 0x36;
743 if (dvb_usb_generic_rw(d
, state
->data
, 3,
744 state
->data
, 0, 0) < 0)
745 err("i2c transfer failed.");
747 case DW2102_RC_QUERY
:
748 state
->data
[0] = 0x10;
749 if (dvb_usb_generic_rw(d
, state
->data
, 1,
750 state
->data
, 2, 0) < 0)
751 err("i2c transfer failed.");
752 msg
[j
].buf
[1] = state
->data
[0];
753 msg
[j
].buf
[0] = state
->data
[1];
756 /* if the current write msg is followed by a another
757 * read msg to/from the same address
759 if ((j
+ 1 < num
) && (msg
[j
+ 1].flags
& I2C_M_RD
) &&
760 (msg
[j
].addr
== msg
[j
+ 1].addr
)) {
761 /* join both i2c msgs to one usb read command */
762 if (4 + msg
[j
].len
> sizeof(state
->data
)) {
763 warn("i2c combined wr/rd: write len=%d is too big!\n",
768 if (1 + msg
[j
+ 1].len
> sizeof(state
->data
)) {
769 warn("i2c combined wr/rd: read len=%d is too big!\n",
775 state
->data
[0] = 0x09;
776 state
->data
[1] = msg
[j
].len
;
777 state
->data
[2] = msg
[j
+ 1].len
;
778 state
->data
[3] = msg
[j
].addr
;
779 memcpy(&state
->data
[4], msg
[j
].buf
, msg
[j
].len
);
781 if (dvb_usb_generic_rw(d
, state
->data
, msg
[j
].len
+ 4,
782 state
->data
, msg
[j
+ 1].len
+ 1, 0) < 0)
783 err("i2c transfer failed.");
785 memcpy(msg
[j
+ 1].buf
, &state
->data
[1], msg
[j
+ 1].len
);
790 if (msg
[j
].flags
& I2C_M_RD
) {
792 if (4 + msg
[j
].len
> sizeof(state
->data
)) {
793 warn("i2c rd: len=%d is too big!\n", msg
[j
].len
);
798 state
->data
[0] = 0x09;
800 state
->data
[2] = msg
[j
].len
;
801 state
->data
[3] = msg
[j
].addr
;
802 memcpy(&state
->data
[4], msg
[j
].buf
, msg
[j
].len
);
804 if (dvb_usb_generic_rw(d
, state
->data
, 4,
805 state
->data
, msg
[j
].len
+ 1, 0) < 0)
806 err("i2c transfer failed.");
808 memcpy(msg
[j
].buf
, &state
->data
[1], msg
[j
].len
);
813 if (3 + msg
[j
].len
> sizeof(state
->data
)) {
814 warn("i2c wr: len=%d is too big!\n", msg
[j
].len
);
819 state
->data
[0] = 0x08;
820 state
->data
[1] = msg
[j
].addr
;
821 state
->data
[2] = msg
[j
].len
;
823 memcpy(&state
->data
[3], msg
[j
].buf
, msg
[j
].len
);
825 if (dvb_usb_generic_rw(d
, state
->data
, msg
[j
].len
+ 3,
826 state
->data
, 1, 0) < 0)
827 err("i2c transfer failed.");
832 mutex_unlock(&d
->data_mutex
);
833 mutex_unlock(&d
->i2c_mutex
);
837 static u32
dw210x_i2c_func(struct i2c_adapter
*adapter
)
842 static struct i2c_algorithm dw2102_i2c_algo
= {
843 .master_xfer
= dw2102_i2c_transfer
,
844 .functionality
= dw210x_i2c_func
,
847 static struct i2c_algorithm dw2102_serit_i2c_algo
= {
848 .master_xfer
= dw2102_serit_i2c_transfer
,
849 .functionality
= dw210x_i2c_func
,
852 static struct i2c_algorithm dw2102_earda_i2c_algo
= {
853 .master_xfer
= dw2102_earda_i2c_transfer
,
854 .functionality
= dw210x_i2c_func
,
857 static struct i2c_algorithm dw2104_i2c_algo
= {
858 .master_xfer
= dw2104_i2c_transfer
,
859 .functionality
= dw210x_i2c_func
,
862 static struct i2c_algorithm dw3101_i2c_algo
= {
863 .master_xfer
= dw3101_i2c_transfer
,
864 .functionality
= dw210x_i2c_func
,
867 static struct i2c_algorithm s6x0_i2c_algo
= {
868 .master_xfer
= s6x0_i2c_transfer
,
869 .functionality
= dw210x_i2c_func
,
872 static struct i2c_algorithm su3000_i2c_algo
= {
873 .master_xfer
= su3000_i2c_transfer
,
874 .functionality
= dw210x_i2c_func
,
877 static int dw210x_read_mac_address(struct dvb_usb_device
*d
, u8 mac
[6])
881 u8 eeprom
[256], eepromline
[16];
883 for (i
= 0; i
< 256; i
++) {
884 if (dw210x_op_rw(d
->udev
, 0xb6, 0xa0, i
, ibuf
, 2, DW210X_READ_MSG
) < 0) {
885 err("read eeprom failed.");
888 eepromline
[i
% 16] = ibuf
[0];
891 if ((i
% 16) == 15) {
892 deb_xfer("%02x: ", i
- 15);
893 debug_dump(eepromline
, 16, deb_xfer
);
897 memcpy(mac
, eeprom
+ 8, 6);
901 static int s6x0_read_mac_address(struct dvb_usb_device
*d
, u8 mac
[6])
904 u8 ibuf
[] = { 0 }, obuf
[] = { 0 };
905 u8 eeprom
[256], eepromline
[16];
906 struct i2c_msg msg
[] = {
920 for (i
= 0; i
< 256; i
++) {
922 ret
= s6x0_i2c_transfer(&d
->i2c_adap
, msg
, 2);
924 err("read eeprom failed.");
927 eepromline
[i
% 16] = ibuf
[0];
931 if ((i
% 16) == 15) {
932 deb_xfer("%02x: ", i
- 15);
933 debug_dump(eepromline
, 16, deb_xfer
);
937 memcpy(mac
, eeprom
+ 16, 6);
941 static int su3000_streaming_ctrl(struct dvb_usb_adapter
*adap
, int onoff
)
943 static u8 command_start
[] = {0x00};
944 static u8 command_stop
[] = {0x01};
945 struct i2c_msg msg
= {
946 .addr
= SU3000_STREAM_CTRL
,
948 .buf
= onoff
? command_start
: command_stop
,
952 i2c_transfer(&adap
->dev
->i2c_adap
, &msg
, 1);
957 static int su3000_power_ctrl(struct dvb_usb_device
*d
, int i
)
959 struct dw2102_state
*state
= d
->priv
;
962 info("%s: %d, initialized %d", __func__
, i
, state
->initialized
);
964 if (i
&& !state
->initialized
) {
965 mutex_lock(&d
->data_mutex
);
967 state
->data
[0] = 0xde;
970 state
->initialized
= 1;
972 ret
= dvb_usb_generic_rw(d
, state
->data
, 2, NULL
, 0, 0);
973 mutex_unlock(&d
->data_mutex
);
979 static int su3000_read_mac_address(struct dvb_usb_device
*d
, u8 mac
[6])
982 u8 obuf
[] = { 0x1f, 0xf0 };
984 struct i2c_msg msg
[] = {
998 for (i
= 0; i
< 6; i
++) {
1000 if (i2c_transfer(&d
->i2c_adap
, msg
, 2) != 2)
1009 static int su3000_identify_state(struct usb_device
*udev
,
1010 const struct dvb_usb_device_properties
*props
,
1011 const struct dvb_usb_device_description
**desc
,
1018 static int dw210x_set_voltage(struct dvb_frontend
*fe
,
1019 enum fe_sec_voltage voltage
)
1021 static u8 command_13v
[] = {0x00, 0x01};
1022 static u8 command_18v
[] = {0x01, 0x01};
1023 static u8 command_off
[] = {0x00, 0x00};
1024 struct i2c_msg msg
= {
1025 .addr
= DW2102_VOLTAGE_CTRL
,
1031 struct dvb_usb_adapter
*udev_adap
= fe
->dvb
->priv
;
1033 if (voltage
== SEC_VOLTAGE_18
)
1034 msg
.buf
= command_18v
;
1035 else if (voltage
== SEC_VOLTAGE_13
)
1036 msg
.buf
= command_13v
;
1038 i2c_transfer(&udev_adap
->dev
->i2c_adap
, &msg
, 1);
1043 static int s660_set_voltage(struct dvb_frontend
*fe
,
1044 enum fe_sec_voltage voltage
)
1046 struct dvb_usb_adapter
*d
= fe
->dvb
->priv
;
1047 struct dw2102_state
*st
= d
->dev
->priv
;
1049 dw210x_set_voltage(fe
, voltage
);
1050 if (st
->old_set_voltage
)
1051 st
->old_set_voltage(fe
, voltage
);
1056 static void dw210x_led_ctrl(struct dvb_frontend
*fe
, int offon
)
1058 static u8 led_off
[] = { 0 };
1059 static u8 led_on
[] = { 1 };
1060 struct i2c_msg msg
= {
1061 .addr
= DW2102_LED_CTRL
,
1066 struct dvb_usb_adapter
*udev_adap
= fe
->dvb
->priv
;
1070 i2c_transfer(&udev_adap
->dev
->i2c_adap
, &msg
, 1);
1073 static int tt_s2_4600_read_status(struct dvb_frontend
*fe
,
1074 enum fe_status
*status
)
1076 struct dvb_usb_adapter
*d
= fe
->dvb
->priv
;
1077 struct dw2102_state
*st
= d
->dev
->priv
;
1080 ret
= st
->fe_read_status(fe
, status
);
1082 /* resync slave fifo when signal change from unlock to lock */
1083 if ((*status
& FE_HAS_LOCK
) && (!st
->last_lock
))
1084 su3000_streaming_ctrl(d
, 1);
1086 st
->last_lock
= (*status
& FE_HAS_LOCK
) ? 1 : 0;
1090 static struct stv0299_config sharp_z0194a_config
= {
1091 .demod_address
= 0x68,
1092 .inittab
= sharp_z0194a_inittab
,
1096 .lock_output
= STV0299_LOCKOUTPUT_1
,
1097 .volt13_op0_op1
= STV0299_VOLT13_OP1
,
1098 .min_delay_ms
= 100,
1099 .set_symbol_rate
= sharp_z0194a_set_symbol_rate
,
1102 static struct cx24116_config dw2104_config
= {
1103 .demod_address
= 0x55,
1104 .mpg_clk_pos_pol
= 0x01,
1107 static struct si21xx_config serit_sp1511lhb_config
= {
1108 .demod_address
= 0x68,
1109 .min_delay_ms
= 100,
1113 static struct tda10023_config dw3101_tda10023_config
= {
1114 .demod_address
= 0x0c,
1118 static struct mt312_config zl313_config
= {
1119 .demod_address
= 0x0e,
1122 static struct ds3000_config dw2104_ds3000_config
= {
1123 .demod_address
= 0x68,
1126 static struct ts2020_config dw2104_ts2020_config
= {
1127 .tuner_address
= 0x60,
1129 .frequency_div
= 1060000,
1132 static struct ds3000_config s660_ds3000_config
= {
1133 .demod_address
= 0x68,
1135 .set_lock_led
= dw210x_led_ctrl
,
1138 static struct ts2020_config s660_ts2020_config
= {
1139 .tuner_address
= 0x60,
1141 .frequency_div
= 1146000,
1144 static struct stv0900_config dw2104a_stv0900_config
= {
1145 .demod_address
= 0x6a,
1148 .clkmode
= 3,/* 0-CLKI, 2-XTALI, else AUTO */
1149 .diseqc_mode
= 2,/* 2/3 PWM */
1150 .tun1_maddress
= 0,/* 0x60 */
1151 .tun1_adc
= 0,/* 2 Vpp */
1155 static struct stb6100_config dw2104a_stb6100_config
= {
1156 .tuner_address
= 0x60,
1157 .refclock
= 27000000,
1160 static struct stv0900_config dw2104_stv0900_config
= {
1161 .demod_address
= 0x68,
1167 .tun1_adc
= 1,/* 1 Vpp */
1171 static struct stv6110_config dw2104_stv6110_config
= {
1172 .i2c_address
= 0x60,
1177 static struct stv0900_config prof_7500_stv0900_config
= {
1178 .demod_address
= 0x6a,
1181 .clkmode
= 3,/* 0-CLKI, 2-XTALI, else AUTO */
1182 .diseqc_mode
= 2,/* 2/3 PWM */
1183 .tun1_maddress
= 0,/* 0x60 */
1184 .tun1_adc
= 0,/* 2 Vpp */
1187 .set_lock_led
= dw210x_led_ctrl
,
1190 static struct ds3000_config su3000_ds3000_config
= {
1191 .demod_address
= 0x68,
1193 .set_lock_led
= dw210x_led_ctrl
,
1196 static struct cxd2820r_config cxd2820r_config
= {
1197 .i2c_address
= 0x6c, /* (0xd8 >> 1) */
1202 static struct tda18271_config tda18271_config
= {
1203 .output_opt
= TDA18271_OUTPUT_LT_OFF
,
1204 .gate
= TDA18271_GATE_DIGITAL
,
1207 static u8 m88rs2000_inittab
[] = {
1208 DEMOD_WRITE
, 0x9a, 0x30,
1209 DEMOD_WRITE
, 0x00, 0x01,
1210 WRITE_DELAY
, 0x19, 0x00,
1211 DEMOD_WRITE
, 0x00, 0x00,
1212 DEMOD_WRITE
, 0x9a, 0xb0,
1213 DEMOD_WRITE
, 0x81, 0xc1,
1214 DEMOD_WRITE
, 0x81, 0x81,
1215 DEMOD_WRITE
, 0x86, 0xc6,
1216 DEMOD_WRITE
, 0x9a, 0x30,
1217 DEMOD_WRITE
, 0xf0, 0x80,
1218 DEMOD_WRITE
, 0xf1, 0xbf,
1219 DEMOD_WRITE
, 0xb0, 0x45,
1220 DEMOD_WRITE
, 0xb2, 0x01,
1221 DEMOD_WRITE
, 0x9a, 0xb0,
1225 static struct m88rs2000_config s421_m88rs2000_config
= {
1227 .inittab
= m88rs2000_inittab
,
1230 static int dw2104_frontend_attach(struct dvb_usb_adapter
*d
)
1232 struct dvb_tuner_ops
*tuner_ops
= NULL
;
1234 if (demod_probe
& 4) {
1235 d
->fe_adap
[0].fe
= dvb_attach(stv0900_attach
, &dw2104a_stv0900_config
,
1236 &d
->dev
->i2c_adap
, 0);
1237 if (d
->fe_adap
[0].fe
) {
1238 if (dvb_attach(stb6100_attach
, d
->fe_adap
[0].fe
,
1239 &dw2104a_stb6100_config
,
1240 &d
->dev
->i2c_adap
)) {
1241 tuner_ops
= &d
->fe_adap
[0].fe
->ops
.tuner_ops
;
1242 tuner_ops
->set_frequency
= stb6100_set_freq
;
1243 tuner_ops
->get_frequency
= stb6100_get_freq
;
1244 tuner_ops
->set_bandwidth
= stb6100_set_bandw
;
1245 tuner_ops
->get_bandwidth
= stb6100_get_bandw
;
1246 d
->fe_adap
[0].fe
->ops
.set_voltage
= dw210x_set_voltage
;
1247 info("Attached STV0900+STB6100!");
1253 if (demod_probe
& 2) {
1254 d
->fe_adap
[0].fe
= dvb_attach(stv0900_attach
, &dw2104_stv0900_config
,
1255 &d
->dev
->i2c_adap
, 0);
1256 if (d
->fe_adap
[0].fe
) {
1257 if (dvb_attach(stv6110_attach
, d
->fe_adap
[0].fe
,
1258 &dw2104_stv6110_config
,
1259 &d
->dev
->i2c_adap
)) {
1260 d
->fe_adap
[0].fe
->ops
.set_voltage
= dw210x_set_voltage
;
1261 info("Attached STV0900+STV6110A!");
1267 if (demod_probe
& 1) {
1268 d
->fe_adap
[0].fe
= dvb_attach(cx24116_attach
, &dw2104_config
,
1270 if (d
->fe_adap
[0].fe
) {
1271 d
->fe_adap
[0].fe
->ops
.set_voltage
= dw210x_set_voltage
;
1272 info("Attached cx24116!");
1277 d
->fe_adap
[0].fe
= dvb_attach(ds3000_attach
, &dw2104_ds3000_config
,
1279 if (d
->fe_adap
[0].fe
) {
1280 dvb_attach(ts2020_attach
, d
->fe_adap
[0].fe
,
1281 &dw2104_ts2020_config
, &d
->dev
->i2c_adap
);
1282 d
->fe_adap
[0].fe
->ops
.set_voltage
= dw210x_set_voltage
;
1283 info("Attached DS3000!");
1290 static struct dvb_usb_device_properties dw2102_properties
;
1291 static struct dvb_usb_device_properties dw2104_properties
;
1292 static struct dvb_usb_device_properties s6x0_properties
;
1294 static int dw2102_frontend_attach(struct dvb_usb_adapter
*d
)
1296 if (dw2102_properties
.i2c_algo
== &dw2102_serit_i2c_algo
) {
1297 /*dw2102_properties.adapter->tuner_attach = NULL;*/
1298 d
->fe_adap
[0].fe
= dvb_attach(si21xx_attach
, &serit_sp1511lhb_config
,
1300 if (d
->fe_adap
[0].fe
) {
1301 d
->fe_adap
[0].fe
->ops
.set_voltage
= dw210x_set_voltage
;
1302 info("Attached si21xx!");
1307 if (dw2102_properties
.i2c_algo
== &dw2102_earda_i2c_algo
) {
1308 d
->fe_adap
[0].fe
= dvb_attach(stv0288_attach
, &earda_config
,
1310 if (d
->fe_adap
[0].fe
) {
1311 if (dvb_attach(stb6000_attach
, d
->fe_adap
[0].fe
, 0x61,
1312 &d
->dev
->i2c_adap
)) {
1313 d
->fe_adap
[0].fe
->ops
.set_voltage
= dw210x_set_voltage
;
1314 info("Attached stv0288!");
1320 if (dw2102_properties
.i2c_algo
== &dw2102_i2c_algo
) {
1321 /*dw2102_properties.adapter->tuner_attach = dw2102_tuner_attach;*/
1322 d
->fe_adap
[0].fe
= dvb_attach(stv0299_attach
, &sharp_z0194a_config
,
1324 if (d
->fe_adap
[0].fe
) {
1325 d
->fe_adap
[0].fe
->ops
.set_voltage
= dw210x_set_voltage
;
1326 info("Attached stv0299!");
1333 static int dw3101_frontend_attach(struct dvb_usb_adapter
*d
)
1335 d
->fe_adap
[0].fe
= dvb_attach(tda10023_attach
, &dw3101_tda10023_config
,
1336 &d
->dev
->i2c_adap
, 0x48);
1337 if (d
->fe_adap
[0].fe
) {
1338 info("Attached tda10023!");
1344 static int zl100313_frontend_attach(struct dvb_usb_adapter
*d
)
1346 d
->fe_adap
[0].fe
= dvb_attach(mt312_attach
, &zl313_config
,
1348 if (d
->fe_adap
[0].fe
) {
1349 if (dvb_attach(zl10039_attach
, d
->fe_adap
[0].fe
, 0x60,
1350 &d
->dev
->i2c_adap
)) {
1351 d
->fe_adap
[0].fe
->ops
.set_voltage
= dw210x_set_voltage
;
1352 info("Attached zl100313+zl10039!");
1360 static int stv0288_frontend_attach(struct dvb_usb_adapter
*d
)
1364 d
->fe_adap
[0].fe
= dvb_attach(stv0288_attach
, &earda_config
,
1367 if (!d
->fe_adap
[0].fe
)
1370 if (dvb_attach(stb6000_attach
, d
->fe_adap
[0].fe
, 0x61, &d
->dev
->i2c_adap
) == NULL
)
1373 d
->fe_adap
[0].fe
->ops
.set_voltage
= dw210x_set_voltage
;
1375 dw210x_op_rw(d
->dev
->udev
, 0x8a, 0, 0, obuf
, 2, DW210X_WRITE_MSG
);
1377 info("Attached stv0288+stb6000!");
1382 static int ds3000_frontend_attach(struct dvb_usb_adapter
*d
)
1384 struct dw2102_state
*st
= d
->dev
->priv
;
1387 d
->fe_adap
[0].fe
= dvb_attach(ds3000_attach
, &s660_ds3000_config
,
1390 if (!d
->fe_adap
[0].fe
)
1393 dvb_attach(ts2020_attach
, d
->fe_adap
[0].fe
, &s660_ts2020_config
,
1396 st
->old_set_voltage
= d
->fe_adap
[0].fe
->ops
.set_voltage
;
1397 d
->fe_adap
[0].fe
->ops
.set_voltage
= s660_set_voltage
;
1399 dw210x_op_rw(d
->dev
->udev
, 0x8a, 0, 0, obuf
, 2, DW210X_WRITE_MSG
);
1401 info("Attached ds3000+ts2020!");
1406 static int prof_7500_frontend_attach(struct dvb_usb_adapter
*d
)
1410 d
->fe_adap
[0].fe
= dvb_attach(stv0900_attach
, &prof_7500_stv0900_config
,
1411 &d
->dev
->i2c_adap
, 0);
1412 if (!d
->fe_adap
[0].fe
)
1415 d
->fe_adap
[0].fe
->ops
.set_voltage
= dw210x_set_voltage
;
1417 dw210x_op_rw(d
->dev
->udev
, 0x8a, 0, 0, obuf
, 2, DW210X_WRITE_MSG
);
1419 info("Attached STV0900+STB6100A!");
1424 static int su3000_frontend_attach(struct dvb_usb_adapter
*adap
)
1426 struct dvb_usb_device
*d
= adap
->dev
;
1427 struct dw2102_state
*state
= d
->priv
;
1429 mutex_lock(&d
->data_mutex
);
1431 state
->data
[0] = 0xe;
1432 state
->data
[1] = 0x80;
1435 if (dvb_usb_generic_rw(d
, state
->data
, 3, state
->data
, 1, 0) < 0)
1436 err("command 0x0e transfer failed.");
1438 state
->data
[0] = 0xe;
1439 state
->data
[1] = 0x02;
1442 if (dvb_usb_generic_rw(d
, state
->data
, 3, state
->data
, 1, 0) < 0)
1443 err("command 0x0e transfer failed.");
1446 state
->data
[0] = 0xe;
1447 state
->data
[1] = 0x83;
1450 if (dvb_usb_generic_rw(d
, state
->data
, 3, state
->data
, 1, 0) < 0)
1451 err("command 0x0e transfer failed.");
1453 state
->data
[0] = 0xe;
1454 state
->data
[1] = 0x83;
1457 if (dvb_usb_generic_rw(d
, state
->data
, 3, state
->data
, 1, 0) < 0)
1458 err("command 0x0e transfer failed.");
1460 state
->data
[0] = 0x51;
1462 if (dvb_usb_generic_rw(d
, state
->data
, 1, state
->data
, 1, 0) < 0)
1463 err("command 0x51 transfer failed.");
1465 mutex_unlock(&d
->data_mutex
);
1467 adap
->fe_adap
[0].fe
= dvb_attach(ds3000_attach
, &su3000_ds3000_config
,
1469 if (!adap
->fe_adap
[0].fe
)
1472 if (dvb_attach(ts2020_attach
, adap
->fe_adap
[0].fe
,
1473 &dw2104_ts2020_config
,
1475 info("Attached DS3000/TS2020!");
1479 info("Failed to attach DS3000/TS2020!");
1483 static int t220_frontend_attach(struct dvb_usb_adapter
*adap
)
1485 struct dvb_usb_device
*d
= adap
->dev
;
1486 struct dw2102_state
*state
= d
->priv
;
1488 mutex_lock(&d
->data_mutex
);
1490 state
->data
[0] = 0xe;
1491 state
->data
[1] = 0x87;
1492 state
->data
[2] = 0x0;
1494 if (dvb_usb_generic_rw(d
, state
->data
, 3, state
->data
, 1, 0) < 0)
1495 err("command 0x0e transfer failed.");
1497 state
->data
[0] = 0xe;
1498 state
->data
[1] = 0x86;
1501 if (dvb_usb_generic_rw(d
, state
->data
, 3, state
->data
, 1, 0) < 0)
1502 err("command 0x0e transfer failed.");
1504 state
->data
[0] = 0xe;
1505 state
->data
[1] = 0x80;
1508 if (dvb_usb_generic_rw(d
, state
->data
, 3, state
->data
, 1, 0) < 0)
1509 err("command 0x0e transfer failed.");
1513 state
->data
[0] = 0xe;
1514 state
->data
[1] = 0x80;
1517 if (dvb_usb_generic_rw(d
, state
->data
, 3, state
->data
, 1, 0) < 0)
1518 err("command 0x0e transfer failed.");
1520 state
->data
[0] = 0x51;
1522 if (dvb_usb_generic_rw(d
, state
->data
, 1, state
->data
, 1, 0) < 0)
1523 err("command 0x51 transfer failed.");
1525 mutex_unlock(&d
->data_mutex
);
1527 adap
->fe_adap
[0].fe
= dvb_attach(cxd2820r_attach
, &cxd2820r_config
,
1528 &d
->i2c_adap
, NULL
);
1529 if (adap
->fe_adap
[0].fe
) {
1530 if (dvb_attach(tda18271_attach
, adap
->fe_adap
[0].fe
, 0x60,
1531 &d
->i2c_adap
, &tda18271_config
)) {
1532 info("Attached TDA18271HD/CXD2820R!");
1537 info("Failed to attach TDA18271HD/CXD2820R!");
1541 static int m88rs2000_frontend_attach(struct dvb_usb_adapter
*adap
)
1543 struct dvb_usb_device
*d
= adap
->dev
;
1544 struct dw2102_state
*state
= d
->priv
;
1546 mutex_lock(&d
->data_mutex
);
1548 state
->data
[0] = 0x51;
1550 if (dvb_usb_generic_rw(d
, state
->data
, 1, state
->data
, 1, 0) < 0)
1551 err("command 0x51 transfer failed.");
1553 mutex_unlock(&d
->data_mutex
);
1555 adap
->fe_adap
[0].fe
= dvb_attach(m88rs2000_attach
,
1556 &s421_m88rs2000_config
,
1559 if (!adap
->fe_adap
[0].fe
)
1562 if (dvb_attach(ts2020_attach
, adap
->fe_adap
[0].fe
,
1563 &dw2104_ts2020_config
,
1565 info("Attached RS2000/TS2020!");
1569 info("Failed to attach RS2000/TS2020!");
1573 static int tt_s2_4600_frontend_attach_probe_demod(struct dvb_usb_device
*d
,
1574 const int probe_addr
)
1576 struct dw2102_state
*state
= d
->priv
;
1578 state
->data
[0] = 0x9;
1579 state
->data
[1] = 0x1;
1580 state
->data
[2] = 0x1;
1581 state
->data
[3] = probe_addr
;
1582 state
->data
[4] = 0x0;
1584 if (dvb_usb_generic_rw(d
, state
->data
, 5, state
->data
, 2, 0) < 0) {
1585 err("i2c probe for address 0x%x failed.", probe_addr
);
1589 if (state
->data
[0] != 8) /* fail(7) or error, no device at address */
1592 /* probing successful */
1596 static int tt_s2_4600_frontend_attach(struct dvb_usb_adapter
*adap
)
1598 struct dvb_usb_device
*d
= adap
->dev
;
1599 struct dw2102_state
*state
= d
->priv
;
1600 struct i2c_adapter
*i2c_adapter
;
1601 struct i2c_client
*client
;
1602 struct i2c_board_info board_info
;
1603 struct m88ds3103_platform_data m88ds3103_pdata
= {};
1604 struct ts2020_config ts2020_config
= {};
1607 mutex_lock(&d
->data_mutex
);
1609 state
->data
[0] = 0xe;
1610 state
->data
[1] = 0x80;
1611 state
->data
[2] = 0x0;
1613 if (dvb_usb_generic_rw(d
, state
->data
, 3, state
->data
, 1, 0) < 0)
1614 err("command 0x0e transfer failed.");
1616 state
->data
[0] = 0xe;
1617 state
->data
[1] = 0x02;
1620 if (dvb_usb_generic_rw(d
, state
->data
, 3, state
->data
, 1, 0) < 0)
1621 err("command 0x0e transfer failed.");
1624 state
->data
[0] = 0xe;
1625 state
->data
[1] = 0x83;
1628 if (dvb_usb_generic_rw(d
, state
->data
, 3, state
->data
, 1, 0) < 0)
1629 err("command 0x0e transfer failed.");
1631 state
->data
[0] = 0xe;
1632 state
->data
[1] = 0x83;
1635 if (dvb_usb_generic_rw(d
, state
->data
, 3, state
->data
, 1, 0) < 0)
1636 err("command 0x0e transfer failed.");
1638 state
->data
[0] = 0x51;
1640 if (dvb_usb_generic_rw(d
, state
->data
, 1, state
->data
, 1, 0) < 0)
1641 err("command 0x51 transfer failed.");
1643 /* probe for demodulator i2c address */
1645 if (tt_s2_4600_frontend_attach_probe_demod(d
, 0x68))
1647 else if (tt_s2_4600_frontend_attach_probe_demod(d
, 0x69))
1649 else if (tt_s2_4600_frontend_attach_probe_demod(d
, 0x6a))
1652 mutex_unlock(&d
->data_mutex
);
1654 if (demod_addr
< 0) {
1655 err("probing for demodulator failed. Is the external power switched on?");
1660 m88ds3103_pdata
.clk
= 27000000;
1661 m88ds3103_pdata
.i2c_wr_max
= 33;
1662 m88ds3103_pdata
.ts_mode
= M88DS3103_TS_CI
;
1663 m88ds3103_pdata
.ts_clk
= 16000;
1664 m88ds3103_pdata
.ts_clk_pol
= 0;
1665 m88ds3103_pdata
.spec_inv
= 0;
1666 m88ds3103_pdata
.agc
= 0x99;
1667 m88ds3103_pdata
.agc_inv
= 0;
1668 m88ds3103_pdata
.clk_out
= M88DS3103_CLOCK_OUT_ENABLED
;
1669 m88ds3103_pdata
.envelope_mode
= 0;
1670 m88ds3103_pdata
.lnb_hv_pol
= 1;
1671 m88ds3103_pdata
.lnb_en_pol
= 0;
1672 memset(&board_info
, 0, sizeof(board_info
));
1673 if (demod_addr
== 0x6a)
1674 strscpy(board_info
.type
, "m88ds3103b", I2C_NAME_SIZE
);
1676 strscpy(board_info
.type
, "m88ds3103", I2C_NAME_SIZE
);
1677 board_info
.addr
= demod_addr
;
1678 board_info
.platform_data
= &m88ds3103_pdata
;
1679 request_module("m88ds3103");
1680 client
= i2c_new_client_device(&d
->i2c_adap
, &board_info
);
1681 if (!i2c_client_has_driver(client
))
1683 if (!try_module_get(client
->dev
.driver
->owner
)) {
1684 i2c_unregister_device(client
);
1687 adap
->fe_adap
[0].fe
= m88ds3103_pdata
.get_dvb_frontend(client
);
1688 i2c_adapter
= m88ds3103_pdata
.get_i2c_adapter(client
);
1690 state
->i2c_client_demod
= client
;
1693 ts2020_config
.fe
= adap
->fe_adap
[0].fe
;
1694 memset(&board_info
, 0, sizeof(board_info
));
1695 strscpy(board_info
.type
, "ts2022", I2C_NAME_SIZE
);
1696 board_info
.addr
= 0x60;
1697 board_info
.platform_data
= &ts2020_config
;
1698 request_module("ts2020");
1699 client
= i2c_new_client_device(i2c_adapter
, &board_info
);
1701 if (!i2c_client_has_driver(client
)) {
1702 dvb_frontend_detach(adap
->fe_adap
[0].fe
);
1706 if (!try_module_get(client
->dev
.driver
->owner
)) {
1707 i2c_unregister_device(client
);
1708 dvb_frontend_detach(adap
->fe_adap
[0].fe
);
1712 /* delegate signal strength measurement to tuner */
1713 adap
->fe_adap
[0].fe
->ops
.read_signal_strength
=
1714 adap
->fe_adap
[0].fe
->ops
.tuner_ops
.get_rf_strength
;
1716 state
->i2c_client_tuner
= client
;
1718 /* hook fe: need to resync the slave fifo when signal locks */
1719 state
->fe_read_status
= adap
->fe_adap
[0].fe
->ops
.read_status
;
1720 adap
->fe_adap
[0].fe
->ops
.read_status
= tt_s2_4600_read_status
;
1722 state
->last_lock
= 0;
1727 static int dw2102_tuner_attach(struct dvb_usb_adapter
*adap
)
1729 dvb_attach(dvb_pll_attach
, adap
->fe_adap
[0].fe
, 0x60,
1730 &adap
->dev
->i2c_adap
, DVB_PLL_OPERA1
);
1734 static int dw3101_tuner_attach(struct dvb_usb_adapter
*adap
)
1736 dvb_attach(dvb_pll_attach
, adap
->fe_adap
[0].fe
, 0x60,
1737 &adap
->dev
->i2c_adap
, DVB_PLL_TUA6034
);
1742 static int dw2102_rc_query(struct dvb_usb_device
*d
)
1745 struct i2c_msg msg
= {
1746 .addr
= DW2102_RC_QUERY
,
1752 if (d
->props
.i2c_algo
->master_xfer(&d
->i2c_adap
, &msg
, 1) == 1) {
1753 if (msg
.buf
[0] != 0xff) {
1754 deb_rc("%s: rc code: %x, %x\n",
1755 __func__
, key
[0], key
[1]);
1756 rc_keydown(d
->rc_dev
, RC_PROTO_UNKNOWN
, key
[0], 0);
1763 static int prof_rc_query(struct dvb_usb_device
*d
)
1766 struct i2c_msg msg
= {
1767 .addr
= DW2102_RC_QUERY
,
1773 if (d
->props
.i2c_algo
->master_xfer(&d
->i2c_adap
, &msg
, 1) == 1) {
1774 if (msg
.buf
[0] != 0xff) {
1775 deb_rc("%s: rc code: %x, %x\n",
1776 __func__
, key
[0], key
[1]);
1777 rc_keydown(d
->rc_dev
, RC_PROTO_UNKNOWN
, key
[0] ^ 0xff,
1785 static int su3000_rc_query(struct dvb_usb_device
*d
)
1788 struct i2c_msg msg
= {
1789 .addr
= DW2102_RC_QUERY
,
1795 if (d
->props
.i2c_algo
->master_xfer(&d
->i2c_adap
, &msg
, 1) == 1) {
1796 if (msg
.buf
[0] != 0xff) {
1797 deb_rc("%s: rc code: %x, %x\n",
1798 __func__
, key
[0], key
[1]);
1799 rc_keydown(d
->rc_dev
, RC_PROTO_RC5
,
1800 RC_SCANCODE_RC5(key
[1], key
[0]), 0);
1807 enum dw2102_table_entry
{
1820 TERRATEC_CINERGY_S2_R1
,
1823 GENIATECH_X3M_SPC1400HD
,
1826 TERRATEC_CINERGY_S2_R2
,
1827 TERRATEC_CINERGY_S2_R3
,
1828 TERRATEC_CINERGY_S2_R4
,
1829 TERRATEC_CINERGY_S2_1
,
1830 TERRATEC_CINERGY_S2_2
,
1833 TECHNOTREND_CONNECT_S2_4600
,
1839 static struct usb_device_id dw2102_table
[] = {
1840 DVB_USB_DEV(CYPRESS
, CYPRESS_DW2102
),
1841 DVB_USB_DEV(CYPRESS
, CYPRESS_DW2101
),
1842 DVB_USB_DEV(CYPRESS
, CYPRESS_DW2104
),
1843 DVB_USB_DEV(TEVII
, TEVII_S650
),
1844 DVB_USB_DEV(TERRATEC
, TERRATEC_CINERGY_S
),
1845 DVB_USB_DEV(CYPRESS
, CYPRESS_DW3101
),
1846 DVB_USB_DEV(TEVII
, TEVII_S630
),
1847 DVB_USB_DEV(PROF_1
, PROF_1100
),
1848 DVB_USB_DEV(TEVII
, TEVII_S660
),
1849 DVB_USB_DEV(PROF_2
, PROF_7500
),
1850 DVB_USB_DEV(GTEK
, GENIATECH_SU3000
),
1851 DVB_USB_DEV(HAUPPAUGE
, HAUPPAUGE_MAX_S2
),
1852 DVB_USB_DEV(TERRATEC
, TERRATEC_CINERGY_S2_R1
),
1853 DVB_USB_DEV(TEVII
, TEVII_S480_1
),
1854 DVB_USB_DEV(TEVII
, TEVII_S480_2
),
1855 DVB_USB_DEV(GTEK
, GENIATECH_X3M_SPC1400HD
),
1856 DVB_USB_DEV(TEVII
, TEVII_S421
),
1857 DVB_USB_DEV(TEVII
, TEVII_S632
),
1858 DVB_USB_DEV(TERRATEC
, TERRATEC_CINERGY_S2_R2
),
1859 DVB_USB_DEV(TERRATEC
, TERRATEC_CINERGY_S2_R3
),
1860 DVB_USB_DEV(TERRATEC
, TERRATEC_CINERGY_S2_R4
),
1861 DVB_USB_DEV(TERRATEC_2
, TERRATEC_CINERGY_S2_1
),
1862 DVB_USB_DEV(TERRATEC_2
, TERRATEC_CINERGY_S2_2
),
1863 DVB_USB_DEV(GOTVIEW
, GOTVIEW_SAT_HD
),
1864 DVB_USB_DEV(GTEK
, GENIATECH_T220
),
1865 DVB_USB_DEV(TECHNOTREND
, TECHNOTREND_CONNECT_S2_4600
),
1866 DVB_USB_DEV(TEVII
, TEVII_S482_1
),
1867 DVB_USB_DEV(TEVII
, TEVII_S482_2
),
1868 DVB_USB_DEV(TEVII
, TEVII_S662
),
1872 MODULE_DEVICE_TABLE(usb
, dw2102_table
);
1874 static int dw2102_load_firmware(struct usb_device
*dev
,
1875 const struct firmware
*frmwr
)
1880 u8 reset16
[] = {0, 0, 0, 0, 0, 0, 0};
1881 const struct firmware
*fw
;
1883 switch (le16_to_cpu(dev
->descriptor
.idProduct
)) {
1885 ret
= request_firmware(&fw
, DW2101_FIRMWARE
, &dev
->dev
);
1887 err(err_str
, DW2101_FIRMWARE
);
1895 info("start downloading DW210X firmware");
1896 p
= kmalloc(fw
->size
, GFP_KERNEL
);
1899 dw210x_op_rw(dev
, 0xa0, 0x7f92, 0, &reset
, 1, DW210X_WRITE_MSG
);
1900 dw210x_op_rw(dev
, 0xa0, 0xe600, 0, &reset
, 1, DW210X_WRITE_MSG
);
1903 memcpy(p
, fw
->data
, fw
->size
);
1904 for (i
= 0; i
< fw
->size
; i
+= 0x40) {
1906 if (dw210x_op_rw(dev
, 0xa0, i
, 0, b
, 0x40,
1907 DW210X_WRITE_MSG
) != 0x40) {
1908 err("error while transferring firmware");
1913 /* restart the CPU */
1915 if (ret
|| dw210x_op_rw(dev
, 0xa0, 0x7f92, 0, &reset
, 1,
1916 DW210X_WRITE_MSG
) != 1) {
1917 err("could not restart the USB controller CPU.");
1920 if (ret
|| dw210x_op_rw(dev
, 0xa0, 0xe600, 0, &reset
, 1,
1921 DW210X_WRITE_MSG
) != 1) {
1922 err("could not restart the USB controller CPU.");
1925 /* init registers */
1926 switch (le16_to_cpu(dev
->descriptor
.idProduct
)) {
1927 case USB_PID_TEVII_S650
:
1928 dw2104_properties
.rc
.core
.rc_codes
= RC_MAP_TEVII_NEC
;
1930 case USB_PID_CYPRESS_DW2104
:
1932 dw210x_op_rw(dev
, 0xc4, 0x0000, 0, &reset
, 1,
1935 case USB_PID_CYPRESS_DW3101
:
1937 dw210x_op_rw(dev
, 0xbf, 0x0040, 0, &reset
, 0,
1940 case USB_PID_TERRATEC_CINERGY_S
:
1941 case USB_PID_CYPRESS_DW2102
:
1942 dw210x_op_rw(dev
, 0xbf, 0x0040, 0, &reset
, 0,
1944 dw210x_op_rw(dev
, 0xb9, 0x0000, 0, &reset16
[0], 2,
1946 /* check STV0299 frontend */
1947 dw210x_op_rw(dev
, 0xb5, 0, 0, &reset16
[0], 2,
1949 if ((reset16
[0] == 0xa1) || (reset16
[0] == 0x80)) {
1950 dw2102_properties
.i2c_algo
= &dw2102_i2c_algo
;
1951 dw2102_properties
.adapter
->fe
[0].tuner_attach
= &dw2102_tuner_attach
;
1954 /* check STV0288 frontend */
1958 dw210x_op_rw(dev
, 0xc2, 0, 0, &reset16
[0], 3,
1960 dw210x_op_rw(dev
, 0xc3, 0xd1, 0, &reset16
[0], 3,
1962 if (reset16
[2] == 0x11) {
1963 dw2102_properties
.i2c_algo
= &dw2102_earda_i2c_algo
;
1968 dw210x_op_rw(dev
, 0xbc, 0x0030, 0, &reset16
[0], 2,
1970 dw210x_op_rw(dev
, 0xba, 0x0000, 0, &reset16
[0], 7,
1972 dw210x_op_rw(dev
, 0xba, 0x0000, 0, &reset16
[0], 7,
1974 dw210x_op_rw(dev
, 0xb9, 0x0000, 0, &reset16
[0], 2,
1983 if (le16_to_cpu(dev
->descriptor
.idProduct
) == 0x2101)
1984 release_firmware(fw
);
1988 static struct dvb_usb_device_properties dw2102_properties
= {
1989 .caps
= DVB_USB_IS_AN_I2C_ADAPTER
,
1990 .usb_ctrl
= DEVICE_SPECIFIC
,
1991 .firmware
= DW2102_FIRMWARE
,
1994 .i2c_algo
= &dw2102_serit_i2c_algo
,
1998 .rc_codes
= RC_MAP_DM1105_NEC
,
1999 .module_name
= "dw2102",
2000 .allowed_protos
= RC_PROTO_BIT_NEC
,
2001 .rc_query
= dw2102_rc_query
,
2004 .generic_bulk_ctrl_endpoint
= 0x81,
2005 /* parameter for the MPEG2-data transfer */
2007 .download_firmware
= dw2102_load_firmware
,
2008 .read_mac_address
= dw210x_read_mac_address
,
2013 .frontend_attach
= dw2102_frontend_attach
,
2027 .num_device_descs
= 3,
2029 {"DVBWorld DVB-S 2102 USB2.0",
2030 {&dw2102_table
[CYPRESS_DW2102
], NULL
},
2033 {"DVBWorld DVB-S 2101 USB2.0",
2034 {&dw2102_table
[CYPRESS_DW2101
], NULL
},
2037 {"TerraTec Cinergy S USB",
2038 {&dw2102_table
[TERRATEC_CINERGY_S
], NULL
},
2044 static struct dvb_usb_device_properties dw2104_properties
= {
2045 .caps
= DVB_USB_IS_AN_I2C_ADAPTER
,
2046 .usb_ctrl
= DEVICE_SPECIFIC
,
2047 .firmware
= DW2104_FIRMWARE
,
2050 .i2c_algo
= &dw2104_i2c_algo
,
2053 .rc_codes
= RC_MAP_DM1105_NEC
,
2054 .module_name
= "dw2102",
2055 .allowed_protos
= RC_PROTO_BIT_NEC
,
2056 .rc_query
= dw2102_rc_query
,
2059 .generic_bulk_ctrl_endpoint
= 0x81,
2060 /* parameter for the MPEG2-data transfer */
2062 .download_firmware
= dw2102_load_firmware
,
2063 .read_mac_address
= dw210x_read_mac_address
,
2068 .frontend_attach
= dw2104_frontend_attach
,
2082 .num_device_descs
= 2,
2084 { "DVBWorld DW2104 USB2.0",
2085 {&dw2102_table
[CYPRESS_DW2104
], NULL
},
2088 { "TeVii S650 USB2.0",
2089 {&dw2102_table
[TEVII_S650
], NULL
},
2095 static struct dvb_usb_device_properties dw3101_properties
= {
2096 .caps
= DVB_USB_IS_AN_I2C_ADAPTER
,
2097 .usb_ctrl
= DEVICE_SPECIFIC
,
2098 .firmware
= DW3101_FIRMWARE
,
2101 .i2c_algo
= &dw3101_i2c_algo
,
2104 .rc_codes
= RC_MAP_DM1105_NEC
,
2105 .module_name
= "dw2102",
2106 .allowed_protos
= RC_PROTO_BIT_NEC
,
2107 .rc_query
= dw2102_rc_query
,
2110 .generic_bulk_ctrl_endpoint
= 0x81,
2111 /* parameter for the MPEG2-data transfer */
2113 .download_firmware
= dw2102_load_firmware
,
2114 .read_mac_address
= dw210x_read_mac_address
,
2119 .frontend_attach
= dw3101_frontend_attach
,
2120 .tuner_attach
= dw3101_tuner_attach
,
2134 .num_device_descs
= 1,
2136 { "DVBWorld DVB-C 3101 USB2.0",
2137 {&dw2102_table
[CYPRESS_DW3101
], NULL
},
2143 static struct dvb_usb_device_properties s6x0_properties
= {
2144 .caps
= DVB_USB_IS_AN_I2C_ADAPTER
,
2145 .usb_ctrl
= DEVICE_SPECIFIC
,
2146 .size_of_priv
= sizeof(struct dw2102_state
),
2147 .firmware
= S630_FIRMWARE
,
2150 .i2c_algo
= &s6x0_i2c_algo
,
2153 .rc_codes
= RC_MAP_TEVII_NEC
,
2154 .module_name
= "dw2102",
2155 .allowed_protos
= RC_PROTO_BIT_NEC
,
2156 .rc_query
= dw2102_rc_query
,
2159 .generic_bulk_ctrl_endpoint
= 0x81,
2161 .download_firmware
= dw2102_load_firmware
,
2162 .read_mac_address
= s6x0_read_mac_address
,
2167 .frontend_attach
= zl100313_frontend_attach
,
2181 .num_device_descs
= 1,
2184 {&dw2102_table
[TEVII_S630
], NULL
},
2190 static struct dvb_usb_device_properties p1100_properties
= {
2191 .caps
= DVB_USB_IS_AN_I2C_ADAPTER
,
2192 .usb_ctrl
= DEVICE_SPECIFIC
,
2193 .size_of_priv
= sizeof(struct dw2102_state
),
2194 .firmware
= P1100_FIRMWARE
,
2197 .i2c_algo
= &s6x0_i2c_algo
,
2200 .rc_codes
= RC_MAP_TBS_NEC
,
2201 .module_name
= "dw2102",
2202 .allowed_protos
= RC_PROTO_BIT_NEC
,
2203 .rc_query
= prof_rc_query
,
2206 .generic_bulk_ctrl_endpoint
= 0x81,
2208 .download_firmware
= dw2102_load_firmware
,
2209 .read_mac_address
= s6x0_read_mac_address
,
2214 .frontend_attach
= stv0288_frontend_attach
,
2228 .num_device_descs
= 1,
2231 {&dw2102_table
[PROF_1100
], NULL
},
2237 static struct dvb_usb_device_properties s660_properties
= {
2238 .caps
= DVB_USB_IS_AN_I2C_ADAPTER
,
2239 .usb_ctrl
= DEVICE_SPECIFIC
,
2240 .size_of_priv
= sizeof(struct dw2102_state
),
2241 .firmware
= S660_FIRMWARE
,
2244 .i2c_algo
= &s6x0_i2c_algo
,
2247 .rc_codes
= RC_MAP_TEVII_NEC
,
2248 .module_name
= "dw2102",
2249 .allowed_protos
= RC_PROTO_BIT_NEC
,
2250 .rc_query
= dw2102_rc_query
,
2253 .generic_bulk_ctrl_endpoint
= 0x81,
2255 .download_firmware
= dw2102_load_firmware
,
2256 .read_mac_address
= s6x0_read_mac_address
,
2261 .frontend_attach
= ds3000_frontend_attach
,
2275 .num_device_descs
= 3,
2278 {&dw2102_table
[TEVII_S660
], NULL
},
2281 {"TeVii S480.1 USB",
2282 {&dw2102_table
[TEVII_S480_1
], NULL
},
2285 {"TeVii S480.2 USB",
2286 {&dw2102_table
[TEVII_S480_2
], NULL
},
2292 static struct dvb_usb_device_properties p7500_properties
= {
2293 .caps
= DVB_USB_IS_AN_I2C_ADAPTER
,
2294 .usb_ctrl
= DEVICE_SPECIFIC
,
2295 .size_of_priv
= sizeof(struct dw2102_state
),
2296 .firmware
= P7500_FIRMWARE
,
2299 .i2c_algo
= &s6x0_i2c_algo
,
2302 .rc_codes
= RC_MAP_TBS_NEC
,
2303 .module_name
= "dw2102",
2304 .allowed_protos
= RC_PROTO_BIT_NEC
,
2305 .rc_query
= prof_rc_query
,
2308 .generic_bulk_ctrl_endpoint
= 0x81,
2310 .download_firmware
= dw2102_load_firmware
,
2311 .read_mac_address
= s6x0_read_mac_address
,
2316 .frontend_attach
= prof_7500_frontend_attach
,
2330 .num_device_descs
= 1,
2332 {"Prof 7500 USB DVB-S2",
2333 {&dw2102_table
[PROF_7500
], NULL
},
2339 static struct dvb_usb_device_properties su3000_properties
= {
2340 .caps
= DVB_USB_IS_AN_I2C_ADAPTER
,
2341 .usb_ctrl
= DEVICE_SPECIFIC
,
2342 .size_of_priv
= sizeof(struct dw2102_state
),
2343 .power_ctrl
= su3000_power_ctrl
,
2345 .identify_state
= su3000_identify_state
,
2346 .i2c_algo
= &su3000_i2c_algo
,
2350 .rc_codes
= RC_MAP_SU3000
,
2351 .module_name
= "dw2102",
2352 .allowed_protos
= RC_PROTO_BIT_RC5
,
2353 .rc_query
= su3000_rc_query
,
2356 .read_mac_address
= su3000_read_mac_address
,
2358 .generic_bulk_ctrl_endpoint
= 0x01,
2364 .streaming_ctrl
= su3000_streaming_ctrl
,
2365 .frontend_attach
= su3000_frontend_attach
,
2379 .num_device_descs
= 9,
2381 { "SU3000HD DVB-S USB2.0",
2382 { &dw2102_table
[GENIATECH_SU3000
], NULL
},
2385 { "Hauppauge MAX S2 or WinTV NOVA HD USB2.0",
2386 { &dw2102_table
[HAUPPAUGE_MAX_S2
], NULL
},
2389 { "Terratec Cinergy S2 USB HD",
2390 { &dw2102_table
[TERRATEC_CINERGY_S2_R1
], NULL
},
2393 { "X3M TV SPC1400HD PCI",
2394 { &dw2102_table
[GENIATECH_X3M_SPC1400HD
], NULL
},
2397 { "Terratec Cinergy S2 USB HD Rev.2",
2398 { &dw2102_table
[TERRATEC_CINERGY_S2_R2
], NULL
},
2401 { "Terratec Cinergy S2 USB HD Rev.3",
2402 { &dw2102_table
[TERRATEC_CINERGY_S2_R3
], NULL
},
2405 { "Terratec Cinergy S2 PCIe Dual Port 1",
2406 { &dw2102_table
[TERRATEC_CINERGY_S2_1
], NULL
},
2409 { "Terratec Cinergy S2 PCIe Dual Port 2",
2410 { &dw2102_table
[TERRATEC_CINERGY_S2_2
], NULL
},
2413 { "GOTVIEW Satellite HD",
2414 { &dw2102_table
[GOTVIEW_SAT_HD
], NULL
},
2420 static struct dvb_usb_device_properties s421_properties
= {
2421 .caps
= DVB_USB_IS_AN_I2C_ADAPTER
,
2422 .usb_ctrl
= DEVICE_SPECIFIC
,
2423 .size_of_priv
= sizeof(struct dw2102_state
),
2424 .power_ctrl
= su3000_power_ctrl
,
2426 .identify_state
= su3000_identify_state
,
2427 .i2c_algo
= &su3000_i2c_algo
,
2431 .rc_codes
= RC_MAP_SU3000
,
2432 .module_name
= "dw2102",
2433 .allowed_protos
= RC_PROTO_BIT_RC5
,
2434 .rc_query
= su3000_rc_query
,
2437 .read_mac_address
= su3000_read_mac_address
,
2439 .generic_bulk_ctrl_endpoint
= 0x01,
2445 .streaming_ctrl
= su3000_streaming_ctrl
,
2446 .frontend_attach
= m88rs2000_frontend_attach
,
2460 .num_device_descs
= 2,
2463 { &dw2102_table
[TEVII_S421
], NULL
},
2467 { &dw2102_table
[TEVII_S632
], NULL
},
2473 static struct dvb_usb_device_properties t220_properties
= {
2474 .caps
= DVB_USB_IS_AN_I2C_ADAPTER
,
2475 .usb_ctrl
= DEVICE_SPECIFIC
,
2476 .size_of_priv
= sizeof(struct dw2102_state
),
2477 .power_ctrl
= su3000_power_ctrl
,
2479 .identify_state
= su3000_identify_state
,
2480 .i2c_algo
= &su3000_i2c_algo
,
2484 .rc_codes
= RC_MAP_SU3000
,
2485 .module_name
= "dw2102",
2486 .allowed_protos
= RC_PROTO_BIT_RC5
,
2487 .rc_query
= su3000_rc_query
,
2490 .read_mac_address
= su3000_read_mac_address
,
2492 .generic_bulk_ctrl_endpoint
= 0x01,
2498 .streaming_ctrl
= su3000_streaming_ctrl
,
2499 .frontend_attach
= t220_frontend_attach
,
2513 .num_device_descs
= 1,
2515 { "Geniatech T220 DVB-T/T2 USB2.0",
2516 { &dw2102_table
[GENIATECH_T220
], NULL
},
2522 static struct dvb_usb_device_properties tt_s2_4600_properties
= {
2523 .caps
= DVB_USB_IS_AN_I2C_ADAPTER
,
2524 .usb_ctrl
= DEVICE_SPECIFIC
,
2525 .size_of_priv
= sizeof(struct dw2102_state
),
2526 .power_ctrl
= su3000_power_ctrl
,
2528 .identify_state
= su3000_identify_state
,
2529 .i2c_algo
= &su3000_i2c_algo
,
2533 .rc_codes
= RC_MAP_TT_1500
,
2534 .module_name
= "dw2102",
2535 .allowed_protos
= RC_PROTO_BIT_RC5
,
2536 .rc_query
= su3000_rc_query
,
2539 .read_mac_address
= su3000_read_mac_address
,
2541 .generic_bulk_ctrl_endpoint
= 0x01,
2547 .streaming_ctrl
= su3000_streaming_ctrl
,
2548 .frontend_attach
= tt_s2_4600_frontend_attach
,
2562 .num_device_descs
= 5,
2564 { "TechnoTrend TT-connect S2-4600",
2565 { &dw2102_table
[TECHNOTREND_CONNECT_S2_4600
], NULL
},
2568 { "TeVii S482 (tuner 1)",
2569 { &dw2102_table
[TEVII_S482_1
], NULL
},
2572 { "TeVii S482 (tuner 2)",
2573 { &dw2102_table
[TEVII_S482_2
], NULL
},
2576 { "Terratec Cinergy S2 USB BOX",
2577 { &dw2102_table
[TERRATEC_CINERGY_S2_R4
], NULL
},
2581 { &dw2102_table
[TEVII_S662
], NULL
},
2587 static int dw2102_probe(struct usb_interface
*intf
,
2588 const struct usb_device_id
*id
)
2590 if (!(dvb_usb_device_init(intf
, &dw2102_properties
,
2591 THIS_MODULE
, NULL
, adapter_nr
) &&
2592 dvb_usb_device_init(intf
, &dw2104_properties
,
2593 THIS_MODULE
, NULL
, adapter_nr
) &&
2594 dvb_usb_device_init(intf
, &dw3101_properties
,
2595 THIS_MODULE
, NULL
, adapter_nr
) &&
2596 dvb_usb_device_init(intf
, &s6x0_properties
,
2597 THIS_MODULE
, NULL
, adapter_nr
) &&
2598 dvb_usb_device_init(intf
, &p1100_properties
,
2599 THIS_MODULE
, NULL
, adapter_nr
) &&
2600 dvb_usb_device_init(intf
, &s660_properties
,
2601 THIS_MODULE
, NULL
, adapter_nr
) &&
2602 dvb_usb_device_init(intf
, &p7500_properties
,
2603 THIS_MODULE
, NULL
, adapter_nr
) &&
2604 dvb_usb_device_init(intf
, &s421_properties
,
2605 THIS_MODULE
, NULL
, adapter_nr
) &&
2606 dvb_usb_device_init(intf
, &su3000_properties
,
2607 THIS_MODULE
, NULL
, adapter_nr
) &&
2608 dvb_usb_device_init(intf
, &t220_properties
,
2609 THIS_MODULE
, NULL
, adapter_nr
) &&
2610 dvb_usb_device_init(intf
, &tt_s2_4600_properties
,
2611 THIS_MODULE
, NULL
, adapter_nr
))) {
2618 static void dw2102_disconnect(struct usb_interface
*intf
)
2620 struct dvb_usb_device
*d
= usb_get_intfdata(intf
);
2621 struct dw2102_state
*st
= d
->priv
;
2622 struct i2c_client
*client
;
2624 /* remove I2C client for tuner */
2625 client
= st
->i2c_client_tuner
;
2627 module_put(client
->dev
.driver
->owner
);
2628 i2c_unregister_device(client
);
2631 /* remove I2C client for demodulator */
2632 client
= st
->i2c_client_demod
;
2634 module_put(client
->dev
.driver
->owner
);
2635 i2c_unregister_device(client
);
2638 dvb_usb_device_exit(intf
);
2641 static struct usb_driver dw2102_driver
= {
2643 .probe
= dw2102_probe
,
2644 .disconnect
= dw2102_disconnect
,
2645 .id_table
= dw2102_table
,
2648 module_usb_driver(dw2102_driver
);
2650 MODULE_AUTHOR("Igor M. Liplianin (c) liplianin@me.by");
2651 MODULE_DESCRIPTION("Driver for DVBWorld DVB-S 2101, 2102, DVB-S2 2104, DVB-C 3101 USB2.0, TeVii S421, S480, S482, S600, S630, S632, S650, TeVii S660, S662, Prof 1100, 7500 USB2.0, Geniatech SU3000, T220, TechnoTrend S2-4600, Terratec Cinergy S2 devices");
2652 MODULE_VERSION("0.1");
2653 MODULE_LICENSE("GPL");
2654 MODULE_FIRMWARE(DW2101_FIRMWARE
);
2655 MODULE_FIRMWARE(DW2102_FIRMWARE
);
2656 MODULE_FIRMWARE(DW2104_FIRMWARE
);
2657 MODULE_FIRMWARE(DW3101_FIRMWARE
);
2658 MODULE_FIRMWARE(S630_FIRMWARE
);
2659 MODULE_FIRMWARE(S660_FIRMWARE
);
2660 MODULE_FIRMWARE(P1100_FIRMWARE
);
2661 MODULE_FIRMWARE(P7500_FIRMWARE
);