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