- add ts recorder
[enigma2.git] / lib / dvb / sec.cpp
1 #include <config.h>
2 #include <lib/dvb/sec.h>
3 #if HAVE_DVB_API_VERSION < 3
4 #include <ost/frontend.h>
5 #define INVERSION Inversion
6 #define FREQUENCY Frequency
7 #define FEC_INNER FEC_inner
8 #define SYMBOLRATE SymbolRate
9 #else
10 #include <linux/dvb/frontend.h>
11 #define INVERSION inversion
12 #define FREQUENCY frequency
13 #define FEC_INNER fec_inner
14 #define SYMBOLRATE symbol_rate
15 #endif
16 #include <lib/base/eerror.h>
17
18 DEFINE_REF(eDVBSatelliteEquipmentControl);
19
20 eDVBSatelliteEquipmentControl::eDVBSatelliteEquipmentControl()
21 {
22 }
23
24 RESULT eDVBSatelliteEquipmentControl::prepare(iDVBFrontend &frontend, FRONTENDPARAMETERS &parm, eDVBFrontendParametersSatellite &sat)
25 {
26         int hi;
27         eDebug("(very) ugly and hardcoded eDVBSatelliteEquipmentControl");
28
29         if (sat.frequency > 11700000)
30                 hi = 1;
31         else
32                 hi = 0;
33         
34         if (hi)
35                 parm.FREQUENCY = sat.frequency - 10600000;
36         else
37                 parm.FREQUENCY = sat.frequency -  9750000;
38         
39 //      frontend.sentDiseqc(...);
40
41         parm.INVERSION = (!sat.inversion) ? INVERSION_ON : INVERSION_OFF;
42
43         switch (sat.fec)
44         {
45 //              case 1:
46 //              case ...:
47         default:
48                 parm.u.qpsk.FEC_INNER = FEC_AUTO;
49                 break;
50         }
51         parm.u.qpsk.SYMBOLRATE = sat.symbol_rate;
52
53         eDVBDiseqcCommand diseqc;
54
55 #if HAVE_DVB_API_VERSION < 3
56         diseqc.voltage = sat.polarisation == eDVBFrontendParametersSatellite::Polarisation::Vertical ? iDVBFrontend::voltage13 : iDVBFrontend::voltage18;
57         diseqc.tone = hi ? iDVBFrontend::toneOn : iDVBFrontend::toneOff;
58 #else
59         frontend.setVoltage(sat.polarisation == eDVBFrontendParametersSatellite::Polarisation::Vertical ? iDVBFrontend::voltage13 : iDVBFrontend::voltage18);
60 #endif
61
62         diseqc.len = 4;
63         diseqc.data[0] = 0xe0;
64         diseqc.data[1] = 0x10;
65         diseqc.data[2] = 0x38;
66         diseqc.data[3] = 0xF0;
67
68         if (hi)
69                 diseqc.data[3] |= 1;
70
71         if (sat.polarisation == eDVBFrontendParametersSatellite::Polarisation::Horizontal)
72                 diseqc.data[3] |= 2;
73
74         frontend.sendDiseqc(diseqc);
75
76 #if HAVE_DVB_API_VERSION > 2
77         frontend.setTone(hi ? iDVBFrontend::toneOn : iDVBFrontend::toneOff);
78 #endif
79
80         return 0;
81 }
82