now link dvb-s frontends to dvb-s2 frontends is possible
[vuplus_dvbapp] / lib / dvb / frontend.h
1 #ifndef __dvb_frontend_h
2 #define __dvb_frontend_h
3
4 #include <lib/dvb/idvb.h>
5
6 class eDVBFrontendParameters: public iDVBFrontendParameters
7 {
8         DECLARE_REF(eDVBFrontendParameters);
9         union
10         {
11                 eDVBFrontendParametersSatellite sat;
12                 eDVBFrontendParametersCable cable;
13                 eDVBFrontendParametersTerrestrial terrestrial;
14         };
15         int m_type;
16 public:
17         eDVBFrontendParameters();
18         ~eDVBFrontendParameters()
19         {
20         }
21
22         RESULT getSystem(int &type) const;
23         RESULT getDVBS(eDVBFrontendParametersSatellite &) const;
24         RESULT getDVBC(eDVBFrontendParametersCable &) const;
25         RESULT getDVBT(eDVBFrontendParametersTerrestrial &) const;
26
27         RESULT setDVBS(const eDVBFrontendParametersSatellite &p, bool no_rotor_command_on_tune=false);
28         RESULT setDVBC(const eDVBFrontendParametersCable &p);
29         RESULT setDVBT(const eDVBFrontendParametersTerrestrial &p);
30
31         RESULT calculateDifference(const iDVBFrontendParameters *parm, int &, bool exact) const;
32
33         RESULT getHash(unsigned long &) const;
34         RESULT calcLockTimeout(unsigned int &) const;
35 };
36
37 #ifndef SWIG
38
39 #include <lib/dvb/sec.h>
40 class eSecCommandList;
41
42 class eDVBFrontend: public iDVBFrontend, public Object
43 {
44 public:
45         enum {
46                 CSW,                  // state of the committed switch
47                 UCSW,                 // state of the uncommitted switch
48                 TONEBURST,            // current state of toneburst switch
49                 NEW_ROTOR_CMD,        // prev sent rotor cmd
50                 NEW_ROTOR_POS,        // new rotor position (not validated)
51                 ROTOR_CMD,            // completed rotor cmd (finalized)
52                 ROTOR_POS,            // current rotor position
53                 LINKED_PREV_PTR,      // prev double linked list (for linked FEs)
54                 LINKED_NEXT_PTR,      // next double linked list (for linked FEs)
55                 SATPOS_DEPENDS_PTR,   // pointer to FE with configured rotor (with twin/quattro lnb)
56                 FREQ_OFFSET,          // current frequency offset
57                 CUR_VOLTAGE,          // current voltage
58                 CUR_TONE,             // current continuous tone
59                 NUM_DATA_ENTRIES
60         };
61         Signal1<void,iDVBFrontend*> m_stateChanged;
62 private:
63         DECLARE_REF(eDVBFrontend);
64         bool m_enabled;
65         int m_type;
66         int m_dvbid;
67         int m_slotid;
68         int m_fd;
69         bool m_need_rotor_workaround;
70         bool m_can_handle_dvbs2;
71         char m_filename[128];
72         char m_description[128];
73 #if HAVE_DVB_API_VERSION < 3
74         int m_secfd;
75         char m_sec_filename[128];
76 #endif
77         FRONTENDPARAMETERS parm;
78         int m_state;
79         ePtr<iDVBSatelliteEquipmentControl> m_sec;
80         eSocketNotifier *m_sn;
81         int m_tuning;
82         eTimer *m_timeout;
83         eTimer *m_tuneTimer;
84
85         eSecCommandList m_sec_sequence;
86
87         long m_data[NUM_DATA_ENTRIES];
88
89         int m_idleInputpower[2];  // 13V .. 18V
90         int m_runningInputpower;
91
92         int m_timeoutCount; // needed for timeout
93         int m_retryCount; // diseqc retry for rotor
94
95         void feEvent(int);
96         void timeout();
97         void tuneLoop();  // called by m_tuneTimer
98         void setFrontend();
99         bool setSecSequencePos(int steps);
100         void setRotorData(int pos, int cmd);
101         static int PriorityOrder;
102 public:
103         eDVBFrontend(int adap, int fe, int &ok);        
104         virtual ~eDVBFrontend();
105
106         int readInputpower();
107         RESULT getFrontendType(int &type);
108         RESULT tune(const iDVBFrontendParameters &where);
109         RESULT prepare_sat(const eDVBFrontendParametersSatellite &, unsigned int timeout);
110         RESULT prepare_cable(const eDVBFrontendParametersCable &);
111         RESULT prepare_terrestrial(const eDVBFrontendParametersTerrestrial &);
112         RESULT connectStateChange(const Slot1<void,iDVBFrontend*> &stateChange, ePtr<eConnection> &connection);
113         RESULT getState(int &state);
114         RESULT setTone(int tone);
115         RESULT setVoltage(int voltage);
116         RESULT sendDiseqc(const eDVBDiseqcCommand &diseqc);
117         RESULT sendToneburst(int burst);
118         RESULT setSEC(iDVBSatelliteEquipmentControl *sec);
119         RESULT setSecSequence(const eSecCommandList &list);
120         RESULT getData(int num, long &data);
121         RESULT setData(int num, long val);
122
123         int readFrontendData(int type); // bitErrorRate, signalPower, signalQualitydB, signalQuality, locked, synced
124         void getFrontendStatus(ePyObject dest);
125         void getTransponderData(ePyObject dest, bool original);
126         void getFrontendData(ePyObject dest);
127
128         int isCompatibleWith(ePtr<iDVBFrontendParameters> &feparm);
129         int getDVBID() { return m_dvbid; }
130         int getSlotID() { return m_slotid; }
131         bool setSlotInfo(ePyObject obj); // get a tuple (slotid, slotdescr)
132         static void setTypePriorityOrder(int val) { PriorityOrder = val; }
133         static int getTypePriorityOrder() { return PriorityOrder; }
134
135         int openFrontend();
136         int closeFrontend(bool force=false);
137         const char *getDescription() const { return m_description; }
138 };
139
140 #endif // SWIG
141 #endif