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