V4L/DVB (7327): cx88: Fix memset for tuner-xc3028 control
[linux-2.6-block.git] / drivers / media / dvb / 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
58
59/*
60 * enum dmx_success: Success codes for the Demux Callback API.
61 */
62
63enum dmx_success {
64 DMX_OK = 0, /* Received Ok */
65 DMX_LENGTH_ERROR, /* Incorrect length */
66 DMX_OVERRUN_ERROR, /* Receiver ring buffer overrun */
67 DMX_CRC_ERROR, /* Incorrect CRC */
68 DMX_FRAME_ERROR, /* Frame alignment error */
69 DMX_FIFO_ERROR, /* Receiver FIFO overrun */
70 DMX_MISSED_ERROR /* Receiver missed packet */
71} ;
72
73/*--------------------------------------------------------------------------*/
74/* TS packet reception */
75/*--------------------------------------------------------------------------*/
76
77/* TS filter type for set() */
78
79#define TS_PACKET 1 /* send TS packets (188 bytes) to callback (default) */
80#define TS_PAYLOAD_ONLY 2 /* in case TS_PACKET is set, only send the TS
81 payload (<=184 bytes per packet) to callback */
82#define TS_DECODER 4 /* send stream to built-in decoder (if present) */
83
84/* PES type for filters which write to built-in decoder */
85/* these should be kept identical to the types in dmx.h */
86
87enum dmx_ts_pes
88{ /* also send packets to decoder (if it exists) */
afd1a0c9 89 DMX_TS_PES_AUDIO0,
1da177e4
LT
90 DMX_TS_PES_VIDEO0,
91 DMX_TS_PES_TELETEXT0,
92 DMX_TS_PES_SUBTITLE0,
93 DMX_TS_PES_PCR0,
94
afd1a0c9 95 DMX_TS_PES_AUDIO1,
1da177e4
LT
96 DMX_TS_PES_VIDEO1,
97 DMX_TS_PES_TELETEXT1,
98 DMX_TS_PES_SUBTITLE1,
99 DMX_TS_PES_PCR1,
100
afd1a0c9 101 DMX_TS_PES_AUDIO2,
1da177e4
LT
102 DMX_TS_PES_VIDEO2,
103 DMX_TS_PES_TELETEXT2,
104 DMX_TS_PES_SUBTITLE2,
105 DMX_TS_PES_PCR2,
106
afd1a0c9 107 DMX_TS_PES_AUDIO3,
1da177e4
LT
108 DMX_TS_PES_VIDEO3,
109 DMX_TS_PES_TELETEXT3,
110 DMX_TS_PES_SUBTITLE3,
111 DMX_TS_PES_PCR3,
112
113 DMX_TS_PES_OTHER
114};
115
116#define DMX_TS_PES_AUDIO DMX_TS_PES_AUDIO0
117#define DMX_TS_PES_VIDEO DMX_TS_PES_VIDEO0
118#define DMX_TS_PES_TELETEXT DMX_TS_PES_TELETEXT0
119#define DMX_TS_PES_SUBTITLE DMX_TS_PES_SUBTITLE0
120#define DMX_TS_PES_PCR DMX_TS_PES_PCR0
121
122
123struct dmx_ts_feed {
afd1a0c9
MCC
124 int is_filtering; /* Set to non-zero when filtering in progress */
125 struct dmx_demux *parent; /* Back-pointer */
126 void *priv; /* Pointer to private data of the API client */
127 int (*set) (struct dmx_ts_feed *feed,
1da177e4
LT
128 u16 pid,
129 int type,
130 enum dmx_ts_pes pes_type,
1da177e4 131 size_t circular_buffer_size,
1da177e4 132 struct timespec timeout);
afd1a0c9
MCC
133 int (*start_filtering) (struct dmx_ts_feed* feed);
134 int (*stop_filtering) (struct dmx_ts_feed* feed);
1da177e4
LT
135};
136
137/*--------------------------------------------------------------------------*/
138/* Section reception */
139/*--------------------------------------------------------------------------*/
140
141struct dmx_section_filter {
afd1a0c9
MCC
142 u8 filter_value [DMX_MAX_FILTER_SIZE];
143 u8 filter_mask [DMX_MAX_FILTER_SIZE];
144 u8 filter_mode [DMX_MAX_FILTER_SIZE];
145 struct dmx_section_feed* parent; /* Back-pointer */
146 void* priv; /* Pointer to private data of the API client */
1da177e4
LT
147};
148
149struct dmx_section_feed {
afd1a0c9
MCC
150 int is_filtering; /* Set to non-zero when filtering in progress */
151 struct dmx_demux* parent; /* Back-pointer */
152 void* priv; /* Pointer to private data of the API client */
1da177e4 153
afd1a0c9 154 int check_crc;
1da177e4
LT
155 u32 crc_val;
156
afd1a0c9
MCC
157 u8 *secbuf;
158 u8 secbuf_base[DMX_MAX_SECFEED_SIZE];
159 u16 secbufp, seclen, tsfeedp;
1da177e4 160
afd1a0c9 161 int (*set) (struct dmx_section_feed* feed,
1da177e4
LT
162 u16 pid,
163 size_t circular_buffer_size,
1da177e4 164 int check_crc);
afd1a0c9 165 int (*allocate_filter) (struct dmx_section_feed* feed,
1da177e4 166 struct dmx_section_filter** filter);
afd1a0c9 167 int (*release_filter) (struct dmx_section_feed* feed,
1da177e4 168 struct dmx_section_filter* filter);
afd1a0c9
MCC
169 int (*start_filtering) (struct dmx_section_feed* feed);
170 int (*stop_filtering) (struct dmx_section_feed* feed);
1da177e4
LT
171};
172
173/*--------------------------------------------------------------------------*/
174/* Callback functions */
175/*--------------------------------------------------------------------------*/
176
177typedef int (*dmx_ts_cb) ( const u8 * buffer1,
178 size_t buffer1_length,
179 const u8 * buffer2,
180 size_t buffer2_length,
181 struct dmx_ts_feed* source,
182 enum dmx_success success);
183
184typedef int (*dmx_section_cb) ( const u8 * buffer1,
185 size_t buffer1_len,
186 const u8 * buffer2,
187 size_t buffer2_len,
188 struct dmx_section_filter * source,
189 enum dmx_success success);
190
191/*--------------------------------------------------------------------------*/
192/* DVB Front-End */
193/*--------------------------------------------------------------------------*/
194
195enum dmx_frontend_source {
196 DMX_MEMORY_FE,
197 DMX_FRONTEND_0,
198 DMX_FRONTEND_1,
199 DMX_FRONTEND_2,
200 DMX_FRONTEND_3,
201 DMX_STREAM_0, /* external stream input, e.g. LVDS */
202 DMX_STREAM_1,
203 DMX_STREAM_2,
204 DMX_STREAM_3
205};
206
207struct dmx_frontend {
afd1a0c9 208 struct list_head connectivity_list; /* List of front-ends that can
1da177e4
LT
209 be connected to a particular
210 demux */
afd1a0c9 211 enum dmx_frontend_source source;
1da177e4
LT
212};
213
214/*--------------------------------------------------------------------------*/
215/* MPEG-2 TS Demux */
216/*--------------------------------------------------------------------------*/
217
218/*
8a59822f 219 * Flags OR'ed in the capabilities field of struct dmx_demux.
1da177e4
LT
220 */
221
222#define DMX_TS_FILTERING 1
223#define DMX_PES_FILTERING 2
224#define DMX_SECTION_FILTERING 4
225#define DMX_MEMORY_BASED_FILTERING 8 /* write() available */
226#define DMX_CRC_CHECKING 16
227#define DMX_TS_DESCRAMBLING 32
1da177e4
LT
228
229/*
230 * Demux resource type identifier.
231*/
232
233/*
234 * DMX_FE_ENTRY(): Casts elements in the list of registered
235 * front-ends from the generic type struct list_head
236 * to the type * struct dmx_frontend
237 *.
238*/
239
240#define DMX_FE_ENTRY(list) list_entry(list, struct dmx_frontend, connectivity_list)
241
242struct dmx_demux {
afd1a0c9
MCC
243 u32 capabilities; /* Bitfield of capability flags */
244 struct dmx_frontend* frontend; /* Front-end connected to the demux */
245 void* priv; /* Pointer to private data of the API client */
246 int (*open) (struct dmx_demux* demux);
247 int (*close) (struct dmx_demux* demux);
248 int (*write) (struct dmx_demux* demux, const char* buf, size_t count);
249 int (*allocate_ts_feed) (struct dmx_demux* demux,
1da177e4
LT
250 struct dmx_ts_feed** feed,
251 dmx_ts_cb callback);
afd1a0c9 252 int (*release_ts_feed) (struct dmx_demux* demux,
1da177e4 253 struct dmx_ts_feed* feed);
afd1a0c9 254 int (*allocate_section_feed) (struct dmx_demux* demux,
1da177e4
LT
255 struct dmx_section_feed** feed,
256 dmx_section_cb callback);
afd1a0c9 257 int (*release_section_feed) (struct dmx_demux* demux,
1da177e4 258 struct dmx_section_feed* feed);
afd1a0c9 259 int (*add_frontend) (struct dmx_demux* demux,
1da177e4 260 struct dmx_frontend* frontend);
afd1a0c9 261 int (*remove_frontend) (struct dmx_demux* demux,
1da177e4 262 struct dmx_frontend* frontend);
afd1a0c9
MCC
263 struct list_head* (*get_frontends) (struct dmx_demux* demux);
264 int (*connect_frontend) (struct dmx_demux* demux,
1da177e4 265 struct dmx_frontend* frontend);
afd1a0c9 266 int (*disconnect_frontend) (struct dmx_demux* demux);
1da177e4 267
afd1a0c9 268 int (*get_pes_pids) (struct dmx_demux* demux, u16 *pids);
1da177e4 269
c0510052
AO
270 int (*get_caps) (struct dmx_demux* demux, struct dmx_caps *caps);
271
272 int (*set_source) (struct dmx_demux* demux, const dmx_source_t *src);
273
afd1a0c9 274 int (*get_stc) (struct dmx_demux* demux, unsigned int num,
1da177e4
LT
275 u64 *stc, unsigned int *base);
276};
277
1da177e4 278#endif /* #ifndef __DEMUX_H */