RT-AC66 3.0.0.4.374.130 core
[tomato.git] / release / src-rt-6.x / linux / linux-2.6 / drivers / media / dvb / ttpci / av7110.h
blob115002b0390ca40bbad0c57b52fe457a0ef529a5
1 #ifndef _AV7110_H_
2 #define _AV7110_H_
4 #include <linux/interrupt.h>
5 #include <linux/socket.h>
6 #include <linux/netdevice.h>
7 #include <linux/i2c.h>
8 #include <linux/input.h>
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>
16 #include <linux/mutex.h>
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"
34 #include <media/saa7146_vv.h>
37 #define ANALOG_TUNER_VES1820 1
38 #define ANALOG_TUNER_STV0297 2
40 extern int av7110_debug;
42 #define dprintk(level,args...) \
43 do { if ((av7110_debug & level)) { printk("dvb-ttpci: %s(): ", __FUNCTION__); printk(args); } } while (0)
45 #define MAXFILT 32
47 enum {AV_PES_STREAM, PS_STREAM, TS_STREAM, PES_STREAM};
49 struct av7110_p2t {
50 u8 pes[TS_SIZE];
51 u8 counter;
52 long int pos;
53 int frags;
54 struct dvb_demux_feed *feed;
57 /* video MPEG decoder events: */
58 /* (code copied from dvb_frontend.c, should maybe be factored out...) */
59 #define MAX_VIDEO_EVENT 8
60 struct 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;
70 struct av7110;
72 /* infrared remote control */
73 struct 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;
91 /* place to store all the necessary device information */
92 struct av7110 {
94 /* devices */
96 struct dvb_device dvb_dev;
97 struct dvb_net dvb_net;
99 struct video_device *v4l_dev;
100 struct video_device *vbi_dev;
102 struct saa7146_dev *dev;
104 struct i2c_adapter i2c_adap;
106 char *card_name;
108 /* support for analog module of dvb-c */
109 int analog_tuner_flags;
110 int current_input;
111 u32 current_freq;
113 struct tasklet_struct debi_tasklet;
114 struct tasklet_struct gpio_tasklet;
116 int adac_type; /* audio DAC type */
117 #define DVB_ADAC_TI 0
118 #define DVB_ADAC_CRYSTAL 1
119 #define DVB_ADAC_MSP34x0 2
120 #define DVB_ADAC_MSP34x5 3
121 #define DVB_ADAC_NONE -1
124 /* buffers */
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)
134 /* bitmap buffers and states */
136 int bmpp;
137 int bmplen;
138 volatile int bmp_state;
139 #define BMP_NONE 0
140 #define BMP_LOADING 1
141 #define BMP_LOADED 2
142 wait_queue_head_t bmpq;
145 /* DEBI and polled command interface */
147 spinlock_t debilock;
148 struct mutex dcomlock;
149 volatile int debitype;
150 volatile int debilen;
153 /* Recording and playback flags */
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
163 /* OSD */
165 int osdwin; /* currently active window */
166 u16 osdbpp[8];
167 struct mutex osd_mutex;
169 /* CA */
171 ca_slot_info_t ci_slot[2];
173 int vidmode;
174 struct dmxdev dmxdev;
175 struct dvb_demux demux;
177 struct dmx_frontend hw_frontend;
178 struct dmx_frontend mem_frontend;
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;
192 int fe_synced;
193 struct mutex pid_mutex;
195 int video_blank;
196 struct video_status videostate;
197 int display_ar;
198 int trickmode;
199 #define TRICK_NONE 0
200 #define TRICK_FAST 1
201 #define TRICK_SLOW 2
202 #define TRICK_FREEZE 3
203 struct audio_status audiostate;
205 struct dvb_demux_filter *handle2filter[32];
206 struct av7110_p2t p2t_filter[MAXFILT];
207 struct dvb_filter_pes2ts p2t[2];
208 struct ipack ipack[2];
209 u8 *kbuf[2];
211 int sinfo;
212 int feeding;
214 int arm_errors;
215 int registered;
218 /* AV711X */
220 u32 arm_fw;
221 u32 arm_rtsl;
222 u32 arm_vid;
223 u32 arm_app;
224 u32 avtype;
225 int arm_ready;
226 struct task_struct *arm_thread;
227 wait_queue_head_t arm_wait;
228 u16 arm_loops;
230 void *debi_virt;
231 dma_addr_t debi_bus;
233 u16 pids[DMX_PES_OTHER];
235 struct dvb_ringbuffer ci_rbuffer;
236 struct dvb_ringbuffer ci_wbuffer;
238 struct audio_mixer mixer;
240 struct dvb_adapter dvb_adapter;
241 struct dvb_device *video_dev;
242 struct dvb_device *audio_dev;
243 struct dvb_device *ca_dev;
244 struct dvb_device *osd_dev;
246 struct dvb_video_events video_events;
247 video_size_t video_size;
249 u16 wssMode;
250 u16 wssData;
252 struct infrared ir;
254 /* firmware stuff */
255 unsigned char *bin_fw;
256 unsigned long size_fw;
258 unsigned char *bin_dpram;
259 unsigned long size_dpram;
261 unsigned char *bin_root;
262 unsigned long size_root;
264 struct dvb_frontend* fe;
265 fe_status_t fe_status;
267 /* crash recovery */
268 void (*recover)(struct av7110* av7110);
269 struct dvb_frontend_parameters saved_fe_params;
270 fe_sec_voltage_t saved_voltage;
271 fe_sec_tone_mode_t saved_tone;
272 struct dvb_diseqc_master_cmd saved_master_cmd;
273 fe_sec_mini_cmd_t saved_minicmd;
275 int (*fe_init)(struct dvb_frontend* fe);
276 int (*fe_read_status)(struct dvb_frontend* fe, fe_status_t* status);
277 int (*fe_diseqc_reset_overload)(struct dvb_frontend* fe);
278 int (*fe_diseqc_send_master_cmd)(struct dvb_frontend* fe, struct dvb_diseqc_master_cmd* cmd);
279 int (*fe_diseqc_send_burst)(struct dvb_frontend* fe, fe_sec_mini_cmd_t minicmd);
280 int (*fe_set_tone)(struct dvb_frontend* fe, fe_sec_tone_mode_t tone);
281 int (*fe_set_voltage)(struct dvb_frontend* fe, fe_sec_voltage_t voltage);
282 int (*fe_dishnetwork_send_legacy_command)(struct dvb_frontend* fe, unsigned long cmd);
283 int (*fe_set_frontend)(struct dvb_frontend* fe, struct dvb_frontend_parameters* params);
287 extern int ChangePIDs(struct av7110 *av7110, u16 vpid, u16 apid, u16 ttpid,
288 u16 subpid, u16 pcrpid);
290 extern int av7110_check_ir_config(struct av7110 *av7110, int force);
291 extern int av7110_ir_init(struct av7110 *av7110);
292 extern void av7110_ir_exit(struct av7110 *av7110);
294 /* msp3400 i2c subaddresses */
295 #define MSP_WR_DEM 0x10
296 #define MSP_RD_DEM 0x11
297 #define MSP_WR_DSP 0x12
298 #define MSP_RD_DSP 0x13
300 extern int i2c_writereg(struct av7110 *av7110, u8 id, u8 reg, u8 val);
301 extern u8 i2c_readreg(struct av7110 *av7110, u8 id, u8 reg);
302 extern int msp_writereg(struct av7110 *av7110, u8 dev, u16 reg, u16 val);
305 extern int av7110_init_analog_module(struct av7110 *av7110);
306 extern int av7110_init_v4l(struct av7110 *av7110);
307 extern int av7110_exit_v4l(struct av7110 *av7110);
309 #endif /* _AV7110_H_ */