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