Mauro Carvalho Chehab | afd1a0c | 2005-12-12 00:37:27 -0800 | [diff] [blame] | 1 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | * dmx.h |
| 3 | * |
| 4 | * Copyright (C) 2000 Marcus Metzler <marcus@convergence.de> |
| 5 | * & Ralph Metzler <ralph@convergence.de> |
| 6 | * for convergence integrated media GmbH |
| 7 | * |
Hamad Kadmany | d432f71 | 2013-01-17 17:36:17 +0200 | [diff] [blame] | 8 | * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved. |
Hamad Kadmany | 32cb982 | 2012-05-10 08:47:44 +0300 | [diff] [blame] | 9 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 10 | * This program is free software; you can redistribute it and/or |
| 11 | * modify it under the terms of the GNU Lesser General Public License |
| 12 | * as published by the Free Software Foundation; either version 2.1 |
| 13 | * of the License, or (at your option) any later version. |
| 14 | * |
| 15 | * This program is distributed in the hope that it will be useful, |
| 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 18 | * GNU General Public License for more details. |
| 19 | * |
| 20 | * You should have received a copy of the GNU Lesser General Public License |
| 21 | * along with this program; if not, write to the Free Software |
| 22 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 23 | * |
| 24 | */ |
| 25 | |
| 26 | #ifndef _DVBDMX_H_ |
| 27 | #define _DVBDMX_H_ |
| 28 | |
Jaswinder Singh Rajput | c86629c | 2009-01-30 19:55:32 +0530 | [diff] [blame] | 29 | #include <linux/types.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | #ifdef __KERNEL__ |
| 31 | #include <linux/time.h> |
| 32 | #else |
| 33 | #include <time.h> |
| 34 | #endif |
| 35 | |
| 36 | |
| 37 | #define DMX_FILTER_SIZE 16 |
| 38 | |
Hamad Kadmany | 4f87794 | 2012-07-15 15:06:01 +0300 | [diff] [blame] | 39 | /* Min recording chunk upon which event is generated */ |
| 40 | #define DMX_REC_BUFF_CHUNK_MIN_SIZE (100*188) |
| 41 | |
Hamad Kadmany | 168203b | 2013-01-28 15:22:46 +0200 | [diff] [blame] | 42 | #define DMX_MAX_DECODER_BUFFER_NUM (32) |
Gilad Broner | 526e57e | 2012-12-03 15:57:44 +0200 | [diff] [blame] | 43 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | typedef enum |
| 45 | { |
| 46 | DMX_OUT_DECODER, /* Streaming directly to decoder. */ |
| 47 | DMX_OUT_TAP, /* Output going to a memory buffer */ |
Mauro Carvalho Chehab | 674434c | 2005-12-12 00:37:28 -0800 | [diff] [blame] | 48 | /* (to be retrieved via the read command).*/ |
Peter Hartley | b01cd93 | 2008-04-22 14:45:36 -0300 | [diff] [blame] | 49 | DMX_OUT_TS_TAP, /* Output multiplexed into a new TS */ |
Mauro Carvalho Chehab | 674434c | 2005-12-12 00:37:28 -0800 | [diff] [blame] | 50 | /* (to be retrieved by reading from the */ |
| 51 | /* logical DVR device). */ |
Peter Hartley | b01cd93 | 2008-04-22 14:45:36 -0300 | [diff] [blame] | 52 | DMX_OUT_TSDEMUX_TAP /* Like TS_TAP but retrieved from the DMX device */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 53 | } dmx_output_t; |
| 54 | |
| 55 | |
| 56 | typedef enum |
| 57 | { |
| 58 | DMX_IN_FRONTEND, /* Input from a front-end device. */ |
| 59 | DMX_IN_DVR /* Input from the logical DVR device. */ |
| 60 | } dmx_input_t; |
| 61 | |
| 62 | |
| 63 | typedef enum |
| 64 | { |
Mauro Carvalho Chehab | afd1a0c | 2005-12-12 00:37:27 -0800 | [diff] [blame] | 65 | DMX_PES_AUDIO0, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 66 | DMX_PES_VIDEO0, |
| 67 | DMX_PES_TELETEXT0, |
| 68 | DMX_PES_SUBTITLE0, |
| 69 | DMX_PES_PCR0, |
| 70 | |
Mauro Carvalho Chehab | afd1a0c | 2005-12-12 00:37:27 -0800 | [diff] [blame] | 71 | DMX_PES_AUDIO1, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 72 | DMX_PES_VIDEO1, |
| 73 | DMX_PES_TELETEXT1, |
| 74 | DMX_PES_SUBTITLE1, |
| 75 | DMX_PES_PCR1, |
| 76 | |
Mauro Carvalho Chehab | afd1a0c | 2005-12-12 00:37:27 -0800 | [diff] [blame] | 77 | DMX_PES_AUDIO2, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 78 | DMX_PES_VIDEO2, |
| 79 | DMX_PES_TELETEXT2, |
| 80 | DMX_PES_SUBTITLE2, |
| 81 | DMX_PES_PCR2, |
| 82 | |
Mauro Carvalho Chehab | afd1a0c | 2005-12-12 00:37:27 -0800 | [diff] [blame] | 83 | DMX_PES_AUDIO3, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 84 | DMX_PES_VIDEO3, |
| 85 | DMX_PES_TELETEXT3, |
| 86 | DMX_PES_SUBTITLE3, |
| 87 | DMX_PES_PCR3, |
| 88 | |
| 89 | DMX_PES_OTHER |
| 90 | } dmx_pes_type_t; |
| 91 | |
| 92 | #define DMX_PES_AUDIO DMX_PES_AUDIO0 |
| 93 | #define DMX_PES_VIDEO DMX_PES_VIDEO0 |
| 94 | #define DMX_PES_TELETEXT DMX_PES_TELETEXT0 |
| 95 | #define DMX_PES_SUBTITLE DMX_PES_SUBTITLE0 |
| 96 | #define DMX_PES_PCR DMX_PES_PCR0 |
| 97 | |
| 98 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 99 | typedef struct dmx_filter |
| 100 | { |
| 101 | __u8 filter[DMX_FILTER_SIZE]; |
| 102 | __u8 mask[DMX_FILTER_SIZE]; |
| 103 | __u8 mode[DMX_FILTER_SIZE]; |
| 104 | } dmx_filter_t; |
| 105 | |
| 106 | |
Liron Kuch | d4cc3b0 | 2012-05-17 16:31:58 +0300 | [diff] [blame] | 107 | /* Filter flags */ |
| 108 | #define DMX_CHECK_CRC 0x01 |
| 109 | #define DMX_ONESHOT 0x02 |
| 110 | #define DMX_IMMEDIATE_START 0x04 |
| 111 | #define DMX_ENABLE_INDEXING 0x08 |
| 112 | #define DMX_KERNEL_CLIENT 0x8000 |
| 113 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 114 | struct dmx_sct_filter_params |
| 115 | { |
| 116 | __u16 pid; |
| 117 | dmx_filter_t filter; |
| 118 | __u32 timeout; |
| 119 | __u32 flags; |
Liron Kuch | d4cc3b0 | 2012-05-17 16:31:58 +0300 | [diff] [blame] | 120 | }; |
| 121 | |
| 122 | |
Hamad Kadmany | c37dee8 | 2013-04-10 18:14:48 +0300 | [diff] [blame^] | 123 | enum dmx_video_codec { |
| 124 | DMX_VIDEO_CODEC_MPEG2, |
| 125 | DMX_VIDEO_CODEC_H264, |
| 126 | DMX_VIDEO_CODEC_VC1 |
Liron Kuch | d4cc3b0 | 2012-05-17 16:31:58 +0300 | [diff] [blame] | 127 | }; |
| 128 | |
Hamad Kadmany | c37dee8 | 2013-04-10 18:14:48 +0300 | [diff] [blame^] | 129 | /* Index entries types */ |
| 130 | #define DMX_IDX_RAI 0x00000001 |
| 131 | #define DMX_IDX_PUSI 0x00000002 |
| 132 | #define DMX_IDX_MPEG_SEQ_HEADER 0x00000004 |
| 133 | #define DMX_IDX_MPEG_GOP 0x00000008 |
| 134 | #define DMX_IDX_MPEG_FIRST_SEQ_FRAME_START 0x00000010 |
| 135 | #define DMX_IDX_MPEG_FIRST_SEQ_FRAME_END 0x00000020 |
| 136 | #define DMX_IDX_MPEG_I_FRAME_START 0x00000040 |
| 137 | #define DMX_IDX_MPEG_I_FRAME_END 0x00000080 |
| 138 | #define DMX_IDX_MPEG_P_FRAME_START 0x00000100 |
| 139 | #define DMX_IDX_MPEG_P_FRAME_END 0x00000200 |
| 140 | #define DMX_IDX_MPEG_B_FRAME_START 0x00000400 |
| 141 | #define DMX_IDX_MPEG_B_FRAME_END 0x00000800 |
| 142 | #define DMX_IDX_H264_SPS 0x00001000 |
| 143 | #define DMX_IDX_H264_PPS 0x00002000 |
| 144 | #define DMX_IDX_H264_FIRST_SPS_FRAME_START 0x00004000 |
| 145 | #define DMX_IDX_H264_FIRST_SPS_FRAME_END 0x00008000 |
| 146 | #define DMX_IDX_H264_IDR_START 0x00010000 |
| 147 | #define DMX_IDX_H264_IDR_END 0x00020000 |
| 148 | #define DMX_IDX_H264_NON_IDR_START 0x00040000 |
| 149 | #define DMX_IDX_H264_NON_IDR_END 0x00080000 |
| 150 | #define DMX_IDX_VC1_SEQ_HEADER 0x00100000 |
| 151 | #define DMX_IDX_VC1_ENTRY_POINT 0x00200000 |
| 152 | #define DMX_IDX_VC1_FIRST_SEQ_FRAME_START 0x00400000 |
| 153 | #define DMX_IDX_VC1_FIRST_SEQ_FRAME_END 0x00800000 |
| 154 | #define DMX_IDX_VC1_FRAME_START 0x01000000 |
| 155 | #define DMX_IDX_VC1_FRAME_END 0x02000000 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 156 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 157 | struct dmx_pes_filter_params |
| 158 | { |
| 159 | __u16 pid; |
| 160 | dmx_input_t input; |
| 161 | dmx_output_t output; |
| 162 | dmx_pes_type_t pes_type; |
| 163 | __u32 flags; |
Liron Kuch | d4cc3b0 | 2012-05-17 16:31:58 +0300 | [diff] [blame] | 164 | |
Hamad Kadmany | 4f87794 | 2012-07-15 15:06:01 +0300 | [diff] [blame] | 165 | /* |
| 166 | * The following configures when the event |
| 167 | * DMX_EVENT_NEW_REC_CHUNK will be triggered. |
| 168 | * When new recorded data is received with size |
| 169 | * equal or larger than this value a new event |
Gilad Broner | a81f42e | 2013-04-07 16:38:47 +0300 | [diff] [blame] | 170 | * will be triggered. This is relevant when |
Hamad Kadmany | 4f87794 | 2012-07-15 15:06:01 +0300 | [diff] [blame] | 171 | * output is DMX_OUT_TS_TAP or DMX_OUT_TSDEMUX_TAP, |
| 172 | * size must be at least DMX_REC_BUFF_CHUNK_MIN_SIZE |
| 173 | * and smaller than buffer size. |
| 174 | */ |
| 175 | __u32 rec_chunk_size; |
| 176 | |
Hamad Kadmany | c37dee8 | 2013-04-10 18:14:48 +0300 | [diff] [blame^] | 177 | enum dmx_video_codec video_codec; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 178 | }; |
| 179 | |
Hamad Kadmany | 32cb982 | 2012-05-10 08:47:44 +0300 | [diff] [blame] | 180 | struct dmx_buffer_status { |
| 181 | /* size of buffer in bytes */ |
| 182 | unsigned int size; |
| 183 | |
| 184 | /* fullness of buffer in bytes */ |
| 185 | unsigned int fullness; |
| 186 | |
| 187 | /* |
| 188 | * How many bytes are free |
| 189 | * It's the same as: size-fullness-1 |
| 190 | */ |
| 191 | unsigned int free_bytes; |
| 192 | |
| 193 | /* read pointer offset in bytes */ |
| 194 | unsigned int read_offset; |
| 195 | |
| 196 | /* write pointer offset in bytes */ |
| 197 | unsigned int write_offset; |
| 198 | |
| 199 | /* non-zero if data error occured */ |
| 200 | int error; |
| 201 | }; |
| 202 | |
Hamad Kadmany | 4f87794 | 2012-07-15 15:06:01 +0300 | [diff] [blame] | 203 | /* Events associated with each demux filter */ |
| 204 | enum dmx_event { |
| 205 | /* New PES packet is ready to be consumed */ |
Hamad Kadmany | a0a00f5 | 2013-03-19 10:11:45 +0200 | [diff] [blame] | 206 | DMX_EVENT_NEW_PES = 0x00000001, |
Hamad Kadmany | 4f87794 | 2012-07-15 15:06:01 +0300 | [diff] [blame] | 207 | |
| 208 | /* New section is ready to be consumed */ |
Hamad Kadmany | a0a00f5 | 2013-03-19 10:11:45 +0200 | [diff] [blame] | 209 | DMX_EVENT_NEW_SECTION = 0x00000002, |
Hamad Kadmany | 4f87794 | 2012-07-15 15:06:01 +0300 | [diff] [blame] | 210 | |
| 211 | /* New recording chunk is ready to be consumed */ |
Hamad Kadmany | a0a00f5 | 2013-03-19 10:11:45 +0200 | [diff] [blame] | 212 | DMX_EVENT_NEW_REC_CHUNK = 0x00000004, |
Hamad Kadmany | 4f87794 | 2012-07-15 15:06:01 +0300 | [diff] [blame] | 213 | |
| 214 | /* New PCR value is ready */ |
Hamad Kadmany | a0a00f5 | 2013-03-19 10:11:45 +0200 | [diff] [blame] | 215 | DMX_EVENT_NEW_PCR = 0x00000008, |
Hamad Kadmany | 4f87794 | 2012-07-15 15:06:01 +0300 | [diff] [blame] | 216 | |
| 217 | /* Overflow */ |
Hamad Kadmany | a0a00f5 | 2013-03-19 10:11:45 +0200 | [diff] [blame] | 218 | DMX_EVENT_BUFFER_OVERFLOW = 0x00000010, |
Hamad Kadmany | 4f87794 | 2012-07-15 15:06:01 +0300 | [diff] [blame] | 219 | |
| 220 | /* Section was dropped due to CRC error */ |
Hamad Kadmany | a0a00f5 | 2013-03-19 10:11:45 +0200 | [diff] [blame] | 221 | DMX_EVENT_SECTION_CRC_ERROR = 0x00000020, |
Hamad Kadmany | 4f87794 | 2012-07-15 15:06:01 +0300 | [diff] [blame] | 222 | |
| 223 | /* End-of-stream, no more data from this filter */ |
Hamad Kadmany | a0a00f5 | 2013-03-19 10:11:45 +0200 | [diff] [blame] | 224 | DMX_EVENT_EOS = 0x00000040, |
Liron Kuch | 41543b7 | 2012-11-26 13:27:22 +0200 | [diff] [blame] | 225 | |
| 226 | /* New Elementary Stream data is ready */ |
Gilad Broner | a81f42e | 2013-04-07 16:38:47 +0300 | [diff] [blame] | 227 | DMX_EVENT_NEW_ES_DATA = 0x00000080, |
| 228 | |
| 229 | /* Data markers */ |
| 230 | DMX_EVENT_MARKER = 0x00000100 |
| 231 | }; |
| 232 | |
| 233 | enum dmx_oob_cmd { |
| 234 | /* End-of-stream, no more data from this filter */ |
| 235 | DMX_OOB_CMD_EOS, |
| 236 | |
| 237 | /* Data markers */ |
| 238 | DMX_OOB_CMD_MARKER, |
Hamad Kadmany | 4f87794 | 2012-07-15 15:06:01 +0300 | [diff] [blame] | 239 | }; |
| 240 | |
| 241 | /* Flags passed in filter events */ |
| 242 | |
| 243 | /* Continuity counter error was detected */ |
| 244 | #define DMX_FILTER_CC_ERROR 0x01 |
| 245 | |
| 246 | /* Discontinuity indicator was set */ |
Liron Kuch | 41543b7 | 2012-11-26 13:27:22 +0200 | [diff] [blame] | 247 | #define DMX_FILTER_DISCONTINUITY_INDICATOR 0x02 |
Hamad Kadmany | 4f87794 | 2012-07-15 15:06:01 +0300 | [diff] [blame] | 248 | |
| 249 | /* PES legnth in PES header is not correct */ |
| 250 | #define DMX_FILTER_PES_LENGTH_ERROR 0x04 |
| 251 | |
| 252 | |
| 253 | /* PES info associated with DMX_EVENT_NEW_PES event */ |
| 254 | struct dmx_pes_event_info { |
| 255 | /* Offset at which PES information starts */ |
| 256 | __u32 base_offset; |
| 257 | |
| 258 | /* |
| 259 | * Start offset at which PES data |
| 260 | * from the stream starts. |
| 261 | * Equal to base_offset if PES data |
| 262 | * starts from the beginning. |
| 263 | */ |
| 264 | __u32 start_offset; |
| 265 | |
| 266 | /* Total length holding the PES information */ |
| 267 | __u32 total_length; |
| 268 | |
| 269 | /* Actual length holding the PES data */ |
| 270 | __u32 actual_length; |
| 271 | |
| 272 | /* Local receiver timestamp in 27MHz */ |
| 273 | __u64 stc; |
| 274 | |
| 275 | /* Flags passed in filter events */ |
| 276 | __u32 flags; |
Hamad Kadmany | d432f71 | 2013-01-17 17:36:17 +0200 | [diff] [blame] | 277 | |
| 278 | /* |
| 279 | * Number of TS packets with Transport Error Indicator (TEI) |
| 280 | * found while constructing the PES. |
| 281 | */ |
| 282 | __u32 transport_error_indicator_counter; |
| 283 | |
| 284 | /* Number of continuity errors found while constructing the PES */ |
| 285 | __u32 continuity_error_counter; |
| 286 | |
| 287 | /* Total number of TS packets holding the PES */ |
| 288 | __u32 ts_packets_num; |
Hamad Kadmany | 4f87794 | 2012-07-15 15:06:01 +0300 | [diff] [blame] | 289 | }; |
| 290 | |
| 291 | /* Section info associated with DMX_EVENT_NEW_SECTION event */ |
| 292 | struct dmx_section_event_info { |
| 293 | /* Offset at which section information starts */ |
| 294 | __u32 base_offset; |
| 295 | |
| 296 | /* |
| 297 | * Start offset at which section data |
| 298 | * from the stream starts. |
| 299 | * Equal to base_offset if section data |
| 300 | * starts from the beginning. |
| 301 | */ |
| 302 | __u32 start_offset; |
| 303 | |
| 304 | /* Total length holding the section information */ |
| 305 | __u32 total_length; |
| 306 | |
| 307 | /* Actual length holding the section data */ |
| 308 | __u32 actual_length; |
| 309 | |
| 310 | /* Flags passed in filter events */ |
| 311 | __u32 flags; |
| 312 | }; |
| 313 | |
| 314 | /* Recording info associated with DMX_EVENT_NEW_REC_CHUNK event */ |
| 315 | struct dmx_rec_chunk_event_info { |
| 316 | /* Offset at which recording chunk starts */ |
| 317 | __u32 offset; |
| 318 | |
| 319 | /* Size of recording chunk in bytes */ |
| 320 | __u32 size; |
| 321 | }; |
| 322 | |
| 323 | /* PCR info associated with DMX_EVENT_NEW_PCR event */ |
| 324 | struct dmx_pcr_event_info { |
| 325 | /* Local timestamp in 27MHz |
| 326 | * when PCR packet was received |
| 327 | */ |
| 328 | __u64 stc; |
| 329 | |
| 330 | /* PCR value in 27MHz */ |
| 331 | __u64 pcr; |
| 332 | |
| 333 | /* Flags passed in filter events */ |
| 334 | __u32 flags; |
| 335 | }; |
| 336 | |
| 337 | /* |
Liron Kuch | 41543b7 | 2012-11-26 13:27:22 +0200 | [diff] [blame] | 338 | * Elementary stream data information associated |
| 339 | * with DMX_EVENT_NEW_ES_DATA event |
| 340 | */ |
| 341 | struct dmx_es_data_event_info { |
| 342 | /* Buffer user-space handle */ |
| 343 | int buf_handle; |
| 344 | |
| 345 | /* |
| 346 | * Cookie to provide when releasing the buffer |
| 347 | * using the DMX_RELEASE_DECODER_BUFFER ioctl command |
| 348 | */ |
| 349 | int cookie; |
| 350 | |
| 351 | /* Offset of data from the beginning of the buffer */ |
| 352 | __u32 offset; |
| 353 | |
| 354 | /* Length of data in buffer (in bytes) */ |
| 355 | __u32 data_len; |
| 356 | |
| 357 | /* Indication whether PTS value is valid */ |
| 358 | int pts_valid; |
| 359 | |
| 360 | /* PTS value associated with the buffer */ |
| 361 | __u64 pts; |
| 362 | |
| 363 | /* Indication whether DTS value is valid */ |
| 364 | int dts_valid; |
| 365 | |
| 366 | /* DTS value associated with the buffer */ |
| 367 | __u64 dts; |
| 368 | |
| 369 | /* |
| 370 | * Number of TS packets with Transport Error Indicator (TEI) set |
| 371 | * in the TS packet header since last reported event |
| 372 | */ |
| 373 | __u32 transport_error_indicator_counter; |
| 374 | |
| 375 | /* Number of continuity errors since last reported event */ |
| 376 | __u32 continuity_error_counter; |
| 377 | |
| 378 | /* Total number of TS packets processed since last reported event */ |
| 379 | __u32 ts_packets_num; |
| 380 | |
| 381 | /* |
| 382 | * Number of dropped bytes due to insufficient buffer space, |
| 383 | * since last reported event |
| 384 | */ |
| 385 | __u32 ts_dropped_bytes; |
| 386 | }; |
| 387 | |
Gilad Broner | a81f42e | 2013-04-07 16:38:47 +0300 | [diff] [blame] | 388 | /* Marker details associated with DMX_EVENT_MARKER event */ |
| 389 | struct dmx_marker_event_info { |
| 390 | /* Marker id */ |
| 391 | __u64 id; |
| 392 | }; |
| 393 | |
Liron Kuch | 41543b7 | 2012-11-26 13:27:22 +0200 | [diff] [blame] | 394 | /* |
Hamad Kadmany | 4f87794 | 2012-07-15 15:06:01 +0300 | [diff] [blame] | 395 | * Filter's event returned through DMX_GET_EVENT. |
| 396 | * poll with POLLPRI would block until events are available. |
| 397 | */ |
| 398 | struct dmx_filter_event { |
| 399 | enum dmx_event type; |
| 400 | |
| 401 | union { |
| 402 | struct dmx_pes_event_info pes; |
| 403 | struct dmx_section_event_info section; |
| 404 | struct dmx_rec_chunk_event_info recording_chunk; |
| 405 | struct dmx_pcr_event_info pcr; |
Liron Kuch | 41543b7 | 2012-11-26 13:27:22 +0200 | [diff] [blame] | 406 | struct dmx_es_data_event_info es_data; |
Gilad Broner | a81f42e | 2013-04-07 16:38:47 +0300 | [diff] [blame] | 407 | struct dmx_marker_event_info marker; |
Hamad Kadmany | 4f87794 | 2012-07-15 15:06:01 +0300 | [diff] [blame] | 408 | } params; |
| 409 | }; |
| 410 | |
Hamad Kadmany | ec6202d | 2012-09-20 07:58:57 +0300 | [diff] [blame] | 411 | /* Filter's buffer requirement returned in dmx_caps */ |
| 412 | struct dmx_buffer_requirement { |
| 413 | /* Buffer size alignment, 0 means no special requirement */ |
| 414 | __u32 size_alignment; |
| 415 | |
| 416 | /* Maximum buffer size allowed */ |
| 417 | __u32 max_size; |
Gilad Broner | 526e57e | 2012-12-03 15:57:44 +0200 | [diff] [blame] | 418 | |
| 419 | /* Maximum number of linear buffers handled by demux */ |
| 420 | __u32 max_buffer_num; |
| 421 | |
| 422 | /* Feature support bitmap as detailed below */ |
Hamad Kadmany | ec6202d | 2012-09-20 07:58:57 +0300 | [diff] [blame] | 423 | __u32 flags; |
| 424 | |
Gilad Broner | 526e57e | 2012-12-03 15:57:44 +0200 | [diff] [blame] | 425 | /* Buffer must be allocated as physically contiguous memory */ |
| 426 | #define DMX_BUFFER_CONTIGUOUS_MEM 0x1 |
Hamad Kadmany | ec6202d | 2012-09-20 07:58:57 +0300 | [diff] [blame] | 427 | |
| 428 | /* If the filter's data is decrypted, the buffer should be secured one */ |
| 429 | #define DMX_BUFFER_SECURED_IF_DECRYPTED 0x2 |
Gilad Broner | 526e57e | 2012-12-03 15:57:44 +0200 | [diff] [blame] | 430 | |
| 431 | /* Buffer can be allocated externally */ |
| 432 | #define DMX_BUFFER_EXTERNAL_SUPPORT 0x4 |
| 433 | |
| 434 | /* Buffer can be allocated internally */ |
| 435 | #define DMX_BUFFER_INTERNAL_SUPPORT 0x8 |
| 436 | |
| 437 | /* Filter output can be output to a linear buffer group */ |
| 438 | #define DMX_BUFFER_LINEAR_GROUP_SUPPORT 0x10 |
Hamad Kadmany | ec6202d | 2012-09-20 07:58:57 +0300 | [diff] [blame] | 439 | }; |
| 440 | |
Gilad Broner | a81f42e | 2013-04-07 16:38:47 +0300 | [diff] [blame] | 441 | /* Out-of-band (OOB) command */ |
| 442 | struct dmx_oob_command { |
| 443 | enum dmx_oob_cmd type; |
| 444 | |
| 445 | union { |
| 446 | struct dmx_marker_event_info marker; |
| 447 | } params; |
| 448 | }; |
| 449 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 450 | typedef struct dmx_caps { |
| 451 | __u32 caps; |
Hamad Kadmany | d2c325e | 2012-05-28 13:52:49 +0300 | [diff] [blame] | 452 | |
| 453 | /* Indicates whether demux support playback from memory in pull mode */ |
| 454 | #define DMX_CAP_PULL_MODE 0x01 |
| 455 | |
| 456 | /* Indicates whether demux support indexing of recorded video stream */ |
| 457 | #define DMX_CAP_VIDEO_INDEXING 0x02 |
| 458 | |
| 459 | /* Indicates whether demux support sending data directly to video decoder */ |
| 460 | #define DMX_CAP_VIDEO_DECODER_DATA 0x04 |
| 461 | |
| 462 | /* Indicates whether demux support sending data directly to audio decoder */ |
| 463 | #define DMX_CAP_AUDIO_DECODER_DATA 0x08 |
| 464 | |
| 465 | /* Indicates whether demux support sending data directly to subtitle decoder */ |
| 466 | #define DMX_CAP_SUBTITLE_DECODER_DATA 0x10 |
| 467 | |
| 468 | /* Number of decoders demux can output data to */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 469 | int num_decoders; |
Hamad Kadmany | d2c325e | 2012-05-28 13:52:49 +0300 | [diff] [blame] | 470 | |
| 471 | /* Number of demux devices */ |
| 472 | int num_demux_devices; |
| 473 | |
| 474 | /* Max number of PID filters */ |
| 475 | int num_pid_filters; |
| 476 | |
| 477 | /* Max number of section filters */ |
| 478 | int num_section_filters; |
| 479 | |
| 480 | /* |
| 481 | * Max number of section filters using same PID, |
| 482 | * 0 if not supported |
| 483 | */ |
| 484 | int num_section_filters_per_pid; |
| 485 | |
| 486 | /* |
| 487 | * Length of section filter, not including section |
| 488 | * length field (2 bytes). |
| 489 | */ |
| 490 | int section_filter_length; |
| 491 | |
| 492 | /* Max number of demod based input */ |
| 493 | int num_demod_inputs; |
| 494 | |
| 495 | /* Max number of memory based input */ |
| 496 | int num_memory_inputs; |
| 497 | |
| 498 | /* Overall bitrate from all inputs concurrently. Mbit/sec */ |
| 499 | int max_bitrate; |
| 500 | |
| 501 | /* Max bitrate from single demod input. Mbit/sec */ |
| 502 | int demod_input_max_bitrate; |
| 503 | |
| 504 | /* Max bitrate from single memory input. Mbit/sec */ |
| 505 | int memory_input_max_bitrate; |
Hamad Kadmany | ec6202d | 2012-09-20 07:58:57 +0300 | [diff] [blame] | 506 | |
| 507 | struct dmx_buffer_requirement section; |
| 508 | |
| 509 | /* For PES not sent to decoder */ |
| 510 | struct dmx_buffer_requirement pes; |
| 511 | |
Gilad Broner | 526e57e | 2012-12-03 15:57:44 +0200 | [diff] [blame] | 512 | /* For PES sent to decoder */ |
| 513 | struct dmx_buffer_requirement decoder; |
| 514 | |
Hamad Kadmany | ec6202d | 2012-09-20 07:58:57 +0300 | [diff] [blame] | 515 | /* Recording buffer for recording of 188 bytes packets */ |
| 516 | struct dmx_buffer_requirement recording_188_tsp; |
| 517 | |
| 518 | /* Recording buffer for recording of 192 bytes packets */ |
| 519 | struct dmx_buffer_requirement recording_192_tsp; |
| 520 | |
| 521 | /* DVR input buffer for playback of 188 bytes packets */ |
| 522 | struct dmx_buffer_requirement playback_188_tsp; |
| 523 | |
| 524 | /* DVR input buffer for playback of 192 bytes packets */ |
| 525 | struct dmx_buffer_requirement playback_192_tsp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 526 | } dmx_caps_t; |
| 527 | |
| 528 | typedef enum { |
| 529 | DMX_SOURCE_FRONT0 = 0, |
| 530 | DMX_SOURCE_FRONT1, |
| 531 | DMX_SOURCE_FRONT2, |
| 532 | DMX_SOURCE_FRONT3, |
| 533 | DMX_SOURCE_DVR0 = 16, |
| 534 | DMX_SOURCE_DVR1, |
| 535 | DMX_SOURCE_DVR2, |
| 536 | DMX_SOURCE_DVR3 |
| 537 | } dmx_source_t; |
| 538 | |
Hamad Kadmany | 32cb982 | 2012-05-10 08:47:44 +0300 | [diff] [blame] | 539 | enum dmx_tsp_format_t { |
| 540 | DMX_TSP_FORMAT_188 = 0, |
| 541 | DMX_TSP_FORMAT_192_TAIL, |
| 542 | DMX_TSP_FORMAT_192_HEAD, |
| 543 | DMX_TSP_FORMAT_204, |
| 544 | }; |
| 545 | |
| 546 | enum dmx_playback_mode_t { |
| 547 | /* |
| 548 | * In push mode, if one of output buffers |
| 549 | * is full, the buffer would overflow |
| 550 | * and demux continue processing incoming stream. |
| 551 | * This is the default mode. When playing from frontend, |
| 552 | * this is the only mode that is allowed. |
| 553 | */ |
| 554 | DMX_PB_MODE_PUSH = 0, |
| 555 | |
| 556 | /* |
| 557 | * In pull mode, if one of output buffers |
| 558 | * is full, demux stalls waiting for free space, |
| 559 | * this would cause DVR input buffer fullness |
| 560 | * to accumulate. |
| 561 | * This mode is possible only when playing |
| 562 | * from DVR. |
| 563 | */ |
| 564 | DMX_PB_MODE_PULL, |
| 565 | }; |
| 566 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 567 | struct dmx_stc { |
Gilad Broner | 526e57e | 2012-12-03 15:57:44 +0200 | [diff] [blame] | 568 | unsigned int num; /* input : which STC? 0..N */ |
| 569 | unsigned int base; /* output: divisor for stc to get 90 kHz clock */ |
| 570 | __u64 stc; /* output: stc in 'base'*90 kHz units */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 571 | }; |
| 572 | |
Hamad Kadmany | ec6202d | 2012-09-20 07:58:57 +0300 | [diff] [blame] | 573 | enum dmx_buffer_mode { |
| 574 | /* |
| 575 | * demux buffers are allocated internally |
| 576 | * by the demux driver. This is the default mode. |
| 577 | * DMX_SET_BUFFER_SIZE can be used to set the size of |
| 578 | * this buffer. |
| 579 | */ |
| 580 | DMX_BUFFER_MODE_INTERNAL, |
| 581 | |
| 582 | /* |
| 583 | * demux buffers are allocated externally and provided |
| 584 | * to demux through DMX_SET_BUFFER. |
| 585 | * When this mode is used DMX_SET_BUFFER_SIZE and |
| 586 | * mmap are prohibited. |
| 587 | */ |
| 588 | DMX_BUFFER_MODE_EXTERNAL, |
| 589 | }; |
| 590 | |
| 591 | struct dmx_buffer { |
| 592 | unsigned int size; |
| 593 | int handle; |
| 594 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 595 | |
Gilad Broner | 526e57e | 2012-12-03 15:57:44 +0200 | [diff] [blame] | 596 | struct dmx_decoder_buffers { |
| 597 | /* |
| 598 | * Specify if linear buffer support is requested. If set, buffers_num |
| 599 | * must be greater than 1 |
| 600 | */ |
| 601 | int is_linear; |
| 602 | |
| 603 | /* |
| 604 | * Specify number of external buffers allocated by user. |
| 605 | * If set to 0 means internal buffer allocation is requested |
| 606 | */ |
| 607 | __u32 buffers_num; |
| 608 | |
| 609 | /* Specify buffer size, either external or internal */ |
| 610 | __u32 buffers_size; |
| 611 | |
| 612 | /* Array of externally allocated buffer handles */ |
| 613 | int handles[DMX_MAX_DECODER_BUFFER_NUM]; |
| 614 | }; |
| 615 | |
Hamad Kadmany | 168203b | 2013-01-28 15:22:46 +0200 | [diff] [blame] | 616 | struct dmx_secure_mode { |
| 617 | /* |
| 618 | * Specifies whether secure mode should be set or not for the filter's |
| 619 | * pid. Note that DMX_OUT_TSDEMUX_TAP filters can have more than 1 pid |
| 620 | */ |
| 621 | int is_secured; |
| 622 | |
| 623 | /* PID to associate with key ladder id */ |
| 624 | __u16 pid; |
| 625 | |
| 626 | /* key ladder information to associate with the specified pid */ |
| 627 | __u32 key_ladder_id; |
| 628 | }; |
| 629 | |
Hamad Kadmany | a0a00f5 | 2013-03-19 10:11:45 +0200 | [diff] [blame] | 630 | struct dmx_events_mask { |
| 631 | /* |
| 632 | * Bitmask of events to be disabled (dmx_event). |
| 633 | * Disabled events will not be notified to the user. |
| 634 | * By default all events are enabled except for |
| 635 | * DMX_EVENT_NEW_ES_DATA. |
| 636 | * Overflow event can't be disabled. |
| 637 | */ |
| 638 | __u32 disable_mask; |
| 639 | |
| 640 | /* |
| 641 | * Bitmask of events that will not wake-up the user |
| 642 | * when user calls poll with POLLPRI flag. |
| 643 | * Events that are used as wake-up source should not be |
| 644 | * disabled in disable_mask or they would not be used |
| 645 | * as a wake-up source. |
| 646 | * By default all enabled events are set as wake-up events. |
| 647 | * Overflow event can't be disabled as a wake-up source. |
| 648 | */ |
| 649 | __u32 no_wakeup_mask; |
| 650 | |
| 651 | /* |
| 652 | * Number of ready wake-up events which will trigger |
| 653 | * a wake-up when user calls poll with POLLPRI flag. |
| 654 | * Default is set to 1. |
| 655 | */ |
| 656 | __u32 wakeup_threshold; |
| 657 | }; |
| 658 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 659 | #define DMX_START _IO('o', 41) |
| 660 | #define DMX_STOP _IO('o', 42) |
| 661 | #define DMX_SET_FILTER _IOW('o', 43, struct dmx_sct_filter_params) |
| 662 | #define DMX_SET_PES_FILTER _IOW('o', 44, struct dmx_pes_filter_params) |
| 663 | #define DMX_SET_BUFFER_SIZE _IO('o', 45) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 664 | #define DMX_GET_PES_PIDS _IOR('o', 47, __u16[5]) |
| 665 | #define DMX_GET_CAPS _IOR('o', 48, dmx_caps_t) |
| 666 | #define DMX_SET_SOURCE _IOW('o', 49, dmx_source_t) |
| 667 | #define DMX_GET_STC _IOWR('o', 50, struct dmx_stc) |
Andreas Oberritter | 1cb662a | 2009-07-14 20:28:50 -0300 | [diff] [blame] | 668 | #define DMX_ADD_PID _IOW('o', 51, __u16) |
| 669 | #define DMX_REMOVE_PID _IOW('o', 52, __u16) |
Hamad Kadmany | 32cb982 | 2012-05-10 08:47:44 +0300 | [diff] [blame] | 670 | #define DMX_SET_TS_PACKET_FORMAT _IOW('o', 53, enum dmx_tsp_format_t) |
| 671 | #define DMX_SET_TS_OUT_FORMAT _IOW('o', 54, enum dmx_tsp_format_t) |
| 672 | #define DMX_SET_DECODER_BUFFER_SIZE _IO('o', 55) |
| 673 | #define DMX_GET_BUFFER_STATUS _IOR('o', 56, struct dmx_buffer_status) |
| 674 | #define DMX_RELEASE_DATA _IO('o', 57) |
| 675 | #define DMX_FEED_DATA _IO('o', 58) |
| 676 | #define DMX_SET_PLAYBACK_MODE _IOW('o', 59, enum dmx_playback_mode_t) |
Liron Kuch | 41543b7 | 2012-11-26 13:27:22 +0200 | [diff] [blame] | 677 | #define DMX_GET_EVENT _IOR('o', 60, struct dmx_filter_event) |
| 678 | #define DMX_SET_BUFFER_MODE _IOW('o', 61, enum dmx_buffer_mode) |
| 679 | #define DMX_SET_BUFFER _IOW('o', 62, struct dmx_buffer) |
Gilad Broner | 526e57e | 2012-12-03 15:57:44 +0200 | [diff] [blame] | 680 | #define DMX_SET_DECODER_BUFFER _IOW('o', 63, struct dmx_decoder_buffers) |
Liron Kuch | 41543b7 | 2012-11-26 13:27:22 +0200 | [diff] [blame] | 681 | #define DMX_REUSE_DECODER_BUFFER _IO('o', 64) |
Hamad Kadmany | 168203b | 2013-01-28 15:22:46 +0200 | [diff] [blame] | 682 | #define DMX_SET_SECURE_MODE _IOW('o', 65, struct dmx_secure_mode) |
Hamad Kadmany | a0a00f5 | 2013-03-19 10:11:45 +0200 | [diff] [blame] | 683 | #define DMX_SET_EVENTS_MASK _IOW('o', 66, struct dmx_events_mask) |
| 684 | #define DMX_GET_EVENTS_MASK _IOR('o', 67, struct dmx_events_mask) |
Gilad Broner | a81f42e | 2013-04-07 16:38:47 +0300 | [diff] [blame] | 685 | #define DMX_PUSH_OOB_COMMAND _IOW('o', 68, struct dmx_oob_command) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 686 | |
| 687 | #endif /*_DVBDMX_H_*/ |