+ 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, m_params[DELAY_AFTER_FINAL_CONT_TONE_CHANGE]) );
+ sec_sequence.push_back( eSecCommand(eSecCommand::SET_FRONTEND) );
+
+ cmd.direction=1; // check for running rotor
+ cmd.deltaA=0;
+ cmd.steps=+3;
+ cmd.okcount=0;
+ sec_sequence.push_back( eSecCommand(eSecCommand::SET_TIMEOUT, m_params[MOTOR_RUNNING_TIMEOUT]*4) ); // 2 minutes running timeout
+ sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, 250) ); // 250msec delay
+ sec_sequence.push_back( eSecCommand(eSecCommand::IF_TUNER_LOCKED_GOTO, cmd ) );
+ sec_sequence.push_back( eSecCommand(eSecCommand::IF_TIMEOUT_GOTO, +3 ) );
+ sec_sequence.push_back( eSecCommand(eSecCommand::GOTO, -3) ); // goto loop start
+ sec_sequence.push_back( eSecCommand(eSecCommand::UPDATE_CURRENT_ROTORPARAMS) );
+ sec_sequence.push_back( eSecCommand(eSecCommand::SET_ROTOR_STOPPED) );
+ sec_sequence.push_back( eSecCommand(eSecCommand::GOTO, +3) );
+ sec_sequence.push_back( eSecCommand(eSecCommand::SET_FRONTEND) );
+ sec_sequence.push_back( eSecCommand(eSecCommand::GOTO, -4) );
+ }
+ }
+ sec_fe->setData(eDVBFrontend::NEW_ROTOR_CMD, RotorCmd);
+ sec_fe->setData(eDVBFrontend::NEW_ROTOR_POS, sat.orbital_position);
+ }
+ }
+ }
+ else
+ {
+ sec_sequence.push_back( eSecCommand(eSecCommand::INVALIDATE_CURRENT_SWITCHPARMS) );
+ csw = band;
+ }
+
+ sec_fe->setData(eDVBFrontend::NEW_CSW, csw);
+ sec_fe->setData(eDVBFrontend::NEW_UCSW, ucsw);
+ sec_fe->setData(eDVBFrontend::NEW_TONEBURST, di_param.m_toneburst_param);
+
+ if ((doSetVoltageToneFrontend) && (lnb_param.SatCR_idx == -1))
+ {
+ eSecCommand::pair compare;
+ 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, voltage) );
+ sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, m_params[DELAY_AFTER_FINAL_VOLTAGE_CHANGE]) );
+ 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, m_params[DELAY_AFTER_FINAL_CONT_TONE_CHANGE]) );
+ }
+
+ sec_sequence.push_back( eSecCommand(eSecCommand::UPDATE_CURRENT_SWITCHPARMS) );
+
+ if(lnb_param.SatCR_idx != -1)
+ {
+ // check if voltage is disabled
+ eSecCommand::pair compare;
+ compare.steps = +3;
+ compare.voltage = iDVBFrontend::voltageOff;
+ sec_sequence.push_back( eSecCommand(eSecCommand::IF_NOT_VOLTAGE_GOTO, compare) );
+ sec_sequence.push_back( eSecCommand(eSecCommand::SET_VOLTAGE, iDVBFrontend::voltage13) );
+ sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, m_params[DELAY_AFTER_ENABLE_VOLTAGE_BEFORE_SWITCH_CMDS] ) );
+
+ sec_sequence.push_back( eSecCommand(eSecCommand::SET_VOLTAGE, iDVBFrontend::voltage18_5) );
+ sec_sequence.push_back( eSecCommand(eSecCommand::SET_TONE, iDVBFrontend::toneOff) );
+ sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, m_params[DELAY_AFTER_VOLTAGE_CHANGE_BEFORE_SWITCH_CMDS]) ); // wait 20 ms after voltage change
+
+ eDVBDiseqcCommand diseqc;
+ memset(diseqc.data, 0, MAX_DISEQC_LENGTH);
+ diseqc.len = 5;
+ diseqc.data[0] = 0xE0;
+ diseqc.data[1] = 0x10;
+ diseqc.data[2] = 0x5A;
+ diseqc.data[3] = lnb_param.UnicableTuningWord >> 8;
+ diseqc.data[4] = lnb_param.UnicableTuningWord;
+
+ sec_sequence.push_back( eSecCommand(eSecCommand::SEND_DISEQC, diseqc) );
+ sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, m_params[DELAY_AFTER_LAST_DISEQC_CMD]) );
+ sec_sequence.push_back( eSecCommand(eSecCommand::SET_VOLTAGE, iDVBFrontend::voltage13) );
+ }
+
+ if (doSetFrontend)
+ {
+ sec_sequence.push_back( eSecCommand(eSecCommand::START_TUNE_TIMEOUT, tunetimeout) );
+ sec_sequence.push_back( eSecCommand(eSecCommand::SET_FRONTEND) );
+ }
+
+ if (forceStaticMode)
+ {
+ sec_sequence.push_front( eSecCommand(eSecCommand::SET_POWER_LIMITING_MODE, eSecCommand::modeStatic) );
+ sec_sequence.push_back( eSecCommand(eSecCommand::SET_POWER_LIMITING_MODE, eSecCommand::modeDynamic) );
+ }
+ frontend.setSecSequence(sec_sequence);
+
+ return 0;
+ }
+ }
+ eDebugNoSimulate("found no useable satellite configuration for %s freq %d%s %s on orbital position (%d)",
+ sat.system ? "DVB-S2" : "DVB-S",
+ sat.frequency,
+ sat.polarisation == eDVBFrontendParametersSatellite::Polarisation_Horizontal ? "H" :
+ eDVBFrontendParametersSatellite::Polarisation_Vertical ? "V" :
+ eDVBFrontendParametersSatellite::Polarisation_CircularLeft ? "CL" : "CR",
+ sat.modulation == eDVBFrontendParametersSatellite::Modulation_Auto ? "AUTO" :
+ eDVBFrontendParametersSatellite::Modulation_QPSK ? "QPSK" :
+ eDVBFrontendParametersSatellite::Modulation_8PSK ? "8PSK" : "QAM16",
+ sat.orbital_position );
+ return -1;
+}
+
+RESULT eDVBSatelliteEquipmentControl::clear()
+{
+ eSecDebug("eDVBSatelliteEquipmentControl::clear()");
+ for (int i=0; i <= m_lnbidx; ++i)
+ {
+ m_lnbs[i].m_satellites.clear();
+ m_lnbs[i].m_slot_mask = 0;
+ m_lnbs[i].m_prio = -1; // auto
+ }
+ m_lnbidx=-1;
+
+ m_not_linked_slot_mask=0;
+
+ //reset some tuner configuration
+ for (eSmartPtrList<eDVBRegisteredFrontend>::iterator it(m_avail_frontends.begin()); it != m_avail_frontends.end(); ++it)
+ {
+ long tmp;
+ if (!strcmp(it->m_frontend->getDescription(), "BCM4501 (internal)") && !it->m_frontend->getData(eDVBFrontend::LINKED_PREV_PTR, tmp) && tmp != -1)
+ {
+ FILE *f=fopen("/proc/stb/tsmux/lnb_b_input", "w");
+ if (!f || fwrite("B", 1, 1, f) != 1)
+ eDebug("set /proc/stb/tsmux/lnb_b_input to B failed!! (%m)");
+ else
+ {
+ eDebug("set /proc/stb/tsmux/lnb_b_input to B OK");
+ fclose(f);
+ }
+ }
+ it->m_frontend->setData(eDVBFrontend::SATPOS_DEPENDS_PTR, -1);
+ it->m_frontend->setData(eDVBFrontend::LINKED_PREV_PTR, -1);
+ it->m_frontend->setData(eDVBFrontend::LINKED_NEXT_PTR, -1);
+ it->m_frontend->setData(eDVBFrontend::ROTOR_POS, -1);
+ it->m_frontend->setData(eDVBFrontend::ROTOR_CMD, -1);
+ it->m_frontend->setData(eDVBFrontend::SATCR, -1);
+ }
+
+ for (eSmartPtrList<eDVBRegisteredFrontend>::iterator it(m_avail_simulate_frontends.begin()); it != m_avail_simulate_frontends.end(); ++it)
+ {
+ it->m_frontend->setData(eDVBFrontend::SATPOS_DEPENDS_PTR, -1);
+ it->m_frontend->setData(eDVBFrontend::LINKED_PREV_PTR, -1);
+ it->m_frontend->setData(eDVBFrontend::LINKED_NEXT_PTR, -1);
+ it->m_frontend->setData(eDVBFrontend::ROTOR_POS, -1);
+ it->m_frontend->setData(eDVBFrontend::ROTOR_CMD, -1);
+ it->m_frontend->setData(eDVBFrontend::SATCR, -1);
+ }
+
+ return 0;
+}
+
+/* LNB Specific Parameters */
+RESULT eDVBSatelliteEquipmentControl::addLNB()
+{
+ if ( (m_lnbidx+1) < (int)(sizeof(m_lnbs) / sizeof(eDVBSatelliteLNBParameters)))
+ m_curSat=m_lnbs[++m_lnbidx].m_satellites.end();
+ else
+ {
+ eDebug("no more LNB free... cnt is %d", m_lnbidx);
+ return -ENOSPC;
+ }
+ eSecDebug("eDVBSatelliteEquipmentControl::addLNB(%d)", m_lnbidx);
+ return 0;
+}
+
+RESULT eDVBSatelliteEquipmentControl::setLNBSlotMask(int slotmask)
+{
+ eSecDebug("eDVBSatelliteEquipmentControl::setLNBSlotMask(%d)", slotmask);
+ if ( currentLNBValid() )
+ m_lnbs[m_lnbidx].m_slot_mask = slotmask;
+ else
+ return -ENOENT;
+ return 0;
+}
+
+RESULT eDVBSatelliteEquipmentControl::setLNBLOFL(int lofl)
+{
+ eSecDebug("eDVBSatelliteEquipmentControl::setLNBLOFL(%d)", lofl);
+ if ( currentLNBValid() )
+ m_lnbs[m_lnbidx].m_lof_lo = lofl;
+ else
+ return -ENOENT;
+ return 0;
+}
+
+RESULT eDVBSatelliteEquipmentControl::setLNBLOFH(int lofh)
+{
+ eSecDebug("eDVBSatelliteEquipmentControl::setLNBLOFH(%d)", lofh);
+ if ( currentLNBValid() )
+ m_lnbs[m_lnbidx].m_lof_hi = lofh;
+ else
+ return -ENOENT;
+ return 0;
+}
+
+RESULT eDVBSatelliteEquipmentControl::setLNBThreshold(int threshold)
+{
+ eSecDebug("eDVBSatelliteEquipmentControl::setLNBThreshold(%d)", threshold);
+ if ( currentLNBValid() )
+ m_lnbs[m_lnbidx].m_lof_threshold = threshold;
+ else
+ return -ENOENT;
+ return 0;
+}
+
+RESULT eDVBSatelliteEquipmentControl::setLNBIncreasedVoltage(bool onoff)
+{
+ eSecDebug("eDVBSatelliteEquipmentControl::setLNBIncreasedVoltage(%d)", onoff);
+ if ( currentLNBValid() )
+ m_lnbs[m_lnbidx].m_increased_voltage = onoff;
+ else
+ return -ENOENT;
+ return 0;
+}
+
+RESULT eDVBSatelliteEquipmentControl::setLNBPrio(int prio)
+{
+ eSecDebug("eDVBSatelliteEquipmentControl::setLNBPrio(%d)", prio);
+ if ( currentLNBValid() )
+ m_lnbs[m_lnbidx].m_prio = prio;
+ else
+ return -ENOENT;
+ return 0;
+}
+
+RESULT eDVBSatelliteEquipmentControl::setLNBNum(int LNBNum)
+{
+ eSecDebug("eDVBSatelliteEquipmentControl::setLNBNum(%d)", LNBNum);
+ if(!((LNBNum >= 1) && (LNBNum <= MAX_LNBNUM)))
+ return -EPERM;
+ if ( currentLNBValid() )
+ m_lnbs[m_lnbidx].LNBNum = LNBNum;
+ else
+ return -ENOENT;
+ return 0;
+}
+
+/* DiSEqC Specific Parameters */
+RESULT eDVBSatelliteEquipmentControl::setDiSEqCMode(int diseqcmode)
+{
+ eSecDebug("eDVBSatelliteEquipmentControl::setDiSEqcMode(%d)", diseqcmode);
+ if ( currentLNBValid() )
+ m_lnbs[m_lnbidx].m_diseqc_parameters.m_diseqc_mode = (eDVBSatelliteDiseqcParameters::t_diseqc_mode)diseqcmode;
+ else
+ return -ENOENT;
+ return 0;
+}
+
+RESULT eDVBSatelliteEquipmentControl::setToneburst(int toneburst)
+{
+ eSecDebug("eDVBSatelliteEquipmentControl::setToneburst(%d)", toneburst);
+ if ( currentLNBValid() )
+ m_lnbs[m_lnbidx].m_diseqc_parameters.m_toneburst_param = (eDVBSatelliteDiseqcParameters::t_toneburst_param)toneburst;
+ else
+ return -ENOENT;
+ return 0;
+}
+
+RESULT eDVBSatelliteEquipmentControl::setRepeats(int repeats)
+{
+ eSecDebug("eDVBSatelliteEquipmentControl::setRepeats(%d)", repeats);
+ if ( currentLNBValid() )
+ m_lnbs[m_lnbidx].m_diseqc_parameters.m_repeats=repeats;
+ else
+ return -ENOENT;
+ return 0;
+}
+
+RESULT eDVBSatelliteEquipmentControl::setCommittedCommand(int command)
+{
+ eSecDebug("eDVBSatelliteEquipmentControl::setCommittedCommand(%d)", command);
+ if ( currentLNBValid() )
+ m_lnbs[m_lnbidx].m_diseqc_parameters.m_committed_cmd=command;
+ else
+ return -ENOENT;
+ return 0;
+}
+
+RESULT eDVBSatelliteEquipmentControl::setUncommittedCommand(int command)
+{
+ eSecDebug("eDVBSatelliteEquipmentControl::setUncommittedCommand(%d)", command);
+ if ( currentLNBValid() )
+ m_lnbs[m_lnbidx].m_diseqc_parameters.m_uncommitted_cmd = command;
+ else
+ return -ENOENT;
+ return 0;
+}
+
+RESULT eDVBSatelliteEquipmentControl::setCommandOrder(int order)
+{
+ eSecDebug("eDVBSatelliteEquipmentControl::setCommandOrder(%d)", order);
+ if ( currentLNBValid() )
+ m_lnbs[m_lnbidx].m_diseqc_parameters.m_command_order=order;
+ else
+ return -ENOENT;
+ return 0;
+}
+
+RESULT eDVBSatelliteEquipmentControl::setFastDiSEqC(bool onoff)
+{
+ eSecDebug("eDVBSatelliteEquipmentControl::setFastDiSEqc(%d)", onoff);
+ if ( currentLNBValid() )
+ m_lnbs[m_lnbidx].m_diseqc_parameters.m_use_fast=onoff;
+ else
+ return -ENOENT;
+ return 0;
+}
+
+RESULT eDVBSatelliteEquipmentControl::setSeqRepeat(bool onoff)
+{
+ eSecDebug("eDVBSatelliteEquipmentControl::setSeqRepeat(%d)", onoff);
+ if ( currentLNBValid() )
+ m_lnbs[m_lnbidx].m_diseqc_parameters.m_seq_repeat = onoff;
+ else
+ return -ENOENT;
+ return 0;
+}
+
+/* Rotor Specific Parameters */
+RESULT eDVBSatelliteEquipmentControl::setLongitude(float longitude)
+{
+ eSecDebug("eDVBSatelliteEquipmentControl::setLongitude(%f)", longitude);
+ if ( currentLNBValid() )
+ m_lnbs[m_lnbidx].m_rotor_parameters.m_gotoxx_parameters.m_longitude=longitude;
+ else
+ return -ENOENT;
+ return 0;
+}
+
+RESULT eDVBSatelliteEquipmentControl::setLatitude(float latitude)
+{
+ eSecDebug("eDVBSatelliteEquipmentControl::setLatitude(%f)", latitude);
+ if ( currentLNBValid() )
+ m_lnbs[m_lnbidx].m_rotor_parameters.m_gotoxx_parameters.m_latitude=latitude;
+ else
+ return -ENOENT;
+ return 0;
+}
+
+RESULT eDVBSatelliteEquipmentControl::setLoDirection(int direction)
+{
+ eSecDebug("eDVBSatelliteEquipmentControl::setLoDirection(%d)", direction);
+ if ( currentLNBValid() )
+ m_lnbs[m_lnbidx].m_rotor_parameters.m_gotoxx_parameters.m_lo_direction=direction;
+ else
+ return -ENOENT;
+ return 0;
+}
+
+RESULT eDVBSatelliteEquipmentControl::setLaDirection(int direction)
+{
+ eSecDebug("eDVBSatelliteEquipmentControl::setLaDirection(%d)", direction);
+ if ( currentLNBValid() )
+ m_lnbs[m_lnbidx].m_rotor_parameters.m_gotoxx_parameters.m_la_direction=direction;
+ else
+ return -ENOENT;
+ return 0;
+}
+
+RESULT eDVBSatelliteEquipmentControl::setUseInputpower(bool onoff)
+{
+ eSecDebug("eDVBSatelliteEquipmentControl::setUseInputpower(%d)", onoff);
+ if ( currentLNBValid() )
+ m_lnbs[m_lnbidx].m_rotor_parameters.m_inputpower_parameters.m_use=onoff;
+ else
+ return -ENOENT;
+ return 0;
+}