blob: 5abadb610e07e1cb596d93ddfe5f0c90f3f471cf [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;
175 int num_decoders;
176} dmx_caps_t;
177
178typedef enum {
179 DMX_SOURCE_FRONT0 = 0,
180 DMX_SOURCE_FRONT1,
181 DMX_SOURCE_FRONT2,
182 DMX_SOURCE_FRONT3,
183 DMX_SOURCE_DVR0 = 16,
184 DMX_SOURCE_DVR1,
185 DMX_SOURCE_DVR2,
186 DMX_SOURCE_DVR3
187} dmx_source_t;
188
Hamad Kadmany32cb9822012-05-10 08:47:44 +0300189enum dmx_tsp_format_t {
190 DMX_TSP_FORMAT_188 = 0,
191 DMX_TSP_FORMAT_192_TAIL,
192 DMX_TSP_FORMAT_192_HEAD,
193 DMX_TSP_FORMAT_204,
194};
195
196enum dmx_playback_mode_t {
197 /*
198 * In push mode, if one of output buffers
199 * is full, the buffer would overflow
200 * and demux continue processing incoming stream.
201 * This is the default mode. When playing from frontend,
202 * this is the only mode that is allowed.
203 */
204 DMX_PB_MODE_PUSH = 0,
205
206 /*
207 * In pull mode, if one of output buffers
208 * is full, demux stalls waiting for free space,
209 * this would cause DVR input buffer fullness
210 * to accumulate.
211 * This mode is possible only when playing
212 * from DVR.
213 */
214 DMX_PB_MODE_PULL,
215};
216
Linus Torvalds1da177e2005-04-16 15:20:36 -0700217struct dmx_stc {
218 unsigned int num; /* input : which STC? 0..N */
219 unsigned int base; /* output: divisor for stc to get 90 kHz clock */
220 __u64 stc; /* output: stc in 'base'*90 kHz units */
221};
222
223
224#define DMX_START _IO('o', 41)
225#define DMX_STOP _IO('o', 42)
226#define DMX_SET_FILTER _IOW('o', 43, struct dmx_sct_filter_params)
227#define DMX_SET_PES_FILTER _IOW('o', 44, struct dmx_pes_filter_params)
228#define DMX_SET_BUFFER_SIZE _IO('o', 45)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700229#define DMX_GET_PES_PIDS _IOR('o', 47, __u16[5])
230#define DMX_GET_CAPS _IOR('o', 48, dmx_caps_t)
231#define DMX_SET_SOURCE _IOW('o', 49, dmx_source_t)
232#define DMX_GET_STC _IOWR('o', 50, struct dmx_stc)
Andreas Oberritter1cb662a2009-07-14 20:28:50 -0300233#define DMX_ADD_PID _IOW('o', 51, __u16)
234#define DMX_REMOVE_PID _IOW('o', 52, __u16)
Hamad Kadmany32cb9822012-05-10 08:47:44 +0300235#define DMX_SET_TS_PACKET_FORMAT _IOW('o', 53, enum dmx_tsp_format_t)
236#define DMX_SET_TS_OUT_FORMAT _IOW('o', 54, enum dmx_tsp_format_t)
237#define DMX_SET_DECODER_BUFFER_SIZE _IO('o', 55)
238#define DMX_GET_BUFFER_STATUS _IOR('o', 56, struct dmx_buffer_status)
239#define DMX_RELEASE_DATA _IO('o', 57)
240#define DMX_FEED_DATA _IO('o', 58)
241#define DMX_SET_PLAYBACK_MODE _IOW('o', 59, enum dmx_playback_mode_t)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700242
243#endif /*_DVBDMX_H_*/