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