- eConnections holds reference to object
[enigma2.git] / lib / dvb / sec.cpp
1 #include <lib/dvb/sec.h>
2 #include <linux/dvb/frontend.h>
3 #include <lib/base/eerror.h>
4
5 DEFINE_REF(eDVBSatelliteEquipmentControl);
6
7 eDVBSatelliteEquipmentControl::eDVBSatelliteEquipmentControl(): ref(0)
8 {
9 }
10
11 RESULT eDVBSatelliteEquipmentControl::prepare(iDVBFrontend &frontend, struct dvb_frontend_parameters &parm, eDVBFrontendParametersSatellite &sat)
12 {
13         int hi;
14         eDebug("(very) ugly and hardcoded eDVBSatelliteEquipmentControl");
15         
16         if (sat.frequency > 11700000)
17                 hi = 1;
18         else
19                 hi = 0;
20         
21         if (hi)
22                 parm.frequency = sat.frequency - 10600000;
23         else
24                 parm.frequency = sat.frequency -  9750000;
25         
26 //      frontend.sentDiseqc(...);
27
28         parm.inversion = sat.inversion ? INVERSION_ON : INVERSION_OFF;
29
30         switch (sat.fec)
31         {
32 //              case 1:
33 //              case ...:
34         default:
35                 parm.u.qpsk.fec_inner = FEC_AUTO;
36                 break;
37         }
38         parm.u.qpsk.symbol_rate = sat.symbol_rate;
39         
40
41         frontend.setVoltage((sat.polarisation == eDVBFrontendParametersSatellite::Polarisation::Vertical) ? iDVBFrontend::voltage13 : iDVBFrontend::voltage18);
42
43         eDVBDiseqcCommand diseqc;
44         
45         diseqc.len = 4;
46         diseqc.data[0] = 0xe0;
47         diseqc.data[1] = 0x10;
48         diseqc.data[2] = 0x38;
49         diseqc.data[3] = 0xF0;
50         
51         if (hi)
52                 diseqc.data[3] |= 1;
53                 
54         if (sat.polarisation == eDVBFrontendParametersSatellite::Polarisation::Horizontal)
55                 diseqc.data[3] |= 2;
56
57         frontend.sendDiseqc(diseqc);
58         frontend.setTone(hi ? iDVBFrontend::toneOn : iDVBFrontend::toneOff);
59         
60         return 0;
61 }
62