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