Merge git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi-misc-2.6
[pandora-kernel.git] / drivers / media / dvb / dvb-usb / dw2102.c
index 2c307ba..f5b9da1 100644 (file)
@@ -1,15 +1,16 @@
 /* DVB USB framework compliant Linux driver for the
-*      DVBWorld DVB-S 2101, 2102, DVB-S2 2104, DVB-C 3101,
-*      TeVii S600, S630, S650,
-*      Prof 1100, 7500 Cards
-* Copyright (C) 2008,2009 Igor M. Liplianin (liplianin@me.by)
-*
-*      This program is free software; you can redistribute it and/or modify it
-*      under the terms of the GNU General Public License as published by the
-*      Free Software Foundation, version 2.
-*
-* see Documentation/dvb/README.dvb-usb for more information
-*/
+ *     DVBWorld DVB-S 2101, 2102, DVB-S2 2104, DVB-C 3101,
+ *     TeVii S600, S630, S650, S660, S480,
+ *     Prof 1100, 7500,
+ *     Geniatech SU3000 Cards
+ * Copyright (C) 2008-2011 Igor M. Liplianin (liplianin@me.by)
+ *
+ *     This program is free software; you can redistribute it and/or modify it
+ *     under the terms of the GNU General Public License as published by the
+ *     Free Software Foundation, version 2.
+ *
+ * see Documentation/dvb/README.dvb-usb for more information
+ */
 #include "dw2102.h"
 #include "si21xx.h"
 #include "stv0299.h"
 #define USB_PID_TEVII_S660 0xd660
 #endif
 
+#ifndef USB_PID_TEVII_S480_1
+#define USB_PID_TEVII_S480_1 0xd481
+#endif
+
+#ifndef USB_PID_TEVII_S480_2
+#define USB_PID_TEVII_S480_2 0xd482
+#endif
+
 #ifndef USB_PID_PROF_1100
 #define USB_PID_PROF_1100 0xb012
 #endif
@@ -67,7 +76,9 @@
 #define REG_21_SYMBOLRATE_BYTE2 0x21
 /* on my own*/
 #define DW2102_VOLTAGE_CTRL (0x1800)
+#define SU3000_STREAM_CTRL (0x1900)
 #define DW2102_RC_QUERY (0x1a00)
+#define DW2102_LED_CTRL (0x1b00)
 
 #define        err_str "did not find the firmware file. (%s) " \
                "Please see linux/Documentation/dvb/ for more details " \
@@ -78,6 +89,14 @@ struct rc_map_dvb_usb_table_table {
        int rc_keys_size;
 };
 
+struct su3000_state {
+       u8 initialized;
+};
+
+struct s6x0_state {
+       int (*old_set_voltage)(struct dvb_frontend *f, fe_sec_voltage_t v);
+};
+
 /* debug */
 static int dvb_usb_dw2102_debug;
 module_param_named(debug, dvb_usb_dw2102_debug, int, 0644);
@@ -87,7 +106,8 @@ MODULE_PARM_DESC(debug, "set debugging level (1=info 2=xfer 4=rc(or-able))."
 /* keymaps */
 static int ir_keymap;
 module_param_named(keymap, ir_keymap, int, 0644);
-MODULE_PARM_DESC(keymap, "set keymap 0=default 1=dvbworld 2=tevii 3=tbs  ...");
+MODULE_PARM_DESC(keymap, "set keymap 0=default 1=dvbworld 2=tevii 3=tbs  ..."
+                       " 256=none");
 
 /* demod probe */
 static int demod_probe = 1;
@@ -136,8 +156,7 @@ static int dw2102_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],
                /* read stv0299 register */
                value = msg[0].buf[0];/* register */
                for (i = 0; i < msg[1].len; i++) {
-                       value = value + i;
-                       ret = dw210x_op_rw(d->udev, 0xb5, value, 0,
+                       ret = dw210x_op_rw(d->udev, 0xb5, value + i, 0,
                                        buf6, 2, DW210X_READ_MSG);
                        msg[1].buf[i] = buf6[0];
                }
@@ -483,10 +502,10 @@ static int s6x0_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],
        for (j = 0; j < num; j++) {
                switch (msg[j].addr) {
                case (DW2102_RC_QUERY): {
-                       u8 ibuf[4];
+                       u8 ibuf[5];
                        ret  = dw210x_op_rw(d->udev, 0xb8, 0, 0,
-                                       ibuf, 4, DW210X_READ_MSG);
-                       memcpy(msg[j].buf, ibuf + 1, 2);
+                                       ibuf, 5, DW210X_READ_MSG);
+                       memcpy(msg[j].buf, ibuf + 3, 2);
                        break;
                }
                case (DW2102_VOLTAGE_CTRL): {
@@ -502,6 +521,15 @@ static int s6x0_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],
                                        obuf, 2, DW210X_WRITE_MSG);
                        break;
                }
