aboutsummaryrefslogtreecommitdiff
path: root/lib/dvb/sec.cpp
blob: b3c4b2cc0aed2be06e6de42d5b4e604a0fdf84b5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include <lib/dvb/sec.h>
#include <linux/dvb/frontend.h>
#include <lib/base/eerror.h>

DEFINE_REF(eDVBSatelliteEquipmentControl);

eDVBSatelliteEquipmentControl::eDVBSatelliteEquipmentControl(): ref(0)
{
}

RESULT eDVBSatelliteEquipmentControl::prepare(iDVBFrontend &frontend, struct dvb_frontend_parameters &parm, eDVBFrontendParametersSatellite &sat)
{
	int hi;
	eDebug("(very) ugly and hardcoded eDVBSatelliteEquipmentControl");
	
	if (sat.frequency > 11700000)
		hi = 1;
	else
		hi = 0;
	
	if (hi)
		parm.frequency = sat.frequency - 10600000;
	else
		parm.frequency = sat.frequency -  9750000;
	
//	frontend.sentDiseqc(...);

	parm.inversion = sat.inversion ? INVERSION_ON : INVERSION_OFF;

	switch (sat.fec)
	{
//		case 1:
//		case ...:
	default:
		parm.u.qpsk.fec_inner = FEC_AUTO;
		break;
	}
	parm.u.qpsk.symbol_rate = sat.symbol_rate;
	

	frontend.setVoltage((sat.polarisation == eDVBFrontendParametersSatellite::Polarisation::Vertical) ? iDVBFrontend::voltage13 : iDVBFrontend::voltage18);

	eDVBDiseqcCommand diseqc;
	
	diseqc.len = 4;
	diseqc.data[0] = 0xe0;
	diseqc.data[1] = 0x10;
	diseqc.data[2] = 0x38;
	diseqc.data[3] = 0xF0;
	
	if (hi)
		diseqc.data[3] |= 1;
		
	if (sat.polarisation == eDVBFrontendParametersSatellite::Polarisation::Horizontal)
		diseqc.data[3] |= 2;

	frontend.sendDiseqc(diseqc);
	frontend.setTone(hi ? iDVBFrontend::toneOn : iDVBFrontend::toneOff);
	
	return 0;
}