Linux 2.3.7pre1
[davej-history.git] / drivers / char / bttv.h
blobda4f91c85caa707e0c223c0aae4d1b4841a50559
1 /*
2 bttv - Bt848 frame grabber driver
4 Copyright (C) 1996,97 Ralph Metzler (rjkm@thp.uni-koeln.de)
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 #ifndef _BTTV_H_
22 #define _BTTV_H_
24 #define BTTV_VERSION_CODE 0x000523
26 #include <linux/types.h>
27 #include <linux/wait.h>
29 #include <linux/i2c.h>
30 #include "msp3400.h"
31 #include "bt848.h"
32 #include <linux/videodev.h>
34 #ifndef O_NONCAP
35 #define O_NONCAP O_TRUNC
36 #endif
38 #define MAX_GBUFFERS 2
39 #define RISCMEM_LEN (32744*2)
40 #define VBIBUF_SIZE 65536
42 /* maximum needed buffer size for extended VBI frame mode capturing */
43 #define BTTV_MAX_FBUF 0x190000
45 #ifdef __KERNEL__
47 struct bttv_window
49 int x, y;
50 ushort width, height;
51 ushort bpp, bpl;
52 ushort swidth, sheight;
53 short cropx, cropy;
54 ushort cropwidth, cropheight;
55 unsigned long vidadr;
56 ushort freq;
57 int norm;
58 int interlace;
59 int color_fmt;
60 ushort depth;
63 struct bttv_pll_info {
64 unsigned int pll_ifreq; /* PLL input frequency */
65 unsigned int pll_ofreq; /* PLL output frequency */
66 unsigned int pll_crystal; /* Crystal used for input */
67 unsigned int pll_current; /* Currently programmed ofreq */
70 /* Per-open data for handling multiple opens on one device */
71 struct device_open
73 int isopen;
74 int noncapturing;
75 struct bttv *dev;
77 #define MAX_OPENS 3
79 struct bttv
81 struct video_device video_dev;
82 struct video_device radio_dev;
83 struct video_device vbi_dev;
84 struct video_picture picture; /* Current picture params */
85 struct video_audio audio_dev; /* Current audio params */
87 int user;
88 int capuser;
89 struct device_open open_data[MAX_OPENS];
91 struct i2c_bus i2c;
92 int have_msp3400;
93 int have_tuner;
94 int tuner_type;
95 int channel;
97 unsigned int nr;
98 unsigned short id;
99 #if LINUX_VERSION_CODE < 0x020100
100 unsigned char bus; /* PCI bus the Bt848 is on */
101 unsigned char devfn;
102 #else
103 struct pci_dev *dev;
104 #endif
105 unsigned char irq; /* IRQ used by Bt848 card */
106 unsigned char revision;
107 unsigned int bt848_adr; /* bus address of IO mem returned by PCI BIOS */
108 unsigned char *bt848_mem; /* pointer to mapped IO memory */
109 unsigned long busriscmem;
110 u32 *riscmem;
112 unsigned char *vbibuf;
113 struct bttv_window win;
114 int type; /* card type */
115 int audio; /* audio mode */
116 int audio_chip;
117 int fader_chip;
118 int radio;
120 u32 *risc_jmp;
121 u32 *vbi_odd;
122 u32 *vbi_even;
123 u32 bus_vbi_even;
124 u32 bus_vbi_odd;
125 wait_queue_head_t vbiq;
126 wait_queue_head_t capq;
127 wait_queue_head_t capqo;
128 wait_queue_head_t capqe;
129 int vbip;
131 u32 *risc_odd;
132 u32 *risc_even;
133 int cap;
134 struct video_clip *cliprecs;
136 struct gbuffer *ogbuffers;
137 struct gbuffer *egbuffers;
138 u16 gwidth, gheight, gfmt;
139 u16 gwidth_next, gheight_next, gfmt_next;
140 u32 *grisc;
142 unsigned long gro;
143 unsigned long gre;
144 unsigned long gro_next;
145 unsigned long gre_next;
147 int grf,grf_next; /* frame numbers in grab queue */
148 int frame_stat[MAX_GBUFFERS];
149 #define GBUFFER_UNUSED 0
150 #define GBUFFER_GRABBING 1
151 #define GBUFFER_DONE 2
153 char *fbuffer;
154 int gmode;
155 int grabbing;
156 int lastgrab;
157 int grab;
158 int grabcount;
160 struct bttv_pll_info pll;
161 unsigned int Fsc;
162 unsigned int field;
163 unsigned int last_field; /* number of last grabbed field */
164 int i2c_command;
165 int triton1;
167 #endif
169 /*The following should be done in more portable way. It depends on define
170 of _ALPHA_BTTV in the Makefile.*/
172 #ifdef _ALPHA_BTTV
173 #define btwrite(dat,adr) writel((dat),(char *) (btv->bt848_adr+(adr)))
174 #define btread(adr) readl(btv->bt848_adr+(adr))
175 #else
176 #define btwrite(dat,adr) writel((dat), (char *) (btv->bt848_mem+(adr)))
177 #define btread(adr) readl(btv->bt848_mem+(adr))
178 #endif
180 #define btand(dat,adr) btwrite((dat) & btread(adr), adr)
181 #define btor(dat,adr) btwrite((dat) | btread(adr), adr)
182 #define btaor(dat,mask,adr) btwrite((dat) | ((mask) & btread(adr)), adr)
184 /* bttv ioctls */
186 #define BTTV_READEE _IOW('v', BASE_VIDIOCPRIVATE+0, char [256])
187 #define BTTV_WRITEE _IOR('v', BASE_VIDIOCPRIVATE+1, char [256])
188 #define BTTV_FIELDNR _IOR('v' , BASE_VIDIOCPRIVATE+2, unsigned int)
189 #define BTTV_PLLSET _IOW('v' , BASE_VIDIOCPRIVATE+3, struct bttv_pll_info)
190 #define BTTV_BURST_ON _IOR('v' , BASE_VIDIOCPRIVATE+4, int)
191 #define BTTV_BURST_OFF _IOR('v' , BASE_VIDIOCPRIVATE+5, int)
192 #define BTTV_VERSION _IOR('v' , BASE_VIDIOCPRIVATE+6, int)
193 #define BTTV_PICNR _IOR('v' , BASE_VIDIOCPRIVATE+7, int)
196 #define BTTV_UNKNOWN 0x00
197 #define BTTV_MIRO 0x01
198 #define BTTV_HAUPPAUGE 0x02
199 #define BTTV_STB 0x03
200 #define BTTV_INTEL 0x04
201 #define BTTV_DIAMOND 0x05
202 #define BTTV_AVERMEDIA 0x06
203 #define BTTV_MATRIX_VISION 0x07
204 #define BTTV_FLYVIDEO 0x08
205 #define BTTV_TURBOTV 0x09
206 #define BTTV_HAUPPAUGE878 0x0a
207 #define BTTV_MIROPRO 0x0b
208 #define BTTV_ADSTECH_TV 0x0c
209 #define BTTV_AVERMEDIA98 0x0d
210 #define BTTV_VHX 0x0e
211 #define BTTV_ZOLTRIX 0x0f
212 #define BTTV_PIXVIEWPLAYTV 0x10
213 #define BTTV_WINVIEW_601 0x11
214 #define BTTV_AVEC_INTERCAP 0x12
216 #define AUDIO_TUNER 0x00
217 #define AUDIO_RADIO 0x01
218 #define AUDIO_EXTERN 0x02
219 #define AUDIO_INTERN 0x03
220 #define AUDIO_OFF 0x04
221 #define AUDIO_ON 0x05
222 #define AUDIO_MUTE 0x80
223 #define AUDIO_UNMUTE 0x81
225 #define TDA9850 0x01
226 #define TDA8425 0x02
227 #define TDA9840 0x03
228 #define TEA6300 0x04
229 #define TEA6320 0x05
231 #define I2C_TSA5522 0xc2
232 #define I2C_TDA9840 0x84
233 #define I2C_TDA9850 0xb6
234 #define I2C_TDA8425 0x82
235 #define I2C_HAUPEE 0xa0
236 #define I2C_STBEE 0xae
237 #define I2C_VHX 0xc0
238 #define I2C_TEA6300 0x80 /* same as TEA6320 */
240 #define TDA9840_SW 0x00
241 #define TDA9840_LVADJ 0x02
242 #define TDA9840_STADJ 0x03
243 #define TDA9840_TEST 0x04
245 #define TDA9850_CON1 0x04
246 #define TDA9850_CON2 0x05
247 #define TDA9850_CON3 0x06
248 #define TDA9850_CON4 0x07
249 #define TDA9850_ALI1 0x08
250 #define TDA9850_ALI2 0x09
251 #define TDA9850_ALI3 0x0a
253 #define TDA8425_VL 0x00
254 #define TDA8425_VR 0x01
255 #define TDA8425_BA 0x02
256 #define TDA8425_TR 0x03
257 #define TDA8425_S1 0x08
259 #define TEA6300_VL 0x00 /* volume control left */
260 #define TEA6300_VR 0x01 /* volume control right */
261 #define TEA6300_BA 0x02 /* bass control */
262 #define TEA6300_TR 0x03 /* treble control */
263 #define TEA6300_FA 0x04 /* fader control */
264 #define TEA6300_SW 0x05 /* mute and source switch */
267 #define TEA6320_V 0x00
268 #define TEA6320_FFR 0x01 /* volume front right */
269 #define TEA6320_FFL 0x02 /* volume front left */
270 #define TEA6320_FRR 0x03 /* volume rear right */
271 #define TEA6320_FRL 0x04 /* volume rear left */
272 #define TEA6320_BA 0x05 /* bass */
273 #define TEA6320_TR 0x06 /* treble */
274 #define TEA6320_S 0x07 /* switch register */
275 /* values for those registers: */
276 #define TEA6320_S_SA 0x01 /* stereo A input */
277 #define TEA6320_S_SB 0x02 /* stereo B */
278 #define TEA6320_S_SC 0x04 /* stereo C */
279 #define TEA6320_S_GMU 0x80 /* general mute */
282 #define PT2254_L_CHANEL 0x10
283 #define PT2254_R_CHANEL 0x08
284 #define PT2254_DBS_IN_2 0x400
285 #define PT2254_DBS_IN_10 0x20000
286 #define WINVIEW_PT2254_CLK 0x40
287 #define WINVIEW_PT2254_DATA 0x20
288 #define WINVIEW_PT2254_STROBE 0x80
290 #endif