+               case (DW2102_LED_CTRL): {
+                       u8 obuf[2];
+
+                       obuf[0] = 5;
+                       obuf[1] = msg[j].buf[0];
+                       ret = dw210x_op_rw(d->udev, 0x8a, 0, 0,
+                                       obuf, 2, DW210X_WRITE_MSG);
+                       break;
+               }
                /*case 0x55: cx24116
                case 0x6a: stv0903
                case 0x68: ds3000, stv0903
@@ -535,14 +563,15 @@ static int s6x0_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],
                                        i += 16;
                                        len -= 16;
                                } while (len > 0);
-                       } else if ((udev->descriptor.idProduct == 0x7500)
-                                       && (j < (num - 1))) {
+                       } else if (j < (num - 1)) {
                                /* write register addr before read */
                                u8 obuf[msg[j].len + 2];
                                obuf[0] = msg[j + 1].len;
                                obuf[1] = (msg[j].addr << 1);
                                memcpy(obuf + 2, msg[j].buf, msg[j].len);
-                               ret = dw210x_op_rw(d->udev, 0x92, 0, 0,
+                               ret = dw210x_op_rw(d->udev,
+                                               udev->descriptor.idProduct ==
+                                               0x7500 ? 0x92 : 0x90, 0, 0,
                                                obuf, msg[j].len + 2,
                                                DW210X_WRITE_MSG);
                                break;
@@ -552,8 +581,7 @@ static int s6x0_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],
                                obuf[0] = msg[j].len + 1;
                                obuf[1] = (msg[j].addr << 1);
                                memcpy(obuf + 2, msg[j].buf, msg[j].len);
-                               ret = dw210x_op_rw(d->udev,
-                                               (num > 1 ? 0x90 : 0x80), 0, 0,
+                               ret = dw210x_op_rw(d->udev, 0x80, 0, 0,
                                                obuf, msg[j].len + 2,
                                                DW210X_WRITE_MSG);
                                break;
@@ -561,14 +589,76 @@ static int s6x0_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],
                        break;
                }
                }
-
-               msleep(3);
        }
 
        mutex_unlock(&d->i2c_mutex);
        return num;
 }
 
