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