Import 2.1.118
[davej-history.git] / drivers / char / bttv.h
blob83a0cecb6aee6ed639a80a2cd6b3f6e511cbd40f
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 TEST_VBI
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 #define MAX_CLIPRECS 100
35 #define MAX_GBUFFERS 2
36 #define RISCMEM_LEN (32744*2)
38 /* maximum needed buffer size for extended VBI frame mode capturing */
39 #define BTTV_MAX_FBUF 0x151000
41 #ifdef __KERNEL__
43 struct bttv_window
45 int x, y;
46 ushort width, height;
47 ushort bpp, bpl;
48 ushort swidth, sheight;
49 short cropx, cropy;
50 ushort cropwidth, cropheight;
51 unsigned long vidadr;
52 ushort freq;
53 int norm;
54 int interlace;
55 int color_fmt;
56 ushort depth;
60 struct bttv
62 struct video_device video_dev;
63 struct video_device radio_dev;
64 struct video_device vbi_dev;
65 struct video_picture picture; /* Current picture params */
66 struct video_audio audio_dev; /* Current audio params */
68 struct i2c_bus i2c;
69 int have_msp3400;
70 int have_tuner;
71 int tuner_type;
72 int channel;
74 unsigned int nr;
75 unsigned short id;
76 unsigned char bus; /* PCI bus the Bt848 is on */
77 unsigned char devfn;
78 struct pci_dev *dev;
79 unsigned char irq; /* IRQ used by Bt848 card */
80 unsigned char revision;
81 unsigned int bt848_adr; /* bus address of IO mem returned by PCI BIOS */
82 unsigned char *bt848_mem; /* pointer to mapped IO memory */
83 unsigned long busriscmem;
84 u32 *riscmem;
86 unsigned char *vbibuf;
87 struct bttv_window win;
88 int type; /* card type */
89 int audio; /* audio mode */
90 int user;
91 int audio_chip;
92 int radio;
94 u32 *risc_jmp;
95 u32 *vbi_odd;
96 u32 *vbi_even;
97 u32 bus_vbi_even;
98 u32 bus_vbi_odd;
99 struct wait_queue *vbiq;
100 struct wait_queue *capq;
101 struct wait_queue *capqo;
102 struct wait_queue *capqe;
103 int vbip;
105 u32 *risc_odd;
106 u32 *risc_even;
107 int cap;
108 struct video_clip *cliprecs;
110 struct gbuffer *ogbuffers;
111 struct gbuffer *egbuffers;
112 u16 gwidth, gheight, gfmt;
113 u32 *grisc;
115 unsigned long gro;
116 unsigned long gre;
117 unsigned long gro_next;
118 unsigned long gre_next;
120 int grf,grf_next; /* frame numbers in grab queue */
121 int frame_stat[MAX_GBUFFERS];
122 #define GBUFFER_UNUSED 0
123 #define GBUFFER_GRABBING 1
124 #define GBUFFER_DONE 2
126 char *fbuffer;
127 int gmode;
128 int grabbing;
129 int lastgrab;
130 int grab;
131 int grabcount;
133 int pll;
134 unsigned int Fsc;
135 unsigned int field;
136 unsigned int last_field; /* number of last grabbed field */
137 int i2c_command;
138 int triton1;
141 #endif
143 /*The following should be done in more portable way. It depends on define
144 of _ALPHA_BTTV in the Makefile.*/
146 #ifdef _ALPHA_BTTV
147 #define btwrite(dat,adr) writel((dat),(char *) (btv->bt848_adr+(adr)))
148 #define btread(adr) readl(btv->bt848_adr+(adr))
149 #else
150 #define btwrite(dat,adr) writel((dat), (char *) (btv->bt848_mem+(adr)))
151 #define btread(adr) readl(btv->bt848_mem+(adr))
152 #endif
154 #define btand(dat,adr) btwrite((dat) & btread(adr), adr)
155 #define btor(dat,adr) btwrite((dat) | btread(adr), adr)
156 #define btaor(dat,mask,adr) btwrite((dat) | ((mask) & btread(adr)), adr)
158 /* bttv ioctls */
160 #define BTTV_READEE _IOW('v', BASE_VIDIOCPRIVATE+0, char [256])
161 #define BTTV_WRITEE _IOR('v', BASE_VIDIOCPRIVATE+1, char [256])
162 #define BTTV_GRAB _IOR('v' , BASE_VIDIOCPRIVATE+2, struct gbuf)
163 #define BTTV_FIELDNR _IOR('v' , BASE_VIDIOCPRIVATE+2, unsigned int)
166 #define BTTV_UNKNOWN 0x00
167 #define BTTV_MIRO 0x01
168 #define BTTV_HAUPPAUGE 0x02
169 #define BTTV_STB 0x03
170 #define BTTV_INTEL 0x04
171 #define BTTV_DIAMOND 0x05
172 #define BTTV_AVERMEDIA 0x06
173 #define BTTV_MATRIX_VISION 0x07
174 #define BTTV_FLYVIDEO 0x08
176 #define AUDIO_TUNER 0x00
177 #define AUDIO_RADIO 0x01
178 #define AUDIO_EXTERN 0x02
179 #define AUDIO_INTERN 0x03
180 #define AUDIO_OFF 0x04
181 #define AUDIO_ON 0x05
182 #define AUDIO_MUTE 0x80
183 #define AUDIO_UNMUTE 0x81
185 #define TDA9850 0x01
186 #define TDA8425 0x02
188 #define I2C_TSA5522 0xc2
189 #define I2C_TDA9850 0xb6
190 #define I2C_TDA8425 0x82
191 #define I2C_HAUPEE 0xa0
192 #define I2C_STBEE 0xae
194 #define TDA9850_CON1 0x04
195 #define TDA9850_CON2 0x05
196 #define TDA9850_CON3 0x06
197 #define TDA9850_CON4 0x07
198 #define TDA9850_ALI1 0x08
199 #define TDA9850_ALI2 0x09
200 #define TDA9850_ALI3 0x0a
202 #define TDA8425_VL 0x00
203 #define TDA8425_VR 0x01
204 #define TDA8425_BA 0x02
205 #define TDA8425_TR 0x03
206 #define TDA8425_S1 0x08
209 #endif