# Aurillac - France (DVB-T transmitter of Aurillac ( Agglomération ) ) # Aurillac - France (signal DVB-T transmis depuis l'émetteur de Agglomération ) # # ATTENTION ! Ce fichier a ete construit automatiquement a partir # des frequences obtenues sur : http://www.tvnt.net/multiplex_frequences.htm # en Avril 2006. Si vous constatez des problemes et voulez apporter des # modifications au fichier, envoyez le fichier modifie a # l'adresse linux-dvb@linuxtv.org (depot des fichiers d'init dvb) # ou a l'auteur du fichier : # Nicolas Estre # # T freq bw fec_hi fec_lo mod transmission-mode guard-interval hierarchy #### Aurillac - Agglomération #### #R1 T 642000000 8MHz AUTO NONE QAM64 8k AUTO NONE #R2 T 578000000 8MHz AUTO NONE QAM64 8k AUTO NONE #R3 T 602000000 8MHz AUTO NONE QAM64 8k AUTO NONE #R4 T 618000000 8MHz AUTO NONE QAM64 8k AUTO NONE #R5 T 706000000 8MHz AUTO NONE QAM64 8k AUTO NONE #R6 T 666000000 8MHz AUTO NONE QAM64 8k AUTO NONE value='pristine-tar'>pristine-tar linux-dvb-apps Debian packagingJonathan McCrohan
aboutsummaryrefslogtreecommitdiffstats
path: root/lib/libdvbcfg/dvbcfg_zapchannel.c
blob: 2c2605e442c95a8b9022988a8249618ba71015b1 (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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
/*
 * dvbcfg - support for linuxtv configuration files
 * zap channel file support
 *
 * Copyright (C) 2006 Christoph Pfister <christophpfister@gmail.com>
 * Copyright (C) 2005 Andrew de Quincey <adq_dvb@lidskialf.net>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
 */

#define _GNU_SOURCE

#include <malloc.h>
#include <string.h>
#include <ctype.h>

#include "dvbcfg_zapchannel.h"
#include "dvbcfg_common.h"

static const struct dvbcfg_setting dvbcfg_inversion_list[] = {
	{ "INVERSION_ON",   DVBFE_INVERSION_ON   },
	{ "INVERSION_OFF",  DVBFE_INVERSION_OFF  },
	{ "INVERSION_AUTO", DVBFE_INVERSION_AUTO },
	{ NULL, 0 }
};

static const struct dvbcfg_setting dvbcfg_fec_list[] = {
	{ "FEC_1_2",  DVBFE_FEC_1_2  },
	{ "FEC_2_3",  DVBFE_FEC_2_3  },
	{ "FEC_3_4",  DVBFE_FEC_3_4  },
	{ "FEC_4_5",  DVBFE_FEC_4_5  },
	{ "FEC_5_6",  DVBFE_FEC_5_6  },
	{ "FEC_6_7",  DVBFE_FEC_6_7  },
	{ "FEC_7_8",  DVBFE_FEC_7_8  },
	{ "FEC_8_9",  DVBFE_FEC_8_9  },
	{ "FEC_AUTO", DVBFE_FEC_AUTO },
	{ "FEC_NONE", DVBFE_FEC_NONE },
	{ NULL, 0 }
};

static const struct dvbcfg_setting dvbcfg_dvbc_modulation_list[] = {
	{ "QAM_16",   DVBFE_DVBC_MOD_QAM_16  },
	{ "QAM_32",   DVBFE_DVBC_MOD_QAM_32  },
	{ "QAM_64",   DVBFE_DVBC_MOD_QAM_64  },
	{ "QAM_128",  DVBFE_DVBC_MOD_QAM_128 },
	{ "QAM_256",  DVBFE_DVBC_MOD_QAM_256 },
	{ "QAM_AUTO", DVBFE_DVBC_MOD_AUTO    },
	{ NULL, 0 }
};

static const struct dvbcfg_setting dvbcfg_bandwidth_list[] = {
	{ "BANDWIDTH_6_MHZ", DVBFE_DVBT_BANDWIDTH_6_MHZ },
	{ "BANDWIDTH_7_MHZ", DVBFE_DVBT_BANDWIDTH_7_MHZ },
	{ "BANDWIDTH_8_MHZ", DVBFE_DVBT_BANDWIDTH_8_MHZ },
	{ "BANDWIDTH_AUTO",  DVBFE_DVBT_BANDWIDTH_AUTO  },
	{ NULL, 0 }
};

static const struct dvbcfg_setting dvbcfg_constellation_list[] = {
	{ "QAM_16",   DVBFE_DVBT_CONST_QAM_16  },
	{ "QAM_32",   DVBFE_DVBT_CONST_QAM_32  },
	{ "QAM_64",   DVBFE_DVBT_CONST_QAM_64  },
	{ "QAM_128",  DVBFE_DVBT_CONST_QAM_128 },
	{ "QAM_256",  DVBFE_DVBT_CONST_QAM_256 },
	{ "QPSK",     DVBFE_DVBT_CONST_QPSK    },
	{ "QAM_AUTO", DVBFE_DVBT_CONST_AUTO    },
	{ NULL, 0 }
};

static const struct dvbcfg_setting dvbcfg_transmission_mode_list[] = {
	{ "TRANSMISSION_MODE_2K",   DVBFE_DVBT_TRANSMISSION_MODE_2K   },
	{ "TRANSMISSION_MODE_8K",   DVBFE_DVBT_TRANSMISSION_MODE_8K   },
	{ "TRANSMISSION_MODE_AUTO", DVBFE_DVBT_TRANSMISSION_MODE_AUTO },
	{ NULL, 0 }
};

static const struct dvbcfg_setting dvbcfg_guard_interval_list[] = {
	{ "GUARD_INTERVAL_1_32", DVBFE_DVBT_GUARD_INTERVAL_1_32 },
	{ "GUARD_INTERVAL_1_16", DVBFE_DVBT_GUARD_INTERVAL_1_16 },
	{ "GUARD_INTERVAL_1_8",  DVBFE_DVBT_GUARD_INTERVAL_1_8  },
	{ "GUARD_INTERVAL_1_4",  DVBFE_DVBT_GUARD_INTERVAL_1_4  },
	{ "GUARD_INTERVAL_AUTO", DVBFE_DVBT_GUARD_INTERVAL_AUTO },
	{ NULL, 0 }
};

static const struct dvbcfg_setting dvbcfg_hierarchy_list[] = {
	{ "HIERARCHY_1",    DVBFE_DVBT_HIERARCHY_1    },
	{ "HIERARCHY_2",    DVBFE_DVBT_HIERARCHY_2    },
	{ "HIERARCHY_4",    DVBFE_DVBT_HIERARCHY_4    },
	{ "HIERARCHY_AUTO", DVBFE_DVBT_HIERARCHY_AUTO },
	{ "HIERARCHY_NONE", DVBFE_DVBT_HIERARCHY_NONE },
	{ NULL, 0 }
};

static const struct dvbcfg_setting dvbcfg_atsc_modulation_list[] = {
	{ "8VSB",    DVBFE_ATSC_MOD_VSB_8   },
	{ "16VSB",   DVBFE_ATSC_MOD_VSB_16  },
	{ "QAM_64",  DVBFE_ATSC_MOD_QAM_64  },
	{ "QAM_256", DVBFE_ATSC_MOD_QAM_256 },
	{ NULL, 0 }
};

int dvbcfg_zapchannel_parse(FILE *file, dvbcfg_zapcallback callback, void *private_data)
{
	char *line_buf = NULL;
	size_t line_size = 0;
	int line_len = 0;
	int ret_val = 0;

	while ((line_len = getline(&line_buf, &line_size, file)) > 0) {
		char *line_tmp = line_buf;
		char *line_pos = line_buf;
		struct dvbcfg_zapchannel tmp;

		/* remove newline and comments (started with hashes) */
		while ((*line_tmp != '\0') && (*line_tmp != '\n') && (*line_tmp != '#'))
			line_tmp++;
		*line_tmp = '\0';

		/* parse name */
		dvbcfg_parse_string(&line_pos, ":", tmp.name, sizeof(tmp.name));
		if (!line_pos)
			continue;

		/* parse frequency */
		tmp.fe_params.frequency = dvbcfg_parse_int(&line_pos, ":");
		if (!line_pos)
			continue;

		/* try to determine frontend type */
		if (strstr(line_pos, ":FEC_")) {
			if (strstr(line_pos, ":HIERARCHY_"))
				tmp.fe_type = DVBFE_TYPE_DVBT;
			else
				tmp.fe_type = DVBFE_TYPE_DVBC;
		} else {
			if (strstr(line_pos, "VSB:") || strstr(line_pos, "QAM_"))
				tmp.fe_type = DVBFE_TYPE_ATSC;
			else
				tmp.fe_type = DVBFE_TYPE_DVBS;
		}

		/* parse frontend specific settings */
		switch (tmp.fe_type) {
		case DVBFE_TYPE_ATSC:
			/* inversion */
			tmp.fe_params.inversion = DVBFE_INVERSION_AUTO;

			/* modulation */
			tmp.fe_params.u.atsc.modulation =
				dvbcfg_parse_setting(&line_pos, ":", dvbcfg_atsc_modulation_list);
			if (!line_pos)
				continue;

			break;

		case DVBFE_TYPE_DVBC:
			/* inversion */
			tmp.fe_params.inversion =
				dvbcfg_parse_setting(&line_pos, ":", dvbcfg_inversion_list);
			if (!line_pos)
				continue;

			/* symbol rate */
			tmp.fe_params.u.dvbc.symbol_rate = dvbcfg_parse_int(&line_pos, ":");
			if (!line_pos)
				continue;

			/* fec */
			tmp.fe_params.u.dvbc.fec_inner =
				dvbcfg_parse_setting(&line_pos, ":", dvbcfg_fec_list);
			if (!line_pos)
				continue;

			/* modulation */
			tmp.fe_params.u.dvbc.modulation =
				dvbcfg_parse_setting(&line_pos, ":", dvbcfg_dvbc_modulation_list);
			if (!line_pos)
				continue;

			break;

		case DVBFE_TYPE_DVBS:
			/* adjust frequency */
			tmp.fe_params.frequency *= 1000;

			/* inversion */
			tmp.fe_params.inversion = DVBFE_INVERSION_AUTO;

			/* fec */
			tmp.fe_params.u.dvbs.fec_inner = DVBFE_FEC_AUTO;

			/* polarization */
			tmp.polarization = tolower(dvbcfg_parse_char(&line_pos, ":"));
			if (!line_pos)
				continue;
			if ((tmp.polarization != 'h') &&
			    (tmp.polarization != 'v') &&
			    (tmp.polarization != 'l') &&
			    (tmp.polarization != 'r'))
				continue;

			/* satellite switch position */
			tmp.diseqc_switch = dvbcfg_parse_int(&line_pos, ":");
			if (!line_pos)
				continue;

			/* symbol rate */
			tmp.fe_params.u.dvbs.symbol_rate =
				dvbcfg_parse_int(&line_pos, ":") * 1000;
			if (!line_pos)
				continue;

			break;

		case DVBFE_TYPE_DVBT:
			/* inversion */
			tmp.fe_params.inversion =
				dvbcfg_parse_setting(&line_pos, ":", dvbcfg_inversion_list);
			if (!line_pos)
				continue;

			/* bandwidth */
			tmp.fe_params.u.dvbt.bandwidth =
				dvbcfg_parse_setting(&line_pos, ":", dvbcfg_bandwidth_list);
			if (!line_pos)
				continue;

			/* fec hp */
			tmp.fe_params.u.dvbt.code_rate_HP =
				dvbcfg_parse_setting(&line_pos, ":", dvbcfg_fec_list);
			if (!line_pos)
				continue;

			/* fec lp */
			tmp.fe_params.u.dvbt.code_rate_LP =
				dvbcfg_parse_setting(&line_pos, ":", dvbcfg_fec_list);
			if (!line_pos)
				continue;

			/* constellation */
			tmp.fe_params.u.dvbt.constellation =
				dvbcfg_parse_setting(&line_pos, ":", dvbcfg_constellation_list);
			if (!line_pos)
				continue;

			/* transmission mode */
			tmp.fe_params.u.dvbt.transmission_mode =
				dvbcfg_parse_setting(&line_pos, ":", dvbcfg_transmission_mode_list);
			if (!line_pos)
				continue;

			/* guard interval */
			tmp.fe_params.u.dvbt.guard_interval =
				dvbcfg_parse_setting(&line_pos, ":", dvbcfg_guard_interval_list);
			if (!line_pos)
				continue;

			/* hierarchy */
			tmp.fe_params.u.dvbt.hierarchy_information =
				dvbcfg_parse_setting(&line_pos, ":", dvbcfg_hierarchy_list);
			if (!line_pos)
				continue;

			break;
		}

		/* parse video and audio pids and service id */
		tmp.video_pid = dvbcfg_parse_int(&line_pos, ":");
		if (!line_pos)
			continue;
		tmp.audio_pid = dvbcfg_parse_int(&line_pos, ":");
		if (!line_pos)
			continue;
		tmp.service_id = dvbcfg_parse_int(&line_pos, ":");
		if (!line_pos) /* old files don't have a service id */
			tmp.service_id = 0;

		/* invoke callback */
		if ((ret_val = callback(&tmp, private_data)) != 0) {
			if (ret_val < 0)
				ret_val = 0;
			break;
		}
	}

	if (line_buf)
		free(line_buf);

	return ret_val;
}

int dvbcfg_zapchannel_save(FILE *file, dvbcfg_zapcallback callback, void *private_data)
{
	int ret_val = 0;
	struct dvbcfg_zapchannel tmp;

	while ((ret_val = callback(&tmp, private_data)) == 0) {
		/* name */
		if ((ret_val = fprintf(file, "%s:", tmp.name)) < 0)
			return ret_val;

		/* frontend specific settings */
		switch (tmp.fe_type) {
		case DVBFE_TYPE_ATSC:
			if ((ret_val = fprintf(file, "%i:%s:",
			    tmp.fe_params.frequency,
			    dvbcfg_lookup_setting(tmp.fe_params.u.atsc.modulation,
						  dvbcfg_atsc_modulation_list))) < 0)
				return ret_val;

			break;

		case DVBFE_TYPE_DVBC:
			if ((ret_val = fprintf(file, "%i:%s:%i:%s:%s:",
			    tmp.fe_params.frequency,
			    dvbcfg_lookup_setting(tmp.fe_params.inversion,
						  dvbcfg_inversion_list),
			    tmp.fe_params.u.dvbc.symbol_rate,
			    dvbcfg_lookup_setting(tmp.fe_params.u.dvbc.fec_inner,
						  dvbcfg_fec_list),
			    dvbcfg_lookup_setting(tmp.fe_params.u.dvbc.modulation,
						  dvbcfg_dvbc_modulation_list))) < 0)
				return ret_val;

			break;

		case DVBFE_TYPE_DVBS:
			if ((ret_val = fprintf(file, "%i:%c:%i:%i:",
			    tmp.fe_params.frequency / 1000,
			    tolower(tmp.polarization),
			    tmp.diseqc_switch,
			    tmp.fe_params.u.dvbs.symbol_rate / 1000)) < 0)
				return ret_val;

			break;
		case DVBFE_TYPE_DVBT:
			if ((ret_val = fprintf(file, "%i:%s:%s:%s:%s:%s:%s:%s:%s:",
			    tmp.fe_params.frequency,
			    dvbcfg_lookup_setting(tmp.fe_params.inversion,
						  dvbcfg_inversion_list),
			    dvbcfg_lookup_setting(tmp.fe_params.u.dvbt.bandwidth,
						  dvbcfg_bandwidth_list),
			    dvbcfg_lookup_setting(tmp.fe_params.u.dvbt.code_rate_HP,
						  dvbcfg_fec_list),
			    dvbcfg_lookup_setting(tmp.fe_params.u.dvbt.code_rate_LP,
						  dvbcfg_fec_list),
			    dvbcfg_lookup_setting(tmp.fe_params.u.dvbt.constellation,
						  dvbcfg_constellation_list),
			    dvbcfg_lookup_setting(tmp.fe_params.u.dvbt.transmission_mode,
						  dvbcfg_transmission_mode_list),
			    dvbcfg_lookup_setting(tmp.fe_params.u.dvbt.guard_interval,
						  dvbcfg_guard_interval_list),
			    dvbcfg_lookup_setting(tmp.fe_params.u.dvbt.hierarchy_information,
						  dvbcfg_hierarchy_list))) < 0)
				return ret_val;

			break;
		}

		/* video and audio pids and service id */
		if ((ret_val = fprintf(file, "%i:%i:%i\n",
		    tmp.video_pid, tmp.audio_pid, tmp.service_id)) < 0)
			return ret_val;

	}

	if (ret_val < 0)
		ret_val = 0;

	return ret_val;
}