small optimize
authorAndreas Monzner <andreas.monzner@multimedia-labs.de>
Tue, 5 Dec 2006 15:30:41 +0000 (15:30 +0000)
committerAndreas Monzner <andreas.monzner@multimedia-labs.de>
Tue, 5 Dec 2006 15:30:41 +0000 (15:30 +0000)
lib/dvb/frontend.cpp
lib/dvb/frontend.h
lib/dvb/sec.cpp
lib/dvb/sec.h

index c4d641226e79b7b58adf796e1ea6a1e0d3597a61..d8be84940e60b0a2a37c366dca4ae73642e140de 100644 (file)
@@ -1147,7 +1147,7 @@ void eDVBFrontend::tuneLoop()  // called by m_tuneTimer
                        case eSecCommand::IF_VOLTAGE_GOTO:
                        {
                                eSecCommand::pair &compare = m_sec_sequence.current()->compare;
                        case eSecCommand::IF_VOLTAGE_GOTO:
                        {
                                eSecCommand::pair &compare = m_sec_sequence.current()->compare;
-                               if ( compare.voltage == m_curVoltage && setSecSequencePos(compare.steps) )
+                               if ( compare.voltage == m_data[CUR_VOLTAGE] && setSecSequencePos(compare.steps) )
                                        break;
                                ++m_sec_sequence.current();
                                break;
                                        break;
                                ++m_sec_sequence.current();
                                break;
@@ -1155,7 +1155,23 @@ void eDVBFrontend::tuneLoop()  // called by m_tuneTimer
                        case eSecCommand::IF_NOT_VOLTAGE_GOTO:
                        {
                                eSecCommand::pair &compare = m_sec_sequence.current()->compare;
                        case eSecCommand::IF_NOT_VOLTAGE_GOTO:
                        {
                                eSecCommand::pair &compare = m_sec_sequence.current()->compare;
-                               if ( compare.voltage != m_curVoltage && setSecSequencePos(compare.steps) )
+                               if ( compare.voltage != m_data[CUR_VOLTAGE] && setSecSequencePos(compare.steps) )
+                                       break;
+                               ++m_sec_sequence.current();
+                               break;
+                       }
+                       case eSecCommand::IF_TONE_GOTO:
+                       {
+                               eSecCommand::pair &compare = m_sec_sequence.current()->compare;
+                               if ( compare.tone == m_data[CUR_TONE] && setSecSequencePos(compare.steps) )
+                                       break;
+                               ++m_sec_sequence.current();
+                               break;
+                       }
+                       case eSecCommand::IF_NOT_TONE_GOTO:
+                       {
+                               eSecCommand::pair &compare = m_sec_sequence.current()->compare;
+                               if ( compare.tone != m_data[CUR_TONE] && setSecSequencePos(compare.steps) )
                                        break;
                                ++m_sec_sequence.current();
                                break;
                                        break;
                                ++m_sec_sequence.current();
                                break;
@@ -1214,7 +1230,7 @@ void eDVBFrontend::tuneLoop()  // called by m_tuneTimer
                        case eSecCommand::IF_MEASURE_IDLE_WAS_NOT_OK_GOTO:
                        {
                                eSecCommand::pair &compare = m_sec_sequence.current()->compare;
                        case eSecCommand::IF_MEASURE_IDLE_WAS_NOT_OK_GOTO:
                        {
                                eSecCommand::pair &compare = m_sec_sequence.current()->compare;
-                               int idx = compare.voltage;
+                               int idx = compare.val;
                                if ( idx == 0 || idx == 1 )
                                {
                                        int idle = readInputpower();
                                if ( idx == 0 || idx == 1 )
                                {
                                        int idle = readInputpower();
@@ -1261,7 +1277,7 @@ void eDVBFrontend::tuneLoop()  // called by m_tuneTimer
                                break;
                        case eSecCommand::IF_INPUTPOWER_DELTA_GOTO:
                        {
                                break;
                        case eSecCommand::IF_INPUTPOWER_DELTA_GOTO:
                        {
-                               int idleInputpower = m_idleInputpower[ (m_curVoltage&1) ? 0 : 1];
+                               int idleInputpower = m_idleInputpower[ (m_data[CUR_VOLTAGE]&1) ? 0 : 1];
                                eSecCommand::rotor &cmd = m_sec_sequence.current()->measure;
                                const char *txt = cmd.direction ? "running" : "stopped";
                                eDebug("[SEC] waiting for rotor %s %d, idle %d, delta %d",
                                eSecCommand::rotor &cmd = m_sec_sequence.current()->measure;
                                const char *txt = cmd.direction ? "running" : "stopped";
                                eDebug("[SEC] waiting for rotor %s %d, idle %d, delta %d",
@@ -1834,7 +1850,7 @@ RESULT eDVBFrontend::setVoltage(int voltage)
        bool increased=false;
        fe_sec_voltage_t vlt;
 #endif
        bool increased=false;
        fe_sec_voltage_t vlt;
 #endif
-       m_curVoltage=voltage;
+       m_data[CUR_VOLTAGE]=voltage;
        switch (voltage)
        {
        case voltageOff:
        switch (voltage)
        {
        case voltageOff:
@@ -1889,7 +1905,7 @@ RESULT eDVBFrontend::setTone(int t)
 #else
        fe_sec_tone_mode_t tone;
 #endif
 #else
        fe_sec_tone_mode_t tone;
 #endif
-
+       m_data[CUR_TONE]=t;
        switch (t)
        {
        case toneOn:
        switch (t)
        {
        case toneOn:
index 7801127641081d4767bac225fdcfa0180ab14d1c..df028c19c3a29ee41a970ebfaac51e0e715ee26c 100644 (file)
@@ -70,6 +70,8 @@ class eDVBFrontend: public iDVBFrontend, public Object
                LINKED_NEXT_PTR,      // next double linked list (for linked FEs)
                SATPOS_DEPENDS_PTR,   // pointer to FE with configured rotor (with twin/quattro lnb)
                FREQ_OFFSET,          // current frequency offset
                LINKED_NEXT_PTR,      // next double linked list (for linked FEs)
                SATPOS_DEPENDS_PTR,   // pointer to FE with configured rotor (with twin/quattro lnb)
                FREQ_OFFSET,          // current frequency offset
+               CUR_VOLTAGE,          // current voltage
+               CUR_TONE,             // current continuous tone
                NUM_DATA_ENTRIES
        };
 
                NUM_DATA_ENTRIES
        };
 
@@ -80,7 +82,6 @@ class eDVBFrontend: public iDVBFrontend, public Object
 
        int m_timeoutCount; // needed for timeout
        int m_retryCount; // diseqc retry for rotor
 
        int m_timeoutCount; // needed for timeout
        int m_retryCount; // diseqc retry for rotor
-       int m_curVoltage;
 
        void feEvent(int);
        void timeout();
 
        void feEvent(int);
        void timeout();
index faad062fab004691e137f98332835294695703ee..8d65e4130931f3dec38cfed96fdfdfe7899255c2 100644 (file)
@@ -523,9 +523,12 @@ RESULT eDVBSatelliteEquipmentControl::prepare(iDVBFrontend &frontend, FRONTENDPA
 
                                if ( send_mask )
                                {
 
                                if ( send_mask )
                                {
+                                       eSecCommand::pair compare;
+                                       compare.steps = +3;
+                                       compare.tone = iDVBFrontend::toneOff;
+                                       sec_sequence.push_back( eSecCommand(eSecCommand::IF_TONE_GOTO, compare) );
                                        sec_sequence.push_back( eSecCommand(eSecCommand::SET_TONE, iDVBFrontend::toneOff) );
                                        sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, 15) );
                                        sec_sequence.push_back( eSecCommand(eSecCommand::SET_TONE, iDVBFrontend::toneOff) );
                                        sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, 15) );
-                                       eSecCommand::pair compare;
                                        compare.voltage = iDVBFrontend::voltageOff;
                                        compare.steps = +4;
                                        // the next is a check if voltage is switched off.. then we first set a voltage :)
                                        compare.voltage = iDVBFrontend::voltageOff;
                                        compare.steps = +4;
                                        // the next is a check if voltage is switched off.. then we first set a voltage :)
@@ -643,12 +646,12 @@ RESULT eDVBSatelliteEquipmentControl::prepare(iDVBFrontend &frontend, FRONTENDPA
 
                                                // voltage was disabled..so we wait a longer time ..
                                                sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, 750) );
 
                                                // voltage was disabled..so we wait a longer time ..
                                                sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, 750) );
-                                               sec_sequence.push_back( eSecCommand(eSecCommand::GOTO, +8) );  // no need to send stop rotor cmd and recheck voltage
+                                               sec_sequence.push_back( eSecCommand(eSecCommand::GOTO, +9) );  // no need to send stop rotor cmd and recheck voltage
                                        }
                                        else
                                        {
                                                sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, 750) ); // wait 750ms after send switch cmd
                                        }
                                        else
                                        {
                                                sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, 750) ); // wait 750ms after send switch cmd
-                                               sec_sequence.push_back( eSecCommand(eSecCommand::GOTO, +8) );  // no need to send stop rotor cmd and recheck voltage
+                                               sec_sequence.push_back( eSecCommand(eSecCommand::GOTO, +9) );  // no need to send stop rotor cmd and recheck voltage
                                        }
 
                                        eDVBDiseqcCommand diseqc;
                                        }
 
                                        eDVBDiseqcCommand diseqc;
@@ -685,19 +688,19 @@ RESULT eDVBSatelliteEquipmentControl::prepare(iDVBFrontend &frontend, FRONTENDPA
                                                eSecCommand::rotor cmd;
                                                eSecCommand::pair compare;
                                                compare.voltage = VOLTAGE(18);
                                                eSecCommand::rotor cmd;
                                                eSecCommand::pair compare;
                                                compare.voltage = VOLTAGE(18);
-                                               compare.steps = +2;
+                                               compare.steps = +3;
                                                sec_sequence.push_back( eSecCommand(eSecCommand::IF_VOLTAGE_GOTO, compare) );
                                                sec_sequence.push_back( eSecCommand(eSecCommand::SET_VOLTAGE, compare.voltage) );
 // measure idle power values
                                                sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, 200) );  // wait 200msec after voltage change
                                                sec_sequence.push_back( eSecCommand(eSecCommand::MEASURE_IDLE_INPUTPOWER, 1) );
                                                sec_sequence.push_back( eSecCommand(eSecCommand::IF_VOLTAGE_GOTO, compare) );
                                                sec_sequence.push_back( eSecCommand(eSecCommand::SET_VOLTAGE, compare.voltage) );
 // measure idle power values
                                                sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, 200) );  // wait 200msec after voltage change
                                                sec_sequence.push_back( eSecCommand(eSecCommand::MEASURE_IDLE_INPUTPOWER, 1) );
-                                               compare.voltage = 1;
+                                               compare.val = 1;
                                                compare.steps = -2;
                                                sec_sequence.push_back( eSecCommand(eSecCommand::IF_MEASURE_IDLE_WAS_NOT_OK_GOTO, compare) );
                                                sec_sequence.push_back( eSecCommand(eSecCommand::SET_VOLTAGE, VOLTAGE(13)) );
                                                sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, 200) );  // wait 200msec before measure
                                                sec_sequence.push_back( eSecCommand(eSecCommand::MEASURE_IDLE_INPUTPOWER, 0) );
                                                compare.steps = -2;
                                                sec_sequence.push_back( eSecCommand(eSecCommand::IF_MEASURE_IDLE_WAS_NOT_OK_GOTO, compare) );
                                                sec_sequence.push_back( eSecCommand(eSecCommand::SET_VOLTAGE, VOLTAGE(13)) );
                                                sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, 200) );  // wait 200msec before measure
                                                sec_sequence.push_back( eSecCommand(eSecCommand::MEASURE_IDLE_INPUTPOWER, 0) );
