Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | #ifndef _AV7110_H_ |
2 | #define _AV7110_H_ | |
3 | ||
4 | #include <linux/interrupt.h> | |
5 | #include <linux/socket.h> | |
6 | #include <linux/netdevice.h> | |
7 | #include <linux/i2c.h> | |
ee820a64 | 8 | #include <linux/input.h> |
1da177e4 | 9 | |
1da177e4 LT |
10 | #include <linux/dvb/video.h> |
11 | #include <linux/dvb/audio.h> | |
12 | #include <linux/dvb/dmx.h> | |
13 | #include <linux/dvb/ca.h> | |
14 | #include <linux/dvb/osd.h> | |
15 | #include <linux/dvb/net.h> | |
3593cab5 | 16 | #include <linux/mutex.h> |
1da177e4 LT |
17 | |
18 | #include "dvbdev.h" | |
19 | #include "demux.h" | |
20 | #include "dvb_demux.h" | |
21 | #include "dmxdev.h" | |
22 | #include "dvb_filter.h" | |
23 | #include "dvb_net.h" | |
24 | #include "dvb_ringbuffer.h" | |
25 | #include "dvb_frontend.h" | |
26 | #include "ves1820.h" | |
27 | #include "ves1x93.h" | |
28 | #include "stv0299.h" | |
29 | #include "tda8083.h" | |
30 | #include "sp8870.h" | |
31 | #include "stv0297.h" | |
32 | #include "l64781.h" | |
33 | ||
34 | #include <media/saa7146_vv.h> | |
35 | ||
36 | ||
37 | #define ANALOG_TUNER_VES1820 1 | |
38 | #define ANALOG_TUNER_STV0297 2 | |
1da177e4 LT |
39 | |
40 | extern int av7110_debug; | |
41 | ||
42 | #define dprintk(level,args...) \ | |
43 | do { if ((av7110_debug & level)) { printk("dvb-ttpci: %s(): ", __FUNCTION__); printk(args); } } while (0) | |
44 | ||
45 | #define MAXFILT 32 | |
46 | ||
47 | enum {AV_PES_STREAM, PS_STREAM, TS_STREAM, PES_STREAM}; | |
48 | ||
58a44040 MS |
49 | enum av7110_video_mode { |
50 | AV7110_VIDEO_MODE_PAL = 0, | |
51 | AV7110_VIDEO_MODE_NTSC = 1 | |
52 | }; | |
53 | ||
1da177e4 LT |
54 | struct av7110_p2t { |
55 | u8 pes[TS_SIZE]; | |
56 | u8 counter; | |
57 | long int pos; | |
58 | int frags; | |
59 | struct dvb_demux_feed *feed; | |
60 | }; | |
61 | ||
62 | /* video MPEG decoder events: */ | |
63 | /* (code copied from dvb_frontend.c, should maybe be factored out...) */ | |
64 | #define MAX_VIDEO_EVENT 8 | |
65 | struct dvb_video_events { | |
66 | struct video_event events[MAX_VIDEO_EVENT]; | |
67 | int eventw; | |
68 | int eventr; | |
69 | int overflow; | |
70 | wait_queue_head_t wait_queue; | |
71 | spinlock_t lock; | |
72 | }; | |
73 | ||
74 | ||
ee820a64 OE |
75 | struct av7110; |
76 | ||
77 | /* infrared remote control */ | |
78 | struct infrared { | |
79 | u16 key_map[256]; | |
80 | struct input_dev *input_dev; | |
81 | char input_phys[32]; | |
82 | struct timer_list keyup_timer; | |
83 | struct tasklet_struct ir_tasklet; | |
84 | void (*ir_handler)(struct av7110 *av7110, u32 ircom); | |
85 | u32 ir_command; | |
86 | u32 ir_config; | |
87 | u32 device_mask; | |
88 | u8 protocol; | |
89 | u8 inversion; | |
90 | u16 last_key; | |
91 | u16 last_toggle; | |
92 | u8 delay_timer_finished; | |
93 | }; | |
94 | ||
95 | ||
1da177e4 LT |
96 | /* place to store all the necessary device information */ |
97 | struct av7110 { | |
98 | ||
99 | /* devices */ | |
100 | ||
101 | struct dvb_device dvb_dev; | |
102 | struct dvb_net dvb_net; | |
103 | ||
104 | struct video_device *v4l_dev; | |
105 | struct video_device *vbi_dev; | |
106 | ||
107 | struct saa7146_dev *dev; | |
108 | ||
109 | struct i2c_adapter i2c_adap; | |
110 | ||
111 | char *card_name; | |
112 | ||
113 | /* support for analog module of dvb-c */ | |
114 | int analog_tuner_flags; | |
115 | int current_input; | |
116 | u32 current_freq; | |
117 | ||
118 | struct tasklet_struct debi_tasklet; | |
119 | struct tasklet_struct gpio_tasklet; | |
120 | ||
121 | int adac_type; /* audio DAC type */ | |
122 | #define DVB_ADAC_TI 0 | |
123 | #define DVB_ADAC_CRYSTAL 1 | |
1c13b95c MS |
124 | #define DVB_ADAC_MSP34x0 2 |
125 | #define DVB_ADAC_MSP34x5 3 | |
1da177e4 LT |
126 | #define DVB_ADAC_NONE -1 |
127 | ||
128 | ||
129 | /* buffers */ | |
130 | ||
131 | void *iobuf; /* memory for all buffers */ | |
132 | struct dvb_ringbuffer avout; /* buffer for video or A/V mux */ | |
133 | #define AVOUTLEN (128*1024) | |
134 | struct dvb_ringbuffer aout; /* buffer for audio */ | |
135 | #define AOUTLEN (64*1024) | |
136 | void *bmpbuf; | |
137 | #define BMPLEN (8*32768+1024) | |
138 | ||
139 | /* bitmap buffers and states */ | |
140 | ||
141 | int bmpp; | |
142 | int bmplen; | |
143 | volatile int bmp_state; | |
144 | #define BMP_NONE 0 | |
145 | #define BMP_LOADING 1 | |
c9090ebb | 146 | #define BMP_LOADED 2 |
1da177e4 LT |
147 | wait_queue_head_t bmpq; |
148 | ||
149 | ||
150 | /* DEBI and polled command interface */ | |
151 | ||
152 | spinlock_t debilock; | |
3593cab5 | 153 | struct mutex dcomlock; |
1da177e4 LT |
154 | volatile int debitype; |
155 | volatile int debilen; | |
156 | ||
157 | ||
158 | /* Recording and playback flags */ | |
159 | ||
160 | int rec_mode; | |
161 | int playing; | |
162 | #define RP_NONE 0 | |
163 | #define RP_VIDEO 1 | |
164 | #define RP_AUDIO 2 | |
165 | #define RP_AV 3 | |
166 | ||
167 | ||
168 | /* OSD */ | |
169 | ||
170 | int osdwin; /* currently active window */ | |
171 | u16 osdbpp[8]; | |
3593cab5 | 172 | struct mutex osd_mutex; |
1da177e4 LT |
173 | |
174 | /* CA */ | |
175 | ||
176 | ca_slot_info_t ci_slot[2]; | |
177 | ||
58a44040 | 178 | enum av7110_video_mode vidmode; |
1da177e4 LT |
179 | struct dmxdev dmxdev; |
180 | struct dvb_demux demux; | |
181 | ||
182 | struct dmx_frontend hw_frontend; | |
183 | struct dmx_frontend mem_frontend; | |
184 | ||
185 | /* for budget mode demux1 */ | |
186 | struct dmxdev dmxdev1; | |
187 | struct dvb_demux demux1; | |
188 | struct dvb_net dvb_net1; | |
189 | spinlock_t feedlock1; | |
190 | int feeding1; | |
191 | u8 tsf; | |
192 | u32 ttbp; | |
193 | unsigned char *grabbing; | |
194 | struct saa7146_pgtable pt; | |
195 | struct tasklet_struct vpe_tasklet; | |
196 | ||
197 | int fe_synced; | |
3593cab5 | 198 | struct mutex pid_mutex; |
1da177e4 LT |
199 | |
200 | int video_blank; | |
201 | struct video_status videostate; | |
defd574e | 202 | u16 display_panscan; |
1da177e4 LT |
203 | int display_ar; |
204 | int trickmode; | |
205 | #define TRICK_NONE 0 | |
206 | #define TRICK_FAST 1 | |
207 | #define TRICK_SLOW 2 | |
208 | #define TRICK_FREEZE 3 | |
209 | struct audio_status audiostate; | |
210 | ||
211 | struct dvb_demux_filter *handle2filter[32]; | |
212 | struct av7110_p2t p2t_filter[MAXFILT]; | |
213 | struct dvb_filter_pes2ts p2t[2]; | |
214 | struct ipack ipack[2]; | |
215 | u8 *kbuf[2]; | |
216 | ||
217 | int sinfo; | |
218 | int feeding; | |
219 | ||
220 | int arm_errors; | |
221 | int registered; | |
222 | ||
223 | ||
224 | /* AV711X */ | |
225 | ||
226 | u32 arm_fw; | |
227 | u32 arm_rtsl; | |
228 | u32 arm_vid; | |
229 | u32 arm_app; | |
230 | u32 avtype; | |
231 | int arm_ready; | |
232 | struct task_struct *arm_thread; | |
233 | wait_queue_head_t arm_wait; | |
234 | u16 arm_loops; | |
1da177e4 LT |
235 | |
236 | void *debi_virt; | |
237 | dma_addr_t debi_bus; | |
238 | ||
239 | u16 pids[DMX_PES_OTHER]; | |
240 | ||
241 | struct dvb_ringbuffer ci_rbuffer; | |
242 | struct dvb_ringbuffer ci_wbuffer; | |
243 | ||
244 | struct audio_mixer mixer; | |
245 | ||
fdc53a6d | 246 | struct dvb_adapter dvb_adapter; |
1da177e4 LT |
247 | struct dvb_device *video_dev; |
248 | struct dvb_device *audio_dev; | |
249 | struct dvb_device *ca_dev; | |
250 | struct dvb_device *osd_dev; | |
251 | ||
252 | struct dvb_video_events video_events; | |
253 | video_size_t video_size; | |
254 | ||
5b0fa4ff OE |
255 | u16 wssMode; |
256 | u16 wssData; | |
257 | ||
ee820a64 | 258 | struct infrared ir; |
1da177e4 LT |
259 | |
260 | /* firmware stuff */ | |
261 | unsigned char *bin_fw; | |
262 | unsigned long size_fw; | |
263 | ||
264 | unsigned char *bin_dpram; | |
265 | unsigned long size_dpram; | |
266 | ||
267 | unsigned char *bin_root; | |
268 | unsigned long size_root; | |
269 | ||
270 | struct dvb_frontend* fe; | |
271 | fe_status_t fe_status; | |
66190a27 OE |
272 | |
273 | /* crash recovery */ | |
274 | void (*recover)(struct av7110* av7110); | |
275 | struct dvb_frontend_parameters saved_fe_params; | |
276 | fe_sec_voltage_t saved_voltage; | |
277 | fe_sec_tone_mode_t saved_tone; | |
278 | struct dvb_diseqc_master_cmd saved_master_cmd; | |
279 | fe_sec_mini_cmd_t saved_minicmd; | |
280 | ||
1da177e4 LT |
281 | int (*fe_init)(struct dvb_frontend* fe); |
282 | int (*fe_read_status)(struct dvb_frontend* fe, fe_status_t* status); | |
283 | int (*fe_diseqc_reset_overload)(struct dvb_frontend* fe); | |
284 | int (*fe_diseqc_send_master_cmd)(struct dvb_frontend* fe, struct dvb_diseqc_master_cmd* cmd); | |
285 | int (*fe_diseqc_send_burst)(struct dvb_frontend* fe, fe_sec_mini_cmd_t minicmd); | |
286 | int (*fe_set_tone)(struct dvb_frontend* fe, fe_sec_tone_mode_t tone); | |
287 | int (*fe_set_voltage)(struct dvb_frontend* fe, fe_sec_voltage_t voltage); | |
400b7083 | 288 | int (*fe_dishnetwork_send_legacy_command)(struct dvb_frontend* fe, unsigned long cmd); |
1da177e4 LT |
289 | int (*fe_set_frontend)(struct dvb_frontend* fe, struct dvb_frontend_parameters* params); |
290 | }; | |
291 | ||
292 | ||
ce18a223 | 293 | extern int ChangePIDs(struct av7110 *av7110, u16 vpid, u16 apid, u16 ttpid, |
1da177e4 LT |
294 | u16 subpid, u16 pcrpid); |
295 | ||
ee820a64 | 296 | extern int av7110_check_ir_config(struct av7110 *av7110, int force); |
03388ae3 OE |
297 | extern int av7110_ir_init(struct av7110 *av7110); |
298 | extern void av7110_ir_exit(struct av7110 *av7110); | |
1da177e4 LT |
299 | |
300 | /* msp3400 i2c subaddresses */ | |
301 | #define MSP_WR_DEM 0x10 | |
302 | #define MSP_RD_DEM 0x11 | |
303 | #define MSP_WR_DSP 0x12 | |
304 | #define MSP_RD_DSP 0x13 | |
305 | ||
306 | extern int i2c_writereg(struct av7110 *av7110, u8 id, u8 reg, u8 val); | |
307 | extern u8 i2c_readreg(struct av7110 *av7110, u8 id, u8 reg); | |
308 | extern int msp_writereg(struct av7110 *av7110, u8 dev, u16 reg, u16 val); | |
1da177e4 LT |
309 | |
310 | ||
311 | extern int av7110_init_analog_module(struct av7110 *av7110); | |
312 | extern int av7110_init_v4l(struct av7110 *av7110); | |
313 | extern int av7110_exit_v4l(struct av7110 *av7110); | |
314 | ||
315 | #endif /* _AV7110_H_ */ |