2 #include <lib/dvb/sec.h>
3 #if HAVE_DVB_API_VERSION < 3
4 #define INVERSION Inversion
5 #define FREQUENCY Frequency
6 #define FEC_INNER FEC_inner
7 #define SYMBOLRATE SymbolRate
9 #define INVERSION inversion
10 #define FREQUENCY frequency
11 #define FEC_INNER fec_inner
12 #define SYMBOLRATE symbol_rate
14 #include <lib/base/eerror.h>
16 DEFINE_REF(eDVBSatelliteEquipmentControl);
18 eDVBSatelliteEquipmentControl::eDVBSatelliteEquipmentControl()
20 m_lnblist.push_back(eDVBSatelliteLNBParameters());
21 eDVBSatelliteLNBParameters &lnb_ref = m_lnblist.front();
22 eDVBSatelliteParameters &astra1 = lnb_ref.m_satellites[192];
23 eDVBSatelliteDiseqcParameters &diseqc_ref = astra1.m_diseqc_parameters;
24 eDVBSatelliteSwitchParameters &switch_ref = astra1.m_switch_parameters;
26 lnb_ref.m_lof_hi = 10607000;
27 lnb_ref.m_lof_lo = 9750000;
28 lnb_ref.m_lof_threshold = 11700000;
30 diseqc_ref.m_diseqc_mode = eDVBSatelliteDiseqcParameters::V1_0;
31 diseqc_ref.m_commited_cmd = eDVBSatelliteDiseqcParameters::BB;
32 diseqc_ref.m_repeats = 0;
33 diseqc_ref.m_seq_repeat = false;
34 diseqc_ref.m_swap_cmds = false;
35 diseqc_ref.m_toneburst_param = eDVBSatelliteDiseqcParameters::NO;
36 diseqc_ref.m_uncommitted_cmd = 0;
37 diseqc_ref.m_use_fast = 1;
39 switch_ref.m_22khz_signal = eDVBSatelliteSwitchParameters::HILO;
40 switch_ref.m_voltage_mode = eDVBSatelliteSwitchParameters::HV;
43 RESULT eDVBSatelliteEquipmentControl::prepare(iDVBFrontend &frontend, FRONTENDPARAMETERS &parm, eDVBFrontendParametersSatellite &sat)
45 std::list<eDVBSatelliteLNBParameters>::iterator it = m_lnblist.begin();
46 for (;it != m_lnblist.end(); ++it )
48 eDVBSatelliteLNBParameters &lnb_param = *it;
49 std::map<int, eDVBSatelliteParameters>::iterator sit =
50 lnb_param.m_satellites.find(sat.orbital_position);
51 if ( sit != lnb_param.m_satellites.end())
54 int voltage = iDVBFrontend::voltageOff;
55 int tone = iDVBFrontend::toneOff;
57 eDVBSatelliteDiseqcParameters &di_param = sit->second.m_diseqc_parameters;
58 eDVBSatelliteSwitchParameters &sw_param = sit->second.m_switch_parameters;
60 if ( sat.frequency > lnb_param.m_lof_threshold )
64 parm.FREQUENCY = sat.frequency - lnb_param.m_lof_hi;
66 parm.FREQUENCY = sat.frequency - lnb_param.m_lof_lo;
68 parm.INVERSION = (!sat.inversion) ? INVERSION_ON : INVERSION_OFF;
75 parm.u.qpsk.FEC_INNER = FEC_AUTO;
79 parm.u.qpsk.SYMBOLRATE = sat.symbol_rate;
81 if ( sw_param.m_voltage_mode == eDVBSatelliteSwitchParameters::_14V
82 || ( sat.polarisation == eDVBFrontendParametersSatellite::Polarisation::Vertical
83 && sw_param.m_voltage_mode == eDVBSatelliteSwitchParameters::HV ) )
84 voltage = iDVBFrontend::voltage13;
85 else if ( sw_param.m_voltage_mode == eDVBSatelliteSwitchParameters::_18V
86 || ( sat.polarisation == eDVBFrontendParametersSatellite::Polarisation::Horizontal
87 && sw_param.m_voltage_mode == eDVBSatelliteSwitchParameters::HV ) )
88 voltage = iDVBFrontend::voltage18;
90 if ( (sw_param.m_22khz_signal == eDVBSatelliteSwitchParameters::ON)
91 || ( sw_param.m_22khz_signal == eDVBSatelliteSwitchParameters::HILO && hi ) )
92 tone = iDVBFrontend::toneOn;
93 else if ( (sw_param.m_22khz_signal == eDVBSatelliteSwitchParameters::OFF)
94 || ( sw_param.m_22khz_signal == eDVBSatelliteSwitchParameters::HILO && !hi ) )
95 tone = iDVBFrontend::toneOff;
97 eSecCommandList sec_sequence;
99 if ( di_param.m_diseqc_mode == eDVBSatelliteDiseqcParameters::V1_2 )
103 else if (di_param.m_diseqc_mode >= eDVBSatelliteDiseqcParameters::V1_0)
105 if ( di_param.m_commited_cmd < eDVBSatelliteDiseqcParameters::SENDNO ||
106 di_param.m_toneburst_param != eDVBSatelliteDiseqcParameters::NO )
108 sec_sequence.push_back( eSecCommand(eSecCommand::SET_TONE, iDVBFrontend::toneOff) );
109 sec_sequence.push_back( eSecCommand(eSecCommand::SET_VOLTAGE, voltage) );
110 sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, 30) );
113 if ( di_param.m_commited_cmd < eDVBSatelliteDiseqcParameters::SENDNO )
115 eDVBDiseqcCommand diseqc;
117 diseqc.data[0] = 0xe0;
118 diseqc.data[1] = 0x10;
119 diseqc.data[2] = 0x38;
120 diseqc.data[3] = 0xF0 | (di_param.m_commited_cmd << 2);
125 if (sat.polarisation == eDVBFrontendParametersSatellite::Polarisation::Horizontal)
128 sec_sequence.push_back( eSecCommand(eSecCommand::SEND_DISEQC, diseqc) );
129 sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, 30) );
132 if ( di_param.m_toneburst_param != eDVBSatelliteDiseqcParameters::NO )
134 sec_sequence.push_back( eSecCommand(eSecCommand::SEND_TONEBURST, di_param.m_toneburst_param) );
135 sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, 30) );
140 sec_sequence.push_back( eSecCommand(eSecCommand::SET_VOLTAGE, voltage) );
141 sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, 10) );
144 sec_sequence.push_back( eSecCommand(eSecCommand::SET_TONE, tone) );
145 sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, 15) );
147 frontend.setSecSequence(sec_sequence);
153 eDebug("not found satellite configuration for orbital position (%d)", sat.orbital_position );