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 Cards
4 * Copyright (C) 2008,2009 Igor M. Liplianin (liplianin@me.by)
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation, version 2.
10 * see Documentation/dvb/README.dvb-usb for more information
24 #ifndef USB_PID_DW2102
25 #define USB_PID_DW2102 0x2102
28 #ifndef USB_PID_DW2104
29 #define USB_PID_DW2104 0x2104
32 #ifndef USB_PID_DW3101
33 #define USB_PID_DW3101 0x3101
36 #ifndef USB_PID_CINERGY_S
37 #define USB_PID_CINERGY_S 0x0064
40 #ifndef USB_PID_TEVII_S650
41 #define USB_PID_TEVII_S650 0xd650
44 #ifndef USB_PID_TEVII_S630
45 #define USB_PID_TEVII_S630 0xd630
48 #define DW210X_READ_MSG 0
49 #define DW210X_WRITE_MSG 1
51 #define REG_1F_SYMBOLRATE_BYTE0 0x1f
52 #define REG_20_SYMBOLRATE_BYTE1 0x20
53 #define REG_21_SYMBOLRATE_BYTE2 0x21
55 #define DW2102_VOLTAGE_CTRL (0x1800)
56 #define DW2102_RC_QUERY (0x1a00)
58 struct dvb_usb_rc_keys_table
{
59 struct dvb_usb_rc_key
*rc_keys
;
64 static int dvb_usb_dw2102_debug
;
65 module_param_named(debug
, dvb_usb_dw2102_debug
, int, 0644);
66 MODULE_PARM_DESC(debug
, "set debugging level (1=info 2=xfer 4=rc(or-able))."
67 DVB_USB_DEBUG_STATUS
);
71 module_param_named(keymap
, ir_keymap
, int, 0644);
72 MODULE_PARM_DESC(keymap
, "set keymap 0=default 1=dvbworld 2=tevii 3=tbs ...");
74 DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr
);
76 static int dw210x_op_rw(struct usb_device
*dev
, u8 request
, u16 value
,
77 u16 index
, u8
* data
, u16 len
, int flags
)
82 unsigned int pipe
= (flags
== DW210X_READ_MSG
) ?
83 usb_rcvctrlpipe(dev
, 0) : usb_sndctrlpipe(dev
, 0);
84 u8 request_type
= (flags
== DW210X_READ_MSG
) ? USB_DIR_IN
: USB_DIR_OUT
;
86 if (flags
== DW210X_WRITE_MSG
)
87 memcpy(u8buf
, data
, len
);
88 ret
= usb_control_msg(dev
, pipe
, request
, request_type
| USB_TYPE_VENDOR
,
89 value
, index
, u8buf
, len
, 2000);
91 if (flags
== DW210X_READ_MSG
)
92 memcpy(data
, u8buf
, len
);
97 static int dw2102_i2c_transfer(struct i2c_adapter
*adap
, struct i2c_msg msg
[],
100 struct dvb_usb_device
*d
= i2c_get_adapdata(adap
);
102 u8 buf6
[] = {0x2c, 0x05, 0xc0, 0, 0, 0, 0};
107 if (mutex_lock_interruptible(&d
->i2c_mutex
) < 0)
112 /* read stv0299 register */
113 value
= msg
[0].buf
[0];/* register */
114 for (i
= 0; i
< msg
[1].len
; i
++) {
116 ret
= dw210x_op_rw(d
->udev
, 0xb5, value
, 0,
117 buf6
, 2, DW210X_READ_MSG
);
118 msg
[1].buf
[i
] = buf6
[0];
122 switch (msg
[0].addr
) {
124 /* write to stv0299 register */
126 buf6
[1] = msg
[0].buf
[0];
127 buf6
[2] = msg
[0].buf
[1];
128 ret
= dw210x_op_rw(d
->udev
, 0xb2, 0, 0,
129 buf6
, 3, DW210X_WRITE_MSG
);
132 if (msg
[0].flags
== 0) {
133 /* write to tuner pll */
137 buf6
[3] = msg
[0].buf
[0];
138 buf6
[4] = msg
[0].buf
[1];
139 buf6
[5] = msg
[0].buf
[2];
140 buf6
[6] = msg
[0].buf
[3];
141 ret
= dw210x_op_rw(d
->udev
, 0xb2, 0, 0,
142 buf6
, 7, DW210X_WRITE_MSG
);
144 /* read from tuner */
145 ret
= dw210x_op_rw(d
->udev
, 0xb5, 0, 0,
146 buf6
, 1, DW210X_READ_MSG
);
147 msg
[0].buf
[0] = buf6
[0];
150 case (DW2102_RC_QUERY
):
151 ret
= dw210x_op_rw(d
->udev
, 0xb8, 0, 0,
152 buf6
, 2, DW210X_READ_MSG
);
153 msg
[0].buf
[0] = buf6
[0];
154 msg
[0].buf
[1] = buf6
[1];
156 case (DW2102_VOLTAGE_CTRL
):
158 buf6
[1] = msg
[0].buf
[0];
159 ret
= dw210x_op_rw(d
->udev
, 0xb2, 0, 0,
160 buf6
, 2, DW210X_WRITE_MSG
);
167 mutex_unlock(&d
->i2c_mutex
);
171 static int dw2102_serit_i2c_transfer(struct i2c_adapter
*adap
,
172 struct i2c_msg msg
[], int num
)
174 struct dvb_usb_device
*d
= i2c_get_adapdata(adap
);
176 u8 buf6
[] = {0, 0, 0, 0, 0, 0, 0};
180 if (mutex_lock_interruptible(&d
->i2c_mutex
) < 0)
185 /* read si2109 register by number */
187 buf6
[1] = msg
[0].len
;
188 buf6
[2] = msg
[0].buf
[0];
189 ret
= dw210x_op_rw(d
->udev
, 0xc2, 0, 0,
190 buf6
, msg
[0].len
+ 2, DW210X_WRITE_MSG
);
191 /* read si2109 register */
192 ret
= dw210x_op_rw(d
->udev
, 0xc3, 0xd0, 0,
193 buf6
, msg
[1].len
+ 2, DW210X_READ_MSG
);
194 memcpy(msg
[1].buf
, buf6
+ 2, msg
[1].len
);
198 switch (msg
[0].addr
) {
200 /* write to si2109 register */
202 buf6
[1] = msg
[0].len
;
203 memcpy(buf6
+ 2, msg
[0].buf
, msg
[0].len
);
204 ret
= dw210x_op_rw(d
->udev
, 0xc2, 0, 0, buf6
,
205 msg
[0].len
+ 2, DW210X_WRITE_MSG
);
207 case(DW2102_RC_QUERY
):
208 ret
= dw210x_op_rw(d
->udev
, 0xb8, 0, 0,
209 buf6
, 2, DW210X_READ_MSG
);
210 msg
[0].buf
[0] = buf6
[0];
211 msg
[0].buf
[1] = buf6
[1];
213 case(DW2102_VOLTAGE_CTRL
):
215 buf6
[1] = msg
[0].buf
[0];
216 ret
= dw210x_op_rw(d
->udev
, 0xb2, 0, 0,
217 buf6
, 2, DW210X_WRITE_MSG
);
223 mutex_unlock(&d
->i2c_mutex
);
227 static int dw2102_earda_i2c_transfer(struct i2c_adapter
*adap
, struct i2c_msg msg
[], int num
)
229 struct dvb_usb_device
*d
= i2c_get_adapdata(adap
);
234 if (mutex_lock_interruptible(&d
->i2c_mutex
) < 0)
240 /* first write first register number */
241 u8 ibuf
[msg
[1].len
+ 2], obuf
[3];
243 obuf
[1] = msg
[0].len
;
244 obuf
[2] = msg
[0].buf
[0];
245 ret
= dw210x_op_rw(d
->udev
, 0xc2, 0, 0,
246 obuf
, msg
[0].len
+ 2, DW210X_WRITE_MSG
);
247 /* second read registers */
248 ret
= dw210x_op_rw(d
->udev
, 0xc3, 0xd1 , 0,
249 ibuf
, msg
[1].len
+ 2, DW210X_READ_MSG
);
250 memcpy(msg
[1].buf
, ibuf
+ 2, msg
[1].len
);
255 switch (msg
[0].addr
) {
257 /* write to register */
258 u8 obuf
[msg
[0].len
+ 2];
260 obuf
[1] = msg
[0].len
;
261 memcpy(obuf
+ 2, msg
[0].buf
, msg
[0].len
);
262 ret
= dw210x_op_rw(d
->udev
, 0xc2, 0, 0,
263 obuf
, msg
[0].len
+ 2, DW210X_WRITE_MSG
);
268 u8 obuf
[msg
[0].len
+ 2];
270 obuf
[1] = msg
[0].len
;
271 memcpy(obuf
+ 2, msg
[0].buf
, msg
[0].len
);
272 ret
= dw210x_op_rw(d
->udev
, 0xc2, 0, 0,
273 obuf
, msg
[0].len
+ 2, DW210X_WRITE_MSG
);
276 case(DW2102_RC_QUERY
): {
278 ret
= dw210x_op_rw(d
->udev
, 0xb8, 0, 0,
279 ibuf
, 2, DW210X_READ_MSG
);
280 memcpy(msg
[0].buf
, ibuf
, 2);
283 case(DW2102_VOLTAGE_CTRL
): {
286 obuf
[1] = msg
[0].buf
[0];
287 ret
= dw210x_op_rw(d
->udev
, 0xb2, 0, 0,
288 obuf
, 2, DW210X_WRITE_MSG
);
296 mutex_unlock(&d
->i2c_mutex
);
300 static int dw2104_i2c_transfer(struct i2c_adapter
*adap
, struct i2c_msg msg
[], int num
)
302 struct dvb_usb_device
*d
= i2c_get_adapdata(adap
);
308 if (mutex_lock_interruptible(&d
->i2c_mutex
) < 0)
314 /* first write first register number */
315 u8 ibuf
[msg
[1].len
+ 2], obuf
[3];
317 obuf
[1] = msg
[0].len
;
318 obuf
[2] = msg
[0].buf
[0];
319 ret
= dw210x_op_rw(d
->udev
, 0xc2, 0, 0,
320 obuf
, msg
[0].len
+ 2, DW210X_WRITE_MSG
);
321 /* second read registers */
322 ret
= dw210x_op_rw(d
->udev
, 0xc3, 0xab , 0,
323 ibuf
, msg
[1].len
+ 2, DW210X_READ_MSG
);
324 memcpy(msg
[1].buf
, ibuf
+ 2, msg
[1].len
);
329 switch (msg
[0].addr
) {
331 if (msg
[0].buf
[0] == 0xf7) {
333 /* Write in small blocks */
338 len
= msg
[0].len
- 1;
341 memcpy(obuf
+ 3, msg
[0].buf
+ i
, (len
> 16 ? 16 : len
));
342 ret
= dw210x_op_rw(d
->udev
, 0xc2, 0, 0,
343 obuf
, (len
> 16 ? 16 : len
) + 3, DW210X_WRITE_MSG
);
348 /* write to register */
349 u8 obuf
[msg
[0].len
+ 2];
351 obuf
[1] = msg
[0].len
;
352 memcpy(obuf
+ 2, msg
[0].buf
, msg
[0].len
);
353 ret
= dw210x_op_rw(d
->udev
, 0xc2, 0, 0,
354 obuf
, msg
[0].len
+ 2, DW210X_WRITE_MSG
);
358 case(DW2102_RC_QUERY
): {
360 ret
= dw210x_op_rw(d
->udev
, 0xb8, 0, 0,
361 ibuf
, 2, DW210X_READ_MSG
);
362 memcpy(msg
[0].buf
, ibuf
, 2);
365 case(DW2102_VOLTAGE_CTRL
): {
368 obuf
[1] = msg
[0].buf
[0];
369 ret
= dw210x_op_rw(d
->udev
, 0xb2, 0, 0,
370 obuf
, 2, DW210X_WRITE_MSG
);
378 mutex_unlock(&d
->i2c_mutex
);
382 static int dw3101_i2c_transfer(struct i2c_adapter
*adap
, struct i2c_msg msg
[],
385 struct dvb_usb_device
*d
= i2c_get_adapdata(adap
);
390 if (mutex_lock_interruptible(&d
->i2c_mutex
) < 0)
396 /* first write first register number */
397 u8 ibuf
[msg
[1].len
+ 2], obuf
[3];
398 obuf
[0] = msg
[0].addr
<< 1;
399 obuf
[1] = msg
[0].len
;
400 obuf
[2] = msg
[0].buf
[0];
401 ret
= dw210x_op_rw(d
->udev
, 0xc2, 0, 0,
402 obuf
, msg
[0].len
+ 2, DW210X_WRITE_MSG
);
403 /* second read registers */
404 ret
= dw210x_op_rw(d
->udev
, 0xc3, 0x19 , 0,
405 ibuf
, msg
[1].len
+ 2, DW210X_READ_MSG
);
406 memcpy(msg
[1].buf
, ibuf
+ 2, msg
[1].len
);
411 switch (msg
[0].addr
) {
414 /* write to register */
415 u8 obuf
[msg
[0].len
+ 2];
416 obuf
[0] = msg
[0].addr
<< 1;
417 obuf
[1] = msg
[0].len
;
418 memcpy(obuf
+ 2, msg
[0].buf
, msg
[0].len
);
419 ret
= dw210x_op_rw(d
->udev
, 0xc2, 0, 0,
420 obuf
, msg
[0].len
+ 2, DW210X_WRITE_MSG
);
423 case(DW2102_RC_QUERY
): {
425 ret
= dw210x_op_rw(d
->udev
, 0xb8, 0, 0,
426 ibuf
, 2, DW210X_READ_MSG
);
427 memcpy(msg
[0].buf
, ibuf
, 2);
435 for (i
= 0; i
< num
; i
++) {
436 deb_xfer("%02x:%02x: %s ", i
, msg
[i
].addr
,
437 msg
[i
].flags
== 0 ? ">>>" : "<<<");
438 debug_dump(msg
[i
].buf
, msg
[i
].len
, deb_xfer
);
441 mutex_unlock(&d
->i2c_mutex
);
445 static int s630_i2c_transfer(struct i2c_adapter
*adap
, struct i2c_msg msg
[],
448 struct dvb_usb_device
*d
= i2c_get_adapdata(adap
);
453 if (mutex_lock_interruptible(&d
->i2c_mutex
) < 0)
458 u8 ibuf
[msg
[1].len
], obuf
[3];
459 obuf
[0] = msg
[1].len
;
460 obuf
[1] = (msg
[0].addr
<< 1);
461 obuf
[2] = msg
[0].buf
[0];
463 ret
= dw210x_op_rw(d
->udev
, 0x90, 0, 0,
464 obuf
, 3, DW210X_WRITE_MSG
);
466 ret
= dw210x_op_rw(d
->udev
, 0x91, 0, 0,
467 ibuf
, msg
[1].len
, DW210X_READ_MSG
);
468 memcpy(msg
[1].buf
, ibuf
, msg
[1].len
);
472 switch (msg
[0].addr
) {
475 /* write to zl10313, zl10039 register, */
476 u8 obuf
[msg
[0].len
+ 2];
477 obuf
[0] = msg
[0].len
+ 1;
478 obuf
[1] = (msg
[0].addr
<< 1);
479 memcpy(obuf
+ 2, msg
[0].buf
, msg
[0].len
);
480 ret
= dw210x_op_rw(d
->udev
, 0x80, 0, 0,
481 obuf
, msg
[0].len
+ 2, DW210X_WRITE_MSG
);
484 case (DW2102_RC_QUERY
): {
486 ret
= dw210x_op_rw(d
->udev
, 0xb8, 0, 0,
487 ibuf
, 4, DW210X_READ_MSG
);
488 msg
[0].buf
[0] = ibuf
[3];
491 case (DW2102_VOLTAGE_CTRL
): {
494 obuf
[1] = msg
[0].buf
[0];
495 ret
= dw210x_op_rw(d
->udev
, 0x8a, 0, 0,
496 obuf
, 2, DW210X_WRITE_MSG
);
504 mutex_unlock(&d
->i2c_mutex
);
508 static u32
dw210x_i2c_func(struct i2c_adapter
*adapter
)
513 static struct i2c_algorithm dw2102_i2c_algo
= {
514 .master_xfer
= dw2102_i2c_transfer
,
515 .functionality
= dw210x_i2c_func
,
518 static struct i2c_algorithm dw2102_serit_i2c_algo
= {
519 .master_xfer
= dw2102_serit_i2c_transfer
,
520 .functionality
= dw210x_i2c_func
,
523 static struct i2c_algorithm dw2102_earda_i2c_algo
= {
524 .master_xfer
= dw2102_earda_i2c_transfer
,
525 .functionality
= dw210x_i2c_func
,
528 static struct i2c_algorithm dw2104_i2c_algo
= {
529 .master_xfer
= dw2104_i2c_transfer
,
530 .functionality
= dw210x_i2c_func
,
533 static struct i2c_algorithm dw3101_i2c_algo
= {
534 .master_xfer
= dw3101_i2c_transfer
,
535 .functionality
= dw210x_i2c_func
,
538 static struct i2c_algorithm s630_i2c_algo
= {
539 .master_xfer
= s630_i2c_transfer
,
540 .functionality
= dw210x_i2c_func
,
543 static int dw210x_read_mac_address(struct dvb_usb_device
*d
, u8 mac
[6])
547 u8 eeprom
[256], eepromline
[16];
549 for (i
= 0; i
< 256; i
++) {
550 if (dw210x_op_rw(d
->udev
, 0xb6, 0xa0 , i
, ibuf
, 2, DW210X_READ_MSG
) < 0) {
551 err("read eeprom failed.");
554 eepromline
[i
%16] = ibuf
[0];
557 if ((i
% 16) == 15) {
558 deb_xfer("%02x: ", i
- 15);
559 debug_dump(eepromline
, 16, deb_xfer
);
563 memcpy(mac
, eeprom
+ 8, 6);
567 static int s630_read_mac_address(struct dvb_usb_device
*d
, u8 mac
[6])
570 u8 buf
[3], eeprom
[256], eepromline
[16];
572 for (i
= 0; i
< 256; i
++) {
576 ret
= dw210x_op_rw(d
->udev
, 0x90, 0, 0,
577 buf
, 3, DW210X_WRITE_MSG
);
578 ret
= dw210x_op_rw(d
->udev
, 0x91, 0, 0,
579 buf
, 1, DW210X_READ_MSG
);
581 err("read eeprom failed.");
584 eepromline
[i
% 16] = buf
[0];
588 if ((i
% 16) == 15) {
589 deb_xfer("%02x: ", i
- 15);
590 debug_dump(eepromline
, 16, deb_xfer
);
594 memcpy(mac
, eeprom
+ 16, 6);
598 static int dw210x_set_voltage(struct dvb_frontend
*fe
, fe_sec_voltage_t voltage
)
600 static u8 command_13v
[1] = {0x00};
601 static u8 command_18v
[1] = {0x01};
602 struct i2c_msg msg
[] = {
603 {.addr
= DW2102_VOLTAGE_CTRL
, .flags
= 0,
604 .buf
= command_13v
, .len
= 1},
607 struct dvb_usb_adapter
*udev_adap
=
608 (struct dvb_usb_adapter
*)(fe
->dvb
->priv
);
609 if (voltage
== SEC_VOLTAGE_18
)
610 msg
[0].buf
= command_18v
;
611 i2c_transfer(&udev_adap
->dev
->i2c_adap
, msg
, 1);
615 static struct stv0299_config sharp_z0194a_config
= {
616 .demod_address
= 0x68,
617 .inittab
= sharp_z0194a_inittab
,
621 .lock_output
= STV0299_LOCKOUTPUT_1
,
622 .volt13_op0_op1
= STV0299_VOLT13_OP1
,
624 .set_symbol_rate
= sharp_z0194a_set_symbol_rate
,
627 static struct cx24116_config dw2104_config
= {
628 .demod_address
= 0x55,
629 .mpg_clk_pos_pol
= 0x01,
632 static struct si21xx_config serit_sp1511lhb_config
= {
633 .demod_address
= 0x68,
638 static struct tda10023_config dw3101_tda10023_config
= {
639 .demod_address
= 0x0c,
643 static struct mt312_config zl313_config
= {
644 .demod_address
= 0x0e,
647 static int dw2104_frontend_attach(struct dvb_usb_adapter
*d
)
649 if ((d
->fe
= dvb_attach(cx24116_attach
, &dw2104_config
,
650 &d
->dev
->i2c_adap
)) != NULL
) {
651 d
->fe
->ops
.set_voltage
= dw210x_set_voltage
;
652 info("Attached cx24116!\n");
658 static struct dvb_usb_device_properties dw2102_properties
;
659 static struct dvb_usb_device_properties dw2104_properties
;
661 static int dw2102_frontend_attach(struct dvb_usb_adapter
*d
)
663 if (dw2102_properties
.i2c_algo
== &dw2102_serit_i2c_algo
) {
664 /*dw2102_properties.adapter->tuner_attach = NULL;*/
665 d
->fe
= dvb_attach(si21xx_attach
, &serit_sp1511lhb_config
,
668 d
->fe
->ops
.set_voltage
= dw210x_set_voltage
;
669 info("Attached si21xx!\n");
673 if (dw2102_properties
.i2c_algo
== &dw2102_earda_i2c_algo
) {
674 /*dw2102_properties.adapter->tuner_attach = dw2102_tuner_attach;*/
675 d
->fe
= dvb_attach(stv0288_attach
, &earda_config
,
678 d
->fe
->ops
.set_voltage
= dw210x_set_voltage
;
679 info("Attached stv0288!\n");
684 if (dw2102_properties
.i2c_algo
== &dw2102_i2c_algo
) {
685 /*dw2102_properties.adapter->tuner_attach = dw2102_tuner_attach;*/
686 d
->fe
= dvb_attach(stv0299_attach
, &sharp_z0194a_config
,
689 d
->fe
->ops
.set_voltage
= dw210x_set_voltage
;
690 info("Attached stv0299!\n");
697 static int dw3101_frontend_attach(struct dvb_usb_adapter
*d
)
699 d
->fe
= dvb_attach(tda10023_attach
, &dw3101_tda10023_config
,
700 &d
->dev
->i2c_adap
, 0x48);
702 info("Attached tda10023!\n");
708 static int s630_frontend_attach(struct dvb_usb_adapter
*d
)
710 d
->fe
= dvb_attach(mt312_attach
, &zl313_config
,
713 d
->fe
->ops
.set_voltage
= dw210x_set_voltage
;
714 info("Attached zl10313!\n");
720 static int dw2102_tuner_attach(struct dvb_usb_adapter
*adap
)
722 dvb_attach(dvb_pll_attach
, adap
->fe
, 0x60,
723 &adap
->dev
->i2c_adap
, DVB_PLL_OPERA1
);
727 static int dw2102_earda_tuner_attach(struct dvb_usb_adapter
*adap
)
729 dvb_attach(stb6000_attach
, adap
->fe
, 0x61,
730 &adap
->dev
->i2c_adap
);
735 static int dw3101_tuner_attach(struct dvb_usb_adapter
*adap
)
737 dvb_attach(dvb_pll_attach
, adap
->fe
, 0x60,
738 &adap
->dev
->i2c_adap
, DVB_PLL_TUA6034
);
743 static int s630_zl10039_tuner_attach(struct dvb_usb_adapter
*adap
)
745 dvb_attach(zl10039_attach
, adap
->fe
, 0x60,
746 &adap
->dev
->i2c_adap
);
751 static struct dvb_usb_rc_key dw210x_rc_keys
[] = {
752 { 0xf80a, KEY_Q
}, /*power*/
753 { 0xf80c, KEY_M
}, /*mute*/
764 { 0xf81c, KEY_PAGEUP
}, /*ch+*/
765 { 0xf80f, KEY_PAGEDOWN
}, /*ch-*/
766 { 0xf81a, KEY_O
}, /*vol+*/
767 { 0xf80e, KEY_Z
}, /*vol-*/
768 { 0xf804, KEY_R
}, /*rec*/
769 { 0xf809, KEY_D
}, /*fav*/
770 { 0xf808, KEY_BACKSPACE
}, /*rewind*/
771 { 0xf807, KEY_A
}, /*fast*/
772 { 0xf80b, KEY_P
}, /*pause*/
773 { 0xf802, KEY_ESC
}, /*cancel*/
774 { 0xf803, KEY_G
}, /*tab*/
775 { 0xf800, KEY_UP
}, /*up*/
776 { 0xf81f, KEY_ENTER
}, /*ok*/
777 { 0xf801, KEY_DOWN
}, /*down*/
778 { 0xf805, KEY_C
}, /*cap*/
779 { 0xf806, KEY_S
}, /*stop*/
780 { 0xf840, KEY_F
}, /*full*/
781 { 0xf81e, KEY_W
}, /*tvmode*/
782 { 0xf81b, KEY_B
}, /*recall*/
785 static struct dvb_usb_rc_key tevii_rc_keys
[] = {
786 { 0xf80a, KEY_POWER
},
787 { 0xf80c, KEY_MUTE
},
798 { 0xf81c, KEY_MENU
},
799 { 0xf80f, KEY_VOLUMEDOWN
},
800 { 0xf81a, KEY_LAST
},
801 { 0xf80e, KEY_OPEN
},
802 { 0xf804, KEY_RECORD
},
803 { 0xf809, KEY_VOLUMEUP
},
804 { 0xf808, KEY_CHANNELUP
},
806 { 0xf80b, KEY_TIME
},
807 { 0xf802, KEY_RIGHT
},
808 { 0xf803, KEY_LEFT
},
811 { 0xf801, KEY_DOWN
},
812 { 0xf805, KEY_TUNER
},
813 { 0xf806, KEY_CHANNELDOWN
},
814 { 0xf840, KEY_PLAYPAUSE
},
815 { 0xf81e, KEY_REWIND
},
816 { 0xf81b, KEY_FAVORITES
},
817 { 0xf81d, KEY_BACK
},
818 { 0xf84d, KEY_FASTFORWARD
},
820 { 0xf84c, KEY_INFO
},
822 { 0xf843, KEY_AUDIO
},
823 { 0xf845, KEY_SUBTITLE
},
824 { 0xf84a, KEY_LIST
},
831 { 0xf856, KEY_MODE
},
832 { 0xf858, KEY_SWITCHVIDEOMODE
},
835 static struct dvb_usb_rc_key tbs_rc_keys
[] = {
836 { 0xf884, KEY_POWER
},
837 { 0xf894, KEY_MUTE
},
848 { 0xf896, KEY_CHANNELUP
},
849 { 0xf891, KEY_CHANNELDOWN
},
850 { 0xf893, KEY_VOLUMEUP
},
851 { 0xf88c, KEY_VOLUMEDOWN
},
852 { 0xf883, KEY_RECORD
},
853 { 0xf898, KEY_PAUSE
},
855 { 0xf89a, KEY_SHUFFLE
},
857 { 0xf890, KEY_LEFT
},
858 { 0xf882, KEY_RIGHT
},
859 { 0xf888, KEY_DOWN
},
860 { 0xf895, KEY_FAVORITES
},
861 { 0xf897, KEY_SUBTITLE
},
862 { 0xf89d, KEY_ZOOM
},
863 { 0xf89f, KEY_EXIT
},
864 { 0xf89e, KEY_MENU
},
866 { 0xf880, KEY_PREVIOUS
},
870 static struct dvb_usb_rc_keys_table keys_tables
[] = {
871 { dw210x_rc_keys
, ARRAY_SIZE(dw210x_rc_keys
) },
872 { tevii_rc_keys
, ARRAY_SIZE(tevii_rc_keys
) },
873 { tbs_rc_keys
, ARRAY_SIZE(tbs_rc_keys
) },
876 static int dw2102_rc_query(struct dvb_usb_device
*d
, u32
*event
, int *state
)
878 struct dvb_usb_rc_key
*keymap
= d
->props
.rc_key_map
;
879 int keymap_size
= d
->props
.rc_key_map_size
;
881 struct i2c_msg msg
= {
882 .addr
= DW2102_RC_QUERY
,
888 /* override keymap */
889 if ((ir_keymap
> 0) && (ir_keymap
<= ARRAY_SIZE(keys_tables
))) {
890 keymap
= keys_tables
[ir_keymap
- 1].rc_keys
;
891 keymap_size
= keys_tables
[ir_keymap
- 1].rc_keys_size
;
894 *state
= REMOTE_NO_KEY_PRESSED
;
895 if (d
->props
.i2c_algo
->master_xfer(&d
->i2c_adap
, &msg
, 1) == 1) {
896 for (i
= 0; i
< keymap_size
; i
++) {
897 if (rc5_data(&keymap
[i
]) == msg
.buf
[0]) {
898 *state
= REMOTE_KEY_PRESSED
;
899 *event
= keymap
[i
].event
;
905 if ((*state
) == REMOTE_KEY_PRESSED
)
906 deb_rc("%s: found rc key: %x, %x, event: %x\n",
907 __func__
, key
[0], key
[1], (*event
));
908 else if (key
[0] != 0xff)
909 deb_rc("%s: unknown rc key: %x, %x\n",
910 __func__
, key
[0], key
[1]);
917 static struct usb_device_id dw2102_table
[] = {
918 {USB_DEVICE(USB_VID_CYPRESS
, USB_PID_DW2102
)},
919 {USB_DEVICE(USB_VID_CYPRESS
, 0x2101)},
920 {USB_DEVICE(USB_VID_CYPRESS
, USB_PID_DW2104
)},
921 {USB_DEVICE(0x9022, USB_PID_TEVII_S650
)},
922 {USB_DEVICE(USB_VID_TERRATEC
, USB_PID_CINERGY_S
)},
923 {USB_DEVICE(USB_VID_CYPRESS
, USB_PID_DW3101
)},
924 {USB_DEVICE(0x9022, USB_PID_TEVII_S630
)},
928 MODULE_DEVICE_TABLE(usb
, dw2102_table
);
930 static int dw2102_load_firmware(struct usb_device
*dev
,
931 const struct firmware
*frmwr
)
936 u8 reset16
[] = {0, 0, 0, 0, 0, 0, 0};
937 const struct firmware
*fw
;
938 const char *filename
= "dvb-usb-dw2101.fw";
940 switch (dev
->descriptor
.idProduct
) {
942 ret
= request_firmware(&fw
, filename
, &dev
->dev
);
944 err("did not find the firmware file. (%s) "
945 "Please see linux/Documentation/dvb/ for more details "
946 "on firmware-problems.", filename
);
954 info("start downloading DW210X firmware");
955 p
= kmalloc(fw
->size
, GFP_KERNEL
);
958 dw210x_op_rw(dev
, 0xa0, 0x7f92, 0, &reset
, 1, DW210X_WRITE_MSG
);
959 dw210x_op_rw(dev
, 0xa0, 0xe600, 0, &reset
, 1, DW210X_WRITE_MSG
);
962 memcpy(p
, fw
->data
, fw
->size
);
963 for (i
= 0; i
< fw
->size
; i
+= 0x40) {
965 if (dw210x_op_rw(dev
, 0xa0, i
, 0, b
, 0x40,
966 DW210X_WRITE_MSG
) != 0x40) {
967 err("error while transferring firmware");
972 /* restart the CPU */
974 if (ret
|| dw210x_op_rw(dev
, 0xa0, 0x7f92, 0, &reset
, 1,
975 DW210X_WRITE_MSG
) != 1) {
976 err("could not restart the USB controller CPU.");
979 if (ret
|| dw210x_op_rw(dev
, 0xa0, 0xe600, 0, &reset
, 1,
980 DW210X_WRITE_MSG
) != 1) {
981 err("could not restart the USB controller CPU.");
985 switch (dev
->descriptor
.idProduct
) {
986 case USB_PID_TEVII_S650
:
987 dw2104_properties
.rc_key_map
= tevii_rc_keys
;
988 dw2104_properties
.rc_key_map_size
=
989 ARRAY_SIZE(tevii_rc_keys
);
992 dw210x_op_rw(dev
, 0xc4, 0x0000, 0, &reset
, 1,
994 /* break omitted intentionally */
997 dw210x_op_rw(dev
, 0xbf, 0x0040, 0, &reset
, 0,
1000 case USB_PID_CINERGY_S
:
1001 case USB_PID_DW2102
:
1002 dw210x_op_rw(dev
, 0xbf, 0x0040, 0, &reset
, 0,
1004 dw210x_op_rw(dev
, 0xb9, 0x0000, 0, &reset16
[0], 2,
1006 /* check STV0299 frontend */
1007 dw210x_op_rw(dev
, 0xb5, 0, 0, &reset16
[0], 2,
1009 if ((reset16
[0] == 0xa1) || (reset16
[0] == 0x80)) {
1010 dw2102_properties
.i2c_algo
= &dw2102_i2c_algo
;
1011 dw2102_properties
.adapter
->tuner_attach
= &dw2102_tuner_attach
;
1014 /* check STV0288 frontend */
1018 dw210x_op_rw(dev
, 0xc2, 0, 0, &reset16
[0], 3,
1020 dw210x_op_rw(dev
, 0xc3, 0xd1, 0, &reset16
[0], 3,
1022 if (reset16
[2] == 0x11) {
1023 dw2102_properties
.i2c_algo
= &dw2102_earda_i2c_algo
;
1024 dw2102_properties
.adapter
->tuner_attach
= &dw2102_earda_tuner_attach
;
1029 dw210x_op_rw(dev
, 0xbc, 0x0030, 0, &reset16
[0], 2,
1031 dw210x_op_rw(dev
, 0xba, 0x0000, 0, &reset16
[0], 7,
1033 dw210x_op_rw(dev
, 0xba, 0x0000, 0, &reset16
[0], 7,
1035 dw210x_op_rw(dev
, 0xb9, 0x0000, 0, &reset16
[0], 2,
1046 static struct dvb_usb_device_properties dw2102_properties
= {
1047 .caps
= DVB_USB_IS_AN_I2C_ADAPTER
,
1048 .usb_ctrl
= DEVICE_SPECIFIC
,
1049 .firmware
= "dvb-usb-dw2102.fw",
1052 .i2c_algo
= &dw2102_serit_i2c_algo
,
1053 .rc_key_map
= dw210x_rc_keys
,
1054 .rc_key_map_size
= ARRAY_SIZE(dw210x_rc_keys
),
1056 .rc_query
= dw2102_rc_query
,
1058 .generic_bulk_ctrl_endpoint
= 0x81,
1059 /* parameter for the MPEG2-data transfer */
1061 .download_firmware
= dw2102_load_firmware
,
1062 .read_mac_address
= dw210x_read_mac_address
,
1065 .frontend_attach
= dw2102_frontend_attach
,
1066 .streaming_ctrl
= NULL
,
1067 .tuner_attach
= NULL
,
1080 .num_device_descs
= 3,
1082 {"DVBWorld DVB-S 2102 USB2.0",
1083 {&dw2102_table
[0], NULL
},
1086 {"DVBWorld DVB-S 2101 USB2.0",
1087 {&dw2102_table
[1], NULL
},
1090 {"TerraTec Cinergy S USB",
1091 {&dw2102_table
[4], NULL
},
1097 static struct dvb_usb_device_properties dw2104_properties
= {
1098 .caps
= DVB_USB_IS_AN_I2C_ADAPTER
,
1099 .usb_ctrl
= DEVICE_SPECIFIC
,
1100 .firmware
= "dvb-usb-dw2104.fw",
1103 .i2c_algo
= &dw2104_i2c_algo
,
1104 .rc_key_map
= dw210x_rc_keys
,
1105 .rc_key_map_size
= ARRAY_SIZE(dw210x_rc_keys
),
1107 .rc_query
= dw2102_rc_query
,
1109 .generic_bulk_ctrl_endpoint
= 0x81,
1110 /* parameter for the MPEG2-data transfer */
1112 .download_firmware
= dw2102_load_firmware
,
1113 .read_mac_address
= dw210x_read_mac_address
,
1116 .frontend_attach
= dw2104_frontend_attach
,
1117 .streaming_ctrl
= NULL
,
1118 /*.tuner_attach = dw2104_tuner_attach,*/
1131 .num_device_descs
= 2,
1133 { "DVBWorld DW2104 USB2.0",
1134 {&dw2102_table
[2], NULL
},
1137 { "TeVii S650 USB2.0",
1138 {&dw2102_table
[3], NULL
},
1144 static struct dvb_usb_device_properties dw3101_properties
= {
1145 .caps
= DVB_USB_IS_AN_I2C_ADAPTER
,
1146 .usb_ctrl
= DEVICE_SPECIFIC
,
1147 .firmware
= "dvb-usb-dw3101.fw",
1150 .i2c_algo
= &dw3101_i2c_algo
,
1151 .rc_key_map
= dw210x_rc_keys
,
1152 .rc_key_map_size
= ARRAY_SIZE(dw210x_rc_keys
),
1154 .rc_query
= dw2102_rc_query
,
1156 .generic_bulk_ctrl_endpoint
= 0x81,
1157 /* parameter for the MPEG2-data transfer */
1159 .download_firmware
= dw2102_load_firmware
,
1160 .read_mac_address
= dw210x_read_mac_address
,
1163 .frontend_attach
= dw3101_frontend_attach
,
1164 .streaming_ctrl
= NULL
,
1165 .tuner_attach
= dw3101_tuner_attach
,
1178 .num_device_descs
= 1,
1180 { "DVBWorld DVB-C 3101 USB2.0",
1181 {&dw2102_table
[5], NULL
},
1187 static struct dvb_usb_device_properties s630_properties
= {
1188 .caps
= DVB_USB_IS_AN_I2C_ADAPTER
,
1189 .usb_ctrl
= DEVICE_SPECIFIC
,
1190 .firmware
= "dvb-usb-s630.fw",
1193 .i2c_algo
= &s630_i2c_algo
,
1194 .rc_key_map
= tevii_rc_keys
,
1195 .rc_key_map_size
= ARRAY_SIZE(tevii_rc_keys
),
1197 .rc_query
= dw2102_rc_query
,
1199 .generic_bulk_ctrl_endpoint
= 0x81,
1201 .download_firmware
= dw2102_load_firmware
,
1202 .read_mac_address
= s630_read_mac_address
,
1205 .frontend_attach
= s630_frontend_attach
,
1206 .streaming_ctrl
= NULL
,
1207 .tuner_attach
= s630_zl10039_tuner_attach
,
1220 .num_device_descs
= 1,
1223 {&dw2102_table
[6], NULL
},
1229 static int dw2102_probe(struct usb_interface
*intf
,
1230 const struct usb_device_id
*id
)
1232 if (0 == dvb_usb_device_init(intf
, &dw2102_properties
,
1233 THIS_MODULE
, NULL
, adapter_nr
) ||
1234 0 == dvb_usb_device_init(intf
, &dw2104_properties
,
1235 THIS_MODULE
, NULL
, adapter_nr
) ||
1236 0 == dvb_usb_device_init(intf
, &dw3101_properties
,
1237 THIS_MODULE
, NULL
, adapter_nr
) ||
1238 0 == dvb_usb_device_init(intf
, &s630_properties
,
1239 THIS_MODULE
, NULL
, adapter_nr
)) {
1245 static struct usb_driver dw2102_driver
= {
1247 .probe
= dw2102_probe
,
1248 .disconnect
= dvb_usb_device_exit
,
1249 .id_table
= dw2102_table
,
1252 static int __init
dw2102_module_init(void)
1254 int ret
= usb_register(&dw2102_driver
);
1256 err("usb_register failed. Error number %d", ret
);
1261 static void __exit
dw2102_module_exit(void)
1263 usb_deregister(&dw2102_driver
);
1266 module_init(dw2102_module_init
);
1267 module_exit(dw2102_module_exit
);
1269 MODULE_AUTHOR("Igor M. Liplianin (c) liplianin@me.by");
1270 MODULE_DESCRIPTION("Driver for DVBWorld DVB-S 2101, 2102, DVB-S2 2104,"
1271 " DVB-C 3101 USB2.0,"
1272 " TeVii S600, S630, S650 USB2.0 devices");
1273 MODULE_VERSION("0.1");
1274 MODULE_LICENSE("GPL");