Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: LGPL-2.1+ WITH Linux-syscall-note */
0002 /*
0003  * dmx.h
0004  *
0005  * Copyright (C) 2000 Marcus Metzler <marcus@convergence.de>
0006  *                  & Ralph  Metzler <ralph@convergence.de>
0007  *                    for convergence integrated media GmbH
0008  *
0009  * This program is free software; you can redistribute it and/or
0010  * modify it under the terms of the GNU Lesser General Public License
0011  * as published by the Free Software Foundation; either version 2.1
0012  * of the License, or (at your option) any later version.
0013  *
0014  * This program is distributed in the hope that it will be useful,
0015  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0017  * GNU General Public License for more details.
0018  *
0019  * You should have received a copy of the GNU Lesser General Public License
0020  * along with this program; if not, write to the Free Software
0021  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
0022  *
0023  */
0024 
0025 #ifndef _UAPI_DVBDMX_H_
0026 #define _UAPI_DVBDMX_H_
0027 
0028 #include <linux/types.h>
0029 #ifndef __KERNEL__
0030 #include <time.h>
0031 #endif
0032 
0033 
0034 #define DMX_FILTER_SIZE 16
0035 
0036 /**
0037  * enum dmx_output - Output for the demux.
0038  *
0039  * @DMX_OUT_DECODER:
0040  *  Streaming directly to decoder.
0041  * @DMX_OUT_TAP:
0042  *  Output going to a memory buffer (to be retrieved via the read command).
0043  *  Delivers the stream output to the demux device on which the ioctl
0044  *  is called.
0045  * @DMX_OUT_TS_TAP:
0046  *  Output multiplexed into a new TS (to be retrieved by reading from the
0047  *  logical DVR device). Routes output to the logical DVR device
0048  *  ``/dev/dvb/adapter?/dvr?``, which delivers a TS multiplexed from all
0049  *  filters for which @DMX_OUT_TS_TAP was specified.
0050  * @DMX_OUT_TSDEMUX_TAP:
0051  *  Like @DMX_OUT_TS_TAP but retrieved from the DMX device.
0052  */
0053 enum dmx_output {
0054     DMX_OUT_DECODER,
0055     DMX_OUT_TAP,
0056     DMX_OUT_TS_TAP,
0057     DMX_OUT_TSDEMUX_TAP
0058 };
0059 
0060 
0061 /**
0062  * enum dmx_input - Input from the demux.
0063  *
0064  * @DMX_IN_FRONTEND:    Input from a front-end device.
0065  * @DMX_IN_DVR:     Input from the logical DVR device.
0066  */
0067 enum dmx_input {
0068     DMX_IN_FRONTEND,
0069     DMX_IN_DVR
0070 };
0071 
0072 /**
0073  * enum dmx_ts_pes - type of the PES filter.
0074  *
0075  * @DMX_PES_AUDIO0: first audio PID. Also referred as @DMX_PES_AUDIO.
0076  * @DMX_PES_VIDEO0: first video PID. Also referred as @DMX_PES_VIDEO.
0077  * @DMX_PES_TELETEXT0:  first teletext PID. Also referred as @DMX_PES_TELETEXT.
0078  * @DMX_PES_SUBTITLE0:  first subtitle PID. Also referred as @DMX_PES_SUBTITLE.
0079  * @DMX_PES_PCR0:   first Program Clock Reference PID.
0080  *          Also referred as @DMX_PES_PCR.
0081  *
0082  * @DMX_PES_AUDIO1: second audio PID.
0083  * @DMX_PES_VIDEO1: second video PID.
0084  * @DMX_PES_TELETEXT1:  second teletext PID.
0085  * @DMX_PES_SUBTITLE1:  second subtitle PID.
0086  * @DMX_PES_PCR1:   second Program Clock Reference PID.
0087  *
0088  * @DMX_PES_AUDIO2: third audio PID.
0089  * @DMX_PES_VIDEO2: third video PID.
0090  * @DMX_PES_TELETEXT2:  third teletext PID.
0091  * @DMX_PES_SUBTITLE2:  third subtitle PID.
0092  * @DMX_PES_PCR2:   third Program Clock Reference PID.
0093  *
0094  * @DMX_PES_AUDIO3: fourth audio PID.
0095  * @DMX_PES_VIDEO3: fourth video PID.
0096  * @DMX_PES_TELETEXT3:  fourth teletext PID.
0097  * @DMX_PES_SUBTITLE3:  fourth subtitle PID.
0098  * @DMX_PES_PCR3:   fourth Program Clock Reference PID.
0099  *
0100  * @DMX_PES_OTHER:  any other PID.
0101  */
0102 
0103 enum dmx_ts_pes {
0104     DMX_PES_AUDIO0,
0105     DMX_PES_VIDEO0,
0106     DMX_PES_TELETEXT0,
0107     DMX_PES_SUBTITLE0,
0108     DMX_PES_PCR0,
0109 
0110     DMX_PES_AUDIO1,
0111     DMX_PES_VIDEO1,
0112     DMX_PES_TELETEXT1,
0113     DMX_PES_SUBTITLE1,
0114     DMX_PES_PCR1,
0115 
0116     DMX_PES_AUDIO2,
0117     DMX_PES_VIDEO2,
0118     DMX_PES_TELETEXT2,
0119     DMX_PES_SUBTITLE2,
0120     DMX_PES_PCR2,
0121 
0122     DMX_PES_AUDIO3,
0123     DMX_PES_VIDEO3,
0124     DMX_PES_TELETEXT3,
0125     DMX_PES_SUBTITLE3,
0126     DMX_PES_PCR3,
0127 
0128     DMX_PES_OTHER
0129 };
0130 
0131 #define DMX_PES_AUDIO    DMX_PES_AUDIO0
0132 #define DMX_PES_VIDEO    DMX_PES_VIDEO0
0133 #define DMX_PES_TELETEXT DMX_PES_TELETEXT0
0134 #define DMX_PES_SUBTITLE DMX_PES_SUBTITLE0
0135 #define DMX_PES_PCR      DMX_PES_PCR0
0136 
0137 
0138 
0139 /**
0140  * struct dmx_filter - Specifies a section header filter.
0141  *
0142  * @filter: bit array with bits to be matched at the section header.
0143  * @mask: bits that are valid at the filter bit array.
0144  * @mode: mode of match: if bit is zero, it will match if equal (positive
0145  *    match); if bit is one, it will match if the bit is negated.
0146  *
0147  * Note: All arrays in this struct have a size of DMX_FILTER_SIZE (16 bytes).
0148  */
0149 struct dmx_filter {
0150     __u8  filter[DMX_FILTER_SIZE];
0151     __u8  mask[DMX_FILTER_SIZE];
0152     __u8  mode[DMX_FILTER_SIZE];
0153 };
0154 
0155 /**
0156  * struct dmx_sct_filter_params - Specifies a section filter.
0157  *
0158  * @pid: PID to be filtered.
0159  * @filter: section header filter, as defined by &struct dmx_filter.
0160  * @timeout: maximum time to filter, in milliseconds.
0161  * @flags: extra flags for the section filter.
0162  *
0163  * Carries the configuration for a MPEG-TS section filter.
0164  *
0165  * The @flags can be:
0166  *
0167  *  - %DMX_CHECK_CRC - only deliver sections where the CRC check succeeded;
0168  *  - %DMX_ONESHOT - disable the section filter after one section
0169  *    has been delivered;
0170  *  - %DMX_IMMEDIATE_START - Start filter immediately without requiring a
0171  *    :ref:`DMX_START`.
0172  */
0173 struct dmx_sct_filter_params {
0174     __u16             pid;
0175     struct dmx_filter filter;
0176     __u32             timeout;
0177     __u32             flags;
0178 #define DMX_CHECK_CRC       1
0179 #define DMX_ONESHOT         2
0180 #define DMX_IMMEDIATE_START 4
0181 };
0182 
0183 /**
0184  * struct dmx_pes_filter_params - Specifies Packetized Elementary Stream (PES)
0185  *  filter parameters.
0186  *
0187  * @pid:    PID to be filtered.
0188  * @input:  Demux input, as specified by &enum dmx_input.
0189  * @output: Demux output, as specified by &enum dmx_output.
0190  * @pes_type:   Type of the pes filter, as specified by &enum dmx_pes_type.
0191  * @flags:  Demux PES flags.
0192  */
0193 struct dmx_pes_filter_params {
0194     __u16           pid;
0195     enum dmx_input  input;
0196     enum dmx_output output;
0197     enum dmx_ts_pes pes_type;
0198     __u32           flags;
0199 };
0200 
0201 /**
0202  * struct dmx_stc - Stores System Time Counter (STC) information.
0203  *
0204  * @num: input data: number of the STC, from 0 to N.
0205  * @base: output: divisor for STC to get 90 kHz clock.
0206  * @stc: output: stc in @base * 90 kHz units.
0207  */
0208 struct dmx_stc {
0209     unsigned int num;
0210     unsigned int base;
0211     __u64 stc;
0212 };
0213 
0214 /**
0215  * enum dmx_buffer_flags - DMX memory-mapped buffer flags
0216  *
0217  * @DMX_BUFFER_FLAG_HAD_CRC32_DISCARD:
0218  *  Indicates that the Kernel discarded one or more frames due to wrong
0219  *  CRC32 checksum.
0220  * @DMX_BUFFER_FLAG_TEI:
0221  *  Indicates that the Kernel has detected a Transport Error indicator
0222  *  (TEI) on a filtered pid.
0223  * @DMX_BUFFER_PKT_COUNTER_MISMATCH:
0224  *  Indicates that the Kernel has detected a packet counter mismatch
0225  *  on a filtered pid.
0226  * @DMX_BUFFER_FLAG_DISCONTINUITY_DETECTED:
0227  *  Indicates that the Kernel has detected one or more frame discontinuity.
0228  * @DMX_BUFFER_FLAG_DISCONTINUITY_INDICATOR:
0229  *  Received at least one packet with a frame discontinuity indicator.
0230  */
0231 
0232 enum dmx_buffer_flags {
0233     DMX_BUFFER_FLAG_HAD_CRC32_DISCARD       = 1 << 0,
0234     DMX_BUFFER_FLAG_TEI             = 1 << 1,
0235     DMX_BUFFER_PKT_COUNTER_MISMATCH         = 1 << 2,
0236     DMX_BUFFER_FLAG_DISCONTINUITY_DETECTED      = 1 << 3,
0237     DMX_BUFFER_FLAG_DISCONTINUITY_INDICATOR     = 1 << 4,
0238 };
0239 
0240 /**
0241  * struct dmx_buffer - dmx buffer info
0242  *
0243  * @index:  id number of the buffer
0244  * @bytesused:  number of bytes occupied by data in the buffer (payload);
0245  * @offset: for buffers with memory == DMX_MEMORY_MMAP;
0246  *      offset from the start of the device memory for this plane,
0247  *      (or a "cookie" that should be passed to mmap() as offset)
0248  * @length: size in bytes of the buffer
0249  * @flags:  bit array of buffer flags as defined by &enum dmx_buffer_flags.
0250  *      Filled only at &DMX_DQBUF.
0251  * @count:  monotonic counter for filled buffers. Helps to identify
0252  *      data stream loses. Filled only at &DMX_DQBUF.
0253  *
0254  * Contains data exchanged by application and driver using one of the streaming
0255  * I/O methods.
0256  *
0257  * Please notice that, for &DMX_QBUF, only @index should be filled.
0258  * On &DMX_DQBUF calls, all fields will be filled by the Kernel.
0259  */
0260 struct dmx_buffer {
0261     __u32           index;
0262     __u32           bytesused;
0263     __u32           offset;
0264     __u32           length;
0265     __u32           flags;
0266     __u32           count;
0267 };
0268 
0269 /**
0270  * struct dmx_requestbuffers - request dmx buffer information
0271  *
0272  * @count:  number of requested buffers,
0273  * @size:   size in bytes of the requested buffer
0274  *
0275  * Contains data used for requesting a dmx buffer.
0276  * All reserved fields must be set to zero.
0277  */
0278 struct dmx_requestbuffers {
0279     __u32           count;
0280     __u32           size;
0281 };
0282 
0283 /**
0284  * struct dmx_exportbuffer - export of dmx buffer as DMABUF file descriptor
0285  *
0286  * @index:  id number of the buffer
0287  * @flags:  flags for newly created file, currently only O_CLOEXEC is
0288  *      supported, refer to manual of open syscall for more details
0289  * @fd:     file descriptor associated with DMABUF (set by driver)
0290  *
0291  * Contains data used for exporting a dmx buffer as DMABUF file descriptor.
0292  * The buffer is identified by a 'cookie' returned by DMX_QUERYBUF
0293  * (identical to the cookie used to mmap() the buffer to userspace). All
0294  * reserved fields must be set to zero. The field reserved0 is expected to
0295  * become a structure 'type' allowing an alternative layout of the structure
0296  * content. Therefore this field should not be used for any other extensions.
0297  */
0298 struct dmx_exportbuffer {
0299     __u32       index;
0300     __u32       flags;
0301     __s32       fd;
0302 };
0303 
0304 #define DMX_START                _IO('o', 41)
0305 #define DMX_STOP                 _IO('o', 42)
0306 #define DMX_SET_FILTER           _IOW('o', 43, struct dmx_sct_filter_params)
0307 #define DMX_SET_PES_FILTER       _IOW('o', 44, struct dmx_pes_filter_params)
0308 #define DMX_SET_BUFFER_SIZE      _IO('o', 45)
0309 #define DMX_GET_PES_PIDS         _IOR('o', 47, __u16[5])
0310 #define DMX_GET_STC              _IOWR('o', 50, struct dmx_stc)
0311 #define DMX_ADD_PID              _IOW('o', 51, __u16)
0312 #define DMX_REMOVE_PID           _IOW('o', 52, __u16)
0313 
0314 #if !defined(__KERNEL__)
0315 
0316 /* This is needed for legacy userspace support */
0317 typedef enum dmx_output dmx_output_t;
0318 typedef enum dmx_input dmx_input_t;
0319 typedef enum dmx_ts_pes dmx_pes_type_t;
0320 typedef struct dmx_filter dmx_filter_t;
0321 
0322 #endif
0323 
0324 #define DMX_REQBUFS              _IOWR('o', 60, struct dmx_requestbuffers)
0325 #define DMX_QUERYBUF             _IOWR('o', 61, struct dmx_buffer)
0326 #define DMX_EXPBUF               _IOWR('o', 62, struct dmx_exportbuffer)
0327 #define DMX_QBUF                 _IOWR('o', 63, struct dmx_buffer)
0328 #define DMX_DQBUF                _IOWR('o', 64, struct dmx_buffer)
0329 
0330 #endif /* _DVBDMX_H_ */