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,
4 * Prof 1100, 7500 Cards
5 * Copyright (C) 2008,2009 Igor M. Liplianin (liplianin@me.by)
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation, version 2.
11 * see Documentation/dvb/README.dvb-usb for more information
28 #include "stb6100_proc.h"
30 #ifndef USB_PID_DW2102
31 #define USB_PID_DW2102 0x2102
34 #ifndef USB_PID_DW2104
35 #define USB_PID_DW2104 0x2104
38 #ifndef USB_PID_DW3101
39 #define USB_PID_DW3101 0x3101
42 #ifndef USB_PID_CINERGY_S
43 #define USB_PID_CINERGY_S 0x0064
46 #ifndef USB_PID_TEVII_S630
47 #define USB_PID_TEVII_S630 0xd630
50 #ifndef USB_PID_TEVII_S650
51 #define USB_PID_TEVII_S650 0xd650
54 #ifndef USB_PID_TEVII_S660
55 #define USB_PID_TEVII_S660 0xd660
58 #ifndef USB_PID_PROF_1100
59 #define USB_PID_PROF_1100 0xb012
62 #define DW210X_READ_MSG 0
63 #define DW210X_WRITE_MSG 1
65 #define REG_1F_SYMBOLRATE_BYTE0 0x1f
66 #define REG_20_SYMBOLRATE_BYTE1 0x20
67 #define REG_21_SYMBOLRATE_BYTE2 0x21
69 #define DW2102_VOLTAGE_CTRL (0x1800)
70 #define DW2102_RC_QUERY (0x1a00)
72 #define err_str "did not find the firmware file. (%s) " \
73 "Please see linux/Documentation/dvb/ for more details " \
74 "on firmware-problems."
76 struct dvb_usb_rc_keys_table
{
77 struct dvb_usb_rc_key
*rc_keys
;
82 static int dvb_usb_dw2102_debug
;
83 module_param_named(debug
, dvb_usb_dw2102_debug
, int, 0644);
84 MODULE_PARM_DESC(debug
, "set debugging level (1=info 2=xfer 4=rc(or-able))."
85 DVB_USB_DEBUG_STATUS
);
89 module_param_named(keymap
, ir_keymap
, int, 0644);
90 MODULE_PARM_DESC(keymap
, "set keymap 0=default 1=dvbworld 2=tevii 3=tbs ...");
93 static int demod_probe
= 1;
94 module_param_named(demod
, demod_probe
, int, 0644);
95 MODULE_PARM_DESC(demod
, "demod to probe (1=cx24116 2=stv0903+stv6110 "
96 "4=stv0903+stb6100(or-able)).");
98 DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr
);
100 static int dw210x_op_rw(struct usb_device
*dev
, u8 request
, u16 value
,
101 u16 index
, u8
* data
, u16 len
, int flags
)
106 unsigned int pipe
= (flags
== DW210X_READ_MSG
) ?
107 usb_rcvctrlpipe(dev
, 0) : usb_sndctrlpipe(dev
, 0);
108 u8 request_type
= (flags
== DW210X_READ_MSG
) ? USB_DIR_IN
: USB_DIR_OUT
;
110 if (flags
== DW210X_WRITE_MSG
)
111 memcpy(u8buf
, data
, len
);
112 ret
= usb_control_msg(dev
, pipe
, request
, request_type
| USB_TYPE_VENDOR
,
113 value
, index
, u8buf
, len
, 2000);
115 if (flags
== DW210X_READ_MSG
)
116 memcpy(data
, u8buf
, len
);
121 static int dw2102_i2c_transfer(struct i2c_adapter
*adap
, struct i2c_msg msg
[],
124 struct dvb_usb_device
*d
= i2c_get_adapdata(adap
);
126 u8 buf6
[] = {0x2c, 0x05, 0xc0, 0, 0, 0, 0};
131 if (mutex_lock_interruptible(&d
->i2c_mutex
) < 0)
136 /* read stv0299 register */
137 value
= msg
[0].buf
[0];/* register */
138 for (i
= 0; i
< msg
[1].len
; i
++) {
140 ret
= dw210x_op_rw(d
->udev
, 0xb5, value
, 0,
141 buf6
, 2, DW210X_READ_MSG
);
142 msg
[1].buf
[i
] = buf6
[0];
146 switch (msg
[0].addr
) {
148 /* write to stv0299 register */
150 buf6
[1] = msg
[0].buf
[0];
151 buf6
[2] = msg
[0].buf
[1];
152 ret
= dw210x_op_rw(d
->udev
, 0xb2, 0, 0,
153 buf6
, 3, DW210X_WRITE_MSG
);
156 if (msg
[0].flags
== 0) {
157 /* write to tuner pll */
161 buf6
[3] = msg
[0].buf
[0];
162 buf6
[4] = msg
[0].buf
[1];
163 buf6
[5] = msg
[0].buf
[2];
164 buf6
[6] = msg
[0].buf
[3];
165 ret
= dw210x_op_rw(d
->udev
, 0xb2, 0, 0,
166 buf6
, 7, DW210X_WRITE_MSG
);
168 /* read from tuner */
169 ret
= dw210x_op_rw(d
->udev
, 0xb5, 0, 0,
170 buf6
, 1, DW210X_READ_MSG
);
171 msg
[0].buf
[0] = buf6
[0];
174 case (DW2102_RC_QUERY
):
175 ret
= dw210x_op_rw(d
->udev
, 0xb8, 0, 0,
176 buf6
, 2, DW210X_READ_MSG
);
177 msg
[0].buf
[0] = buf6
[0];
178 msg
[0].buf
[1] = buf6
[1];
180 case (DW2102_VOLTAGE_CTRL
):
182 buf6
[1] = msg
[0].buf
[0];
183 ret
= dw210x_op_rw(d
->udev
, 0xb2, 0, 0,
184 buf6
, 2, DW210X_WRITE_MSG
);
191 mutex_unlock(&d
->i2c_mutex
);
195 static int dw2102_serit_i2c_transfer(struct i2c_adapter
*adap
,
196 struct i2c_msg msg
[], int num
)
198 struct dvb_usb_device
*d
= i2c_get_adapdata(adap
);
200 u8 buf6
[] = {0, 0, 0, 0, 0, 0, 0};
204 if (mutex_lock_interruptible(&d
->i2c_mutex
) < 0)
209 /* read si2109 register by number */
210 buf6
[0] = msg
[0].addr
<< 1;
211 buf6
[1] = msg
[0].len
;
212 buf6
[2] = msg
[0].buf
[0];
213 ret
= dw210x_op_rw(d
->udev
, 0xc2, 0, 0,
214 buf6
, msg
[0].len
+ 2, DW210X_WRITE_MSG
);
215 /* read si2109 register */
216 ret
= dw210x_op_rw(d
->udev
, 0xc3, 0xd0, 0,
217 buf6
, msg
[1].len
+ 2, DW210X_READ_MSG
);
218 memcpy(msg
[1].buf
, buf6
+ 2, msg
[1].len
);
222 switch (msg
[0].addr
) {
224 /* write to si2109 register */
225 buf6
[0] = msg
[0].addr
<< 1;
226 buf6
[1] = msg
[0].len
;
227 memcpy(buf6
+ 2, msg
[0].buf
, msg
[0].len
);
228 ret
= dw210x_op_rw(d
->udev
, 0xc2, 0, 0, buf6
,
229 msg
[0].len
+ 2, DW210X_WRITE_MSG
);
231 case(DW2102_RC_QUERY
):
232 ret
= dw210x_op_rw(d
->udev
, 0xb8, 0, 0,
233 buf6
, 2, DW210X_READ_MSG
);
234 msg
[0].buf
[0] = buf6
[0];
235 msg
[0].buf
[1] = buf6
[1];
237 case(DW2102_VOLTAGE_CTRL
):
239 buf6
[1] = msg
[0].buf
[0];
240 ret
= dw210x_op_rw(d
->udev
, 0xb2, 0, 0,
241 buf6
, 2, DW210X_WRITE_MSG
);
247 mutex_unlock(&d
->i2c_mutex
);
251 static int dw2102_earda_i2c_transfer(struct i2c_adapter
*adap
, struct i2c_msg msg
[], int num
)
253 struct dvb_usb_device
*d
= i2c_get_adapdata(adap
);
258 if (mutex_lock_interruptible(&d
->i2c_mutex
) < 0)
264 /* first write first register number */
265 u8 ibuf
[msg
[1].len
+ 2], obuf
[3];
266 obuf
[0] = msg
[0].addr
<< 1;
267 obuf
[1] = msg
[0].len
;
268 obuf
[2] = msg
[0].buf
[0];
269 ret
= dw210x_op_rw(d
->udev
, 0xc2, 0, 0,
270 obuf
, msg
[0].len
+ 2, DW210X_WRITE_MSG
);
271 /* second read registers */
272 ret
= dw210x_op_rw(d
->udev
, 0xc3, 0xd1 , 0,
273 ibuf
, msg
[1].len
+ 2, DW210X_READ_MSG
);
274 memcpy(msg
[1].buf
, ibuf
+ 2, msg
[1].len
);
279 switch (msg
[0].addr
) {
281 /* write to register */
282 u8 obuf
[msg
[0].len
+ 2];
283 obuf
[0] = msg
[0].addr
<< 1;
284 obuf
[1] = msg
[0].len
;
285 memcpy(obuf
+ 2, msg
[0].buf
, msg
[0].len
);
286 ret
= dw210x_op_rw(d
->udev
, 0xc2, 0, 0,
287 obuf
, msg
[0].len
+ 2, DW210X_WRITE_MSG
);
292 u8 obuf
[msg
[0].len
+ 2];
293 obuf
[0] = msg
[0].addr
<< 1;
294 obuf
[1] = msg
[0].len
;
295 memcpy(obuf
+ 2, msg
[0].buf
, msg
[0].len
);
296 ret
= dw210x_op_rw(d
->udev
, 0xc2, 0, 0,
297 obuf
, msg
[0].len
+ 2, DW210X_WRITE_MSG
);
300 case(DW2102_RC_QUERY
): {
302 ret
= dw210x_op_rw(d
->udev
, 0xb8, 0, 0,
303 ibuf
, 2, DW210X_READ_MSG
);
304 memcpy(msg
[0].buf
, ibuf
, 2);
307 case(DW2102_VOLTAGE_CTRL
): {
310 obuf
[1] = msg
[0].buf
[0];
311 ret
= dw210x_op_rw(d
->udev
, 0xb2, 0, 0,
312 obuf
, 2, DW210X_WRITE_MSG
);
320 mutex_unlock(&d
->i2c_mutex
);
324 static int dw2104_i2c_transfer(struct i2c_adapter
*adap
, struct i2c_msg msg
[], int num
)
326 struct dvb_usb_device
*d
= i2c_get_adapdata(adap
);
332 if (mutex_lock_interruptible(&d
->i2c_mutex
) < 0)
335 for (j
= 0; j
< num
; j
++) {
336 switch (msg
[j
].addr
) {
337 case(DW2102_RC_QUERY
): {
339 ret
= dw210x_op_rw(d
->udev
, 0xb8, 0, 0,
340 ibuf
, 2, DW210X_READ_MSG
);
341 memcpy(msg
[j
].buf
, ibuf
, 2);
344 case(DW2102_VOLTAGE_CTRL
): {
347 obuf
[1] = msg
[j
].buf
[0];
348 ret
= dw210x_op_rw(d
->udev
, 0xb2, 0, 0,
349 obuf
, 2, DW210X_WRITE_MSG
);
354 case 0x68: ds3000, stv0903
355 case 0x60: ts2020, stv6110, stb6100 */
357 if (msg
[j
].flags
== I2C_M_RD
) {
359 u8 ibuf
[msg
[j
].len
+ 2];
360 ret
= dw210x_op_rw(d
->udev
, 0xc3,
361 (msg
[j
].addr
<< 1) + 1, 0,
362 ibuf
, msg
[j
].len
+ 2,
364 memcpy(msg
[j
].buf
, ibuf
+ 2, msg
[j
].len
);
366 } else if (((msg
[j
].buf
[0] == 0xb0) &&
367 (msg
[j
].addr
== 0x68)) ||
368 ((msg
[j
].buf
[0] == 0xf7) &&
369 (msg
[j
].addr
== 0x55))) {
372 obuf
[0] = msg
[j
].addr
<< 1;
373 obuf
[1] = (msg
[j
].len
> 15 ? 17 : msg
[j
].len
);
374 obuf
[2] = msg
[j
].buf
[0];
375 len
= msg
[j
].len
- 1;
378 memcpy(obuf
+ 3, msg
[j
].buf
+ i
,
379 (len
> 16 ? 16 : len
));
380 ret
= dw210x_op_rw(d
->udev
, 0xc2, 0, 0,
381 obuf
, (len
> 16 ? 16 : len
) + 3,
387 /* write registers */
388 u8 obuf
[msg
[j
].len
+ 2];
389 obuf
[0] = msg
[j
].addr
<< 1;
390 obuf
[1] = msg
[j
].len
;
391 memcpy(obuf
+ 2, msg
[j
].buf
, msg
[j
].len
);
392 ret
= dw210x_op_rw(d
->udev
, 0xc2, 0, 0,
393 obuf
, msg
[j
].len
+ 2,
402 mutex_unlock(&d
->i2c_mutex
);
406 static int dw3101_i2c_transfer(struct i2c_adapter
*adap
, struct i2c_msg msg
[],
409 struct dvb_usb_device
*d
= i2c_get_adapdata(adap
);
414 if (mutex_lock_interruptible(&d
->i2c_mutex
) < 0)
420 /* first write first register number */
421 u8 ibuf
[msg
[1].len
+ 2], obuf
[3];
422 obuf
[0] = msg
[0].addr
<< 1;
423 obuf
[1] = msg
[0].len
;
424 obuf
[2] = msg
[0].buf
[0];
425 ret
= dw210x_op_rw(d
->udev
, 0xc2, 0, 0,
426 obuf
, msg
[0].len
+ 2, DW210X_WRITE_MSG
);
427 /* second read registers */
428 ret
= dw210x_op_rw(d
->udev
, 0xc3, 0x19 , 0,
429 ibuf
, msg
[1].len
+ 2, DW210X_READ_MSG
);
430 memcpy(msg
[1].buf
, ibuf
+ 2, msg
[1].len
);
435 switch (msg
[0].addr
) {
438 /* write to register */
439 u8 obuf
[msg
[0].len
+ 2];
440 obuf
[0] = msg
[0].addr
<< 1;
441 obuf
[1] = msg
[0].len
;
442 memcpy(obuf
+ 2, msg
[0].buf
, msg
[0].len
);
443 ret
= dw210x_op_rw(d
->udev
, 0xc2, 0, 0,
444 obuf
, msg
[0].len
+ 2, DW210X_WRITE_MSG
);
447 case(DW2102_RC_QUERY
): {
449 ret
= dw210x_op_rw(d
->udev
, 0xb8, 0, 0,
450 ibuf
, 2, DW210X_READ_MSG
);
451 memcpy(msg
[0].buf
, ibuf
, 2);
459 for (i
= 0; i
< num
; i
++) {
460 deb_xfer("%02x:%02x: %s ", i
, msg
[i
].addr
,
461 msg
[i
].flags
== 0 ? ">>>" : "<<<");
462 debug_dump(msg
[i
].buf
, msg
[i
].len
, deb_xfer
);
465 mutex_unlock(&d
->i2c_mutex
);
469 static int s6x0_i2c_transfer(struct i2c_adapter
*adap
, struct i2c_msg msg
[],
472 struct dvb_usb_device
*d
= i2c_get_adapdata(adap
);
473 struct usb_device
*udev
;
480 if (mutex_lock_interruptible(&d
->i2c_mutex
) < 0)
483 for (j
= 0; j
< num
; j
++) {
484 switch (msg
[j
].addr
) {
485 case (DW2102_RC_QUERY
): {
487 ret
= dw210x_op_rw(d
->udev
, 0xb8, 0, 0,
488 ibuf
, 4, DW210X_READ_MSG
);
489 memcpy(msg
[j
].buf
, ibuf
+ 1, 2);
492 case (DW2102_VOLTAGE_CTRL
): {
496 obuf
[1] = msg
[j
].buf
[1];/* off-on */
497 ret
= dw210x_op_rw(d
->udev
, 0x8a, 0, 0,
498 obuf
, 2, DW210X_WRITE_MSG
);
500 obuf
[1] = msg
[j
].buf
[0];/* 13v-18v */
501 ret
= dw210x_op_rw(d
->udev
, 0x8a, 0, 0,
502 obuf
, 2, DW210X_WRITE_MSG
);
507 case 0x68: ds3000, stv0903
508 case 0x60: ts2020, stv6110, stb6100
511 if (msg
[j
].flags
== I2C_M_RD
) {
514 ret
= dw210x_op_rw(d
->udev
, 0x91, 0, 0,
517 memcpy(msg
[j
].buf
, ibuf
, msg
[j
].len
);
519 } else if ((msg
[j
].buf
[0] == 0xb0) &&
520 (msg
[j
].addr
== 0x68)) {
523 obuf
[0] = (msg
[j
].len
> 16 ?
524 18 : msg
[j
].len
+ 1);
525 obuf
[1] = msg
[j
].addr
<< 1;
526 obuf
[2] = msg
[j
].buf
[0];
527 len
= msg
[j
].len
- 1;
530 memcpy(obuf
+ 3, msg
[j
].buf
+ i
,
531 (len
> 16 ? 16 : len
));
532 ret
= dw210x_op_rw(d
->udev
, 0x80, 0, 0,
533 obuf
, (len
> 16 ? 16 : len
) + 3,
538 } else if ((udev
->descriptor
.idProduct
== 0x7500)
539 && (j
< (num
- 1))) {
540 /* write register addr before read */
541 u8 obuf
[msg
[j
].len
+ 2];
542 obuf
[0] = msg
[j
+ 1].len
;
543 obuf
[1] = (msg
[j
].addr
<< 1);
544 memcpy(obuf
+ 2, msg
[j
].buf
, msg
[j
].len
);
545 ret
= dw210x_op_rw(d
->udev
, 0x92, 0, 0,
546 obuf
, msg
[j
].len
+ 2,
550 /* write registers */
551 u8 obuf
[msg
[j
].len
+ 2];
552 obuf
[0] = msg
[j
].len
+ 1;
553 obuf
[1] = (msg
[j
].addr
<< 1);
554 memcpy(obuf
+ 2, msg
[j
].buf
, msg
[j
].len
);
555 ret
= dw210x_op_rw(d
->udev
,
556 (num
> 1 ? 0x90 : 0x80), 0, 0,
557 obuf
, msg
[j
].len
+ 2,
568 mutex_unlock(&d
->i2c_mutex
);
572 static u32
dw210x_i2c_func(struct i2c_adapter
*adapter
)
577 static struct i2c_algorithm dw2102_i2c_algo
= {
578 .master_xfer
= dw2102_i2c_transfer
,
579 .functionality
= dw210x_i2c_func
,
582 static struct i2c_algorithm dw2102_serit_i2c_algo
= {
583 .master_xfer
= dw2102_serit_i2c_transfer
,
584 .functionality
= dw210x_i2c_func
,
587 static struct i2c_algorithm dw2102_earda_i2c_algo
= {
588 .master_xfer
= dw2102_earda_i2c_transfer
,
589 .functionality
= dw210x_i2c_func
,
592 static struct i2c_algorithm dw2104_i2c_algo
= {
593 .master_xfer
= dw2104_i2c_transfer
,
594 .functionality
= dw210x_i2c_func
,
597 static struct i2c_algorithm dw3101_i2c_algo
= {
598 .master_xfer
= dw3101_i2c_transfer
,
599 .functionality
= dw210x_i2c_func
,
602 static struct i2c_algorithm s6x0_i2c_algo
= {
603 .master_xfer
= s6x0_i2c_transfer
,
604 .functionality
= dw210x_i2c_func
,
607 static int dw210x_read_mac_address(struct dvb_usb_device
*d
, u8 mac
[6])
611 u8 eeprom
[256], eepromline
[16];
613 for (i
= 0; i
< 256; i
++) {
614 if (dw210x_op_rw(d
->udev
, 0xb6, 0xa0 , i
, ibuf
, 2, DW210X_READ_MSG
) < 0) {
615 err("read eeprom failed.");
618 eepromline
[i
%16] = ibuf
[0];
621 if ((i
% 16) == 15) {
622 deb_xfer("%02x: ", i
- 15);
623 debug_dump(eepromline
, 16, deb_xfer
);
627 memcpy(mac
, eeprom
+ 8, 6);
631 static int s6x0_read_mac_address(struct dvb_usb_device
*d
, u8 mac
[6])
634 u8 ibuf
[] = { 0 }, obuf
[] = { 0 };
635 u8 eeprom
[256], eepromline
[16];
636 struct i2c_msg msg
[] = {
650 for (i
= 0; i
< 256; i
++) {
652 ret
= s6x0_i2c_transfer(&d
->i2c_adap
, msg
, 2);
654 err("read eeprom failed.");
657 eepromline
[i
% 16] = ibuf
[0];
661 if ((i
% 16) == 15) {
662 deb_xfer("%02x: ", i
- 15);
663 debug_dump(eepromline
, 16, deb_xfer
);
667 memcpy(mac
, eeprom
+ 16, 6);
671 static int dw210x_set_voltage(struct dvb_frontend
*fe
, fe_sec_voltage_t voltage
)
673 static u8 command_13v
[] = {0x00, 0x01};
674 static u8 command_18v
[] = {0x01, 0x01};
675 static u8 command_off
[] = {0x00, 0x00};
676 struct i2c_msg msg
= {
677 .addr
= DW2102_VOLTAGE_CTRL
,
683 struct dvb_usb_adapter
*udev_adap
=
684 (struct dvb_usb_adapter
*)(fe
->dvb
->priv
);
685 if (voltage
== SEC_VOLTAGE_18
)
686 msg
.buf
= command_18v
;
687 else if (voltage
== SEC_VOLTAGE_13
)
688 msg
.buf
= command_13v
;
690 i2c_transfer(&udev_adap
->dev
->i2c_adap
, &msg
, 1);
695 static struct stv0299_config sharp_z0194a_config
= {
696 .demod_address
= 0x68,
697 .inittab
= sharp_z0194a_inittab
,
701 .lock_output
= STV0299_LOCKOUTPUT_1
,
702 .volt13_op0_op1
= STV0299_VOLT13_OP1
,
704 .set_symbol_rate
= sharp_z0194a_set_symbol_rate
,
707 static struct cx24116_config dw2104_config
= {
708 .demod_address
= 0x55,
709 .mpg_clk_pos_pol
= 0x01,
712 static struct si21xx_config serit_sp1511lhb_config
= {
713 .demod_address
= 0x68,
718 static struct tda10023_config dw3101_tda10023_config
= {
719 .demod_address
= 0x0c,
723 static struct mt312_config zl313_config
= {
724 .demod_address
= 0x0e,
727 static struct ds3000_config dw2104_ds3000_config
= {
728 .demod_address
= 0x68,
731 static struct stv0900_config dw2104a_stv0900_config
= {
732 .demod_address
= 0x6a,
735 .clkmode
= 3,/* 0-CLKI, 2-XTALI, else AUTO */
736 .diseqc_mode
= 2,/* 2/3 PWM */
737 .tun1_maddress
= 0,/* 0x60 */
738 .tun1_adc
= 0,/* 2 Vpp */
742 static struct stb6100_config dw2104a_stb6100_config
= {
743 .tuner_address
= 0x60,
744 .refclock
= 27000000,
747 static struct stv0900_config dw2104_stv0900_config
= {
748 .demod_address
= 0x68,
754 .tun1_adc
= 1,/* 1 Vpp */
758 static struct stv6110_config dw2104_stv6110_config
= {
764 static struct stv0900_config prof_7500_stv0900_config
= {
765 .demod_address
= 0x6a,
768 .clkmode
= 3,/* 0-CLKI, 2-XTALI, else AUTO */
769 .diseqc_mode
= 2,/* 2/3 PWM */
770 .tun1_maddress
= 0,/* 0x60 */
771 .tun1_adc
= 0,/* 2 Vpp */
776 static int dw2104_frontend_attach(struct dvb_usb_adapter
*d
)
778 struct dvb_tuner_ops
*tuner_ops
= NULL
;
780 if (demod_probe
& 4) {
781 d
->fe
= dvb_attach(stv0900_attach
, &dw2104a_stv0900_config
,
782 &d
->dev
->i2c_adap
, 0);
784 if (dvb_attach(stb6100_attach
, d
->fe
,
785 &dw2104a_stb6100_config
,
786 &d
->dev
->i2c_adap
)) {
787 tuner_ops
= &d
->fe
->ops
.tuner_ops
;
788 tuner_ops
->set_frequency
= stb6100_set_freq
;
789 tuner_ops
->get_frequency
= stb6100_get_freq
;
790 tuner_ops
->set_bandwidth
= stb6100_set_bandw
;
791 tuner_ops
->get_bandwidth
= stb6100_get_bandw
;
792 d
->fe
->ops
.set_voltage
= dw210x_set_voltage
;
793 info("Attached STV0900+STB6100!\n");
799 if (demod_probe
& 2) {
800 d
->fe
= dvb_attach(stv0900_attach
, &dw2104_stv0900_config
,
801 &d
->dev
->i2c_adap
, 0);
803 if (dvb_attach(stv6110_attach
, d
->fe
,
804 &dw2104_stv6110_config
,
805 &d
->dev
->i2c_adap
)) {
806 d
->fe
->ops
.set_voltage
= dw210x_set_voltage
;
807 info("Attached STV0900+STV6110A!\n");
813 if (demod_probe
& 1) {
814 d
->fe
= dvb_attach(cx24116_attach
, &dw2104_config
,
817 d
->fe
->ops
.set_voltage
= dw210x_set_voltage
;
818 info("Attached cx24116!\n");
823 d
->fe
= dvb_attach(ds3000_attach
, &dw2104_ds3000_config
,
826 d
->fe
->ops
.set_voltage
= dw210x_set_voltage
;
827 info("Attached DS3000!\n");
834 static struct dvb_usb_device_properties dw2102_properties
;
835 static struct dvb_usb_device_properties dw2104_properties
;
836 static struct dvb_usb_device_properties s6x0_properties
;
838 static int dw2102_frontend_attach(struct dvb_usb_adapter
*d
)
840 if (dw2102_properties
.i2c_algo
== &dw2102_serit_i2c_algo
) {
841 /*dw2102_properties.adapter->tuner_attach = NULL;*/
842 d
->fe
= dvb_attach(si21xx_attach
, &serit_sp1511lhb_config
,
845 d
->fe
->ops
.set_voltage
= dw210x_set_voltage
;
846 info("Attached si21xx!\n");
851 if (dw2102_properties
.i2c_algo
== &dw2102_earda_i2c_algo
) {
852 d
->fe
= dvb_attach(stv0288_attach
, &earda_config
,
855 if (dvb_attach(stb6000_attach
, d
->fe
, 0x61,
856 &d
->dev
->i2c_adap
)) {
857 d
->fe
->ops
.set_voltage
= dw210x_set_voltage
;
858 info("Attached stv0288!\n");
864 if (dw2102_properties
.i2c_algo
== &dw2102_i2c_algo
) {
865 /*dw2102_properties.adapter->tuner_attach = dw2102_tuner_attach;*/
866 d
->fe
= dvb_attach(stv0299_attach
, &sharp_z0194a_config
,
869 d
->fe
->ops
.set_voltage
= dw210x_set_voltage
;
870 info("Attached stv0299!\n");
877 static int dw3101_frontend_attach(struct dvb_usb_adapter
*d
)
879 d
->fe
= dvb_attach(tda10023_attach
, &dw3101_tda10023_config
,
880 &d
->dev
->i2c_adap
, 0x48);
882 info("Attached tda10023!\n");
888 static int s6x0_frontend_attach(struct dvb_usb_adapter
*d
)
890 d
->fe
= dvb_attach(mt312_attach
, &zl313_config
,
893 if (dvb_attach(zl10039_attach
, d
->fe
, 0x60,
894 &d
->dev
->i2c_adap
)) {
895 d
->fe
->ops
.set_voltage
= dw210x_set_voltage
;
896 info("Attached zl100313+zl10039!\n");
901 d
->fe
= dvb_attach(stv0288_attach
, &earda_config
,
904 if (dvb_attach(stb6000_attach
, d
->fe
, 0x61,
905 &d
->dev
->i2c_adap
)) {
906 d
->fe
->ops
.set_voltage
= dw210x_set_voltage
;
907 info("Attached stv0288+stb6000!\n");
912 d
->fe
= dvb_attach(ds3000_attach
, &dw2104_ds3000_config
,
915 d
->fe
->ops
.set_voltage
= dw210x_set_voltage
;
916 info("Attached ds3000+ds2020!\n");
923 static int prof_7500_frontend_attach(struct dvb_usb_adapter
*d
)
925 d
->fe
= dvb_attach(stv0900_attach
, &prof_7500_stv0900_config
,
926 &d
->dev
->i2c_adap
, 0);
929 d
->fe
->ops
.set_voltage
= dw210x_set_voltage
;
931 info("Attached STV0900+STB6100A!\n");
936 static int dw2102_tuner_attach(struct dvb_usb_adapter
*adap
)
938 dvb_attach(dvb_pll_attach
, adap
->fe
, 0x60,
939 &adap
->dev
->i2c_adap
, DVB_PLL_OPERA1
);
943 static int dw3101_tuner_attach(struct dvb_usb_adapter
*adap
)
945 dvb_attach(dvb_pll_attach
, adap
->fe
, 0x60,
946 &adap
->dev
->i2c_adap
, DVB_PLL_TUA6034
);
951 static struct dvb_usb_rc_key dw210x_rc_keys
[] = {
952 { 0xf80a, KEY_Q
}, /*power*/
953 { 0xf80c, KEY_M
}, /*mute*/
964 { 0xf81c, KEY_PAGEUP
}, /*ch+*/
965 { 0xf80f, KEY_PAGEDOWN
}, /*ch-*/
966 { 0xf81a, KEY_O
}, /*vol+*/
967 { 0xf80e, KEY_Z
}, /*vol-*/
968 { 0xf804, KEY_R
}, /*rec*/
969 { 0xf809, KEY_D
}, /*fav*/
970 { 0xf808, KEY_BACKSPACE
}, /*rewind*/
971 { 0xf807, KEY_A
}, /*fast*/
972 { 0xf80b, KEY_P
}, /*pause*/
973 { 0xf802, KEY_ESC
}, /*cancel*/
974 { 0xf803, KEY_G
}, /*tab*/
975 { 0xf800, KEY_UP
}, /*up*/
976 { 0xf81f, KEY_ENTER
}, /*ok*/
977 { 0xf801, KEY_DOWN
}, /*down*/
978 { 0xf805, KEY_C
}, /*cap*/
979 { 0xf806, KEY_S
}, /*stop*/
980 { 0xf840, KEY_F
}, /*full*/
981 { 0xf81e, KEY_W
}, /*tvmode*/
982 { 0xf81b, KEY_B
}, /*recall*/
985 static struct dvb_usb_rc_key tevii_rc_keys
[] = {
986 { 0xf80a, KEY_POWER
},
987 { 0xf80c, KEY_MUTE
},
998 { 0xf81c, KEY_MENU
},
999 { 0xf80f, KEY_VOLUMEDOWN
},
1000 { 0xf81a, KEY_LAST
},
1001 { 0xf80e, KEY_OPEN
},
1002 { 0xf804, KEY_RECORD
},
1003 { 0xf809, KEY_VOLUMEUP
},
1004 { 0xf808, KEY_CHANNELUP
},
1005 { 0xf807, KEY_PVR
},
1006 { 0xf80b, KEY_TIME
},
1007 { 0xf802, KEY_RIGHT
},
1008 { 0xf803, KEY_LEFT
},
1011 { 0xf801, KEY_DOWN
},
1012 { 0xf805, KEY_TUNER
},
1013 { 0xf806, KEY_CHANNELDOWN
},
1014 { 0xf840, KEY_PLAYPAUSE
},
1015 { 0xf81e, KEY_REWIND
},
1016 { 0xf81b, KEY_FAVORITES
},
1017 { 0xf81d, KEY_BACK
},
1018 { 0xf84d, KEY_FASTFORWARD
},
1019 { 0xf844, KEY_EPG
},
1020 { 0xf84c, KEY_INFO
},
1022 { 0xf843, KEY_AUDIO
},
1023 { 0xf845, KEY_SUBTITLE
},
1024 { 0xf84a, KEY_LIST
},
1031 { 0xf856, KEY_MODE
},
1032 { 0xf858, KEY_SWITCHVIDEOMODE
},
1035 static struct dvb_usb_rc_key tbs_rc_keys
[] = {
1036 { 0xf884, KEY_POWER
},
1037 { 0xf894, KEY_MUTE
},
1048 { 0xf896, KEY_CHANNELUP
},
1049 { 0xf891, KEY_CHANNELDOWN
},
1050 { 0xf893, KEY_VOLUMEUP
},
1051 { 0xf88c, KEY_VOLUMEDOWN
},
1052 { 0xf883, KEY_RECORD
},
1053 { 0xf898, KEY_PAUSE
},
1055 { 0xf89a, KEY_SHUFFLE
},
1057 { 0xf890, KEY_LEFT
},
1058 { 0xf882, KEY_RIGHT
},
1059 { 0xf888, KEY_DOWN
},
1060 { 0xf895, KEY_FAVORITES
},
1061 { 0xf897, KEY_SUBTITLE
},
1062 { 0xf89d, KEY_ZOOM
},
1063 { 0xf89f, KEY_EXIT
},
1064 { 0xf89e, KEY_MENU
},
1065 { 0xf89c, KEY_EPG
},
1066 { 0xf880, KEY_PREVIOUS
},
1067 { 0xf89b, KEY_MODE
}
1070 static struct dvb_usb_rc_keys_table keys_tables
[] = {
1071 { dw210x_rc_keys
, ARRAY_SIZE(dw210x_rc_keys
) },
1072 { tevii_rc_keys
, ARRAY_SIZE(tevii_rc_keys
) },
1073 { tbs_rc_keys
, ARRAY_SIZE(tbs_rc_keys
) },
1076 static int dw2102_rc_query(struct dvb_usb_device
*d
, u32
*event
, int *state
)
1078 struct dvb_usb_rc_key
*keymap
= d
->props
.rc_key_map
;
1079 int keymap_size
= d
->props
.rc_key_map_size
;
1081 struct i2c_msg msg
= {
1082 .addr
= DW2102_RC_QUERY
,
1088 /* override keymap */
1089 if ((ir_keymap
> 0) && (ir_keymap
<= ARRAY_SIZE(keys_tables
))) {
1090 keymap
= keys_tables
[ir_keymap
- 1].rc_keys
;
1091 keymap_size
= keys_tables
[ir_keymap
- 1].rc_keys_size
;
1094 *state
= REMOTE_NO_KEY_PRESSED
;
1095 if (d
->props
.i2c_algo
->master_xfer(&d
->i2c_adap
, &msg
, 1) == 1) {
1096 for (i
= 0; i
< keymap_size
; i
++) {
1097 if (rc5_data(&keymap
[i
]) == msg
.buf
[0]) {
1098 *state
= REMOTE_KEY_PRESSED
;
1099 *event
= keymap
[i
].event
;
1105 if ((*state
) == REMOTE_KEY_PRESSED
)
1106 deb_rc("%s: found rc key: %x, %x, event: %x\n",
1107 __func__
, key
[0], key
[1], (*event
));
1108 else if (key
[0] != 0xff)
1109 deb_rc("%s: unknown rc key: %x, %x\n",
1110 __func__
, key
[0], key
[1]);
1117 static struct usb_device_id dw2102_table
[] = {
1118 {USB_DEVICE(USB_VID_CYPRESS
, USB_PID_DW2102
)},
1119 {USB_DEVICE(USB_VID_CYPRESS
, 0x2101)},
1120 {USB_DEVICE(USB_VID_CYPRESS
, USB_PID_DW2104
)},
1121 {USB_DEVICE(0x9022, USB_PID_TEVII_S650
)},
1122 {USB_DEVICE(USB_VID_TERRATEC
, USB_PID_CINERGY_S
)},
1123 {USB_DEVICE(USB_VID_CYPRESS
, USB_PID_DW3101
)},
1124 {USB_DEVICE(0x9022, USB_PID_TEVII_S630
)},
1125 {USB_DEVICE(0x3011, USB_PID_PROF_1100
)},
1126 {USB_DEVICE(0x9022, USB_PID_TEVII_S660
)},
1127 {USB_DEVICE(0x3034, 0x7500)},
1131 MODULE_DEVICE_TABLE(usb
, dw2102_table
);
1133 static int dw2102_load_firmware(struct usb_device
*dev
,
1134 const struct firmware
*frmwr
)
1139 u8 reset16
[] = {0, 0, 0, 0, 0, 0, 0};
1140 const struct firmware
*fw
;
1141 const char *fw_2101
= "dvb-usb-dw2101.fw";
1143 switch (dev
->descriptor
.idProduct
) {
1145 ret
= request_firmware(&fw
, fw_2101
, &dev
->dev
);
1147 err(err_str
, fw_2101
);
1155 info("start downloading DW210X firmware");
1156 p
= kmalloc(fw
->size
, GFP_KERNEL
);
1159 dw210x_op_rw(dev
, 0xa0, 0x7f92, 0, &reset
, 1, DW210X_WRITE_MSG
);
1160 dw210x_op_rw(dev
, 0xa0, 0xe600, 0, &reset
, 1, DW210X_WRITE_MSG
);
1163 memcpy(p
, fw
->data
, fw
->size
);
1164 for (i
= 0; i
< fw
->size
; i
+= 0x40) {
1166 if (dw210x_op_rw(dev
, 0xa0, i
, 0, b
, 0x40,
1167 DW210X_WRITE_MSG
) != 0x40) {
1168 err("error while transferring firmware");
1173 /* restart the CPU */
1175 if (ret
|| dw210x_op_rw(dev
, 0xa0, 0x7f92, 0, &reset
, 1,
1176 DW210X_WRITE_MSG
) != 1) {
1177 err("could not restart the USB controller CPU.");
1180 if (ret
|| dw210x_op_rw(dev
, 0xa0, 0xe600, 0, &reset
, 1,
1181 DW210X_WRITE_MSG
) != 1) {
1182 err("could not restart the USB controller CPU.");
1185 /* init registers */
1186 switch (dev
->descriptor
.idProduct
) {
1187 case USB_PID_PROF_1100
:
1188 s6x0_properties
.rc_key_map
= tbs_rc_keys
;
1189 s6x0_properties
.rc_key_map_size
=
1190 ARRAY_SIZE(tbs_rc_keys
);
1192 case USB_PID_TEVII_S650
:
1193 dw2104_properties
.rc_key_map
= tevii_rc_keys
;
1194 dw2104_properties
.rc_key_map_size
=
1195 ARRAY_SIZE(tevii_rc_keys
);
1196 case USB_PID_DW2104
:
1198 dw210x_op_rw(dev
, 0xc4, 0x0000, 0, &reset
, 1,
1200 /* break omitted intentionally */
1201 case USB_PID_DW3101
:
1203 dw210x_op_rw(dev
, 0xbf, 0x0040, 0, &reset
, 0,
1206 case USB_PID_CINERGY_S
:
1207 case USB_PID_DW2102
:
1208 dw210x_op_rw(dev
, 0xbf, 0x0040, 0, &reset
, 0,
1210 dw210x_op_rw(dev
, 0xb9, 0x0000, 0, &reset16
[0], 2,
1212 /* check STV0299 frontend */
1213 dw210x_op_rw(dev
, 0xb5, 0, 0, &reset16
[0], 2,
1215 if ((reset16
[0] == 0xa1) || (reset16
[0] == 0x80)) {
1216 dw2102_properties
.i2c_algo
= &dw2102_i2c_algo
;
1217 dw2102_properties
.adapter
->tuner_attach
= &dw2102_tuner_attach
;
1220 /* check STV0288 frontend */
1224 dw210x_op_rw(dev
, 0xc2, 0, 0, &reset16
[0], 3,
1226 dw210x_op_rw(dev
, 0xc3, 0xd1, 0, &reset16
[0], 3,
1228 if (reset16
[2] == 0x11) {
1229 dw2102_properties
.i2c_algo
= &dw2102_earda_i2c_algo
;
1234 dw210x_op_rw(dev
, 0xbc, 0x0030, 0, &reset16
[0], 2,
1236 dw210x_op_rw(dev
, 0xba, 0x0000, 0, &reset16
[0], 7,
1238 dw210x_op_rw(dev
, 0xba, 0x0000, 0, &reset16
[0], 7,
1240 dw210x_op_rw(dev
, 0xb9, 0x0000, 0, &reset16
[0], 2,
1251 static struct dvb_usb_device_properties dw2102_properties
= {
1252 .caps
= DVB_USB_IS_AN_I2C_ADAPTER
,
1253 .usb_ctrl
= DEVICE_SPECIFIC
,
1254 .firmware
= "dvb-usb-dw2102.fw",
1257 .i2c_algo
= &dw2102_serit_i2c_algo
,
1258 .rc_key_map
= dw210x_rc_keys
,
1259 .rc_key_map_size
= ARRAY_SIZE(dw210x_rc_keys
),
1261 .rc_query
= dw2102_rc_query
,
1263 .generic_bulk_ctrl_endpoint
= 0x81,
1264 /* parameter for the MPEG2-data transfer */
1266 .download_firmware
= dw2102_load_firmware
,
1267 .read_mac_address
= dw210x_read_mac_address
,
1270 .frontend_attach
= dw2102_frontend_attach
,
1271 .streaming_ctrl
= NULL
,
1272 .tuner_attach
= NULL
,
1285 .num_device_descs
= 3,
1287 {"DVBWorld DVB-S 2102 USB2.0",
1288 {&dw2102_table
[0], NULL
},
1291 {"DVBWorld DVB-S 2101 USB2.0",
1292 {&dw2102_table
[1], NULL
},
1295 {"TerraTec Cinergy S USB",
1296 {&dw2102_table
[4], NULL
},
1302 static struct dvb_usb_device_properties dw2104_properties
= {
1303 .caps
= DVB_USB_IS_AN_I2C_ADAPTER
,
1304 .usb_ctrl
= DEVICE_SPECIFIC
,
1305 .firmware
= "dvb-usb-dw2104.fw",
1308 .i2c_algo
= &dw2104_i2c_algo
,
1309 .rc_key_map
= dw210x_rc_keys
,
1310 .rc_key_map_size
= ARRAY_SIZE(dw210x_rc_keys
),
1312 .rc_query
= dw2102_rc_query
,
1314 .generic_bulk_ctrl_endpoint
= 0x81,
1315 /* parameter for the MPEG2-data transfer */
1317 .download_firmware
= dw2102_load_firmware
,
1318 .read_mac_address
= dw210x_read_mac_address
,
1321 .frontend_attach
= dw2104_frontend_attach
,
1322 .streaming_ctrl
= NULL
,
1323 /*.tuner_attach = dw2104_tuner_attach,*/
1336 .num_device_descs
= 2,
1338 { "DVBWorld DW2104 USB2.0",
1339 {&dw2102_table
[2], NULL
},
1342 { "TeVii S650 USB2.0",
1343 {&dw2102_table
[3], NULL
},
1349 static struct dvb_usb_device_properties dw3101_properties
= {
1350 .caps
= DVB_USB_IS_AN_I2C_ADAPTER
,
1351 .usb_ctrl
= DEVICE_SPECIFIC
,
1352 .firmware
= "dvb-usb-dw3101.fw",
1355 .i2c_algo
= &dw3101_i2c_algo
,
1356 .rc_key_map
= dw210x_rc_keys
,
1357 .rc_key_map_size
= ARRAY_SIZE(dw210x_rc_keys
),
1359 .rc_query
= dw2102_rc_query
,
1361 .generic_bulk_ctrl_endpoint
= 0x81,
1362 /* parameter for the MPEG2-data transfer */
1364 .download_firmware
= dw2102_load_firmware
,
1365 .read_mac_address
= dw210x_read_mac_address
,
1368 .frontend_attach
= dw3101_frontend_attach
,
1369 .streaming_ctrl
= NULL
,
1370 .tuner_attach
= dw3101_tuner_attach
,
1383 .num_device_descs
= 1,
1385 { "DVBWorld DVB-C 3101 USB2.0",
1386 {&dw2102_table
[5], NULL
},
1392 static struct dvb_usb_device_properties s6x0_properties
= {
1393 .caps
= DVB_USB_IS_AN_I2C_ADAPTER
,
1394 .usb_ctrl
= DEVICE_SPECIFIC
,
1395 .firmware
= "dvb-usb-s630.fw",
1398 .i2c_algo
= &s6x0_i2c_algo
,
1399 .rc_key_map
= tevii_rc_keys
,
1400 .rc_key_map_size
= ARRAY_SIZE(tevii_rc_keys
),
1402 .rc_query
= dw2102_rc_query
,
1404 .generic_bulk_ctrl_endpoint
= 0x81,
1406 .download_firmware
= dw2102_load_firmware
,
1407 .read_mac_address
= s6x0_read_mac_address
,
1410 .frontend_attach
= s6x0_frontend_attach
,
1411 .streaming_ctrl
= NULL
,
1412 .tuner_attach
= NULL
,
1425 .num_device_descs
= 3,
1428 {&dw2102_table
[6], NULL
},
1432 {&dw2102_table
[7], NULL
},
1436 {&dw2102_table
[8], NULL
},
1442 struct dvb_usb_device_properties
*p7500
;
1443 static struct dvb_usb_device_description d7500
= {
1444 "Prof 7500 USB DVB-S2",
1445 {&dw2102_table
[9], NULL
},
1449 static int dw2102_probe(struct usb_interface
*intf
,
1450 const struct usb_device_id
*id
)
1453 p7500
= kzalloc(sizeof(struct dvb_usb_device_properties
), GFP_KERNEL
);
1456 /* copy default structure */
1457 memcpy(p7500
, &s6x0_properties
,
1458 sizeof(struct dvb_usb_device_properties
));
1459 /* fill only different fields */
1460 p7500
->firmware
= "dvb-usb-p7500.fw";
1461 p7500
->devices
[0] = d7500
;
1462 p7500
->rc_key_map
= tbs_rc_keys
;
1463 p7500
->rc_key_map_size
= ARRAY_SIZE(tbs_rc_keys
);
1464 p7500
->adapter
->frontend_attach
= prof_7500_frontend_attach
;
1466 if (0 == dvb_usb_device_init(intf
, &dw2102_properties
,
1467 THIS_MODULE
, NULL
, adapter_nr
) ||
1468 0 == dvb_usb_device_init(intf
, &dw2104_properties
,
1469 THIS_MODULE
, NULL
, adapter_nr
) ||
1470 0 == dvb_usb_device_init(intf
, &dw3101_properties
,
1471 THIS_MODULE
, NULL
, adapter_nr
) ||
1472 0 == dvb_usb_device_init(intf
, &s6x0_properties
,
1473 THIS_MODULE
, NULL
, adapter_nr
) ||
1474 0 == dvb_usb_device_init(intf
, p7500
,
1475 THIS_MODULE
, NULL
, adapter_nr
))
1481 static struct usb_driver dw2102_driver
= {
1483 .probe
= dw2102_probe
,
1484 .disconnect
= dvb_usb_device_exit
,
1485 .id_table
= dw2102_table
,
1488 static int __init
dw2102_module_init(void)
1490 int ret
= usb_register(&dw2102_driver
);
1492 err("usb_register failed. Error number %d", ret
);
1497 static void __exit
dw2102_module_exit(void)
1499 usb_deregister(&dw2102_driver
);
1502 module_init(dw2102_module_init
);
1503 module_exit(dw2102_module_exit
);
1505 MODULE_AUTHOR("Igor M. Liplianin (c) liplianin@me.by");
1506 MODULE_DESCRIPTION("Driver for DVBWorld DVB-S 2101, 2102, DVB-S2 2104,"
1507 " DVB-C 3101 USB2.0,"
1508 " TeVii S600, S630, S650, S660 USB2.0,"
1509 " Prof 1100, 7500 USB2.0 devices");
1510 MODULE_VERSION("0.1");
1511 MODULE_LICENSE("GPL");