1/* SPDX-License-Identifier: LGPL-2.1+ WITH Linux-syscall-note */
2/*
3 * dmx.h
4 *
5 * Copyright (C) 2000 Marcus Metzler <marcus@convergence.de>
6 * & Ralph Metzler <ralph@convergence.de>
7 * for convergence integrated media GmbH
8 */
9
10#ifndef _UAPI_DVBDMX_H_
11#define _UAPI_DVBDMX_H_
12
13#include <linux/types.h>
14#ifndef __KERNEL__
15#include <time.h>
16#endif
17
18
19#define DMX_FILTER_SIZE 16
20
21/**
22 * enum dmx_output - Output for the demux.
23 *
24 * @DMX_OUT_DECODER:
25 * Streaming directly to decoder.
26 * @DMX_OUT_TAP:
27 * Output going to a memory buffer (to be retrieved via the read command).
28 * Delivers the stream output to the demux device on which the ioctl
29 * is called.
30 * @DMX_OUT_TS_TAP:
31 * Output multiplexed into a new TS (to be retrieved by reading from the
32 * logical DVR device). Routes output to the logical DVR device
33 * ``/dev/dvb/adapter?/dvr?``, which delivers a TS multiplexed from all
34 * filters for which @DMX_OUT_TS_TAP was specified.
35 * @DMX_OUT_TSDEMUX_TAP:
36 * Like @DMX_OUT_TS_TAP but retrieved from the DMX device.
37 */
38enum dmx_output {
39 DMX_OUT_DECODER,
40 DMX_OUT_TAP,
41 DMX_OUT_TS_TAP,
42 DMX_OUT_TSDEMUX_TAP
43};
44
45
46/**
47 * enum dmx_input - Input from the demux.
48 *
49 * @DMX_IN_FRONTEND: Input from a front-end device.
50 * @DMX_IN_DVR: Input from the logical DVR device.
51 */
52enum dmx_input {
53 DMX_IN_FRONTEND,
54 DMX_IN_DVR
55};
56
57/**
58 * enum dmx_ts_pes - type of the PES filter.
59 *
60 * @DMX_PES_AUDIO0: first audio PID. Also referred as @DMX_PES_AUDIO.
61 * @DMX_PES_VIDEO0: first video PID. Also referred as @DMX_PES_VIDEO.
62 * @DMX_PES_TELETEXT0: first teletext PID. Also referred as @DMX_PES_TELETEXT.
63 * @DMX_PES_SUBTITLE0: first subtitle PID. Also referred as @DMX_PES_SUBTITLE.
64 * @DMX_PES_PCR0: first Program Clock Reference PID.
65 * Also referred as @DMX_PES_PCR.
66 *
67 * @DMX_PES_AUDIO1: second audio PID.
68 * @DMX_PES_VIDEO1: second video PID.
69 * @DMX_PES_TELETEXT1: second teletext PID.
70 * @DMX_PES_SUBTITLE1: second subtitle PID.
71 * @DMX_PES_PCR1: second Program Clock Reference PID.
72 *
73 * @DMX_PES_AUDIO2: third audio PID.
74 * @DMX_PES_VIDEO2: third video PID.
75 * @DMX_PES_TELETEXT2: third teletext PID.
76 * @DMX_PES_SUBTITLE2: third subtitle PID.
77 * @DMX_PES_PCR2: third Program Clock Reference PID.
78 *
79 * @DMX_PES_AUDIO3: fourth audio PID.
80 * @DMX_PES_VIDEO3: fourth video PID.
81 * @DMX_PES_TELETEXT3: fourth teletext PID.
82 * @DMX_PES_SUBTITLE3: fourth subtitle PID.
83 * @DMX_PES_PCR3: fourth Program Clock Reference PID.
84 *
85 * @DMX_PES_OTHER: any other PID.
86 */
87
88enum dmx_ts_pes {
89 DMX_PES_AUDIO0,
90 DMX_PES_VIDEO0,
91 DMX_PES_TELETEXT0,
92 DMX_PES_SUBTITLE0,
93 DMX_PES_PCR0,
94
95 DMX_PES_AUDIO1,
96 DMX_PES_VIDEO1,
97 DMX_PES_TELETEXT1,
98 DMX_PES_SUBTITLE1,
99 DMX_PES_PCR1,
100
101 DMX_PES_AUDIO2,
102 DMX_PES_VIDEO2,
103 DMX_PES_TELETEXT2,
104 DMX_PES_SUBTITLE2,
105 DMX_PES_PCR2,
106
107 DMX_PES_AUDIO3,
108 DMX_PES_VIDEO3,
109 DMX_PES_TELETEXT3,
110 DMX_PES_SUBTITLE3,
111 DMX_PES_PCR3,
112
113 DMX_PES_OTHER
114};
115
116#define DMX_PES_AUDIO DMX_PES_AUDIO0
117#define DMX_PES_VIDEO DMX_PES_VIDEO0
118#define DMX_PES_TELETEXT DMX_PES_TELETEXT0
119#define DMX_PES_SUBTITLE DMX_PES_SUBTITLE0
120#define DMX_PES_PCR DMX_PES_PCR0
121
122
123
124/**
125 * struct dmx_filter - Specifies a section header filter.
126 *
127 * @filter: bit array with bits to be matched at the section header.
128 * @mask: bits that are valid at the filter bit array.
129 * @mode: mode of match: if bit is zero, it will match if equal (positive
130 * match); if bit is one, it will match if the bit is negated.
131 *
132 * Note: All arrays in this struct have a size of DMX_FILTER_SIZE (16 bytes).
133 */
134struct dmx_filter {
135 __u8 filter[DMX_FILTER_SIZE];
136 __u8 mask[DMX_FILTER_SIZE];
137 __u8 mode[DMX_FILTER_SIZE];
138};
139
140/**
141 * struct dmx_sct_filter_params - Specifies a section filter.
142 *
143 * @pid: PID to be filtered.
144 * @filter: section header filter, as defined by &struct dmx_filter.
145 * @timeout: maximum time to filter, in milliseconds.
146 * @flags: extra flags for the section filter.
147 *
148 * Carries the configuration for a MPEG-TS section filter.
149 *
150 * The @flags can be:
151 *
152 * - %DMX_CHECK_CRC - only deliver sections where the CRC check succeeded;
153 * - %DMX_ONESHOT - disable the section filter after one section
154 * has been delivered;
155 * - %DMX_IMMEDIATE_START - Start filter immediately without requiring a
156 * :ref:`DMX_START`.
157 */
158struct dmx_sct_filter_params {
159 __u16 pid;
160 struct dmx_filter filter;
161 __u32 timeout;
162 __u32 flags;
163#define DMX_CHECK_CRC 1
164#define DMX_ONESHOT 2
165#define DMX_IMMEDIATE_START 4
166};
167
168/**
169 * struct dmx_pes_filter_params - Specifies Packetized Elementary Stream (PES)
170 * filter parameters.
171 *
172 * @pid: PID to be filtered.
173 * @input: Demux input, as specified by &enum dmx_input.
174 * @output: Demux output, as specified by &enum dmx_output.
175 * @pes_type: Type of the pes filter, as specified by &enum dmx_pes_type.
176 * @flags: Demux PES flags.
177 */
178struct dmx_pes_filter_params {
179 __u16 pid;
180 enum dmx_input input;
181 enum dmx_output output;
182 enum dmx_ts_pes pes_type;
183 __u32 flags;
184};
185
186/**
187 * struct dmx_stc - Stores System Time Counter (STC) information.
188 *
189 * @num: input data: number of the STC, from 0 to N.
190 * @base: output: divisor for STC to get 90 kHz clock.
191 * @stc: output: stc in @base * 90 kHz units.
192 */
193struct dmx_stc {
194 unsigned int num;
195 unsigned int base;
196 __u64 stc;
197};
198
199/**
200 * enum dmx_buffer_flags - DMX memory-mapped buffer flags
201 *
202 * @DMX_BUFFER_FLAG_HAD_CRC32_DISCARD:
203 * Indicates that the Kernel discarded one or more frames due to wrong
204 * CRC32 checksum.
205 * @DMX_BUFFER_FLAG_TEI:
206 * Indicates that the Kernel has detected a Transport Error indicator
207 * (TEI) on a filtered pid.
208 * @DMX_BUFFER_PKT_COUNTER_MISMATCH:
209 * Indicates that the Kernel has detected a packet counter mismatch
210 * on a filtered pid.
211 * @DMX_BUFFER_FLAG_DISCONTINUITY_DETECTED:
212 * Indicates that the Kernel has detected one or more frame discontinuity.
213 * @DMX_BUFFER_FLAG_DISCONTINUITY_INDICATOR:
214 * Received at least one packet with a frame discontinuity indicator.
215 */
216
217enum dmx_buffer_flags {
218 DMX_BUFFER_FLAG_HAD_CRC32_DISCARD = 1 << 0,
219 DMX_BUFFER_FLAG_TEI = 1 << 1,
220 DMX_BUFFER_PKT_COUNTER_MISMATCH = 1 << 2,
221 DMX_BUFFER_FLAG_DISCONTINUITY_DETECTED = 1 << 3,
222 DMX_BUFFER_FLAG_DISCONTINUITY_INDICATOR = 1 << 4,
223};
224
225/**
226 * struct dmx_buffer - dmx buffer info
227 *
228 * @index: id number of the buffer
229 * @bytesused: number of bytes occupied by data in the buffer (payload);
230 * @offset: for buffers with memory == DMX_MEMORY_MMAP;
231 * offset from the start of the device memory for this plane,
232 * (or a "cookie" that should be passed to mmap() as offset)
233 * @length: size in bytes of the buffer
234 * @flags: bit array of buffer flags as defined by &enum dmx_buffer_flags.
235 * Filled only at &DMX_DQBUF.
236 * @count: monotonic counter for filled buffers. Helps to identify
237 * data stream loses. Filled only at &DMX_DQBUF.
238 *
239 * Contains data exchanged by application and driver using one of the streaming
240 * I/O methods.
241 *
242 * Please notice that, for &DMX_QBUF, only @index should be filled.
243 * On &DMX_DQBUF calls, all fields will be filled by the Kernel.
244 */
245struct dmx_buffer {
246 __u32 index;
247 __u32 bytesused;
248 __u32 offset;
249 __u32 length;
250 __u32 flags;
251 __u32 count;
252};
253
254/**
255 * struct dmx_requestbuffers - request dmx buffer information
256 *
257 * @count: number of requested buffers,
258 * @size: size in bytes of the requested buffer
259 *
260 * Contains data used for requesting a dmx buffer.
261 * All reserved fields must be set to zero.
262 */
263struct dmx_requestbuffers {
264 __u32 count;
265 __u32 size;
266};
267
268/**
269 * struct dmx_exportbuffer - export of dmx buffer as DMABUF file descriptor
270 *
271 * @index: id number of the buffer
272 * @flags: flags for newly created file, currently only O_CLOEXEC is
273 * supported, refer to manual of open syscall for more details
274 * @fd: file descriptor associated with DMABUF (set by driver)
275 *
276 * Contains data used for exporting a dmx buffer as DMABUF file descriptor.
277 * The buffer is identified by a 'cookie' returned by DMX_QUERYBUF
278 * (identical to the cookie used to mmap() the buffer to userspace). All
279 * reserved fields must be set to zero. The field reserved0 is expected to
280 * become a structure 'type' allowing an alternative layout of the structure
281 * content. Therefore this field should not be used for any other extensions.
282 */
283struct dmx_exportbuffer {
284 __u32 index;
285 __u32 flags;
286 __s32 fd;
287};
288
289#define DMX_START _IO('o', 41)
290#define DMX_STOP _IO('o', 42)
291#define DMX_SET_FILTER _IOW('o', 43, struct dmx_sct_filter_params)
292#define DMX_SET_PES_FILTER _IOW('o', 44, struct dmx_pes_filter_params)
293#define DMX_SET_BUFFER_SIZE _IO('o', 45)
294#define DMX_GET_PES_PIDS _IOR('o', 47, __u16[5])
295#define DMX_GET_STC _IOWR('o', 50, struct dmx_stc)
296#define DMX_ADD_PID _IOW('o', 51, __u16)
297#define DMX_REMOVE_PID _IOW('o', 52, __u16)
298
299#if !defined(__KERNEL__)
300
301/* This is needed for legacy userspace support */
302typedef enum dmx_output dmx_output_t;
303typedef enum dmx_input dmx_input_t;
304typedef enum dmx_ts_pes dmx_pes_type_t;
305typedef struct dmx_filter dmx_filter_t;
306
307#endif
308
309#define DMX_REQBUFS _IOWR('o', 60, struct dmx_requestbuffers)
310#define DMX_QUERYBUF _IOWR('o', 61, struct dmx_buffer)
311#define DMX_EXPBUF _IOWR('o', 62, struct dmx_exportbuffer)
312#define DMX_QBUF _IOWR('o', 63, struct dmx_buffer)
313#define DMX_DQBUF _IOWR('o', 64, struct dmx_buffer)
314
315#endif /* _DVBDMX_H_ */
316

source code of linux/include/uapi/linux/dvb/dmx.h