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,
23 IF_ROTORPOS_VALID_GOTO,
25 IF_TONE_GOTO, IF_NOT_TONE_GOTO,
34 int deltaA; // difference in mA between running and stopped rotor
37 int okcount; // counter
38 int steps; // goto steps
62 eDVBDiseqcCommand diseqc;
65 eSecCommand( int cmd )
68 eSecCommand( int cmd, int val )
71 eSecCommand( int cmd, eDVBDiseqcCommand diseqc )
72 :cmd(cmd), diseqc(diseqc)
74 eSecCommand( int cmd, rotor measure )
75 :cmd(cmd), measure(measure)
77 eSecCommand( int cmd, pair compare )
78 :cmd(cmd), compare(compare)
87 typedef std::list<eSecCommand> List;
90 typedef List::iterator iterator;
95 :cur(secSequence.end())
98 void push_front(const eSecCommand &cmd)
100 secSequence.push_front(cmd);
102 void push_back(const eSecCommand &cmd)
104 secSequence.push_back(cmd);
109 cur=secSequence.end();
111 inline iterator ¤t()
115 inline iterator begin()
117 return secSequence.begin();
119 inline iterator end()
121 return secSequence.end();
125 return secSequence.size();
127 operator bool() const
129 return secSequence.size();
134 class eDVBSatelliteDiseqcParameters
137 eDVBSatelliteDiseqcParameters();
138 ~eDVBSatelliteDiseqcParameters();
141 enum { AA=0, AB=1, BA=2, BB=3, SENDNO=4 /* and 0xF0 .. 0xFF*/ }; // DiSEqC Parameter
142 enum t_diseqc_mode { NONE=0, V1_0=1, V1_1=2, V1_2=3, SMATV=4 }; // DiSEqC Mode
143 enum t_toneburst_param { NO=0, A=1, B=2 };
145 __u8 m_committed_cmd;
146 t_diseqc_mode m_diseqc_mode;
147 t_toneburst_param m_toneburst_param;
149 __u8 m_repeats; // for cascaded switches
150 bool m_use_fast; // send no DiSEqC on H/V or Lo/Hi change
151 bool m_seq_repeat; // send the complete DiSEqC Sequence twice...
152 __u8 m_command_order;
154 0) commited, toneburst
155 1) toneburst, committed
157 2) committed, uncommitted, toneburst
158 3) toneburst, committed, uncommitted
159 4) uncommitted, committed, toneburst
160 5) toneburst, uncommitted, committed */
161 __u8 m_uncommitted_cmd; // state of the 4 uncommitted switches..
165 class eDVBSatelliteSwitchParameters
168 eDVBSatelliteSwitchParameters();
169 ~eDVBSatelliteSwitchParameters();
172 enum t_22khz_signal { HILO=0, ON=1, OFF=2 }; // 22 Khz
173 enum t_voltage_mode { HV=0, _14V=1, _18V=2, _0V=3 }; // 14/18 V
175 t_voltage_mode m_voltage_mode;
176 t_22khz_signal m_22khz_signal;
177 __u8 m_rotorPosNum; // 0 is disable.. then use gotoxx
181 class eDVBSatelliteRotorParameters
184 eDVBSatelliteRotorParameters();
185 ~eDVBSatelliteRotorParameters();
188 enum { NORTH, SOUTH, EAST, WEST };
191 eDVBSatelliteRotorParameters() { setDefaultOptions(); }
193 struct eDVBSatelliteRotorInputpowerParameters
195 bool m_use; // can we use rotor inputpower to detect rotor running state ?
196 __u8 m_delta; // delta between running and stopped rotor
197 unsigned int m_turning_speed; // SLOW, FAST, or fast turning epoch
199 eDVBSatelliteRotorInputpowerParameters m_inputpower_parameters;
201 struct eDVBSatelliteRotorGotoxxParameters
203 __u8 m_lo_direction; // EAST, WEST
204 __u8 m_la_direction; // NORT, SOUTH
205 double m_longitude; // longitude for gotoXX? function
206 double m_latitude; // latitude for gotoXX? function
208 eDVBSatelliteRotorGotoxxParameters m_gotoxx_parameters;
210 void setDefaultOptions() // set default rotor options
212 m_inputpower_parameters.m_turning_speed = FAST; // fast turning
213 m_inputpower_parameters.m_use = true;
214 m_inputpower_parameters.m_delta = 60;
215 m_gotoxx_parameters.m_lo_direction = EAST;
216 m_gotoxx_parameters.m_la_direction = NORTH;
217 m_gotoxx_parameters.m_longitude = 0.0;
218 m_gotoxx_parameters.m_latitude = 0.0;
223 class eDVBSatelliteLNBParameters
226 eDVBSatelliteLNBParameters();
227 ~eDVBSatelliteLNBParameters();
230 enum t_12V_relais_state { OFF=0, ON };
232 t_12V_relais_state m_12V_relais_state; // 12V relais output on/off
234 __u8 slot_mask; // useable by slot ( 1 | 2 | 4...)
236 unsigned int m_lof_hi, // for 2 band universal lnb 10600 Mhz (high band offset frequency)
237 m_lof_lo, // for 2 band universal lnb 9750 Mhz (low band offset frequency)
238 m_lof_threshold; // for 2 band universal lnb 11750 Mhz (band switch frequency)
240 bool m_increased_voltage; // use increased voltage ( 14/18V )
242 std::map<int, eDVBSatelliteSwitchParameters> m_satellites;
243 eDVBSatelliteDiseqcParameters m_diseqc_parameters;
244 eDVBSatelliteRotorParameters m_rotor_parameters;
248 class eDVBRegisteredFrontend;
250 class eDVBSatelliteEquipmentControl: public iDVBSatelliteEquipmentControl
252 DECLARE_REF(eDVBSatelliteEquipmentControl);
255 DELAY_AFTER_CONT_TONE=0, // delay after continuous tone change
256 DELAY_AFTER_FINAL_VOLTAGE_CHANGE, // delay after voltage change at end of complete sequence
257 DELAY_BETWEEN_DISEQC_REPEATS, // delay between repeated diseqc commands
258 DELAY_AFTER_LAST_DISEQC_CMD, // delay after last diseqc command
259 DELAY_AFTER_TONEBURST, // delay after toneburst
260 DELAY_AFTER_ENABLE_VOLTAGE_BEFORE_SWITCH_CMDS, // delay after enable voltage before transmit toneburst/diseqc
261 DELAY_BETWEEN_SWITCH_AND_MOTOR_CMD, // delay after transmit toneburst / diseqc and before transmit motor command
262 DELAY_AFTER_VOLTAGE_CHANGE_BEFORE_MEASURE_IDLE_INPUTPOWER, // delay after voltage change before measure idle input power
263 DELAY_AFTER_ENABLE_VOLTAGE_BEFORE_MOTOR_CMD, // delay after enable voltage before transmit motor command
264 DELAY_AFTER_MOTOR_STOP_CMD, // delay after transmit motor stop
265 DELAY_AFTER_VOLTAGE_CHANGE_BEFORE_MOTOR_CMD, // delay after voltage change before transmit motor command
266 DELAY_BEFORE_SEQUENCE_REPEAT, // delay before the complete sequence is repeated (when enabled)
267 MOTOR_COMMAND_RETRIES, // max transmit tries of rotor command when the rotor dont start turning (with power measurement)
268 MOTOR_RUNNING_TIMEOUT, // max motor running time before timeout
269 DELAY_AFTER_VOLTAGE_CHANGE_BEFORE_SWITCH_CMDS, // delay after change voltage before transmit toneburst/diseqc
274 static eDVBSatelliteEquipmentControl *instance;
275 eDVBSatelliteLNBParameters m_lnbs[144]; // i think its enough
276 int m_lnbidx; // current index for set parameters
277 std::map<int, eDVBSatelliteSwitchParameters>::iterator m_curSat;
278 eSmartPtrList<eDVBRegisteredFrontend> &m_avail_frontends, &m_avail_simulate_frontends;
280 int m_not_linked_slot_mask;
281 bool m_canMeasureInputPower;
284 eDVBSatelliteEquipmentControl();
285 ~eDVBSatelliteEquipmentControl();
287 static int m_params[MAX_PARAMS];
290 eDVBSatelliteEquipmentControl(eSmartPtrList<eDVBRegisteredFrontend> &avail_frontends, eSmartPtrList<eDVBRegisteredFrontend> &avail_simulate_frontends);
291 RESULT prepare(iDVBFrontend &frontend, FRONTENDPARAMETERS &parm, const eDVBFrontendParametersSatellite &sat, int frontend_id, unsigned int tunetimeout);
292 int canTune(const eDVBFrontendParametersSatellite &feparm, iDVBFrontend *, int frontend_id, int *highest_score_lnb=0);
293 bool currentLNBValid() { return m_lnbidx > -1 && m_lnbidx < (int)(sizeof(m_lnbs) / sizeof(eDVBSatelliteLNBParameters)); }
295 static eDVBSatelliteEquipmentControl *getInstance() { return instance; }
296 static void setParam(int param, int value);
298 /* LNB Specific Parameters */
300 RESULT setLNBSlotMask(int slotmask);
301 RESULT setLNBLOFL(int lofl);
302 RESULT setLNBLOFH(int lofh);
303 RESULT setLNBThreshold(int threshold);
304 RESULT setLNBIncreasedVoltage(bool onoff);
305 /* DiSEqC Specific Parameters */
306 RESULT setDiSEqCMode(int diseqcmode);
307 RESULT setToneburst(int toneburst);
308 RESULT setRepeats(int repeats);
309 RESULT setCommittedCommand(int command);
310 RESULT setUncommittedCommand(int command);
311 RESULT setCommandOrder(int order);
312 RESULT setFastDiSEqC(bool onoff);
313 RESULT setSeqRepeat(bool onoff); // send the complete switch sequence twice (without rotor command)
314 /* Rotor Specific Parameters */
315 RESULT setLongitude(float longitude);
316 RESULT setLatitude(float latitude);
317 RESULT setLoDirection(int direction);
318 RESULT setLaDirection(int direction);
319 RESULT setUseInputpower(bool onoff);
320 RESULT setInputpowerDelta(int delta); // delta between running and stopped rotor
321 RESULT setRotorTurningSpeed(int speed); // set turning speed..
322 /* Satellite Specific Parameters */
323 RESULT addSatellite(int orbital_position);
324 RESULT setVoltageMode(int mode);
325 RESULT setToneMode(int mode);
326 RESULT setRotorPosNum(int rotor_pos_num);
327 /* Tuner Specific Parameters */
328 RESULT setTunerLinked(int from, int to);
329 RESULT setTunerDepends(int from, int to);
330 void setSlotNotLinked(int tuner_no);
332 void setRotorMoving(bool); // called from the frontend's
333 bool isRotorMoving();
334 bool canMeasureInputPower() { return m_canMeasureInputPower; }