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