+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;
+ return 0;
+}
+
+RESULT eDVBSatelliteEquipmentControl::setVoltageMode(int mode)
+{
+ eSecDebug("eDVBSatelliteEquipmentControl::setVoltageMode(%d)", mode);
+ if ( currentLNBValid() && m_curSat != m_lnbs[m_lnbidx].m_satellites.end() )
+ m_curSat->second.m_voltage_mode = (eDVBSatelliteSwitchParameters::t_voltage_mode)mode;
+ else
+ return -ENOENT;
+ return 0;
+
+}
+
+RESULT eDVBSatelliteEquipmentControl::setToneMode(int mode)
+{
+ eSecDebug("eDVBSatelliteEquipmentControl::setToneMode(%d)", mode);
+ if ( currentLNBValid() )
+ {
+ if ( m_curSat != m_lnbs[m_lnbidx].m_satellites.end() )
+ m_curSat->second.m_22khz_signal = (eDVBSatelliteSwitchParameters::t_22khz_signal)mode;
+ else
+ return -EPERM;
+ }
+ else
+ return -ENOENT;
+ return 0;
+}
+
+RESULT eDVBSatelliteEquipmentControl::setRotorPosNum(int rotor_pos_num)
+{
+ eSecDebug("eDVBSatelliteEquipmentControl::setRotorPosNum(%d)", rotor_pos_num);
+ if ( currentLNBValid() )
+ {
+ if ( m_curSat != m_lnbs[m_lnbidx].m_satellites.end() )
+ m_curSat->second.m_rotorPosNum=rotor_pos_num;
+ else
+ return -EPERM;
+ }
+ else
+ return -ENOENT;
+ return 0;
+}
+
+RESULT eDVBSatelliteEquipmentControl::setRotorTurningSpeed(int speed)
+{
+ eSecDebug("eDVBSatelliteEquipmentControl::setRotorTurningSpeed(%d)", speed);
+ if ( currentLNBValid() )
+ m_lnbs[m_lnbidx].m_rotor_parameters.m_inputpower_parameters.m_turning_speed = speed;
+ else
+ return -ENOENT;
+ return 0;
+}
+
+struct sat_compare
+{
+ int orb_pos, lofl, lofh;
+ sat_compare(int o, int lofl, int lofh)
+ :orb_pos(o), lofl(lofl), lofh(lofh)
+ {}
+ sat_compare(const sat_compare &x)
+ :orb_pos(x.orb_pos), lofl(x.lofl), lofh(x.lofh)
+ {}
+ bool operator < (const sat_compare & cmp) const
+ {
+ if (orb_pos == cmp.orb_pos)
+ {
+ if ( abs(lofl-cmp.lofl) < 200000 )
+ {
+ if (abs(lofh-cmp.lofh) < 200000)
+ return false;
+ return lofh<cmp.lofh;
+ }
+ return lofl<cmp.lofl;
+ }
+ return orb_pos < cmp.orb_pos;
+ }
+};
+
+RESULT eDVBSatelliteEquipmentControl::setTunerLinked(int tu1, int tu2)
+{
+ eSecDebug("eDVBSatelliteEquipmentControl::setTunerLinked(%d, %d)", tu1, tu2);
+ if (tu1 != tu2)
+ {
+ eDVBRegisteredFrontend *p1=NULL, *p2=NULL;
+
+ for (eSmartPtrList<eDVBRegisteredFrontend>::iterator it(m_avail_frontends.begin()); it != m_avail_frontends.end(); ++it)
+ {
+ if (it->m_frontend->getSlotID() == tu1)
+ p1 = *it;
+ else if (it->m_frontend->getSlotID() == tu2)
+ p2 = *it;
+ }
+ if (p1 && p2)
+ {
+ p1->m_frontend->setData(eDVBFrontend::LINKED_PREV_PTR, (long)p2);
+ p2->m_frontend->setData(eDVBFrontend::LINKED_NEXT_PTR, (long)p1);
+ if (!strcmp(p1->m_frontend->getDescription(), p2->m_frontend->getDescription()) && !strcmp(p1->m_frontend->getDescription(), "BCM4501 (internal)"))
+ {
+ FILE *f=fopen("/proc/stb/tsmux/lnb_b_input", "w");
+ if (!f || fwrite("A", 1, 1, f) != 1)
+ eDebug("set /proc/stb/tsmux/lnb_b_input to A failed!! (%m)");
+ else
+ {
+ eDebug("set /proc/stb/tsmux/lnb_b_input to A OK");
+ fclose(f);
+ }
+ }
+ }
+
+ p1=p2=NULL;
+ for (eSmartPtrList<eDVBRegisteredFrontend>::iterator it(m_avail_simulate_frontends.begin()); it != m_avail_simulate_frontends.end(); ++it)
+ {
+ if (it->m_frontend->getSlotID() == tu1)
+ p1 = *it;
+ else if (it->m_frontend->getSlotID() == tu2)
+ p2 = *it;
+ }
+ if (p1 && p2)
+ {
+ p1->m_frontend->setData(eDVBFrontend::LINKED_PREV_PTR, (long)p2);
+ p2->m_frontend->setData(eDVBFrontend::LINKED_NEXT_PTR, (long)p1);
+ return 0;
+ }
+ }
+ return -1;
+}
+
+RESULT eDVBSatelliteEquipmentControl::setTunerDepends(int tu1, int tu2)
+{
+ eSecDebug("eDVBSatelliteEquipmentControl::setTunerDepends(%d, %d)", tu1, tu2);
+ if (tu1 == tu2)
+ return -1;
+
+ eDVBRegisteredFrontend *p1=NULL, *p2=NULL;
+
+ for (eSmartPtrList<eDVBRegisteredFrontend>::iterator it(m_avail_frontends.begin()); it != m_avail_frontends.end(); ++it)
+ {
+ if (it->m_frontend->getSlotID() == tu1)
+ p1 = *it;
+ else if (it->m_frontend->getSlotID() == tu2)
+ p2 = *it;
+ }
+ if (p1 && p2)
+ {
+ p1->m_frontend->setData(eDVBFrontend::SATPOS_DEPENDS_PTR, (long)p2);
+ p2->m_frontend->setData(eDVBFrontend::SATPOS_DEPENDS_PTR, (long)p1);
+ }
+
+ p1=p2=NULL;
+ for (eSmartPtrList<eDVBRegisteredFrontend>::iterator it(m_avail_simulate_frontends.begin()); it != m_avail_simulate_frontends.end(); ++it)
+ {
+ if (it->m_frontend->getSlotID() == tu1)
+ p1 = *it;
+ else if (it->m_frontend->getSlotID() == tu2)
+ p2 = *it;
+ }
+ if (p1 && p2)
+ {
+ p1->m_frontend->setData(eDVBFrontend::SATPOS_DEPENDS_PTR, (long)p2);
+ p2->m_frontend->setData(eDVBFrontend::SATPOS_DEPENDS_PTR, (long)p1);
+ return 0;
+ }