remove local changes
[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 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
112 class eDVBSatelliteDiseqcParameters
113 {
114 public:
115         enum { AA=0, AB=1, BA=2, BB=3, SENDNO=4 /* and 0xF0 .. 0xFF*/  };       // DiSEqC Parameter
116         __u8 m_committed_cmd;
117
118         enum t_diseqc_mode { NONE=0, V1_0=1, V1_1=2, V1_2=3, SMATV=4 }; // DiSEqC Mode
119         t_diseqc_mode m_diseqc_mode;
120
121         enum t_toneburst_param { NO=0, A=1, B=2 };
122         t_toneburst_param m_toneburst_param;
123
124         __u8 m_repeats; // for cascaded switches
125         bool m_use_fast;        // send no DiSEqC on H/V or Lo/Hi change
126         bool m_seq_repeat;      // send the complete DiSEqC Sequence twice...
127         __u8 m_command_order;
128         /*      diseqc 1.0)
129                         0) commited, toneburst
130                         1) toneburst, committed
131                 diseqc > 1.0)
132                         2) committed, uncommitted, toneburst
133                         3) toneburst, committed, uncommitted
134                         4) uncommitted, committed, toneburst
135                         5) toneburst, uncommitted, committed */
136         __u8 m_uncommitted_cmd; // state of the 4 uncommitted switches..
137 };
138
139 class eDVBSatelliteSwitchParameters
140 {
141 public:
142         enum t_22khz_signal {   HILO=0, ON=1, OFF=2     }; // 22 Khz
143         enum t_voltage_mode     {       HV=0, _14V=1, _18V=2, _0V=3 }; // 14/18 V
144         t_voltage_mode m_voltage_mode;
145         t_22khz_signal m_22khz_signal;
146         __u8 m_rotorPosNum; // 0 is disable.. then use gotoxx
147 };
148
149 class eDVBSatelliteRotorParameters
150 {
151 public:
152         enum { NORTH, SOUTH, EAST, WEST };
153
154         eDVBSatelliteRotorParameters() { setDefaultOptions(); }
155
156         struct eDVBSatelliteRotorInputpowerParameters
157         {
158                 bool m_use;     // can we use rotor inputpower to detect rotor running state ?
159                 __u8 m_delta;   // delta between running and stopped rotor
160         };
161         eDVBSatelliteRotorInputpowerParameters m_inputpower_parameters;
162
163         struct eDVBSatelliteRotorGotoxxParameters
164         {
165                 __u8 m_lo_direction;    // EAST, WEST
166                 __u8 m_la_direction;    // NORT, SOUTH
167                 double m_longitude;     // longitude for gotoXX° function
168                 double m_latitude;      // latitude for gotoXX° function
169         };
170         eDVBSatelliteRotorGotoxxParameters m_gotoxx_parameters;
171
172         void setDefaultOptions() // set default rotor options
173         {
174                 m_inputpower_parameters.m_use = true;
175                 m_inputpower_parameters.m_delta = 60;
176                 m_gotoxx_parameters.m_lo_direction = EAST;
177                 m_gotoxx_parameters.m_la_direction = NORTH;
178                 m_gotoxx_parameters.m_longitude = 0.0;
179                 m_gotoxx_parameters.m_latitude = 0.0;
180         }
181 };
182
183 class eDVBSatelliteLNBParameters
184 {
185 public:
186         enum t_12V_relais_state { OFF=0, ON };
187         t_12V_relais_state m_12V_relais_state;  // 12V relais output on/off
188
189         __u8 tuner_mask; // useable by tuner ( 1 | 2 | 4...)
190
191         unsigned int m_lof_hi,  // for 2 band universal lnb 10600 Mhz (high band offset frequency)
192                                 m_lof_lo,       // for 2 band universal lnb  9750 Mhz (low band offset frequency)
193                                 m_lof_threshold;        // for 2 band universal lnb 11750 Mhz (band switch frequency)
194
195         bool m_increased_voltage; // use increased voltage ( 14/18V )
196
197         std::map<int, eDVBSatelliteSwitchParameters> m_satellites;
198         eDVBSatelliteDiseqcParameters m_diseqc_parameters;
199         eDVBSatelliteRotorParameters m_rotor_parameters;
200 };
201
202 class eDVBSatelliteEquipmentControl: public iDVBSatelliteEquipmentControl
203 {
204         eDVBSatelliteLNBParameters m_lnbs[128]; // i think its enough
205         int m_lnbidx; // current index for set parameters
206         std::map<int, eDVBSatelliteSwitchParameters>::iterator m_curSat;
207 public:
208         DECLARE_REF(eDVBSatelliteEquipmentControl);
209         eDVBSatelliteEquipmentControl();
210         RESULT prepare(iDVBFrontend &frontend, FRONTENDPARAMETERS &parm, eDVBFrontendParametersSatellite &sat);
211
212         bool currentLNBValid() { return m_lnbidx > -1 && m_lnbidx < (int)(sizeof(m_lnbs) / sizeof(eDVBSatelliteLNBParameters)); }
213         RESULT clear();
214 /* LNB Specific Parameters */
215         RESULT addLNB();
216         RESULT setLNBTunerMask(int tunermask);
217         RESULT setLNBLOFL(int lofl);
218         RESULT setLNBLOFH(int lofh);
219         RESULT setLNBThreshold(int threshold);
220         RESULT setLNBIncreasedVoltage(bool onoff);
221 /* DiSEqC Specific Parameters */
222         RESULT setDiSEqCMode(int diseqcmode);
223         RESULT setToneburst(int toneburst);
224         RESULT setRepeats(int repeats);
225         RESULT setCommittedCommand(int command);
226         RESULT setUncommittedCommand(int command);
227         RESULT setCommandOrder(int order);
228         RESULT setFastDiSEqC(bool onoff);
229 /* Rotor Specific Parameters */
230         RESULT setLongitude(float longitude);
231         RESULT setLatitude(float latitude);
232         RESULT setLoDirection(int direction);
233         RESULT setLaDirection(int direction);
234         RESULT setUseInputpower(bool onoff);
235         RESULT setInputpowerDelta(int delta);  // delta between running and stopped rotor
236 /* Satellite Specific Parameters */
237         RESULT addSatellite(int orbital_position);
238         RESULT setVoltageMode(int mode);
239         RESULT setToneMode(int mode);
240         RESULT setRotorPosNum(int rotor_pos_num);
241 };
242
243 #endif