]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/media/dvb/bt8xx/dst.c
V4L/DVB (4170): ATSC typecheck bugfix
[linux-2.6-omap-h63xx.git] / drivers / media / dvb / bt8xx / dst.c
index 0310e3dd07e60e0c41489aac538f3da89aecc78e..97d6c632542a050fd1c96e488d8eb21e83bf7ac1 100644 (file)
@@ -38,6 +38,10 @@ static unsigned int dst_addons;
 module_param(dst_addons, int, 0644);
 MODULE_PARM_DESC(dst_addons, "CA daughterboard, default is 0 (No addons)");
 
+static unsigned int dst_algo;
+module_param(dst_algo, int, 0644);
+MODULE_PARM_DESC(dst_algo, "tuning algo: default is 0=(SW), 1=(HW)");
+
 #define HAS_LOCK               1
 #define ATTEMPT_TUNE           2
 #define HAS_POWER              4
@@ -363,6 +367,17 @@ static int dst_set_freq(struct dst_state *state, u32 freq)
                state->tx_tuna[2] = (freq >> 16) & 0xff;
                state->tx_tuna[3] = (freq >> 8) & 0xff;
                state->tx_tuna[4] = (u8) freq;
+       } else if (state->dst_type == DST_TYPE_IS_ATSC) {
+               freq = freq / 1000;
+               if (freq < 51000 || freq > 858000)
+                       return -EINVAL;
+               state->tx_tuna[2] = (freq >> 16) & 0xff;
+               state->tx_tuna[3] = (freq >>  8) & 0xff;
+               state->tx_tuna[4] = (u8) freq;
+               state->tx_tuna[5] = 0x00;               /*      ATSC    */
+               state->tx_tuna[6] = 0x00;
+               if (state->dst_hw_cap & DST_TYPE_HAS_ANALOG)
+                       state->tx_tuna[7] = 0x00;       /*      Digital */
        } else
                return -EINVAL;
 
@@ -528,6 +543,8 @@ static void dst_type_flags_print(u32 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_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_SYMDIV)
@@ -558,6 +575,10 @@ static int dst_type_print(u8 type)
                otype = "cable";
                break;
 
+       case DST_TYPE_IS_ATSC:
+               otype = "atsc";
+               break;
+
        default:
                dprintk(verbose, DST_INFO, 1, "invalid dst type %d", type);
                return -EINVAL;
@@ -567,6 +588,120 @@ static int dst_type_print(u8 type)
        return 0;
 }
 
