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