[media] dvb: Remove unused frontend sources at demux.h and sync doc
[deliverable/linux.git] / drivers / media / dvb-core / demux.h
CommitLineData
1da177e4
LT
1/*
2 * demux.h
3 *
4 * Copyright (c) 2002 Convergence GmbH
5 *
6 * based on code:
7 * Copyright (c) 2000 Nokia Research Center
8 * Tampere, FINLAND
9 *
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public License
12 * as published by the Free Software Foundation; either version 2.1
13 * of the License, or (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
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>
c0510052 33#include <linux/dvb/dmx.h>
1da177e4
LT
34
35/*--------------------------------------------------------------------------*/
36/* Common definitions */
37/*--------------------------------------------------------------------------*/
38
39/*
40 * DMX_MAX_FILTER_SIZE: Maximum length (in bytes) of a section/PES filter.
41 */
42
43#ifndef DMX_MAX_FILTER_SIZE
44#define DMX_MAX_FILTER_SIZE 18
45#endif
46
47/*
48 * DMX_MAX_SECFEED_SIZE: Maximum length (in bytes) of a private section feed filter.
49 */
50
b3967d6c
MA
51#ifndef DMX_MAX_SECTION_SIZE
52#define DMX_MAX_SECTION_SIZE 4096
53#endif
1da177e4 54#ifndef DMX_MAX_SECFEED_SIZE
b3967d6c 55#define DMX_MAX_SECFEED_SIZE (DMX_MAX_SECTION_SIZE + 188)
1da177e4
LT
56#endif
57
1da177e4
LT
58/*--------------------------------------------------------------------------*/
59/* TS packet reception */
60/*--------------------------------------------------------------------------*/
61
62/* TS filter type for set() */
63
64#define TS_PACKET 1 /* send TS packets (188 bytes) to callback (default) */
65#define TS_PAYLOAD_ONLY 2 /* in case TS_PACKET is set, only send the TS
66 payload (<=184 bytes per packet) to callback */
67#define TS_DECODER 4 /* send stream to built-in decoder (if present) */
4a24ce3a
AO
68#define TS_DEMUX 8 /* in case TS_PACKET is set, send the TS to
69 the demux device, not to the dvr device */
1da177e4 70
1da177e4 71struct dmx_ts_feed {
afd1a0c9
MCC
72 int is_filtering; /* Set to non-zero when filtering in progress */
73 struct dmx_demux *parent; /* Back-pointer */
74 void *priv; /* Pointer to private data of the API client */
75 int (*set) (struct dmx_ts_feed *feed,
1da177e4
LT
76 u16 pid,
77 int type,
78 enum dmx_ts_pes pes_type,
1da177e4 79 size_t circular_buffer_size,
1da177e4 80 struct timespec timeout);
afd1a0c9
MCC
81 int (*start_filtering) (struct dmx_ts_feed* feed);
82 int (*stop_filtering) (struct dmx_ts_feed* feed);
1da177e4
LT
83};
84
85/*--------------------------------------------------------------------------*/
86/* Section reception */
87/*--------------------------------------------------------------------------*/
88
89struct dmx_section_filter {
afd1a0c9
MCC
90 u8 filter_value [DMX_MAX_FILTER_SIZE];
91 u8 filter_mask [DMX_MAX_FILTER_SIZE];
92 u8 filter_mode [DMX_MAX_FILTER_SIZE];
93 struct dmx_section_feed* parent; /* Back-pointer */
94 void* priv; /* Pointer to private data of the API client */
1da177e4
LT
95};
96
97struct dmx_section_feed {
afd1a0c9
MCC
98 int is_filtering; /* Set to non-zero when filtering in progress */
99 struct dmx_demux* parent; /* Back-pointer */
100 void* priv; /* Pointer to private data of the API client */
1da177e4 101
afd1a0c9 102 int check_crc;
1da177e4
LT
103 u32 crc_val;
104
afd1a0c9
MCC
105 u8 *secbuf;
106 u8 secbuf_base[DMX_MAX_SECFEED_SIZE];
107 u16 secbufp, seclen, tsfeedp;
1da177e4 108
afd1a0c9 109 int (*set) (struct dmx_section_feed* feed,
1da177e4
LT
110 u16 pid,
111 size_t circular_buffer_size,
1da177e4 112 int check_crc);
afd1a0c9 113 int (*allocate_filter) (struct dmx_section_feed* feed,
1da177e4 114 struct dmx_section_filter** filter);
afd1a0c9 115 int (*release_filter) (struct dmx_section_feed* feed,
1da177e4 116 struct dmx_section_filter* filter);
afd1a0c9
MCC
117 int (*start_filtering) (struct dmx_section_feed* feed);
118 int (*stop_filtering) (struct dmx_section_feed* feed);
1da177e4
LT
119};
120
121/*--------------------------------------------------------------------------*/
122/* Callback functions */
123/*--------------------------------------------------------------------------*/
124
125typedef int (*dmx_ts_cb) ( const u8 * buffer1,
126 size_t buffer1_length,
127 const u8 * buffer2,
128 size_t buffer2_length,
2f684b23 129 struct dmx_ts_feed* source);
1da177e4
LT
130
131typedef int (*dmx_section_cb) ( const u8 * buffer1,
132 size_t buffer1_len,
133 const u8 * buffer2,
134 size_t buffer2_len,
2f684b23 135 struct dmx_section_filter * source);
1da177e4
LT
136
137/*--------------------------------------------------------------------------*/
138/* DVB Front-End */
139/*--------------------------------------------------------------------------*/
140
141enum dmx_frontend_source {
142 DMX_MEMORY_FE,
143 DMX_FRONTEND_0,
1da177e4
LT
144};
145
146struct dmx_frontend {
afd1a0c9 147 struct list_head connectivity_list; /* List of front-ends that can
1da177e4
LT
148 be connected to a particular
149 demux */
afd1a0c9 150 enum dmx_frontend_source source;
1da177e4
LT
151};
152
153/*--------------------------------------------------------------------------*/
154/* MPEG-2 TS Demux */
155/*--------------------------------------------------------------------------*/
156
157/*
8a59822f 158 * Flags OR'ed in the capabilities field of struct dmx_demux.
1da177e4
LT
159 */
160
161#define DMX_TS_FILTERING 1
162#define DMX_PES_FILTERING 2
163#define DMX_SECTION_FILTERING 4
164#define DMX_MEMORY_BASED_FILTERING 8 /* write() available */
165#define DMX_CRC_CHECKING 16
166#define DMX_TS_DESCRAMBLING 32
1da177e4
LT
167
168/*
169 * Demux resource type identifier.
170*/
171
172/*
173 * DMX_FE_ENTRY(): Casts elements in the list of registered
174 * front-ends from the generic type struct list_head
175 * to the type * struct dmx_frontend
176 *.
177*/
178
179#define DMX_FE_ENTRY(list) list_entry(list, struct dmx_frontend, connectivity_list)
180
95abfdb9
MCC
181/**
182 * struct dmx_demux - Structure that contains the demux capabilities and
183 * callbacks.
184 *
185 * @capabilities: Bitfield of capability flags
186 *
187 * @frontend: Front-end connected to the demux
188 *
189 * @priv: Pointer to private data of the API client
190 *
191 * @open: This function reserves the demux for use by the caller and, if
192 * necessary, initializes the demux. When the demux is no longer needed,
28cff82c 193 * the function @close should be called. It should be possible for
95abfdb9
MCC
194 * multiple clients to access the demux at the same time. Thus, the
195 * function implementation should increment the demux usage count when
28cff82c 196 * @open is called and decrement it when @close is called.
95abfdb9
MCC
197 * The @demux function parameter contains a pointer to the demux API and
198 * instance data.
199 * It returns
200 * 0 on success;
201 * -EUSERS, if maximum usage count was reached;
202 * -EINVAL, on bad parameter.
203 *
204 * @close: This function reserves the demux for use by the caller and, if
205 * necessary, initializes the demux. When the demux is no longer needed,
28cff82c 206 * the function @close should be called. It should be possible for
95abfdb9
MCC
207 * multiple clients to access the demux at the same time. Thus, the
208 * function implementation should increment the demux usage count when
28cff82c 209 * @open is called and decrement it when @close is called.
95abfdb9
MCC
210 * The @demux function parameter contains a pointer to the demux API and
211 * instance data.
212 * It returns
213 * 0 on success;
28cff82c 214 * -ENODEV, if demux was not in use (e. g. no users);
95abfdb9
MCC
215 * -EINVAL, on bad parameter.
216 *
217 * @write: This function provides the demux driver with a memory buffer
218 * containing TS packets. Instead of receiving TS packets from the DVB
219 * front-end, the demux driver software will read packets from memory.
220 * Any clients of this demux with active TS, PES or Section filters will
221 * receive filtered data via the Demux callback API (see 0). The function
222 * returns when all the data in the buffer has been consumed by the demux.
223 * Demux hardware typically cannot read TS from memory. If this is the
224 * case, memory-based filtering has to be implemented entirely in software.
225 * The @demux function parameter contains a pointer to the demux API and
226 * instance data.
227 * The @buf function parameter contains a pointer to the TS data in
228 * kernel-space memory.
229 * The @count function parameter contains the length of the TS data.
230 * It returns
231 * 0 on success;
28cff82c
MCC
232 * -ERESTARTSYS, if mutex lock was interrupted;
233 * -EINTR, if a signal handling is pending;
234 * -ENODEV, if demux was removed;
95abfdb9
MCC
235 * -EINVAL, on bad parameter.
236 *
237 * @allocate_ts_feed: Allocates a new TS feed, which is used to filter the TS
238 * packets carrying a certain PID. The TS feed normally corresponds to a
239 * hardware PID filter on the demux chip.
240 * The @demux function parameter contains a pointer to the demux API and
241 * instance data.
242 * The @feed function parameter contains a pointer to the TS feed API and
243 * instance data.
244 * The @callback function parameter contains a pointer to the callback
245 * function for passing received TS packet.
246 * It returns
247 * 0 on success;
28cff82c 248 * -ERESTARTSYS, if mutex lock was interrupted;
95abfdb9 249 * -EBUSY, if no more TS feeds is available;
95abfdb9
MCC
250 * -EINVAL, on bad parameter.
251 *
28cff82c 252 * @release_ts_feed: Releases the resources allocated with @allocate_ts_feed.
95abfdb9
MCC
253 * Any filtering in progress on the TS feed should be stopped before
254 * calling this function.
255 * The @demux function parameter contains a pointer to the demux API and
256 * instance data.
257 * The @feed function parameter contains a pointer to the TS feed API and
258 * instance data.
259 * It returns
260 * 0 on success;
261 * -EINVAL on bad parameter.
262 *
263 * @allocate_section_feed: Allocates a new section feed, i.e. a demux resource
264 * for filtering and receiving sections. On platforms with hardware
265 * support for section filtering, a section feed is directly mapped to
266 * the demux HW. On other platforms, TS packets are first PID filtered in
267 * hardware and a hardware section filter then emulated in software. The
268 * caller obtains an API pointer of type dmx_section_feed_t as an out
269 * parameter. Using this API the caller can set filtering parameters and
270 * start receiving sections.
271 * The @demux function parameter contains a pointer to the demux API and
272 * instance data.
273 * The @feed function parameter contains a pointer to the TS feed API and
274 * instance data.
275 * The @callback function parameter contains a pointer to the callback
276 * function for passing received TS packet.
277 * It returns
278 * 0 on success;
279 * -EBUSY, if no more TS feeds is available;
95abfdb9
MCC
280 * -EINVAL, on bad parameter.
281 *
282 * @release_section_feed: Releases the resources allocated with
28cff82c 283 * @allocate_section_feed, including allocated filters. Any filtering in
95abfdb9
MCC
284 * progress on the section feed should be stopped before calling this
285 * function.
286 * The @demux function parameter contains a pointer to the demux API and
287 * instance data.
288 * The @feed function parameter contains a pointer to the TS feed API and
289 * instance data.
290 * It returns
291 * 0 on success;
292 * -EINVAL, on bad parameter.
293 *
294 * @add_frontend: Registers a connectivity between a demux and a front-end,
295 * i.e., indicates that the demux can be connected via a call to
28cff82c 296 * @connect_frontend to use the given front-end as a TS source. The
95abfdb9
MCC
297 * client of this function has to allocate dynamic or static memory for
298 * the frontend structure and initialize its fields before calling this
299 * function. This function is normally called during the driver
300 * initialization. The caller must not free the memory of the frontend
28cff82c 301 * struct before successfully calling @remove_frontend.
95abfdb9
MCC
302 * The @demux function parameter contains a pointer to the demux API and
303 * instance data.
304 * The @frontend function parameter contains a pointer to the front-end
305 * instance data.
306 * It returns
307 * 0 on success;
95abfdb9
MCC
308 * -EINVAL, on bad parameter.
309 *
310 * @remove_frontend: Indicates that the given front-end, registered by a call
28cff82c 311 * to @add_frontend, can no longer be connected as a TS source by this
95abfdb9
MCC
312 * demux. The function should be called when a front-end driver or a demux
313 * driver is removed from the system. If the front-end is in use, the
314 * function fails with the return value of -EBUSY. After successfully
315 * calling this function, the caller can free the memory of the frontend
28cff82c 316 * struct if it was dynamically allocated before the @add_frontend
95abfdb9
MCC
317 * operation.
318 * The @demux function parameter contains a pointer to the demux API and
319 * instance data.
320 * The @frontend function parameter contains a pointer to the front-end
321 * instance data.
322 * It returns
323 * 0 on success;
28cff82c 324 * -ENODEV, if the front-end was not found,
95abfdb9
MCC
325 * -EINVAL, on bad parameter.
326 *
327 * @get_frontends: Provides the APIs of the front-ends that have been
328 * registered for this demux. Any of the front-ends obtained with this
28cff82c 329 * call can be used as a parameter for @connect_frontend. The include
95abfdb9 330 * file demux.h contains the macro DMX_FE_ENTRY() for converting an
28cff82c
MCC
331 * element of the generic type struct &list_head * to the type
332 * struct &dmx_frontend *. The caller must not free the memory of any of
333 * the elements obtained via this function call.
95abfdb9
MCC
334 * The @demux function parameter contains a pointer to the demux API and
335 * instance data.
336 * It returns a struct list_head pointer to the list of front-end
337 * interfaces, or NULL in the case of an empty list.
338 *
339 * @connect_frontend: Connects the TS output of the front-end to the input of
340 * the demux. A demux can only be connected to a front-end registered to
28cff82c 341 * the demux with the function @add_frontend. It may or may not be
95abfdb9
MCC
342 * possible to connect multiple demuxes to the same front-end, depending
343 * on the capabilities of the HW platform. When not used, the front-end
28cff82c 344 * should be released by calling @disconnect_frontend.
95abfdb9
MCC
345 * The @demux function parameter contains a pointer to the demux API and
346 * instance data.
347 * The @frontend function parameter contains a pointer to the front-end
348 * instance data.
349 * It returns
350 * 0 on success;
95abfdb9
MCC
351 * -EINVAL, on bad parameter.
352 *
353 * @disconnect_frontend: Disconnects the demux and a front-end previously
28cff82c 354 * connected by a @connect_frontend call.
95abfdb9
MCC
355 * The @demux function parameter contains a pointer to the demux API and
356 * instance data.
357 * It returns
358 * 0 on success;
359 * -EINVAL on bad parameter.
4bc645df
MCC
360 *
361 * @get_pes_pids: Get the PIDs for DMX_PES_AUDIO0, DMX_PES_VIDEO0,
362 * DMX_PES_TELETEXT0, DMX_PES_SUBTITLE0 and DMX_PES_PCR0.
363 * The @demux function parameter contains a pointer to the demux API and
364 * instance data.
365 * The @pids function parameter contains an array with five u16 elements
366 * where the PIDs will be stored.
367 * It returns
368 * 0 on success;
369 * -EINVAL on bad parameter.
95abfdb9
MCC
370 */
371
1da177e4 372struct dmx_demux {
95abfdb9
MCC
373 u32 capabilities;
374 struct dmx_frontend* frontend;
375 void* priv;
afd1a0c9
MCC
376 int (*open) (struct dmx_demux* demux);
377 int (*close) (struct dmx_demux* demux);
947a0800 378 int (*write) (struct dmx_demux* demux, const char __user *buf, size_t count);
afd1a0c9 379 int (*allocate_ts_feed) (struct dmx_demux* demux,
1da177e4
LT
380 struct dmx_ts_feed** feed,
381 dmx_ts_cb callback);
afd1a0c9 382 int (*release_ts_feed) (struct dmx_demux* demux,
1da177e4 383 struct dmx_ts_feed* feed);
afd1a0c9 384 int (*allocate_section_feed) (struct dmx_demux* demux,
1da177e4
LT
385 struct dmx_section_feed** feed,
386 dmx_section_cb callback);
afd1a0c9 387 int (*release_section_feed) (struct dmx_demux* demux,
1da177e4 388 struct dmx_section_feed* feed);
afd1a0c9 389 int (*add_frontend) (struct dmx_demux* demux,
1da177e4 390 struct dmx_frontend* frontend);
afd1a0c9 391 int (*remove_frontend) (struct dmx_demux* demux,
1da177e4 392 struct dmx_frontend* frontend);
afd1a0c9
MCC
393 struct list_head* (*get_frontends) (struct dmx_demux* demux);
394 int (*connect_frontend) (struct dmx_demux* demux,
1da177e4 395 struct dmx_frontend* frontend);
afd1a0c9 396 int (*disconnect_frontend) (struct dmx_demux* demux);
1da177e4 397
afd1a0c9 398 int (*get_pes_pids) (struct dmx_demux* demux, u16 *pids);
1da177e4 399
1e92bbe0
MCC
400 /* private: Not used upstream and never documented */
401#if 0
c0510052 402 int (*get_caps) (struct dmx_demux* demux, struct dmx_caps *caps);
c0510052 403 int (*set_source) (struct dmx_demux* demux, const dmx_source_t *src);
1e92bbe0 404#endif
4bc645df
MCC
405 /*
406 * private: Only used at av7110, to read some data from firmware.
407 * As this was never documented, we have no clue about what's
408 * there, and its usage on other drivers aren't encouraged.
409 */
afd1a0c9 410 int (*get_stc) (struct dmx_demux* demux, unsigned int num,
1da177e4
LT
411 u64 *stc, unsigned int *base);
412};
413
1da177e4 414#endif /* #ifndef __DEMUX_H */
This page took 0.926027 seconds and 5 git commands to generate.