Merge git://git.kernel.org/pub/scm/linux/kernel/git/sfrench/cifs-2.6
[powerpc.git] / drivers / media / dvb / bt8xx / dst.c
index 55a00cf..06ac899 100644 (file)
@@ -51,20 +51,24 @@ MODULE_PARM_DESC(dst_algo, "tuning algo: default is 0=(SW), 1=(HW)");
 #define DST_INFO               2
 #define DST_DEBUG              3
 
-#define dprintk(x, y, z, format, arg...) do {                                          \
-       if (z) {                                                                        \
-               if      ((x > DST_ERROR) && (x > y))                                    \
-                       printk(KERN_ERR "%s: " format "\n", __FUNCTION__ , ##arg);      \
-               else if ((x > DST_NOTICE) && (x > y))                                   \
-                       printk(KERN_NOTICE "%s: " format "\n", __FUNCTION__ , ##arg);   \
-               else if ((x > DST_INFO) && (x > y))                                     \
-                       printk(KERN_INFO "%s: " format "\n", __FUNCTION__ , ##arg);     \
-               else if ((x > DST_DEBUG) && (x > y))                                    \
-                       printk(KERN_DEBUG "%s: " format "\n", __FUNCTION__ , ##arg);    \
-       } else {                                                                        \
-               if (x > y)                                                              \
-                       printk(format, ##arg);                                          \
-       }                                                                               \
+#define dprintk(x, y, z, format, arg...) do {                          \
+       if (z) {                                                        \
+               if      ((x > DST_ERROR) && (x > y))                    \
+                       printk(KERN_ERR "dst(%d) %s: " format "\n",     \
+                               state->bt->nr, __func__ , ##arg);       \
+               else if ((x > DST_NOTICE) && (x > y))                   \
+                       printk(KERN_NOTICE "dst(%d) %s: " format "\n",  \
+                               state->bt->nr, __func__ , ##arg);       \
+               else if ((x > DST_INFO) && (x > y))                     \
+                       printk(KERN_INFO "dst(%d) %s: " format "\n",    \
+                               state->bt->nr, __func__ , ##arg);       \
+               else if ((x > DST_DEBUG) && (x > y))                    \
+                       printk(KERN_DEBUG "dst(%d) %s: " format "\n",   \
+                               state->bt->nr,  __func__ , ##arg);      \
+       } else {                                                        \
+               if (x > y)                                              \
+                       printk(format, ##arg);                          \
+       }                                                               \
 } while(0)
 
 
@@ -114,7 +118,7 @@ int dst_gpio_inb(struct dst_state *state, u8 *result)
 
        *result = 0;
        if ((err = bt878_device_control(state->bt, DST_IG_READ, &rd_packet)) < 0) {
-               dprintk(verbose, DST_ERROR, 1, "dst_gpio_inb error (err == %i)\n", err);
+               dprintk(verbose, DST_ERROR, 1, "dst_gpio_inb error (err == %i)", err);
                return -EREMOTEIO;
        }
        *result = (u8) rd_packet.rd.value;
@@ -389,7 +393,7 @@ static int dst_set_bandwidth(struct dst_state *state, fe_bandwidth_t bandwidth)
        state->bandwidth = bandwidth;
 
        if (state->dst_type != DST_TYPE_IS_TERR)
-               return 0;
+               return -EOPNOTSUPP;
 
        switch (bandwidth) {
        case BANDWIDTH_6_MHZ:
@@ -458,37 +462,49 @@ static int dst_set_symbolrate(struct dst_state *state, u32 srate)
 
        state->symbol_rate = srate;
        if (state->dst_type == DST_TYPE_IS_TERR) {
-               return 0;
+               return -EOPNOTSUPP;
        }
        dprintk(verbose, DST_INFO, 1, "set symrate %u", srate);
        srate /= 1000;
-       if (state->type_flags & DST_TYPE_HAS_SYMDIV) {
-               sval = srate;
-               sval <<= 20;
-               do_div(sval, 88000);
-               symcalc = (u32) sval;
-               dprintk(verbose, DST_INFO, 1, "set symcalc %u", symcalc);
-               state->tx_tuna[5] = (u8) (symcalc >> 12);
-               state->tx_tuna[6] = (u8) (symcalc >> 4);
-               state->tx_tuna[7] = (u8) (symcalc << 4);
-       } else {
-               state->tx_tuna[5] = (u8) (srate >> 16) & 0x7f;
-               state->tx_tuna[6] = (u8) (srate >> 8);
-               state->tx_tuna[7] = (u8) srate;
-       }
-       state->tx_tuna[8] &= ~0x20;
-       if (state->type_flags & DST_TYPE_HAS_OBS_REGS) {
-               if (srate > 8000)
-                       state->tx_tuna[8] |= 0x20;
+       if (state->dst_type == DST_TYPE_IS_SAT) {
+               if (state->type_flags & DST_TYPE_HAS_SYMDIV) {
+                       sval = srate;
+                       sval <<= 20;
+                       do_div(sval, 88000);
+                       symcalc = (u32) sval;
+                       dprintk(verbose, DST_INFO, 1, "set symcalc %u", symcalc);
+                       state->tx_tuna[5] = (u8) (symcalc >> 12);
+                       state->tx_tuna[6] = (u8) (symcalc >> 4);
+                       state->tx_tuna[7] = (u8) (symcalc << 4);
+               } else {
+                       state->tx_tuna[5] = (u8) (srate >> 16) & 0x7f;
+                       state->tx_tuna[6] = (u8) (srate >> 8);
+                       state->tx_tuna[7] = (u8) srate;
+               }
+               state->tx_tuna[8] &= ~0x20;
+               if (state->type_flags & DST_TYPE_HAS_OBS_REGS) {
+                       if (srate > 8000)
+                               state->tx_tuna[8] |= 0x20;
+               }
+       } else if (state->dst_type == DST_TYPE_IS_CABLE) {
+               dprintk(verbose, DST_DEBUG, 1, "%s", state->fw_name);
+               if (!strncmp(state->fw_name, "DCTNEW", 6)) {
+                       state->tx_tuna[5] = (u8) (srate >> 8);
+                       state->tx_tuna[6] = (u8) srate;
+                       state->tx_tuna[7] = 0x00;
+               } else if (!strncmp(state->fw_name, "DCT-CI", 6)) {
+                       state->tx_tuna[5] = 0x00;
+                       state->tx_tuna[6] = (u8) (srate >> 8);
+                       state->tx_tuna[7] = (u8) srate;
+               }
        }
        return 0;
 }
 
-
 static int dst_set_modulation(struct dst_state *state, fe_modulation_t modulation)
 {
        if (state->dst_type != DST_TYPE_IS_CABLE)
-               return 0;
+               return -EOPNOTSUPP;
 
        state->modulation = modulation;
        switch (modulation) {
@@ -505,7 +521,10 @@ static int dst_set_modulation(struct dst_state *state, fe_modulation_t modulatio
                state->tx_tuna[8] = 0x80;
                break;
        case QAM_256:
-               state->tx_tuna[8] = 0x00;
+               if (!strncmp(state->fw_name, "DCTNEW", 6))
+                       state->tx_tuna[8] = 0xff;
+               else if (!strncmp(state->fw_name, "DCT-CI", 6))
+                       state->tx_tuna[8] = 0x00;
                break;
        case QPSK:
        case QAM_AUTO:
@@ -538,15 +557,19 @@ u8 dst_check_sum(u8 *buf, u32 len)
 }
 EXPORT_SYMBOL(dst_check_sum);
 
-static void dst_type_flags_print(u32 type_flags)
+static void dst_type_flags_print(struct dst_state *state)
 {
+       u32 type_flags = state->type_flags;
+
        dprintk(verbose, DST_ERROR, 0, "DST type flags :");
-       if (type_flags & DST_TYPE_HAS_NEWTUNE)
-               dprintk(verbose, DST_ERROR, 0, " 0x%x newtuner", DST_TYPE_HAS_NEWTUNE);
+       if (type_flags & DST_TYPE_HAS_TS188)
+               dprintk(verbose, DST_ERROR, 0, " 0x%x newtuner", DST_TYPE_HAS_TS188);
        if (type_flags & DST_TYPE_HAS_NEWTUNE_2)
                dprintk(verbose, DST_ERROR, 0, " 0x%x newtuner 2", DST_TYPE_HAS_NEWTUNE_2);
        if (type_flags & DST_TYPE_HAS_TS204)
                dprintk(verbose, DST_ERROR, 0, " 0x%x ts204", DST_TYPE_HAS_TS204);
+       if (type_flags & DST_TYPE_HAS_VLF)
+               dprintk(verbose, DST_ERROR, 0, " 0x%x VLF", DST_TYPE_HAS_VLF);
        if (type_flags & DST_TYPE_HAS_SYMDIV)
                dprintk(verbose, DST_ERROR, 0, " 0x%x symdiv", DST_TYPE_HAS_SYMDIV);
        if (type_flags & DST_TYPE_HAS_FW_1)
@@ -559,7 +582,7 @@ static void dst_type_flags_print(u32 type_flags)
 }
 
 
-static int dst_type_print(u8 type)
+static int dst_type_print(struct dst_state *state, u8 type)
 {
        char *otype;
        switch (type) {
@@ -638,6 +661,13 @@ struct tuner_types tuner_list[] = {
                .fw_name    = "DSTMCI"
        },
 
+       {
+               .tuner_type = TUNER_TYPE_UNKNOWN,
+               .tuner_name = "UNKNOWN",
+               .board_name = "VP2021",
+               .fw_name    = "DCTNEW"
+       },
+
        {
                .tuner_type = TUNER_TYPE_UNKNOWN,
                .tuner_name = "UNKNOWN",
@@ -760,7 +790,7 @@ static struct dst_types dst_tlist[] = {
                .device_id = "DST-030",
                .offset =  0,
                .dst_type = DST_TYPE_IS_SAT,
-               .type_flags = DST_TYPE_HAS_TS204 | DST_TYPE_HAS_NEWTUNE | DST_TYPE_HAS_FW_1,
+               .type_flags = DST_TYPE_HAS_TS204 | DST_TYPE_HAS_TS188 | DST_TYPE_HAS_FW_1,
                .dst_feature = 0,
                .tuner_type = 0
        },      /*      obsolete        */
@@ -797,7 +827,7 @@ static struct dst_types dst_tlist[] = {
                .device_id = "DSTMCI",
                .offset = 1,
                .dst_type = DST_TYPE_IS_SAT,
-               .type_flags = DST_TYPE_HAS_NEWTUNE | DST_TYPE_HAS_FW_2 | DST_TYPE_HAS_FW_BUILD | DST_TYPE_HAS_INC_COUNT,
+               .type_flags = DST_TYPE_HAS_TS188 | DST_TYPE_HAS_FW_2 | DST_TYPE_HAS_FW_BUILD | DST_TYPE_HAS_INC_COUNT | DST_TYPE_HAS_VLF,
                .dst_feature = DST_TYPE_HAS_CA | DST_TYPE_HAS_DISEQC3 | DST_TYPE_HAS_DISEQC4
                                                        | DST_TYPE_HAS_MOTO | DST_TYPE_HAS_MAC,
                .tuner_type = TUNER_TYPE_MULTI
@@ -807,7 +837,7 @@ static struct dst_types dst_tlist[] = {
                .device_id = "DSTFCI",
                .offset = 1,
                .dst_type = DST_TYPE_IS_SAT,
-               .type_flags = DST_TYPE_HAS_NEWTUNE | DST_TYPE_HAS_FW_1,
+               .type_flags = DST_TYPE_HAS_TS188 | DST_TYPE_HAS_FW_1,
                .dst_feature = 0,
                .tuner_type = 0
        },      /* unknown to vendor    */
@@ -816,7 +846,7 @@ static struct dst_types dst_tlist[] = {
                .device_id = "DCT-CI",
                .offset = 1,
                .dst_type = DST_TYPE_IS_CABLE,
-               .type_flags = DST_TYPE_HAS_MULTI_FE | DST_TYPE_HAS_FW_1 | DST_TYPE_HAS_FW_2,
+               .type_flags = DST_TYPE_HAS_MULTI_FE | DST_TYPE_HAS_FW_1 | DST_TYPE_HAS_FW_2 | DST_TYPE_HAS_VLF,
                .dst_feature = DST_TYPE_HAS_CA,
                .tuner_type = 0
        },
@@ -825,7 +855,7 @@ static struct dst_types dst_tlist[] = {
                .device_id = "DCTNEW",
                .offset = 1,
                .dst_type = DST_TYPE_IS_CABLE,
-               .type_flags = DST_TYPE_HAS_NEWTUNE | DST_TYPE_HAS_FW_3 | DST_TYPE_HAS_FW_BUILD,
+               .type_flags = DST_TYPE_HAS_TS188 | DST_TYPE_HAS_FW_3 | DST_TYPE_HAS_FW_BUILD | DST_TYPE_HAS_MULTI_FE,
                .dst_feature = 0,
                .tuner_type = 0
        },
@@ -834,7 +864,7 @@ static struct dst_types dst_tlist[] = {
                .device_id = "DTT-CI",
                .offset = 1,
                .dst_type = DST_TYPE_IS_TERR,
-               .type_flags = DST_TYPE_HAS_FW_2 | DST_TYPE_HAS_MULTI_FE,
+               .type_flags = DST_TYPE_HAS_FW_2 | DST_TYPE_HAS_MULTI_FE | DST_TYPE_HAS_VLF,
                .dst_feature = DST_TYPE_HAS_CA,
                .tuner_type = 0
        },
@@ -933,7 +963,7 @@ static int dst_card_type(struct dst_state *state)
        for (j = 0, p_tuner_list = tuner_list; j < ARRAY_SIZE(tuner_list); j++, p_tuner_list++) {
                if (!strcmp(&state->card_info[0], p_tuner_list->board_name)) {
                        state->tuner_type = p_tuner_list->tuner_type;
-                       dprintk(verbose, DST_ERROR, 1, "DST has [%s] tuner, tuner type=[%d]\n",
+                       dprintk(verbose, DST_ERROR, 1, "DST has [%s] tuner, tuner type=[%d]",
                                p_tuner_list->tuner_name, p_tuner_list->tuner_type);
                }
        }
@@ -956,6 +986,58 @@ static int dst_get_vendor(struct dst_state *state)
        return 0;
 }
 
+static void debug_dst_buffer(struct dst_state *state)
+{
+       int i;
+
+       if (verbose > 2) {
+               printk("%s: [", __func__);
+               for (i = 0; i < 8; i++)
+                       printk(" %02x", state->rxbuffer[i]);
+               printk("]\n");
+       }
+}
+
+static int dst_check_stv0299(struct dst_state *state)
+{
+       u8 check_stv0299[] = { 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
+
+       check_stv0299[7] = dst_check_sum(check_stv0299, 7);
+       if (dst_command(state, check_stv0299, 8) < 0) {
+               dprintk(verbose, DST_ERROR, 1, "Cmd=[0x04] failed");
+               return -1;
+       }
+       debug_dst_buffer(state);
+
+       if (memcmp(&check_stv0299, &state->rxbuffer, 8)) {
+               dprintk(verbose, DST_ERROR, 1, "Found a STV0299 NIM");
+               state->tuner_type = TUNER_TYPE_STV0299;
+               return 0;
+       }
+
+       return -1;
+}
+
+static int dst_check_mb86a15(struct dst_state *state)
+{
+       u8 check_mb86a15[] = { 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
+
+       check_mb86a15[7] = dst_check_sum(check_mb86a15, 7);
+       if (dst_command(state, check_mb86a15, 8) < 0) {
+               dprintk(verbose, DST_ERROR, 1, "Cmd=[0x10], failed");
+               return -1;
+       }
+       debug_dst_buffer(state);
+
+       if (memcmp(&check_mb86a15, &state->rxbuffer, 8) < 0) {
+               dprintk(verbose, DST_ERROR, 1, "Found a MB86A15 NIM");
+               state->tuner_type = TUNER_TYPE_MB86A15;
+               return 0;
+       }
+
+       return -1;
+}
+
 static int dst_get_tuner_info(struct dst_state *state)
 {
        u8 get_tuner_1[] = { 0x00, 0x13, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
@@ -965,57 +1047,41 @@ static int dst_get_tuner_info(struct dst_state *state)
        get_tuner_2[7] = dst_check_sum(get_tuner_2, 7);
        dprintk(verbose, DST_ERROR, 1, "DST TYpe = MULTI FE");
        if (state->type_flags & DST_TYPE_HAS_MULTI_FE) {
-//             if (dst_command(state, get_tuner_2, 8) < 0) {
                if (dst_command(state, get_tuner_1, 8) < 0) {
                        dprintk(verbose, DST_INFO, 1, "Cmd=[0x13], Unsupported");
-                       return -1;
+                       goto force;
                }
        } else {
-//             if (dst_command(state, get_tuner_1, 8) < 0) {
                if (dst_command(state, get_tuner_2, 8) < 0) {
                        dprintk(verbose, DST_INFO, 1, "Cmd=[0xb], Unsupported");
-                       return -1;
+                       goto force;
                }
        }
        memset(&state->board_info, '\0', 8);
        memcpy(&state->board_info, &state->rxbuffer, 8);
        if (state->type_flags & DST_TYPE_HAS_MULTI_FE) {
                dprintk(verbose, DST_ERROR, 1, "DST type has TS=188");
-/*
-               if (state->board_info[1] == 0x0b) {
-                       if (state->type_flags & DST_TYPE_HAS_TS204)
-                               state->type_flags &= ~DST_TYPE_HAS_TS204;
-                       state->type_flags |= DST_TYPE_HAS_NEWTUNE;
-                       dprintk(verbose, DST_INFO, 1, "DST type has TS=188");
-               } else {
-                       if (state->type_flags & DST_TYPE_HAS_NEWTUNE)
-                               state->type_flags &= ~DST_TYPE_HAS_NEWTUNE;
-                       state->type_flags |= DST_TYPE_HAS_TS204;
-                       dprintk(verbose, DST_INFO, 1, "DST type has TS=204");
-               }
-       } else {
-*/
        }
        if (state->board_info[0] == 0xbc) {
-//             if (state->type_flags & DST_TYPE_HAS_TS204)
-//                     state->type_flags &= ~DST_TYPE_HAS_TS204;
-//             state->type_flags |= DST_TYPE_HAS_NEWTUNE;
-               if (!(state->type_flags & DST_TYPE_IS_ATSC)) {
-                       state->type_flags |= DST_TYPE_HAS_NEWTUNE;
-               } else {
+               if (state->type_flags != DST_TYPE_IS_ATSC)
+                       state->type_flags |= DST_TYPE_HAS_TS188;
+               else
                        state->type_flags |= DST_TYPE_HAS_NEWTUNE_2;
+
+               if (state->board_info[1] == 0x01) {
+                       state->dst_hw_cap |= DST_TYPE_HAS_DBOARD;
+                       dprintk(verbose, DST_ERROR, 1, "DST has Daughterboard");
                }
-               dprintk(verbose, DST_INFO, 1, "DST type has TS=188, Daughterboard=[%d]", state->board_info[1]);
+       }
 
-       } else if (state->board_info[0] == 0xcc) {
-//             if (state->type_flags & DST_TYPE_HAS_NEWTUNE)
-//                     state->type_flags &= ~DST_TYPE_HAS_NEWTUNE;
+       return 0;
+force:
+       if (!strncmp(state->fw_name, "DCT-CI", 6)) {
                state->type_flags |= DST_TYPE_HAS_TS204;
-               dprintk(verbose, DST_INFO, 1, "DST type has TS=204 Daughterboard=[%d]", state->board_info[1]);
+               dprintk(verbose, DST_ERROR, 1, "Forcing [%s] to TS188", state->fw_name);
        }
-//     }
 
-       return 0;
+       return -1;
 }
 
 static int dst_get_device_id(struct dst_state *state)
@@ -1023,14 +1089,15 @@ static int dst_get_device_id(struct dst_state *state)
        u8 reply;
 
        int i, j;
-       struct dst_types *p_dst_type;
-       struct tuner_types *p_tuner_list;
+       struct dst_types *p_dst_type = NULL;
+       struct tuner_types *p_tuner_list = NULL;
 
        u8 use_dst_type = 0;
        u32 use_type_flags = 0;
 
        static u8 device_type[8] = {0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff};
 
+       state->tuner_type = 0;
        device_type[7] = dst_check_sum(device_type, 7);
 
        if (write_dst(state, device_type, FIXED_COMM))
@@ -1062,16 +1129,32 @@ static int dst_get_device_id(struct dst_state *state)
 
                        /*      Card capabilities       */
                        state->dst_hw_cap = p_dst_type->dst_feature;
-                       dprintk(verbose, DST_ERROR, 1, "Recognise [%s]\n", p_dst_type->device_id);
-
-                       if (p_dst_type->tuner_type != TUNER_TYPE_MULTI) {
-                               state->tuner_type = p_dst_type->tuner_type;
-
-                               for (j = 0, p_tuner_list = tuner_list; j < ARRAY_SIZE(tuner_list); j++, p_tuner_list++) {
-                                       if (p_dst_type->tuner_type == p_tuner_list->tuner_type) {
-                                               state->tuner_type = p_tuner_list->tuner_type;
-                                               dprintk(verbose, DST_ERROR, 1, "DST has a [%s] based tuner\n", p_tuner_list->tuner_name);
+                       dprintk(verbose, DST_ERROR, 1, "Recognise [%s]", p_dst_type->device_id);
+                       strncpy(&state->fw_name[0], p_dst_type->device_id, 6);
+                       /*      Multiple tuners         */
+                       if (p_dst_type->tuner_type & TUNER_TYPE_MULTI) {
+                               switch (use_dst_type) {
+                               case DST_TYPE_IS_SAT:
+                                       /*      STV0299 check   */
+                                       if (dst_check_stv0299(state) < 0) {
+                                               dprintk(verbose, DST_ERROR, 1, "Unsupported");
+                                               state->tuner_type = TUNER_TYPE_MB86A15;
                                        }
+                                       break;
+                               default:
+                                       break;
+                               }
+                               if (dst_check_mb86a15(state) < 0)
+                                       dprintk(verbose, DST_ERROR, 1, "Unsupported");
+                       /*      Single tuner            */
+                       } else {
+                               state->tuner_type = p_dst_type->tuner_type;
+                       }
+                       for (j = 0, p_tuner_list = tuner_list; j < ARRAY_SIZE(tuner_list); j++, p_tuner_list++) {
+                               if (!(strncmp(p_dst_type->device_id, p_tuner_list->fw_name, 7)) &&
+                                       p_tuner_list->tuner_type == state->tuner_type) {
+                                       dprintk(verbose, DST_ERROR, 1, "[%s] has a [%s]",
+                                               p_dst_type->device_id, p_tuner_list->tuner_name);
                                }
                        }
                        break;
@@ -1084,10 +1167,10 @@ static int dst_get_device_id(struct dst_state *state)
                use_dst_type = DST_TYPE_IS_SAT;
                use_type_flags = DST_TYPE_HAS_SYMDIV;
        }
-       dst_type_print(use_dst_type);
+       dst_type_print(state, use_dst_type);
        state->type_flags = use_type_flags;
        state->dst_type = use_dst_type;
-       dst_type_flags_print(state->type_flags);
+       dst_type_flags_print(state);
 
        return 0;
 }
@@ -1115,7 +1198,6 @@ static int dst_probe(struct dst_state *state)
        }
        if (dst_get_mac(state) < 0) {
                dprintk(verbose, DST_INFO, 1, "MAC: Unsupported command");
-               return 0;
        }
        if ((state->type_flags & DST_TYPE_HAS_MULTI_FE) || (state->type_flags & DST_TYPE_HAS_FW_BUILD)) {
                if (dst_get_tuner_info(state) < 0)
@@ -1152,7 +1234,7 @@ int dst_command(struct dst_state *state, u8 *data, u8 len)
                goto error;
        }
        if (write_dst(state, data, len)) {
-               dprintk(verbose, DST_INFO, 1, "Tring to recover.. ");
+               dprintk(verbose, DST_INFO, 1, "Trying to recover.. ");
                if ((dst_error_recovery(state)) < 0) {
                        dprintk(verbose, DST_ERROR, 1, "Recovery Failed.");
                        goto error;
@@ -1246,15 +1328,13 @@ static int dst_tone_power_cmd(struct dst_state *state)
 {
        u8 paket[8] = { 0x00, 0x09, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00 };
 
-       if (state->dst_type == DST_TYPE_IS_TERR)
-               return 0;
+       if (state->dst_type != DST_TYPE_IS_SAT)
+               return -EOPNOTSUPP;
        paket[4] = state->tx_tuna[4];
        paket[2] = state->tx_tuna[2];
        paket[3] = state->tx_tuna[3];
        paket[7] = dst_check_sum (paket, 7);
-       dst_command(state, paket, 8);
-
-       return 0;
+       return dst_command(state, paket, 8);
 }
 
 static int dst_get_tuna(struct dst_state *state)
@@ -1266,8 +1346,9 @@ static int dst_get_tuna(struct dst_state *state)
        state->diseq_flags &= ~(HAS_LOCK);
        if (!dst_wait_dst_ready(state, NO_DELAY))
                return -EIO;
-       if (state->type_flags & DST_TYPE_HAS_NEWTUNE)
-               /* how to get variable length reply ???? */
+       if ((state->type_flags & DST_TYPE_HAS_VLF) &&
+               !(state->dst_type == DST_TYPE_IS_ATSC))
+
                retval = read_dst(state, state->rx_tuna, 10);
        else
                retval = read_dst(state, &state->rx_tuna[2], FIXED_COMM);
@@ -1275,7 +1356,10 @@ static int dst_get_tuna(struct dst_state *state)
                dprintk(verbose, DST_DEBUG, 1, "read not successful");
                return retval;
        }
-       if (state->type_flags & DST_TYPE_HAS_NEWTUNE) {
+       if ((state->type_flags & DST_TYPE_HAS_VLF) &&
+               !(state->dst_type == DST_TYPE_IS_CABLE) &&
+               !(state->dst_type == DST_TYPE_IS_ATSC)) {
+
                if (state->rx_tuna[9] != dst_check_sum(&state->rx_tuna[0], 9)) {
                        dprintk(verbose, DST_INFO, 1, "checksum failure ? ");
                        return -EIO;
@@ -1321,7 +1405,10 @@ static int dst_write_tuna(struct dvb_frontend *fe)
                dprintk(verbose, DST_DEBUG, 1, "DST Communication initialization failed.");
                goto error;
        }
-       if (state->type_flags & DST_TYPE_HAS_NEWTUNE) {
+//     if (state->type_flags & DST_TYPE_HAS_NEWTUNE) {
+       if ((state->type_flags & DST_TYPE_HAS_VLF) &&
+               (!(state->dst_type == DST_TYPE_IS_ATSC))) {
+
                state->tx_tuna[9] = dst_check_sum(&state->tx_tuna[0], 9);
                retval = write_dst(state, &state->tx_tuna[0], 10);
        } else {
@@ -1376,23 +1463,25 @@ static int dst_set_diseqc(struct dvb_frontend *fe, struct dvb_diseqc_master_cmd
        u8 paket[8] = { 0x00, 0x08, 0x04, 0xe0, 0x10, 0x38, 0xf0, 0xec };
 
        if (state->dst_type != DST_TYPE_IS_SAT)
-               return 0;
-       if (cmd->msg_len == 0 || cmd->msg_len > 4)
+               return -EOPNOTSUPP;
+       if (cmd->msg_len > 0 && cmd->msg_len < 5)
+               memcpy(&paket[3], cmd->msg, cmd->msg_len);
+       else if (cmd->msg_len == 5 && state->dst_hw_cap & DST_TYPE_HAS_DISEQC5)
+               memcpy(&paket[2], cmd->msg, cmd->msg_len);
+       else
                return -EINVAL;
-       memcpy(&paket[3], cmd->msg, cmd->msg_len);
        paket[7] = dst_check_sum(&paket[0], 7);
-       dst_command(state, paket, 8);
-       return 0;
+       return dst_command(state, paket, 8);
 }
 
 static int dst_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
 {
-       int need_cmd;
+       int need_cmd, retval = 0;
        struct dst_state *state = fe->demodulator_priv;
 
        state->voltage = voltage;
        if (state->dst_type != DST_TYPE_IS_SAT)
-               return 0;
+               return -EOPNOTSUPP;
 
        need_cmd = 0;
 
@@ -1414,9 +1503,9 @@ static int dst_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
        }
 
        if (need_cmd)
-               dst_tone_power_cmd(state);
+               retval = dst_tone_power_cmd(state);
 
-       return 0;
+       return retval;
 }
 
 static int dst_set_tone(struct dvb_frontend *fe, fe_sec_tone_mode_t tone)
@@ -1425,7 +1514,7 @@ static int dst_set_tone(struct dvb_frontend *fe, fe_sec_tone_mode_t tone)
 
        state->tone = tone;
        if (state->dst_type != DST_TYPE_IS_SAT)
-               return 0;
+               return -EOPNOTSUPP;
 
        switch (tone) {
        case SEC_TONE_OFF:
@@ -1441,9 +1530,7 @@ static int dst_set_tone(struct dvb_frontend *fe, fe_sec_tone_mode_t tone)
        default:
                return -EINVAL;
        }
-       dst_tone_power_cmd(state);
-
-       return 0;
+       return dst_tone_power_cmd(state);
 }
 
 static int dst_send_burst(struct dvb_frontend *fe, fe_sec_mini_cmd_t minicmd)
@@ -1451,7 +1538,7 @@ static int dst_send_burst(struct dvb_frontend *fe, fe_sec_mini_cmd_t minicmd)
        struct dst_state *state = fe->demodulator_priv;
 
        if (state->dst_type != DST_TYPE_IS_SAT)
-               return 0;
+               return -EOPNOTSUPP;
        state->minicmd = minicmd;
        switch (minicmd) {
        case SEC_MINI_A:
@@ -1461,9 +1548,7 @@ static int dst_send_burst(struct dvb_frontend *fe, fe_sec_mini_cmd_t minicmd)
                state->tx_tuna[3] = 0xff;
                break;
        }
-       dst_tone_power_cmd(state);
-
-       return 0;
+       return dst_tone_power_cmd(state);
 }
 
 
@@ -1475,8 +1560,8 @@ static int dst_init(struct dvb_frontend *fe)
        static u8 sat_tuna_204[] = { 0x00, 0x00, 0x03, 0xb6, 0x01, 0x55, 0xbd, 0x50, 0x00, 0x00 };
        static u8 ter_tuna_188[] = { 0x09, 0x00, 0x03, 0xb6, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00 };
        static u8 ter_tuna_204[] = { 0x00, 0x00, 0x03, 0xb6, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00 };
-       static u8 cab_tuna_204[] = { 0x00, 0x00, 0x03, 0xb6, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00 };
        static u8 cab_tuna_188[] = { 0x09, 0x00, 0x03, 0xb6, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00 };
+       static u8 cab_tuna_204[] = { 0x00, 0x00, 0x03, 0xb6, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00 };
        static u8 atsc_tuner[] = { 0x00, 0x00, 0x03, 0xb6, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00 };
 
        state->inversion = INVERSION_OFF;
@@ -1487,11 +1572,11 @@ static int dst_init(struct dvb_frontend *fe)
        state->bandwidth = BANDWIDTH_7_MHZ;
        state->cur_jiff = jiffies;
        if (state->dst_type == DST_TYPE_IS_SAT)
-               memcpy(state->tx_tuna, ((state->type_flags & DST_TYPE_HAS_NEWTUNE) ? sat_tuna_188 : sat_tuna_204), sizeof (sat_tuna_204));
+               memcpy(state->tx_tuna, ((state->type_flags & DST_TYPE_HAS_VLF) ? sat_tuna_188 : sat_tuna_204), sizeof (sat_tuna_204));
        else if (state->dst_type == DST_TYPE_IS_TERR)
-               memcpy(state->tx_tuna, ((state->type_flags & DST_TYPE_HAS_NEWTUNE) ? ter_tuna_188 : ter_tuna_204), sizeof (ter_tuna_204));
+               memcpy(state->tx_tuna, ((state->type_flags & DST_TYPE_HAS_VLF) ? ter_tuna_188 : ter_tuna_204), sizeof (ter_tuna_204));
        else if (state->dst_type == DST_TYPE_IS_CABLE)
-               memcpy(state->tx_tuna, ((state->type_flags & DST_TYPE_HAS_NEWTUNE) ? cab_tuna_188 : cab_tuna_204), sizeof (cab_tuna_204));
+               memcpy(state->tx_tuna, ((state->type_flags & DST_TYPE_HAS_VLF) ? cab_tuna_188 : cab_tuna_204), sizeof (cab_tuna_204));
        else if (state->dst_type == DST_TYPE_IS_ATSC)
                memcpy(state->tx_tuna, atsc_tuner, sizeof (atsc_tuner));
 
@@ -1516,28 +1601,31 @@ static int dst_read_signal_strength(struct dvb_frontend *fe, u16 *strength)
 {
        struct dst_state *state = fe->demodulator_priv;
 
-       dst_get_signal(state);
+       int retval = dst_get_signal(state);
        *strength = state->decode_strength;
 
-       return 0;
+       return retval;
 }
 
 static int dst_read_snr(struct dvb_frontend *fe, u16 *snr)
 {
        struct dst_state *state = fe->demodulator_priv;
 
-       dst_get_signal(state);
+       int retval = dst_get_signal(state);
        *snr = state->decode_snr;
 
-       return 0;
+       return retval;
 }
 
 static int dst_set_frontend(struct dvb_frontend *fe, struct dvb_frontend_parameters *p)
 {
+       int retval = -EINVAL;
        struct dst_state *state = fe->demodulator_priv;
 
        if (p != NULL) {
-               dst_set_freq(state, p->frequency);
+               retval = dst_set_freq(state, p->frequency);
+               if(retval != 0)
+                       return retval;
                dprintk(verbose, DST_DEBUG, 1, "Set Frequency=[%d]", p->frequency);
 
                if (state->dst_type == DST_TYPE_IS_SAT) {
@@ -1555,10 +1643,10 @@ static int dst_set_frontend(struct dvb_frontend *fe, struct dvb_frontend_paramet
                        dst_set_symbolrate(state, p->u.qam.symbol_rate);
                        dst_set_modulation(state, p->u.qam.modulation);
                }
-               dst_write_tuna(fe);
+               retval = dst_write_tuna(fe);
        }
 
-       return 0;
+       return retval;
 }
 
 static int dst_tune_frontend(struct dvb_frontend* fe,