-                                               compare.voltage = 0;
+                                               compare.val = 0;
                                                sec_sequence.push_back( eSecCommand(eSecCommand::IF_MEASURE_IDLE_WAS_NOT_OK_GOTO, compare) );
 ////////////////////////////
                                                sec_sequence.push_back( eSecCommand(eSecCommand::SET_POWER_LIMITING_MODE, eSecCommand::modeStatic) );
                                                sec_sequence.push_back( eSecCommand(eSecCommand::IF_MEASURE_IDLE_WAS_NOT_OK_GOTO, compare) );
 ////////////////////////////
                                                sec_sequence.push_back( eSecCommand(eSecCommand::SET_POWER_LIMITING_MODE, eSecCommand::modeStatic) );
@@ -737,7 +740,7 @@ RESULT eDVBSatelliteEquipmentControl::prepare(iDVBFrontend &frontend, FRONTENDPA
                                                eSecCommand::rotor cmd;
                                                eSecCommand::pair compare;
                                                compare.voltage = VOLTAGE(13);
                                                eSecCommand::rotor cmd;
                                                eSecCommand::pair compare;
                                                compare.voltage = VOLTAGE(13);
-                                               compare.steps = +2;
+                                               compare.steps = +3;
                                                sec_sequence.push_back( eSecCommand(eSecCommand::IF_VOLTAGE_GOTO, compare) );
                                                sec_sequence.push_back( eSecCommand(eSecCommand::SET_VOLTAGE, compare.voltage) );
                                                sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, 200) );  // wait 200msec after voltage change
                                                sec_sequence.push_back( eSecCommand(eSecCommand::IF_VOLTAGE_GOTO, compare) );
                                                sec_sequence.push_back( eSecCommand(eSecCommand::SET_VOLTAGE, compare.voltage) );
                                                sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, 200) );  // wait 200msec after voltage change
