Linux 2.2.0
[davej-history.git] / drivers / char / bttv.h
blobba6c52af483068713ed87b1d27a3459f010f0737
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 radio;
119 u32 *risc_jmp;
120 u32 *vbi_odd;
121 u32 *vbi_even;
122 u32 bus_vbi_even;
123 u32 bus_vbi_odd;
124 struct wait_queue *vbiq;
125 struct wait_queue *capq;
126 struct wait_queue *capqo;
127 struct wait_queue *capqe;
128 int vbip;
130 u32 *risc_odd;
131 u32 *risc_even;
132 int cap;
133 struct video_clip *cliprecs;
135 struct gbuffer *ogbuffers;
136 struct gbuffer *egbuffers;
137 u16 gwidth, gheight, gfmt;
138 u16 gwidth_next, gheight_next, gfmt_next;
139 u32 *grisc;
141 unsigned long gro;
142 unsigned long gre;
143 unsigned long gro_next;
144 unsigned long gre_next;
146 int grf,grf_next; /* frame numbers in grab queue */
147 int frame_stat[MAX_GBUFFERS];
148 #define GBUFFER_UNUSED 0
149 #define GBUFFER_GRABBING 1
150 #define GBUFFER_DONE 2
152 char *fbuffer;
153 int gmode;
154 int grabbing;
155 int lastgrab;
156 int grab;
157 int grabcount;
159 struct bttv_pll_info pll;
160 unsigned int Fsc;
161 unsigned int field;
162 unsigned int last_field; /* number of last grabbed field */
163 int i2c_command;
164 int triton1;
166 #endif
168 /*The following should be done in more portable way. It depends on define
169 of _ALPHA_BTTV in the Makefile.*/
171 #ifdef _ALPHA_BTTV
172 #define btwrite(dat,adr) writel((dat),(char *) (btv->bt848_adr+(adr)))
173 #define btread(adr) readl(btv->bt848_adr+(adr))
174 #else
175 #define btwrite(dat,adr) writel((dat), (char *) (btv->bt848_mem+(adr)))
176 #define btread(adr) readl(btv->bt848_mem+(adr))
177 #endif
179 #define btand(dat,adr) btwrite((dat) & btread(adr), adr)
180 #define btor(dat,adr) btwrite((dat) | btread(adr), adr)
181 #define btaor(dat,mask,adr) btwrite((dat) | ((mask) & btread(adr)), adr)
183 /* bttv ioctls */
185 #define BTTV_READEE _IOW('v', BASE_VIDIOCPRIVATE+0, char [256])
186 #define BTTV_WRITEE _IOR('v', BASE_VIDIOCPRIVATE+1, char [256])
187 #define BTTV_FIELDNR _IOR('v' , BASE_VIDIOCPRIVATE+2, unsigned int)
188 #define BTTV_PLLSET _IOW('v' , BASE_VIDIOCPRIVATE+3, struct bttv_pll_info)
189 #define BTTV_BURST_ON _IOR('v' , BASE_VIDIOCPRIVATE+4, int)
190 #define BTTV_BURST_OFF _IOR('v' , BASE_VIDIOCPRIVATE+5, int)
191 #define BTTV_VERSION _IOR('v' , BASE_VIDIOCPRIVATE+6, int)
192 #define BTTV_PICNR _IOR('v' , BASE_VIDIOCPRIVATE+7, int)
195 #define BTTV_UNKNOWN 0x00
196 #define BTTV_MIRO 0x01
197 #define BTTV_HAUPPAUGE 0x02
198 #define BTTV_STB 0x03
199 #define BTTV_INTEL 0x04
200 #define BTTV_DIAMOND 0x05
201 #define BTTV_AVERMEDIA 0x06
202 #define BTTV_MATRIX_VISION 0x07
203 #define BTTV_FLYVIDEO 0x08
204 #define BTTV_TURBOTV 0x09
205 #define BTTV_HAUPPAUGE878 0x0a
206 #define BTTV_MIROPRO 0x0b
207 #define BTTV_ADSTECH_TV 0x0c
208 #define BTTV_AVERMEDIA98 0x0d
209 #define BTTV_VHX 0x0e
211 #define AUDIO_TUNER 0x00
212 #define AUDIO_RADIO 0x01
213 #define AUDIO_EXTERN 0x02
214 #define AUDIO_INTERN 0x03
215 #define AUDIO_OFF 0x04
216 #define AUDIO_ON 0x05
217 #define AUDIO_MUTE 0x80
218 #define AUDIO_UNMUTE 0x81
220 #define TDA9850 0x01
221 #define TDA8425 0x02
222 #define TDA9840 0x03
224 #define I2C_TSA5522 0xc2
225 #define I2C_TDA9840 0x84
226 #define I2C_TDA9850 0xb6
227 #define I2C_TDA8425 0x82
228 #define I2C_HAUPEE 0xa0
229 #define I2C_STBEE 0xae
230 #define I2C_VHX 0xc0
232 #define TDA9840_SW 0x00
233 #define TDA9840_LVADJ 0x02
234 #define TDA9840_STADJ 0x03
235 #define TDA9840_TEST 0x04
237 #define TDA9850_CON1 0x04
238 #define TDA9850_CON2 0x05
239 #define TDA9850_CON3 0x06
240 #define TDA9850_CON4 0x07
241 #define TDA9850_ALI1 0x08
242 #define TDA9850_ALI2 0x09
243 #define TDA9850_ALI3 0x0a
245 #define TDA8425_VL 0x00
246 #define TDA8425_VR 0x01
247 #define TDA8425_BA 0x02
248 #define TDA8425_TR 0x03
249 #define TDA8425_S1 0x08
252 #endif