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