vserver 1.9.3
[linux-2.6.git] / drivers / media / video / bttv-cards.c
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-2001 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 #include <linux/config.h>
28 #include <linux/delay.h>
29 #include <linux/module.h>
30 #include <linux/kmod.h>
31 #include <linux/init.h>
32 #include <linux/pci.h>
33 #include <linux/vmalloc.h>
34 #if defined(CONFIG_FW_LOADER) || defined(CONFIG_FW_LOADER_MODULE)
35 # include <linux/firmware.h>
36 #endif
37
38 #include <asm/io.h>
39
40 #include "bttvp.h"
41 #include "bt832.h"
42
43 /* fwd decl */
44 static void boot_msp34xx(struct bttv *btv, int pin);
45 static void boot_bt832(struct bttv *btv);
46 static void hauppauge_eeprom(struct bttv *btv);
47 static void avermedia_eeprom(struct bttv *btv);
48 static void osprey_eeprom(struct bttv *btv);
49 static void modtec_eeprom(struct bttv *btv);
50 static void init_PXC200(struct bttv *btv);
51
52 static void winview_audio(struct bttv *btv, struct video_audio *v, int set);
53 static void lt9415_audio(struct bttv *btv, struct video_audio *v, int set);
54 static void avermedia_tvphone_audio(struct bttv *btv, struct video_audio *v,
55                                     int set);
56 static void avermedia_tv_stereo_audio(struct bttv *btv, struct video_audio *v,
57                                       int set);
58 static void terratv_audio(struct bttv *btv, struct video_audio *v, int set);
59 static void gvbctv3pci_audio(struct bttv *btv, struct video_audio *v, int set);
60 static void gvbctv5pci_audio(struct bttv *btv, struct video_audio *v, int set);
61 static void winfast2000_audio(struct bttv *btv, struct video_audio *v, int set);
62 static void pvbt878p9b_audio(struct bttv *btv, struct video_audio *v, int set);
63 static void fv2000s_audio(struct bttv *btv, struct video_audio *v, int set);
64 static void windvr_audio(struct bttv *btv, struct video_audio *v, int set);
65 static void adtvk503_audio(struct bttv *btv, struct video_audio *v, int set);
66 static void rv605_muxsel(struct bttv *btv, unsigned int input);
67 static void eagle_muxsel(struct bttv *btv, unsigned int input);
68 static void xguard_muxsel(struct bttv *btv, unsigned int input);
69 static void ivc120_muxsel(struct bttv *btv, unsigned int input);
70 static void gvc1100_muxsel(struct bttv *btv, unsigned int input);
71
72 static void PXC200_muxsel(struct bttv *btv, unsigned int input);
73
74 static void picolo_tetra_muxsel(struct bttv *btv, unsigned int input);
75 static void picolo_tetra_init(struct bttv *btv);
76
77 static void sigmaSLC_muxsel(struct bttv *btv, unsigned int input);
78 static void sigmaSQ_muxsel(struct bttv *btv, unsigned int input);
79
80 static int terratec_active_radio_upgrade(struct bttv *btv);
81 static int tea5757_read(struct bttv *btv);
82 static int tea5757_write(struct bttv *btv, int value);
83 static void identify_by_eeprom(struct bttv *btv,
84                                unsigned char eeprom_data[256]);
85
86 /* config variables */
87 static unsigned int triton1=0;
88 static unsigned int vsfx=0;
89 static unsigned int latency = UNSET;
90 unsigned int no_overlay=-1;
91
92 static unsigned int card[BTTV_MAX]   = { [ 0 ... (BTTV_MAX-1) ] = UNSET };
93 static unsigned int pll[BTTV_MAX]    = { [ 0 ... (BTTV_MAX-1) ] = UNSET };
94 static unsigned int tuner[BTTV_MAX]  = { [ 0 ... (BTTV_MAX-1) ] = UNSET };
95 static unsigned int svhs[BTTV_MAX]   = { [ 0 ... (BTTV_MAX-1) ] = UNSET };
96 static unsigned int remote[BTTV_MAX] = { [ 0 ... (BTTV_MAX-1) ] = UNSET };
97 #ifdef MODULE
98 static unsigned int autoload = 1;
99 #else
100 static unsigned int autoload = 0;
101 #endif
102 static unsigned int gpiomask = UNSET;
103 static unsigned int audioall = UNSET;
104 static unsigned int audiomux[5] = { [ 0 ... 4 ] = UNSET };
105
106 /* insmod options */
107 MODULE_PARM(triton1,"i");
108 MODULE_PARM_DESC(triton1,"set ETBF pci config bit "
109                  "[enable bug compatibility for triton1 + others]");
110 MODULE_PARM(vsfx,"i");
111 MODULE_PARM_DESC(vsfx,"set VSFX pci config bit "
112                  "[yet another chipset flaw workaround]");
113 MODULE_PARM(no_overlay,"i");
114 MODULE_PARM(latency,"i");
115 MODULE_PARM_DESC(latency,"pci latency timer");
116 MODULE_PARM(card,"1-" __stringify(BTTV_MAX) "i");
117 MODULE_PARM_DESC(card,"specify TV/grabber card model, see CARDLIST file for a list");
118 MODULE_PARM(pll,"1-" __stringify(BTTV_MAX) "i");
119 MODULE_PARM_DESC(pll,"specify installed crystal (0=none, 28=28 MHz, 35=35 MHz)");
120 MODULE_PARM(tuner,"1-" __stringify(BTTV_MAX) "i");
121 MODULE_PARM_DESC(tuner,"specify installed tuner type");
122 MODULE_PARM(autoload,"i");
123 MODULE_PARM_DESC(autoload,"automatically load i2c modules like tuner.o, default is 1 (yes)");
124
125 MODULE_PARM(svhs,"1-" __stringify(BTTV_MAX) "i");
126 MODULE_PARM(remote,"1-" __stringify(BTTV_MAX) "i");
127
128 MODULE_PARM(gpiomask,"i");
129 MODULE_PARM(audioall,"i");
130 MODULE_PARM(audiomux,"1-6i");
131
132 /* kernel args */
133 #ifndef MODULE
134 static int __init p_card(char *str)  { return bttv_parse(str,BTTV_MAX,card);  }
135 static int __init p_pll(char *str)   { return bttv_parse(str,BTTV_MAX,pll);   }
136 static int __init p_tuner(char *str) { return bttv_parse(str,BTTV_MAX,tuner); }
137 __setup("bttv.card=",  p_card);
138 __setup("bttv.pll=",   p_pll);
139 __setup("bttv.tuner=", p_tuner);
140
141 int __init bttv_parse(char *str, int max, int *vals)
142 {
143         int i,number,res = 2;
144         
145         for (i = 0; res == 2 && i < max; i++) {
146                 res = get_option(&str,&number);
147                 if (res)
148                         vals[i] = number;
149         }
150         return 1;
151 }
152 #endif
153
154 /* ----------------------------------------------------------------------- */
155 /* list of card IDs for bt878+ cards                                       */
156
157 static struct CARD {
158         unsigned id;
159         int cardnr;
160         char *name;
161 } cards[] __devinitdata = {
162         { 0x13eb0070, BTTV_HAUPPAUGE878,  "Hauppauge WinTV" },
163         { 0x39000070, BTTV_HAUPPAUGE878,  "Hauppauge WinTV-D" },
164         { 0x45000070, BTTV_HAUPPAUGEPVR,  "Hauppauge WinTV/PVR" },
165         { 0xff000070, BTTV_OSPREY1x0,     "Osprey-100" },
166         { 0xff010070, BTTV_OSPREY2x0_SVID,"Osprey-200" },
167         { 0xff020070, BTTV_OSPREY500,     "Osprey-500" },
168         { 0xff030070, BTTV_OSPREY2000,    "Osprey-2000" },
169         { 0xff040070, BTTV_OSPREY540,     "Osprey-540" },
170
171         { 0x00011002, BTTV_ATI_TVWONDER,  "ATI TV Wonder" },
172         { 0x00031002, BTTV_ATI_TVWONDERVE,"ATI TV Wonder/VE" },
173
174         { 0x6606107d, BTTV_WINFAST2000,   "Leadtek WinFast TV 2000" },
175         { 0x6607107d, BTTV_WINFASTVC100,  "Leadtek WinFast VC 100" },
176         { 0x6609107d, BTTV_WINFAST2000,   "Leadtek TV 2000 XP" },
177         { 0x263610b4, BTTV_STB2,          "STB TV PCI FM, Gateway P/N 6000704" },
178         { 0x264510b4, BTTV_STB2,          "STB TV PCI FM, Gateway P/N 6000704" },
179         { 0x402010fc, BTTV_GVBCTV3PCI,    "I-O Data Co. GV-BCTV3/PCI" },
180         { 0x405010fc, BTTV_GVBCTV4PCI,    "I-O Data Co. GV-BCTV4/PCI" },
181         { 0x407010fc, BTTV_GVBCTV5PCI,    "I-O Data Co. GV-BCTV5/PCI" },
182         { 0xd01810fc, BTTV_GVBCTV5PCI,    "I-O Data Co. GV-BCTV5/PCI" },
183
184         { 0x001211bd, BTTV_PINNACLE,      "Pinnacle PCTV" },
185         { 0x001c11bd, BTTV_PINNACLESAT,   "Pinnacle PCTV Sat" },
186         // some cards ship with byteswapped IDs ...
187         { 0x1200bd11, BTTV_PINNACLE,      "Pinnacle PCTV [bswap]" },
188         { 0xff00bd11, BTTV_PINNACLE,      "Pinnacle PCTV [bswap]" },
189
190         { 0x3000121a, BTTV_VOODOOTV_FM,   "3Dfx VoodooTV FM/ VoodooTV 200" },
191         { 0x263710b4, BTTV_VOODOOTV_FM,   "3Dfx VoodooTV FM/ VoodooTV 200" },
192         { 0x3060121a, BTTV_STB2,          "3Dfx VoodooTV 100/ STB OEM" },
193         
194         { 0x3000144f, BTTV_MAGICTVIEW063, "(Askey Magic/others) TView99 CPH06x" },
195         { 0x3002144f, BTTV_MAGICTVIEW061, "(Askey Magic/others) TView99 CPH05x" },
196         { 0x3005144f, BTTV_MAGICTVIEW061, "(Askey Magic/others) TView99 CPH061/06L (T1/LC)" },
197         { 0x5000144f, BTTV_MAGICTVIEW061, "Askey CPH050" },
198         { 0x300014ff, BTTV_MAGICTVIEW061, "TView 99 (CPH061)" },
199         { 0x300214ff, BTTV_PHOEBE_TVMAS,  "Phoebe TV Master (CPH060)" },
200
201         { 0x00011461, BTTV_AVPHONE98,     "AVerMedia TVPhone98" },
202         { 0x00021461, BTTV_AVERMEDIA98,   "AVermedia TVCapture 98" },
203         { 0x00031461, BTTV_AVPHONE98,     "AVerMedia TVPhone98" },
204         { 0x00041461, BTTV_AVERMEDIA98,   "AVerMedia TVCapture 98" },
205         { 0x03001461, BTTV_AVERMEDIA98,   "VDOMATE TV TUNER CARD" },
206
207         { 0x1117153b, BTTV_TERRATVALUE,   "Terratec TValue (Philips PAL B/G)" },
208         { 0x1118153b, BTTV_TERRATVALUE,   "Terratec TValue (Temic PAL B/G)" },
209         { 0x1119153b, BTTV_TERRATVALUE,   "Terratec TValue (Philips PAL I)" },
210         { 0x111a153b, BTTV_TERRATVALUE,   "Terratec TValue (Temic PAL I)" },
211  
212         { 0x1123153b, BTTV_TERRATVRADIO,  "Terratec TV Radio+" },
213         { 0x1127153b, BTTV_TERRATV,       "Terratec TV+ (V1.05)"    },
214         // clashes with FlyVideo
215         //{ 0x18521852, BTTV_TERRATV,     "Terratec TV+ (V1.10)"    },
216         { 0x1134153b, BTTV_TERRATVALUE,   "Terratec TValue (LR102)" },
217         { 0x1135153b, BTTV_TERRATVALUER,  "Terratec TValue Radio" }, // LR102
218         { 0x5018153b, BTTV_TERRATVALUE,   "Terratec TValue" },       // ??
219         { 0xff3b153b, BTTV_TERRATVALUER,  "Terratec TValue Radio" }, // ??
220
221         { 0x400015b0, BTTV_ZOLTRIX_GENIE, "Zoltrix Genie TV" },
222         { 0x400a15b0, BTTV_ZOLTRIX_GENIE, "Zoltrix Genie TV" },
223         { 0x400d15b0, BTTV_ZOLTRIX_GENIE, "Zoltrix Genie TV / Radio" },
224         { 0x401015b0, BTTV_ZOLTRIX_GENIE, "Zoltrix Genie TV / Radio" },
225         { 0x401615b0, BTTV_ZOLTRIX_GENIE, "Zoltrix Genie TV / Radio" },
226
227         { 0x1430aa00, BTTV_PV143,         "Provideo PV143A" },
228         { 0x1431aa00, BTTV_PV143,         "Provideo PV143B" },
229         { 0x1432aa00, BTTV_PV143,         "Provideo PV143C" },
230         { 0x1433aa00, BTTV_PV143,         "Provideo PV143D" },
231         { 0x1433aa03, BTTV_PV143,         "Security Eyes" },
232
233         { 0x1460aa00, BTTV_PV150,         "Provideo PV150A-1" },
234         { 0x1461aa01, BTTV_PV150,         "Provideo PV150A-2" },
235         { 0x1462aa02, BTTV_PV150,         "Provideo PV150A-3" },
236         { 0x1463aa03, BTTV_PV150,         "Provideo PV150A-4" },
237
238         { 0x1464aa04, BTTV_PV150,         "Provideo PV150B-1" },
239         { 0x1465aa05, BTTV_PV150,         "Provideo PV150B-2" },
240         { 0x1466aa06, BTTV_PV150,         "Provideo PV150B-3" },
241         { 0x1467aa07, BTTV_PV150,         "Provideo PV150B-4" },
242
243         { 0xa132ff00, BTTV_IVC100,        "IVC-100"  },
244         { 0xa1550000, BTTV_IVC200,        "IVC-200"  },
245         { 0xa1550001, BTTV_IVC200,        "IVC-200"  },
246         { 0xa1550002, BTTV_IVC200,        "IVC-200"  },
247         { 0xa1550003, BTTV_IVC200,        "IVC-200"  }, 
248         { 0xa1550100, BTTV_IVC200,        "IVC-200G" },
249         { 0xa1550101, BTTV_IVC200,        "IVC-200G" },
250         { 0xa1550102, BTTV_IVC200,        "IVC-200G" },
251         { 0xa1550103, BTTV_IVC200,        "IVC-200G" },
252         { 0xa182ff00, BTTV_IVC120,        "IVC-120G" },
253         { 0xa182ff01, BTTV_IVC120,        "IVC-120G" },
254         { 0xa182ff02, BTTV_IVC120,        "IVC-120G" },
255         { 0xa182ff03, BTTV_IVC120,        "IVC-120G" },
256         { 0xa182ff04, BTTV_IVC120,        "IVC-120G" },
257         { 0xa182ff05, BTTV_IVC120,        "IVC-120G" },
258         { 0xa182ff06, BTTV_IVC120,        "IVC-120G" },
259         { 0xa182ff07, BTTV_IVC120,        "IVC-120G" },
260         { 0xa182ff08, BTTV_IVC120,        "IVC-120G" },
261         { 0xa182ff09, BTTV_IVC120,        "IVC-120G" },
262         { 0xa182ff0a, BTTV_IVC120,        "IVC-120G" },
263         { 0xa182ff0b, BTTV_IVC120,        "IVC-120G" },
264         { 0xa182ff0c, BTTV_IVC120,        "IVC-120G" },
265         { 0xa182ff0d, BTTV_IVC120,        "IVC-120G" },
266         { 0xa182ff0e, BTTV_IVC120,        "IVC-120G" },
267         { 0xa182ff0f, BTTV_IVC120,        "IVC-120G" },
268         
269         { 0x41424344, BTTV_GRANDTEC,      "GrandTec Multi Capture" },
270         { 0x01020304, BTTV_XGUARD,        "Grandtec Grand X-Guard" },
271         
272         { 0x18501851, BTTV_CHRONOS_VS2,   "FlyVideo 98 (LR50)/ Chronos Video Shuttle II" },
273         { 0xa0501851, BTTV_CHRONOS_VS2,   "FlyVideo 98 (LR50)/ Chronos Video Shuttle II" },
274         { 0x18511851, BTTV_FLYVIDEO98EZ,  "FlyVideo 98EZ (LR51)/ CyberMail AV" },
275         { 0x18521852, BTTV_TYPHOON_TVIEW, "FlyVideo 98FM (LR50)/ Typhoon TView TV/FM Tuner" },
276         { 0x41a0a051, BTTV_FLYVIDEO_98FM, "Lifeview FlyVideo 98 LR50 Rev Q" },
277         { 0x18501f7f, BTTV_FLYVIDEO_98,   "Lifeview Flyvideo 98" },
278
279         { 0x010115cb, BTTV_GMV1,          "AG GMV1" },
280         { 0x010114c7, BTTV_MODTEC_205,    "Modular Technology MM201/MM202/MM205/MM210/MM215 PCTV" },
281
282         { 0x10b42636, BTTV_HAUPPAUGE878,  "STB ???" },
283         { 0x217d6606, BTTV_WINFAST2000,   "Leadtek WinFast TV 2000" },
284         { 0xfff6f6ff, BTTV_WINFAST2000,   "Leadtek WinFast TV 2000" },
285         { 0x03116000, BTTV_SENSORAY311,   "Sensoray 311" },
286         { 0x00790e11, BTTV_WINDVR,        "Canopus WinDVR PCI" },
287         { 0xa0fca1a0, BTTV_ZOLTRIX,       "Face to Face Tvmax" },
288         { 0x20007063, BTTV_PC_HDTV,       "pcHDTV HD-2000 TV"},
289         { 0x82b2aa6a, BTTV_SIMUS_GVC1100, "SIMUS GVC1100" },
290         { 0x146caa0c, BTTV_PV951,         "ituner spectra8" },
291         { 0x200a1295, BTTV_PXC200,        "ImageNation PXC200A" },
292
293         { 0x40111554, BTTV_PV_BT878P_9B,  "Prolink Pixelview PV-BT" },
294         { 0x17de0a01, BTTV_KWORLD,        "Mecer TV/FM/Video Tuner" },
295
296         { 0x01051805, BTTV_PICOLO_TETRA_CHIP, "Picolo Tetra Chip #1" },
297         { 0x01061805, BTTV_PICOLO_TETRA_CHIP, "Picolo Tetra Chip #2" },
298         { 0x01071805, BTTV_PICOLO_TETRA_CHIP, "Picolo Tetra Chip #3" },
299         { 0x01081805, BTTV_PICOLO_TETRA_CHIP, "Picolo Tetra Chip #4" },
300
301         // likely broken, vendor id doesn't match the other magic views ...
302         //{ 0xa0fca04f, BTTV_MAGICTVIEW063, "Guillemot Maxi TV Video 3" },
303         
304         // DVB cards (using pci function .1 for mpeg data xfer)
305         { 0x01010071, BTTV_NEBULA_DIGITV, "Nebula Electronics DigiTV" },
306         { 0x07611461, BTTV_AVDVBT_761,    "AverMedia AverTV DVB-T" },
307         { 0x002611bd, BTTV_TWINHAN_DST,   "Pinnacle PCTV SAT CI" },
308         { 0x00011822, BTTV_TWINHAN_DST,   "Twinhan VisionPlus DVB-T" },
309         { 0xfc00270f, BTTV_TWINHAN_DST,   "ChainTech digitop DST-1000 DVB-S" },
310         { 0x07711461, BTTV_AVDVBT_771,    "AVermedia DVB-T 771" },
311         
312         { 0, -1, NULL }
313 };
314
315 /* ----------------------------------------------------------------------- */
316 /* array with description for bt848 / bt878 tv/grabber cards               */
317
318 struct tvcard bttv_tvcards[] = {
319 {
320 /* ---- card 0x00 ---------------------------------- */
321         .name           = " *** UNKNOWN/GENERIC *** ",
322         .video_inputs   = 4,
323         .audio_inputs   = 1,
324         .tuner          = 0,
325         .svhs           = 2,
326         .muxsel         = { 2, 3, 1, 0},
327         .tuner_type     = -1,
328 },{
329         .name           = "MIRO PCTV",
330         .video_inputs   = 4,
331         .audio_inputs   = 1,
332         .tuner          = 0,
333         .svhs           = 2,
334         .gpiomask       = 15,
335         .muxsel         = { 2, 3, 1, 1},
336         .audiomux       = { 2, 0, 0, 0, 10},
337         .needs_tvaudio  = 1,
338         .tuner_type     = -1,
339 },{
340         .name           = "Hauppauge (bt848)",
341         .video_inputs   = 4,
342         .audio_inputs   = 1,
343         .tuner          = 0,
344         .svhs           = 2,
345         .gpiomask       = 7,
346         .muxsel         = { 2, 3, 1, 1},
347         .audiomux       = { 0, 1, 2, 3, 4},
348         .needs_tvaudio  = 1,
349         .tuner_type     = -1,
350 },{
351         .name           = "STB, Gateway P/N 6000699 (bt848)",
352         .video_inputs   = 3,
353         .audio_inputs   = 1,
354         .tuner          = 0,
355         .svhs           = 2,
356         .gpiomask       = 7,
357         .muxsel         = { 2, 3, 1, 1},
358         .audiomux       = { 4, 0, 2, 3, 1},
359         .no_msp34xx     = 1,
360         .needs_tvaudio  = 1,
361         .tuner_type     = TUNER_PHILIPS_NTSC,
362         .pll            = PLL_28,
363         .has_radio      = 1,
364 },{
365
366 /* ---- card 0x04 ---------------------------------- */
367         .name           = "Intel Create and Share PCI/ Smart Video Recorder III",
368         .video_inputs   = 4,
369         .audio_inputs   = 0,
370         .tuner          = -1,
371         .svhs           = 2,
372         .gpiomask       = 0,
373         .muxsel         = { 2, 3, 1, 1},
374         .audiomux       = { 0 },
375         .needs_tvaudio  = 0,
376         .tuner_type     = 4,
377 },{
378         .name           = "Diamond DTV2000",
379         .video_inputs   = 4,
380         .audio_inputs   = 1,
381         .tuner          = 0,
382         .svhs           = 2,
383         .gpiomask       = 3,
384         .muxsel         = { 2, 3, 1, 0},
385         .audiomux       = { 0, 1, 0, 1, 3},
386         .needs_tvaudio  = 1,
387         .tuner_type     = -1,
388 },{
389         .name           = "AVerMedia TVPhone",
390         .video_inputs   = 3,
391         .audio_inputs   = 1,
392         .tuner          = 0,
393         .svhs           = 3,
394         .muxsel         = { 2, 3, 1, 1},
395         .gpiomask       = 0x0f,
396         .audiomux       = { 0x0c, 0x04, 0x08, 0x04, 0},
397         /*                0x04 for some cards ?? */
398         .needs_tvaudio  = 1,
399         .tuner_type     = -1,
400         .audio_hook     = avermedia_tvphone_audio,
401         .has_remote     = 1,
402 },{
403         .name           = "MATRIX-Vision MV-Delta",
404         .video_inputs   = 5,
405         .audio_inputs   = 1,
406         .tuner          = -1,
407         .svhs           = 3,
408         .gpiomask       = 0,
409         .muxsel         = { 2, 3, 1, 0, 0},
410         .audiomux       = {0 },
411         .needs_tvaudio  = 1,
412         .tuner_type     = -1,
413 },{
414
415 /* ---- card 0x08 ---------------------------------- */
416         .name           = "Lifeview FlyVideo II (Bt848) LR26 / MAXI TV Video PCI2 LR26",
417         .video_inputs   = 4,
418         .audio_inputs   = 1,
419         .tuner          = 0,
420         .svhs           = 2,
421         .gpiomask       = 0xc00,
422         .muxsel         = { 2, 3, 1, 1},
423         .audiomux       = { 0, 0xc00, 0x800, 0x400, 0xc00, 0},
424         .needs_tvaudio  = 1,
425         .pll            = PLL_28,
426         .tuner_type     = -1,
427 },{
428         .name           = "IMS/IXmicro TurboTV",
429         .video_inputs   = 3,
430         .audio_inputs   = 1,
431         .tuner          = 0,
432         .svhs           = 2,
433         .gpiomask       = 3,
434         .muxsel         = { 2, 3, 1, 1},
435         .audiomux       = { 1, 1, 2, 3, 0},
436         .needs_tvaudio  = 0,
437         .pll            = PLL_28,
438         .tuner_type     = TUNER_TEMIC_PAL,
439 },{
440         .name           = "Hauppauge (bt878)",
441         .video_inputs   = 4,
442         .audio_inputs   = 1,
443         .tuner          = 0,
444         .svhs           = 2,
445         .gpiomask       = 0x0f, /* old: 7 */
446         .muxsel         = { 2, 0, 1, 1},
447         .audiomux       = { 0, 1, 2, 3, 4},
448         .needs_tvaudio  = 1,
449         .pll            = PLL_28,
450         .tuner_type     = -1,
451 },{
452         .name           = "MIRO PCTV pro",
453         .video_inputs   = 3,
454         .audio_inputs   = 1,
455         .tuner          = 0,
456         .svhs           = 2,
457         .gpiomask       = 0x3014f,
458         .muxsel         = { 2, 3, 1, 1},
459         .audiomux       = { 0x20001,0x10001, 0, 0,10},
460         .needs_tvaudio  = 1,
461         .tuner_type     = -1,
462 },{
463
464 /* ---- card 0x0c ---------------------------------- */
465         .name           = "ADS Technologies Channel Surfer TV (bt848)",
466         .video_inputs   = 3,
467         .audio_inputs   = 1,
468         .tuner          = 0,
469         .svhs           = 2,
470         .gpiomask       = 15,
471         .muxsel         = { 2, 3, 1, 1},
472         .audiomux       = { 13, 14, 11, 7, 0, 0},
473         .needs_tvaudio  = 1,
474         .tuner_type     = -1,
475 },{
476         .name           = "AVerMedia TVCapture 98",
477         .video_inputs   = 3,
478         .audio_inputs   = 4,
479         .tuner          = 0,
480         .svhs           = 2,
481         .gpiomask       = 15,
482         .muxsel         = { 2, 3, 1, 1},
483         .audiomux       = { 13, 14, 11, 7, 0, 0},
484         .needs_tvaudio  = 1,
485         .msp34xx_alt    = 1,
486         .pll            = PLL_28,
487         .tuner_type     = TUNER_PHILIPS_PAL,
488         .audio_hook     = avermedia_tv_stereo_audio,
489 },{
490         .name           = "Aimslab Video Highway Xtreme (VHX)",
491         .video_inputs   = 3,
492         .audio_inputs   = 1,
493         .tuner          = 0,
494         .svhs           = 2,
495         .gpiomask       = 7,
496         .muxsel         = { 2, 3, 1, 1},
497         .audiomux       = { 0, 2, 1, 3, 4}, /* old: { 0, 1, 2, 3, 4} */
498         .needs_tvaudio  = 1,
499         .pll            = PLL_28,
500         .tuner_type     = -1,
501 },{
502         .name           = "Zoltrix TV-Max",
503         .video_inputs   = 3,
504         .audio_inputs   = 1,
505         .tuner          = 0,
506         .svhs           = 2,
507         .gpiomask       = 15,
508         .muxsel         = { 2, 3, 1, 1},
509         .audiomux       = {0 , 0, 1 , 0, 10},
510         .needs_tvaudio  = 1,
511         .tuner_type     = -1,
512 },{
513
514 /* ---- card 0x10 ---------------------------------- */
515         .name           = "Prolink Pixelview PlayTV (bt878)",
516         .video_inputs   = 3,
517         .audio_inputs   = 1,
518         .tuner          = 0,
519         .svhs           = 2,
520         .gpiomask       = 0x01fe00,
521         .muxsel         = { 2, 3, 1, 1},
522 #if 0
523         // old
524         .audiomux       = { 0x01c000, 0, 0x018000, 0x014000, 0x002000, 0 },
525 #else
526         // 2003-10-20 by "Anton A. Arapov" <arapov@mail.ru>
527         .audiomux       = { 0x001e00, 0, 0x018000, 0x014000, 0x002000, 0 },
528 #endif
529         .needs_tvaudio  = 1,
530         .pll            = PLL_28,
531         .tuner_type     = -1,
532 },{
533         .name           = "Leadtek WinView 601",
534         .video_inputs   = 3,
535         .audio_inputs   = 1,
536         .tuner          = 0,
537         .svhs           = 2,
538         .gpiomask       = 0x8300f8,
539         .muxsel         = { 2, 3, 1, 1,0},
540         .audiomux       = { 0x4fa007,0xcfa007,0xcfa007,0xcfa007,0xcfa007,0xcfa007},
541         .needs_tvaudio  = 1,
542         .tuner_type     = -1,
543         .audio_hook     = winview_audio,
544         .has_radio      = 1,
545 },{
546         .name           = "AVEC Intercapture",
547         .video_inputs   = 3,
548         .audio_inputs   = 2,
549         .tuner          = 0,
550         .svhs           = 2,
551         .gpiomask       = 0,
552         .muxsel         = {2, 3, 1, 1},
553         .audiomux       = {1, 0, 0, 0, 0},
554         .needs_tvaudio  = 1,
555         .tuner_type     = -1,
556 },{
557         .name           = "Lifeview FlyVideo II EZ /FlyKit LR38 Bt848 (capture only)",
558         .video_inputs   = 4,
559         .audio_inputs   = 1,
560         .tuner          = -1,
561         .svhs           = -1,
562         .gpiomask       = 0x8dff00,
563         .muxsel         = { 2, 3, 1, 1},
564         .audiomux       = { 0 },
565         .no_msp34xx     = 1,
566         .tuner_type     = -1,
567 },{
568
569 /* ---- card 0x14 ---------------------------------- */
570         .name           = "CEI Raffles Card",
571         .video_inputs   = 3,
572         .audio_inputs   = 3,
573         .tuner          = 0,
574         .svhs           = 2,
575         .muxsel         = {2, 3, 1, 1},
576         .tuner_type     = -1,
577 },{
578         .name           = "Lifeview FlyVideo 98/ Lucky Star Image World ConferenceTV LR50",
579         .video_inputs   = 4,
580         .audio_inputs   = 2,  // tuner, line in
581         .tuner          = 0,
582         .svhs           = 2,
583         .gpiomask       = 0x1800,
584         .muxsel         = { 2, 3, 1, 1},
585         .audiomux       = { 0, 0x800, 0x1000, 0x1000, 0x1800},
586         .pll            = PLL_28,
587         .tuner_type     = TUNER_PHILIPS_PAL_I,
588 },{
589         .name           = "Askey CPH050/ Phoebe Tv Master + FM",
590         .video_inputs   = 3,
591         .audio_inputs   = 1,
592         .tuner          = 0,
593         .svhs           = 2,
594         .gpiomask       = 0xc00,
595         .muxsel         = { 2, 3, 1, 1},
596         .audiomux       = {0, 1, 0x800, 0x400, 0xc00, 0},
597         .needs_tvaudio  = 1,
598         .pll            = PLL_28,
599         .tuner_type     = -1,
600 },{
601         .name           = "Modular Technology MM201/MM202/MM205/MM210/MM215 PCTV, bt878",
602         .video_inputs   = 3,
603         .audio_inputs   = 1,
604         .tuner          = 0,
605         .svhs           = -1,
606         .gpiomask       = 7,
607         .muxsel         = { 2, 3, -1 },
608         .digital_mode   = DIGITAL_MODE_CAMERA,
609         .audiomux       = { 0, 0, 0, 0, 0 },
610         .no_msp34xx     = 1,
611         .pll            = PLL_28,
612         .tuner_type     = TUNER_ALPS_TSBB5_PAL_I,
613 },{
614
615 /* ---- card 0x18 ---------------------------------- */
616         .name           = "Askey CPH05X/06X (bt878) [many vendors]",
617         .video_inputs   = 3,
618         .audio_inputs   = 1,
619         .tuner          = 0,
620         .svhs           = 2,
621         .gpiomask       = 0xe00,
622         .muxsel         = { 2, 3, 1, 1},
623         .audiomux       = {0x400, 0x400, 0x400, 0x400, 0xc00},
624         .needs_tvaudio  = 1,
625         .pll            = PLL_28,
626         .tuner_type     = -1,
627         .has_remote     = 1,
628 },{
629         .name           = "Terratec TerraTV+ Version 1.0 (Bt848)/ Terra TValue Version 1.0/ Vobis TV-Boostar",
630         .video_inputs   = 3,
631         .audio_inputs   = 1,
632         .tuner          = 0,
633         .svhs           = 2,
634         .gpiomask       = 0x1f0fff,
635         .muxsel         = { 2, 3, 1, 1},
636         .audiomux       = { 0x20000, 0x30000, 0x10000, 0, 0x40000},
637         .needs_tvaudio  = 0,
638         .tuner_type     = TUNER_PHILIPS_PAL,
639         .audio_hook     = terratv_audio,
640 },{
641         .name           = "Hauppauge WinCam newer (bt878)",
642         .video_inputs   = 4,
643         .audio_inputs   = 1,
644         .tuner          = 0,
645         .svhs           = 3,
646         .gpiomask       = 7,
647         .muxsel         = { 2, 0, 1, 1},
648         .audiomux       = { 0, 1, 2, 3, 4},
649         .needs_tvaudio  = 1,
650         .tuner_type     = -1,
651 },{
652         .name           = "Lifeview FlyVideo 98/ MAXI TV Video PCI2 LR50",
653         .video_inputs   = 4,
654         .audio_inputs   = 2,
655         .tuner          = 0,
656         .svhs           = 2,
657         .gpiomask       = 0x1800,
658         .muxsel         = { 2, 3, 1, 1},
659         .audiomux       = { 0, 0x800, 0x1000, 0x1000, 0x1800},
660         .pll            = PLL_28,
661         .tuner_type     = TUNER_PHILIPS_SECAM,
662 },{
663
664 /* ---- card 0x1c ---------------------------------- */
665         .name           = "Terratec TerraTV+ Version 1.1 (bt878)",
666         .video_inputs   = 3,
667         .audio_inputs   = 1,
668         .tuner          = 0,
669         .svhs           = 2,
670         .gpiomask       = 0x1f0fff,
671         .muxsel         = { 2, 3, 1, 1},
672         .audiomux       = { 0x20000, 0x30000, 0x10000, 0x00000, 0x40000},
673         .needs_tvaudio  = 0,
674         .tuner_type     = TUNER_PHILIPS_PAL,
675         .audio_hook     = terratv_audio,
676         /* GPIO wiring:
677                External 20 pin connector (for Active Radio Upgrade board)
678                gpio00: i2c-sda
679                gpio01: i2c-scl
680                gpio02: om5610-data
681                gpio03: om5610-clk
682                gpio04: om5610-wre
683                gpio05: om5610-stereo
684                gpio06: rds6588-davn
685                gpio07: Pin 7 n.c.
686                gpio08: nIOW
687                gpio09+10: nIOR, nSEL ?? (bt878)
688                 gpio09: nIOR (bt848)
689                 gpio10: nSEL (bt848)
690               Sound Routing:
691                gpio16: u2-A0 (1st 4052bt)
692                gpio17: u2-A1
693                gpio18: u2-nEN
694                gpio19: u4-A0 (2nd 4052)
695                gpio20: u4-A1
696                        u4-nEN - GND
697             Btspy:
698                 00000 : Cdrom (internal audio input)
699                 10000 : ext. Video audio input
700                 20000 : TV Mono
701                 a0000 : TV Mono/2
702                1a0000 : TV Stereo       
703                 30000 : Radio
704                 40000 : Mute
705        */
706
707 },{
708         /* Jannik Fritsch <jannik@techfak.uni-bielefeld.de> */
709         .name           = "Imagenation PXC200",
710         .video_inputs   = 5,
711         .audio_inputs   = 1,
712         .tuner          = -1,
713         .svhs           = 1, /* was: 4 */
714         .gpiomask       = 0,
715         .muxsel         = { 2, 3, 1, 0, 0},
716         .audiomux       = { 0 },
717         .needs_tvaudio  = 1,
718         .tuner_type     = -1,
719         .muxsel_hook    = PXC200_muxsel,
720
721 },{
722         .name           = "Lifeview FlyVideo 98 LR50",
723         .video_inputs   = 4,
724         .audio_inputs   = 1,
725         .tuner          = 0,
726         .svhs           = 2,
727         .gpiomask       = 0x1800,  //0x8dfe00
728         .muxsel         = { 2, 3, 1, 1},
729         .audiomux       = { 0, 0x0800, 0x1000, 0x1000, 0x1800, 0 },
730         .pll            = PLL_28,
731         .tuner_type     = -1,
732 },{
733         .name           = "Formac iProTV, Formac ProTV I (bt848)",
734         .video_inputs   = 4,
735         .audio_inputs   = 1,
736         .tuner          = 0,
737         .svhs           = 3,
738         .gpiomask       = 1,
739         .muxsel         = { 2, 3, 1, 1},
740         .audiomux       = { 1, 0, 0, 0, 0 },
741         .pll            = PLL_28,
742         .tuner_type     = TUNER_PHILIPS_PAL,
743 },{
744
745 /* ---- card 0x20 ---------------------------------- */
746         .name           = "Intel Create and Share PCI/ Smart Video Recorder III",
747         .video_inputs   = 4,
748         .audio_inputs   = 0,
749         .tuner          = -1,
750         .svhs           = 2,
751         .gpiomask       = 0,
752         .muxsel         = { 2, 3, 1, 1},
753         .audiomux       = { 0 },
754         .needs_tvaudio  = 0,
755         .tuner_type     = 4,
756 },{
757         .name           = "Terratec TerraTValue Version Bt878",
758         .video_inputs   = 3,
759         .audio_inputs   = 1,
760         .tuner          = 0,
761         .svhs           = 2,
762         .gpiomask       = 0xffff00,
763         .muxsel         = { 2, 3, 1, 1},
764         .audiomux       = { 0x500, 0, 0x300, 0x900, 0x900},
765         .needs_tvaudio  = 1,
766         .pll            = PLL_28,
767         .tuner_type     = TUNER_PHILIPS_PAL,
768 },{
769         .name           = "Leadtek WinFast 2000/ WinFast 2000 XP",
770         .video_inputs   = 4,
771         .audio_inputs   = 1,
772         .tuner          = 0,
773         .svhs           = 2,
774         .muxsel         = { 2, 3, 1, 1, 0}, // TV, CVid, SVid, CVid over SVid connector
775 #if 0
776         .gpiomask       = 0xc33000,
777         .audiomux       = { 0x422000,0x1000,0x0000,0x620000,0x800000 },
778 #else
779         /* Alexander Varakin <avarakin@hotmail.com> [stereo version] */
780         .gpiomask       = 0xb33000,
781         .audiomux       = { 0x122000,0x1000,0x0000,0x620000,0x800000 },
782 #endif
783         /* Audio Routing for "WinFast 2000 XP" (no tv stereo !)
784                 gpio23 -- hef4052:nEnable (0x800000)
785                 gpio12 -- hef4052:A1
786                 gpio13 -- hef4052:A0
787             0x0000: external audio
788             0x1000: FM
789             0x2000: TV
790             0x3000: n.c.
791           Note: There exists another variant "Winfast 2000" with tv stereo !?
792           Note: eeprom only contains FF and pci subsystem id 107d:6606
793          */
794         .needs_tvaudio  = 0,
795         .pll            = PLL_28,
796         .has_radio      = 1,
797         .tuner_type     = 5, // default for now, gpio reads BFFF06 for Pal bg+dk
798         .audio_hook     = winfast2000_audio,
799         .has_remote     = 1,
800 },{
801         .name           = "Lifeview FlyVideo 98 LR50 / Chronos Video Shuttle II",
802         .video_inputs   = 4,
803         .audio_inputs   = 3,
804         .tuner          = 0,
805         .svhs           = 2,
806         .gpiomask       = 0x1800,
807         .muxsel         = { 2, 3, 1, 1},
808         .audiomux       = { 0, 0x800, 0x1000, 0x1000, 0x1800},
809         .pll            = PLL_28,
810         .tuner_type     = -1,
811 },{
812
813 /* ---- card 0x24 ---------------------------------- */
814         .name           = "Lifeview FlyVideo 98FM LR50 / Typhoon TView TV/FM Tuner",
815         .video_inputs   = 4,
816         .audio_inputs   = 3,
817         .tuner          = 0,
818         .svhs           = 2,
819         .gpiomask       = 0x1800,
820         .muxsel         = { 2, 3, 1, 1},
821         .audiomux       = { 0, 0x800, 0x1000, 0x1000, 0x1800, 0 },
822         .pll            = PLL_28,
823         .tuner_type     = -1,
824         .has_radio      = 1,
825 },{
826         .name           = "Prolink PixelView PlayTV pro",
827         .video_inputs   = 3,
828         .audio_inputs   = 1,
829         .tuner          = 0,
830         .svhs           = 2,
831         .gpiomask       = 0xff,
832         .muxsel         = { 2, 3, 1, 1 },
833         .audiomux       = { 0x21, 0x20, 0x24, 0x2c, 0x29, 0x29 },
834         .no_msp34xx     = 1,
835         .pll            = PLL_28,
836         .tuner_type     = -1,
837 },{
838         .name           = "Askey CPH06X TView99",
839         .video_inputs   = 4,
840         .audio_inputs   = 1,
841         .tuner          = 0,
842         .svhs           = 2,
843         .gpiomask       = 0x551e00,
844         .muxsel         = { 2, 3, 1, 0},
845         .audiomux       = { 0x551400, 0x551200, 0, 0, 0x551c00, 0x551200 },
846         .needs_tvaudio  = 1,
847         .pll            = PLL_28,
848         .tuner_type     = 1,
849         .has_remote     = 1,
850 },{
851         .name           = "Pinnacle PCTV Studio/Rave",
852         .video_inputs   = 3,
853         .audio_inputs   = 1,
854         .tuner          = 0,
855         .svhs           = 2,
856         .gpiomask       = 0x03000F,
857         .muxsel         = { 2, 3, 1, 1},
858         .audiomux       = { 2, 0xd0001, 0, 0, 1},
859         .needs_tvaudio  = 0,
860         .pll            = PLL_28,
861         .tuner_type     = -1,
862 },{
863
864 /* ---- card 0x28 ---------------------------------- */
865         .name           = "STB TV PCI FM, Gateway P/N 6000704 (bt878), 3Dfx VoodooTV 100",
866         .video_inputs   = 3,
867         .audio_inputs   = 1,
868         .tuner          = 0,
869         .svhs           = 2,
870         .gpiomask       = 7,
871         .muxsel         = { 2, 3, 1, 1},
872         .audiomux       = { 4, 0, 2, 3, 1},
873         .no_msp34xx     = 1,
874         .needs_tvaudio  = 1,
875         .tuner_type     = TUNER_PHILIPS_NTSC,
876         .pll            = PLL_28,
877         .has_radio      = 1,
878 },{
879         .name           = "AVerMedia TVPhone 98",
880         .video_inputs   = 3,
881         .audio_inputs   = 4,
882         .tuner          = 0,
883         .svhs           = 2,
884         .gpiomask       = 15,
885         .muxsel         = { 2, 3, 1, 1},
886         .audiomux       = { 13, 4, 11, 7, 0, 0},
887         .needs_tvaudio  = 1,
888         .pll            = PLL_28,
889         .tuner_type     = -1,
890         .has_radio      = 1,
891         .audio_hook     = avermedia_tvphone_audio,
892 },{
893         .name           = "ProVideo PV951", /* pic16c54 */
894         .video_inputs   = 3,
895         .audio_inputs   = 1,
896         .tuner          = 0,
897         .svhs           = 2,
898         .gpiomask       = 0,
899         .muxsel         = { 2, 3, 1, 1},
900         .audiomux       = { 0, 0, 0, 0, 0},
901         .needs_tvaudio  = 1,
902         .no_msp34xx     = 1,
903         .pll            = PLL_28,
904         .tuner_type     = 1,
905 },{
906         .name           = "Little OnAir TV",
907         .video_inputs   = 3,
908         .audio_inputs   = 1,
909         .tuner          = 0,
910         .svhs           = 2,
911         .gpiomask       = 0xe00b,
912         .muxsel         = {2, 3, 1, 1},
913         .audiomux       = {0xff9ff6, 0xff9ff6, 0xff1ff7, 0, 0xff3ffc},
914         .no_msp34xx     = 1,
915         .tuner_type     = -1,
916 },{
917
918 /* ---- card 0x2c ---------------------------------- */
919         .name           = "Sigma TVII-FM",
920         .video_inputs   = 2,
921         .audio_inputs   = 1,
922         .tuner          = 0,
923         .svhs           = -1,
924         .gpiomask       = 3,
925         .muxsel         = {2, 3, 1, 1},
926         .audiomux       = {1, 1, 0, 2, 3},
927         .no_msp34xx     = 1,
928         .pll            = PLL_NONE,
929         .tuner_type     = -1,
930 },{
931         .name           = "MATRIX-Vision MV-Delta 2",
932         .video_inputs   = 5,
933         .audio_inputs   = 1,
934         .tuner          = -1,
935         .svhs           = 3,
936         .gpiomask       = 0,
937         .muxsel         = { 2, 3, 1, 0, 0},
938         .audiomux       = {0 },
939         .no_msp34xx     = 1,
940         .pll            = PLL_28,
941         .tuner_type     = -1,
942 },{
943         .name           = "Zoltrix Genie TV/FM",
944         .video_inputs   = 3,
945         .audio_inputs   = 1,
946         .tuner          = 0,
947         .svhs           = 2,
948         .gpiomask       = 0xbcf03f,
949         .muxsel         = { 2, 3, 1, 1},
950         .audiomux       = { 0xbc803f, 0xbc903f, 0xbcb03f, 0, 0xbcb03f},
951         .no_msp34xx     = 1,
952         .pll            = PLL_28,
953         .tuner_type     = 21,
954 },{
955         .name           = "Terratec TV/Radio+",
956         .video_inputs   = 3,
957         .audio_inputs   = 1,
958         .tuner          = 0,
959         .svhs           = 2,
960         .gpiomask       = 0x70000,
961         .muxsel         = { 2, 3, 1, 1},
962         .audiomux       = { 0x20000, 0x30000, 0x10000, 0, 0x40000, 0x20000 },
963         .needs_tvaudio  = 1,
964         .no_msp34xx     = 1,
965         .pll            = PLL_35,
966         .tuner_type     = 1,
967         .has_radio      = 1,
968 },{
969
970 /* ---- card 0x30 ---------------------------------- */
971         .name           = "Askey CPH03x/ Dynalink Magic TView",
972         .video_inputs   = 3,
973         .audio_inputs   = 1,
974         .tuner          = 0,
975         .svhs           = 2,
976         .gpiomask       = 15,
977         .muxsel         = { 2, 3, 1, 1},
978         .audiomux       = {2,0,0,0,1},
979         .needs_tvaudio  = 1,
980         .pll            = PLL_28,
981         .tuner_type     = -1,
982 },{
983         .name           = "IODATA GV-BCTV3/PCI",
984         .video_inputs   = 3,
985         .audio_inputs   = 1,
986         .tuner          = 0,
987         .svhs           = 2,
988         .gpiomask       = 0x010f00,
989         .muxsel         = {2, 3, 0, 0},
990         .audiomux       = {0x10000, 0, 0x10000, 0, 0, 0},
991         .no_msp34xx     = 1,
992         .pll            = PLL_28,
993         .tuner_type     = TUNER_ALPS_TSHC6_NTSC,
994         .audio_hook     = gvbctv3pci_audio,
995 },{
996         .name           = "Prolink PV-BT878P+4E / PixelView PlayTV PAK / Lenco MXTV-9578 CP",
997         .video_inputs   = 5,
998         .audio_inputs   = 1,
999         .tuner          = 0,
1000         .svhs           = 3,
1001         .gpiomask       = 0xAA0000,
1002         .muxsel         = { 2,3,1,1,-1 },
1003         .digital_mode   = DIGITAL_MODE_CAMERA,
1004         .audiomux       = { 0x20000, 0, 0x80000, 0x80000, 0xa8000, 0x46000  },
1005         .no_msp34xx     = 1,
1006         .pll            = PLL_28,
1007         .tuner_type     = TUNER_PHILIPS_PAL_I,
1008         .has_remote     = 1,
1009         /* GPIO wiring: (different from Rev.4C !)
1010                 GPIO17: U4.A0 (first hef4052bt)
1011                 GPIO19: U4.A1
1012                 GPIO20: U5.A1 (second hef4052bt)
1013                 GPIO21: U4.nEN
1014                 GPIO22: BT832 Reset Line
1015                 GPIO23: A5,A0, U5,nEN
1016            Note: At i2c=0x8a is a Bt832 chip, which changes to 0x88 after being reset via GPIO22
1017          */
1018 },{
1019         .name           = "Eagle Wireless Capricorn2 (bt878A)",
1020         .video_inputs   = 4,
1021         .audio_inputs   = 1,
1022         .tuner          = 0,
1023         .svhs           = 2,
1024         .gpiomask       = 7,
1025         .muxsel         = { 2, 0, 1, 1},
1026         .audiomux       = { 0, 1, 2, 3, 4},
1027         .pll            = PLL_28,
1028         .tuner_type     = -1 /* TUNER_ALPS_TMDH2_NTSC */,
1029 },{
1030
1031 /* ---- card 0x34 ---------------------------------- */
1032         /* David Härdeman <david@2gen.com> */
1033         .name           = "Pinnacle PCTV Studio Pro",
1034         .video_inputs   = 4,
1035         .audio_inputs   = 1,
1036         .tuner          = 0,
1037         .svhs           = 3,
1038         .gpiomask       = 0x03000F,
1039         .muxsel         = { 2, 3, 1, 1},
1040         .audiomux       = { 1, 0xd0001, 0, 0, 10},
1041                         /* sound path (5 sources):
1042                            MUX1 (mask 0x03), Enable Pin 0x08 (0=enable, 1=disable)
1043                                 0= ext. Audio IN
1044                                 1= from MUX2
1045                                 2= Mono TV sound from Tuner
1046                                 3= not connected
1047                            MUX2 (mask 0x30000):
1048                                 0,2,3= from MSP34xx
1049                                 1= FM stereo Radio from Tuner */
1050         .needs_tvaudio  = 0,
1051         .pll            = PLL_28,
1052         .tuner_type     = -1,
1053 },{
1054         /* Claas Langbehn <claas@bigfoot.com>,
1055            Sven Grothklags <sven@upb.de> */
1056         .name           = "Typhoon TView RDS + FM Stereo / KNC1 TV Station RDS",
1057         .video_inputs   = 4,
1058         .audio_inputs   = 3,
1059         .tuner          = 0,
1060         .svhs           = 2,
1061         .gpiomask       = 0x1c,
1062         .muxsel         = { 2, 3, 1, 1},
1063         .audiomux       = { 0, 0, 0x10, 8, 4 },
1064         .needs_tvaudio  = 1,
1065         .pll            = PLL_28,
1066         .tuner_type     = TUNER_PHILIPS_PAL,
1067         .has_radio      = 1,
1068 },{
1069         /* Tim Röstermundt <rosterm@uni-muenster.de>
1070            in de.comp.os.unix.linux.hardware:
1071                 options bttv card=0 pll=1 radio=1 gpiomask=0x18e0
1072                 audiomux=0x44c71f,0x44d71f,0,0x44d71f,0x44dfff
1073                 options tuner type=5 */
1074         .name           = "Lifeview FlyVideo 2000 /FlyVideo A2/ Lifetec LT 9415 TV [LR90]",
1075         .video_inputs   = 4,
1076         .audio_inputs   = 1,
1077         .tuner          = 0,
1078         .svhs           = 2,
1079         .gpiomask       = 0x18e0,
1080         .muxsel         = { 2, 3, 1, 1},
1081         .audiomux       = { 0x0000,0x0800,0x1000,0x1000,0x18e0 },
1082                        /* For cards with tda9820/tda9821:
1083                           0x0000: Tuner normal stereo
1084                           0x0080: Tuner A2 SAP (second audio program = Zweikanalton)
1085                           0x0880: Tuner A2 stereo */
1086         .pll            = PLL_28,
1087         .tuner_type     = -1,
1088 },{
1089         /* Miguel Angel Alvarez <maacruz@navegalia.com>
1090            old Easy TV BT848 version (model CPH031) */
1091         .name           = "Askey CPH031/ BESTBUY Easy TV",
1092         .video_inputs   = 4,
1093         .audio_inputs   = 1,
1094         .tuner          = 0,
1095         .svhs           = 2,
1096         .gpiomask       = 0xF,
1097         .muxsel         = { 2, 3, 1, 0},
1098         .audiomux       = { 2, 0, 0, 0, 10},
1099         .needs_tvaudio  = 0,
1100         .pll            = PLL_28,
1101         .tuner_type     = TUNER_TEMIC_PAL,
1102 },{
1103
1104 /* ---- card 0x38 ---------------------------------- */
1105         /* Gordon Heydon <gjheydon@bigfoot.com ('98) */
1106         .name           = "Lifeview FlyVideo 98FM LR50",
1107         .video_inputs   = 4,
1108         .audio_inputs   = 3,
1109         .tuner          = 0,
1110         .svhs           = 2,
1111         .gpiomask       = 0x1800,
1112         .muxsel         = { 2, 3, 1, 1},
1113         .audiomux       = { 0, 0x800, 0x1000, 0x1000, 0x1800, 0 },
1114         .pll            = PLL_28,
1115         .tuner_type     = 5,
1116 },{
1117         /* This is the ultimate cheapo capture card 
1118          * just a BT848A on a small PCB!
1119          * Steve Hosgood <steve@equiinet.com> */
1120         .name           = "GrandTec 'Grand Video Capture' (Bt848)",
1121         .video_inputs   = 2,
1122         .audio_inputs   = 0,
1123         .tuner          = -1,
1124         .svhs           = 1,
1125         .gpiomask       = 0,
1126         .muxsel         = { 3, 1 },
1127         .audiomux       = { 0 },
1128         .needs_tvaudio  = 0,
1129         .no_msp34xx     = 1,
1130         .pll            = PLL_35,
1131         .tuner_type     = -1,
1132 },{
1133         /* Daniel Herrington <daniel.herrington@home.com> */
1134         .name           = "Askey CPH060/ Phoebe TV Master Only (No FM)",
1135         .video_inputs   = 3,
1136         .audio_inputs   = 1,
1137         .tuner          = 0,
1138         .svhs           = 2,
1139         .gpiomask       = 0xe00,
1140         .muxsel         = { 2, 3, 1, 1},
1141         .audiomux       = { 0x400, 0x400, 0x400, 0x400, 0x800, 0x400 },
1142         .needs_tvaudio  = 1,
1143         .pll            = PLL_28,
1144         .tuner_type     = TUNER_TEMIC_4036FY5_NTSC,
1145 },{
1146         /* Matti Mottus <mottus@physic.ut.ee> */
1147         .name           = "Askey CPH03x TV Capturer",
1148         .video_inputs   = 4,
1149         .audio_inputs   = 1,
1150         .tuner          = 0,
1151         .svhs           = 2,
1152         .gpiomask       = 0x03000F,
1153         .muxsel         = { 2, 3, 1, 0},
1154         .audiomux       = { 2,0,0,0,1 },
1155         .pll            = PLL_28,
1156         .tuner_type     = 0,
1157 },{
1158
1159 /* ---- card 0x3c ---------------------------------- */
1160         /* Philip Blundell <philb@gnu.org> */
1161         .name           = "Modular Technology MM100PCTV",
1162         .video_inputs   = 2,
1163         .audio_inputs   = 2,
1164         .tuner          = 0,
1165         .svhs           = -1,
1166         .gpiomask       = 11,
1167         .muxsel         = { 2, 3, 1, 1},
1168         .audiomux       = { 2, 0, 0, 1, 8},
1169         .pll            = PLL_35,
1170         .tuner_type     = TUNER_TEMIC_PAL,
1171
1172 },{
1173         /* Adrian Cox <adrian@humboldt.co.uk */
1174         .name           = "AG Electronics GMV1",
1175         .video_inputs   = 2,
1176         .audio_inputs   = 0,
1177         .tuner          = -1,
1178         .svhs           = 1,
1179         .gpiomask       = 0xF,
1180         .muxsel         = { 2, 2},
1181         .audiomux       = { },
1182         .no_msp34xx     = 1,
1183         .needs_tvaudio  = 0,
1184         .pll            = PLL_28,
1185         .tuner_type     = -1,
1186 },{
1187         /* Miguel Angel Alvarez <maacruz@navegalia.com>
1188            new Easy TV BT878 version (model CPH061) 
1189            special thanks to Informatica Mieres for providing the card */
1190         .name           = "Askey CPH061/ BESTBUY Easy TV (bt878)",
1191         .video_inputs   = 3,
1192         .audio_inputs   = 2,
1193         .tuner          = 0,
1194         .svhs           = 2,
1195         .gpiomask       = 0xFF,
1196         .muxsel         = { 2, 3, 1, 0},
1197         .audiomux       = { 1, 0, 4, 4, 9},
1198         .needs_tvaudio  = 0,
1199         .pll            = PLL_28,
1200         .tuner_type     = TUNER_PHILIPS_PAL,
1201 },{
1202         /* Lukas Gebauer <geby@volny.cz> */
1203         .name           = "ATI TV-Wonder",
1204         .video_inputs   = 3,
1205         .audio_inputs   = 1,
1206         .tuner          = 0,
1207         .svhs           = 2,
1208         .gpiomask       = 0xf03f,
1209         .muxsel         = { 2, 3, 1, 0 },
1210         .audiomux       = { 0xbffe, 0, 0xbfff, 0, 0xbffe},
1211         .pll            = PLL_28,
1212         .tuner_type     = TUNER_TEMIC_4006FN5_MULTI_PAL,
1213 },{
1214
1215 /* ---- card 0x40 ---------------------------------- */
1216         /* Lukas Gebauer <geby@volny.cz> */
1217         .name           = "ATI TV-Wonder VE",
1218         .video_inputs   = 2,
1219         .audio_inputs   = 1,
1220         .tuner          = 0,
1221         .svhs           = -1,
1222         .gpiomask       = 1,
1223         .muxsel         = { 2, 3, 0, 1},
1224         .audiomux       = { 0, 0, 1, 0, 0},
1225         .no_msp34xx     = 1,
1226         .pll            = PLL_28,
1227         .tuner_type     = TUNER_TEMIC_4006FN5_MULTI_PAL,
1228 },{
1229         /* DeeJay <deejay@westel900.net (2000S) */
1230         .name           = "Lifeview FlyVideo 2000S LR90",
1231         .video_inputs   = 3,
1232         .audio_inputs   = 3,
1233         .tuner          = 0,
1234         .svhs           = 2,
1235         .gpiomask       = 0x18e0,
1236         .muxsel         = { 2, 3, 0, 1},
1237                         /* Radio changed from 1e80 to 0x800 to make
1238                            FlyVideo2000S in .hu happy (gm)*/
1239                         /* -dk-???: set mute=0x1800 for tda9874h daughterboard */
1240         .audiomux       = { 0x0000,0x0800,0x1000,0x1000,0x1800, 0x1080 },
1241         .audio_hook     = fv2000s_audio,
1242         .no_msp34xx     = 1,
1243         .no_tda9875     = 1,
1244         .needs_tvaudio  = 1,
1245         .pll            = PLL_28,
1246         .tuner_type     = 5,
1247 },{
1248         .name           = "Terratec TValueRadio",
1249         .video_inputs   = 3,
1250         .audio_inputs   = 1,
1251         .tuner          = 0,
1252         .svhs           = 2,
1253         .gpiomask       = 0xffff00,
1254         .muxsel         = { 2, 3, 1, 1},
1255         .audiomux       = { 0x500, 0x500, 0x300, 0x900, 0x900},
1256         .needs_tvaudio  = 1,
1257         .pll            = PLL_28,
1258         .tuner_type     = TUNER_PHILIPS_PAL,
1259         .has_radio      = 1,
1260 },{
1261         /* TANAKA Kei <peg00625@nifty.com> */
1262         .name           = "IODATA GV-BCTV4/PCI",
1263         .video_inputs   = 3,
1264         .audio_inputs   = 1,
1265         .tuner          = 0,
1266         .svhs           = 2,
1267         .gpiomask       = 0x010f00,
1268         .muxsel         = {2, 3, 0, 0},
1269         .audiomux       = {0x10000, 0, 0x10000, 0, 0, 0},
1270         .no_msp34xx     = 1,
1271         .pll            = PLL_28,
1272         .tuner_type     = TUNER_SHARP_2U5JF5540_NTSC,
1273         .audio_hook     = gvbctv3pci_audio,
1274 },{
1275
1276 /* ---- card 0x44 ---------------------------------- */
1277         .name           = "3Dfx VoodooTV FM (Euro), VoodooTV 200 (USA)",
1278         // try "insmod msp3400 simple=0" if you have
1279         // sound problems with this card.
1280         .video_inputs   = 4,
1281         .audio_inputs   = 1,
1282         .tuner          = 0,
1283         .svhs           = -1,
1284         .gpiomask       = 0x4f8a00,
1285         // 0x100000: 1=MSP enabled (0=disable again)
1286         // 0x010000: Connected to "S0" on tda9880 (0=Pal/BG, 1=NTSC)
1287         .audiomux       = {0x947fff, 0x987fff,0x947fff,0x947fff, 0x947fff},
1288         // tvtuner, radio,   external,internal, mute,  stereo
1289         /* tuner, Composit, SVid, Composit-on-Svid-adapter*/
1290         .muxsel         = { 2, 3 ,0 ,1},
1291         .tuner_type     = TUNER_MT2032,
1292         .pll            = PLL_28,
1293         .has_radio      = 1,
1294 },{
1295         /* Philip Blundell <pb@nexus.co.uk> */
1296         .name           = "Active Imaging AIMMS",
1297         .video_inputs   = 1,
1298         .audio_inputs   = 0,
1299         .tuner          = -1,
1300         .tuner_type     = -1,
1301         .pll            = PLL_28,
1302         .muxsel         = { 2 },
1303         .gpiomask       = 0
1304 },{
1305         /* Tomasz Pyra <hellfire@sedez.iq.pl> */
1306         .name           = "Prolink Pixelview PV-BT878P+ (Rev.4C,8E)",
1307         .video_inputs   = 3,
1308         .audio_inputs   = 4,
1309         .tuner          = 0,
1310         .svhs           = 2,
1311         .gpiomask       = 15,
1312         .muxsel         = { 2, 3, 1, 1},
1313         .audiomux       = { 0, 0, 11, 7, 13, 0}, // TV and Radio with same GPIO !
1314         .needs_tvaudio  = 1,
1315         .pll            = PLL_28,
1316         .tuner_type     = 25,
1317         .has_remote     = 1,
1318         /* GPIO wiring:
1319                 GPIO0: U4.A0 (hef4052bt)
1320                 GPIO1: U4.A1
1321                 GPIO2: U4.A1 (second hef4052bt)
1322                 GPIO3: U4.nEN, U5.A0, A5.nEN
1323                 GPIO8-15: vrd866b ?
1324          */
1325 },{
1326         .name           = "Lifeview FlyVideo 98EZ (capture only) LR51",
1327         .video_inputs   = 4,
1328         .audio_inputs   = 0,
1329         .tuner          = -1,
1330         .svhs           = 2,
1331         .muxsel         = { 2, 3, 1, 1}, // AV1, AV2, SVHS, CVid adapter on SVHS
1332         .pll            = PLL_28,
1333         .no_msp34xx     = 1,
1334 },{
1335
1336 /* ---- card 0x48 ---------------------------------- */
1337         /* Dariusz Kowalewski <darekk@automex.pl> */
1338         .name           = "Prolink Pixelview PV-BT878P+9B (PlayTV Pro rev.9B FM+NICAM)",
1339         .video_inputs   = 4,
1340         .audio_inputs   = 1,
1341         .tuner          = 0,
1342         .svhs           = 2,
1343         .gpiomask       = 0x3f,
1344         .muxsel         = { 2, 3, 1, 1 },
1345         .audiomux       = { 0x01, 0x00, 0x03, 0x03, 0x09, 0x02 },
1346         .needs_tvaudio  = 1,
1347         .no_msp34xx     = 1,
1348         .no_tda9875     = 1,
1349         .pll            = PLL_28,
1350         .tuner_type     = 5,
1351         .audio_hook     = pvbt878p9b_audio, // Note: not all cards have stereo
1352         .has_radio      = 1,  // Note: not all cards have radio
1353         .has_remote     = 1,
1354         /* GPIO wiring:
1355                 GPIO0: A0 hef4052
1356                 GPIO1: A1 hef4052
1357                 GPIO3: nEN hef4052
1358                 GPIO8-15: vrd866b
1359                 GPIO20,22,23: R30,R29,R28
1360          */
1361 },{
1362         /* Clay Kunz <ckunz@mail.arc.nasa.gov> */
1363         /* you must jumper JP5 for the card to work */
1364         .name           = "Sensoray 311",
1365         .video_inputs   = 5,
1366         .audio_inputs   = 0,
1367         .tuner          = -1,
1368         .svhs           = 4,
1369         .gpiomask       = 0,
1370         .muxsel         = { 2, 3, 1, 0, 0},
1371         .audiomux       = { 0 },
1372         .needs_tvaudio  = 0,
1373         .tuner_type     = -1,
1374 },{
1375         /* Miguel Freitas <miguel@cetuc.puc-rio.br> */
1376         .name           = "RemoteVision MX (RV605)",
1377         .video_inputs   = 16,
1378         .audio_inputs   = 0,
1379         .tuner          = -1,
1380         .svhs           = -1,
1381         .gpiomask       = 0x00,
1382         .gpiomask2      = 0x07ff,
1383         .muxsel         = { 0x33, 0x13, 0x23, 0x43, 0xf3, 0x73, 0xe3, 0x03,
1384                           0xd3, 0xb3, 0xc3, 0x63, 0x93, 0x53, 0x83, 0xa3 },
1385         .no_msp34xx     = 1,
1386         .no_tda9875     = 1,
1387         .tuner_type     = -1,
1388         .muxsel_hook    = rv605_muxsel,
1389 },{
1390         .name           = "Powercolor MTV878/ MTV878R/ MTV878F",
1391         .video_inputs   = 3,
1392         .audio_inputs   = 2, 
1393         .tuner          = 0,
1394         .svhs           = 2,
1395         .gpiomask       = 0x1C800F,  // Bit0-2: Audio select, 8-12:remote control 14:remote valid 15:remote reset
1396         .muxsel         = { 2, 1, 1, },
1397         .audiomux       = { 0, 1, 2, 2, 4 },
1398         .needs_tvaudio  = 0,
1399         .tuner_type     = TUNER_PHILIPS_PAL,
1400         .pll            = PLL_28,
1401         .has_radio      = 1,
1402 },{
1403
1404 /* ---- card 0x4c ---------------------------------- */
1405         /* Masaki Suzuki <masaki@btree.org> */
1406         .name           = "Canopus WinDVR PCI (COMPAQ Presario 3524JP, 5112JP)",
1407         .video_inputs   = 3,
1408         .audio_inputs   = 1,
1409         .tuner          = 0,
1410         .svhs           = 2,
1411         .gpiomask       = 0x140007,
1412         .muxsel         = { 2, 3, 1, 1 },
1413         .audiomux       = { 0, 1, 2, 3, 4, 0 },
1414         .tuner_type     = TUNER_PHILIPS_NTSC,
1415         .audio_hook     = windvr_audio,
1416 },{
1417         .name           = "GrandTec Multi Capture Card (Bt878)",
1418         .video_inputs   = 4,
1419         .audio_inputs   = 0,
1420         .tuner          = -1,
1421         .svhs           = -1,
1422         .gpiomask       = 0,
1423         .muxsel         = { 2, 3, 1, 0 },
1424         .audiomux       = { 0 },
1425         .needs_tvaudio  = 0,
1426         .no_msp34xx     = 1,
1427         .pll            = PLL_28,
1428         .tuner_type     = -1,
1429 },{
1430         .name           = "Jetway TV/Capture JW-TV878-FBK, Kworld KW-TV878RF",
1431         .video_inputs   = 4,
1432         .audio_inputs   = 3,
1433         .tuner          = 0,
1434         .svhs           = 2,
1435         .gpiomask       = 7,
1436         .muxsel         = { 2, 3, 1, 1 },   // Tuner, SVid, SVHS, SVid to SVHS connector
1437         .audiomux       = { 0 ,0 ,4, 4,4,4},// Yes, this tuner uses the same audio output for TV and FM radio!
1438                                           // This card lacks external Audio In, so we mute it on Ext. & Int.
1439                                           // The PCB can take a sbx1637/sbx1673, wiring unknown.
1440                                           // This card lacks PCI subsystem ID, sigh.
1441                                           // audiomux=1: lower volume, 2+3: mute
1442                                           // btwincap uses 0x80000/0x80003
1443         .needs_tvaudio  = 0,
1444         .no_msp34xx     = 1,
1445         .pll            = PLL_28,
1446         .tuner_type     = 5, // Samsung TCPA9095PC27A (BG+DK), philips compatible, w/FM, stereo and
1447                            // radio signal strength indicators work fine.
1448         .has_radio              = 1,
1449         /* GPIO Info:
1450                 GPIO0,1:   HEF4052 A0,A1
1451                 GPIO2:     HEF4052 nENABLE
1452                 GPIO3-7:   n.c.
1453                 GPIO8-13:  IRDC357 data0-5 (data6 n.c. ?) [chip not present on my card]
1454                 GPIO14,15: ??
1455                 GPIO16-21: n.c.
1456                 GPIO22,23: ??
1457                 ??       : mtu8b56ep microcontroller for IR (GPIO wiring unknown)*/
1458 },{
1459         /* Arthur Tetzlaff-Deas, DSP Design Ltd <software@dspdesign.com> */
1460         .name           = "DSP Design TCVIDEO",
1461         .video_inputs   = 4,
1462         .svhs           = -1,
1463         .muxsel         = { 2, 3, 1, 0},
1464         .pll            = PLL_28,
1465         .tuner_type     = -1,
1466 },{
1467
1468         /* ---- card 0x50 ---------------------------------- */
1469         .name           = "Hauppauge WinTV PVR",
1470         .video_inputs   = 4,
1471         .audio_inputs   = 1,
1472         .tuner          = 0,
1473         .svhs           = 2,
1474         .muxsel         = { 2, 0, 1, 1},
1475         .needs_tvaudio  = 1,
1476         .pll            = PLL_28,
1477         .tuner_type     = -1,
1478
1479         .gpiomask       = 7,
1480         .audiomux       = {7},
1481 },{
1482         .name           = "IODATA GV-BCTV5/PCI",
1483         .video_inputs   = 3,
1484         .audio_inputs   = 1,
1485         .tuner          = 0,
1486         .svhs           = 2,
1487         .gpiomask       = 0x0f0f80,
1488         .muxsel         = {2, 3, 1, 0},
1489         .audiomux       = {0x030000, 0x010000, 0, 0, 0x020000, 0},
1490         .no_msp34xx     = 1,
1491         .pll            = PLL_28,
1492         .tuner_type     = TUNER_PHILIPS_NTSC_M,
1493         .audio_hook     = gvbctv5pci_audio,
1494         .has_radio      = 1,
1495 },{
1496         .name           = "Osprey 100/150 (878)", /* 0x1(2|3)-45C6-C1 */
1497         .video_inputs   = 4,                  /* id-inputs-clock */
1498         .audio_inputs   = 0,
1499         .tuner          = -1,
1500         .svhs           = 3,
1501         .muxsel         = { 3, 2, 0, 1 },
1502         .pll            = PLL_28,
1503         .tuner_type     = -1,
1504         .no_msp34xx     = 1,
1505         .no_tda9875     = 1,
1506         .no_tda7432     = 1,
1507 },{
1508         .name           = "Osprey 100/150 (848)", /* 0x04-54C0-C1 & older boards */
1509         .video_inputs   = 3,
1510         .audio_inputs   = 0,
1511         .tuner          = -1,
1512         .svhs           = 2,
1513         .muxsel         = { 2, 3, 1 },
1514         .pll            = PLL_28,
1515         .tuner_type     = -1,
1516         .no_msp34xx     = 1,
1517         .no_tda9875     = 1,
1518         .no_tda7432     = 1,
1519 },{
1520
1521         /* ---- card 0x54 ---------------------------------- */
1522         .name           = "Osprey 101 (848)", /* 0x05-40C0-C1 */
1523         .video_inputs   = 2,
1524         .audio_inputs   = 0,
1525         .tuner          = -1,
1526         .svhs           = 1,
1527         .muxsel         = { 3, 1 },
1528         .pll            = PLL_28,
1529         .tuner_type     = -1,
1530         .no_msp34xx     = 1,
1531         .no_tda9875     = 1,
1532         .no_tda7432     = 1,
1533 },{
1534         .name           = "Osprey 101/151",       /* 0x1(4|5)-0004-C4 */
1535         .video_inputs   = 1,
1536         .audio_inputs   = 0,
1537         .tuner          = -1,
1538         .svhs           = -1,
1539         .muxsel         = { 0 },
1540         .pll            = PLL_28,
1541         .tuner_type     = -1,
1542         .no_msp34xx     = 1,
1543         .no_tda9875     = 1,
1544         .no_tda7432     = 1,
1545 },{
1546         .name           = "Osprey 101/151 w/ svid",  /* 0x(16|17|20)-00C4-C1 */
1547         .video_inputs   = 2,
1548         .audio_inputs   = 0,
1549         .tuner          = -1,
1550         .svhs           = 1,
1551         .muxsel         = { 0, 1 },
1552         .pll            = PLL_28,
1553         .tuner_type     = -1,
1554         .no_msp34xx     = 1,
1555         .no_tda9875     = 1,
1556         .no_tda7432     = 1,
1557 },{
1558         .name           = "Osprey 200/201/250/251",  /* 0x1(8|9|E|F)-0004-C4 */
1559         .video_inputs   = 1,
1560         .audio_inputs   = 1,
1561         .tuner          = -1,
1562         .svhs           = -1,
1563         .muxsel         = { 0 },
1564         .pll            = PLL_28,
1565         .tuner_type     = -1,
1566         .no_msp34xx     = 1,
1567         .no_tda9875     = 1,
1568         .no_tda7432     = 1,
1569 },{
1570         
1571         /* ---- card 0x58 ---------------------------------- */
1572         .name           = "Osprey 200/250",   /* 0x1(A|B)-00C4-C1 */
1573         .video_inputs   = 2,
1574         .audio_inputs   = 1,
1575         .tuner          = -1,
1576         .svhs           = 1,
1577         .muxsel         = { 0, 1 },
1578         .pll            = PLL_28,
1579         .tuner_type     = -1,
1580         .no_msp34xx     = 1,
1581         .no_tda9875     = 1,
1582         .no_tda7432     = 1,
1583 },{
1584         .name           = "Osprey 210/220",   /* 0x1(A|B)-04C0-C1 */
1585         .video_inputs   = 2,
1586         .audio_inputs   = 1,
1587         .tuner          = -1,
1588         .svhs           = 1,
1589         .muxsel         = { 2, 3 },
1590         .pll            = PLL_28,
1591         .tuner_type     = -1,
1592         .no_msp34xx     = 1,
1593         .no_tda9875     = 1,
1594         .no_tda7432     = 1,
1595 },{
1596         .name           = "Osprey 500",   /* 500 */
1597         .video_inputs   = 2,
1598         .audio_inputs   = 1,
1599         .tuner          = -1,
1600         .svhs           = 1,
1601         .muxsel         = { 2, 3 },
1602         .pll            = PLL_28,
1603         .tuner_type     = -1,
1604         .no_msp34xx     = 1,
1605         .no_tda9875     = 1,
1606         .no_tda7432     = 1,
1607 },{
1608        .name           = "Osprey 540",   /* 540 */
1609        .video_inputs   = 4,
1610        .audio_inputs   = 1,
1611        .tuner          = -1,
1612 #if 0 /* TODO ... */
1613        .svhs           = OSPREY540_SVID_ANALOG,
1614        .muxsel         = {       [OSPREY540_COMP_ANALOG] = 2,
1615                                [OSPREY540_SVID_ANALOG] = 3, },
1616 #endif
1617        .pll            = PLL_28,
1618        .tuner_type     = -1,
1619        .no_msp34xx     = 1,
1620        .no_tda9875     = 1,
1621        .no_tda7432     = 1,
1622 #if 0 /* TODO ... */
1623        .muxsel_hook    = osprey_540_muxsel,
1624        .picture_hook   = osprey_540_set_picture,
1625 #endif
1626 },{
1627
1628         /* ---- card 0x5C ---------------------------------- */
1629         .name           = "Osprey 2000",  /* 2000 */
1630         .video_inputs   = 2,
1631         .audio_inputs   = 1,
1632         .tuner          = -1,
1633         .svhs           = 1,
1634         .muxsel         = { 2, 3 },
1635         .pll            = PLL_28,
1636         .tuner_type     = -1,
1637         .no_msp34xx     = 1,
1638         .no_tda9875     = 1,
1639         .no_tda7432     = 1,      /* must avoid, conflicts with the bt860 */
1640 },{
1641         /* M G Berberich <berberic@forwiss.uni-passau.de> */
1642         .name           = "IDS Eagle",
1643         .video_inputs   = 4,
1644         .audio_inputs   = 0,
1645         .tuner          = -1,
1646         .tuner_type     = -1,
1647         .svhs           = -1,
1648         .gpiomask       = 0,
1649         .muxsel         = { 0, 1, 2, 3 },
1650         .muxsel_hook    = eagle_muxsel,
1651         .no_msp34xx     = 1,
1652         .no_tda9875     = 1,
1653         .pll            = PLL_28,
1654 },{
1655         .name           = "Pinnacle PCTV Sat",
1656         .video_inputs   = 2,
1657         .audio_inputs   = 0,
1658         .svhs           = 1,
1659         .tuner          = -1,
1660         .tuner_type     = -1,
1661         .no_msp34xx     = 1,
1662         .no_tda9875     = 1,
1663         .no_tda7432     = 1,   
1664         .gpiomask       = 0x01,
1665         .audiomux       = { 0, 0, 0, 0, 1 },
1666         .muxsel         = { 3, 0, 1, 2},
1667         .needs_tvaudio  = 0, 
1668         .pll            = PLL_28,
1669         .no_gpioirq     = 1,
1670 },{
1671         .name           = "Formac ProTV II (bt878)",
1672         .video_inputs   = 4,
1673         .audio_inputs   = 1,
1674         .tuner          = 0,
1675         .svhs           = 3,
1676         .gpiomask       = 2,
1677         // TV, Comp1, Composite over SVID con, SVID
1678         .muxsel         = { 2, 3, 1, 1},
1679         .audiomux       = { 2, 2, 0, 0, 0 }, 
1680         .pll            = PLL_28,
1681         .has_radio      = 1,
1682         .tuner_type     = TUNER_PHILIPS_PAL,
1683       /* sound routing:
1684            GPIO=0x00,0x01,0x03: mute (?)
1685               0x02: both TV and radio (tuner: FM1216/I)
1686          The card has onboard audio connectors labeled "cdrom" and "board",
1687          not soldered here, though unknown wiring.
1688          Card lacks: external audio in, pci subsystem id.
1689        */
1690 },{
1691
1692         /* ---- card 0x60 ---------------------------------- */
1693         .name           = "MachTV",
1694         .video_inputs   = 3,
1695         .audio_inputs   = 1,
1696         .tuner          = 0,
1697         .svhs           = -1,
1698         .gpiomask       = 7,
1699         .muxsel         = { 2, 3, 1, 1},
1700         .audiomux       = { 0, 1, 2, 3, 4},
1701         .needs_tvaudio  = 1,
1702         .tuner_type     = 5,
1703         .pll            = 1,
1704 },{
1705         .name           = "Euresys Picolo",
1706         .video_inputs   = 3,
1707         .audio_inputs   = 0,
1708         .tuner          = -1,
1709         .svhs           = 2,
1710         .gpiomask       = 0,
1711         .no_msp34xx     = 1,
1712         .no_tda9875     = 1,
1713         .no_tda7432     = 1,
1714         .muxsel         = { 2, 0, 1},
1715         .pll            = PLL_28,
1716 },{
1717         /* Luc Van Hoeylandt <luc@e-magic.be> */
1718         .name           = "ProVideo PV150", /* 0x4f */
1719         .video_inputs   = 2,
1720         .audio_inputs   = 0,
1721         .tuner          = -1,
1722         .svhs           = -1,
1723         .gpiomask       = 0,
1724         .muxsel         = { 2, 3 },
1725         .audiomux       = { 0 },
1726         .needs_tvaudio  = 0,
1727         .no_msp34xx     = 1,
1728         .pll            = PLL_28,
1729         .tuner_type     = -1,
1730 },{
1731         /* Hiroshi Takekawa <sian@big.or.jp> */
1732         /* This card lacks subsystem ID */
1733         .name           = "AD-TVK503", /* 0x63 */
1734         .video_inputs   = 4,
1735         .audio_inputs   = 1,
1736         .tuner          = 0,
1737         .svhs           = 2,
1738         .gpiomask       = 0x001e8007,
1739         .muxsel         = { 2, 3, 1, 0 },
1740         /*                  Tuner, Radio, external, internal, off,  on */
1741         .audiomux       = { 0x08,  0x0f,  0x0a,     0x08,     0x0f, 0x08 },
1742         .needs_tvaudio  = 0,
1743         .no_msp34xx     = 1,
1744         .pll            = PLL_28,
1745         .tuner_type     = 2,
1746         .audio_hook     = adtvk503_audio,
1747 },{
1748
1749         /* ---- card 0x64 ---------------------------------- */
1750         .name           = "Hercules Smart TV Stereo",
1751         .video_inputs   = 4,
1752         .audio_inputs   = 1,
1753         .tuner          = 0,
1754         .svhs           = 2,
1755         .gpiomask       = 0x00,
1756         .muxsel         = { 2, 3, 1, 1 },
1757         .needs_tvaudio  = 1,
1758         .no_msp34xx     = 1,
1759         .pll            = PLL_28,
1760         .tuner_type     = 5,
1761         /* Notes:
1762            - card lacks subsystem ID
1763            - stereo variant w/ daughter board with tda9874a @0xb0
1764            - Audio Routing: 
1765                 always from tda9874 independent of GPIO (?)
1766                 external line in: unknown
1767            - Other chips: em78p156elp @ 0x96 (probably IR remote control)
1768                       hef4053 (instead 4052) for unknown function
1769         */
1770 },{
1771         .name           = "Pace TV & Radio Card",
1772         .video_inputs   = 4,
1773         .audio_inputs   = 1,
1774         .tuner          = 0,
1775         .svhs           = 2,
1776         .muxsel         = { 2, 3, 1, 1}, // Tuner, CVid, SVid, CVid over SVid connector
1777         .gpiomask       = 0,
1778         .no_tda9875     = 1,
1779         .no_tda7432     = 1,
1780         .tuner_type     = 1,
1781         .has_radio      = 1,
1782         .pll            = PLL_28,
1783         /* Bt878, Bt832, FI1246 tuner; no pci subsystem id
1784            only internal line out: (4pin header) RGGL
1785            Radio must be decoded by msp3410d (not routed through)*/
1786         //         .digital_mode   = DIGITAL_MODE_CAMERA, // todo!
1787 },{
1788         /* Chris Willing <chris@vislab.usyd.edu.au> */
1789         .name           = "IVC-200",
1790         .video_inputs   = 1,
1791         .audio_inputs   = 0,
1792         .tuner          = -1,
1793         .tuner_type     = -1,
1794         .svhs           = -1,
1795         .gpiomask       = 0xdf,
1796         .muxsel         = { 2 },
1797         .pll            = PLL_28,
1798 },{
1799         .name           = "Grand X-Guard / Trust 814PCI",
1800         .video_inputs   = 16,
1801         .audio_inputs   = 0,
1802         .tuner          = -1,
1803         .svhs           = -1,
1804         .tuner_type     = 4,
1805         .gpiomask2      = 0xff,
1806         .muxsel         = { 2,2,2,2, 3,3,3,3, 1,1,1,1, 0,0,0,0 },
1807         .muxsel_hook    = xguard_muxsel,
1808         .no_msp34xx     = 1,
1809         .no_tda9875     = 1,
1810         .no_tda7432     = 1,
1811         .pll            = PLL_28,
1812 },{
1813
1814         /* ---- card 0x68 ---------------------------------- */
1815         .name           = "Nebula Electronics DigiTV",
1816         .video_inputs   = 1,
1817         .tuner          = -1,
1818         .svhs           = -1,
1819         .muxsel         = { 2, 3, 1, 0},
1820         .no_msp34xx     = 1,
1821         .no_tda9875     = 1,
1822         .no_tda7432     = 1,
1823         .pll            = PLL_28,
1824         .tuner_type     = -1,
1825         .has_dvb        = 1,
1826         .no_gpioirq     = 1,
1827 },{
1828         /* Jorge Boncompte - DTI2 <jorge@dti2.net> */
1829         .name           = "ProVideo PV143",
1830         .video_inputs   = 4,
1831         .audio_inputs   = 0,
1832         .tuner          = -1,
1833         .svhs           = -1,
1834         .gpiomask       = 0,
1835         .muxsel         = { 2, 3, 1, 0 },
1836         .audiomux       = { 0 },
1837         .needs_tvaudio  = 0,
1838         .no_msp34xx     = 1,
1839         .pll            = PLL_28,
1840         .tuner_type     = -1,
1841 },{
1842         /* M.Klahr@phytec.de */
1843         .name           = "PHYTEC VD-009-X1 MiniDIN (bt878)",
1844         .video_inputs   = 4,
1845         .audio_inputs   = 0,
1846         .tuner          = -1, /* card has no tuner */
1847         .svhs           = 3,
1848         .gpiomask       = 0x00, 
1849         .muxsel         = { 2, 3, 1, 0},
1850         .audiomux       = { 0, 0, 0, 0, 0, 0 }, /* card has no audio */
1851         .needs_tvaudio  = 1,
1852         .pll            = PLL_28,
1853         .tuner_type     = -1,
1854 },{
1855         .name           = "PHYTEC VD-009-X1 Combi (bt878)",
1856         .video_inputs   = 4,
1857         .audio_inputs   = 0,
1858         .tuner          = -1, /* card has no tuner */
1859         .svhs           = 3,
1860         .gpiomask       = 0x00,
1861         .muxsel         = { 2, 3, 1, 1},
1862         .audiomux       = { 0, 0, 0, 0, 0, 0 }, /* card has no audio */
1863         .needs_tvaudio  = 1,
1864         .pll            = PLL_28,
1865         .tuner_type     = -1,
1866 },{
1867
1868         /* ---- card 0x6c ---------------------------------- */
1869         .name           = "PHYTEC VD-009 MiniDIN (bt878)",
1870         .video_inputs   = 10,
1871         .audio_inputs   = 0,
1872         .tuner          = -1, /* card has no tuner */
1873         .svhs           = 9,
1874         .gpiomask       = 0x00,
1875         .gpiomask2      = 0x03, /* gpiomask2 defines the bits used to switch audio
1876                                    via the upper nibble of muxsel. here: used for
1877                                    xternal video-mux */
1878         .muxsel         = { 0x02, 0x12, 0x22, 0x32, 0x03, 0x13, 0x23, 0x33, 0x01, 0x00 },
1879         .audiomux       = { 0, 0, 0, 0, 0, 0 }, /* card has no audio */
1880         .needs_tvaudio  = 1,
1881         .pll            = PLL_28,
1882         .tuner_type     = -1,
1883 },{
1884         .name           = "PHYTEC VD-009 Combi (bt878)",
1885         .video_inputs   = 10,
1886         .audio_inputs   = 0,
1887         .tuner          = -1, /* card has no tuner */
1888         .svhs           = 9,
1889         .gpiomask       = 0x00,
1890         .gpiomask2      = 0x03, /* gpiomask2 defines the bits used to switch audio
1891                                    via the upper nibble of muxsel. here: used for
1892                                    xternal video-mux */
1893         .muxsel         = { 0x02, 0x12, 0x22, 0x32, 0x03, 0x13, 0x23, 0x33, 0x01, 0x01 },
1894         .audiomux       = { 0, 0, 0, 0, 0, 0 }, /* card has no audio */
1895         .needs_tvaudio  = 1,
1896         .pll            = PLL_28,
1897         .tuner_type     = -1,
1898 },{
1899         .name           = "IVC-100",
1900         .video_inputs   = 4,
1901         .audio_inputs   = 0,
1902         .tuner          = -1,
1903         .tuner_type     = -1,
1904         .svhs           = -1,
1905         .gpiomask       = 0xdf,
1906         .muxsel         = { 2, 3, 1, 0 },
1907         .pll            = PLL_28,
1908 },{
1909         /* IVC-120G - Alan Garfield <alan@fromorbit.com> */
1910         .name           = "IVC-120G",
1911         .video_inputs   = 16,
1912         .audio_inputs   = 0,    /* card has no audio */
1913         .tuner          = -1,   /* card has no tuner */
1914         .tuner_type     = -1,
1915         .svhs           = -1,   /* card has no svhs */
1916         .needs_tvaudio  = 0,
1917         .no_msp34xx     = 1,
1918         .no_tda9875     = 1,
1919         .no_tda7432     = 1,
1920         .gpiomask       = 0x00,
1921         .muxsel         = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 
1922                             0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10 },
1923         .muxsel_hook    = ivc120_muxsel,
1924         .pll            = PLL_28,
1925 },{
1926
1927         /* ---- card 0x70 ---------------------------------- */
1928         .name           = "pcHDTV HD-2000 TV",
1929         .video_inputs   = 4,
1930         .audio_inputs   = 1,
1931         .tuner          = 0,
1932         .svhs           = 2,
1933         .muxsel         = { 2, 3, 1, 0},
1934         .tuner_type     = TUNER_PHILIPS_ATSC,
1935 },{
1936         .name           = "Twinhan DST + clones",
1937         .no_msp34xx     = 1,
1938         .no_tda9875     = 1,
1939         .no_tda7432     = 1,
1940         .tuner_type     = TUNER_ABSENT,
1941         .no_video       = 1,
1942         .has_dvb        = 1,
1943 },{
1944         .name           = "Winfast VC100",
1945         .video_inputs   = 3,
1946         .audio_inputs   = 0,
1947         .svhs           = 1,
1948         .tuner          = -1, // no tuner
1949         .muxsel         = { 3, 1, 1, 3}, // Vid In, SVid In, Vid over SVid in connector
1950         .no_msp34xx     = 1,
1951         .no_tda9875     = 1,
1952         .no_tda7432     = 1,
1953         .tuner_type     = TUNER_ABSENT,
1954         .no_video       = 1,
1955         .pll            = PLL_28,
1956 },{
1957         .name           = "Teppro TEV-560/InterVision IV-560",
1958         .video_inputs   = 3,
1959         .audio_inputs   = 1,
1960         .tuner          = 0,
1961         .svhs           = 2,
1962         .gpiomask       = 3,
1963         .muxsel         = { 2, 3, 1, 1},
1964         .audiomux       = { 1, 1, 1, 1, 0},
1965         .needs_tvaudio  = 1,
1966         .tuner_type     = TUNER_PHILIPS_PAL,
1967         .pll            = PLL_35,
1968 },{
1969
1970         /* ---- card 0x74 ---------------------------------- */
1971         .name           = "SIMUS GVC1100",
1972         .video_inputs   = 4,
1973         .audio_inputs   = 0,
1974         .tuner          = -1,
1975         .svhs           = -1,
1976         .tuner_type     = -1,
1977         .pll            = PLL_28,
1978         .muxsel         = { 2, 2, 2, 2},
1979         .gpiomask       = 0x3F,
1980         .muxsel_hook    = gvc1100_muxsel,
1981 },{
1982         /* Carlos Silva r3pek@r3pek.homelinux.org || card 0x75 */
1983         .name           = "NGS NGSTV+",
1984         .video_inputs   = 3,
1985         .tuner          = 0,
1986         .svhs           = 2,
1987         .gpiomask       = 0x008007,
1988         .muxsel         = {2, 3, 0, 0},
1989         .audiomux       = {0, 0, 0, 0, 0x000003, 0},
1990         .pll            = PLL_28,
1991         .tuner_type     = TUNER_PHILIPS_PAL,
1992         .has_remote     = 1,
1993 },{
1994         /* http://linuxmedialabs.com */
1995         .name           = "LMLBT4",
1996         .video_inputs   = 4, /* IN1,IN2,IN3,IN4 */
1997         .audio_inputs   = 0,
1998         .tuner          = -1,
1999         .svhs           = -1,
2000         .muxsel         = { 2, 3, 1, 0 },
2001         .no_msp34xx     = 1,
2002         .no_tda9875     = 1,
2003         .no_tda7432     = 1,
2004         .needs_tvaudio  = 0,
2005 },{
2006         /* Helmroos Harri <harri.helmroos@pp.inet.fi> */
2007         .name           = "Tekram M205 PRO",
2008         .video_inputs   = 3,
2009         .audio_inputs   = 1,
2010         .tuner          = 0,
2011         .tuner_type     = TUNER_PHILIPS_PAL,
2012         .svhs           = 2,
2013         .needs_tvaudio  = 0,
2014         .gpiomask       = 0x68,
2015         .muxsel         = { 2, 3, 1},
2016         .audiomux       = { 0x68, 0x68, 0x61, 0x61, 0x00 },
2017         .pll            = PLL_28,
2018 },{
2019
2020         /* ---- card 0x78 ---------------------------------- */
2021         /* Javier Cendan Ares <jcendan@lycos.es> */
2022         /* bt878 TV + FM without subsystem ID */
2023         .name           = "Conceptronic CONTVFMi",
2024         .video_inputs   = 3,
2025         .audio_inputs   = 1,
2026         .tuner          = 0,
2027         .svhs           = 2,
2028         .gpiomask       = 0x008007,
2029         .muxsel         = { 2, 3, 1, 1 },
2030         .audiomux       = { 0, 1, 2, 2, 3 },
2031         .needs_tvaudio  = 0,
2032         .pll            = PLL_28,
2033         .tuner_type     = TUNER_PHILIPS_PAL,
2034         .has_remote     = 1,
2035         .has_radio      = 1,
2036 },{
2037         /*Eric DEBIEF <debief@telemsa.com>*/
2038         /*EURESYS Picolo Tetra : 4 Conexant Fusion 878A, no audio, video input set with analog multiplexers GPIO controled*/
2039         /* adds picolo_tetra_muxsel(), picolo_tetra_init(), the folowing declaration strucure, and #define BTTV_PICOLO_TETRA_CHIP*/
2040         /*0x79 in bttv.h*/
2041         .name           = "Euresys Picolo Tetra",
2042         .video_inputs   = 4,
2043         .audio_inputs   = 0,
2044         .tuner          = -1,
2045         .svhs           = -1,
2046         .gpiomask       = 0,
2047         .gpiomask2      = 0x3C<<16,/*Set the GPIO[18]->GPIO[21] as output pin.==> drive the video inputs through analog multiplexers*/
2048         .no_msp34xx     = 1,
2049         .no_tda9875     = 1,
2050         .no_tda7432     = 1,
2051         .muxsel         = {2,2,2,2},/*878A input is always MUX0, see above.*/
2052         .audiomux       = { 0, 0, 0, 0, 0, 0 }, /* card has no audio */
2053         .pll            = PLL_28,
2054         .needs_tvaudio  = 0,
2055         .muxsel_hook    = picolo_tetra_muxsel,/*Required as it doesn't follow the classic input selection policy*/
2056 },{
2057         /* Spirit TV Tuner from http://spiritmodems.com.au */
2058         /* Stafford Goodsell <surge@goliath.homeunix.org> */
2059         .name           = "Spirit TV Tuner",
2060         .video_inputs   = 3,
2061         .audio_inputs   = 1,
2062         .tuner          = 0,
2063         .svhs           = 2,
2064         .gpiomask       = 0x0000000f,
2065         .muxsel         = { 2, 1, 1 },
2066         .audiomux       = { 0x02, 0x00, 0x00, 0x00, 0x00},
2067         .tuner_type     = TUNER_TEMIC_PAL,
2068         .no_msp34xx     = 1,
2069         .no_tda9875     = 1,
2070 },{
2071         /* Wolfram Joost <wojo@frokaschwei.de> */
2072         .name           = "AVerMedia AVerTV DVB-T 771",
2073         .video_inputs   = 2,
2074         .svhs           = 1,
2075         .tuner          = -1,
2076         .tuner_type     = TUNER_ABSENT,
2077         .muxsel         = { 3 , 3 },
2078         .no_msp34xx     = 1,
2079         .no_tda9875     = 1,
2080         .no_tda7432     = 1,
2081         .pll            = PLL_28,
2082         .has_dvb        = 1,
2083         .no_gpioirq     = 1,
2084 #if 0 /* untested */
2085         .has_remote     = 1,
2086 #endif
2087 },{
2088         /* ---- card 0x7c ---------------------------------- */
2089         /* Matt Jesson <dvb@jesson.eclipse.co.uk> */
2090         /* Based on the Nebula card data - added remote and new card number - BTTV_AVDVBT_761, see also ir-kbd-gpio.c */
2091         .name           = "AverMedia AverTV DVB-T 761",
2092         .video_inputs   = 1,
2093         .tuner          = -1,
2094         .svhs           = -1,
2095         .muxsel         = { 2, 3, 1, 0},
2096         .no_msp34xx     = 1,
2097         .no_tda9875     = 1,
2098         .no_tda7432     = 1,
2099         .pll            = PLL_28,
2100         .tuner_type     = -1,
2101         .has_dvb        = 1,
2102         .no_gpioirq     = 1,
2103         .has_remote     = 1,
2104 },{
2105         /* andre.schwarz@matrix-vision.de */
2106         .name             = "MATRIX Vision Sigma-SQ",
2107         .video_inputs     = 16,
2108         .audio_inputs     = 0,
2109         .tuner            = -1,
2110         .svhs             = -1,
2111         .gpiomask         = 0x0,
2112         .muxsel           = { 2, 2, 2, 2, 2, 2, 2, 2,
2113                               3, 3, 3, 3, 3, 3, 3, 3 },
2114         .muxsel_hook      = sigmaSQ_muxsel,
2115         .audiomux         = { 0 },
2116         .no_msp34xx       = 1,
2117         .pll              = PLL_28,
2118         .tuner_type       = -1,
2119 },{
2120         /* andre.schwarz@matrix-vision.de */
2121         .name             = "MATRIX Vision Sigma-SLC",
2122         .video_inputs     = 4,
2123         .audio_inputs     = 0,
2124         .tuner            = -1,
2125         .svhs             = -1,
2126         .gpiomask         = 0x0,
2127         .muxsel           = { 2, 2, 2, 2 },
2128         .muxsel_hook      = sigmaSLC_muxsel,
2129         .audiomux         = { 0 },
2130         .no_msp34xx       = 1,
2131         .pll              = PLL_28,
2132         .tuner_type       = -1,
2133 },{
2134         /* BTTV_APAC_VIEWCOMP */
2135         /* Attila Kondoros <attila.kondoros@chello.hu> */
2136         /* bt878 TV + FM 0x00000000 subsystem ID */
2137         .name           = "APAC Viewcomp 878(AMAX)",
2138         .video_inputs   = 2,
2139         .audio_inputs   = 1,
2140         .tuner          = 0,
2141         .svhs           = -1,
2142         .gpiomask       = 0xFF,
2143         .muxsel         = { 2, 3, 1, 1},
2144         .audiomux       = { 2, 0, 0, 0, 10},
2145         .needs_tvaudio  = 0,
2146         .pll            = PLL_28,
2147         .tuner_type     = TUNER_PHILIPS_PAL,
2148         .has_remote     = 1,   /* miniremote works, see ir-kbd-gpio.c */
2149         .has_radio      = 1,   /* not every card has radio */
2150 }};
2151
2152 const unsigned int bttv_num_tvcards = ARRAY_SIZE(bttv_tvcards);
2153
2154 /* ----------------------------------------------------------------------- */
2155
2156 static unsigned char eeprom_data[256];
2157
2158 /*
2159  * identify card
2160  */
2161 void __devinit bttv_idcard(struct bttv *btv)
2162 {
2163         unsigned int gpiobits;
2164         int i,type;
2165         unsigned short tmp;
2166
2167         /* read PCI subsystem ID */
2168         pci_read_config_word(btv->c.pci, PCI_SUBSYSTEM_ID, &tmp);
2169         btv->cardid = tmp << 16;
2170         pci_read_config_word(btv->c.pci, PCI_SUBSYSTEM_VENDOR_ID, &tmp);
2171         btv->cardid |= tmp;
2172
2173         if (0 != btv->cardid && 0xffffffff != btv->cardid) {
2174                 /* look for the card */
2175                 for (type = -1, i = 0; cards[i].id != 0; i++)
2176                         if (cards[i].id  == btv->cardid)
2177                                 type = i;
2178                 
2179                 if (type != -1) {
2180                         /* found it */
2181                         printk(KERN_INFO "bttv%d: detected: %s [card=%d], "
2182                                "PCI subsystem ID is %04x:%04x\n",
2183                                btv->c.nr,cards[type].name,cards[type].cardnr,
2184                                btv->cardid & 0xffff,
2185                                (btv->cardid >> 16) & 0xffff);
2186                         btv->c.type = cards[type].cardnr;
2187                 } else {
2188                         /* 404 */
2189                         printk(KERN_INFO "bttv%d: subsystem: %04x:%04x (UNKNOWN)\n",
2190                                btv->c.nr, btv->cardid & 0xffff,
2191                                (btv->cardid >> 16) & 0xffff);
2192                         printk(KERN_DEBUG "please mail id, board name and "
2193                                "the correct card= insmod option to kraxel@bytesex.org\n");
2194                 }
2195         } 
2196
2197         /* let the user override the autodetected type */
2198         if (card[btv->c.nr] < bttv_num_tvcards)
2199                 btv->c.type=card[btv->c.nr];
2200         
2201         /* print which card config we are using */
2202         printk(KERN_INFO "bttv%d: using: %s [card=%d,%s]\n",btv->c.nr,
2203                bttv_tvcards[btv->c.type].name, btv->c.type,
2204                card[btv->c.nr] < bttv_num_tvcards
2205                ? "insmod option" : "autodetected");
2206
2207         /* overwrite gpio stuff ?? */
2208         if (UNSET == audioall && UNSET == audiomux[0])
2209                 return;
2210
2211         if (UNSET != audiomux[0]) {
2212                 gpiobits = 0;
2213                 for (i = 0; i < 5; i++) {
2214                         bttv_tvcards[btv->c.type].audiomux[i] = audiomux[i];
2215                         gpiobits |= audiomux[i];
2216                 }
2217         } else {
2218                 gpiobits = audioall;
2219                 for (i = 0; i < 5; i++) {
2220                         bttv_tvcards[btv->c.type].audiomux[i] = audioall;
2221                 }
2222         }
2223         bttv_tvcards[btv->c.type].gpiomask = (UNSET != gpiomask) ? gpiomask : gpiobits;
2224         printk(KERN_INFO "bttv%d: gpio config override: mask=0x%x, mux=",
2225                btv->c.nr,bttv_tvcards[btv->c.type].gpiomask);
2226         for (i = 0; i < 5; i++) {
2227                 printk("%s0x%x", i ? "," : "", bttv_tvcards[btv->c.type].audiomux[i]);
2228         }
2229         printk("\n");
2230 }
2231
2232 /*
2233  * (most) board specific initialisations goes here
2234  */
2235
2236 /* Some Modular Technology cards have an eeprom, but no subsystem ID */
2237 void identify_by_eeprom(struct bttv *btv, unsigned char eeprom_data[256])
2238 {
2239         int type = -1;
2240         
2241         if (0 == strncmp(eeprom_data,"GET MM20xPCTV",13))
2242                 type = BTTV_MODTEC_205;
2243         else if (0 == strncmp(eeprom_data+20,"Picolo",7))
2244                 type = BTTV_EURESYS_PICOLO;
2245         else if (eeprom_data[0] == 0x84 && eeprom_data[2]== 0)
2246                 type = BTTV_HAUPPAUGE; /* old bt848 */
2247
2248         if (-1 != type) {
2249                 btv->c.type = type;
2250                 printk("bttv%d: detected by eeprom: %s [card=%d]\n",
2251                        btv->c.nr, bttv_tvcards[btv->c.type].name, btv->c.type);
2252         }
2253 }
2254
2255 static void flyvideo_gpio(struct bttv *btv)
2256
2257         int gpio,has_remote,has_radio,is_capture_only,is_lr90,has_tda9820_tda9821;
2258         int tuner=-1,ttype;
2259
2260         gpio_inout(0xffffff, 0);
2261         udelay(8);  // without this we would see the 0x1800 mask
2262         gpio = gpio_read();
2263         /* FIXME: must restore OUR_EN ??? */
2264
2265         // all cards provide GPIO info, some have an additional eeprom
2266         // LR50: GPIO coding can be found lower right CP1 .. CP9
2267         //       CP9=GPIO23 .. CP1=GPIO15; when OPEN, the corresponding GPIO reads 1.
2268         //       GPIO14-12: n.c.
2269         // LR90: GP9=GPIO23 .. GP1=GPIO15 (right above the bt878)
2270         
2271         // lowest 3 bytes are remote control codes (no handshake needed)
2272         // xxxFFF: No remote control chip soldered
2273         // xxxF00(LR26/LR50), xxxFE0(LR90): Remote control chip (LVA001 or CF45) soldered 
2274         // Note: Some bits are Audio_Mask !
2275
2276         ttype=(gpio&0x0f0000)>>16;
2277         switch(ttype) {
2278         case 0x0: tuner=2; // NTSC, e.g. TPI8NSR11P
2279                 break;
2280         case 0x2: tuner=39;// LG NTSC (newer TAPC series) TAPC-H701P
2281                 break;
2282         case 0x4: tuner=5; // Philips PAL TPI8PSB02P, TPI8PSB12P, TPI8PSB12D or FI1216, FM1216
2283                 break;
2284         case 0x6: tuner=37; // LG PAL (newer TAPC series) TAPC-G702P
2285                 break;
2286         case 0xC: tuner=3; // Philips SECAM(+PAL) FQ1216ME or FI1216MF
2287                 break;
2288         default:
2289                 printk(KERN_INFO "bttv%d: FlyVideo_gpio: unknown tuner type.\n", btv->c.nr);
2290         }
2291
2292         has_remote          =   gpio & 0x800000;
2293         has_radio           =   gpio & 0x400000;
2294         //   unknown                   0x200000;
2295         //   unknown2                  0x100000;
2296         is_capture_only     = !(gpio & 0x008000); //GPIO15
2297         has_tda9820_tda9821 = !(gpio & 0x004000);
2298         is_lr90             = !(gpio & 0x002000); // else LR26/LR50 (LR38/LR51 f. capture only)
2299         //                      gpio & 0x001000 // output bit for audio routing
2300
2301         if(is_capture_only) 
2302                 tuner=4; // No tuner present 
2303
2304         printk(KERN_INFO "bttv%d: FlyVideo Radio=%s RemoteControl=%s Tuner=%d gpio=0x%06x\n", 
2305                btv->c.nr, has_radio? "yes":"no ", has_remote? "yes":"no ", tuner, gpio); 
2306         printk(KERN_INFO "bttv%d: FlyVideo  LR90=%s tda9821/tda9820=%s capture_only=%s\n",
2307                 btv->c.nr, is_lr90?"yes":"no ", has_tda9820_tda9821?"yes":"no ", 
2308                 is_capture_only?"yes":"no ");
2309
2310         if(tuner!= -1) // only set if known tuner autodetected, else let insmod option through
2311                 btv->tuner_type = tuner;
2312         btv->has_radio = has_radio;  
2313
2314         // LR90 Audio Routing is done by 2 hef4052, so Audio_Mask has 4 bits: 0x001c80
2315         // LR26/LR50 only has 1 hef4052, Audio_Mask 0x000c00
2316         // Audio options: from tuner, from tda9821/tda9821(mono,stereo,sap), from tda9874, ext., mute
2317         if(has_tda9820_tda9821) btv->audio_hook = lt9415_audio;
2318         //todo: if(has_tda9874) btv->audio_hook = fv2000s_audio;
2319 }
2320
2321 int miro_tunermap[] = { 0,6,2,3,   4,5,6,0,  3,0,4,5,  5,2,16,1,
2322                         14,2,17,1, 4,1,4,3,  1,2,16,1, 4,4,4,4 };
2323 int miro_fmtuner[]  = { 0,0,0,0,   0,0,0,0,  0,0,0,0,  0,0,0,1,
2324                         1,1,1,1,   1,1,1,0,  0,0,0,0,  0,1,0,0 };
2325
2326 static void miro_pinnacle_gpio(struct bttv *btv)
2327 {
2328         int id,msp,gpio;
2329         char *info;
2330
2331         gpio_inout(0xffffff, 0);
2332         gpio = gpio_read();
2333         id   = ((gpio>>10) & 63) -1;
2334         msp  = bttv_I2CRead(btv, I2C_MSP3400, "MSP34xx");
2335         if (id < 32) {
2336                 btv->tuner_type = miro_tunermap[id];
2337                 if (0 == (gpio & 0x20)) {
2338                         btv->has_radio = 1;
2339                         if (!miro_fmtuner[id]) {
2340                                 btv->has_matchbox = 1;
2341                                 btv->mbox_we    = (1<<6);
2342                                 btv->mbox_most  = (1<<7);
2343                                 btv->mbox_clk   = (1<<8);
2344                                 btv->mbox_data  = (1<<9);
2345                                 btv->mbox_mask  = (1<<6)|(1<<7)|(1<<8)|(1<<9);
2346                         }
2347                 } else {
2348                         btv->has_radio = 0;
2349                 }
2350                 if (-1 != msp) {
2351                         if (btv->c.type == BTTV_MIRO)
2352                                 btv->c.type = BTTV_MIROPRO;
2353                         if (btv->c.type == BTTV_PINNACLE)
2354                                 btv->c.type = BTTV_PINNACLEPRO;
2355                 }
2356                 printk(KERN_INFO
2357                        "bttv%d: miro: id=%d tuner=%d radio=%s stereo=%s\n",
2358                        btv->c.nr, id+1, btv->tuner_type,
2359                        !btv->has_radio ? "no" :
2360                        (btv->has_matchbox ? "matchbox" : "fmtuner"),
2361                        (-1 == msp) ? "no" : "yes");
2362         } else {
2363                 /* new cards with microtune tuner */
2364                 id = 63 - id;
2365                 btv->has_radio = 0;
2366                 switch (id) {
2367                 case 1:
2368                         info = "PAL / mono";
2369                         break;
2370                 case 2:
2371                         info = "PAL+SECAM / stereo";
2372                         btv->has_radio = 1;
2373                         break;
2374                 case 3:
2375                         info = "NTSC / stereo";
2376                         btv->has_radio = 1;
2377                         break;
2378                 case 4:
2379                         info = "PAL+SECAM / mono";
2380                         break;
2381                 case 5:
2382                         info = "NTSC / mono";
2383                         break;
2384                 case 6:
2385                         info = "NTSC / stereo";
2386                         break;
2387                 case 7:
2388                         info = "PAL / stereo";
2389                         break;
2390                 default:
2391                         info = "oops: unknown card";
2392                         break;
2393                 }
2394                 if (-1 != msp)
2395                         btv->c.type = BTTV_PINNACLEPRO;
2396                 printk(KERN_INFO
2397                        "bttv%d: pinnacle/mt: id=%d info=\"%s\" radio=%s\n",
2398                        btv->c.nr, id, info, btv->has_radio ? "yes" : "no");
2399                 btv->tuner_type  = 33;
2400                 btv->pinnacle_id = id;
2401         }
2402 }
2403
2404 /* GPIO21   L: Buffer aktiv, H: Buffer inaktiv */
2405 #define LM1882_SYNC_DRIVE     0x200000L
2406
2407 static void init_ids_eagle(struct bttv *btv)
2408 {
2409         gpio_inout(0xffffff,0xFFFF37);
2410         gpio_write(0x200020);
2411         
2412         /* flash strobe inverter ?! */
2413         gpio_write(0x200024);
2414         
2415         /* switch sync drive off */
2416         gpio_bits(LM1882_SYNC_DRIVE,LM1882_SYNC_DRIVE);
2417         
2418         /* set BT848 muxel to 2 */
2419         btaor((2)<<5, ~(2<<5), BT848_IFORM);
2420 }
2421
2422 /* Muxsel helper for the IDS Eagle.
2423  * the eagles does not use the standard muxsel-bits but
2424  * has its own multiplexer */
2425 static void eagle_muxsel(struct bttv *btv, unsigned int input)
2426 {
2427         btaor((2)<<5, ~(3<<5), BT848_IFORM);
2428         gpio_bits(3,bttv_tvcards[btv->c.type].muxsel[input&7]);
2429
2430 #if 0
2431        /* svhs */
2432        /* wake chroma ADC */
2433        btand(~BT848_ADC_C_SLEEP, BT848_ADC);
2434        /* set to YC video */
2435        btor(BT848_CONTROL_COMP, BT848_E_CONTROL);
2436        btor(BT848_CONTROL_COMP, BT848_O_CONTROL);
2437 #else
2438        /* composite */
2439        /* set chroma ADC to sleep */
2440        btor(BT848_ADC_C_SLEEP, BT848_ADC);
2441        /* set to composite video */
2442        btand(~BT848_CONTROL_COMP, BT848_E_CONTROL);
2443        btand(~BT848_CONTROL_COMP, BT848_O_CONTROL);
2444 #endif
2445
2446        /* switch sync drive off */
2447        gpio_bits(LM1882_SYNC_DRIVE,LM1882_SYNC_DRIVE);
2448 }
2449
2450 static void gvc1100_muxsel(struct bttv *btv, unsigned int input)
2451 {
2452         static const int masks[] = {0x30, 0x01, 0x12, 0x23};
2453         gpio_write(masks[input%4]);
2454 }
2455
2456 /* LMLBT4x initialization - to allow access to GPIO bits for sensors input and
2457    alarms output
2458
2459    GPIObit    | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
2460    assignment | TI | O3|INx| O2| O1|IN4|IN3|IN2|IN1|   |   |
2461
2462    IN - sensor inputs, INx - sensor inputs and TI XORed together
2463    O1,O2,O3 - alarm outputs (relays)
2464
2465    OUT ENABLE   1    1   0  . 1  1   0   0 . 0   0   0    0   = 0x6C0
2466
2467 */
2468
2469 static void init_lmlbt4x(struct bttv *btv)
2470 {
2471         printk(KERN_DEBUG "LMLBT4x init\n");
2472         btwrite(0x000000, BT848_GPIO_REG_INP);
2473         gpio_inout(0xffffff, 0x0006C0);
2474         gpio_write(0x000000);
2475 }
2476
2477 static void sigmaSQ_muxsel(struct bttv *btv, unsigned int input)
2478 {
2479         unsigned int inmux = input % 8;
2480         gpio_inout( 0xf, 0xf );
2481         gpio_bits( 0xf, inmux );
2482 }
2483
2484 static void sigmaSLC_muxsel(struct bttv *btv, unsigned int input)
2485 {
2486         unsigned int inmux = input % 4;
2487         gpio_inout( 3<<9, 3<<9 );
2488         gpio_bits( 3<<9, inmux<<9 );
2489 }
2490
2491 /* ----------------------------------------------------------------------- */
2492
2493 void bttv_reset_audio(struct bttv *btv)
2494 {
2495         /*
2496          * BT878A has a audio-reset register.
2497          * 1. This register is an audio reset function but it is in
2498          *    function-0 (video capture) address space.
2499          * 2. It is enough to do this once per power-up of the card.
2500          * 3. There is a typo in the Conexant doc -- it is not at
2501          *    0x5B, but at 0x058. (B is an odd-number, obviously a typo!).
2502          * --//Shrikumar 030609
2503          */
2504         if (btv->id != 878)
2505                 return;
2506         
2507         if (bttv_debug)
2508                 printk("bttv%d: BT878A ARESET\n",btv->c.nr);
2509         btwrite((1<<7), 0x058);
2510         udelay(10);
2511         btwrite(     0, 0x058);
2512 }
2513
2514 /* initialization part one -- before registering i2c bus */
2515 void __devinit bttv_init_card1(struct bttv *btv)
2516 {
2517         switch (btv->c.type) {
2518         case BTTV_HAUPPAUGE:
2519         case BTTV_HAUPPAUGE878:
2520                 boot_msp34xx(btv,5);
2521                 break;
2522         case BTTV_VOODOOTV_FM:
2523                 boot_msp34xx(btv,20);
2524                 break;
2525         case BTTV_AVERMEDIA98:
2526                 boot_msp34xx(btv,11);
2527                 break;
2528         case BTTV_HAUPPAUGEPVR:
2529                 pvr_boot(btv);
2530                 break;
2531         case BTTV_TWINHAN_DST:
2532         case BTTV_AVDVBT_771:
2533                 btv->use_i2c_hw = 1;
2534                 break;
2535         }
2536 }
2537
2538 /* initialization part two -- after registering i2c bus */
2539 void __devinit bttv_init_card2(struct bttv *btv)
2540 {
2541         btv->tuner_type = -1;
2542
2543         if (BTTV_UNKNOWN == btv->c.type) {
2544                 bttv_readee(btv,eeprom_data,0xa0);
2545                 identify_by_eeprom(btv,eeprom_data);
2546         }
2547
2548         switch (btv->c.type) {
2549         case BTTV_MIRO:
2550         case BTTV_MIROPRO:
2551         case BTTV_PINNACLE:
2552         case BTTV_PINNACLEPRO: 
2553                 /* miro/pinnacle */
2554                 miro_pinnacle_gpio(btv);
2555                 break;
2556         case BTTV_FLYVIDEO_98:
2557         case BTTV_MAXI:
2558         case BTTV_LIFE_FLYKIT:
2559         case BTTV_FLYVIDEO:
2560         case BTTV_TYPHOON_TVIEW:
2561         case BTTV_CHRONOS_VS2:
2562         case BTTV_FLYVIDEO_98FM:
2563         case BTTV_FLYVIDEO2000:
2564         case BTTV_FLYVIDEO98EZ:
2565         case BTTV_CONFERENCETV:
2566         case BTTV_LIFETEC_9415:
2567                 flyvideo_gpio(btv);
2568                 break;
2569         case BTTV_HAUPPAUGE:
2570         case BTTV_HAUPPAUGE878:
2571         case BTTV_HAUPPAUGEPVR:
2572                 /* pick up some config infos from the eeprom */
2573                 bttv_readee(btv,eeprom_data,0xa0);
2574                 hauppauge_eeprom(btv);
2575                 break;
2576         case BTTV_AVERMEDIA98:
2577         case BTTV_AVPHONE98:
2578                 bttv_readee(btv,eeprom_data,0xa0);
2579                 avermedia_eeprom(btv);
2580                 break;
2581         case BTTV_PXC200:
2582                 init_PXC200(btv);
2583                 break;
2584         case BTTV_PICOLO_TETRA_CHIP:
2585                 picolo_tetra_init(btv);
2586                 break;
2587         case BTTV_VHX:
2588                 btv->has_radio    = 1;
2589                 btv->has_matchbox = 1;
2590                 btv->mbox_we      = 0x20;
2591                 btv->mbox_most    = 0;
2592                 btv->mbox_clk     = 0x08;
2593                 btv->mbox_data    = 0x10;
2594                 btv->mbox_mask    = 0x38;
2595                 break;
2596         case BTTV_VOBIS_BOOSTAR:
2597         case BTTV_TERRATV:
2598                 terratec_active_radio_upgrade(btv);
2599                 break;
2600         case BTTV_MAGICTVIEW061:
2601                 if (btv->cardid == 0x3002144f) {
2602                         btv->has_radio=1;
2603                         printk("bttv%d: radio detected by subsystem id (CPH05x)\n",btv->c.nr);
2604                 }
2605                 break;
2606        case BTTV_STB2:
2607                 if (btv->cardid == 0x3060121a) {
2608                         /* Fix up entry for 3DFX VoodooTV 100,
2609                            which is an OEM STB card variant. */
2610                         btv->has_radio=0;
2611                         btv->tuner_type=TUNER_TEMIC_NTSC;
2612                 }
2613                 break;
2614         case BTTV_OSPREY1x0:
2615         case BTTV_OSPREY1x0_848:
2616         case BTTV_OSPREY101_848:
2617         case BTTV_OSPREY1x1:
2618         case BTTV_OSPREY1x1_SVID:
2619         case BTTV_OSPREY2xx:
2620         case BTTV_OSPREY2x0_SVID:
2621         case BTTV_OSPREY2x0:
2622         case BTTV_OSPREY500:
2623         case BTTV_OSPREY540:
2624         case BTTV_OSPREY2000:
2625                 bttv_readee(btv,eeprom_data,0xa0);
2626                 osprey_eeprom(btv);
2627                 break;
2628         case BTTV_IDS_EAGLE:
2629                 init_ids_eagle(btv);
2630                 break;
2631         case BTTV_MODTEC_205:
2632                 bttv_readee(btv,eeprom_data,0xa0);
2633                 modtec_eeprom(btv);
2634                 break;
2635         case BTTV_LMLBT4:
2636                 init_lmlbt4x(btv);
2637                 break;
2638         }
2639
2640         /* pll configuration */
2641         if (!(btv->id==848 && btv->revision==0x11)) {
2642                 /* defaults from card list */
2643                 if (PLL_28 == bttv_tvcards[btv->c.type].pll) {
2644                         btv->pll.pll_ifreq=28636363;
2645                         btv->pll.pll_crystal=BT848_IFORM_XT0;
2646                 }
2647                 if (PLL_35 == bttv_tvcards[btv->c.type].pll) {
2648                         btv->pll.pll_ifreq=35468950;
2649                         btv->pll.pll_crystal=BT848_IFORM_XT1;
2650                 }
2651                 /* insmod options can override */
2652                 switch (pll[btv->c.nr]) {
2653                 case 0: /* none */
2654                         btv->pll.pll_crystal = 0;
2655                         btv->pll.pll_ifreq   = 0;
2656                         btv->pll.pll_ofreq   = 0;
2657                         break;
2658                 case 1: /* 28 MHz */
2659                 case 28:
2660                         btv->pll.pll_ifreq   = 28636363;
2661                         btv->pll.pll_ofreq   = 0;
2662                         btv->pll.pll_crystal = BT848_IFORM_XT0;
2663                         break;
2664                 case 2: /* 35 MHz */
2665                 case 35:
2666                         btv->pll.pll_ifreq   = 35468950;
2667                         btv->pll.pll_ofreq   = 0;
2668                         btv->pll.pll_crystal = BT848_IFORM_XT1;
2669                         break;
2670                 }
2671         }
2672         btv->pll.pll_current = -1;
2673
2674         /* tuner configuration (from card list / autodetect / insmod option) */
2675         if (UNSET != bttv_tvcards[btv->c.type].tuner_type)
2676                 if(UNSET == btv->tuner_type) 
2677                         btv->tuner_type = bttv_tvcards[btv->c.type].tuner_type;
2678         if (UNSET != tuner[btv->c.nr])
2679                 btv->tuner_type = tuner[btv->c.nr];
2680         printk("bttv%d: using tuner=%d\n",btv->c.nr,btv->tuner_type);
2681         if (btv->pinnacle_id != UNSET)
2682                 bttv_call_i2c_clients(btv,AUDC_CONFIG_PINNACLE,
2683                                       &btv->pinnacle_id);
2684         if (btv->tuner_type != UNSET)
2685                 bttv_call_i2c_clients(btv,TUNER_SET_TYPE,&btv->tuner_type);
2686         btv->svhs = bttv_tvcards[btv->c.type].svhs;
2687         if (svhs[btv->c.nr] != UNSET)
2688                 btv->svhs = svhs[btv->c.nr];
2689         if (remote[btv->c.nr] != UNSET)
2690                 btv->has_remote = remote[btv->c.nr];
2691
2692         if (bttv_tvcards[btv->c.type].has_radio)
2693                 btv->has_radio=1;
2694         if (bttv_tvcards[btv->c.type].has_remote)
2695                 btv->has_remote=1;
2696         if (bttv_tvcards[btv->c.type].no_gpioirq)
2697                 btv->gpioirq=0;
2698         if (bttv_tvcards[btv->c.type].audio_hook)
2699                 btv->audio_hook=bttv_tvcards[btv->c.type].audio_hook;
2700
2701         if (bttv_tvcards[btv->c.type].digital_mode == DIGITAL_MODE_CAMERA) {
2702                 /* detect Bt832 chip for quartzsight digital camera */
2703                 if ((bttv_I2CRead(btv, I2C_BT832_ALT1, "Bt832") >=0) ||
2704                     (bttv_I2CRead(btv, I2C_BT832_ALT2, "Bt832") >=0))
2705                         boot_bt832(btv);
2706         }
2707
2708         /* try to detect audio/fader chips */
2709         if (!bttv_tvcards[btv->c.type].no_msp34xx &&
2710             bttv_I2CRead(btv, I2C_MSP3400, "MSP34xx") >=0) {
2711                 if (autoload)
2712                         request_module("msp3400");
2713         }
2714
2715         if (bttv_tvcards[btv->c.type].msp34xx_alt &&
2716             bttv_I2CRead(btv, I2C_MSP3400_ALT, "MSP34xx (alternate address)") >=0) {
2717                 if (autoload)
2718                         request_module("msp3400");
2719         }
2720
2721         if (!bttv_tvcards[btv->c.type].no_tda9875 &&
2722             bttv_I2CRead(btv, I2C_TDA9875, "TDA9875") >=0) {
2723                 if (autoload)
2724                         request_module("tda9875");
2725         }
2726
2727         if (!bttv_tvcards[btv->c.type].no_tda7432 && 
2728             bttv_I2CRead(btv, I2C_TDA7432, "TDA7432") >=0) {
2729                 if (autoload)
2730                         request_module("tda7432");
2731         }
2732
2733         if (bttv_tvcards[btv->c.type].needs_tvaudio) {
2734                 if (autoload)
2735                         request_module("tvaudio");
2736         }
2737
2738         /* tuner modules */
2739         if (btv->pinnacle_id != UNSET) {
2740                 if (autoload)
2741                         request_module("tda9887");
2742         }
2743         if (btv->tuner_type != UNSET) {
2744                 if (autoload)
2745                         request_module("tuner");
2746         }
2747 }
2748
2749
2750 /* ----------------------------------------------------------------------- */
2751 /* some hauppauge specific stuff                                           */
2752
2753 static struct HAUPPAUGE_TUNER 
2754 {
2755         int  id;
2756         char *name;
2757
2758 hauppauge_tuner[] __devinitdata = 
2759 {
2760         { TUNER_ABSENT,        "" },
2761         { TUNER_ABSENT,        "External" },
2762         { TUNER_ABSENT,        "Unspecified" },
2763         { TUNER_PHILIPS_PAL,   "Philips FI1216" },
2764         { TUNER_PHILIPS_SECAM, "Philips FI1216MF" },
2765         { TUNER_PHILIPS_NTSC,  "Philips FI1236" },
2766         { TUNER_PHILIPS_PAL_I, "Philips FI1246" },
2767         { TUNER_PHILIPS_PAL_DK,"Philips FI1256" },
2768         { TUNER_PHILIPS_PAL,   "Philips FI1216 MK2" },
2769         { TUNER_PHILIPS_SECAM, "Philips FI1216MF MK2" },
2770         { TUNER_PHILIPS_NTSC,  "Philips FI1236 MK2" },
2771         { TUNER_PHILIPS_PAL_I, "Philips FI1246 MK2" },
2772         { TUNER_PHILIPS_PAL_DK,"Philips FI1256 MK2" },
2773         { TUNER_TEMIC_NTSC,    "Temic 4032FY5" },
2774         { TUNER_TEMIC_PAL,     "Temic 4002FH5" },
2775         { TUNER_TEMIC_PAL_I,   "Temic 4062FY5" },
2776         { TUNER_PHILIPS_PAL,   "Philips FR1216 MK2" },
2777         { TUNER_PHILIPS_SECAM, "Philips FR1216MF MK2" },
2778         { TUNER_PHILIPS_NTSC,  "Philips FR1236 MK2" },
2779         { TUNER_PHILIPS_PAL_I, "Philips FR1246 MK2" },
2780         { TUNER_PHILIPS_PAL_DK,"Philips FR1256 MK2" },
2781         { TUNER_PHILIPS_PAL,   "Philips FM1216" },
2782         { TUNER_PHILIPS_SECAM, "Philips FM1216MF" },
2783         { TUNER_PHILIPS_NTSC,  "Philips FM1236" },
2784         { TUNER_PHILIPS_PAL_I, "Philips FM1246" },
2785         { TUNER_PHILIPS_PAL_DK,"Philips FM1256" },
2786         { TUNER_TEMIC_4036FY5_NTSC, "Temic 4036FY5" },
2787         { TUNER_ABSENT,        "Samsung TCPN9082D" },
2788         { TUNER_ABSENT,        "Samsung TCPM9092P" },
2789         { TUNER_TEMIC_4006FH5_PAL, "Temic 4006FH5" },
2790         { TUNER_ABSENT,        "Samsung TCPN9085D" },
2791         { TUNER_ABSENT,        "Samsung TCPB9085P" },
2792         { TUNER_ABSENT,        "Samsung TCPL9091P" },
2793         { TUNER_TEMIC_4039FR5_NTSC, "Temic 4039FR5" },
2794         { TUNER_PHILIPS_FQ1216ME,   "Philips FQ1216 ME" },
2795         { TUNER_TEMIC_4066FY5_PAL_I, "Temic 4066FY5" },
2796         { TUNER_PHILIPS_NTSC,        "Philips TD1536" },
2797         { TUNER_PHILIPS_NTSC,        "Philips TD1536D" },
2798         { TUNER_PHILIPS_NTSC,  "Philips FMR1236" }, /* mono radio */
2799         { TUNER_ABSENT,        "Philips FI1256MP" },
2800         { TUNER_ABSENT,        "Samsung TCPQ9091P" },
2801         { TUNER_TEMIC_4006FN5_MULTI_PAL, "Temic 4006FN5" },
2802         { TUNER_TEMIC_4009FR5_PAL, "Temic 4009FR5" },
2803         { TUNER_TEMIC_4046FM5,     "Temic 4046FM5" },
2804         { TUNER_TEMIC_4009FN5_MULTI_PAL_FM, "Temic 4009FN5" },
2805         { TUNER_ABSENT,        "Philips TD1536D_FH_44"},
2806         { TUNER_LG_NTSC_FM,    "LG TPI8NSR01F"},
2807         { TUNER_LG_PAL_FM,     "LG TPI8PSB01D"},
2808         { TUNER_LG_PAL,        "LG TPI8PSB11D"},        
2809         { TUNER_LG_PAL_I_FM,   "LG TAPC-I001D"},
2810         { TUNER_LG_PAL_I,      "LG TAPC-I701D"}
2811 };
2812
2813 static void modtec_eeprom(struct bttv *btv)
2814 {
2815         if( strncmp(&(eeprom_data[0x1e]),"Temic 4066 FY5",14) ==0) {
2816                 btv->tuner_type=TUNER_TEMIC_4066FY5_PAL_I;
2817                 printk("bttv%d: Modtec: Tuner autodetected by eeprom: %s\n",
2818                        btv->c.nr,&eeprom_data[0x1e]);
2819         } else if (strncmp(&(eeprom_data[0x1e]),"Alps TSBB5",10) ==0) {
2820                 btv->tuner_type=TUNER_ALPS_TSBB5_PAL_I;
2821                 printk("bttv%d: Modtec: Tuner autodetected by eeprom: %s\n",
2822                        btv->c.nr,&eeprom_data[0x1e]);
2823         } else if (strncmp(&(eeprom_data[0x1e]),"Philips FM1246",14) ==0) {
2824                 btv->tuner_type=TUNER_PHILIPS_NTSC;
2825                 printk("bttv%d: Modtec: Tuner autodetected by eeprom: %s\n",
2826                        btv->c.nr,&eeprom_data[0x1e]);
2827         } else {
2828                 printk("bttv%d: Modtec: Unknown TunerString: %s\n",
2829                        btv->c.nr,&eeprom_data[0x1e]);
2830         }
2831 }
2832
2833 static void __devinit hauppauge_eeprom(struct bttv *btv)
2834 {
2835         unsigned int blk2,tuner,radio,model;
2836
2837         if (eeprom_data[0] != 0x84 || eeprom_data[2] != 0)
2838                 printk(KERN_WARNING "bttv%d: Hauppauge eeprom: invalid\n",
2839                        btv->c.nr);
2840
2841         /* Block 2 starts after len+3 bytes header */
2842         blk2 = eeprom_data[1] + 3;
2843
2844         /* decode + use some config infos */
2845         model = eeprom_data[12] << 8 | eeprom_data[11];
2846         tuner = eeprom_data[9];
2847         radio = eeprom_data[blk2-1] & 0x01;
2848         
2849         if (tuner < ARRAY_SIZE(hauppauge_tuner))
2850                 btv->tuner_type = hauppauge_tuner[tuner].id;
2851         if (radio)
2852                 btv->has_radio = 1;
2853         
2854         if (bttv_verbose)
2855                 printk(KERN_INFO "bttv%d: Hauppauge eeprom: model=%d, "
2856                        "tuner=%s (%d), radio=%s\n",
2857                        btv->c.nr, model, hauppauge_tuner[tuner].name,
2858                        btv->tuner_type, radio ? "yes" : "no");
2859 }
2860
2861 static int terratec_active_radio_upgrade(struct bttv *btv)
2862 {
2863         int freq;
2864
2865         btv->has_radio    = 1;
2866         btv->has_matchbox = 1;
2867         btv->mbox_we      = 0x10;
2868         btv->mbox_most    = 0x20;
2869         btv->mbox_clk     = 0x08;
2870         btv->mbox_data    = 0x04;
2871         btv->mbox_mask    = 0x3c;
2872
2873         btv->mbox_iow     = 1 <<  8;
2874         btv->mbox_ior     = 1 <<  9;
2875         btv->mbox_csel    = 1 << 10;
2876
2877         freq=88000/62.5;
2878         tea5757_write(btv, 5 * freq + 0x358); // write 0x1ed8
2879         if (0x1ed8 == tea5757_read(btv)) {
2880                 printk("bttv%d: Terratec Active Radio Upgrade found.\n",
2881                        btv->c.nr);
2882                 btv->has_radio    = 1;
2883                 btv->has_matchbox = 1;
2884         } else {
2885                 btv->has_radio    = 0;
2886                 btv->has_matchbox = 0;
2887         }
2888         return 0;
2889 }       
2890
2891
2892 /* ----------------------------------------------------------------------- */
2893
2894 /*
2895  * minimal bootstrap for the WinTV/PVR -- upload altera firmware.
2896  *
2897  * The hcwamc.rbf firmware file is on the Hauppauge driver CD.  Have
2898  * a look at Pvr/pvr45xxx.EXE (self-extracting zip archive, can be
2899  * unpacked with unzip).
2900  */
2901 #define PVR_GPIO_DELAY          10
2902
2903 #define BTTV_ALT_DATA           0x000001
2904 #define BTTV_ALT_DCLK           0x100000
2905 #define BTTV_ALT_NCONFIG        0x800000
2906
2907 static int __devinit pvr_altera_load(struct bttv *btv, u8 *micro, u32 microlen)
2908 {
2909         u32 n;
2910         u8 bits;
2911         int i;
2912
2913         gpio_inout(0xffffff,BTTV_ALT_DATA|BTTV_ALT_DCLK|BTTV_ALT_NCONFIG);
2914         gpio_write(0);
2915         udelay(PVR_GPIO_DELAY);
2916         
2917         gpio_write(BTTV_ALT_NCONFIG);
2918         udelay(PVR_GPIO_DELAY);
2919
2920         for (n = 0; n < microlen; n++) {
2921                 bits = micro[n];
2922                 for ( i = 0 ; i < 8 ; i++ ) {
2923                         gpio_bits(BTTV_ALT_DCLK,0);
2924                         if (bits & 0x01)
2925                                 gpio_bits(BTTV_ALT_DATA,BTTV_ALT_DATA);
2926                         else 
2927                                 gpio_bits(BTTV_ALT_DATA,0);
2928                         gpio_bits(BTTV_ALT_DCLK,BTTV_ALT_DCLK);
2929                         bits >>= 1;
2930                 }
2931         }
2932         gpio_bits(BTTV_ALT_DCLK,0);
2933         udelay(PVR_GPIO_DELAY);
2934         
2935         /* begin Altera init loop (Not necessary,but doesn't hurt) */
2936         for (i = 0 ; i < 30 ; i++) {
2937                 gpio_bits(BTTV_ALT_DCLK,0);
2938                 gpio_bits(BTTV_ALT_DCLK,BTTV_ALT_DCLK);
2939         }
2940         gpio_bits(BTTV_ALT_DCLK,0);
2941         return 0;
2942 }
2943
2944 #if !defined(CONFIG_FW_LOADER) && !defined(CONFIG_FW_LOADER_MODULE)
2945 /* old 2.4.x way -- via soundcore's mod_firmware_load */
2946    
2947 static char *firm_altera = "/usr/lib/video4linux/hcwamc.rbf";
2948 MODULE_PARM(firm_altera,"s");
2949 MODULE_PARM_DESC(firm_altera,"WinTV/PVR firmware "
2950                  "(driver CD => unzip pvr45xxx.exe => hcwamc.rbf)");
2951
2952 extern int mod_firmware_load(const char *fn, char **fp);
2953
2954 int __devinit pvr_boot(struct bttv *btv)
2955 {
2956         u32 microlen;
2957         u8 *micro;
2958         int result;
2959
2960         microlen = mod_firmware_load(firm_altera, (char**) &micro);
2961         if (!microlen) {
2962                 printk(KERN_WARNING "bttv%d: altera firmware not found [%s]\n",
2963                        btv->c.nr, firm_altera);
2964                 return -1;
2965         }
2966         
2967         printk(KERN_INFO "bttv%d: uploading altera firmware [%s] ...\n",
2968                btv->c.nr, firm_altera);
2969         result = pvr_altera_load(btv, micro, microlen);
2970         printk(KERN_INFO "bttv%d: ... upload %s\n",
2971                btv->c.nr, (result < 0) ? "failed" : "ok");
2972         vfree(micro);
2973         return result;
2974 }
2975 #else
2976 /* new 2.5.x way -- via hotplug firmware loader */
2977
2978 int __devinit pvr_boot(struct bttv *btv)
2979 {
2980         const struct firmware *fw_entry;
2981         int rc;
2982
2983         rc = request_firmware(&fw_entry, "hcwamc.rbf", &btv->c.pci->dev);
2984         if (rc != 0) {
2985                 printk(KERN_WARNING "bttv%d: no altera firmware [via hotplug]\n",
2986                        btv->c.nr);
2987                 return rc;
2988         }
2989         rc = pvr_altera_load(btv, fw_entry->data, fw_entry->size);
2990         printk(KERN_INFO "bttv%d: altera firmware upload %s\n",
2991                btv->c.nr, (rc < 0) ? "failed" : "ok");
2992         release_firmware(fw_entry);
2993         return rc;
2994 }       
2995 #endif
2996
2997 /* ----------------------------------------------------------------------- */
2998 /* some osprey specific stuff                                              */
2999
3000 static void __devinit osprey_eeprom(struct bttv *btv)
3001 {
3002        int i = 0;
3003        unsigned char *ee = eeprom_data;
3004        unsigned long serial = 0;
3005     
3006        if (btv->c.type == 0) {
3007                /* this might be an antique... check for MMAC label in eeprom */
3008                if ((ee[0]=='M') && (ee[1]=='M') && (ee[2]=='A') && (ee[3]=='C')) {
3009                        unsigned char checksum = 0;
3010                        for (i =0; i<21; i++)
3011                                checksum += ee[i];
3012                        if (checksum != ee[21])
3013                                return;
3014                        btv->c.type = BTTV_OSPREY1x0_848;
3015                        for (i = 12; i < 21; i++)
3016                                serial *= 10, serial += ee[i] - '0';
3017                }
3018        } else {
3019                unsigned short type;
3020                int offset = 4*16;
3021         
3022                for(; offset < 8*16; offset += 16) {
3023                        unsigned short checksum = 0;
3024                        /* verify the checksum */
3025                        for(i = 0; i<14; i++) checksum += ee[i+offset];
3026                                checksum = ~checksum;  /* no idea why */
3027                                if ((((checksum>>8)&0x0FF) == ee[offset+14]) &&
3028                                    ((checksum & 0x0FF) == ee[offset+15])) {
3029                                break;
3030                        }
3031                }
3032         
3033                if (offset >= 8*16)
3034                        return;
3035
3036                /* found a valid descriptor */
3037                type = (ee[offset+4]<<8) | (ee[offset+5]);
3038                
3039                switch(type) {
3040
3041                /* 848 based */
3042                case 0x0004:
3043                        btv->c.type = BTTV_OSPREY1x0_848;
3044                        break;
3045                case 0x0005:
3046                        btv->c.type = BTTV_OSPREY101_848;
3047                        break;
3048                        
3049                /* 878 based */
3050                case 0x0012:
3051                case 0x0013:
3052                        btv->c.type = BTTV_OSPREY1x0;
3053                        break;
3054                case 0x0014:
3055                case 0x0015:
3056                        btv->c.type = BTTV_OSPREY1x1;
3057                        break;
3058                case 0x0016:
3059                case 0x0017:
3060                case 0x0020:
3061                        btv->c.type = BTTV_OSPREY1x1_SVID;
3062                        break;
3063                case 0x0018:
3064                case 0x0019:
3065                case 0x001E:
3066                case 0x001F:
3067                        btv->c.type = BTTV_OSPREY2xx;
3068                        break;
3069                case 0x001A:
3070                case 0x001B:
3071                        btv->c.type = BTTV_OSPREY2x0_SVID;
3072                        break;
3073                case 0x0040:
3074                        btv->c.type = BTTV_OSPREY500;
3075                        break;
3076                case 0x0050:
3077                case 0x0056:
3078                        btv->c.type = BTTV_OSPREY540;
3079                        /* bttv_osprey_540_init(btv); */
3080                        break;
3081                case 0x0060:
3082                case 0x0070:
3083                        btv->c.type = BTTV_OSPREY2x0;
3084                        //enable output on select control lines
3085                        gpio_inout(0xffffff,0x000303);
3086                        break;
3087                default:
3088                        /* unknown...leave generic, but get serial # */
3089                        break;
3090                }
3091                serial =  (ee[offset+6] << 24)
3092                        | (ee[offset+7] << 16)
3093                        | (ee[offset+8] <<  8)
3094                        | (ee[offset+9]);
3095        }
3096        
3097        printk(KERN_INFO "bttv%d: osprey eeprom: card=%d name=%s serial=%ld\n",
3098               btv->c.nr, btv->c.type, bttv_tvcards[btv->c.type].name,serial);
3099 }       
3100
3101 /* ----------------------------------------------------------------------- */
3102 /* AVermedia specific stuff, from  bktr_card.c                             */
3103
3104 int tuner_0_table[] = {
3105         TUNER_PHILIPS_NTSC,  TUNER_PHILIPS_PAL /* PAL-BG*/,
3106         TUNER_PHILIPS_PAL,   TUNER_PHILIPS_PAL /* PAL-I*/,
3107         TUNER_PHILIPS_PAL,   TUNER_PHILIPS_PAL,
3108         TUNER_PHILIPS_SECAM, TUNER_PHILIPS_SECAM,
3109         TUNER_PHILIPS_SECAM, TUNER_PHILIPS_PAL};
3110 #if 0
3111 int tuner_0_fm_table[] = {
3112         PHILIPS_FR1236_NTSC,  PHILIPS_FR1216_PAL,
3113         PHILIPS_FR1216_PAL,   PHILIPS_FR1216_PAL,
3114         PHILIPS_FR1216_PAL,   PHILIPS_FR1216_PAL,
3115         PHILIPS_FR1236_SECAM, PHILIPS_FR1236_SECAM,
3116         PHILIPS_FR1236_SECAM, PHILIPS_FR1216_PAL};
3117 #endif
3118
3119 int tuner_1_table[] = {
3120         TUNER_TEMIC_NTSC,  TUNER_TEMIC_PAL,
3121         TUNER_TEMIC_PAL,   TUNER_TEMIC_PAL,
3122         TUNER_TEMIC_PAL,   TUNER_TEMIC_PAL,
3123         TUNER_TEMIC_4012FY5, TUNER_TEMIC_4012FY5, //TUNER_TEMIC_SECAM
3124         TUNER_TEMIC_4012FY5, TUNER_TEMIC_PAL};
3125
3126 static void __devinit avermedia_eeprom(struct bttv *btv)
3127 {
3128         int tuner_make,tuner_tv_fm,tuner_format,tuner=0;
3129
3130         tuner_make      = (eeprom_data[0x41] & 0x7);
3131         tuner_tv_fm     = (eeprom_data[0x41] & 0x18) >> 3;
3132         tuner_format    = (eeprom_data[0x42] & 0xf0) >> 4;
3133         btv->has_remote = (eeprom_data[0x42] & 0x01);
3134
3135         if (tuner_make == 0 || tuner_make == 2)
3136                 if(tuner_format <=9)
3137                         tuner = tuner_0_table[tuner_format];
3138         if (tuner_make == 1)
3139                 if(tuner_format <=9)
3140                         tuner = tuner_1_table[tuner_format];
3141         
3142         printk(KERN_INFO "bttv%d: Avermedia eeprom[0x%02x%02x]: tuner=",
3143                 btv->c.nr,eeprom_data[0x41],eeprom_data[0x42]);
3144         if(tuner) {
3145                 btv->tuner_type=tuner;
3146                 printk("%d",tuner);
3147         } else
3148                 printk("Unknown type");
3149         printk(" radio:%s remote control:%s\n",
3150                tuner_tv_fm     ? "yes" : "no",
3151                btv->has_remote ? "yes" : "no");
3152 }
3153
3154 /* used on Voodoo TV/FM (Voodoo 200), S0 wired to 0x10000 */
3155 void bttv_tda9880_setnorm(struct bttv *btv, int norm)
3156 {
3157         // fix up our card entry
3158         if(norm==VIDEO_MODE_NTSC) {
3159                 bttv_tvcards[BTTV_VOODOOTV_FM].audiomux[0]=0x957fff;
3160                 bttv_tvcards[BTTV_VOODOOTV_FM].audiomux[4]=0x957fff;
3161                 dprintk("bttv_tda9880_setnorm to NTSC\n");
3162         }
3163         else {
3164                 bttv_tvcards[BTTV_VOODOOTV_FM].audiomux[0]=0x947fff;
3165                 bttv_tvcards[BTTV_VOODOOTV_FM].audiomux[4]=0x947fff;
3166                 dprintk("bttv_tda9880_setnorm to PAL\n");
3167         }
3168         // set GPIO according
3169         gpio_bits(bttv_tvcards[btv->c.type].gpiomask,
3170                   bttv_tvcards[btv->c.type].audiomux[btv->audio]);
3171 }
3172
3173
3174 /*
3175  * reset/enable the MSP on some Hauppauge cards
3176  * Thanks to Kyösti Mälkki (kmalkki@cc.hut.fi)!
3177  *
3178  * Hauppauge:  pin  5
3179  * Voodoo:     pin 20
3180  */
3181 static void __devinit boot_msp34xx(struct bttv *btv, int pin)
3182 {
3183         int mask = (1 << pin);
3184
3185         gpio_inout(mask,mask);
3186         gpio_bits(mask,0);
3187         udelay(2500);
3188         gpio_bits(mask,mask);
3189
3190         if (bttv_gpio)
3191                 bttv_gpio_tracking(btv,"msp34xx");
3192         if (bttv_verbose)
3193                 printk(KERN_INFO "bttv%d: Hauppauge/Voodoo msp34xx: reset line "
3194                        "init [%d]\n", btv->c.nr, pin);
3195 }
3196
3197 static void __devinit boot_bt832(struct bttv *btv)
3198 {
3199         int resetbit=0;
3200
3201         switch (btv->c.type) {
3202         case BTTV_PXELVWPLTVPAK:
3203                 resetbit = 0x400000;
3204                 break;
3205         case BTTV_MODTEC_205:
3206                 resetbit = 1<<9;
3207                 break;
3208         default:
3209                 BUG();
3210         }
3211
3212         request_module("bt832");
3213         bttv_call_i2c_clients(btv, BT832_HEXDUMP, NULL);
3214
3215         printk("bttv%d: Reset Bt832 [line=0x%x]\n",btv->c.nr,resetbit);
3216         gpio_write(0);
3217         gpio_inout(resetbit, resetbit);
3218         udelay(5);
3219         gpio_bits(resetbit, resetbit);
3220         udelay(5);
3221         gpio_bits(resetbit, 0);
3222         udelay(5);
3223
3224         // bt832 on pixelview changes from i2c 0x8a to 0x88 after
3225         // being reset as above. So we must follow by this:
3226         bttv_call_i2c_clients(btv, BT832_REATTACH, NULL);
3227 }
3228
3229 /* ----------------------------------------------------------------------- */
3230 /*  Imagenation L-Model PXC200 Framegrabber */
3231 /*  This is basically the same procedure as 
3232  *  used by Alessandro Rubini in his pxc200 
3233  *  driver, but using BTTV functions */
3234
3235 static void __devinit init_PXC200(struct bttv *btv)
3236 {
3237         static int vals[] __devinitdata = { 0x08, 0x09, 0x0a, 0x0b, 0x0d, 0x0d,
3238                                             0x01, 0x02, 0x03, 0x04, 0x05, 0x06,
3239                                             0x00 };
3240         unsigned int i;
3241         int tmp;
3242         u32 val;
3243         
3244         /* Initialise GPIO-connevted stuff */
3245         gpio_inout(0xffffff, (1<<13));
3246         gpio_write(0);
3247         udelay(3);
3248         gpio_write(1<<13);
3249         /* GPIO inputs are pulled up, so no need to drive 
3250          * reset pin any longer */
3251         gpio_bits(0xffffff, 0);
3252         if (bttv_gpio)
3253                 bttv_gpio_tracking(btv,"pxc200");
3254
3255         /*  we could/should try and reset/control the AD pots? but
3256             right now  we simply  turned off the crushing.  Without
3257             this the AGC drifts drifts
3258             remember the EN is reverse logic -->
3259             setting BT848_ADC_AGC_EN disable the AGC
3260             tboult@eecs.lehigh.edu
3261         */
3262
3263         btwrite(BT848_ADC_RESERVED|BT848_ADC_AGC_EN, BT848_ADC);
3264         
3265         /*      Initialise MAX517 DAC */
3266         printk(KERN_INFO "Setting DAC reference voltage level ...\n");
3267         bttv_I2CWrite(btv,0x5E,0,0x80,1);
3268         
3269         /*      Initialise 12C508 PIC */
3270         /*      The I2CWrite and I2CRead commmands are actually to the 
3271          *      same chips - but the R/W bit is included in the address
3272          *      argument so the numbers are different */
3273         
3274
3275         printk(KERN_INFO "Initialising 12C508 PIC chip ...\n");
3276
3277         /* First of all, enable the clock line. This is used in the PXC200-F */
3278         val = btread(BT848_GPIO_DMA_CTL);
3279         val |= BT848_GPIO_DMA_CTL_GPCLKMODE;
3280         btwrite(val, BT848_GPIO_DMA_CTL);
3281         
3282         /* Then, push to 0 the reset pin long enough to reset the *
3283          * device same as above for the reset line, but not the same
3284          * value sent to the GPIO-connected stuff
3285          * which one is the good one? */
3286         gpio_inout(0xffffff,(1<<2));
3287         gpio_write(0);
3288         udelay(10);
3289         gpio_write(1<<2);
3290
3291         for (i = 0; i < ARRAY_SIZE(vals); i++) {
3292                 tmp=bttv_I2CWrite(btv,0x1E,0,vals[i],1);
3293                 if (tmp != -1) {
3294                         printk(KERN_INFO
3295                                "I2C Write(%2.2x) = %i\nI2C Read () = %2.2x\n\n",
3296                                vals[i],tmp,bttv_I2CRead(btv,0x1F,NULL));
3297                 }
3298         }
3299
3300         printk(KERN_INFO "PXC200 Initialised.\n");
3301 }
3302
3303
3304 /* ----------------------------------------------------------------------- */
3305 /* Miro Pro radio stuff -- the tea5757 is connected to some GPIO ports     */
3306 /*
3307  * Copyright (c) 1999 Csaba Halasz <qgehali@uni-miskolc.hu>
3308  * This code is placed under the terms of the GNU General Public License
3309  *
3310  * Brutally hacked by Dan Sheridan <dan.sheridan@contact.org.uk> djs52 8/3/00
3311  */
3312
3313 void bus_low(struct bttv *btv, int bit)
3314 {
3315         if (btv->mbox_ior) {
3316                 gpio_bits(btv->mbox_ior | btv->mbox_iow | btv->mbox_csel,
3317                           btv->mbox_ior | btv->mbox_iow | btv->mbox_csel);
3318                 udelay(5);
3319         }
3320
3321         gpio_bits(bit,0);
3322         udelay(5);
3323
3324         if (btv->mbox_ior) {
3325                 gpio_bits(btv->mbox_iow | btv->mbox_csel, 0);
3326                 udelay(5);
3327         }
3328 }
3329
3330 void bus_high(struct bttv *btv, int bit)
3331 {
3332         if (btv->mbox_ior) {
3333                 gpio_bits(btv->mbox_ior | btv->mbox_iow | btv->mbox_csel,
3334                           btv->mbox_ior | btv->mbox_iow | btv->mbox_csel);
3335                 udelay(5);
3336         }
3337
3338         gpio_bits(bit,bit);
3339         udelay(5);
3340
3341         if (btv->mbox_ior) {
3342                 gpio_bits(btv->mbox_iow | btv->mbox_csel, 0);
3343                 udelay(5);
3344         }
3345 }
3346
3347 int bus_in(struct bttv *btv, int bit)
3348 {
3349         if (btv->mbox_ior) {
3350                 gpio_bits(btv->mbox_ior | btv->mbox_iow | btv->mbox_csel,
3351                           btv->mbox_ior | btv->mbox_iow | btv->mbox_csel);
3352                 udelay(5);
3353
3354                 gpio_bits(btv->mbox_iow | btv->mbox_csel, 0);
3355                 udelay(5);
3356         }
3357         return gpio_read() & (bit);
3358 }
3359
3360 /* TEA5757 register bits */
3361 #define TEA_FREQ                0:14
3362 #define TEA_BUFFER              15:15
3363
3364 #define TEA_SIGNAL_STRENGTH     16:17
3365
3366 #define TEA_PORT1               18:18
3367 #define TEA_PORT0               19:19
3368
3369 #define TEA_BAND                20:21
3370 #define TEA_BAND_FM             0
3371 #define TEA_BAND_MW             1
3372 #define TEA_BAND_LW             2
3373 #define TEA_BAND_SW             3
3374
3375 #define TEA_MONO                22:22
3376 #define TEA_ALLOW_STEREO        0
3377 #define TEA_FORCE_MONO          1
3378
3379 #define TEA_SEARCH_DIRECTION    23:23
3380 #define TEA_SEARCH_DOWN         0
3381 #define TEA_SEARCH_UP           1
3382
3383 #define TEA_STATUS              24:24
3384 #define TEA_STATUS_TUNED        0
3385 #define TEA_STATUS_SEARCHING    1
3386
3387 /* Low-level stuff */
3388 static int tea5757_read(struct bttv *btv)
3389 {
3390         unsigned long timeout;
3391         int value = 0;
3392         int i;
3393         
3394         /* better safe than sorry */
3395         gpio_inout(btv->mbox_mask, btv->mbox_clk | btv->mbox_we);
3396
3397         if (btv->mbox_ior) {
3398                 gpio_bits(btv->mbox_ior | btv->mbox_iow | btv->mbox_csel,
3399                           btv->mbox_ior | btv->mbox_iow | btv->mbox_csel);
3400                 udelay(5);
3401         }
3402
3403         if (bttv_gpio)
3404                 bttv_gpio_tracking(btv,"tea5757 read");
3405         
3406         bus_low(btv,btv->mbox_we);
3407         bus_low(btv,btv->mbox_clk);
3408         
3409         udelay(10);
3410         timeout= jiffies + HZ;
3411
3412         // wait for DATA line to go low; error if it doesn't
3413         while (bus_in(btv,btv->mbox_data) && time_before(jiffies, timeout))
3414                 schedule();
3415         if (bus_in(btv,btv->mbox_data)) {
3416                 printk(KERN_WARNING "bttv%d: tea5757: read timeout\n",btv->c.nr);
3417                 return -1;
3418         }
3419
3420         dprintk("bttv%d: tea5757:",btv->c.nr);
3421         for(i = 0; i < 24; i++)
3422         {
3423                 udelay(5);
3424                 bus_high(btv,btv->mbox_clk);
3425                 udelay(5);
3426                 dprintk("%c",(bus_in(btv,btv->mbox_most) == 0)?'T':'-');
3427                 bus_low(btv,btv->mbox_clk);
3428                 value <<= 1;
3429                 value |= (bus_in(btv,btv->mbox_data) == 0)?0:1;  /* MSB first */
3430                 dprintk("%c", (bus_in(btv,btv->mbox_most) == 0)?'S':'M');
3431         }
3432         dprintk("\nbttv%d: tea5757: read 0x%X\n", btv->c.nr, value);
3433         return value;
3434 }
3435
3436 static int tea5757_write(struct bttv *btv, int value)
3437 {
3438         int i;
3439         int reg = value;
3440         
3441         gpio_inout(btv->mbox_mask, btv->mbox_clk | btv->mbox_we | btv->mbox_data);
3442
3443         if (btv->mbox_ior) {
3444                 gpio_bits(btv->mbox_ior | btv->mbox_iow | btv->mbox_csel,
3445                           btv->mbox_ior | btv->mbox_iow | btv->mbox_csel);
3446                 udelay(5);
3447         }
3448         if (bttv_gpio)
3449                 bttv_gpio_tracking(btv,"tea5757 write");
3450
3451         dprintk("bttv%d: tea5757: write 0x%X\n", btv->c.nr, value);
3452         bus_low(btv,btv->mbox_clk);
3453         bus_high(btv,btv->mbox_we);
3454         for(i = 0; i < 25; i++)
3455         {
3456                 if (reg & 0x1000000)
3457                         bus_high(btv,btv->mbox_data);
3458                 else
3459                         bus_low(btv,btv->mbox_data);
3460                 reg <<= 1;
3461                 bus_high(btv,btv->mbox_clk);
3462                 udelay(10);
3463                 bus_low(btv,btv->mbox_clk);
3464                 udelay(10);
3465         }
3466         bus_low(btv,btv->mbox_we);  /* unmute !!! */
3467         return 0;
3468 }
3469
3470 void tea5757_set_freq(struct bttv *btv, unsigned short freq)
3471 {
3472         dprintk("tea5757_set_freq %d\n",freq);
3473         tea5757_write(btv, 5 * freq + 0x358); /* add 10.7MHz (see docs) */
3474 #if 0
3475         /* breaks Miro PCTV */
3476         value = tea5757_read(btv);
3477         dprintk("bttv%d: tea5757 readback=0x%x\n",btv->c.nr,value);
3478 #endif
3479 }
3480
3481
3482 /* ----------------------------------------------------------------------- */
3483 /* winview                                                                 */
3484
3485 void winview_audio(struct bttv *btv, struct video_audio *v, int set)
3486 {
3487         /* PT2254A programming Jon Tombs, jon@gte.esi.us.es */
3488         int bits_out, loops, vol, data;
3489
3490         if (!set) {
3491                 /* Fixed by Leandro Lucarella <luca@linuxmendoza.org.ar (07/31/01) */
3492                 v->flags |= VIDEO_AUDIO_VOLUME;
3493                 return;
3494         }
3495         
3496         /* 32 levels logarithmic */
3497         vol = 32 - ((v->volume>>11));
3498         /* units */
3499         bits_out = (PT2254_DBS_IN_2>>(vol%5));
3500         /* tens */
3501         bits_out |= (PT2254_DBS_IN_10>>(vol/5));
3502         bits_out |= PT2254_L_CHANNEL | PT2254_R_CHANNEL;
3503         data = gpio_read();
3504         data &= ~(WINVIEW_PT2254_CLK| WINVIEW_PT2254_DATA|
3505                   WINVIEW_PT2254_STROBE);
3506         for (loops = 17; loops >= 0 ; loops--) {
3507                 if (bits_out & (1<<loops))
3508                         data |=  WINVIEW_PT2254_DATA;
3509                 else
3510                         data &= ~WINVIEW_PT2254_DATA;
3511                 gpio_write(data);
3512                 udelay(5);
3513                 data |= WINVIEW_PT2254_CLK;
3514                 gpio_write(data);
3515                 udelay(5);
3516                 data &= ~WINVIEW_PT2254_CLK;
3517                 gpio_write(data);
3518         }
3519         data |=  WINVIEW_PT2254_STROBE;
3520         data &= ~WINVIEW_PT2254_DATA;
3521         gpio_write(data);
3522         udelay(10);                     
3523         data &= ~WINVIEW_PT2254_STROBE;
3524         gpio_write(data);
3525 }
3526
3527 /* ----------------------------------------------------------------------- */
3528 /* mono/stereo control for various cards (which don't use i2c chips but    */
3529 /* connect something to the GPIO pins                                      */
3530
3531 static void
3532 gvbctv3pci_audio(struct bttv *btv, struct video_audio *v, int set)
3533 {
3534         unsigned int con = 0;
3535
3536         if (set) {
3537                 gpio_inout(0x300, 0x300);
3538                 if (v->mode & VIDEO_SOUND_LANG1)
3539                         con = 0x000;
3540                 if (v->mode & VIDEO_SOUND_LANG2)
3541                         con = 0x300;
3542                 if (v->mode & VIDEO_SOUND_STEREO)
3543                         con = 0x200;
3544 //              if (v->mode & VIDEO_SOUND_MONO)
3545 //                      con = 0x100;
3546                 gpio_bits(0x300, con);
3547         } else {
3548                 v->mode = VIDEO_SOUND_STEREO |
3549                           VIDEO_SOUND_LANG1  | VIDEO_SOUND_LANG2;
3550         }
3551 }
3552
3553 static void
3554 gvbctv5pci_audio(struct bttv *btv, struct video_audio *v, int set)
3555 {
3556         unsigned int val, con;
3557
3558 #if BTTV_VERSION_CODE > KERNEL_VERSION(0,8,0)
3559         if (btv->radio_user)
3560                 return;
3561 #else
3562         if (btv->radio)
3563                 return;
3564 #endif
3565
3566         val = gpio_read();
3567         if (set) {
3568                 con = 0x000;
3569                 if (v->mode & VIDEO_SOUND_LANG2) {
3570                         if (v->mode & VIDEO_SOUND_LANG1) {
3571                                 /* LANG1 + LANG2 */
3572                                 con = 0x100;
3573                         }
3574                         else {
3575                                 /* LANG2 */
3576                                 con = 0x300;
3577                         }
3578                 }
3579                 if (con != (val & 0x300)) {
3580                         gpio_bits(0x300, con);
3581                         if (bttv_gpio)
3582                                 bttv_gpio_tracking(btv,"gvbctv5pci");
3583                 }
3584         } else {
3585                 switch (val & 0x70) {
3586                   case 0x10:
3587                         v->mode = VIDEO_SOUND_LANG1 | VIDEO_SOUND_LANG2;
3588                         break;
3589                   case 0x30:
3590                         v->mode = VIDEO_SOUND_LANG2;
3591                         break;
3592                   case 0x50:
3593                         v->mode = VIDEO_SOUND_LANG1;
3594                         break;
3595                   case 0x60:
3596                         v->mode = VIDEO_SOUND_STEREO;
3597                         break;
3598                   case 0x70:
3599                         v->mode = VIDEO_SOUND_MONO;
3600                         break;
3601                   default:
3602                         v->mode = VIDEO_SOUND_MONO | VIDEO_SOUND_STEREO |
3603                                   VIDEO_SOUND_LANG1 | VIDEO_SOUND_LANG2;
3604                 }
3605         }
3606 }
3607
3608 /*
3609  * Mario Medina Nussbaum <medisoft@alohabbs.org.mx>
3610  *  I discover that on BT848_GPIO_DATA address a byte 0xcce enable stereo,
3611  *  0xdde enables mono and 0xccd enables sap
3612  *
3613  * Petr Vandrovec <VANDROVE@vc.cvut.cz>
3614  *  P.S.: At least mask in line above is wrong - GPIO pins 3,2 select
3615  *  input/output sound connection, so both must be set for output mode.
3616  *
3617  * Looks like it's needed only for the "tvphone", the "tvphone 98"
3618  * handles this with a tda9840
3619  *
3620  */
3621 static void
3622 avermedia_tvphone_audio(struct bttv *btv, struct video_audio *v, int set)
3623 {
3624         int val = 0;
3625
3626         if (set) {
3627                 if (v->mode & VIDEO_SOUND_LANG2)   /* SAP */
3628                         val = 0x02;
3629                 if (v->mode & VIDEO_SOUND_STEREO)
3630                         val = 0x01;
3631                 if (val) {
3632                         gpio_bits(0x03,val);
3633                         if (bttv_gpio)
3634                                 bttv_gpio_tracking(btv,"avermedia");
3635                 }
3636         } else {
3637                 v->mode = VIDEO_SOUND_MONO | VIDEO_SOUND_STEREO |
3638                         VIDEO_SOUND_LANG1;
3639                 return;
3640         }
3641 }
3642
3643 static void
3644 avermedia_tv_stereo_audio(struct bttv *btv, struct video_audio *v, int set)
3645 {
3646         int val = 0;
3647         
3648         if (set) {
3649                 if (v->mode & VIDEO_SOUND_LANG2)   /* SAP */
3650                         val = 0x01;
3651                 if (v->mode & VIDEO_SOUND_STEREO)  /* STEREO */
3652                         val = 0x02;
3653                 btaor(val, ~0x03, BT848_GPIO_DATA);
3654                 if (bttv_gpio)
3655                         bttv_gpio_tracking(btv,"avermedia");
3656         } else {
3657                 v->mode = VIDEO_SOUND_MONO | VIDEO_SOUND_STEREO |
3658                         VIDEO_SOUND_LANG1 | VIDEO_SOUND_LANG2;
3659                 return;
3660         }
3661 }
3662
3663 /* Lifetec 9415 handling */
3664 static void
3665 lt9415_audio(struct bttv *btv, struct video_audio *v, int set)
3666 {
3667         int val = 0;
3668
3669         if (gpio_read() & 0x4000) {
3670                 v->mode = VIDEO_SOUND_MONO;
3671                 return;
3672         }
3673
3674         if (set) {
3675                 if (v->mode & VIDEO_SOUND_LANG2)  /* A2 SAP */
3676                         val = 0x0080;
3677                 if (v->mode & VIDEO_SOUND_STEREO) /* A2 stereo */
3678                         val = 0x0880;
3679                 if ((v->mode & VIDEO_SOUND_LANG1) ||
3680                     (v->mode & VIDEO_SOUND_MONO))
3681                         val = 0;
3682                 gpio_bits(0x0880, val);
3683                 if (bttv_gpio)
3684                         bttv_gpio_tracking(btv,"lt9415");
3685         } else {
3686                 /* autodetect doesn't work with this card :-( */
3687                 v->mode = VIDEO_SOUND_MONO | VIDEO_SOUND_STEREO |
3688                         VIDEO_SOUND_LANG1 | VIDEO_SOUND_LANG2;
3689                 return;
3690         }
3691 }
3692
3693 // TDA9821 on TerraTV+ Bt848, Bt878
3694 static void
3695 terratv_audio(struct bttv *btv, struct video_audio *v, int set)
3696 {
3697         unsigned int con = 0;
3698
3699         if (set) {
3700                 gpio_inout(0x180000,0x180000);
3701                 if (v->mode & VIDEO_SOUND_LANG2)
3702                         con = 0x080000;
3703                 if (v->mode & VIDEO_SOUND_STEREO)
3704                         con = 0x180000;
3705                 gpio_bits(0x180000, con);
3706                 if (bttv_gpio)
3707                         bttv_gpio_tracking(btv,"terratv");
3708         } else {
3709                 v->mode = VIDEO_SOUND_MONO | VIDEO_SOUND_STEREO |
3710                         VIDEO_SOUND_LANG1 | VIDEO_SOUND_LANG2;
3711         }
3712 }
3713
3714 static void
3715 winfast2000_audio(struct bttv *btv, struct video_audio *v, int set)
3716 {
3717         unsigned long val = 0;
3718
3719         if (set) {
3720                 /*btor (0xc32000, BT848_GPIO_OUT_EN);*/
3721                 if (v->mode & VIDEO_SOUND_MONO)         /* Mono */
3722                         val = 0x420000;
3723                 if (v->mode & VIDEO_SOUND_LANG1)        /* Mono */
3724                         val = 0x420000;
3725                 if (v->mode & VIDEO_SOUND_LANG2)        /* SAP */
3726                         val = 0x410000;
3727                 if (v->mode & VIDEO_SOUND_STEREO)       /* Stereo */
3728                         val = 0x020000;
3729                 if (val) {
3730                         gpio_bits(0x430000, val);
3731                         if (bttv_gpio)
3732                                 bttv_gpio_tracking(btv,"winfast2000");
3733                 }
3734         } else {
3735                 v->mode = VIDEO_SOUND_MONO | VIDEO_SOUND_STEREO |
3736                           VIDEO_SOUND_LANG1 | VIDEO_SOUND_LANG2;
3737         }
3738 }
3739
3740 /*
3741  * Dariusz Kowalewski <darekk@automex.pl>
3742  * sound control for Prolink PV-BT878P+9B (PixelView PlayTV Pro FM+NICAM
3743  * revision 9B has on-board TDA9874A sound decoder).
3744  *
3745  * Note: There are card variants without tda9874a. Forcing the "stereo sound route"
3746  *       will mute this cards.
3747  */
3748 static void
3749 pvbt878p9b_audio(struct bttv *btv, struct video_audio *v, int set)
3750 {
3751         unsigned int val = 0;
3752
3753 #if BTTV_VERSION_CODE > KERNEL_VERSION(0,8,0)
3754         if (btv->radio_user)
3755                 return;
3756 #else
3757         if (btv->radio)
3758                 return;
3759 #endif
3760
3761         if (set) {
3762                 if (v->mode & VIDEO_SOUND_MONO) {
3763                         val = 0x01;
3764                 }
3765                 if ((v->mode & (VIDEO_SOUND_LANG1 | VIDEO_SOUND_LANG2))
3766                     || (v->mode & VIDEO_SOUND_STEREO)) {
3767                         val = 0x02;
3768                 }
3769                 if (val) {
3770                         gpio_bits(0x03,val);
3771                         if (bttv_gpio)
3772                                 bttv_gpio_tracking(btv,"pvbt878p9b");
3773                 }
3774         } else {
3775                 v->mode = VIDEO_SOUND_MONO | VIDEO_SOUND_STEREO |
3776                         VIDEO_SOUND_LANG1 | VIDEO_SOUND_LANG2;
3777         }
3778 }
3779
3780 /*
3781  * Dariusz Kowalewski <darekk@automex.pl>
3782  * sound control for FlyVideo 2000S (with tda9874 decoder) 
3783  * based on pvbt878p9b_audio() - this is not tested, please fix!!!
3784  */
3785 static void
3786 fv2000s_audio(struct bttv *btv, struct video_audio *v, int set)
3787 {
3788         unsigned int val = 0xffff;
3789
3790 #if BTTV_VERSION_CODE > KERNEL_VERSION(0,8,0)
3791         if (btv->radio_user)
3792                 return;
3793 #else
3794         if (btv->radio)
3795                 return;
3796 #endif
3797         if (set) {
3798                 if (v->mode & VIDEO_SOUND_MONO) {
3799                         val = 0x0000;
3800                 }
3801                 if ((v->mode & (VIDEO_SOUND_LANG1 | VIDEO_SOUND_LANG2))
3802                     || (v->mode & VIDEO_SOUND_STEREO)) {
3803                         val = 0x1080; //-dk-???: 0x0880, 0x0080, 0x1800 ...
3804                 }
3805                 if (val != 0xffff) {
3806                         gpio_bits(0x1800, val);
3807                         if (bttv_gpio)
3808                                 bttv_gpio_tracking(btv,"fv2000s");
3809                 }
3810         } else {
3811                 v->mode = VIDEO_SOUND_MONO | VIDEO_SOUND_STEREO |
3812                         VIDEO_SOUND_LANG1 | VIDEO_SOUND_LANG2;
3813         }
3814 }
3815
3816 /*
3817  * sound control for Canopus WinDVR PCI
3818  * Masaki Suzuki <masaki@btree.org>
3819  */
3820 static void
3821 windvr_audio(struct bttv *btv, struct video_audio *v, int set)
3822 {
3823         unsigned long val = 0;
3824
3825         if (set) {
3826                 if (v->mode & VIDEO_SOUND_MONO)
3827                         val = 0x040000;
3828                 if (v->mode & VIDEO_SOUND_LANG1)
3829                         val = 0;
3830                 if (v->mode & VIDEO_SOUND_LANG2)
3831                         val = 0x100000;
3832                 if (v->mode & VIDEO_SOUND_STEREO)
3833                         val = 0;
3834                 if (val) {
3835                         gpio_bits(0x140000, val);
3836                         if (bttv_gpio)
3837                                 bttv_gpio_tracking(btv,"windvr");
3838                 }
3839         } else {
3840                 v->mode = VIDEO_SOUND_MONO | VIDEO_SOUND_STEREO |
3841                           VIDEO_SOUND_LANG1 | VIDEO_SOUND_LANG2;
3842         }
3843 }
3844
3845 /*
3846  * sound control for AD-TVK503
3847  * Hiroshi Takekawa <sian@big.or.jp>
3848  */
3849 static void
3850 adtvk503_audio(struct bttv *btv, struct video_audio *v, int set)
3851 {
3852         unsigned int con = 0xffffff;
3853
3854         //btaor(0x1e0000, ~0x1e0000, BT848_GPIO_OUT_EN);
3855
3856         if (set) {
3857                 //btor(***, BT848_GPIO_OUT_EN);
3858                 if (v->mode & VIDEO_SOUND_LANG1)
3859                         con = 0x00000000;
3860                 if (v->mode & VIDEO_SOUND_LANG2)
3861                         con = 0x00180000;
3862                 if (v->mode & VIDEO_SOUND_STEREO)
3863                         con = 0x00000000;
3864                 if (v->mode & VIDEO_SOUND_MONO)
3865                         con = 0x00060000;
3866                 if (con != 0xffffff) {
3867                         gpio_bits(0x1e0000,con);
3868                         if (bttv_gpio)
3869                                 bttv_gpio_tracking(btv, "adtvk503");
3870                 }
3871         } else {
3872                 v->mode = VIDEO_SOUND_MONO | VIDEO_SOUND_STEREO |
3873                           VIDEO_SOUND_LANG1  | VIDEO_SOUND_LANG2;
3874         }
3875 }
3876
3877 /* RemoteVision MX (rv605) muxsel helper [Miguel Freitas]
3878  *
3879  * This is needed because rv605 don't use a normal multiplex, but a crosspoint
3880  * switch instead (CD22M3494E). This IC can have multiple active connections
3881  * between Xn (input) and Yn (output) pins. We need to clear any existing
3882  * connection prior to establish a new one, pulsing the STROBE pin.
3883  *
3884  * The board hardwire Y0 (xpoint) to MUX1 and MUXOUT to Yin.
3885  * GPIO pins are wired as:
3886  *  GPIO[0:3] - AX[0:3] (xpoint) - P1[0:3] (microcontroler)
3887  *  GPIO[4:6] - AY[0:2] (xpoint) - P1[4:6] (microcontroler)
3888  *  GPIO[7]   - DATA (xpoint)    - P1[7] (microcontroler)
3889  *  GPIO[8]   -                  - P3[5] (microcontroler)
3890  *  GPIO[9]   - RESET (xpoint)   - P3[6] (microcontroler)
3891  *  GPIO[10]  - STROBE (xpoint)  - P3[7] (microcontroler)
3892  *  GPINTR    -                  - P3[4] (microcontroler)
3893  *
3894  * The microcontroler is a 80C32 like. It should be possible to change xpoint
3895  * configuration either directly (as we are doing) or using the microcontroler
3896  * which is also wired to I2C interface. I have no further info on the
3897  * microcontroler features, one would need to disassembly the firmware.
3898  * note: the vendor refused to give any information on this product, all
3899  *       that stuff was found using a multimeter! :)
3900  */
3901 static void rv605_muxsel(struct bttv *btv, unsigned int input)
3902 {
3903         /* reset all conections */
3904         gpio_bits(0x200,0x200);
3905         mdelay(1);
3906         gpio_bits(0x200,0x000);
3907         mdelay(1);
3908
3909         /* create a new conection */
3910         gpio_bits(0x480,0x080);
3911         gpio_bits(0x480,0x480);
3912         mdelay(1);
3913         gpio_bits(0x480,0x080);
3914         mdelay(1);
3915 }
3916
3917 // The Grandtec X-Guard framegrabber card uses two Dual 4-channel
3918 // video multiplexers to provide up to 16 video inputs. These
3919 // multiplexers are controlled by the lower 8 GPIO pins of the
3920 // bt878. The multiplexers probably Pericom PI5V331Q or similar.
3921
3922 // xxx0 is pin xxx of multiplexer U5,
3923 // yyy1 is pin yyy of multiplexer U2
3924
3925 #define ENA0    0x01
3926 #define ENB0    0x02
3927 #define ENA1    0x04
3928 #define ENB1    0x08
3929
3930 #define IN10    0x10
3931 #define IN00    0x20
3932 #define IN11    0x40
3933 #define IN01    0x80
3934
3935 static void xguard_muxsel(struct bttv *btv, unsigned int input)
3936 {
3937         static const int masks[] = {
3938                 ENB0, ENB0|IN00, ENB0|IN10, ENB0|IN00|IN10,
3939                 ENA0, ENA0|IN00, ENA0|IN10, ENA0|IN00|IN10,
3940                 ENB1, ENB1|IN01, ENB1|IN11, ENB1|IN01|IN11,
3941                 ENA1, ENA1|IN01, ENA1|IN11, ENA1|IN01|IN11,
3942         };
3943         gpio_write(masks[input%16]);
3944 }
3945 static void picolo_tetra_init(struct bttv *btv)
3946 {
3947         /*This is the video input redirection fonctionality : I DID NOT USED IT. */
3948         btwrite (0x08<<16,BT848_GPIO_DATA);/*GPIO[19] [==> 4053 B+C] set to 1 */
3949         btwrite (0x04<<16,BT848_GPIO_DATA);/*GPIO[18] [==> 4053 A]  set to 1*/
3950 }
3951 static void picolo_tetra_muxsel (struct bttv* btv, unsigned int input)
3952 {
3953
3954         dprintk (KERN_DEBUG "bttv%d : picolo_tetra_muxsel =>  input = %d\n",btv->c.nr,input);
3955         /*Just set the right path in the analog multiplexers : channel 1 -> 4 ==> Analog Mux ==> MUX0*/
3956         /*GPIO[20]&GPIO[21] used to choose the right input*/
3957         btwrite (input<<20,BT848_GPIO_DATA);
3958
3959 }
3960
3961 /*
3962  * ivc120_muxsel [Added by Alan Garfield <alan@fromorbit.com>]
3963  *
3964  * The IVC120G security card has 4 i2c controlled TDA8540 matrix
3965  * swichers to provide 16 channels to MUX0. The TDA8540's have 
3966  * 4 indepedant outputs and as such the IVC120G also has the 
3967  * optional "Monitor Out" bus. This allows the card to be looking 
3968  * at one input while the monitor is looking at another.
3969  *
3970  * Since I've couldn't be bothered figuring out how to add an
3971  * independant muxsel for the monitor bus, I've just set it to 
3972  * whatever the card is looking at.
3973  *
3974  *  OUT0 of the TDA8540's is connected to MUX0         (0x03)
3975  *  OUT1 of the TDA8540's is connected to "Monitor Out"        (0x0C)
3976  *
3977  *  TDA8540_ALT3 IN0-3 = Channel 13 - 16       (0x03)
3978  *  TDA8540_ALT4 IN0-3 = Channel 1 - 4         (0x03)
3979  *  TDA8540_ALT5 IN0-3 = Channel 5 - 8         (0x03)
3980  *  TDA8540_ALT6 IN0-3 = Channel 9 - 12                (0x03)
3981  *
3982  */
3983
3984 /* All 7 possible sub-ids for the TDA8540 Matrix Switcher */
3985 #define I2C_TDA8540        0x90
3986 #define I2C_TDA8540_ALT1   0x92
3987 #define I2C_TDA8540_ALT2   0x94
3988 #define I2C_TDA8540_ALT3   0x96
3989 #define I2C_TDA8540_ALT4   0x98
3990 #define I2C_TDA8540_ALT5   0x9a
3991 #define I2C_TDA8540_ALT6   0x9c
3992
3993 static void ivc120_muxsel(struct bttv *btv, unsigned int input)
3994 {
3995         // Simple maths
3996         int key = input % 4;    
3997         int matrix = input / 4;
3998         
3999         dprintk("bttv%d: ivc120_muxsel: Input - %02d | TDA - %02d | In - %02d\n",
4000                 btv->c.nr, input, matrix, key);
4001         
4002         // Handles the input selection on the TDA8540's
4003         bttv_I2CWrite(btv, I2C_TDA8540_ALT3, 0x00,
4004                       ((matrix == 3) ? (key | key << 2) : 0x00), 1);
4005         bttv_I2CWrite(btv, I2C_TDA8540_ALT4, 0x00,
4006                       ((matrix == 0) ? (key | key << 2) : 0x00), 1);
4007         bttv_I2CWrite(btv, I2C_TDA8540_ALT5, 0x00,
4008                       ((matrix == 1) ? (key | key << 2) : 0x00), 1);
4009         bttv_I2CWrite(btv, I2C_TDA8540_ALT6, 0x00,
4010                       ((matrix == 2) ? (key | key << 2) : 0x00), 1);
4011         
4012         // Handles the output enables on the TDA8540's
4013         bttv_I2CWrite(btv, I2C_TDA8540_ALT3, 0x02,
4014                       ((matrix == 3) ? 0x03 : 0x00), 1);  // 13 - 16
4015         bttv_I2CWrite(btv, I2C_TDA8540_ALT4, 0x02,
4016                       ((matrix == 0) ? 0x03 : 0x00), 1);  // 1-4
4017         bttv_I2CWrite(btv, I2C_TDA8540_ALT5, 0x02,
4018                       ((matrix == 1) ? 0x03 : 0x00), 1);  // 5-8 
4019         bttv_I2CWrite(btv, I2C_TDA8540_ALT6, 0x02,
4020                       ((matrix == 2) ? 0x03 : 0x00), 1);  // 9-12
4021         
4022         // Selects MUX0 for input on the 878
4023         btaor((0)<<5, ~(3<<5), BT848_IFORM);
4024 }
4025
4026
4027 /* ----------------------------------------------------------------------- */
4028 /* motherboard chipset specific stuff                                      */
4029
4030 void __devinit bttv_check_chipset(void)
4031 {
4032         int pcipci_fail = 0;
4033         struct pci_dev *dev = NULL;
4034
4035         if (pci_pci_problems & PCIPCI_FAIL)
4036                 pcipci_fail = 1;
4037         if (pci_pci_problems & (PCIPCI_TRITON|PCIPCI_NATOMA|PCIPCI_VIAETBF))
4038                 triton1 = 1;
4039         if (pci_pci_problems & PCIPCI_VSFX)
4040                 vsfx = 1;
4041 #ifdef PCIPCI_ALIMAGIK
4042         if (pci_pci_problems & PCIPCI_ALIMAGIK)
4043                 latency = 0x0A;
4044 #endif
4045
4046 #if 0
4047         /* print which chipset we have */
4048         while ((dev = pci_find_class(PCI_CLASS_BRIDGE_HOST << 8,dev)))
4049                 printk(KERN_INFO "bttv: Host bridge is %s\n",pci_name(dev));
4050 #endif
4051
4052         /* print warnings about any quirks found */
4053         if (triton1)
4054                 printk(KERN_INFO "bttv: Host bridge needs ETBF enabled.\n");
4055         if (vsfx)
4056                 printk(KERN_INFO "bttv: Host bridge needs VSFX enabled.\n");
4057         if (pcipci_fail) {
4058                 printk(KERN_WARNING "bttv: BT848 and your chipset may not work together.\n");
4059                 if (UNSET == no_overlay) {
4060                         printk(KERN_WARNING "bttv: going to disable overlay.\n");
4061                         no_overlay = 1;
4062                 }
4063         }
4064         if (UNSET != latency)
4065                 printk(KERN_INFO "bttv: pci latency fixup [%d]\n",latency);
4066
4067         while ((dev = pci_find_device(PCI_VENDOR_ID_INTEL,
4068                                       PCI_DEVICE_ID_INTEL_82441, dev))) {
4069                 unsigned char b;
4070                 pci_read_config_byte(dev, 0x53, &b);
4071                 if (bttv_debug)
4072                         printk(KERN_INFO "bttv: Host bridge: 82441FX Natoma, "
4073                                "bufcon=0x%02x\n",b);
4074         }
4075 }
4076
4077 int __devinit bttv_handle_chipset(struct bttv *btv)
4078 {
4079         unsigned char command;
4080
4081         if (!triton1 && !vsfx && UNSET == latency)
4082                 return 0;
4083
4084         if (bttv_verbose) {
4085                 if (triton1)
4086                         printk(KERN_INFO "bttv%d: enabling ETBF (430FX/VP3 compatibilty)\n",btv->c.nr);
4087                 if (vsfx && btv->id >= 878)
4088                         printk(KERN_INFO "bttv%d: enabling VSFX\n",btv->c.nr);
4089                 if (UNSET != latency)
4090                         printk(KERN_INFO "bttv%d: setting pci timer to %d\n",
4091                                btv->c.nr,latency);
4092         }
4093
4094         if (btv->id < 878) {
4095                 /* bt848 (mis)uses a bit in the irq mask for etbf */
4096                 if (triton1)
4097                         btv->triton1 = BT848_INT_ETBF;
4098         } else {
4099                 /* bt878 has a bit in the pci config space for it */
4100                 pci_read_config_byte(btv->c.pci, BT878_DEVCTRL, &command);
4101                 if (triton1)
4102                         command |= BT878_EN_TBFX;
4103                 if (vsfx)
4104                         command |= BT878_EN_VSFX;
4105                 pci_write_config_byte(btv->c.pci, BT878_DEVCTRL, command);
4106         }
4107         if (UNSET != latency)
4108                 pci_write_config_byte(btv->c.pci, PCI_LATENCY_TIMER, latency);
4109         return 0;
4110 }
4111
4112
4113 /* PXC200 muxsel helper
4114  * luke@syseng.anu.edu.au
4115  * another transplant
4116  * from Alessandro Rubini (rubini@linux.it)
4117  *
4118  * There are 4 kinds of cards:
4119  * PXC200L which is bt848
4120  * PXC200F which is bt848 with PIC controlling mux
4121  * PXC200AL which is bt878
4122  * PXC200AF which is bt878 with PIC controlling mux
4123  */
4124 #define PX_CFG_PXC200F 0x01
4125 #define PX_FLAG_PXC200A  0x00001000 /* a pxc200A is bt-878 based */
4126 #define PX_I2C_PIC       0x0f
4127 #define PX_PXC200A_CARDID 0x200a1295
4128 #define PX_I2C_CMD_CFG   0x00
4129
4130 static void PXC200_muxsel(struct bttv *btv, unsigned int input)
4131 {
4132         int rc;
4133         long mux;
4134         int bitmask;
4135         unsigned char buf[2];
4136
4137         /* Read PIC config to determine if this is a PXC200F */
4138         /* PX_I2C_CMD_CFG*/
4139         buf[0]=0;
4140         buf[1]=0;
4141         rc=bttv_I2CWrite(btv,(PX_I2C_PIC<<1),buf[0],buf[1],1);
4142         if (rc) {
4143           printk(KERN_DEBUG "bttv%d: PXC200_muxsel: pic cfg write failed:%d\n", btv->c.nr,rc);
4144           /* not PXC ? do nothing */
4145           return;
4146         }
4147
4148         rc=bttv_I2CRead(btv,(PX_I2C_PIC<<1),0);
4149         if (!(rc & PX_CFG_PXC200F)) {
4150           printk(KERN_DEBUG "bttv%d: PXC200_muxsel: not PXC200F rc:%d \n", btv->c.nr,rc);
4151           return;
4152         }
4153
4154
4155         /* The multiplexer in the 200F is handled by the GPIO port */
4156         /* get correct mapping between inputs  */
4157         /*  mux = bttv_tvcards[btv->type].muxsel[input] & 3; */
4158         /* ** not needed!?   */
4159         mux = input;
4160
4161         /* make sure output pins are enabled */
4162         /* bitmask=0x30f; */
4163         bitmask=0x302;
4164         /* check whether we have a PXC200A */
4165         if (btv->cardid == PX_PXC200A_CARDID)  {
4166            bitmask ^= 0x180; /* use 7 and 9, not 8 and 9 */
4167            bitmask |= 7<<4; /* the DAC */
4168         }
4169         btwrite(bitmask, BT848_GPIO_OUT_EN);
4170
4171         bitmask = btread(BT848_GPIO_DATA);
4172         if (btv->cardid == PX_PXC200A_CARDID)
4173           bitmask = (bitmask & ~0x280) | ((mux & 2) << 8) | ((mux & 1) << 7);
4174         else /* older device */
4175           bitmask = (bitmask & ~0x300) | ((mux & 3) << 8);
4176         btwrite(bitmask,BT848_GPIO_DATA);
4177
4178         /*
4179          * Was "to be safe, set the bt848 to input 0"
4180          * Actually, since it's ok at load time, better not messing
4181          * with these bits (on PXC200AF you need to set mux 2 here)
4182          *
4183          * needed because bttv-driver sets mux before calling this function
4184          */
4185         if (btv->cardid == PX_PXC200A_CARDID)
4186           btaor(2<<5, ~BT848_IFORM_MUXSEL, BT848_IFORM);
4187         else /* older device */
4188           btand(~BT848_IFORM_MUXSEL,BT848_IFORM);
4189
4190         printk(KERN_DEBUG "bttv%d: setting input channel to:%d\n", btv->c.nr,(int)mux);
4191 }
4192
4193 /*
4194  * Local variables:
4195  * c-basic-offset: 8
4196  * End:
4197  */