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