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