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