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