1 /*
2 bttv-cards.c
3
4 this file has configuration informations - card-specific stuff
5 like the big tvcards array for the most part
6
7 Copyright (C) 1996,97,98 Ralph Metzler (rjkm@thp.uni-koeln.de)
8 & Marcus Metzler (mocm@thp.uni-koeln.de)
9 (c) 1999,2000 Gerd Knorr <kraxel@goldbach.in-berlin.de>
10
11 This program is free software; you can redistribute it and/or modify
12 it under the terms of the GNU General Public License as published by
13 the Free Software Foundation; either version 2 of the License, or
14 (at your option) any later version.
15
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License for more details.
20
21 You should have received a copy of the GNU General Public License
22 along with this program; if not, write to the Free Software
23 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24
25 */
26
27 #define __NO_VERSION__ 1
28
29 #include <linux/version.h>
30 #include <linux/delay.h>
31 #include <linux/module.h>
32 #include <linux/kmod.h>
33 #include <linux/init.h>
34 #include <linux/pci.h>
35
36 #include <asm/io.h>
37
38 #include "bttvp.h"
39 #include "tuner.h"
40
41 /* fwd decl */
42 static void hauppauge_eeprom(struct bttv *btv);
43 static void init_PXC200(struct bttv *btv);
44 #if 0
45 static void init_tea5757(struct bttv *btv);
46 #endif
47
48 static void winview_audio(struct bttv *btv, struct video_audio *v, int set);
49 static void avermedia_tvphone_audio(struct bttv *btv, struct video_audio *v,
50 int set);
51 static void terratv_audio(struct bttv *btv, struct video_audio *v, int set);
52 static void gvbctv3pci_audio(struct bttv *btv, struct video_audio *v, int set);
53
54 /* config variables */
55 static int triton1=0;
56 static unsigned int card[4] = { -1, -1, -1, -1 };
57 static unsigned int pll[4] = { -1, -1, -1, -1 };
58 static unsigned int tuner[4] = { -1, -1, -1, -1 };
59 #ifdef MODULE
60 static unsigned int autoload = 1;
61 #else
62 static unsigned int autoload = 0;
63 #endif
64 static unsigned int gpiomask = -1;
65 static unsigned int audioall = -1;
66 static unsigned int audiomux[5] = { -1, -1, -1, -1, -1 };
67
68 /* insmod options */
69 MODULE_PARM(triton1,"i");
70 MODULE_PARM(card,"1-4i");
71 MODULE_PARM_DESC(card,"specify TV/grabber card model, see CARDLIST file for a list");
72 MODULE_PARM(pll,"1-4i");
73 MODULE_PARM_DESC(pll,"specify installed crystal (0=none, 28=28 MHz, 35=35 MHz)");
74 MODULE_PARM(tuner,"1-4i");
75 MODULE_PARM_DESC(tuner,"specify installed tuner type");
76 MODULE_PARM(autoload,"i");
77 MODULE_PARM_DESC(autoload,"automatically load i2c modules like tuner.o, default is 1 (yes)");
78 MODULE_PARM(gpiomask,"i");
79 MODULE_PARM(audioall,"i");
80 MODULE_PARM(audiomux,"1-5i");
81
82 /* kernel args */
83 #ifndef MODULE
84 static int __init p_card(char *str) { return bttv_parse(str,BTTV_MAX,card); }
85 static int __init p_pll(char *str) { return bttv_parse(str,BTTV_MAX,pll); }
86 static int __init p_tuner(char *str) { return bttv_parse(str,BTTV_MAX,tuner); }
87 __setup("bttv.card=", p_card);
88 __setup("bttv.pll=", p_pll);
89 __setup("bttv.tuner=", p_tuner);
90
91 int __init bttv_parse(char *str, int max, int *vals)
92 {
93 int i,number,res = 2;
94
95 for (i = 0; res == 2 && i < max; i++) {
96 res = get_option(&str,&number);
97 if (res)
98 vals[i] = number;
99 }
100 return 1;
101 }
102 #endif
103
104 /* ----------------------------------------------------------------------- */
105 /* list of card IDs for bt878+ cards */
106
107 static struct CARD {
108 unsigned id;
109 int cardnr;
110 char *name;
111 } cards[] __devinitdata = {
112 { 0x00011002, BTTV_HAUPPAUGE878, "ATI TV Wonder" },
113 { 0x00011461, BTTV_AVPHONE98, "AVerMedia TVPhone98" },
114 { 0x00021461, BTTV_AVERMEDIA98, "Avermedia TVCapture 98" },
115 { 0x00031002, BTTV_HAUPPAUGE878, "ATI TV Wonder/VE" },
116 { 0x00031461, BTTV_AVPHONE98, "AVerMedia TVPhone98" },
117 { 0x00041461, BTTV_AVERMEDIA98, "AVerMedia TVCapture 98" },
118 { 0x10b42636, BTTV_HAUPPAUGE878, "STB ???" },
119 { 0x1118153b, BTTV_TERRATVALUE, "Terratec TV Value" },
120 { 0x1123153b, BTTV_TERRATVRADIO, "Terratec TV/Radio+" },
121 { 0x1200bd11, BTTV_PINNACLERAVE, "Pinnacle PCTV Rave" },
122 { 0x13eb0070, BTTV_HAUPPAUGE878, "Hauppauge WinTV" },
123 { 0x18501851, BTTV_CHRONOS_VS2, "Chronos Video Shuttle II" },
124 { 0x18521852, BTTV_TYPHOON_TVIEW, "Typhoon TView TV/FM Tuner" },
125 { 0x217d6606, BTTV_WINFAST2000, "Leadtek WinFast TV 2000" },
126 { 0x263610b4, BTTV_STB2, "STB TV PCI FM, P/N 6000704" },
127 { 0x3000121a, 0/* no entry yet */,"VoodooTV 200" },
128 { 0x3000144f, BTTV_MAGICTVIEW063, "TView 99 (CPH063)" },
129 { 0x300014ff, BTTV_MAGICTVIEW061, "TView 99 (CPH061)" },
130 { 0x3002144f, BTTV_MAGICTVIEW061, "Askey Magic TView" },
131 { 0x300214ff, BTTV_PHOEBE_TVMAS, "Phoebe TV Master" },
132 { 0x39000070, BTTV_HAUPPAUGE878, "Hauppauge WinTV-D" },
133 { 0x400a15b0, BTTV_ZOLTRIX_GENIE, "Zoltrix Genie TV" },
134 { 0x401015b0, BTTV_ZOLTRIX_GENIE, "Zoltrix Genie TV / Radio" },
135 { 0x402010fc, BTTV_GVBCTV3PCI, "I-O Data Co. GV-BCV3/PCI" },
136 { 0xff000070, BTTV_HAUPPAUGE878, "Osprey-100" },
137 { 0xff010070, BTTV_HAUPPAUGE878, "Osprey-200" },
138 #if 0 /* probably wrong */
139 { 0x14610002, BTTV_AVERMEDIA98, "Avermedia TVCapture 98" },
140 { 0x6606217d, BTTV_WINFAST2000, "Leadtek WinFast TV 2000" },
141 #endif
142 { 0, -1, NULL }
143 };
144
145 /* ----------------------------------------------------------------------- */
146 /* array with description for bt848 / bt878 tv/grabber cards */
147
148 struct tvcard bttv_tvcards[] = {
149 {
150 /* ---- card 0x00 ---------------------------------- */
151 name: " *** UNKNOWN *** ",
152 video_inputs: 4,
153 audio_inputs: 1,
154 tuner: 0,
155 svhs: 2,
156 muxsel: { 2, 3, 1, 0},
157 tuner_type: -1,
158 },{
159 name: "MIRO PCTV",
160 video_inputs: 4,
161 audio_inputs: 1,
162 tuner: 0,
163 svhs: 2,
164 gpiomask: 15,
165 muxsel: { 2, 3, 1, 1},
166 audiomux: { 2, 0, 0, 0, 10},
167 needs_tvaudio: 1,
168 tuner_type: -1,
169 },{
170 name: "Hauppauge old",
171 video_inputs: 4,
172 audio_inputs: 1,
173 tuner: 0,
174 svhs: 2,
175 gpiomask: 7,
176 muxsel: { 2, 3, 1, 1},
177 audiomux: { 0, 1, 2, 3, 4},
178 needs_tvaudio: 1,
179 tuner_type: -1,
180 },{
181 name: "STB",
182 video_inputs: 3,
183 audio_inputs: 1,
184 tuner: 0,
185 svhs: 2,
186 gpiomask: 7,
187 muxsel: { 2, 3, 1, 1},
188 audiomux: { 4, 0, 2, 3, 1},
189 no_msp34xx: 1,
190 needs_tvaudio: 1,
191 tuner_type: -1,
192 },{
193
194 /* ---- card 0x04 ---------------------------------- */
195 name: "Intel",
196 video_inputs: 3,
197 audio_inputs: 1,
198 tuner: 0,
199 svhs: -1,
200 gpiomask: 7,
201 muxsel: { 2, 3, 1, 1},
202 audiomux: { 0, 1, 2, 3, 4},
203 needs_tvaudio: 1,
204 tuner_type: -1,
205 },{
206 name: "Diamond DTV2000",
207 video_inputs: 4,
208 audio_inputs: 1,
209 tuner: 0,
210 svhs: 2,
211 gpiomask: 3,
212 muxsel: { 2, 3, 1, 0},
213 audiomux: { 0, 1, 0, 1, 3},
214 needs_tvaudio: 1,
215 tuner_type: -1,
216 },{
217 name: "AVerMedia TVPhone",
218 video_inputs: 3,
219 audio_inputs: 1,
220 tuner: 0,
221 svhs: 3,
222 gpiomask: 15,
223 muxsel: { 2, 3, 1, 1},
224 audiomux: {12, 4,11,11, 0},
225 needs_tvaudio: 1,
226 pll: PLL_28,
227 tuner_type: -1,
228 },{
229 name: "MATRIX-Vision MV-Delta",
230 video_inputs: 5,
231 audio_inputs: 1,
232 tuner: -1,
233 svhs: 3,
234 gpiomask: 0,
235 muxsel: { 2, 3, 1, 0, 0},
236 audiomux: {0 },
237 needs_tvaudio: 1,
238 tuner_type: -1,
239 },{
240
241 /* ---- card 0x08 ---------------------------------- */
242 name: "Fly Video II",
243 video_inputs: 3,
244 audio_inputs: 1,
245 tuner: 0,
246 svhs: 2,
247 gpiomask: 0xc00,
248 muxsel: { 2, 3, 1, 1},
249 audiomux: { 0, 0xc00, 0x800, 0x400, 0xc00, 0},
250 needs_tvaudio: 1,
251 tuner_type: -1,
252 },{
253 name: "TurboTV",
254 video_inputs: 3,
255 audio_inputs: 1,
256 tuner: 0,
257 svhs: 2,
258 gpiomask: 3,
259 muxsel: { 2, 3, 1, 1},
260 audiomux: { 1, 1, 2, 3, 0},
261 needs_tvaudio: 1,
262 tuner_type: -1,
263 },{
264 name: "Hauppauge new (bt878)",
265 video_inputs: 4,
266 audio_inputs: 1,
267 tuner: 0,
268 svhs: 2,
269 gpiomask: 7,
270 muxsel: { 2, 0, 1, 1},
271 audiomux: { 0, 1, 2, 3, 4},
272 needs_tvaudio: 1,
273 pll: PLL_28,
274 tuner_type: -1,
275 },{
276 name: "MIRO PCTV pro",
277 video_inputs: 3,
278 audio_inputs: 1,
279 tuner: 0,
280 svhs: 2,
281 gpiomask: 65551,
282 muxsel: { 2, 3, 1, 1},
283 audiomux: {1,65537, 0, 0,10},
284 needs_tvaudio: 1,
285 tuner_type: -1,
286 },{
287
288 /* ---- card 0x0c ---------------------------------- */
289 name: "ADS Technologies Channel Surfer TV",
290 video_inputs: 3,
291 audio_inputs: 1,
292 tuner: 0,
293 svhs: 2,
294 gpiomask: 15,
295 muxsel: { 2, 3, 1, 1},
296 audiomux: { 13, 14, 11, 7, 0, 0},
297 needs_tvaudio: 1,
298 tuner_type: -1,
299 },{
300 name: "AVerMedia TVCapture 98",
301 video_inputs: 3,
302 audio_inputs: 4,
303 tuner: 0,
304 svhs: 2,
305 gpiomask: 15,
306 muxsel: { 2, 3, 1, 1},
307 audiomux: { 13, 14, 11, 7, 0, 0},
308 needs_tvaudio: 1,
309 pll: PLL_28,
310 tuner_type: 5,
311 },{
312 name: "Aimslab VHX",
313 video_inputs: 3,
314 audio_inputs: 1,
315 tuner: 0,
316 svhs: 2,
317 gpiomask: 7,
318 muxsel: { 2, 3, 1, 1},
319 audiomux: { 0, 1, 2, 3, 4},
320 needs_tvaudio: 1,
321 tuner_type: -1,
322 },{
323 name: "Zoltrix TV-Max",
324 video_inputs: 3,
325 audio_inputs: 1,
326 tuner: 0,
327 svhs: 2,
328 gpiomask: 15,
329 muxsel: { 2, 3, 1, 1},
330 audiomux: {0 , 0, 1 , 0, 10},
331 needs_tvaudio: 1,
332 tuner_type: -1,
333 },{
334
335 /* ---- card 0x10 ---------------------------------- */
336 name: "Pixelview PlayTV (bt878)",
337 video_inputs: 3,
338 audio_inputs: 1,
339 tuner: 0,
340 svhs: 2,
341 gpiomask: 0x01fe00,
342 muxsel: { 2, 3, 1, 1},
343 audiomux: { 0x01c000, 0, 0x018000, 0x014000, 0x002000, 0 },
344 needs_tvaudio: 1,
345 pll: PLL_28,
346 tuner_type: -1,
347 },{
348 name: "Leadtek WinView 601",
349 video_inputs: 3,
350 audio_inputs: 1,
351 tuner: 0,
352 svhs: 2,
353 gpiomask: 0x8300f8,
354 muxsel: { 2, 3, 1, 1,0},
355 audiomux: { 0x4fa007,0xcfa007,0xcfa007,0xcfa007,0xcfa007,0xcfa007},
356 needs_tvaudio: 1,
357 tuner_type: -1,
358 audio_hook: winview_audio,
359 },{
360 name: "AVEC Intercapture",
361 video_inputs: 3,
362 audio_inputs: 2,
363 tuner: 0,
364 svhs: 2,
365 gpiomask: 0,
366 muxsel: {2, 3, 1, 1},
367 audiomux: {1, 0, 0, 0, 0},
368 needs_tvaudio: 1,
369 tuner_type: -1,
370 },{
371 name: "LifeView FlyKit w/o Tuner",
372 video_inputs: 3,
373 audio_inputs: 1,
374 tuner: -1,
375 svhs: -1,
376 gpiomask: 0x8dff00,
377 muxsel: { 2, 3, 1, 1},
378 audiomux: { 0 },
379 no_msp34xx: 1,
380 tuner_type: -1,
381 },{
382
383 /* ---- card 0x14 ---------------------------------- */
384 name: "CEI Raffles Card",
385 video_inputs: 3,
386 audio_inputs: 3,
387 tuner: 0,
388 svhs: 2,
389 muxsel: {2, 3, 1, 1},
390 tuner_type: -1,
391 },{
392 name: "Lucky Star Image World ConferenceTV",
393 video_inputs: 3,
394 audio_inputs: 1,
395 tuner: 0,
396 svhs: 2,
397 gpiomask: 0x00fffe07,
398 muxsel: { 2, 3, 1, 1},
399 audiomux: { 131072, 1, 1638400, 3, 4},
400 needs_tvaudio: 1,
401 pll: PLL_28,
402 tuner_type: TUNER_PHILIPS_PAL_I,
403 },{
404 name: "Phoebe Tv Master + FM",
405 video_inputs: 3,
406 audio_inputs: 1,
407 tuner: 0,
408 svhs: 2,
409 gpiomask: 0xc00,
410 muxsel: { 2, 3, 1, 1},
411 audiomux: {0, 1, 0x800, 0x400, 0xc00, 0},
412 needs_tvaudio: 1,
413 tuner_type: -1,
414 },{
415 name: "Modular Technology MM205 PCTV, bt878",
416 video_inputs: 2,
417 audio_inputs: 1,
418 tuner: 0,
419 svhs: -1,
420 gpiomask: 7,
421 muxsel: { 2, 3 },
422 audiomux: { 0, 0, 0, 0, 0 },
423 no_msp34xx: 1,
424 needs_tvaudio: 1,
425 tuner_type: -1,
426 },{
427
428 /* ---- card 0x18 ---------------------------------- */
429 name: "Askey/Typhoon/Anubis Magic TView CPH051/061 (bt878)",
430 video_inputs: 3,
431 audio_inputs: 1,
432 tuner: 0,
433 svhs: 2,
434 gpiomask: 0xe00,
435 muxsel: { 2, 3, 1, 1},
436 audiomux: {0x400, 0x400, 0x400, 0x400, 0},
437 needs_tvaudio: 1,
438 pll: PLL_28,
439 tuner_type: -1,
440 },{
441 name: "Terratec/Vobis TV-Boostar",
442 video_inputs: 3,
443 audio_inputs: 1,
444 tuner: 0,
445 svhs: 2,
446 gpiomask: 16777215,
447 muxsel: { 2, 3, 1, 1},
448 audiomux: { 131072, 1, 1638400, 3,4},
449 needs_tvaudio: 1,
450 tuner_type: -1,
451 },{
452 name: "Newer Hauppauge WinCam (bt878)",
453 video_inputs: 4,
454 audio_inputs: 1,
455 tuner: 0,
456 svhs: 3,
457 gpiomask: 7,
458 muxsel: { 2, 0, 1, 1},
459 audiomux: { 0, 1, 2, 3, 4},
460 needs_tvaudio: 1,
461 tuner_type: -1,
462 },{
463 name: "MAXI TV Video PCI2",
464 video_inputs: 3,
465 audio_inputs: 1,
466 tuner: 0,
467 svhs: 2,
468 gpiomask: 0xffff,
469 muxsel: { 2, 3, 1, 1},
470 audiomux: { 0, 1, 2, 3, 0xc00},
471 needs_tvaudio: 1,
472 tuner_type: TUNER_PHILIPS_SECAM,
473 },{
474
475 /* ---- card 0x1c ---------------------------------- */
476 name: "Terratec TerraTV+",
477 video_inputs: 3,
478 audio_inputs: 1,
479 tuner: 0,
480 svhs: 2,
481 gpiomask: 0x70000,
482 muxsel: { 2, 3, 1, 1},
483 audiomux: { 0x20000, 0x30000, 0x00000, 0x10000, 0x40000},
484 needs_tvaudio: 1,
485 tuner_type: -1,
486 audio_hook: terratv_audio,
487 },{
488 name: "Imagenation PXC200",
489 video_inputs: 5,
490 audio_inputs: 1,
491 tuner: -1,
492 svhs: 4,
493 gpiomask: 0,
494 muxsel: { 2, 3, 1, 0, 0},
495 audiomux: { 0 },
496 needs_tvaudio: 1,
497 tuner_type: -1,
498 },{
499 name: "FlyVideo 98",
500 video_inputs: 3,
501 audio_inputs: 1,
502 tuner: 0,
503 svhs: 2,
504 gpiomask: 0x8dfe00,
505 muxsel: {2, 3, 1, 1},
506 audiomux: { 0, 0x8dff00, 0x8df700, 0x8de700, 0x8dff00, 0 },
507 needs_tvaudio: 1,
508 tuner_type: -1,
509 },{
510 name: "iProTV",
511 video_inputs: 3,
512 audio_inputs: 1,
513 tuner: 0,
514 svhs: 2,
515 gpiomask: 1,
516 muxsel: { 2, 3, 1, 1},
517 audiomux: { 1, 0, 0, 0, 0 },
518 tuner_type: -1,
519 },{
520
521 /* ---- card 0x20 ---------------------------------- */
522 name: "Intel Create and Share PCI",
523 video_inputs: 4,
524 audio_inputs: 1,
525 tuner: 0,
526 svhs: 2,
527 gpiomask: 7,
528 muxsel: { 2, 3, 1, 1},
529 audiomux: { 4, 4, 4, 4, 4},
530 needs_tvaudio: 1,
531 tuner_type: -1,
532 },{
533 name: "Terratec TerraTValue",
534 video_inputs: 3,
535 audio_inputs: 1,
536 tuner: 0,
537 svhs: 2,
538 gpiomask: 0xffff00,
539 muxsel: { 2, 3, 1, 1},
540 audiomux: { 0x500, 0, 0x300, 0x900, 0x900},
541 needs_tvaudio: 1,
542 tuner_type: -1,
543 },{
544 name: "Leadtek WinFast 2000",
545 video_inputs: 3,
546 audio_inputs: 1,
547 tuner: 0,
548 svhs: 2,
549 gpiomask: 0xfff000,
550 muxsel: { 2, 3, 1, 1,0},
551 audiomux: { 0x621000,0x6ddf07,0x621100,0x620000,0xE210000,0x620000},
552 needs_tvaudio: 1,
553 pll: PLL_28,
554 tuner_type: -1,
555 },{
556 name: "Chronos Video Shuttle II",
557 video_inputs: 3,
558 audio_inputs: 3,
559 tuner: 0,
560 svhs: 2,
561 gpiomask: 0x1800,
562 muxsel: { 2, 3, 1, 1},
563 audiomux: { 0, 0, 0x1000, 0x1000, 0x0800},
564 needs_tvaudio: 1,
565 pll: PLL_28,
566 tuner_type: -1,
567 },{
568
569 /* ---- card 0x24 ---------------------------------- */
570 name: "Typhoon TView TV/FM Tuner",
571 video_inputs: 3,
572 audio_inputs: 3,
573 tuner: 0,
574 svhs: 2,
575 gpiomask: 0x1800,
576 muxsel: { 2, 3, 1, 1},
577 audiomux: { 0, 0x800, 0, 0, 0x1800, 0 },
578 needs_tvaudio: 1,
579 pll: PLL_28,
580 tuner_type: -1,
581 },{
582 name: "PixelView PlayTV pro",
583 video_inputs: 3,
584 audio_inputs: 1,
585 tuner: 0,
586 svhs: 2,
587 gpiomask: 0xff,
588 muxsel: { 2, 3, 1, 1 },
589 audiomux: { 0x21, 0x20, 0x24, 0x2c, 0x29, 0x29 },
590 no_msp34xx: 1,
591 pll: PLL_28,
592 tuner_type: -1,
593 },{
594 name: "TView99 CPH063",
595 video_inputs: 4,
596 audio_inputs: 1,
597 tuner: 0,
598 svhs: 2,
599 gpiomask: 0x551e00,
600 muxsel: { 2, 3, 1, 0},
601 audiomux: { 0x551400, 0x551200, 0, 0, 0, 0x551200 },
602 needs_tvaudio: 1,
603 pll: PLL_28,
604 tuner_type: -1,
605 },{
606 name: "Pinnacle PCTV Rave",
607 video_inputs: 3,
608 audio_inputs: 1,
609 tuner: 0,
610 svhs: 2,
611 gpiomask: 0x03000F,
612 muxsel: { 2, 3, 1, 1},
613 audiomux: { 2, 0, 0, 0, 1},
614 needs_tvaudio: 1,
615 pll: PLL_28,
616 tuner_type: -1,
617 },{
618
619 /* ---- card 0x28 ---------------------------------- */
620 name: "STB2",
621 video_inputs: 3,
622 audio_inputs: 1,
623 tuner: 0,
624 svhs: 2,
625 gpiomask: 7,
626 muxsel: { 2, 3, 1, 1},
627 audiomux: { 4, 0, 2, 3, 1},
628 no_msp34xx: 1,
629 needs_tvaudio: 1,
630 tuner_type: -1,
631 },{
632 name: "AVerMedia TVPhone 98",
633 video_inputs: 3,
634 audio_inputs: 4,
635 tuner: 0,
636 svhs: 2,
637 gpiomask: 12,
638 muxsel: { 2, 3, 1, 1},
639 audiomux: { 13, 14, 11, 7, 0, 0},
640 needs_tvaudio: 1,
641 pll: PLL_28,
642 tuner_type: 5,
643 audio_hook: avermedia_tvphone_audio,
644 },{
645 name: "ProVideo PV951", /* pic16c54 */
646 video_inputs: 3,
647 audio_inputs: 1,
648 tuner: 0,
649 svhs: 2,
650 gpiomask: 0,
651 muxsel: { 2, 3, 1, 1},
652 audiomux: { 0, 0, 0, 0, 0},
653 no_msp34xx: 1,
654 pll: PLL_28,
655 tuner_type: 1,
656 },{
657 name: "Little OnAir TV",
658 video_inputs: 3,
659 audio_inputs: 1,
660 tuner: 0,
661 svhs: 2,
662 gpiomask: 0xe00b,
663 muxsel: {2, 3, 1, 1},
664 audiomux: {0xff9ff6, 0xff9ff6, 0xff1ff7, 0, 0xff3ffc},
665 no_msp34xx: 1,
666 tuner_type: -1,
667 },{
668
669 /* ---- card 0x2c ---------------------------------- */
670 name: "Sigma TVII-FM",
671 video_inputs: 2,
672 audio_inputs: 1,
673 tuner: 0,
674 svhs: -1,
675 gpiomask: 3,
676 muxsel: {2, 3, 1, 1},
677 audiomux: {1, 1, 0, 2, 3},
678 no_msp34xx: 1,
679 pll: PLL_NONE,
680 tuner_type: -1,
681 },{
682 name: "MATRIX-Vision MV-Delta 2",
683 video_inputs: 5,
684 audio_inputs: 1,
685 tuner: -1,
686 svhs: 3,
687 gpiomask: 0,
688 muxsel: { 2, 3, 1, 0, 0},
689 audiomux: {0 },
690 no_msp34xx: 1,
691 pll: PLL_28,
692 tuner_type: -1,
693 },{
694 name: "Zoltrix Genie TV",
695 video_inputs: 3,
696 audio_inputs: 1,
697 tuner: 0,
698 svhs: 2,
699 gpiomask: 0xbcf03f,
700 muxsel: { 2, 3, 1, 1},
701 audiomux: { 0xbc803f, 0, 0xbcb03f, 0, 0xbcb03f},
702 no_msp34xx: 1,
703 pll: PLL_28,
704 tuner_type: 5,
705 },{
706 name: "Terratec TV/Radio+",
707 video_inputs: 3,
708 audio_inputs: 1,
709 tuner: 0,
710 svhs: 2,
711 gpiomask: 0x1f0000,
712 muxsel: { 2, 3, 1, 1},
713 audiomux: { 0xe2ffff, 0xebffff, 0, 0, 0xe0ffff, 0xe2ffff },
714 no_msp34xx: 1,
715 pll: PLL_35,
716 tuner_type: 1,
717 },{
718
719 /* ---- card 0x30 ---------------------------------- */
720 name: "Dynalink Magic TView ",
721 video_inputs: 3,
722 audio_inputs: 1,
723 tuner: 0,
724 svhs: 2,
725 gpiomask: 15,
726 muxsel: { 2, 3, 1, 1},
727 audiomux: {2,0,0,0,1},
728 needs_tvaudio: 1,
729 pll: PLL_28,
730 tuner_type: -1,
731 },{
732 name: "GV-BCTV3",
733 video_inputs: 3,
734 audio_inputs: 1,
735 tuner: 0,
736 svhs: 2,
737 gpiomask: 0x010f00,
738 muxsel: {2, 3, 0, 0},
739 audiomux: {0x10000, 0, 0x10000, 0, 0, 0},
740 no_msp34xx: 1,
741 pll: PLL_28,
742 tuner_type: TUNER_ALPS_TSHC6_NTSC,
743 audio_hook: gvbctv3pci_audio,
744 },{
745 name: "Prolink PV-BT878P+4E (PixelView PlayTV PAK)",
746 video_inputs: 4,
747 audio_inputs: 1,
748 tuner: 0,
749 svhs: 2,
750 gpiomask: 0xAA0000,
751 muxsel: { 2,3,1,1 },
752 audiomux: { 0x20000, 0, 0x80000, 0x80000, 0xa8000, 0x46000 },
753 no_msp34xx: 1,
754 pll: PLL_28,
755 tuner_type: TUNER_PHILIPS_PAL_I,
756 },{
757 name: "Eagle Wireless Capricorn2 (bt878A)",
758 video_inputs: 4,
759 audio_inputs: 1,
760 tuner: 0,
761 svhs: 2,
762 gpiomask: 7,
763 muxsel: { 2, 0, 1, 1},
764 audiomux: { 0, 1, 2, 3, 4},
765 pll: PLL_28,
766 tuner_type: -1 /* TUNER_ALPS_TMDH2_NTSC */,
767 },{
768
769 /* ---- card 0x34 ---------------------------------- */
770 name: "Pinnacle Studio PCTV Pro", /* David Härdeman <david@2gen.com> */
771 video_inputs: 3,
772 audio_inputs: 1,
773 tuner: 0,
774 svhs: 2,
775 gpiomask: 0x03000F,
776 muxsel: { 2, 3, 1, 1},
777 audiomux: { 1, 65537, 0, 0, 10},
778 needs_tvaudio: 1,
779 pll: PLL_28,
780 tuner_type: -1,
781 },{
782 name: "Typhoon TView RDS", /* Claas Langbehn <claas@bigfoot.com> */
783 video_inputs: 3,
784 audio_inputs: 3,
785 tuner: 0,
786 svhs: 2,
787 gpiomask: 0xffff,
788 muxsel: { 2, 3, 1, 1},
789 audiomux: { 0xb002, 0, 0x12, 0x12, 0x3007 },
790 needs_tvaudio: 1,
791 pll: PLL_28,
792 tuner_type: TUNER_PHILIPS_PAL_I,
793 }};
794
795 const int bttv_num_tvcards = (sizeof(bttv_tvcards)/sizeof(struct tvcard));
796
797 /* ----------------------------------------------------------------------- */
798
799 static unsigned char eeprom_data[256];
800
801 /*
802 * identify card
803 */
804 void __devinit bttv_idcard(struct bttv *btv)
805 {
806 unsigned int gpiobits;
807 int i,type;
808 unsigned short tmp;
809
810 /* read PCI subsystem ID */
811 pci_read_config_word(btv->dev, PCI_SUBSYSTEM_ID, &tmp);
812 btv->cardid = tmp << 16;
813 pci_read_config_word(btv->dev, PCI_SUBSYSTEM_VENDOR_ID, &tmp);
814 btv->cardid |= tmp;
815
816 if (0 != btv->cardid && 0xffffffff != btv->cardid) {
817 /* look for the card */
818 for (type = -1, i = 0; cards[i].id != 0; i++)
819 if (cards[i].id == btv->cardid)
820 type = i;
821
822 if (type != -1) {
823 /* found it */
824 printk(KERN_INFO "bttv%d: subsystem: %04x:%04x => %s => card=%d\n",
825 btv->nr, btv->cardid & 0xffff, btv->cardid >> 16,
826 cards[type].name,cards[type].cardnr);
827 btv->type = cards[type].cardnr;
828 } else {
829 /* 404 */
830 printk(KERN_INFO "bttv%d: subsystem: %04x:%04x (UNKNOWN)\n",
831 btv->nr, btv->cardid&0xffff, btv->cardid>>16);
832 printk(KERN_DEBUG "please mail id, board name and "
833 "the correct card= insmod option to "
834 "kraxel@goldbach.in-berlin.de\n");
835 }
836 }
837
838 /* let the user override the autodetected type */
839 if (card[btv->nr] >= 0 && card[btv->nr] < bttv_num_tvcards)
840 btv->type=card[btv->nr];
841
842 /* print which card config we are using */
843 sprintf(btv->video_dev.name,"BT%d%s(%.23s)",
844 btv->id,
845 (btv->id==848 && btv->revision==0x12) ? "A" : "",
846 bttv_tvcards[btv->type].name);
847 printk(KERN_INFO "bttv%d: model: %s [%s]\n",btv->nr,btv->video_dev.name,
848 (card[btv->nr] >= 0 && card[btv->nr] < bttv_num_tvcards) ?
849 "insmod option" : "autodetected");
850
851 /* overwrite gpio stuff ?? */
852 if (-1 == audioall && -1 == audiomux[0])
853 return;
854
855 if (-1 != audiomux[0]) {
856 gpiobits = 0;
857 for (i = 0; i < 5; i++) {
858 bttv_tvcards[btv->type].audiomux[i] = audiomux[i];
859 gpiobits |= audiomux[i];
860 }
861 } else {
862 gpiobits = audioall;
863 for (i = 0; i < 5; i++) {
864 bttv_tvcards[btv->type].audiomux[i] = audioall;
865 }
866 }
867 bttv_tvcards[btv->type].gpiomask = (-1 != gpiomask) ? gpiomask : gpiobits;
868 printk(KERN_INFO "bttv%d: gpio config override: mask=0x%x, mux=",
869 btv->nr,bttv_tvcards[btv->type].gpiomask);
870 for (i = 0; i < 5; i++) {
871 printk("%s0x%x", i ? "," : "", bttv_tvcards[btv->type].audiomux[i]);
872 }
873 printk("\n");
874 }
875
876 /*
877 * (most) board specific initialisations goes here
878 */
879 void __devinit bttv_init_card(struct bttv *btv)
880 {
881 int eeprom = 0;
882
883 if (btv->type == BTTV_MIRO || btv->type == BTTV_MIROPRO) {
884 /* auto detect tuner for MIRO cards */
885 btv->tuner_type=((btread(BT848_GPIO_DATA)>>10)-1)&7;
886 #if 0
887 if (btv->type == BTTV_MIROPRO) {
888 if (bttv_verbose)
889 printk(KERN_INFO "Initializing TEA5757...\n");
890 init_tea5757(btv);
891 }
892 #endif
893 }
894 if (btv->type == BTTV_HAUPPAUGE || btv->type == BTTV_HAUPPAUGE878) {
895 /* pick up some config infos from the eeprom */
896 if (0xa0 != eeprom) {
897 eeprom = 0xa0;
898 bttv_readee(btv,eeprom_data,0xa0);
899 }
900 hauppauge_eeprom(btv);
901 }
902 if (btv->type == BTTV_PXC200)
903 init_PXC200(btv);
904
905 /* pll configuration */
906 if (!(btv->id==848 && btv->revision==0x11)) {
907 /* defaults from card list */
908 if (PLL_28 == bttv_tvcards[btv->type].pll) {
909 btv->pll.pll_ifreq=28636363;
910 btv->pll.pll_crystal=BT848_IFORM_XT0;
911 }
912 if (PLL_35 == bttv_tvcards[btv->type].pll) {
913 btv->pll.pll_ifreq=35468950;
914 btv->pll.pll_crystal=BT848_IFORM_XT1;
915 }
916 /* insmod options can override */
917 switch (pll[btv->nr]) {
918 case 0: /* none */
919 btv->pll.pll_crystal = 0;
920 btv->pll.pll_ifreq = 0;
921 btv->pll.pll_ofreq = 0;
922 break;
923 case 1: /* 28 MHz */
924 case 28:
925 btv->pll.pll_ifreq = 28636363;
926 btv->pll.pll_ofreq = 0;
927 btv->pll.pll_crystal = BT848_IFORM_XT0;
928 break;
929 case 2: /* 35 MHz */
930 case 35:
931 btv->pll.pll_ifreq = 35468950;
932 btv->pll.pll_ofreq = 0;
933 btv->pll.pll_crystal = BT848_IFORM_XT1;
934 break;
935 }
936 }
937
938 /* tuner configuration (from card list / insmod option) */
939 if (-1 != bttv_tvcards[btv->type].tuner_type)
940 btv->tuner_type = bttv_tvcards[btv->type].tuner_type;
941 if (-1 != tuner[btv->nr])
942 btv->tuner_type = tuner[btv->nr];
943 if (btv->tuner_type != -1)
944 bttv_call_i2c_clients(btv,TUNER_SET_TYPE,&btv->tuner_type);
945
946 /* try to detect audio/fader chips */
947 if (!bttv_tvcards[btv->type].no_msp34xx &&
948 bttv_I2CRead(btv, I2C_MSP3400, "MSP34xx") >=0) {
949 if (autoload)
950 request_module("msp3400");
951 }
952
953 if (bttv_I2CRead(btv, I2C_TDA9875, "TDA9875") >=0) {
954 if (autoload)
955 request_module("tda9875");
956 }
957
958 if (bttv_I2CRead(btv, I2C_TDA7432, "TDA7432") >=0) {
959 if (autoload)
960 request_module("tda7432");
961 }
962
963 if (bttv_tvcards[btv->type].needs_tvaudio) {
964 if (autoload)
965 request_module("tvaudio");
966 }
967
968 if (bttv_tvcards[btv->type].tuner != -1) {
969 if (autoload)
970 request_module("tuner");
971 }
972 }
973
974
975 /* ----------------------------------------------------------------------- */
976 /* some hauppauge specific stuff */
977
978 static struct HAUPPAUGE_TUNER
979 {
980 int id;
981 char *name;
982 }
983 hauppauge_tuner[] __devinitdata =
984 {
985 { TUNER_ABSENT, "" },
986 { TUNER_ABSENT, "External" },
987 { TUNER_ABSENT, "Unspecified" },
988 { TUNER_ABSENT, "Philips FI1216" },
989 { TUNER_PHILIPS_SECAM, "Philips FI1216MF" },
990 { TUNER_PHILIPS_NTSC, "Philips FI1236" },
991 { TUNER_ABSENT, "Philips FI1246" },
992 { TUNER_ABSENT, "Philips FI1256" },
993 { TUNER_PHILIPS_PAL, "Philips FI1216 MK2" },
994 { TUNER_PHILIPS_SECAM, "Philips FI1216MF MK2" },
995 { TUNER_PHILIPS_NTSC, "Philips FI1236 MK2" },
996 { TUNER_PHILIPS_PAL_I, "Philips FI1246 MK2" },
997 { TUNER_ABSENT, "Philips FI1256 MK2" },
998 { TUNER_ABSENT, "Temic 4032FY5" },
999 { TUNER_TEMIC_PAL, "Temic 4002FH5" },
1000 { TUNER_TEMIC_PAL_I, "Temic 4062FY5" },
1001 { TUNER_ABSENT, "Philips FR1216 MK2" },
1002 { TUNER_PHILIPS_SECAM, "Philips FR1216MF MK2" },
1003 { TUNER_PHILIPS_NTSC, "Philips FR1236 MK2" },
1004 { TUNER_PHILIPS_PAL_I, "Philips FR1246 MK2" },
1005 { TUNER_ABSENT, "Philips FR1256 MK2" },
1006 { TUNER_PHILIPS_PAL, "Philips FM1216" },
1007 { TUNER_ABSENT, "Philips FM1216MF" },
1008 { TUNER_PHILIPS_NTSC, "Philips FM1236" },
1009 { TUNER_PHILIPS_PAL_I, "Philips FM1246" },
1010 { TUNER_ABSENT, "Philips FM1256" },
1011 { TUNER_TEMIC_4036FY5_NTSC, "Temic 4036FY5" },
1012 { TUNER_ABSENT, "Samsung TCPN9082D" },
1013 { TUNER_ABSENT, "Samsung TCPM9092P" },
1014 { TUNER_TEMIC_PAL, "Temic 4006FH5" },
1015 { TUNER_ABSENT, "Samsung TCPN9085D" },
1016 { TUNER_ABSENT, "Samsung TCPB9085P" },
1017 { TUNER_ABSENT, "Samsung TCPL9091P" },
1018 { TUNER_ABSENT, "Temic 4039FR5" },
1019 { TUNER_ABSENT, "Philips FQ1216 ME" },
1020 { TUNER_TEMIC_PAL_I, "Temic 4066FY5" },
1021 { TUNER_ABSENT, "Philips TD1536" },
1022 { TUNER_ABSENT, "Philips TD1536D" },
1023 { TUNER_ABSENT, "Philips FMR1236" },
1024 { TUNER_ABSENT, "Philips FI1256MP" },
1025 { TUNER_ABSENT, "Samsung TCPQ9091P" },
1026 { TUNER_ABSENT, "Temic 4006FN5" },
1027 { TUNER_ABSENT, "Temic 4009FR5" },
1028 { TUNER_ABSENT, "Temic 4046FM5" },
1029 };
1030
1031 static void __devinit hauppauge_eeprom(struct bttv *btv)
1032 {
1033 if (eeprom_data[9] < sizeof(hauppauge_tuner)/sizeof(struct HAUPPAUGE_TUNER))
1034 {
1035 btv->tuner_type = hauppauge_tuner[eeprom_data[9]].id;
1036 if (bttv_verbose)
1037 printk("bttv%d: Hauppauge eeprom: model=%d, tuner=%s (%d)\n",btv->nr,
1038 eeprom_data[12] << 8 | eeprom_data[11],
1039 hauppauge_tuner[eeprom_data[9]].name,btv->tuner_type);
1040 }
1041 }
1042
1043 void __devinit bttv_hauppauge_boot_msp34xx(struct bttv *btv)
1044 {
1045 /* reset/enable the MSP on some Hauppauge cards */
1046 /* Thanks to Kyösti Mälkki (kmalkki@cc.hut.fi)! */
1047 btaor(32, ~32, BT848_GPIO_OUT_EN);
1048 btaor(0, ~32, BT848_GPIO_DATA);
1049 udelay(2500);
1050 btaor(32, ~32, BT848_GPIO_DATA);
1051 if (bttv_gpio)
1052 bttv_gpio_tracking(btv,"msp34xx");
1053
1054 if (bttv_verbose)
1055 printk("bttv%d: Hauppauge msp34xx: reset line init\n",btv->nr);
1056 }
1057
1058
1059 /* ----------------------------------------------------------------------- */
1060 /* Imagenation L-Model PXC200 Framegrabber */
1061 /* This is basically the same procedure as
1062 * used by Alessandro Rubini in his pxc200
1063 * driver, but using BTTV functions */
1064
1065 static void __devinit init_PXC200(struct bttv *btv)
1066 {
1067 static const int vals[] = { 0x08, 0x09, 0x0a, 0x0b, 0x0d, 0x0d,
1068 0x01, 0x02, 0x03, 0x04, 0x05, 0x06,
1069 0x00 };
1070 int i,tmp;
1071
1072 /* Initialise GPIO-connevted stuff */
1073 btwrite(1<<13,BT848_GPIO_OUT_EN); /* Reset pin only */
1074 btwrite(0,BT848_GPIO_DATA);
1075 udelay(3);
1076 btwrite(1<<13,BT848_GPIO_DATA);
1077 /* GPIO inputs are pulled up, so no need to drive
1078 * reset pin any longer */
1079 btwrite(0,BT848_GPIO_OUT_EN);
1080 if (bttv_gpio)
1081 bttv_gpio_tracking(btv,"pxc200");
1082
1083 /* we could/should try and reset/control the AD pots? but
1084 right now we simply turned off the crushing. Without
1085 this the AGC drifts drifts
1086 remember the EN is reverse logic -->
1087 setting BT848_ADC_AGC_EN disable the AGC
1088 tboult@eecs.lehigh.edu
1089 */
1090 btwrite(BT848_ADC_RESERVED|BT848_ADC_AGC_EN, BT848_ADC);
1091
1092 /* Initialise MAX517 DAC */
1093 printk(KERN_INFO "Setting DAC reference voltage level ...\n");
1094 bttv_I2CWrite(btv,0x5E,0,0x80,1);
1095
1096 /* Initialise 12C508 PIC */
1097 /* The I2CWrite and I2CRead commmands are actually to the
1098 * same chips - but the R/W bit is included in the address
1099 * argument so the numbers are different */
1100
1101 printk(KERN_INFO "Initialising 12C508 PIC chip ...\n");
1102
1103 for (i = 0; i < sizeof(vals)/sizeof(int); i++) {
1104 tmp=bttv_I2CWrite(btv,0x1E,vals[i],0,1);
1105 printk(KERN_INFO "I2C Write(0x08) = %i\nI2C Read () = %x\n\n",
1106 tmp,bttv_I2CRead(btv,0x1F,NULL));
1107 }
1108 printk(KERN_INFO "PXC200 Initialised.\n");
1109 }
1110
1111 /* ----------------------------------------------------------------------- */
1112 /* Miro Pro radio stuff -- the tea5757 is connected to some GPIO ports */
1113 /*
1114 * Copyright (c) 1999 Csaba Halasz <qgehali@uni-miskolc.hu>
1115 * This code is placed under the terms of the GNU General Public License
1116 *
1117 * Brutally hacked by Dan Sheridan <dan.sheridan@contact.org.uk> djs52 8/3/00
1118 */
1119
1120 /* bus bits on the GPIO port */
1121 #define TEA_WE 6
1122 #define TEA_DATA 9
1123 #define TEA_CLK 8
1124 #define TEA_MOST 7
1125
1126 #define BUS_LOW(bit) btand(~(1<<TEA_##bit), BT848_GPIO_DATA)
1127 #define BUS_HIGH(bit) btor((1<<TEA_##bit), BT848_GPIO_DATA)
1128 #define BUS_IN(bit) ((btread(BT848_GPIO_DATA) >> TEA_##bit) & 1)
1129
1130 /* TEA5757 register bits */
1131 #define TEA_FREQ 0:14
1132 #define TEA_BUFFER 15:15
1133
1134 #define TEA_SIGNAL_STRENGTH 16:17
1135
1136 #define TEA_PORT1 18:18
1137 #define TEA_PORT0 19:19
1138
1139 #define TEA_BAND 20:21
1140 #define TEA_BAND_FM 0
1141 #define TEA_BAND_MW 1
1142 #define TEA_BAND_LW 2
1143 #define TEA_BAND_SW 3
1144
1145 #define TEA_MONO 22:22
1146 #define TEA_ALLOW_STEREO 0
1147 #define TEA_FORCE_MONO 1
1148
1149 #define TEA_SEARCH_DIRECTION 23:23
1150 #define TEA_SEARCH_DOWN 0
1151 #define TEA_SEARCH_UP 1
1152
1153 #define TEA_STATUS 24:24
1154 #define TEA_STATUS_TUNED 0
1155 #define TEA_STATUS_SEARCHING 1
1156
1157 /* Low-level stuff */
1158 static int tea_read(struct bttv *btv)
1159 {
1160 int value = 0;
1161 long timeout;
1162 int i;
1163
1164 /* better safe than sorry */
1165 btaor((1<<TEA_CLK) | (1<<TEA_WE), ~((1<<TEA_CLK) | (1<<TEA_DATA) | (1<<TEA_WE) | (1<<TEA_MOST)), BT848_GPIO_OUT_EN);
1166 if (bttv_gpio)
1167 bttv_gpio_tracking(btv,"miro tea read");
1168
1169 BUS_LOW(WE);
1170 BUS_LOW(CLK);
1171
1172 udelay(10);
1173 for(timeout = jiffies + 10 * HZ;
1174 BUS_IN(DATA) == 1 && time_before(jiffies, timeout);
1175 schedule()); /* 10 s */
1176 if (BUS_IN(DATA) == 1) {
1177 printk("tea5757: read timeout\n");
1178 return -1;
1179 }
1180 for(timeout = jiffies + HZ/5;
1181 BUS_IN(MOST) == 1 && time_before(jiffies, timeout);
1182 schedule()); /* 0.2 s */
1183 if (bttv_debug) printk("tea5757:");
1184 for(i = 0; i < 24; i++)
1185 {
1186 udelay(10);
1187 BUS_HIGH(CLK);
1188 udelay(10);
1189 if (bttv_debug) printk("%c", (BUS_IN(MOST) == 0)?'T':'-');
1190 BUS_LOW(CLK);
1191 value <<= 1;
1192 value |= (BUS_IN(DATA) == 0)?0:1; /* MSB first */
1193 if (bttv_debug) printk("%c", (BUS_IN(MOST) == 0)?'S':'M');
1194 }
1195 if (bttv_debug) printk("\ntea5757: read 0x%X\n", value);
1196 return value;
1197 }
1198
1199 static int tea_write(struct bttv *btv, int value)
1200 {
1201 int i;
1202 int reg = value;
1203
1204 btaor((1<<TEA_CLK) | (1<<TEA_WE) | (1<<TEA_DATA), ~((1<<TEA_CLK) | (1<<TEA_DATA) | (1<<TEA_WE) | (1<<TEA_MOST)), BT848_GPIO_OUT_EN);
1205 if (bttv_gpio)
1206 bttv_gpio_tracking(btv,"miro tea write");
1207 if (bttv_debug)
1208 printk("tea5757: write 0x%X\n", value);
1209 BUS_LOW(CLK);
1210 BUS_HIGH(WE);
1211 for(i = 0; i < 25; i++)
1212 {
1213 if (reg & 0x1000000)
1214 BUS_HIGH(DATA);
1215 else
1216 BUS_LOW(DATA);
1217 reg <<= 1;
1218 BUS_HIGH(CLK);
1219 udelay(10);
1220 BUS_LOW(CLK);
1221 udelay(10);
1222 }
1223 BUS_LOW(WE); /* unmute !!! */
1224 return 0;
1225 }
1226
1227 void tea5757_set_freq(struct bttv *btv, unsigned short freq)
1228 {
1229 tea_write(btv, 5 * freq + 0x358); /* add 10.7MHz (see docs) */
1230 if (bttv_debug) tea_read(btv);
1231 }
1232
1233 #if 0
1234 void init_tea5757(struct bttv *btv)
1235 {
1236 BUS_LOW(CLK);
1237 BUS_LOW(WE); /* just to be on the safe side... */
1238
1239 /* software CLK (unused) */
1240 btaor(0, BT848_GPIO_DMA_CTL_GPCLKMODE, BT848_GPIO_DMA_CTL);
1241 /* normal mode for GPIO */
1242 btaor(0, BT848_GPIO_DMA_CTL_GPIOMODE, BT848_GPIO_DMA_CTL);
1243 }
1244 #endif
1245
1246 /* ----------------------------------------------------------------------- */
1247 /* winview */
1248
1249 void winview_audio(struct bttv *btv, struct video_audio *v, int set)
1250 {
1251 /* PT2254A programming Jon Tombs, jon@gte.esi.us.es */
1252 int bits_out, loops, vol, data;
1253
1254 if (!set) {
1255 v->mode |= VIDEO_AUDIO_VOLUME;
1256 return;
1257 }
1258
1259 /* 32 levels logarithmic */
1260 vol = 32 - ((v->volume>>11));
1261 /* units */
1262 bits_out = (PT2254_DBS_IN_2>>(vol%5));
1263 /* tens */
1264 bits_out |= (PT2254_DBS_IN_10>>(vol/5));
1265 bits_out |= PT2254_L_CHANEL | PT2254_R_CHANEL;
1266 data = btread(BT848_GPIO_DATA);
1267 data &= ~(WINVIEW_PT2254_CLK| WINVIEW_PT2254_DATA|
1268 WINVIEW_PT2254_STROBE);
1269 for (loops = 17; loops >= 0 ; loops--) {
1270 if (bits_out & (1<<loops))
1271 data |= WINVIEW_PT2254_DATA;
1272 else
1273 data &= ~WINVIEW_PT2254_DATA;
1274 btwrite(data, BT848_GPIO_DATA);
1275 udelay(5);
1276 data |= WINVIEW_PT2254_CLK;
1277 btwrite(data, BT848_GPIO_DATA);
1278 udelay(5);
1279 data &= ~WINVIEW_PT2254_CLK;
1280 btwrite(data, BT848_GPIO_DATA);
1281 }
1282 data |= WINVIEW_PT2254_STROBE;
1283 data &= ~WINVIEW_PT2254_DATA;
1284 btwrite(data, BT848_GPIO_DATA);
1285 udelay(10);
1286 data &= ~WINVIEW_PT2254_STROBE;
1287 btwrite(data, BT848_GPIO_DATA);
1288 }
1289
1290 /* ----------------------------------------------------------------------- */
1291 /* mono/stereo control for various cards (which don't use i2c chips but */
1292 /* connect something to the GPIO pins */
1293
1294 static void
1295 gvbctv3pci_audio(struct bttv *btv, struct video_audio *v, int set)
1296 {
1297 unsigned int con = 0;
1298
1299 if (set) {
1300 btor(0x100, BT848_GPIO_OUT_EN);
1301 if (v->mode & VIDEO_SOUND_LANG1)
1302 con = 0x000;
1303 if (v->mode & VIDEO_SOUND_LANG2)
1304 con = 0x300;
1305 if (v->mode & VIDEO_SOUND_STEREO)
1306 con = 0x200;
1307 // if (v->mode & VIDEO_SOUND_MONO)
1308 // con = 0x100;
1309 btaor(con, ~0x300, BT848_GPIO_DATA);
1310 } else {
1311 v->mode = VIDEO_SOUND_STEREO |
1312 VIDEO_SOUND_LANG1 | VIDEO_SOUND_LANG2;
1313 }
1314 }
1315
1316 /*
1317 * Mario Medina Nussbaum <medisoft@alohabbs.org.mx>
1318 * I discover that on BT848_GPIO_DATA address a byte 0xcce enable stereo,
1319 * 0xdde enables mono and 0xccd enables sap
1320 *
1321 * Petr Vandrovec <VANDROVE@vc.cvut.cz>
1322 * P.S.: At least mask in line above is wrong - GPIO pins 3,2 select
1323 * input/output sound connection, so both must be set for output mode.
1324 *
1325 */
1326 static void
1327 avermedia_tvphone_audio(struct bttv *btv, struct video_audio *v, int set)
1328 {
1329 #if 0 /* needs more testing -- might be we need two versions for PAL/NTSC */
1330 int val = 0;
1331
1332 if (set) {
1333 if (v->mode & VIDEO_SOUND_LANG1) /* SAP */
1334 val = 0xce;
1335 if (v->mode & VIDEO_SOUND_STEREO)
1336 val = 0xcd;
1337 if (val) {
1338 btaor(val, 0xff, BT848_GPIO_OUT_EN);
1339 btaor(val, 0xff, BT848_GPIO_DATA);
1340 if (bttv_gpio)
1341 bttv_gpio_tracking(btv,"avermedia");
1342 }
1343 } else {
1344 v->mode = VIDEO_SOUND_MONO | VIDEO_SOUND_STEREO |
1345 VIDEO_SOUND_LANG1;
1346 return;
1347 }
1348 #endif
1349 }
1350
1351 static void
1352 terratv_audio(struct bttv *btv, struct video_audio *v, int set)
1353 {
1354 unsigned int con = 0;
1355
1356 if (set) {
1357 btor(0x180000, BT848_GPIO_OUT_EN);
1358 if (v->mode & VIDEO_SOUND_LANG2)
1359 con = 0x080000;
1360 if (v->mode & VIDEO_SOUND_STEREO)
1361 con = 0x180000;
1362 btaor(con, ~0x180000, BT848_GPIO_DATA);
1363 if (bttv_gpio)
1364 bttv_gpio_tracking(btv,"terratv");
1365 } else {
1366 v->mode = VIDEO_SOUND_MONO | VIDEO_SOUND_STEREO |
1367 VIDEO_SOUND_LANG1 | VIDEO_SOUND_LANG2;
1368 }
1369 }
1370
1371
1372 /* ----------------------------------------------------------------------- */
1373 /* motherboard chipset specific stuff */
1374
1375 static struct {
1376 char *name;
1377 unsigned short vendor;
1378 unsigned short device;
1379 } needs_etbf[] __devinitdata = {
1380 { "Intel 82437FX [Triton PIIX]",
1381 PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82437 },
1382 { "VIA VT82C597 [Apollo VP3]",
1383 PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C597_0 },
1384 { NULL, 0, 0 }
1385 };
1386
1387 void __devinit bttv_check_chipset(void)
1388 {
1389 int i;
1390 struct pci_dev *dev = NULL;
1391
1392 if(pci_pci_problems & PCIPCI_FAIL)
1393 printk(KERN_WARNING "BT848 and your chipset may not work together.\n");
1394
1395 while ((dev = pci_find_device(PCI_VENDOR_ID_INTEL,
1396 PCI_DEVICE_ID_INTEL_82441, dev))) {
1397 unsigned char b;
1398 pci_read_config_byte(dev, 0x53, &b);
1399 if (bttv_debug)
1400 printk(KERN_INFO "bttv: Host bridge: 82441FX Natoma, "
1401 "bufcon=0x%02x\n",b);
1402 }
1403
1404 if(pci_pci_problems & (PCIPCI_TRITON|PCIPCI_VIAETBF))
1405 {
1406 printk(KERN_INFO "bttv: Host bridge needs ETBF enabled.\n");
1407 triton1=1;
1408 }
1409 }
1410
1411 int __devinit bttv_handle_chipset(struct bttv *btv)
1412 {
1413 unsigned char command;
1414
1415 if (!triton1)
1416 return 0;
1417
1418 if (bttv_verbose)
1419 printk("bttv%d: enabling 430FX/VP3 compatibilty\n",btv->nr);
1420
1421 if (btv->id < 878) {
1422 /* bt848 (mis)uses a bit in the irq mask */
1423 btv->triton1 = BT848_INT_ETBF;
1424 } else {
1425 /* bt878 has a bit in the pci config space for it */
1426 pci_read_config_byte(btv->dev, BT878_DEVCTRL, &command);
1427 command |= BT878_EN_TBFX;
1428 pci_write_config_byte(btv->dev, BT878_DEVCTRL, command);
1429 pci_read_config_byte(btv->dev, BT878_DEVCTRL, &command);
1430 if (!(command&BT878_EN_TBFX)) {
1431 printk("bttv: 430FX compatibility could not be enabled\n");
1432 return -1;
1433 }
1434 }
1435 return 0;
1436 }
1437
1438
1439 #ifndef MODULE
1440
1441 static int __init bttv_card_setup(char *str)
1442 {
1443 int i,number,res = 2;
1444
1445 for (i = 0; res == 2 && i < BTTV_MAX; i++) {
1446 res = get_option(&str,&number);
1447 if (res)
1448 card[i] = number;
1449 }
1450 return 1;
1451 }
1452
1453 __setup("bttv_card=", bttv_card_setup);
1454
1455 #endif /* not MODULE */
1456
1457 /*
1458 * Local variables:
1459 * c-basic-offset: 8
1460 * End:
1461 */
1462
This page was automatically generated by the
LXR engine.
Visit the LXR main site for more
information.