blob: 0cb43952749891855ceefe5a7c6fd9c0fbffc0e1 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#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>
Oliver Endrissee820a62007-04-27 12:31:21 -03008#include <linux/input.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -07009
Linus Torvalds1da177e2005-04-16 15:20:36 -070010#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>
Ingo Molnar3593cab2006-02-07 06:49:14 -020016#include <linux/mutex.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070017
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
Linus Torvalds1da177e2005-04-16 15:20:36 -070039
40extern 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
47enum {AV_PES_STREAM, PS_STREAM, TS_STREAM, PES_STREAM};
48
49struct av7110_p2t {
50 u8 pes[TS_SIZE];
51 u8 counter;
52 long int pos;
53 int frags;
54 struct dvb_demux_feed *feed;
55};
56
57/* video MPEG decoder events: */
58/* (code copied from dvb_frontend.c, should maybe be factored out...) */
59#define MAX_VIDEO_EVENT 8
60struct dvb_video_events {
61 struct video_event events[MAX_VIDEO_EVENT];
62 int eventw;
63 int eventr;
64 int overflow;
65 wait_queue_head_t wait_queue;
66 spinlock_t lock;
67};
68
69
Oliver Endrissee820a62007-04-27 12:31:21 -030070struct av7110;
71
72/* infrared remote control */
73struct infrared {
74 u16 key_map[256];
75 struct input_dev *input_dev;
76 char input_phys[32];
77 struct timer_list keyup_timer;
78 struct tasklet_struct ir_tasklet;
79 void (*ir_handler)(struct av7110 *av7110, u32 ircom);
80 u32 ir_command;
81 u32 ir_config;
82 u32 device_mask;
83 u8 protocol;
84 u8 inversion;
85 u16 last_key;
86 u16 last_toggle;
87 u8 delay_timer_finished;
88};
89
90
Linus Torvalds1da177e2005-04-16 15:20:36 -070091/* place to store all the necessary device information */
92struct av7110 {
93
94 /* devices */
95
96 struct dvb_device dvb_dev;
97 struct dvb_net dvb_net;
98
99 struct video_device *v4l_dev;
100 struct video_device *vbi_dev;
101
102 struct saa7146_dev *dev;
103
104 struct i2c_adapter i2c_adap;
105
106 char *card_name;
107
108 /* support for analog module of dvb-c */
109 int analog_tuner_flags;
110 int current_input;
111 u32 current_freq;
112
113 struct tasklet_struct debi_tasklet;
114 struct tasklet_struct gpio_tasklet;
115
116 int adac_type; /* audio DAC type */
117#define DVB_ADAC_TI 0
118#define DVB_ADAC_CRYSTAL 1
Marco Schluessler1c13b952006-01-09 15:25:06 -0200119#define DVB_ADAC_MSP34x0 2
120#define DVB_ADAC_MSP34x5 3
Linus Torvalds1da177e2005-04-16 15:20:36 -0700121#define DVB_ADAC_NONE -1
122
123
124 /* buffers */
125
126 void *iobuf; /* memory for all buffers */
127 struct dvb_ringbuffer avout; /* buffer for video or A/V mux */
128#define AVOUTLEN (128*1024)
129 struct dvb_ringbuffer aout; /* buffer for audio */
130#define AOUTLEN (64*1024)
131 void *bmpbuf;
132#define BMPLEN (8*32768+1024)
133
134 /* bitmap buffers and states */
135
136 int bmpp;
137 int bmplen;
138 volatile int bmp_state;
139#define BMP_NONE 0
140#define BMP_LOADING 1
Wolfgang Rohdewaldc9090eb2005-07-07 17:57:55 -0700141#define BMP_LOADED 2
Linus Torvalds1da177e2005-04-16 15:20:36 -0700142 wait_queue_head_t bmpq;
143
144
145 /* DEBI and polled command interface */
146
147 spinlock_t debilock;
Ingo Molnar3593cab2006-02-07 06:49:14 -0200148 struct mutex dcomlock;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700149 volatile int debitype;
150 volatile int debilen;
151
152
153 /* Recording and playback flags */
154
155 int rec_mode;
156 int playing;
157#define RP_NONE 0
158#define RP_VIDEO 1
159#define RP_AUDIO 2
160#define RP_AV 3
161
162
163 /* OSD */
164
165 int osdwin; /* currently active window */
166 u16 osdbpp[8];
Ingo Molnar3593cab2006-02-07 06:49:14 -0200167 struct mutex osd_mutex;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700168
169 /* CA */
170
171 ca_slot_info_t ci_slot[2];
172
173 int vidmode;
174 struct dmxdev dmxdev;
175 struct dvb_demux demux;
176
177 struct dmx_frontend hw_frontend;
178 struct dmx_frontend mem_frontend;
179
180 /* for budget mode demux1 */
181 struct dmxdev dmxdev1;
182 struct dvb_demux demux1;
183 struct dvb_net dvb_net1;
184 spinlock_t feedlock1;
185 int feeding1;
186 u8 tsf;
187 u32 ttbp;
188 unsigned char *grabbing;
189 struct saa7146_pgtable pt;
190 struct tasklet_struct vpe_tasklet;
191
192 int fe_synced;
Ingo Molnar3593cab2006-02-07 06:49:14 -0200193 struct mutex pid_mutex;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700194
195 int video_blank;
196 struct video_status videostate;
Oliver Endrissdefd574e2007-07-12 23:08:07 -0300197 u16 display_panscan;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700198 int display_ar;
199 int trickmode;
200#define TRICK_NONE 0
201#define TRICK_FAST 1
202#define TRICK_SLOW 2
203#define TRICK_FREEZE 3
204 struct audio_status audiostate;
205
206 struct dvb_demux_filter *handle2filter[32];
207 struct av7110_p2t p2t_filter[MAXFILT];
208 struct dvb_filter_pes2ts p2t[2];
209 struct ipack ipack[2];
210 u8 *kbuf[2];
211
212 int sinfo;
213 int feeding;
214
215 int arm_errors;
216 int registered;
217
218
219 /* AV711X */
220
221 u32 arm_fw;
222 u32 arm_rtsl;
223 u32 arm_vid;
224 u32 arm_app;
225 u32 avtype;
226 int arm_ready;
227 struct task_struct *arm_thread;
228 wait_queue_head_t arm_wait;
229 u16 arm_loops;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700230
231 void *debi_virt;
232 dma_addr_t debi_bus;
233
234 u16 pids[DMX_PES_OTHER];
235
236 struct dvb_ringbuffer ci_rbuffer;
237 struct dvb_ringbuffer ci_wbuffer;
238
239 struct audio_mixer mixer;
240
Johannes Stezenbachfdc53a62005-05-16 21:54:39 -0700241 struct dvb_adapter dvb_adapter;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700242 struct dvb_device *video_dev;
243 struct dvb_device *audio_dev;
244 struct dvb_device *ca_dev;
245 struct dvb_device *osd_dev;
246
247 struct dvb_video_events video_events;
248 video_size_t video_size;
249
Oliver Endriss5b0fa4f2006-01-09 18:21:37 -0200250 u16 wssMode;
251 u16 wssData;
252
Oliver Endrissee820a62007-04-27 12:31:21 -0300253 struct infrared ir;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700254
255 /* firmware stuff */
256 unsigned char *bin_fw;
257 unsigned long size_fw;
258
259 unsigned char *bin_dpram;
260 unsigned long size_dpram;
261
262 unsigned char *bin_root;
263 unsigned long size_root;
264
265 struct dvb_frontend* fe;
266 fe_status_t fe_status;
Oliver Endriss66190a22006-01-09 15:32:42 -0200267
268 /* crash recovery */
269 void (*recover)(struct av7110* av7110);
270 struct dvb_frontend_parameters saved_fe_params;
271 fe_sec_voltage_t saved_voltage;
272 fe_sec_tone_mode_t saved_tone;
273 struct dvb_diseqc_master_cmd saved_master_cmd;
274 fe_sec_mini_cmd_t saved_minicmd;
275
Linus Torvalds1da177e2005-04-16 15:20:36 -0700276 int (*fe_init)(struct dvb_frontend* fe);
277 int (*fe_read_status)(struct dvb_frontend* fe, fe_status_t* status);
278 int (*fe_diseqc_reset_overload)(struct dvb_frontend* fe);
279 int (*fe_diseqc_send_master_cmd)(struct dvb_frontend* fe, struct dvb_diseqc_master_cmd* cmd);
280 int (*fe_diseqc_send_burst)(struct dvb_frontend* fe, fe_sec_mini_cmd_t minicmd);
281 int (*fe_set_tone)(struct dvb_frontend* fe, fe_sec_tone_mode_t tone);
282 int (*fe_set_voltage)(struct dvb_frontend* fe, fe_sec_voltage_t voltage);
Peter Beutner400b7082006-01-09 15:32:43 -0200283 int (*fe_dishnetwork_send_legacy_command)(struct dvb_frontend* fe, unsigned long cmd);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700284 int (*fe_set_frontend)(struct dvb_frontend* fe, struct dvb_frontend_parameters* params);
285};
286
287
Wolfgang Rohdewaldce18a222005-07-07 17:57:59 -0700288extern int ChangePIDs(struct av7110 *av7110, u16 vpid, u16 apid, u16 ttpid,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700289 u16 subpid, u16 pcrpid);
290
Oliver Endrissee820a62007-04-27 12:31:21 -0300291extern int av7110_check_ir_config(struct av7110 *av7110, int force);
Oliver Endriss03388ae2005-09-09 13:03:12 -0700292extern int av7110_ir_init(struct av7110 *av7110);
293extern void av7110_ir_exit(struct av7110 *av7110);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700294
295/* msp3400 i2c subaddresses */
296#define MSP_WR_DEM 0x10
297#define MSP_RD_DEM 0x11
298#define MSP_WR_DSP 0x12
299#define MSP_RD_DSP 0x13
300
301extern int i2c_writereg(struct av7110 *av7110, u8 id, u8 reg, u8 val);
302extern u8 i2c_readreg(struct av7110 *av7110, u8 id, u8 reg);
303extern int msp_writereg(struct av7110 *av7110, u8 dev, u16 reg, u16 val);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700304
305
306extern int av7110_init_analog_module(struct av7110 *av7110);
307extern int av7110_init_v4l(struct av7110 *av7110);
308extern int av7110_exit_v4l(struct av7110 *av7110);
309
310#endif /* _AV7110_H_ */