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