import of ftp.dlink.com/GPL/DSMG-600_reB/ppclinux.tar.gz
[linux-2.4.21-pre4.git] / drivers / media / video / bttvp.h
1 /*
2     bttv - Bt848 frame grabber driver
3
4     bttv's *private* header file  --  nobody else than bttv itself
5     should ever include this file.
6
7     Copyright (C) 1996,97 Ralph Metzler (rjkm@thp.uni-koeln.de)
8     (c) 1999,2000 Gerd Knorr <kraxel@goldbach.in-berlin.de>
9
10     This program is free software; you can redistribute it and/or modify
11     it under the terms of the GNU General Public License as published by
12     the Free Software Foundation; either version 2 of the License, or
13     (at your option) any later version.
14
15     This program is distributed in the hope that it will be useful,
16     but WITHOUT ANY WARRANTY; without even the implied warranty of
17     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18     GNU General Public License for more details.
19
20     You should have received a copy of the GNU General Public License
21     along with this program; if not, write to the Free Software
22     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 */
24
25 #ifndef _BTTVP_H_
26 #define _BTTVP_H_
27
28 #define BTTV_VERSION_CODE KERNEL_VERSION(0,7,96)
29
30 #include <linux/types.h>
31 #include <linux/wait.h>
32 #include <linux/i2c.h>
33 #include <linux/i2c-algo-bit.h>
34
35 #include "bt848.h"
36 #include "bttv.h"
37 #include "audiochip.h"
38
39 #ifdef __KERNEL__
40
41 /* ---------------------------------------------------------- */
42 /* bttv-driver.c                                              */
43
44 /* insmod options / kernel args */
45 extern int no_overlay;
46 extern unsigned int bttv_verbose;
47 extern unsigned int bttv_debug;
48 extern unsigned int bttv_gpio;
49 extern void bttv_gpio_tracking(struct bttv *btv, char *comment);
50 extern int init_bttv_i2c(struct bttv *btv);
51 extern int pvr_boot(struct bttv *btv);
52
53 #define dprintk         if (bttv_debug) printk
54
55 /* Anybody who uses more than four? */
56 #define BTTV_MAX 4
57 extern int bttv_num;                    /* number of Bt848s in use */
58 extern struct bttv bttvs[BTTV_MAX];
59
60
61 #ifndef O_NONCAP  
62 #define O_NONCAP        O_TRUNC
63 #endif
64
65 #ifdef VIDEODAT_HACK
66 # define VBI_MAXLINES   19
67 #else
68 # define VBI_MAXLINES   16
69 #endif
70 #define VBIBUF_SIZE     (2048*VBI_MAXLINES*2)
71 #define MAX_GBUFFERS    64
72 #define RISCMEM_LEN     (32744*2)
73
74 #define BTTV_MAX_FBUF   0x208000
75
76 struct bttv_window 
77 {
78         int x, y;
79         ushort width, height;
80         ushort bpp, bpl;
81         ushort swidth, sheight;
82         unsigned long vidadr;
83         ushort freq;
84         int norm;
85         int interlace;
86         int color_fmt;
87         ushort depth;
88 };
89
90 struct bttv_pll_info {
91         unsigned int pll_ifreq;    /* PLL input frequency        */
92         unsigned int pll_ofreq;    /* PLL output frequency       */
93         unsigned int pll_crystal;  /* Crystal used for input     */
94         unsigned int pll_current;  /* Currently programmed ofreq */
95 };
96
97 struct bttv_gbuf {
98         int stat;
99 #define GBUFFER_UNUSED       0
100 #define GBUFFER_GRABBING     1
101 #define GBUFFER_DONE         2
102 #define GBUFFER_ERROR        3
103         struct timeval tv;
104         
105         u16 width;
106         u16 height;
107         u16 fmt;
108         
109         u32 *risc;
110         unsigned long ro;
111         unsigned long re;
112 };
113
114 struct bttv {
115         struct video_device video_dev;
116         struct video_device radio_dev;
117         struct video_device vbi_dev;
118         struct video_picture picture;           /* Current picture params */
119         struct video_audio audio_dev;           /* Current audio params */
120
121         spinlock_t s_lock;
122         struct semaphore lock;
123         int user;
124         int capuser;
125
126         /* i2c */
127         struct i2c_adapter         i2c_adap;
128         struct i2c_algo_bit_data   i2c_algo;
129         struct i2c_client          i2c_client;
130         int                        i2c_state, i2c_rc;
131         struct i2c_client         *i2c_clients[I2C_CLIENTS_MAX];
132
133         int tuner_type;
134         int channel;
135         
136         unsigned int nr;
137         unsigned short id;
138         struct pci_dev *dev;
139         unsigned char revision;
140         unsigned long bt848_adr;      /* bus address of IO mem returned by PCI BIOS */
141         unsigned char *bt848_mem;   /* pointer to mapped IO memory */
142         unsigned long busriscmem; 
143         u32 *riscmem;
144   
145         unsigned char *vbibuf;
146         struct bttv_window win;
147         int fb_color_ctl;
148         int type;            /* card type  */
149         int cardid;
150         int audio;           /* audio mode */
151         int audio_chip;      /* set to one of the chips supported by bttv.c */
152         int radio;
153         int has_radio;
154
155         /* miro/pinnacle + Aimslab VHX
156            philips matchbox (tea5757 radio tuner) support */
157         int has_matchbox;
158         int mbox_we;
159         int mbox_data;
160         int mbox_clk;
161         int mbox_most;
162         int mbox_mask;
163
164         u32 *risc_jmp;
165         u32 *vbi_odd;
166         u32 *vbi_even;
167         u32 bus_vbi_even;
168         u32 bus_vbi_odd;
169         wait_queue_head_t vbiq;
170         wait_queue_head_t capq;
171         int vbip;
172
173         u32 *risc_scr_odd;
174         u32 *risc_scr_even;
175         u32 risc_cap_odd;
176         u32 risc_cap_even;
177         int scr_on;
178         int vbi_on;
179         struct video_clip *cliprecs;
180
181         struct bttv_gbuf *gbuf;
182         int gqueue[MAX_GBUFFERS];
183         int gq_in,gq_out,gq_grab,gq_start;
184         char *fbuffer;
185
186         struct bttv_pll_info pll;
187         unsigned int Fsc;
188         unsigned int field;
189         unsigned int last_field; /* number of last grabbed field */
190         int i2c_command;
191         int triton1;
192
193         int errors;
194         int needs_restart;
195
196         wait_queue_head_t gpioq;
197         int shutdown;
198         void (*audio_hook)(struct bttv *btv, struct video_audio *v, int set);
199 };
200 #endif
201
202 #define btwrite(dat,adr)    writel((dat), (char *) (btv->bt848_mem+(adr)))
203 #define btread(adr)         readl(btv->bt848_mem+(adr))
204
205 #define btand(dat,adr)      btwrite((dat) & btread(adr), adr)
206 #define btor(dat,adr)       btwrite((dat) | btread(adr), adr)
207 #define btaor(dat,mask,adr) btwrite((dat) | ((mask) & btread(adr)), adr)
208
209 /* bttv ioctls */
210
211 #define BTTV_READEE             _IOW('v',  BASE_VIDIOCPRIVATE+0, char [256])
212 #define BTTV_WRITEE             _IOR('v',  BASE_VIDIOCPRIVATE+1, char [256])
213 #define BTTV_FIELDNR            _IOR('v' , BASE_VIDIOCPRIVATE+2, unsigned int)
214 #define BTTV_PLLSET             _IOW('v' , BASE_VIDIOCPRIVATE+3, struct bttv_pll_info)
215 #define BTTV_BURST_ON           _IOR('v' , BASE_VIDIOCPRIVATE+4, int)
216 #define BTTV_BURST_OFF          _IOR('v' , BASE_VIDIOCPRIVATE+5, int)
217 #define BTTV_VERSION            _IOR('v' , BASE_VIDIOCPRIVATE+6, int)
218 #define BTTV_PICNR              _IOR('v' , BASE_VIDIOCPRIVATE+7, int)
219 #define BTTV_VBISIZE            _IOR('v' , BASE_VIDIOCPRIVATE+8, int)
220
221 #define TDA9850            0x01
222 #define TDA9840            0x02
223 #define TDA8425            0x03
224 #define TEA6300            0x04
225
226 #endif /* _BTTVP_H_ */
227
228 /*
229  * Local variables:
230  * c-basic-offset: 8
231  * End:
232  */