4 #include <lib/dvb/idvb.h>
11 enum { modeStatic, modeDynamic };
13 NONE, SLEEP, SET_VOLTAGE, SET_TONE, GOTO,
14 SEND_DISEQC, SEND_TONEBURST, SET_FRONTEND,
15 SET_TIMEOUT, IF_TIMEOUT_GOTO,
16 IF_VOLTAGE_GOTO, IF_NOT_VOLTAGE_GOTO,
17 SET_POWER_LIMITING_MODE,
18 SET_ROTOR_DISEQC_RETRYS, IF_NO_MORE_ROTOR_DISEQC_RETRYS_GOTO,
19 MEASURE_IDLE_INPUTPOWER, MEASURE_RUNNING_INPUTPOWER,
20 IF_MEASURE_IDLE_WAS_NOT_OK_GOTO, IF_INPUTPOWER_DELTA_GOTO,
21 UPDATE_CURRENT_ROTORPARAMS, INVALIDATE_CURRENT_ROTORPARMS,
22 UPDATE_CURRENT_SWITCHPARMS, INVALIDATE_CURRENT_SWITCHPARMS,
25 IF_NOT_ROTOR_PENDING_GOTO,
26 IF_ROTORPOS_VALID_GOTO,
28 IF_TONE_GOTO, IF_NOT_TONE_GOTO,
32 DELAYED_CLOSE_FRONTEND,
33 IF_ACQUIRE_SEC_LOCK_GOTO,
40 int deltaA; // difference in mA between running and stopped rotor
43 int okcount; // counter
44 int steps; // goto steps
68 eDVBDiseqcCommand diseqc;
71 eSecCommand( int cmd )
74 eSecCommand( int cmd, int val )
77 eSecCommand( int cmd, eDVBDiseqcCommand diseqc )
78 :cmd(cmd), diseqc(diseqc)
80 eSecCommand( int cmd, rotor measure )
81 :cmd(cmd), measure(measure)
83 eSecCommand( int cmd, pair compare )
84 :cmd(cmd), compare(compare)
93 typedef std::list<eSecCommand> List;
96 typedef List::iterator iterator;
101 :cur(secSequence.end())
104 void push_front(const eSecCommand &cmd)
106 secSequence.push_front(cmd);
108 void push_back(const eSecCommand &cmd)
110 secSequence.push_back(cmd);
112 void push_back(eSecCommandList &list)
114 secSequence.insert(end(), list.begin(), list.end());
119 cur=secSequence.end();
121 inline iterator ¤t()
125 inline iterator begin()
127 return secSequence.begin();
129 inline iterator end()
131 return secSequence.end();
135 return secSequence.size();
137 operator bool() const
139 return secSequence.size();
141 eSecCommandList &operator=(const eSecCommandList &lst)
143 secSequence = lst.secSequence;
150 class eDVBSatelliteDiseqcParameters
153 eDVBSatelliteDiseqcParameters();
154 ~eDVBSatelliteDiseqcParameters();
157 enum { AA=0, AB=1, BA=2, BB=3, SENDNO=4 /* and 0xF0 .. 0xFF*/ }; // DiSEqC Parameter
158 enum t_diseqc_mode { NONE=0, V1_0=1, V1_1=2, V1_2=3, SMATV=4 }; // DiSEqC Mode
159 enum t_toneburst_param { NO=0, A=1, B=2 };
161 __u8 m_committed_cmd;
162 t_diseqc_mode m_diseqc_mode;
163 t_toneburst_param m_toneburst_param;
165 __u8 m_repeats; // for cascaded switches
166 bool m_use_fast; // send no DiSEqC on H/V or Lo/Hi change
167 bool m_seq_repeat; // send the complete DiSEqC Sequence twice...
168 __u8 m_command_order;
170 0) commited, toneburst
171 1) toneburst, committed
173 2) committed, uncommitted, toneburst
174 3) toneburst, committed, uncommitted
175 4) uncommitted, committed, toneburst
176 5) toneburst, uncommitted, committed */
177 __u8 m_uncommitted_cmd; // state of the 4 uncommitted switches..
181 class eDVBSatelliteSwitchParameters
184 eDVBSatelliteSwitchParameters();
185 ~eDVBSatelliteSwitchParameters();
188 enum t_22khz_signal { HILO=0, ON=1, OFF=2 }; // 22 Khz
189 enum t_voltage_mode { HV=0, _14V=1, _18V=2, _0V=3, HV_13=4 }; // 14/18 V
191 t_voltage_mode m_voltage_mode;
192 t_22khz_signal m_22khz_signal;
193 __u8 m_rotorPosNum; // 0 is disable.. then use gotoxx
197 class eDVBSatelliteRotorParameters
200 eDVBSatelliteRotorParameters();
201 ~eDVBSatelliteRotorParameters();
204 enum { NORTH, SOUTH, EAST, WEST };
207 eDVBSatelliteRotorParameters() { setDefaultOptions(); }
209 struct eDVBSatelliteRotorInputpowerParameters
211 bool m_use; // can we use rotor inputpower to detect rotor running state ?
212 __u8 m_delta; // delta between running and stopped rotor
213 unsigned int m_turning_speed; // SLOW, FAST, or fast turning epoch
215 eDVBSatelliteRotorInputpowerParameters m_inputpower_parameters;
217 struct eDVBSatelliteRotorGotoxxParameters
219 __u8 m_lo_direction; // EAST, WEST
220 __u8 m_la_direction; // NORT, SOUTH
221 double m_longitude; // longitude for gotoXX? function
222 double m_latitude; // latitude for gotoXX? function
224 eDVBSatelliteRotorGotoxxParameters m_gotoxx_parameters;
226 void setDefaultOptions() // set default rotor options
228 m_inputpower_parameters.m_turning_speed = FAST; // fast turning
229 m_inputpower_parameters.m_use = true;
230 m_inputpower_parameters.m_delta = 60;
231 m_gotoxx_parameters.m_lo_direction = EAST;
232 m_gotoxx_parameters.m_la_direction = NORTH;
233 m_gotoxx_parameters.m_longitude = 0.0;
234 m_gotoxx_parameters.m_latitude = 0.0;
239 class eDVBSatelliteLNBParameters
242 eDVBSatelliteLNBParameters();
243 ~eDVBSatelliteLNBParameters();
246 enum t_12V_relais_state { OFF=0, ON };
248 t_12V_relais_state m_12V_relais_state; // 12V relais output on/off
250 int m_slot_mask; // useable by slot ( 1 | 2 | 4...)
252 unsigned int m_lof_hi, // for 2 band universal lnb 10600 Mhz (high band offset frequency)
253 m_lof_lo, // for 2 band universal lnb 9750 Mhz (low band offset frequency)
254 m_lof_threshold; // for 2 band universal lnb 11750 Mhz (band switch frequency)
256 bool m_increased_voltage; // use increased voltage ( 14/18V )
258 std::map<int, eDVBSatelliteSwitchParameters> m_satellites;
259 eDVBSatelliteDiseqcParameters m_diseqc_parameters;
260 eDVBSatelliteRotorParameters m_rotor_parameters;
262 int m_prio; // to override automatic tuner management ... -1 is Auto
265 #define guard_offset_min -8000
266 #define guard_offset_max 8000
267 #define guard_offset_step 8000
269 #define MAX_LNBNUM 32
273 unsigned int SatCRvco;
274 unsigned int UnicableTuningWord;
275 unsigned int UnicableConfigWord;
278 int old_polarisation;
279 int old_orbital_position;
280 int guard_offset_old;
286 class eDVBRegisteredFrontend;
288 class eDVBSatelliteEquipmentControl: public iDVBSatelliteEquipmentControl
290 DECLARE_REF(eDVBSatelliteEquipmentControl);
293 DELAY_AFTER_CONT_TONE_DISABLE_BEFORE_DISEQC=0, // delay after continuous tone disable before diseqc command
294 DELAY_AFTER_FINAL_CONT_TONE_CHANGE, // delay after continuous tone change before tune
295 DELAY_AFTER_FINAL_VOLTAGE_CHANGE, // delay after voltage change at end of complete sequence
296 DELAY_BETWEEN_DISEQC_REPEATS, // delay between repeated diseqc commands
297 DELAY_AFTER_LAST_DISEQC_CMD, // delay after last diseqc command
298 DELAY_AFTER_TONEBURST, // delay after toneburst
299 DELAY_AFTER_ENABLE_VOLTAGE_BEFORE_SWITCH_CMDS, // delay after enable voltage before transmit toneburst/diseqc
300 DELAY_BETWEEN_SWITCH_AND_MOTOR_CMD, // delay after transmit toneburst / diseqc and before transmit motor command
301 DELAY_AFTER_VOLTAGE_CHANGE_BEFORE_MEASURE_IDLE_INPUTPOWER, // delay after voltage change before measure idle input power
302 DELAY_AFTER_ENABLE_VOLTAGE_BEFORE_MOTOR_CMD, // delay after enable voltage before transmit motor command
303 DELAY_AFTER_MOTOR_STOP_CMD, // delay after transmit motor stop
304 DELAY_AFTER_VOLTAGE_CHANGE_BEFORE_MOTOR_CMD, // delay after voltage change before transmit motor command
305 DELAY_BEFORE_SEQUENCE_REPEAT, // delay before the complete sequence is repeated (when enabled)
306 MOTOR_COMMAND_RETRIES, // max transmit tries of rotor command when the rotor dont start turning (with power measurement)
307 MOTOR_RUNNING_TIMEOUT, // max motor running time before timeout
308 DELAY_AFTER_VOLTAGE_CHANGE_BEFORE_SWITCH_CMDS, // delay after change voltage before transmit toneburst/diseqc
309 DELAY_AFTER_DISEQC_RESET_CMD,
310 DELAY_AFTER_DISEQC_PERIPHERIAL_POWERON_CMD,
315 static eDVBSatelliteEquipmentControl *instance;
316 eDVBSatelliteLNBParameters m_lnbs[144]; // i think its enough
317 int m_lnbidx; // current index for set parameters
318 std::map<int, eDVBSatelliteSwitchParameters>::iterator m_curSat;
319 eSmartPtrList<eDVBRegisteredFrontend> &m_avail_frontends, &m_avail_simulate_frontends;
321 int m_not_linked_slot_mask;
322 bool m_canMeasureInputPower;
325 eDVBSatelliteEquipmentControl();
326 ~eDVBSatelliteEquipmentControl();
328 static int m_params[MAX_PARAMS];
331 eDVBSatelliteEquipmentControl(eSmartPtrList<eDVBRegisteredFrontend> &avail_frontends, eSmartPtrList<eDVBRegisteredFrontend> &avail_simulate_frontends);
332 RESULT prepare(iDVBFrontend &frontend, FRONTENDPARAMETERS &parm, const eDVBFrontendParametersSatellite &sat, int frontend_id, unsigned int tunetimeout);
333 void prepareClose(iDVBFrontend &frontend);
334 int canTune(const eDVBFrontendParametersSatellite &feparm, iDVBFrontend *, int frontend_id, int *highest_score_lnb=0);
335 bool currentLNBValid() { return m_lnbidx > -1 && m_lnbidx < (int)(sizeof(m_lnbs) / sizeof(eDVBSatelliteLNBParameters)); }
337 static eDVBSatelliteEquipmentControl *getInstance() { return instance; }
338 static void setParam(int param, int value);
340 /* LNB Specific Parameters */
342 RESULT setLNBSlotMask(int slotmask);
343 RESULT setLNBLOFL(int lofl);
344 RESULT setLNBLOFH(int lofh);
345 RESULT setLNBThreshold(int threshold);
346 RESULT setLNBIncreasedVoltage(bool onoff);
347 RESULT setLNBPrio(int prio);
348 RESULT setLNBNum(int LNBNum);
349 /* DiSEqC Specific Parameters */
350 RESULT setDiSEqCMode(int diseqcmode);
351 RESULT setToneburst(int toneburst);
352 RESULT setRepeats(int repeats);
353 RESULT setCommittedCommand(int command);
354 RESULT setUncommittedCommand(int command);
355 RESULT setCommandOrder(int order);
356 RESULT setFastDiSEqC(bool onoff);
357 RESULT setSeqRepeat(bool onoff); // send the complete switch sequence twice (without rotor command)
358 /* Rotor Specific Parameters */
359 RESULT setLongitude(float longitude);
360 RESULT setLatitude(float latitude);
361 RESULT setLoDirection(int direction);
362 RESULT setLaDirection(int direction);
363 RESULT setUseInputpower(bool onoff);
364 RESULT setInputpowerDelta(int delta); // delta between running and stopped rotor
365 RESULT setRotorTurningSpeed(int speed); // set turning speed..
366 /* Unicable Specific Parameters */
367 RESULT setLNBSatCR(int SatCR_idx);
368 RESULT setLNBSatCRvco(int SatCRvco);
369 RESULT setLNBSatCRpositions(int SatCR_positions);
370 RESULT getLNBSatCR();
371 RESULT getLNBSatCRvco();
372 RESULT getLNBSatCRpositions();
373 /* Satellite Specific Parameters */
374 RESULT addSatellite(int orbital_position);
375 RESULT setVoltageMode(int mode);
376 RESULT setToneMode(int mode);
377 RESULT setRotorPosNum(int rotor_pos_num);
378 /* Tuner Specific Parameters */
379 RESULT setTunerLinked(int from, int to);
380 RESULT setTunerDepends(int from, int to);
381 void setSlotNotLinked(int tuner_no);
383 SWIG_PYOBJECT(ePyObject) getFrequencyRangeList(int slot_no, int orb_pos);
384 void setRotorMoving(int, bool); // called from the frontend's
385 bool isRotorMoving();
386 bool canMeasureInputPower() { return m_canMeasureInputPower; }