@@ -752,7 +755,10 @@ RESULT eDVBSatelliteEquipmentControl::prepare(iDVBFrontend &frontend, FRONTENDPA
                                                sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, 2000) );  // wait 2 second before set high voltage
                                                sec_sequence.push_back( eSecCommand(eSecCommand::SET_VOLTAGE, voltage) );
 
                                                sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, 2000) );  // wait 2 second before set high voltage
                                                sec_sequence.push_back( eSecCommand(eSecCommand::SET_VOLTAGE, voltage) );
 
+                                               compare.tone = tone;
+                                               sec_sequence.push_back( eSecCommand(eSecCommand::IF_TONE_GOTO, compare) );
                                                sec_sequence.push_back( eSecCommand(eSecCommand::SET_TONE, tone) );
                                                sec_sequence.push_back( eSecCommand(eSecCommand::SET_TONE, tone) );
+                                               sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, 15) );
                                                sec_sequence.push_back( eSecCommand(eSecCommand::SET_FRONTEND) );
 
                                                cmd.direction=1;  // check for running rotor
                                                sec_sequence.push_back( eSecCommand(eSecCommand::SET_FRONTEND) );
 
                                                cmd.direction=1;  // check for running rotor
@@ -788,6 +794,8 @@ RESULT eDVBSatelliteEquipmentControl::prepare(iDVBFrontend &frontend, FRONTENDPA
                                sec_sequence.push_back( eSecCommand(eSecCommand::SET_VOLTAGE, voltage) );
                                sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, 10) );
 
                                sec_sequence.push_back( eSecCommand(eSecCommand::SET_VOLTAGE, voltage) );
                                sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, 10) );
 
