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