dmx.h 10 KB

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