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