+struct tuner_types tuner_list[] = {
+       {
+               .tuner_type = TUNER_TYPE_L64724,
+               .tuner_name = "L 64724",
+               .board_name = "UNKNOWN",
+               .fw_name    = "UNKNOWN"
+       },
+
+       {
+               .tuner_type = TUNER_TYPE_STV0299,
+               .tuner_name = "STV 0299",
+               .board_name = "VP1020",
+               .fw_name    = "DST-MOT"
+       },
+
+       {
+               .tuner_type = TUNER_TYPE_STV0299,
+               .tuner_name = "STV 0299",
+               .board_name = "VP1020",
+               .fw_name    = "DST-03T"
+       },
+
+       {
+               .tuner_type = TUNER_TYPE_MB86A15,
+               .tuner_name = "MB 86A15",
+               .board_name = "VP1022",
+               .fw_name    = "DST-03T"
+       },
+
+       {
+               .tuner_type = TUNER_TYPE_MB86A15,
+               .tuner_name = "MB 86A15",
+               .board_name = "VP1025",
+               .fw_name    = "DST-03T"
+       },
+
+       {
+               .tuner_type = TUNER_TYPE_STV0299,
+               .tuner_name = "STV 0299",
+               .board_name = "VP1030",
+               .fw_name    = "DST-CI"
+       },
+
+       {
+               .tuner_type = TUNER_TYPE_STV0299,
+               .tuner_name = "STV 0299",
+               .board_name = "VP1030",
+               .fw_name    = "DSTMCI"
+       },
+
+       {
+               .tuner_type = TUNER_TYPE_UNKNOWN,
+               .tuner_name = "UNKNOWN",
+               .board_name = "VP2030",
+               .fw_name    = "DCT-CI"
+       },
+
+       {
+               .tuner_type = TUNER_TYPE_UNKNOWN,
+               .tuner_name = "UNKNOWN",
+               .board_name = "VP2031",
+               .fw_name    = "DCT-CI"
+       },
+
+       {
+               .tuner_type = TUNER_TYPE_UNKNOWN,
+               .tuner_name = "UNKNOWN",
+               .board_name = "VP2040",
+               .fw_name    = "DCT-CI"
+       },
+
+       {
+               .tuner_type = TUNER_TYPE_UNKNOWN,
+               .tuner_name = "UNKNOWN",
+               .board_name = "VP3020",
+               .fw_name    = "DTTFTA"
+       },
+
+       {
+               .tuner_type = TUNER_TYPE_UNKNOWN,
+               .tuner_name = "UNKNOWN",
+               .board_name = "VP3021",
+               .fw_name    = "DTTFTA"
+       },
+
+       {
+               .tuner_type = TUNER_TYPE_TDA10046,
+               .tuner_name = "TDA10046",
+               .board_name = "VP3040",
+               .fw_name    = "DTT-CI"
+       },
+
+       {
+               .tuner_type = TUNER_TYPE_UNKNOWN,
+               .tuner_name = "UNKNOWN",
+               .board_name = "VP3051",
+               .fw_name    = "DTTNXT"
+       },
+
+       {
+               .tuner_type = TUNER_TYPE_NXT200x,
+               .tuner_name = "NXT200x",
+               .board_name = "VP3220",
+               .fw_name    = "ATSCDI"
+       },
+
+       {
+               .tuner_type = TUNER_TYPE_NXT200x,
+               .tuner_name = "NXT200x",
+               .board_name = "VP3250",
+               .fw_name    = "ATSCAD"
+       },
+};
+
 /*
        Known cards list
        Satellite
@@ -608,7 +743,8 @@ static struct dst_types dst_tlist[] = {
                .offset = 0,
                .dst_type =  DST_TYPE_IS_SAT,
                .type_flags = DST_TYPE_HAS_SYMDIV | DST_TYPE_HAS_FW_1 | DST_TYPE_HAS_OBS_REGS,
-               .dst_feature = 0
+               .dst_feature = 0,
+               .tuner_type = 0
        },      /*      obsolete        */
 
        {
@@ -616,7 +752,8 @@ static struct dst_types dst_tlist[] = {
                .offset = 0,
                .dst_type =  DST_TYPE_IS_SAT,
                .type_flags = DST_TYPE_HAS_SYMDIV | DST_TYPE_HAS_FW_1,
-               .dst_feature = 0
+               .dst_feature = 0,
+               .tuner_type = 0
        },      /*      obsolete        */
 
        {
@@ -624,7 +761,8 @@ static struct dst_types dst_tlist[] = {
                .offset =  0,
                .dst_type = DST_TYPE_IS_SAT,
                .type_flags = DST_TYPE_HAS_TS204 | DST_TYPE_HAS_NEWTUNE | DST_TYPE_HAS_FW_1,
-               .dst_feature = 0
+               .dst_feature = 0,
+               .tuner_type = 0
        },      /*      obsolete        */
 
        {
@@ -633,7 +771,8 @@ static struct dst_types dst_tlist[] = {
                .dst_type = DST_TYPE_IS_SAT,
                .type_flags = DST_TYPE_HAS_SYMDIV | DST_TYPE_HAS_TS204 | DST_TYPE_HAS_FW_2,
                .dst_feature = DST_TYPE_HAS_DISEQC3 | DST_TYPE_HAS_DISEQC4 | DST_TYPE_HAS_DISEQC5
-                                                        | DST_TYPE_HAS_MAC | DST_TYPE_HAS_MOTO
+                                                        | DST_TYPE_HAS_MAC | DST_TYPE_HAS_MOTO,
+               .tuner_type = TUNER_TYPE_MULTI
         },
 
        {
@@ -641,15 +780,17 @@ static struct dst_types dst_tlist[] = {
                .offset =  0,
                .dst_type = DST_TYPE_IS_SAT,
                .type_flags = DST_TYPE_HAS_SYMDIV | DST_TYPE_HAS_FW_1,
-               .dst_feature = 0
+               .dst_feature = 0,
+               .tuner_type = 0
        },      /*      obsolete        */
 
        {
                .device_id = "DST-CI",
                .offset = 1,
                .dst_type = DST_TYPE_IS_SAT,
-               .type_flags = DST_TYPE_HAS_TS204 | DST_TYPE_HAS_NEWTUNE | DST_TYPE_HAS_FW_1,
-               .dst_feature = DST_TYPE_HAS_CA
+               .type_flags = DST_TYPE_HAS_TS204 | DST_TYPE_HAS_FW_1,
+               .dst_feature = DST_TYPE_HAS_CA,
+               .tuner_type = 0
        },      /*      An OEM board    */
 
        {
@@ -658,7 +799,8 @@ static struct dst_types dst_tlist[] = {
                .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,
                .dst_feature = DST_TYPE_HAS_CA | DST_TYPE_HAS_DISEQC3 | DST_TYPE_HAS_DISEQC4
-                                                       | DST_TYPE_HAS_MOTO | DST_TYPE_HAS_MAC
+                                                       | DST_TYPE_HAS_MOTO | DST_TYPE_HAS_MAC,
+               .tuner_type = TUNER_TYPE_MULTI
        },
 
        {
@@ -666,16 +808,17 @@ static struct dst_types dst_tlist[] = {
                .offset = 1,
                .dst_type = DST_TYPE_IS_SAT,
                .type_flags = DST_TYPE_HAS_NEWTUNE | DST_TYPE_HAS_FW_1,
-               .dst_feature = 0
+               .dst_feature = 0,
+               .tuner_type = 0
        },      /* unknown to vendor    */
 
        {
                .device_id = "DCT-CI",
                .offset = 1,
                .dst_type = DST_TYPE_IS_CABLE,
-               .type_flags = DST_TYPE_HAS_TS204 | DST_TYPE_HAS_NEWTUNE | DST_TYPE_HAS_FW_1
-                                                       | DST_TYPE_HAS_FW_2,
-               .dst_feature = DST_TYPE_HAS_CA
+               .type_flags = DST_TYPE_HAS_MULTI_FE | DST_TYPE_HAS_FW_1 | DST_TYPE_HAS_FW_2,
+               .dst_feature = DST_TYPE_HAS_CA,
+               .tuner_type = 0
        },
 
        {
@@ -683,15 +826,17 @@ static struct dst_types dst_tlist[] = {
                .offset = 1,
                .dst_type = DST_TYPE_IS_CABLE,
                .type_flags = DST_TYPE_HAS_NEWTUNE | DST_TYPE_HAS_FW_3 | DST_TYPE_HAS_FW_BUILD,
-               .dst_feature = 0
+               .dst_feature = 0,
+               .tuner_type = 0
        },
 
        {
                .device_id = "DTT-CI",
                .offset = 1,
                .dst_type = DST_TYPE_IS_TERR,
-               .type_flags = DST_TYPE_HAS_TS204 | DST_TYPE_HAS_NEWTUNE | DST_TYPE_HAS_FW_2 | DST_TYPE_HAS_MULTI_FE,
-               .dst_feature = DST_TYPE_HAS_CA
+               .type_flags = DST_TYPE_HAS_FW_2 | DST_TYPE_HAS_MULTI_FE,
+               .dst_feature = DST_TYPE_HAS_CA,
+               .tuner_type = 0
        },
 
        {
@@ -699,7 +844,8 @@ static struct dst_types dst_tlist[] = {
                .offset = 1,
                .dst_type = DST_TYPE_IS_TERR,
                .type_flags = DST_TYPE_HAS_FW_2,
-               .dst_feature = 0
+               .dst_feature = 0,
+               .tuner_type = 0
        },
 
        {
@@ -707,7 +853,8 @@ static struct dst_types dst_tlist[] = {
                .offset = 1,
                .dst_type = DST_TYPE_IS_TERR,
                .type_flags = DST_TYPE_HAS_FW_2,
-               .dst_feature = DST_TYPE_HAS_ANALOG
+               .dst_feature = DST_TYPE_HAS_ANALOG,
+               .tuner_type = 0
        },
 
        {
@@ -715,15 +862,17 @@ static struct dst_types dst_tlist[] = {
                .offset = 1,
                .dst_type = DST_TYPE_IS_ATSC,
                .type_flags = DST_TYPE_HAS_FW_2,
-               .dst_feature = 0
+               .dst_feature = 0,
+               .tuner_type = 0
        },
 
        {
                .device_id = "ATSCAD",
                .offset = 1,
                .dst_type = DST_TYPE_IS_ATSC,
-               .type_flags = DST_TYPE_HAS_FW_2,
-               .dst_feature = 0
+               .type_flags = DST_TYPE_HAS_MULTI_FE | DST_TYPE_HAS_FW_2 | DST_TYPE_HAS_FW_BUILD,
+               .dst_feature = DST_TYPE_HAS_MAC | DST_TYPE_HAS_ANALOG,
+               .tuner_type = 0
        },
 
        { }
@@ -768,6 +917,9 @@ static int dst_fw_ver(struct dst_state *state)
 
 static int dst_card_type(struct dst_state *state)
 {
+       int j;
+       struct tuner_types *p_tuner_list = NULL;
+
        u8 get_type[] = { 0x00, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
        get_type[7] = dst_check_sum(get_type, 7);
        if (dst_command(state, get_type, 8) < 0) {
@@ -775,9 +927,17 @@ static int dst_card_type(struct dst_state *state)
                return -1;
        }
        memset(&state->card_info, '\0', 8);
-       memcpy(&state->card_info, &state->rxbuffer, 8);
+       memcpy(&state->card_info, &state->rxbuffer, 7);
        dprintk(verbose, DST_ERROR, 1, "Device Model=[%s]", &state->card_info[0]);
 
+       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",
+                               p_tuner_list->tuner_name, p_tuner_list->tuner_type);
+               }
+       }
+
        return 0;
 }
 
@@ -790,7 +950,7 @@ static int dst_get_vendor(struct dst_state *state)
                return -1;
        }
        memset(&state->vendor, '\0', 8);
-       memcpy(&state->vendor, &state->rxbuffer, 8);
+       memcpy(&state->vendor, &state->rxbuffer, 7);
        dprintk(verbose, DST_ERROR, 1, "Vendor=[%s]", &state->vendor[0]);
 
        return 0;
@@ -803,20 +963,25 @@ static int dst_get_tuner_info(struct dst_state *state)
 
        get_tuner_1[7] = dst_check_sum(get_tuner_1, 7);
        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) {
-                       dprintk(verbose, DST_INFO, 1, "Unsupported Command");
+//             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;
                }
        } else {
-               if (dst_command(state, get_tuner_1, 8) < 0) {
-                       dprintk(verbose, DST_INFO, 1, "Unsupported Command");
+//             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;
                }
        }
        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;
@@ -829,19 +994,26 @@ static int dst_get_tuner_info(struct dst_state *state)
                        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;
+*/
+       }
+       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;
-                       dprintk(verbose, DST_INFO, 1, "DST type has TS=188, Daughterboard=[%d]", state->board_info[1]);
+               else
+                       state->type_flags |= DST_TYPE_HAS_NEWTUNE_2;
 
-               } else if (state->board_info[0] == 0xcc) {
-                       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 Daughterboard=[%d]", state->board_info[1]);
-               }
+               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;
+               state->type_flags |= DST_TYPE_HAS_TS204;
+               dprintk(verbose, DST_INFO, 1, "DST type has TS=204 Daughterboard=[%d]", state->board_info[1]);
        }
+//     }
 
        return 0;
 }
@@ -850,8 +1022,10 @@ static int dst_get_device_id(struct dst_state *state)
 {
        u8 reply;
 
-       int i;
+       int i, j;
        struct dst_types *p_dst_type;
+       struct tuner_types *p_tuner_list;
+
        u8 use_dst_type = 0;
        u32 use_type_flags = 0;
 
@@ -890,6 +1064,16 @@ static int dst_get_device_id(struct dst_state *state)
                        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);
+                                       }
+                               }
+                       }
                        break;
                }
        }