+                               compare.tone = tone;
+                               sec_sequence.push_back( eSecCommand(eSecCommand::IF_TONE_GOTO, compare) );
                                sec_sequence.push_back( eSecCommand(eSecCommand::SET_TONE, tone) );
                                sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, 15) );
                        }
                                sec_sequence.push_back( eSecCommand(eSecCommand::SET_TONE, tone) );
                                sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, 15) );
                        }
index 701797a4c78ad25070f0a1011606b581c275bb41..499e3737f3f0830ca2eb70b2d25f0dce28f842fa 100644 (file)
@@ -21,6 +21,7 @@ public:
                UPDATE_CURRENT_ROTORPARAMS, INVALIDATE_CURRENT_ROTORPARMS,
                IF_ROTORPOS_VALID_GOTO,
                IF_TUNER_LOCKED_GOTO,
                UPDATE_CURRENT_ROTORPARAMS, INVALIDATE_CURRENT_ROTORPARMS,
                IF_ROTORPOS_VALID_GOTO,
                IF_TUNER_LOCKED_GOTO,
+               IF_TONE_GOTO, IF_NOT_TONE_GOTO,
                START_TUNE_TIMEOUT
        };
        int cmd;
                START_TUNE_TIMEOUT
        };
        int cmd;
@@ -33,7 +34,12 @@ public:
        };
        struct pair
        {
        };
        struct pair
        {
-               int voltage;
+               union
+               {
+                       int voltage;
+                       int tone;
+                       int val;
+               };
                int steps;
        };
        union
                int steps;
        };
        union