71fff6a5d2e16380e918b3c239718e77fd902df6
[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 {
12                 NONE, SLEEP, SET_VOLTAGE, SET_TONE, GOTO,
13                 SEND_DISEQC, SEND_TONEBURST, SET_FRONTEND,
14                 MEASURE_IDLE_INPUTPOWER, MEASURE_RUNNING_INPUTPOWER,
15                 IF_TIMEOUT_GOTO, IF_RUNNING_GOTO, IF_STOPPED_GOTO,
16                 UPDATE_CURRENT_ROTORPARAMS, SET_TIMEOUT, 
17         };
18         int cmd;
19         union
20         {
21                 int val;
22                 int steps;
23                 int timeout;
24                 int voltage;
25                 int tone;
26                 int toneburst;
27                 int msec;
28                 eDVBDiseqcCommand diseqc;
29         };
30         eSecCommand( int cmd )
31                 :cmd(cmd)
32         {}
33         eSecCommand( int cmd, int val )
34                 :cmd(cmd), val(val)
35         {}
36         eSecCommand( int cmd, eDVBDiseqcCommand diseqc )
37                 :cmd(cmd), diseqc(diseqc)
38         {}
39         eSecCommand()
40                 :cmd(NONE)
41         {}
42 };
43
44 class eSecCommandList
45 {
46         std::list<eSecCommand> secSequence;
47         std::list<eSecCommand>::iterator cur;
48 public:
49         eSecCommandList()
50                 :cur(secSequence.end())
51         {
52         }
53         void push_front(const eSecCommand &cmd)
54         {
55                 secSequence.push_front(cmd);
56         }
57         void push_back(const eSecCommand &cmd)
58         {
59                 secSequence.push_back(cmd);
60         }
61         void clear()
62         {
63                 secSequence.clear();
64                 cur=secSequence.end();
65         }
66         inline std::list<eSecCommand>::iterator &current()
67         {
68                 return cur;
69         }
70         inline std::list<eSecCommand>::iterator begin()
71         {
72                 return secSequence.begin();
73         }
74         inline std::list<eSecCommand>::iterator end()
75         {
76                 return secSequence.end();
77         }
78         int size() const
79         {
80                 return secSequence.size();
81         }
82         operator bool() const
83         {
84                 return secSequence.size();
85         }
86 };
87
88 class eDVBSatelliteDiseqcParameters
89 {
90 public:
91         enum { AA=0, AB=1, BA=2, BB=3, SENDNO=4 /* and 0xF0 .. 0xFF*/  };       // DiSEqC Parameter
92         int m_committed_cmd;
93
94         enum t_diseqc_mode { NONE=0, V1_0=1, V1_1=2, V1_2=3, SMATV=4 }; // DiSEqC Mode
95         t_diseqc_mode m_diseqc_mode;
96
97         enum t_toneburst_param { NO=0, A=1, B=2 };
98         t_toneburst_param m_toneburst_param;
99
100         int m_repeats;  // for cascaded switches
101         bool m_use_fast;        // send no DiSEqC on H/V or Lo/Hi change
102         bool m_seq_repeat;      // send the complete DiSEqC Sequence twice...
103         bool m_swap_cmds;       // swaps the committed & uncommitted cmd
104         int m_uncommitted_cmd;  // state of the 4 uncommitted switches..
105 };
106
107 class eDVBSatelliteSwitchParameters
108 {
109 public:
110         enum t_22khz_signal {   HILO=0, ON=1, OFF=2     }; // 22 Khz
111         enum t_voltage_mode     {       HV=0, _14V=1, _18V=2, _0V=3 }; // 14/18 V
112         t_voltage_mode m_voltage_mode;
113         t_22khz_signal m_22khz_signal;
114 };
115
116 class eDVBSatelliteRotorParameters
117 {
118 public:
119         enum { NORTH, SOUTH, EAST, WEST };
120
121         struct eDVBSatelliteRotorInputpowerParameters
122         {
123                 bool m_use;     // can we use rotor inputpower to detect rotor running state ?
124                 int m_threshold;        // threshold between running and stopped rotor
125         };
126         eDVBSatelliteRotorInputpowerParameters m_inputpower_parameters;
127
128         struct eDVBSatelliteRotorGotoxxParameters
129         {
130                 bool m_can_use; // rotor support gotoXX cmd ?
131                 int m_lo_direction;     // EAST, WEST
132                 int m_la_direction;     // NORT, SOUTH
133                 double m_longitude;     // longitude for gotoXX┬░ function
134                 double m_latitude;      // latitude for gotoXX┬░ function
135         };
136         eDVBSatelliteRotorGotoxxParameters m_gotoxx_parameters;
137
138         struct Orbital_Position_Compare
139         {
140                 inline bool operator()(const int &i1, const int &i2) const
141                 {
142                         return abs(i1-i2) < 6 ? false: i1 < i2;
143                 }
144         };
145         std::map< int, int, Orbital_Position_Compare > m_rotor_position_table;
146         /* mapping orbitalposition <-> number stored in rotor */
147
148         void setDefaultOptions(); // set default rotor options
149 };
150
151 class eDVBSatelliteParameters
152 {
153 public:
154         eDVBSatelliteDiseqcParameters m_diseqc_parameters;
155         eDVBSatelliteRotorParameters m_rotor_parameters;
156         eDVBSatelliteSwitchParameters m_switch_parameters;
157 };
158
159 class eDVBSatelliteLNBParameters
160 {
161 public:
162         enum t_12V_relais_state { OFF=0, ON };
163         t_12V_relais_state m_12V_relais_state;  // 12V relais output on/off
164
165         unsigned int m_lof_hi,  // for 2 band universal lnb 10600 Mhz (high band offset frequency)
166                                 m_lof_lo,       // for 2 band universal lnb  9750 Mhz (low band offset frequency)
167                                 m_lof_threshold;        // for 2 band universal lnb 11750 Mhz (band switch frequency)
168
169         bool m_increased_voltage; // use increased voltage ( 14/18V )
170
171         std::map<int, eDVBSatelliteParameters> m_satellites;
172 };
173
174 class eDVBSatelliteEquipmentControl: public iDVBSatelliteEquipmentControl
175 {
176         std::list<eDVBSatelliteLNBParameters> m_lnblist;
177 public:
178         DECLARE_REF(eDVBSatelliteEquipmentControl);
179         eDVBSatelliteEquipmentControl();
180         RESULT prepare(iDVBFrontend &frontend, FRONTENDPARAMETERS &parm, eDVBFrontendParametersSatellite &sat);
181 };
182
183 #endif