@@ -910,16 +1094,16 @@ static int dst_get_device_id(struct dst_state *state)
 
 static int dst_probe(struct dst_state *state)
 {
-       sema_init(&state->dst_mutex, 1);
-       if ((rdc_8820_reset(state)) < 0) {
-               dprintk(verbose, DST_ERROR, 1, "RDC 8820 RESET Failed.");
-               return -1;
-       }
-       if (dst_addons & DST_TYPE_HAS_CA)
+       mutex_init(&state->dst_mutex);
+       if (dst_addons & DST_TYPE_HAS_CA) {
+               if ((rdc_8820_reset(state)) < 0) {
+                       dprintk(verbose, DST_ERROR, 1, "RDC 8820 RESET Failed.");
+                       return -1;
+               }
                msleep(4000);
-       else
+       } else {
                msleep(100);
-
+       }
        if ((dst_comm_init(state)) < 0) {
                dprintk(verbose, DST_ERROR, 1, "DST Initialization Failed.");
                return -1;
@@ -962,7 +1146,7 @@ int dst_command(struct dst_state *state, u8 *data, u8 len)
 {
        u8 reply;
 
-       down(&state->dst_mutex);
+       mutex_lock(&state->dst_mutex);
        if ((dst_comm_init(state)) < 0) {
                dprintk(verbose, DST_NOTICE, 1, "DST Communication Initialization Failed.");
                goto error;
@@ -1013,11 +1197,11 @@ int dst_command(struct dst_state *state, u8 *data, u8 len)
                dprintk(verbose, DST_INFO, 1, "checksum failure");
                goto error;
        }
-       up(&state->dst_mutex);
+       mutex_unlock(&state->dst_mutex);
        return 0;
 
 error:
-       up(&state->dst_mutex);
+       mutex_unlock(&state->dst_mutex);
        return -EIO;
 
 }
@@ -1048,6 +1232,10 @@ static int dst_get_signal(struct dst_state *state)
                        state->decode_lock = (state->rxbuffer[1]) ? 1 : 0;
                        state->decode_strength = state->rxbuffer[4] << 8;
                        state->decode_snr = state->rxbuffer[3] << 8;
+               } else if (state->dst_type == DST_TYPE_IS_ATSC) {
+                       state->decode_lock = (state->rxbuffer[6] == 0x00) ? 1 : 0;
+                       state->decode_strength = state->rxbuffer[4] << 8;
+                       state->decode_snr = state->rxbuffer[2] << 8 | state->rxbuffer[3];
                }
                state->cur_jiff = jiffies;
        }
