+ 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;
+}
+
+RESULT eDVBSatelliteEquipmentControl::setInputpowerDelta(int delta)
+{
+ eSecDebug("eDVBSatelliteEquipmentControl::setInputpowerDelta(%d)", delta);
+ if ( currentLNBValid() )
+ m_lnbs[m_lnbidx].m_rotor_parameters.m_inputpower_parameters.m_delta=delta;
+ else
+ return -ENOENT;
+ return 0;
+}
+
+/* Unicable Specific Parameters */
+RESULT eDVBSatelliteEquipmentControl::setLNBSatCR(int SatCR_idx)
+{
+ eSecDebug("eDVBSatelliteEquipmentControl::setLNBSatCR(%d)", SatCR_idx);
+ if(!((SatCR_idx >=-1) && (SatCR_idx < MAX_SATCR)))
+ return -EPERM;
+ if ( currentLNBValid() )
+ m_lnbs[m_lnbidx].SatCR_idx = SatCR_idx;
+ else
+ return -ENOENT;
+ return 0;
+}
+
+RESULT eDVBSatelliteEquipmentControl::setLNBSatCRvco(int SatCRvco)
+{
+ eSecDebug("eDVBSatelliteEquipmentControl::setLNBSatCRvco(%d)", SatCRvco);
+ if(!((SatCRvco >= 950*1000) && (SatCRvco <= 2150*1000)))
+ return -EPERM;
+ if(!((m_lnbs[m_lnbidx].SatCR_idx >= 0) && (m_lnbs[m_lnbidx].SatCR_idx < MAX_SATCR)))
+ return -ENOENT;
+ if ( currentLNBValid() )
+ m_lnbs[m_lnbidx].SatCRvco = SatCRvco;
+ else
+ return -ENOENT;
+ return 0;
+}
+RESULT eDVBSatelliteEquipmentControl::getLNBSatCR()
+{
+ if ( currentLNBValid() )
+ return m_lnbs[m_lnbidx].SatCR_idx;
+ return -ENOENT;
+}
+
+RESULT eDVBSatelliteEquipmentControl::getLNBSatCRvco()
+{
+ if ( currentLNBValid() )
+ return m_lnbs[m_lnbidx].SatCRvco;
+ return -ENOENT;
+}
+
+/* Satellite Specific Parameters */
+RESULT eDVBSatelliteEquipmentControl::addSatellite(int orbital_position)
+{
+ eSecDebug("eDVBSatelliteEquipmentControl::addSatellite(%d)", orbital_position);
+ if ( currentLNBValid() )
+ {
+ std::map<int, eDVBSatelliteSwitchParameters>::iterator it =
+ m_lnbs[m_lnbidx].m_satellites.find(orbital_position);
+ if ( it == m_lnbs[m_lnbidx].m_satellites.end() )
+ {
+ std::pair<std::map<int, eDVBSatelliteSwitchParameters>::iterator, bool > ret =
+ m_lnbs[m_lnbidx].m_satellites.insert(
+ std::pair<int, eDVBSatelliteSwitchParameters>(orbital_position, eDVBSatelliteSwitchParameters())
+ );
+ if ( ret.second )
+ m_curSat = ret.first;
+ else
+ return -ENOMEM;
+ }
+ else
+ return -EEXIST;
+ }
+ else
+ return -ENOENT;