blob: b344cad096cd3980173fc06837cd06437be450c4 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
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 Oberritterc0510052005-09-09 13:02:21 -070033#include <linux/dvb/dmx.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070034
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 Adamsb3967d62005-11-08 21:35:50 -080051#ifndef DMX_MAX_SECTION_SIZE
52#define DMX_MAX_SECTION_SIZE 4096
53#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070054#ifndef DMX_MAX_SECFEED_SIZE
Mark Adamsb3967d62005-11-08 21:35:50 -080055#define DMX_MAX_SECFEED_SIZE (DMX_MAX_SECTION_SIZE + 188)
Linus Torvalds1da177e2005-04-16 15:20:36 -070056#endif
57
Linus Torvalds1da177e2005-04-16 15:20:36 -070058/*--------------------------------------------------------------------------*/
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 Oberritter4a24ce32008-04-22 14:45:47 -030068#define TS_DEMUX 8 /* in case TS_PACKET is set, send the TS to
69 the demux device, not to the dvr device */
Linus Torvalds1da177e2005-04-16 15:20:36 -070070
Mauro Carvalho Chehab548e5ae2015-10-07 16:11:03 -030071/**
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 Torvalds1da177e2005-04-16 15:20:36 -070085struct dmx_ts_feed {
Mauro Carvalho Chehab548e5ae2015-10-07 16:11:03 -030086 int is_filtering;
87 struct dmx_demux *parent;
88 void *priv;
Mauro Carvalho Chehabafd1a0c2005-12-12 00:37:27 -080089 int (*set) (struct dmx_ts_feed *feed,
Linus Torvalds1da177e2005-04-16 15:20:36 -070090 u16 pid,
91 int type,
92 enum dmx_ts_pes pes_type,
Linus Torvalds1da177e2005-04-16 15:20:36 -070093 size_t circular_buffer_size,
Linus Torvalds1da177e2005-04-16 15:20:36 -070094 struct timespec timeout);
Mauro Carvalho Chehabafd1a0c2005-12-12 00:37:27 -080095 int (*start_filtering) (struct dmx_ts_feed* feed);
96 int (*stop_filtering) (struct dmx_ts_feed* feed);
Linus Torvalds1da177e2005-04-16 15:20:36 -070097};
98
99/*--------------------------------------------------------------------------*/
100/* Section reception */
101/*--------------------------------------------------------------------------*/
102
Mauro Carvalho Chehab548e5ae2015-10-07 16:11:03 -0300103/**
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 Torvalds1da177e2005-04-16 15:20:36 -0700121struct dmx_section_filter {
Mauro Carvalho Chehabafd1a0c2005-12-12 00:37:27 -0800122 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 Torvalds1da177e2005-04-16 15:20:36 -0700127};
128
Mauro Carvalho Chehab548e5ae2015-10-07 16:11:03 -0300129/**
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 Torvalds1da177e2005-04-16 15:20:36 -0700154struct dmx_section_feed {
Mauro Carvalho Chehab548e5ae2015-10-07 16:11:03 -0300155 int is_filtering;
156 struct dmx_demux* parent;
157 void* priv;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700158
Mauro Carvalho Chehabafd1a0c2005-12-12 00:37:27 -0800159 int check_crc;
Mauro Carvalho Chehab548e5ae2015-10-07 16:11:03 -0300160
161 /* private: Used internally at dvb_demux.c */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700162 u32 crc_val;
163
Mauro Carvalho Chehabafd1a0c2005-12-12 00:37:27 -0800164 u8 *secbuf;
165 u8 secbuf_base[DMX_MAX_SECFEED_SIZE];
166 u16 secbufp, seclen, tsfeedp;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700167
Mauro Carvalho Chehab548e5ae2015-10-07 16:11:03 -0300168 /* public: */
Mauro Carvalho Chehabafd1a0c2005-12-12 00:37:27 -0800169 int (*set) (struct dmx_section_feed* feed,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700170 u16 pid,
171 size_t circular_buffer_size,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700172 int check_crc);
Mauro Carvalho Chehabafd1a0c2005-12-12 00:37:27 -0800173 int (*allocate_filter) (struct dmx_section_feed* feed,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700174 struct dmx_section_filter** filter);
Mauro Carvalho Chehabafd1a0c2005-12-12 00:37:27 -0800175 int (*release_filter) (struct dmx_section_feed* feed,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700176 struct dmx_section_filter* filter);
Mauro Carvalho Chehabafd1a0c2005-12-12 00:37:27 -0800177 int (*start_filtering) (struct dmx_section_feed* feed);
178 int (*stop_filtering) (struct dmx_section_feed* feed);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700179};
180
181/*--------------------------------------------------------------------------*/
182/* Callback functions */
183/*--------------------------------------------------------------------------*/
184
185typedef int (*dmx_ts_cb) ( const u8 * buffer1,
186 size_t buffer1_length,
187 const u8 * buffer2,
188 size_t buffer2_length,
Mauro Carvalho Chehab2f684b22015-10-06 19:53:02 -0300189 struct dmx_ts_feed* source);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700190
191typedef int (*dmx_section_cb) ( const u8 * buffer1,
192 size_t buffer1_len,
193 const u8 * buffer2,
194 size_t buffer2_len,
Mauro Carvalho Chehab2f684b22015-10-06 19:53:02 -0300195 struct dmx_section_filter * source);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700196
197/*--------------------------------------------------------------------------*/
198/* DVB Front-End */
199/*--------------------------------------------------------------------------*/
200
Mauro Carvalho Chehab548e5ae2015-10-07 16:11:03 -0300201/**
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 Torvalds1da177e2005-04-16 15:20:36 -0700211enum dmx_frontend_source {
212 DMX_MEMORY_FE,
213 DMX_FRONTEND_0,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700214};
215
Mauro Carvalho Chehab548e5ae2015-10-07 16:11:03 -0300216/**
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 Torvalds1da177e2005-04-16 15:20:36 -0700227struct dmx_frontend {
Mauro Carvalho Chehab548e5ae2015-10-07 16:11:03 -0300228 struct list_head connectivity_list;
Mauro Carvalho Chehabafd1a0c2005-12-12 00:37:27 -0800229 enum dmx_frontend_source source;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700230};
231
232/*--------------------------------------------------------------------------*/
233/* MPEG-2 TS Demux */
234/*--------------------------------------------------------------------------*/
235
236/*
Alexey Dobriyan8a598222006-03-07 22:20:23 -0300237 * Flags OR'ed in the capabilities field of struct dmx_demux.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700238 */
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 Torvalds1da177e2005-04-16 15:20:36 -0700246
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 Chehab95abfdb2015-10-05 15:10:55 -0300260/**
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 Chehab28cff822015-10-06 15:30:46 -0300272 * the function @close should be called. It should be possible for
Mauro Carvalho Chehab95abfdb2015-10-05 15:10:55 -0300273 * multiple clients to access the demux at the same time. Thus, the
274 * function implementation should increment the demux usage count when
Mauro Carvalho Chehab28cff822015-10-06 15:30:46 -0300275 * @open is called and decrement it when @close is called.
Mauro Carvalho Chehab95abfdb2015-10-05 15:10:55 -0300276 * 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 Chehab28cff822015-10-06 15:30:46 -0300285 * the function @close should be called. It should be possible for
Mauro Carvalho Chehab95abfdb2015-10-05 15:10:55 -0300286 * multiple clients to access the demux at the same time. Thus, the
287 * function implementation should increment the demux usage count when
Mauro Carvalho Chehab28cff822015-10-06 15:30:46 -0300288 * @open is called and decrement it when @close is called.
Mauro Carvalho Chehab95abfdb2015-10-05 15:10:55 -0300289 * The @demux function parameter contains a pointer to the demux API and
290 * instance data.
291 * It returns
292 * 0 on success;
Mauro Carvalho Chehab28cff822015-10-06 15:30:46 -0300293 * -ENODEV, if demux was not in use (e. g. no users);
Mauro Carvalho Chehab95abfdb2015-10-05 15:10:55 -0300294 * -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 Chehab28cff822015-10-06 15:30:46 -0300311 * -ERESTARTSYS, if mutex lock was interrupted;
312 * -EINTR, if a signal handling is pending;
313 * -ENODEV, if demux was removed;
Mauro Carvalho Chehab95abfdb2015-10-05 15:10:55 -0300314 * -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 Chehab28cff822015-10-06 15:30:46 -0300327 * -ERESTARTSYS, if mutex lock was interrupted;
Mauro Carvalho Chehab95abfdb2015-10-05 15:10:55 -0300328 * -EBUSY, if no more TS feeds is available;
Mauro Carvalho Chehab95abfdb2015-10-05 15:10:55 -0300329 * -EINVAL, on bad parameter.
330 *
Mauro Carvalho Chehab28cff822015-10-06 15:30:46 -0300331 * @release_ts_feed: Releases the resources allocated with @allocate_ts_feed.
Mauro Carvalho Chehab95abfdb2015-10-05 15:10:55 -0300332 * 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 Chehab95abfdb2015-10-05 15:10:55 -0300359 * -EINVAL, on bad parameter.
360 *
361 * @release_section_feed: Releases the resources allocated with
Mauro Carvalho Chehab28cff822015-10-06 15:30:46 -0300362 * @allocate_section_feed, including allocated filters. Any filtering in
Mauro Carvalho Chehab95abfdb2015-10-05 15:10:55 -0300363 * 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 Chehab28cff822015-10-06 15:30:46 -0300375 * @connect_frontend to use the given front-end as a TS source. The
Mauro Carvalho Chehab95abfdb2015-10-05 15:10:55 -0300376 * 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 Chehab28cff822015-10-06 15:30:46 -0300380 * struct before successfully calling @remove_frontend.
Mauro Carvalho Chehab95abfdb2015-10-05 15:10:55 -0300381 * 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 Chehab95abfdb2015-10-05 15:10:55 -0300387 * -EINVAL, on bad parameter.
388 *
389 * @remove_frontend: Indicates that the given front-end, registered by a call
Mauro Carvalho Chehab28cff822015-10-06 15:30:46 -0300390 * to @add_frontend, can no longer be connected as a TS source by this
Mauro Carvalho Chehab95abfdb2015-10-05 15:10:55 -0300391 * 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 Chehab28cff822015-10-06 15:30:46 -0300395 * struct if it was dynamically allocated before the @add_frontend
Mauro Carvalho Chehab95abfdb2015-10-05 15:10:55 -0300396 * 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 Chehab28cff822015-10-06 15:30:46 -0300403 * -ENODEV, if the front-end was not found,
Mauro Carvalho Chehab95abfdb2015-10-05 15:10:55 -0300404 * -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 Chehab28cff822015-10-06 15:30:46 -0300408 * call can be used as a parameter for @connect_frontend. The include
Mauro Carvalho Chehab95abfdb2015-10-05 15:10:55 -0300409 * file demux.h contains the macro DMX_FE_ENTRY() for converting an
Mauro Carvalho Chehab28cff822015-10-06 15:30:46 -0300410 * 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 Chehab95abfdb2015-10-05 15:10:55 -0300413 * 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 Chehab28cff822015-10-06 15:30:46 -0300420 * the demux with the function @add_frontend. It may or may not be
Mauro Carvalho Chehab95abfdb2015-10-05 15:10:55 -0300421 * 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 Chehab28cff822015-10-06 15:30:46 -0300423 * should be released by calling @disconnect_frontend.
Mauro Carvalho Chehab95abfdb2015-10-05 15:10:55 -0300424 * 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 Chehab95abfdb2015-10-05 15:10:55 -0300430 * -EINVAL, on bad parameter.
431 *
432 * @disconnect_frontend: Disconnects the demux and a front-end previously
Mauro Carvalho Chehab28cff822015-10-06 15:30:46 -0300433 * connected by a @connect_frontend call.
Mauro Carvalho Chehab95abfdb2015-10-05 15:10:55 -0300434 * 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 Chehab4bc645d2015-10-06 18:39:40 -0300439 *
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 Chehab95abfdb2015-10-05 15:10:55 -0300449 */
450
Linus Torvalds1da177e2005-04-16 15:20:36 -0700451struct dmx_demux {
Mauro Carvalho Chehab95abfdb2015-10-05 15:10:55 -0300452 u32 capabilities;
453 struct dmx_frontend* frontend;
454 void* priv;
Mauro Carvalho Chehabafd1a0c2005-12-12 00:37:27 -0800455 int (*open) (struct dmx_demux* demux);
456 int (*close) (struct dmx_demux* demux);
Al Viro947a0802008-06-22 14:20:19 -0300457 int (*write) (struct dmx_demux* demux, const char __user *buf, size_t count);
Mauro Carvalho Chehabafd1a0c2005-12-12 00:37:27 -0800458 int (*allocate_ts_feed) (struct dmx_demux* demux,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700459 struct dmx_ts_feed** feed,
460 dmx_ts_cb callback);
Mauro Carvalho Chehabafd1a0c2005-12-12 00:37:27 -0800461 int (*release_ts_feed) (struct dmx_demux* demux,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700462 struct dmx_ts_feed* feed);
Mauro Carvalho Chehabafd1a0c2005-12-12 00:37:27 -0800463 int (*allocate_section_feed) (struct dmx_demux* demux,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700464 struct dmx_section_feed** feed,
465 dmx_section_cb callback);
Mauro Carvalho Chehabafd1a0c2005-12-12 00:37:27 -0800466 int (*release_section_feed) (struct dmx_demux* demux,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700467 struct dmx_section_feed* feed);
Mauro Carvalho Chehabafd1a0c2005-12-12 00:37:27 -0800468 int (*add_frontend) (struct dmx_demux* demux,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700469 struct dmx_frontend* frontend);
Mauro Carvalho Chehabafd1a0c2005-12-12 00:37:27 -0800470 int (*remove_frontend) (struct dmx_demux* demux,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700471 struct dmx_frontend* frontend);
Mauro Carvalho Chehabafd1a0c2005-12-12 00:37:27 -0800472 struct list_head* (*get_frontends) (struct dmx_demux* demux);
473 int (*connect_frontend) (struct dmx_demux* demux,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700474 struct dmx_frontend* frontend);
Mauro Carvalho Chehabafd1a0c2005-12-12 00:37:27 -0800475 int (*disconnect_frontend) (struct dmx_demux* demux);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700476
Mauro Carvalho Chehabafd1a0c2005-12-12 00:37:27 -0800477 int (*get_pes_pids) (struct dmx_demux* demux, u16 *pids);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700478
Mauro Carvalho Chehab1e92bbe2015-10-06 18:36:20 -0300479 /* private: Not used upstream and never documented */
480#if 0
Andreas Oberritterc0510052005-09-09 13:02:21 -0700481 int (*get_caps) (struct dmx_demux* demux, struct dmx_caps *caps);
Andreas Oberritterc0510052005-09-09 13:02:21 -0700482 int (*set_source) (struct dmx_demux* demux, const dmx_source_t *src);
Mauro Carvalho Chehab1e92bbe2015-10-06 18:36:20 -0300483#endif
Mauro Carvalho Chehab4bc645d2015-10-06 18:39:40 -0300484 /*
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 Chehabafd1a0c2005-12-12 00:37:27 -0800489 int (*get_stc) (struct dmx_demux* demux, unsigned int num,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700490 u64 *stc, unsigned int *base);
491};
492
Linus Torvalds1da177e2005-04-16 15:20:36 -0700493#endif /* #ifndef __DEMUX_H */