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