root/trunk/tvheadend/src/dvb/dvb.h @ 3040

Revision 3040, 5.2 KB (checked in by andoma, 15 months ago)

Make DVB FE logging DEBUGish

Line 
1/*
2 *  TV Input - Linux DVB interface
3 *  Copyright (C) 2007 Andreas �an
4 *
5 *  This program is free software: you can redistribute it and/or modify
6 *  it under the terms of the GNU General Public License as published by
7 *  the Free Software Foundation, either version 3 of the License, or
8 *  (at your option) any later version.
9 *
10 *  This program is distributed in the hope that it will be useful,
11 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 *  GNU General Public License for more details.
14 *
15 *  You should have received a copy of the GNU General Public License
16 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef DVB_H_
20#define DVB_H_
21
22#include <linux/dvb/frontend.h>
23
24TAILQ_HEAD(th_dvb_adapter_queue, th_dvb_adapter);
25RB_HEAD(th_dvb_mux_instance_tree, th_dvb_mux_instance);
26TAILQ_HEAD(th_dvb_mux_instance_queue, th_dvb_mux_instance);
27
28
29enum polarisation {
30        POLARISATION_HORIZONTAL     = 0x00,
31        POLARISATION_VERTICAL       = 0x01,
32        POLARISATION_CIRCULAR_LEFT  = 0x02,
33        POLARISATION_CIRCULAR_RIGHT = 0x03
34};
35
36#define DVB_FEC_ERROR_LIMIT 20
37
38
39/**
40 * DVB Mux instance
41 */
42typedef struct th_dvb_mux_instance {
43
44  RB_ENTRY(th_dvb_mux_instance) tdmi_global_link;
45  RB_ENTRY(th_dvb_mux_instance) tdmi_adapter_link;
46
47
48  struct th_dvb_adapter *tdmi_adapter;
49
50  uint16_t tdmi_snr, tdmi_signal;
51  uint32_t tdmi_ber, tdmi_uncorrected_blocks;
52
53#define TDMI_FEC_ERR_HISTOGRAM_SIZE 10
54  uint32_t tdmi_fec_err_histogram[TDMI_FEC_ERR_HISTOGRAM_SIZE];
55  int      tdmi_fec_err_ptr;
56
57  time_t tdmi_time;
58  LIST_HEAD(, th_dvb_table) tdmi_tables;
59
60  enum {
61    TDMI_FE_UNKNOWN,
62    TDMI_FE_NO_SIGNAL,
63    TDMI_FE_FAINT_SIGNAL,
64    TDMI_FE_BAD_SIGNAL,
65    TDMI_FE_CONSTANT_FEC,
66    TDMI_FE_BURSTY_FEC,
67    TDMI_FE_OK,
68  } tdmi_fe_status;
69
70  int tdmi_quality;
71
72  time_t tdmi_got_adapter;
73  time_t tdmi_lost_adapter;
74
75  struct dvb_frontend_parameters tdmi_fe_params;
76  uint8_t tdmi_polarisation;  /* for DVB-S */
77  uint8_t tdmi_switchport;    /* for DVB-S */
78
79  uint16_t tdmi_transport_stream_id;
80
81  char *tdmi_identifier;
82  char *tdmi_network;     /* Name of network, from NIT table */
83
84  struct th_transport_list tdmi_transports; /* via tht_mux_link */
85
86
87  TAILQ_ENTRY(th_dvb_mux_instance) tdmi_scan_link;
88  struct th_dvb_mux_instance_queue *tdmi_scan_queue;
89
90} th_dvb_mux_instance_t;
91
92
93#define DVB_MUX_SCAN_BAD 0      /* On the bad queue */
94#define DVB_MUX_SCAN_OK  1      /* Ok, don't need to scan that often */
95#define DVB_MUX_SCAN_INITIAL 2  /* To get a scan directly when a mux
96                                   is discovered */
97
98/**
99 * DVB Adapter (one of these per physical adapter)
100 */
101typedef struct th_dvb_adapter {
102
103  TAILQ_ENTRY(th_dvb_adapter) tda_global_link;
104
105  struct th_dvb_mux_instance_tree tda_muxes;
106
107  /**
108   * We keep our muxes on three queues in order to select how
109   * they are to be idle-scanned
110   */
111  struct th_dvb_mux_instance_queue tda_scan_queues[3];
112  int tda_scan_selector;  /* To alternate between bad and ok queue */
113
114  th_dvb_mux_instance_t *tda_mux_current;
115
116  int tda_table_epollfd;
117
118  const char *tda_rootpath;
119  char *tda_identifier;
120  uint32_t tda_autodiscovery;
121  char *tda_displayname;
122
123  int tda_fe_fd;
124  int tda_type;
125  struct dvb_frontend_info *tda_fe_info;
126
127  char *tda_demux_path;
128
129  char *tda_dvr_path;
130
131  gtimer_t tda_mux_scanner_timer;
132
133  pthread_mutex_t tda_delivery_mutex;
134  struct th_transport_list tda_transports; /* Currently bound transports */
135
136  gtimer_t tda_fe_monitor_timer;
137  int tda_fe_monitor_hold;
138
139} th_dvb_adapter_t;
140
141
142
143extern struct th_dvb_adapter_queue dvb_adapters;
144extern struct th_dvb_mux_instance_tree dvb_muxes;
145
146void dvb_init(void);
147
148/**
149 * DVB Adapter
150 */
151void dvb_adapter_init(void);
152
153void dvb_adapter_mux_scanner(void *aux);
154
155void dvb_adapter_notify_reload(th_dvb_adapter_t *tda);
156
157void dvb_adapter_set_displayname(th_dvb_adapter_t *tda, const char *s);
158
159void dvb_adapter_set_auto_discovery(th_dvb_adapter_t *tda, int on);
160
161void dvb_adapter_clone(th_dvb_adapter_t *dst, th_dvb_adapter_t *src);
162
163void dvb_adapter_clean(th_dvb_adapter_t *tda);
164
165int dvb_adapter_destroy(th_dvb_adapter_t *tda);
166
167/**
168 * DVB Multiplex
169 */
170void dvb_mux_save(th_dvb_mux_instance_t *tdmi);
171
172void dvb_mux_load(th_dvb_adapter_t *tda);
173
174void dvb_mux_destroy(th_dvb_mux_instance_t *tdmi);
175
176th_dvb_mux_instance_t *dvb_mux_create(th_dvb_adapter_t *tda,
177                                      struct dvb_frontend_parameters *fe_param,
178                                      int polarisation, int switchport,
179                                      uint16_t tsid, const char *network,
180                                      const char *logprefix);
181
182void dvb_mux_set_networkname(th_dvb_mux_instance_t *tdmi, const char *name);
183
184/**
185 * DVB Transport (aka DVB service)
186 */
187void dvb_transport_load(th_dvb_mux_instance_t *tdmi);
188
189th_transport_t *dvb_transport_find(th_dvb_mux_instance_t *tdmi,
190                                   uint16_t sid, int pmt_pid, int *created);
191
192
193/**
194 * DVB Frontend
195 */
196void dvb_fe_tune(th_dvb_mux_instance_t *tdmi, const char *reason);
197
198void dvb_fe_stop(th_dvb_mux_instance_t *tdmi);
199
200
201/**
202 * DVB Tables
203 */
204void dvb_table_init(th_dvb_adapter_t *tda);
205
206void dvb_table_add_default(th_dvb_mux_instance_t *tdmi);
207
208void dvb_table_add_transport(th_dvb_mux_instance_t *tdmi, th_transport_t *t,
209                             int pmt_pid);
210
211void dvb_table_flush_all(th_dvb_mux_instance_t *tdmi);
212
213#endif /* DVB_H_ */
Note: See TracBrowser for help on using the browser.