Ticket #973: 5-mythtv_multilnb_positioner_rev2.diff

File 5-mythtv_multilnb_positioner_rev2.diff, 31.3 KB (added by zdzisekg@…, 18 years ago)
  • libs/libmythtv/dvbdiseqc.cpp

    diff -Naur mythtv/libs/libmythtv/dvbdiseqc.cpp mythtv-diseqc/libs/libmythtv/dvbdiseqc.cpp
    old new  
    1313 *          - DiSEqC 1.0 - 1.1.
    1414 *      Kenneth Aafloy (ke-aa at frisurf.no)
    1515 *          - Initial framework.
     16 *      Zdzislaw Gorlicki (zdzisekg at yahoo.com
     17 *          - DiSEqC 1.2/1.3 + switch
    1618 *
    1719 *   This program is free software; you can redistribute it and/or modify
    1820 *   it under the terms of the GNU General Public License as published by
     
    8486            break;
    8587        case 6: // 1.2 Positioner (HH Motor)
    8688            if (!PositionerGoto(tuning,reset,havetuned))
    87                 return false;
     89                return false;
    8890            break;
    8991        case 7: // 1.3 Positioner (HH Motor with USALS)
    9092            if (!PositionerGotoAngular(tuning,reset,havetuned))
    91                 return false;
     93                return false;
    9294            break;
    9395        case 8: // v1.1 10 Way
    9496            if (!Diseqc1xSwitch(tuning, reset, havetuned, 10))
    9597                return false;
    9698            break;
    97  
     99        case 10: // 1.2 Positioner (HH Motor with a switch behind it)
     100            if (!PositionerGoto(tuning,reset,havetuned))
     101                return false;
     102            break;
     103        case 11: // 1.3 Positioner (HH Motor with USALS and with a switch behind it)
     104            if (!PositionerGotoAngular(tuning, reset, havetuned))
     105                return false;
     106            break;
    98107        default:
    99108            VERBOSE(VB_IMPORTANT, LOC_ERR + "Unsupported DiSEqC type("
    100109                    <<tuning.diseqc_type<<")");
    101110    }
    102    
     111
    103112    return true;
    104113}
    105114
     
    156165            VERBOSE(VB_IMPORTANT, LOC_ERR +
    157166                    "Tone Switches only support two ports.");
    158167
     168        // I think SEC_MINI_A is 0 in DB so we should compare against that. right?
    159169        if (ioctl(fd_frontend, FE_DISEQC_SEND_BURST,
    160                   (tuning.diseqc_port == 1 ? SEC_MINI_A : SEC_MINI_B )) < 0)
     170                  (tuning.diseqc_port == 0 ? SEC_MINI_A : SEC_MINI_B )) < 0)
    161171        {
    162172            VERBOSE(VB_IMPORTANT, LOC_ERR +
    163173                    "Setting Tone Switch failed." + ENO);
     
    175185/*****************************************************************************
    176186                    Diseqc 1.x Compatible Methods
    177187 ****************************************************************************/
     188bool DVBDiSEqC::DiseqcReset()
     189{
     190    struct dvb_diseqc_master_cmd reset_cmd =
     191        {{CMD_FIRST, MASTER_TO_LSS, RESET, 0x00, 0x00}, 3};
     192 
     193    struct dvb_diseqc_master_cmd init_cmd =
     194        {{CMD_FIRST, MASTER_TO_LSS, POWERON, 0x00, 0x00}, 3};
    178195
    179 bool DVBDiSEqC::SendDiSEqCMessage(DVBTuning& tuning, dvb_diseqc_master_cmd &cmd)
     196    if (ioctl(fd_frontend, FE_DISEQC_SEND_MASTER_CMD, &init_cmd) <0)
     197    {
     198        VERBOSE(VB_IMPORTANT, LOC_ERR +
     199                "Setup: Sending init command failed." + ENO);
     200        return false;
     201    }
     202    usleep(DISEQC_LONG_WAIT);
     203
     204    if (ioctl(fd_frontend, FE_DISEQC_SEND_MASTER_CMD, &reset_cmd) <0)
     205    {
     206        VERBOSE(VB_IMPORTANT, LOC_ERR +
     207                "Setup: Sending reset command failed." + ENO);
     208        return false;
     209    }
     210    usleep(DISEQC_LONG_WAIT);
     211
     212    if (ioctl(fd_frontend, FE_DISEQC_SEND_MASTER_CMD, &init_cmd) <0)
     213    {
     214        VERBOSE(VB_IMPORTANT, LOC_ERR +
     215                "Setup: Sending init command failed." + ENO);
     216        return false;
     217    }
     218    usleep(DISEQC_LONG_WAIT);
     219
     220    return true;
     221}
     222
     223
     224bool DVBDiSEqC::SendDiSEqCPrepareBus(DVBTuning& tuning, bool reset)
    180225{
    181     // Turn off tone burst
    182     if (ioctl(fd_frontend, FE_SET_TONE, SEC_TONE_OFF) == -1)
     226    // Reset "visible" DiSEqC switches or LNBs
     227    if (reset)
     228    {
     229        if (!DiseqcReset())
     230        {
     231            VERBOSE(VB_IMPORTANT, LOC_ERR + "DiseqcReset() failed");
     232            return false;
     233        }
     234    }
     235
     236    // Turn off Continuous tone
     237    if (ioctl(fd_frontend, FE_SET_TONE, SEC_TONE_OFF) == -1)
    183238    {
    184239        VERBOSE(VB_IMPORTANT, LOC_ERR + "FE_SET_TONE failed" + ENO);
    185240        return false;
    186241    }
     242    else
     243    {
     244        VERBOSE(VB_CHANNEL, LOC + QString("DiSEqC -> Continuous Tone set to: OFF"));
     245    }
    187246
    188 /*
    189    Old version of the code set the voltage to 13V everytime.
    190    After looking at the EutelSat specs I saw no reason that
    191    this was done. I have tested this with my DiSEqC switch
    192    and all is fine.
    193 */
    194 
    195     if (ioctl(fd_frontend, FE_SET_VOLTAGE, tuning.voltage) == -1)
     247    //  Set Voltage
     248    if (ioctl(fd_frontend, FE_SET_VOLTAGE, tuning.voltage) == -1)
    196249    {
    197250        VERBOSE(VB_IMPORTANT, LOC_ERR + "FE_SET_VOLTAGE failed" + ENO);
    198251        return false;
    199     }   
     252    }
     253    else
     254    {
     255        VERBOSE(VB_CHANNEL, LOC + QString("DiSEqC -> Voltage set to: %1")
     256                .arg(tuning.voltage==SEC_VOLTAGE_13?"13V":"18V"));
     257    }
    200258
    201     usleep(DISEQC_SHORT_WAIT);
     259    return true;
     260}
    202261
    203     VERBOSE(VB_CHANNEL, LOC + QString("Sending 1.0 Command: %1 %2 %3 %4")
    204             .arg(cmd.msg[0], 2, 16)
    205             .arg(cmd.msg[1], 2, 16)
    206             .arg(cmd.msg[2], 2, 16)
    207             .arg(cmd.msg[3], 2, 16));
     262
     263bool DVBDiSEqC::SendDiSEqCMessage(DVBTuning& tuning, dvb_diseqc_master_cmd &cmd)
     264{
     265    // Send the DiSEqC command
     266    usleep(DISEQC_SHORT_WAIT);
    208267
    209268    if (ioctl(fd_frontend, FE_DISEQC_SEND_MASTER_CMD, &cmd) == -1)
    210269    {
     
    212271                "FE_DISEQC_SEND_MASTER_CMD failed" + ENO);
    213272        return false;
    214273    }
     274    else
     275    {
     276        if ((tuning.diseqc_type == 7) || (tuning.diseqc_type == 11))
     277        {
     278        VERBOSE(VB_CHANNEL, LOC + QString("DiSEqC -> Sent 1.3 Command: %1 %2 %3 %4 %5")
     279                .arg(cmd.msg[FRAME], 2, 16)
     280                .arg(cmd.msg[ADDRESS], 2, 16)
     281                .arg(cmd.msg[COMMAND], 2, 16)
     282                .arg(cmd.msg[DATA_1], 2, 16)
     283                .arg(cmd.msg[DATA_2], 2, 16));
     284        }
     285        else
     286        {
     287        VERBOSE(VB_CHANNEL, LOC + QString("DiSEqC -> Sent 1.0 Command: %1 %2 %3 %4")
     288                .arg(cmd.msg[FRAME], 2, 16)
     289                .arg(cmd.msg[ADDRESS], 2, 16)
     290                .arg(cmd.msg[COMMAND], 2, 16)
     291                .arg(cmd.msg[DATA_1], 2, 16));
     292        }
     293    }
    215294
    216     usleep(DISEQC_SHORT_WAIT);
    217 
    218     // Check to see if its a 1.1 or 1.2 device. If so repeat the message repeats times.
     295    // Check to see if its a 1.1, 1.2 or 1.3 device. If so repeat the message repeats times.
    219296    if ((tuning.diseqc_type == 3) || (tuning.diseqc_type == 5) ||
    220         (tuning.diseqc_type == 6) || (tuning.diseqc_type == 7))
     297        (tuning.diseqc_type == 6) || (tuning.diseqc_type == 7) ||
     298        (tuning.diseqc_type == 10) || (tuning.diseqc_type == 11))
    221299    {
     300        int repeats;
     301        if((tuning.diseqc_type == 10) || (tuning.diseqc_type == 11))
     302        {
     303            repeats = repeat + 1;
     304        }
     305        else
     306        {
     307            repeats = repeat;
     308        }
    222309
    223         int repeats = repeat;
    224310        while (repeats--)
    225311        {
    226 
    227             if (tuning.diseqc_type == 7)
    228             {
    229                 VERBOSE(VB_CHANNEL, LOC +
    230                         QString("Sending 1.3 Repeat Command: %1 %2 %3 %4 %5")
    231                         .arg(cmd.msg[0],2,16)
    232                         .arg(cmd.msg[1],2,16)
    233                         .arg(cmd.msg[2],2,16)
    234                         .arg(cmd.msg[3],2,16)
    235                         .arg(cmd.msg[4],2,16));
    236             }
    237             else
    238             {
    239                 VERBOSE(VB_CHANNEL, LOC +
    240                         QString("Sending 1.1/1.2 Repeat Command: %1 %2 %3 %4")
    241                         .arg(cmd.msg[0],2,16)
    242                         .arg(cmd.msg[1],2,16)
    243                         .arg(cmd.msg[2],2,16)
    244                         .arg(cmd.msg[3],2,16));
    245             }
    246 
    247             cmd.msg[0] = CMD_REPEAT;     
     312            usleep(DISEQC_SHORT_WAIT);
     313            cmd.msg[FRAME] = CMD_REPEAT;
    248314            if (ioctl(fd_frontend, FE_DISEQC_SEND_MASTER_CMD, &cmd) == -1)
    249315            {
    250316                VERBOSE(VB_IMPORTANT, LOC_ERR +
    251317                        "FE_DISEQC_SEND_MASTER_CMD failed" + ENO);
    252318                return false;
    253319            }
    254             usleep(DISEQC_SHORT_WAIT);
    255      
    256             cmd.msg[0] = CMD_FIRST;     
    257             if (ioctl(fd_frontend, FE_DISEQC_SEND_MASTER_CMD, &cmd) == -1)
     320            else
    258321            {
    259                 VERBOSE(VB_IMPORTANT, LOC_ERR +
    260                         "FE_DISEQC_SEND_MASTER_CMD failed" + ENO);
    261                 return false;
     322                if ((tuning.diseqc_type == 7) || (tuning.diseqc_type == 11))
     323                {
     324                    VERBOSE(VB_CHANNEL, LOC + QString("DiSEqC -> Sent 1.3 Repeat Command: %1 %2 %3 %4 %5")
     325                            .arg(cmd.msg[FRAME], 2, 16)
     326                            .arg(cmd.msg[ADDRESS], 2, 16)
     327                            .arg(cmd.msg[COMMAND], 2, 16)
     328                            .arg(cmd.msg[DATA_1], 2, 16)
     329                            .arg(cmd.msg[DATA_2], 2, 16));
     330                }
     331                else
     332                {
     333                    VERBOSE(VB_CHANNEL, LOC + QString("DiSEqC -> Sent 1.0 Repeat Command: %1 %2 %3 %4")
     334                            .arg(cmd.msg[FRAME], 2, 16)
     335                            .arg(cmd.msg[ADDRESS], 2, 16)
     336                            .arg(cmd.msg[COMMAND], 2, 16)
     337                            .arg(cmd.msg[DATA_1], 2, 16));
     338                }
    262339            }
    263             usleep(DISEQC_SHORT_WAIT);
    264340        }
    265341    }
    266342
    267     if (ioctl(fd_frontend, FE_DISEQC_SEND_BURST, SEC_MINI_A ) == -1)
    268     {
    269         VERBOSE(VB_IMPORTANT, LOC_ERR +
    270                 "FE_DISEQC_SEND_BURST failed" + ENO);
    271         return false;
    272     }
    273 
    274343    usleep(DISEQC_SHORT_WAIT);
    275344
    276     if (ioctl(fd_frontend, FE_SET_TONE, tuning.tone) == -1)
    277     {
    278         VERBOSE(VB_IMPORTANT, LOC_ERR + "FE_SET_TONE failed" + ENO);
    279         return false;
    280     }
    281 
    282345    return true;
    283346}
    284347
    285348
    286 bool DVBDiSEqC::SendDiSEqCMessage(dvb_diseqc_master_cmd &cmd)
     349bool DVBDiSEqC::SendDiSEqCSetupBus(DVBTuning& tuning)
    287350{
    288     // Turn off tone burst
    289     if (ioctl(fd_frontend, FE_SET_TONE, SEC_TONE_OFF) == -1)
     351    //Determin the Tone Burst for switches with more then 2 ports and send it
     352    //This one I had hard time figuring out from the specs at eutelsat
     353    //I guess the tone burst can be interpreted differently for different setups
     354    //but in our case (with pure diseqc) it may only affect the LNB
     355    if (ioctl(fd_frontend, FE_DISEQC_SEND_BURST,
     356              ((tuning.diseqc_port % 2) == 0 ? SEC_MINI_A : SEC_MINI_B )) < 0)
    290357    {
    291         VERBOSE(VB_IMPORTANT, LOC_ERR + "FE_SET_TONE failed" + ENO);
     358        VERBOSE(VB_IMPORTANT, LOC_ERR +
     359                "FE_DISEQC_SEND_BURST failed" + ENO);
    292360        return false;
    293361    }
    294 
    295     usleep(DISEQC_SHORT_WAIT);
    296 
    297     VERBOSE(VB_CHANNEL, LOC + QString("Sending 1.0 Command: %1 %2 %3 %4")
    298             .arg(cmd.msg[0], 2, 16)
    299             .arg(cmd.msg[1], 2, 16)
    300             .arg(cmd.msg[2], 2, 16)
    301             .arg(cmd.msg[3], 2, 16));
    302 
    303     if (ioctl(fd_frontend, FE_DISEQC_SEND_MASTER_CMD, &cmd) == -1)
     362    else
    304363    {
    305         VERBOSE(VB_IMPORTANT, LOC_ERR +
    306                 "FE_DISEQC_SEND_MASTER_CMD failed" + ENO);
    307         return false;
     364        VERBOSE(VB_CHANNEL, LOC + QString("DiSEqC -> Tone Burst set to: %1")
     365                .arg((tuning.diseqc_port % 2) == 0 ? "A" : "B"));
    308366    }
    309367
    310368    usleep(DISEQC_SHORT_WAIT);
    311  
    312     int repeats = repeat;
    313     while (repeats--)
    314     {
    315         VERBOSE(VB_CHANNEL, LOC +
    316                 QString("Sending 1.1/1.2/1.3 Repeat Command: %1 %2 %3 %4")
    317                 .arg(cmd.msg[0], 2, 16)
    318                 .arg(cmd.msg[1], 2, 16)
    319                 .arg(cmd.msg[2], 2, 16)
    320                 .arg(cmd.msg[3], 2, 16));
    321369
    322         cmd.msg[0] = CMD_REPEAT;     
    323         if (ioctl(fd_frontend, FE_DISEQC_SEND_MASTER_CMD, &cmd) == -1)
    324         {
    325             VERBOSE(VB_IMPORTANT, LOC_ERR +
    326                     "FE_DISEQC_SEND_MASTER_CMD failed" + ENO);
    327             return false;
    328         }
    329         usleep(DISEQC_SHORT_WAIT);
    330    
    331         cmd.msg[0] = CMD_FIRST;     
    332         if (ioctl(fd_frontend, FE_DISEQC_SEND_MASTER_CMD, &cmd) == -1)
    333         {
    334             VERBOSE(VB_IMPORTANT, LOC_ERR +
    335                     "FE_DISEQC_SEND_MASTER_CMD failed" + ENO);
    336             return false;
    337         }
    338         usleep(DISEQC_SHORT_WAIT);
    339     }
    340 
    341     if (ioctl(fd_frontend, FE_DISEQC_SEND_BURST, SEC_MINI_A ) == -1)
     370    //finally, set the continuous tone
     371    if (ioctl(fd_frontend, FE_SET_TONE, tuning.tone) == -1)
    342372    {
    343         VERBOSE(VB_IMPORTANT, LOC_ERR + "FE_DISEQC_SEND_BURST failed" + ENO);
     373        VERBOSE(VB_IMPORTANT, LOC_ERR + "FE_SET_TONE failed" + ENO);
    344374        return false;
    345375    }
     376    else
     377    {
     378        VERBOSE(VB_CHANNEL, LOC + QString("DiSEqC -> Continuous Tone set to: %1")
     379                .arg(tuning.tone == 0 ? "OFF" : "ON"));
     380    }
    346381
    347382    return true;
    348383}
    349384
     385
    350386bool DVBDiSEqC::Diseqc1xSwitch(DVBTuning& tuning, bool reset,
    351387                               bool& havetuned, uint ports)
    352388{
    353     if (reset)
    354     {
    355         if (!DiseqcReset())
    356         {
    357             VERBOSE(VB_IMPORTANT, LOC_ERR + "DiseqcReset() failed");
    358             return false;
    359         }
    360     }
    361 
    362     VERBOSE(VB_CHANNEL, LOC +
    363             QString("1.1 Switch (%1 ports) - Port %2 - %3 %4")
    364             .arg(ports)
    365             .arg(tuning.diseqc_port)
    366             .arg(tuning.tone==SEC_TONE_ON?"Tone ON":"Tone OFF")
    367             .arg(tuning.voltage==SEC_VOLTAGE_13?"13V":"18V"));
    368 
    369389    if ((prev_tuning.diseqc_port != tuning.diseqc_port  ||
    370390         prev_tuning.tone != tuning.tone                ||
    371391         prev_tuning.voltage != tuning.voltage        ) || reset)
     
    399418                        "Unsupported number of ports for DiSEqC 1.1 Switch");
    400419        }
    401420
     421        if (!SendDiSEqCPrepareBus(tuning, reset))
     422        {
     423            VERBOSE(VB_IMPORTANT, LOC_ERR + "Setting DiSEqC failed -> Segment I");
     424            return false;
     425        }
     426
    402427        if (!SendDiSEqCMessage(tuning,cmd))
    403428        {
    404             VERBOSE(VB_IMPORTANT, LOC_ERR + "Setting DiSEqC failed.");
     429            VERBOSE(VB_IMPORTANT, LOC_ERR + "Setting DiSEqC failed. -> Segment II");
     430            return false;
     431        }
     432
     433        if (!SendDiSEqCSetupBus(tuning))
     434        {
     435            VERBOSE(VB_IMPORTANT, LOC_ERR + "Setting DiSEqC failed -> Segment III");
    405436            return false;
    406437        }
    407438
     
    420451    return true;
    421452}
    422453
    423 bool DVBDiSEqC::DiseqcReset()
    424 {
    425     struct dvb_diseqc_master_cmd reset_cmd =
    426         {{CMD_FIRST, MASTER_TO_LSS, RESET, 0x00, 0x00}, 3};
    427  
    428     struct dvb_diseqc_master_cmd init_cmd =
    429         {{CMD_FIRST, MASTER_TO_LSS, POWERON, 0x00, 0x00}, 3};
    430 
    431     if (ioctl(fd_frontend, FE_DISEQC_SEND_MASTER_CMD, &init_cmd) <0)
    432     {
    433         VERBOSE(VB_IMPORTANT, LOC_ERR +
    434                 "Setup: Sending init command failed." + ENO);
    435         return false;
    436     }
    437     usleep(DISEQC_LONG_WAIT);
    438 
    439     if (ioctl(fd_frontend, FE_DISEQC_SEND_MASTER_CMD, &reset_cmd) <0)
    440     {
    441         VERBOSE(VB_IMPORTANT, LOC_ERR +
    442                 "Setup: Sending reset command failed." + ENO);
    443         return false;
    444     }
    445     usleep(DISEQC_LONG_WAIT);
    446 
    447     if (ioctl(fd_frontend, FE_DISEQC_SEND_MASTER_CMD, &init_cmd) <0)
    448     {
    449         VERBOSE(VB_IMPORTANT, LOC_ERR +
    450                 "Setup: Sending init command failed." + ENO);
    451         return false;
    452     }
    453     usleep(DISEQC_LONG_WAIT);
    454 
    455     return true;
    456 }
    457454
    458455/*****************************************************************************
    459456                            Positioner Control
    460457 *****************************************************************************/
    461 
     458/*
     459// Currently not used so not needed, also will need to be modified
     460// to be used with current way of sending DiSEqC messages
    462461bool DVBDiSEqC::PositionerDriveEast(int timestep)
    463462{
    464463    if (!DiseqcReset())
     
    475474        VERBOSE(VB_IMPORTANT, LOC_ERR + "Setting DiSEqC failed.");
    476475        return false;
    477476    }
    478    
     477
    479478    return true;
    480479}
    481480
     
    499498    return true;
    500499}
    501500
    502 bool DVBDiSEqC::PositionerGoto(DVBTuning& tuning, bool reset, bool& havetuned)
    503 {
    504     // A reset seems to be required for my positioner to work consistently
    505     VERBOSE(VB_CHANNEL, LOC + QString("1.2 Motor - Goto Stored Position %1")
    506             .arg(tuning.diseqc_port));
    507 
    508     if ((prev_tuning.diseqc_port != tuning.diseqc_port ||
    509          prev_tuning.tone != tuning.tone ||
    510          prev_tuning.voltage != tuning.voltage) || reset)
    511     {
    512         if (!DiseqcReset())
    513         {
    514             VERBOSE(VB_IMPORTANT, LOC_ERR + "DiseqcReset() failed");
    515             return false;
    516         }
    517        
    518         dvb_diseqc_master_cmd cmd =
    519             {{CMD_FIRST, MASTER_TO_POSITIONER, GOTO, tuning.diseqc_port,
    520               0x00, 0x00}, 4};
    521 
    522         if (!SendDiSEqCMessage(tuning,cmd))
    523         {
    524             VERBOSE(VB_IMPORTANT, LOC_ERR + "Setting DiSEqC failed.");
    525             return false;
    526         }
    527 
    528         prev_tuning.diseqc_port = tuning.diseqc_port;
    529         prev_tuning.tone = tuning.tone;
    530         prev_tuning.voltage = tuning.voltage;
    531     }
    532 
    533     havetuned |=
    534         (prev_tuning.diseqc_port == tuning.diseqc_port) &&
    535         (prev_tuning.voltage     == tuning.voltage)     &&
    536         (prev_tuning.tone        == tuning.tone);
    537 
    538     return true;
    539 }
    540 
    541501bool DVBDiSEqC::PositionerStore(DVBTuning& tuning)
    542502{
    543503    if (!DiseqcReset())
     
    649609
    650610    return true;
    651611}
     612*/
    652613
    653614/*****************************************************************************
    654                                 Diseqc v1.3 (Goto X)
     615                             Diseqc Psitioner v1.2
     616 ****************************************************************************/
     617bool DVBDiSEqC::PositionerGoto(DVBTuning& tuning, bool reset, bool& havetuned)
     618{
     619    if ((prev_tuning.diseqc_port != tuning.diseqc_port  ||
     620         prev_tuning.tone        != tuning.tone         ||
     621         prev_tuning.diseqc_pos  != tuning.diseqc_pos   ||
     622         prev_tuning.voltage     != tuning.voltage    ) || reset)
     623    {
     624        dvb_diseqc_master_cmd cmd_1 =
     625            {{CMD_FIRST, MASTER_TO_POSITIONER, GOTO, tuning.diseqc_pos,
     626              0x00, 0x00}, 4};
     627
     628        VERBOSE(VB_CHANNEL, LOC + QString("DiSEqC -> Goto Stored Position %1")
     629                .arg(tuning.diseqc_pos));
     630
     631        if (!SendDiSEqCPrepareBus(tuning, reset))
     632        {
     633            VERBOSE(VB_IMPORTANT, LOC_ERR + "Setting DiSEqC failed -> Segment I");
     634            return false;
     635        }
     636
     637        if (!SendDiSEqCMessage(tuning,cmd_1))
     638        {
     639            VERBOSE(VB_IMPORTANT, LOC_ERR + "Setting DiSEqC failed. -> Segment II");
     640            return false;
     641        }
     642
     643        if (tuning.diseqc_type == 10)
     644        {
     645            dvb_diseqc_master_cmd cmd_2 =
     646                {{CMD_FIRST, MASTER_TO_LSS, WRITE_N0, 0xf0, 0x00, 0x00}, 4};
     647
     648            cmd_2.msg[DATA_1] =
     649                0xF0 |
     650                (((tuning.diseqc_port) * 4) & 0x0F)          |
     651                ((tuning.voltage == SEC_VOLTAGE_18) ? 2 : 0) |
     652                ((tuning.tone == SEC_TONE_ON) ? 1 : 0);
     653
     654            if (!SendDiSEqCMessage(tuning,cmd_2))
     655            {
     656                VERBOSE(VB_IMPORTANT, LOC_ERR + "Setting DiSEqC failed. -> Segment II");
     657                return false;
     658            }
     659        }
     660
     661        if (!SendDiSEqCSetupBus(tuning))
     662        {
     663            VERBOSE(VB_IMPORTANT, LOC_ERR + "Setting DiSEqC failed -> Segment III");
     664            return false;
     665        }
     666
     667        prev_tuning.diseqc_port = tuning.diseqc_port;
     668        prev_tuning.diseqc_pos = tuning.diseqc_pos;
     669        prev_tuning.tone = tuning.tone;
     670        prev_tuning.voltage = tuning.voltage;
     671    }
     672
     673    havetuned |=
     674        (prev_tuning.diseqc_port == tuning.diseqc_port) &&
     675        (prev_tuning.diseqc_pos  == tuning.diseqc_pos)  &&
     676        (prev_tuning.voltage     == tuning.voltage)     &&
     677        (prev_tuning.tone        == tuning.tone);
     678
     679    return true;
     680}
     681
     682
     683/*****************************************************************************
     684                                Diseqc Positioner v1.3 (Goto X)
    655685 ****************************************************************************/
    656686
    657687bool DVBDiSEqC::PositionerGotoAngular(DVBTuning& tuning, bool reset,
    658688                                      bool& havetuned)
    659689{
     690/*
    660691    // TODO: Send information here to FE saying motor is moving and
    661692    //       to expect a longer than average tuning delay
    662693    if (prev_tuning.diseqc_pos != tuning.diseqc_pos)
    663694        VERBOSE(VB_CHANNEL, LOC + "DiSEqC Motor Moving");
     695*/
    664696
    665697    int CMD1=0x00 , CMD2=0x00;        // Bytes sent to motor
    666698    double USALS=0.0;
     
    679711    double el = atan( (cos(x) - 0.1513 ) /sin(x) );
    680712    double Azimuth = atan((-cos(el)*sin(az))/(sin(el)*cos(P)-cos(el)*sin(P)*cos(az)))* TO_DEC;
    681713
    682 //    printf("Offset = %f\n",Azimuth);
    683 
    684714    if (Azimuth > 0.0)
    685715        CMD1=0xE0;    // East
    686716    else
    687717        CMD1=0xD0;      // West
    688718
    689719    USALS = fabs(Azimuth);
    690  
     720
    691721    while (USALS > 16)
    692722    {
    693723        CMD1++;
    694         USALS -=16;
     724        USALS -=16;
    695725    }
    696726
    697727    while (USALS >= 1.0)
    698728    {
    699         CMD2+=0x10;
     729        CMD2+=0x10;
    700730        USALS--;
    701731    }
    702732
    703733    CMD2 += DecimalLookup[(int)round(USALS*10)];
    704  
    705     if (!DiseqcReset())
    706     {
    707         VERBOSE(VB_IMPORTANT, LOC_ERR + "DiseqcReset() failed");
    708         return false;
    709     }
    710734
    711735    // required db changes - get lat and lon for ground station location in db
    712736    // and added to tuning
    713737    // sat_pos be passed into tuning, and be a float not an int./
    714738
    715     VERBOSE(VB_CHANNEL, LOC + QString("1.3 Motor - Goto Angular Position %1")
    716             .arg(tuning.diseqc_pos));
    717 
    718739    if ((prev_tuning.diseqc_port != tuning.diseqc_port  ||
    719740         prev_tuning.tone        != tuning.tone         ||
    720741         prev_tuning.diseqc_pos  != tuning.diseqc_pos   ||
    721742         prev_tuning.voltage     != tuning.voltage    ) || reset)
    722743    {
    723 
    724         dvb_diseqc_master_cmd cmd =
     744        dvb_diseqc_master_cmd cmd_1 =
    725745            {{CMD_FIRST, MASTER_TO_POSITIONER, GOTO_ANGULAR, CMD1 , CMD2 ,
    726746              0x00}, 5};
    727747
    728         if (!SendDiSEqCMessage(tuning,cmd))
     748        VERBOSE(VB_CHANNEL, LOC + QString("DiSEqC -> Goto Angular Position %1")
     749                .arg(tuning.diseqc_pos));
     750
     751        if (!SendDiSEqCPrepareBus(tuning, reset))
    729752        {
    730             VERBOSE(VB_IMPORTANT, LOC_ERR + "Setting DiSEqC failed.");
     753            VERBOSE(VB_IMPORTANT, LOC_ERR + "Setting DiSEqC failed -> Segment I");
     754            return false;
     755        }
     756
     757        if (!SendDiSEqCMessage(tuning,cmd_1))
     758        {
     759            VERBOSE(VB_IMPORTANT, LOC_ERR + "Setting DiSEqC failed. -> Segment II");
     760            return false;
     761        }
     762
     763        if (tuning.diseqc_type == 11)
     764        {
     765            dvb_diseqc_master_cmd cmd_2 =
     766                {{CMD_FIRST, MASTER_TO_LSS, WRITE_N0, 0xf0, 0x00, 0x00}, 4};
     767
     768            cmd_2.msg[DATA_1] =
     769                0xF0 |
     770                (((tuning.diseqc_port) * 4) & 0x0F)          |
     771                ((tuning.voltage == SEC_VOLTAGE_18) ? 2 : 0) |
     772                ((tuning.tone == SEC_TONE_ON) ? 1 : 0);
     773
     774            if (!SendDiSEqCMessage(tuning,cmd_2))
     775            {
     776                VERBOSE(VB_IMPORTANT, LOC_ERR + "Setting DiSEqC failed. -> Segment II");
     777                return false;
     778            }
     779        }
     780
     781        if (!SendDiSEqCSetupBus(tuning))
     782        {
     783            VERBOSE(VB_IMPORTANT, LOC_ERR + "Setting DiSEqC failed -> Segment III");
    731784            return false;
    732785        }
    733786
     
    744797        (prev_tuning.tone        == tuning.tone);
    745798
    746799    return true;
    747 }
     800}
     801 No newline at end of file
  • libs/libmythtv/dvbdiseqc.h

    diff -Naur mythtv/libs/libmythtv/dvbdiseqc.h mythtv-diseqc/libs/libmythtv/dvbdiseqc.h
    old new  
    3131    DVBTuning prev_tuning;
    3232    int repeat;
    3333
    34    
    35     bool SendDiSEqCMessage(DVBTuning& tuning, dvb_diseqc_master_cmd &cmd);
    36     bool SendDiSEqCMessage(dvb_diseqc_master_cmd &cmd);
    37    
    3834    bool ToneVoltageLnb(DVBTuning& tuning, bool reset, bool& havetuned);
    3935    bool ToneSwitch(DVBTuning& tuning, bool reset, bool& havetuned);
     36
     37    bool SendDiSEqCPrepareBus(DVBTuning& tuning, bool reset);
     38    bool SendDiSEqCMessage(DVBTuning& tuning, dvb_diseqc_master_cmd &cmd);
     39    bool SendDiSEqCSetupBus(DVBTuning& tuning);
     40
    4041    bool Diseqc1xSwitch(DVBTuning& tuning, bool reset, bool& havetuned,
    4142                        uint ports);
    4243    bool PositionerGoto(DVBTuning& tuning, bool reset, bool& havetuned);
     44    bool PositionerGotoAngular(DVBTuning& tuning, bool reset,
     45                               bool& havetuned);
     46/*
     47//currently not used
    4348    bool PositionerStore(DVBTuning& tuning);
    4449    bool PositionerStopMovement();
    4550    bool PositionerStoreEastLimit();
    4651    bool PositionerStoreWestLimit();
    47     bool PositionerDisableLimits();   
     52    bool PositionerDisableLimits();
    4853    bool PositionerDriveEast(int timestep);
    4954    bool PositionerDriveWest(int timestep);
    50     bool PositionerGotoAngular(DVBTuning& tuning, bool reset,
    51                                bool& havetuned);
    52 
    5355    // Still need to be written
    5456    bool Positioner_Status();
     57*/
    5558
    5659    enum diseqc_cmd_bytes {
    5760        FRAME               = 0x0,
     
    7275        REPLY_CRCERR_RPT    = 0xe6,
    7376        REPLY_CMDERR_RPT    = 0xe7
    7477    };
    75        
     78
    7679    enum diseqc_address {
    7780        MASTER_TO_ALL        = 0x00,
    7881        MASTER_TO_LSS        = 0x10,
  • libs/libmythtv/videosource.cpp

    diff -Naur mythtv/libs/libmythtv/videosource.cpp mythtv-diseqc/libs/libmythtv/videosource.cpp
    old new  
    12381238        addSelection("DiSEqC v1.2 Positioner","6");
    12391239        addSelection("DiSEqC v1.3 Positioner (Goto X)","7");
    12401240        addSelection("DiSEqC v1.1 or 2.1 (10-way method2)","8");
     1241        addSelection("DiSEqC v1.2 Positioner with a DiSEqC switch behind it.","10");
     1242        addSelection("DiSEqC v1.3 Positioner (Goto X) with a DiSEqC switch behind it.","11");
    12411243        setHelpText(QObject::tr("Select the input type for DVB-S cards. "
    12421244                    "Leave as Single LNB/Input for DVB-C or DVB-T. "
    12431245                    "The inputs are mapped from Input Connections option "
     
    16831685    {
    16841686        setLabel(QObject::tr("DiSEqC Satellite Location"));
    16851687        setValue("0.0");
    1686         setHelpText(QObject::tr("The longitude of the satellite "
    1687                     "you are aiming at.  For western hemisphere use "
    1688                     "a negative value.  Value is in decimal."));
     1688        setHelpText(QObject::tr("For 1.2 positioner enter the number as it is stored in the positioner for this satellite"
     1689                    "or for the GotoX (DiSEqC 1.3/USALS) positioner, this is a longitude of the satellite "
     1690                    "you are aiming at.  For western hemisphere use a negative value.  Value is in decimal."));
    16891691//        setVisible(false);
    16901692    };
    16911693//    void fillSelections(const QString& pos) {
     
    17081710};
    17091711
    17101712
     1713class DiSEqCPortPos: public SpinBoxSetting, public CISetting {
     1714  public:
     1715    DiSEqCPortPos(const CardInput& parent):
     1716        SpinBoxSetting(0,4,0),
     1717        CISetting(parent, "diseqc_port") {
     1718        setLabel(QObject::tr("DiSEqC Port"));
     1719        setValue(0);
     1720        setHelpText(QObject::tr("Port umber of a DiSEqC switch "
     1721                    "behind a positioner. "));
     1722    };
     1723};
     1724
     1725
    17111726class FreeToAir: public CheckBoxSetting, public CISetting {
    17121727  public:
    17131728    FreeToAir(const CardInput& parent):
     
    18801895    {
    18811896        group->addChild(diseqcpos    = new DiSEqCPos(*this));
    18821897        group->addChild(diseqcport   = new DiSEqCPort(*this));
     1898        group->addChild(diseqcportpos = new DiSEqCPortPos(*this));
    18831899        group->addChild(lnblofswitch = new LNBLofSwitch(*this));
    18841900        group->addChild(lnblofhi = new LNBLofHi(*this));
    18851901        group->addChild(lnbloflo = new LNBLofLo(*this));
     
    19902006        {
    19912007            if (dvbType == CardUtil::QPSK)
    19922008            {
    1993                 //Check for DiSEqC type
    1994                 diseqcpos->setVisible(true);
    1995                 lnblofswitch->setVisible(true);
    1996                 lnbloflo->setVisible(true);
    1997                 lnblofhi->setVisible(true);
    1998                 if (CardUtil::GetDISEqCType(_cardid) == CardUtil::POSITIONER_X)
    1999                     diseqcpos->setEnabled(true);
    2000                 else
    2001                     diseqcpos->setEnabled(false);
    2002             }
    2003             else
    2004             {
    2005                 diseqcpos->setVisible(false);
    2006                 lnblofswitch->setVisible(false);
    2007                 lnbloflo->setVisible(false);
    2008                 lnblofhi->setVisible(false);
     2009                 //Check for DiSEqC type
     2010                 diseqcpos->setVisible(true);
     2011                 diseqcportpos->setVisible(true);
     2012                 lnblofswitch->setVisible(true);
     2013                 lnbloflo->setVisible(true);
     2014                 lnblofhi->setVisible(true);
     2015                 if (CardUtil::GetDISEqCType(_cardid) == CardUtil::POSITIONER_1_2 ||
     2016                      CardUtil::GetDISEqCType(_cardid) == CardUtil::POSITIONER_1_2_SWITCH ||
     2017                      CardUtil::GetDISEqCType(_cardid) == CardUtil::POSITIONER_X ||
     2018                      CardUtil::GetDISEqCType(_cardid) == CardUtil::POSITIONER_X_SWITCH)
     2019                 {
     2020                     diseqcpos->setEnabled(true);
     2021                     diseqcportpos->setEnabled(true);
     2022                 }
     2023                 else
     2024                 {
     2025                     diseqcpos->setEnabled(false);
     2026                     diseqcportpos->setEnabled(false);
     2027                 }
     2028             }
     2029             else
     2030             {
     2031                 diseqcpos->setVisible(false);
     2032                 diseqcportpos->setVisible(false);
     2033                 lnblofswitch->setVisible(false);
     2034                 lnbloflo->setVisible(false);
     2035                 lnblofhi->setVisible(false);
    20092036            }
    20102037        }
    20112038    }
     
    24292456                list.append(DVBDiSEqCInputList(
    24302457                                stxt.arg(i+1,2), QString::number(i), ""));
    24312458            break;
     2459        case 10:
     2460            for (i = 1; i < 50; ++i)
     2461                list.append(DVBDiSEqCInputList(
     2462                                mtxt.arg(i), "", QString::number(i)));
     2463            break;
     2464        case 11:
     2465            for (i = 1; i < 100; ++i)
     2466                list.append(DVBDiSEqCInputList(
     2467                                itxt.arg(i), "", QString::number(i)));
     2468            break;
     2469
    24322470        default:
    24332471            list.append(DVBDiSEqCInputList(
    24342472                            QString("DVBInput"), QString(""), QString("")));
  • libs/libmythtv/videosource.h

    diff -Naur mythtv/libs/libmythtv/videosource.h mythtv-diseqc/libs/libmythtv/videosource.h
    old new  
    5353        POSITIONER_X,
    5454        POSITIONER_1_2_SWITCH_2,
    5555        POSITIONER_X_SWITCH_2,
     56        POSITIONER_1_2_SWITCH,
     57        POSITIONER_X_SWITCH,
    5658    };
    5759    /// \brief dvb card type
    5860    static const QString DVB;
     
    522524class DVBLNBChooser;
    523525class DiSEqCPos;
    524526class DiSEqCPort;
     527class DiSEqCPortPos;
    525528class LNBLofSwitch;
    526529class LNBLofLo;
    527530class LNBLofHi;
     
    573576    DVBLNBChooser   *lnbsettings;
    574577    DiSEqCPos       *diseqcpos;
    575578    DiSEqCPort      *diseqcport;
     579    DiSEqCPortPos   *diseqcportpos;
    576580    LNBLofSwitch    *lnblofswitch;
    577581    LNBLofLo        *lnbloflo;
    578582    LNBLofHi        *lnblofhi;