]>
Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | /* |
2 | * dmxdev.h | |
3 | * | |
4 | * Copyright (C) 2000 Ralph Metzler & Marcus Metzler | |
5 | * for convergence integrated media GmbH | |
6 | * | |
7 | * This program is free software; you can redistribute it and/or | |
8 | * modify it under the terms of the GNU Lesser General Public License | |
9 | * as published by the Free Software Foundation; either version 2.1 | |
10 | * of the License, or (at your option) any later version. | |
11 | * | |
12 | * This program is distributed in the hope that it will be useful, | |
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | * GNU General Public License for more details. | |
16 | * | |
1da177e4 LT |
17 | */ |
18 | ||
19 | #ifndef _DMXDEV_H_ | |
20 | #define _DMXDEV_H_ | |
21 | ||
22 | #include <linux/types.h> | |
23 | #include <linux/spinlock.h> | |
24 | #include <linux/kernel.h> | |
b2409b65 | 25 | #include <linux/time.h> |
1da177e4 LT |
26 | #include <linux/timer.h> |
27 | #include <linux/wait.h> | |
28 | #include <linux/fs.h> | |
29 | #include <linux/string.h> | |
3593cab5 | 30 | #include <linux/mutex.h> |
5a0e3ad6 | 31 | #include <linux/slab.h> |
1da177e4 LT |
32 | |
33 | #include <linux/dvb/dmx.h> | |
34 | ||
fada1935 MCC |
35 | #include <media/dvbdev.h> |
36 | #include <media/demux.h> | |
37 | #include <media/dvb_ringbuffer.h> | |
38 | #include <media/dvb_vb2.h> | |
1da177e4 | 39 | |
e7446385 MCC |
40 | /** |
41 | * enum dmxdev_type - type of demux filter type. | |
42 | * | |
43 | * @DMXDEV_TYPE_NONE: no filter set. | |
44 | * @DMXDEV_TYPE_SEC: section filter. | |
45 | * @DMXDEV_TYPE_PES: Program Elementary Stream (PES) filter. | |
46 | */ | |
bbad7dc5 | 47 | enum dmxdev_type { |
1da177e4 LT |
48 | DMXDEV_TYPE_NONE, |
49 | DMXDEV_TYPE_SEC, | |
50 | DMXDEV_TYPE_PES, | |
51 | }; | |
52 | ||
e7446385 MCC |
53 | /** |
54 | * enum dmxdev_state - state machine for the dmxdev. | |
55 | * | |
56 | * @DMXDEV_STATE_FREE: indicates that the filter is freed. | |
57 | * @DMXDEV_STATE_ALLOCATED: indicates that the filter was allocated | |
58 | * to be used. | |
59 | * @DMXDEV_STATE_SET: indicates that the filter parameters are set. | |
60 | * @DMXDEV_STATE_GO: indicates that the filter is running. | |
61 | * @DMXDEV_STATE_DONE: indicates that a packet was already filtered | |
62 | * and the filter is now disabled. | |
63 | * Set only if %DMX_ONESHOT. See | |
64 | * &dmx_sct_filter_params. | |
65 | * @DMXDEV_STATE_TIMEDOUT: Indicates a timeout condition. | |
66 | */ | |
1da177e4 LT |
67 | enum dmxdev_state { |
68 | DMXDEV_STATE_FREE, | |
69 | DMXDEV_STATE_ALLOCATED, | |
70 | DMXDEV_STATE_SET, | |
71 | DMXDEV_STATE_GO, | |
72 | DMXDEV_STATE_DONE, | |
73 | DMXDEV_STATE_TIMEDOUT | |
74 | }; | |
75 | ||
e7446385 MCC |
76 | /** |
77 | * struct dmxdev_feed - digital TV dmxdev feed | |
78 | * | |
79 | * @pid: Program ID to be filtered | |
80 | * @ts: pointer to &struct dmx_ts_feed | |
81 | * @next: &struct list_head pointing to the next feed. | |
82 | */ | |
83 | ||
1cb662a3 AO |
84 | struct dmxdev_feed { |
85 | u16 pid; | |
86 | struct dmx_ts_feed *ts; | |
87 | struct list_head next; | |
88 | }; | |
89 | ||
e7446385 MCC |
90 | /** |
91 | * struct dmxdev_filter - digital TV dmxdev filter | |
92 | * | |
3483d3ae MCC |
93 | * @filter: a union describing a dmxdev filter. |
94 | * Currently used only for section filters. | |
95 | * @filter.sec: a &struct dmx_section_filter pointer. | |
96 | * For section filter only. | |
97 | * @feed: a union describing a dmxdev feed. | |
98 | * Depending on the filter type, it can be either | |
99 | * @feed.ts or @feed.sec. | |
100 | * @feed.ts: a &struct list_head list. | |
101 | * For TS and PES feeds. | |
102 | * @feed.sec: a &struct dmx_section_feed pointer. | |
103 | * For section feed only. | |
104 | * @params: a union describing dmxdev filter parameters. | |
105 | * Depending on the filter type, it can be either | |
106 | * @params.sec or @params.pes. | |
107 | * @params.sec: a &struct dmx_sct_filter_params embedded struct. | |
108 | * For section filter only. | |
109 | * @params.pes: a &struct dmx_pes_filter_params embedded struct. | |
110 | * For PES filter only. | |
e7446385 MCC |
111 | * @type: type of the dmxdev filter, as defined by &enum dmxdev_type. |
112 | * @state: state of the dmxdev filter, as defined by &enum dmxdev_state. | |
113 | * @dev: pointer to &struct dmxdev. | |
114 | * @buffer: an embedded &struct dvb_ringbuffer buffer. | |
9f577d6d | 115 | * @vb2_ctx: control struct for VB2 handler |
e7446385 MCC |
116 | * @mutex: protects the access to &struct dmxdev_filter. |
117 | * @timer: &struct timer_list embedded timer, used to check for | |
118 | * feed timeouts. | |
119 | * Only for section filter. | |
120 | * @todo: index for the @secheader. | |
121 | * Only for section filter. | |
122 | * @secheader: buffer cache to parse the section header. | |
123 | * Only for section filter. | |
124 | */ | |
1da177e4 | 125 | struct dmxdev_filter { |
afd1a0c9 MCC |
126 | union { |
127 | struct dmx_section_filter *sec; | |
1da177e4 LT |
128 | } filter; |
129 | ||
afd1a0c9 | 130 | union { |
1cb662a3 AO |
131 | /* list of TS and PES feeds (struct dmxdev_feed) */ |
132 | struct list_head ts; | |
afd1a0c9 | 133 | struct dmx_section_feed *sec; |
1da177e4 LT |
134 | } feed; |
135 | ||
afd1a0c9 MCC |
136 | union { |
137 | struct dmx_sct_filter_params sec; | |
138 | struct dmx_pes_filter_params pes; | |
1da177e4 LT |
139 | } params; |
140 | ||
bbad7dc5 | 141 | enum dmxdev_type type; |
afd1a0c9 MCC |
142 | enum dmxdev_state state; |
143 | struct dmxdev *dev; | |
34731df2 | 144 | struct dvb_ringbuffer buffer; |
57868acc | 145 | struct dvb_vb2_ctx vb2_ctx; |
1da177e4 | 146 | |
3593cab5 | 147 | struct mutex mutex; |
1da177e4 | 148 | |
afd1a0c9 MCC |
149 | /* only for sections */ |
150 | struct timer_list timer; | |
151 | int todo; | |
152 | u8 secheader[3]; | |
1da177e4 LT |
153 | }; |
154 | ||
e7446385 MCC |
155 | /** |
156 | * struct dmxdev - Describes a digital TV demux device. | |
157 | * | |
158 | * @dvbdev: pointer to &struct dvb_device associated with | |
159 | * the demux device node. | |
160 | * @dvr_dvbdev: pointer to &struct dvb_device associated with | |
161 | * the dvr device node. | |
162 | * @filter: pointer to &struct dmxdev_filter. | |
163 | * @demux: pointer to &struct dmx_demux. | |
164 | * @filternum: number of filters. | |
165 | * @capabilities: demux capabilities as defined by &enum dmx_demux_caps. | |
0b23498a | 166 | * @may_do_mmap: flag used to indicate if the device may do mmap. |
e7446385 MCC |
167 | * @exit: flag to indicate that the demux is being released. |
168 | * @dvr_orig_fe: pointer to &struct dmx_frontend. | |
169 | * @dvr_buffer: embedded &struct dvb_ringbuffer for DVB output. | |
9f577d6d | 170 | * @dvr_vb2_ctx: control struct for VB2 handler |
e7446385 MCC |
171 | * @mutex: protects the usage of this structure. |
172 | * @lock: protects access to &dmxdev->filter->data. | |
173 | */ | |
1da177e4 LT |
174 | struct dmxdev { |
175 | struct dvb_device *dvbdev; | |
176 | struct dvb_device *dvr_dvbdev; | |
177 | ||
afd1a0c9 | 178 | struct dmxdev_filter *filter; |
afd1a0c9 | 179 | struct dmx_demux *demux; |
1da177e4 | 180 | |
afd1a0c9 MCC |
181 | int filternum; |
182 | int capabilities; | |
57861b43 | 183 | |
0b23498a | 184 | unsigned int may_do_mmap:1; |
57861b43 | 185 | unsigned int exit:1; |
1da177e4 | 186 | #define DMXDEV_CAP_DUPLEX 1 |
afd1a0c9 | 187 | struct dmx_frontend *dvr_orig_fe; |
1da177e4 | 188 | |
34731df2 | 189 | struct dvb_ringbuffer dvr_buffer; |
1da177e4 LT |
190 | #define DVR_BUFFER_SIZE (10*188*1024) |
191 | ||
57868acc SST |
192 | struct dvb_vb2_ctx dvr_vb2_ctx; |
193 | ||
3593cab5 | 194 | struct mutex mutex; |
1da177e4 LT |
195 | spinlock_t lock; |
196 | }; | |
197 | ||
e7446385 MCC |
198 | /** |
199 | * dvb_dmxdev_init - initializes a digital TV demux and registers both demux | |
200 | * and DVR devices. | |
201 | * | |
202 | * @dmxdev: pointer to &struct dmxdev. | |
203 | * @adap: pointer to &struct dvb_adapter. | |
204 | */ | |
205 | int dvb_dmxdev_init(struct dmxdev *dmxdev, struct dvb_adapter *adap); | |
1da177e4 | 206 | |
e7446385 MCC |
207 | /** |
208 | * dvb_dmxdev_release - releases a digital TV demux and unregisters it. | |
209 | * | |
210 | * @dmxdev: pointer to &struct dmxdev. | |
211 | */ | |
1da177e4 LT |
212 | void dvb_dmxdev_release(struct dmxdev *dmxdev); |
213 | ||
214 | #endif /* _DMXDEV_H_ */ |