cleanup the plugins to fit the new namespace
[enigma2.git] / lib / dvb / sec.cpp
index 0b40ae5096197719181766e216bc63b66c3e3cd9..aeaf5a2ae33c34470164882dded478b380820e20 100644 (file)
@@ -209,6 +209,60 @@ int eDVBSatelliteEquipmentControl::canTune(const eDVBFrontendParametersSatellite
 //                                     else
 //                                             eDebug("OK .. can tune this transponder satpos is correct :)");
                                }
+                               if (ret)
+                               {
+                                       static int lofs[] = { 3650000, 5150000, 9750000, 10600000 };
+                                       int lof = sat.frequency > lnb_param.m_lof_threshold ?
+                                               lnb_param.m_lof_hi : lnb_param.m_lof_lo;
+                                       int diff = 0x7FFFFFFF;
+                                       unsigned int num_lofs = sizeof(lofs) / sizeof(int);
+                                       int used_band = -1;
+                                       for (int i=0; i < num_lofs; ++i)
+                                       {
+                                               int lof_diff = abs(lof - lofs[i]);
+                                               if ( lof_diff < diff )
+                                               {
+                                                       diff = lof_diff;
+                                                       used_band = i;
+                                               }
+                                       }
+                                       if ( used_band != -1 )
+                                       {
+                                               if ( diff > 50000 )
+                                               {
+                                                       eDebug("could not detect used lnb freq range .. disable range check !!!");
+                                                       used_band = -1;
+                                               }
+                                       }
+                                       if ( used_band != -1 )
+                                       {
+                                               int range[2];
+                                               switch(used_band)
+                                               {
+                                                       case 0:  // s-band
+                                                               range[0] = 2500000;
+                                                               range[1] = 2700000;
+                                                               break;
+                                                       case 1:  // c-band
+                                                               range[0] = 3400000;
+                                                               range[1] = 4200000;
+                                                               break;
+                                                       case 2:  // ku-band low
+                                                               range[0] = 10700000;
+                                                               range[1] = 11750000;
+                                                               break;
+                                                       case 3:  // ku-band high
+                                                               range[0] = 11750000;
+                                                               range[1] = 12750000;
+                                                               break;
+                                               }
+                                               // check frequency in range ( +/- 75Mhz )
+                                               if ( (sat.frequency+75000) < range[0] )
+                                                       ret=0;
+                                               if ( (sat.frequency-75000) > range[1] )
+                                                       ret=0;
+                                       }
+                               }
                        }
                }
        }
@@ -602,27 +656,24 @@ RESULT eDVBSatelliteEquipmentControl::prepare(iDVBFrontend &frontend, FRONTENDPA
                                        sec_sequence.push_back( eSecCommand(eSecCommand::SET_VOLTAGE, VOLTAGE(18)) );
                                        // voltage was disabled..so we wait a longer time ..
                                        sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, 500) );
-                                       sec_sequence.push_back( eSecCommand(eSecCommand::GOTO, +4) );  // no need to send stop rotor cmd
+                                       sec_sequence.push_back( eSecCommand(eSecCommand::GOTO, +7) );  // no need to send stop rotor cmd
 
-                                       eDVBDiseqcCommand diseqc;
-                                       if ( !send_mask )  // no switch changed.. so we send first the rotor stop command
-                                       {
-                                               diseqc.len = 3;
-                                               diseqc.data[0] = 0xE0;
-                                               diseqc.data[1] = 0x31;  // positioner
-                                               diseqc.data[2] = 0x60;  // stop
-                                               sec_sequence.push_back( eSecCommand(eSecCommand::IF_ROTORPOS_VALID_GOTO, +3) );
-                                               sec_sequence.push_back( eSecCommand(eSecCommand::SEND_DISEQC, diseqc) );
-                                               // wait 300msec after send rotor stop cmd
-                                               sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, 300) );
-                                       }
+                                       if (send_mask)
+                                               sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, 750) ); // wait 750ms after send switch cmd
                                        else
-                                       {
-                                               // wait 500msec after switching to rotor
-                                               sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, 500) );
-                                               sec_sequence.push_back( eSecCommand(eSecCommand::GOTO, +2) );
                                                sec_sequence.push_back( eSecCommand(eSecCommand::GOTO, +1) );
-                                       }
+
+                                       eDVBDiseqcCommand diseqc;
+                                       diseqc.len = 3;
+                                       diseqc.data[0] = 0xE0;
+                                       diseqc.data[1] = 0x31;  // positioner
+                                       diseqc.data[2] = 0x60;  // stop
+                                       sec_sequence.push_back( eSecCommand(eSecCommand::IF_ROTORPOS_VALID_GOTO, +5) );
+                                       sec_sequence.push_back( eSecCommand(eSecCommand::SEND_DISEQC, diseqc) );
+                                       sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, 50) );
+                                       sec_sequence.push_back( eSecCommand(eSecCommand::SEND_DISEQC, diseqc) );
+                                       // wait 300msec after send rotor stop cmd
+                                       sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, 300) );
 
                                        diseqc.data[0] = 0xE0;
                                        diseqc.data[1] = 0x31;          // positioner