blob: e0058d3c32e6eaddbec9fc9bce16e9c049ca9003 [file] [log] [blame]
Mauro Carvalho Chehabafd1a0c2005-12-12 00:37:27 -08001/*
Linus Torvalds1da177e2005-04-16 15:20:36 -07002 * dmx.h
3 *
4 * Copyright (C) 2000 Marcus Metzler <marcus@convergence.de>
5 * & Ralph Metzler <ralph@convergence.de>
6 * for convergence integrated media GmbH
7 *
Hamad Kadmany32cb9822012-05-10 08:47:44 +03008 * Copyright (c) 2012, Code Aurora Forum. All rights reserved.
9 *
Linus Torvalds1da177e2005-04-16 15:20:36 -070010 * 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 _DVBDMX_H_
27#define _DVBDMX_H_
28
Jaswinder Singh Rajputc86629c2009-01-30 19:55:32 +053029#include <linux/types.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070030#ifdef __KERNEL__
31#include <linux/time.h>
32#else
33#include <time.h>
34#endif
35
36
37#define DMX_FILTER_SIZE 16
38
39typedef enum
40{
41 DMX_OUT_DECODER, /* Streaming directly to decoder. */
42 DMX_OUT_TAP, /* Output going to a memory buffer */
Mauro Carvalho Chehab674434c2005-12-12 00:37:28 -080043 /* (to be retrieved via the read command).*/
Peter Hartleyb01cd932008-04-22 14:45:36 -030044 DMX_OUT_TS_TAP, /* Output multiplexed into a new TS */
Mauro Carvalho Chehab674434c2005-12-12 00:37:28 -080045 /* (to be retrieved by reading from the */
46 /* logical DVR device). */
Peter Hartleyb01cd932008-04-22 14:45:36 -030047 DMX_OUT_TSDEMUX_TAP /* Like TS_TAP but retrieved from the DMX device */
Linus Torvalds1da177e2005-04-16 15:20:36 -070048} dmx_output_t;
49
50
51typedef enum
52{
53 DMX_IN_FRONTEND, /* Input from a front-end device. */
54 DMX_IN_DVR /* Input from the logical DVR device. */
55} dmx_input_t;
56
57
58typedef enum
59{
Mauro Carvalho Chehabafd1a0c2005-12-12 00:37:27 -080060 DMX_PES_AUDIO0,
Linus Torvalds1da177e2005-04-16 15:20:36 -070061 DMX_PES_VIDEO0,
62 DMX_PES_TELETEXT0,
63 DMX_PES_SUBTITLE0,
64 DMX_PES_PCR0,
65
Mauro Carvalho Chehabafd1a0c2005-12-12 00:37:27 -080066 DMX_PES_AUDIO1,
Linus Torvalds1da177e2005-04-16 15:20:36 -070067 DMX_PES_VIDEO1,
68 DMX_PES_TELETEXT1,
69 DMX_PES_SUBTITLE1,
70 DMX_PES_PCR1,
71
Mauro Carvalho Chehabafd1a0c2005-12-12 00:37:27 -080072 DMX_PES_AUDIO2,
Linus Torvalds1da177e2005-04-16 15:20:36 -070073 DMX_PES_VIDEO2,
74 DMX_PES_TELETEXT2,
75 DMX_PES_SUBTITLE2,
76 DMX_PES_PCR2,
77
Mauro Carvalho Chehabafd1a0c2005-12-12 00:37:27 -080078 DMX_PES_AUDIO3,
Linus Torvalds1da177e2005-04-16 15:20:36 -070079 DMX_PES_VIDEO3,
80 DMX_PES_TELETEXT3,
81 DMX_PES_SUBTITLE3,
82 DMX_PES_PCR3,
83
84 DMX_PES_OTHER
85} dmx_pes_type_t;
86
87#define DMX_PES_AUDIO DMX_PES_AUDIO0
88#define DMX_PES_VIDEO DMX_PES_VIDEO0
89#define DMX_PES_TELETEXT DMX_PES_TELETEXT0
90#define DMX_PES_SUBTITLE DMX_PES_SUBTITLE0
91#define DMX_PES_PCR DMX_PES_PCR0
92
93
Linus Torvalds1da177e2005-04-16 15:20:36 -070094typedef struct dmx_filter
95{
96 __u8 filter[DMX_FILTER_SIZE];
97 __u8 mask[DMX_FILTER_SIZE];
98 __u8 mode[DMX_FILTER_SIZE];
99} dmx_filter_t;
100
101
Liron Kuchd4cc3b02012-05-17 16:31:58 +0300102/* Filter flags */
103#define DMX_CHECK_CRC 0x01
104#define DMX_ONESHOT 0x02
105#define DMX_IMMEDIATE_START 0x04
106#define DMX_ENABLE_INDEXING 0x08
107#define DMX_KERNEL_CLIENT 0x8000
108
Linus Torvalds1da177e2005-04-16 15:20:36 -0700109struct dmx_sct_filter_params
110{
111 __u16 pid;
112 dmx_filter_t filter;
113 __u32 timeout;
114 __u32 flags;
Liron Kuchd4cc3b02012-05-17 16:31:58 +0300115};
116
117
118/* Indexing: supported video standards */
119enum dmx_indexing_video_standard {
120 DMX_INDEXING_MPEG2,
121 DMX_INDEXING_H264,
122 DMX_INDEXING_VC1
123};
124
125/* Indexing: Supported video profiles */
126enum dmx_indexing_video_profile {
127 DMX_INDEXING_MPEG2_ANY,
128 DMX_INDEXING_H264_ANY,
129 DMX_INDEXING_VC1_ANY
130};
131
132/* Indexing: video configuration parameters */
133struct dmx_indexing_video_params {
134 enum dmx_indexing_video_standard standard;
135 enum dmx_indexing_video_profile profile;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700136};
137
138
139struct dmx_pes_filter_params
140{
141 __u16 pid;
142 dmx_input_t input;
143 dmx_output_t output;
144 dmx_pes_type_t pes_type;
145 __u32 flags;
Liron Kuchd4cc3b02012-05-17 16:31:58 +0300146
147 struct dmx_indexing_video_params video_params;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700148};
149
Hamad Kadmany32cb9822012-05-10 08:47:44 +0300150struct dmx_buffer_status {
151 /* size of buffer in bytes */
152 unsigned int size;
153
154 /* fullness of buffer in bytes */
155 unsigned int fullness;
156
157 /*
158 * How many bytes are free
159 * It's the same as: size-fullness-1
160 */
161 unsigned int free_bytes;
162
163 /* read pointer offset in bytes */
164 unsigned int read_offset;
165
166 /* write pointer offset in bytes */
167 unsigned int write_offset;
168
169 /* non-zero if data error occured */
170 int error;
171};
172
Linus Torvalds1da177e2005-04-16 15:20:36 -0700173typedef struct dmx_caps {
174 __u32 caps;
Hamad Kadmanyd2c325e2012-05-28 13:52:49 +0300175
176/* Indicates whether demux support playback from memory in pull mode */
177#define DMX_CAP_PULL_MODE 0x01
178
179/* Indicates whether demux support indexing of recorded video stream */
180#define DMX_CAP_VIDEO_INDEXING 0x02
181
182/* Indicates whether demux support sending data directly to video decoder */
183#define DMX_CAP_VIDEO_DECODER_DATA 0x04
184
185/* Indicates whether demux support sending data directly to audio decoder */
186#define DMX_CAP_AUDIO_DECODER_DATA 0x08
187
188/* Indicates whether demux support sending data directly to subtitle decoder */
189#define DMX_CAP_SUBTITLE_DECODER_DATA 0x10
190
191 /* Number of decoders demux can output data to */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700192 int num_decoders;
Hamad Kadmanyd2c325e2012-05-28 13:52:49 +0300193
194 /* Number of demux devices */
195 int num_demux_devices;
196
197 /* Max number of PID filters */
198 int num_pid_filters;
199
200 /* Max number of section filters */
201 int num_section_filters;
202
203 /*
204 * Max number of section filters using same PID,
205 * 0 if not supported
206 */
207 int num_section_filters_per_pid;
208
209 /*
210 * Length of section filter, not including section
211 * length field (2 bytes).
212 */
213 int section_filter_length;
214
215 /* Max number of demod based input */
216 int num_demod_inputs;
217
218 /* Max number of memory based input */
219 int num_memory_inputs;
220
221 /* Overall bitrate from all inputs concurrently. Mbit/sec */
222 int max_bitrate;
223
224 /* Max bitrate from single demod input. Mbit/sec */
225 int demod_input_max_bitrate;
226
227 /* Max bitrate from single memory input. Mbit/sec */
228 int memory_input_max_bitrate;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700229} dmx_caps_t;
230
231typedef enum {
232 DMX_SOURCE_FRONT0 = 0,
233 DMX_SOURCE_FRONT1,
234 DMX_SOURCE_FRONT2,
235 DMX_SOURCE_FRONT3,
236 DMX_SOURCE_DVR0 = 16,
237 DMX_SOURCE_DVR1,
238 DMX_SOURCE_DVR2,
239 DMX_SOURCE_DVR3
240} dmx_source_t;
241
Hamad Kadmany32cb9822012-05-10 08:47:44 +0300242enum dmx_tsp_format_t {
243 DMX_TSP_FORMAT_188 = 0,
244 DMX_TSP_FORMAT_192_TAIL,
245 DMX_TSP_FORMAT_192_HEAD,
246 DMX_TSP_FORMAT_204,
247};
248
249enum dmx_playback_mode_t {
250 /*
251 * In push mode, if one of output buffers
252 * is full, the buffer would overflow
253 * and demux continue processing incoming stream.
254 * This is the default mode. When playing from frontend,
255 * this is the only mode that is allowed.
256 */
257 DMX_PB_MODE_PUSH = 0,
258
259 /*
260 * In pull mode, if one of output buffers
261 * is full, demux stalls waiting for free space,
262 * this would cause DVR input buffer fullness
263 * to accumulate.
264 * This mode is possible only when playing
265 * from DVR.
266 */
267 DMX_PB_MODE_PULL,
268};
269
Linus Torvalds1da177e2005-04-16 15:20:36 -0700270struct dmx_stc {
271 unsigned int num; /* input : which STC? 0..N */
272 unsigned int base; /* output: divisor for stc to get 90 kHz clock */
273 __u64 stc; /* output: stc in 'base'*90 kHz units */
274};
275
276
277#define DMX_START _IO('o', 41)
278#define DMX_STOP _IO('o', 42)
279#define DMX_SET_FILTER _IOW('o', 43, struct dmx_sct_filter_params)
280#define DMX_SET_PES_FILTER _IOW('o', 44, struct dmx_pes_filter_params)
281#define DMX_SET_BUFFER_SIZE _IO('o', 45)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700282#define DMX_GET_PES_PIDS _IOR('o', 47, __u16[5])
283#define DMX_GET_CAPS _IOR('o', 48, dmx_caps_t)
284#define DMX_SET_SOURCE _IOW('o', 49, dmx_source_t)
285#define DMX_GET_STC _IOWR('o', 50, struct dmx_stc)
Andreas Oberritter1cb662a2009-07-14 20:28:50 -0300286#define DMX_ADD_PID _IOW('o', 51, __u16)
287#define DMX_REMOVE_PID _IOW('o', 52, __u16)
Hamad Kadmany32cb9822012-05-10 08:47:44 +0300288#define DMX_SET_TS_PACKET_FORMAT _IOW('o', 53, enum dmx_tsp_format_t)
289#define DMX_SET_TS_OUT_FORMAT _IOW('o', 54, enum dmx_tsp_format_t)
290#define DMX_SET_DECODER_BUFFER_SIZE _IO('o', 55)
291#define DMX_GET_BUFFER_STATUS _IOR('o', 56, struct dmx_buffer_status)
292#define DMX_RELEASE_DATA _IO('o', 57)
293#define DMX_FEED_DATA _IO('o', 58)
294#define DMX_SET_PLAYBACK_MODE _IOW('o', 59, enum dmx_playback_mode_t)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700295
296#endif /*_DVBDMX_H_*/