linux-headers (unknown)

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