Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * demux.h |
| 3 | * |
| 4 | * Copyright (c) 2002 Convergence GmbH |
| 5 | * |
| 6 | * based on code: |
| 7 | * Copyright (c) 2000 Nokia Research Center |
| 8 | * Tampere, FINLAND |
| 9 | * |
| 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 __DEMUX_H |
| 27 | #define __DEMUX_H |
| 28 | |
| 29 | #include <linux/types.h> |
| 30 | #include <linux/errno.h> |
| 31 | #include <linux/list.h> |
| 32 | #include <linux/time.h> |
Andreas Oberritter | c051005 | 2005-09-09 13:02:21 -0700 | [diff] [blame] | 33 | #include <linux/dvb/dmx.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | |
| 35 | /*--------------------------------------------------------------------------*/ |
| 36 | /* Common definitions */ |
| 37 | /*--------------------------------------------------------------------------*/ |
| 38 | |
| 39 | /* |
| 40 | * DMX_MAX_FILTER_SIZE: Maximum length (in bytes) of a section/PES filter. |
| 41 | */ |
| 42 | |
| 43 | #ifndef DMX_MAX_FILTER_SIZE |
| 44 | #define DMX_MAX_FILTER_SIZE 18 |
| 45 | #endif |
| 46 | |
| 47 | /* |
| 48 | * DMX_MAX_SECFEED_SIZE: Maximum length (in bytes) of a private section feed filter. |
| 49 | */ |
| 50 | |
Mark Adams | b3967d6 | 2005-11-08 21:35:50 -0800 | [diff] [blame] | 51 | #ifndef DMX_MAX_SECTION_SIZE |
| 52 | #define DMX_MAX_SECTION_SIZE 4096 |
| 53 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 54 | #ifndef DMX_MAX_SECFEED_SIZE |
Mark Adams | b3967d6 | 2005-11-08 21:35:50 -0800 | [diff] [blame] | 55 | #define DMX_MAX_SECFEED_SIZE (DMX_MAX_SECTION_SIZE + 188) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 56 | #endif |
| 57 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 58 | /*--------------------------------------------------------------------------*/ |
| 59 | /* TS packet reception */ |
| 60 | /*--------------------------------------------------------------------------*/ |
| 61 | |
| 62 | /* TS filter type for set() */ |
| 63 | |
| 64 | #define TS_PACKET 1 /* send TS packets (188 bytes) to callback (default) */ |
| 65 | #define TS_PAYLOAD_ONLY 2 /* in case TS_PACKET is set, only send the TS |
| 66 | payload (<=184 bytes per packet) to callback */ |
| 67 | #define TS_DECODER 4 /* send stream to built-in decoder (if present) */ |
Andreas Oberritter | 4a24ce3 | 2008-04-22 14:45:47 -0300 | [diff] [blame] | 68 | #define TS_DEMUX 8 /* in case TS_PACKET is set, send the TS to |
| 69 | the demux device, not to the dvr device */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 70 | |
Mauro Carvalho Chehab | 548e5ae | 2015-10-07 16:11:03 -0300 | [diff] [blame^] | 71 | /** |
| 72 | * struct dmx_ts_feed - Structure that contains a TS feed filter |
| 73 | * |
| 74 | * @is_filtering: Set to non-zero when filtering in progress |
| 75 | * @parent: pointer to struct dmx_demux |
| 76 | * @priv: pointer to private data of the API client |
| 77 | * @set: sets the TS filter |
| 78 | * @start_filtering: starts TS filtering |
| 79 | * @stop_filtering: stops TS filtering |
| 80 | * |
| 81 | * A TS feed is typically mapped to a hardware PID filter on the demux chip. |
| 82 | * Using this API, the client can set the filtering properties to start/stop |
| 83 | * filtering TS packets on a particular TS feed. |
| 84 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 85 | struct dmx_ts_feed { |
Mauro Carvalho Chehab | 548e5ae | 2015-10-07 16:11:03 -0300 | [diff] [blame^] | 86 | int is_filtering; |
| 87 | struct dmx_demux *parent; |
| 88 | void *priv; |
Mauro Carvalho Chehab | afd1a0c | 2005-12-12 00:37:27 -0800 | [diff] [blame] | 89 | int (*set) (struct dmx_ts_feed *feed, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 90 | u16 pid, |
| 91 | int type, |
| 92 | enum dmx_ts_pes pes_type, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 93 | size_t circular_buffer_size, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 94 | struct timespec timeout); |
Mauro Carvalho Chehab | afd1a0c | 2005-12-12 00:37:27 -0800 | [diff] [blame] | 95 | int (*start_filtering) (struct dmx_ts_feed* feed); |
| 96 | int (*stop_filtering) (struct dmx_ts_feed* feed); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 97 | }; |
| 98 | |
| 99 | /*--------------------------------------------------------------------------*/ |
| 100 | /* Section reception */ |
| 101 | /*--------------------------------------------------------------------------*/ |
| 102 | |
Mauro Carvalho Chehab | 548e5ae | 2015-10-07 16:11:03 -0300 | [diff] [blame^] | 103 | /** |
| 104 | * struct dmx_section_filter - Structure that describes a section filter |
| 105 | * |
| 106 | * @filter_value: Contains up to 16 bytes (128 bits) of the TS section header |
| 107 | * that will be matched by the section filter |
| 108 | * @filter_mask: Contains a 16 bytes (128 bits) filter mask with the bits |
| 109 | * specified by @filter_value that will be used on the filter |
| 110 | * match logic. |
| 111 | * @filter_mode: Contains a 16 bytes (128 bits) filter mode. |
| 112 | * @parent: Pointer to struct dmx_section_feed. |
| 113 | * @priv: Pointer to private data of the API client. |
| 114 | * |
| 115 | * |
| 116 | * The @filter_mask controls which bits of @filter_value are compared with |
| 117 | * the section headers/payload. On a binary value of 1 in filter_mask, the |
| 118 | * corresponding bits are compared. The filter only accepts sections that are |
| 119 | * equal to filter_value in all the tested bit positions. |
| 120 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 121 | struct dmx_section_filter { |
Mauro Carvalho Chehab | afd1a0c | 2005-12-12 00:37:27 -0800 | [diff] [blame] | 122 | u8 filter_value [DMX_MAX_FILTER_SIZE]; |
| 123 | u8 filter_mask [DMX_MAX_FILTER_SIZE]; |
| 124 | u8 filter_mode [DMX_MAX_FILTER_SIZE]; |
| 125 | struct dmx_section_feed* parent; /* Back-pointer */ |
| 126 | void* priv; /* Pointer to private data of the API client */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 127 | }; |
| 128 | |
Mauro Carvalho Chehab | 548e5ae | 2015-10-07 16:11:03 -0300 | [diff] [blame^] | 129 | /** |
| 130 | * struct dmx_section_feed - Structure that contains a section feed filter |
| 131 | * |
| 132 | * @is_filtering: Set to non-zero when filtering in progress |
| 133 | * @parent: pointer to struct dmx_demux |
| 134 | * @priv: pointer to private data of the API client |
| 135 | * @check_crc: If non-zero, check the CRC values of filtered sections. |
| 136 | * @set: sets the section filter |
| 137 | * @allocate_filter: This function is used to allocate a section filter on |
| 138 | * the demux. It should only be called when no filtering |
| 139 | * is in progress on this section feed. If a filter cannot |
| 140 | * be allocated, the function fails with -ENOSPC. |
| 141 | * @release_filter: This function releases all the resources of a |
| 142 | * previously allocated section filter. The function |
| 143 | * should not be called while filtering is in progress |
| 144 | * on this section feed. After calling this function, |
| 145 | * the caller should not try to dereference the filter |
| 146 | * pointer. |
| 147 | * @start_filtering: starts section filtering |
| 148 | * @stop_filtering: stops section filtering |
| 149 | * |
| 150 | * A TS feed is typically mapped to a hardware PID filter on the demux chip. |
| 151 | * Using this API, the client can set the filtering properties to start/stop |
| 152 | * filtering TS packets on a particular TS feed. |
| 153 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 154 | struct dmx_section_feed { |
Mauro Carvalho Chehab | 548e5ae | 2015-10-07 16:11:03 -0300 | [diff] [blame^] | 155 | int is_filtering; |
| 156 | struct dmx_demux* parent; |
| 157 | void* priv; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 158 | |
Mauro Carvalho Chehab | afd1a0c | 2005-12-12 00:37:27 -0800 | [diff] [blame] | 159 | int check_crc; |
Mauro Carvalho Chehab | 548e5ae | 2015-10-07 16:11:03 -0300 | [diff] [blame^] | 160 | |
| 161 | /* private: Used internally at dvb_demux.c */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 162 | u32 crc_val; |
| 163 | |
Mauro Carvalho Chehab | afd1a0c | 2005-12-12 00:37:27 -0800 | [diff] [blame] | 164 | u8 *secbuf; |
| 165 | u8 secbuf_base[DMX_MAX_SECFEED_SIZE]; |
| 166 | u16 secbufp, seclen, tsfeedp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 167 | |
Mauro Carvalho Chehab | 548e5ae | 2015-10-07 16:11:03 -0300 | [diff] [blame^] | 168 | /* public: */ |
Mauro Carvalho Chehab | afd1a0c | 2005-12-12 00:37:27 -0800 | [diff] [blame] | 169 | int (*set) (struct dmx_section_feed* feed, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 170 | u16 pid, |
| 171 | size_t circular_buffer_size, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 172 | int check_crc); |
Mauro Carvalho Chehab | afd1a0c | 2005-12-12 00:37:27 -0800 | [diff] [blame] | 173 | int (*allocate_filter) (struct dmx_section_feed* feed, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 174 | struct dmx_section_filter** filter); |
Mauro Carvalho Chehab | afd1a0c | 2005-12-12 00:37:27 -0800 | [diff] [blame] | 175 | int (*release_filter) (struct dmx_section_feed* feed, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 176 | struct dmx_section_filter* filter); |
Mauro Carvalho Chehab | afd1a0c | 2005-12-12 00:37:27 -0800 | [diff] [blame] | 177 | int (*start_filtering) (struct dmx_section_feed* feed); |
| 178 | int (*stop_filtering) (struct dmx_section_feed* feed); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 179 | }; |
| 180 | |
| 181 | /*--------------------------------------------------------------------------*/ |
| 182 | /* Callback functions */ |
| 183 | /*--------------------------------------------------------------------------*/ |
| 184 | |
| 185 | typedef int (*dmx_ts_cb) ( const u8 * buffer1, |
| 186 | size_t buffer1_length, |
| 187 | const u8 * buffer2, |
| 188 | size_t buffer2_length, |
Mauro Carvalho Chehab | 2f684b2 | 2015-10-06 19:53:02 -0300 | [diff] [blame] | 189 | struct dmx_ts_feed* source); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 190 | |
| 191 | typedef int (*dmx_section_cb) ( const u8 * buffer1, |
| 192 | size_t buffer1_len, |
| 193 | const u8 * buffer2, |
| 194 | size_t buffer2_len, |
Mauro Carvalho Chehab | 2f684b2 | 2015-10-06 19:53:02 -0300 | [diff] [blame] | 195 | struct dmx_section_filter * source); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 196 | |
| 197 | /*--------------------------------------------------------------------------*/ |
| 198 | /* DVB Front-End */ |
| 199 | /*--------------------------------------------------------------------------*/ |
| 200 | |
Mauro Carvalho Chehab | 548e5ae | 2015-10-07 16:11:03 -0300 | [diff] [blame^] | 201 | /** |
| 202 | * enum dmx_frontend_source - Used to identify the type of frontend |
| 203 | * |
| 204 | * @DMX_MEMORY_FE: The source of the demux is memory. It means that |
| 205 | * the MPEG-TS to be filtered comes from userspace, |
| 206 | * via write() syscall. |
| 207 | * |
| 208 | * @DMX_FRONTEND_0: The source of the demux is a frontend connected |
| 209 | * to the demux. |
| 210 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 211 | enum dmx_frontend_source { |
| 212 | DMX_MEMORY_FE, |
| 213 | DMX_FRONTEND_0, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 214 | }; |
| 215 | |
Mauro Carvalho Chehab | 548e5ae | 2015-10-07 16:11:03 -0300 | [diff] [blame^] | 216 | /** |
| 217 | * struct dmx_frontend - Structure that lists the frontends associated with |
| 218 | * a demux |
| 219 | * |
| 220 | * @connectivity_list: List of front-ends that can be connected to a |
| 221 | * particular demux; |
| 222 | * @source: Type of the frontend. |
| 223 | * |
| 224 | * FIXME: this structure should likely be replaced soon by some |
| 225 | * media-controller based logic. |
| 226 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 227 | struct dmx_frontend { |
Mauro Carvalho Chehab | 548e5ae | 2015-10-07 16:11:03 -0300 | [diff] [blame^] | 228 | struct list_head connectivity_list; |
Mauro Carvalho Chehab | afd1a0c | 2005-12-12 00:37:27 -0800 | [diff] [blame] | 229 | enum dmx_frontend_source source; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 230 | }; |
| 231 | |
| 232 | /*--------------------------------------------------------------------------*/ |
| 233 | /* MPEG-2 TS Demux */ |
| 234 | /*--------------------------------------------------------------------------*/ |
| 235 | |
| 236 | /* |
Alexey Dobriyan | 8a59822 | 2006-03-07 22:20:23 -0300 | [diff] [blame] | 237 | * Flags OR'ed in the capabilities field of struct dmx_demux. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 238 | */ |
| 239 | |
| 240 | #define DMX_TS_FILTERING 1 |
| 241 | #define DMX_PES_FILTERING 2 |
| 242 | #define DMX_SECTION_FILTERING 4 |
| 243 | #define DMX_MEMORY_BASED_FILTERING 8 /* write() available */ |
| 244 | #define DMX_CRC_CHECKING 16 |
| 245 | #define DMX_TS_DESCRAMBLING 32 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 246 | |
| 247 | /* |
| 248 | * Demux resource type identifier. |
| 249 | */ |
| 250 | |
| 251 | /* |
| 252 | * DMX_FE_ENTRY(): Casts elements in the list of registered |
| 253 | * front-ends from the generic type struct list_head |
| 254 | * to the type * struct dmx_frontend |
| 255 | *. |
| 256 | */ |
| 257 | |
| 258 | #define DMX_FE_ENTRY(list) list_entry(list, struct dmx_frontend, connectivity_list) |
| 259 | |
Mauro Carvalho Chehab | 95abfdb | 2015-10-05 15:10:55 -0300 | [diff] [blame] | 260 | /** |
| 261 | * struct dmx_demux - Structure that contains the demux capabilities and |
| 262 | * callbacks. |
| 263 | * |
| 264 | * @capabilities: Bitfield of capability flags |
| 265 | * |
| 266 | * @frontend: Front-end connected to the demux |
| 267 | * |
| 268 | * @priv: Pointer to private data of the API client |
| 269 | * |
| 270 | * @open: This function reserves the demux for use by the caller and, if |
| 271 | * necessary, initializes the demux. When the demux is no longer needed, |
Mauro Carvalho Chehab | 28cff82 | 2015-10-06 15:30:46 -0300 | [diff] [blame] | 272 | * the function @close should be called. It should be possible for |
Mauro Carvalho Chehab | 95abfdb | 2015-10-05 15:10:55 -0300 | [diff] [blame] | 273 | * multiple clients to access the demux at the same time. Thus, the |
| 274 | * function implementation should increment the demux usage count when |
Mauro Carvalho Chehab | 28cff82 | 2015-10-06 15:30:46 -0300 | [diff] [blame] | 275 | * @open is called and decrement it when @close is called. |
Mauro Carvalho Chehab | 95abfdb | 2015-10-05 15:10:55 -0300 | [diff] [blame] | 276 | * The @demux function parameter contains a pointer to the demux API and |
| 277 | * instance data. |
| 278 | * It returns |
| 279 | * 0 on success; |
| 280 | * -EUSERS, if maximum usage count was reached; |
| 281 | * -EINVAL, on bad parameter. |
| 282 | * |
| 283 | * @close: This function reserves the demux for use by the caller and, if |
| 284 | * necessary, initializes the demux. When the demux is no longer needed, |
Mauro Carvalho Chehab | 28cff82 | 2015-10-06 15:30:46 -0300 | [diff] [blame] | 285 | * the function @close should be called. It should be possible for |
Mauro Carvalho Chehab | 95abfdb | 2015-10-05 15:10:55 -0300 | [diff] [blame] | 286 | * multiple clients to access the demux at the same time. Thus, the |
| 287 | * function implementation should increment the demux usage count when |
Mauro Carvalho Chehab | 28cff82 | 2015-10-06 15:30:46 -0300 | [diff] [blame] | 288 | * @open is called and decrement it when @close is called. |
Mauro Carvalho Chehab | 95abfdb | 2015-10-05 15:10:55 -0300 | [diff] [blame] | 289 | * The @demux function parameter contains a pointer to the demux API and |
| 290 | * instance data. |
| 291 | * It returns |
| 292 | * 0 on success; |
Mauro Carvalho Chehab | 28cff82 | 2015-10-06 15:30:46 -0300 | [diff] [blame] | 293 | * -ENODEV, if demux was not in use (e. g. no users); |
Mauro Carvalho Chehab | 95abfdb | 2015-10-05 15:10:55 -0300 | [diff] [blame] | 294 | * -EINVAL, on bad parameter. |
| 295 | * |
| 296 | * @write: This function provides the demux driver with a memory buffer |
| 297 | * containing TS packets. Instead of receiving TS packets from the DVB |
| 298 | * front-end, the demux driver software will read packets from memory. |
| 299 | * Any clients of this demux with active TS, PES or Section filters will |
| 300 | * receive filtered data via the Demux callback API (see 0). The function |
| 301 | * returns when all the data in the buffer has been consumed by the demux. |
| 302 | * Demux hardware typically cannot read TS from memory. If this is the |
| 303 | * case, memory-based filtering has to be implemented entirely in software. |
| 304 | * The @demux function parameter contains a pointer to the demux API and |
| 305 | * instance data. |
| 306 | * The @buf function parameter contains a pointer to the TS data in |
| 307 | * kernel-space memory. |
| 308 | * The @count function parameter contains the length of the TS data. |
| 309 | * It returns |
| 310 | * 0 on success; |
Mauro Carvalho Chehab | 28cff82 | 2015-10-06 15:30:46 -0300 | [diff] [blame] | 311 | * -ERESTARTSYS, if mutex lock was interrupted; |
| 312 | * -EINTR, if a signal handling is pending; |
| 313 | * -ENODEV, if demux was removed; |
Mauro Carvalho Chehab | 95abfdb | 2015-10-05 15:10:55 -0300 | [diff] [blame] | 314 | * -EINVAL, on bad parameter. |
| 315 | * |
| 316 | * @allocate_ts_feed: Allocates a new TS feed, which is used to filter the TS |
| 317 | * packets carrying a certain PID. The TS feed normally corresponds to a |
| 318 | * hardware PID filter on the demux chip. |
| 319 | * The @demux function parameter contains a pointer to the demux API and |
| 320 | * instance data. |
| 321 | * The @feed function parameter contains a pointer to the TS feed API and |
| 322 | * instance data. |
| 323 | * The @callback function parameter contains a pointer to the callback |
| 324 | * function for passing received TS packet. |
| 325 | * It returns |
| 326 | * 0 on success; |
Mauro Carvalho Chehab | 28cff82 | 2015-10-06 15:30:46 -0300 | [diff] [blame] | 327 | * -ERESTARTSYS, if mutex lock was interrupted; |
Mauro Carvalho Chehab | 95abfdb | 2015-10-05 15:10:55 -0300 | [diff] [blame] | 328 | * -EBUSY, if no more TS feeds is available; |
Mauro Carvalho Chehab | 95abfdb | 2015-10-05 15:10:55 -0300 | [diff] [blame] | 329 | * -EINVAL, on bad parameter. |
| 330 | * |
Mauro Carvalho Chehab | 28cff82 | 2015-10-06 15:30:46 -0300 | [diff] [blame] | 331 | * @release_ts_feed: Releases the resources allocated with @allocate_ts_feed. |
Mauro Carvalho Chehab | 95abfdb | 2015-10-05 15:10:55 -0300 | [diff] [blame] | 332 | * Any filtering in progress on the TS feed should be stopped before |
| 333 | * calling this function. |
| 334 | * The @demux function parameter contains a pointer to the demux API and |
| 335 | * instance data. |
| 336 | * The @feed function parameter contains a pointer to the TS feed API and |
| 337 | * instance data. |
| 338 | * It returns |
| 339 | * 0 on success; |
| 340 | * -EINVAL on bad parameter. |
| 341 | * |
| 342 | * @allocate_section_feed: Allocates a new section feed, i.e. a demux resource |
| 343 | * for filtering and receiving sections. On platforms with hardware |
| 344 | * support for section filtering, a section feed is directly mapped to |
| 345 | * the demux HW. On other platforms, TS packets are first PID filtered in |
| 346 | * hardware and a hardware section filter then emulated in software. The |
| 347 | * caller obtains an API pointer of type dmx_section_feed_t as an out |
| 348 | * parameter. Using this API the caller can set filtering parameters and |
| 349 | * start receiving sections. |
| 350 | * The @demux function parameter contains a pointer to the demux API and |
| 351 | * instance data. |
| 352 | * The @feed function parameter contains a pointer to the TS feed API and |
| 353 | * instance data. |
| 354 | * The @callback function parameter contains a pointer to the callback |
| 355 | * function for passing received TS packet. |
| 356 | * It returns |
| 357 | * 0 on success; |
| 358 | * -EBUSY, if no more TS feeds is available; |
Mauro Carvalho Chehab | 95abfdb | 2015-10-05 15:10:55 -0300 | [diff] [blame] | 359 | * -EINVAL, on bad parameter. |
| 360 | * |
| 361 | * @release_section_feed: Releases the resources allocated with |
Mauro Carvalho Chehab | 28cff82 | 2015-10-06 15:30:46 -0300 | [diff] [blame] | 362 | * @allocate_section_feed, including allocated filters. Any filtering in |
Mauro Carvalho Chehab | 95abfdb | 2015-10-05 15:10:55 -0300 | [diff] [blame] | 363 | * progress on the section feed should be stopped before calling this |
| 364 | * function. |
| 365 | * The @demux function parameter contains a pointer to the demux API and |
| 366 | * instance data. |
| 367 | * The @feed function parameter contains a pointer to the TS feed API and |
| 368 | * instance data. |
| 369 | * It returns |
| 370 | * 0 on success; |
| 371 | * -EINVAL, on bad parameter. |
| 372 | * |
| 373 | * @add_frontend: Registers a connectivity between a demux and a front-end, |
| 374 | * i.e., indicates that the demux can be connected via a call to |
Mauro Carvalho Chehab | 28cff82 | 2015-10-06 15:30:46 -0300 | [diff] [blame] | 375 | * @connect_frontend to use the given front-end as a TS source. The |
Mauro Carvalho Chehab | 95abfdb | 2015-10-05 15:10:55 -0300 | [diff] [blame] | 376 | * client of this function has to allocate dynamic or static memory for |
| 377 | * the frontend structure and initialize its fields before calling this |
| 378 | * function. This function is normally called during the driver |
| 379 | * initialization. The caller must not free the memory of the frontend |
Mauro Carvalho Chehab | 28cff82 | 2015-10-06 15:30:46 -0300 | [diff] [blame] | 380 | * struct before successfully calling @remove_frontend. |
Mauro Carvalho Chehab | 95abfdb | 2015-10-05 15:10:55 -0300 | [diff] [blame] | 381 | * The @demux function parameter contains a pointer to the demux API and |
| 382 | * instance data. |
| 383 | * The @frontend function parameter contains a pointer to the front-end |
| 384 | * instance data. |
| 385 | * It returns |
| 386 | * 0 on success; |
Mauro Carvalho Chehab | 95abfdb | 2015-10-05 15:10:55 -0300 | [diff] [blame] | 387 | * -EINVAL, on bad parameter. |
| 388 | * |
| 389 | * @remove_frontend: Indicates that the given front-end, registered by a call |
Mauro Carvalho Chehab | 28cff82 | 2015-10-06 15:30:46 -0300 | [diff] [blame] | 390 | * to @add_frontend, can no longer be connected as a TS source by this |
Mauro Carvalho Chehab | 95abfdb | 2015-10-05 15:10:55 -0300 | [diff] [blame] | 391 | * demux. The function should be called when a front-end driver or a demux |
| 392 | * driver is removed from the system. If the front-end is in use, the |
| 393 | * function fails with the return value of -EBUSY. After successfully |
| 394 | * calling this function, the caller can free the memory of the frontend |
Mauro Carvalho Chehab | 28cff82 | 2015-10-06 15:30:46 -0300 | [diff] [blame] | 395 | * struct if it was dynamically allocated before the @add_frontend |
Mauro Carvalho Chehab | 95abfdb | 2015-10-05 15:10:55 -0300 | [diff] [blame] | 396 | * operation. |
| 397 | * The @demux function parameter contains a pointer to the demux API and |
| 398 | * instance data. |
| 399 | * The @frontend function parameter contains a pointer to the front-end |
| 400 | * instance data. |
| 401 | * It returns |
| 402 | * 0 on success; |
Mauro Carvalho Chehab | 28cff82 | 2015-10-06 15:30:46 -0300 | [diff] [blame] | 403 | * -ENODEV, if the front-end was not found, |
Mauro Carvalho Chehab | 95abfdb | 2015-10-05 15:10:55 -0300 | [diff] [blame] | 404 | * -EINVAL, on bad parameter. |
| 405 | * |
| 406 | * @get_frontends: Provides the APIs of the front-ends that have been |
| 407 | * registered for this demux. Any of the front-ends obtained with this |
Mauro Carvalho Chehab | 28cff82 | 2015-10-06 15:30:46 -0300 | [diff] [blame] | 408 | * call can be used as a parameter for @connect_frontend. The include |
Mauro Carvalho Chehab | 95abfdb | 2015-10-05 15:10:55 -0300 | [diff] [blame] | 409 | * file demux.h contains the macro DMX_FE_ENTRY() for converting an |
Mauro Carvalho Chehab | 28cff82 | 2015-10-06 15:30:46 -0300 | [diff] [blame] | 410 | * element of the generic type struct &list_head * to the type |
| 411 | * struct &dmx_frontend *. The caller must not free the memory of any of |
| 412 | * the elements obtained via this function call. |
Mauro Carvalho Chehab | 95abfdb | 2015-10-05 15:10:55 -0300 | [diff] [blame] | 413 | * The @demux function parameter contains a pointer to the demux API and |
| 414 | * instance data. |
| 415 | * It returns a struct list_head pointer to the list of front-end |
| 416 | * interfaces, or NULL in the case of an empty list. |
| 417 | * |
| 418 | * @connect_frontend: Connects the TS output of the front-end to the input of |
| 419 | * the demux. A demux can only be connected to a front-end registered to |
Mauro Carvalho Chehab | 28cff82 | 2015-10-06 15:30:46 -0300 | [diff] [blame] | 420 | * the demux with the function @add_frontend. It may or may not be |
Mauro Carvalho Chehab | 95abfdb | 2015-10-05 15:10:55 -0300 | [diff] [blame] | 421 | * possible to connect multiple demuxes to the same front-end, depending |
| 422 | * on the capabilities of the HW platform. When not used, the front-end |
Mauro Carvalho Chehab | 28cff82 | 2015-10-06 15:30:46 -0300 | [diff] [blame] | 423 | * should be released by calling @disconnect_frontend. |
Mauro Carvalho Chehab | 95abfdb | 2015-10-05 15:10:55 -0300 | [diff] [blame] | 424 | * The @demux function parameter contains a pointer to the demux API and |
| 425 | * instance data. |
| 426 | * The @frontend function parameter contains a pointer to the front-end |
| 427 | * instance data. |
| 428 | * It returns |
| 429 | * 0 on success; |
Mauro Carvalho Chehab | 95abfdb | 2015-10-05 15:10:55 -0300 | [diff] [blame] | 430 | * -EINVAL, on bad parameter. |
| 431 | * |
| 432 | * @disconnect_frontend: Disconnects the demux and a front-end previously |
Mauro Carvalho Chehab | 28cff82 | 2015-10-06 15:30:46 -0300 | [diff] [blame] | 433 | * connected by a @connect_frontend call. |
Mauro Carvalho Chehab | 95abfdb | 2015-10-05 15:10:55 -0300 | [diff] [blame] | 434 | * The @demux function parameter contains a pointer to the demux API and |
| 435 | * instance data. |
| 436 | * It returns |
| 437 | * 0 on success; |
| 438 | * -EINVAL on bad parameter. |
Mauro Carvalho Chehab | 4bc645d | 2015-10-06 18:39:40 -0300 | [diff] [blame] | 439 | * |
| 440 | * @get_pes_pids: Get the PIDs for DMX_PES_AUDIO0, DMX_PES_VIDEO0, |
| 441 | * DMX_PES_TELETEXT0, DMX_PES_SUBTITLE0 and DMX_PES_PCR0. |
| 442 | * The @demux function parameter contains a pointer to the demux API and |
| 443 | * instance data. |
| 444 | * The @pids function parameter contains an array with five u16 elements |
| 445 | * where the PIDs will be stored. |
| 446 | * It returns |
| 447 | * 0 on success; |
| 448 | * -EINVAL on bad parameter. |
Mauro Carvalho Chehab | 95abfdb | 2015-10-05 15:10:55 -0300 | [diff] [blame] | 449 | */ |
| 450 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 451 | struct dmx_demux { |
Mauro Carvalho Chehab | 95abfdb | 2015-10-05 15:10:55 -0300 | [diff] [blame] | 452 | u32 capabilities; |
| 453 | struct dmx_frontend* frontend; |
| 454 | void* priv; |
Mauro Carvalho Chehab | afd1a0c | 2005-12-12 00:37:27 -0800 | [diff] [blame] | 455 | int (*open) (struct dmx_demux* demux); |
| 456 | int (*close) (struct dmx_demux* demux); |
Al Viro | 947a080 | 2008-06-22 14:20:19 -0300 | [diff] [blame] | 457 | int (*write) (struct dmx_demux* demux, const char __user *buf, size_t count); |
Mauro Carvalho Chehab | afd1a0c | 2005-12-12 00:37:27 -0800 | [diff] [blame] | 458 | int (*allocate_ts_feed) (struct dmx_demux* demux, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 459 | struct dmx_ts_feed** feed, |
| 460 | dmx_ts_cb callback); |
Mauro Carvalho Chehab | afd1a0c | 2005-12-12 00:37:27 -0800 | [diff] [blame] | 461 | int (*release_ts_feed) (struct dmx_demux* demux, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 462 | struct dmx_ts_feed* feed); |
Mauro Carvalho Chehab | afd1a0c | 2005-12-12 00:37:27 -0800 | [diff] [blame] | 463 | int (*allocate_section_feed) (struct dmx_demux* demux, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 464 | struct dmx_section_feed** feed, |
| 465 | dmx_section_cb callback); |
Mauro Carvalho Chehab | afd1a0c | 2005-12-12 00:37:27 -0800 | [diff] [blame] | 466 | int (*release_section_feed) (struct dmx_demux* demux, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 467 | struct dmx_section_feed* feed); |
Mauro Carvalho Chehab | afd1a0c | 2005-12-12 00:37:27 -0800 | [diff] [blame] | 468 | int (*add_frontend) (struct dmx_demux* demux, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 469 | struct dmx_frontend* frontend); |
Mauro Carvalho Chehab | afd1a0c | 2005-12-12 00:37:27 -0800 | [diff] [blame] | 470 | int (*remove_frontend) (struct dmx_demux* demux, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 471 | struct dmx_frontend* frontend); |
Mauro Carvalho Chehab | afd1a0c | 2005-12-12 00:37:27 -0800 | [diff] [blame] | 472 | struct list_head* (*get_frontends) (struct dmx_demux* demux); |
| 473 | int (*connect_frontend) (struct dmx_demux* demux, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 474 | struct dmx_frontend* frontend); |
Mauro Carvalho Chehab | afd1a0c | 2005-12-12 00:37:27 -0800 | [diff] [blame] | 475 | int (*disconnect_frontend) (struct dmx_demux* demux); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 476 | |
Mauro Carvalho Chehab | afd1a0c | 2005-12-12 00:37:27 -0800 | [diff] [blame] | 477 | int (*get_pes_pids) (struct dmx_demux* demux, u16 *pids); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 478 | |
Mauro Carvalho Chehab | 1e92bbe | 2015-10-06 18:36:20 -0300 | [diff] [blame] | 479 | /* private: Not used upstream and never documented */ |
| 480 | #if 0 |
Andreas Oberritter | c051005 | 2005-09-09 13:02:21 -0700 | [diff] [blame] | 481 | int (*get_caps) (struct dmx_demux* demux, struct dmx_caps *caps); |
Andreas Oberritter | c051005 | 2005-09-09 13:02:21 -0700 | [diff] [blame] | 482 | int (*set_source) (struct dmx_demux* demux, const dmx_source_t *src); |
Mauro Carvalho Chehab | 1e92bbe | 2015-10-06 18:36:20 -0300 | [diff] [blame] | 483 | #endif |
Mauro Carvalho Chehab | 4bc645d | 2015-10-06 18:39:40 -0300 | [diff] [blame] | 484 | /* |
| 485 | * private: Only used at av7110, to read some data from firmware. |
| 486 | * As this was never documented, we have no clue about what's |
| 487 | * there, and its usage on other drivers aren't encouraged. |
| 488 | */ |
Mauro Carvalho Chehab | afd1a0c | 2005-12-12 00:37:27 -0800 | [diff] [blame] | 489 | int (*get_stc) (struct dmx_demux* demux, unsigned int num, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 490 | u64 *stc, unsigned int *base); |
| 491 | }; |
| 492 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 493 | #endif /* #ifndef __DEMUX_H */ |