blob: 4e3f3a2fe83f1e21b20ebf875ca37ae96a52c170 [file] [log] [blame]
David Howellsc57fd022012-10-09 09:48:42 +01001/*
2 * 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 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public License
10 * as published by the Free Software Foundation; either version 2.1
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 *
22 */
23
24#ifndef _UAPI_DVBDMX_H_
25#define _UAPI_DVBDMX_H_
26
27#include <linux/types.h>
28#ifndef __KERNEL__
29#include <time.h>
30#endif
31
32
33#define DMX_FILTER_SIZE 16
34
Mauro Carvalho Chehabbb98e6d2017-08-31 12:28:52 -040035/**
36 * enum dmx_output - Output for the demux.
37 *
38 * @DMX_OUT_DECODER:
39 * Streaming directly to decoder.
40 * @DMX_OUT_TAP:
41 * Output going to a memory buffer (to be retrieved via the read command).
42 * Delivers the stream output to the demux device on which the ioctl
43 * is called.
44 * @DMX_OUT_TS_TAP:
45 * Output multiplexed into a new TS (to be retrieved by reading from the
46 * logical DVR device). Routes output to the logical DVR device
47 * ``/dev/dvb/adapter?/dvr?``, which delivers a TS multiplexed from all
48 * filters for which @DMX_OUT_TS_TAP was specified.
49 * @DMX_OUT_TSDEMUX_TAP:
50 * Like @DMX_OUT_TS_TAP but retrieved from the DMX device.
51 */
52enum dmx_output {
53 DMX_OUT_DECODER,
54 DMX_OUT_TAP,
55 DMX_OUT_TS_TAP,
56 DMX_OUT_TSDEMUX_TAP
Mauro Carvalho Chehab3256b362017-09-01 06:09:14 -040057};
David Howellsc57fd022012-10-09 09:48:42 +010058
59
Mauro Carvalho Chehabbb98e6d2017-08-31 12:28:52 -040060/**
61 * enum dmx_input - Input from the demux.
62 *
63 * @DMX_IN_FRONTEND: Input from a front-end device.
64 * @DMX_IN_DVR: Input from the logical DVR device.
65 */
66enum dmx_input {
67 DMX_IN_FRONTEND,
68 DMX_IN_DVR
69};
70
71/**
72 * enum dmx_ts_pes - type of the PES filter.
73 *
74 * @DMX_PES_AUDIO0: first audio PID. Also referred as @DMX_PES_AUDIO.
75 * @DMX_PES_VIDEO0: first video PID. Also referred as @DMX_PES_VIDEO.
76 * @DMX_PES_TELETEXT0: first teletext PID. Also referred as @DMX_PES_TELETEXT.
77 * @DMX_PES_SUBTITLE0: first subtitle PID. Also referred as @DMX_PES_SUBTITLE.
78 * @DMX_PES_PCR0: first Program Clock Reference PID.
79 * Also referred as @DMX_PES_PCR.
80 *
81 * @DMX_PES_AUDIO1: second audio PID.
82 * @DMX_PES_VIDEO1: second video PID.
83 * @DMX_PES_TELETEXT1: second teletext PID.
84 * @DMX_PES_SUBTITLE1: second subtitle PID.
85 * @DMX_PES_PCR1: second Program Clock Reference PID.
86 *
87 * @DMX_PES_AUDIO2: third audio PID.
88 * @DMX_PES_VIDEO2: third video PID.
89 * @DMX_PES_TELETEXT2: third teletext PID.
90 * @DMX_PES_SUBTITLE2: third subtitle PID.
91 * @DMX_PES_PCR2: third Program Clock Reference PID.
92 *
93 * @DMX_PES_AUDIO3: fourth audio PID.
94 * @DMX_PES_VIDEO3: fourth video PID.
95 * @DMX_PES_TELETEXT3: fourth teletext PID.
96 * @DMX_PES_SUBTITLE3: fourth subtitle PID.
97 * @DMX_PES_PCR3: fourth Program Clock Reference PID.
98 *
99 * @DMX_PES_OTHER: any other PID.
100 */
101
102enum dmx_ts_pes {
David Howellsc57fd022012-10-09 09:48:42 +0100103 DMX_PES_AUDIO0,
104 DMX_PES_VIDEO0,
105 DMX_PES_TELETEXT0,
106 DMX_PES_SUBTITLE0,
107 DMX_PES_PCR0,
108
109 DMX_PES_AUDIO1,
110 DMX_PES_VIDEO1,
111 DMX_PES_TELETEXT1,
112 DMX_PES_SUBTITLE1,
113 DMX_PES_PCR1,
114
115 DMX_PES_AUDIO2,
116 DMX_PES_VIDEO2,
117 DMX_PES_TELETEXT2,
118 DMX_PES_SUBTITLE2,
119 DMX_PES_PCR2,
120
121 DMX_PES_AUDIO3,
122 DMX_PES_VIDEO3,
123 DMX_PES_TELETEXT3,
124 DMX_PES_SUBTITLE3,
125 DMX_PES_PCR3,
126
127 DMX_PES_OTHER
Mauro Carvalho Chehab3256b362017-09-01 06:09:14 -0400128};
David Howellsc57fd022012-10-09 09:48:42 +0100129
130#define DMX_PES_AUDIO DMX_PES_AUDIO0
131#define DMX_PES_VIDEO DMX_PES_VIDEO0
132#define DMX_PES_TELETEXT DMX_PES_TELETEXT0
133#define DMX_PES_SUBTITLE DMX_PES_SUBTITLE0
134#define DMX_PES_PCR DMX_PES_PCR0
135
136
Mauro Carvalho Chehabbb98e6d2017-08-31 12:28:52 -0400137
138/**
139 * struct dmx_filter - Specifies a section header filter.
140 *
141 * @filter: bit array with bits to be matched at the section header.
142 * @mask: bits that are valid at the filter bit array.
143 * @mode: mode of match: if bit is zero, it will match if equal (positive
144 * match); if bit is one, it will match if the bit is negated.
145 *
146 * Note: All arrays in this struct have a size of DMX_FILTER_SIZE (16 bytes).
147 */
148struct dmx_filter {
David Howellsc57fd022012-10-09 09:48:42 +0100149 __u8 filter[DMX_FILTER_SIZE];
150 __u8 mask[DMX_FILTER_SIZE];
151 __u8 mode[DMX_FILTER_SIZE];
Mauro Carvalho Chehab3256b362017-09-01 06:09:14 -0400152};
David Howellsc57fd022012-10-09 09:48:42 +0100153
Mauro Carvalho Chehabbb98e6d2017-08-31 12:28:52 -0400154/**
155 * struct dmx_sct_filter_params - Specifies a section filter.
156 *
157 * @pid: PID to be filtered.
158 * @filter: section header filter, as defined by &struct dmx_filter.
159 * @timeout: maximum time to filter, in milliseconds.
160 * @flags: extra flags for the section filter.
161 *
162 * Carries the configuration for a MPEG-TS section filter.
163 *
164 * The @flags can be:
165 *
166 * - %DMX_CHECK_CRC - only deliver sections where the CRC check succeeded;
167 * - %DMX_ONESHOT - disable the section filter after one section
168 * has been delivered;
169 * - %DMX_IMMEDIATE_START - Start filter immediately without requiring a
170 * :ref:`DMX_START`.
171 */
172struct dmx_sct_filter_params {
Mauro Carvalho Chehab3256b362017-09-01 06:09:14 -0400173 __u16 pid;
174 struct dmx_filter filter;
175 __u32 timeout;
176 __u32 flags;
David Howellsc57fd022012-10-09 09:48:42 +0100177#define DMX_CHECK_CRC 1
178#define DMX_ONESHOT 2
179#define DMX_IMMEDIATE_START 4
David Howellsc57fd022012-10-09 09:48:42 +0100180};
181
Mauro Carvalho Chehabbb98e6d2017-08-31 12:28:52 -0400182/**
183 * struct dmx_pes_filter_params - Specifies Packetized Elementary Stream (PES)
184 * filter parameters.
185 *
186 * @pid: PID to be filtered.
187 * @input: Demux input, as specified by &enum dmx_input.
188 * @output: Demux output, as specified by &enum dmx_output.
189 * @pes_type: Type of the pes filter, as specified by &enum dmx_pes_type.
190 * @flags: Demux PES flags.
191 */
David Howellsc57fd022012-10-09 09:48:42 +0100192struct dmx_pes_filter_params
193{
Mauro Carvalho Chehab3256b362017-09-01 06:09:14 -0400194 __u16 pid;
195 enum dmx_input input;
196 enum dmx_output output;
197 enum dmx_ts_pes pes_type;
198 __u32 flags;
David Howellsc57fd022012-10-09 09:48:42 +0100199};
200
Mauro Carvalho Chehabbb98e6d2017-08-31 12:28:52 -0400201/**
202 * struct dmx_stc - Stores System Time Counter (STC) information.
203 *
204 * @num: input data: number of the STC, from 0 to N.
205 * @base: output: divisor for STC to get 90 kHz clock.
206 * @stc: output: stc in @base * 90 kHz units.
207 */
David Howellsc57fd022012-10-09 09:48:42 +0100208struct dmx_stc {
Mauro Carvalho Chehabbb98e6d2017-08-31 12:28:52 -0400209 unsigned int num;
210 unsigned int base;
211 __u64 stc;
David Howellsc57fd022012-10-09 09:48:42 +0100212};
213
David Howellsc57fd022012-10-09 09:48:42 +0100214#define DMX_START _IO('o', 41)
215#define DMX_STOP _IO('o', 42)
216#define DMX_SET_FILTER _IOW('o', 43, struct dmx_sct_filter_params)
217#define DMX_SET_PES_FILTER _IOW('o', 44, struct dmx_pes_filter_params)
218#define DMX_SET_BUFFER_SIZE _IO('o', 45)
219#define DMX_GET_PES_PIDS _IOR('o', 47, __u16[5])
David Howellsc57fd022012-10-09 09:48:42 +0100220#define DMX_GET_STC _IOWR('o', 50, struct dmx_stc)
221#define DMX_ADD_PID _IOW('o', 51, __u16)
222#define DMX_REMOVE_PID _IOW('o', 52, __u16)
223
Mauro Carvalho Chehab3256b362017-09-01 06:09:14 -0400224#if !defined (__KERNEL__)
225
226/* This is needed for legacy userspace support */
227typedef enum dmx_output dmx_output_t;
228typedef enum dmx_input dmx_input_t;
229typedef enum dmx_ts_pes dmx_pes_type_t;
230typedef struct dmx_filter dmx_filter_t;
Mauro Carvalho Chehab3256b362017-09-01 06:09:14 -0400231
232#endif
233
David Howellsc57fd022012-10-09 09:48:42 +0100234#endif /* _UAPI_DVBDMX_H_ */