@@ -1128,7 +1316,7 @@ static int dst_write_tuna(struct dvb_frontend *fe)
                        dst_set_voltage(fe, SEC_VOLTAGE_13);
        }
        state->diseq_flags &= ~(HAS_LOCK | ATTEMPT_TUNE);
-       down(&state->dst_mutex);
+       mutex_lock(&state->dst_mutex);
        if ((dst_comm_init(state)) < 0) {
                dprintk(verbose, DST_DEBUG, 1, "DST Communication initialization failed.");
                goto error;
@@ -1160,11 +1348,11 @@ static int dst_write_tuna(struct dvb_frontend *fe)
        state->diseq_flags |= ATTEMPT_TUNE;
        retval = dst_get_tuna(state);
 werr:
-       up(&state->dst_mutex);
+       mutex_unlock(&state->dst_mutex);
        return retval;
 
 error:
-       up(&state->dst_mutex);
+       mutex_unlock(&state->dst_mutex);
        return -EIO;
 }
 
@@ -1289,6 +1477,7 @@ static int dst_init(struct dvb_frontend *fe)
        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 atsc_tuner[] = { 0x00, 0x00, 0x03, 0xb6, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00 };
 
        state->inversion = INVERSION_OFF;
        state->voltage = SEC_VOLTAGE_13;
