blob: b3ac317c1a59ab619b1698f3e527c6e54addebe3 [file] [log] [blame]
chuangcheng pengfacd04c2023-08-21 14:02:24 +08001/* SPDX-License-Identifier: GPL-2.0 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 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public License
11 * as published by the Free Software Foundation; either version 2.1
12 * of the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU Lesser General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 *
23 */
24
25#ifndef _UAPI_DVBDMX_H_
26#define _UAPI_DVBDMX_H_
27
28#include <linux/types.h>
29#ifndef __KERNEL__
30#include <time.h>
31#endif
32
33
34#define DMX_FILTER_SIZE 16
35
36/**
37 * enum dmx_output - Output for the demux.
38 *
39 * @DMX_OUT_DECODER:
40 * Streaming directly to decoder.
41 * @DMX_OUT_TAP:
42 * Output going to a memory buffer (to be retrieved via the read command).
43 * Delivers the stream output to the demux device on which the ioctl
44 * is called.
45 * @DMX_OUT_TS_TAP:
46 * Output multiplexed into a new TS (to be retrieved by reading from the
47 * logical DVR device). Routes output to the logical DVR device
48 * ``/dev/dvb/adapter?/dvr?``, which delivers a TS multiplexed from all
49 * filters for which @DMX_OUT_TS_TAP was specified.
50 * @DMX_OUT_TSDEMUX_TAP:
51 * Like @DMX_OUT_TS_TAP but retrieved from the DMX device.
52 */
53enum dmx_output {
54 DMX_OUT_DECODER,
55 DMX_OUT_TAP,
56 DMX_OUT_TS_TAP,
57 DMX_OUT_TSDEMUX_TAP
58};
59
60
61/**
62 * enum dmx_input - Input from the demux.
63 *
64 * @DMX_IN_FRONTEND: Input from a front-end device.
65 * @DMX_IN_DVR: Input from the logical DVR device.
66 */
67enum dmx_input {
68 DMX_IN_FRONTEND,
69 DMX_IN_DVR
70};
71
72/**
73 * enum dmx_ts_pes - type of the PES filter.
74 *
75 * @DMX_PES_AUDIO0: first audio PID. Also referred as @DMX_PES_AUDIO.
76 * @DMX_PES_VIDEO0: first video PID. Also referred as @DMX_PES_VIDEO.
77 * @DMX_PES_TELETEXT0: first teletext PID. Also referred as @DMX_PES_TELETEXT.
78 * @DMX_PES_SUBTITLE0: first subtitle PID. Also referred as @DMX_PES_SUBTITLE.
79 * @DMX_PES_PCR0: first Program Clock Reference PID.
80 * Also referred as @DMX_PES_PCR.
81 *
82 * @DMX_PES_AUDIO1: second audio PID.
83 * @DMX_PES_VIDEO1: second video PID.
84 * @DMX_PES_TELETEXT1: second teletext PID.
85 * @DMX_PES_SUBTITLE1: second subtitle PID.
86 * @DMX_PES_PCR1: second Program Clock Reference PID.
87 *
88 * @DMX_PES_AUDIO2: third audio PID.
89 * @DMX_PES_VIDEO2: third video PID.
90 * @DMX_PES_TELETEXT2: third teletext PID.
91 * @DMX_PES_SUBTITLE2: third subtitle PID.
92 * @DMX_PES_PCR2: third Program Clock Reference PID.
93 *
94 * @DMX_PES_AUDIO3: fourth audio PID.
95 * @DMX_PES_VIDEO3: fourth video PID.
96 * @DMX_PES_TELETEXT3: fourth teletext PID.
97 * @DMX_PES_SUBTITLE3: fourth subtitle PID.
98 * @DMX_PES_PCR3: fourth Program Clock Reference PID.
99 *
100 * @DMX_PES_OTHER: any other PID.
101 */
102
103enum dmx_ts_pes {
104 DMX_PES_AUDIO0,
105 DMX_PES_VIDEO0,
106 DMX_PES_TELETEXT0,
107 DMX_PES_SUBTITLE0,
108 DMX_PES_PCR0,
109
110 DMX_PES_AUDIO1,
111 DMX_PES_VIDEO1,
112 DMX_PES_TELETEXT1,
113 DMX_PES_SUBTITLE1,
114 DMX_PES_PCR1,
115
116 DMX_PES_AUDIO2,
117 DMX_PES_VIDEO2,
118 DMX_PES_TELETEXT2,
119 DMX_PES_SUBTITLE2,
120 DMX_PES_PCR2,
121
122 DMX_PES_AUDIO3,
123 DMX_PES_VIDEO3,
124 DMX_PES_TELETEXT3,
125 DMX_PES_SUBTITLE3,
126 DMX_PES_PCR3,
127
128 DMX_PES_OTHER
129};
130
131#define DMX_PES_AUDIO DMX_PES_AUDIO0
132#define DMX_PES_VIDEO DMX_PES_VIDEO0
133#define DMX_PES_TELETEXT DMX_PES_TELETEXT0
134#define DMX_PES_SUBTITLE DMX_PES_SUBTITLE0
135#define DMX_PES_PCR DMX_PES_PCR0
136
137
138
139/**
140 * struct dmx_filter - Specifies a section header filter.
141 *
142 * @filter: bit array with bits to be matched at the section header.
143 * @mask: bits that are valid at the filter bit array.
144 * @mode: mode of match: if bit is zero, it will match if equal (positive
145 * match); if bit is one, it will match if the bit is negated.
146 *
147 * Note: All arrays in this struct have a size of DMX_FILTER_SIZE (16 bytes).
148 */
149struct dmx_filter {
150 __u8 filter[DMX_FILTER_SIZE];
151 __u8 mask[DMX_FILTER_SIZE];
152 __u8 mode[DMX_FILTER_SIZE];
153};
154
155/**
156 * struct dmx_sct_filter_params - Specifies a section filter.
157 *
158 * @pid: PID to be filtered.
159 * @filter: section header filter, as defined by &struct dmx_filter.
160 * @timeout: maximum time to filter, in milliseconds.
161 * @flags: extra flags for the section filter.
162 *
163 * Carries the configuration for a MPEG-TS section filter.
164 *
165 * The @flags can be:
166 *
167 * - %DMX_CHECK_CRC - only deliver sections where the CRC check succeeded;
168 * - %DMX_ONESHOT - disable the section filter after one section
169 * has been delivered;
170 * - %DMX_IMMEDIATE_START - Start filter immediately without requiring a
171 * :ref:`DMX_START`.
172 */
173struct dmx_sct_filter_params {
174 __u16 pid;
175 struct dmx_filter filter;
176 __u32 timeout;
177 __u32 flags;
178#define DMX_CHECK_CRC 1
179#define DMX_ONESHOT 2
180#define DMX_IMMEDIATE_START 4
181#ifdef CONFIG_AMLOGIC_DVB_COMPAT
182#define DMX_USE_SWFILTER 0x100
183
184/*bit 8~15 for mem sec_level*/
185#define DMX_MEM_SEC_LEVEL1 (1 << 10)
186#define DMX_MEM_SEC_LEVEL2 (2 << 10)
187#define DMX_MEM_SEC_LEVEL3 (3 << 10)
188#define DMX_MEM_SEC_LEVEL4 (4 << 10)
189#define DMX_MEM_SEC_LEVEL5 (5 << 10)
190#define DMX_MEM_SEC_LEVEL6 (6 << 10)
191#define DMX_MEM_SEC_LEVEL7 (7 << 10)
192#endif
193};
194
195#ifdef CONFIG_AMLOGIC_DVB_COMPAT
196
197enum dmx_input_source {
198 INPUT_DEMOD,
199 INPUT_LOCAL,
200 INPUT_LOCAL_SEC
201};
202
203/**
204 * struct dmx_non_sec_es_header - non-sec Elementary Stream (ES) Header
205 *
206 * @pts_dts_flag:[1:0], 10:pts valid, 01:dts valid
207 * @pts_dts_flag:[3:2], 10:scb is scrambled, 01:pscp invalid
208 * @pts: pts value
209 * @dts: dts value
210 * @len: data len
211 */
212struct dmx_non_sec_es_header {
213 __u8 pts_dts_flag;
214 __u64 pts;
215 __u64 dts;
216 __u32 len;
217};
218
219/**
220 * struct dmx_sec_es_data - sec Elementary Stream (ES)
221 *
222 * @pts_dts_flag:[1:0], 10:pts valid, 01:dts valid
223 * @pts_dts_flag:[3:2], 10:scb is scrambled, 01:pscp invalid
224 * @pts: pts value
225 * @dts: dts value
226 * @buf_start: buf start addr
227 * @buf_end: buf end addr
228 * @data_start: data start addr
229 * @data_end: data end addr
230 */
231struct dmx_sec_es_data {
232 __u8 pts_dts_flag;
233 __u64 pts;
234 __u64 dts;
235 __u32 buf_start;
236 __u32 buf_end;
237 __u32 data_start;
238 __u32 data_end;
239};
240
241struct dmx_sec_ts_data {
242 __u32 buf_start;
243 __u32 buf_end;
244 __u32 data_start;
245 __u32 data_end;
246};
247
248struct dmx_temi_data {
249 __u8 pts_dts_flag;
250 __u64 pts;
251 __u64 dts;
252 __u8 temi[188];
253};
254
255enum dmx_audio_format {
256 AUDIO_UNKNOWN = 0, /* unknown media */
257 AUDIO_MPX = 1, /* mpeg audio MP2/MP3 */
258 AUDIO_AC3 = 2, /* Dolby AC3/EAC3 */
259 AUDIO_AAC_ADTS = 3, /* AAC-ADTS */
260 AUDIO_AAC_LOAS = 4, /* AAC-LOAS */
261 AUDIO_DTS = 5, /* DTS */
262 AUDIO_MAX
263};
264
265struct dmx_mem_info {
266 __u32 dmx_total_size;
267 __u32 dmx_buf_phy_start;
268 __u32 dmx_free_size;
269 __u32 dvb_core_total_size;
270 __u32 dvb_core_free_size;
271 __u32 wp_offset;
272 __u64 newest_pts;
273};
274
275struct dmx_sec_mem {
276 __u32 buff;
277 __u32 size;
278};
279#endif
280
281/**
282 * struct dmx_pes_filter_params - Specifies Packetized Elementary Stream (PES)
283 * filter parameters.
284 *
285 * @pid: PID to be filtered.
286 * @input: Demux input, as specified by &enum dmx_input.
287 * @output: Demux output, as specified by &enum dmx_output.
288 * @pes_type: Type of the pes filter, as specified by &enum dmx_pes_type.
289 * @flags: Demux PES flags.
290 */
291struct dmx_pes_filter_params {
292 __u16 pid;
293 enum dmx_input input;
294 enum dmx_output output;
295 enum dmx_ts_pes pes_type;
296 __u32 flags;
297#ifdef CONFIG_AMLOGIC_DVB_COMPAT
298/*bit 8~15 for mem sec_level*/
299#define DMX_MEM_SEC_LEVEL1 (1 << 10)
300#define DMX_MEM_SEC_LEVEL2 (2 << 10)
301#define DMX_MEM_SEC_LEVEL3 (3 << 10)
302#define DMX_MEM_SEC_LEVEL4 (4 << 10)
303#define DMX_MEM_SEC_LEVEL5 (5 << 10)
304#define DMX_MEM_SEC_LEVEL6 (6 << 10)
305#define DMX_MEM_SEC_LEVEL7 (7 << 10)
306
307/*bit 16~23 for output */
308#define DMX_ES_OUTPUT (1 << 16)
309/*set raw mode, it will send the struct dmx_sec_es_data, not es data*/
310#define DMX_OUTPUT_RAW_MODE (1 << 17)
311#define DMX_TEMI_FLAGS (1 << 18)
312
313/*24~31 one byte for audio type, dmx_audio_format_t*/
314#define DMX_AUDIO_FORMAT_BIT 24
315
316#endif
317};
318
319/**
320 * struct dmx_stc - Stores System Time Counter (STC) information.
321 *
322 * @num: input data: number of the STC, from 0 to N.
323 * @base: output: divisor for STC to get 90 kHz clock.
324 * @stc: output: stc in @base * 90 kHz units.
325 */
326struct dmx_stc {
327 unsigned int num;
328 unsigned int base;
329 __u64 stc;
330};
331
332/**
333 * enum dmx_buffer_flags - DMX memory-mapped buffer flags
334 *
335 * @DMX_BUFFER_FLAG_HAD_CRC32_DISCARD:
336 * Indicates that the Kernel discarded one or more frames due to wrong
337 * CRC32 checksum.
338 * @DMX_BUFFER_FLAG_TEI:
339 * Indicates that the Kernel has detected a Transport Error indicator
340 * (TEI) on a filtered pid.
341 * @DMX_BUFFER_PKT_COUNTER_MISMATCH:
342 * Indicates that the Kernel has detected a packet counter mismatch
343 * on a filtered pid.
344 * @DMX_BUFFER_FLAG_DISCONTINUITY_DETECTED:
345 * Indicates that the Kernel has detected one or more frame discontinuity.
346 * @DMX_BUFFER_FLAG_DISCONTINUITY_INDICATOR:
347 * Received at least one packet with a frame discontinuity indicator.
348 */
349
350enum dmx_buffer_flags {
351 DMX_BUFFER_FLAG_HAD_CRC32_DISCARD = 1 << 0,
352 DMX_BUFFER_FLAG_TEI = 1 << 1,
353 DMX_BUFFER_PKT_COUNTER_MISMATCH = 1 << 2,
354 DMX_BUFFER_FLAG_DISCONTINUITY_DETECTED = 1 << 3,
355 DMX_BUFFER_FLAG_DISCONTINUITY_INDICATOR = 1 << 4,
356};
357
358/**
359 * struct dmx_buffer - dmx buffer info
360 *
361 * @index: id number of the buffer
362 * @bytesused: number of bytes occupied by data in the buffer (payload);
363 * @offset: for buffers with memory == DMX_MEMORY_MMAP;
364 * offset from the start of the device memory for this plane,
365 * (or a "cookie" that should be passed to mmap() as offset)
366 * @length: size in bytes of the buffer
367 * @flags: bit array of buffer flags as defined by &enum dmx_buffer_flags.
368 * Filled only at &DMX_DQBUF.
369 * @count: monotonic counter for filled buffers. Helps to identify
370 * data stream loses. Filled only at &DMX_DQBUF.
371 *
372 * Contains data exchanged by application and driver using one of the streaming
373 * I/O methods.
374 *
375 * Please notice that, for &DMX_QBUF, only @index should be filled.
376 * On &DMX_DQBUF calls, all fields will be filled by the Kernel.
377 */
378struct dmx_buffer {
379 __u32 index;
380 __u32 bytesused;
381 __u32 offset;
382 __u32 length;
383 __u32 flags;
384 __u32 count;
385};
386
387/**
388 * struct dmx_requestbuffers - request dmx buffer information
389 *
390 * @count: number of requested buffers,
391 * @size: size in bytes of the requested buffer
392 *
393 * Contains data used for requesting a dmx buffer.
394 * All reserved fields must be set to zero.
395 */
396struct dmx_requestbuffers {
397 __u32 count;
398 __u32 size;
399};
400
401/**
402 * struct dmx_exportbuffer - export of dmx buffer as DMABUF file descriptor
403 *
404 * @index: id number of the buffer
405 * @flags: flags for newly created file, currently only O_CLOEXEC is
406 * supported, refer to manual of open syscall for more details
407 * @fd: file descriptor associated with DMABUF (set by driver)
408 *
409 * Contains data used for exporting a dmx buffer as DMABUF file descriptor.
410 * The buffer is identified by a 'cookie' returned by DMX_QUERYBUF
411 * (identical to the cookie used to mmap() the buffer to userspace). All
412 * reserved fields must be set to zero. The field reserved0 is expected to
413 * become a structure 'type' allowing an alternative layout of the structure
414 * content. Therefore this field should not be used for any other extensions.
415 */
416struct dmx_exportbuffer {
417 __u32 index;
418 __u32 flags;
419 __s32 fd;
420};
421
422#ifdef CONFIG_AMLOGIC_DVB_COMPAT
423enum {
424 DMA_0 = 0,
425 DMA_1,
426 DMA_2,
427 DMA_3,
428 DMA_4,
429 DMA_5,
430 DMA_6,
431 DMA_7,
432 FRONTEND_TS0 = 32,
433 FRONTEND_TS1,
434 FRONTEND_TS2,
435 FRONTEND_TS3,
436 FRONTEND_TS4,
437 FRONTEND_TS5,
438 FRONTEND_TS6,
439 FRONTEND_TS7,
440 DMA_0_1 = 64,
441 DMA_1_1,
442 DMA_2_1,
443 DMA_3_1,
444 DMA_4_1,
445 DMA_5_1,
446 DMA_6_1,
447 DMA_7_1,
448 FRONTEND_TS0_1 = 96,
449 FRONTEND_TS1_1,
450 FRONTEND_TS2_1,
451 FRONTEND_TS3_1,
452 FRONTEND_TS4_1,
453 FRONTEND_TS5_1,
454 FRONTEND_TS6_1,
455 FRONTEND_TS7_1,
456};
457
458/*define filter mem_info type*/
459enum {
460 DMX_VIDEO_TYPE = 0,
461 DMX_AUDIO_TYPE,
462 DMX_SUBTITLE_TYPE,
463 DMX_TELETEXT_TYPE,
464 DMX_SECTION_TYPE,
465};
466
467struct filter_mem_info {
468 __u32 type;
469 __u32 pid;
470 struct dmx_mem_info filter_info;
471};
472
473struct dmx_filter_mem_info {
474 __u32 filter_num;
475 struct filter_mem_info info[40];
476};
477
478struct dvr_mem_info {
479 __u32 wp_offset;
480};
481
482struct decoder_mem_info {
483 __u32 rp_phy;
484};
485#endif
486
487#define DMX_START _IO('o', 41)
488#define DMX_STOP _IO('o', 42)
489#define DMX_SET_FILTER _IOW('o', 43, struct dmx_sct_filter_params)
490#define DMX_SET_PES_FILTER _IOW('o', 44, struct dmx_pes_filter_params)
491#define DMX_SET_BUFFER_SIZE _IO('o', 45)
492#define DMX_GET_PES_PIDS _IOR('o', 47, __u16[5])
493#define DMX_GET_STC _IOWR('o', 50, struct dmx_stc)
494#define DMX_ADD_PID _IOW('o', 51, __u16)
495#define DMX_REMOVE_PID _IOW('o', 52, __u16)
496#if !defined(__KERNEL__)
497
498/* This is needed for legacy userspace support */
499typedef enum dmx_output dmx_output_t;
500typedef enum dmx_input dmx_input_t;
501typedef enum dmx_ts_pes dmx_pes_type_t;
502typedef struct dmx_filter dmx_filter_t;
503
504#endif
505
506#define DMX_REQBUFS _IOWR('o', 60, struct dmx_requestbuffers)
507#define DMX_QUERYBUF _IOWR('o', 61, struct dmx_buffer)
508#define DMX_EXPBUF _IOWR('o', 62, struct dmx_exportbuffer)
509#define DMX_QBUF _IOWR('o', 63, struct dmx_buffer)
510#define DMX_DQBUF _IOWR('o', 64, struct dmx_buffer)
511
512#ifdef CONFIG_AMLOGIC_DVB_COMPAT
513#define DMX_SET_INPUT _IO('o', 80)
514#define DMX_GET_MEM_INFO _IOR('o', 81, struct dmx_mem_info)
515#define DMX_SET_HW_SOURCE _IO('o', 82)
516#define DMX_GET_HW_SOURCE _IOR('o', 83, int)
517#define DMX_GET_FILTER_MEM_INFO _IOR('o', 84, struct dmx_filter_mem_info)
518/*just for dvr sec mem, please call before DMX_SET_PES_FILTER*/
519#define DMX_SET_SEC_MEM _IOW('o', 85, struct dmx_sec_mem)
520#define DMX_GET_DVR_MEM _IOR('o', 86, struct dvr_mem_info)
521#define DMX_REMAP_PID _IOR('o', 87, __u16[2])
522#define DMX_SET_DECODE_INFO _IOW('o', 88, struct decoder_mem_info)
523#endif
524#endif /* _DVBDMX_H_ */