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.
24 #define BTTV_VERSION_CODE 0x000523
26 #include <linux/types.h>
27 #include <linux/wait.h>
29 #include <linux/i2c.h>
32 #include <linux/videodev.h>
35 #define O_NONCAP O_TRUNC
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
52 ushort swidth
, sheight
;
54 ushort cropwidth
, cropheight
;
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 */
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 */
89 struct device_open open_data
[MAX_OPENS
];
99 #if LINUX_VERSION_CODE < 0x020100
100 unsigned char bus
; /* PCI bus the Bt848 is on */
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
;
112 unsigned char *vbibuf
;
113 struct bttv_window win
;
114 int type
; /* card type */
115 int audio
; /* audio mode */
124 struct wait_queue
*vbiq
;
125 struct wait_queue
*capq
;
126 struct wait_queue
*capqo
;
127 struct wait_queue
*capqe
;
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
;
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
159 struct bttv_pll_info pll
;
162 unsigned int last_field
; /* number of last grabbed field */
168 /*The following should be done in more portable way. It depends on define
169 of _ALPHA_BTTV in the Makefile.*/
172 #define btwrite(dat,adr) writel((dat),(char *) (btv->bt848_adr+(adr)))
173 #define btread(adr) readl(btv->bt848_adr+(adr))
175 #define btwrite(dat,adr) writel((dat), (char *) (btv->bt848_mem+(adr)))
176 #define btread(adr) readl(btv->bt848_mem+(adr))
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)
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
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
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