remove unneeded code
[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 eDVBRegisteredFrontend;
205
206 class eDVBSatelliteEquipmentControl: public iDVBSatelliteEquipmentControl
207 {
208 #ifndef SWIG
209         static eDVBSatelliteEquipmentControl *instance;
210         eDVBSatelliteLNBParameters m_lnbs[128]; // i think its enough
211         int m_lnbidx; // current index for set parameters
212         std::map<int, eDVBSatelliteSwitchParameters>::iterator m_curSat;
213         eSmartPtrList<eDVBRegisteredFrontend> &m_avail_frontends;
214         bool m_rotorMoving;
215 #endif
216 public:
217         eDVBSatelliteEquipmentControl(eSmartPtrList<eDVBRegisteredFrontend> &avail_frontends);
218 #ifndef SWIG
219         DECLARE_REF(eDVBSatelliteEquipmentControl);
220         RESULT prepare(iDVBFrontend &frontend, FRONTENDPARAMETERS &parm, eDVBFrontendParametersSatellite &sat, int frontend_id);
221         int canTune(const eDVBFrontendParametersSatellite &feparm, iDVBFrontend *, int frontend_id);
222         bool currentLNBValid() { return m_lnbidx > -1 && m_lnbidx < (int)(sizeof(m_lnbs) / sizeof(eDVBSatelliteLNBParameters)); }
223 #endif
224         static eDVBSatelliteEquipmentControl *getInstance() { return instance; }
225         RESULT clear();
226 /* LNB Specific Parameters */
227         RESULT addLNB();
228         RESULT setLNBTunerMask(int tunermask);
229         RESULT setLNBLOFL(int lofl);
230         RESULT setLNBLOFH(int lofh);
231         RESULT setLNBThreshold(int threshold);
232         RESULT setLNBIncreasedVoltage(bool onoff);
233 /* DiSEqC Specific Parameters */
234         RESULT setDiSEqCMode(int diseqcmode);
235         RESULT setToneburst(int toneburst);
236         RESULT setRepeats(int repeats);
237         RESULT setCommittedCommand(int command);
238         RESULT setUncommittedCommand(int command);
239         RESULT setCommandOrder(int order);
240         RESULT setFastDiSEqC(bool onoff);
241         RESULT setSeqRepeat(bool onoff); // send the complete switch sequence twice (without rotor command)
242 /* Rotor Specific Parameters */
243         RESULT setLongitude(float longitude);
244         RESULT setLatitude(float latitude);
245         RESULT setLoDirection(int direction);
246         RESULT setLaDirection(int direction);
247         RESULT setUseInputpower(bool onoff);
248         RESULT setInputpowerDelta(int delta);  // delta between running and stopped rotor
249 /* Satellite Specific Parameters */
250         RESULT addSatellite(int orbital_position);
251         RESULT setVoltageMode(int mode);
252         RESULT setToneMode(int mode);
253         RESULT setRotorPosNum(int rotor_pos_num);
254 /* Tuner Specific Parameters */
255         RESULT setTunerLinked(int from, int to);
256
257         void setRotorMoving(bool); // called from the frontend's
258         bool isRotorMoving();
259 };
260
261 #endif