X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/aa5f0da5970746434fe4deea234a98b35857c473..31fb73a15d12559b15f5506622c3902476d3ea0f:/lib/dvb/sec.cpp diff --git a/lib/dvb/sec.cpp b/lib/dvb/sec.cpp index d504fcb2..aeaf5a2a 100644 --- a/lib/dvb/sec.cpp +++ b/lib/dvb/sec.cpp @@ -138,7 +138,8 @@ int eDVBSatelliteEquipmentControl::canTune(const eDVBFrontendParametersSatellite if ( di_param.m_committed_cmd < eDVBSatelliteDiseqcParameters::SENDNO ) csw = 0xF0 | (csw << 2); - csw |= band; + if (di_param.m_committed_cmd <= eDVBSatelliteDiseqcParameters::SENDNO) + csw |= band; if ( di_param.m_diseqc_mode == eDVBSatelliteDiseqcParameters::V1_2 ) // ROTOR { @@ -208,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; + } + } } } } @@ -287,6 +342,8 @@ RESULT eDVBSatelliteEquipmentControl::prepare(iDVBFrontend &frontend, FRONTENDPA else parm.FREQUENCY = sat.frequency - lnb_param.m_lof_lo; + parm.FREQUENCY = abs(parm.FREQUENCY); + if (sat.polarisation == eDVBFrontendParametersSatellite::Polarisation::Horizontal) band |= 2; @@ -353,7 +410,8 @@ RESULT eDVBSatelliteEquipmentControl::prepare(iDVBFrontend &frontend, FRONTENDPA if ( di_param.m_committed_cmd < eDVBSatelliteDiseqcParameters::SENDNO ) csw = 0xF0 | (csw << 2); - csw |= band; + if (di_param.m_committed_cmd <= eDVBSatelliteDiseqcParameters::SENDNO) + csw |= band; bool send_csw = (di_param.m_committed_cmd != eDVBSatelliteDiseqcParameters::SENDNO); @@ -395,7 +453,10 @@ RESULT eDVBSatelliteEquipmentControl::prepare(iDVBFrontend &frontend, FRONTENDPA } if (changed_csw) { - if ( di_param.m_use_fast && (lastcsw & 0xF0) && ((csw / 4) == (lastcsw / 4)) ) + if ( di_param.m_use_fast + && di_param.m_committed_cmd < eDVBSatelliteDiseqcParameters::SENDNO + && (lastcsw & 0xF0) + && ((csw / 4) == (lastcsw / 4)) ) eDebug("dont send committed cmd (fast diseqc)"); else { @@ -595,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