Subversion Repositories shark

Rev

Rev 667 | Details | Compare with Previous | Last modification | View Log | RSS feed

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