+static int su3000_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],
+                                                               int num)
+{
+       struct dvb_usb_device *d = i2c_get_adapdata(adap);
+       u8 obuf[0x40], ibuf[0x40];
+
+       if (!d)
+               return -ENODEV;
+       if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
+               return -EAGAIN;
+
+       switch (num) {
+       case 1:
+               switch (msg[0].addr) {
+               case SU3000_STREAM_CTRL:
+                       obuf[0] = msg[0].buf[0] + 0x36;
+                       obuf[1] = 3;
+                       obuf[2] = 0;
+                       if (dvb_usb_generic_rw(d, obuf, 3, ibuf, 0, 0) < 0)
+                               err("i2c transfer failed.");
+                       break;
+               case DW2102_RC_QUERY:
+                       obuf[0] = 0x10;
+                       if (dvb_usb_generic_rw(d, obuf, 1, ibuf, 2, 0) < 0)
+                               err("i2c transfer failed.");
+                       msg[0].buf[1] = ibuf[0];
+                       msg[0].buf[0] = ibuf[1];
+                       break;
+               default:
+                       /* always i2c write*/
+                       obuf[0] = 0x08;
+                       obuf[1] = msg[0].addr;
+                       obuf[2] = msg[0].len;
+
+                       memcpy(&obuf[3], msg[0].buf, msg[0].len);
+
+                       if (dvb_usb_generic_rw(d, obuf, msg[0].len + 3,
+                                               ibuf, 1, 0) < 0)
+                               err("i2c transfer failed.");
+
+               }
+               break;
+       case 2:
+               /* always i2c read */
+               obuf[0] = 0x09;
+               obuf[1] = msg[0].len;
+               obuf[2] = msg[1].len;
+               obuf[3] = msg[0].addr;
+               memcpy(&obuf[4], msg[0].buf, msg[0].len);
+
+               if (dvb_usb_generic_rw(d, obuf, msg[0].len + 4,
+                                       ibuf, msg[1].len + 1, 0) < 0)
+                       err("i2c transfer failed.");
+
+               memcpy(msg[1].buf, &ibuf[1], msg[1].len);
+               break;
+       default:
+               warn("more than 2 i2c messages at a time is not handled yet.");
+               break;
+       }
+       mutex_unlock(&d->i2c_mutex);
+       return num;
+}
+
 static u32 dw210x_i2c_func(struct i2c_adapter *adapter)
 {
        return I2C_FUNC_I2C;
@@ -604,6 +694,11 @@ static struct i2c_algorithm s6x0_i2c_algo = {
        .functionality = dw210x_i2c_func,
 };
 
+static struct i2c_algorithm su3000_i2c_algo = {
+       .master_xfer = su3000_i2c_transfer,
+       .functionality = dw210x_i2c_func,
+};
+
 static int dw210x_read_mac_address(struct dvb_usb_device *d, u8 mac[6])
 {
        int i;
@@ -668,6 +763,82 @@ static int s6x0_read_mac_address(struct dvb_usb_device *d, u8 mac[6])
        return 0;
 };
 
+static int su3000_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff)
+{
+       static u8 command_start[] = {0x00};
+       static u8 command_stop[] = {0x01};
+       struct i2c_msg msg = {
+               .addr = SU3000_STREAM_CTRL,
+               .flags = 0,
+               .buf = onoff ? command_start : command_stop,
+               .len = 1
+       };
+
+       i2c_transfer(&adap->dev->i2c_adap, &msg, 1);
+
+       return 0;
+}
+
+static int su3000_power_ctrl(struct dvb_usb_device *d, int i)
+{
+       struct su3000_state *state = (struct su3000_state *)d->priv;
+       u8 obuf[] = {0xde, 0};
+
+       info("%s: %d, initialized %d\n", __func__, i, state->initialized);
+
+       if (i && !state->initialized) {
+               state->initialized = 1;
+               /* reset board */
+               dvb_usb_generic_rw(d, obuf, 2, NULL, 0, 0);
+       }
+
+       return 0;
+}
+
+static int su3000_read_mac_address(struct dvb_usb_device *d, u8 mac[6])
+{
+       int i;
+       u8 obuf[] = { 0x1f, 0xf0 };
+       u8 ibuf[] = { 0 };
+       struct i2c_msg msg[] = {
+               {
+                       .addr = 0x51,
+                       .flags = 0,
+                       .buf = obuf,
+                       .len = 2,
+               }, {
+                       .addr = 0x51,
+                       .flags = I2C_M_RD,
+                       .buf = ibuf,
+                       .len = 1,
+
+               }
+       };
+
+       for (i = 0; i < 6; i++) {
+               obuf[1] = 0xf0 + i;
+               if (i2c_transfer(&d->i2c_adap, msg, 2) != 2)
+                       break;
+               else
+                       mac[i] = ibuf[0];
+
+               debug_dump(mac, 6, printk);
+       }
+
+       return 0;
+}
+
+static int su3000_identify_state(struct usb_device *udev,
+                                struct dvb_usb_device_properties *props,
+                                struct dvb_usb_device_description **desc,
+                                int *cold)
+{
+       info("%s\n", __func__);
+
+       *cold = 0;
+       return 0;
+}
+
 static int dw210x_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
 {
        static u8 command_13v[] = {0x00, 0x01};
@@ -692,6 +863,37 @@ static int dw210x_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
        return 0;
 }
 
+static int s660_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
+{
+       struct dvb_usb_adapter *d =
+               (struct dvb_usb_adapter *)(fe->dvb->priv);
+       struct s6x0_state *st = (struct s6x0_state *)d->dev->priv;
+
+       dw210x_set_voltage(fe, voltage);
+       if (st->old_set_voltage)
+               st->old_set_voltage(fe, voltage);
+
+       return 0;
+}
+
+static void dw210x_led_ctrl(struct dvb_frontend *fe, int offon)
+{
+       static u8 led_off[] = { 0 };
+       static u8 led_on[] = { 1 };
+       struct i2c_msg msg = {
+               .addr = DW2102_LED_CTRL,
+               .flags = 0,
+               .buf = led_off,
+               .len = 1
+       };
+       struct dvb_usb_adapter *udev_adap =
+               (struct dvb_usb_adapter *)(fe->dvb->priv);
+
+       if (offon)
+               msg.buf = led_on;
+       i2c_transfer(&udev_adap->dev->i2c_adap, &msg, 1);
+}
+
 static struct stv0299_config sharp_z0194a_config = {
        .demod_address = 0x68,
        .inittab = sharp_z0194a_inittab,
@@ -771,6 +973,12 @@ static struct stv0900_config prof_7500_stv0900_config = {
        .tun1_adc = 0,/* 2 Vpp */
        .path1_mode = 3,
        .tun1_type = 3,
+       .set_lock_led = dw210x_led_ctrl,
+};
+
+static struct ds3000_config su3000_ds3000_config = {
+       .demod_address = 0x68,
+       .ci_mode = 1,
 };
 
 static int dw2104_frontend_attach(struct dvb_usb_adapter *d)
@@ -885,7 +1093,7 @@ static int dw3101_frontend_attach(struct dvb_usb_adapter *d)
        return -EIO;
 }
 
