fix for canAllocateChannel
[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         char m_filename[128];
44 #if HAVE_DVB_API_VERSION < 3
45         int m_secfd;
46         char m_sec_filename[128];
47 #endif
48
49         FRONTENDPARAMETERS parm;
50         int m_state;
51         Signal1<void,iDVBFrontend*> m_stateChanged;
52         ePtr<iDVBSatelliteEquipmentControl> m_sec;
53         eSocketNotifier *m_sn;
54         int m_tuning;
55         eTimer *m_timeout;
56         eTimer *m_tuneTimer;
57
58         eSecCommandList m_sec_sequence;
59
60         int m_data[8]; /* when satellite frontend then
61                 data[0] = lastcsw -> state of the committed switch
62                 data[1] = lastucsw -> state of the uncommitted switch
63                 data[2] = lastToneburst -> current state of toneburst switch
64                 data[3] = newRotorCmd -> last sent rotor cmd
65                 data[4] = newRotorPos -> current Rotor Position
66                 data[5] = curRotorCmd
67                 data[6] = curRotorPos
68                 data[7] = linkedToTunerNo */
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