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