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