add tuner B option "Equal to Socket A"
[vuplus_dvbapp] / 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[9]; /* 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                 data[8] = dependsToTunerNo (just satpos.. for rotor with twin lnb) */
70
71         int m_idleInputpower[2];  // 13V .. 18V
72         int m_runningInputpower;
73         int m_timeoutCount; // needed for timeout
74         int m_curVoltage;
75
76         void feEvent(int);
77         void timeout();
78         void tuneLoop();  // called by m_tuneTimer
79         void setFrontend();
80         int readInputpower();
81         bool setSecSequencePos(int steps);
82 public:
83         eDVBFrontend(int adap, int fe, int &ok);        
84         virtual ~eDVBFrontend();
85
86         RESULT getFrontendType(int &type);
87         RESULT tune(const iDVBFrontendParameters &where);
88         RESULT connectStateChange(const Slot1<void,iDVBFrontend*> &stateChange, ePtr<eConnection> &connection);
89         RESULT getState(int &state);
90         RESULT setTone(int tone);
91         RESULT setVoltage(int voltage);
92         RESULT sendDiseqc(const eDVBDiseqcCommand &diseqc);
93         RESULT sendToneburst(int burst);
94         RESULT setSEC(iDVBSatelliteEquipmentControl *sec);
95         RESULT setSecSequence(const eSecCommandList &list);
96         RESULT getData(int num, int &data);
97         RESULT setData(int num, int val);
98
99         int readFrontendData(int type); // bitErrorRate, signalPower, signalQuality
100         int isCompatibleWith(ePtr<iDVBFrontendParameters> &feparm);
101         int getID() { return m_fe; }
102
103         int openFrontend();
104         int closeFrontend();
105 };
106
107 #endif