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
86struct dmx_ts_feed {
87 int is_filtering;
88 struct dmx_demux *parent;
89 void *priv;
90 int (*set) (struct dmx_ts_feed *feed,
91 u16 pid,
92 int type,
93 enum dmx_ts_pes pes_type,
94 size_t circular_buffer_size,
95 struct timespec timeout);
96 int (*start_filtering) (struct dmx_ts_feed* feed);
97 int (*stop_filtering) (struct dmx_ts_feed* feed);
98};
99
100
101
102
103
104struct dmx_section_filter {
105 u8 filter_value [DMX_MAX_FILTER_SIZE];
106 u8 filter_mask [DMX_MAX_FILTER_SIZE];
107 u8 filter_mode [DMX_MAX_FILTER_SIZE];
108 struct dmx_section_feed* parent;
109 void* priv;
110};
111
112struct dmx_section_feed {
113 int is_filtering;
114 struct dmx_demux* parent;
115 void* priv;
116
117 int check_crc;
118 u32 crc_val;
119
120 u8 *secbuf;
121 u8 secbuf_base[DMX_MAX_SECFEED_SIZE];
122 u16 secbufp, seclen, tsfeedp;
123
124 int (*set) (struct dmx_section_feed* feed,
125 u16 pid,
126 size_t circular_buffer_size,
127 int check_crc);
128 int (*allocate_filter) (struct dmx_section_feed* feed,
129 struct dmx_section_filter** filter);
130 int (*release_filter) (struct dmx_section_feed* feed,
131 struct dmx_section_filter* filter);
132 int (*start_filtering) (struct dmx_section_feed* feed);
133 int (*stop_filtering) (struct dmx_section_feed* feed);
134};
135
136
137
138
139
140typedef int (*dmx_ts_cb) ( const u8 * buffer1,
141 size_t buffer1_length,
142 const u8 * buffer2,
143 size_t buffer2_length,
144 struct dmx_ts_feed* source,
145 enum dmx_success success);
146
147typedef int (*dmx_section_cb) ( const u8 * buffer1,
148 size_t buffer1_len,
149 const u8 * buffer2,
150 size_t buffer2_len,
151 struct dmx_section_filter * source,
152 enum dmx_success success);
153
154
155
156
157
158enum dmx_frontend_source {
159 DMX_MEMORY_FE,
160 DMX_FRONTEND_0,
161 DMX_FRONTEND_1,
162 DMX_FRONTEND_2,
163 DMX_FRONTEND_3,
164 DMX_STREAM_0,
165 DMX_STREAM_1,
166 DMX_STREAM_2,
167 DMX_STREAM_3
168};
169
170struct dmx_frontend {
171 struct list_head connectivity_list;
172
173
174 enum dmx_frontend_source source;
175};
176
177
178
179
180
181
182
183
184
185#define DMX_TS_FILTERING 1
186#define DMX_PES_FILTERING 2
187#define DMX_SECTION_FILTERING 4
188#define DMX_MEMORY_BASED_FILTERING 8
189#define DMX_CRC_CHECKING 16
190#define DMX_TS_DESCRAMBLING 32
191
192
193
194
195
196
197
198
199
200
201
202
203#define DMX_FE_ENTRY(list) list_entry(list, struct dmx_frontend, connectivity_list)
204
205struct dmx_demux {
206 u32 capabilities;
207 struct dmx_frontend* frontend;
208 void* priv;
209 int (*open) (struct dmx_demux* demux);
210 int (*close) (struct dmx_demux* demux);
211 int (*write) (struct dmx_demux* demux, const char __user *buf, size_t count);
212 int (*allocate_ts_feed) (struct dmx_demux* demux,
213 struct dmx_ts_feed** feed,
214 dmx_ts_cb callback);
215 int (*release_ts_feed) (struct dmx_demux* demux,
216 struct dmx_ts_feed* feed);
217 int (*allocate_section_feed) (struct dmx_demux* demux,
218 struct dmx_section_feed** feed,
219 dmx_section_cb callback);
220 int (*release_section_feed) (struct dmx_demux* demux,
221 struct dmx_section_feed* feed);
222 int (*add_frontend) (struct dmx_demux* demux,
223 struct dmx_frontend* frontend);
224 int (*remove_frontend) (struct dmx_demux* demux,
225 struct dmx_frontend* frontend);
226 struct list_head* (*get_frontends) (struct dmx_demux* demux);
227 int (*connect_frontend) (struct dmx_demux* demux,
228 struct dmx_frontend* frontend);
229 int (*disconnect_frontend) (struct dmx_demux* demux);
230
231 int (*get_pes_pids) (struct dmx_demux* demux, u16 *pids);
232
233 int (*get_caps) (struct dmx_demux* demux, struct dmx_caps *caps);
234
235 int (*set_source) (struct dmx_demux* demux, const dmx_source_t *src);
236
237 int (*get_stc) (struct dmx_demux* demux, unsigned int num,
238 u64 *stc, unsigned int *base);
239};
240
241#endif
242