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