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