Rev 170 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
170 | giacomo | 1 | /* |
2 | * bttv - Bt848 frame grabber driver |
||
3 | * |
||
4 | * card ID's and external interfaces of the bttv driver |
||
5 | * basically stuff needed by other drivers (i2c, lirc, ...) |
||
6 | * and is supported not to change much over time. |
||
7 | * |
||
8 | * Copyright (C) 1996,97 Ralph Metzler (rjkm@thp.uni-koeln.de) |
||
9 | * (c) 1999,2000 Gerd Knorr <kraxel@goldbach.in-berlin.de> |
||
10 | * |
||
11 | */ |
||
12 | |||
13 | #ifndef _BTTV_H_ |
||
14 | #define _BTTV_H_ |
||
15 | |||
16 | #include <sys/types.h> |
||
17 | #include "drivers/compbttv.h" |
||
18 | |||
19 | #include "drivers/videodev.h" |
||
425 | giacomo | 20 | #include "linux/i2c.h" |
21 | #include "linux/i2c-algo-bit.h" |
||
170 | giacomo | 22 | |
23 | #include "drivers/bt848.h" |
||
24 | #include "drivers/audiochip.h" |
||
25 | |||
26 | #include "drivers/gpio.h" |
||
27 | |||
28 | #define I2C_CLIENTS_MAX 16 |
||
29 | |||
30 | #define BTTV_UNKNOWN 0x00 |
||
31 | #define BTTV_MIRO 0x01 |
||
32 | #define BTTV_HAUPPAUGE 0x02 |
||
33 | #define BTTV_STB 0x03 |
||
34 | #define BTTV_INTEL 0x04 |
||
35 | #define BTTV_DIAMOND 0x05 |
||
36 | #define BTTV_AVERMEDIA 0x06 |
||
37 | #define BTTV_MATRIX_VISION 0x07 |
||
38 | #define BTTV_FLYVIDEO 0x08 |
||
39 | #define BTTV_TURBOTV 0x09 |
||
40 | #define BTTV_HAUPPAUGE878 0x0a |
||
41 | #define BTTV_MIROPRO 0x0b |
||
42 | #define BTTV_ADSTECH_TV 0x0c |
||
43 | #define BTTV_AVERMEDIA98 0x0d |
||
44 | #define BTTV_VHX 0x0e |
||
45 | #define BTTV_ZOLTRIX 0x0f |
||
46 | #define BTTV_PIXVIEWPLAYTV 0x10 |
||
47 | #define BTTV_WINVIEW_601 0x11 |
||
48 | #define BTTV_AVEC_INTERCAP 0x12 |
||
49 | #define BTTV_LIFE_FLYKIT 0x13 |
||
50 | #define BTTV_CEI_RAFFLES 0x14 |
||
51 | #define BTTV_CONFERENCETV 0x15 |
||
52 | #define BTTV_PHOEBE_TVMAS 0x16 |
||
53 | #define BTTV_MODTEC_205 0x17 |
||
54 | #define BTTV_MAGICTVIEW061 0x18 |
||
55 | #define BTTV_VOBIS_BOOSTAR 0x19 |
||
56 | #define BTTV_HAUPPAUG_WCAM 0x1a |
||
57 | #define BTTV_MAXI 0x1b |
||
58 | #define BTTV_TERRATV 0x1c |
||
59 | #define BTTV_PXC200 0x1d |
||
60 | #define BTTV_FLYVIDEO_98 0x1e |
||
61 | #define BTTV_IPROTV 0x1f |
||
62 | #define BTTV_INTEL_C_S_PCI 0x20 |
||
63 | #define BTTV_TERRATVALUE 0x21 |
||
64 | #define BTTV_WINFAST2000 0x22 |
||
65 | #define BTTV_CHRONOS_VS2 0x23 |
||
66 | #define BTTV_TYPHOON_TVIEW 0x24 |
||
67 | #define BTTV_PXELVWPLTVPRO 0x25 |
||
68 | #define BTTV_MAGICTVIEW063 0x26 |
||
69 | #define BTTV_PINNACLE 0x27 |
||
70 | #define BTTV_STB2 0x28 |
||
71 | #define BTTV_AVPHONE98 0x29 |
||
72 | #define BTTV_PV951 0x2a |
||
73 | #define BTTV_ONAIR_TV 0x2b |
||
74 | #define BTTV_SIGMA_TVII_FM 0x2c |
||
75 | #define BTTV_MATRIX_VISION2 0x2d |
||
76 | #define BTTV_ZOLTRIX_GENIE 0x2e |
||
77 | #define BTTV_TERRATVRADIO 0x2f |
||
78 | #define BTTV_DYNALINK 0x30 |
||
79 | #define BTTV_GVBCTV3PCI 0x31 |
||
80 | #define BTTV_PXELVWPLTVPAK 0x32 |
||
81 | #define BTTV_EAGLE 0x33 |
||
82 | #define BTTV_PINNACLEPRO 0x34 |
||
83 | #define BTTV_TVIEW_RDS_FM 0x35 |
||
84 | #define BTTV_LIFETEC_9415 0x36 |
||
85 | #define BTTV_BESTBUY_EASYTV 0x37 |
||
86 | #define BTTV_FLYVIDEO_98FM 0x38 |
||
87 | #define BTTV_GMV1 0x3d |
||
88 | #define BTTV_BESTBUY_EASYTV2 0x3e |
||
89 | #define BTTV_ATI_TVWONDER 0x3f |
||
90 | #define BTTV_ATI_TVWONDERVE 0x40 |
||
91 | #define BTTV_FLYVIDEO2000 0x41 |
||
92 | #define BTTV_TERRATVALUER 0x42 |
||
93 | #define BTTV_GVBCTV4PCI 0x43 |
||
94 | #define BTTV_VOODOOTV_FM 0x44 |
||
95 | #define BTTV_AIMMS 0x45 |
||
96 | #define BTTV_PV_BT878P_PLUS 0x46 |
||
97 | #define BTTV_FLYVIDEO98EZ 0x47 |
||
98 | #define BTTV_PV_BT878P_9B 0x48 |
||
99 | #define BTTV_SENSORAY311 0x49 |
||
100 | #define BTTV_RV605 0x4a |
||
101 | #define BTTV_WINDVR 0x4c |
||
102 | #define BTTV_OSPREY1x0 0x4f |
||
103 | #define BTTV_OSPREY1x0_848 0x50 |
||
104 | #define BTTV_OSPREY101_848 0x51 |
||
105 | #define BTTV_OSPREY1x1 0x52 |
||
106 | #define BTTV_OSPREY1x1_SVID 0x53 |
||
107 | #define BTTV_OSPREY2xx 0x54 |
||
108 | #define BTTV_OSPREY2x0_SVID 0x55 |
||
109 | #define BTTV_OSPREY2x0 0x56 |
||
110 | #define BTTV_OSPREY5x0 0x57 |
||
111 | #define BTTV_OSPREY2000 0x58 |
||
112 | #define BTTV_OSPREY_BEGIN BTTV_OSPREY1x0 |
||
113 | #define BTTV_OSPREY_END BTTV_OSPREY2000 |
||
114 | |||
115 | /* i2c address list */ |
||
116 | #define I2C_TSA5522 0xc2 |
||
117 | #define I2C_TDA7432 0x8a |
||
118 | #define I2C_TDA8425 0x82 |
||
119 | #define I2C_TDA9840 0x84 |
||
120 | #define I2C_TDA9850 0xb6 /* also used by 9855,9873 */ |
||
121 | #define I2C_TDA9874 0xb0 /* also used by 9875 */ |
||
122 | #define I2C_TDA9875 0xb0 |
||
123 | #define I2C_HAUPEE 0xa0 |
||
124 | #define I2C_STBEE 0xae |
||
125 | #define I2C_VHX 0xc0 |
||
126 | #define I2C_MSP3400 0x80 |
||
127 | #define I2C_TEA6300 0x80 |
||
128 | #define I2C_DPL3518 0x84 |
||
129 | |||
130 | /* more card-specific defines */ |
||
131 | #define PT2254_L_CHANNEL 0x10 |
||
132 | #define PT2254_R_CHANNEL 0x08 |
||
133 | #define PT2254_DBS_IN_2 0x400 |
||
134 | #define PT2254_DBS_IN_10 0x20000 |
||
135 | #define WINVIEW_PT2254_CLK 0x40 |
||
136 | #define WINVIEW_PT2254_DATA 0x20 |
||
137 | #define WINVIEW_PT2254_STROBE 0x80 |
||
138 | |||
139 | #define dprintk if (bttv_debug) cprintf |
||
140 | |||
141 | /* Anybody who uses more than four? */ |
||
142 | #define BTTV_MAX 4 |
||
143 | extern int bttv_num; /* number of Bt848s in use */ |
||
144 | extern struct bttv bttvs[BTTV_MAX]; |
||
145 | |||
146 | #ifndef O_NONCAP |
||
147 | #define O_NONCAP O_TRUNC |
||
148 | #endif |
||
149 | |||
150 | #ifdef VIDEODAT_HACK |
||
151 | # define VBI_MAXLINES 19 |
||
152 | #else |
||
153 | # define VBI_MAXLINES 16 |
||
154 | #endif |
||
155 | #define VBIBUF_SIZE (2048*VBI_MAXLINES*2) |
||
156 | #define MAX_GBUFFERS 64 |
||
157 | #define RISCMEM_LEN (32744*2) |
||
158 | |||
159 | #define BTTV_MAX_FBUF 0x208000 |
||
160 | |||
161 | struct bttv_window |
||
162 | { |
||
163 | int x, y; |
||
164 | ushort width, height; |
||
165 | ushort bpp, bpl; |
||
166 | ushort swidth, sheight; |
||
167 | unsigned long vidadr; |
||
168 | ushort freq; |
||
169 | int norm; |
||
170 | int interlace; |
||
171 | int color_fmt; |
||
172 | ushort depth; |
||
173 | }; |
||
174 | |||
175 | struct bttv_pll_info { |
||
176 | unsigned int pll_ifreq; /* PLL input frequency */ |
||
177 | unsigned int pll_ofreq; /* PLL output frequency */ |
||
178 | unsigned int pll_crystal; /* Crystal used for input */ |
||
179 | unsigned int pll_current; /* Currently programmed ofreq */ |
||
180 | }; |
||
181 | |||
182 | struct bttv_gbuf { |
||
183 | int stat; |
||
184 | #define GBUFFER_UNUSED 0 |
||
185 | #define GBUFFER_GRABBING 1 |
||
186 | #define GBUFFER_DONE 2 |
||
187 | #define GBUFFER_ERROR 3 |
||
188 | struct timespec tv; |
||
189 | |||
190 | u16 width; |
||
191 | u16 height; |
||
192 | u16 fmt; |
||
193 | |||
194 | u32 *risc; |
||
195 | unsigned long ro; |
||
196 | unsigned long re; |
||
197 | }; |
||
198 | |||
199 | struct bttv { |
||
200 | struct video_device video_dev; |
||
201 | struct video_device radio_dev; |
||
202 | struct video_device vbi_dev; |
||
203 | struct video_picture picture; /* Current picture params */ |
||
204 | struct video_audio audio_dev; /* Current audio params */ |
||
205 | |||
206 | int user; |
||
207 | int capuser; |
||
208 | |||
209 | /* i2c */ |
||
210 | struct i2c_adapter i2c_adap; |
||
211 | struct i2c_algo_bit_data i2c_algo; |
||
212 | struct i2c_client i2c_client; |
||
213 | int i2c_state, i2c_rc; |
||
214 | struct i2c_client *i2c_clients[I2C_CLIENTS_MAX]; |
||
215 | |||
216 | int tuner_type; |
||
217 | int channel; |
||
218 | |||
219 | unsigned int nr; |
||
220 | unsigned short id; |
||
221 | unsigned char revision; |
||
222 | unsigned long bt848_adr; /* bus address of IO mem returned by PCI BIOS */ |
||
223 | struct pci_dev *dev; |
||
224 | unsigned char *bt848_mem; /* ptr to mapped IO memory */ |
||
225 | struct gpio_adapter gpio_adap; |
||
226 | unsigned long busriscmem; |
||
227 | u32 *riscmem; |
||
228 | |||
229 | unsigned char *vbibuf; |
||
230 | struct bttv_window win; |
||
231 | int fb_color_ctl; |
||
232 | int type; /* card type */ |
||
233 | int cardid; |
||
234 | int audio; /* audio mode */ |
||
235 | int audio_chip; /* set to one of the chips supported by bttv.c */ |
||
236 | int radio; |
||
237 | int has_radio; |
||
238 | |||
239 | /* miro/pinnacle + Aimslab VHX |
||
240 | philips matchbox (tea5757 radio tuner) support */ |
||
241 | int has_matchbox; |
||
242 | int mbox_we; |
||
243 | int mbox_data; |
||
244 | int mbox_clk; |
||
245 | int mbox_most; |
||
246 | int mbox_mask; |
||
247 | |||
248 | u32 *risc_jmp; |
||
249 | u32 *vbi_odd; |
||
250 | u32 *vbi_even; |
||
251 | u32 bus_vbi_even; |
||
252 | u32 bus_vbi_odd; |
||
253 | int vbip; |
||
254 | |||
255 | u32 *risc_scr_odd; |
||
256 | u32 *risc_scr_even; |
||
257 | u32 risc_cap_odd; |
||
258 | u32 risc_cap_even; |
||
259 | int scr_on; |
||
260 | int vbi_on; |
||
261 | struct video_clip *cliprecs; |
||
262 | |||
263 | struct bttv_gbuf *gbuf; |
||
264 | int gqueue[MAX_GBUFFERS]; |
||
265 | int gq_in,gq_out,gq_grab,gq_start; |
||
266 | char *fbuffer; |
||
267 | |||
268 | struct bttv_pll_info pll; |
||
269 | unsigned int Fsc; |
||
270 | unsigned int field; |
||
271 | unsigned int last_field; /* number of last grabbed field */ |
||
272 | int i2c_command; |
||
273 | int triton1; |
||
274 | |||
275 | int errors; |
||
276 | int needs_restart; |
||
277 | |||
278 | int shutdown; |
||
279 | }; |
||
280 | |||
281 | /* insmod options / kernel args */ |
||
282 | extern int no_overlay; |
||
283 | extern unsigned int bttv_verbose; |
||
284 | extern unsigned int bttv_debug; |
||
285 | extern unsigned int bttv_gpio; |
||
286 | extern void bttv_gpio_tracking(struct bttv *btv, char *comment); |
||
287 | extern int init_bttv_i2c(struct bttv *btv); |
||
288 | |||
289 | #define btwrite(dat,adr) *(unsigned long *) (btv->bt848_mem+(adr)) = (unsigned long)(dat) |
||
290 | #define btread(adr) *(unsigned long *)(btv->bt848_mem+(adr)) |
||
291 | |||
292 | #define btand(dat,adr) btwrite((dat) & btread(adr), adr) |
||
293 | #define btor(dat,adr) btwrite((dat) | btread(adr), adr) |
||
294 | #define btaor(dat,mask,adr) btwrite((dat) | ((mask) & btread(adr)), adr) |
||
295 | |||
296 | #define gpiowrite(dat) gpio_set (&(btv->gpio_adap),dat) |
||
297 | #define gpioread() btread(BT848_GPIO_DATA) |
||
298 | #define gpioand(dat) gpio_and (&(btv->gpio_adap),dat) |
||
299 | #define gpioor(dat) gpio_or (&(btv->gpio_adap),dat) |
||
300 | #define gpioaor(dat,mask) gpio_andor(&(btv->gpio_adap),mask,dat) |
||
301 | |||
302 | /* bttv ioctls */ |
||
303 | |||
304 | #define BTTV_READEE _IOW('v', BASE_VIDIOCPRIVATE+0, char [256]) |
||
305 | #define BTTV_WRITEE _IOR('v', BASE_VIDIOCPRIVATE+1, char [256]) |
||
306 | #define BTTV_FIELDNR _IOR('v' , BASE_VIDIOCPRIVATE+2, unsigned int) |
||
307 | #define BTTV_PLLSET _IOW('v' , BASE_VIDIOCPRIVATE+3, struct bttv_pll_info) |
||
308 | #define BTTV_BURST_ON _IOR('v' , BASE_VIDIOCPRIVATE+4, int) |
||
309 | #define BTTV_BURST_OFF _IOR('v' , BASE_VIDIOCPRIVATE+5, int) |
||
310 | #define BTTV_VERSION _IOR('v' , BASE_VIDIOCPRIVATE+6, int) |
||
311 | #define BTTV_PICNR _IOR('v' , BASE_VIDIOCPRIVATE+7, int) |
||
312 | #define BTTV_VBISIZE _IOR('v' , BASE_VIDIOCPRIVATE+8, int) |
||
313 | |||
314 | #define TDA9850 0x01 |
||
315 | #define TDA9840 0x02 |
||
316 | #define TDA8425 0x03 |
||
317 | #define TEA6300 0x04 |
||
318 | |||
319 | struct tvcard |
||
320 | { |
||
321 | char *name; |
||
322 | int video_inputs; |
||
323 | int audio_inputs; |
||
324 | int tuner; |
||
325 | int svhs; |
||
326 | u32 gpiomask; |
||
327 | u32 muxsel[16]; |
||
328 | u32 audiomux[6]; /* Tuner, Radio, external, internal, mute, stereo */ |
||
329 | u32 gpiomask2; /* GPIO MUX mask */ |
||
330 | |||
331 | /* i2c audio flags */ |
||
332 | int no_msp34xx:1; |
||
333 | int no_tda9875:1; |
||
334 | int no_tda7432:1; |
||
335 | int needs_tvaudio:1; |
||
336 | |||
337 | /* other settings */ |
||
338 | int pll; |
||
339 | #define PLL_NONE 0 |
||
340 | #define PLL_28 1 |
||
341 | #define PLL_35 2 |
||
342 | |||
343 | int tuner_type; |
||
344 | int has_radio; |
||
345 | void (*audio_hook)(struct bttv *btv, struct video_audio *v, int set); |
||
346 | void (*muxsel_hook)(struct bttv *btv, unsigned int input); |
||
347 | }; |
||
348 | |||
349 | extern struct tvcard bttv_tvcards[]; |
||
350 | extern const int bttv_num_tvcards; |
||
351 | |||
352 | /* identification / initialization of the card */ |
||
353 | extern void bttv_idcard(struct bttv *btv); |
||
354 | extern void bttv_init_card1(struct bttv *btv); |
||
355 | extern void bttv_init_card2(struct bttv *btv); |
||
356 | |||
357 | /* card-specific funtions */ |
||
358 | extern void tea5757_set_freq(struct bttv *btv, unsigned short freq); |
||
359 | extern void bttv_tda9880_setnorm(struct bttv *btv, int norm); |
||
360 | |||
361 | /* kernel cmd line parse helper */ |
||
362 | extern int bttv_parse(char *str, int max, int *vals); |
||
363 | |||
364 | /* extra tweaks for some chipsets */ |
||
365 | extern void bttv_check_chipset(void); |
||
366 | extern int bttv_handle_chipset(struct bttv *btv); |
||
367 | |||
368 | /* ---------------------------------------------------------- */ |
||
369 | /* exported by bttv-if.c */ |
||
370 | /* interface for gpio access by other modules */ |
||
371 | |||
372 | /* returns card type + card ID (for bt878-based ones) |
||
373 | for possible values see lines below beginning with #define BTTV_UNKNOWN |
||
374 | returns negative value if error occurred |
||
375 | */ |
||
376 | extern int bttv_get_cardinfo(unsigned int card, int *type, int *cardid); |
||
377 | |||
378 | /* obsolete, use bttv_get_cardinfo instead */ |
||
379 | extern int bttv_get_id(unsigned int card); |
||
380 | |||
381 | /* sets GPOE register (BT848_GPIO_OUT_EN) to new value: |
||
382 | data | (current_GPOE_value & ~mask) |
||
383 | returns negative value if error occurred |
||
384 | */ |
||
385 | extern int bttv_gpio_enable(unsigned int card, |
||
386 | unsigned long mask, unsigned long data); |
||
387 | |||
388 | /* fills data with GPDATA register contents |
||
389 | returns negative value if error occurred |
||
390 | */ |
||
391 | extern int bttv_read_gpio(unsigned int card, unsigned long *data); |
||
392 | |||
393 | /* sets GPDATA register to new value: |
||
394 | (data & mask) | (current_GPDATA_value & ~mask) |
||
395 | returns negative value if error occurred |
||
396 | */ |
||
397 | extern int bttv_write_gpio(unsigned int card, |
||
398 | unsigned long mask, unsigned long data); |
||
399 | |||
400 | /* i2c */ |
||
401 | extern void bttv_bit_setscl(void *data, int state); |
||
402 | extern void bttv_bit_setsda(void *data, int state); |
||
403 | extern void bttv_call_i2c_clients(struct bttv *btv, unsigned int cmd, void *arg); |
||
404 | extern int bttv_I2CRead(struct bttv *btv, unsigned char addr, char *probe_for); |
||
405 | extern int bttv_I2CWrite(struct bttv *btv, unsigned char addr, unsigned char b1, |
||
406 | unsigned char b2, int both); |
||
407 | extern void bttv_readee(struct bttv *btv, unsigned char *eedata, int addr); |
||
408 | |||
409 | struct pci_dev; |
||
410 | extern struct bttv *bttv_find_matching_card( struct pci_dev *dev ); |
||
411 | |||
412 | #endif /* _BTTV_H_ */ |