Portability cleanup as required by Linus.
[linux-2.6/linux-mips.git] / drivers / char / bttv.h
blob9189bfa777d6dc5006f7f7a015b5cfb89557bfb7
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 KERNEL_VERSION(0,7,31)
26 #ifndef PCI_GET_DRIVER_DATA
27 # define PCI_GET_DRIVER_DATA(pdev) ((pdev)->driver_data)
28 # define PCI_SET_DRIVER_DATA(pdev,data) (((pdev)->driver_data) = (data))
29 #endif /* PCI_GET_DRIVER_DATA */
31 #include <linux/types.h>
32 #include <linux/wait.h>
33 #include <linux/videodev.h>
34 #include <linux/i2c.h>
35 #include <linux/i2c-algo-bit.h>
37 #include "audiochip.h"
38 #include "bt848.h"
40 /* returns card type + card ID (for bt878-based ones)
41 for possible values see lines below beginning with #define BTTV_UNKNOWN
42 returns negative value if error ocurred
44 extern int bttv_get_cardinfo(unsigned int card, int *type, int *cardid);
46 /* obsolete, use bttv_get_cardinfo instead */
47 extern int bttv_get_id(unsigned int card);
49 /* sets GPOE register (BT848_GPIO_OUT_EN) to new value:
50 data | (current_GPOE_value & ~mask)
51 returns negative value if error ocurred
53 extern int bttv_gpio_enable(unsigned int card,
54 unsigned long mask, unsigned long data);
56 /* fills data with GPDATA register contents
57 returns negative value if error ocurred
59 extern int bttv_read_gpio(unsigned int card, unsigned long *data);
61 /* sets GPDATA register to new value:
62 (data & mask) | (current_GPDATA_value & ~mask)
63 returns negative value if error ocurred
65 extern int bttv_write_gpio(unsigned int card,
66 unsigned long mask, unsigned long data);
68 /* returns pointer to task queue which can be used as parameter to
69 interruptible_sleep_on
70 in interrupt handler if BT848_INT_GPINT bit is set - this queue is activated
71 (wake_up_interruptible) and following call to the function bttv_read_gpio
72 should return new value of GPDATA,
73 returns NULL value if error ocurred or queue is not available
74 WARNING: because there is no buffer for GPIO data, one MUST
75 process data ASAP
77 extern wait_queue_head_t* bttv_get_gpio_queue(unsigned int card);
80 #ifndef O_NONCAP
81 #define O_NONCAP O_TRUNC
82 #endif
84 #define MAX_GBUFFERS 64
85 #define RISCMEM_LEN (32744*2)
86 #define VBI_MAXLINES 16
87 #define VBIBUF_SIZE (2048*VBI_MAXLINES*2)
89 #define BTTV_MAX_FBUF 0x208000
90 #define I2C_CLIENTS_MAX 8
92 #ifdef __KERNEL__
94 struct bttv_window
96 int x, y;
97 ushort width, height;
98 ushort bpp, bpl;
99 ushort swidth, sheight;
100 unsigned long vidadr;
101 ushort freq;
102 int norm;
103 int interlace;
104 int color_fmt;
105 ushort depth;
108 struct bttv_pll_info {
109 unsigned int pll_ifreq; /* PLL input frequency */
110 unsigned int pll_ofreq; /* PLL output frequency */
111 unsigned int pll_crystal; /* Crystal used for input */
112 unsigned int pll_current; /* Currently programmed ofreq */
115 struct bttv_gbuf {
116 int stat;
117 #define GBUFFER_UNUSED 0
118 #define GBUFFER_GRABBING 1
119 #define GBUFFER_DONE 2
120 #define GBUFFER_ERROR 3
121 struct timeval tv;
123 u16 width;
124 u16 height;
125 u16 fmt;
127 u32 *risc;
128 unsigned long ro;
129 unsigned long re;
132 struct bttv {
133 struct video_device video_dev;
134 struct video_device radio_dev;
135 struct video_device vbi_dev;
136 struct video_picture picture; /* Current picture params */
137 struct video_audio audio_dev; /* Current audio params */
139 spinlock_t s_lock;
140 struct semaphore lock;
141 int user;
142 int capuser;
144 /* i2c */
145 struct i2c_adapter i2c_adap;
146 struct i2c_algo_bit_data i2c_algo;
147 struct i2c_client i2c_client;
148 int i2c_state, i2c_ok;
149 struct i2c_client *i2c_clients[I2C_CLIENTS_MAX];
151 int tuner_type;
152 int channel;
154 unsigned int nr;
155 unsigned short id;
156 struct pci_dev *dev;
157 unsigned int irq; /* IRQ used by Bt848 card */
158 unsigned char revision;
159 unsigned long bt848_adr; /* bus address of IO mem returned by PCI BIOS */
160 unsigned char *bt848_mem; /* pointer to mapped IO memory */
161 unsigned long busriscmem;
162 u32 *riscmem;
164 unsigned char *vbibuf;
165 struct bttv_window win;
166 int fb_color_ctl;
167 int type; /* card type */
168 int cardid;
169 int audio; /* audio mode */
170 int audio_chip; /* set to one of the chips supported by bttv.c */
171 int radio;
173 u32 *risc_jmp;
174 u32 *vbi_odd;
175 u32 *vbi_even;
176 u32 bus_vbi_even;
177 u32 bus_vbi_odd;
178 wait_queue_head_t vbiq;
179 wait_queue_head_t capq;
180 int vbip;
182 u32 *risc_scr_odd;
183 u32 *risc_scr_even;
184 u32 risc_cap_odd;
185 u32 risc_cap_even;
186 int scr_on;
187 int vbi_on;
188 struct video_clip *cliprecs;
190 struct bttv_gbuf *gbuf;
191 int gqueue[MAX_GBUFFERS];
192 int gq_in,gq_out,gq_grab,gq_start;
193 char *fbuffer;
195 struct bttv_pll_info pll;
196 unsigned int Fsc;
197 unsigned int field;
198 unsigned int last_field; /* number of last grabbed field */
199 int i2c_command;
200 int triton1;
202 int errors;
203 int needs_restart;
205 wait_queue_head_t gpioq;
206 int shutdown;
208 #endif
210 #if defined(__powerpc__) /* big-endian */
211 extern __inline__ void io_st_le32(volatile unsigned *addr, unsigned val)
213 __asm__ __volatile__ ("stwbrx %1,0,%2" : \
214 "=m" (*addr) : "r" (val), "r" (addr));
215 __asm__ __volatile__ ("eieio" : : : "memory");
218 #define btwrite(dat,adr) io_st_le32((unsigned *)(btv->bt848_mem+(adr)),(dat))
219 #define btread(adr) ld_le32((unsigned *)(btv->bt848_mem+(adr)))
220 #else
221 #define btwrite(dat,adr) writel((dat), (char *) (btv->bt848_mem+(adr)))
222 #define btread(adr) readl(btv->bt848_mem+(adr))
223 #endif
225 #define btand(dat,adr) btwrite((dat) & btread(adr), adr)
226 #define btor(dat,adr) btwrite((dat) | btread(adr), adr)
227 #define btaor(dat,mask,adr) btwrite((dat) | ((mask) & btread(adr)), adr)
229 /* bttv ioctls */
231 #define BTTV_READEE _IOW('v', BASE_VIDIOCPRIVATE+0, char [256])
232 #define BTTV_WRITEE _IOR('v', BASE_VIDIOCPRIVATE+1, char [256])
233 #define BTTV_FIELDNR _IOR('v' , BASE_VIDIOCPRIVATE+2, unsigned int)
234 #define BTTV_PLLSET _IOW('v' , BASE_VIDIOCPRIVATE+3, struct bttv_pll_info)
235 #define BTTV_BURST_ON _IOR('v' , BASE_VIDIOCPRIVATE+4, int)
236 #define BTTV_BURST_OFF _IOR('v' , BASE_VIDIOCPRIVATE+5, int)
237 #define BTTV_VERSION _IOR('v' , BASE_VIDIOCPRIVATE+6, int)
238 #define BTTV_PICNR _IOR('v' , BASE_VIDIOCPRIVATE+7, int)
239 #define BTTV_VBISIZE _IOR('v' , BASE_VIDIOCPRIVATE+8, int)
241 #define BTTV_UNKNOWN 0x00
242 #define BTTV_MIRO 0x01
243 #define BTTV_HAUPPAUGE 0x02
244 #define BTTV_STB 0x03
245 #define BTTV_INTEL 0x04
246 #define BTTV_DIAMOND 0x05
247 #define BTTV_AVERMEDIA 0x06
248 #define BTTV_MATRIX_VISION 0x07
249 #define BTTV_FLYVIDEO 0x08
250 #define BTTV_TURBOTV 0x09
251 #define BTTV_HAUPPAUGE878 0x0a
252 #define BTTV_MIROPRO 0x0b
253 #define BTTV_ADSTECH_TV 0x0c
254 #define BTTV_AVERMEDIA98 0x0d
255 #define BTTV_VHX 0x0e
256 #define BTTV_ZOLTRIX 0x0f
257 #define BTTV_PIXVIEWPLAYTV 0x10
258 #define BTTV_WINVIEW_601 0x11
259 #define BTTV_AVEC_INTERCAP 0x12
260 #define BTTV_LIFE_FLYKIT 0x13
261 #define BTTV_CEI_RAFFLES 0x14
262 #define BTTV_CONFERENCETV 0x15
263 #define BTTV_PHOEBE_TVMAS 0x16
264 #define BTTV_MODTEC_205 0x17
265 #define BTTV_MAGICTVIEW061 0x18
266 #define BTTV_VOBIS_BOOSTAR 0x19
267 #define BTTV_HAUPPAUG_WCAM 0x1a
268 #define BTTV_MAXI 0x1b
269 #define BTTV_TERRATV 0x1c
270 #define BTTV_PXC200 0x1d
271 #define BTTV_FLYVIDEO_98 0x1e
272 #define BTTV_IPROTV 0x1f
273 #define BTTV_INTEL_C_S_PCI 0x20
274 #define BTTV_TERRATVALUE 0x21
275 #define BTTV_WINFAST2000 0x22
276 #define BTTV_CHRONOS_VS2 0x23
277 #define BTTV_TYPHOON_TVIEW 0x24
278 #define BTTV_PXELVWPLTVPRO 0x25
279 #define BTTV_MAGICTVIEW063 0x26
280 #define BTTV_PINNACLERAVE 0x27
281 #define BTTV_STB2 0x28
282 #define BTTV_AVPHONE98 0x29
283 #define BTTV_PV951 0x2a
284 #define BTTV_ONAIR_TV 0x2b
285 #define BTTV_SIGMA_TVII_FM 0x2c
287 #define PLL_NONE 0
288 #define PLL_28 1
289 #define PLL_35 2
291 #define AUDIO_TUNER 0x00
292 #define AUDIO_RADIO 0x01
293 #define AUDIO_EXTERN 0x02
294 #define AUDIO_INTERN 0x03
295 #define AUDIO_OFF 0x04
296 #define AUDIO_ON 0x05
297 #define AUDIO_MUTE 0x80
298 #define AUDIO_UNMUTE 0x81
300 #define TDA9850 0x01
301 #define TDA9840 0x02
302 #define TDA8425 0x03
303 #define TEA6300 0x04
305 #define I2C_TSA5522 0xc2
306 #define I2C_TDA7432 0x8a
307 #define I2C_TDA8425 0x82
308 #define I2C_TDA9840 0x84
309 #define I2C_TDA9850 0xb6
310 #define I2C_TDA9875 0xb0
311 #define I2C_HAUPEE 0xa0
312 #define I2C_STBEE 0xae
313 #define I2C_VHX 0xc0
314 #define I2C_MSP3400 0x80
315 #define I2C_TEA6300 0x80
316 #define I2C_DPL3518 0x84
318 #define TDA9840_SW 0x00
319 #define TDA9840_LVADJ 0x02
320 #define TDA9840_STADJ 0x03
321 #define TDA9840_TEST 0x04
323 #define PT2254_L_CHANEL 0x10
324 #define PT2254_R_CHANEL 0x08
325 #define PT2254_DBS_IN_2 0x400
326 #define PT2254_DBS_IN_10 0x20000
327 #define WINVIEW_PT2254_CLK 0x40
328 #define WINVIEW_PT2254_DATA 0x20
329 #define WINVIEW_PT2254_STROBE 0x80
331 #endif
334 * Local variables:
335 * c-basic-offset: 8
336 * End: