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#ifndef __DEMUX_H
27#define __DEMUX_H
28
29#include <linux/types.h>
30#include <linux/errno.h>
31#include <linux/list.h>
32#include <linux/time.h>
33#include <linux/dvb/dmx.h>
34
35
36
37
38
39
40
41
42
43#ifndef DMX_MAX_FILTER_SIZE
44#define DMX_MAX_FILTER_SIZE 18
45#endif
46
47
48
49
50
51#ifndef DMX_MAX_SECTION_SIZE
52#define DMX_MAX_SECTION_SIZE 4096
53#endif
54#ifndef DMX_MAX_SECFEED_SIZE
55#define DMX_MAX_SECFEED_SIZE (DMX_MAX_SECTION_SIZE + 188)
56#endif
57
58
59
60
61
62
63enum dmx_success {
64 DMX_OK = 0,
65 DMX_LENGTH_ERROR,
66 DMX_OVERRUN_ERROR,
67 DMX_CRC_ERROR,
68 DMX_FRAME_ERROR,
69 DMX_FIFO_ERROR,
70 DMX_MISSED_ERROR
71} ;
72
73
74
75
76
77
78
79#define TS_PACKET 1
80#define TS_PAYLOAD_ONLY 2
81
82#define TS_DECODER 4
83#define TS_DEMUX 8
84
85
86
87
88
89enum dmx_ts_pes
90{
91 DMX_TS_PES_AUDIO0,
92 DMX_TS_PES_VIDEO0,
93 DMX_TS_PES_TELETEXT0,
94 DMX_TS_PES_SUBTITLE0,
95 DMX_TS_PES_PCR0,
96
97 DMX_TS_PES_AUDIO1,
98 DMX_TS_PES_VIDEO1,
99 DMX_TS_PES_TELETEXT1,
100 DMX_TS_PES_SUBTITLE1,
101 DMX_TS_PES_PCR1,
102
103 DMX_TS_PES_AUDIO2,
104 DMX_TS_PES_VIDEO2,
105 DMX_TS_PES_TELETEXT2,
106 DMX_TS_PES_SUBTITLE2,
107 DMX_TS_PES_PCR2,
108
109 DMX_TS_PES_AUDIO3,
110 DMX_TS_PES_VIDEO3,
111 DMX_TS_PES_TELETEXT3,
112 DMX_TS_PES_SUBTITLE3,
113 DMX_TS_PES_PCR3,
114
115 DMX_TS_PES_OTHER
116};
117
118#define DMX_TS_PES_AUDIO DMX_TS_PES_AUDIO0
119#define DMX_TS_PES_VIDEO DMX_TS_PES_VIDEO0
120#define DMX_TS_PES_TELETEXT DMX_TS_PES_TELETEXT0
121#define DMX_TS_PES_SUBTITLE DMX_TS_PES_SUBTITLE0
122#define DMX_TS_PES_PCR DMX_TS_PES_PCR0
123
124
125struct dmx_ts_feed {
126 int is_filtering;
127 struct dmx_demux *parent;
128 void *priv;
129 int (*set) (struct dmx_ts_feed *feed,
130 u16 pid,
131 int type,
132 enum dmx_ts_pes pes_type,
133 size_t circular_buffer_size,
134 struct timespec timeout);
135 int (*start_filtering) (struct dmx_ts_feed* feed);
136 int (*stop_filtering) (struct dmx_ts_feed* feed);
137};
138
139
140
141
142
143struct dmx_section_filter {
144 u8 filter_value [DMX_MAX_FILTER_SIZE];
145 u8 filter_mask [DMX_MAX_FILTER_SIZE];
146 u8 filter_mode [DMX_MAX_FILTER_SIZE];
147 struct dmx_section_feed* parent;
148 void* priv;
149};
150
151struct dmx_section_feed {
152 int is_filtering;
153 struct dmx_demux* parent;
154 void* priv;
155
156 int check_crc;
157 u32 crc_val;
158
159 u8 *secbuf;
160 u8 secbuf_base[DMX_MAX_SECFEED_SIZE];
161 u16 secbufp, seclen, tsfeedp;
162
163 int (*set) (struct dmx_section_feed* feed,
164 u16 pid,
165 size_t circular_buffer_size,
166 int check_crc);
167 int (*allocate_filter) (struct dmx_section_feed* feed,
168 struct dmx_section_filter** filter);
169 int (*release_filter) (struct dmx_section_feed* feed,
170 struct dmx_section_filter* filter);
171 int (*start_filtering) (struct dmx_section_feed* feed);
172 int (*stop_filtering) (struct dmx_section_feed* feed);
173};
174
175
176
177
178
179typedef int (*dmx_ts_cb) ( const u8 * buffer1,
180 size_t buffer1_length,
181 const u8 * buffer2,
182 size_t buffer2_length,
183 struct dmx_ts_feed* source,
184 enum dmx_success success);
185
186typedef int (*dmx_section_cb) ( const u8 * buffer1,
187 size_t buffer1_len,
188 const u8 * buffer2,
189 size_t buffer2_len,
190 struct dmx_section_filter * source,
191 enum dmx_success success);
192
193
194
195
196
197enum dmx_frontend_source {
198 DMX_MEMORY_FE,
199 DMX_FRONTEND_0,
200 DMX_FRONTEND_1,
201 DMX_FRONTEND_2,
202 DMX_FRONTEND_3,
203 DMX_STREAM_0,
204 DMX_STREAM_1,
205 DMX_STREAM_2,
206 DMX_STREAM_3
207};
208
209struct dmx_frontend {
210 struct list_head connectivity_list;
211
212
213 enum dmx_frontend_source source;
214};
215
216
217
218
219
220
221
222
223
224#define DMX_TS_FILTERING 1
225#define DMX_PES_FILTERING 2
226#define DMX_SECTION_FILTERING 4
227#define DMX_MEMORY_BASED_FILTERING 8
228#define DMX_CRC_CHECKING 16
229#define DMX_TS_DESCRAMBLING 32
230
231
232
233
234
235
236
237
238
239
240
241
242#define DMX_FE_ENTRY(list) list_entry(list, struct dmx_frontend, connectivity_list)
243
244struct dmx_demux {
245 u32 capabilities;
246 struct dmx_frontend* frontend;
247 void* priv;
248 int (*open) (struct dmx_demux* demux);
249 int (*close) (struct dmx_demux* demux);
250 int (*write) (struct dmx_demux* demux, const char __user *buf, size_t count);
251 int (*allocate_ts_feed) (struct dmx_demux* demux,
252 struct dmx_ts_feed** feed,
253 dmx_ts_cb callback);
254 int (*release_ts_feed) (struct dmx_demux* demux,
255 struct dmx_ts_feed* feed);
256 int (*allocate_section_feed) (struct dmx_demux* demux,
257 struct dmx_section_feed** feed,
258 dmx_section_cb callback);
259 int (*release_section_feed) (struct dmx_demux* demux,
260 struct dmx_section_feed* feed);
261 int (*add_frontend) (struct dmx_demux* demux,
262 struct dmx_frontend* frontend);
263 int (*remove_frontend) (struct dmx_demux* demux,
264 struct dmx_frontend* frontend);
265 struct list_head* (*get_frontends) (struct dmx_demux* demux);
266 int (*connect_frontend) (struct dmx_demux* demux,
267 struct dmx_frontend* frontend);
268 int (*disconnect_frontend) (struct dmx_demux* demux);
269
270 int (*get_pes_pids) (struct dmx_demux* demux, u16 *pids);
271
272 int (*get_caps) (struct dmx_demux* demux, struct dmx_caps *caps);
273
274 int (*set_source) (struct dmx_demux* demux, const dmx_source_t *src);
275
276 int (*get_stc) (struct dmx_demux* demux, unsigned int num,
277 u64 *stc, unsigned int *base);
278};
279
280#endif
281