always initialize diseqc.data to make compiler happy
[enigma2.git] / lib / dvb / sec.cpp
index 411cb52eda157797a9035df91b246db31c2db4fd..9b4ee15adecf048d81a262fd99f80fc5ea772052 100644 (file)
@@ -28,7 +28,6 @@ eDVBSatelliteEquipmentControl::eDVBSatelliteEquipmentControl(eSmartPtrList<eDVBR
 
        clear();
 
-#if 1
 // ASTRA
        addLNB();
        setLNBTunerMask(3);
@@ -62,7 +61,6 @@ eDVBSatelliteEquipmentControl::eDVBSatelliteEquipmentControl(eSmartPtrList<eDVBR
        addSatellite(130);
        setVoltageMode(eDVBSatelliteSwitchParameters::HV);
        setToneMode(eDVBSatelliteSwitchParameters::HILO);
-#else
 
 // Rotor
        addLNB();
@@ -84,12 +82,7 @@ eDVBSatelliteEquipmentControl::eDVBSatelliteEquipmentControl(eSmartPtrList<eDVBR
        setUseInputpower(true);
        setInputpowerDelta(50);
 
-       addSatellite(130);
-       setVoltageMode(eDVBSatelliteSwitchParameters::HV);
-       setToneMode(eDVBSatelliteSwitchParameters::HILO);
-       setRotorPosNum(0);
-
-       addSatellite(192);
+       addSatellite(235);
        setVoltageMode(eDVBSatelliteSwitchParameters::HV);
        setToneMode(eDVBSatelliteSwitchParameters::HILO);
        setRotorPosNum(0);
@@ -103,7 +96,6 @@ eDVBSatelliteEquipmentControl::eDVBSatelliteEquipmentControl(eSmartPtrList<eDVBR
        setVoltageMode(eDVBSatelliteSwitchParameters::HV);
        setToneMode(eDVBSatelliteSwitchParameters::HILO);
        setRotorPosNum(1); // stored pos 1
-#endif
 }
 
 int eDVBSatelliteEquipmentControl::canTune(const eDVBFrontendParametersSatellite &sat, iDVBFrontend *fe, int frontend_id )
@@ -202,6 +194,8 @@ int eDVBSatelliteEquipmentControl::canTune(const eDVBFrontendParametersSatellite
        return ret;
 }
 
+#define VOLTAGE(x) (lnb_param.m_increased_voltage ? iDVBFrontend::voltage##x##_5 : iDVBFrontend::voltage##x)
+
 RESULT eDVBSatelliteEquipmentControl::prepare(iDVBFrontend &frontend, FRONTENDPARAMETERS &parm, eDVBFrontendParametersSatellite &sat, int frontend_id)
 {
        bool linked=false;
@@ -261,7 +255,19 @@ RESULT eDVBSatelliteEquipmentControl::prepare(iDVBFrontend &frontend, FRONTENDPA
                        if (sat.polarisation == eDVBFrontendParametersSatellite::Polarisation::Horizontal)
                                band |= 2;
 
-                       parm.INVERSION = (!sat.inversion) ? INVERSION_ON : INVERSION_OFF;
+                       switch (sat.inversion)
+                       {
+                               case eDVBFrontendParametersCable::Inversion::On:
+                                       parm.INVERSION = INVERSION_ON;
+                                       break;
+                               case eDVBFrontendParametersCable::Inversion::Off:
+                                       parm.INVERSION = INVERSION_OFF;
+                                       break;
+                               default:
+                               case eDVBFrontendParametersCable::Inversion::Unknown:
+                                       parm.INVERSION = INVERSION_AUTO;
+                                       break;
+                       }
 
                        switch (sat.fec)
                        {
@@ -293,12 +299,11 @@ RESULT eDVBSatelliteEquipmentControl::prepare(iDVBFrontend &frontend, FRONTENDPA
                        if ( sw_param.m_voltage_mode == eDVBSatelliteSwitchParameters::_14V
                                || ( sat.polarisation == eDVBFrontendParametersSatellite::Polarisation::Vertical
                                        && sw_param.m_voltage_mode == eDVBSatelliteSwitchParameters::HV )  )
-                               voltage = iDVBFrontend::voltage13;
+                               voltage = VOLTAGE(13);
                        else if ( sw_param.m_voltage_mode == eDVBSatelliteSwitchParameters::_18V
                                || ( sat.polarisation == eDVBFrontendParametersSatellite::Polarisation::Horizontal
                                        && sw_param.m_voltage_mode == eDVBSatelliteSwitchParameters::HV )  )
-                               voltage = iDVBFrontend::voltage18;
-
+                               voltage = VOLTAGE(18);
                        if ( (sw_param.m_22khz_signal == eDVBSatelliteSwitchParameters::ON)
                                || ( sw_param.m_22khz_signal == eDVBSatelliteSwitchParameters::HILO && (band&1) ) )
                                tone = iDVBFrontend::toneOn;
@@ -422,6 +427,11 @@ RESULT eDVBSatelliteEquipmentControl::prepare(iDVBFrontend &frontend, FRONTENDPA
                                                        diseqc.data[2] = 0x38;
                                                        diseqc.data[3] = csw;
                                                }
+                                               else
+                                               {
+                                                       diseqc.data[2] = 0x00;
+                                                       diseqc.data[3] = 0x00;
+                                               }
                                                sec_sequence.push_back( eSecCommand(eSecCommand::SEND_DISEQC, diseqc) );
 
                                                i++;
@@ -471,10 +481,6 @@ RESULT eDVBSatelliteEquipmentControl::prepare(iDVBFrontend &frontend, FRONTENDPA
                                                eDebug("Entry for %d,%d? not in Rotor Table found... i try gotoXX?", sat.orbital_position / 10, sat.orbital_position % 10 );
                                                useGotoXX = true;
 
-                                               int satDir = sat.orbital_position < 0 ?
-                                                       eDVBSatelliteRotorParameters::WEST :
-                                                       eDVBSatelliteRotorParameters::EAST;
-
                                                double  SatLon = abs(sat.orbital_position)/10.00,
                                                                SiteLat = rotor_param.m_gotoxx_parameters.m_latitude,
                                                                SiteLon = rotor_param.m_gotoxx_parameters.m_longitude;
@@ -485,9 +491,6 @@ RESULT eDVBSatelliteEquipmentControl::prepare(iDVBFrontend &frontend, FRONTENDPA
                                                if ( rotor_param.m_gotoxx_parameters.m_lo_direction == eDVBSatelliteRotorParameters::WEST )
                                                        SiteLon = 360 - SiteLon;
 
-                                               if (satDir == eDVBSatelliteRotorParameters::WEST )
-                                                       SatLon = 360 - SatLon;
-
                                                eDebug("siteLatitude = %lf, siteLongitude = %lf, %lf degrees", SiteLat, SiteLon, SatLon );
                                                double satHourAngle =
                                                        calcSatHourangle( SatLon, SiteLat, SiteLon );
@@ -528,7 +531,7 @@ RESULT eDVBSatelliteEquipmentControl::prepare(iDVBFrontend &frontend, FRONTENDPA
                                                if ( send_mask )
                                                {
                                                        // override first voltage change
-                                                       *(++(++sec_sequence.begin()))=eSecCommand(eSecCommand::SET_VOLTAGE, iDVBFrontend::voltage13);
+                                                       *(++(++sec_sequence.begin()))=eSecCommand(eSecCommand::SET_VOLTAGE, VOLTAGE(13));
                                                        // wait 1 second after first switch diseqc command
                                                        sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, 1000) );
                                                }
@@ -540,7 +543,7 @@ RESULT eDVBSatelliteEquipmentControl::prepare(iDVBFrontend &frontend, FRONTENDPA
                                                        compare.voltage = voltage;
                                                        compare.steps = +3;
                                                        sec_sequence.push_back( eSecCommand(eSecCommand::IF_VOLTAGE_GOTO, compare) ); // voltage already correct ?
-                                                       sec_sequence.push_back( eSecCommand(eSecCommand::SET_VOLTAGE, iDVBFrontend::voltage13) );
+                                                       sec_sequence.push_back( eSecCommand(eSecCommand::SET_VOLTAGE, VOLTAGE(13)) );
                                                        sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, 50) );  // wait 50msec after voltage change
                                                }
 
@@ -559,6 +562,7 @@ RESULT eDVBSatelliteEquipmentControl::prepare(iDVBFrontend &frontend, FRONTENDPA
                                                        diseqc.len = 4;
                                                        diseqc.data[2] = 0x6B;  // goto stored sat position
                                                        diseqc.data[3] = RotorCmd;
+                                                       diseqc.data[4] = 0x00;
                                                }
 
                                                if ( rotor_param.m_inputpower_parameters.m_use )
@@ -568,10 +572,10 @@ RESULT eDVBSatelliteEquipmentControl::prepare(iDVBFrontend &frontend, FRONTENDPA
                                                        sec_sequence.push_back( eSecCommand(eSecCommand::IF_IDLE_INPUTPOWER_AVAIL_GOTO, +8) ); // already measured?
                                                        sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, 50) );  // wait 50msec after voltage change
                                                        sec_sequence.push_back( eSecCommand(eSecCommand::MEASURE_IDLE_INPUTPOWER, 0) );
-                                                       sec_sequence.push_back( eSecCommand(eSecCommand::SET_VOLTAGE, iDVBFrontend::voltage18) );
+                                                       sec_sequence.push_back( eSecCommand(eSecCommand::SET_VOLTAGE, VOLTAGE(18)) );
                                                        sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, 100) );  // wait 100msec before measure
                                                        sec_sequence.push_back( eSecCommand(eSecCommand::MEASURE_IDLE_INPUTPOWER, 1) );
-                                                       sec_sequence.push_back( eSecCommand(eSecCommand::SET_VOLTAGE, iDVBFrontend::voltage13) ); // back to lower voltage
+                                                       sec_sequence.push_back( eSecCommand(eSecCommand::SET_VOLTAGE, VOLTAGE(13)) ); // back to lower voltage
                                                        sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, 50) );  // wait 50msec
 ////////////////////////////
                                                        sec_sequence.push_back( eSecCommand(eSecCommand::SET_POWER_LIMITING_MODE, eSecCommand::modeStatic) );
@@ -586,12 +590,11 @@ RESULT eDVBSatelliteEquipmentControl::prepare(iDVBFrontend &frontend, FRONTENDPA
                                                        cmd.steps=+3;
                                                        cmd.okcount=0;
                                                        sec_sequence.push_back( eSecCommand(eSecCommand::IF_INPUTPOWER_DELTA_GOTO, cmd ) );  // check if rotor has started
-                                                       sec_sequence.push_back( eSecCommand(eSecCommand::IF_TIMEOUT_GOTO, +10 ) );  // timeout .. we assume now the rotor is already at the correct position
+                                                       sec_sequence.push_back( eSecCommand(eSecCommand::IF_TIMEOUT_GOTO, +9 ) );  // timeout .. we assume now the rotor is already at the correct position
                                                        sec_sequence.push_back( eSecCommand(eSecCommand::GOTO, -4) );  // goto loop start
 ////////////////////
                                                        sec_sequence.push_back( eSecCommand(eSecCommand::SET_TIMEOUT, 2400) );  // 2 minutes running timeout
-                                                       sec_sequence.push_back( eSecCommand(eSecCommand::SET_VOLTAGE, iDVBFrontend::voltage18) );
-                                                       sec_sequence.push_back( eSecCommand(eSecCommand::SET_POWER_LIMITING_MODE, eSecCommand::modeDynamic) );
+                                                       sec_sequence.push_back( eSecCommand(eSecCommand::SET_VOLTAGE, VOLTAGE(18)) );
 // rotor running loop
                                                        sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, 50) );  // wait 50msec
                                                        sec_sequence.push_back( eSecCommand(eSecCommand::MEASURE_RUNNING_INPUTPOWER) );
@@ -602,6 +605,7 @@ RESULT eDVBSatelliteEquipmentControl::prepare(iDVBFrontend &frontend, FRONTENDPA
                                                        sec_sequence.push_back( eSecCommand(eSecCommand::GOTO, -4) );  // running loop start
 /////////////////////
                                                        sec_sequence.push_back( eSecCommand(eSecCommand::UPDATE_CURRENT_ROTORPARAMS) );
+                                                       sec_sequence.push_back( eSecCommand(eSecCommand::SET_POWER_LIMITING_MODE, eSecCommand::modeDynamic) );
                                                        if ( linked )
                                                        {
                                                                frontend.setData(5, RotorCmd);