1 /* DVB USB framework compliant Linux driver for the
2 * DVBWorld DVB-S 2101, 2102, DVB-S2 2104, DVB-C 3101,
3 * TeVii S600, S630, S650, S660, S480,
5 * Geniatech SU3000 Cards
6 * Copyright (C) 2008-2011 Igor M. Liplianin (liplianin@me.by)
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation, version 2.
12 * see Documentation/dvb/README.dvb-usb for more information
29 #include "stb6100_proc.h"
31 #ifndef USB_PID_DW2102
32 #define USB_PID_DW2102 0x2102
35 #ifndef USB_PID_DW2104
36 #define USB_PID_DW2104 0x2104
39 #ifndef USB_PID_DW3101
40 #define USB_PID_DW3101 0x3101
43 #ifndef USB_PID_CINERGY_S
44 #define USB_PID_CINERGY_S 0x0064
47 #ifndef USB_PID_TEVII_S630
48 #define USB_PID_TEVII_S630 0xd630
51 #ifndef USB_PID_TEVII_S650
52 #define USB_PID_TEVII_S650 0xd650
55 #ifndef USB_PID_TEVII_S660
56 #define USB_PID_TEVII_S660 0xd660
59 #ifndef USB_PID_TEVII_S480_1
60 #define USB_PID_TEVII_S480_1 0xd481
63 #ifndef USB_PID_TEVII_S480_2
64 #define USB_PID_TEVII_S480_2 0xd482
67 #ifndef USB_PID_PROF_1100
68 #define USB_PID_PROF_1100 0xb012
71 #define DW210X_READ_MSG 0
72 #define DW210X_WRITE_MSG 1
74 #define REG_1F_SYMBOLRATE_BYTE0 0x1f
75 #define REG_20_SYMBOLRATE_BYTE1 0x20
76 #define REG_21_SYMBOLRATE_BYTE2 0x21
78 #define DW2102_VOLTAGE_CTRL (0x1800)
79 #define SU3000_STREAM_CTRL (0x1900)
80 #define DW2102_RC_QUERY (0x1a00)
81 #define DW2102_LED_CTRL (0x1b00)
83 #define err_str "did not find the firmware file. (%s) " \
84 "Please see linux/Documentation/dvb/ for more details " \
85 "on firmware-problems."
87 struct rc_map_dvb_usb_table_table {
88 struct rc_map_table *rc_keys;
97 int (*old_set_voltage)(struct dvb_frontend *f, fe_sec_voltage_t v);
101 static int dvb_usb_dw2102_debug;
102 module_param_named(debug, dvb_usb_dw2102_debug, int, 0644);
103 MODULE_PARM_DESC(debug, "set debugging level (1=info 2=xfer 4=rc(or-able))."
104 DVB_USB_DEBUG_STATUS);
107 static int ir_keymap;
108 module_param_named(keymap, ir_keymap, int, 0644);
109 MODULE_PARM_DESC(keymap, "set keymap 0=default 1=dvbworld 2=tevii 3=tbs ..."
113 static int demod_probe = 1;
114 module_param_named(demod, demod_probe, int, 0644);
115 MODULE_PARM_DESC(demod, "demod to probe (1=cx24116 2=stv0903+stv6110 "
116 "4=stv0903+stb6100(or-able)).");
118 DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
120 static int dw210x_op_rw(struct usb_device *dev, u8 request, u16 value,
121 u16 index, u8 * data, u16 len, int flags)
125 unsigned int pipe = (flags == DW210X_READ_MSG) ?
126 usb_rcvctrlpipe(dev, 0) : usb_sndctrlpipe(dev, 0);
127 u8 request_type = (flags == DW210X_READ_MSG) ? USB_DIR_IN : USB_DIR_OUT;
129 u8buf = kmalloc(len, GFP_KERNEL);
134 if (flags == DW210X_WRITE_MSG)
135 memcpy(u8buf, data, len);
136 ret = usb_control_msg(dev, pipe, request, request_type | USB_TYPE_VENDOR,
137 value, index , u8buf, len, 2000);
139 if (flags == DW210X_READ_MSG)
140 memcpy(data, u8buf, len);
147 static int dw2102_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],
150 struct dvb_usb_device *d = i2c_get_adapdata(adap);
152 u8 buf6[] = {0x2c, 0x05, 0xc0, 0, 0, 0, 0};
157 if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
162 /* read stv0299 register */
163 value = msg[0].buf[0];/* register */
164 for (i = 0; i < msg[1].len; i++) {
165 ret = dw210x_op_rw(d->udev, 0xb5, value + i, 0,
166 buf6, 2, DW210X_READ_MSG);
167 msg[1].buf[i] = buf6[0];
171 switch (msg[0].addr) {
173 /* write to stv0299 register */
175 buf6[1] = msg[0].buf[0];
176 buf6[2] = msg[0].buf[1];
177 ret = dw210x_op_rw(d->udev, 0xb2, 0, 0,
178 buf6, 3, DW210X_WRITE_MSG);
181 if (msg[0].flags == 0) {
182 /* write to tuner pll */
186 buf6[3] = msg[0].buf[0];
187 buf6[4] = msg[0].buf[1];
188 buf6[5] = msg[0].buf[2];
189 buf6[6] = msg[0].buf[3];
190 ret = dw210x_op_rw(d->udev, 0xb2, 0, 0,
191 buf6, 7, DW210X_WRITE_MSG);
193 /* read from tuner */
194 ret = dw210x_op_rw(d->udev, 0xb5, 0, 0,
195 buf6, 1, DW210X_READ_MSG);
196 msg[0].buf[0] = buf6[0];
199 case (DW2102_RC_QUERY):
200 ret = dw210x_op_rw(d->udev, 0xb8, 0, 0,
201 buf6, 2, DW210X_READ_MSG);
202 msg[0].buf[0] = buf6[0];
203 msg[0].buf[1] = buf6[1];
205 case (DW2102_VOLTAGE_CTRL):
207 buf6[1] = msg[0].buf[0];
208 ret = dw210x_op_rw(d->udev, 0xb2, 0, 0,
209 buf6, 2, DW210X_WRITE_MSG);
216 mutex_unlock(&d->i2c_mutex);
220 static int dw2102_serit_i2c_transfer(struct i2c_adapter *adap,
221 struct i2c_msg msg[], int num)
223 struct dvb_usb_device *d = i2c_get_adapdata(adap);
225 u8 buf6[] = {0, 0, 0, 0, 0, 0, 0};
229 if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
234 /* read si2109 register by number */
235 buf6[0] = msg[0].addr << 1;
236 buf6[1] = msg[0].len;
237 buf6[2] = msg[0].buf[0];
238 ret = dw210x_op_rw(d->udev, 0xc2, 0, 0,
239 buf6, msg[0].len + 2, DW210X_WRITE_MSG);
240 /* read si2109 register */
241 ret = dw210x_op_rw(d->udev, 0xc3, 0xd0, 0,
242 buf6, msg[1].len + 2, DW210X_READ_MSG);
243 memcpy(msg[1].buf, buf6 + 2, msg[1].len);
247 switch (msg[0].addr) {
249 /* write to si2109 register */
250 buf6[0] = msg[0].addr << 1;
251 buf6[1] = msg[0].len;
252 memcpy(buf6 + 2, msg[0].buf, msg[0].len);
253 ret = dw210x_op_rw(d->udev, 0xc2, 0, 0, buf6,
254 msg[0].len + 2, DW210X_WRITE_MSG);
256 case(DW2102_RC_QUERY):
257 ret = dw210x_op_rw(d->udev, 0xb8, 0, 0,
258 buf6, 2, DW210X_READ_MSG);
259 msg[0].buf[0] = buf6[0];
260 msg[0].buf[1] = buf6[1];
262 case(DW2102_VOLTAGE_CTRL):
264 buf6[1] = msg[0].buf[0];
265 ret = dw210x_op_rw(d->udev, 0xb2, 0, 0,
266 buf6, 2, DW210X_WRITE_MSG);
272 mutex_unlock(&d->i2c_mutex);
276 static int dw2102_earda_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], int num)
278 struct dvb_usb_device *d = i2c_get_adapdata(adap);
283 if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
289 /* first write first register number */
290 u8 ibuf[msg[1].len + 2], obuf[3];
291 obuf[0] = msg[0].addr << 1;
292 obuf[1] = msg[0].len;
293 obuf[2] = msg[0].buf[0];
294 ret = dw210x_op_rw(d->udev, 0xc2, 0, 0,
295 obuf, msg[0].len + 2, DW210X_WRITE_MSG);
296 /* second read registers */
297 ret = dw210x_op_rw(d->udev, 0xc3, 0xd1 , 0,
298 ibuf, msg[1].len + 2, DW210X_READ_MSG);
299 memcpy(msg[1].buf, ibuf + 2, msg[1].len);
304 switch (msg[0].addr) {
306 /* write to register */
307 u8 obuf[msg[0].len + 2];
308 obuf[0] = msg[0].addr << 1;
309 obuf[1] = msg[0].len;
310 memcpy(obuf + 2, msg[0].buf, msg[0].len);
311 ret = dw210x_op_rw(d->udev, 0xc2, 0, 0,
312 obuf, msg[0].len + 2, DW210X_WRITE_MSG);
317 u8 obuf[msg[0].len + 2];
318 obuf[0] = msg[0].addr << 1;
319 obuf[1] = msg[0].len;
320 memcpy(obuf + 2, msg[0].buf, msg[0].len);
321 ret = dw210x_op_rw(d->udev, 0xc2, 0, 0,
322 obuf, msg[0].len + 2, DW210X_WRITE_MSG);
325 case(DW2102_RC_QUERY): {
327 ret = dw210x_op_rw(d->udev, 0xb8, 0, 0,
328 ibuf, 2, DW210X_READ_MSG);
329 memcpy(msg[0].buf, ibuf , 2);
332 case(DW2102_VOLTAGE_CTRL): {
335 obuf[1] = msg[0].buf[0];
336 ret = dw210x_op_rw(d->udev, 0xb2, 0, 0,
337 obuf, 2, DW210X_WRITE_MSG);
345 mutex_unlock(&d->i2c_mutex);
349 static int dw2104_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], int num)
351 struct dvb_usb_device *d = i2c_get_adapdata(adap);
357 if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
360 for (j = 0; j < num; j++) {
361 switch (msg[j].addr) {
362 case(DW2102_RC_QUERY): {
364 ret = dw210x_op_rw(d->udev, 0xb8, 0, 0,
365 ibuf, 2, DW210X_READ_MSG);
366 memcpy(msg[j].buf, ibuf , 2);
369 case(DW2102_VOLTAGE_CTRL): {
372 obuf[1] = msg[j].buf[0];
373 ret = dw210x_op_rw(d->udev, 0xb2, 0, 0,
374 obuf, 2, DW210X_WRITE_MSG);
379 case 0x68: ds3000, stv0903
380 case 0x60: ts2020, stv6110, stb6100 */
382 if (msg[j].flags == I2C_M_RD) {
384 u8 ibuf[msg[j].len + 2];
385 ret = dw210x_op_rw(d->udev, 0xc3,
386 (msg[j].addr << 1) + 1, 0,
387 ibuf, msg[j].len + 2,
389 memcpy(msg[j].buf, ibuf + 2, msg[j].len);
391 } else if (((msg[j].buf[0] == 0xb0) &&
392 (msg[j].addr == 0x68)) ||
393 ((msg[j].buf[0] == 0xf7) &&
394 (msg[j].addr == 0x55))) {
397 obuf[0] = msg[j].addr << 1;
398 obuf[1] = (msg[j].len > 15 ? 17 : msg[j].len);
399 obuf[2] = msg[j].buf[0];
400 len = msg[j].len - 1;
403 memcpy(obuf + 3, msg[j].buf + i,
404 (len > 16 ? 16 : len));
405 ret = dw210x_op_rw(d->udev, 0xc2, 0, 0,
406 obuf, (len > 16 ? 16 : len) + 3,
412 /* write registers */
413 u8 obuf[msg[j].len + 2];
414 obuf[0] = msg[j].addr << 1;
415 obuf[1] = msg[j].len;
416 memcpy(obuf + 2, msg[j].buf, msg[j].len);
417 ret = dw210x_op_rw(d->udev, 0xc2, 0, 0,
418 obuf, msg[j].len + 2,
427 mutex_unlock(&d->i2c_mutex);
431 static int dw3101_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],
434 struct dvb_usb_device *d = i2c_get_adapdata(adap);
439 if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
445 /* first write first register number */
446 u8 ibuf[msg[1].len + 2], obuf[3];
447 obuf[0] = msg[0].addr << 1;
448 obuf[1] = msg[0].len;
449 obuf[2] = msg[0].buf[0];
450 ret = dw210x_op_rw(d->udev, 0xc2, 0, 0,
451 obuf, msg[0].len + 2, DW210X_WRITE_MSG);
452 /* second read registers */
453 ret = dw210x_op_rw(d->udev, 0xc3, 0x19 , 0,
454 ibuf, msg[1].len + 2, DW210X_READ_MSG);
455 memcpy(msg[1].buf, ibuf + 2, msg[1].len);
460 switch (msg[0].addr) {
463 /* write to register */
464 u8 obuf[msg[0].len + 2];
465 obuf[0] = msg[0].addr << 1;
466 obuf[1] = msg[0].len;
467 memcpy(obuf + 2, msg[0].buf, msg[0].len);
468 ret = dw210x_op_rw(d->udev, 0xc2, 0, 0,
469 obuf, msg[0].len + 2, DW210X_WRITE_MSG);
472 case(DW2102_RC_QUERY): {
474 ret = dw210x_op_rw(d->udev, 0xb8, 0, 0,
475 ibuf, 2, DW210X_READ_MSG);
476 memcpy(msg[0].buf, ibuf , 2);
484 for (i = 0; i < num; i++) {
485 deb_xfer("%02x:%02x: %s ", i, msg[i].addr,
486 msg[i].flags == 0 ? ">>>" : "<<<");
487 debug_dump(msg[i].buf, msg[i].len, deb_xfer);
490 mutex_unlock(&d->i2c_mutex);
494 static int s6x0_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],
497 struct dvb_usb_device *d = i2c_get_adapdata(adap);
498 struct usb_device *udev;
505 if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
508 for (j = 0; j < num; j++) {
509 switch (msg[j].addr) {
510 case (DW2102_RC_QUERY): {
512 ret = dw210x_op_rw(d->udev, 0xb8, 0, 0,
513 ibuf, 5, DW210X_READ_MSG);
514 memcpy(msg[j].buf, ibuf + 3, 2);
517 case (DW2102_VOLTAGE_CTRL): {
521 obuf[1] = msg[j].buf[1];/* off-on */
522 ret = dw210x_op_rw(d->udev, 0x8a, 0, 0,
523 obuf, 2, DW210X_WRITE_MSG);
525 obuf[1] = msg[j].buf[0];/* 13v-18v */
526 ret = dw210x_op_rw(d->udev, 0x8a, 0, 0,
527 obuf, 2, DW210X_WRITE_MSG);
530 case (DW2102_LED_CTRL): {
534 obuf[1] = msg[j].buf[0];
535 ret = dw210x_op_rw(d->udev, 0x8a, 0, 0,
536 obuf, 2, DW210X_WRITE_MSG);
541 case 0x68: ds3000, stv0903
542 case 0x60: ts2020, stv6110, stb6100
545 if (msg[j].flags == I2C_M_RD) {
548 ret = dw210x_op_rw(d->udev, 0x91, 0, 0,
551 memcpy(msg[j].buf, ibuf, msg[j].len);
553 } else if ((msg[j].buf[0] == 0xb0) &&
554 (msg[j].addr == 0x68)) {
557 obuf[0] = (msg[j].len > 16 ?
558 18 : msg[j].len + 1);
559 obuf[1] = msg[j].addr << 1;
560 obuf[2] = msg[j].buf[0];
561 len = msg[j].len - 1;
564 memcpy(obuf + 3, msg[j].buf + i,
565 (len > 16 ? 16 : len));
566 ret = dw210x_op_rw(d->udev, 0x80, 0, 0,
567 obuf, (len > 16 ? 16 : len) + 3,
572 } else if (j < (num - 1)) {
573 /* write register addr before read */
574 u8 obuf[msg[j].len + 2];
575 obuf[0] = msg[j + 1].len;
576 obuf[1] = (msg[j].addr << 1);
577 memcpy(obuf + 2, msg[j].buf, msg[j].len);
578 ret = dw210x_op_rw(d->udev,
579 udev->descriptor.idProduct ==
580 0x7500 ? 0x92 : 0x90, 0, 0,
581 obuf, msg[j].len + 2,
585 /* write registers */
586 u8 obuf[msg[j].len + 2];
587 obuf[0] = msg[j].len + 1;
588 obuf[1] = (msg[j].addr << 1);
589 memcpy(obuf + 2, msg[j].buf, msg[j].len);
590 ret = dw210x_op_rw(d->udev, 0x80, 0, 0,
591 obuf, msg[j].len + 2,
600 mutex_unlock(&d->i2c_mutex);
604 static int su3000_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],
607 struct dvb_usb_device *d = i2c_get_adapdata(adap);
608 u8 obuf[0x40], ibuf[0x40];
612 if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
617 switch (msg[0].addr) {
618 case SU3000_STREAM_CTRL:
619 obuf[0] = msg[0].buf[0] + 0x36;
622 if (dvb_usb_generic_rw(d, obuf, 3, ibuf, 0, 0) < 0)
623 err("i2c transfer failed.");
625 case DW2102_RC_QUERY:
627 if (dvb_usb_generic_rw(d, obuf, 1, ibuf, 2, 0) < 0)
628 err("i2c transfer failed.");
629 msg[0].buf[1] = ibuf[0];
630 msg[0].buf[0] = ibuf[1];
633 /* always i2c write*/
635 obuf[1] = msg[0].addr;
636 obuf[2] = msg[0].len;
638 memcpy(&obuf[3], msg[0].buf, msg[0].len);
640 if (dvb_usb_generic_rw(d, obuf, msg[0].len + 3,
642 err("i2c transfer failed.");
647 /* always i2c read */
649 obuf[1] = msg[0].len;
650 obuf[2] = msg[1].len;
651 obuf[3] = msg[0].addr;
652 memcpy(&obuf[4], msg[0].buf, msg[0].len);
654 if (dvb_usb_generic_rw(d, obuf, msg[0].len + 4,
655 ibuf, msg[1].len + 1, 0) < 0)
656 err("i2c transfer failed.");
658 memcpy(msg[1].buf, &ibuf[1], msg[1].len);
661 warn("more than 2 i2c messages at a time is not handled yet.");
664 mutex_unlock(&d->i2c_mutex);
668 static u32 dw210x_i2c_func(struct i2c_adapter *adapter)
673 static struct i2c_algorithm dw2102_i2c_algo = {
674 .master_xfer = dw2102_i2c_transfer,
675 .functionality = dw210x_i2c_func,
678 static struct i2c_algorithm dw2102_serit_i2c_algo = {
679 .master_xfer = dw2102_serit_i2c_transfer,
680 .functionality = dw210x_i2c_func,
683 static struct i2c_algorithm dw2102_earda_i2c_algo = {
684 .master_xfer = dw2102_earda_i2c_transfer,
685 .functionality = dw210x_i2c_func,
688 static struct i2c_algorithm dw2104_i2c_algo = {
689 .master_xfer = dw2104_i2c_transfer,
690 .functionality = dw210x_i2c_func,
693 static struct i2c_algorithm dw3101_i2c_algo = {
694 .master_xfer = dw3101_i2c_transfer,
695 .functionality = dw210x_i2c_func,
698 static struct i2c_algorithm s6x0_i2c_algo = {
699 .master_xfer = s6x0_i2c_transfer,
700 .functionality = dw210x_i2c_func,
703 static struct i2c_algorithm su3000_i2c_algo = {
704 .master_xfer = su3000_i2c_transfer,
705 .functionality = dw210x_i2c_func,
708 static int dw210x_read_mac_address(struct dvb_usb_device *d, u8 mac[6])
712 u8 eeprom[256], eepromline[16];
714 for (i = 0; i < 256; i++) {
715 if (dw210x_op_rw(d->udev, 0xb6, 0xa0 , i, ibuf, 2, DW210X_READ_MSG) < 0) {
716 err("read eeprom failed.");
719 eepromline[i%16] = ibuf[0];
722 if ((i % 16) == 15) {
723 deb_xfer("%02x: ", i - 15);
724 debug_dump(eepromline, 16, deb_xfer);
728 memcpy(mac, eeprom + 8, 6);
732 static int s6x0_read_mac_address(struct dvb_usb_device *d, u8 mac[6])
735 u8 ibuf[] = { 0 }, obuf[] = { 0 };
736 u8 eeprom[256], eepromline[16];
737 struct i2c_msg msg[] = {
751 for (i = 0; i < 256; i++) {
753 ret = s6x0_i2c_transfer(&d->i2c_adap, msg, 2);
755 err("read eeprom failed.");
758 eepromline[i % 16] = ibuf[0];
762 if ((i % 16) == 15) {
763 deb_xfer("%02x: ", i - 15);
764 debug_dump(eepromline, 16, deb_xfer);
768 memcpy(mac, eeprom + 16, 6);
772 static int su3000_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff)
774 static u8 command_start[] = {0x00};
775 static u8 command_stop[] = {0x01};
776 struct i2c_msg msg = {
777 .addr = SU3000_STREAM_CTRL,
779 .buf = onoff ? command_start : command_stop,
783 i2c_transfer(&adap->dev->i2c_adap, &msg, 1);
788 static int su3000_power_ctrl(struct dvb_usb_device *d, int i)
790 struct su3000_state *state = (struct su3000_state *)d->priv;
791 u8 obuf[] = {0xde, 0};
793 info("%s: %d, initialized %d\n", __func__, i, state->initialized);
795 if (i && !state->initialized) {
796 state->initialized = 1;
798 dvb_usb_generic_rw(d, obuf, 2, NULL, 0, 0);
804 static int su3000_read_mac_address(struct dvb_usb_device *d, u8 mac[6])
807 u8 obuf[] = { 0x1f, 0xf0 };
809 struct i2c_msg msg[] = {
824 for (i = 0; i < 6; i++) {
826 if (i2c_transfer(&d->i2c_adap, msg, 2) != 2)
831 debug_dump(mac, 6, printk);
837 static int su3000_identify_state(struct usb_device *udev,
838 struct dvb_usb_device_properties *props,
839 struct dvb_usb_device_description **desc,
842 info("%s\n", __func__);
848 static int dw210x_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
850 static u8 command_13v[] = {0x00, 0x01};
851 static u8 command_18v[] = {0x01, 0x01};
852 static u8 command_off[] = {0x00, 0x00};
853 struct i2c_msg msg = {
854 .addr = DW2102_VOLTAGE_CTRL,
860 struct dvb_usb_adapter *udev_adap =
861 (struct dvb_usb_adapter *)(fe->dvb->priv);
862 if (voltage == SEC_VOLTAGE_18)
863 msg.buf = command_18v;
864 else if (voltage == SEC_VOLTAGE_13)
865 msg.buf = command_13v;
867 i2c_transfer(&udev_adap->dev->i2c_adap, &msg, 1);
872 static int s660_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
874 struct dvb_usb_adapter *d =
875 (struct dvb_usb_adapter *)(fe->dvb->priv);
876 struct s6x0_state *st = (struct s6x0_state *)d->dev->priv;
878 dw210x_set_voltage(fe, voltage);
879 if (st->old_set_voltage)
880 st->old_set_voltage(fe, voltage);
885 static void dw210x_led_ctrl(struct dvb_frontend *fe, int offon)
887 static u8 led_off[] = { 0 };
888 static u8 led_on[] = { 1 };
889 struct i2c_msg msg = {
890 .addr = DW2102_LED_CTRL,
895 struct dvb_usb_adapter *udev_adap =
896 (struct dvb_usb_adapter *)(fe->dvb->priv);
900 i2c_transfer(&udev_adap->dev->i2c_adap, &msg, 1);
903 static struct stv0299_config sharp_z0194a_config = {
904 .demod_address = 0x68,
905 .inittab = sharp_z0194a_inittab,
909 .lock_output = STV0299_LOCKOUTPUT_1,
910 .volt13_op0_op1 = STV0299_VOLT13_OP1,
912 .set_symbol_rate = sharp_z0194a_set_symbol_rate,
915 static struct cx24116_config dw2104_config = {
916 .demod_address = 0x55,
917 .mpg_clk_pos_pol = 0x01,
920 static struct si21xx_config serit_sp1511lhb_config = {
921 .demod_address = 0x68,
926 static struct tda10023_config dw3101_tda10023_config = {
927 .demod_address = 0x0c,
931 static struct mt312_config zl313_config = {
932 .demod_address = 0x0e,
935 static struct ds3000_config dw2104_ds3000_config = {
936 .demod_address = 0x68,
939 static struct stv0900_config dw2104a_stv0900_config = {
940 .demod_address = 0x6a,
943 .clkmode = 3,/* 0-CLKI, 2-XTALI, else AUTO */
944 .diseqc_mode = 2,/* 2/3 PWM */
945 .tun1_maddress = 0,/* 0x60 */
946 .tun1_adc = 0,/* 2 Vpp */
950 static struct stb6100_config dw2104a_stb6100_config = {
951 .tuner_address = 0x60,
952 .refclock = 27000000,
955 static struct stv0900_config dw2104_stv0900_config = {
956 .demod_address = 0x68,
962 .tun1_adc = 1,/* 1 Vpp */
966 static struct stv6110_config dw2104_stv6110_config = {
972 static struct stv0900_config prof_7500_stv0900_config = {
973 .demod_address = 0x6a,
976 .clkmode = 3,/* 0-CLKI, 2-XTALI, else AUTO */
977 .diseqc_mode = 2,/* 2/3 PWM */
978 .tun1_maddress = 0,/* 0x60 */
979 .tun1_adc = 0,/* 2 Vpp */
982 .set_lock_led = dw210x_led_ctrl,
985 static struct ds3000_config su3000_ds3000_config = {
986 .demod_address = 0x68,
990 static int dw2104_frontend_attach(struct dvb_usb_adapter *d)
992 struct dvb_tuner_ops *tuner_ops = NULL;
994 if (demod_probe & 4) {
995 d->fe_adap[0].fe = dvb_attach(stv0900_attach, &dw2104a_stv0900_config,
996 &d->dev->i2c_adap, 0);
997 if (d->fe_adap[0].fe != NULL) {
998 if (dvb_attach(stb6100_attach, d->fe_adap[0].fe,
999 &dw2104a_stb6100_config,
1000 &d->dev->i2c_adap)) {
1001 tuner_ops = &d->fe_adap[0].fe->ops.tuner_ops;
1002 tuner_ops->set_frequency = stb6100_set_freq;
1003 tuner_ops->get_frequency = stb6100_get_freq;
1004 tuner_ops->set_bandwidth = stb6100_set_bandw;
1005 tuner_ops->get_bandwidth = stb6100_get_bandw;
1006 d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage;
1007 info("Attached STV0900+STB6100!\n");
1013 if (demod_probe & 2) {
1014 d->fe_adap[0].fe = dvb_attach(stv0900_attach, &dw2104_stv0900_config,
1015 &d->dev->i2c_adap, 0);
1016 if (d->fe_adap[0].fe != NULL) {
1017 if (dvb_attach(stv6110_attach, d->fe_adap[0].fe,
1018 &dw2104_stv6110_config,
1019 &d->dev->i2c_adap)) {
1020 d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage;
1021 info("Attached STV0900+STV6110A!\n");
1027 if (demod_probe & 1) {
1028 d->fe_adap[0].fe = dvb_attach(cx24116_attach, &dw2104_config,
1030 if (d->fe_adap[0].fe != NULL) {
1031 d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage;
1032 info("Attached cx24116!\n");
1037 d->fe_adap[0].fe = dvb_attach(ds3000_attach, &dw2104_ds3000_config,
1039 if (d->fe_adap[0].fe != NULL) {
1040 d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage;
1041 info("Attached DS3000!\n");
1048 static struct dvb_usb_device_properties dw2102_properties;
1049 static struct dvb_usb_device_properties dw2104_properties;
1050 static struct dvb_usb_device_properties s6x0_properties;
1052 static int dw2102_frontend_attach(struct dvb_usb_adapter *d)
1054 if (dw2102_properties.i2c_algo == &dw2102_serit_i2c_algo) {
1055 /*dw2102_properties.adapter->tuner_attach = NULL;*/
1056 d->fe_adap[0].fe = dvb_attach(si21xx_attach, &serit_sp1511lhb_config,
1058 if (d->fe_adap[0].fe != NULL) {
1059 d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage;
1060 info("Attached si21xx!\n");
1065 if (dw2102_properties.i2c_algo == &dw2102_earda_i2c_algo) {
1066 d->fe_adap[0].fe = dvb_attach(stv0288_attach, &earda_config,
1068 if (d->fe_adap[0].fe != NULL) {
1069 if (dvb_attach(stb6000_attach, d->fe_adap[0].fe, 0x61,
1070 &d->dev->i2c_adap)) {
1071 d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage;
1072 info("Attached stv0288!\n");
1078 if (dw2102_properties.i2c_algo == &dw2102_i2c_algo) {
1079 /*dw2102_properties.adapter->tuner_attach = dw2102_tuner_attach;*/
1080 d->fe_adap[0].fe = dvb_attach(stv0299_attach, &sharp_z0194a_config,
1082 if (d->fe_adap[0].fe != NULL) {
1083 d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage;
1084 info("Attached stv0299!\n");
1091 static int dw3101_frontend_attach(struct dvb_usb_adapter *d)
1093 d->fe_adap[0].fe = dvb_attach(tda10023_attach, &dw3101_tda10023_config,
1094 &d->dev->i2c_adap, 0x48);
1095 if (d->fe_adap[0].fe != NULL) {
1096 info("Attached tda10023!\n");
1102 static int zl100313_frontend_attach(struct dvb_usb_adapter *d)
1104 d->fe_adap[0].fe = dvb_attach(mt312_attach, &zl313_config,
1106 if (d->fe_adap[0].fe != NULL) {
1107 if (dvb_attach(zl10039_attach, d->fe_adap[0].fe, 0x60,
1108 &d->dev->i2c_adap)) {
1109 d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage;
1110 info("Attached zl100313+zl10039!\n");
1118 static int stv0288_frontend_attach(struct dvb_usb_adapter *d)
1122 d->fe_adap[0].fe = dvb_attach(stv0288_attach, &earda_config,
1125 if (d->fe_adap[0].fe == NULL)
1128 if (NULL == dvb_attach(stb6000_attach, d->fe_adap[0].fe, 0x61, &d->dev->i2c_adap))
1131 d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage;
1133 dw210x_op_rw(d->dev->udev, 0x8a, 0, 0, obuf, 2, DW210X_WRITE_MSG);
1135 info("Attached stv0288+stb6000!\n");
1141 static int ds3000_frontend_attach(struct dvb_usb_adapter *d)
1143 struct s6x0_state *st = (struct s6x0_state *)d->dev->priv;
1146 d->fe_adap[0].fe = dvb_attach(ds3000_attach, &dw2104_ds3000_config,
1149 if (d->fe_adap[0].fe == NULL)
1152 st->old_set_voltage = d->fe_adap[0].fe->ops.set_voltage;
1153 d->fe_adap[0].fe->ops.set_voltage = s660_set_voltage;
1155 dw210x_op_rw(d->dev->udev, 0x8a, 0, 0, obuf, 2, DW210X_WRITE_MSG);
1157 info("Attached ds3000+ds2020!\n");
1162 static int prof_7500_frontend_attach(struct dvb_usb_adapter *d)
1166 d->fe_adap[0].fe = dvb_attach(stv0900_attach, &prof_7500_stv0900_config,
1167 &d->dev->i2c_adap, 0);
1168 if (d->fe_adap[0].fe == NULL)
1171 d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage;
1173 dw210x_op_rw(d->dev->udev, 0x8a, 0, 0, obuf, 2, DW210X_WRITE_MSG);
1175 info("Attached STV0900+STB6100A!\n");
1180 static int su3000_frontend_attach(struct dvb_usb_adapter *d)
1182 u8 obuf[3] = { 0xe, 0x80, 0 };
1185 if (dvb_usb_generic_rw(d->dev, obuf, 3, ibuf, 1, 0) < 0)
1186 err("command 0x0e transfer failed.");
1192 if (dvb_usb_generic_rw(d->dev, obuf, 3, ibuf, 1, 0) < 0)
1193 err("command 0x0e transfer failed.");
1199 if (dvb_usb_generic_rw(d->dev, obuf, 3, ibuf, 1, 0) < 0)
1200 err("command 0x0e transfer failed.");
1204 if (dvb_usb_generic_rw(d->dev, obuf, 1, ibuf, 1, 0) < 0)
1205 err("command 0x51 transfer failed.");
1207 d->fe_adap[0].fe = dvb_attach(ds3000_attach, &su3000_ds3000_config,
1209 if (d->fe_adap[0].fe == NULL)
1212 info("Attached DS3000!\n");
1217 static int dw2102_tuner_attach(struct dvb_usb_adapter *adap)
1219 dvb_attach(dvb_pll_attach, adap->fe_adap[0].fe, 0x60,
1220 &adap->dev->i2c_adap, DVB_PLL_OPERA1);
1224 static int dw3101_tuner_attach(struct dvb_usb_adapter *adap)
1226 dvb_attach(dvb_pll_attach, adap->fe_adap[0].fe, 0x60,
1227 &adap->dev->i2c_adap, DVB_PLL_TUA6034);
1232 static struct rc_map_table rc_map_dw210x_table[] = {
1233 { 0xf80a, KEY_POWER2 }, /*power*/
1234 { 0xf80c, KEY_MUTE }, /*mute*/
1245 { 0xf81c, KEY_CHANNELUP }, /*ch+*/
1246 { 0xf80f, KEY_CHANNELDOWN }, /*ch-*/
1247 { 0xf81a, KEY_VOLUMEUP }, /*vol+*/
1248 { 0xf80e, KEY_VOLUMEDOWN }, /*vol-*/
1249 { 0xf804, KEY_RECORD }, /*rec*/
1250 { 0xf809, KEY_FAVORITES }, /*fav*/
1251 { 0xf808, KEY_REWIND }, /*rewind*/
1252 { 0xf807, KEY_FASTFORWARD }, /*fast*/
1253 { 0xf80b, KEY_PAUSE }, /*pause*/
1254 { 0xf802, KEY_ESC }, /*cancel*/
1255 { 0xf803, KEY_TAB }, /*tab*/
1256 { 0xf800, KEY_UP }, /*up*/
1257 { 0xf81f, KEY_OK }, /*ok*/
1258 { 0xf801, KEY_DOWN }, /*down*/
1259 { 0xf805, KEY_CAMERA }, /*cap*/
1260 { 0xf806, KEY_STOP }, /*stop*/
1261 { 0xf840, KEY_ZOOM }, /*full*/
1262 { 0xf81e, KEY_TV }, /*tvmode*/
1263 { 0xf81b, KEY_LAST }, /*recall*/
1266 static struct rc_map_table rc_map_tevii_table[] = {
1267 { 0xf80a, KEY_POWER },
1268 { 0xf80c, KEY_MUTE },
1279 { 0xf81c, KEY_MENU },
1280 { 0xf80f, KEY_VOLUMEDOWN },
1281 { 0xf81a, KEY_LAST },
1282 { 0xf80e, KEY_OPEN },
1283 { 0xf804, KEY_RECORD },
1284 { 0xf809, KEY_VOLUMEUP },
1285 { 0xf808, KEY_CHANNELUP },
1286 { 0xf807, KEY_PVR },
1287 { 0xf80b, KEY_TIME },
1288 { 0xf802, KEY_RIGHT },
1289 { 0xf803, KEY_LEFT },
1292 { 0xf801, KEY_DOWN },
1293 { 0xf805, KEY_TUNER },
1294 { 0xf806, KEY_CHANNELDOWN },
1295 { 0xf840, KEY_PLAYPAUSE },
1296 { 0xf81e, KEY_REWIND },
1297 { 0xf81b, KEY_FAVORITES },
1298 { 0xf81d, KEY_BACK },
1299 { 0xf84d, KEY_FASTFORWARD },
1300 { 0xf844, KEY_EPG },
1301 { 0xf84c, KEY_INFO },
1303 { 0xf843, KEY_AUDIO },
1304 { 0xf845, KEY_SUBTITLE },
1305 { 0xf84a, KEY_LIST },
1312 { 0xf856, KEY_MODE },
1313 { 0xf858, KEY_SWITCHVIDEOMODE },
1316 static struct rc_map_table rc_map_tbs_table[] = {
1317 { 0xf884, KEY_POWER },
1318 { 0xf894, KEY_MUTE },
1329 { 0xf896, KEY_CHANNELUP },
1330 { 0xf891, KEY_CHANNELDOWN },
1331 { 0xf893, KEY_VOLUMEUP },
1332 { 0xf88c, KEY_VOLUMEDOWN },
1333 { 0xf883, KEY_RECORD },
1334 { 0xf898, KEY_PAUSE },
1336 { 0xf89a, KEY_SHUFFLE },
1338 { 0xf890, KEY_LEFT },
1339 { 0xf882, KEY_RIGHT },
1340 { 0xf888, KEY_DOWN },
1341 { 0xf895, KEY_FAVORITES },
1342 { 0xf897, KEY_SUBTITLE },
1343 { 0xf89d, KEY_ZOOM },
1344 { 0xf89f, KEY_EXIT },
1345 { 0xf89e, KEY_MENU },
1346 { 0xf89c, KEY_EPG },
1347 { 0xf880, KEY_PREVIOUS },
1348 { 0xf89b, KEY_MODE }
1351 static struct rc_map_table rc_map_su3000_table[] = {
1352 { 0x25, KEY_POWER }, /* right-bottom Red */
1353 { 0x0a, KEY_MUTE }, /* -/-- */
1364 { 0x20, KEY_UP }, /* CH+ */
1365 { 0x21, KEY_DOWN }, /* CH+ */
1366 { 0x12, KEY_VOLUMEUP }, /* Brightness Up */
1367 { 0x13, KEY_VOLUMEDOWN },/* Brightness Down */
1368 { 0x1f, KEY_RECORD },
1370 { 0x16, KEY_PAUSE },
1372 { 0x27, KEY_FASTFORWARD },/* >> */
1373 { 0x26, KEY_REWIND }, /* << */
1374 { 0x0d, KEY_OK }, /* Mute */
1375 { 0x11, KEY_LEFT }, /* VOL- */
1376 { 0x10, KEY_RIGHT }, /* VOL+ */
1377 { 0x29, KEY_BACK }, /* button under 9 */
1378 { 0x2c, KEY_MENU }, /* TTX */
1379 { 0x2b, KEY_EPG }, /* EPG */
1380 { 0x1e, KEY_RED }, /* OSD */
1381 { 0x0e, KEY_GREEN }, /* Window */
1382 { 0x2d, KEY_YELLOW }, /* button under << */
1383 { 0x0f, KEY_BLUE }, /* bottom yellow button */
1384 { 0x14, KEY_AUDIO }, /* Snapshot */
1385 { 0x38, KEY_TV }, /* TV/Radio */
1386 { 0x0c, KEY_ESC } /* upper Red button */
1389 static struct rc_map_dvb_usb_table_table keys_tables[] = {
1390 { rc_map_dw210x_table, ARRAY_SIZE(rc_map_dw210x_table) },
1391 { rc_map_tevii_table, ARRAY_SIZE(rc_map_tevii_table) },
1392 { rc_map_tbs_table, ARRAY_SIZE(rc_map_tbs_table) },
1393 { rc_map_su3000_table, ARRAY_SIZE(rc_map_su3000_table) },
1396 static int dw2102_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
1398 struct rc_map_table *keymap = d->props.rc.legacy.rc_map_table;
1399 int keymap_size = d->props.rc.legacy.rc_map_size;
1401 struct i2c_msg msg = {
1402 .addr = DW2102_RC_QUERY,
1408 /* override keymap */
1409 if ((ir_keymap > 0) && (ir_keymap <= ARRAY_SIZE(keys_tables))) {
1410 keymap = keys_tables[ir_keymap - 1].rc_keys ;
1411 keymap_size = keys_tables[ir_keymap - 1].rc_keys_size;
1412 } else if (ir_keymap > ARRAY_SIZE(keys_tables))
1413 return 0; /* none */
1415 *state = REMOTE_NO_KEY_PRESSED;
1416 if (d->props.i2c_algo->master_xfer(&d->i2c_adap, &msg, 1) == 1) {
1417 for (i = 0; i < keymap_size ; i++) {
1418 if (rc5_data(&keymap[i]) == msg.buf[0]) {
1419 *state = REMOTE_KEY_PRESSED;
1420 *event = keymap[i].keycode;
1426 if ((*state) == REMOTE_KEY_PRESSED)
1427 deb_rc("%s: found rc key: %x, %x, event: %x\n",
1428 __func__, key[0], key[1], (*event));
1429 else if (key[0] != 0xff)
1430 deb_rc("%s: unknown rc key: %x, %x\n",
1431 __func__, key[0], key[1]);
1438 static struct usb_device_id dw2102_table[] = {
1439 {USB_DEVICE(USB_VID_CYPRESS, USB_PID_DW2102)},
1440 {USB_DEVICE(USB_VID_CYPRESS, 0x2101)},
1441 {USB_DEVICE(USB_VID_CYPRESS, USB_PID_DW2104)},
1442 {USB_DEVICE(0x9022, USB_PID_TEVII_S650)},
1443 {USB_DEVICE(USB_VID_TERRATEC, USB_PID_CINERGY_S)},
1444 {USB_DEVICE(USB_VID_CYPRESS, USB_PID_DW3101)},
1445 {USB_DEVICE(0x9022, USB_PID_TEVII_S630)},
1446 {USB_DEVICE(0x3011, USB_PID_PROF_1100)},
1447 {USB_DEVICE(0x9022, USB_PID_TEVII_S660)},
1448 {USB_DEVICE(0x3034, 0x7500)},
1449 {USB_DEVICE(0x1f4d, 0x3000)},
1450 {USB_DEVICE(USB_VID_TERRATEC, 0x00a8)},
1451 {USB_DEVICE(0x9022, USB_PID_TEVII_S480_1)},
1452 {USB_DEVICE(0x9022, USB_PID_TEVII_S480_2)},
1453 {USB_DEVICE(0x1f4d, 0x3100)},
1457 MODULE_DEVICE_TABLE(usb, dw2102_table);
1459 static int dw2102_load_firmware(struct usb_device *dev,
1460 const struct firmware *frmwr)
1465 u8 reset16[] = {0, 0, 0, 0, 0, 0, 0};
1466 const struct firmware *fw;
1467 const char *fw_2101 = "dvb-usb-dw2101.fw";
1469 switch (dev->descriptor.idProduct) {
1471 ret = request_firmware(&fw, fw_2101, &dev->dev);
1473 err(err_str, fw_2101);
1481 info("start downloading DW210X firmware");
1482 p = kmalloc(fw->size, GFP_KERNEL);
1485 dw210x_op_rw(dev, 0xa0, 0x7f92, 0, &reset, 1, DW210X_WRITE_MSG);
1486 dw210x_op_rw(dev, 0xa0, 0xe600, 0, &reset, 1, DW210X_WRITE_MSG);
1489 memcpy(p, fw->data, fw->size);
1490 for (i = 0; i < fw->size; i += 0x40) {
1492 if (dw210x_op_rw(dev, 0xa0, i, 0, b , 0x40,
1493 DW210X_WRITE_MSG) != 0x40) {
1494 err("error while transferring firmware");
1499 /* restart the CPU */
1501 if (ret || dw210x_op_rw(dev, 0xa0, 0x7f92, 0, &reset, 1,
1502 DW210X_WRITE_MSG) != 1) {
1503 err("could not restart the USB controller CPU.");
1506 if (ret || dw210x_op_rw(dev, 0xa0, 0xe600, 0, &reset, 1,
1507 DW210X_WRITE_MSG) != 1) {
1508 err("could not restart the USB controller CPU.");
1511 /* init registers */
1512 switch (dev->descriptor.idProduct) {
1513 case USB_PID_TEVII_S650:
1514 dw2104_properties.rc.legacy.rc_map_table = rc_map_tevii_table;
1515 dw2104_properties.rc.legacy.rc_map_size =
1516 ARRAY_SIZE(rc_map_tevii_table);
1517 case USB_PID_DW2104:
1519 dw210x_op_rw(dev, 0xc4, 0x0000, 0, &reset, 1,
1521 /* break omitted intentionally */
1522 case USB_PID_DW3101:
1524 dw210x_op_rw(dev, 0xbf, 0x0040, 0, &reset, 0,
1527 case USB_PID_CINERGY_S:
1528 case USB_PID_DW2102:
1529 dw210x_op_rw(dev, 0xbf, 0x0040, 0, &reset, 0,
1531 dw210x_op_rw(dev, 0xb9, 0x0000, 0, &reset16[0], 2,
1533 /* check STV0299 frontend */
1534 dw210x_op_rw(dev, 0xb5, 0, 0, &reset16[0], 2,
1536 if ((reset16[0] == 0xa1) || (reset16[0] == 0x80)) {
1537 dw2102_properties.i2c_algo = &dw2102_i2c_algo;
1538 dw2102_properties.adapter->fe[0].tuner_attach = &dw2102_tuner_attach;
1541 /* check STV0288 frontend */
1545 dw210x_op_rw(dev, 0xc2, 0, 0, &reset16[0], 3,
1547 dw210x_op_rw(dev, 0xc3, 0xd1, 0, &reset16[0], 3,
1549 if (reset16[2] == 0x11) {
1550 dw2102_properties.i2c_algo = &dw2102_earda_i2c_algo;
1555 dw210x_op_rw(dev, 0xbc, 0x0030, 0, &reset16[0], 2,
1557 dw210x_op_rw(dev, 0xba, 0x0000, 0, &reset16[0], 7,
1559 dw210x_op_rw(dev, 0xba, 0x0000, 0, &reset16[0], 7,
1561 dw210x_op_rw(dev, 0xb9, 0x0000, 0, &reset16[0], 2,
1572 static struct dvb_usb_device_properties dw2102_properties = {
1573 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1574 .usb_ctrl = DEVICE_SPECIFIC,
1575 .firmware = "dvb-usb-dw2102.fw",
1578 .i2c_algo = &dw2102_serit_i2c_algo,
1581 .rc_map_table = rc_map_dw210x_table,
1582 .rc_map_size = ARRAY_SIZE(rc_map_dw210x_table),
1584 .rc_query = dw2102_rc_query,
1587 .generic_bulk_ctrl_endpoint = 0x81,
1588 /* parameter for the MPEG2-data transfer */
1590 .download_firmware = dw2102_load_firmware,
1591 .read_mac_address = dw210x_read_mac_address,
1596 .frontend_attach = dw2102_frontend_attach,
1610 .num_device_descs = 3,
1612 {"DVBWorld DVB-S 2102 USB2.0",
1613 {&dw2102_table[0], NULL},
1616 {"DVBWorld DVB-S 2101 USB2.0",
1617 {&dw2102_table[1], NULL},
1620 {"TerraTec Cinergy S USB",
1621 {&dw2102_table[4], NULL},
1627 static struct dvb_usb_device_properties dw2104_properties = {
1628 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1629 .usb_ctrl = DEVICE_SPECIFIC,
1630 .firmware = "dvb-usb-dw2104.fw",
1633 .i2c_algo = &dw2104_i2c_algo,
1635 .rc_map_table = rc_map_dw210x_table,
1636 .rc_map_size = ARRAY_SIZE(rc_map_dw210x_table),
1638 .rc_query = dw2102_rc_query,
1641 .generic_bulk_ctrl_endpoint = 0x81,
1642 /* parameter for the MPEG2-data transfer */
1644 .download_firmware = dw2102_load_firmware,
1645 .read_mac_address = dw210x_read_mac_address,
1650 .frontend_attach = dw2104_frontend_attach,
1664 .num_device_descs = 2,
1666 { "DVBWorld DW2104 USB2.0",
1667 {&dw2102_table[2], NULL},
1670 { "TeVii S650 USB2.0",
1671 {&dw2102_table[3], NULL},
1677 static struct dvb_usb_device_properties dw3101_properties = {
1678 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1679 .usb_ctrl = DEVICE_SPECIFIC,
1680 .firmware = "dvb-usb-dw3101.fw",
1683 .i2c_algo = &dw3101_i2c_algo,
1685 .rc_map_table = rc_map_dw210x_table,
1686 .rc_map_size = ARRAY_SIZE(rc_map_dw210x_table),
1688 .rc_query = dw2102_rc_query,
1691 .generic_bulk_ctrl_endpoint = 0x81,
1692 /* parameter for the MPEG2-data transfer */
1694 .download_firmware = dw2102_load_firmware,
1695 .read_mac_address = dw210x_read_mac_address,
1700 .frontend_attach = dw3101_frontend_attach,
1701 .tuner_attach = dw3101_tuner_attach,
1715 .num_device_descs = 1,
1717 { "DVBWorld DVB-C 3101 USB2.0",
1718 {&dw2102_table[5], NULL},
1724 static struct dvb_usb_device_properties s6x0_properties = {
1725 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1726 .usb_ctrl = DEVICE_SPECIFIC,
1727 .size_of_priv = sizeof(struct s6x0_state),
1728 .firmware = "dvb-usb-s630.fw",
1731 .i2c_algo = &s6x0_i2c_algo,
1733 .rc_map_table = rc_map_tevii_table,
1734 .rc_map_size = ARRAY_SIZE(rc_map_tevii_table),
1736 .rc_query = dw2102_rc_query,
1739 .generic_bulk_ctrl_endpoint = 0x81,
1741 .download_firmware = dw2102_load_firmware,
1742 .read_mac_address = s6x0_read_mac_address,
1747 .frontend_attach = zl100313_frontend_attach,
1761 .num_device_descs = 1,
1764 {&dw2102_table[6], NULL},
1770 struct dvb_usb_device_properties *p1100;
1771 static struct dvb_usb_device_description d1100 = {
1773 {&dw2102_table[7], NULL},
1777 struct dvb_usb_device_properties *s660;
1778 static struct dvb_usb_device_description d660 = {
1780 {&dw2102_table[8], NULL},
1784 static struct dvb_usb_device_description d480_1 = {
1786 {&dw2102_table[12], NULL},
1790 static struct dvb_usb_device_description d480_2 = {
1792 {&dw2102_table[13], NULL},
1796 struct dvb_usb_device_properties *p7500;
1797 static struct dvb_usb_device_description d7500 = {
1798 "Prof 7500 USB DVB-S2",
1799 {&dw2102_table[9], NULL},
1803 static struct dvb_usb_device_properties su3000_properties = {
1804 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1805 .usb_ctrl = DEVICE_SPECIFIC,
1806 .size_of_priv = sizeof(struct su3000_state),
1807 .power_ctrl = su3000_power_ctrl,
1809 .identify_state = su3000_identify_state,
1810 .i2c_algo = &su3000_i2c_algo,
1813 .rc_map_table = rc_map_su3000_table,
1814 .rc_map_size = ARRAY_SIZE(rc_map_su3000_table),
1816 .rc_query = dw2102_rc_query,
1819 .read_mac_address = su3000_read_mac_address,
1821 .generic_bulk_ctrl_endpoint = 0x01,
1827 .streaming_ctrl = su3000_streaming_ctrl,
1828 .frontend_attach = su3000_frontend_attach,
1842 .num_device_descs = 3,
1844 { "SU3000HD DVB-S USB2.0",
1845 { &dw2102_table[10], NULL },
1848 { "Terratec Cinergy S2 USB HD",
1849 { &dw2102_table[11], NULL },
1852 { "X3M TV SPC1400HD PCI",
1853 { &dw2102_table[14], NULL },
1859 static int dw2102_probe(struct usb_interface *intf,
1860 const struct usb_device_id *id)
1862 p1100 = kzalloc(sizeof(struct dvb_usb_device_properties), GFP_KERNEL);
1865 /* copy default structure */
1866 memcpy(p1100, &s6x0_properties,
1867 sizeof(struct dvb_usb_device_properties));
1868 /* fill only different fields */
1869 p1100->firmware = "dvb-usb-p1100.fw";
1870 p1100->devices[0] = d1100;
1871 p1100->rc.legacy.rc_map_table = rc_map_tbs_table;
1872 p1100->rc.legacy.rc_map_size = ARRAY_SIZE(rc_map_tbs_table);
1873 p1100->adapter->fe[0].frontend_attach = stv0288_frontend_attach;
1875 s660 = kzalloc(sizeof(struct dvb_usb_device_properties), GFP_KERNEL);
1880 memcpy(s660, &s6x0_properties,
1881 sizeof(struct dvb_usb_device_properties));
1882 s660->firmware = "dvb-usb-s660.fw";
1883 s660->num_device_descs = 3;
1884 s660->devices[0] = d660;
1885 s660->devices[1] = d480_1;
1886 s660->devices[2] = d480_2;
1887 s660->adapter->fe[0].frontend_attach = ds3000_frontend_attach;
1889 p7500 = kzalloc(sizeof(struct dvb_usb_device_properties), GFP_KERNEL);
1895 memcpy(p7500, &s6x0_properties,
1896 sizeof(struct dvb_usb_device_properties));
1897 p7500->firmware = "dvb-usb-p7500.fw";
1898 p7500->devices[0] = d7500;
1899 p7500->rc.legacy.rc_map_table = rc_map_tbs_table;
1900 p7500->rc.legacy.rc_map_size = ARRAY_SIZE(rc_map_tbs_table);
1901 p7500->adapter->fe[0].frontend_attach = prof_7500_frontend_attach;
1903 if (0 == dvb_usb_device_init(intf, &dw2102_properties,
1904 THIS_MODULE, NULL, adapter_nr) ||
1905 0 == dvb_usb_device_init(intf, &dw2104_properties,
1906 THIS_MODULE, NULL, adapter_nr) ||
1907 0 == dvb_usb_device_init(intf, &dw3101_properties,
1908 THIS_MODULE, NULL, adapter_nr) ||
1909 0 == dvb_usb_device_init(intf, &s6x0_properties,
1910 THIS_MODULE, NULL, adapter_nr) ||
1911 0 == dvb_usb_device_init(intf, p1100,
1912 THIS_MODULE, NULL, adapter_nr) ||
1913 0 == dvb_usb_device_init(intf, s660,
1914 THIS_MODULE, NULL, adapter_nr) ||
1915 0 == dvb_usb_device_init(intf, p7500,
1916 THIS_MODULE, NULL, adapter_nr) ||
1917 0 == dvb_usb_device_init(intf, &su3000_properties,
1918 THIS_MODULE, NULL, adapter_nr))
1924 static struct usb_driver dw2102_driver = {
1926 .probe = dw2102_probe,
1927 .disconnect = dvb_usb_device_exit,
1928 .id_table = dw2102_table,
1931 static int __init dw2102_module_init(void)
1933 int ret = usb_register(&dw2102_driver);
1935 err("usb_register failed. Error number %d", ret);
1940 static void __exit dw2102_module_exit(void)
1942 usb_deregister(&dw2102_driver);
1945 module_init(dw2102_module_init);
1946 module_exit(dw2102_module_exit);
1948 MODULE_AUTHOR("Igor M. Liplianin (c) liplianin@me.by");
1949 MODULE_DESCRIPTION("Driver for DVBWorld DVB-S 2101, 2102, DVB-S2 2104,"
1950 " DVB-C 3101 USB2.0,"
1951 " TeVii S600, S630, S650, S660, S480,"
1952 " Prof 1100, 7500 USB2.0,"
1953 " Geniatech SU3000 devices");
1954 MODULE_VERSION("0.1");
1955 MODULE_LICENSE("GPL");