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 | 32cb982 | 2012-05-10 08:47:44 +0300 | [diff] [blame] | 8 | * Copyright (c) 2012, Code Aurora Forum. All rights reserved. |
| 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 | |
| 39 | typedef enum |
| 40 | { |
| 41 | DMX_OUT_DECODER, /* Streaming directly to decoder. */ |
| 42 | DMX_OUT_TAP, /* Output going to a memory buffer */ |
Mauro Carvalho Chehab | 674434c | 2005-12-12 00:37:28 -0800 | [diff] [blame] | 43 | /* (to be retrieved via the read command).*/ |
Peter Hartley | b01cd93 | 2008-04-22 14:45:36 -0300 | [diff] [blame] | 44 | DMX_OUT_TS_TAP, /* Output multiplexed into a new TS */ |
Mauro Carvalho Chehab | 674434c | 2005-12-12 00:37:28 -0800 | [diff] [blame] | 45 | /* (to be retrieved by reading from the */ |
| 46 | /* logical DVR device). */ |
Peter Hartley | b01cd93 | 2008-04-22 14:45:36 -0300 | [diff] [blame] | 47 | 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] | 48 | } dmx_output_t; |
| 49 | |
| 50 | |
| 51 | typedef enum |
| 52 | { |
| 53 | DMX_IN_FRONTEND, /* Input from a front-end device. */ |
| 54 | DMX_IN_DVR /* Input from the logical DVR device. */ |
| 55 | } dmx_input_t; |
| 56 | |
| 57 | |
| 58 | typedef enum |
| 59 | { |
Mauro Carvalho Chehab | afd1a0c | 2005-12-12 00:37:27 -0800 | [diff] [blame] | 60 | DMX_PES_AUDIO0, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 61 | DMX_PES_VIDEO0, |
| 62 | DMX_PES_TELETEXT0, |
| 63 | DMX_PES_SUBTITLE0, |
| 64 | DMX_PES_PCR0, |
| 65 | |
Mauro Carvalho Chehab | afd1a0c | 2005-12-12 00:37:27 -0800 | [diff] [blame] | 66 | DMX_PES_AUDIO1, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 67 | DMX_PES_VIDEO1, |
| 68 | DMX_PES_TELETEXT1, |
| 69 | DMX_PES_SUBTITLE1, |
| 70 | DMX_PES_PCR1, |
| 71 | |
Mauro Carvalho Chehab | afd1a0c | 2005-12-12 00:37:27 -0800 | [diff] [blame] | 72 | DMX_PES_AUDIO2, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 73 | DMX_PES_VIDEO2, |
| 74 | DMX_PES_TELETEXT2, |
| 75 | DMX_PES_SUBTITLE2, |
| 76 | DMX_PES_PCR2, |
| 77 | |
Mauro Carvalho Chehab | afd1a0c | 2005-12-12 00:37:27 -0800 | [diff] [blame] | 78 | DMX_PES_AUDIO3, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 79 | DMX_PES_VIDEO3, |
| 80 | DMX_PES_TELETEXT3, |
| 81 | DMX_PES_SUBTITLE3, |
| 82 | DMX_PES_PCR3, |
| 83 | |
| 84 | DMX_PES_OTHER |
| 85 | } dmx_pes_type_t; |
| 86 | |
| 87 | #define DMX_PES_AUDIO DMX_PES_AUDIO0 |
| 88 | #define DMX_PES_VIDEO DMX_PES_VIDEO0 |
| 89 | #define DMX_PES_TELETEXT DMX_PES_TELETEXT0 |
| 90 | #define DMX_PES_SUBTITLE DMX_PES_SUBTITLE0 |
| 91 | #define DMX_PES_PCR DMX_PES_PCR0 |
| 92 | |
| 93 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 94 | typedef struct dmx_filter |
| 95 | { |
| 96 | __u8 filter[DMX_FILTER_SIZE]; |
| 97 | __u8 mask[DMX_FILTER_SIZE]; |
| 98 | __u8 mode[DMX_FILTER_SIZE]; |
| 99 | } dmx_filter_t; |
| 100 | |
| 101 | |
Liron Kuch | d4cc3b0 | 2012-05-17 16:31:58 +0300 | [diff] [blame] | 102 | /* Filter flags */ |
| 103 | #define DMX_CHECK_CRC 0x01 |
| 104 | #define DMX_ONESHOT 0x02 |
| 105 | #define DMX_IMMEDIATE_START 0x04 |
| 106 | #define DMX_ENABLE_INDEXING 0x08 |
| 107 | #define DMX_KERNEL_CLIENT 0x8000 |
| 108 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 109 | struct dmx_sct_filter_params |
| 110 | { |
| 111 | __u16 pid; |
| 112 | dmx_filter_t filter; |
| 113 | __u32 timeout; |
| 114 | __u32 flags; |
Liron Kuch | d4cc3b0 | 2012-05-17 16:31:58 +0300 | [diff] [blame] | 115 | }; |
| 116 | |
| 117 | |
| 118 | /* Indexing: supported video standards */ |
| 119 | enum dmx_indexing_video_standard { |
| 120 | DMX_INDEXING_MPEG2, |
| 121 | DMX_INDEXING_H264, |
| 122 | DMX_INDEXING_VC1 |
| 123 | }; |
| 124 | |
| 125 | /* Indexing: Supported video profiles */ |
| 126 | enum dmx_indexing_video_profile { |
| 127 | DMX_INDEXING_MPEG2_ANY, |
| 128 | DMX_INDEXING_H264_ANY, |
| 129 | DMX_INDEXING_VC1_ANY |
| 130 | }; |
| 131 | |
| 132 | /* Indexing: video configuration parameters */ |
| 133 | struct dmx_indexing_video_params { |
| 134 | enum dmx_indexing_video_standard standard; |
| 135 | enum dmx_indexing_video_profile profile; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 136 | }; |
| 137 | |
| 138 | |
| 139 | struct dmx_pes_filter_params |
| 140 | { |
| 141 | __u16 pid; |
| 142 | dmx_input_t input; |
| 143 | dmx_output_t output; |
| 144 | dmx_pes_type_t pes_type; |
| 145 | __u32 flags; |
Liron Kuch | d4cc3b0 | 2012-05-17 16:31:58 +0300 | [diff] [blame] | 146 | |
| 147 | struct dmx_indexing_video_params video_params; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 148 | }; |
| 149 | |
Hamad Kadmany | 32cb982 | 2012-05-10 08:47:44 +0300 | [diff] [blame] | 150 | struct dmx_buffer_status { |
| 151 | /* size of buffer in bytes */ |
| 152 | unsigned int size; |
| 153 | |
| 154 | /* fullness of buffer in bytes */ |
| 155 | unsigned int fullness; |
| 156 | |
| 157 | /* |
| 158 | * How many bytes are free |
| 159 | * It's the same as: size-fullness-1 |
| 160 | */ |
| 161 | unsigned int free_bytes; |
| 162 | |
| 163 | /* read pointer offset in bytes */ |
| 164 | unsigned int read_offset; |
| 165 | |
| 166 | /* write pointer offset in bytes */ |
| 167 | unsigned int write_offset; |
| 168 | |
| 169 | /* non-zero if data error occured */ |
| 170 | int error; |
| 171 | }; |
| 172 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 173 | typedef struct dmx_caps { |
| 174 | __u32 caps; |
Hamad Kadmany | d2c325e | 2012-05-28 13:52:49 +0300 | [diff] [blame^] | 175 | |
| 176 | /* Indicates whether demux support playback from memory in pull mode */ |
| 177 | #define DMX_CAP_PULL_MODE 0x01 |
| 178 | |
| 179 | /* Indicates whether demux support indexing of recorded video stream */ |
| 180 | #define DMX_CAP_VIDEO_INDEXING 0x02 |
| 181 | |
| 182 | /* Indicates whether demux support sending data directly to video decoder */ |
| 183 | #define DMX_CAP_VIDEO_DECODER_DATA 0x04 |
| 184 | |
| 185 | /* Indicates whether demux support sending data directly to audio decoder */ |
| 186 | #define DMX_CAP_AUDIO_DECODER_DATA 0x08 |
| 187 | |
| 188 | /* Indicates whether demux support sending data directly to subtitle decoder */ |
| 189 | #define DMX_CAP_SUBTITLE_DECODER_DATA 0x10 |
| 190 | |
| 191 | /* Number of decoders demux can output data to */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 192 | int num_decoders; |
Hamad Kadmany | d2c325e | 2012-05-28 13:52:49 +0300 | [diff] [blame^] | 193 | |
| 194 | /* Number of demux devices */ |
| 195 | int num_demux_devices; |
| 196 | |
| 197 | /* Max number of PID filters */ |
| 198 | int num_pid_filters; |
| 199 | |
| 200 | /* Max number of section filters */ |
| 201 | int num_section_filters; |
| 202 | |
| 203 | /* |
| 204 | * Max number of section filters using same PID, |
| 205 | * 0 if not supported |
| 206 | */ |
| 207 | int num_section_filters_per_pid; |
| 208 | |
| 209 | /* |
| 210 | * Length of section filter, not including section |
| 211 | * length field (2 bytes). |
| 212 | */ |
| 213 | int section_filter_length; |
| 214 | |
| 215 | /* Max number of demod based input */ |
| 216 | int num_demod_inputs; |
| 217 | |
| 218 | /* Max number of memory based input */ |
| 219 | int num_memory_inputs; |
| 220 | |
| 221 | /* Overall bitrate from all inputs concurrently. Mbit/sec */ |
| 222 | int max_bitrate; |
| 223 | |
| 224 | /* Max bitrate from single demod input. Mbit/sec */ |
| 225 | int demod_input_max_bitrate; |
| 226 | |
| 227 | /* Max bitrate from single memory input. Mbit/sec */ |
| 228 | int memory_input_max_bitrate; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 229 | } dmx_caps_t; |
| 230 | |
| 231 | typedef enum { |
| 232 | DMX_SOURCE_FRONT0 = 0, |
| 233 | DMX_SOURCE_FRONT1, |
| 234 | DMX_SOURCE_FRONT2, |
| 235 | DMX_SOURCE_FRONT3, |
| 236 | DMX_SOURCE_DVR0 = 16, |
| 237 | DMX_SOURCE_DVR1, |
| 238 | DMX_SOURCE_DVR2, |
| 239 | DMX_SOURCE_DVR3 |
| 240 | } dmx_source_t; |
| 241 | |
Hamad Kadmany | 32cb982 | 2012-05-10 08:47:44 +0300 | [diff] [blame] | 242 | enum dmx_tsp_format_t { |
| 243 | DMX_TSP_FORMAT_188 = 0, |
| 244 | DMX_TSP_FORMAT_192_TAIL, |
| 245 | DMX_TSP_FORMAT_192_HEAD, |
| 246 | DMX_TSP_FORMAT_204, |
| 247 | }; |
| 248 | |
| 249 | enum dmx_playback_mode_t { |
| 250 | /* |
| 251 | * In push mode, if one of output buffers |
| 252 | * is full, the buffer would overflow |
| 253 | * and demux continue processing incoming stream. |
| 254 | * This is the default mode. When playing from frontend, |
| 255 | * this is the only mode that is allowed. |
| 256 | */ |
| 257 | DMX_PB_MODE_PUSH = 0, |
| 258 | |
| 259 | /* |
| 260 | * In pull mode, if one of output buffers |
| 261 | * is full, demux stalls waiting for free space, |
| 262 | * this would cause DVR input buffer fullness |
| 263 | * to accumulate. |
| 264 | * This mode is possible only when playing |
| 265 | * from DVR. |
| 266 | */ |
| 267 | DMX_PB_MODE_PULL, |
| 268 | }; |
| 269 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 270 | struct dmx_stc { |
| 271 | unsigned int num; /* input : which STC? 0..N */ |
| 272 | unsigned int base; /* output: divisor for stc to get 90 kHz clock */ |
| 273 | __u64 stc; /* output: stc in 'base'*90 kHz units */ |
| 274 | }; |
| 275 | |
| 276 | |
| 277 | #define DMX_START _IO('o', 41) |
| 278 | #define DMX_STOP _IO('o', 42) |
| 279 | #define DMX_SET_FILTER _IOW('o', 43, struct dmx_sct_filter_params) |
| 280 | #define DMX_SET_PES_FILTER _IOW('o', 44, struct dmx_pes_filter_params) |
| 281 | #define DMX_SET_BUFFER_SIZE _IO('o', 45) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 282 | #define DMX_GET_PES_PIDS _IOR('o', 47, __u16[5]) |
| 283 | #define DMX_GET_CAPS _IOR('o', 48, dmx_caps_t) |
| 284 | #define DMX_SET_SOURCE _IOW('o', 49, dmx_source_t) |
| 285 | #define DMX_GET_STC _IOWR('o', 50, struct dmx_stc) |
Andreas Oberritter | 1cb662a | 2009-07-14 20:28:50 -0300 | [diff] [blame] | 286 | #define DMX_ADD_PID _IOW('o', 51, __u16) |
| 287 | #define DMX_REMOVE_PID _IOW('o', 52, __u16) |
Hamad Kadmany | 32cb982 | 2012-05-10 08:47:44 +0300 | [diff] [blame] | 288 | #define DMX_SET_TS_PACKET_FORMAT _IOW('o', 53, enum dmx_tsp_format_t) |
| 289 | #define DMX_SET_TS_OUT_FORMAT _IOW('o', 54, enum dmx_tsp_format_t) |
| 290 | #define DMX_SET_DECODER_BUFFER_SIZE _IO('o', 55) |
| 291 | #define DMX_GET_BUFFER_STATUS _IOR('o', 56, struct dmx_buffer_status) |
| 292 | #define DMX_RELEASE_DATA _IO('o', 57) |
| 293 | #define DMX_FEED_DATA _IO('o', 58) |
| 294 | #define DMX_SET_PLAYBACK_MODE _IOW('o', 59, enum dmx_playback_mode_t) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 295 | |
| 296 | #endif /*_DVBDMX_H_*/ |