always emit timeUpdated signal on first received TDT
[enigma2.git] / lib / dvb / frontend.h
1 #ifndef __dvb_frontend_h
2 #define __dvb_frontend_h
3
4 #include <config.h>
5 #include <lib/dvb/idvb.h>
6 #include <lib/dvb/sec.h>
7
8 class eSecCommandList;
9
10 class eDVBFrontendParameters: public iDVBFrontendParameters
11 {
12         DECLARE_REF(eDVBFrontendParameters);
13         union
14         {
15                 eDVBFrontendParametersSatellite sat;
16                 eDVBFrontendParametersCable cable;
17                 eDVBFrontendParametersTerrestrial terrestrial;
18         };
19         int m_type;
20 public:
21         eDVBFrontendParameters();
22         
23         RESULT getSystem(int &type) const;
24         RESULT getDVBS(eDVBFrontendParametersSatellite &p) const;
25         RESULT getDVBC(eDVBFrontendParametersCable &p) const;
26         RESULT getDVBT(eDVBFrontendParametersTerrestrial &p) const;
27
28         RESULT setDVBS(const eDVBFrontendParametersSatellite &p);
29         RESULT setDVBC(const eDVBFrontendParametersCable &p);
30         RESULT setDVBT(const eDVBFrontendParametersTerrestrial &p);
31         
32         RESULT calculateDifference(const iDVBFrontendParameters *parm, int &diff) const;
33         
34         RESULT getHash(unsigned long &hash) const;
35 };
36
37 class eDVBFrontend: public iDVBFrontend, public Object
38 {
39         DECLARE_REF(eDVBFrontend);
40         int m_type;
41         int m_fe;
42         int m_fd;
43 #if HAVE_DVB_API_VERSION < 3
44         int m_secfd;
45 #endif
46         FRONTENDPARAMETERS parm;
47         int m_state;
48         Signal1<void,iDVBFrontend*> m_stateChanged;
49         ePtr<iDVBSatelliteEquipmentControl> m_sec;
50         eSocketNotifier *m_sn;
51         int m_tuning;
52         eTimer *m_timeout;
53         eTimer *m_tuneTimer;
54
55         eSecCommandList m_sec_sequence;
56
57         int m_data[7]; /* when satellite frontend then
58                 data[0] = lastcsw -> state of the committed switch
59                 data[1] = lastucsw -> state of the uncommitted switch
60                 data[2] = lastToneburst -> current state of toneburst switch
61                 data[3] = newRotorCmd -> last sent rotor cmd
62                 data[4] = newRotorPos -> current Rotor Position
63                 data[5] = curRotorCmd
64                 data[6] = curRotorPos */
65
66         int m_idleInputpower[2];  // 13V .. 18V
67         int m_runningInputpower;
68         int m_timeoutCount; // needed for timeout
69         int m_curVoltage;
70
71         void feEvent(int);
72         void timeout();
73         void tuneLoop();  // called by m_tuneTimer
74         void setFrontend();
75         int readInputpower();
76         bool setSecSequencePos(int steps);
77 public:
78         eDVBFrontend(int adap, int fe, int &ok);        
79         virtual ~eDVBFrontend();
80
81         RESULT getFrontendType(int &type);
82         RESULT tune(const iDVBFrontendParameters &where);
83         RESULT connectStateChange(const Slot1<void,iDVBFrontend*> &stateChange, ePtr<eConnection> &connection);
84         RESULT getState(int &state);
85         RESULT setTone(int tone);
86         RESULT setVoltage(int voltage);
87         RESULT sendDiseqc(const eDVBDiseqcCommand &diseqc);
88         RESULT sendToneburst(int burst);
89         RESULT setSEC(iDVBSatelliteEquipmentControl *sec);
90         RESULT setSecSequence(const eSecCommandList &list);
91         RESULT getData(int num, int &data);
92         RESULT setData(int num, int val);
93         
94         int isCompatibleWith(const eDVBChannelID &chid);
95         
96         int getID() { return m_fe; }
97 };
98
99 #endif