Ticket #518: mythdiseqcupdate-1.patch

File mythdiseqcupdate-1.patch, 4.4 KB (added by Dibblah, 18 years ago)

Replaces Diseqc1xSwitch_10way with a generalised Diseqc1xSwitch

  • libs/libmythtv/dvbdiseqc.cpp

     
    7171            break;
    7272        case 2: // v1.0 2 Way
    7373        case 3: // v1.1 2 Way
     74            if (!Diseqc1xSwitch(tuning, reset, havetuned, 2))
     75                return false;
     76            break;
    7477        case 4: // v1.0 4 Way
    7578        case 5: // v1.1 4 Way
    76             if (!Diseqc1xSwitch(tuning, reset, havetuned))
     79            if (!Diseqc1xSwitch(tuning, reset, havetuned, 4))
    7780                return false;
    7881            break;
    7982        case 6: // 1.2 Positioner (HH Motor)
     
    8588                return false;
    8689            break;
    8790        case 8: // v1.1 10 Way
    88             if (!Diseqc1xSwitch_10way(tuning, reset, havetuned))
     91            if (!Diseqc1xSwitch(tuning, reset, havetuned, 10))
    8992                return false;
    9093            break;
    9194 
     
    322325    return true;
    323326}
    324327
    325 bool DVBDiSEqC::Diseqc1xSwitch_10way(DVBTuning& tuning, bool reset,
    326                                bool& havetuned)
     328bool DVBDiSEqC::Diseqc1xSwitch(DVBTuning& tuning, bool reset,
     329                               bool& havetuned, unsigned int ports)
    327330{
     331
     332
    328333    if (reset)
    329334    {
    330335        if (!DiseqcReset())
     
    334339        }
    335340    }
    336341
    337     GENERAL(QString("DiSEqC 1.1 Switch - Port %1").arg(tuning.diseqc_port));
     342    CHANNEL(QString("DiSEqC 1.1 Switch (%1 ports) - Port %2 - %3 %4")
     343        .arg(ports)
     344        .arg(tuning.diseqc_port)
     345        .arg(tuning.tone==SEC_TONE_ON?"Tone ON":"Tone OFF")
     346        .arg(tuning.voltage==SEC_VOLTAGE_13?"13V":"18V"));
    338347
    339348    if ((prev_tuning.diseqc_port != tuning.diseqc_port ||
    340349        prev_tuning.tone != tuning.tone ||
    341350        prev_tuning.voltage != tuning.voltage) || reset)
    342351    {
    343         if (tuning.diseqc_port > 9)
    344         {
    345             ERRNO("Supports only up to 10-way switches.");
    346             return false;
    347         }
    348 
    349         dvb_diseqc_master_cmd cmd =
     352        dvb_diseqc_master_cmd cmd =
    350353            {{CMD_FIRST, MASTER_TO_LSS, WRITE_N1, 0xf0, 0x00, 0x00}, 4};
    351354
    352         cmd.msg[DATA_1] = 0xF0
    353                 | (tuning.diseqc_port & 0x0F);
    354 
    355         if (!SendDiSEqCMessage(tuning,cmd))
     355        if (tuning.diseqc_port >= ports )
    356356        {
    357             ERRNO("Setting DiSEqC failed.\n");
     357            ERRNO(QString("Supports only up to %d-way switches.").arg(ports));
    358358            return false;
    359359        }
    360360
    361         prev_tuning.diseqc_port = tuning.diseqc_port;
    362         prev_tuning.tone = tuning.tone;
    363         prev_tuning.voltage = tuning.voltage;
    364         havetuned = true;
    365361
    366     }
    367 
    368     return true;
    369 }
    370 
    371 bool DVBDiSEqC::Diseqc1xSwitch(DVBTuning& tuning, bool reset,
    372                                bool& havetuned)
    373 {
    374     if (reset)
    375     {
    376         if (!DiseqcReset())
     362        switch (ports)
    377363        {
    378             ERRNO("DiseqcReset() failed");
    379             return false;
    380         }
    381     }
     364            case 10:
     365                cmd.msg[COMMAND] = WRITE_N1;
    382366
    383     GENERAL(QString("DiSEqC 1.0 Switch - Port %1").arg(tuning.diseqc_port));
     367                cmd.msg[DATA_1] = 0xF0
     368                                  | (tuning.diseqc_port & 0x0F);
     369                break;
     370            case 4:
     371            case 2:
     372                cmd.msg[COMMAND] = WRITE_N0;
    384373
    385     if ((prev_tuning.diseqc_port != tuning.diseqc_port ||
    386         prev_tuning.tone != tuning.tone ||
    387         prev_tuning.voltage != tuning.voltage) || reset)
    388     {
    389         if (tuning.diseqc_port > 3)
    390         {
    391             ERRNO("Supports only up to 4-way switches.");
    392             return false;
     374                cmd.msg[DATA_1] = 0xF0
     375                                  | (((tuning.diseqc_port) * 4) & 0x0F)
     376                                  | ((tuning.voltage == SEC_VOLTAGE_18) ? 2 : 0)
     377                                  | ((tuning.tone == SEC_TONE_ON) ? 1 : 0);
     378                break;
     379            default:
     380                ERRNO("Unsupported number of ports for DiSEqC 1.1 Switch");
    393381        }
    394382
    395         dvb_diseqc_master_cmd cmd =
    396             {{CMD_FIRST, MASTER_TO_LSS, WRITE_N0, 0xf0, 0x00, 0x00}, 4};
    397 
    398         cmd.msg[DATA_1] = 0xF0
    399                           | (((tuning.diseqc_port) * 4) & 0x0F)
    400                           | ((tuning.voltage == SEC_VOLTAGE_18) ? 2 : 0)
    401                           | ((tuning.tone == SEC_TONE_ON) ? 1 : 0);
    402 
    403383        if (!SendDiSEqCMessage(tuning,cmd))
    404384        {
    405385            ERRNO("Setting DiSEqC failed.\n");