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