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.
26 #include <linux/types.h>
27 #include <linux/wait.h>
29 #include <linux/i2c.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
48 ushort swidth
, sheight
;
50 ushort cropwidth
, cropheight
;
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 */
76 unsigned char bus
; /* PCI bus the Bt848 is on */
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
;
86 unsigned char *vbibuf
;
87 struct bttv_window win
;
88 int type
; /* card type */
89 int audio
; /* audio mode */
99 struct wait_queue
*vbiq
;
100 struct wait_queue
*capq
;
101 struct wait_queue
*capqo
;
102 struct wait_queue
*capqe
;
108 struct video_clip
*cliprecs
;
110 struct gbuffer
*ogbuffers
;
111 struct gbuffer
*egbuffers
;
112 u16 gwidth
, gheight
, gfmt
;
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
136 unsigned int last_field
; /* number of last grabbed field */
143 /*The following should be done in more portable way. It depends on define
144 of _ALPHA_BTTV in the Makefile.*/
147 #define btwrite(dat,adr) writel((dat),(char *) (btv->bt848_adr+(adr)))
148 #define btread(adr) readl(btv->bt848_adr+(adr))
150 #define btwrite(dat,adr) writel((dat), (char *) (btv->bt848_mem+(adr)))
151 #define btread(adr) readl(btv->bt848_mem+(adr))
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)
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
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