2 $Id: bttv-cards.c,v 1.49 2005/06/10 17:20:24 mchehab Exp $
6 this file has configuration informations - card-specific stuff
7 like the big tvcards array for the most part
9 Copyright (C) 1996,97,98 Ralph Metzler (rjkm@thp.uni-koeln.de)
10 & Marcus Metzler (mocm@thp.uni-koeln.de)
11 (c) 1999-2001 Gerd Knorr <kraxel@goldbach.in-berlin.de>
13 This program is free software; you can redistribute it and/or modify
14 it under the terms of the GNU General Public License as published by
15 the Free Software Foundation; either version 2 of the License, or
16 (at your option) any later version.
18 This program is distributed in the hope that it will be useful,
19 but WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 GNU General Public License for more details.
23 You should have received a copy of the GNU General Public License
24 along with this program; if not, write to the Free Software
25 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
29 #include <linux/config.h>
30 #include <linux/delay.h>
31 #include <linux/module.h>
32 #include <linux/moduleparam.h>
33 #include <linux/kmod.h>
34 #include <linux/init.h>
35 #include <linux/pci.h>
36 #include <linux/vmalloc.h>
37 #include <linux/firmware.h>
42 #if 0 /* not working yet */
47 static void boot_msp34xx(struct bttv *btv, int pin);
48 static void boot_bt832(struct bttv *btv);
49 static void hauppauge_eeprom(struct bttv *btv);
50 static void avermedia_eeprom(struct bttv *btv);
51 static void osprey_eeprom(struct bttv *btv);
52 static void modtec_eeprom(struct bttv *btv);
53 static void init_PXC200(struct bttv *btv);
54 static void init_RTV24(struct bttv *btv);
56 static void winview_audio(struct bttv *btv, struct video_audio *v, int set);
57 static void lt9415_audio(struct bttv *btv, struct video_audio *v, int set);
58 static void avermedia_tvphone_audio(struct bttv *btv, struct video_audio *v,
60 static void avermedia_tv_stereo_audio(struct bttv *btv, struct video_audio *v,
62 static void terratv_audio(struct bttv *btv, struct video_audio *v, int set);
63 static void gvbctv3pci_audio(struct bttv *btv, struct video_audio *v, int set);
64 static void gvbctv5pci_audio(struct bttv *btv, struct video_audio *v, int set);
65 static void winfast2000_audio(struct bttv *btv, struct video_audio *v, int set);
66 static void pvbt878p9b_audio(struct bttv *btv, struct video_audio *v, int set);
67 static void fv2000s_audio(struct bttv *btv, struct video_audio *v, int set);
68 static void windvr_audio(struct bttv *btv, struct video_audio *v, int set);
69 static void adtvk503_audio(struct bttv *btv, struct video_audio *v, int set);
70 static void rv605_muxsel(struct bttv *btv, unsigned int input);
71 static void eagle_muxsel(struct bttv *btv, unsigned int input);
72 static void xguard_muxsel(struct bttv *btv, unsigned int input);
73 static void ivc120_muxsel(struct bttv *btv, unsigned int input);
74 static void gvc1100_muxsel(struct bttv *btv, unsigned int input);
76 static void PXC200_muxsel(struct bttv *btv, unsigned int input);
78 static void picolo_tetra_muxsel(struct bttv *btv, unsigned int input);
79 static void picolo_tetra_init(struct bttv *btv);
81 static void tibetCS16_muxsel(struct bttv *btv, unsigned int input);
82 static void tibetCS16_init(struct bttv *btv);
84 static void kodicom4400r_muxsel(struct bttv *btv, unsigned int input);
85 static void kodicom4400r_init(struct bttv *btv);
87 static void sigmaSLC_muxsel(struct bttv *btv, unsigned int input);
88 static void sigmaSQ_muxsel(struct bttv *btv, unsigned int input);
90 static int terratec_active_radio_upgrade(struct bttv *btv);
91 static int tea5757_read(struct bttv *btv);
92 static int tea5757_write(struct bttv *btv, int value);
93 static void identify_by_eeprom(struct bttv *btv,
94 unsigned char eeprom_data[256]);
95 static int __devinit pvr_boot(struct bttv *btv);
97 /* config variables */
98 static unsigned int triton1=0;
99 static unsigned int vsfx=0;
100 static unsigned int latency = UNSET;
101 static unsigned int no_overlay=-1;
103 static unsigned int card[BTTV_MAX] = { [ 0 ... (BTTV_MAX-1) ] = UNSET };
104 static unsigned int pll[BTTV_MAX] = { [ 0 ... (BTTV_MAX-1) ] = UNSET };
105 static unsigned int tuner[BTTV_MAX] = { [ 0 ... (BTTV_MAX-1) ] = UNSET };
106 static unsigned int svhs[BTTV_MAX] = { [ 0 ... (BTTV_MAX-1) ] = UNSET };
107 static unsigned int remote[BTTV_MAX] = { [ 0 ... (BTTV_MAX-1) ] = UNSET };
108 static struct bttv *master[BTTV_MAX] = { [ 0 ... (BTTV_MAX-1) ] = NULL };
110 static unsigned int autoload = 1;
112 static unsigned int autoload = 0;
114 static unsigned int gpiomask = UNSET;
115 static unsigned int audioall = UNSET;
116 static unsigned int audiomux[5] = { [ 0 ... 4 ] = UNSET };
119 module_param(triton1, int, 0444);
120 module_param(vsfx, int, 0444);
121 module_param(no_overlay, int, 0444);
122 module_param(latency, int, 0444);
123 module_param(gpiomask, int, 0444);
124 module_param(audioall, int, 0444);
125 module_param(autoload, int, 0444);
127 module_param_array(card, int, NULL, 0444);
128 module_param_array(pll, int, NULL, 0444);
129 module_param_array(tuner, int, NULL, 0444);
130 module_param_array(svhs, int, NULL, 0444);
131 module_param_array(remote, int, NULL, 0444);
132 module_param_array(audiomux, int, NULL, 0444);
134 MODULE_PARM_DESC(triton1,"set ETBF pci config bit "
135 "[enable bug compatibility for triton1 + others]");
136 MODULE_PARM_DESC(vsfx,"set VSFX pci config bit "
137 "[yet another chipset flaw workaround]");
138 MODULE_PARM_DESC(latency,"pci latency timer");
139 MODULE_PARM_DESC(card,"specify TV/grabber card model, see CARDLIST file for a list");
140 MODULE_PARM_DESC(pll,"specify installed crystal (0=none, 28=28 MHz, 35=35 MHz)");
141 MODULE_PARM_DESC(tuner,"specify installed tuner type");
142 MODULE_PARM_DESC(autoload,"automatically load i2c modules like tuner.o, default is 1 (yes)");
144 /* ----------------------------------------------------------------------- */
145 /* list of card IDs for bt878+ cards */
151 } cards[] __devinitdata = {
152 { 0x13eb0070, BTTV_HAUPPAUGE878, "Hauppauge WinTV" },
153 { 0x39000070, BTTV_HAUPPAUGE878, "Hauppauge WinTV-D" },
154 { 0x45000070, BTTV_HAUPPAUGEPVR, "Hauppauge WinTV/PVR" },
155 { 0xff000070, BTTV_OSPREY1x0, "Osprey-100" },
156 { 0xff010070, BTTV_OSPREY2x0_SVID,"Osprey-200" },
157 { 0xff020070, BTTV_OSPREY500, "Osprey-500" },
158 { 0xff030070, BTTV_OSPREY2000, "Osprey-2000" },
159 { 0xff040070, BTTV_OSPREY540, "Osprey-540" },
161 { 0x00011002, BTTV_ATI_TVWONDER, "ATI TV Wonder" },
162 { 0x00031002, BTTV_ATI_TVWONDERVE,"ATI TV Wonder/VE" },
164 { 0x6606107d, BTTV_WINFAST2000, "Leadtek WinFast TV 2000" },
165 { 0x6607107d, BTTV_WINFASTVC100, "Leadtek WinFast VC 100" },
166 { 0x6609107d, BTTV_WINFAST2000, "Leadtek TV 2000 XP" },
167 { 0x263610b4, BTTV_STB2, "STB TV PCI FM, Gateway P/N 6000704" },
168 { 0x264510b4, BTTV_STB2, "STB TV PCI FM, Gateway P/N 6000704" },
169 { 0x402010fc, BTTV_GVBCTV3PCI, "I-O Data Co. GV-BCTV3/PCI" },
170 { 0x405010fc, BTTV_GVBCTV4PCI, "I-O Data Co. GV-BCTV4/PCI" },
171 { 0x407010fc, BTTV_GVBCTV5PCI, "I-O Data Co. GV-BCTV5/PCI" },
172 { 0xd01810fc, BTTV_GVBCTV5PCI, "I-O Data Co. GV-BCTV5/PCI" },
174 { 0x001211bd, BTTV_PINNACLE, "Pinnacle PCTV" },
175 // some cards ship with byteswapped IDs ...
176 { 0x1200bd11, BTTV_PINNACLE, "Pinnacle PCTV [bswap]" },
177 { 0xff00bd11, BTTV_PINNACLE, "Pinnacle PCTV [bswap]" },
178 // this seems to happen as well ...
179 { 0xff1211bd, BTTV_PINNACLE, "Pinnacle PCTV" },
181 { 0x3000121a, BTTV_VOODOOTV_FM, "3Dfx VoodooTV FM/ VoodooTV 200" },
182 { 0x263710b4, BTTV_VOODOOTV_FM, "3Dfx VoodooTV FM/ VoodooTV 200" },
183 { 0x3060121a, BTTV_STB2, "3Dfx VoodooTV 100/ STB OEM" },
185 { 0x3000144f, BTTV_MAGICTVIEW063, "(Askey Magic/others) TView99 CPH06x" },
186 { 0xa005144f, BTTV_MAGICTVIEW063, "CPH06X TView99-Card" },
187 { 0x3002144f, BTTV_MAGICTVIEW061, "(Askey Magic/others) TView99 CPH05x" },
188 { 0x3005144f, BTTV_MAGICTVIEW061, "(Askey Magic/others) TView99 CPH061/06L (T1/LC)" },
189 { 0x5000144f, BTTV_MAGICTVIEW061, "Askey CPH050" },
190 { 0x300014ff, BTTV_MAGICTVIEW061, "TView 99 (CPH061)" },
191 { 0x300214ff, BTTV_PHOEBE_TVMAS, "Phoebe TV Master (CPH060)" },
193 { 0x00011461, BTTV_AVPHONE98, "AVerMedia TVPhone98" },
194 { 0x00021461, BTTV_AVERMEDIA98, "AVermedia TVCapture 98" },
195 { 0x00031461, BTTV_AVPHONE98, "AVerMedia TVPhone98" },
196 { 0x00041461, BTTV_AVERMEDIA98, "AVerMedia TVCapture 98" },
197 { 0x03001461, BTTV_AVERMEDIA98, "VDOMATE TV TUNER CARD" },
199 { 0x1117153b, BTTV_TERRATVALUE, "Terratec TValue (Philips PAL B/G)" },
200 { 0x1118153b, BTTV_TERRATVALUE, "Terratec TValue (Temic PAL B/G)" },
201 { 0x1119153b, BTTV_TERRATVALUE, "Terratec TValue (Philips PAL I)" },
202 { 0x111a153b, BTTV_TERRATVALUE, "Terratec TValue (Temic PAL I)" },
204 { 0x1123153b, BTTV_TERRATVRADIO, "Terratec TV Radio+" },
205 { 0x1127153b, BTTV_TERRATV, "Terratec TV+ (V1.05)" },
206 // clashes with FlyVideo
207 //{ 0x18521852, BTTV_TERRATV, "Terratec TV+ (V1.10)" },
208 { 0x1134153b, BTTV_TERRATVALUE, "Terratec TValue (LR102)" },
209 { 0x1135153b, BTTV_TERRATVALUER, "Terratec TValue Radio" }, // LR102
210 { 0x5018153b, BTTV_TERRATVALUE, "Terratec TValue" }, // ??
211 { 0xff3b153b, BTTV_TERRATVALUER, "Terratec TValue Radio" }, // ??
213 { 0x400015b0, BTTV_ZOLTRIX_GENIE, "Zoltrix Genie TV" },
214 { 0x400a15b0, BTTV_ZOLTRIX_GENIE, "Zoltrix Genie TV" },
215 { 0x400d15b0, BTTV_ZOLTRIX_GENIE, "Zoltrix Genie TV / Radio" },
216 { 0x401015b0, BTTV_ZOLTRIX_GENIE, "Zoltrix Genie TV / Radio" },
217 { 0x401615b0, BTTV_ZOLTRIX_GENIE, "Zoltrix Genie TV / Radio" },
219 { 0x1430aa00, BTTV_PV143, "Provideo PV143A" },
220 { 0x1431aa00, BTTV_PV143, "Provideo PV143B" },
221 { 0x1432aa00, BTTV_PV143, "Provideo PV143C" },
222 { 0x1433aa00, BTTV_PV143, "Provideo PV143D" },
223 { 0x1433aa03, BTTV_PV143, "Security Eyes" },
225 { 0x1460aa00, BTTV_PV150, "Provideo PV150A-1" },
226 { 0x1461aa01, BTTV_PV150, "Provideo PV150A-2" },
227 { 0x1462aa02, BTTV_PV150, "Provideo PV150A-3" },
228 { 0x1463aa03, BTTV_PV150, "Provideo PV150A-4" },
230 { 0x1464aa04, BTTV_PV150, "Provideo PV150B-1" },
231 { 0x1465aa05, BTTV_PV150, "Provideo PV150B-2" },
232 { 0x1466aa06, BTTV_PV150, "Provideo PV150B-3" },
233 { 0x1467aa07, BTTV_PV150, "Provideo PV150B-4" },
235 { 0xa132ff00, BTTV_IVC100, "IVC-100" },
236 { 0xa1550000, BTTV_IVC200, "IVC-200" },
237 { 0xa1550001, BTTV_IVC200, "IVC-200" },
238 { 0xa1550002, BTTV_IVC200, "IVC-200" },
239 { 0xa1550003, BTTV_IVC200, "IVC-200" },
240 { 0xa1550100, BTTV_IVC200, "IVC-200G" },
241 { 0xa1550101, BTTV_IVC200, "IVC-200G" },
242 { 0xa1550102, BTTV_IVC200, "IVC-200G" },
243 { 0xa1550103, BTTV_IVC200, "IVC-200G" },
244 { 0xa182ff00, BTTV_IVC120, "IVC-120G" },
245 { 0xa182ff01, BTTV_IVC120, "IVC-120G" },
246 { 0xa182ff02, BTTV_IVC120, "IVC-120G" },
247 { 0xa182ff03, BTTV_IVC120, "IVC-120G" },
248 { 0xa182ff04, BTTV_IVC120, "IVC-120G" },
249 { 0xa182ff05, BTTV_IVC120, "IVC-120G" },
250 { 0xa182ff06, BTTV_IVC120, "IVC-120G" },
251 { 0xa182ff07, BTTV_IVC120, "IVC-120G" },
252 { 0xa182ff08, BTTV_IVC120, "IVC-120G" },
253 { 0xa182ff09, BTTV_IVC120, "IVC-120G" },
254 { 0xa182ff0a, BTTV_IVC120, "IVC-120G" },
255 { 0xa182ff0b, BTTV_IVC120, "IVC-120G" },
256 { 0xa182ff0c, BTTV_IVC120, "IVC-120G" },
257 { 0xa182ff0d, BTTV_IVC120, "IVC-120G" },
258 { 0xa182ff0e, BTTV_IVC120, "IVC-120G" },
259 { 0xa182ff0f, BTTV_IVC120, "IVC-120G" },
261 { 0x41424344, BTTV_GRANDTEC, "GrandTec Multi Capture" },
262 { 0x01020304, BTTV_XGUARD, "Grandtec Grand X-Guard" },
264 { 0x18501851, BTTV_CHRONOS_VS2, "FlyVideo 98 (LR50)/ Chronos Video Shuttle II" },
265 { 0xa0501851, BTTV_CHRONOS_VS2, "FlyVideo 98 (LR50)/ Chronos Video Shuttle II" },
266 { 0x18511851, BTTV_FLYVIDEO98EZ, "FlyVideo 98EZ (LR51)/ CyberMail AV" },
267 { 0x18521852, BTTV_TYPHOON_TVIEW, "FlyVideo 98FM (LR50)/ Typhoon TView TV/FM Tuner" },
268 { 0x41a0a051, BTTV_FLYVIDEO_98FM, "Lifeview FlyVideo 98 LR50 Rev Q" },
269 { 0x18501f7f, BTTV_FLYVIDEO_98, "Lifeview Flyvideo 98" },
271 { 0x010115cb, BTTV_GMV1, "AG GMV1" },
272 { 0x010114c7, BTTV_MODTEC_205, "Modular Technology MM201/MM202/MM205/MM210/MM215 PCTV" },
274 { 0x10b42636, BTTV_HAUPPAUGE878, "STB ???" },
275 { 0x217d6606, BTTV_WINFAST2000, "Leadtek WinFast TV 2000" },
276 { 0xfff6f6ff, BTTV_WINFAST2000, "Leadtek WinFast TV 2000" },
277 { 0x03116000, BTTV_SENSORAY311, "Sensoray 311" },
278 { 0x00790e11, BTTV_WINDVR, "Canopus WinDVR PCI" },
279 { 0xa0fca1a0, BTTV_ZOLTRIX, "Face to Face Tvmax" },
280 { 0x20007063, BTTV_PC_HDTV, "pcHDTV HD-2000 TV"},
281 { 0x82b2aa6a, BTTV_SIMUS_GVC1100, "SIMUS GVC1100" },
282 { 0x146caa0c, BTTV_PV951, "ituner spectra8" },
283 { 0x200a1295, BTTV_PXC200, "ImageNation PXC200A" },
285 { 0x40111554, BTTV_PV_BT878P_9B, "Prolink Pixelview PV-BT" },
286 { 0x17de0a01, BTTV_KWORLD, "Mecer TV/FM/Video Tuner" },
288 { 0x01051805, BTTV_PICOLO_TETRA_CHIP, "Picolo Tetra Chip #1" },
289 { 0x01061805, BTTV_PICOLO_TETRA_CHIP, "Picolo Tetra Chip #2" },
290 { 0x01071805, BTTV_PICOLO_TETRA_CHIP, "Picolo Tetra Chip #3" },
291 { 0x01081805, BTTV_PICOLO_TETRA_CHIP, "Picolo Tetra Chip #4" },
293 // likely broken, vendor id doesn't match the other magic views ...
294 //{ 0xa0fca04f, BTTV_MAGICTVIEW063, "Guillemot Maxi TV Video 3" },
296 // DVB cards (using pci function .1 for mpeg data xfer)
297 { 0x01010071, BTTV_NEBULA_DIGITV, "Nebula Electronics DigiTV" },
298 { 0x07611461, BTTV_AVDVBT_761, "AverMedia AverTV DVB-T 761" },
299 { 0x001c11bd, BTTV_PINNACLESAT, "Pinnacle PCTV Sat" },
300 { 0x002611bd, BTTV_TWINHAN_DST, "Pinnacle PCTV SAT CI" },
301 { 0x00011822, BTTV_TWINHAN_DST, "Twinhan VisionPlus DVB" },
302 { 0xfc00270f, BTTV_TWINHAN_DST, "ChainTech digitop DST-1000 DVB-S" },
303 { 0x07711461, BTTV_AVDVBT_771, "AVermedia AverTV DVB-T 771" },
304 { 0xdb1018ac, BTTV_DVICO_DVBT_LITE, "DVICO FusionHDTV DVB-T Lite" },
309 /* ----------------------------------------------------------------------- */
310 /* array with description for bt848 / bt878 tv/grabber cards */
312 struct tvcard bttv_tvcards[] = {
314 /* ---- card 0x00 ---------------------------------- */
315 .name = " *** UNKNOWN/GENERIC *** ",
320 .muxsel = { 2, 3, 1, 0},
329 .muxsel = { 2, 3, 1, 1},
330 .audiomux = { 2, 0, 0, 0, 10},
334 .name = "Hauppauge (bt848)",
340 .muxsel = { 2, 3, 1, 1},
341 .audiomux = { 0, 1, 2, 3, 4},
345 .name = "STB, Gateway P/N 6000699 (bt848)",
351 .muxsel = { 2, 3, 1, 1},
352 .audiomux = { 4, 0, 2, 3, 1},
355 .tuner_type = TUNER_PHILIPS_NTSC,
360 /* ---- card 0x04 ---------------------------------- */
361 .name = "Intel Create and Share PCI/ Smart Video Recorder III",
367 .muxsel = { 2, 3, 1, 1},
372 .name = "Diamond DTV2000",
378 .muxsel = { 2, 3, 1, 0},
379 .audiomux = { 0, 1, 0, 1, 3},
383 .name = "AVerMedia TVPhone",
388 .muxsel = { 2, 3, 1, 1},
390 .audiomux = { 0x0c, 0x04, 0x08, 0x04, 0},
391 /* 0x04 for some cards ?? */
394 .audio_hook = avermedia_tvphone_audio,
397 .name = "MATRIX-Vision MV-Delta",
403 .muxsel = { 2, 3, 1, 0, 0},
409 /* ---- card 0x08 ---------------------------------- */
410 .name = "Lifeview FlyVideo II (Bt848) LR26 / MAXI TV Video PCI2 LR26",
416 .muxsel = { 2, 3, 1, 1},
417 .audiomux = { 0, 0xc00, 0x800, 0x400, 0xc00, 0},
422 .name = "IMS/IXmicro TurboTV",
428 .muxsel = { 2, 3, 1, 1},
429 .audiomux = { 1, 1, 2, 3, 0},
432 .tuner_type = TUNER_TEMIC_PAL,
434 .name = "Hauppauge (bt878)",
439 .gpiomask = 0x0f, /* old: 7 */
440 .muxsel = { 2, 0, 1, 1},
441 .audiomux = { 0, 1, 2, 3, 4},
446 .name = "MIRO PCTV pro",
452 .muxsel = { 2, 3, 1, 1},
453 .audiomux = { 0x20001,0x10001, 0, 0,10},
458 /* ---- card 0x0c ---------------------------------- */
459 .name = "ADS Technologies Channel Surfer TV (bt848)",
465 .muxsel = { 2, 3, 1, 1},
466 .audiomux = { 13, 14, 11, 7, 0, 0},
470 .name = "AVerMedia TVCapture 98",
476 .muxsel = { 2, 3, 1, 1},
477 .audiomux = { 13, 14, 11, 7, 0, 0},
481 .tuner_type = TUNER_PHILIPS_PAL,
482 .audio_hook = avermedia_tv_stereo_audio,
484 .name = "Aimslab Video Highway Xtreme (VHX)",
490 .muxsel = { 2, 3, 1, 1},
491 .audiomux = { 0, 2, 1, 3, 4}, /* old: { 0, 1, 2, 3, 4} */
496 .name = "Zoltrix TV-Max",
502 .muxsel = { 2, 3, 1, 1},
503 .audiomux = {0 , 0, 1 , 0, 10},
508 /* ---- card 0x10 ---------------------------------- */
509 .name = "Prolink Pixelview PlayTV (bt878)",
514 .gpiomask = 0x01fe00,
515 .muxsel = { 2, 3, 1, 1},
518 .audiomux = { 0x01c000, 0, 0x018000, 0x014000, 0x002000, 0 },
520 // 2003-10-20 by "Anton A. Arapov" <arapov@mail.ru>
521 .audiomux = { 0x001e00, 0, 0x018000, 0x014000, 0x002000, 0 },
527 .name = "Leadtek WinView 601",
532 .gpiomask = 0x8300f8,
533 .muxsel = { 2, 3, 1, 1,0},
534 .audiomux = { 0x4fa007,0xcfa007,0xcfa007,0xcfa007,0xcfa007,0xcfa007},
537 .audio_hook = winview_audio,
540 .name = "AVEC Intercapture",
546 .muxsel = {2, 3, 1, 1},
547 .audiomux = {1, 0, 0, 0, 0},
551 .name = "Lifeview FlyVideo II EZ /FlyKit LR38 Bt848 (capture only)",
556 .gpiomask = 0x8dff00,
557 .muxsel = { 2, 3, 1, 1},
563 /* ---- card 0x14 ---------------------------------- */
564 .name = "CEI Raffles Card",
569 .muxsel = {2, 3, 1, 1},
572 .name = "Lifeview FlyVideo 98/ Lucky Star Image World ConferenceTV LR50",
574 .audio_inputs = 2, // tuner, line in
578 .muxsel = { 2, 3, 1, 1},
579 .audiomux = { 0, 0x800, 0x1000, 0x1000, 0x1800},
581 .tuner_type = TUNER_PHILIPS_PAL_I,
583 .name = "Askey CPH050/ Phoebe Tv Master + FM",
589 .muxsel = { 2, 3, 1, 1},
590 .audiomux = {0, 1, 0x800, 0x400, 0xc00, 0},
595 .name = "Modular Technology MM201/MM202/MM205/MM210/MM215 PCTV, bt878",
601 .muxsel = { 2, 3, -1 },
602 .digital_mode = DIGITAL_MODE_CAMERA,
603 .audiomux = { 0, 0, 0, 0, 0 },
606 .tuner_type = TUNER_ALPS_TSBB5_PAL_I,
609 /* ---- card 0x18 ---------------------------------- */
610 .name = "Askey CPH05X/06X (bt878) [many vendors]",
616 .muxsel = { 2, 3, 1, 1},
617 .audiomux = {0x400, 0x400, 0x400, 0x400, 0xc00},
623 .name = "Terratec TerraTV+ Version 1.0 (Bt848)/ Terra TValue Version 1.0/ Vobis TV-Boostar",
628 .gpiomask = 0x1f0fff,
629 .muxsel = { 2, 3, 1, 1},
630 .audiomux = { 0x20000, 0x30000, 0x10000, 0, 0x40000},
632 .tuner_type = TUNER_PHILIPS_PAL,
633 .audio_hook = terratv_audio,
635 .name = "Hauppauge WinCam newer (bt878)",
641 .muxsel = { 2, 0, 1, 1},
642 .audiomux = { 0, 1, 2, 3, 4},
646 .name = "Lifeview FlyVideo 98/ MAXI TV Video PCI2 LR50",
652 .muxsel = { 2, 3, 1, 1},
653 .audiomux = { 0, 0x800, 0x1000, 0x1000, 0x1800},
655 .tuner_type = TUNER_PHILIPS_SECAM,
658 /* ---- card 0x1c ---------------------------------- */
659 .name = "Terratec TerraTV+ Version 1.1 (bt878)",
664 .gpiomask = 0x1f0fff,
665 .muxsel = { 2, 3, 1, 1},
666 .audiomux = { 0x20000, 0x30000, 0x10000, 0x00000, 0x40000},
668 .tuner_type = TUNER_PHILIPS_PAL,
669 .audio_hook = terratv_audio,
671 External 20 pin connector (for Active Radio Upgrade board)
677 gpio05: om5610-stereo
681 gpio09+10: nIOR, nSEL ?? (bt878)
685 gpio16: u2-A0 (1st 4052bt)
688 gpio19: u4-A0 (2nd 4052)
692 00000 : Cdrom (internal audio input)
693 10000 : ext. Video audio input
702 /* Jannik Fritsch <jannik@techfak.uni-bielefeld.de> */
703 .name = "Imagenation PXC200",
707 .svhs = 1, /* was: 4 */
709 .muxsel = { 2, 3, 1, 0, 0},
713 .muxsel_hook = PXC200_muxsel,
716 .name = "Lifeview FlyVideo 98 LR50",
721 .gpiomask = 0x1800, //0x8dfe00
722 .muxsel = { 2, 3, 1, 1},
723 .audiomux = { 0, 0x0800, 0x1000, 0x1000, 0x1800, 0 },
727 .name = "Formac iProTV, Formac ProTV I (bt848)",
733 .muxsel = { 2, 3, 1, 1},
734 .audiomux = { 1, 0, 0, 0, 0 },
736 .tuner_type = TUNER_PHILIPS_PAL,
739 /* ---- card 0x20 ---------------------------------- */
740 .name = "Intel Create and Share PCI/ Smart Video Recorder III",
746 .muxsel = { 2, 3, 1, 1},
751 .name = "Terratec TerraTValue Version Bt878",
756 .gpiomask = 0xffff00,
757 .muxsel = { 2, 3, 1, 1},
758 .audiomux = { 0x500, 0, 0x300, 0x900, 0x900},
761 .tuner_type = TUNER_PHILIPS_PAL,
763 .name = "Leadtek WinFast 2000/ WinFast 2000 XP",
768 .muxsel = { 2, 3, 1, 1, 0}, // TV, CVid, SVid, CVid over SVid connector
770 .gpiomask = 0xc33000,
771 .audiomux = { 0x422000,0x1000,0x0000,0x620000,0x800000 },
773 /* Alexander Varakin <avarakin@hotmail.com> [stereo version] */
774 .gpiomask = 0xb33000,
775 .audiomux = { 0x122000,0x1000,0x0000,0x620000,0x800000 },
777 /* Audio Routing for "WinFast 2000 XP" (no tv stereo !)
778 gpio23 -- hef4052:nEnable (0x800000)
781 0x0000: external audio
785 Note: There exists another variant "Winfast 2000" with tv stereo !?
786 Note: eeprom only contains FF and pci subsystem id 107d:6606
791 .tuner_type = 5, // default for now, gpio reads BFFF06 for Pal bg+dk
792 .audio_hook = winfast2000_audio,
795 .name = "Lifeview FlyVideo 98 LR50 / Chronos Video Shuttle II",
801 .muxsel = { 2, 3, 1, 1},
802 .audiomux = { 0, 0x800, 0x1000, 0x1000, 0x1800},
807 /* ---- card 0x24 ---------------------------------- */
808 .name = "Lifeview FlyVideo 98FM LR50 / Typhoon TView TV/FM Tuner",
814 .muxsel = { 2, 3, 1, 1},
815 .audiomux = { 0, 0x800, 0x1000, 0x1000, 0x1800, 0 },
820 .name = "Prolink PixelView PlayTV pro",
826 .muxsel = { 2, 3, 1, 1 },
827 .audiomux = { 0x21, 0x20, 0x24, 0x2c, 0x29, 0x29 },
832 .name = "Askey CPH06X TView99",
837 .gpiomask = 0x551e00,
838 .muxsel = { 2, 3, 1, 0},
839 .audiomux = { 0x551400, 0x551200, 0, 0, 0x551c00, 0x551200 },
845 .name = "Pinnacle PCTV Studio/Rave",
850 .gpiomask = 0x03000F,
851 .muxsel = { 2, 3, 1, 1},
852 .audiomux = { 2, 0xd0001, 0, 0, 1},
858 /* ---- card 0x28 ---------------------------------- */
859 .name = "STB TV PCI FM, Gateway P/N 6000704 (bt878), 3Dfx VoodooTV 100",
865 .muxsel = { 2, 3, 1, 1},
866 .audiomux = { 4, 0, 2, 3, 1},
869 .tuner_type = TUNER_PHILIPS_NTSC,
873 .name = "AVerMedia TVPhone 98",
879 .muxsel = { 2, 3, 1, 1},
880 .audiomux = { 13, 4, 11, 7, 0, 0},
885 .audio_hook = avermedia_tvphone_audio,
887 .name = "ProVideo PV951", /* pic16c54 */
893 .muxsel = { 2, 3, 1, 1},
894 .audiomux = { 0, 0, 0, 0, 0},
900 .name = "Little OnAir TV",
906 .muxsel = {2, 3, 1, 1},
907 .audiomux = {0xff9ff6, 0xff9ff6, 0xff1ff7, 0, 0xff3ffc},
912 /* ---- card 0x2c ---------------------------------- */
913 .name = "Sigma TVII-FM",
919 .muxsel = {2, 3, 1, 1},
920 .audiomux = {1, 1, 0, 2, 3},
925 .name = "MATRIX-Vision MV-Delta 2",
931 .muxsel = { 2, 3, 1, 0, 0},
937 .name = "Zoltrix Genie TV/FM",
942 .gpiomask = 0xbcf03f,
943 .muxsel = { 2, 3, 1, 1},
944 .audiomux = { 0xbc803f, 0xbc903f, 0xbcb03f, 0, 0xbcb03f},
949 .name = "Terratec TV/Radio+",
955 .muxsel = { 2, 3, 1, 1},
956 .audiomux = { 0x20000, 0x30000, 0x10000, 0, 0x40000, 0x20000 },
964 /* ---- card 0x30 ---------------------------------- */
965 .name = "Askey CPH03x/ Dynalink Magic TView",
971 .muxsel = { 2, 3, 1, 1},
972 .audiomux = {2,0,0,0,1},
977 .name = "IODATA GV-BCTV3/PCI",
982 .gpiomask = 0x010f00,
983 .muxsel = {2, 3, 0, 0},
984 .audiomux = {0x10000, 0, 0x10000, 0, 0, 0},
987 .tuner_type = TUNER_ALPS_TSHC6_NTSC,
988 .audio_hook = gvbctv3pci_audio,
990 .name = "Prolink PV-BT878P+4E / PixelView PlayTV PAK / Lenco MXTV-9578 CP",
995 .gpiomask = 0xAA0000,
996 .muxsel = { 2,3,1,1,-1 },
997 .digital_mode = DIGITAL_MODE_CAMERA,
998 .audiomux = { 0x20000, 0, 0x80000, 0x80000, 0xa8000, 0x46000 },
1001 .tuner_type = TUNER_PHILIPS_PAL_I,
1003 /* GPIO wiring: (different from Rev.4C !)
1004 GPIO17: U4.A0 (first hef4052bt)
1006 GPIO20: U5.A1 (second hef4052bt)
1008 GPIO22: BT832 Reset Line
1009 GPIO23: A5,A0, U5,nEN
1010 Note: At i2c=0x8a is a Bt832 chip, which changes to 0x88 after being reset via GPIO22
1013 .name = "Eagle Wireless Capricorn2 (bt878A)",
1019 .muxsel = { 2, 0, 1, 1},
1020 .audiomux = { 0, 1, 2, 3, 4},
1022 .tuner_type = -1 /* TUNER_ALPS_TMDH2_NTSC */,
1025 /* ---- card 0x34 ---------------------------------- */
1026 /* David Härdeman <david@2gen.com> */
1027 .name = "Pinnacle PCTV Studio Pro",
1032 .gpiomask = 0x03000F,
1033 .muxsel = { 2, 3, 1, 1},
1034 .audiomux = { 1, 0xd0001, 0, 0, 10},
1035 /* sound path (5 sources):
1036 MUX1 (mask 0x03), Enable Pin 0x08 (0=enable, 1=disable)
1039 2= Mono TV sound from Tuner
1041 MUX2 (mask 0x30000):
1043 1= FM stereo Radio from Tuner */
1048 /* Claas Langbehn <claas@bigfoot.com>,
1049 Sven Grothklags <sven@upb.de> */
1050 .name = "Typhoon TView RDS + FM Stereo / KNC1 TV Station RDS",
1056 .muxsel = { 2, 3, 1, 1},
1057 .audiomux = { 0, 0, 0x10, 8, 4 },
1060 .tuner_type = TUNER_PHILIPS_PAL,
1063 /* Tim Röstermundt <rosterm@uni-muenster.de>
1064 in de.comp.os.unix.linux.hardware:
1065 options bttv card=0 pll=1 radio=1 gpiomask=0x18e0
1066 audiomux=0x44c71f,0x44d71f,0,0x44d71f,0x44dfff
1067 options tuner type=5 */
1068 .name = "Lifeview FlyVideo 2000 /FlyVideo A2/ Lifetec LT 9415 TV [LR90]",
1074 .muxsel = { 2, 3, 1, 1},
1075 .audiomux = { 0x0000,0x0800,0x1000,0x1000,0x18e0 },
1076 /* For cards with tda9820/tda9821:
1077 0x0000: Tuner normal stereo
1078 0x0080: Tuner A2 SAP (second audio program = Zweikanalton)
1079 0x0880: Tuner A2 stereo */
1083 /* Miguel Angel Alvarez <maacruz@navegalia.com>
1084 old Easy TV BT848 version (model CPH031) */
1085 .name = "Askey CPH031/ BESTBUY Easy TV",
1091 .muxsel = { 2, 3, 1, 0},
1092 .audiomux = { 2, 0, 0, 0, 10},
1095 .tuner_type = TUNER_TEMIC_PAL,
1098 /* ---- card 0x38 ---------------------------------- */
1099 /* Gordon Heydon <gjheydon@bigfoot.com ('98) */
1100 .name = "Lifeview FlyVideo 98FM LR50",
1106 .muxsel = { 2, 3, 1, 1},
1107 .audiomux = { 0, 0x800, 0x1000, 0x1000, 0x1800, 0 },
1111 /* This is the ultimate cheapo capture card
1112 * just a BT848A on a small PCB!
1113 * Steve Hosgood <steve@equiinet.com> */
1114 .name = "GrandTec 'Grand Video Capture' (Bt848)",
1127 /* Daniel Herrington <daniel.herrington@home.com> */
1128 .name = "Askey CPH060/ Phoebe TV Master Only (No FM)",
1134 .muxsel = { 2, 3, 1, 1},
1135 .audiomux = { 0x400, 0x400, 0x400, 0x400, 0x800, 0x400 },
1138 .tuner_type = TUNER_TEMIC_4036FY5_NTSC,
1140 /* Matti Mottus <mottus@physic.ut.ee> */
1141 .name = "Askey CPH03x TV Capturer",
1146 .gpiomask = 0x03000F,
1147 .muxsel = { 2, 3, 1, 0},
1148 .audiomux = { 2,0,0,0,1 },
1153 /* ---- card 0x3c ---------------------------------- */
1154 /* Philip Blundell <philb@gnu.org> */
1155 .name = "Modular Technology MM100PCTV",
1161 .muxsel = { 2, 3, 1, 1},
1162 .audiomux = { 2, 0, 0, 1, 8},
1164 .tuner_type = TUNER_TEMIC_PAL,
1167 /* Adrian Cox <adrian@humboldt.co.uk */
1168 .name = "AG Electronics GMV1",
1181 /* Miguel Angel Alvarez <maacruz@navegalia.com>
1182 new Easy TV BT878 version (model CPH061)
1183 special thanks to Informatica Mieres for providing the card */
1184 .name = "Askey CPH061/ BESTBUY Easy TV (bt878)",
1190 .muxsel = { 2, 3, 1, 0},
1191 .audiomux = { 1, 0, 4, 4, 9},
1194 .tuner_type = TUNER_PHILIPS_PAL,
1196 /* Lukas Gebauer <geby@volny.cz> */
1197 .name = "ATI TV-Wonder",
1203 .muxsel = { 2, 3, 1, 0 },
1204 .audiomux = { 0xbffe, 0, 0xbfff, 0, 0xbffe},
1206 .tuner_type = TUNER_TEMIC_4006FN5_MULTI_PAL,
1209 /* ---- card 0x40 ---------------------------------- */
1210 /* Lukas Gebauer <geby@volny.cz> */
1211 .name = "ATI TV-Wonder VE",
1217 .muxsel = { 2, 3, 0, 1},
1218 .audiomux = { 0, 0, 1, 0, 0},
1221 .tuner_type = TUNER_TEMIC_4006FN5_MULTI_PAL,
1223 /* DeeJay <deejay@westel900.net (2000S) */
1224 .name = "Lifeview FlyVideo 2000S LR90",
1230 .muxsel = { 2, 3, 0, 1},
1231 /* Radio changed from 1e80 to 0x800 to make
1232 FlyVideo2000S in .hu happy (gm)*/
1233 /* -dk-???: set mute=0x1800 for tda9874h daughterboard */
1234 .audiomux = { 0x0000,0x0800,0x1000,0x1000,0x1800, 0x1080 },
1235 .audio_hook = fv2000s_audio,
1242 .name = "Terratec TValueRadio",
1247 .gpiomask = 0xffff00,
1248 .muxsel = { 2, 3, 1, 1},
1249 .audiomux = { 0x500, 0x500, 0x300, 0x900, 0x900},
1252 .tuner_type = TUNER_PHILIPS_PAL,
1255 /* TANAKA Kei <peg00625@nifty.com> */
1256 .name = "IODATA GV-BCTV4/PCI",
1261 .gpiomask = 0x010f00,
1262 .muxsel = {2, 3, 0, 0},
1263 .audiomux = {0x10000, 0, 0x10000, 0, 0, 0},
1266 .tuner_type = TUNER_SHARP_2U5JF5540_NTSC,
1267 .audio_hook = gvbctv3pci_audio,
1270 /* ---- card 0x44 ---------------------------------- */
1271 .name = "3Dfx VoodooTV FM (Euro), VoodooTV 200 (USA)",
1272 // try "insmod msp3400 simple=0" if you have
1273 // sound problems with this card.
1278 .gpiomask = 0x4f8a00,
1279 // 0x100000: 1=MSP enabled (0=disable again)
1280 // 0x010000: Connected to "S0" on tda9880 (0=Pal/BG, 1=NTSC)
1281 .audiomux = {0x947fff, 0x987fff,0x947fff,0x947fff, 0x947fff},
1282 // tvtuner, radio, external,internal, mute, stereo
1283 /* tuner, Composit, SVid, Composit-on-Svid-adapter*/
1284 .muxsel = { 2, 3 ,0 ,1},
1285 .tuner_type = TUNER_MT2032,
1289 /* Philip Blundell <pb@nexus.co.uk> */
1290 .name = "Active Imaging AIMMS",
1299 /* Tomasz Pyra <hellfire@sedez.iq.pl> */
1300 .name = "Prolink Pixelview PV-BT878P+ (Rev.4C,8E)",
1306 .muxsel = { 2, 3, 1, 1},
1307 .audiomux = { 0, 0, 11, 7, 13, 0}, // TV and Radio with same GPIO !
1313 GPIO0: U4.A0 (hef4052bt)
1315 GPIO2: U4.A1 (second hef4052bt)
1316 GPIO3: U4.nEN, U5.A0, A5.nEN
1320 .name = "Lifeview FlyVideo 98EZ (capture only) LR51",
1325 .muxsel = { 2, 3, 1, 1}, // AV1, AV2, SVHS, CVid adapter on SVHS
1330 /* ---- card 0x48 ---------------------------------- */
1331 /* Dariusz Kowalewski <darekk@automex.pl> */
1332 .name = "Prolink Pixelview PV-BT878P+9B (PlayTV Pro rev.9B FM+NICAM)",
1338 .muxsel = { 2, 3, 1, 1 },
1339 .audiomux = { 0x01, 0x00, 0x03, 0x03, 0x09, 0x02 },
1345 .audio_hook = pvbt878p9b_audio, // Note: not all cards have stereo
1346 .has_radio = 1, // Note: not all cards have radio
1353 GPIO20,22,23: R30,R29,R28
1356 /* Clay Kunz <ckunz@mail.arc.nasa.gov> */
1357 /* you must jumper JP5 for the card to work */
1358 .name = "Sensoray 311",
1364 .muxsel = { 2, 3, 1, 0, 0},
1369 /* Miguel Freitas <miguel@cetuc.puc-rio.br> */
1370 .name = "RemoteVision MX (RV605)",
1376 .gpiomask2 = 0x07ff,
1377 .muxsel = { 0x33, 0x13, 0x23, 0x43, 0xf3, 0x73, 0xe3, 0x03,
1378 0xd3, 0xb3, 0xc3, 0x63, 0x93, 0x53, 0x83, 0xa3 },
1382 .muxsel_hook = rv605_muxsel,
1384 .name = "Powercolor MTV878/ MTV878R/ MTV878F",
1389 .gpiomask = 0x1C800F, // Bit0-2: Audio select, 8-12:remote control 14:remote valid 15:remote reset
1390 .muxsel = { 2, 1, 1, },
1391 .audiomux = { 0, 1, 2, 2, 4 },
1393 .tuner_type = TUNER_PHILIPS_PAL,
1398 /* ---- card 0x4c ---------------------------------- */
1399 /* Masaki Suzuki <masaki@btree.org> */
1400 .name = "Canopus WinDVR PCI (COMPAQ Presario 3524JP, 5112JP)",
1405 .gpiomask = 0x140007,
1406 .muxsel = { 2, 3, 1, 1 },
1407 .audiomux = { 0, 1, 2, 3, 4, 0 },
1408 .tuner_type = TUNER_PHILIPS_NTSC,
1409 .audio_hook = windvr_audio,
1411 .name = "GrandTec Multi Capture Card (Bt878)",
1417 .muxsel = { 2, 3, 1, 0 },
1424 .name = "Jetway TV/Capture JW-TV878-FBK, Kworld KW-TV878RF",
1430 .muxsel = { 2, 3, 1, 1 }, // Tuner, SVid, SVHS, SVid to SVHS connector
1431 .audiomux = { 0 ,0 ,4, 4,4,4},// Yes, this tuner uses the same audio output for TV and FM radio!
1432 // This card lacks external Audio In, so we mute it on Ext. & Int.
1433 // The PCB can take a sbx1637/sbx1673, wiring unknown.
1434 // This card lacks PCI subsystem ID, sigh.
1435 // audiomux=1: lower volume, 2+3: mute
1436 // btwincap uses 0x80000/0x80003
1440 .tuner_type = 5, // Samsung TCPA9095PC27A (BG+DK), philips compatible, w/FM, stereo and
1441 // radio signal strength indicators work fine.
1444 GPIO0,1: HEF4052 A0,A1
1445 GPIO2: HEF4052 nENABLE
1447 GPIO8-13: IRDC357 data0-5 (data6 n.c. ?) [chip not present on my card]
1451 ?? : mtu8b56ep microcontroller for IR (GPIO wiring unknown)*/
1453 /* Arthur Tetzlaff-Deas, DSP Design Ltd <software@dspdesign.com> */
1454 .name = "DSP Design TCVIDEO",
1457 .muxsel = { 2, 3, 1, 0},
1462 /* ---- card 0x50 ---------------------------------- */
1463 .name = "Hauppauge WinTV PVR",
1468 .muxsel = { 2, 0, 1, 1},
1476 .name = "IODATA GV-BCTV5/PCI",
1481 .gpiomask = 0x0f0f80,
1482 .muxsel = {2, 3, 1, 0},
1483 .audiomux = {0x030000, 0x010000, 0, 0, 0x020000, 0},
1486 .tuner_type = TUNER_PHILIPS_NTSC_M,
1487 .audio_hook = gvbctv5pci_audio,
1490 .name = "Osprey 100/150 (878)", /* 0x1(2|3)-45C6-C1 */
1491 .video_inputs = 4, /* id-inputs-clock */
1495 .muxsel = { 3, 2, 0, 1 },
1502 .name = "Osprey 100/150 (848)", /* 0x04-54C0-C1 & older boards */
1507 .muxsel = { 2, 3, 1 },
1515 /* ---- card 0x54 ---------------------------------- */
1516 .name = "Osprey 101 (848)", /* 0x05-40C0-C1 */
1528 .name = "Osprey 101/151", /* 0x1(4|5)-0004-C4 */
1540 .name = "Osprey 101/151 w/ svid", /* 0x(16|17|20)-00C4-C1 */
1552 .name = "Osprey 200/201/250/251", /* 0x1(8|9|E|F)-0004-C4 */
1565 /* ---- card 0x58 ---------------------------------- */
1566 .name = "Osprey 200/250", /* 0x1(A|B)-00C4-C1 */
1578 .name = "Osprey 210/220", /* 0x1(A|B)-04C0-C1 */
1590 .name = "Osprey 500", /* 500 */
1602 .name = "Osprey 540", /* 540 */
1606 #if 0 /* TODO ... */
1607 .svhs = OSPREY540_SVID_ANALOG,
1608 .muxsel = { [OSPREY540_COMP_ANALOG] = 2,
1609 [OSPREY540_SVID_ANALOG] = 3, },
1616 #if 0 /* TODO ... */
1617 .muxsel_hook = osprey_540_muxsel,
1618 .picture_hook = osprey_540_set_picture,
1622 /* ---- card 0x5C ---------------------------------- */
1623 .name = "Osprey 2000", /* 2000 */
1633 .no_tda7432 = 1, /* must avoid, conflicts with the bt860 */
1635 /* M G Berberich <berberic@forwiss.uni-passau.de> */
1636 .name = "IDS Eagle",
1643 .muxsel = { 0, 1, 2, 3 },
1644 .muxsel_hook = eagle_muxsel,
1649 .name = "Pinnacle PCTV Sat",
1659 .audiomux = { 0, 0, 0, 0, 1 },
1660 .muxsel = { 3, 0, 1, 2},
1666 .name = "Formac ProTV II (bt878)",
1672 // TV, Comp1, Composite over SVID con, SVID
1673 .muxsel = { 2, 3, 1, 1},
1674 .audiomux = { 2, 2, 0, 0, 0 },
1677 .tuner_type = TUNER_PHILIPS_PAL,
1679 GPIO=0x00,0x01,0x03: mute (?)
1680 0x02: both TV and radio (tuner: FM1216/I)
1681 The card has onboard audio connectors labeled "cdrom" and "board",
1682 not soldered here, though unknown wiring.
1683 Card lacks: external audio in, pci subsystem id.
1687 /* ---- card 0x60 ---------------------------------- */
1694 .muxsel = { 2, 3, 1, 1},
1695 .audiomux = { 0, 1, 2, 3, 4},
1700 .name = "Euresys Picolo",
1709 .muxsel = { 2, 0, 1},
1712 /* Luc Van Hoeylandt <luc@e-magic.be> */
1713 .name = "ProVideo PV150", /* 0x4f */
1726 /* Hiroshi Takekawa <sian@big.or.jp> */
1727 /* This card lacks subsystem ID */
1728 .name = "AD-TVK503", /* 0x63 */
1733 .gpiomask = 0x001e8007,
1734 .muxsel = { 2, 3, 1, 0 },
1735 /* Tuner, Radio, external, internal, off, on */
1736 .audiomux = { 0x08, 0x0f, 0x0a, 0x08, 0x0f, 0x08 },
1741 .audio_hook = adtvk503_audio,
1744 /* ---- card 0x64 ---------------------------------- */
1745 .name = "Hercules Smart TV Stereo",
1751 .muxsel = { 2, 3, 1, 1 },
1757 - card lacks subsystem ID
1758 - stereo variant w/ daughter board with tda9874a @0xb0
1760 always from tda9874 independent of GPIO (?)
1761 external line in: unknown
1762 - Other chips: em78p156elp @ 0x96 (probably IR remote control)
1763 hef4053 (instead 4052) for unknown function
1766 .name = "Pace TV & Radio Card",
1771 .muxsel = { 2, 3, 1, 1}, // Tuner, CVid, SVid, CVid over SVid connector
1778 /* Bt878, Bt832, FI1246 tuner; no pci subsystem id
1779 only internal line out: (4pin header) RGGL
1780 Radio must be decoded by msp3410d (not routed through)*/
1781 // .digital_mode = DIGITAL_MODE_CAMERA, // todo!
1783 /* Chris Willing <chris@vislab.usyd.edu.au> */
1794 .name = "Grand X-Guard / Trust 814PCI",
1801 .muxsel = { 2,2,2,2, 3,3,3,3, 1,1,1,1, 0,0,0,0 },
1802 .muxsel_hook = xguard_muxsel,
1809 /* ---- card 0x68 ---------------------------------- */
1810 .name = "Nebula Electronics DigiTV",
1814 .muxsel = { 2, 3, 1, 0},
1823 /* Jorge Boncompte - DTI2 <jorge@dti2.net> */
1824 .name = "ProVideo PV143",
1830 .muxsel = { 2, 3, 1, 0 },
1837 /* M.Klahr@phytec.de */
1838 .name = "PHYTEC VD-009-X1 MiniDIN (bt878)",
1841 .tuner = -1, /* card has no tuner */
1844 .muxsel = { 2, 3, 1, 0},
1845 .audiomux = { 0, 0, 0, 0, 0, 0 }, /* card has no audio */
1850 .name = "PHYTEC VD-009-X1 Combi (bt878)",
1853 .tuner = -1, /* card has no tuner */
1856 .muxsel = { 2, 3, 1, 1},
1857 .audiomux = { 0, 0, 0, 0, 0, 0 }, /* card has no audio */
1863 /* ---- card 0x6c ---------------------------------- */
1864 .name = "PHYTEC VD-009 MiniDIN (bt878)",
1867 .tuner = -1, /* card has no tuner */
1870 .gpiomask2 = 0x03, /* gpiomask2 defines the bits used to switch audio
1871 via the upper nibble of muxsel. here: used for
1872 xternal video-mux */
1873 .muxsel = { 0x02, 0x12, 0x22, 0x32, 0x03, 0x13, 0x23, 0x33, 0x01, 0x00 },
1874 .audiomux = { 0, 0, 0, 0, 0, 0 }, /* card has no audio */
1879 .name = "PHYTEC VD-009 Combi (bt878)",
1882 .tuner = -1, /* card has no tuner */
1885 .gpiomask2 = 0x03, /* gpiomask2 defines the bits used to switch audio
1886 via the upper nibble of muxsel. here: used for
1887 xternal video-mux */
1888 .muxsel = { 0x02, 0x12, 0x22, 0x32, 0x03, 0x13, 0x23, 0x33, 0x01, 0x01 },
1889 .audiomux = { 0, 0, 0, 0, 0, 0 }, /* card has no audio */
1901 .muxsel = { 2, 3, 1, 0 },
1904 /* IVC-120G - Alan Garfield <alan@fromorbit.com> */
1907 .audio_inputs = 0, /* card has no audio */
1908 .tuner = -1, /* card has no tuner */
1910 .svhs = -1, /* card has no svhs */
1916 .muxsel = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
1917 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10 },
1918 .muxsel_hook = ivc120_muxsel,
1922 /* ---- card 0x70 ---------------------------------- */
1923 .name = "pcHDTV HD-2000 TV",
1928 .muxsel = { 2, 3, 1, 0},
1929 .tuner_type = TUNER_PHILIPS_ATSC,
1932 .name = "Twinhan DST + clones",
1936 .tuner_type = TUNER_ABSENT,
1940 .name = "Winfast VC100",
1944 .tuner = -1, // no tuner
1945 .muxsel = { 3, 1, 1, 3}, // Vid In, SVid In, Vid over SVid in connector
1949 .tuner_type = TUNER_ABSENT,
1952 .name = "Teppro TEV-560/InterVision IV-560",
1958 .muxsel = { 2, 3, 1, 1},
1959 .audiomux = { 1, 1, 1, 1, 0},
1961 .tuner_type = TUNER_PHILIPS_PAL,
1965 /* ---- card 0x74 ---------------------------------- */
1966 .name = "SIMUS GVC1100",
1973 .muxsel = { 2, 2, 2, 2},
1975 .muxsel_hook = gvc1100_muxsel,
1977 /* Carlos Silva r3pek@r3pek.homelinux.org || card 0x75 */
1978 .name = "NGS NGSTV+",
1982 .gpiomask = 0x008007,
1983 .muxsel = {2, 3, 0, 0},
1984 .audiomux = {0, 0, 0, 0, 0x000003, 0},
1986 .tuner_type = TUNER_PHILIPS_PAL,
1989 /* http://linuxmedialabs.com */
1991 .video_inputs = 4, /* IN1,IN2,IN3,IN4 */
1995 .muxsel = { 2, 3, 1, 0 },
2001 /* Helmroos Harri <harri.helmroos@pp.inet.fi> */
2002 .name = "Tekram M205 PRO",
2006 .tuner_type = TUNER_PHILIPS_PAL,
2010 .muxsel = { 2, 3, 1},
2011 .audiomux = { 0x68, 0x68, 0x61, 0x61, 0x00 },
2015 /* ---- card 0x78 ---------------------------------- */
2016 /* Javier Cendan Ares <jcendan@lycos.es> */
2017 /* bt878 TV + FM without subsystem ID */
2018 .name = "Conceptronic CONTVFMi",
2023 .gpiomask = 0x008007,
2024 .muxsel = { 2, 3, 1, 1 },
2025 .audiomux = { 0, 1, 2, 2, 3 },
2028 .tuner_type = TUNER_PHILIPS_PAL,
2032 /*Eric DEBIEF <debief@telemsa.com>*/
2033 /*EURESYS Picolo Tetra : 4 Conexant Fusion 878A, no audio, video input set with analog multiplexers GPIO controled*/
2034 /* adds picolo_tetra_muxsel(), picolo_tetra_init(), the folowing declaration strucure, and #define BTTV_PICOLO_TETRA_CHIP*/
2036 .name = "Euresys Picolo Tetra",
2042 .gpiomask2 = 0x3C<<16,/*Set the GPIO[18]->GPIO[21] as output pin.==> drive the video inputs through analog multiplexers*/
2046 .muxsel = {2,2,2,2},/*878A input is always MUX0, see above.*/
2047 .audiomux = { 0, 0, 0, 0, 0, 0 }, /* card has no audio */
2050 .muxsel_hook = picolo_tetra_muxsel,/*Required as it doesn't follow the classic input selection policy*/
2052 /* Spirit TV Tuner from http://spiritmodems.com.au */
2053 /* Stafford Goodsell <surge@goliath.homeunix.org> */
2054 .name = "Spirit TV Tuner",
2059 .gpiomask = 0x0000000f,
2060 .muxsel = { 2, 1, 1 },
2061 .audiomux = { 0x02, 0x00, 0x00, 0x00, 0x00},
2062 .tuner_type = TUNER_TEMIC_PAL,
2066 /* Wolfram Joost <wojo@frokaschwei.de> */
2067 .name = "AVerMedia AVerTV DVB-T 771",
2071 .tuner_type = TUNER_ABSENT,
2072 .muxsel = { 3 , 3 },
2081 /* ---- card 0x7c ---------------------------------- */
2082 /* Matt Jesson <dvb@jesson.eclipse.co.uk> */
2083 /* Based on the Nebula card data - added remote and new card number - BTTV_AVDVBT_761, see also ir-kbd-gpio.c */
2084 .name = "AverMedia AverTV DVB-T 761",
2088 .muxsel = { 3, 1, 2, 0}, /* Comp0, S-Video, ?, ? */
2098 /* andre.schwarz@matrix-vision.de */
2099 .name = "MATRIX Vision Sigma-SQ",
2105 .muxsel = { 2, 2, 2, 2, 2, 2, 2, 2,
2106 3, 3, 3, 3, 3, 3, 3, 3 },
2107 .muxsel_hook = sigmaSQ_muxsel,
2113 /* andre.schwarz@matrix-vision.de */
2114 .name = "MATRIX Vision Sigma-SLC",
2120 .muxsel = { 2, 2, 2, 2 },
2121 .muxsel_hook = sigmaSLC_muxsel,
2127 /* BTTV_APAC_VIEWCOMP */
2128 /* Attila Kondoros <attila.kondoros@chello.hu> */
2129 /* bt878 TV + FM 0x00000000 subsystem ID */
2130 .name = "APAC Viewcomp 878(AMAX)",
2136 .muxsel = { 2, 3, 1, 1},
2137 .audiomux = { 2, 0, 0, 0, 10},
2140 .tuner_type = TUNER_PHILIPS_PAL,
2141 .has_remote = 1, /* miniremote works, see ir-kbd-gpio.c */
2142 .has_radio = 1, /* not every card has radio */
2145 /* ---- card 0x80 ---------------------------------- */
2146 /* Chris Pascoe <c.pascoe@itee.uq.edu.au> */
2147 .name = "DVICO FusionHDTV DVB-T Lite",
2157 /* Steven <photon38@pchome.com.tw> */
2158 .name = "V-Gear MyVCD",
2164 .muxsel = {2, 3, 1, 0},
2165 .audiomux = {0x31, 0x31, 0x31, 0x31, 0x31, 0x31},
2168 .tuner_type = TUNER_PHILIPS_NTSC_M,
2172 /* Rick C <cryptdragoon@gmail.com> */
2173 .name = "Super TV Tuner",
2178 .muxsel = { 2, 3, 1, 0},
2179 .tuner_type = TUNER_PHILIPS_NTSC,
2180 .gpiomask = 0x008007,
2181 .audiomux = { 0, 0x000001,0,0, 0},
2185 /* Chris Fanning <video4linux@haydon.net> */
2186 .name = "Tibet Systems 'Progress DVR' CS16",
2191 .muxsel = { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 },
2197 .muxsel_hook = tibetCS16_muxsel,
2200 /* Bill Brack <wbrack@mmm.com.hk> */
2202 * Note that, because of the card's wiring, the "master"
2203 * BT878A chip (i.e. the one which controls the analog switch
2204 * and must use this card type) is the 2nd one detected. The
2205 * other 3 chips should use card type 0x85, whose description
2206 * follows this one. There is a EEPROM on the card (which is
2207 * connected to the I2C of one of those other chips), but is
2208 * not currently handled. There is also a facility for a
2209 * "monitor", which is also not currently implemented.
2211 .name = "Kodicom 4400R (master)",
2217 /* GPIO bits 0-9 used for analog switch:
2218 * 00 - 03: camera selector
2219 * 04 - 06: channel (controller) selector
2220 * 07: data (1->on, 0->off)
2223 * bit 16 is input from sync separator for the channel
2225 .gpiomask = 0x0003ff,
2227 .muxsel = { 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 },
2232 .muxsel_hook = kodicom4400r_muxsel,
2235 /* Bill Brack <wbrack@mmm.com.hk> */
2236 /* Note that, for reasons unknown, the "master" BT878A chip (i.e. the
2237 * one which controls the analog switch, and must use the card type)
2238 * is the 2nd one detected. The other 3 chips should use this card
2241 .name = "Kodicom 4400R (slave)",
2247 .gpiomask = 0x010000,
2249 .muxsel = { 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 },
2254 .muxsel_hook = kodicom4400r_muxsel,
2257 /* ---- card 0x85---------------------------------- */
2258 /* Michael Henson <mhenson@clarityvi.com> */
2259 /* Adlink RTV24 with special unlock codes */
2260 .name = "Adlink RTV24",
2265 .muxsel = { 2, 3, 1, 0},
2271 static const unsigned int bttv_num_tvcards = ARRAY_SIZE(bttv_tvcards);
2273 /* ----------------------------------------------------------------------- */
2275 static unsigned char eeprom_data[256];
2280 void __devinit bttv_idcard(struct bttv *btv)
2282 unsigned int gpiobits;
2286 /* read PCI subsystem ID */
2287 pci_read_config_word(btv->c.pci, PCI_SUBSYSTEM_ID, &tmp);
2288 btv->cardid = tmp << 16;
2289 pci_read_config_word(btv->c.pci, PCI_SUBSYSTEM_VENDOR_ID, &tmp);
2292 if (0 != btv->cardid && 0xffffffff != btv->cardid) {
2293 /* look for the card */
2294 for (type = -1, i = 0; cards[i].id != 0; i++)
2295 if (cards[i].id == btv->cardid)
2300 printk(KERN_INFO "bttv%d: detected: %s [card=%d], "
2301 "PCI subsystem ID is %04x:%04x\n",
2302 btv->c.nr,cards[type].name,cards[type].cardnr,
2303 btv->cardid & 0xffff,
2304 (btv->cardid >> 16) & 0xffff);
2305 btv->c.type = cards[type].cardnr;
2308 printk(KERN_INFO "bttv%d: subsystem: %04x:%04x (UNKNOWN)\n",
2309 btv->c.nr, btv->cardid & 0xffff,
2310 (btv->cardid >> 16) & 0xffff);
2311 printk(KERN_DEBUG "please mail id, board name and "
2312 "the correct card= insmod option to kraxel@bytesex.org\n");
2316 /* let the user override the autodetected type */
2317 if (card[btv->c.nr] < bttv_num_tvcards)
2318 btv->c.type=card[btv->c.nr];
2320 /* print which card config we are using */
2321 printk(KERN_INFO "bttv%d: using: %s [card=%d,%s]\n",btv->c.nr,
2322 bttv_tvcards[btv->c.type].name, btv->c.type,
2323 card[btv->c.nr] < bttv_num_tvcards
2324 ? "insmod option" : "autodetected");
2326 /* overwrite gpio stuff ?? */
2327 if (UNSET == audioall && UNSET == audiomux[0])
2330 if (UNSET != audiomux[0]) {
2332 for (i = 0; i < 5; i++) {
2333 bttv_tvcards[btv->c.type].audiomux[i] = audiomux[i];
2334 gpiobits |= audiomux[i];
2337 gpiobits = audioall;
2338 for (i = 0; i < 5; i++) {
2339 bttv_tvcards[btv->c.type].audiomux[i] = audioall;
2342 bttv_tvcards[btv->c.type].gpiomask = (UNSET != gpiomask) ? gpiomask : gpiobits;
2343 printk(KERN_INFO "bttv%d: gpio config override: mask=0x%x, mux=",
2344 btv->c.nr,bttv_tvcards[btv->c.type].gpiomask);
2345 for (i = 0; i < 5; i++) {
2346 printk("%s0x%x", i ? "," : "", bttv_tvcards[btv->c.type].audiomux[i]);
2352 * (most) board specific initialisations goes here
2355 /* Some Modular Technology cards have an eeprom, but no subsystem ID */
2356 void identify_by_eeprom(struct bttv *btv, unsigned char eeprom_data[256])
2360 if (0 == strncmp(eeprom_data,"GET MM20xPCTV",13))
2361 type = BTTV_MODTEC_205;
2362 else if (0 == strncmp(eeprom_data+20,"Picolo",7))
2363 type = BTTV_EURESYS_PICOLO;
2364 else if (eeprom_data[0] == 0x84 && eeprom_data[2]== 0)
2365 type = BTTV_HAUPPAUGE; /* old bt848 */
2369 printk("bttv%d: detected by eeprom: %s [card=%d]\n",
2370 btv->c.nr, bttv_tvcards[btv->c.type].name, btv->c.type);
2374 static void flyvideo_gpio(struct bttv *btv)
2376 int gpio,has_remote,has_radio,is_capture_only,is_lr90,has_tda9820_tda9821;
2379 gpio_inout(0xffffff, 0);
2380 udelay(8); // without this we would see the 0x1800 mask
2382 /* FIXME: must restore OUR_EN ??? */
2384 // all cards provide GPIO info, some have an additional eeprom
2385 // LR50: GPIO coding can be found lower right CP1 .. CP9
2386 // CP9=GPIO23 .. CP1=GPIO15; when OPEN, the corresponding GPIO reads 1.
2388 // LR90: GP9=GPIO23 .. GP1=GPIO15 (right above the bt878)
2390 // lowest 3 bytes are remote control codes (no handshake needed)
2391 // xxxFFF: No remote control chip soldered
2392 // xxxF00(LR26/LR50), xxxFE0(LR90): Remote control chip (LVA001 or CF45) soldered
2393 // Note: Some bits are Audio_Mask !
2395 ttype=(gpio&0x0f0000)>>16;
2397 case 0x0: tuner=2; // NTSC, e.g. TPI8NSR11P
2399 case 0x2: tuner=39;// LG NTSC (newer TAPC series) TAPC-H701P
2401 case 0x4: tuner=5; // Philips PAL TPI8PSB02P, TPI8PSB12P, TPI8PSB12D or FI1216, FM1216
2403 case 0x6: tuner=37; // LG PAL (newer TAPC series) TAPC-G702P
2405 case 0xC: tuner=3; // Philips SECAM(+PAL) FQ1216ME or FI1216MF
2408 printk(KERN_INFO "bttv%d: FlyVideo_gpio: unknown tuner type.\n", btv->c.nr);
2411 has_remote = gpio & 0x800000;
2412 has_radio = gpio & 0x400000;
2413 // unknown 0x200000;
2414 // unknown2 0x100000;
2415 is_capture_only = !(gpio & 0x008000); //GPIO15
2416 has_tda9820_tda9821 = !(gpio & 0x004000);
2417 is_lr90 = !(gpio & 0x002000); // else LR26/LR50 (LR38/LR51 f. capture only)
2418 // gpio & 0x001000 // output bit for audio routing
2421 tuner=4; // No tuner present
2423 printk(KERN_INFO "bttv%d: FlyVideo Radio=%s RemoteControl=%s Tuner=%d gpio=0x%06x\n",
2424 btv->c.nr, has_radio? "yes":"no ", has_remote? "yes":"no ", tuner, gpio);
2425 printk(KERN_INFO "bttv%d: FlyVideo LR90=%s tda9821/tda9820=%s capture_only=%s\n",
2426 btv->c.nr, is_lr90?"yes":"no ", has_tda9820_tda9821?"yes":"no ",
2427 is_capture_only?"yes":"no ");
2429 if(tuner!= -1) // only set if known tuner autodetected, else let insmod option through
2430 btv->tuner_type = tuner;
2431 btv->has_radio = has_radio;
2433 // LR90 Audio Routing is done by 2 hef4052, so Audio_Mask has 4 bits: 0x001c80
2434 // LR26/LR50 only has 1 hef4052, Audio_Mask 0x000c00
2435 // Audio options: from tuner, from tda9821/tda9821(mono,stereo,sap), from tda9874, ext., mute
2436 if(has_tda9820_tda9821) btv->audio_hook = lt9415_audio;
2437 //todo: if(has_tda9874) btv->audio_hook = fv2000s_audio;
2440 static int miro_tunermap[] = { 0,6,2,3, 4,5,6,0, 3,0,4,5, 5,2,16,1,
2441 14,2,17,1, 4,1,4,3, 1,2,16,1, 4,4,4,4 };
2442 static int miro_fmtuner[] = { 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,1,
2443 1,1,1,1, 1,1,1,0, 0,0,0,0, 0,1,0,0 };
2445 static void miro_pinnacle_gpio(struct bttv *btv)
2450 gpio_inout(0xffffff, 0);
2452 id = ((gpio>>10) & 63) -1;
2453 msp = bttv_I2CRead(btv, I2C_MSP3400, "MSP34xx");
2455 btv->tuner_type = miro_tunermap[id];
2456 if (0 == (gpio & 0x20)) {
2458 if (!miro_fmtuner[id]) {
2459 btv->has_matchbox = 1;
2460 btv->mbox_we = (1<<6);
2461 btv->mbox_most = (1<<7);
2462 btv->mbox_clk = (1<<8);
2463 btv->mbox_data = (1<<9);
2464 btv->mbox_mask = (1<<6)|(1<<7)|(1<<8)|(1<<9);
2470 if (btv->c.type == BTTV_MIRO)
2471 btv->c.type = BTTV_MIROPRO;
2472 if (btv->c.type == BTTV_PINNACLE)
2473 btv->c.type = BTTV_PINNACLEPRO;
2476 "bttv%d: miro: id=%d tuner=%d radio=%s stereo=%s\n",
2477 btv->c.nr, id+1, btv->tuner_type,
2478 !btv->has_radio ? "no" :
2479 (btv->has_matchbox ? "matchbox" : "fmtuner"),
2480 (-1 == msp) ? "no" : "yes");
2482 /* new cards with microtune tuner */
2487 info = "PAL / mono";
2490 info = "PAL+SECAM / stereo";
2494 info = "NTSC / stereo";
2498 info = "PAL+SECAM / mono";
2501 info = "NTSC / mono";
2504 info = "NTSC / stereo";
2507 info = "PAL / stereo";
2510 info = "oops: unknown card";
2514 btv->c.type = BTTV_PINNACLEPRO;
2516 "bttv%d: pinnacle/mt: id=%d info=\"%s\" radio=%s\n",
2517 btv->c.nr, id, info, btv->has_radio ? "yes" : "no");
2518 btv->tuner_type = 33;
2519 btv->pinnacle_id = id;
2523 /* GPIO21 L: Buffer aktiv, H: Buffer inaktiv */
2524 #define LM1882_SYNC_DRIVE 0x200000L
2526 static void init_ids_eagle(struct bttv *btv)
2528 gpio_inout(0xffffff,0xFFFF37);
2529 gpio_write(0x200020);
2531 /* flash strobe inverter ?! */
2532 gpio_write(0x200024);
2534 /* switch sync drive off */
2535 gpio_bits(LM1882_SYNC_DRIVE,LM1882_SYNC_DRIVE);
2537 /* set BT848 muxel to 2 */
2538 btaor((2)<<5, ~(2<<5), BT848_IFORM);
2541 /* Muxsel helper for the IDS Eagle.
2542 * the eagles does not use the standard muxsel-bits but
2543 * has its own multiplexer */
2544 static void eagle_muxsel(struct bttv *btv, unsigned int input)
2546 btaor((2)<<5, ~(3<<5), BT848_IFORM);
2547 gpio_bits(3,bttv_tvcards[btv->c.type].muxsel[input&7]);
2551 /* wake chroma ADC */
2552 btand(~BT848_ADC_C_SLEEP, BT848_ADC);
2553 /* set to YC video */
2554 btor(BT848_CONTROL_COMP, BT848_E_CONTROL);
2555 btor(BT848_CONTROL_COMP, BT848_O_CONTROL);
2558 /* set chroma ADC to sleep */
2559 btor(BT848_ADC_C_SLEEP, BT848_ADC);
2560 /* set to composite video */
2561 btand(~BT848_CONTROL_COMP, BT848_E_CONTROL);
2562 btand(~BT848_CONTROL_COMP, BT848_O_CONTROL);
2565 /* switch sync drive off */
2566 gpio_bits(LM1882_SYNC_DRIVE,LM1882_SYNC_DRIVE);
2569 static void gvc1100_muxsel(struct bttv *btv, unsigned int input)
2571 static const int masks[] = {0x30, 0x01, 0x12, 0x23};
2572 gpio_write(masks[input%4]);
2575 /* LMLBT4x initialization - to allow access to GPIO bits for sensors input and
2578 GPIObit | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
2579 assignment | TI | O3|INx| O2| O1|IN4|IN3|IN2|IN1| | |
2581 IN - sensor inputs, INx - sensor inputs and TI XORed together
2582 O1,O2,O3 - alarm outputs (relays)
2584 OUT ENABLE 1 1 0 . 1 1 0 0 . 0 0 0 0 = 0x6C0
2588 static void init_lmlbt4x(struct bttv *btv)
2590 printk(KERN_DEBUG "LMLBT4x init\n");
2591 btwrite(0x000000, BT848_GPIO_REG_INP);
2592 gpio_inout(0xffffff, 0x0006C0);
2593 gpio_write(0x000000);
2596 static void sigmaSQ_muxsel(struct bttv *btv, unsigned int input)
2598 unsigned int inmux = input % 8;
2599 gpio_inout( 0xf, 0xf );
2600 gpio_bits( 0xf, inmux );
2603 static void sigmaSLC_muxsel(struct bttv *btv, unsigned int input)
2605 unsigned int inmux = input % 4;
2606 gpio_inout( 3<<9, 3<<9 );
2607 gpio_bits( 3<<9, inmux<<9 );
2610 /* ----------------------------------------------------------------------- */
2612 static void bttv_reset_audio(struct bttv *btv)
2615 * BT878A has a audio-reset register.
2616 * 1. This register is an audio reset function but it is in
2617 * function-0 (video capture) address space.
2618 * 2. It is enough to do this once per power-up of the card.
2619 * 3. There is a typo in the Conexant doc -- it is not at
2620 * 0x5B, but at 0x058. (B is an odd-number, obviously a typo!).
2621 * --//Shrikumar 030609
2627 printk("bttv%d: BT878A ARESET\n",btv->c.nr);
2628 btwrite((1<<7), 0x058);
2633 /* initialization part one -- before registering i2c bus */
2634 void __devinit bttv_init_card1(struct bttv *btv)
2636 switch (btv->c.type) {
2637 case BTTV_HAUPPAUGE:
2638 case BTTV_HAUPPAUGE878:
2639 boot_msp34xx(btv,5);
2641 case BTTV_VOODOOTV_FM:
2642 boot_msp34xx(btv,20);
2644 case BTTV_AVERMEDIA98:
2645 boot_msp34xx(btv,11);
2647 case BTTV_HAUPPAUGEPVR:
2650 case BTTV_TWINHAN_DST:
2651 case BTTV_AVDVBT_771:
2652 btv->use_i2c_hw = 1;
2654 case BTTV_ADLINK_RTV24:
2659 if (!bttv_tvcards[btv->c.type].has_dvb)
2660 bttv_reset_audio(btv);
2663 /* initialization part two -- after registering i2c bus */
2664 void __devinit bttv_init_card2(struct bttv *btv)
2667 btv->tuner_type = -1;
2669 if (BTTV_UNKNOWN == btv->c.type) {
2670 bttv_readee(btv,eeprom_data,0xa0);
2671 identify_by_eeprom(btv,eeprom_data);
2674 switch (btv->c.type) {
2678 case BTTV_PINNACLEPRO:
2680 miro_pinnacle_gpio(btv);
2682 case BTTV_FLYVIDEO_98:
2684 case BTTV_LIFE_FLYKIT:
2686 case BTTV_TYPHOON_TVIEW:
2687 case BTTV_CHRONOS_VS2:
2688 case BTTV_FLYVIDEO_98FM:
2689 case BTTV_FLYVIDEO2000:
2690 case BTTV_FLYVIDEO98EZ:
2691 case BTTV_CONFERENCETV:
2692 case BTTV_LIFETEC_9415:
2695 case BTTV_HAUPPAUGE:
2696 case BTTV_HAUPPAUGE878:
2697 case BTTV_HAUPPAUGEPVR:
2698 /* pick up some config infos from the eeprom */
2699 bttv_readee(btv,eeprom_data,0xa0);
2700 hauppauge_eeprom(btv);
2702 case BTTV_AVERMEDIA98:
2703 case BTTV_AVPHONE98:
2704 bttv_readee(btv,eeprom_data,0xa0);
2705 avermedia_eeprom(btv);
2710 case BTTV_PICOLO_TETRA_CHIP:
2711 picolo_tetra_init(btv);
2715 btv->has_matchbox = 1;
2716 btv->mbox_we = 0x20;
2718 btv->mbox_clk = 0x08;
2719 btv->mbox_data = 0x10;
2720 btv->mbox_mask = 0x38;
2722 case BTTV_VOBIS_BOOSTAR:
2724 terratec_active_radio_upgrade(btv);
2726 case BTTV_MAGICTVIEW061:
2727 if (btv->cardid == 0x3002144f) {
2729 printk("bttv%d: radio detected by subsystem id (CPH05x)\n",btv->c.nr);
2733 if (btv->cardid == 0x3060121a) {
2734 /* Fix up entry for 3DFX VoodooTV 100,
2735 which is an OEM STB card variant. */
2737 btv->tuner_type=TUNER_TEMIC_NTSC;
2740 case BTTV_OSPREY1x0:
2741 case BTTV_OSPREY1x0_848:
2742 case BTTV_OSPREY101_848:
2743 case BTTV_OSPREY1x1:
2744 case BTTV_OSPREY1x1_SVID:
2745 case BTTV_OSPREY2xx:
2746 case BTTV_OSPREY2x0_SVID:
2747 case BTTV_OSPREY2x0:
2748 case BTTV_OSPREY500:
2749 case BTTV_OSPREY540:
2750 case BTTV_OSPREY2000:
2751 bttv_readee(btv,eeprom_data,0xa0);
2754 case BTTV_IDS_EAGLE:
2755 init_ids_eagle(btv);
2757 case BTTV_MODTEC_205:
2758 bttv_readee(btv,eeprom_data,0xa0);
2764 case BTTV_TIBET_CS16:
2765 tibetCS16_init(btv);
2767 case BTTV_KODICOM_4400R:
2768 kodicom4400r_init(btv);
2772 /* pll configuration */
2773 if (!(btv->id==848 && btv->revision==0x11)) {
2774 /* defaults from card list */
2775 if (PLL_28 == bttv_tvcards[btv->c.type].pll) {
2776 btv->pll.pll_ifreq=28636363;
2777 btv->pll.pll_crystal=BT848_IFORM_XT0;
2779 if (PLL_35 == bttv_tvcards[btv->c.type].pll) {
2780 btv->pll.pll_ifreq=35468950;
2781 btv->pll.pll_crystal=BT848_IFORM_XT1;
2783 /* insmod options can override */
2784 switch (pll[btv->c.nr]) {
2786 btv->pll.pll_crystal = 0;
2787 btv->pll.pll_ifreq = 0;
2788 btv->pll.pll_ofreq = 0;
2790 case 1: /* 28 MHz */
2792 btv->pll.pll_ifreq = 28636363;
2793 btv->pll.pll_ofreq = 0;
2794 btv->pll.pll_crystal = BT848_IFORM_XT0;
2796 case 2: /* 35 MHz */
2798 btv->pll.pll_ifreq = 35468950;
2799 btv->pll.pll_ofreq = 0;
2800 btv->pll.pll_crystal = BT848_IFORM_XT1;
2804 btv->pll.pll_current = -1;
2806 bttv_reset_audio(btv);
2808 /* tuner configuration (from card list / autodetect / insmod option) */
2809 if (UNSET != bttv_tvcards[btv->c.type].tuner_type)
2810 if(UNSET == btv->tuner_type)
2811 btv->tuner_type = bttv_tvcards[btv->c.type].tuner_type;
2812 if (UNSET != tuner[btv->c.nr])
2813 btv->tuner_type = tuner[btv->c.nr];
2814 printk("bttv%d: using tuner=%d\n",btv->c.nr,btv->tuner_type);
2815 if (btv->pinnacle_id != UNSET)
2816 bttv_call_i2c_clients(btv,AUDC_CONFIG_PINNACLE,
2818 if (btv->tuner_type != UNSET)
2819 bttv_call_i2c_clients(btv,TUNER_SET_TYPE,&btv->tuner_type);
2820 btv->svhs = bttv_tvcards[btv->c.type].svhs;
2821 if (svhs[btv->c.nr] != UNSET)
2822 btv->svhs = svhs[btv->c.nr];
2823 if (remote[btv->c.nr] != UNSET)
2824 btv->has_remote = remote[btv->c.nr];
2826 if (bttv_tvcards[btv->c.type].has_radio)
2828 if (bttv_tvcards[btv->c.type].has_remote)
2830 if (bttv_tvcards[btv->c.type].no_gpioirq)
2832 if (bttv_tvcards[btv->c.type].audio_hook)
2833 btv->audio_hook=bttv_tvcards[btv->c.type].audio_hook;
2835 if (bttv_tvcards[btv->c.type].digital_mode == DIGITAL_MODE_CAMERA) {
2836 /* detect Bt832 chip for quartzsight digital camera */
2837 if ((bttv_I2CRead(btv, I2C_BT832_ALT1, "Bt832") >=0) ||
2838 (bttv_I2CRead(btv, I2C_BT832_ALT2, "Bt832") >=0))
2845 /* try to detect audio/fader chips */
2846 if (!bttv_tvcards[btv->c.type].no_msp34xx &&
2847 bttv_I2CRead(btv, I2C_MSP3400, "MSP34xx") >=0)
2848 request_module("msp3400");
2850 if (bttv_tvcards[btv->c.type].msp34xx_alt &&
2851 bttv_I2CRead(btv, I2C_MSP3400_ALT, "MSP34xx (alternate address)") >=0)
2852 request_module("msp3400");
2854 if (!bttv_tvcards[btv->c.type].no_tda9875 &&
2855 bttv_I2CRead(btv, I2C_TDA9875, "TDA9875") >=0)
2856 request_module("tda9875");
2858 if (!bttv_tvcards[btv->c.type].no_tda7432 &&
2859 bttv_I2CRead(btv, I2C_TDA7432, "TDA7432") >=0)
2860 request_module("tda7432");
2862 if (bttv_tvcards[btv->c.type].needs_tvaudio)
2863 request_module("tvaudio");
2867 if (btv->pinnacle_id != UNSET)
2869 if (0 == tda9887 && 0 == bttv_tvcards[btv->c.type].has_dvb &&
2870 bttv_I2CRead(btv, I2C_TDA9887, "TDA9887") >=0)
2872 if((btv->tuner_type == TUNER_PHILIPS_FM1216ME_MK3) ||
2873 (btv->tuner_type == TUNER_PHILIPS_FM1236_MK3) ||
2874 (btv->tuner_type == TUNER_PHILIPS_FM1256_IH3) ||
2876 request_module("tda9887");
2877 if (btv->tuner_type != UNSET)
2878 request_module("tuner");
2882 /* ----------------------------------------------------------------------- */
2884 static void modtec_eeprom(struct bttv *btv)
2886 if( strncmp(&(eeprom_data[0x1e]),"Temic 4066 FY5",14) ==0) {
2887 btv->tuner_type=TUNER_TEMIC_4066FY5_PAL_I;
2888 printk("bttv%d: Modtec: Tuner autodetected by eeprom: %s\n",
2889 btv->c.nr,&eeprom_data[0x1e]);
2890 } else if (strncmp(&(eeprom_data[0x1e]),"Alps TSBB5",10) ==0) {
2891 btv->tuner_type=TUNER_ALPS_TSBB5_PAL_I;
2892 printk("bttv%d: Modtec: Tuner autodetected by eeprom: %s\n",
2893 btv->c.nr,&eeprom_data[0x1e]);
2894 } else if (strncmp(&(eeprom_data[0x1e]),"Philips FM1246",14) ==0) {
2895 btv->tuner_type=TUNER_PHILIPS_NTSC;
2896 printk("bttv%d: Modtec: Tuner autodetected by eeprom: %s\n",
2897 btv->c.nr,&eeprom_data[0x1e]);
2899 printk("bttv%d: Modtec: Unknown TunerString: %s\n",
2900 btv->c.nr,&eeprom_data[0x1e]);
2904 static void __devinit hauppauge_eeprom(struct bttv *btv)
2908 tveeprom_hauppauge_analog(&tv, eeprom_data);
2909 btv->tuner_type = tv.tuner_type;
2910 btv->has_radio = tv.has_radio;
2913 static int terratec_active_radio_upgrade(struct bttv *btv)
2918 btv->has_matchbox = 1;
2919 btv->mbox_we = 0x10;
2920 btv->mbox_most = 0x20;
2921 btv->mbox_clk = 0x08;
2922 btv->mbox_data = 0x04;
2923 btv->mbox_mask = 0x3c;
2925 btv->mbox_iow = 1 << 8;
2926 btv->mbox_ior = 1 << 9;
2927 btv->mbox_csel = 1 << 10;
2930 tea5757_write(btv, 5 * freq + 0x358); // write 0x1ed8
2931 if (0x1ed8 == tea5757_read(btv)) {
2932 printk("bttv%d: Terratec Active Radio Upgrade found.\n",
2935 btv->has_matchbox = 1;
2938 btv->has_matchbox = 0;
2944 /* ----------------------------------------------------------------------- */
2947 * minimal bootstrap for the WinTV/PVR -- upload altera firmware.
2949 * The hcwamc.rbf firmware file is on the Hauppauge driver CD. Have
2950 * a look at Pvr/pvr45xxx.EXE (self-extracting zip archive, can be
2951 * unpacked with unzip).
2953 #define PVR_GPIO_DELAY 10
2955 #define BTTV_ALT_DATA 0x000001
2956 #define BTTV_ALT_DCLK 0x100000
2957 #define BTTV_ALT_NCONFIG 0x800000
2959 static int __devinit pvr_altera_load(struct bttv *btv, u8 *micro, u32 microlen)
2965 gpio_inout(0xffffff,BTTV_ALT_DATA|BTTV_ALT_DCLK|BTTV_ALT_NCONFIG);
2967 udelay(PVR_GPIO_DELAY);
2969 gpio_write(BTTV_ALT_NCONFIG);
2970 udelay(PVR_GPIO_DELAY);
2972 for (n = 0; n < microlen; n++) {
2974 for ( i = 0 ; i < 8 ; i++ ) {
2975 gpio_bits(BTTV_ALT_DCLK,0);
2977 gpio_bits(BTTV_ALT_DATA,BTTV_ALT_DATA);
2979 gpio_bits(BTTV_ALT_DATA,0);
2980 gpio_bits(BTTV_ALT_DCLK,BTTV_ALT_DCLK);
2984 gpio_bits(BTTV_ALT_DCLK,0);
2985 udelay(PVR_GPIO_DELAY);
2987 /* begin Altera init loop (Not necessary,but doesn't hurt) */
2988 for (i = 0 ; i < 30 ; i++) {
2989 gpio_bits(BTTV_ALT_DCLK,0);
2990 gpio_bits(BTTV_ALT_DCLK,BTTV_ALT_DCLK);
2992 gpio_bits(BTTV_ALT_DCLK,0);
2996 static int __devinit pvr_boot(struct bttv *btv)
2998 const struct firmware *fw_entry;
3001 rc = request_firmware(&fw_entry, "hcwamc.rbf", &btv->c.pci->dev);
3003 printk(KERN_WARNING "bttv%d: no altera firmware [via hotplug]\n",
3007 rc = pvr_altera_load(btv, fw_entry->data, fw_entry->size);
3008 printk(KERN_INFO "bttv%d: altera firmware upload %s\n",
3009 btv->c.nr, (rc < 0) ? "failed" : "ok");
3010 release_firmware(fw_entry);
3014 /* ----------------------------------------------------------------------- */
3015 /* some osprey specific stuff */
3017 static void __devinit osprey_eeprom(struct bttv *btv)
3020 unsigned char *ee = eeprom_data;
3021 unsigned long serial = 0;
3023 if (btv->c.type == 0) {
3024 /* this might be an antique... check for MMAC label in eeprom */
3025 if ((ee[0]=='M') && (ee[1]=='M') && (ee[2]=='A') && (ee[3]=='C')) {
3026 unsigned char checksum = 0;
3027 for (i =0; i<21; i++)
3029 if (checksum != ee[21])
3031 btv->c.type = BTTV_OSPREY1x0_848;
3032 for (i = 12; i < 21; i++)
3033 serial *= 10, serial += ee[i] - '0';
3036 unsigned short type;
3039 for(; offset < 8*16; offset += 16) {
3040 unsigned short checksum = 0;
3041 /* verify the checksum */
3042 for(i = 0; i<14; i++) checksum += ee[i+offset];
3043 checksum = ~checksum; /* no idea why */
3044 if ((((checksum>>8)&0x0FF) == ee[offset+14]) &&
3045 ((checksum & 0x0FF) == ee[offset+15])) {
3053 /* found a valid descriptor */
3054 type = (ee[offset+4]<<8) | (ee[offset+5]);
3060 btv->c.type = BTTV_OSPREY1x0_848;
3063 btv->c.type = BTTV_OSPREY101_848;
3069 btv->c.type = BTTV_OSPREY1x0;
3073 btv->c.type = BTTV_OSPREY1x1;
3078 btv->c.type = BTTV_OSPREY1x1_SVID;
3084 btv->c.type = BTTV_OSPREY2xx;
3088 btv->c.type = BTTV_OSPREY2x0_SVID;
3091 btv->c.type = BTTV_OSPREY500;
3095 btv->c.type = BTTV_OSPREY540;
3096 /* bttv_osprey_540_init(btv); */
3100 btv->c.type = BTTV_OSPREY2x0;
3101 //enable output on select control lines
3102 gpio_inout(0xffffff,0x000303);
3105 /* unknown...leave generic, but get serial # */
3108 serial = (ee[offset+6] << 24)
3109 | (ee[offset+7] << 16)
3110 | (ee[offset+8] << 8)
3114 printk(KERN_INFO "bttv%d: osprey eeprom: card=%d name=%s serial=%ld\n",
3115 btv->c.nr, btv->c.type, bttv_tvcards[btv->c.type].name,serial);
3118 /* ----------------------------------------------------------------------- */
3119 /* AVermedia specific stuff, from bktr_card.c */
3121 static int tuner_0_table[] = {
3122 TUNER_PHILIPS_NTSC, TUNER_PHILIPS_PAL /* PAL-BG*/,
3123 TUNER_PHILIPS_PAL, TUNER_PHILIPS_PAL /* PAL-I*/,
3124 TUNER_PHILIPS_PAL, TUNER_PHILIPS_PAL,
3125 TUNER_PHILIPS_SECAM, TUNER_PHILIPS_SECAM,
3126 TUNER_PHILIPS_SECAM, TUNER_PHILIPS_PAL,
3127 TUNER_PHILIPS_FM1216ME_MK3 };
3129 int tuner_0_fm_table[] = {
3130 PHILIPS_FR1236_NTSC, PHILIPS_FR1216_PAL,
3131 PHILIPS_FR1216_PAL, PHILIPS_FR1216_PAL,
3132 PHILIPS_FR1216_PAL, PHILIPS_FR1216_PAL,
3133 PHILIPS_FR1236_SECAM, PHILIPS_FR1236_SECAM,
3134 PHILIPS_FR1236_SECAM, PHILIPS_FR1216_PAL};
3137 static int tuner_1_table[] = {
3138 TUNER_TEMIC_NTSC, TUNER_TEMIC_PAL,
3139 TUNER_TEMIC_PAL, TUNER_TEMIC_PAL,
3140 TUNER_TEMIC_PAL, TUNER_TEMIC_PAL,
3141 TUNER_TEMIC_4012FY5, TUNER_TEMIC_4012FY5, //TUNER_TEMIC_SECAM
3142 TUNER_TEMIC_4012FY5, TUNER_TEMIC_PAL};
3144 static void __devinit avermedia_eeprom(struct bttv *btv)
3146 int tuner_make,tuner_tv_fm,tuner_format,tuner=0;
3148 tuner_make = (eeprom_data[0x41] & 0x7);
3149 tuner_tv_fm = (eeprom_data[0x41] & 0x18) >> 3;
3150 tuner_format = (eeprom_data[0x42] & 0xf0) >> 4;
3151 btv->has_remote = (eeprom_data[0x42] & 0x01);
3153 if (tuner_make == 0 || tuner_make == 2)
3154 if(tuner_format <=0x0a)
3155 tuner = tuner_0_table[tuner_format];
3156 if (tuner_make == 1)
3157 if(tuner_format <=9)
3158 tuner = tuner_1_table[tuner_format];
3160 if (tuner_make == 4)
3161 if(tuner_format == 0x09)
3162 tuner = TUNER_LG_NTSC_NEW_TAPC; // TAPC-G702P
3164 printk(KERN_INFO "bttv%d: Avermedia eeprom[0x%02x%02x]: tuner=",
3165 btv->c.nr,eeprom_data[0x41],eeprom_data[0x42]);
3167 btv->tuner_type=tuner;
3170 printk("Unknown type");
3171 printk(" radio:%s remote control:%s\n",
3172 tuner_tv_fm ? "yes" : "no",
3173 btv->has_remote ? "yes" : "no");
3176 /* used on Voodoo TV/FM (Voodoo 200), S0 wired to 0x10000 */
3177 void bttv_tda9880_setnorm(struct bttv *btv, int norm)
3179 // fix up our card entry
3180 if(norm==VIDEO_MODE_NTSC) {
3181 bttv_tvcards[BTTV_VOODOOTV_FM].audiomux[0]=0x957fff;
3182 bttv_tvcards[BTTV_VOODOOTV_FM].audiomux[4]=0x957fff;
3183 dprintk("bttv_tda9880_setnorm to NTSC\n");
3186 bttv_tvcards[BTTV_VOODOOTV_FM].audiomux[0]=0x947fff;
3187 bttv_tvcards[BTTV_VOODOOTV_FM].audiomux[4]=0x947fff;
3188 dprintk("bttv_tda9880_setnorm to PAL\n");
3190 // set GPIO according
3191 gpio_bits(bttv_tvcards[btv->c.type].gpiomask,
3192 bttv_tvcards[btv->c.type].audiomux[btv->audio]);
3197 * reset/enable the MSP on some Hauppauge cards
3198 * Thanks to Kyösti Mälkki (kmalkki@cc.hut.fi)!
3203 static void __devinit boot_msp34xx(struct bttv *btv, int pin)
3205 int mask = (1 << pin);
3207 gpio_inout(mask,mask);
3210 gpio_bits(mask,mask);
3213 bttv_gpio_tracking(btv,"msp34xx");
3215 printk(KERN_INFO "bttv%d: Hauppauge/Voodoo msp34xx: reset line "
3216 "init [%d]\n", btv->c.nr, pin);
3219 static void __devinit boot_bt832(struct bttv *btv)
3221 #if 0 /* not working yet */
3224 switch (btv->c.type) {
3225 case BTTV_PXELVWPLTVPAK:
3226 resetbit = 0x400000;
3228 case BTTV_MODTEC_205:
3235 request_module("bt832");
3236 bttv_call_i2c_clients(btv, BT832_HEXDUMP, NULL);
3238 printk("bttv%d: Reset Bt832 [line=0x%x]\n",btv->c.nr,resetbit);
3240 gpio_inout(resetbit, resetbit);
3242 gpio_bits(resetbit, resetbit);
3244 gpio_bits(resetbit, 0);
3247 // bt832 on pixelview changes from i2c 0x8a to 0x88 after
3248 // being reset as above. So we must follow by this:
3249 bttv_call_i2c_clients(btv, BT832_REATTACH, NULL);
3253 /* ----------------------------------------------------------------------- */
3254 /* Imagenation L-Model PXC200 Framegrabber */
3255 /* This is basically the same procedure as
3256 * used by Alessandro Rubini in his pxc200
3257 * driver, but using BTTV functions */
3259 static void __devinit init_PXC200(struct bttv *btv)
3261 static int vals[] __devinitdata = { 0x08, 0x09, 0x0a, 0x0b, 0x0d, 0x0d,
3262 0x01, 0x02, 0x03, 0x04, 0x05, 0x06,
3268 /* Initialise GPIO-connevted stuff */
3269 gpio_inout(0xffffff, (1<<13));
3273 /* GPIO inputs are pulled up, so no need to drive
3274 * reset pin any longer */
3275 gpio_bits(0xffffff, 0);
3277 bttv_gpio_tracking(btv,"pxc200");
3279 /* we could/should try and reset/control the AD pots? but
3280 right now we simply turned off the crushing. Without
3281 this the AGC drifts drifts
3282 remember the EN is reverse logic -->
3283 setting BT848_ADC_AGC_EN disable the AGC
3284 tboult@eecs.lehigh.edu
3287 btwrite(BT848_ADC_RESERVED|BT848_ADC_AGC_EN, BT848_ADC);
3289 /* Initialise MAX517 DAC */
3290 printk(KERN_INFO "Setting DAC reference voltage level ...\n");
3291 bttv_I2CWrite(btv,0x5E,0,0x80,1);
3293 /* Initialise 12C508 PIC */
3294 /* The I2CWrite and I2CRead commmands are actually to the
3295 * same chips - but the R/W bit is included in the address
3296 * argument so the numbers are different */
3299 printk(KERN_INFO "Initialising 12C508 PIC chip ...\n");
3301 /* First of all, enable the clock line. This is used in the PXC200-F */
3302 val = btread(BT848_GPIO_DMA_CTL);
3303 val |= BT848_GPIO_DMA_CTL_GPCLKMODE;
3304 btwrite(val, BT848_GPIO_DMA_CTL);
3306 /* Then, push to 0 the reset pin long enough to reset the *
3307 * device same as above for the reset line, but not the same
3308 * value sent to the GPIO-connected stuff
3309 * which one is the good one? */
3310 gpio_inout(0xffffff,(1<<2));
3315 for (i = 0; i < ARRAY_SIZE(vals); i++) {
3316 tmp=bttv_I2CWrite(btv,0x1E,0,vals[i],1);
3319 "I2C Write(%2.2x) = %i\nI2C Read () = %2.2x\n\n",
3320 vals[i],tmp,bttv_I2CRead(btv,0x1F,NULL));
3324 printk(KERN_INFO "PXC200 Initialised.\n");
3329 /* ----------------------------------------------------------------------- */
3331 * The Adlink RTV-24 (aka Angelo) has some special initialisation to unlock
3332 * it. This apparently involves the following procedure for each 878 chip:
3334 * 1) write 0x00C3FEFF to the GPIO_OUT_EN register
3336 * 2) write to GPIO_DATA
3342 * read from GPIO_DATA into buf (uint_32)
3343 * - if ( data>>18 & 0x01 != 0) || ( buf>>19 & 0x01 != 1 )
3344 * error. ERROR_CPLD_Check_Failed stop.
3346 * 3) write to GPIO_DATA
3347 * - write 0x4400 + 0x0E
3349 * - write 0x4410 + 0x0E
3352 * read from GPIO_DATA into buf (uint_32)
3353 * - if ( buf>>18 & 0x01 ) || ( buf>>19 && 0x01 != 0 )
3354 * error. ERROR_CPLD_Check_Failed.
3356 /* ----------------------------------------------------------------------- */
3358 init_RTV24 (struct bttv *btv)
3360 uint32_t dataRead = 0;
3361 long watchdog_value = 0x0E;
3364 "bttv%d: Adlink RTV-24 initialisation in progress ...\n",
3367 btwrite (0x00c3feff, BT848_GPIO_OUT_EN);
3369 btwrite (0 + watchdog_value, BT848_GPIO_DATA);
3371 btwrite (0x10 + watchdog_value, BT848_GPIO_DATA);
3373 btwrite (0 + watchdog_value, BT848_GPIO_DATA);
3375 dataRead = btread (BT848_GPIO_DATA);
3377 if ((((dataRead >> 18) & 0x01) != 0) || (((dataRead >> 19) & 0x01) != 1)) {
3379 "bttv%d: Adlink RTV-24 initialisation(1) ERROR_CPLD_Check_Failed (read %d)\n",
3380 btv->c.nr, dataRead);
3383 btwrite (0x4400 + watchdog_value, BT848_GPIO_DATA);
3385 btwrite (0x4410 + watchdog_value, BT848_GPIO_DATA);
3387 btwrite (watchdog_value, BT848_GPIO_DATA);
3389 dataRead = btread (BT848_GPIO_DATA);
3391 if ((((dataRead >> 18) & 0x01) != 0) || (((dataRead >> 19) & 0x01) != 0)) {
3393 "bttv%d: Adlink RTV-24 initialisation(2) ERROR_CPLD_Check_Failed (read %d)\n",
3394 btv->c.nr, dataRead);
3400 "bttv%d: Adlink RTV-24 initialisation complete.\n", btv->c.nr);
3405 /* ----------------------------------------------------------------------- */
3406 /* Miro Pro radio stuff -- the tea5757 is connected to some GPIO ports */
3408 * Copyright (c) 1999 Csaba Halasz <qgehali@uni-miskolc.hu>
3409 * This code is placed under the terms of the GNU General Public License
3411 * Brutally hacked by Dan Sheridan <dan.sheridan@contact.org.uk> djs52 8/3/00
3414 static void bus_low(struct bttv *btv, int bit)
3416 if (btv->mbox_ior) {
3417 gpio_bits(btv->mbox_ior | btv->mbox_iow | btv->mbox_csel,
3418 btv->mbox_ior | btv->mbox_iow | btv->mbox_csel);
3425 if (btv->mbox_ior) {
3426 gpio_bits(btv->mbox_iow | btv->mbox_csel, 0);
3431 static void bus_high(struct bttv *btv, int bit)
3433 if (btv->mbox_ior) {
3434 gpio_bits(btv->mbox_ior | btv->mbox_iow | btv->mbox_csel,
3435 btv->mbox_ior | btv->mbox_iow | btv->mbox_csel);
3442 if (btv->mbox_ior) {
3443 gpio_bits(btv->mbox_iow | btv->mbox_csel, 0);
3448 static int bus_in(struct bttv *btv, int bit)
3450 if (btv->mbox_ior) {
3451 gpio_bits(btv->mbox_ior | btv->mbox_iow | btv->mbox_csel,
3452 btv->mbox_ior | btv->mbox_iow | btv->mbox_csel);
3455 gpio_bits(btv->mbox_iow | btv->mbox_csel, 0);
3458 return gpio_read() & (bit);
3461 /* TEA5757 register bits */
3462 #define TEA_FREQ 0:14
3463 #define TEA_BUFFER 15:15
3465 #define TEA_SIGNAL_STRENGTH 16:17
3467 #define TEA_PORT1 18:18
3468 #define TEA_PORT0 19:19
3470 #define TEA_BAND 20:21
3471 #define TEA_BAND_FM 0
3472 #define TEA_BAND_MW 1
3473 #define TEA_BAND_LW 2
3474 #define TEA_BAND_SW 3
3476 #define TEA_MONO 22:22
3477 #define TEA_ALLOW_STEREO 0
3478 #define TEA_FORCE_MONO 1
3480 #define TEA_SEARCH_DIRECTION 23:23
3481 #define TEA_SEARCH_DOWN 0
3482 #define TEA_SEARCH_UP 1
3484 #define TEA_STATUS 24:24
3485 #define TEA_STATUS_TUNED 0
3486 #define TEA_STATUS_SEARCHING 1
3488 /* Low-level stuff */
3489 static int tea5757_read(struct bttv *btv)
3491 unsigned long timeout;
3495 /* better safe than sorry */
3496 gpio_inout(btv->mbox_mask, btv->mbox_clk | btv->mbox_we);
3498 if (btv->mbox_ior) {
3499 gpio_bits(btv->mbox_ior | btv->mbox_iow | btv->mbox_csel,
3500 btv->mbox_ior | btv->mbox_iow | btv->mbox_csel);
3505 bttv_gpio_tracking(btv,"tea5757 read");
3507 bus_low(btv,btv->mbox_we);
3508 bus_low(btv,btv->mbox_clk);
3511 timeout= jiffies + HZ;
3513 // wait for DATA line to go low; error if it doesn't
3514 while (bus_in(btv,btv->mbox_data) && time_before(jiffies, timeout))
3516 if (bus_in(btv,btv->mbox_data)) {
3517 printk(KERN_WARNING "bttv%d: tea5757: read timeout\n",btv->c.nr);
3521 dprintk("bttv%d: tea5757:",btv->c.nr);
3522 for(i = 0; i < 24; i++)
3525 bus_high(btv,btv->mbox_clk);
3527 dprintk("%c",(bus_in(btv,btv->mbox_most) == 0)?'T':'-');
3528 bus_low(btv,btv->mbox_clk);
3530 value |= (bus_in(btv,btv->mbox_data) == 0)?0:1; /* MSB first */
3531 dprintk("%c", (bus_in(btv,btv->mbox_most) == 0)?'S':'M');
3533 dprintk("\nbttv%d: tea5757: read 0x%X\n", btv->c.nr, value);
3537 static int tea5757_write(struct bttv *btv, int value)
3542 gpio_inout(btv->mbox_mask, btv->mbox_clk | btv->mbox_we | btv->mbox_data);
3544 if (btv->mbox_ior) {
3545 gpio_bits(btv->mbox_ior | btv->mbox_iow | btv->mbox_csel,
3546 btv->mbox_ior | btv->mbox_iow | btv->mbox_csel);
3550 bttv_gpio_tracking(btv,"tea5757 write");
3552 dprintk("bttv%d: tea5757: write 0x%X\n", btv->c.nr, value);
3553 bus_low(btv,btv->mbox_clk);
3554 bus_high(btv,btv->mbox_we);
3555 for(i = 0; i < 25; i++)
3557 if (reg & 0x1000000)
3558 bus_high(btv,btv->mbox_data);
3560 bus_low(btv,btv->mbox_data);
3562 bus_high(btv,btv->mbox_clk);
3564 bus_low(btv,btv->mbox_clk);
3567 bus_low(btv,btv->mbox_we); /* unmute !!! */
3571 void tea5757_set_freq(struct bttv *btv, unsigned short freq)
3573 dprintk("tea5757_set_freq %d\n",freq);
3574 tea5757_write(btv, 5 * freq + 0x358); /* add 10.7MHz (see docs) */
3576 /* breaks Miro PCTV */
3577 value = tea5757_read(btv);
3578 dprintk("bttv%d: tea5757 readback=0x%x\n",btv->c.nr,value);
3583 /* ----------------------------------------------------------------------- */
3586 void winview_audio(struct bttv *btv, struct video_audio *v, int set)
3588 /* PT2254A programming Jon Tombs, jon@gte.esi.us.es */
3589 int bits_out, loops, vol, data;
3592 /* Fixed by Leandro Lucarella <luca@linuxmendoza.org.ar (07/31/01) */
3593 v->flags |= VIDEO_AUDIO_VOLUME;
3597 /* 32 levels logarithmic */
3598 vol = 32 - ((v->volume>>11));
3600 bits_out = (PT2254_DBS_IN_2>>(vol%5));
3602 bits_out |= (PT2254_DBS_IN_10>>(vol/5));
3603 bits_out |= PT2254_L_CHANNEL | PT2254_R_CHANNEL;
3605 data &= ~(WINVIEW_PT2254_CLK| WINVIEW_PT2254_DATA|
3606 WINVIEW_PT2254_STROBE);
3607 for (loops = 17; loops >= 0 ; loops--) {
3608 if (bits_out & (1<<loops))
3609 data |= WINVIEW_PT2254_DATA;
3611 data &= ~WINVIEW_PT2254_DATA;
3614 data |= WINVIEW_PT2254_CLK;
3617 data &= ~WINVIEW_PT2254_CLK;
3620 data |= WINVIEW_PT2254_STROBE;
3621 data &= ~WINVIEW_PT2254_DATA;
3624 data &= ~WINVIEW_PT2254_STROBE;
3628 /* ----------------------------------------------------------------------- */
3629 /* mono/stereo control for various cards (which don't use i2c chips but */
3630 /* connect something to the GPIO pins */
3633 gvbctv3pci_audio(struct bttv *btv, struct video_audio *v, int set)
3635 unsigned int con = 0;
3638 gpio_inout(0x300, 0x300);
3639 if (v->mode & VIDEO_SOUND_LANG1)
3641 if (v->mode & VIDEO_SOUND_LANG2)
3643 if (v->mode & VIDEO_SOUND_STEREO)
3645 // if (v->mode & VIDEO_SOUND_MONO)
3647 gpio_bits(0x300, con);
3649 v->mode = VIDEO_SOUND_STEREO |
3650 VIDEO_SOUND_LANG1 | VIDEO_SOUND_LANG2;
3655 gvbctv5pci_audio(struct bttv *btv, struct video_audio *v, int set)
3657 unsigned int val, con;
3659 #if BTTV_VERSION_CODE > KERNEL_VERSION(0,8,0)
3660 if (btv->radio_user)
3670 if (v->mode & VIDEO_SOUND_LANG2) {
3671 if (v->mode & VIDEO_SOUND_LANG1) {
3680 if (con != (val & 0x300)) {
3681 gpio_bits(0x300, con);
3683 bttv_gpio_tracking(btv,"gvbctv5pci");
3686 switch (val & 0x70) {
3688 v->mode = VIDEO_SOUND_LANG1 | VIDEO_SOUND_LANG2;
3691 v->mode = VIDEO_SOUND_LANG2;
3694 v->mode = VIDEO_SOUND_LANG1;
3697 v->mode = VIDEO_SOUND_STEREO;
3700 v->mode = VIDEO_SOUND_MONO;
3703 v->mode = VIDEO_SOUND_MONO | VIDEO_SOUND_STEREO |
3704 VIDEO_SOUND_LANG1 | VIDEO_SOUND_LANG2;
3710 * Mario Medina Nussbaum <medisoft@alohabbs.org.mx>
3711 * I discover that on BT848_GPIO_DATA address a byte 0xcce enable stereo,
3712 * 0xdde enables mono and 0xccd enables sap
3714 * Petr Vandrovec <VANDROVE@vc.cvut.cz>
3715 * P.S.: At least mask in line above is wrong - GPIO pins 3,2 select
3716 * input/output sound connection, so both must be set for output mode.
3718 * Looks like it's needed only for the "tvphone", the "tvphone 98"
3719 * handles this with a tda9840
3723 avermedia_tvphone_audio(struct bttv *btv, struct video_audio *v, int set)
3728 if (v->mode & VIDEO_SOUND_LANG2) /* SAP */
3730 if (v->mode & VIDEO_SOUND_STEREO)
3733 gpio_bits(0x03,val);
3735 bttv_gpio_tracking(btv,"avermedia");
3738 v->mode = VIDEO_SOUND_MONO | VIDEO_SOUND_STEREO |
3745 avermedia_tv_stereo_audio(struct bttv *btv, struct video_audio *v, int set)
3750 if (v->mode & VIDEO_SOUND_LANG2) /* SAP */
3752 if (v->mode & VIDEO_SOUND_STEREO) /* STEREO */
3754 btaor(val, ~0x03, BT848_GPIO_DATA);
3756 bttv_gpio_tracking(btv,"avermedia");
3758 v->mode = VIDEO_SOUND_MONO | VIDEO_SOUND_STEREO |
3759 VIDEO_SOUND_LANG1 | VIDEO_SOUND_LANG2;
3764 /* Lifetec 9415 handling */
3766 lt9415_audio(struct bttv *btv, struct video_audio *v, int set)
3770 if (gpio_read() & 0x4000) {
3771 v->mode = VIDEO_SOUND_MONO;
3776 if (v->mode & VIDEO_SOUND_LANG2) /* A2 SAP */
3778 if (v->mode & VIDEO_SOUND_STEREO) /* A2 stereo */
3780 if ((v->mode & VIDEO_SOUND_LANG1) ||
3781 (v->mode & VIDEO_SOUND_MONO))
3783 gpio_bits(0x0880, val);
3785 bttv_gpio_tracking(btv,"lt9415");
3787 /* autodetect doesn't work with this card :-( */
3788 v->mode = VIDEO_SOUND_MONO | VIDEO_SOUND_STEREO |
3789 VIDEO_SOUND_LANG1 | VIDEO_SOUND_LANG2;
3794 // TDA9821 on TerraTV+ Bt848, Bt878
3796 terratv_audio(struct bttv *btv, struct video_audio *v, int set)
3798 unsigned int con = 0;
3801 gpio_inout(0x180000,0x180000);
3802 if (v->mode & VIDEO_SOUND_LANG2)
3804 if (v->mode & VIDEO_SOUND_STEREO)
3806 gpio_bits(0x180000, con);
3808 bttv_gpio_tracking(btv,"terratv");
3810 v->mode = VIDEO_SOUND_MONO | VIDEO_SOUND_STEREO |
3811 VIDEO_SOUND_LANG1 | VIDEO_SOUND_LANG2;
3816 winfast2000_audio(struct bttv *btv, struct video_audio *v, int set)
3818 unsigned long val = 0;
3821 /*btor (0xc32000, BT848_GPIO_OUT_EN);*/
3822 if (v->mode & VIDEO_SOUND_MONO) /* Mono */
3824 if (v->mode & VIDEO_SOUND_LANG1) /* Mono */
3826 if (v->mode & VIDEO_SOUND_LANG2) /* SAP */
3828 if (v->mode & VIDEO_SOUND_STEREO) /* Stereo */
3831 gpio_bits(0x430000, val);
3833 bttv_gpio_tracking(btv,"winfast2000");
3836 v->mode = VIDEO_SOUND_MONO | VIDEO_SOUND_STEREO |
3837 VIDEO_SOUND_LANG1 | VIDEO_SOUND_LANG2;
3842 * Dariusz Kowalewski <darekk@automex.pl>
3843 * sound control for Prolink PV-BT878P+9B (PixelView PlayTV Pro FM+NICAM
3844 * revision 9B has on-board TDA9874A sound decoder).
3846 * Note: There are card variants without tda9874a. Forcing the "stereo sound route"
3847 * will mute this cards.
3850 pvbt878p9b_audio(struct bttv *btv, struct video_audio *v, int set)
3852 unsigned int val = 0;
3854 #if BTTV_VERSION_CODE > KERNEL_VERSION(0,8,0)
3855 if (btv->radio_user)
3863 if (v->mode & VIDEO_SOUND_MONO) {
3866 if ((v->mode & (VIDEO_SOUND_LANG1 | VIDEO_SOUND_LANG2))
3867 || (v->mode & VIDEO_SOUND_STEREO)) {
3871 gpio_bits(0x03,val);
3873 bttv_gpio_tracking(btv,"pvbt878p9b");
3876 v->mode = VIDEO_SOUND_MONO | VIDEO_SOUND_STEREO |
3877 VIDEO_SOUND_LANG1 | VIDEO_SOUND_LANG2;
3882 * Dariusz Kowalewski <darekk@automex.pl>
3883 * sound control for FlyVideo 2000S (with tda9874 decoder)
3884 * based on pvbt878p9b_audio() - this is not tested, please fix!!!
3887 fv2000s_audio(struct bttv *btv, struct video_audio *v, int set)
3889 unsigned int val = 0xffff;
3891 #if BTTV_VERSION_CODE > KERNEL_VERSION(0,8,0)
3892 if (btv->radio_user)
3899 if (v->mode & VIDEO_SOUND_MONO) {
3902 if ((v->mode & (VIDEO_SOUND_LANG1 | VIDEO_SOUND_LANG2))
3903 || (v->mode & VIDEO_SOUND_STEREO)) {
3904 val = 0x1080; //-dk-???: 0x0880, 0x0080, 0x1800 ...
3906 if (val != 0xffff) {
3907 gpio_bits(0x1800, val);
3909 bttv_gpio_tracking(btv,"fv2000s");
3912 v->mode = VIDEO_SOUND_MONO | VIDEO_SOUND_STEREO |
3913 VIDEO_SOUND_LANG1 | VIDEO_SOUND_LANG2;
3918 * sound control for Canopus WinDVR PCI
3919 * Masaki Suzuki <masaki@btree.org>
3922 windvr_audio(struct bttv *btv, struct video_audio *v, int set)
3924 unsigned long val = 0;
3927 if (v->mode & VIDEO_SOUND_MONO)
3929 if (v->mode & VIDEO_SOUND_LANG1)
3931 if (v->mode & VIDEO_SOUND_LANG2)
3933 if (v->mode & VIDEO_SOUND_STEREO)
3936 gpio_bits(0x140000, val);
3938 bttv_gpio_tracking(btv,"windvr");
3941 v->mode = VIDEO_SOUND_MONO | VIDEO_SOUND_STEREO |
3942 VIDEO_SOUND_LANG1 | VIDEO_SOUND_LANG2;
3947 * sound control for AD-TVK503
3948 * Hiroshi Takekawa <sian@big.or.jp>
3951 adtvk503_audio(struct bttv *btv, struct video_audio *v, int set)
3953 unsigned int con = 0xffffff;
3955 //btaor(0x1e0000, ~0x1e0000, BT848_GPIO_OUT_EN);
3958 //btor(***, BT848_GPIO_OUT_EN);
3959 if (v->mode & VIDEO_SOUND_LANG1)
3961 if (v->mode & VIDEO_SOUND_LANG2)
3963 if (v->mode & VIDEO_SOUND_STEREO)
3965 if (v->mode & VIDEO_SOUND_MONO)
3967 if (con != 0xffffff) {
3968 gpio_bits(0x1e0000,con);
3970 bttv_gpio_tracking(btv, "adtvk503");
3973 v->mode = VIDEO_SOUND_MONO | VIDEO_SOUND_STEREO |
3974 VIDEO_SOUND_LANG1 | VIDEO_SOUND_LANG2;
3978 /* RemoteVision MX (rv605) muxsel helper [Miguel Freitas]
3980 * This is needed because rv605 don't use a normal multiplex, but a crosspoint
3981 * switch instead (CD22M3494E). This IC can have multiple active connections
3982 * between Xn (input) and Yn (output) pins. We need to clear any existing
3983 * connection prior to establish a new one, pulsing the STROBE pin.
3985 * The board hardwire Y0 (xpoint) to MUX1 and MUXOUT to Yin.
3986 * GPIO pins are wired as:
3987 * GPIO[0:3] - AX[0:3] (xpoint) - P1[0:3] (microcontroler)
3988 * GPIO[4:6] - AY[0:2] (xpoint) - P1[4:6] (microcontroler)
3989 * GPIO[7] - DATA (xpoint) - P1[7] (microcontroler)
3990 * GPIO[8] - - P3[5] (microcontroler)
3991 * GPIO[9] - RESET (xpoint) - P3[6] (microcontroler)
3992 * GPIO[10] - STROBE (xpoint) - P3[7] (microcontroler)
3993 * GPINTR - - P3[4] (microcontroler)
3995 * The microcontroler is a 80C32 like. It should be possible to change xpoint
3996 * configuration either directly (as we are doing) or using the microcontroler
3997 * which is also wired to I2C interface. I have no further info on the
3998 * microcontroler features, one would need to disassembly the firmware.
3999 * note: the vendor refused to give any information on this product, all
4000 * that stuff was found using a multimeter! :)
4002 static void rv605_muxsel(struct bttv *btv, unsigned int input)
4004 /* reset all conections */
4005 gpio_bits(0x200,0x200);
4007 gpio_bits(0x200,0x000);
4010 /* create a new conection */
4011 gpio_bits(0x480,0x080);
4012 gpio_bits(0x480,0x480);
4014 gpio_bits(0x480,0x080);
4018 /* Tibet Systems 'Progress DVR' CS16 muxsel helper [Chris Fanning]
4020 * The CS16 (available on eBay cheap) is a PCI board with four Fusion
4021 * 878A chips, a PCI bridge, an Atmel microcontroller, four sync seperator
4022 * chips, ten eight input analog multiplexors, a not chip and a few
4025 * 16 inputs on a secondary bracket are provided and can be selected
4026 * from each of the four capture chips. Two of the eight input
4027 * multiplexors are used to select from any of the 16 input signals.
4029 * Unsupported hardware capabilities:
4030 * . A video output monitor on the secondary bracket can be selected from
4031 * one of the 878A chips.
4032 * . Another passthrough but I haven't spent any time investigating it.
4033 * . Digital I/O (logic level connected to GPIO) is available from an
4036 * The on chip input mux should always be set to 2.
4037 * GPIO[16:19] - Video input selection
4038 * GPIO[0:3] - Video output monitor select (only available from one 878A)
4039 * GPIO[?:?] - Digital I/O.
4041 * There is an ATMEL microcontroller with an 8031 core on board. I have not
4042 * determined what function (if any) it provides. With the microcontroller
4043 * and sync seperator chips a guess is that it might have to do with video
4044 * switching and maybe some digital I/O.
4046 static void tibetCS16_muxsel(struct bttv *btv, unsigned int input)
4049 gpio_bits(0x0f0000, input << 16);
4052 static void tibetCS16_init(struct bttv *btv)
4054 /* enable gpio bits, mask obtained via btSpy */
4055 gpio_inout(0xffffff, 0x0f7fff);
4056 gpio_write(0x0f7fff);
4060 * The following routines for the Kodicom-4400r get a little mind-twisting.
4061 * There is a "master" controller and three "slave" controllers, together
4062 * an analog switch which connects any of 16 cameras to any of the BT87A's.
4063 * The analog switch is controlled by the "master", but the detection order
4064 * of the four BT878A chips is in an order which I just don't understand.
4065 * The "master" is actually the second controller to be detected. The
4066 * logic on the board uses logical numbers for the 4 controlers, but
4067 * those numbers are different from the detection sequence. When working
4068 * with the analog switch, we need to "map" from the detection sequence
4069 * over to the board's logical controller number. This mapping sequence
4070 * is {3, 0, 2, 1}, i.e. the first controller to be detected is logical
4071 * unit 3, the second (which is the master) is logical unit 0, etc.
4072 * We need to maintain the status of the analog switch (which of the 16
4073 * cameras is connected to which of the 4 controllers). Rather than
4074 * add to the bttv structure for this, we use the data reserved for
4075 * the mbox (unused for this card type).
4079 * First a routine to set the analog switch, which controls which camera
4080 * is routed to which controller. The switch comprises an X-address
4081 * (gpio bits 0-3, representing the camera, ranging from 0-15), and a
4082 * Y-address (gpio bits 4-6, representing the controller, ranging from 0-3).
4083 * A data value (gpio bit 7) of '1' enables the switch, and '0' disables
4084 * the switch. A STROBE bit (gpio bit 8) latches the data value into the
4085 * specified address. The idea is to set the address and data, then bring
4086 * STROBE high, and finally bring STROBE back to low.
4088 static void kodicom4400r_write(struct bttv *btv,
4089 unsigned char xaddr,
4090 unsigned char yaddr,
4091 unsigned char data) {
4094 udata = (data << 7) | ((yaddr&3) << 4) | (xaddr&0xf);
4095 gpio_bits(0x1ff, udata); /* write ADDR and DAT */
4096 gpio_bits(0x1ff, udata | (1 << 8)); /* strobe high */
4097 gpio_bits(0x1ff, udata); /* strobe low */
4101 * Next the mux select. Both the "master" and "slave" 'cards' (controllers)
4102 * use this routine. The routine finds the "master" for the card, maps
4103 * the controller number from the detected position over to the logical
4104 * number, writes the appropriate data to the analog switch, and housekeeps
4105 * the local copy of the switch information. The parameter 'input' is the
4106 * requested camera number (0 - 15).
4108 static void kodicom4400r_muxsel(struct bttv *btv, unsigned int input)
4113 static unsigned char map[4] = {3, 0, 2, 1};
4115 mctlr = master[btv->c.nr];
4116 if (mctlr == NULL) { /* ignore if master not yet detected */
4119 yaddr = (btv->c.nr - mctlr->c.nr + 1) & 3; /* the '&' is for safety */
4121 sw_status = (char *)(&mctlr->mbox_we);
4122 xaddr = input & 0xf;
4123 /* Check if the controller/camera pair has changed, else ignore */
4124 if (sw_status[yaddr] != xaddr)
4126 /* "open" the old switch, "close" the new one, save the new */
4127 kodicom4400r_write(mctlr, sw_status[yaddr], yaddr, 0);
4128 sw_status[yaddr] = xaddr;
4129 kodicom4400r_write(mctlr, xaddr, yaddr, 1);
4134 * During initialisation, we need to reset the analog switch. We
4135 * also preset the switch to map the 4 connectors on the card to the
4136 * *user's* (see above description of kodicom4400r_muxsel) channels
4139 static void kodicom4400r_init(struct bttv *btv)
4141 char *sw_status = (char *)(&btv->mbox_we);
4144 gpio_inout(0x0003ff, 0x0003ff);
4145 gpio_write(1 << 9); /* reset MUX */
4147 /* Preset camera 0 to the 4 controllers */
4148 for (ix=0; ix<4; ix++) {
4150 kodicom4400r_write(btv, ix, ix, 1);
4153 * Since this is the "master", we need to set up the
4154 * other three controller chips' pointers to this structure
4155 * for later use in the muxsel routine.
4157 if ((btv->c.nr<1) || (btv->c.nr>BTTV_MAX-3))
4159 master[btv->c.nr-1] = btv;
4160 master[btv->c.nr] = btv;
4161 master[btv->c.nr+1] = btv;
4162 master[btv->c.nr+2] = btv;
4165 // The Grandtec X-Guard framegrabber card uses two Dual 4-channel
4166 // video multiplexers to provide up to 16 video inputs. These
4167 // multiplexers are controlled by the lower 8 GPIO pins of the
4168 // bt878. The multiplexers probably Pericom PI5V331Q or similar.
4170 // xxx0 is pin xxx of multiplexer U5,
4171 // yyy1 is pin yyy of multiplexer U2
4183 static void xguard_muxsel(struct bttv *btv, unsigned int input)
4185 static const int masks[] = {
4186 ENB0, ENB0|IN00, ENB0|IN10, ENB0|IN00|IN10,
4187 ENA0, ENA0|IN00, ENA0|IN10, ENA0|IN00|IN10,
4188 ENB1, ENB1|IN01, ENB1|IN11, ENB1|IN01|IN11,
4189 ENA1, ENA1|IN01, ENA1|IN11, ENA1|IN01|IN11,
4191 gpio_write(masks[input%16]);
4193 static void picolo_tetra_init(struct bttv *btv)
4195 /*This is the video input redirection fonctionality : I DID NOT USED IT. */
4196 btwrite (0x08<<16,BT848_GPIO_DATA);/*GPIO[19] [==> 4053 B+C] set to 1 */
4197 btwrite (0x04<<16,BT848_GPIO_DATA);/*GPIO[18] [==> 4053 A] set to 1*/
4199 static void picolo_tetra_muxsel (struct bttv* btv, unsigned int input)
4202 dprintk (KERN_DEBUG "bttv%d : picolo_tetra_muxsel => input = %d\n",btv->c.nr,input);
4203 /*Just set the right path in the analog multiplexers : channel 1 -> 4 ==> Analog Mux ==> MUX0*/
4204 /*GPIO[20]&GPIO[21] used to choose the right input*/
4205 btwrite (input<<20,BT848_GPIO_DATA);
4210 * ivc120_muxsel [Added by Alan Garfield <alan@fromorbit.com>]
4212 * The IVC120G security card has 4 i2c controlled TDA8540 matrix
4213 * swichers to provide 16 channels to MUX0. The TDA8540's have
4214 * 4 indepedant outputs and as such the IVC120G also has the
4215 * optional "Monitor Out" bus. This allows the card to be looking
4216 * at one input while the monitor is looking at another.
4218 * Since I've couldn't be bothered figuring out how to add an
4219 * independant muxsel for the monitor bus, I've just set it to
4220 * whatever the card is looking at.
4222 * OUT0 of the TDA8540's is connected to MUX0 (0x03)
4223 * OUT1 of the TDA8540's is connected to "Monitor Out" (0x0C)
4225 * TDA8540_ALT3 IN0-3 = Channel 13 - 16 (0x03)
4226 * TDA8540_ALT4 IN0-3 = Channel 1 - 4 (0x03)
4227 * TDA8540_ALT5 IN0-3 = Channel 5 - 8 (0x03)
4228 * TDA8540_ALT6 IN0-3 = Channel 9 - 12 (0x03)
4232 /* All 7 possible sub-ids for the TDA8540 Matrix Switcher */
4233 #define I2C_TDA8540 0x90
4234 #define I2C_TDA8540_ALT1 0x92
4235 #define I2C_TDA8540_ALT2 0x94
4236 #define I2C_TDA8540_ALT3 0x96
4237 #define I2C_TDA8540_ALT4 0x98
4238 #define I2C_TDA8540_ALT5 0x9a
4239 #define I2C_TDA8540_ALT6 0x9c
4241 static void ivc120_muxsel(struct bttv *btv, unsigned int input)
4244 int key = input % 4;
4245 int matrix = input / 4;
4247 dprintk("bttv%d: ivc120_muxsel: Input - %02d | TDA - %02d | In - %02d\n",
4248 btv->c.nr, input, matrix, key);
4250 // Handles the input selection on the TDA8540's
4251 bttv_I2CWrite(btv, I2C_TDA8540_ALT3, 0x00,
4252 ((matrix == 3) ? (key | key << 2) : 0x00), 1);
4253 bttv_I2CWrite(btv, I2C_TDA8540_ALT4, 0x00,
4254 ((matrix == 0) ? (key | key << 2) : 0x00), 1);
4255 bttv_I2CWrite(btv, I2C_TDA8540_ALT5, 0x00,
4256 ((matrix == 1) ? (key | key << 2) : 0x00), 1);
4257 bttv_I2CWrite(btv, I2C_TDA8540_ALT6, 0x00,
4258 ((matrix == 2) ? (key | key << 2) : 0x00), 1);
4260 // Handles the output enables on the TDA8540's
4261 bttv_I2CWrite(btv, I2C_TDA8540_ALT3, 0x02,
4262 ((matrix == 3) ? 0x03 : 0x00), 1); // 13 - 16
4263 bttv_I2CWrite(btv, I2C_TDA8540_ALT4, 0x02,
4264 ((matrix == 0) ? 0x03 : 0x00), 1); // 1-4
4265 bttv_I2CWrite(btv, I2C_TDA8540_ALT5, 0x02,
4266 ((matrix == 1) ? 0x03 : 0x00), 1); // 5-8
4267 bttv_I2CWrite(btv, I2C_TDA8540_ALT6, 0x02,
4268 ((matrix == 2) ? 0x03 : 0x00), 1); // 9-12
4270 // Selects MUX0 for input on the 878
4271 btaor((0)<<5, ~(3<<5), BT848_IFORM);
4275 /* PXC200 muxsel helper
4276 * luke@syseng.anu.edu.au
4277 * another transplant
4278 * from Alessandro Rubini (rubini@linux.it)
4280 * There are 4 kinds of cards:
4281 * PXC200L which is bt848
4282 * PXC200F which is bt848 with PIC controlling mux
4283 * PXC200AL which is bt878
4284 * PXC200AF which is bt878 with PIC controlling mux
4286 #define PX_CFG_PXC200F 0x01
4287 #define PX_FLAG_PXC200A 0x00001000 /* a pxc200A is bt-878 based */
4288 #define PX_I2C_PIC 0x0f
4289 #define PX_PXC200A_CARDID 0x200a1295
4290 #define PX_I2C_CMD_CFG 0x00
4292 static void PXC200_muxsel(struct bttv *btv, unsigned int input)
4297 unsigned char buf[2];
4299 /* Read PIC config to determine if this is a PXC200F */
4303 rc=bttv_I2CWrite(btv,(PX_I2C_PIC<<1),buf[0],buf[1],1);
4305 printk(KERN_DEBUG "bttv%d: PXC200_muxsel: pic cfg write failed:%d\n", btv->c.nr,rc);
4306 /* not PXC ? do nothing */
4310 rc=bttv_I2CRead(btv,(PX_I2C_PIC<<1),NULL);
4311 if (!(rc & PX_CFG_PXC200F)) {
4312 printk(KERN_DEBUG "bttv%d: PXC200_muxsel: not PXC200F rc:%d \n", btv->c.nr,rc);
4317 /* The multiplexer in the 200F is handled by the GPIO port */
4318 /* get correct mapping between inputs */
4319 /* mux = bttv_tvcards[btv->type].muxsel[input] & 3; */
4320 /* ** not needed!? */
4323 /* make sure output pins are enabled */
4324 /* bitmask=0x30f; */
4326 /* check whether we have a PXC200A */
4327 if (btv->cardid == PX_PXC200A_CARDID) {
4328 bitmask ^= 0x180; /* use 7 and 9, not 8 and 9 */
4329 bitmask |= 7<<4; /* the DAC */
4331 btwrite(bitmask, BT848_GPIO_OUT_EN);
4333 bitmask = btread(BT848_GPIO_DATA);
4334 if (btv->cardid == PX_PXC200A_CARDID)
4335 bitmask = (bitmask & ~0x280) | ((mux & 2) << 8) | ((mux & 1) << 7);
4336 else /* older device */
4337 bitmask = (bitmask & ~0x300) | ((mux & 3) << 8);
4338 btwrite(bitmask,BT848_GPIO_DATA);
4341 * Was "to be safe, set the bt848 to input 0"
4342 * Actually, since it's ok at load time, better not messing
4343 * with these bits (on PXC200AF you need to set mux 2 here)
4345 * needed because bttv-driver sets mux before calling this function
4347 if (btv->cardid == PX_PXC200A_CARDID)
4348 btaor(2<<5, ~BT848_IFORM_MUXSEL, BT848_IFORM);
4349 else /* older device */
4350 btand(~BT848_IFORM_MUXSEL,BT848_IFORM);
4352 printk(KERN_DEBUG "bttv%d: setting input channel to:%d\n", btv->c.nr,(int)mux);
4355 /* ----------------------------------------------------------------------- */
4356 /* motherboard chipset specific stuff */
4358 void __devinit bttv_check_chipset(void)
4360 int pcipci_fail = 0;
4361 struct pci_dev *dev = NULL;
4363 if (pci_pci_problems & PCIPCI_FAIL)
4365 if (pci_pci_problems & (PCIPCI_TRITON|PCIPCI_NATOMA|PCIPCI_VIAETBF))
4367 if (pci_pci_problems & PCIPCI_VSFX)
4369 #ifdef PCIPCI_ALIMAGIK
4370 if (pci_pci_problems & PCIPCI_ALIMAGIK)
4375 /* print which chipset we have */
4376 while ((dev = pci_find_class(PCI_CLASS_BRIDGE_HOST << 8,dev)))
4377 printk(KERN_INFO "bttv: Host bridge is %s\n",pci_name(dev));
4380 /* print warnings about any quirks found */
4382 printk(KERN_INFO "bttv: Host bridge needs ETBF enabled.\n");
4384 printk(KERN_INFO "bttv: Host bridge needs VSFX enabled.\n");
4386 printk(KERN_WARNING "bttv: BT848 and your chipset may not work together.\n");
4387 if (UNSET == no_overlay) {
4388 printk(KERN_WARNING "bttv: going to disable overlay.\n");
4392 if (UNSET != latency)
4393 printk(KERN_INFO "bttv: pci latency fixup [%d]\n",latency);
4395 while ((dev = pci_find_device(PCI_VENDOR_ID_INTEL,
4396 PCI_DEVICE_ID_INTEL_82441, dev))) {
4398 pci_read_config_byte(dev, 0x53, &b);
4400 printk(KERN_INFO "bttv: Host bridge: 82441FX Natoma, "
4401 "bufcon=0x%02x\n",b);
4405 int __devinit bttv_handle_chipset(struct bttv *btv)
4407 unsigned char command;
4409 if (!triton1 && !vsfx && UNSET == latency)
4414 printk(KERN_INFO "bttv%d: enabling ETBF (430FX/VP3 compatibilty)\n",btv->c.nr);
4415 if (vsfx && btv->id >= 878)
4416 printk(KERN_INFO "bttv%d: enabling VSFX\n",btv->c.nr);
4417 if (UNSET != latency)
4418 printk(KERN_INFO "bttv%d: setting pci timer to %d\n",
4422 if (btv->id < 878) {
4423 /* bt848 (mis)uses a bit in the irq mask for etbf */
4425 btv->triton1 = BT848_INT_ETBF;
4427 /* bt878 has a bit in the pci config space for it */
4428 pci_read_config_byte(btv->c.pci, BT878_DEVCTRL, &command);
4430 command |= BT878_EN_TBFX;
4432 command |= BT878_EN_VSFX;
4433 pci_write_config_byte(btv->c.pci, BT878_DEVCTRL, command);
4435 if (UNSET != latency)
4436 pci_write_config_byte(btv->c.pci, PCI_LATENCY_TIMER, latency);