blob: d85b8512ac307cb2bfa59f3d695036a1a6a35515 [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...) \
Harvey Harrison3ca7fc82008-04-08 23:20:00 -030043 do { if ((av7110_debug & level)) { printk("dvb-ttpci: %s(): ", __func__); printk(args); } } while (0)
Linus Torvalds1da177e2005-04-16 15:20:36 -070044
45#define MAXFILT 32
46
47enum {AV_PES_STREAM, PS_STREAM, TS_STREAM, PES_STREAM};
48
Marco Schluessler58a44042007-10-31 01:20:42 -030049enum av7110_video_mode {
50 AV7110_VIDEO_MODE_PAL = 0,
51 AV7110_VIDEO_MODE_NTSC = 1
52};
53
Linus Torvalds1da177e2005-04-16 15:20:36 -070054struct 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
65struct 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
Oliver Endrissee820a62007-04-27 12:31:21 -030075struct av7110;
76
77/* infrared remote control */
78struct 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
Linus Torvalds1da177e2005-04-16 15:20:36 -070096/* place to store all the necessary device information */
97struct 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
Marco Schluessler1c13b952006-01-09 15:25:06 -0200124#define DVB_ADAC_MSP34x0 2
125#define DVB_ADAC_MSP34x5 3
Linus Torvalds1da177e2005-04-16 15:20:36 -0700126#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
Wolfgang Rohdewaldc9090eb2005-07-07 17:57:55 -0700146#define BMP_LOADED 2
Linus Torvalds1da177e2005-04-16 15:20:36 -0700147 wait_queue_head_t bmpq;
148
149
150 /* DEBI and polled command interface */
151
152 spinlock_t debilock;
Ingo Molnar3593cab2006-02-07 06:49:14 -0200153 struct mutex dcomlock;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700154 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];
Ingo Molnar3593cab2006-02-07 06:49:14 -0200172 struct mutex osd_mutex;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700173
174 /* CA */
175
176 ca_slot_info_t ci_slot[2];
177
Marco Schluessler58a44042007-10-31 01:20:42 -0300178 enum av7110_video_mode vidmode;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700179 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;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700191 u32 ttbp;
192 unsigned char *grabbing;
193 struct saa7146_pgtable pt;
194 struct tasklet_struct vpe_tasklet;
Oliver Endriss9e615ea2008-09-03 19:15:27 -0300195 bool full_ts;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700196
197 int fe_synced;
Ingo Molnar3593cab2006-02-07 06:49:14 -0200198 struct mutex pid_mutex;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700199
200 int video_blank;
201 struct video_status videostate;
Oliver Endrissdefd574e2007-07-12 23:08:07 -0300202 u16 display_panscan;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700203 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;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700235
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
Johannes Stezenbachfdc53a62005-05-16 21:54:39 -0700246 struct dvb_adapter dvb_adapter;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700247 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
Oliver Endriss5b0fa4f2006-01-09 18:21:37 -0200255 u16 wssMode;
256 u16 wssData;
257
Oliver Endrissee820a62007-04-27 12:31:21 -0300258 struct infrared ir;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700259
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;
Oliver Endriss66190a22006-01-09 15:32:42 -0200272
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
Linus Torvalds1da177e2005-04-16 15:20:36 -0700281 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);
Peter Beutner400b7082006-01-09 15:32:43 -0200288 int (*fe_dishnetwork_send_legacy_command)(struct dvb_frontend* fe, unsigned long cmd);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700289 int (*fe_set_frontend)(struct dvb_frontend* fe, struct dvb_frontend_parameters* params);
290};
291
292
Wolfgang Rohdewaldce18a222005-07-07 17:57:59 -0700293extern int ChangePIDs(struct av7110 *av7110, u16 vpid, u16 apid, u16 ttpid,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700294 u16 subpid, u16 pcrpid);
295
Oliver Endrissee820a62007-04-27 12:31:21 -0300296extern int av7110_check_ir_config(struct av7110 *av7110, int force);
Oliver Endriss03388ae2005-09-09 13:03:12 -0700297extern int av7110_ir_init(struct av7110 *av7110);
298extern void av7110_ir_exit(struct av7110 *av7110);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700299
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
306extern int i2c_writereg(struct av7110 *av7110, u8 id, u8 reg, u8 val);
307extern u8 i2c_readreg(struct av7110 *av7110, u8 id, u8 reg);
308extern int msp_writereg(struct av7110 *av7110, u8 dev, u16 reg, u16 val);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700309
310
311extern int av7110_init_analog_module(struct av7110 *av7110);
312extern int av7110_init_v4l(struct av7110 *av7110);
313extern int av7110_exit_v4l(struct av7110 *av7110);
314
315#endif /* _AV7110_H_ */