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 | |
| 58 | |
| 59 | /* |
| 60 | * enum dmx_success: Success codes for the Demux Callback API. |
| 61 | */ |
| 62 | |
| 63 | enum dmx_success { |
| 64 | DMX_OK = 0, /* Received Ok */ |
| 65 | DMX_LENGTH_ERROR, /* Incorrect length */ |
| 66 | DMX_OVERRUN_ERROR, /* Receiver ring buffer overrun */ |
| 67 | DMX_CRC_ERROR, /* Incorrect CRC */ |
| 68 | DMX_FRAME_ERROR, /* Frame alignment error */ |
| 69 | DMX_FIFO_ERROR, /* Receiver FIFO overrun */ |
| 70 | DMX_MISSED_ERROR /* Receiver missed packet */ |
| 71 | } ; |
| 72 | |
| 73 | /*--------------------------------------------------------------------------*/ |
| 74 | /* TS packet reception */ |
| 75 | /*--------------------------------------------------------------------------*/ |
| 76 | |
| 77 | /* TS filter type for set() */ |
| 78 | |
| 79 | #define TS_PACKET 1 /* send TS packets (188 bytes) to callback (default) */ |
| 80 | #define TS_PAYLOAD_ONLY 2 /* in case TS_PACKET is set, only send the TS |
| 81 | payload (<=184 bytes per packet) to callback */ |
| 82 | #define TS_DECODER 4 /* send stream to built-in decoder (if present) */ |
Andreas Oberritter | 4a24ce3 | 2008-04-22 14:45:47 -0300 | [diff] [blame] | 83 | #define TS_DEMUX 8 /* in case TS_PACKET is set, send the TS to |
| 84 | the demux device, not to the dvr device */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 85 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 86 | struct dmx_ts_feed { |
Mauro Carvalho Chehab | afd1a0c | 2005-12-12 00:37:27 -0800 | [diff] [blame] | 87 | int is_filtering; /* Set to non-zero when filtering in progress */ |
| 88 | struct dmx_demux *parent; /* Back-pointer */ |
| 89 | void *priv; /* Pointer to private data of the API client */ |
| 90 | int (*set) (struct dmx_ts_feed *feed, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 91 | u16 pid, |
| 92 | int type, |
| 93 | enum dmx_ts_pes pes_type, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 94 | size_t circular_buffer_size, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 95 | struct timespec timeout); |
Mauro Carvalho Chehab | afd1a0c | 2005-12-12 00:37:27 -0800 | [diff] [blame] | 96 | int (*start_filtering) (struct dmx_ts_feed* feed); |
| 97 | int (*stop_filtering) (struct dmx_ts_feed* feed); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 98 | }; |
| 99 | |
| 100 | /*--------------------------------------------------------------------------*/ |
| 101 | /* Section reception */ |
| 102 | /*--------------------------------------------------------------------------*/ |
| 103 | |
| 104 | struct dmx_section_filter { |
Mauro Carvalho Chehab | afd1a0c | 2005-12-12 00:37:27 -0800 | [diff] [blame] | 105 | u8 filter_value [DMX_MAX_FILTER_SIZE]; |
| 106 | u8 filter_mask [DMX_MAX_FILTER_SIZE]; |
| 107 | u8 filter_mode [DMX_MAX_FILTER_SIZE]; |
| 108 | struct dmx_section_feed* parent; /* Back-pointer */ |
| 109 | void* priv; /* Pointer to private data of the API client */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 110 | }; |
| 111 | |
| 112 | struct dmx_section_feed { |
Mauro Carvalho Chehab | afd1a0c | 2005-12-12 00:37:27 -0800 | [diff] [blame] | 113 | int is_filtering; /* Set to non-zero when filtering in progress */ |
| 114 | struct dmx_demux* parent; /* Back-pointer */ |
| 115 | void* priv; /* Pointer to private data of the API client */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 116 | |
Mauro Carvalho Chehab | afd1a0c | 2005-12-12 00:37:27 -0800 | [diff] [blame] | 117 | int check_crc; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 118 | u32 crc_val; |
| 119 | |
Mauro Carvalho Chehab | afd1a0c | 2005-12-12 00:37:27 -0800 | [diff] [blame] | 120 | u8 *secbuf; |
| 121 | u8 secbuf_base[DMX_MAX_SECFEED_SIZE]; |
| 122 | u16 secbufp, seclen, tsfeedp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 123 | |
Mauro Carvalho Chehab | afd1a0c | 2005-12-12 00:37:27 -0800 | [diff] [blame] | 124 | int (*set) (struct dmx_section_feed* feed, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 125 | u16 pid, |
| 126 | size_t circular_buffer_size, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 127 | int check_crc); |
Mauro Carvalho Chehab | afd1a0c | 2005-12-12 00:37:27 -0800 | [diff] [blame] | 128 | int (*allocate_filter) (struct dmx_section_feed* feed, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 129 | struct dmx_section_filter** filter); |
Mauro Carvalho Chehab | afd1a0c | 2005-12-12 00:37:27 -0800 | [diff] [blame] | 130 | int (*release_filter) (struct dmx_section_feed* feed, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 131 | struct dmx_section_filter* filter); |
Mauro Carvalho Chehab | afd1a0c | 2005-12-12 00:37:27 -0800 | [diff] [blame] | 132 | int (*start_filtering) (struct dmx_section_feed* feed); |
| 133 | int (*stop_filtering) (struct dmx_section_feed* feed); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 134 | }; |
| 135 | |
| 136 | /*--------------------------------------------------------------------------*/ |
| 137 | /* Callback functions */ |
| 138 | /*--------------------------------------------------------------------------*/ |
| 139 | |
| 140 | typedef int (*dmx_ts_cb) ( const u8 * buffer1, |
| 141 | size_t buffer1_length, |
| 142 | const u8 * buffer2, |
| 143 | size_t buffer2_length, |
| 144 | struct dmx_ts_feed* source, |
| 145 | enum dmx_success success); |
| 146 | |
| 147 | typedef int (*dmx_section_cb) ( const u8 * buffer1, |
| 148 | size_t buffer1_len, |
| 149 | const u8 * buffer2, |
| 150 | size_t buffer2_len, |
| 151 | struct dmx_section_filter * source, |
| 152 | enum dmx_success success); |
| 153 | |
| 154 | /*--------------------------------------------------------------------------*/ |
| 155 | /* DVB Front-End */ |
| 156 | /*--------------------------------------------------------------------------*/ |
| 157 | |
| 158 | enum dmx_frontend_source { |
| 159 | DMX_MEMORY_FE, |
| 160 | DMX_FRONTEND_0, |
| 161 | DMX_FRONTEND_1, |
| 162 | DMX_FRONTEND_2, |
| 163 | DMX_FRONTEND_3, |
| 164 | DMX_STREAM_0, /* external stream input, e.g. LVDS */ |
| 165 | DMX_STREAM_1, |
| 166 | DMX_STREAM_2, |
| 167 | DMX_STREAM_3 |
| 168 | }; |
| 169 | |
| 170 | struct dmx_frontend { |
Mauro Carvalho Chehab | afd1a0c | 2005-12-12 00:37:27 -0800 | [diff] [blame] | 171 | struct list_head connectivity_list; /* List of front-ends that can |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 172 | be connected to a particular |
| 173 | demux */ |
Mauro Carvalho Chehab | afd1a0c | 2005-12-12 00:37:27 -0800 | [diff] [blame] | 174 | enum dmx_frontend_source source; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 175 | }; |
| 176 | |
| 177 | /*--------------------------------------------------------------------------*/ |
| 178 | /* MPEG-2 TS Demux */ |
| 179 | /*--------------------------------------------------------------------------*/ |
| 180 | |
| 181 | /* |
Alexey Dobriyan | 8a59822 | 2006-03-07 22:20:23 -0300 | [diff] [blame] | 182 | * Flags OR'ed in the capabilities field of struct dmx_demux. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 183 | */ |
| 184 | |
| 185 | #define DMX_TS_FILTERING 1 |
| 186 | #define DMX_PES_FILTERING 2 |
| 187 | #define DMX_SECTION_FILTERING 4 |
| 188 | #define DMX_MEMORY_BASED_FILTERING 8 /* write() available */ |
| 189 | #define DMX_CRC_CHECKING 16 |
| 190 | #define DMX_TS_DESCRAMBLING 32 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 191 | |
| 192 | /* |
| 193 | * Demux resource type identifier. |
| 194 | */ |
| 195 | |
| 196 | /* |
| 197 | * DMX_FE_ENTRY(): Casts elements in the list of registered |
| 198 | * front-ends from the generic type struct list_head |
| 199 | * to the type * struct dmx_frontend |
| 200 | *. |
| 201 | */ |
| 202 | |
| 203 | #define DMX_FE_ENTRY(list) list_entry(list, struct dmx_frontend, connectivity_list) |
| 204 | |
| 205 | struct dmx_demux { |
Mauro Carvalho Chehab | afd1a0c | 2005-12-12 00:37:27 -0800 | [diff] [blame] | 206 | u32 capabilities; /* Bitfield of capability flags */ |
| 207 | struct dmx_frontend* frontend; /* Front-end connected to the demux */ |
| 208 | void* priv; /* Pointer to private data of the API client */ |
| 209 | int (*open) (struct dmx_demux* demux); |
| 210 | int (*close) (struct dmx_demux* demux); |
Al Viro | 947a080 | 2008-06-22 14:20:19 -0300 | [diff] [blame] | 211 | 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] | 212 | int (*allocate_ts_feed) (struct dmx_demux* demux, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 213 | struct dmx_ts_feed** feed, |
| 214 | dmx_ts_cb callback); |
Mauro Carvalho Chehab | afd1a0c | 2005-12-12 00:37:27 -0800 | [diff] [blame] | 215 | int (*release_ts_feed) (struct dmx_demux* demux, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 216 | struct dmx_ts_feed* feed); |
Mauro Carvalho Chehab | afd1a0c | 2005-12-12 00:37:27 -0800 | [diff] [blame] | 217 | int (*allocate_section_feed) (struct dmx_demux* demux, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 218 | struct dmx_section_feed** feed, |
| 219 | dmx_section_cb callback); |
Mauro Carvalho Chehab | afd1a0c | 2005-12-12 00:37:27 -0800 | [diff] [blame] | 220 | int (*release_section_feed) (struct dmx_demux* demux, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 221 | struct dmx_section_feed* feed); |
Mauro Carvalho Chehab | afd1a0c | 2005-12-12 00:37:27 -0800 | [diff] [blame] | 222 | int (*add_frontend) (struct dmx_demux* demux, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 223 | struct dmx_frontend* frontend); |
Mauro Carvalho Chehab | afd1a0c | 2005-12-12 00:37:27 -0800 | [diff] [blame] | 224 | int (*remove_frontend) (struct dmx_demux* demux, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 225 | struct dmx_frontend* frontend); |
Mauro Carvalho Chehab | afd1a0c | 2005-12-12 00:37:27 -0800 | [diff] [blame] | 226 | struct list_head* (*get_frontends) (struct dmx_demux* demux); |
| 227 | int (*connect_frontend) (struct dmx_demux* demux, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 228 | struct dmx_frontend* frontend); |
Mauro Carvalho Chehab | afd1a0c | 2005-12-12 00:37:27 -0800 | [diff] [blame] | 229 | int (*disconnect_frontend) (struct dmx_demux* demux); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 230 | |
Mauro Carvalho Chehab | afd1a0c | 2005-12-12 00:37:27 -0800 | [diff] [blame] | 231 | int (*get_pes_pids) (struct dmx_demux* demux, u16 *pids); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 232 | |
Andreas Oberritter | c051005 | 2005-09-09 13:02:21 -0700 | [diff] [blame] | 233 | int (*get_caps) (struct dmx_demux* demux, struct dmx_caps *caps); |
| 234 | |
| 235 | int (*set_source) (struct dmx_demux* demux, const dmx_source_t *src); |
| 236 | |
Mauro Carvalho Chehab | afd1a0c | 2005-12-12 00:37:27 -0800 | [diff] [blame] | 237 | int (*get_stc) (struct dmx_demux* demux, unsigned int num, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 238 | u64 *stc, unsigned int *base); |
| 239 | }; |
| 240 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 241 | #endif /* #ifndef __DEMUX_H */ |