-static int s6x0_frontend_attach(struct dvb_usb_adapter *d)
+static int zl100313_frontend_attach(struct dvb_usb_adapter *d)
 {
        d->fe = dvb_attach(mt312_attach, &zl313_config,
                        &d->dev->i2c_adap);
@@ -898,41 +1106,108 @@ static int s6x0_frontend_attach(struct dvb_usb_adapter *d)
                }
        }
 
+       return -EIO;
+}
+
+static int stv0288_frontend_attach(struct dvb_usb_adapter *d)
+{
+       u8 obuf[] = {7, 1};
+
        d->fe = dvb_attach(stv0288_attach, &earda_config,
                        &d->dev->i2c_adap);
-       if (d->fe != NULL) {
-               if (dvb_attach(stb6000_attach, d->fe, 0x61,
-                               &d->dev->i2c_adap)) {
-                       d->fe->ops.set_voltage = dw210x_set_voltage;
-                       info("Attached stv0288+stb6000!\n");
-                       return 0;
-               }
-       }
+
+       if (d->fe == NULL)
+               return -EIO;
+
+       if (NULL == dvb_attach(stb6000_attach, d->fe, 0x61, &d->dev->i2c_adap))
+               return -EIO;
+
+       d->fe->ops.set_voltage = dw210x_set_voltage;
+
+       dw210x_op_rw(d->dev->udev, 0x8a, 0, 0, obuf, 2, DW210X_WRITE_MSG);
+
+       info("Attached stv0288+stb6000!\n");
+
+       return 0;
+
+}
+
+static int ds3000_frontend_attach(struct dvb_usb_adapter *d)
+{
+       struct s6x0_state *st = (struct s6x0_state *)d->dev->priv;
+       u8 obuf[] = {7, 1};
 
        d->fe = dvb_attach(ds3000_attach, &dw2104_ds3000_config,
                        &d->dev->i2c_adap);
-       if (d->fe != NULL) {
-               d->fe->ops.set_voltage = dw210x_set_voltage;
-               info("Attached ds3000+ds2020!\n");
-               return 0;
-       }
 
-       return -EIO;
+       if (d->fe == NULL)
+               return -EIO;
+
+       st->old_set_voltage = d->fe->ops.set_voltage;
+       d->fe->ops.set_voltage = s660_set_voltage;
+
+       dw210x_op_rw(d->dev->udev, 0x8a, 0, 0, obuf, 2, DW210X_WRITE_MSG);
+
+       info("Attached ds3000+ds2020!\n");
+
+       return 0;
 }
 
 static int prof_7500_frontend_attach(struct dvb_usb_adapter *d)
 {
+       u8 obuf[] = {7, 1};
+
        d->fe = dvb_attach(stv0900_attach, &prof_7500_stv0900_config,
                                        &d->dev->i2c_adap, 0);
        if (d->fe == NULL)
                return -EIO;
+
        d->fe->ops.set_voltage = dw210x_set_voltage;
 
+       dw210x_op_rw(d->dev->udev, 0x8a, 0, 0, obuf, 2, DW210X_WRITE_MSG);
+
        info("Attached STV0900+STB6100A!\n");
 
        return 0;
 }
 
