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