@@ -1303,6 +1492,8 @@ static int dst_init(struct dvb_frontend *fe)
                memcpy(state->tx_tuna, ((state->type_flags & DST_TYPE_HAS_NEWTUNE) ? 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));
+       else if (state->dst_type == DST_TYPE_IS_ATSC)
+               memcpy(state->tx_tuna, atsc_tuner, sizeof (atsc_tuner));
 
        return 0;
 }
@@ -1341,7 +1532,36 @@ static int dst_read_snr(struct dvb_frontend *fe, u16 *snr)
        return 0;
 }
 
-static int dst_set_frontend(struct dvb_frontend* fe,
+static int dst_set_frontend(struct dvb_frontend *fe, struct dvb_frontend_parameters *p)
+{
+       struct dst_state *state = fe->demodulator_priv;
+
+       if (p != NULL) {
+               dst_set_freq(state, p->frequency);
+               dprintk(verbose, DST_DEBUG, 1, "Set Frequency=[%d]", p->frequency);
+
+               if (state->dst_type == DST_TYPE_IS_SAT) {
+                       if (state->type_flags & DST_TYPE_HAS_OBS_REGS)
+                               dst_set_inversion(state, p->inversion);
+                       dst_set_fec(state, p->u.qpsk.fec_inner);
+                       dst_set_symbolrate(state, p->u.qpsk.symbol_rate);
+                       dst_set_polarization(state);
+                       dprintk(verbose, DST_DEBUG, 1, "Set Symbolrate=[%d]", p->u.qpsk.symbol_rate);
+
+               } else if (state->dst_type == DST_TYPE_IS_TERR)
+                       dst_set_bandwidth(state, p->u.ofdm.bandwidth);
+               else if (state->dst_type == DST_TYPE_IS_CABLE) {
+                       dst_set_fec(state, p->u.qam.fec_inner);
+                       dst_set_symbolrate(state, p->u.qam.symbol_rate);
+                       dst_set_modulation(state, p->u.qam.modulation);
+               }
+               dst_write_tuna(fe);
+       }
+
+       return 0;
+}
+
+static int dst_tune_frontend(struct dvb_frontend* fe,
                            struct dvb_frontend_parameters* p,
                            unsigned int mode_flags,
                            int *delay,
@@ -1378,6 +1598,11 @@ static int dst_set_frontend(struct dvb_frontend* fe,
        return 0;
 }
 
+static int dst_get_tuning_algo(struct dvb_frontend *fe)
+{
+       return dst_algo;
+}
+
 static int dst_get_frontend(struct dvb_frontend *fe, struct dvb_frontend_parameters *p)
 {
        struct dst_state *state = fe->demodulator_priv;
@@ -1408,6 +1633,7 @@ static void dst_release(struct dvb_frontend *fe)
 static struct dvb_frontend_ops dst_dvbt_ops;
 static struct dvb_frontend_ops dst_dvbs_ops;
 static struct dvb_frontend_ops dst_dvbc_ops;
+static struct dvb_frontend_ops dst_atsc_ops;
 
 struct dst_state *dst_attach(struct dst_state *state, struct dvb_adapter *dvb_adapter)
 {
@@ -1417,24 +1643,25 @@ struct dst_state *dst_attach(struct dst_state *state, struct dvb_adapter *dvb_ad
                return NULL;
        }
        /* determine settings based on type */
+       /* create dvb_frontend */
        switch (state->dst_type) {
        case DST_TYPE_IS_TERR:
-               memcpy(&state->ops, &dst_dvbt_ops, sizeof(struct dvb_frontend_ops));
+               memcpy(&state->frontend.ops, &dst_dvbt_ops, sizeof(struct dvb_frontend_ops));
                break;
        case DST_TYPE_IS_CABLE:
-               memcpy(&state->ops, &dst_dvbc_ops, sizeof(struct dvb_frontend_ops));
+               memcpy(&state->frontend.ops, &dst_dvbc_ops, sizeof(struct dvb_frontend_ops));
                break;
        case DST_TYPE_IS_SAT:
-               memcpy(&state->ops, &dst_dvbs_ops, sizeof(struct dvb_frontend_ops));
+               memcpy(&state->frontend.ops, &dst_dvbs_ops, sizeof(struct dvb_frontend_ops));
+               break;
+       case DST_TYPE_IS_ATSC:
+               memcpy(&state->frontend.ops, &dst_atsc_ops, sizeof(struct dvb_frontend_ops));
                break;
        default:
                dprintk(verbose, DST_ERROR, 1, "unknown DST type. please report to the LinuxTV.org DVB mailinglist.");
                kfree(state);
                return NULL;
        }
-
-       /* create dvb_frontend */
-       state->frontend.ops = &state->ops;
        state->frontend.demodulator_priv = state;
 
        return state;                           /*      Manu (DST is a card not a frontend)     */
@@ -1455,8 +1682,10 @@ static struct dvb_frontend_ops dst_dvbt_ops = {
 
        .release = dst_release,
        .init = dst_init,
-       .tune = dst_set_frontend,
+       .tune = dst_tune_frontend,
+       .set_frontend = dst_set_frontend,
        .get_frontend = dst_get_frontend,
+       .get_frontend_algo = dst_get_tuning_algo,
        .read_status = dst_read_status,
        .read_signal_strength = dst_read_signal_strength,
        .read_snr = dst_read_snr,
@@ -1479,8 +1708,10 @@ static struct dvb_frontend_ops dst_dvbs_ops = {
 
        .release = dst_release,
        .init = dst_init,
-       .tune = dst_set_frontend,
+       .tune = dst_tune_frontend,
+       .set_frontend = dst_set_frontend,
        .get_frontend = dst_get_frontend,
+       .get_frontend_algo = dst_get_tuning_algo,
        .read_status = dst_read_status,
        .read_signal_strength = dst_read_signal_strength,
        .read_snr = dst_read_snr,
@@ -1506,13 +1737,38 @@ static struct dvb_frontend_ops dst_dvbc_ops = {
 
        .release = dst_release,
        .init = dst_init,
-       .tune = dst_set_frontend,
+       .tune = dst_tune_frontend,
+       .set_frontend = dst_set_frontend,
+       .get_frontend = dst_get_frontend,
+       .get_frontend_algo = dst_get_tuning_algo,
+       .read_status = dst_read_status,
+       .read_signal_strength = dst_read_signal_strength,
+       .read_snr = dst_read_snr,
+};
+
+static struct dvb_frontend_ops dst_atsc_ops = {
+       .info = {
+               .name = "DST ATSC",
+               .type = FE_ATSC,
+               .frequency_stepsize = 62500,
+               .frequency_min = 510000000,
+               .frequency_max = 858000000,
+               .symbol_rate_min = 1000000,
+               .symbol_rate_max = 45000000,
+               .caps = FE_CAN_FEC_AUTO | FE_CAN_QAM_AUTO | FE_CAN_QAM_64 | FE_CAN_QAM_256 | FE_CAN_8VSB
+       },
+
+       .release = dst_release,
+       .init = dst_init,
+       .tune = dst_tune_frontend,
+       .set_frontend = dst_set_frontend,
        .get_frontend = dst_get_frontend,
+       .get_frontend_algo = dst_get_tuning_algo,
        .read_status = dst_read_status,
        .read_signal_strength = dst_read_signal_strength,
        .read_snr = dst_read_snr,
 };
 
-MODULE_DESCRIPTION("DST DVB-S/T/C Combo Frontend driver");
+MODULE_DESCRIPTION("DST DVB-S/T/C/ATSC Combo Frontend driver");
 MODULE_AUTHOR("Jamie Honan, Manu Abraham");
 MODULE_LICENSE("GPL");