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