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