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