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