aboutsummaryrefslogtreecommitdiffstats
path: root/util/scan/dump-zap.c
blob: fb46a2a8be9c45a811e70caa9b7f8bc51f5526a6 (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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#include <stdio.h>
#include <linux/dvb/frontend.h>
#include "dump-zap.h"

static const char *inv_name [] = {
	"INVERSION_OFF",
	"INVERSION_ON",
	"INVERSION_AUTO"
};

static const char *fec_name [] = {
	"FEC_NONE",
	"FEC_1_2",
	"FEC_2_3",
	"FEC_3_4",
	"FEC_4_5",
	"FEC_5_6",
	"FEC_6_7",
	"FEC_7_8",
	"FEC_8_9",
	"FEC_AUTO"
};


static const char *qam_name [] = {
	"QPSK",
	"QAM_16",
	"QAM_32",
	"QAM_64",
	"QAM_128",
	"QAM_256",
	"QAM_AUTO"
};


static const char *bw_name [] = {
	"BANDWIDTH_8_MHZ",
	"BANDWIDTH_7_MHZ",
	"BANDWIDTH_6_MHZ",
	"BANDWIDTH_AUTO"
};


static const char *mode_name [] = {
	"TRANSMISSION_MODE_2K",
	"TRANSMISSION_MODE_8K",
	"TRANSMISSION_MODE_AUTO"
};

static const char *guard_name [] = {
	"GUARD_INTERVAL_1_32",
	"GUARD_INTERVAL_1_16",
	"GUARD_INTERVAL_1_8",
	"GUARD_INTERVAL_1_4",
	"GUARD_INTERVAL_AUTO"
};


static const char *hierarchy_name [] = {
	"HIERARCHY_NONE",
	"HIERARCHY_1",
	"HIERARCHY_2",
	"HIERARCHY_4",
	"HIERARCHY_AUTO"
};


void zap_dump_dvb_parameters (FILE *f, fe_type_t type, struct dvb_frontend_parameters *p, char polarity, int sat_number)
{
	switch (type) {
	case FE_QPSK:
		fprintf (f, "%i:", p->frequency / 1000);	/* channels.conf wants MHz */
		fprintf (f, "%c:", polarity);
		fprintf (f, "%d:", sat_number);
		fprintf (f, "%i", p->u.qpsk.symbol_rate / 1000); /* channels.conf wants kBaud */
		/*fprintf (f, "%s", fec_name[p->u.qpsk.fec_inner]);*/
		break;

	case FE_QAM:
		fprintf (f, "%i:", p->frequency);
		fprintf (f, "%s:", inv_name[p->inversion]);
		fprintf (f, "%i:", p->u.qpsk.symbol_rate);
		fprintf (f, "%s:", fec_name[p->u.qpsk.fec_inner]);
		fprintf (f, "%s", qam_name[p->u.qam.modulation]);
		break;

	case FE_OFDM:
		fprintf (f, "%i:", p->frequency);
		fprintf (f, "%s:", inv_name[p->inversion]);
		fprintf (f, "%s:", bw_name[p->u.ofdm.bandwidth]);
		fprintf (f, "%s:", fec_name[p->u.ofdm.code_rate_HP]);
		fprintf (f, "%s:", fec_name[p->u.ofdm.code_rate_LP]);
		fprintf (f, "%s:", qam_name[p->u.ofdm.constellation]);
		fprintf (f, "%s:", mode_name[p->u.ofdm.transmission_mode]);
		fprintf (f, "%s:", guard_name[p->u.ofdm.guard_interval]);
		fprintf (f, "%s", hierarchy_name[p->u.ofdm.hierarchy_information]);
		break;

	default:
		;
	};
}

void zap_dump_service_parameter_set (FILE *f, 
				 const char *service_name,
				 fe_type_t type,
				 struct dvb_frontend_parameters *p,
				 char polarity,
				 int sat_number,
				 uint16_t video_pid,
				 uint16_t *audio_pid,
				 uint16_t service_id)
{
	fprintf (f, "%s:", service_name);
	zap_dump_dvb_parameters (f, type, p, polarity, sat_number);
	fprintf (f, ":%i:%i:%i", video_pid, audio_pid[0], service_id);
	fprintf (f, "\n");
}