dont ask for scanning second nim in automatic scan, when it is not meaningful
[vuplus_dvbapp] / lib / dvb / sec.h
1 #ifndef __dvb_sec_h
2 #define __dvb_sec_h
3
4 #include <lib/dvb/idvb.h>
5 #include <list>
6
7 #ifndef SWIG
8 class eSecCommand
9 {
10 public:
11         enum { modeStatic, modeDynamic };
12         enum {
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                 IF_ROTORPOS_VALID_GOTO,
23                 IF_TUNER_LOCKED_GOTO,
24                 START_TUNE_TIMEOUT
25         };
26         int cmd;
27         struct rotor
28         {
29                 int deltaA;   // difference in mA between running and stopped rotor
30                 int okcount;  // counter
31                 int steps;    // goto steps
32                 int direction;
33         };
34         struct pair
35         {
36                 int voltage;
37                 int steps;
38         };
39         union
40         {
41                 int val;
42                 int steps;
43                 int timeout;
44                 int voltage;
45                 int tone;
46                 int toneburst;
47                 int msec;
48                 int mode;
49                 rotor measure;
50                 eDVBDiseqcCommand diseqc;
51                 pair compare;
52         };
53         eSecCommand( int cmd )
54                 :cmd(cmd)
55         {}
56         eSecCommand( int cmd, int val )
57                 :cmd(cmd), val(val)
58         {}
59         eSecCommand( int cmd, eDVBDiseqcCommand diseqc )
60                 :cmd(cmd), diseqc(diseqc)
61         {}
62         eSecCommand( int cmd, rotor measure )
63                 :cmd(cmd), measure(measure)
64         {}
65         eSecCommand( int cmd, pair compare )
66                 :cmd(cmd), compare(compare)
67         {}
68         eSecCommand()
69                 :cmd(NONE)
70         {}
71 };
72
73 class eSecCommandList
74 {
75         typedef std::list<eSecCommand> List;
76         List secSequence;
77 public:
78         typedef List::iterator iterator;
79 private:
80         iterator cur;
81 public:
82         eSecCommandList()
83                 :cur(secSequence.end())
84         {
85         }
86         void push_front(const eSecCommand &cmd)
87         {
88                 secSequence.push_front(cmd);
89         }
90         void push_back(const eSecCommand &cmd)
91         {
92                 secSequence.push_back(cmd);
93         }
94         void clear()
95         {
96                 secSequence.clear();
97                 cur=secSequence.end();
98         }
99         inline iterator &current()
100         {
101                 return cur;
102         }
103         inline iterator begin()
104         {
105                 return secSequence.begin();
106         }
107         inline iterator end()
108         {
109                 return secSequence.end();
110         }
111         int size() const
112         {
113                 return secSequence.size();
114         }
115         operator bool() const
116         {
117                 return secSequence.size();
118         }
119 };
120 #endif
121
122 class eDVBSatelliteDiseqcParameters
123 {
124 #ifdef SWIG
125         eDVBSatelliteDiseqcParameters();
126         ~eDVBSatelliteDiseqcParameters();
127 #endif
128 public:
129         enum { AA=0, AB=1, BA=2, BB=3, SENDNO=4 /* and 0xF0 .. 0xFF*/  };       // DiSEqC Parameter
130         enum t_diseqc_mode { NONE=0, V1_0=1, V1_1=2, V1_2=3, SMATV=4 }; // DiSEqC Mode
131         enum t_toneburst_param { NO=0, A=1, B=2 };
132 #ifndef SWIG
133         __u8 m_committed_cmd;
134         t_diseqc_mode m_diseqc_mode;
135         t_toneburst_param m_toneburst_param;
136
137         __u8 m_repeats; // for cascaded switches
138         bool m_use_fast;        // send no DiSEqC on H/V or Lo/Hi change
139         bool m_seq_repeat;      // send the complete DiSEqC Sequence twice...
140         __u8 m_command_order;
141         /*      diseqc 1.0)
142                         0) commited, toneburst
143                         1) toneburst, committed
144                 diseqc > 1.0)
145                         2) committed, uncommitted, toneburst
146                         3) toneburst, committed, uncommitted
147                         4) uncommitted, committed, toneburst
148                         5) toneburst, uncommitted, committed */
149         __u8 m_uncommitted_cmd; // state of the 4 uncommitted switches..
150 #endif
151 };
152
153 class eDVBSatelliteSwitchParameters
154 {
155 #ifdef SWIG
156         eDVBSatelliteSwitchParameters();
157         ~eDVBSatelliteSwitchParameters();
158 #endif
159 public:
160         enum t_22khz_signal {   HILO=0, ON=1, OFF=2     }; // 22 Khz
161         enum t_voltage_mode     {       HV=0, _14V=1, _18V=2, _0V=3 }; // 14/18 V
162 #ifndef SWIG
163         t_voltage_mode m_voltage_mode;
164         t_22khz_signal m_22khz_signal;
165         __u8 m_rotorPosNum; // 0 is disable.. then use gotoxx
166 #endif
167 };
168
169 class eDVBSatelliteRotorParameters
170 {
171 #ifdef SWIG
172         eDVBSatelliteRotorParameters();
173         ~eDVBSatelliteRotorParameters();
174 #endif
175 public:
176         enum { NORTH, SOUTH, EAST, WEST };
177 #ifndef SWIG
178         eDVBSatelliteRotorParameters() { setDefaultOptions(); }
179
180         struct eDVBSatelliteRotorInputpowerParameters
181         {
182                 bool m_use;     // can we use rotor inputpower to detect rotor running state ?
183                 __u8 m_delta;   // delta between running and stopped rotor
184         };
185         eDVBSatelliteRotorInputpowerParameters m_inputpower_parameters;
186
187         struct eDVBSatelliteRotorGotoxxParameters
188         {
189                 __u8 m_lo_direction;    // EAST, WEST
190                 __u8 m_la_direction;    // NORT, SOUTH
191                 double m_longitude;     // longitude for gotoXX? function
192                 double m_latitude;      // latitude for gotoXX? function
193         };
194         eDVBSatelliteRotorGotoxxParameters m_gotoxx_parameters;
195
196         void setDefaultOptions() // set default rotor options
197         {
198                 m_inputpower_parameters.m_use = true;
199                 m_inputpower_parameters.m_delta = 60;
200                 m_gotoxx_parameters.m_lo_direction = EAST;
201                 m_gotoxx_parameters.m_la_direction = NORTH;
202                 m_gotoxx_parameters.m_longitude = 0.0;
203                 m_gotoxx_parameters.m_latitude = 0.0;
204         }
205 #endif
206 };
207
208 class eDVBSatelliteLNBParameters
209 {
210 #ifdef SWIG
211         eDVBSatelliteLNBParameters();
212         ~eDVBSatelliteLNBParameters();
213 #endif
214 public:
215         enum t_12V_relais_state { OFF=0, ON };
216 #ifndef SWIG
217         t_12V_relais_state m_12V_relais_state;  // 12V relais output on/off
218
219         __u8 tuner_mask; // useable by tuner ( 1 | 2 | 4...)
220
221         unsigned int m_lof_hi,  // for 2 band universal lnb 10600 Mhz (high band offset frequency)
222                                 m_lof_lo,       // for 2 band universal lnb  9750 Mhz (low band offset frequency)
223                                 m_lof_threshold;        // for 2 band universal lnb 11750 Mhz (band switch frequency)
224
225         bool m_increased_voltage; // use increased voltage ( 14/18V )
226
227         std::map<int, eDVBSatelliteSwitchParameters> m_satellites;
228         eDVBSatelliteDiseqcParameters m_diseqc_parameters;
229         eDVBSatelliteRotorParameters m_rotor_parameters;
230 #endif
231 };
232
233 class eDVBRegisteredFrontend;
234
235 class eDVBSatelliteEquipmentControl: public iDVBSatelliteEquipmentControl
236 {
237 #ifndef SWIG
238         static eDVBSatelliteEquipmentControl *instance;
239         eDVBSatelliteLNBParameters m_lnbs[128]; // i think its enough
240         int m_lnbidx; // current index for set parameters
241         std::map<int, eDVBSatelliteSwitchParameters>::iterator m_curSat;
242         eSmartPtrList<eDVBRegisteredFrontend> &m_avail_frontends;
243         bool m_rotorMoving;
244 #endif
245 #ifdef SWIG
246         eDVBSatelliteEquipmentControl();
247         ~eDVBSatelliteEquipmentControl();
248 #endif
249         // helper function for setTunerLinked and setTunerDepends
250         RESULT setDependencyPointers( int no1, int no2, int dest_data_byte );
251 public:
252 #ifndef SWIG
253         eDVBSatelliteEquipmentControl(eSmartPtrList<eDVBRegisteredFrontend> &avail_frontends);
254         DECLARE_REF(eDVBSatelliteEquipmentControl);
255         RESULT prepare(iDVBFrontend &frontend, FRONTENDPARAMETERS &parm, const eDVBFrontendParametersSatellite &sat, int frontend_id);
256         int canTune(const eDVBFrontendParametersSatellite &feparm, iDVBFrontend *, int frontend_id);
257         bool currentLNBValid() { return m_lnbidx > -1 && m_lnbidx < (int)(sizeof(m_lnbs) / sizeof(eDVBSatelliteLNBParameters)); }
258 #endif
259         static eDVBSatelliteEquipmentControl *getInstance() { return instance; }
260         RESULT clear();
261 /* LNB Specific Parameters */
262         RESULT addLNB();
263         RESULT setLNBTunerMask(int tunermask);
264         RESULT setLNBLOFL(int lofl);
265         RESULT setLNBLOFH(int lofh);
266         RESULT setLNBThreshold(int threshold);
267         RESULT setLNBIncreasedVoltage(bool onoff);
268 /* DiSEqC Specific Parameters */
269         RESULT setDiSEqCMode(int diseqcmode);
270         RESULT setToneburst(int toneburst);
271         RESULT setRepeats(int repeats);
272         RESULT setCommittedCommand(int command);
273         RESULT setUncommittedCommand(int command);
274         RESULT setCommandOrder(int order);
275         RESULT setFastDiSEqC(bool onoff);
276         RESULT setSeqRepeat(bool onoff); // send the complete switch sequence twice (without rotor command)
277 /* Rotor Specific Parameters */
278         RESULT setLongitude(float longitude);
279         RESULT setLatitude(float latitude);
280         RESULT setLoDirection(int direction);
281         RESULT setLaDirection(int direction);
282         RESULT setUseInputpower(bool onoff);
283         RESULT setInputpowerDelta(int delta);  // delta between running and stopped rotor
284 /* Satellite Specific Parameters */
285         RESULT addSatellite(int orbital_position);
286         RESULT setVoltageMode(int mode);
287         RESULT setToneMode(int mode);
288         RESULT setRotorPosNum(int rotor_pos_num);
289 /* Tuner Specific Parameters */
290         RESULT setTunerLinked(int from, int to);
291         RESULT setTunerDepends(int from, int to);
292
293         PyObject *get_different_satellites(int tu1, int tu2);
294         void setRotorMoving(bool); // called from the frontend's
295         bool isRotorMoving();
296 };
297
298 #endif