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