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 */
87 struct semaphore lock
;
90 struct device_open open_data
[MAX_OPENS
];
100 #if LINUX_VERSION_CODE < 0x020100
101 unsigned char bus
; /* PCI bus the Bt848 is on */
106 unsigned int irq
; /* IRQ used by Bt848 card */
107 unsigned char revision
;
108 unsigned long bt848_adr
; /* bus address of IO mem returned by PCI BIOS */
109 unsigned char *bt848_mem
; /* pointer to mapped IO memory */
110 unsigned long busriscmem
;
113 unsigned char *vbibuf
;
114 struct bttv_window win
;
115 int type
; /* card type */
116 int audio
; /* audio mode */
126 wait_queue_head_t vbiq
;
127 wait_queue_head_t capq
;
128 wait_queue_head_t capqo
;
129 wait_queue_head_t capqe
;
135 struct video_clip
*cliprecs
;
137 struct gbuffer
*ogbuffers
;
138 struct gbuffer
*egbuffers
;
139 u16 gwidth
, gheight
, gfmt
;
140 u16 gwidth_next
, gheight_next
, gfmt_next
;
145 unsigned long gro_next
;
146 unsigned long gre_next
;
148 int grf
,grf_next
; /* frame numbers in grab queue */
149 int frame_stat
[MAX_GBUFFERS
];
150 #define GBUFFER_UNUSED 0
151 #define GBUFFER_GRABBING 1
152 #define GBUFFER_DONE 2
161 struct bttv_pll_info pll
;
164 unsigned int last_field
; /* number of last grabbed field */
170 /*The following should be done in more portable way. It depends on define
171 of _ALPHA_BTTV in the Makefile.*/
174 #define btwrite(dat,adr) writel((dat),(char *) (btv->bt848_adr+(adr)))
175 #define btread(adr) readl(btv->bt848_adr+(adr))
177 #define btwrite(dat,adr) writel((dat), (char *) (btv->bt848_mem+(adr)))
178 #define btread(adr) readl(btv->bt848_mem+(adr))
181 #define btand(dat,adr) btwrite((dat) & btread(adr), adr)
182 #define btor(dat,adr) btwrite((dat) | btread(adr), adr)
183 #define btaor(dat,mask,adr) btwrite((dat) | ((mask) & btread(adr)), adr)
187 #define BTTV_READEE _IOW('v', BASE_VIDIOCPRIVATE+0, char [256])
188 #define BTTV_WRITEE _IOR('v', BASE_VIDIOCPRIVATE+1, char [256])
189 #define BTTV_FIELDNR _IOR('v' , BASE_VIDIOCPRIVATE+2, unsigned int)
190 #define BTTV_PLLSET _IOW('v' , BASE_VIDIOCPRIVATE+3, struct bttv_pll_info)
191 #define BTTV_BURST_ON _IOR('v' , BASE_VIDIOCPRIVATE+4, int)
192 #define BTTV_BURST_OFF _IOR('v' , BASE_VIDIOCPRIVATE+5, int)
193 #define BTTV_VERSION _IOR('v' , BASE_VIDIOCPRIVATE+6, int)
194 #define BTTV_PICNR _IOR('v' , BASE_VIDIOCPRIVATE+7, int)
197 #define BTTV_UNKNOWN 0x00
198 #define BTTV_MIRO 0x01
199 #define BTTV_HAUPPAUGE 0x02
200 #define BTTV_STB 0x03
201 #define BTTV_INTEL 0x04
202 #define BTTV_DIAMOND 0x05
203 #define BTTV_AVERMEDIA 0x06
204 #define BTTV_MATRIX_VISION 0x07
205 #define BTTV_FLYVIDEO 0x08
206 #define BTTV_TURBOTV 0x09
207 #define BTTV_HAUPPAUGE878 0x0a
208 #define BTTV_MIROPRO 0x0b
209 #define BTTV_ADSTECH_TV 0x0c
210 #define BTTV_AVERMEDIA98 0x0d
211 #define BTTV_VHX 0x0e
212 #define BTTV_ZOLTRIX 0x0f
213 #define BTTV_PIXVIEWPLAYTV 0x10
214 #define BTTV_WINVIEW_601 0x11
215 #define BTTV_AVEC_INTERCAP 0x12
217 #define AUDIO_TUNER 0x00
218 #define AUDIO_RADIO 0x01
219 #define AUDIO_EXTERN 0x02
220 #define AUDIO_INTERN 0x03
221 #define AUDIO_OFF 0x04
222 #define AUDIO_ON 0x05
223 #define AUDIO_MUTE 0x80
224 #define AUDIO_UNMUTE 0x81
232 #define I2C_TSA5522 0xc2
233 #define I2C_TDA9840 0x84
234 #define I2C_TDA9850 0xb6
235 #define I2C_TDA8425 0x82
236 #define I2C_HAUPEE 0xa0
237 #define I2C_STBEE 0xae
239 #define I2C_TEA6300 0x80 /* same as TEA6320 */
241 #define TDA9840_SW 0x00
242 #define TDA9840_LVADJ 0x02
243 #define TDA9840_STADJ 0x03
244 #define TDA9840_TEST 0x04
246 #define TDA9850_CON1 0x04
247 #define TDA9850_CON2 0x05
248 #define TDA9850_CON3 0x06
249 #define TDA9850_CON4 0x07
250 #define TDA9850_ALI1 0x08
251 #define TDA9850_ALI2 0x09
252 #define TDA9850_ALI3 0x0a
254 #define TDA8425_VL 0x00
255 #define TDA8425_VR 0x01
256 #define TDA8425_BA 0x02
257 #define TDA8425_TR 0x03
258 #define TDA8425_S1 0x08
260 #define TEA6300_VL 0x00 /* volume control left */
261 #define TEA6300_VR 0x01 /* volume control right */
262 #define TEA6300_BA 0x02 /* bass control */
263 #define TEA6300_TR 0x03 /* treble control */
264 #define TEA6300_FA 0x04 /* fader control */
265 #define TEA6300_SW 0x05 /* mute and source switch */
268 #define TEA6320_V 0x00
269 #define TEA6320_FFR 0x01 /* volume front right */
270 #define TEA6320_FFL 0x02 /* volume front left */
271 #define TEA6320_FRR 0x03 /* volume rear right */
272 #define TEA6320_FRL 0x04 /* volume rear left */
273 #define TEA6320_BA 0x05 /* bass */
274 #define TEA6320_TR 0x06 /* treble */
275 #define TEA6320_S 0x07 /* switch register */
276 /* values for those registers: */
277 #define TEA6320_S_SA 0x01 /* stereo A input */
278 #define TEA6320_S_SB 0x07 /* stereo B -- databook wrong? this works */
279 #define TEA6320_S_SC 0x04 /* stereo C */
280 #define TEA6320_S_GMU 0x80 /* general mute */
283 #define PT2254_L_CHANEL 0x10
284 #define PT2254_R_CHANEL 0x08
285 #define PT2254_DBS_IN_2 0x400
286 #define PT2254_DBS_IN_10 0x20000
287 #define WINVIEW_PT2254_CLK 0x40
288 #define WINVIEW_PT2254_DATA 0x20
289 #define WINVIEW_PT2254_STROBE 0x80