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