fix tune failed problems on fast zap when a diseqc swicth is in use
[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                 NEW_CSW,
47                 NEW_UCSW,
48                 NEW_TONEBURST,
49                 CSW,                  // state of the committed switch
50                 UCSW,                 // state of the uncommitted switch
51                 TONEBURST,            // current state of toneburst switch
52                 NEW_ROTOR_CMD,        // prev sent rotor cmd
53                 NEW_ROTOR_POS,        // new rotor position (not validated)
54                 ROTOR_CMD,            // completed rotor cmd (finalized)
55                 ROTOR_POS,            // current rotor position
56                 LINKED_PREV_PTR,      // prev double linked list (for linked FEs)
57                 LINKED_NEXT_PTR,      // next double linked list (for linked FEs)
58                 SATPOS_DEPENDS_PTR,   // pointer to FE with configured rotor (with twin/quattro lnb)
59                 FREQ_OFFSET,          // current frequency offset
60                 CUR_VOLTAGE,          // current voltage
61                 CUR_TONE,             // current continuous tone
62                 NUM_DATA_ENTRIES
63         };
64         Signal1<void,iDVBFrontend*> m_stateChanged;
65 private:
66         DECLARE_REF(eDVBFrontend);
67         bool m_enabled;
68         int m_type;
69         int m_dvbid;
70         int m_slotid;
71         int m_fd;
72         bool m_need_rotor_workaround;
73         bool m_can_handle_dvbs2;
74         char m_filename[128];
75         char m_description[128];
76 #if HAVE_DVB_API_VERSION < 3
77         int m_secfd;
78         char m_sec_filename[128];
79 #endif
80         FRONTENDPARAMETERS parm;
81         int m_state;
82         ePtr<iDVBSatelliteEquipmentControl> m_sec;
83         eSocketNotifier *m_sn;
84         int m_tuning;
85         eTimer *m_timeout;
86         eTimer *m_tuneTimer;
87
88         eSecCommandList m_sec_sequence;
89
90         long m_data[NUM_DATA_ENTRIES];
91
92         int m_idleInputpower[2];  // 13V .. 18V
93         int m_runningInputpower;
94
95         int m_timeoutCount; // needed for timeout
96         int m_retryCount; // diseqc retry for rotor
97
98         void feEvent(int);
99         void timeout();
100         void tuneLoop();  // called by m_tuneTimer
101         void setFrontend();
102         bool setSecSequencePos(int steps);
103         static int PriorityOrder;
104 public:
105         eDVBFrontend(int adap, int fe, int &ok);        
106         virtual ~eDVBFrontend();
107
108         int readInputpower();
109         RESULT getFrontendType(int &type);
110         RESULT tune(const iDVBFrontendParameters &where);
111         RESULT prepare_sat(const eDVBFrontendParametersSatellite &, unsigned int timeout);
112         RESULT prepare_cable(const eDVBFrontendParametersCable &);
113         RESULT prepare_terrestrial(const eDVBFrontendParametersTerrestrial &);
114         RESULT connectStateChange(const Slot1<void,iDVBFrontend*> &stateChange, ePtr<eConnection> &connection);
115         RESULT getState(int &state);
116         RESULT setTone(int tone);
117         RESULT setVoltage(int voltage);
118         RESULT sendDiseqc(const eDVBDiseqcCommand &diseqc);
119         RESULT sendToneburst(int burst);
120         RESULT setSEC(iDVBSatelliteEquipmentControl *sec);
121         RESULT setSecSequence(const eSecCommandList &list);
122         RESULT getData(int num, long &data);
123         RESULT setData(int num, long val);
124
125         int readFrontendData(int type); // bitErrorRate, signalPower, signalQualitydB, signalQuality, locked, synced
126         void getFrontendStatus(ePyObject dest);
127         void getTransponderData(ePyObject dest, bool original);
128         void getFrontendData(ePyObject dest);
129
130         int isCompatibleWith(ePtr<iDVBFrontendParameters> &feparm);
131         int getDVBID() { return m_dvbid; }
132         int getSlotID() { return m_slotid; }
133         bool setSlotInfo(ePyObject obj); // get a tuple (slotid, slotdescr)
134         static void setTypePriorityOrder(int val) { PriorityOrder = val; }
135         static int getTypePriorityOrder() { return PriorityOrder; }
136
137         int openFrontend();
138         int closeFrontend(bool force=false);
139         const char *getDescription() const { return m_description; }
140 };
141
142 #endif // SWIG
143 #endif