+static int su3000_frontend_attach(struct dvb_usb_adapter *d)
+{
+       u8 obuf[3] = { 0xe, 0x80, 0 };
+       u8 ibuf[] = { 0 };
+
+       if (dvb_usb_generic_rw(d->dev, obuf, 3, ibuf, 1, 0) < 0)
+               err("command 0x0e transfer failed.");
+
+       obuf[0] = 0xe;
+       obuf[1] = 0x83;
+       obuf[2] = 0;
+
+       if (dvb_usb_generic_rw(d->dev, obuf, 3, ibuf, 1, 0) < 0)
+               err("command 0x0e transfer failed.");
+
+       obuf[0] = 0xe;
+       obuf[1] = 0x83;
+       obuf[2] = 1;
+
+       if (dvb_usb_generic_rw(d->dev, obuf, 3, ibuf, 1, 0) < 0)
+               err("command 0x0e transfer failed.");
+
+       obuf[0] = 0x51;
+
+       if (dvb_usb_generic_rw(d->dev, obuf, 1, ibuf, 1, 0) < 0)
+               err("command 0x51 transfer failed.");
+
+       d->fe = dvb_attach(ds3000_attach, &su3000_ds3000_config,
+                                       &d->dev->i2c_adap);
+       if (d->fe == NULL)
+               return -EIO;
+
+       info("Attached DS3000!\n");
+
+       return 0;
+}
+
 static int dw2102_tuner_attach(struct dvb_usb_adapter *adap)
 {
        dvb_attach(dvb_pll_attach, adap->fe, 0x60,
@@ -949,8 +1224,8 @@ static int dw3101_tuner_attach(struct dvb_usb_adapter *adap)
 }
 
 static struct rc_map_table rc_map_dw210x_table[] = {
-       { 0xf80a, KEY_Q },              /*power*/
-       { 0xf80c, KEY_M },              /*mute*/
+       { 0xf80a, KEY_POWER2 },         /*power*/
+       { 0xf80c, KEY_MUTE },           /*mute*/
        { 0xf811, KEY_1 },
        { 0xf812, KEY_2 },
        { 0xf813, KEY_3 },
@@ -961,25 +1236,25 @@ static struct rc_map_table rc_map_dw210x_table[] = {
        { 0xf818, KEY_8 },
        { 0xf819, KEY_9 },
        { 0xf810, KEY_0 },
-       { 0xf81c, KEY_PAGEUP }, /*ch+*/
-       { 0xf80f, KEY_PAGEDOWN },       /*ch-*/
-       { 0xf81a, KEY_O },              /*vol+*/
-       { 0xf80e, KEY_Z },              /*vol-*/
-       { 0xf804, KEY_R },              /*rec*/
-       { 0xf809, KEY_D },              /*fav*/
-       { 0xf808, KEY_BACKSPACE },      /*rewind*/
-       { 0xf807, KEY_A },              /*fast*/
-       { 0xf80b, KEY_P },              /*pause*/
-       { 0xf802, KEY_ESC },    /*cancel*/
-       { 0xf803, KEY_G },              /*tab*/
+       { 0xf81c, KEY_CHANNELUP },      /*ch+*/
+       { 0xf80f, KEY_CHANNELDOWN },    /*ch-*/
+       { 0xf81a, KEY_VOLUMEUP },       /*vol+*/
+       { 0xf80e, KEY_VOLUMEDOWN },     /*vol-*/
+       { 0xf804, KEY_RECORD },         /*rec*/
+       { 0xf809, KEY_FAVORITES },      /*fav*/
+       { 0xf808, KEY_REWIND },         /*rewind*/
+       { 0xf807, KEY_FASTFORWARD },    /*fast*/
+       { 0xf80b, KEY_PAUSE },          /*pause*/
+       { 0xf802, KEY_ESC },            /*cancel*/
+       { 0xf803, KEY_TAB },            /*tab*/
        { 0xf800, KEY_UP },             /*up*/
-       { 0xf81f, KEY_ENTER },  /*ok*/
-       { 0xf801, KEY_DOWN },   /*down*/
-       { 0xf805, KEY_C },              /*cap*/
-       { 0xf806, KEY_S },              /*stop*/
-       { 0xf840, KEY_F },              /*full*/
-       { 0xf81e, KEY_W },              /*tvmode*/
-       { 0xf81b, KEY_B },              /*recall*/
+       { 0xf81f, KEY_OK },             /*ok*/
+       { 0xf801, KEY_DOWN },           /*down*/
+       { 0xf805, KEY_CAMERA },         /*cap*/
+       { 0xf806, KEY_STOP },           /*stop*/
+       { 0xf840, KEY_ZOOM },           /*full*/
+       { 0xf81e, KEY_TV },             /*tvmode*/
+       { 0xf81b, KEY_LAST },           /*recall*/
 };
 
 static struct rc_map_table rc_map_tevii_table[] = {
@@ -1067,10 +1342,49 @@ static struct rc_map_table rc_map_tbs_table[] = {
        { 0xf89b, KEY_MODE }
 };
 
+static struct rc_map_table rc_map_su3000_table[] = {
+       { 0x25, KEY_POWER },    /* right-bottom Red */
+       { 0x0a, KEY_MUTE },     /* -/-- */
+       { 0x01, KEY_1 },
+       { 0x02, KEY_2 },
+       { 0x03, KEY_3 },
+       { 0x04, KEY_4 },
+       { 0x05, KEY_5 },
+       { 0x06, KEY_6 },
+       { 0x07, KEY_7 },
+       { 0x08, KEY_8 },
+       { 0x09, KEY_9 },
+       { 0x00, KEY_0 },
+       { 0x20, KEY_UP },       /* CH+ */
+       { 0x21, KEY_DOWN },     /* CH+ */
+       { 0x12, KEY_VOLUMEUP }, /* Brightness Up */
+       { 0x13, KEY_VOLUMEDOWN },/* Brightness Down */
+       { 0x1f, KEY_RECORD },
+       { 0x17, KEY_PLAY },
+       { 0x16, KEY_PAUSE },
+       { 0x0b, KEY_STOP },
+       { 0x27, KEY_FASTFORWARD },/* >> */
+       { 0x26, KEY_REWIND },   /* << */
+       { 0x0d, KEY_OK },       /* Mute */
+       { 0x11, KEY_LEFT },     /* VOL- */
+       { 0x10, KEY_RIGHT },    /* VOL+ */
+       { 0x29, KEY_BACK },     /* button under 9 */
+       { 0x2c, KEY_MENU },     /* TTX */
+       { 0x2b, KEY_EPG },      /* EPG */
+       { 0x1e, KEY_RED },      /* OSD */
+       { 0x0e, KEY_GREEN },    /* Window */
+       { 0x2d, KEY_YELLOW },   /* button under << */
+       { 0x0f, KEY_BLUE },     /* bottom yellow button */
+       { 0x14, KEY_AUDIO },    /* Snapshot */
+       { 0x38, KEY_TV },       /* TV/Radio */
+       { 0x0c, KEY_ESC }       /* upper Red buttton */
+};
+
 static struct rc_map_dvb_usb_table_table keys_tables[] = {
        { rc_map_dw210x_table, ARRAY_SIZE(rc_map_dw210x_table) },
        { rc_map_tevii_table, ARRAY_SIZE(rc_map_tevii_table) },
        { rc_map_tbs_table, ARRAY_SIZE(rc_map_tbs_table) },
+       { rc_map_su3000_table, ARRAY_SIZE(rc_map_su3000_table) },
 };
 
 static int dw2102_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
@@ -1089,7 +1403,8 @@ static int dw2102_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
        if ((ir_keymap > 0) && (ir_keymap <= ARRAY_SIZE(keys_tables))) {
                keymap = keys_tables[ir_keymap - 1].rc_keys ;
                keymap_size = keys_tables[ir_keymap - 1].rc_keys_size;
-       }
+       } else if (ir_keymap > ARRAY_SIZE(keys_tables))
+               return 0; /* none */
 
        *state = REMOTE_NO_KEY_PRESSED;
        if (d->props.i2c_algo->master_xfer(&d->i2c_adap, &msg, 1) == 1) {
@@ -1125,6 +1440,11 @@ static struct usb_device_id dw2102_table[] = {
        {USB_DEVICE(0x3011, USB_PID_PROF_1100)},
        {USB_DEVICE(0x9022, USB_PID_TEVII_S660)},
        {USB_DEVICE(0x3034, 0x7500)},
+       {USB_DEVICE(0x1f4d, 0x3000)},
+       {USB_DEVICE(USB_VID_TERRATEC, 0x00a8)},
+       {USB_DEVICE(0x9022, USB_PID_TEVII_S480_1)},
+       {USB_DEVICE(0x9022, USB_PID_TEVII_S480_2)},
+       {USB_DEVICE(0x1f4d, 0x3100)},
        { }
 };
 
@@ -1184,11 +1504,6 @@ static int dw2102_load_firmware(struct usb_device *dev,
                }
                /* init registers */
                switch (dev->descriptor.idProduct) {
-               case USB_PID_PROF_1100:
-                       s6x0_properties.rc.legacy.rc_map_table = rc_map_tbs_table;
-                       s6x0_properties.rc.legacy.rc_map_size =
-                                       ARRAY_SIZE(rc_map_tbs_table);
-                       break;
                case USB_PID_TEVII_S650:
                        dw2104_properties.rc.legacy.rc_map_table = rc_map_tevii_table;
                        dw2104_properties.rc.legacy.rc_map_size =
@@ -1271,8 +1586,6 @@ static struct dvb_usb_device_properties dw2102_properties = {
        .adapter = {
                {
                        .frontend_attach = dw2102_frontend_attach,
-                       .streaming_ctrl = NULL,
-                       .tuner_attach = NULL,
                        .stream = {
                                .type = USB_BULK,
                                .count = 8,
@@ -1324,8 +1637,6 @@ static struct dvb_usb_device_properties dw2104_properties = {
        .adapter = {
                {
                        .frontend_attach = dw2104_frontend_attach,
-                       .streaming_ctrl = NULL,
-                       /*.tuner_attach = dw2104_tuner_attach,*/
                        .stream = {
                                .type = USB_BULK,
                                .count = 8,
@@ -1373,7 +1684,6 @@ static struct dvb_usb_device_properties dw3101_properties = {
        .adapter = {
                {
                        .frontend_attach = dw3101_frontend_attach,
-                       .streaming_ctrl = NULL,
                        .tuner_attach = dw3101_tuner_attach,
                        .stream = {
                                .type = USB_BULK,
@@ -1399,6 +1709,7 @@ static struct dvb_usb_device_properties dw3101_properties = {
 static struct dvb_usb_device_properties s6x0_properties = {
        .caps = DVB_USB_IS_AN_I2C_ADAPTER,
        .usb_ctrl = DEVICE_SPECIFIC,
+       .size_of_priv = sizeof(struct s6x0_state),
        .firmware = "dvb-usb-s630.fw",
        .no_reconnect = 1,
 
@@ -1416,9 +1727,7 @@ static struct dvb_usb_device_properties s6x0_properties = {
        .read_mac_address = s6x0_read_mac_address,
        .adapter = {
                {
-                       .frontend_attach = s6x0_frontend_attach,
-                       .streaming_ctrl = NULL,
-                       .tuner_attach = NULL,
+                       .frontend_attach = zl100313_frontend_attach,
                        .stream = {
                                .type = USB_BULK,
                                .count = 8,
@@ -1431,23 +1740,41 @@ static struct dvb_usb_device_properties s6x0_properties = {
                        },
                }
        },
-       .num_device_descs = 3,
+       .num_device_descs = 1,
        .devices = {
                {"TeVii S630 USB",
                        {&dw2102_table[6], NULL},
                        {NULL},
                },
-               {"Prof 1100 USB ",
-                       {&dw2102_table[7], NULL},
-                       {NULL},
-               },
-               {"TeVii S660 USB",
-                       {&dw2102_table[8], NULL},
-                       {NULL},
-               },
        }
 };
 
+struct dvb_usb_device_properties *p1100;
+static struct dvb_usb_device_description d1100 = {
+       "Prof 1100 USB ",
+       {&dw2102_table[7], NULL},
+       {NULL},
+};
+
+struct dvb_usb_device_properties *s660;
+static struct dvb_usb_device_description d660 = {
+       "TeVii S660 USB",
+       {&dw2102_table[8], NULL},
+       {NULL},
+};
+
+static struct dvb_usb_device_description d480_1 = {
+       "TeVii S480.1 USB",
+       {&dw2102_table[12], NULL},
+       {NULL},
+};
+
+static struct dvb_usb_device_description d480_2 = {
+       "TeVii S480.2 USB",
+       {&dw2102_table[13], NULL},
+       {NULL},
+};
+
 struct dvb_usb_device_properties *p7500;
 static struct dvb_usb_device_description d7500 = {
        "Prof 7500 USB DVB-S2",
@@ -1455,17 +1782,97 @@ static struct dvb_usb_device_description d7500 = {
        {NULL},
 };
 
+static struct dvb_usb_device_properties su3000_properties = {
+       .caps = DVB_USB_IS_AN_I2C_ADAPTER,
+       .usb_ctrl = DEVICE_SPECIFIC,
+       .size_of_priv = sizeof(struct su3000_state),
+       .power_ctrl = su3000_power_ctrl,
+       .num_adapters = 1,
+       .identify_state = su3000_identify_state,
+       .i2c_algo = &su3000_i2c_algo,
+
+       .rc.legacy = {
+               .rc_map_table = rc_map_su3000_table,
+               .rc_map_size = ARRAY_SIZE(rc_map_su3000_table),
+               .rc_interval = 150,
+               .rc_query = dw2102_rc_query,
+       },
+
+       .read_mac_address = su3000_read_mac_address,
+
+       .generic_bulk_ctrl_endpoint = 0x01,
+
+       .adapter = {
+               {
+                       .streaming_ctrl   = su3000_streaming_ctrl,
+                       .frontend_attach  = su3000_frontend_attach,
+                       .stream = {
+                               .type = USB_BULK,
+                               .count = 8,
+                               .endpoint = 0x82,
+                               .u = {
+                                       .bulk = {
+                                               .buffersize = 4096,
+                                       }
+                               }
+                       }
+               }
+       },
+       .num_device_descs = 3,
+       .devices = {
+               { "SU3000HD DVB-S USB2.0",
+                       { &dw2102_table[10], NULL },
+                       { NULL },
+               },
+               { "Terratec Cinergy S2 USB HD",
+                       { &dw2102_table[11], NULL },
+                       { NULL },
+               },
+               { "X3M TV SPC1400HD PCI",
+                       { &dw2102_table[14], NULL },
+                       { NULL },
+               },
+       }
+};
+
 static int dw2102_probe(struct usb_interface *intf,
                const struct usb_device_id *id)
 {
+       p1100 = kzalloc(sizeof(struct dvb_usb_device_properties), GFP_KERNEL);
+       if (!p1100)
+               return -ENOMEM;
+       /* copy default structure */
+       memcpy(p1100, &s6x0_properties,
+                       sizeof(struct dvb_usb_device_properties));
+       /* fill only different fields */
+       p1100->firmware = "dvb-usb-p1100.fw";
+       p1100->devices[0] = d1100;
+       p1100->rc.legacy.rc_map_table = rc_map_tbs_table;
+       p1100->rc.legacy.rc_map_size = ARRAY_SIZE(rc_map_tbs_table);
+       p1100->adapter->frontend_attach = stv0288_frontend_attach;
+
+       s660 = kzalloc(sizeof(struct dvb_usb_device_properties), GFP_KERNEL);
+       if (!s660) {
+               kfree(p1100);
+               return -ENOMEM;
+       }
+       memcpy(s660, &s6x0_properties,
+                       sizeof(struct dvb_usb_device_properties));
+       s660->firmware = "dvb-usb-s660.fw";
+       s660->num_device_descs = 3;
+       s660->devices[0] = d660;
+       s660->devices[1] = d480_1;
+       s660->devices[2] = d480_2;
+       s660->adapter->frontend_attach = ds3000_frontend_attach;
 
        p7500 = kzalloc(sizeof(struct dvb_usb_device_properties), GFP_KERNEL);
-       if (!p7500)
+       if (!p7500) {
+               kfree(p1100);
+               kfree(s660);
                return -ENOMEM;
-       /* copy default structure */
+       }
        memcpy(p7500, &s6x0_properties,
                        sizeof(struct dvb_usb_device_properties));
-       /* fill only different fields */
        p7500->firmware = "dvb-usb-p7500.fw";
        p7500->devices[0] = d7500;
        p7500->rc.legacy.rc_map_table = rc_map_tbs_table;
@@ -1480,8 +1887,14 @@ static int dw2102_probe(struct usb_interface *intf,
                        THIS_MODULE, NULL, adapter_nr) ||
            0 == dvb_usb_device_init(intf, &s6x0_properties,
                        THIS_MODULE, NULL, adapter_nr) ||
+           0 == dvb_usb_device_init(intf, p1100,
+                       THIS_MODULE, NULL, adapter_nr) ||
+           0 == dvb_usb_device_init(intf, s660,
+                       THIS_MODULE, NULL, adapter_nr) ||
            0 == dvb_usb_device_init(intf, p7500,
-                       THIS_MODULE, NULL, adapter_nr))
+                       THIS_MODULE, NULL, adapter_nr) ||
+           0 == dvb_usb_device_init(intf, &su3000_properties,
+                                    THIS_MODULE, NULL, adapter_nr))
                return 0;
 
        return -ENODEV;
@@ -1514,7 +1927,8 @@ module_exit(dw2102_module_exit);
 MODULE_AUTHOR("Igor M. Liplianin (c) liplianin@me.by");
 MODULE_DESCRIPTION("Driver for DVBWorld DVB-S 2101, 2102, DVB-S2 2104,"
                                " DVB-C 3101 USB2.0,"
-                               " TeVii S600, S630, S650, S660 USB2.0,"
-                               " Prof 1100, 7500 USB2.0 devices");
+                               " TeVii S600, S630, S650, S660, S480,"
+                               " Prof 1100, 7500 USB2.0,"
+                               " Geniatech SU3000 devices");
 MODULE_VERSION("0.1");
 MODULE_LICENSE("GPL");