1 /*
2     bttv-cards.c
3 
4     this file has configuration informations - card-specific stuff
5     like the big tvcards array for the most part
6 
7     Copyright (C) 1996,97,98 Ralph  Metzler (rjkm@thp.uni-koeln.de)
8                            & Marcus Metzler (mocm@thp.uni-koeln.de)
9     (c) 1999-2001 Gerd Knorr <kraxel@goldbach.in-berlin.de>
10 
11     This program is free software; you can redistribute it and/or modify
12     it under the terms of the GNU General Public License as published by
13     the Free Software Foundation; either version 2 of the License, or
14     (at your option) any later version.
15 
16     This program is distributed in the hope that it will be useful,
17     but WITHOUT ANY WARRANTY; without even the implied warranty of
18     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19     GNU General Public License for more details.
20 
21     You should have received a copy of the GNU General Public License
22     along with this program; if not, write to the Free Software
23     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 
25 */
26 
27 #include <linux/config.h>
28 #include <linux/delay.h>
29 #include <linux/module.h>
30 #include <linux/kmod.h>
31 #include <linux/init.h>
32 #include <linux/pci.h>
33 #include <linux/vmalloc.h>
34 #ifdef CONFIG_FW_LOADER
35 # include <linux/firmware.h>
36 #endif
37 
38 #include <asm/io.h>
39 
40 #include "bttvp.h"
41 #include "bt832.h"
42 
43 /* fwd decl */
44 static void boot_msp34xx(struct bttv *btv, int pin);
45 static void boot_bt832(struct bttv *btv);
46 static void hauppauge_eeprom(struct bttv *btv);
47 static void avermedia_eeprom(struct bttv *btv);
48 static void osprey_eeprom(struct bttv *btv);
49 static void modtec_eeprom(struct bttv *btv);
50 static void init_PXC200(struct bttv *btv);
51 
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 terratv_audio(struct bttv *btv, struct video_audio *v, int set);
57 static void gvbctv3pci_audio(struct bttv *btv, struct video_audio *v, int set);
58 static void winfast2000_audio(struct bttv *btv, struct video_audio *v, int set);
59 static void pvbt878p9b_audio(struct bttv *btv, struct video_audio *v, int set);
60 static void fv2000s_audio(struct bttv *btv, struct video_audio *v, int set);
61 static void windvr_audio(struct bttv *btv, struct video_audio *v, int set);
62 static void adtvk503_audio(struct bttv *btv, struct video_audio *v, int set);
63 static void rv605_muxsel(struct bttv *btv, unsigned int input);
64 static void eagle_muxsel(struct bttv *btv, unsigned int input);
65 static void xguard_muxsel(struct bttv *btv, unsigned int input);
66 
67 static int terratec_active_radio_upgrade(struct bttv *btv);
68 static int tea5757_read(struct bttv *btv);
69 static int tea5757_write(struct bttv *btv, int value);
70 static void identify_by_eeprom(struct bttv *btv,
71 			       unsigned char eeprom_data[256]);
72 
73 /* config variables */
74 static unsigned int triton1=0;
75 static unsigned int vsfx=0;
76 static unsigned int latency = UNSET;
77 unsigned int no_overlay=-1;
78 
79 static unsigned int card[BTTV_MAX]  = { [ 0 ... (BTTV_MAX-1) ] = UNSET};
80 static unsigned int pll[BTTV_MAX]   = { [ 0 ... (BTTV_MAX-1) ] = UNSET};
81 static unsigned int tuner[BTTV_MAX] = { [ 0 ... (BTTV_MAX-1) ] = UNSET};
82 static unsigned int svhs[BTTV_MAX]  = { [ 0 ... (BTTV_MAX-1) ] = UNSET};
83 #ifdef MODULE
84 static unsigned int autoload = 1;
85 #else
86 static unsigned int autoload = 0;
87 #endif
88 static unsigned int gpiomask = UNSET;
89 static unsigned int audioall = UNSET;
90 static unsigned int audiomux[5] = { [ 0 ... 4 ] = UNSET };
91 
92 /* insmod options */
93 MODULE_PARM(triton1,"i");
94 MODULE_PARM_DESC(triton1,"set ETBF pci config bit "
95 		 "[enable bug compatibility for triton1 + others]");
96 MODULE_PARM(vsfx,"i");
97 MODULE_PARM_DESC(vsfx,"set VSFX pci config bit "
98 		 "[yet another chipset flaw workaround]");
99 MODULE_PARM(no_overlay,"i");
100 MODULE_PARM(latency,"i");
101 MODULE_PARM_DESC(latency,"pci latency timer");
102 MODULE_PARM(card,"1-" __stringify(BTTV_MAX) "i");
103 MODULE_PARM_DESC(card,"specify TV/grabber card model, see CARDLIST file for a list");
104 MODULE_PARM(pll,"1-" __stringify(BTTV_MAX) "i");
105 MODULE_PARM_DESC(pll,"specify installed crystal (0=none, 28=28 MHz, 35=35 MHz)");
106 MODULE_PARM(tuner,"1-" __stringify(BTTV_MAX) "i");
107 MODULE_PARM_DESC(tuner,"specify installed tuner type");
108 MODULE_PARM(autoload,"i");
109 MODULE_PARM_DESC(autoload,"automatically load i2c modules like tuner.o, default is 1 (yes)");
110 MODULE_PARM(gpiomask,"i");
111 MODULE_PARM(audioall,"i");
112 MODULE_PARM(audiomux,"1-5i");
113 
114 /* kernel args */
115 #ifndef MODULE
p_card(char * str)116 static int __init p_card(char *str)  { return bttv_parse(str,BTTV_MAX,card);  }
p_pll(char * str)117 static int __init p_pll(char *str)   { return bttv_parse(str,BTTV_MAX,pll);   }
p_tuner(char * str)118 static int __init p_tuner(char *str) { return bttv_parse(str,BTTV_MAX,tuner); }
119 __setup("bttv.card=",  p_card);
120 __setup("bttv.pll=",   p_pll);
121 __setup("bttv.tuner=", p_tuner);
122 
bttv_parse(char * str,int max,int * vals)123 int __init bttv_parse(char *str, int max, int *vals)
124 {
125 	int i,number,res = 2;
126 
127 	for (i = 0; res == 2 && i < max; i++) {
128 		res = get_option(&str,&number);
129 		if (res)
130 			vals[i] = number;
131 	}
132 	return 1;
133 }
134 #endif
135 
136 /* ----------------------------------------------------------------------- */
137 /* list of card IDs for bt878+ cards                                       */
138 
139 static struct CARD {
140 	unsigned id;
141 	int cardnr;
142 	char *name;
143 } cards[] __devinitdata = {
144 	{ 0x13eb0070, BTTV_HAUPPAUGE878,  "Hauppauge WinTV" },
145 	{ 0x39000070, BTTV_HAUPPAUGE878,  "Hauppauge WinTV-D" },
146 	{ 0x45000070, BTTV_HAUPPAUGEPVR,  "Hauppauge WinTV/PVR" },
147 	{ 0xff000070, BTTV_OSPREY1x0,     "Osprey-100" },
148 	{ 0xff010070, BTTV_OSPREY2x0_SVID,"Osprey-200" },
149 	{ 0xff020070, BTTV_OSPREY500,     "Osprey-500" },
150 	{ 0xff030070, BTTV_OSPREY2000,    "Osprey-2000" },
151 	{ 0xff040070, BTTV_OSPREY540,     "Osprey-540" },
152 
153 	{ 0x00011002, BTTV_ATI_TVWONDER,  "ATI TV Wonder" },
154 	{ 0x00031002, BTTV_ATI_TVWONDERVE,"ATI TV Wonder/VE" },
155 
156 	{ 0x6606107d, BTTV_WINFAST2000,   "Leadtek WinFast TV 2000" },
157 	{ 0x6607107d, BTTV_WINFAST2000,   "Leadtek WinFast VC 100" },
158 	{ 0x263610b4, BTTV_STB2,          "STB TV PCI FM, Gateway P/N 6000704" },
159 	{ 0x264510b4, BTTV_STB2,          "STB TV PCI FM, Gateway P/N 6000704" },
160  	{ 0x402010fc, BTTV_GVBCTV3PCI,    "I-O Data Co. GV-BCTV3/PCI" },
161 	{ 0x405010fc, BTTV_GVBCTV4PCI,    "I-O Data Co. GV-BCTV4/PCI" },
162 	{ 0x407010fc, BTTV_GVBCTV5PCI,    "I-O Data Co. GV-BCTV5/PCI" },
163 
164 	{ 0x001211bd, BTTV_PINNACLE,      "Pinnacle PCTV" },
165 	{ 0x001c11bd, BTTV_PINNACLESAT,   "Pinnacle PCTV Sat" },
166 	// some cards ship with byteswapped IDs ...
167 	{ 0x1200bd11, BTTV_PINNACLE,      "Pinnacle PCTV [bswap]" },
168 	{ 0xff00bd11, BTTV_PINNACLE,      "Pinnacle PCTV [bswap]" },
169 
170 	{ 0x3000121a, BTTV_VOODOOTV_FM,   "3Dfx VoodooTV FM/ VoodooTV 200" },
171 	{ 0x3060121a, BTTV_STB2,	  "3Dfx VoodooTV 100/ STB OEM" },
172 
173 	{ 0x3000144f, BTTV_MAGICTVIEW063, "(Askey Magic/others) TView99 CPH06x" },
174 	{ 0x3002144f, BTTV_MAGICTVIEW061, "(Askey Magic/others) TView99 CPH05x" },
175 	{ 0x3005144f, BTTV_MAGICTVIEW061, "(Askey Magic/others) TView99 CPH061/06L (T1/LC)" },
176 	{ 0x5000144f, BTTV_MAGICTVIEW061, "Askey CPH050" },
177 
178 	{ 0x00011461, BTTV_AVPHONE98,     "AVerMedia TVPhone98" },
179 	{ 0x00021461, BTTV_AVERMEDIA98,   "AVermedia TVCapture 98" },
180 	{ 0x00031461, BTTV_AVPHONE98,     "AVerMedia TVPhone98" },
181 	{ 0x00041461, BTTV_AVERMEDIA98,   "AVerMedia TVCapture 98" },
182 	{ 0x03001461, BTTV_AVERMEDIA98,   "VDOMATE TV TUNER CARD" },
183 
184 	{ 0x300014ff, BTTV_MAGICTVIEW061, "TView 99 (CPH061)" },
185 	{ 0x300214ff, BTTV_PHOEBE_TVMAS,  "Phoebe TV Master (CPH060)" },
186 
187 	{ 0x1117153b, BTTV_TERRATVALUE,   "Terratec TValue (Philips PAL B/G)" },
188 	{ 0x1118153b, BTTV_TERRATVALUE,   "Terratec TValue (Temic PAL B/G)" },
189 	{ 0x1119153b, BTTV_TERRATVALUE,   "Terratec TValue (Philips PAL I)" },
190 	{ 0x111a153b, BTTV_TERRATVALUE,   "Terratec TValue (Temic PAL I)" },
191 
192 	{ 0x1123153b, BTTV_TERRATVRADIO,  "Terratec TV Radio+" },
193 	{ 0x1127153b, BTTV_TERRATV,       "Terratec TV+ (V1.05)"    },
194 	// clashes with FlyVideo
195 	//{ 0x18521852, BTTV_TERRATV,     "Terratec TV+ (V1.10)"    },
196 	{ 0x1134153b, BTTV_TERRATVALUE,   "Terratec TValue (LR102)" },
197 	{ 0x1135153b, BTTV_TERRATVALUER,  "Terratec TValue Radio" }, // LR102
198 	{ 0x5018153b, BTTV_TERRATVALUE,   "Terratec TValue" }, // ??
199 
200 	{ 0x400015b0, BTTV_ZOLTRIX_GENIE, "Zoltrix Genie TV" },
201 	{ 0x400a15b0, BTTV_ZOLTRIX_GENIE, "Zoltrix Genie TV" },
202 	{ 0x400d15b0, BTTV_ZOLTRIX_GENIE, "Zoltrix Genie TV / Radio" },
203 	{ 0x401015b0, BTTV_ZOLTRIX_GENIE, "Zoltrix Genie TV / Radio" },
204 	{ 0x401615b0, BTTV_ZOLTRIX_GENIE, "Zoltrix Genie TV / Radio" },
205 
206 	{ 0x1430aa00, BTTV_PV143,         "Provideo PV143A" },
207 	{ 0x1431aa00, BTTV_PV143,         "Provideo PV143B" },
208 	{ 0x1432aa00, BTTV_PV143,         "Provideo PV143C" },
209 	{ 0x1433aa00, BTTV_PV143,         "Provideo PV143D" },
210 
211 	{ 0x1460aa00, BTTV_PV150,         "Provideo PV150A-1" },
212 	{ 0x1461aa01, BTTV_PV150,         "Provideo PV150A-2" },
213 	{ 0x1462aa02, BTTV_PV150,         "Provideo PV150A-3" },
214 	{ 0x1463aa03, BTTV_PV150,         "Provideo PV150A-4" },
215 
216 	{ 0x1464aa04, BTTV_PV150,         "Provideo PV150B-1" },
217 	{ 0x1465aa05, BTTV_PV150,         "Provideo PV150B-2" },
218 	{ 0x1466aa06, BTTV_PV150,         "Provideo PV150B-3" },
219 	{ 0x1467aa07, BTTV_PV150,         "Provideo PV150B-4" },
220 
221 	{ 0xa1550000, BTTV_IVC200,        "IVC-200" },
222 	{ 0xa1550001, BTTV_IVC200,        "IVC-200" },
223 	{ 0xa1550002, BTTV_IVC200,        "IVC-200" },
224 	{ 0xa1550003, BTTV_IVC200,        "IVC-200" },
225 	{ 0xa1550100, BTTV_IVC200,        "IVC-200G" },
226 	{ 0xa1550101, BTTV_IVC200,        "IVC-200G" },
227 	{ 0xa1550102, BTTV_IVC200,        "IVC-200G" },
228 	{ 0xa1550103, BTTV_IVC200,        "IVC-200G" },
229 
230 	{ 0x41424344, BTTV_GRANDTEC,      "GrandTec Multi Capture" },
231 	{ 0x01020304, BTTV_XGUARD,        "Grandtec Grand X-Guard" },
232 
233     	{ 0x010115cb, BTTV_GMV1,          "AG GMV1" },
234 	{ 0x010114c7, BTTV_MODTEC_205,    "Modular Technology MM201/MM202/MM205/MM210/MM215 PCTV" },
235 	{ 0x18501851, BTTV_CHRONOS_VS2,   "FlyVideo 98 (LR50)/ Chronos Video Shuttle II" },
236 	{ 0x18511851, BTTV_FLYVIDEO98EZ,  "FlyVideo 98EZ (LR51)/ CyberMail AV" },
237 	{ 0x18521852, BTTV_TYPHOON_TVIEW, "FlyVideo 98FM (LR50)/ Typhoon TView TV/FM Tuner" },
238 	{ 0x10b42636, BTTV_HAUPPAUGE878,  "STB ???" },
239 	{ 0x217d6606, BTTV_WINFAST2000,   "Leadtek WinFast TV 2000" },
240 	{ 0x03116000, BTTV_SENSORAY311,   "Sensoray 311" },
241 	{ 0x00790e11, BTTV_WINDVR,        "Canopus WinDVR PCI" },
242 	{ 0xa0fca1a0, BTTV_ZOLTRIX,       "Face to Face Tvmax" },
243 	{ 0x01010071, BTTV_NEBULA_DIGITV, "Nebula Electronics DigiTV" },
244 
245 	// likely broken, vendor id doesn't match the other magic views ...
246 	//{ 0xa0fca04f, BTTV_MAGICTVIEW063, "Guillemot Maxi TV Video 3" },
247 
248 	{ 0, -1, NULL }
249 };
250 
251 /* ----------------------------------------------------------------------- */
252 /* array with description for bt848 / bt878 tv/grabber cards               */
253 
254 struct tvcard bttv_tvcards[] = {
255 {
256 /* ---- card 0x00 ---------------------------------- */
257 	.name		= " *** UNKNOWN/GENERIC *** ",
258 	.video_inputs	= 4,
259 	.audio_inputs	= 1,
260 	.tuner		= 0,
261 	.svhs		= 2,
262 	.muxsel		= { 2, 3, 1, 0},
263 	.tuner_type	= -1,
264 },{
265 	.name		= "MIRO PCTV",
266 	.video_inputs	= 4,
267 	.audio_inputs	= 1,
268 	.tuner		= 0,
269 	.svhs		= 2,
270 	.gpiomask	= 15,
271 	.muxsel		= { 2, 3, 1, 1},
272 	.audiomux	= { 2, 0, 0, 0, 10},
273 	.needs_tvaudio	= 1,
274 	.tuner_type	= -1,
275 },{
276 	.name		= "Hauppauge (bt848)",
277 	.video_inputs	= 4,
278 	.audio_inputs	= 1,
279 	.tuner		= 0,
280 	.svhs		= 2,
281 	.gpiomask	= 7,
282 	.muxsel		= { 2, 3, 1, 1},
283 	.audiomux	= { 0, 1, 2, 3, 4},
284 	.needs_tvaudio	= 1,
285 	.tuner_type	= -1,
286 },{
287 	.name		= "STB, Gateway P/N 6000699 (bt848)",
288 	.video_inputs	= 3,
289 	.audio_inputs	= 1,
290 	.tuner		= 0,
291 	.svhs		= 2,
292 	.gpiomask	= 7,
293 	.muxsel		= { 2, 3, 1, 1},
294 	.audiomux	= { 4, 0, 2, 3, 1},
295 	.no_msp34xx	= 1,
296 	.needs_tvaudio	= 1,
297 	.tuner_type     = TUNER_PHILIPS_NTSC,
298 	.pll            = PLL_28,
299 	.has_radio      = 1,
300 },{
301 
302 /* ---- card 0x04 ---------------------------------- */
303 	.name		= "Intel Create and Share PCI/ Smart Video Recorder III",
304 	.video_inputs	= 4,
305 	.audio_inputs	= 0,
306 	.tuner		= -1,
307 	.svhs		= 2,
308 	.gpiomask	= 0,
309 	.muxsel		= { 2, 3, 1, 1},
310 	.audiomux	= { 0 },
311 	.needs_tvaudio	= 0,
312 	.tuner_type	= 4,
313 },{
314 	.name		= "Diamond DTV2000",
315 	.video_inputs	= 4,
316 	.audio_inputs	= 1,
317 	.tuner		= 0,
318 	.svhs		= 2,
319 	.gpiomask	= 3,
320 	.muxsel		= { 2, 3, 1, 0},
321 	.audiomux	= { 0, 1, 0, 1, 3},
322 	.needs_tvaudio	= 1,
323 	.tuner_type	= -1,
324 },{
325 	.name		= "AVerMedia TVPhone",
326 	.video_inputs	= 3,
327 	.audio_inputs	= 1,
328 	.tuner		= 0,
329 	.svhs		= 3,
330 	.muxsel		= { 2, 3, 1, 1},
331 	.gpiomask	= 0x0f,
332 	.audiomux	= { 0x0c, 0x04, 0x08, 0x04, 0},
333 	/*                0x04 for some cards ?? */
334 	.needs_tvaudio	= 1,
335 	.tuner_type	= -1,
336 	.audio_hook	= avermedia_tvphone_audio,
337 },{
338 	.name		= "MATRIX-Vision MV-Delta",
339 	.video_inputs	= 5,
340 	.audio_inputs	= 1,
341 	.tuner		= -1,
342 	.svhs		= 3,
343 	.gpiomask	= 0,
344 	.muxsel		= { 2, 3, 1, 0, 0},
345 	.audiomux	= {0 },
346 	.needs_tvaudio	= 1,
347 	.tuner_type	= -1,
348 },{
349 
350 /* ---- card 0x08 ---------------------------------- */
351 	.name		= "Lifeview FlyVideo II (Bt848) LR26 / MAXI TV Video PCI2 LR26",
352 	.video_inputs	= 4,
353 	.audio_inputs	= 1,
354 	.tuner		= 0,
355 	.svhs		= 2,
356 	.gpiomask	= 0xc00,
357 	.muxsel		= { 2, 3, 1, 1},
358 	.audiomux	= { 0, 0xc00, 0x800, 0x400, 0xc00, 0},
359 	.needs_tvaudio	= 1,
360 	.pll		= PLL_28,
361 	.tuner_type	= -1,
362 },{
363 	.name		= "IMS/IXmicro TurboTV",
364 	.video_inputs	= 3,
365 	.audio_inputs	= 1,
366 	.tuner		= 0,
367 	.svhs		= 2,
368 	.gpiomask	= 3,
369 	.muxsel		= { 2, 3, 1, 1},
370 	.audiomux	= { 1, 1, 2, 3, 0},
371 	.needs_tvaudio	= 0,
372 	.pll		= PLL_28,
373 	.tuner_type	= TUNER_TEMIC_PAL,
374 },{
375 	.name		= "Hauppauge (bt878)",
376 	.video_inputs	= 4,
377 	.audio_inputs	= 1,
378 	.tuner		= 0,
379 	.svhs		= 2,
380 	.gpiomask	= 0x0f, /* old: 7 */
381 	.muxsel		= { 2, 0, 1, 1},
382 	.audiomux	= { 0, 1, 2, 3, 4},
383 	.needs_tvaudio	= 1,
384 	.pll		= PLL_28,
385 	.tuner_type	= -1,
386 },{
387 	.name		= "MIRO PCTV pro",
388 	.video_inputs	= 3,
389 	.audio_inputs	= 1,
390 	.tuner		= 0,
391 	.svhs		= 2,
392 	.gpiomask	= 0x3014f,
393 	.muxsel		= { 2, 3, 1, 1},
394 	.audiomux	= { 0x20001,0x10001, 0, 0,10},
395 	.needs_tvaudio	= 1,
396 	.tuner_type	= -1,
397 },{
398 
399 /* ---- card 0x0c ---------------------------------- */
400 	.name		= "ADS Technologies Channel Surfer TV (bt848)",
401 	.video_inputs	= 3,
402 	.audio_inputs	= 1,
403 	.tuner		= 0,
404 	.svhs		= 2,
405 	.gpiomask	= 15,
406 	.muxsel		= { 2, 3, 1, 1},
407 	.audiomux	= { 13, 14, 11, 7, 0, 0},
408 	.needs_tvaudio	= 1,
409 	.tuner_type	= -1,
410 },{
411 	.name		= "AVerMedia TVCapture 98",
412 	.video_inputs	= 3,
413 	.audio_inputs	= 4,
414 	.tuner		= 0,
415 	.svhs		= 2,
416 	.gpiomask	= 15,
417 	.muxsel		= { 2, 3, 1, 1},
418 	.audiomux	= { 13, 14, 11, 7, 0, 0},
419 	.needs_tvaudio	= 1,
420 	.msp34xx_alt    = 1,
421 	.pll		= PLL_28,
422 	.tuner_type	= TUNER_PHILIPS_PAL,
423 },{
424 	.name		= "Aimslab Video Highway Xtreme (VHX)",
425 	.video_inputs	= 3,
426 	.audio_inputs	= 1,
427 	.tuner		= 0,
428 	.svhs		= 2,
429 	.gpiomask	= 7,
430 	.muxsel		= { 2, 3, 1, 1},
431 	.audiomux	= { 0, 2, 1, 3, 4}, /* old: { 0, 1, 2, 3, 4} */
432 	.needs_tvaudio	= 1,
433 	.pll		= PLL_28,
434 	.tuner_type	= -1,
435 },{
436 	.name		= "Zoltrix TV-Max",
437 	.video_inputs	= 3,
438 	.audio_inputs	= 1,
439 	.tuner		= 0,
440 	.svhs		= 2,
441 	.gpiomask	= 15,
442 	.muxsel		= { 2, 3, 1, 1},
443 	.audiomux	= {0 , 0, 1 , 0, 10},
444 	.needs_tvaudio	= 1,
445 	.tuner_type	= -1,
446 },{
447 
448 /* ---- card 0x10 ---------------------------------- */
449 	.name		= "Prolink Pixelview PlayTV (bt878)",
450 	.video_inputs	= 3,
451 	.audio_inputs	= 1,
452 	.tuner		= 0,
453 	.svhs		= 2,
454 	.gpiomask	= 0x01fe00,
455 	.muxsel		= { 2, 3, 1, 1},
456 	.audiomux	= { 0x01c000, 0, 0x018000, 0x014000, 0x002000, 0 },
457 	.needs_tvaudio	= 1,
458 	.pll		= PLL_28,
459 	.tuner_type	= -1,
460 },{
461 	.name		= "Leadtek WinView 601",
462 	.video_inputs	= 3,
463 	.audio_inputs	= 1,
464 	.tuner		= 0,
465 	.svhs		= 2,
466 	.gpiomask	= 0x8300f8,
467 	.muxsel		= { 2, 3, 1, 1,0},
468 	.audiomux	= { 0x4fa007,0xcfa007,0xcfa007,0xcfa007,0xcfa007,0xcfa007},
469 	.needs_tvaudio	= 1,
470 	.tuner_type	= -1,
471 	.audio_hook	= winview_audio,
472 	.has_radio	= 1,
473 },{
474 	.name		= "AVEC Intercapture",
475 	.video_inputs	= 3,
476 	.audio_inputs	= 2,
477 	.tuner		= 0,
478 	.svhs		= 2,
479 	.gpiomask	= 0,
480 	.muxsel		= {2, 3, 1, 1},
481 	.audiomux	= {1, 0, 0, 0, 0},
482 	.needs_tvaudio	= 1,
483 	.tuner_type	= -1,
484 },{
485 	.name		= "Lifeview FlyVideo II EZ /FlyKit LR38 Bt848 (capture only)",
486 	.video_inputs	= 4,
487 	.audio_inputs	= 1,
488 	.tuner		= -1,
489 	.svhs		= -1,
490 	.gpiomask	= 0x8dff00,
491 	.muxsel		= { 2, 3, 1, 1},
492 	.audiomux	= { 0 },
493 	.no_msp34xx	= 1,
494 	.tuner_type	= -1,
495 },{
496 
497 /* ---- card 0x14 ---------------------------------- */
498 	.name		= "CEI Raffles Card",
499 	.video_inputs	= 3,
500 	.audio_inputs	= 3,
501 	.tuner		= 0,
502 	.svhs		= 2,
503 	.muxsel		= {2, 3, 1, 1},
504 	.tuner_type	= -1,
505 },{
506 	.name		= "Lifeview FlyVideo 98/ Lucky Star Image World ConferenceTV LR50",
507 	.video_inputs	= 4,
508 	.audio_inputs	= 2,  // tuner, line in
509 	.tuner		= 0,
510 	.svhs		= 2,
511 	.gpiomask	= 0x1800,
512 	.muxsel		= { 2, 3, 1, 1},
513 	.audiomux	= { 0, 0x800, 0x1000, 0x1000, 0x1800},
514 	.pll		= PLL_28,
515 	.tuner_type	= TUNER_PHILIPS_PAL_I,
516 },{
517 	.name		= "Askey CPH050/ Phoebe Tv Master + FM",
518 	.video_inputs	= 3,
519 	.audio_inputs	= 1,
520 	.tuner		= 0,
521 	.svhs		= 2,
522 	.gpiomask	= 0xc00,
523 	.muxsel		= { 2, 3, 1, 1},
524 	.audiomux	= {0, 1, 0x800, 0x400, 0xc00, 0},
525 	.needs_tvaudio	= 1,
526 	.pll		= PLL_28,
527 	.tuner_type	= -1,
528 },{
529 	.name		= "Modular Technology MM201/MM202/MM205/MM210/MM215 PCTV, bt878",
530 	.video_inputs	= 3,
531 	.audio_inputs	= 1,
532 	.tuner		= 0,
533 	.svhs		= -1,
534 	.gpiomask	= 7,
535 	.muxsel		= { 2, 3, -1 },
536         .digital_mode   = DIGITAL_MODE_CAMERA,
537 	.audiomux	= { 0, 0, 0, 0, 0 },
538 	.no_msp34xx	= 1,
539 	.pll            = PLL_28,
540 	.tuner_type     = TUNER_ALPS_TSBB5_PAL_I,
541 },{
542 
543 /* ---- card 0x18 ---------------------------------- */
544 	.name		= "Askey CPH05X/06X (bt878) [many vendors]",
545 	.video_inputs	= 3,
546 	.audio_inputs	= 1,
547 	.tuner		= 0,
548 	.svhs		= 2,
549 	.gpiomask	= 0xe00,
550 	.muxsel		= { 2, 3, 1, 1},
551 	.audiomux	= {0x400, 0x400, 0x400, 0x400, 0xc00},
552 	.needs_tvaudio	= 1,
553 	.pll		= PLL_28,
554 	.tuner_type	= -1,
555 },{
556 	.name           = "Terratec TerraTV+ Version 1.0 (Bt848)/ Terra TValue Version 1.0/ Vobis TV-Boostar",
557 	.video_inputs	= 3,
558 	.audio_inputs	= 1,
559 	.tuner		= 0,
560 	.svhs		= 2,
561 	.gpiomask       = 0x1f0fff,
562 	.muxsel		= { 2, 3, 1, 1},
563 	.audiomux       = { 0x20000, 0x30000, 0x10000, 0, 0x40000},
564 	.needs_tvaudio	= 0,
565 	.tuner_type	= TUNER_PHILIPS_PAL,
566 	.audio_hook     = terratv_audio,
567 },{
568 	.name		= "Hauppauge WinCam newer (bt878)",
569 	.video_inputs	= 4,
570 	.audio_inputs	= 1,
571 	.tuner		= 0,
572 	.svhs		= 3,
573 	.gpiomask	= 7,
574 	.muxsel		= { 2, 0, 1, 1},
575 	.audiomux	= { 0, 1, 2, 3, 4},
576 	.needs_tvaudio	= 1,
577 	.tuner_type	= -1,
578 },{
579 	.name		= "Lifeview FlyVideo 98/ MAXI TV Video PCI2 LR50",
580 	.video_inputs	= 4,
581 	.audio_inputs	= 2,
582 	.tuner		= 0,
583 	.svhs		= 2,
584 	.gpiomask	= 0x1800,
585 	.muxsel		= { 2, 3, 1, 1},
586 	.audiomux	= { 0, 0x800, 0x1000, 0x1000, 0x1800},
587 	.pll            = PLL_28,
588 	.tuner_type	= TUNER_PHILIPS_SECAM,
589 },{
590 
591 /* ---- card 0x1c ---------------------------------- */
592 	.name           = "Terratec TerraTV+ Version 1.1 (bt878)",
593 	.video_inputs	= 3,
594 	.audio_inputs	= 1,
595 	.tuner		= 0,
596 	.svhs		= 2,
597 	.gpiomask	= 0x1f0fff,
598 	.muxsel		= { 2, 3, 1, 1},
599 	.audiomux	= { 0x20000, 0x30000, 0x10000, 0x00000, 0x40000},
600 	.needs_tvaudio	= 0,
601 	.tuner_type	= TUNER_PHILIPS_PAL,
602 	.audio_hook	= terratv_audio,
603 	/* GPIO wiring:
604                External 20 pin connector (for Active Radio Upgrade board)
605                gpio00: i2c-sda
606                gpio01: i2c-scl
607                gpio02: om5610-data
608                gpio03: om5610-clk
609                gpio04: om5610-wre
610                gpio05: om5610-stereo
611                gpio06: rds6588-davn
612                gpio07: Pin 7 n.c.
613                gpio08: nIOW
614                gpio09+10: nIOR, nSEL ?? (bt878)
615                 gpio09: nIOR (bt848)
616                 gpio10: nSEL (bt848)
617               Sound Routing:
618                gpio16: u2-A0 (1st 4052bt)
619                gpio17: u2-A1
620                gpio18: u2-nEN
621                gpio19: u4-A0 (2nd 4052)
622                gpio20: u4-A1
623                        u4-nEN - GND
624 	    Btspy:
625 	  	00000 : Cdrom (internal audio input)
626 		10000 : ext. Video audio input
627 		20000 : TV Mono
628 		a0000 : TV Mono/2
629 	       1a0000 : TV Stereo
630 		30000 : Radio
631 		40000 : Mute
632        */
633 
634 },{
635 	/* Jannik Fritsch <jannik@techfak.uni-bielefeld.de> */
636 	.name		= "Imagenation PXC200",
637 	.video_inputs	= 5,
638 	.audio_inputs	= 1,
639 	.tuner		= -1,
640 	.svhs		= 1, /* was: 4 */
641 	.gpiomask	= 0,
642 	.muxsel		= { 2, 3, 1, 0, 0},
643 	.audiomux	= { 0 },
644 	.needs_tvaudio	= 1,
645 	.tuner_type	= -1,
646 },{
647 	.name		= "Lifeview FlyVideo 98 LR50",
648 	.video_inputs	= 4,
649 	.audio_inputs	= 1,
650 	.tuner		= 0,
651 	.svhs		= 2,
652 	.gpiomask	= 0x1800,  //0x8dfe00
653 	.muxsel		= { 2, 3, 1, 1},
654 	.audiomux	= { 0, 0x0800, 0x1000, 0x1000, 0x1800, 0 },
655 	.pll            = PLL_28,
656 	.tuner_type	= -1,
657 },{
658 	.name		= "Formac iProTV, Formac ProTV I (bt848)",
659 	.video_inputs	= 4,
660 	.audio_inputs	= 1,
661 	.tuner		= 0,
662 	.svhs		= 3,
663 	.gpiomask	= 1,
664 	.muxsel		= { 2, 3, 1, 1},
665 	.audiomux	= { 1, 0, 0, 0, 0 },
666 	.pll            = PLL_28,
667 	.tuner_type	= TUNER_PHILIPS_PAL,
668 },{
669 
670 /* ---- card 0x20 ---------------------------------- */
671 	.name		= "Intel Create and Share PCI/ Smart Video Recorder III",
672 	.video_inputs	= 4,
673 	.audio_inputs	= 0,
674 	.tuner		= -1,
675 	.svhs		= 2,
676 	.gpiomask	= 0,
677 	.muxsel		= { 2, 3, 1, 1},
678 	.audiomux	= { 0 },
679 	.needs_tvaudio	= 0,
680 	.tuner_type	= 4,
681 },{
682 	.name           = "Terratec TerraTValue Version Bt878",
683 	.video_inputs	= 3,
684 	.audio_inputs	= 1,
685 	.tuner		= 0,
686 	.svhs		= 2,
687 	.gpiomask	= 0xffff00,
688 	.muxsel		= { 2, 3, 1, 1},
689 	.audiomux	= { 0x500, 0, 0x300, 0x900, 0x900},
690 	.needs_tvaudio	= 1,
691 	.pll		= PLL_28,
692 	.tuner_type	= TUNER_PHILIPS_PAL,
693 },{
694 	.name		= "Leadtek WinFast 2000/ WinFast 2000 XP",
695 	.video_inputs	= 4,
696 	.audio_inputs	= 1,
697 	.tuner		= 0,
698 	.svhs		= 2,
699 	.gpiomask	= 0xc33000,
700 	.muxsel		= { 2, 3, 1, 1, 0}, // TV, CVid, SVid, CVid over SVid connector
701 	.audiomux	= { 0x422000,0x1000,0x0000,0x620000,0x800000},
702 	/* Audio Routing for "WinFast 2000 XP" (no tv stereo !)
703 		gpio23 -- hef4052:nEnable (0x800000)
704 		gpio12 -- hef4052:A1
705 	        gpio13 -- hef4052:A0
706 	    0x0000: external audio
707 	    0x1000: FM
708 	    0x2000: TV
709 	    0x3000: n.c.
710           Note: There exists another variant "Winfast 2000" with tv stereo !?
711 	  Note: eeprom only contains FF and pci subsystem id 107d:6606
712 	 */
713 	.needs_tvaudio	= 0,
714 	.pll		= PLL_28,
715 	.has_radio	= 1,
716 	.tuner_type	= 5, // default for now, gpio reads BFFF06 for Pal bg+dk
717 	.audio_hook	= winfast2000_audio,
718 },{
719 	.name		= "Lifeview FlyVideo 98 LR50 / Chronos Video Shuttle II",
720 	.video_inputs	= 4,
721 	.audio_inputs	= 3,
722 	.tuner		= 0,
723 	.svhs		= 2,
724 	.gpiomask	= 0x1800,
725 	.muxsel		= { 2, 3, 1, 1},
726 	.audiomux	= { 0, 0x800, 0x1000, 0x1000, 0x1800},
727 	.pll		= PLL_28,
728 	.tuner_type	= -1,
729 },{
730 
731 /* ---- card 0x24 ---------------------------------- */
732 	.name		= "Lifeview FlyVideo 98FM LR50 / Typhoon TView TV/FM Tuner",
733 	.video_inputs	= 4,
734 	.audio_inputs	= 3,
735 	.tuner		= 0,
736 	.svhs		= 2,
737 	.gpiomask	= 0x1800,
738 	.muxsel		= { 2, 3, 1, 1},
739 	.audiomux	= { 0, 0x800, 0x1000, 0x1000, 0x1800, 0 },
740 	.pll		= PLL_28,
741 	.tuner_type	= -1,
742 	.has_radio	= 1,
743 },{
744 	.name		= "Prolink PixelView PlayTV pro",
745 	.video_inputs	= 3,
746 	.audio_inputs	= 1,
747 	.tuner		= 0,
748 	.svhs		= 2,
749 	.gpiomask	= 0xff,
750 	.muxsel		= { 2, 3, 1, 1 },
751 	.audiomux	= { 0x21, 0x20, 0x24, 0x2c, 0x29, 0x29 },
752 	.no_msp34xx	= 1,
753 	.pll		= PLL_28,
754 	.tuner_type	= -1,
755 },{
756 	.name		= "Askey CPH06X TView99",
757 	.video_inputs	= 4,
758 	.audio_inputs	= 1,
759 	.tuner		= 0,
760 	.svhs		= 2,
761 	.gpiomask	= 0x551e00,
762 	.muxsel		= { 2, 3, 1, 0},
763 	.audiomux	= { 0x551400, 0x551200, 0, 0, 0x551c00, 0x551200 },
764 	.needs_tvaudio	= 1,
765 	.pll		= PLL_28,
766 	.tuner_type	= 1,
767 },{
768 	.name		= "Pinnacle PCTV Studio/Rave",
769 	.video_inputs	= 3,
770 	.audio_inputs	= 1,
771 	.tuner		= 0,
772 	.svhs		= 2,
773 	.gpiomask	= 0x03000F,
774 	.muxsel		= { 2, 3, 1, 1},
775 	.audiomux	= { 2, 0, 0, 0, 1},
776 	.needs_tvaudio	= 1,
777 	.pll		= PLL_28,
778 	.tuner_type	= -1,
779 },{
780 
781 /* ---- card 0x28 ---------------------------------- */
782 	.name		= "STB TV PCI FM, Gateway P/N 6000704 (bt878), 3Dfx VoodooTV 100",
783 	.video_inputs	= 3,
784 	.audio_inputs	= 1,
785 	.tuner		= 0,
786 	.svhs		= 2,
787 	.gpiomask	= 7,
788 	.muxsel		= { 2, 3, 1, 1},
789 	.audiomux	= { 4, 0, 2, 3, 1},
790 	.no_msp34xx	= 1,
791 	.needs_tvaudio	= 1,
792 	.tuner_type     = TUNER_PHILIPS_NTSC,
793 	.pll            = PLL_28,
794 	.has_radio      = 1,
795 },{
796 	.name		= "AVerMedia TVPhone 98",
797 	.video_inputs	= 3,
798 	.audio_inputs	= 4,
799 	.tuner		= 0,
800 	.svhs		= 2,
801 	.gpiomask	= 15,
802 	.muxsel		= { 2, 3, 1, 1},
803 	.audiomux	= { 13, 4, 11, 7, 0, 0},
804 	.needs_tvaudio	= 1,
805 	.pll		= PLL_28,
806 	.tuner_type	= -1,
807 	.has_radio	= 1,
808 	.audio_hook	= avermedia_tvphone_audio,
809 },{
810 	.name		= "ProVideo PV951", /* pic16c54 */
811 	.video_inputs	= 3,
812 	.audio_inputs	= 1,
813 	.tuner		= 0,
814 	.svhs		= 2,
815 	.gpiomask	= 0,
816 	.muxsel		= { 2, 3, 1, 1},
817 	.audiomux	= { 0, 0, 0, 0, 0},
818 	.needs_tvaudio	= 1,
819 	.no_msp34xx	= 1,
820 	.pll		= PLL_28,
821 	.tuner_type	= 1,
822 },{
823 	.name		= "Little OnAir TV",
824 	.video_inputs	= 3,
825 	.audio_inputs	= 1,
826 	.tuner		= 0,
827 	.svhs		= 2,
828 	.gpiomask	= 0xe00b,
829 	.muxsel		= {2, 3, 1, 1},
830 	.audiomux	= {0xff9ff6, 0xff9ff6, 0xff1ff7, 0, 0xff3ffc},
831 	.no_msp34xx	= 1,
832 	.tuner_type	= -1,
833 },{
834 
835 /* ---- card 0x2c ---------------------------------- */
836 	.name		= "Sigma TVII-FM",
837 	.video_inputs	= 2,
838 	.audio_inputs	= 1,
839 	.tuner		= 0,
840 	.svhs		= -1,
841 	.gpiomask	= 3,
842 	.muxsel		= {2, 3, 1, 1},
843 	.audiomux	= {1, 1, 0, 2, 3},
844 	.no_msp34xx	= 1,
845 	.pll		= PLL_NONE,
846 	.tuner_type	= -1,
847 },{
848 	.name		= "MATRIX-Vision MV-Delta 2",
849 	.video_inputs	= 5,
850 	.audio_inputs	= 1,
851 	.tuner		= -1,
852 	.svhs		= 3,
853 	.gpiomask	= 0,
854 	.muxsel		= { 2, 3, 1, 0, 0},
855 	.audiomux	= {0 },
856 	.no_msp34xx	= 1,
857 	.pll		= PLL_28,
858 	.tuner_type	= -1,
859 },{
860 	.name		= "Zoltrix Genie TV/FM",
861 	.video_inputs	= 3,
862 	.audio_inputs	= 1,
863 	.tuner		= 0,
864 	.svhs		= 2,
865 	.gpiomask	= 0xbcf03f,
866 	.muxsel		= { 2, 3, 1, 1},
867 	.audiomux	= { 0xbc803f, 0xbc903f, 0xbcb03f, 0, 0xbcb03f},
868 	.no_msp34xx	= 1,
869 	.pll		= PLL_28,
870 	.tuner_type	= 21,
871 },{
872 	.name		= "Terratec TV/Radio+",
873 	.video_inputs	= 3,
874 	.audio_inputs	= 1,
875 	.tuner		= 0,
876 	.svhs		= 2,
877 	.gpiomask	= 0x70000,
878 	.muxsel		= { 2, 3, 1, 1},
879 	.audiomux	= { 0x20000, 0x30000, 0x10000, 0, 0x40000, 0x20000 },
880 	.needs_tvaudio	= 1,
881 	.no_msp34xx	= 1,
882 	.pll		= PLL_35,
883 	.tuner_type	= 1,
884 	.has_radio	= 1,
885 },{
886 
887 /* ---- card 0x30 ---------------------------------- */
888 	.name		= "Askey CPH03x/ Dynalink Magic TView",
889 	.video_inputs	= 3,
890 	.audio_inputs	= 1,
891 	.tuner		= 0,
892 	.svhs		= 2,
893 	.gpiomask	= 15,
894 	.muxsel		= { 2, 3, 1, 1},
895 	.audiomux	= {2,0,0,0,1},
896 	.needs_tvaudio	= 1,
897 	.pll		= PLL_28,
898 	.tuner_type	= -1,
899 },{
900 	.name		= "IODATA GV-BCTV3/PCI",
901 	.video_inputs	= 3,
902 	.audio_inputs	= 1,
903 	.tuner		= 0,
904 	.svhs		= 2,
905 	.gpiomask	= 0x010f00,
906 	.muxsel		= {2, 3, 0, 0},
907 	.audiomux	= {0x10000, 0, 0x10000, 0, 0, 0},
908 	.no_msp34xx	= 1,
909 	.pll		= PLL_28,
910 	.tuner_type	= TUNER_ALPS_TSHC6_NTSC,
911 	.audio_hook	= gvbctv3pci_audio,
912 },{
913 	.name		= "Prolink PV-BT878P+4E / PixelView PlayTV PAK / Lenco MXTV-9578 CP",
914 	.video_inputs	= 5,
915 	.audio_inputs	= 1,
916 	.tuner		= 0,
917 	.svhs		= 3,
918 	.gpiomask	= 0xAA0000,
919 	.muxsel		= { 2,3,1,1,-1 },
920 	.digital_mode   = DIGITAL_MODE_CAMERA,
921 	.audiomux	= { 0x20000, 0, 0x80000, 0x80000, 0xa8000, 0x46000  },
922 	.no_msp34xx	= 1,
923 	.pll		= PLL_28,
924 	.tuner_type	= TUNER_PHILIPS_PAL_I,
925 	/* GPIO wiring: (different from Rev.4C !)
926 		GPIO17: U4.A0 (first hef4052bt)
927 		GPIO19: U4.A1
928 		GPIO20: U5.A1 (second hef4052bt)
929 		GPIO21: U4.nEN
930 		GPIO22: BT832 Reset Line
931 		GPIO23: A5,A0, U5,nEN
932 	   Note: At i2c=0x8a is a Bt832 chip, which changes to 0x88 after being reset via GPIO22
933 	 */
934 },{
935 	.name           = "Eagle Wireless Capricorn2 (bt878A)",
936 	.video_inputs   = 4,
937 	.audio_inputs   = 1,
938 	.tuner          = 0,
939 	.svhs           = 2,
940 	.gpiomask       = 7,
941 	.muxsel         = { 2, 0, 1, 1},
942 	.audiomux       = { 0, 1, 2, 3, 4},
943 	.pll            = PLL_28,
944 	.tuner_type     = -1 /* TUNER_ALPS_TMDH2_NTSC */,
945 },{
946 
947 /* ---- card 0x34 ---------------------------------- */
948 	/* David H�rdeman <david@2gen.com> */
949 	.name           = "Pinnacle PCTV Studio Pro",
950 	.video_inputs   = 4,
951 	.audio_inputs   = 1,
952 	.tuner          = 0,
953 	.svhs           = 3,
954 	.gpiomask       = 0x03000F,
955 	.muxsel		= { 2, 3, 1, 1},
956 	.audiomux	= { 1, 0xd0001, 0, 0, 10},
957 			/* sound path (5 sources):
958 			   MUX1 (mask 0x03), Enable Pin 0x08 (0=enable, 1=disable)
959 				0= ext. Audio IN
960 				1= from MUX2
961 				2= Mono TV sound from Tuner
962 				3= not connected
963 			   MUX2 (mask 0x30000):
964 				0,2,3= from MSP34xx
965 				1= FM stereo Radio from Tuner */
966 	.needs_tvaudio  = 1,
967 	.pll            = PLL_28,
968 	.tuner_type     = -1,
969 },{
970 	/* Claas Langbehn <claas@bigfoot.com>,
971 	   Sven Grothklags <sven@upb.de> */
972 	.name		= "Typhoon TView RDS + FM Stereo / KNC1 TV Station RDS",
973 	.video_inputs	= 3,
974 	.audio_inputs	= 3,
975 	.tuner		= 0,
976 	.svhs		= 2,
977 	.gpiomask	= 0x1c,
978 	.muxsel		= { 2, 3, 1, 1},
979 	.audiomux	= { 0, 0, 0x10, 8, 4 },
980 	.needs_tvaudio	= 1,
981 	.pll		= PLL_28,
982 	.tuner_type	= TUNER_PHILIPS_PAL_I,
983 	.has_radio	= 1,
984 },{
985 	/* Tim R�stermundt <rosterm@uni-muenster.de>
986 	   in de.comp.os.unix.linux.hardware:
987 		options bttv card=0 pll=1 radio=1 gpiomask=0x18e0
988 		audiomux=0x44c71f,0x44d71f,0,0x44d71f,0x44dfff
989 		options tuner type=5 */
990 	.name		= "Lifeview FlyVideo 2000 /FlyVideo A2/ Lifetec LT 9415 TV [LR90]",
991 	.video_inputs	= 4,
992 	.audio_inputs	= 1,
993 	.tuner		= 0,
994 	.svhs		= 2,
995 	.gpiomask	= 0x18e0,
996 	.muxsel		= { 2, 3, 1, 1},
997 	.audiomux	= { 0x0000,0x0800,0x1000,0x1000,0x18e0 },
998 		       /* For cards with tda9820/tda9821:
999 			  0x0000: Tuner normal stereo
1000 			  0x0080: Tuner A2 SAP (second audio program = Zweikanalton)
1001 			  0x0880: Tuner A2 stereo */
1002 	.pll		= PLL_28,
1003 	.tuner_type	= -1,
1004 },{
1005 	/* Miguel Angel Alvarez <maacruz@navegalia.com>
1006 	   old Easy TV BT848 version (model CPH031) */
1007 	.name           = "Askey CPH031/ BESTBUY Easy TV",
1008 	.video_inputs	= 4,
1009 	.audio_inputs   = 1,
1010 	.tuner          = 0,
1011 	.svhs           = 2,
1012 	.gpiomask       = 0xF,
1013 	.muxsel         = { 2, 3, 1, 0},
1014 	.audiomux       = { 2, 0, 0, 0, 10},
1015 	.needs_tvaudio  = 0,
1016 	.pll		= PLL_28,
1017 	.tuner_type	= TUNER_TEMIC_PAL,
1018 },{
1019 
1020 /* ---- card 0x38 ---------------------------------- */
1021 	/* Gordon Heydon <gjheydon@bigfoot.com ('98) */
1022 	.name           = "Lifeview FlyVideo 98FM LR50",
1023 	.video_inputs   = 4,
1024 	.audio_inputs   = 3,
1025 	.tuner          = 0,
1026 	.svhs           = 2,
1027 	.gpiomask       = 0x1800,
1028 	.muxsel         = { 2, 3, 1, 1},
1029 	.audiomux       = { 0, 0x800, 0x1000, 0x1000, 0x1800, 0 },
1030 	.pll            = PLL_28,
1031 	.tuner_type     = 5,
1032 },{
1033 	/* This is the ultimate cheapo capture card
1034 	 * just a BT848A on a small PCB!
1035 	 * Steve Hosgood <steve@equiinet.com> */
1036 	.name           = "GrandTec 'Grand Video Capture' (Bt848)",
1037 	.video_inputs   = 2,
1038 	.audio_inputs   = 0,
1039 	.tuner          = -1,
1040 	.svhs           = 1,
1041 	.gpiomask       = 0,
1042 	.muxsel         = { 3, 1 },
1043 	.audiomux       = { 0 },
1044 	.needs_tvaudio  = 0,
1045 	.no_msp34xx     = 1,
1046 	.pll            = PLL_35,
1047 	.tuner_type     = -1,
1048 },{
1049         /* Daniel Herrington <daniel.herrington@home.com> */
1050         .name           = "Askey CPH060/ Phoebe TV Master Only (No FM)",
1051         .video_inputs   = 3,
1052         .audio_inputs   = 1,
1053         .tuner          = 0,
1054         .svhs           = 2,
1055         .gpiomask       = 0xe00,
1056         .muxsel         = { 2, 3, 1, 1},
1057         .audiomux       = { 0x400, 0x400, 0x400, 0x400, 0x800, 0x400 },
1058         .needs_tvaudio  = 1,
1059         .pll            = PLL_28,
1060         .tuner_type     = TUNER_TEMIC_4036FY5_NTSC,
1061 },{
1062 	/* Matti Mottus <mottus@physic.ut.ee> */
1063 	.name		= "Askey CPH03x TV Capturer",
1064 	.video_inputs	= 4,
1065 	.audio_inputs	= 1,
1066 	.tuner		= 0,
1067 	.svhs		= 2,
1068         .gpiomask       = 0x03000F,
1069 	.muxsel		= { 2, 3, 1, 0},
1070         .audiomux       = { 2,0,0,0,1 },
1071 	.pll            = PLL_28,
1072 	.tuner_type	= 0,
1073 },{
1074 
1075 /* ---- card 0x3c ---------------------------------- */
1076 	/* Philip Blundell <philb@gnu.org> */
1077 	.name           = "Modular Technology MM100PCTV",
1078 	.video_inputs   = 2,
1079 	.audio_inputs   = 2,
1080 	.tuner		= 0,
1081 	.svhs		= -1,
1082 	.gpiomask       = 11,
1083 	.muxsel         = { 2, 3, 1, 1},
1084 	.audiomux       = { 2, 0, 0, 1, 8},
1085 	.pll            = PLL_35,
1086 	.tuner_type     = TUNER_TEMIC_PAL,
1087 
1088 },{
1089 	/* Adrian Cox <adrian@humboldt.co.uk */
1090 	.name	        = "AG Electronics GMV1",
1091 	.video_inputs   = 2,
1092 	.audio_inputs   = 0,
1093 	.tuner	        = -1,
1094 	.svhs	        = 1,
1095 	.gpiomask       = 0xF,
1096 	.muxsel	        = { 2, 2},
1097 	.audiomux       = { },
1098 	.no_msp34xx     = 1,
1099 	.needs_tvaudio  = 0,
1100 	.pll	        = PLL_28,
1101 	.tuner_type     = -1,
1102 },{
1103 	/* Miguel Angel Alvarez <maacruz@navegalia.com>
1104 	   new Easy TV BT878 version (model CPH061)
1105 	   special thanks to Informatica Mieres for providing the card */
1106 	.name           = "Askey CPH061/ BESTBUY Easy TV (bt878)",
1107 	.video_inputs	= 3,
1108 	.audio_inputs   = 2,
1109 	.tuner          = 0,
1110 	.svhs           = 2,
1111 	.gpiomask       = 0xFF,
1112 	.muxsel         = { 2, 3, 1, 0},
1113 	.audiomux       = { 1, 0, 4, 4, 9},
1114 	.needs_tvaudio  = 0,
1115 	.pll		= PLL_28,
1116 	.tuner_type	= TUNER_PHILIPS_PAL,
1117 },{
1118 	/* Lukas Gebauer <geby@volny.cz> */
1119 	.name		= "ATI TV-Wonder",
1120 	.video_inputs	= 3,
1121 	.audio_inputs	= 1,
1122 	.tuner		= 0,
1123 	.svhs		= 2,
1124 	.gpiomask	= 0xf03f,
1125 	.muxsel		= { 2, 3, 1, 0 },
1126 	.audiomux	= { 0xbffe, 0, 0xbfff, 0, 0xbffe},
1127 	.pll		= PLL_28,
1128 	.tuner_type	= TUNER_TEMIC_4006FN5_MULTI_PAL,
1129 },{
1130 
1131 /* ---- card 0x40 ---------------------------------- */
1132 	/* Lukas Gebauer <geby@volny.cz> */
1133 	.name		= "ATI TV-Wonder VE",
1134 	.video_inputs	= 2,
1135 	.audio_inputs	= 1,
1136 	.tuner		= 0,
1137 	.svhs		= -1,
1138 	.gpiomask	= 1,
1139 	.muxsel		= { 2, 3, 0, 1},
1140 	.audiomux	= { 0, 0, 1, 0, 0},
1141 	.no_msp34xx	= 1,
1142 	.pll		= PLL_28,
1143 	.tuner_type	= TUNER_TEMIC_4006FN5_MULTI_PAL,
1144 },{
1145 	/* DeeJay <deejay@westel900.net (2000S) */
1146 	.name           = "Lifeview FlyVideo 2000S LR90",
1147 	.video_inputs   = 3,
1148 	.audio_inputs   = 3,
1149 	.tuner          = 0,
1150 	.svhs           = 2,
1151 	.gpiomask	= 0x18e0,
1152 	.muxsel		= { 2, 3, 0, 1},
1153 			/* Radio changed from 1e80 to 0x800 to make
1154 			   FlyVideo2000S in .hu happy (gm)*/
1155 			/* -dk-???: set mute=0x1800 for tda9874h daughterboard */
1156 	.audiomux	= { 0x0000,0x0800,0x1000,0x1000,0x1800, 0x1080 },
1157 	.audio_hook	= fv2000s_audio,
1158 	.no_msp34xx	= 1,
1159 	.no_tda9875	= 1,
1160 	.needs_tvaudio  = 1,
1161 	.pll            = PLL_28,
1162 	.tuner_type     = 5,
1163 },{
1164 	.name		= "Terratec TValueRadio",
1165 	.video_inputs	= 3,
1166 	.audio_inputs	= 1,
1167 	.tuner		= 0,
1168 	.svhs		= 2,
1169 	.gpiomask	= 0xffff00,
1170 	.muxsel		= { 2, 3, 1, 1},
1171 	.audiomux	= { 0x500, 0x500, 0x300, 0x900, 0x900},
1172 	.needs_tvaudio	= 1,
1173 	.pll		= PLL_28,
1174 	.tuner_type	= TUNER_PHILIPS_PAL,
1175 	.has_radio	= 1,
1176 },{
1177 	/* TANAKA Kei <peg00625@nifty.com> */
1178 	.name           = "IODATA GV-BCTV4/PCI",
1179 	.video_inputs   = 3,
1180 	.audio_inputs   = 1,
1181 	.tuner          = 0,
1182 	.svhs           = 2,
1183 	.gpiomask       = 0x010f00,
1184 	.muxsel         = {2, 3, 0, 0},
1185 	.audiomux       = {0x10000, 0, 0x10000, 0, 0, 0},
1186 	.no_msp34xx     = 1,
1187 	.pll            = PLL_28,
1188 	.tuner_type     = TUNER_SHARP_2U5JF5540_NTSC,
1189 	.audio_hook     = gvbctv3pci_audio,
1190 },{
1191 
1192 /* ---- card 0x44 ---------------------------------- */
1193         .name           = "3Dfx VoodooTV FM (Euro), VoodooTV 200 (USA)",
1194 	// try "insmod msp3400 simple=0" if you have
1195 	// sound problems with this card.
1196         .video_inputs   = 4,
1197         .audio_inputs   = 1,
1198         .tuner          = 0,
1199         .svhs           = -1,
1200         .gpiomask       = 0x4f8a00,
1201 	// 0x100000: 1=MSP enabled (0=disable again)
1202 	// 0x010000: Connected to "S0" on tda9880 (0=Pal/BG, 1=NTSC)
1203         .audiomux       = {0x947fff, 0x987fff,0x947fff,0x947fff, 0x947fff},
1204 	// tvtuner, radio,   external,internal, mute,  stereo
1205 	/* tuner, Composit, SVid, Composit-on-Svid-adapter*/
1206         .muxsel         = { 2, 3 ,0 ,1},
1207         .tuner_type     = TUNER_MT2032,
1208 	.pll		= PLL_28,
1209 	.has_radio	= 1,
1210 },{
1211 	/* Philip Blundell <pb@nexus.co.uk> */
1212 	.name           = "Active Imaging AIMMS",
1213 	.video_inputs   = 1,
1214 	.audio_inputs   = 0,
1215 	.tuner          = -1,
1216 	.tuner_type     = -1,
1217 	.pll            = PLL_28,
1218 	.muxsel         = { 2 },
1219 	.gpiomask       = 0
1220 },{
1221         /* Tomasz Pyra <hellfire@sedez.iq.pl> */
1222         .name           = "Prolink Pixelview PV-BT878P+ (Rev.4C,8E)",
1223         .video_inputs   = 3,
1224         .audio_inputs   = 4,
1225         .tuner          = 0,
1226         .svhs           = 2,
1227         .gpiomask       = 15,
1228         .muxsel         = { 2, 3, 1, 1},
1229         .audiomux       = { 0, 0, 11, 7, 13, 0}, // TV and Radio with same GPIO !
1230         .needs_tvaudio  = 1,
1231         .pll            = PLL_28,
1232         .tuner_type     = 25,
1233 	/* GPIO wiring:
1234 		GPIO0: U4.A0 (hef4052bt)
1235 		GPIO1: U4.A1
1236 		GPIO2: U4.A1 (second hef4052bt)
1237 		GPIO3: U4.nEN, U5.A0, A5.nEN
1238 		GPIO8-15: vrd866b ?
1239 	 */
1240 },{
1241 	.name		= "Lifeview FlyVideo 98EZ (capture only) LR51",
1242 	.video_inputs	= 4,
1243 	.audio_inputs   = 0,
1244 	.tuner		= -1,
1245 	.svhs		= 2,
1246 	.muxsel		= { 2, 3, 1, 1}, // AV1, AV2, SVHS, CVid adapter on SVHS
1247 	.pll		= PLL_28,
1248 	.no_msp34xx	= 1,
1249 },{
1250 
1251 /* ---- card 0x48 ---------------------------------- */
1252 	/* Dariusz Kowalewski <darekk@automex.pl> */
1253 	.name		= "Prolink Pixelview PV-BT878P+9B (PlayTV Pro rev.9B FM+NICAM)",
1254 	.video_inputs	= 4,
1255 	.audio_inputs	= 1,
1256 	.tuner		= 0,
1257 	.svhs		= 2,
1258 	.gpiomask	= 0x3f,
1259 	.muxsel		= { 2, 3, 1, 1 },
1260 	.audiomux	= { 0x01, 0x00, 0x03, 0x03, 0x09, 0x02 },
1261 	.needs_tvaudio  = 1,
1262 	.no_msp34xx	= 1,
1263 	.no_tda9875	= 1,
1264 	.pll		= PLL_28,
1265 	.tuner_type	= 5,
1266 	.audio_hook	= pvbt878p9b_audio, // Note: not all cards have stereo
1267 	.has_radio	= 1,  // Note: not all cards have radio
1268 	/* GPIO wiring:
1269 		GPIO0: A0 hef4052
1270 		GPIO1: A1 hef4052
1271 		GPIO3: nEN hef4052
1272 		GPIO8-15: vrd866b
1273 		GPIO20,22,23: R30,R29,R28
1274 	 */
1275 },{
1276 	/* Clay Kunz <ckunz@mail.arc.nasa.gov> */
1277 	/* you must jumper JP5 for the card to work */
1278 	.name           = "Sensoray 311",
1279 	.video_inputs   = 5,
1280 	.audio_inputs   = 0,
1281 	.tuner          = -1,
1282 	.svhs           = 4,
1283 	.gpiomask       = 0,
1284 	.muxsel         = { 2, 3, 1, 0, 0},
1285 	.audiomux       = { 0 },
1286 	.needs_tvaudio  = 0,
1287 	.tuner_type     = -1,
1288 },{
1289 	/* Miguel Freitas <miguel@cetuc.puc-rio.br> */
1290 	.name           = "RemoteVision MX (RV605)",
1291 	.video_inputs   = 16,
1292 	.audio_inputs   = 0,
1293 	.tuner          = -1,
1294 	.svhs           = -1,
1295 	.gpiomask       = 0x00,
1296 	.gpiomask2      = 0x07ff,
1297 	.muxsel         = { 0x33, 0x13, 0x23, 0x43, 0xf3, 0x73, 0xe3, 0x03,
1298 			  0xd3, 0xb3, 0xc3, 0x63, 0x93, 0x53, 0x83, 0xa3 },
1299 	.no_msp34xx     = 1,
1300 	.no_tda9875     = 1,
1301 	.tuner_type     = -1,
1302 	.muxsel_hook    = rv605_muxsel,
1303 },{
1304         .name           = "Powercolor MTV878/ MTV878R/ MTV878F",
1305         .video_inputs   = 3,
1306         .audio_inputs   = 2,
1307 	.tuner		= 0,
1308         .svhs           = 2,
1309         .gpiomask       = 0x1C800F,  // Bit0-2: Audio select, 8-12:remote control 14:remote valid 15:remote reset
1310         .muxsel         = { 2, 1, 1, },
1311         .audiomux       = { 0, 1, 2, 2, 4 },
1312         .needs_tvaudio  = 0,
1313         .tuner_type     = TUNER_PHILIPS_PAL,
1314 	.pll		= PLL_28,
1315 	.has_radio	= 1,
1316 },{
1317 
1318 /* ---- card 0x4c ---------------------------------- */
1319         /* Masaki Suzuki <masaki@btree.org> */
1320         .name           = "Canopus WinDVR PCI (COMPAQ Presario 3524JP, 5112JP)",
1321         .video_inputs   = 3,
1322         .audio_inputs   = 1,
1323         .tuner          = 0,
1324         .svhs           = 2,
1325         .gpiomask       = 0x140007,
1326         .muxsel         = { 2, 3, 1, 1 },
1327         .audiomux       = { 0, 1, 2, 3, 4, 0 },
1328         .tuner_type     = TUNER_PHILIPS_NTSC,
1329         .audio_hook     = windvr_audio,
1330 },{
1331         .name           = "GrandTec Multi Capture Card (Bt878)",
1332         .video_inputs   = 4,
1333         .audio_inputs   = 0,
1334         .tuner          = -1,
1335         .svhs           = -1,
1336         .gpiomask       = 0,
1337         .muxsel         = { 2, 3, 1, 0 },
1338         .audiomux       = { 0 },
1339         .needs_tvaudio  = 0,
1340         .no_msp34xx     = 1,
1341         .pll            = PLL_28,
1342         .tuner_type     = -1,
1343 },{
1344         .name           = "Jetway TV/Capture JW-TV878-FBK, Kworld KW-TV878RF",
1345         .video_inputs   = 4,
1346         .audio_inputs   = 3,
1347         .tuner          = 0,
1348         .svhs           = 2,
1349         .gpiomask       = 7,
1350         .muxsel         = { 2, 3, 1, 1 },   // Tuner, SVid, SVHS, SVid to SVHS connector
1351         .audiomux       = { 0 ,0 ,4, 4,4,4},// Yes, this tuner uses the same audio output for TV and FM radio!
1352 					  // This card lacks external Audio In, so we mute it on Ext. & Int.
1353 					  // The PCB can take a sbx1637/sbx1673, wiring unknown.
1354 					  // This card lacks PCI subsystem ID, sigh.
1355 					  // audiomux=1: lower volume, 2+3: mute
1356 					  // btwincap uses 0x80000/0x80003
1357         .needs_tvaudio  = 0,
1358         .no_msp34xx     = 1,
1359         .pll            = PLL_28,
1360         .tuner_type     = 5, // Samsung TCPA9095PC27A (BG+DK), philips compatible, w/FM, stereo and
1361 			   // radio signal strength indicators work fine.
1362 	.has_radio		= 1,
1363 	/* GPIO Info:
1364 		GPIO0,1:   HEF4052 A0,A1
1365 		GPIO2:     HEF4052 nENABLE
1366 		GPIO3-7:   n.c.
1367 		GPIO8-13:  IRDC357 data0-5 (data6 n.c. ?) [chip not present on my card]
1368 		GPIO14,15: ??
1369 		GPIO16-21: n.c.
1370 		GPIO22,23: ??
1371 		??       : mtu8b56ep microcontroller for IR (GPIO wiring unknown)*/
1372 },{
1373         /* Arthur Tetzlaff-Deas, DSP Design Ltd <software@dspdesign.com> */
1374         .name           = "DSP Design TCVIDEO",
1375         .video_inputs   = 4,
1376         .svhs           = -1,
1377         .muxsel         = { 2, 3, 1, 0},
1378         .pll            = PLL_28,
1379         .tuner_type     = -1,
1380 },{
1381 
1382         /* ---- card 0x50 ---------------------------------- */
1383 	.name           = "Hauppauge WinTV PVR",
1384         .video_inputs   = 4,
1385         .audio_inputs   = 1,
1386         .tuner          = 0,
1387         .svhs           = 2,
1388         .muxsel         = { 2, 0, 1, 1},
1389         .needs_tvaudio  = 1,
1390         .pll            = PLL_28,
1391         .tuner_type     = -1,
1392 
1393 	.gpiomask       = 7,
1394 	.audiomux       = {7},
1395 },{
1396 	.name           = "IODATA GV-BCTV5/PCI",
1397 	.video_inputs   = 3,
1398 	.audio_inputs   = 1,
1399 	.tuner          = 0,
1400 	.svhs           = 2,
1401 	.gpiomask       = 0x0f0f80,
1402 	.muxsel         = {2, 3, 1, 0},
1403 	.audiomux       = {0x030000, 0x010000, 0x030000, 0, 0x020000, 0},
1404 	.no_msp34xx     = 1,
1405 	.pll            = PLL_28,
1406 	.tuner_type     = TUNER_PHILIPS_NTSC_M,
1407 	.audio_hook     = gvbctv3pci_audio,
1408 	.has_radio      = 1,
1409 },{
1410 	.name           = "Osprey 100/150 (878)", /* 0x1(2|3)-45C6-C1 */
1411 	.video_inputs   = 4,                  /* id-inputs-clock */
1412 	.audio_inputs   = 0,
1413 	.tuner          = -1,
1414 	.svhs           = 3,
1415 	.muxsel         = { 3, 2, 0, 1 },
1416 	.pll            = PLL_28,
1417 	.tuner_type     = -1,
1418         .no_msp34xx     = 1,
1419         .no_tda9875     = 1,
1420         .no_tda7432     = 1,
1421 },{
1422 	.name           = "Osprey 100/150 (848)", /* 0x04-54C0-C1 & older boards */
1423 	.video_inputs   = 3,
1424 	.audio_inputs   = 0,
1425 	.tuner          = -1,
1426 	.svhs           = 2,
1427 	.muxsel         = { 2, 3, 1 },
1428 	.pll            = PLL_28,
1429 	.tuner_type     = -1,
1430         .no_msp34xx     = 1,
1431         .no_tda9875     = 1,
1432         .no_tda7432     = 1,
1433 },{
1434 
1435 	/* ---- card 0x54 ---------------------------------- */
1436 	.name           = "Osprey 101 (848)", /* 0x05-40C0-C1 */
1437 	.video_inputs   = 2,
1438 	.audio_inputs   = 0,
1439 	.tuner          = -1,
1440 	.svhs           = 1,
1441 	.muxsel         = { 3, 1 },
1442 	.pll            = PLL_28,
1443 	.tuner_type     = -1,
1444         .no_msp34xx     = 1,
1445         .no_tda9875     = 1,
1446         .no_tda7432     = 1,
1447 },{
1448 	.name           = "Osprey 101/151",       /* 0x1(4|5)-0004-C4 */
1449 	.video_inputs   = 1,
1450 	.audio_inputs   = 0,
1451 	.tuner          = -1,
1452 	.svhs           = -1,
1453 	.muxsel         = { 0 },
1454 	.pll            = PLL_28,
1455 	.tuner_type     = -1,
1456         .no_msp34xx     = 1,
1457         .no_tda9875     = 1,
1458         .no_tda7432     = 1,
1459 },{
1460 	.name           = "Osprey 101/151 w/ svid",  /* 0x(16|17|20)-00C4-C1 */
1461 	.video_inputs   = 2,
1462 	.audio_inputs   = 0,
1463 	.tuner          = -1,
1464 	.svhs           = 1,
1465 	.muxsel         = { 0, 1 },
1466 	.pll            = PLL_28,
1467 	.tuner_type     = -1,
1468         .no_msp34xx     = 1,
1469         .no_tda9875     = 1,
1470         .no_tda7432     = 1,
1471 },{
1472 	.name           = "Osprey 200/201/250/251",  /* 0x1(8|9|E|F)-0004-C4 */
1473 	.video_inputs   = 1,
1474 	.audio_inputs   = 1,
1475 	.tuner          = -1,
1476 	.svhs           = -1,
1477 	.muxsel         = { 0 },
1478 	.pll            = PLL_28,
1479 	.tuner_type     = -1,
1480         .no_msp34xx     = 1,
1481         .no_tda9875     = 1,
1482         .no_tda7432     = 1,
1483 },{
1484 
1485 	/* ---- card 0x58 ---------------------------------- */
1486 	.name           = "Osprey 200/250",   /* 0x1(A|B)-00C4-C1 */
1487 	.video_inputs   = 2,
1488 	.audio_inputs   = 1,
1489 	.tuner          = -1,
1490 	.svhs           = 1,
1491 	.muxsel         = { 0, 1 },
1492 	.pll            = PLL_28,
1493 	.tuner_type     = -1,
1494         .no_msp34xx     = 1,
1495         .no_tda9875     = 1,
1496         .no_tda7432     = 1,
1497 },{
1498 	.name           = "Osprey 210/220",   /* 0x1(A|B)-04C0-C1 */
1499 	.video_inputs   = 2,
1500 	.audio_inputs   = 1,
1501 	.tuner          = -1,
1502 	.svhs           = 1,
1503 	.muxsel         = { 2, 3 },
1504 	.pll            = PLL_28,
1505 	.tuner_type     = -1,
1506         .no_msp34xx     = 1,
1507         .no_tda9875     = 1,
1508         .no_tda7432     = 1,
1509 },{
1510 	.name           = "Osprey 500",   /* 500 */
1511 	.video_inputs   = 2,
1512 	.audio_inputs   = 1,
1513 	.tuner          = -1,
1514 	.svhs           = 1,
1515 	.muxsel         = { 2, 3 },
1516 	.pll            = PLL_28,
1517 	.tuner_type     = -1,
1518         .no_msp34xx     = 1,
1519         .no_tda9875     = 1,
1520         .no_tda7432     = 1,
1521 },{
1522        .name           = "Osprey 540",   /* 540 */
1523        .video_inputs   = 4,
1524        .audio_inputs   = 1,
1525        .tuner          = -1,
1526 #if 0 /* TODO ... */
1527        .svhs           = OSPREY540_SVID_ANALOG,
1528        .muxsel         = {       [OSPREY540_COMP_ANALOG] = 2,
1529                                [OSPREY540_SVID_ANALOG] = 3, },
1530 #endif
1531        .pll            = PLL_28,
1532        .tuner_type     = -1,
1533        .no_msp34xx     = 1,
1534        .no_tda9875     = 1,
1535        .no_tda7432     = 1,
1536 #if 0 /* TODO ... */
1537        .muxsel_hook    = osprey_540_muxsel,
1538        .picture_hook   = osprey_540_set_picture,
1539 #endif
1540 },{
1541 
1542 	/* ---- card 0x5C ---------------------------------- */
1543 	.name           = "Osprey 2000",  /* 2000 */
1544 	.video_inputs   = 2,
1545 	.audio_inputs   = 1,
1546 	.tuner          = -1,
1547 	.svhs           = 1,
1548 	.muxsel         = { 2, 3 },
1549 	.pll            = PLL_28,
1550 	.tuner_type     = -1,
1551         .no_msp34xx     = 1,
1552         .no_tda9875     = 1,
1553         .no_tda7432     = 1,      /* must avoid, conflicts with the bt860 */
1554 },{
1555 	/* M G Berberich <berberic@forwiss.uni-passau.de> */
1556 	.name           = "IDS Eagle",
1557 	.video_inputs   = 4,
1558 	.audio_inputs   = 0,
1559 	.tuner          = -1,
1560 	.tuner_type     = -1,
1561 	.svhs           = -1,
1562 	.gpiomask       = 0,
1563 	.muxsel         = { 0, 1, 2, 3 },
1564 	.muxsel_hook    = eagle_muxsel,
1565 	.no_msp34xx     = 1,
1566 	.no_tda9875     = 1,
1567 	.pll            = PLL_28,
1568 },{
1569 	.name           = "Pinnacle PCTV Sat",
1570 	.video_inputs   = 2,
1571 	.audio_inputs   = 0,
1572 	.svhs           = 1,
1573 	.tuner          = -1,
1574 	.tuner_type     = -1,
1575 	.no_msp34xx     = 1,
1576 	.no_tda9875     = 1,
1577 	.no_tda7432     = 1,
1578 	.gpiomask       = 0x01,
1579 	.audiomux       = { 0, 0, 0, 0, 1 },
1580 	.muxsel         = { 3, 0, 1, 2},
1581 	.needs_tvaudio  = 0,
1582 	.pll            = PLL_28,
1583 },{
1584         .name           = "Formac ProTV II (bt878)",
1585         .video_inputs   = 4,
1586         .audio_inputs   = 1,
1587         .tuner          = 0,
1588         .svhs           = 3,
1589         .gpiomask       = 2,
1590 	// TV, Comp1, Composite over SVID con, SVID
1591         .muxsel         = { 2, 3, 1, 1},
1592         .audiomux       = { 2, 2, 0, 0, 0 },
1593         .pll            = PLL_28,
1594 	.has_radio      = 1,
1595         .tuner_type     = TUNER_PHILIPS_PAL,
1596       /* sound routing:
1597            GPIO=0x00,0x01,0x03: mute (?)
1598               0x02: both TV and radio (tuner: FM1216/I)
1599          The card has onboard audio connectors labeled "cdrom" and "board",
1600 	 not soldered here, though unknown wiring.
1601          Card lacks: external audio in, pci subsystem id.
1602        */
1603 },{
1604 
1605 	/* ---- card 0x60 ---------------------------------- */
1606 	.name           = "MachTV",
1607         .video_inputs   = 3,
1608         .audio_inputs   = 1,
1609         .tuner          = 0,
1610         .svhs           = -1,
1611         .gpiomask       = 7,
1612         .muxsel         = { 2, 3, 1, 1},
1613         .audiomux       = { 0, 1, 2, 3, 4},
1614         .needs_tvaudio  = 1,
1615         .tuner_type     = 5,
1616 	.pll            = 1,
1617 },{
1618 	.name           = "Euresys Picolo",
1619 	.video_inputs   = 3,
1620 	.audio_inputs   = 0,
1621 	.tuner          = -1,
1622 	.svhs           = 2,
1623 	.gpiomask       = 0,
1624 	.no_msp34xx     = 1,
1625 	.no_tda9875     = 1,
1626 	.no_tda7432     = 1,
1627 	.muxsel         = { 2, 0, 1},
1628 	.pll            = PLL_28,
1629 },{
1630 	/* Luc Van Hoeylandt <luc@e-magic.be> */
1631 	.name           = "ProVideo PV150", /* 0x4f */
1632 	.video_inputs   = 2,
1633 	.audio_inputs   = 0,
1634 	.tuner          = -1,
1635 	.svhs           = -1,
1636 	.gpiomask       = 0,
1637 	.muxsel         = { 2, 3 },
1638 	.audiomux       = { 0 },
1639 	.needs_tvaudio  = 0,
1640 	.no_msp34xx     = 1,
1641 	.pll            = PLL_28,
1642 	.tuner_type     = -1,
1643 },{
1644 	/* Hiroshi Takekawa <sian@big.or.jp> */
1645 	/* This card lacks subsystem ID */
1646 	.name           = "AD-TVK503", /* 0x63 */
1647 	.video_inputs   = 4,
1648 	.audio_inputs   = 1,
1649 	.tuner          = 0,
1650 	.svhs           = 2,
1651 	.gpiomask       = 0x001e8007,
1652 	.muxsel         = { 2, 3, 1, 0 },
1653 	/*                  Tuner, Radio, external, internal, off,  on */
1654 	.audiomux       = { 0x08,  0x0f,  0x0a,     0x08,     0x0f, 0x08 },
1655 	.needs_tvaudio  = 0,
1656 	.no_msp34xx     = 1,
1657 	.pll            = PLL_28,
1658 	.tuner_type     = 2,
1659 	.audio_hook	= adtvk503_audio,
1660 },{
1661 
1662 	/* ---- card 0x64 ---------------------------------- */
1663         .name           = "Hercules Smart TV Stereo",
1664         .video_inputs   = 4,
1665         .audio_inputs   = 1,
1666         .tuner          = 0,
1667         .svhs           = 2,
1668         .gpiomask       = 0x00,
1669         .muxsel         = { 2, 3, 1, 1 },
1670         .needs_tvaudio  = 1,
1671         .no_msp34xx     = 1,
1672         .pll            = PLL_28,
1673         .tuner_type     = 5,
1674 	/* Notes:
1675 	   - card lacks subsystem ID
1676 	   - stereo variant w/ daughter board with tda9874a @0xb0
1677 	   - Audio Routing:
1678 		always from tda9874 independent of GPIO (?)
1679 		external line in: unknown
1680 	   - Other chips: em78p156elp @ 0x96 (probably IR remote control)
1681 	              hef4053 (instead 4052) for unknown function
1682 	*/
1683 },{
1684         .name           = "Pace TV & Radio Card",
1685         .video_inputs   = 4,
1686         .audio_inputs   = 1,
1687         .tuner          = 0,
1688         .svhs           = 2,
1689         .muxsel         = { 2, 3, 1, 1}, // Tuner, CVid, SVid, CVid over SVid connector
1690         .gpiomask       = 0,
1691         .no_tda9875     = 1,
1692         .no_tda7432     = 1,
1693         .tuner_type     = 1,
1694         .has_radio      = 1,
1695         .pll            = PLL_28,
1696         /* Bt878, Bt832, FI1246 tuner; no pci subsystem id
1697            only internal line out: (4pin header) RGGL
1698            Radio must be decoded by msp3410d (not routed through)*/
1699         //         .digital_mode   = DIGITAL_MODE_CAMERA, // todo!
1700 },{
1701         /* Chris Willing <chris@vislab.usyd.edu.au> */
1702         .name           = "IVC-200",
1703         .video_inputs   = 1,
1704         .audio_inputs   = 0,
1705         .tuner          = -1,
1706         .tuner_type     = -1,
1707         .svhs           = -1,
1708         .gpiomask       = 0xdf,
1709         .muxsel         = { 2 },
1710         .pll            = PLL_28,
1711 },{
1712 	.name           = "Grand X-Guard / Trust 814PCI",
1713 	.video_inputs   = 16,
1714         .audio_inputs   = 0,
1715         .tuner          = -1,
1716         .svhs           = -1,
1717 	.tuner_type     = 4,
1718         .gpiomask2      = 0xff,
1719 	.muxsel         = { 2,2,2,2, 3,3,3,3, 1,1,1,1, 0,0,0,0 },
1720 	.muxsel_hook    = xguard_muxsel,
1721 	.no_msp34xx     = 1,
1722 	.no_tda9875     = 1,
1723         .no_tda7432     = 1,
1724 	.pll            = PLL_28,
1725 },{
1726 
1727 	/* ---- card 0x68 ---------------------------------- */
1728 	.name           = "Nebula Electronics DigiTV",
1729 	.video_inputs   = 0,
1730 	.audio_inputs   = 0,
1731 	.svhs           = -1,
1732 	.muxsel         = { 2, 3, 1, 0},
1733 	.needs_tvaudio  = 0,
1734 	.no_msp34xx     = 1,
1735 	.no_tda9875     = 1,
1736 	.no_tda7432     = 1,
1737 	.pll            = PLL_28,
1738 	.tuner_type     = -1,
1739 },{
1740 	/* Jorge Boncompte - DTI2 <jorge@dti2.net> */
1741 	.name           = "ProVideo PV143",
1742         .video_inputs   = 4,
1743         .audio_inputs   = 0,
1744         .tuner          = -1,
1745         .svhs           = -1,
1746         .gpiomask       = 0,
1747         .muxsel         = { 2, 3, 1, 0 },
1748         .audiomux       = { 0 },
1749         .needs_tvaudio  = 0,
1750         .no_msp34xx     = 1,
1751         .pll            = PLL_28,
1752         .tuner_type     = -1,
1753 },{
1754 	/* M.Klahr@phytec.de */
1755 	.name           = "PHYTEC VD-009-X1 MiniDIN (bt878)",
1756 	.video_inputs   = 4,
1757 	.audio_inputs   = 0,
1758 	.tuner          = -1, /* card has no tuner */
1759 	.svhs           = 3,
1760 	.gpiomask       = 0x00,
1761 	.muxsel         = { 2, 3, 1, 0},
1762 	.audiomux       = { 0, 0, 0, 0, 0, 0 }, /* card has no audio */
1763 	.needs_tvaudio  = 1,
1764 	.pll            = PLL_28,
1765 	.tuner_type     = -1,
1766 },{
1767 	.name           = "PHYTEC VD-009-X1 Combi (bt878)",
1768 	.video_inputs   = 4,
1769 	.audio_inputs   = 0,
1770 	.tuner          = -1, /* card has no tuner */
1771 	.svhs           = 3,
1772 	.gpiomask       = 0x00,
1773 	.muxsel         = { 2, 3, 1, 1},
1774 	.audiomux       = { 0, 0, 0, 0, 0, 0 }, /* card has no audio */
1775 	.needs_tvaudio  = 1,
1776 	.pll            = PLL_28,
1777 	.tuner_type     = -1,
1778 },{
1779 
1780 	/* ---- card 0x6c ---------------------------------- */
1781 	.name           = "PHYTEC VD-009 MiniDIN (bt878)",
1782 	.video_inputs   = 10,
1783 	.audio_inputs   = 0,
1784 	.tuner          = -1, /* card has no tuner */
1785 	.svhs           = 9,
1786 	.gpiomask       = 0x00,
1787 	.gpiomask2      = 0x03, /* gpiomask2 defines the bits used to switch audio
1788 				   via the upper nibble of muxsel. here: used for
1789 				   xternal video-mux */
1790 	.muxsel         = { 0x02, 0x12, 0x22, 0x32, 0x03, 0x13, 0x23, 0x33, 0x01, 0x00 },
1791 	.audiomux       = { 0, 0, 0, 0, 0, 0 }, /* card has no audio */
1792 	.needs_tvaudio  = 1,
1793 	.pll            = PLL_28,
1794 	.tuner_type     = -1,
1795 },{
1796 	.name           = "PHYTEC VD-009 Combi (bt878)",
1797 	.video_inputs   = 10,
1798 	.audio_inputs   = 0,
1799 	.tuner          = -1, /* card has no tuner */
1800 	.svhs           = 9,
1801 	.gpiomask       = 0x00,
1802 	.gpiomask2      = 0x03, /* gpiomask2 defines the bits used to switch audio
1803 				   via the upper nibble of muxsel. here: used for
1804 				   xternal video-mux */
1805 	.muxsel         = { 0x02, 0x12, 0x22, 0x32, 0x03, 0x13, 0x23, 0x33, 0x01, 0x01 },
1806 	.audiomux       = { 0, 0, 0, 0, 0, 0 }, /* card has no audio */
1807 	.needs_tvaudio  = 1,
1808 	.pll            = PLL_28,
1809 	.tuner_type     = -1,
1810 }};
1811 
1812 const unsigned int bttv_num_tvcards = ARRAY_SIZE(bttv_tvcards);
1813 
1814 /* ----------------------------------------------------------------------- */
1815 
1816 static unsigned char eeprom_data[256];
1817 
1818 /*
1819  * identify card
1820  */
bttv_idcard(struct bttv * btv)1821 void __devinit bttv_idcard(struct bttv *btv)
1822 {
1823 	unsigned int gpiobits;
1824 	int i,type;
1825 	unsigned short tmp;
1826 
1827 	/* read PCI subsystem ID */
1828 	pci_read_config_word(btv->dev, PCI_SUBSYSTEM_ID, &tmp);
1829 	btv->cardid = tmp << 16;
1830 	pci_read_config_word(btv->dev, PCI_SUBSYSTEM_VENDOR_ID, &tmp);
1831 	btv->cardid |= tmp;
1832 
1833 	if (0 != btv->cardid && 0xffffffff != btv->cardid) {
1834 		/* look for the card */
1835 		for (type = -1, i = 0; cards[i].id != 0; i++)
1836 			if (cards[i].id  == btv->cardid)
1837 				type = i;
1838 
1839 		if (type != -1) {
1840 			/* found it */
1841 			printk(KERN_INFO "bttv%d: detected: %s [card=%d], "
1842 			       "PCI subsystem ID is %04x:%04x\n",
1843 			       btv->nr,cards[type].name,cards[type].cardnr,
1844 			       btv->cardid & 0xffff,
1845 			       (btv->cardid >> 16) & 0xffff);
1846 			btv->type = cards[type].cardnr;
1847 		} else {
1848 			/* 404 */
1849 			printk(KERN_INFO "bttv%d: subsystem: %04x:%04x (UNKNOWN)\n",
1850 			       btv->nr, btv->cardid & 0xffff,
1851 			       (btv->cardid >> 16) & 0xffff);
1852 			printk(KERN_DEBUG "please mail id, board name and "
1853 			       "the correct card= insmod option to kraxel@bytesex.org\n");
1854 		}
1855 	}
1856 
1857 	/* let the user override the autodetected type */
1858 	if (card[btv->nr] < bttv_num_tvcards)
1859 		btv->type=card[btv->nr];
1860 
1861 	/* print which card config we are using */
1862 	printk(KERN_INFO "bttv%d: using: %s [card=%d,%s]\n",btv->nr,
1863 	       bttv_tvcards[btv->type].name, btv->type,
1864 	       card[btv->nr] < bttv_num_tvcards
1865 	       ? "insmod option" : "autodetected");
1866 
1867 	/* overwrite gpio stuff ?? */
1868 	if (UNSET == audioall && UNSET == audiomux[0])
1869 		return;
1870 
1871 	if (UNSET != audiomux[0]) {
1872 		gpiobits = 0;
1873 		for (i = 0; i < 5; i++) {
1874 			bttv_tvcards[btv->type].audiomux[i] = audiomux[i];
1875 			gpiobits |= audiomux[i];
1876 		}
1877 	} else {
1878 		gpiobits = audioall;
1879 		for (i = 0; i < 5; i++) {
1880 			bttv_tvcards[btv->type].audiomux[i] = audioall;
1881 		}
1882 	}
1883 	bttv_tvcards[btv->type].gpiomask = (UNSET != gpiomask) ? gpiomask : gpiobits;
1884 	printk(KERN_INFO "bttv%d: gpio config override: mask=0x%x, mux=",
1885 	       btv->nr,bttv_tvcards[btv->type].gpiomask);
1886 	for (i = 0; i < 5; i++) {
1887 		printk("%s0x%x", i ? "," : "", bttv_tvcards[btv->type].audiomux[i]);
1888 	}
1889 	printk("\n");
1890 }
1891 
1892 /*
1893  * (most) board specific initialisations goes here
1894  */
1895 
1896 /* Some Modular Technology cards have an eeprom, but no subsystem ID */
identify_by_eeprom(struct bttv * btv,unsigned char eeprom_data[256])1897 void identify_by_eeprom(struct bttv *btv, unsigned char eeprom_data[256])
1898 {
1899 	int type = -1;
1900 
1901 	if (0 == strncmp(eeprom_data,"GET.MM20xPCTV",13))
1902 		type = BTTV_MODTEC_205;
1903 	else if (0 == strncmp(eeprom_data+20,"Picolo",7))
1904 		type = BTTV_EURESYS_PICOLO;
1905 	else if (eeprom_data[0] == 0x84 && eeprom_data[2]== 0)
1906                 type = BTTV_HAUPPAUGE; /* old bt848 */
1907 
1908 	if (-1 != type) {
1909 		btv->type = type;
1910 		printk("bttv%d: detected by eeprom: %s [card=%d]\n",
1911 		       btv->nr, bttv_tvcards[btv->type].name, btv->type);
1912 	}
1913 }
1914 
flyvideo_gpio(struct bttv * btv)1915 static void flyvideo_gpio(struct bttv *btv)
1916 {
1917 	int gpio,outbits,has_remote,has_radio,is_capture_only,is_lr90,has_tda9820_tda9821;
1918 	int tuner=-1,ttype;
1919 
1920 	outbits = btread(BT848_GPIO_OUT_EN);
1921 	btwrite(0x00, BT848_GPIO_OUT_EN);
1922 	udelay(8);  // without this we would see the 0x1800 mask
1923 	gpio=btread(BT848_GPIO_DATA);
1924 	btwrite(outbits, BT848_GPIO_OUT_EN);
1925 	// all cards provide GPIO info, some have an additional eeprom
1926 	// LR50: GPIO coding can be found lower right CP1 .. CP9
1927 	//       CP9=GPIO23 .. CP1=GPIO15; when OPEN, the corresponding GPIO reads 1.
1928 	//       GPIO14-12: n.c.
1929 	// LR90: GP9=GPIO23 .. GP1=GPIO15 (right above the bt878)
1930 
1931 	// lowest 3 bytes are remote control codes (no handshake needed)
1932         // xxxFFF: No remote control chip soldered
1933         // xxxF00(LR26/LR50), xxxFE0(LR90): Remote control chip (LVA001 or CF45) soldered
1934 	// Note: Some bits are Audio_Mask !
1935 
1936 	ttype=(gpio&0x0f0000)>>16;
1937 	switch(ttype) {
1938 	case 0x0: tuner=2; // NTSC, e.g. TPI8NSR11P
1939 		break;
1940         case 0x2: tuner=39;// LG NTSC (newer TAPC series) TAPC-H701P
1941 		break;
1942 	case 0x4: tuner=5; // Philips PAL TPI8PSB02P, TPI8PSB12P, TPI8PSB12D or FI1216, FM1216
1943 		break;
1944 	case 0x6: tuner=37; // LG PAL (newer TAPC series) TAPC-G702P
1945 		break;
1946 	case 0xC: tuner=3; // Philips SECAM(+PAL) FQ1216ME or FI1216MF
1947 		break;
1948 	default:
1949 		printk(KERN_INFO "bttv%d: FlyVideo_gpio: unknown tuner type.\n", btv->nr);
1950 	}
1951 
1952 	has_remote          =   gpio & 0x800000;
1953 	has_radio	    =   gpio & 0x400000;
1954 	//   unknown                   0x200000;
1955 	//   unknown2                  0x100000;
1956         is_capture_only     = !(gpio & 0x008000); //GPIO15
1957 	has_tda9820_tda9821 = !(gpio & 0x004000);
1958 	is_lr90             = !(gpio & 0x002000); // else LR26/LR50 (LR38/LR51 f. capture only)
1959         //		        gpio & 0x001000 // output bit for audio routing
1960 
1961 	if(is_capture_only)
1962 		tuner=4; // No tuner present
1963 
1964 	printk(KERN_INFO "bttv%d: FlyVideo Radio=%s RemoteControl=%s Tuner=%d gpio=0x%06x\n",
1965 	       btv->nr, has_radio? "yes":"no ", has_remote? "yes":"no ", tuner, gpio);
1966 	printk(KERN_INFO "bttv%d: FlyVideo  LR90=%s tda9821/tda9820=%s capture_only=%s\n",
1967 		btv->nr, is_lr90?"yes":"no ", has_tda9820_tda9821?"yes":"no ",
1968 		is_capture_only?"yes":"no ");
1969 
1970 	if(tuner!= -1) // only set if known tuner autodetected, else let insmod option through
1971 		btv->tuner_type = tuner;
1972 	btv->has_radio = has_radio;
1973 
1974 	// LR90 Audio Routing is done by 2 hef4052, so Audio_Mask has 4 bits: 0x001c80
1975         // LR26/LR50 only has 1 hef4052, Audio_Mask 0x000c00
1976 	// Audio options: from tuner, from tda9821/tda9821(mono,stereo,sap), from tda9874, ext., mute
1977 	if(has_tda9820_tda9821) btv->audio_hook = lt9415_audio;
1978 	//todo: if(has_tda9874) btv->audio_hook = fv2000s_audio;
1979 }
1980 
1981 int miro_tunermap[] = { 0,6,2,3,   4,5,6,0,  3,0,4,5,  5,2,16,1,
1982 			14,2,17,1, 4,1,4,3,  1,2,16,1, 4,4,4,4 };
1983 int miro_fmtuner[]  = { 0,0,0,0,   0,0,0,0,  0,0,0,0,  0,0,0,1,
1984 			1,1,1,1,   1,1,1,0,  0,0,0,0,  0,1,0,0 };
1985 
miro_pinnacle_gpio(struct bttv * btv)1986 static void miro_pinnacle_gpio(struct bttv *btv)
1987 {
1988 	int id,msp,gpio;
1989 	char *info;
1990 
1991 	btwrite(0,BT848_GPIO_OUT_EN);
1992         gpio = btread(BT848_GPIO_DATA);
1993 	id   = ((gpio>>10) & 63) -1;
1994 	msp  = bttv_I2CRead(btv, I2C_MSP3400, "MSP34xx");
1995 	if (id < 32) {
1996 		btv->tuner_type = miro_tunermap[id];
1997 		if (0 == (gpio & 0x20)) {
1998 			btv->has_radio = 1;
1999 			if (!miro_fmtuner[id]) {
2000 				btv->has_matchbox = 1;
2001 				btv->mbox_we    = (1<<6);
2002 				btv->mbox_most  = (1<<7);
2003 				btv->mbox_clk   = (1<<8);
2004 				btv->mbox_data  = (1<<9);
2005 				btv->mbox_mask  = (1<<6)|(1<<7)|(1<<8)|(1<<9);
2006 			}
2007 		} else {
2008 			btv->has_radio = 0;
2009 		}
2010 		if (-1 != msp) {
2011 			if (btv->type == BTTV_MIRO)
2012 				btv->type = BTTV_MIROPRO;
2013 			if (btv->type == BTTV_PINNACLE)
2014 				btv->type = BTTV_PINNACLEPRO;
2015 		}
2016 		printk(KERN_INFO
2017 		       "bttv%d: miro: id=%d tuner=%d radio=%s stereo=%s\n",
2018 		       btv->nr, id+1, btv->tuner_type,
2019 		       !btv->has_radio ? "no" :
2020 		       (btv->has_matchbox ? "matchbox" : "fmtuner"),
2021 		       (-1 == msp) ? "no" : "yes");
2022 	} else {
2023 		/* new cards with microtune tuner */
2024 		id = 63 - id;
2025 		btv->has_radio = 0;
2026 		switch (id) {
2027 		case 1:
2028 			info = "PAL / mono";
2029 			break;
2030 		case 2:
2031 			info = "PAL+SECAM / stereo";
2032 			btv->has_radio = 1;
2033 			break;
2034 		case 3:
2035 			info = "NTSC / stereo";
2036 			btv->has_radio = 1;
2037 			break;
2038 		case 4:
2039 			info = "PAL+SECAM / mono";
2040 			break;
2041 		case 5:
2042 			info = "NTSC / mono";
2043 			break;
2044 		case 6:
2045 			info = "NTSC / stereo";
2046 			break;
2047 		default:
2048 			info = "oops: unknown card";
2049 			break;
2050 		}
2051 		if (-1 != msp)
2052 			btv->type = BTTV_PINNACLEPRO;
2053 		printk(KERN_INFO
2054 		       "bttv%d: pinnacle/mt: id=%d info=\"%s\" radio=%s\n",
2055 		       btv->nr, id, info, btv->has_radio ? "yes" : "no");
2056 		btv->tuner_type  = 33;
2057 		btv->pinnacle_id = id;
2058 	}
2059 }
2060 
2061 /* GPIO21   L: Buffer aktiv, H: Buffer inaktiv */
2062 #define LM1882_SYNC_DRIVE     0x200000L
2063 
init_ids_eagle(struct bttv * btv)2064 static void init_ids_eagle(struct bttv *btv)
2065 {
2066 	btwrite(0xFFFF37, BT848_GPIO_OUT_EN);
2067 	btwrite(0x000000, BT848_GPIO_REG_INP);
2068 
2069 	btwrite(0x200020, BT848_GPIO_DATA);
2070 
2071 	/* flash strobe inverter ?! */
2072 	btwrite(0x200024, BT848_GPIO_DATA);
2073 
2074 	/* switch sync drive off */
2075 	btor(LM1882_SYNC_DRIVE, BT848_GPIO_DATA);
2076 
2077 	/* set BT848 muxel to 2 */
2078 	btaor((2)<<5, ~(2<<5), BT848_IFORM);
2079 }
2080 
2081 /* Muxsel helper for the IDS Eagle.
2082  * the eagles does not use the standard muxsel-bits but
2083  * has its own multiplexer */
eagle_muxsel(struct bttv * btv,unsigned int input)2084 static void eagle_muxsel(struct bttv *btv, unsigned int input)
2085 {
2086 	btaor((2)<<5, ~(3<<5), BT848_IFORM);
2087 	btaor((bttv_tvcards[btv->type].muxsel[input&7]&3),
2088 	      ~3, BT848_GPIO_DATA);
2089 
2090 #if 0
2091        /* svhs */
2092        /* wake chroma ADC */
2093        btand(~BT848_ADC_C_SLEEP, BT848_ADC);
2094        /* set to YC video */
2095        btor(BT848_CONTROL_COMP, BT848_E_CONTROL);
2096        btor(BT848_CONTROL_COMP, BT848_O_CONTROL);
2097 #else
2098        /* composite */
2099        /* set chroma ADC to sleep */
2100        btor(BT848_ADC_C_SLEEP, BT848_ADC);
2101        /* set to composite video */
2102        btand(~BT848_CONTROL_COMP, BT848_E_CONTROL);
2103        btand(~BT848_CONTROL_COMP, BT848_O_CONTROL);
2104 #endif
2105 
2106        /* switch sync drive off */
2107        btor(LM1882_SYNC_DRIVE, BT848_GPIO_DATA);
2108 }
2109 
2110 /* ----------------------------------------------------------------------- */
2111 
2112 /* initialization part one -- before registering i2c bus */
bttv_init_card1(struct bttv * btv)2113 void __devinit bttv_init_card1(struct bttv *btv)
2114 {
2115 	switch (btv->type) {
2116 	case BTTV_HAUPPAUGE:
2117 	case BTTV_HAUPPAUGE878:
2118                 boot_msp34xx(btv,5);
2119 		break;
2120 	case BTTV_VOODOOTV_FM:
2121                 boot_msp34xx(btv,20);
2122 		break;
2123 	case BTTV_AVERMEDIA98:
2124 		boot_msp34xx(btv,11);
2125 		break;
2126 	case BTTV_HAUPPAUGEPVR:
2127 		pvr_boot(btv);
2128 		break;
2129 	}
2130 }
2131 
2132 /* initialization part two -- after registering i2c bus */
bttv_init_card2(struct bttv * btv)2133 void __devinit bttv_init_card2(struct bttv *btv)
2134 {
2135         btv->tuner_type = -1;
2136 
2137 	if (BTTV_UNKNOWN == btv->type) {
2138 		bttv_readee(btv,eeprom_data,0xa0);
2139 		identify_by_eeprom(btv,eeprom_data);
2140 	}
2141 
2142 	switch (btv->type) {
2143 	case BTTV_MIRO:
2144 	case BTTV_MIROPRO:
2145 	case BTTV_PINNACLE:
2146 	case BTTV_PINNACLEPRO:
2147 		/* miro/pinnacle */
2148 		miro_pinnacle_gpio(btv);
2149 		break;
2150 	case BTTV_FLYVIDEO_98:
2151 	case BTTV_MAXI:
2152 	case BTTV_LIFE_FLYKIT:
2153 	case BTTV_FLYVIDEO:
2154 	case BTTV_TYPHOON_TVIEW:
2155 	case BTTV_CHRONOS_VS2:
2156 	case BTTV_FLYVIDEO_98FM:
2157 	case BTTV_FLYVIDEO2000:
2158 	case BTTV_FLYVIDEO98EZ:
2159 	case BTTV_CONFERENCETV:
2160 	case BTTV_LIFETEC_9415:
2161 		flyvideo_gpio(btv);
2162 		break;
2163 	case BTTV_HAUPPAUGE:
2164 	case BTTV_HAUPPAUGE878:
2165 	case BTTV_HAUPPAUGEPVR:
2166 		/* pick up some config infos from the eeprom */
2167 		bttv_readee(btv,eeprom_data,0xa0);
2168                 hauppauge_eeprom(btv);
2169 		break;
2170 	case BTTV_AVERMEDIA98:
2171 	case BTTV_AVPHONE98:
2172 		bttv_readee(btv,eeprom_data,0xa0);
2173 		avermedia_eeprom(btv);
2174 		break;
2175 	case BTTV_PXC200:
2176 		init_PXC200(btv);
2177 		break;
2178 	case BTTV_VHX:
2179 		btv->has_radio    = 1;
2180 		btv->has_matchbox = 1;
2181 		btv->mbox_we      = 0x20;
2182 		btv->mbox_most    = 0;
2183 		btv->mbox_clk     = 0x08;
2184 		btv->mbox_data    = 0x10;
2185 		btv->mbox_mask    = 0x38;
2186 		break;
2187 	case BTTV_VOBIS_BOOSTAR:
2188 	case BTTV_TERRATV:
2189 		terratec_active_radio_upgrade(btv);
2190 		break;
2191 	case BTTV_MAGICTVIEW061:
2192 		if (btv->cardid == 0x3002144f) {
2193 			btv->has_radio=1;
2194 			printk("bttv%d: radio detected by subsystem id (CPH05x)\n",btv->nr);
2195 		}
2196 		break;
2197        case BTTV_STB2:
2198                 if (btv->cardid == 0x3060121a) {
2199 			/* Fix up entry for 3DFX VoodooTV 100,
2200 			   which is an OEM STB card variant. */
2201 			btv->has_radio=0;
2202 			btv->tuner_type=TUNER_TEMIC_NTSC;
2203 		}
2204 		break;
2205 	case BTTV_OSPREY1x0:
2206 	case BTTV_OSPREY1x0_848:
2207 	case BTTV_OSPREY101_848:
2208 	case BTTV_OSPREY1x1:
2209 	case BTTV_OSPREY1x1_SVID:
2210 	case BTTV_OSPREY2xx:
2211 	case BTTV_OSPREY2x0_SVID:
2212 	case BTTV_OSPREY2x0:
2213 	case BTTV_OSPREY500:
2214 	case BTTV_OSPREY540:
2215 	case BTTV_OSPREY2000:
2216 		bttv_readee(btv,eeprom_data,0xa0);
2217                 osprey_eeprom(btv);
2218 		break;
2219 	case BTTV_IDS_EAGLE:
2220 		init_ids_eagle(btv);
2221 		break;
2222 	case BTTV_MODTEC_205:
2223 		bttv_readee(btv,eeprom_data,0xa0);
2224 		modtec_eeprom(btv);
2225 		break;
2226 	}
2227 
2228 	/* pll configuration */
2229         if (!(btv->id==848 && btv->revision==0x11)) {
2230 		/* defaults from card list */
2231 		if (PLL_28 == bttv_tvcards[btv->type].pll) {
2232 			btv->pll.pll_ifreq=28636363;
2233 			btv->pll.pll_crystal=BT848_IFORM_XT0;
2234 		}
2235 		if (PLL_35 == bttv_tvcards[btv->type].pll) {
2236 			btv->pll.pll_ifreq=35468950;
2237 			btv->pll.pll_crystal=BT848_IFORM_XT1;
2238 		}
2239 		/* insmod options can override */
2240                 switch (pll[btv->nr]) {
2241                 case 0: /* none */
2242 			btv->pll.pll_crystal = 0;
2243 			btv->pll.pll_ifreq   = 0;
2244 			btv->pll.pll_ofreq   = 0;
2245                         break;
2246                 case 1: /* 28 MHz */
2247 		case 28:
2248                         btv->pll.pll_ifreq   = 28636363;
2249 			btv->pll.pll_ofreq   = 0;
2250                         btv->pll.pll_crystal = BT848_IFORM_XT0;
2251                         break;
2252                 case 2: /* 35 MHz */
2253 		case 35:
2254                         btv->pll.pll_ifreq   = 35468950;
2255 			btv->pll.pll_ofreq   = 0;
2256                         btv->pll.pll_crystal = BT848_IFORM_XT1;
2257                         break;
2258                 }
2259         }
2260 	btv->pll.pll_current = -1;
2261 
2262 	/* tuner configuration (from card list / autodetect / insmod option) */
2263  	if (UNSET != bttv_tvcards[btv->type].tuner_type)
2264 		if(UNSET == btv->tuner_type)
2265                 	btv->tuner_type = bttv_tvcards[btv->type].tuner_type;
2266 	if (UNSET != tuner[btv->nr])
2267 		btv->tuner_type = tuner[btv->nr];
2268 	printk("bttv%d: using tuner=%d\n",btv->nr,btv->tuner_type);
2269 	if (btv->pinnacle_id != UNSET)
2270 		bttv_call_i2c_clients(btv,AUDC_CONFIG_PINNACLE,
2271 				      &btv->pinnacle_id);
2272 	if (btv->tuner_type != UNSET)
2273 		bttv_call_i2c_clients(btv,TUNER_SET_TYPE,&btv->tuner_type);
2274 	btv->svhs = bttv_tvcards[btv->type].svhs;
2275 	if (svhs[btv->nr] != UNSET)
2276 		btv->svhs = svhs[btv->nr];
2277 
2278 	if (bttv_tvcards[btv->type].has_radio)
2279 		btv->has_radio=1;
2280 	if (bttv_tvcards[btv->type].audio_hook)
2281 		btv->audio_hook=bttv_tvcards[btv->type].audio_hook;
2282 
2283 	if (bttv_tvcards[btv->type].digital_mode == DIGITAL_MODE_CAMERA) {
2284 		/* detect Bt832 chip for quartzsight digital camera */
2285 		if ((bttv_I2CRead(btv, I2C_BT832_ALT1, "Bt832") >=0) ||
2286 		    (bttv_I2CRead(btv, I2C_BT832_ALT2, "Bt832") >=0))
2287 			boot_bt832(btv);
2288 	}
2289 
2290 	/* try to detect audio/fader chips */
2291 	if (!bttv_tvcards[btv->type].no_msp34xx &&
2292 	    bttv_I2CRead(btv, I2C_MSP3400, "MSP34xx") >=0) {
2293 		if (autoload)
2294 			request_module("msp3400");
2295 	}
2296 
2297 	if (bttv_tvcards[btv->type].msp34xx_alt &&
2298 	    bttv_I2CRead(btv, I2C_MSP3400_ALT, "MSP34xx (alternate address)") >=0) {
2299 		if (autoload)
2300 			request_module("msp3400");
2301 	}
2302 
2303 	if (!bttv_tvcards[btv->type].no_tda9875 &&
2304 	    bttv_I2CRead(btv, I2C_TDA9875, "TDA9875") >=0) {
2305 		if (autoload)
2306 			request_module("tda9875");
2307 	}
2308 
2309 	if (!bttv_tvcards[btv->type].no_tda7432 &&
2310 	    bttv_I2CRead(btv, I2C_TDA7432, "TDA7432") >=0) {
2311 		if (autoload)
2312 			request_module("tda7432");
2313 	}
2314 
2315 	if (bttv_tvcards[btv->type].needs_tvaudio) {
2316 		if (autoload)
2317 			request_module("tvaudio");
2318 	}
2319 
2320 	/* tuner modules */
2321 	if (btv->pinnacle_id != UNSET) {
2322 		if (autoload)
2323 			request_module("tda9887");
2324 	}
2325 	if (btv->tuner_type != UNSET) {
2326 		if (autoload)
2327 			request_module("tuner");
2328 	}
2329 }
2330 
2331 
2332 /* ----------------------------------------------------------------------- */
2333 /* some hauppauge specific stuff                                           */
2334 
2335 static struct HAUPPAUGE_TUNER
2336 {
2337         int  id;
2338         char *name;
2339 }
2340 hauppauge_tuner[] __devinitdata =
2341 {
2342         { TUNER_ABSENT,        "" },
2343         { TUNER_ABSENT,        "External" },
2344         { TUNER_ABSENT,        "Unspecified" },
2345         { TUNER_PHILIPS_PAL,   "Philips FI1216" },
2346         { TUNER_PHILIPS_SECAM, "Philips FI1216MF" },
2347         { TUNER_PHILIPS_NTSC,  "Philips FI1236" },
2348         { TUNER_PHILIPS_PAL_I, "Philips FI1246" },
2349         { TUNER_PHILIPS_PAL_DK,"Philips FI1256" },
2350         { TUNER_PHILIPS_PAL,   "Philips FI1216 MK2" },
2351         { TUNER_PHILIPS_SECAM, "Philips FI1216MF MK2" },
2352         { TUNER_PHILIPS_NTSC,  "Philips FI1236 MK2" },
2353         { TUNER_PHILIPS_PAL_I, "Philips FI1246 MK2" },
2354         { TUNER_PHILIPS_PAL_DK,"Philips FI1256 MK2" },
2355         { TUNER_TEMIC_NTSC,    "Temic 4032FY5" },
2356         { TUNER_TEMIC_PAL,     "Temic 4002FH5" },
2357         { TUNER_TEMIC_PAL_I,   "Temic 4062FY5" },
2358         { TUNER_PHILIPS_PAL,   "Philips FR1216 MK2" },
2359         { TUNER_PHILIPS_SECAM, "Philips FR1216MF MK2" },
2360         { TUNER_PHILIPS_NTSC,  "Philips FR1236 MK2" },
2361         { TUNER_PHILIPS_PAL_I, "Philips FR1246 MK2" },
2362         { TUNER_PHILIPS_PAL_DK,"Philips FR1256 MK2" },
2363         { TUNER_PHILIPS_PAL,   "Philips FM1216" },
2364         { TUNER_PHILIPS_SECAM, "Philips FM1216MF" },
2365         { TUNER_PHILIPS_NTSC,  "Philips FM1236" },
2366         { TUNER_PHILIPS_PAL_I, "Philips FM1246" },
2367         { TUNER_PHILIPS_PAL_DK,"Philips FM1256" },
2368         { TUNER_TEMIC_4036FY5_NTSC, "Temic 4036FY5" },
2369         { TUNER_ABSENT,        "Samsung TCPN9082D" },
2370         { TUNER_ABSENT,        "Samsung TCPM9092P" },
2371         { TUNER_TEMIC_4006FH5_PAL, "Temic 4006FH5" },
2372         { TUNER_ABSENT,        "Samsung TCPN9085D" },
2373         { TUNER_ABSENT,        "Samsung TCPB9085P" },
2374         { TUNER_ABSENT,        "Samsung TCPL9091P" },
2375         { TUNER_TEMIC_4039FR5_NTSC, "Temic 4039FR5" },
2376         { TUNER_PHILIPS_FQ1216ME,   "Philips FQ1216 ME" },
2377         { TUNER_TEMIC_4066FY5_PAL_I, "Temic 4066FY5" },
2378         { TUNER_ABSENT,        "Philips TD1536" },
2379         { TUNER_ABSENT,        "Philips TD1536D" },
2380 	{ TUNER_PHILIPS_NTSC,  "Philips FMR1236" }, /* mono radio */
2381         { TUNER_ABSENT,        "Philips FI1256MP" },
2382         { TUNER_ABSENT,        "Samsung TCPQ9091P" },
2383         { TUNER_TEMIC_4006FN5_MULTI_PAL, "Temic 4006FN5" },
2384         { TUNER_TEMIC_4009FR5_PAL, "Temic 4009FR5" },
2385         { TUNER_TEMIC_4046FM5,     "Temic 4046FM5" },
2386 	{ TUNER_TEMIC_4009FN5_MULTI_PAL_FM, "Temic 4009FN5" },
2387 	{ TUNER_ABSENT,        "Philips TD1536D_FH_44"},
2388 	{ TUNER_LG_NTSC_FM,    "LG TPI8NSR01F"},
2389 	{ TUNER_LG_PAL_FM,     "LG TPI8PSB01D"},
2390 	{ TUNER_LG_PAL,        "LG TPI8PSB11D"},
2391 	{ TUNER_LG_PAL_I_FM,   "LG TAPC-I001D"},
2392 	{ TUNER_LG_PAL_I,      "LG TAPC-I701D"}
2393 };
2394 
modtec_eeprom(struct bttv * btv)2395 static void modtec_eeprom(struct bttv *btv)
2396 {
2397 	if( strncmp(&(eeprom_data[0x1e]),"Temic 4066 FY5",14) ==0) {
2398 		btv->tuner_type=TUNER_TEMIC_4066FY5_PAL_I;
2399 		printk("bttv Modtec: Tuner autodetected %s\n",
2400 		       &eeprom_data[0x1e]);
2401 	} else {
2402 		printk("bttv Modtec: Unknown TunerString:%s\n",
2403 		       &eeprom_data[0x1e]);
2404 	}
2405 }
2406 
hauppauge_eeprom(struct bttv * btv)2407 static void __devinit hauppauge_eeprom(struct bttv *btv)
2408 {
2409 	unsigned int blk2,tuner,radio,model;
2410 
2411 	if (eeprom_data[0] != 0x84 || eeprom_data[2] != 0)
2412 		printk(KERN_WARNING "bttv%d: Hauppauge eeprom: invalid\n",
2413 		       btv->nr);
2414 
2415 	/* Block 2 starts after len+3 bytes header */
2416 	blk2 = eeprom_data[1] + 3;
2417 
2418 	/* decode + use some config infos */
2419 	model = eeprom_data[12] << 8 | eeprom_data[11];
2420 	tuner = eeprom_data[9];
2421 	radio = eeprom_data[blk2-1] & 0x01;
2422 
2423         if (tuner < ARRAY_SIZE(hauppauge_tuner))
2424                 btv->tuner_type = hauppauge_tuner[tuner].id;
2425 	if (radio)
2426 		btv->has_radio = 1;
2427 
2428 	if (bttv_verbose)
2429 		printk(KERN_INFO "bttv%d: Hauppauge eeprom: model=%d, "
2430 		       "tuner=%s (%d), radio=%s\n",
2431 		       btv->nr, model, hauppauge_tuner[tuner].name,
2432 		       btv->tuner_type, radio ? "yes" : "no");
2433 }
2434 
terratec_active_radio_upgrade(struct bttv * btv)2435 static int terratec_active_radio_upgrade(struct bttv *btv)
2436 {
2437 	int freq;
2438 
2439 	btv->has_radio    = 1;
2440 	btv->has_matchbox = 1;
2441 	btv->mbox_we      = 0x10;
2442 	btv->mbox_most    = 0x20;
2443 	btv->mbox_clk     = 0x08;
2444 	btv->mbox_data    = 0x04;
2445 	btv->mbox_mask    = 0x3c;
2446 
2447 	btv->mbox_iow     = 1 <<  8;
2448 	btv->mbox_ior     = 1 <<  9;
2449 	btv->mbox_csel    = 1 << 10;
2450 
2451 	freq=88000/62.5;
2452 	tea5757_write(btv, 5 * freq + 0x358); // write 0x1ed8
2453 	if (0x1ed8 == tea5757_read(btv)) {
2454 		printk("bttv%d: Terratec Active Radio Upgrade found.\n",
2455 		       btv->nr);
2456 		btv->has_radio    = 1;
2457 		btv->has_matchbox = 1;
2458 	} else {
2459 		btv->has_radio    = 0;
2460 		btv->has_matchbox = 0;
2461 	}
2462 	return 0;
2463 }
2464 
2465 
2466 /* ----------------------------------------------------------------------- */
2467 
2468 /*
2469  * minimal bootstrap for the WinTV/PVR -- upload altera firmware.
2470  *
2471  * The hcwamc.rbf firmware file is on the Hauppauge driver CD.  Have
2472  * a look at Pvr/pvr45xxx.EXE (self-extracting zip archive, can be
2473  * unpacked with unzip).
2474  */
2475 #define PVR_GPIO_DELAY		10
2476 
2477 #define BTTV_ALT_DATA		0x000001
2478 #define BTTV_ALT_DCLK		0x100000
2479 #define BTTV_ALT_NCONFIG	0x800000
2480 
pvr_altera_load(struct bttv * btv,u8 * micro,u32 microlen)2481 static int __devinit pvr_altera_load(struct bttv *btv, u8 *micro, u32 microlen)
2482 {
2483 	u32 n;
2484   	u8 bits;
2485 	int i;
2486 
2487 	btwrite(BTTV_ALT_DATA|BTTV_ALT_DCLK|BTTV_ALT_NCONFIG,
2488 		BT848_GPIO_OUT_EN);
2489 	btwrite(0,BT848_GPIO_DATA);
2490 	udelay(PVR_GPIO_DELAY);
2491 
2492 	btwrite(BTTV_ALT_NCONFIG,BT848_GPIO_DATA);
2493 	udelay(PVR_GPIO_DELAY);
2494 
2495 	for (n = 0; n < microlen; n++) {
2496 		bits = micro[n];
2497 		for ( i = 0 ; i < 8 ; i++ ) {
2498 			btand(~BTTV_ALT_DCLK,BT848_GPIO_DATA);
2499 			if (bits & 0x01)
2500 				btor(BTTV_ALT_DATA,BT848_GPIO_DATA);
2501 			else
2502 				btand(~BTTV_ALT_DATA,BT848_GPIO_DATA);
2503 			btor(BTTV_ALT_DCLK,BT848_GPIO_DATA);
2504 			bits >>= 1;
2505 		}
2506 	}
2507 	btand(~BTTV_ALT_DCLK,BT848_GPIO_DATA);
2508 	udelay(PVR_GPIO_DELAY);
2509 
2510 	/* begin Altera init loop (Not necessary,but doesn't hurt) */
2511 	for (i = 0 ; i < 30 ; i++) {
2512 		btand(~BTTV_ALT_DCLK,BT848_GPIO_DATA);
2513 		btor(BTTV_ALT_DCLK,BT848_GPIO_DATA);
2514 	}
2515 	btand(~BTTV_ALT_DCLK,BT848_GPIO_DATA);
2516 	return 0;
2517 }
2518 
2519 #ifndef CONFIG_FW_LOADER
2520 /* old 2.4.x way -- via soundcore's mod_firmware_load */
2521 
2522 static char *firm_altera = "/usr/lib/video4linux/hcwamc.rbf";
2523 MODULE_PARM(firm_altera,"s");
2524 MODULE_PARM_DESC(firm_altera,"WinTV/PVR firmware "
2525 		 "(driver CD => unzip pvr45xxx.exe => hcwamc.rbf)");
2526 
2527 extern int mod_firmware_load(const char *fn, char **fp);
2528 
pvr_boot(struct bttv * btv)2529 int __devinit pvr_boot(struct bttv *btv)
2530 {
2531 	u32 microlen;
2532 	u8 *micro;
2533 	int result;
2534 
2535 	microlen = mod_firmware_load(firm_altera, (char**) &micro);
2536 	if (!microlen) {
2537 		printk(KERN_WARNING "bttv%d: altera firmware not found [%s]\n",
2538 		       btv->nr, firm_altera);
2539 		return -1;
2540 	}
2541 
2542 	printk(KERN_INFO "bttv%d: uploading altera firmware [%s] ...\n",
2543 	       btv->nr, firm_altera);
2544 	result = pvr_altera_load(btv, micro, microlen);
2545 	printk(KERN_INFO "bttv%d: ... upload %s\n",
2546 	       btv->nr, (result < 0) ? "failed" : "ok");
2547 	vfree(micro);
2548 	return result;
2549 }
2550 #else
2551 /* new 2.5.x way -- via hotplug firmware loader */
2552 
pvr_boot(struct bttv * btv)2553 int __devinit pvr_boot(struct bttv *btv)
2554 {
2555         const struct firmware *fw_entry;
2556 	int rc;
2557 
2558 	rc = request_firmware(&fw_entry, "hcwamc.rbf", pci_name(btv->dev));
2559 	if (rc != 0) {
2560 		printk(KERN_WARNING "bttv%d: no altera firmware [via hotplug]\n",
2561 		       btv->nr);
2562                 return rc;
2563         }
2564 	rc = pvr_altera_load(btv, fw_entry->data, fw_entry->size);
2565 	printk(KERN_INFO "bttv%d: altera firmware upload %s\n",
2566 	       btv->nr, (rc < 0) ? "failed" : "ok");
2567         release_firmware(fw_entry);
2568 	return rc;
2569 }
2570 #endif
2571 
2572 /* ----------------------------------------------------------------------- */
2573 /* some osprey specific stuff                                              */
2574 
osprey_eeprom(struct bttv * btv)2575 static void __devinit osprey_eeprom(struct bttv *btv)
2576 {
2577        int i = 0;
2578        unsigned char *ee = eeprom_data;
2579        unsigned long serial = 0;
2580 
2581        if (btv->type == 0) {
2582                /* this might be an antique... check for MMAC label in eeprom */
2583                if ((ee[0]=='M') && (ee[1]=='M') && (ee[2]=='A') && (ee[3]=='C')) {
2584                        unsigned char checksum = 0;
2585                        for (i =0; i<21; i++)
2586 			       checksum += ee[i];
2587                        if (checksum != ee[21])
2588 			       return;
2589 		       btv->type = BTTV_OSPREY1x0_848;
2590 		       for (i = 12; i < 21; i++)
2591 			       serial *= 10, serial += ee[i] - '0';
2592                }
2593        } else {
2594 	       unsigned short type;
2595                int offset = 4*16;
2596 
2597                for(; offset < 8*16; offset += 16) {
2598                        unsigned short checksum = 0;
2599                        /* verify the checksum */
2600                        for(i = 0; i<14; i++) checksum += ee[i+offset];
2601                                checksum = ~checksum;  /* no idea why */
2602                                if ((((checksum>>8)&0x0FF) == ee[offset+14]) &&
2603                                    ((checksum & 0x0FF) == ee[offset+15])) {
2604                                break;
2605                        }
2606                }
2607 
2608                if (offset >= 8*16)
2609 		       return;
2610 
2611 	       /* found a valid descriptor */
2612 	       type = (ee[offset+4]<<8) | (ee[offset+5]);
2613 
2614 	       switch(type) {
2615 
2616 	       /* 848 based */
2617 	       case 0x0004:
2618 		       btv->type = BTTV_OSPREY1x0_848;
2619 		       break;
2620 	       case 0x0005:
2621 		       btv->type = BTTV_OSPREY101_848;
2622 		       break;
2623 
2624                /* 878 based */
2625 	       case 0x0012:
2626 	       case 0x0013:
2627 		       btv->type = BTTV_OSPREY1x0;
2628 		       break;
2629 	       case 0x0014:
2630 	       case 0x0015:
2631 		       btv->type = BTTV_OSPREY1x1;
2632 		       break;
2633 	       case 0x0016:
2634 	       case 0x0017:
2635 	       case 0x0020:
2636 		       btv->type = BTTV_OSPREY1x1_SVID;
2637 		       break;
2638 	       case 0x0018:
2639 	       case 0x0019:
2640 	       case 0x001E:
2641 	       case 0x001F:
2642 		       btv->type = BTTV_OSPREY2xx;
2643 		       break;
2644 	       case 0x001A:
2645 	       case 0x001B:
2646 		       btv->type = BTTV_OSPREY2x0_SVID;
2647 		       break;
2648 	       case 0x0040:
2649 		       btv->type = BTTV_OSPREY500;
2650 		       break;
2651 	       case 0x0050:
2652 	       case 0x0056:
2653 		       btv->type = BTTV_OSPREY540;
2654 		       /* bttv_osprey_540_init(btv); */
2655 		       break;
2656 	       case 0x0060:
2657 	       case 0x0070:
2658 		       btv->type = BTTV_OSPREY2x0;
2659 		       //enable output on select control lines
2660 		       btwrite(0x000303, BT848_GPIO_OUT_EN);
2661 		       break;
2662 	       default:
2663 		       /* unknown...leave generic, but get serial # */
2664 		       break;
2665 	       }
2666 	       serial =  (ee[offset+6] << 24)
2667 		       | (ee[offset+7] << 16)
2668 		       | (ee[offset+8] <<  8)
2669 		       | (ee[offset+9]);
2670        }
2671 
2672        printk(KERN_INFO "bttv%d: osprey eeprom: card=%d name=%s serial=%ld\n",
2673 	      btv->nr, btv->type, bttv_tvcards[btv->type].name,serial);
2674 }
2675 
2676 /* ----------------------------------------------------------------------- */
2677 /* AVermedia specific stuff, from  bktr_card.c                             */
2678 
2679 int tuner_0_table[] = {
2680         TUNER_PHILIPS_NTSC,  TUNER_PHILIPS_PAL /* PAL-BG*/,
2681         TUNER_PHILIPS_PAL,   TUNER_PHILIPS_PAL /* PAL-I*/,
2682         TUNER_PHILIPS_PAL,   TUNER_PHILIPS_PAL,
2683         TUNER_PHILIPS_SECAM, TUNER_PHILIPS_SECAM,
2684         TUNER_PHILIPS_SECAM, TUNER_PHILIPS_PAL};
2685 #if 0
2686 int tuner_0_fm_table[] = {
2687         PHILIPS_FR1236_NTSC,  PHILIPS_FR1216_PAL,
2688         PHILIPS_FR1216_PAL,   PHILIPS_FR1216_PAL,
2689         PHILIPS_FR1216_PAL,   PHILIPS_FR1216_PAL,
2690         PHILIPS_FR1236_SECAM, PHILIPS_FR1236_SECAM,
2691         PHILIPS_FR1236_SECAM, PHILIPS_FR1216_PAL};
2692 #endif
2693 
2694 int tuner_1_table[] = {
2695         TUNER_TEMIC_NTSC,  TUNER_TEMIC_PAL,
2696 	TUNER_TEMIC_PAL,   TUNER_TEMIC_PAL,
2697 	TUNER_TEMIC_PAL,   TUNER_TEMIC_PAL,
2698         TUNER_TEMIC_4012FY5, TUNER_TEMIC_4012FY5, //TUNER_TEMIC_SECAM
2699         TUNER_TEMIC_4012FY5, TUNER_TEMIC_PAL};
2700 
avermedia_eeprom(struct bttv * btv)2701 static void __devinit avermedia_eeprom(struct bttv *btv)
2702 {
2703         int tuner_make,tuner_tv_fm,tuner_format,tuner=0;
2704 
2705 	tuner_make      = (eeprom_data[0x41] & 0x7);
2706         tuner_tv_fm     = (eeprom_data[0x41] & 0x18) >> 3;
2707         tuner_format    = (eeprom_data[0x42] & 0xf0) >> 4;
2708 	btv->has_remote = (eeprom_data[0x42] & 0x01);
2709 
2710 	if (tuner_make == 0 || tuner_make == 2)
2711 		if(tuner_format <=9)
2712 			tuner = tuner_0_table[tuner_format];
2713 	if (tuner_make == 1)
2714 		if(tuner_format <=9)
2715 			tuner = tuner_1_table[tuner_format];
2716 
2717 	printk(KERN_INFO "bttv%d: Avermedia eeprom[0x%02x%02x]: tuner=",
2718 		btv->nr,eeprom_data[0x41],eeprom_data[0x42]);
2719 	if(tuner) {
2720 		btv->tuner_type=tuner;
2721 		printk("%d",tuner);
2722 	} else
2723 		printk("Unknown type");
2724 	printk(" radio:%s remote control:%s\n",
2725 	       tuner_tv_fm     ? "yes" : "no",
2726 	       btv->has_remote ? "yes" : "no");
2727 }
2728 
2729 /* used on Voodoo TV/FM (Voodoo 200), S0 wired to 0x10000 */
bttv_tda9880_setnorm(struct bttv * btv,int norm)2730 void bttv_tda9880_setnorm(struct bttv *btv, int norm)
2731 {
2732 	// fix up our card entry
2733 	if(norm==VIDEO_MODE_NTSC) {
2734 		bttv_tvcards[BTTV_VOODOOTV_FM].audiomux[0]=0x957fff;
2735 		bttv_tvcards[BTTV_VOODOOTV_FM].audiomux[4]=0x957fff;
2736 		dprintk("bttv_tda9880_setnorm to NTSC\n");
2737 	}
2738 	else {
2739 	        bttv_tvcards[BTTV_VOODOOTV_FM].audiomux[0]=0x947fff;
2740                 bttv_tvcards[BTTV_VOODOOTV_FM].audiomux[4]=0x947fff;
2741 		dprintk("bttv_tda9880_setnorm to PAL\n");
2742 	}
2743 	// set GPIO according
2744 	btaor(bttv_tvcards[btv->type].audiomux[btv->audio],
2745               ~bttv_tvcards[btv->type].gpiomask, BT848_GPIO_DATA);
2746 }
2747 
2748 
2749 /*
2750  * reset/enable the MSP on some Hauppauge cards
2751  * Thanks to Ky�sti M�lkki (kmalkki@cc.hut.fi)!
2752  *
2753  * Hauppauge:  pin  5
2754  * Voodoo:     pin 20
2755  */
boot_msp34xx(struct bttv * btv,int pin)2756 static void __devinit boot_msp34xx(struct bttv *btv, int pin)
2757 {
2758 	int mask = (1 << pin);
2759 
2760         btaor(mask, ~mask, BT848_GPIO_OUT_EN);
2761         btaor(0, ~mask, BT848_GPIO_DATA);
2762         udelay(2500);
2763         btaor(mask, ~mask, BT848_GPIO_DATA);
2764 	if (bttv_gpio)
2765 		bttv_gpio_tracking(btv,"msp34xx");
2766 
2767 	if (bttv_verbose)
2768 		printk(KERN_INFO "bttv%d: Hauppauge/Voodoo msp34xx: reset line "
2769 		       "init [%d]\n", btv->nr, pin);
2770 }
2771 
boot_bt832(struct bttv * btv)2772 static void __devinit boot_bt832(struct bttv *btv)
2773 {
2774 	int outbits,databits,resetbit=0;
2775 
2776 	switch (btv->type) {
2777 	case BTTV_PXELVWPLTVPAK:
2778 		resetbit = 0x400000;
2779 		break;
2780 	case BTTV_MODTEC_205:
2781 		resetbit = 1<<9;
2782 		break;
2783 	default:
2784 		BUG();
2785 	}
2786 
2787 	request_module("bt832");
2788 	bttv_call_i2c_clients(btv, BT832_HEXDUMP, NULL);
2789 
2790 	printk("bttv%d: Reset Bt832 [line=0x%x]\n",btv->nr,resetbit);
2791 	btwrite(0, BT848_GPIO_DATA);
2792 	outbits = btread(BT848_GPIO_OUT_EN);
2793 	databits= btread(BT848_GPIO_DATA);
2794 	btwrite(resetbit, BT848_GPIO_OUT_EN);
2795 	udelay(5);
2796 	btwrite(resetbit, BT848_GPIO_DATA);
2797 	udelay(5);
2798 	btwrite(0, BT848_GPIO_DATA);
2799 	udelay(5);
2800 	btwrite(outbits, BT848_GPIO_OUT_EN);
2801 	btwrite(databits, BT848_GPIO_DATA);
2802 
2803 	// bt832 on pixelview changes from i2c 0x8a to 0x88 after
2804 	// being reset as above. So we must follow by this:
2805 	bttv_call_i2c_clients(btv, BT832_REATTACH, NULL);
2806 }
2807 
2808 /* ----------------------------------------------------------------------- */
2809 /*  Imagenation L-Model PXC200 Framegrabber */
2810 /*  This is basically the same procedure as
2811  *  used by Alessandro Rubini in his pxc200
2812  *  driver, but using BTTV functions */
2813 
init_PXC200(struct bttv * btv)2814 static void __devinit init_PXC200(struct bttv *btv)
2815 {
2816 	static int vals[] __devinitdata = { 0x08, 0x09, 0x0a, 0x0b, 0x0d, 0x0d,
2817 					    0x01, 0x02, 0x03, 0x04, 0x05, 0x06,
2818 					    0x00 };
2819 	unsigned int i;
2820 	int tmp;
2821 	u32 val;
2822 
2823 	/* Initialise GPIO-connevted stuff */
2824 	btwrite(1<<13,BT848_GPIO_OUT_EN); /* Reset pin only */
2825 	btwrite(0,BT848_GPIO_DATA);
2826 	udelay(3);
2827 	btwrite(1<<13,BT848_GPIO_DATA);
2828 	/* GPIO inputs are pulled up, so no need to drive
2829 	 * reset pin any longer */
2830 	btwrite(0,BT848_GPIO_OUT_EN);
2831 	if (bttv_gpio)
2832 		bttv_gpio_tracking(btv,"pxc200");
2833 
2834 	/*  we could/should try and reset/control the AD pots? but
2835 	    right now  we simply  turned off the crushing.  Without
2836 	    this the AGC drifts drifts
2837 	    remember the EN is reverse logic -->
2838 	    setting BT848_ADC_AGC_EN disable the AGC
2839 	    tboult@eecs.lehigh.edu
2840 	*/
2841 
2842 	btwrite(BT848_ADC_RESERVED|BT848_ADC_AGC_EN, BT848_ADC);
2843 
2844 	/*	Initialise MAX517 DAC */
2845 	printk(KERN_INFO "Setting DAC reference voltage level ...\n");
2846 	bttv_I2CWrite(btv,0x5E,0,0x80,1);
2847 
2848 	/*	Initialise 12C508 PIC */
2849 	/*	The I2CWrite and I2CRead commmands are actually to the
2850 	 *	same chips - but the R/W bit is included in the address
2851 	 *	argument so the numbers are different */
2852 
2853 
2854 	printk(KERN_INFO "Initialising 12C508 PIC chip ...\n");
2855 
2856 	/* First of all, enable the clock line. This is used in the PXC200-F */
2857 	val = btread(BT848_GPIO_DMA_CTL);
2858 	val |= BT848_GPIO_DMA_CTL_GPCLKMODE;
2859 	btwrite(val, BT848_GPIO_DMA_CTL);
2860 
2861 	/* Then, push to 0 the reset pin long enough to reset the *
2862 	 * device same as above for the reset line, but not the same
2863 	 * value sent to the GPIO-connected stuff
2864 	 * which one is the good one? */
2865 	btwrite( (1<<2), BT848_GPIO_OUT_EN); /* only the reset pin */
2866 	btwrite(0, BT848_GPIO_DATA);
2867 	udelay(10);
2868 	btwrite(1<<2, BT848_GPIO_DATA);
2869 
2870        	for (i = 0; i < ARRAY_SIZE(vals); i++) {
2871 		tmp=bttv_I2CWrite(btv,0x1E,0,vals[i],1);
2872 		if (tmp != -1) {
2873 			printk(KERN_INFO
2874 			       "I2C Write(%2.2x) = %i\nI2C Read () = %2.2x\n\n",
2875 			       vals[i],tmp,bttv_I2CRead(btv,0x1F,NULL));
2876 		}
2877 	}
2878 
2879 	printk(KERN_INFO "PXC200 Initialised.\n");
2880 }
2881 
2882 
2883 /* ----------------------------------------------------------------------- */
2884 /* Miro Pro radio stuff -- the tea5757 is connected to some GPIO ports     */
2885 /*
2886  * Copyright (c) 1999 Csaba Halasz <qgehali@uni-miskolc.hu>
2887  * This code is placed under the terms of the GNU General Public License
2888  *
2889  * Brutally hacked by Dan Sheridan <dan.sheridan@contact.org.uk> djs52 8/3/00
2890  */
2891 
bus_low(struct bttv * btv,int bit)2892 void bus_low(struct bttv *btv, int bit)
2893 {
2894 	if (btv->mbox_ior) {
2895 		btor(btv->mbox_ior | btv->mbox_iow | btv->mbox_csel,
2896 		     BT848_GPIO_DATA);
2897 		udelay(5);
2898 	}
2899 
2900 	btand(~(bit), BT848_GPIO_DATA);
2901 	udelay(5);
2902 
2903 	if (btv->mbox_ior) {
2904 		btand(~(btv->mbox_iow | btv->mbox_csel),
2905 		      BT848_GPIO_DATA);
2906 		udelay(5);
2907 	}
2908 }
2909 
bus_high(struct bttv * btv,int bit)2910 void bus_high(struct bttv *btv, int bit)
2911 {
2912 	if (btv->mbox_ior) {
2913 		btor(btv->mbox_ior | btv->mbox_iow | btv->mbox_csel,
2914 		     BT848_GPIO_DATA);
2915 		udelay(5);
2916 	}
2917 
2918 	btor((bit), BT848_GPIO_DATA);
2919 	udelay(5);
2920 
2921 	if (btv->mbox_ior) {
2922 		btand(~(btv->mbox_iow | btv->mbox_csel),
2923 		      BT848_GPIO_DATA);
2924 		udelay(5);
2925 	}
2926 }
2927 
bus_in(struct bttv * btv,int bit)2928 int bus_in(struct bttv *btv, int bit)
2929 {
2930 	if (btv->mbox_ior) {
2931 		btor(btv->mbox_ior | btv->mbox_iow | btv->mbox_csel,
2932 		     BT848_GPIO_DATA);
2933 		udelay(5);
2934 
2935 		btand(~(btv->mbox_ior | btv->mbox_csel),
2936 		      BT848_GPIO_DATA);
2937 		udelay(5);
2938 	}
2939 	return btread(BT848_GPIO_DATA) & (bit);
2940 }
2941 
2942 /* TEA5757 register bits */
2943 #define TEA_FREQ		0:14
2944 #define TEA_BUFFER		15:15
2945 
2946 #define TEA_SIGNAL_STRENGTH	16:17
2947 
2948 #define TEA_PORT1		18:18
2949 #define TEA_PORT0		19:19
2950 
2951 #define TEA_BAND		20:21
2952 #define TEA_BAND_FM		0
2953 #define TEA_BAND_MW		1
2954 #define TEA_BAND_LW		2
2955 #define TEA_BAND_SW		3
2956 
2957 #define TEA_MONO		22:22
2958 #define TEA_ALLOW_STEREO	0
2959 #define TEA_FORCE_MONO		1
2960 
2961 #define TEA_SEARCH_DIRECTION	23:23
2962 #define TEA_SEARCH_DOWN		0
2963 #define TEA_SEARCH_UP		1
2964 
2965 #define TEA_STATUS		24:24
2966 #define TEA_STATUS_TUNED	0
2967 #define TEA_STATUS_SEARCHING	1
2968 
2969 /* Low-level stuff */
tea5757_read(struct bttv * btv)2970 static int tea5757_read(struct bttv *btv)
2971 {
2972 	unsigned long timeout;
2973 	int value = 0;
2974 	int i;
2975 
2976 	/* better safe than sorry */
2977 	btaor((btv->mbox_clk | btv->mbox_we),
2978 	      ~btv->mbox_mask, BT848_GPIO_OUT_EN);
2979 
2980 	if (btv->mbox_ior) {
2981 		btor(btv->mbox_ior | btv->mbox_iow | btv->mbox_csel,
2982 		     BT848_GPIO_DATA);
2983 		udelay(5);
2984 	}
2985 
2986 	if (bttv_gpio)
2987 		bttv_gpio_tracking(btv,"tea5757 read");
2988 
2989 	bus_low(btv,btv->mbox_we);
2990 	bus_low(btv,btv->mbox_clk);
2991 
2992 	udelay(10);
2993 	timeout= jiffies + HZ;
2994 
2995 	// wait for DATA line to go low; error if it doesn't
2996 	while (bus_in(btv,btv->mbox_data) && time_before(jiffies, timeout))
2997 		schedule();
2998 	if (bus_in(btv,btv->mbox_data)) {
2999 		printk(KERN_WARNING "bttv%d: tea5757: read timeout\n",btv->nr);
3000 		return -1;
3001 	}
3002 
3003 	dprintk("bttv%d: tea5757:",btv->nr);
3004 	for(i = 0; i < 24; i++)
3005 	{
3006 		udelay(5);
3007 		bus_high(btv,btv->mbox_clk);
3008 		udelay(5);
3009 		dprintk("%c",(bus_in(btv,btv->mbox_most) == 0)?'T':'-');
3010 		bus_low(btv,btv->mbox_clk);
3011 		value <<= 1;
3012 		value |= (bus_in(btv,btv->mbox_data) == 0)?0:1;  /* MSB first */
3013 		dprintk("%c", (bus_in(btv,btv->mbox_most) == 0)?'S':'M');
3014 	}
3015 	dprintk("\nbttv%d: tea5757: read 0x%X\n", btv->nr, value);
3016 	return value;
3017 }
3018 
tea5757_write(struct bttv * btv,int value)3019 static int tea5757_write(struct bttv *btv, int value)
3020 {
3021 	int i;
3022 	int reg = value;
3023 
3024 	btaor(btv->mbox_clk | btv->mbox_we | btv->mbox_data,
3025 	      ~btv->mbox_mask, BT848_GPIO_OUT_EN);
3026 
3027 	if (btv->mbox_ior) {
3028 		btor(btv->mbox_ior | btv->mbox_iow | btv->mbox_csel,
3029 		     BT848_GPIO_DATA);
3030 		udelay(5);
3031 	}
3032 	if (bttv_gpio)
3033 		bttv_gpio_tracking(btv,"tea5757 write");
3034 
3035 	dprintk("bttv%d: tea5757: write 0x%X\n", btv->nr, value);
3036 	bus_low(btv,btv->mbox_clk);
3037 	bus_high(btv,btv->mbox_we);
3038 	for(i = 0; i < 25; i++)
3039 	{
3040 		if (reg & 0x1000000)
3041 			bus_high(btv,btv->mbox_data);
3042 		else
3043 			bus_low(btv,btv->mbox_data);
3044 		reg <<= 1;
3045 		bus_high(btv,btv->mbox_clk);
3046 		udelay(10);
3047 		bus_low(btv,btv->mbox_clk);
3048 		udelay(10);
3049 	}
3050 	bus_low(btv,btv->mbox_we);  /* unmute !!! */
3051 	return 0;
3052 }
3053 
tea5757_set_freq(struct bttv * btv,unsigned short freq)3054 void tea5757_set_freq(struct bttv *btv, unsigned short freq)
3055 {
3056 	dprintk("tea5757_set_freq %d\n",freq);
3057 	tea5757_write(btv, 5 * freq + 0x358); /* add 10.7MHz (see docs) */
3058 #if 0
3059 	/* breaks Miro PCTV */
3060 	value = tea5757_read(btv);
3061 	dprintk("bttv%d: tea5757 readback=0x%x\n",btv->nr,value);
3062 #endif
3063 }
3064 
3065 
3066 /* ----------------------------------------------------------------------- */
3067 /* winview                                                                 */
3068 
winview_audio(struct bttv * btv,struct video_audio * v,int set)3069 void winview_audio(struct bttv *btv, struct video_audio *v, int set)
3070 {
3071 	/* PT2254A programming Jon Tombs, jon@gte.esi.us.es */
3072 	int bits_out, loops, vol, data;
3073 
3074 	if (!set) {
3075 		/* Fixed by Leandro Lucarella <luca@linuxmendoza.org.ar (07/31/01) */
3076 		v->flags |= VIDEO_AUDIO_VOLUME;
3077 		return;
3078 	}
3079 
3080 	/* 32 levels logarithmic */
3081 	vol = 32 - ((v->volume>>11));
3082 	/* units */
3083 	bits_out = (PT2254_DBS_IN_2>>(vol%5));
3084 	/* tens */
3085 	bits_out |= (PT2254_DBS_IN_10>>(vol/5));
3086 	bits_out |= PT2254_L_CHANNEL | PT2254_R_CHANNEL;
3087 	data = btread(BT848_GPIO_DATA);
3088 	data &= ~(WINVIEW_PT2254_CLK| WINVIEW_PT2254_DATA|
3089 		  WINVIEW_PT2254_STROBE);
3090 	for (loops = 17; loops >= 0 ; loops--) {
3091 		if (bits_out & (1<<loops))
3092 			data |=  WINVIEW_PT2254_DATA;
3093 		else
3094 			data &= ~WINVIEW_PT2254_DATA;
3095 		btwrite(data, BT848_GPIO_DATA);
3096 		udelay(5);
3097 		data |= WINVIEW_PT2254_CLK;
3098 		btwrite(data, BT848_GPIO_DATA);
3099 		udelay(5);
3100 		data &= ~WINVIEW_PT2254_CLK;
3101 		btwrite(data, BT848_GPIO_DATA);
3102 	}
3103 	data |=  WINVIEW_PT2254_STROBE;
3104 	data &= ~WINVIEW_PT2254_DATA;
3105 	btwrite(data, BT848_GPIO_DATA);
3106 	udelay(10);
3107 	data &= ~WINVIEW_PT2254_STROBE;
3108 	btwrite(data, BT848_GPIO_DATA);
3109 }
3110 
3111 /* ----------------------------------------------------------------------- */
3112 /* mono/stereo control for various cards (which don't use i2c chips but    */
3113 /* connect something to the GPIO pins                                      */
3114 
3115 static void
gvbctv3pci_audio(struct bttv * btv,struct video_audio * v,int set)3116 gvbctv3pci_audio(struct bttv *btv, struct video_audio *v, int set)
3117 {
3118 	unsigned int con = 0;
3119 
3120 	if (set) {
3121 		btor(0x300, BT848_GPIO_OUT_EN);
3122 		if (v->mode & VIDEO_SOUND_LANG1)
3123 			con = 0x000;
3124 		if (v->mode & VIDEO_SOUND_LANG2)
3125 			con = 0x300;
3126 		if (v->mode & VIDEO_SOUND_STEREO)
3127 			con = 0x200;
3128 //		if (v->mode & VIDEO_SOUND_MONO)
3129 //			con = 0x100;
3130 		btaor(con, ~0x300, BT848_GPIO_DATA);
3131 	} else {
3132 		v->mode = VIDEO_SOUND_STEREO |
3133 			  VIDEO_SOUND_LANG1  | VIDEO_SOUND_LANG2;
3134 	}
3135 }
3136 
3137 /*
3138  * Mario Medina Nussbaum <medisoft@alohabbs.org.mx>
3139  *  I discover that on BT848_GPIO_DATA address a byte 0xcce enable stereo,
3140  *  0xdde enables mono and 0xccd enables sap
3141  *
3142  * Petr Vandrovec <VANDROVE@vc.cvut.cz>
3143  *  P.S.: At least mask in line above is wrong - GPIO pins 3,2 select
3144  *  input/output sound connection, so both must be set for output mode.
3145  *
3146  * Looks like it's needed only for the "tvphone", the "tvphone 98"
3147  * handles this with a tda9840
3148  *
3149  */
3150 static void
avermedia_tvphone_audio(struct bttv * btv,struct video_audio * v,int set)3151 avermedia_tvphone_audio(struct bttv *btv, struct video_audio *v, int set)
3152 {
3153 	int val = 0;
3154 
3155 	if (set) {
3156 		if (v->mode & VIDEO_SOUND_LANG1)   /* SAP */
3157 			val = 0x02;
3158 		if (v->mode & VIDEO_SOUND_STEREO)
3159 			val = 0x01;
3160 		if (val) {
3161 			btaor(val, ~0x03, BT848_GPIO_DATA);
3162 			if (bttv_gpio)
3163 				bttv_gpio_tracking(btv,"avermedia");
3164 		}
3165 	} else {
3166 		v->mode = VIDEO_SOUND_MONO | VIDEO_SOUND_STEREO |
3167 			VIDEO_SOUND_LANG1;
3168 		return;
3169 	}
3170 }
3171 
3172 /* Lifetec 9415 handling */
3173 static void
lt9415_audio(struct bttv * btv,struct video_audio * v,int set)3174 lt9415_audio(struct bttv *btv, struct video_audio *v, int set)
3175 {
3176         int val = 0;
3177 
3178         if (btread(BT848_GPIO_DATA) & 0x4000) {
3179 		v->mode = VIDEO_SOUND_MONO;
3180 		return;
3181 	}
3182 
3183         if (set) {
3184                 if (v->mode & VIDEO_SOUND_LANG2)  /* A2 SAP */
3185                         val = 0x0080;
3186 		if (v->mode & VIDEO_SOUND_STEREO) /* A2 stereo */
3187                         val = 0x0880;
3188                 if ((v->mode & VIDEO_SOUND_LANG1) ||
3189 		    (v->mode & VIDEO_SOUND_MONO))
3190 			val = 0;
3191                 btaor(val, ~0x0880, BT848_GPIO_DATA);
3192                 if (bttv_gpio)
3193                         bttv_gpio_tracking(btv,"lt9415");
3194         } else {
3195 		/* autodetect doesn't work with this card :-( */
3196                 v->mode = VIDEO_SOUND_MONO | VIDEO_SOUND_STEREO |
3197 			VIDEO_SOUND_LANG1 | VIDEO_SOUND_LANG2;
3198                 return;
3199         }
3200 }
3201 
3202 // TDA9821 on TerraTV+ Bt848, Bt878
3203 static void
terratv_audio(struct bttv * btv,struct video_audio * v,int set)3204 terratv_audio(struct bttv *btv, struct video_audio *v, int set)
3205 {
3206 	unsigned int con = 0;
3207 
3208 	if (set) {
3209 		btor(0x180000, BT848_GPIO_OUT_EN);
3210 		if (v->mode & VIDEO_SOUND_LANG2)
3211 			con = 0x080000;
3212 		if (v->mode & VIDEO_SOUND_STEREO)
3213 			con = 0x180000;
3214 		btaor(con, ~0x180000, BT848_GPIO_DATA);
3215 		if (bttv_gpio)
3216 			bttv_gpio_tracking(btv,"terratv");
3217 	} else {
3218 		v->mode = VIDEO_SOUND_MONO | VIDEO_SOUND_STEREO |
3219 			VIDEO_SOUND_LANG1 | VIDEO_SOUND_LANG2;
3220 	}
3221 }
3222 
3223 static void
winfast2000_audio(struct bttv * btv,struct video_audio * v,int set)3224 winfast2000_audio(struct bttv *btv, struct video_audio *v, int set)
3225 {
3226 	unsigned long val = 0;
3227 
3228 	if (set) {
3229 		/*btor (0xc32000, BT848_GPIO_OUT_EN);*/
3230 		if (v->mode & VIDEO_SOUND_MONO)		/* Mono */
3231 			val = 0x420000;
3232 		if (v->mode & VIDEO_SOUND_LANG1)	/* Mono */
3233 			val = 0x420000;
3234 		if (v->mode & VIDEO_SOUND_LANG2)	/* SAP */
3235 			val = 0x410000;
3236 		if (v->mode & VIDEO_SOUND_STEREO)	/* Stereo */
3237 			val = 0x020000;
3238 		if (val) {
3239 			btaor(val, ~0x430000, BT848_GPIO_DATA);
3240 			if (bttv_gpio)
3241 				bttv_gpio_tracking(btv,"winfast2000");
3242 		}
3243 	} else {
3244 		v->mode = VIDEO_SOUND_MONO | VIDEO_SOUND_STEREO |
3245 			  VIDEO_SOUND_LANG1 | VIDEO_SOUND_LANG2;
3246 	}
3247 }
3248 
3249 /*
3250  * Dariusz Kowalewski <darekk@automex.pl>
3251  * sound control for Prolink PV-BT878P+9B (PixelView PlayTV Pro FM+NICAM
3252  * revision 9B has on-board TDA9874A sound decoder).
3253  *
3254  * Note: There are card variants without tda9874a. Forcing the "stereo sound route"
3255  *       will mute this cards.
3256  */
3257 static void
pvbt878p9b_audio(struct bttv * btv,struct video_audio * v,int set)3258 pvbt878p9b_audio(struct bttv *btv, struct video_audio *v, int set)
3259 {
3260 	unsigned int val = 0;
3261 
3262 #if BTTV_VERSION_CODE > KERNEL_VERSION(0,8,0)
3263 	if (btv->radio_user)
3264 		return;
3265 #else
3266 	if (btv->radio)
3267 		return;
3268 #endif
3269 
3270 	if (set) {
3271 		if (v->mode & VIDEO_SOUND_MONO)	{
3272 			val = 0x01;
3273 		}
3274 		if ((v->mode & (VIDEO_SOUND_LANG1 | VIDEO_SOUND_LANG2))
3275 		    || (v->mode & VIDEO_SOUND_STEREO)) {
3276 			val = 0x02;
3277 		}
3278 		if (val) {
3279 			btaor(val, ~0x03, BT848_GPIO_DATA);
3280 			if (bttv_gpio)
3281 				bttv_gpio_tracking(btv,"pvbt878p9b");
3282 		}
3283 	} else {
3284 		v->mode = VIDEO_SOUND_MONO | VIDEO_SOUND_STEREO |
3285 			VIDEO_SOUND_LANG1 | VIDEO_SOUND_LANG2;
3286 	}
3287 }
3288 
3289 /*
3290  * Dariusz Kowalewski <darekk@automex.pl>
3291  * sound control for FlyVideo 2000S (with tda9874 decoder)
3292  * based on pvbt878p9b_audio() - this is not tested, please fix!!!
3293  */
3294 static void
fv2000s_audio(struct bttv * btv,struct video_audio * v,int set)3295 fv2000s_audio(struct bttv *btv, struct video_audio *v, int set)
3296 {
3297 	unsigned int val = 0xffff;
3298 
3299 #if BTTV_VERSION_CODE > KERNEL_VERSION(0,8,0)
3300 	if (btv->radio_user)
3301 		return;
3302 #else
3303 	if (btv->radio)
3304 		return;
3305 #endif
3306 	if (set) {
3307 		if (v->mode & VIDEO_SOUND_MONO)	{
3308 			val = 0x0000;
3309 		}
3310 		if ((v->mode & (VIDEO_SOUND_LANG1 | VIDEO_SOUND_LANG2))
3311 		    || (v->mode & VIDEO_SOUND_STEREO)) {
3312 			val = 0x1080; //-dk-???: 0x0880, 0x0080, 0x1800 ...
3313 		}
3314 		if (val != 0xffff) {
3315 			btaor(val, ~0x1800, BT848_GPIO_DATA);
3316 			if (bttv_gpio)
3317 				bttv_gpio_tracking(btv,"fv2000s");
3318 		}
3319 	} else {
3320 		v->mode = VIDEO_SOUND_MONO | VIDEO_SOUND_STEREO |
3321 			VIDEO_SOUND_LANG1 | VIDEO_SOUND_LANG2;
3322 	}
3323 }
3324 
3325 /*
3326  * sound control for Canopus WinDVR PCI
3327  * Masaki Suzuki <masaki@btree.org>
3328  */
3329 static void
windvr_audio(struct bttv * btv,struct video_audio * v,int set)3330 windvr_audio(struct bttv *btv, struct video_audio *v, int set)
3331 {
3332         unsigned long val = 0;
3333 
3334         if (set) {
3335                 if (v->mode & VIDEO_SOUND_MONO)
3336                         val = 0x040000;
3337                 if (v->mode & VIDEO_SOUND_LANG1)
3338                         val = 0;
3339                 if (v->mode & VIDEO_SOUND_LANG2)
3340                         val = 0x100000;
3341                 if (v->mode & VIDEO_SOUND_STEREO)
3342                         val = 0;
3343                 if (val) {
3344                         btaor(val, ~0x140000, BT848_GPIO_DATA);
3345                         if (bttv_gpio)
3346                                 bttv_gpio_tracking(btv,"windvr");
3347                 }
3348         } else {
3349                 v->mode = VIDEO_SOUND_MONO | VIDEO_SOUND_STEREO |
3350                           VIDEO_SOUND_LANG1 | VIDEO_SOUND_LANG2;
3351         }
3352 }
3353 
3354 /*
3355  * sound control for AD-TVK503
3356  * Hiroshi Takekawa <sian@big.or.jp>
3357  */
3358 static void
adtvk503_audio(struct bttv * btv,struct video_audio * v,int set)3359 adtvk503_audio(struct bttv *btv, struct video_audio *v, int set)
3360 {
3361 	unsigned int con = 0xffffff;
3362 
3363 	//btaor(0x1e0000, ~0x1e0000, BT848_GPIO_OUT_EN);
3364 
3365 	if (set) {
3366 		//btor(***, BT848_GPIO_OUT_EN);
3367 		if (v->mode & VIDEO_SOUND_LANG1)
3368 			con = 0x00000000;
3369 		if (v->mode & VIDEO_SOUND_LANG2)
3370 			con = 0x00180000;
3371 		if (v->mode & VIDEO_SOUND_STEREO)
3372 			con = 0x00000000;
3373 		if (v->mode & VIDEO_SOUND_MONO)
3374 			con = 0x00060000;
3375 		if (con != 0xffffff) {
3376 			btaor(con, ~0x1e0000, BT848_GPIO_DATA);
3377 			if (bttv_gpio)
3378 				bttv_gpio_tracking(btv, "adtvk503");
3379 		}
3380 	} else {
3381 		v->mode = VIDEO_SOUND_MONO | VIDEO_SOUND_STEREO |
3382 			  VIDEO_SOUND_LANG1  | VIDEO_SOUND_LANG2;
3383 	}
3384 }
3385 
3386 /* RemoteVision MX (rv605) muxsel helper [Miguel Freitas]
3387  *
3388  * This is needed because rv605 don't use a normal multiplex, but a crosspoint
3389  * switch instead (CD22M3494E). This IC can have multiple active connections
3390  * between Xn (input) and Yn (output) pins. We need to clear any existing
3391  * connection prior to establish a new one, pulsing the STROBE pin.
3392  *
3393  * The board hardwire Y0 (xpoint) to MUX1 and MUXOUT to Yin.
3394  * GPIO pins are wired as:
3395  *  GPIO[0:3] - AX[0:3] (xpoint) - P1[0:3] (microcontroler)
3396  *  GPIO[4:6] - AY[0:2] (xpoint) - P1[4:6] (microcontroler)
3397  *  GPIO[7]   - DATA (xpoint)    - P1[7] (microcontroler)
3398  *  GPIO[8]   -                  - P3[5] (microcontroler)
3399  *  GPIO[9]   - RESET (xpoint)   - P3[6] (microcontroler)
3400  *  GPIO[10]  - STROBE (xpoint)  - P3[7] (microcontroler)
3401  *  GPINTR    -                  - P3[4] (microcontroler)
3402  *
3403  * The microcontroler is a 80C32 like. It should be possible to change xpoint
3404  * configuration either directly (as we are doing) or using the microcontroler
3405  * which is also wired to I2C interface. I have no further info on the
3406  * microcontroler features, one would need to disassembly the firmware.
3407  * note: the vendor refused to give any information on this product, all
3408  *       that stuff was found using a multimeter! :)
3409  */
rv605_muxsel(struct bttv * btv,unsigned int input)3410 static void rv605_muxsel(struct bttv *btv, unsigned int input)
3411 {
3412 	/* reset all conections */
3413 	btaor(0x200,~0x200, BT848_GPIO_DATA);
3414 	mdelay(1);
3415 	btaor(0x000,~0x200, BT848_GPIO_DATA);
3416 	mdelay(1);
3417 
3418 	/* create a new conection */
3419 	btaor(0x080,~0x480, BT848_GPIO_DATA);
3420 	btaor(0x480,~0x480, BT848_GPIO_DATA);
3421 	mdelay(1);
3422 	btaor(0x080,~0x480, BT848_GPIO_DATA);
3423 	mdelay(1);
3424 }
3425 
3426 // The Grandtec X-Guard framegrabber card uses two Dual 4-channel
3427 // video multiplexers to provide up to 16 video inputs. These
3428 // multiplexers are controlled by the lower 8 GPIO pins of the
3429 // bt878. The multiplexers probably Pericom PI5V331Q or similar.
3430 
3431 // xxx0 is pin xxx of multiplexer U5,
3432 // yyy1 is pin yyy of multiplexer U2
3433 
3434 #define ENA0    0x01
3435 #define ENB0    0x02
3436 #define ENA1    0x04
3437 #define ENB1    0x08
3438 
3439 #define IN10    0x10
3440 #define IN00    0x20
3441 #define IN11    0x40
3442 #define IN01    0x80
3443 
xguard_muxsel(struct bttv * btv,unsigned int input)3444 static void xguard_muxsel(struct bttv *btv, unsigned int input)
3445 {
3446 	static const int masks[] = {
3447                 ENB0, ENB0|IN00, ENB0|IN10, ENB0|IN00|IN10,
3448                 ENA0, ENA0|IN00, ENA0|IN10, ENA0|IN00|IN10,
3449                 ENB1, ENB1|IN01, ENB1|IN11, ENB1|IN01|IN11,
3450                 ENA1, ENA1|IN01, ENA1|IN11, ENA1|IN01|IN11,
3451 	};
3452         btwrite(masks[input%16], BT848_GPIO_DATA);
3453 }
3454 
3455 /* ----------------------------------------------------------------------- */
3456 /* motherboard chipset specific stuff                                      */
3457 
bttv_check_chipset(void)3458 void __devinit bttv_check_chipset(void)
3459 {
3460 	int pcipci_fail = 0;
3461 	struct pci_dev *dev = NULL;
3462 
3463 	if (pci_pci_problems & PCIPCI_FAIL)
3464 		pcipci_fail = 1;
3465 	if (pci_pci_problems & (PCIPCI_TRITON|PCIPCI_NATOMA|PCIPCI_VIAETBF))
3466 		triton1 = 1;
3467 	if (pci_pci_problems & PCIPCI_VSFX)
3468 		vsfx = 1;
3469 #ifdef PCIPCI_ALIMAGIK
3470 	if (pci_pci_problems & PCIPCI_ALIMAGIK)
3471 		latency = 0x0A;
3472 #endif
3473 
3474 #if 0
3475 	/* print which chipset we have */
3476 	while ((dev = pci_find_class(PCI_CLASS_BRIDGE_HOST << 8,dev)))
3477 		printk(KERN_INFO "bttv: Host bridge is %s\n",pci_name(dev));
3478 #endif
3479 
3480 	/* print warnings about any quirks found */
3481 	if (triton1)
3482 		printk(KERN_INFO "bttv: Host bridge needs ETBF enabled.\n");
3483 	if (vsfx)
3484 		printk(KERN_INFO "bttv: Host bridge needs VSFX enabled.\n");
3485 	if (pcipci_fail) {
3486 		printk(KERN_WARNING "bttv: BT848 and your chipset may not work together.\n");
3487 		if (UNSET == no_overlay) {
3488 			printk(KERN_WARNING "bttv: going to disable overlay.\n");
3489 			no_overlay = 1;
3490 		}
3491 	}
3492 	if (UNSET != latency)
3493 		printk(KERN_INFO "bttv: pci latency fixup [%d]\n",latency);
3494 
3495 	while ((dev = pci_find_device(PCI_VENDOR_ID_INTEL,
3496 				      PCI_DEVICE_ID_INTEL_82441, dev))) {
3497                 unsigned char b;
3498 		pci_read_config_byte(dev, 0x53, &b);
3499 		if (bttv_debug)
3500 			printk(KERN_INFO "bttv: Host bridge: 82441FX Natoma, "
3501 			       "bufcon=0x%02x\n",b);
3502 	}
3503 }
3504 
bttv_handle_chipset(struct bttv * btv)3505 int __devinit bttv_handle_chipset(struct bttv *btv)
3506 {
3507  	unsigned char command;
3508 
3509 	if (!triton1 && !vsfx && UNSET == latency)
3510 		return 0;
3511 
3512 	if (bttv_verbose) {
3513 		if (triton1)
3514 			printk(KERN_INFO "bttv%d: enabling ETBF (430FX/VP3 compatibilty)\n",btv->nr);
3515 		if (vsfx && btv->id >= 878)
3516 			printk(KERN_INFO "bttv%d: enabling VSFX\n",btv->nr);
3517 		if (UNSET != latency)
3518 			printk(KERN_INFO "bttv%d: setting pci timer to %d\n",
3519 			       btv->nr,latency);
3520 	}
3521 
3522 	if (btv->id < 878) {
3523 		/* bt848 (mis)uses a bit in the irq mask for etbf */
3524 		if (triton1)
3525 			btv->triton1 = BT848_INT_ETBF;
3526 	} else {
3527 		/* bt878 has a bit in the pci config space for it */
3528                 pci_read_config_byte(btv->dev, BT878_DEVCTRL, &command);
3529 		if (triton1)
3530 			command |= BT878_EN_TBFX;
3531 		if (vsfx)
3532 			command |= BT878_EN_VSFX;
3533                 pci_write_config_byte(btv->dev, BT878_DEVCTRL, command);
3534         }
3535 	if (UNSET != latency)
3536 		pci_write_config_byte(btv->dev, PCI_LATENCY_TIMER, latency);
3537 	return 0;
3538 }
3539 
3540 
3541 /*
3542  * Local variables:
3543  * c-basic-offset: 8
3544  * End:
3545  */
3546