Expand PMF_FN_* macros.
[netbsd-mini2440.git] / sys / dev / pci / bktr / bktr_card.c
blob7070f831c43c5fd9bb8b0e74105b9e3a5e568b83
1 /* $SourceForge: bktr_card.c,v 1.3 2003/03/11 23:11:21 thomasklausner Exp $ */
3 /* $NetBSD: bktr_card.c,v 1.23 2006/11/16 01:33:20 christos Exp $ */
4 /* $FreeBSD: src/sys/dev/bktr/bktr_card.c,v 1.16 2000/10/31 13:09:56 roger Exp$ */
6 /*
7 * This is part of the Driver for Video Capture Cards (Frame grabbers)
8 * and TV Tuner cards using the Brooktree Bt848, Bt848A, Bt849A, Bt878, Bt879
9 * chipset.
10 * Copyright Roger Hardiman and Amancio Hasty.
12 * bktr_card : This deals with identifying TV cards.
13 * trying to find the card make and model of card.
14 * trying to find the type of tuner fitted.
15 * reading the configuration EEPROM.
16 * locating i2c devices.
21 * 1. Redistributions of source code must retain the
22 * Copyright (c) 1997 Amancio Hasty, 1999 Roger Hardiman
23 * All rights reserved.
25 * Redistribution and use in source and binary forms, with or without
26 * modification, are permitted provided that the following conditions
27 * are met:
28 * 1. Redistributions of source code must retain the above copyright
29 * notice, this list of conditions and the following disclaimer.
30 * 2. Redistributions in binary form must reproduce the above copyright
31 * notice, this list of conditions and the following disclaimer in the
32 * documentation and/or other materials provided with the distribution.
33 * 3. All advertising materials mentioning features or use of this software
34 * must display the following acknowledgement:
35 * This product includes software developed by Amancio Hasty and
36 * Roger Hardiman
37 * 4. The name of the author may not be used to endorse or promote products
38 * derived from this software without specific prior written permission.
40 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
41 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
42 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
43 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
44 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
45 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
46 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
48 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
49 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
50 * POSSIBILITY OF SUCH DAMAGE.
53 #include <sys/cdefs.h>
54 __KERNEL_RCSID(0, "$NetBSD: bktr_card.c,v 1.23 2006/11/16 01:33:20 christos Exp $");
56 #include "opt_bktr.h" /* Include any kernel config options */
58 #include <sys/param.h>
59 #include <sys/systm.h>
60 #include <sys/vnode.h>
62 #ifdef __FreeBSD__
64 #if (__FreeBSD_version < 500000)
65 #include <machine/clock.h> /* for DELAY */
66 #endif
68 #include <pci/pcivar.h>
70 #if (__FreeBSD_version >=300000)
71 #include <machine/bus_memio.h> /* for bus space */
72 #include <sys/bus.h>
73 #include <sys/bus.h>
74 #endif
75 #endif
77 #ifdef __NetBSD__
78 #include <dev/ic/bt8xx.h> /* NetBSD location for .h files */
79 #include <dev/pci/bktr/bktr_reg.h>
80 #include <dev/pci/bktr/bktr_core.h>
81 #include <dev/pci/bktr/bktr_tuner.h>
82 #include <dev/pci/bktr/bktr_card.h>
83 #include <dev/pci/bktr/bktr_audio.h>
84 #else
85 #include <machine/ioctl_meteor.h> /* Traditional location for .h files */
86 #include <machine/ioctl_bt848.h> /* extensions to ioctl_meteor.h */
87 #include <dev/bktr/bktr_reg.h>
88 #include <dev/bktr/bktr_core.h>
89 #include <dev/bktr/bktr_tuner.h>
90 #include <dev/bktr/bktr_card.h>
91 #include <dev/bktr/bktr_audio.h>
92 #endif
94 /* Include the PCI Vendor definitions */
95 #ifdef __NetBSD__
96 #include <dev/pci/pcidevs.h>
97 #include <dev/pci/pcireg.h>
98 #endif
100 /* Various defines */
101 #define HAUP_REMOTE_INT_WADDR 0x30
102 #define HAUP_REMOTE_INT_RADDR 0x31
104 #define HAUP_REMOTE_EXT_WADDR 0x34
105 #define HAUP_REMOTE_EXT_RADDR 0x35
107 /* address of BTSC/SAP decoder chip */
108 #define TDA9850_WADDR 0xb6
109 #define TDA9850_RADDR 0xb7
111 /* address of MSP3400C chip */
112 #define MSP3400C_WADDR 0x80
113 #define MSP3400C_RADDR 0x81
115 /* address of DPL3518A chip */
116 #define DPL3518A_WADDR 0x84
117 #define DPL3518A_RADDR 0x85
119 /* EEProm (128 * 8) on an STB card */
120 #define X24C01_WADDR 0xae
121 #define X24C01_RADDR 0xaf
124 /* EEProm (256 * 8) on a Hauppauge card */
125 /* and on most BT878s cards to store the sub-system vendor id */
126 #define PFC8582_WADDR 0xa0
127 #define PFC8582_RADDR 0xa1
129 #if BKTR_SYSTEM_DEFAULT == BROOKTREE_PAL
130 #define DEFAULT_TUNER PHILIPS_PALI
131 #else
132 #define DEFAULT_TUNER PHILIPS_NTSC
133 #endif
139 * the data for each type of card
141 * Note:
142 * these entried MUST be kept in the order defined by the CARD_XXX defines!
144 static const struct CARDTYPE cards[] = {
146 { CARD_UNKNOWN, /* the card id */
147 "Unknown", /* the 'name' */
148 NULL, /* the tuner */
149 0, /* the tuner i2c address */
150 0, /* dbx unknown */
153 0, /* EEProm unknown */
154 0, /* EEProm unknown */
155 { 0, 0, 0, 0, 0 },
156 0 }, /* GPIO mask */
158 { CARD_MIRO, /* the card id */
159 "Pinnacle/Miro TV", /* the 'name' */
160 NULL, /* the tuner */
161 0, /* the tuner i2c address */
162 0, /* dbx unknown */
165 0, /* EEProm unknown */
166 0, /* size unknown */
167 { 0x02, 0x01, 0x00, 0x0a, 1 }, /* audio MUX values */
168 0x0f }, /* GPIO mask */
170 { CARD_HAUPPAUGE, /* the card id */
171 "Hauppauge WinCast/TV", /* the 'name' */
172 NULL, /* the tuner */
173 0, /* the tuner i2c address */
174 0, /* dbx is optional */
177 PFC8582_WADDR, /* EEProm type */
178 (u_char)(256 / EEPROMBLOCKSIZE), /* 256 bytes */
179 { 0x00, 0x02, 0x01, 0x04, 1 }, /* audio MUX values */
180 0x0f }, /* GPIO mask */
182 { CARD_STB, /* the card id */
183 "STB TV/PCI", /* the 'name' */
184 NULL, /* the tuner */
185 0, /* the tuner i2c address */
186 0, /* dbx is optional */
189 X24C01_WADDR, /* EEProm type */
190 (u_char)(128 / EEPROMBLOCKSIZE), /* 128 bytes */
191 { 0x00, 0x01, 0x02, 0x02, 1 }, /* audio MUX values */
192 0x0f }, /* GPIO mask */
194 { CARD_INTEL, /* the card id */
195 "Intel Smart Video III/VideoLogic Captivator PCI", /* the 'name' */
196 NULL, /* the tuner */
197 0, /* the tuner i2c address */
203 { 0, 0, 0, 0, 0 }, /* audio MUX values */
204 0x00 }, /* GPIO mask */
206 { CARD_IMS_TURBO, /* the card id */
207 "IMS TV Turbo", /* the 'name' */
208 NULL, /* the tuner */
209 0, /* the tuner i2c address */
210 0, /* dbx is optional */
213 PFC8582_WADDR, /* EEProm type */
214 (u_char)(256 / EEPROMBLOCKSIZE), /* 256 bytes */
215 { 0x01, 0x02, 0x01, 0x00, 1 }, /* audio MUX values */
216 0x0f }, /* GPIO mask */
218 { CARD_AVER_MEDIA, /* the card id */
219 "AVer Media TV/FM", /* the 'name' */
220 NULL, /* the tuner */
221 0, /* the tuner i2c address */
222 0, /* dbx is optional */
225 0, /* EEProm type */
226 0, /* EEProm size */
227 { 0x0c, 0x08, 0x04, 0x00, 1 }, /* audio MUX values */
228 0x1f }, /* GPIO mask */
230 { CARD_OSPREY, /* the card id */
231 "MMAC Osprey", /* the 'name' */
232 NULL, /* the tuner */
233 0, /* the tuner i2c address */
234 0, /* dbx is optional */
237 PFC8582_WADDR, /* EEProm type */
238 (u_char)(256 / EEPROMBLOCKSIZE), /* 256 bytes */
239 { 0x00, 0x00, 0x00, 0x00, 0 }, /* audio MUX values */
240 0 }, /* GPIO mask */
242 { CARD_NEC_PK, /* the card id */
243 "NEC PK-UG-X017", /* the 'name' */
244 NULL, /* the tuner */
245 0, /* the tuner i2c address */
246 0, /* dbx is optional */
249 0, /* EEProm type */
250 0, /* EEProm size */
251 { 0x01, 0x02, 0x01, 0x00, 1 }, /* audio MUX values */
252 0x0f }, /* GPIO mask */
254 { CARD_IO_GV, /* the card id */
255 "I/O DATA GV-BCTV2/PCI", /* the 'name' */
256 NULL, /* the tuner */
257 0, /* the tuner i2c address */
258 0, /* dbx is optional */
261 0, /* EEProm type */
262 0, /* EEProm size */
263 { 0x00, 0x00, 0x00, 0x00, 1 }, /* Has special MUX handler */
264 0x0f }, /* GPIO mask */
266 { CARD_FLYVIDEO, /* the card id */
267 "FlyVideo", /* the 'name' */
268 NULL, /* the tuner */
269 0, /* the tuner i2c address */
270 0, /* dbx is optional */
271 0, /* msp34xx is optional */
272 0, /* dpl3518a is optional */
273 0xac, /* EEProm type */
274 (u_char)(256 / EEPROMBLOCKSIZE), /* 256 bytes */
275 { 0x000, 0x800, 0x400, 0x8dff00, 1 },/* audio MUX values */
276 0x8dff00 }, /* GPIO mask */
278 { CARD_ZOLTRIX, /* the card id */
279 "Zoltrix", /* the 'name' */
280 NULL, /* the tuner */
281 0, /* the tuner i2c address */
282 0, /* dbx is optional */
283 0, /* msp34xx is optional */
284 0, /* dpl3518a is optional */
285 0, /* EEProm type */
286 0, /* EEProm size */
287 { 0x04, 0x01, 0x00, 0x0a, 1 }, /* audio MUX values */
288 0x0f }, /* GPIO mask */
290 { CARD_KISS, /* the card id */
291 "KISS TV/FM PCI", /* the 'name' */
292 NULL, /* the tuner */
293 0, /* the tuner i2c address */
294 0, /* dbx is optional */
295 0, /* msp34xx is optional */
296 0, /* dpl3518a is optional */
297 0, /* EEProm type */
298 0, /* EEProm size */
299 { 0x0c, 0x00, 0x0b, 0x0b, 1 }, /* audio MUX values */
300 0x0f }, /* GPIO mask */
302 { CARD_VIDEO_HIGHWAY_XTREME, /* the card id */
303 "Video Highway Xtreme", /* the 'name' */
304 NULL, /* the tuner */
309 0, /* EEProm type */
310 0, /* EEProm size */
311 { 0x00, 0x02, 0x01, 0x04, 1 }, /* audio MUX values */
312 0x0f }, /* GPIO mask */
314 { CARD_ASKEY_DYNALINK_MAGIC_TVIEW, /* the card id */
315 "Askey/Dynalink Magic TView", /* the 'name' */
316 NULL, /* the tuner */
321 0, /* EEProm type */
322 0, /* EEProm size */
323 { 0x400, 0xE00, 0x400, 0xC00, 1 }, /* audio MUX values */
324 0xE00 }, /* GPIO mask */
326 { CARD_LEADTEK, /* the card id */
327 "Leadtek WinFast TV2000/VC100", /* the 'name' */
328 NULL, /* the tuner */
333 0, /* EEProm type */
334 0, /* EEProm size */
335 /* Tuner, Extern, Intern, Mute, Enabled */
336 { 0x621000, 0x621000, 0x621000, 0xE21000, 1 }, /* audio MUX values */
337 0xfff000 }, /* GPIO mask */
339 { CARD_TERRATVPLUS, /* the card id */
340 "TerraTVplus", /* the 'name' */
341 NULL, /* the tuner */
346 0, /* EEProm type */
347 0, /* EEProm size */
348 { 0x20000, 0x00000, 0x30000, 0x40000, 1 }, /* audio MUX values*/
349 0x70000 }, /* GPIO mask */
351 { CARD_TERRATVALUE, /* the card id */
352 "Terratec TValue", /* the 'name' */
353 NULL, /* the tuner */
358 0, /* EEProm type */
359 0, /* EEProm size */
360 { 0x500, 0x900, 0x300, 0x900, 1 }, /* audio MUX values*/
361 0xffff00 }, /* GPIO mask */
365 struct bt848_card_sig bt848_card_signature[1]= {
366 /* IMS TURBO TV : card 5 */
367 { 5,9, {00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 02, 00, 00, 00}}
374 * Write to the configuration EEPROM on the card.
375 * This is dangerous and will mess up your card. Therefore it is not
376 * implemented.
379 writeEEProm(bktr_ptr_t bktr, int offset, int count,
380 u_char *data)
382 return(-1);
386 * Read the contents of the configuration EEPROM on the card.
387 * (This is not fitted to all makes of card. All Hauppauge cards have them
388 * and so do newer Bt878 based cards.
391 readEEProm(bktr_ptr_t bktr, int offset, int count, u_char *data)
393 int x;
394 int addr;
395 int xmax;
396 int byte;
398 /* get the address of the EEProm */
399 addr = (int)(bktr->card.eepromAddr & 0xff);
400 if (addr == 0)
401 return(-1);
403 xmax = (int)(bktr->card.eepromSize * EEPROMBLOCKSIZE);
404 if ((offset + count) > xmax)
405 return(-1);
407 /* set the start address */
408 if (i2cWrite(bktr, addr, offset, -1) == -1)
409 return(-1);
411 /* the read cycle */
412 for (x = 0; x < count; ++x) {
413 if ((byte = i2cRead(bktr, (addr | 1))) == -1)
414 return(-1);
415 data[x] = byte;
418 return(0);
422 #define ABSENT (-1)
425 * get a signature of the card
426 * read all 128 possible i2c read addresses from 0x01 thru 0xff
427 * build a bit array with a 1 bit for each i2c device that responds
429 * XXX FIXME: use offset & count args
432 signCard(bktr_ptr_t bktr, int offset, int count, u_char* sig)
434 int x;
436 for (x = 0; x < 16; ++x)
437 sig[x] = 0;
439 for (x = 0; x < count; ++x) {
440 if (i2cRead(bktr, (2 * x) + 1) != ABSENT) {
441 sig[x / 8] |= (1 << (x % 8));
445 return(0);
450 * check_for_i2c_devices.
451 * Some BT848 cards have no tuner and no additional i2c devices
452 * eg stereo decoder. These are used for video conferencing or capture from
453 * a video camera. (eg VideoLogic Captivator PCI, Intel SmartCapture card).
455 * Determine if there are any i2c devices present. There are none present if
456 * a) reading from all 128 devices returns ABSENT (-1) for each one
457 * (eg VideoLogic Captivator PCI with BT848)
458 * b) reading from all 128 devices returns 0 for each one
459 * (eg VideoLogic Captivator PCI rev. 2F with BT848A)
461 static int check_for_i2c_devices(bktr_ptr_t bktr) {
462 int x, temp_read;
463 int i2c_all_0 = 1;
464 int i2c_all_absent = 1;
465 for (x = 0; x < 128; ++x) {
466 temp_read = i2cRead(bktr, (2 * x) + 1);
467 if (temp_read != 0) i2c_all_0 = 0;
468 if (temp_read != ABSENT) i2c_all_absent = 0;
471 if ((i2c_all_0) || (i2c_all_absent)) return 0;
472 else return 1;
477 * Temic/Philips datasheets say tuners can be at i2c addresses 0xc0, 0xc2,
478 * 0xc4 or 0xc6, settable by links on the tuner.
479 * Determine the actual address used on the TV card by probing read addresses.
481 static int locate_tuner_address(bktr_ptr_t bktr) {
482 if (i2cRead(bktr, 0xc1) != ABSENT) return 0xc0;
483 if (i2cRead(bktr, 0xc3) != ABSENT) return 0xc2;
484 if (i2cRead(bktr, 0xc5) != ABSENT) return 0xc4;
485 if (i2cRead(bktr, 0xc7) != ABSENT) return 0xc6;
486 return -1; /* no tuner found */
491 * Search for a configuration EEPROM on the i2c bus by looking at i2c addresses
492 * where EEPROMs are usually found.
493 * On some cards, the EEPROM appears in several locations, but all in the
494 * range 0xa0 to 0xae.
496 static int locate_eeprom_address(bktr_ptr_t bktr) {
497 if (i2cRead(bktr, 0xa0) != ABSENT) return 0xa0;
498 if (i2cRead(bktr, 0xac) != ABSENT) return 0xac;
499 if (i2cRead(bktr, 0xae) != ABSENT) return 0xae;
500 return -1; /* no eeprom found */
505 * determine the card brand/model
506 * BKTR_OVERRIDE_CARD, BKTR_OVERRIDE_TUNER, BKTR_OVERRIDE_DBX and
507 * BKTR_OVERRIDE_MSP can be used to select a specific device,
508 * regardless of the autodetection and i2c device checks.
510 * The scheme used for probing cards faces these problems:
511 * It is impossible to work out which type of tuner is actually fitted,
512 * (the driver cannot tell if the Tuner is PAL or NTSC, Temic or Philips)
513 * It is impossible to determine what audio-mux hardware is connected.
514 * It is impossible to determine if there is extra hardware connected to the
515 * GPIO pins (eg radio chips or MSP34xx reset logic)
517 * However some makes of card (eg Hauppauge) come with a configuration eeprom
518 * which tells us the make of the card. Most eeproms also tell us the
519 * tuner type and other features of the cards.
521 * The current probe code works as follows
522 * A) If the card uses a Bt878/879:
523 * 1) Read the sub-system vendor id from the configuration EEPROM.
524 * Select the required tuner, audio mux arrangement and any other
525 * onboard features. If this fails, move to step B.
526 * B) If it card uses a Bt848, 848A, 849A or an unknown Bt878/879:
527 * 1) Look for I2C devices. If there are none fitted, it is an Intel or
528 * VideoLogic cards.
529 * 2) Look for a configuration EEPROM.
530 * 2a) If there is one at I2C address 0xa0 it may be
531 * a Hauppauge or an Osprey. Check the EEPROM contents to determine which
532 * one it is. For Hauppauge, select the tuner type and audio hardware.
533 * 2b) If there is an EEPROM at I2C address 0xa8 it will be an STB card.
534 * We still have to guess on the tuner type.
536 * C) If we do not know the card type from (A) or (B), guess at the tuner
537 * type based on the I2C address of the tuner.
539 * D) After determining the Tuner Type, we probe the i2c bus for other
540 * devices at known locations, eg IR-Remote Control, MSP34xx and TDA
541 * stereo chips.
546 * These are the sub-system vendor ID codes stored in the
547 * configuration EEPROM used on Bt878/879 cards. They should match the
548 * number assigned to the company by the PCI Special Interest Group
550 #ifndef __NetBSD__
551 #define PCI_VENDOR_HAUPPAUGE 0x0070
552 #define PCI_VENDOR_AVERMEDIA 0x1461
553 #define PCI_VENDOR_STB 0x10B4
554 #define PCI_VENDOR_ASKEY 0x144F
555 #define PCI_VENDOR_TERRATEC 0x153B
556 #endif
557 /* Following not confirmed with http://www.pcidatabase.com/,
558 so not added to NetBSD's pcidevs */
559 #define PCI_VENDOR_LEADTEK_ALT 0x6606
560 #define PCI_VENDOR_LEADTEK_ALT_2 0x6607
561 #define PCI_VENDOR_LEADTEK_ALT_3 0x107D
562 #define PCI_VENDOR_FLYVIDEO 0x1851
563 #define PCI_VENDOR_FLYVIDEO_2 0x1852
564 #define PCI_VENDOR_PINNACLE_ALT 0xBD11
566 #define MODEL_TERRATVALUE_1118 0x1118
567 #define MODEL_TERRATVALUE_1134 0x1134
569 void
570 probeCard(bktr_ptr_t bktr, int verbose, int unit)
572 int card, i,j, card_found;
573 int status;
574 u_char probe_signature[128], *probe_temp;
575 int any_i2c_devices;
576 u_char eeprom[256];
577 int tuner_i2c_address = -1;
578 int eeprom_i2c_address = -1;
580 /* Select all GPIO bits as inputs */
581 OUTL(bktr, BKTR_GPIO_OUT_EN, 0);
582 if (bootverbose)
583 printf("%s: GPIO is 0x%08x\n", bktr_name(bktr),
584 INL(bktr, BKTR_GPIO_DATA));
586 #ifdef HAUPPAUGE_MSP_RESET
587 /* Reset the MSP34xx audio chip. This resolves bootup card
588 * detection problems with old Bt848 based Hauppauge cards with
589 * MSP34xx stereo audio chips. This must be user enabled because
590 * at this point the probe function does not know the card type. */
591 OUTL(bktr, BKTR_GPIO_OUT_EN, INL(bktr, BKTR_GPIO_OUT_EN) | (1<<5));
592 OUTL(bktr, BKTR_GPIO_DATA, INL(bktr, BKTR_GPIO_DATA) | (1<<5)); /* write '1' */
593 DELAY(2500); /* wait 2.5ms */
594 OUTL(bktr, BKTR_GPIO_DATA, INL(bktr, BKTR_GPIO_DATA) & ~(1<<5)); /* write '0' */
595 DELAY(2500); /* wait 2.5ms */
596 OUTL(bktr, BKTR_GPIO_DATA, INL(bktr, BKTR_GPIO_DATA) | (1<<5)); /* write '1' */
597 DELAY(2500); /* wait 2.5ms */
598 #endif
600 /* Check for the presence of i2c devices */
601 any_i2c_devices = check_for_i2c_devices(bktr);
604 /* Check for a user specified override on the card selection */
605 #if defined(BKTR_OVERRIDE_CARD)
606 bktr->card = cards[(card = BKTR_OVERRIDE_CARD)];
607 goto checkEEPROM;
608 #endif
609 if (bktr->bt848_card != -1) {
610 bktr->card = cards[(card = bktr->bt848_card)];
611 goto checkEEPROM;
615 /* No override, so try and determine the make of the card */
617 /* On BT878/879 cards, read the sub-system vendor id */
618 /* This identifies the manufacturer of the card and the model */
619 /* In theory this can be read from PCI registers but this does not */
620 /* appear to work on the FlyVideo 98. Hauppauge also warned that */
621 /* the PCI registers are sometimes not loaded correctly. */
622 /* Therefore, I will read the sub-system vendor ID from the EEPROM */
623 /* (just like the Bt878 does during power up initialisation) */
625 if ((bktr->id==BROOKTREE_878) || (bktr->id==BROOKTREE_879)) {
626 /* Try and locate the EEPROM */
627 eeprom_i2c_address = locate_eeprom_address(bktr);
628 if (eeprom_i2c_address != -1) {
630 unsigned int subsystem_vendor_id; /* vendors PCI-SIG ID */
631 unsigned int subsystem_id; /* board model number */
632 unsigned int byte_252, byte_253, byte_254, byte_255;
634 bktr->card = cards[(card = CARD_UNKNOWN)];
635 bktr->card.eepromAddr = eeprom_i2c_address;
636 bktr->card.eepromSize = (u_char)(256 / EEPROMBLOCKSIZE);
638 if(readEEProm(bktr, 0, 256, (u_char *) &eeprom))
639 printf("%s: error reading EEPROM\n", bktr_name(bktr));
641 byte_252 = (unsigned int)eeprom[252];
642 byte_253 = (unsigned int)eeprom[253];
643 byte_254 = (unsigned int)eeprom[254];
644 byte_255 = (unsigned int)eeprom[255];
646 subsystem_id = (byte_252 << 8) | byte_253;
647 subsystem_vendor_id = (byte_254 << 8) | byte_255;
649 if (bootverbose)
650 printf("%s: subsystem 0x%04x 0x%04x\n", bktr_name(bktr),
651 subsystem_vendor_id, subsystem_id);
653 if (subsystem_vendor_id == PCI_VENDOR_AVERMEDIA) {
654 bktr->card = cards[(card = CARD_AVER_MEDIA)];
655 bktr->card.eepromAddr = eeprom_i2c_address;
656 bktr->card.eepromSize = (u_char)(256 / EEPROMBLOCKSIZE);
657 goto checkTuner;
660 if (subsystem_vendor_id == PCI_VENDOR_HAUPPAUGE) {
661 bktr->card = cards[(card = CARD_HAUPPAUGE)];
662 bktr->card.eepromAddr = eeprom_i2c_address;
663 bktr->card.eepromSize = (u_char)(256 / EEPROMBLOCKSIZE);
664 goto checkTuner;
667 if ((subsystem_vendor_id == PCI_VENDOR_FLYVIDEO)
668 || (subsystem_vendor_id == PCI_VENDOR_FLYVIDEO_2)) {
669 bktr->card = cards[(card = CARD_FLYVIDEO)];
670 bktr->card.eepromAddr = eeprom_i2c_address;
671 bktr->card.eepromSize = (u_char)(256 / EEPROMBLOCKSIZE);
672 goto checkTuner;
675 if (subsystem_vendor_id == PCI_VENDOR_STB) {
676 bktr->card = cards[(card = CARD_STB)];
677 bktr->card.eepromAddr = eeprom_i2c_address;
678 bktr->card.eepromSize = (u_char)(256 / EEPROMBLOCKSIZE);
679 goto checkTuner;
682 if (subsystem_vendor_id == PCI_VENDOR_ASKEY) {
683 bktr->card = cards[(card = CARD_ASKEY_DYNALINK_MAGIC_TVIEW)];
684 bktr->card.eepromAddr = eeprom_i2c_address;
685 bktr->card.eepromSize = (u_char)(256 / EEPROMBLOCKSIZE);
686 goto checkTuner;
689 if ((subsystem_vendor_id == PCI_VENDOR_LEADTEK)
690 || (subsystem_vendor_id == PCI_VENDOR_LEADTEK_ALT)
691 || (subsystem_vendor_id == PCI_VENDOR_LEADTEK_ALT_2)
692 || (subsystem_vendor_id == PCI_VENDOR_LEADTEK_ALT_3)) {
693 bktr->card = cards[(card = CARD_LEADTEK)];
694 bktr->card.eepromAddr = eeprom_i2c_address;
695 bktr->card.eepromSize = (u_char)(256 / EEPROMBLOCKSIZE);
696 goto checkTuner;
699 if (subsystem_vendor_id == PCI_VENDOR_PINNACLE_ALT) {
700 bktr->card = cards[(card = CARD_MIRO)];
701 bktr->card.eepromAddr = eeprom_i2c_address;
702 bktr->card.eepromSize = (u_char)(256 / EEPROMBLOCKSIZE);
703 goto checkTuner;
706 if (subsystem_vendor_id == PCI_VENDOR_TERRATEC
707 && (subsystem_id == MODEL_TERRATVALUE_1118
708 || subsystem_id == MODEL_TERRATVALUE_1134)) {
709 bktr->card = cards[(card = CARD_TERRATVALUE)];
710 bktr->card.eepromAddr = eeprom_i2c_address;
711 bktr->card.eepromSize = (u_char)(256 / EEPROMBLOCKSIZE);
712 goto checkTuner;
715 if (subsystem_vendor_id == PCI_VENDOR_TERRATEC) {
716 bktr->card = cards[(card = CARD_TERRATVPLUS)];
717 bktr->card.eepromAddr = eeprom_i2c_address;
718 bktr->card.eepromSize = (u_char)(256 / EEPROMBLOCKSIZE);
719 goto checkTuner;
722 /* Vendor is unknown. We will use the standard probe code */
723 /* which may not give best results */
724 printf("%s: Warning - card vendor 0x%04x (model 0x%04x) unknown.\n",
725 bktr_name(bktr), subsystem_vendor_id, subsystem_id);
727 else
729 printf("%s: Card has no configuration EEPROM. Cannot determine card make.\n",
730 bktr_name(bktr));
732 } /* end of bt878/bt879 card detection code */
734 /* If we get to this point, we must have a Bt848/848A/849A card */
735 /* or a Bt878/879 with an unknown subsystem vendor id */
736 /* Try and determine the make of card by clever i2c probing */
738 /* Check for i2c devices. If none, move on */
739 if (!any_i2c_devices) {
740 bktr->card = cards[(card = CARD_INTEL)];
741 bktr->card.eepromAddr = 0;
742 bktr->card.eepromSize = 0;
743 goto checkTuner;
746 /* Look for Hauppauge, STB and Osprey cards by the presence */
747 /* of an EEPROM */
748 /* Note: Bt878 based cards also use EEPROMs so we can only do this */
749 /* test on BT848/848A and 849A based cards. */
750 if ((bktr->id==BROOKTREE_848) ||
751 (bktr->id==BROOKTREE_848A) ||
752 (bktr->id==BROOKTREE_849A)) {
754 /* At i2c address 0xa0, look for Hauppauge and Osprey cards */
755 if ((status = i2cRead(bktr, PFC8582_RADDR)) != ABSENT) {
757 /* Read the eeprom contents */
758 bktr->card = cards[(card = CARD_UNKNOWN)];
759 bktr->card.eepromAddr = PFC8582_WADDR;
760 bktr->card.eepromSize = (u_char)(256 / EEPROMBLOCKSIZE);
761 readEEProm(bktr, 0, 128, (u_char *) &eeprom);
763 /* For Hauppauge, check the EEPROM begins with 0x84 */
764 if (eeprom[0] == 0x84) {
765 bktr->card = cards[(card = CARD_HAUPPAUGE)];
766 bktr->card.eepromAddr = PFC8582_WADDR;
767 bktr->card.eepromSize = (u_char)(256 / EEPROMBLOCKSIZE);
768 goto checkTuner;
771 /* For Osprey, check the EEPROM begins with "MMAC" */
772 if ((eeprom[0] == 'M') &&(eeprom[1] == 'M')
773 &&(eeprom[2] == 'A') &&(eeprom[3] == 'C')) {
774 bktr->card = cards[(card = CARD_OSPREY)];
775 bktr->card.eepromAddr = PFC8582_WADDR;
776 bktr->card.eepromSize = (u_char)(256 / EEPROMBLOCKSIZE);
777 goto checkTuner;
779 printf("%s: Warning: Unknown card type. EEPROM data not recognised\n",
780 bktr_name(bktr));
781 printf("%s: %x %x %x %x\n", bktr_name(bktr),
782 eeprom[0],eeprom[1],eeprom[2],eeprom[3]);
785 /* look for an STB card */
786 if ((status = i2cRead(bktr, X24C01_RADDR)) != ABSENT) {
787 bktr->card = cards[(card = CARD_STB)];
788 bktr->card.eepromAddr = X24C01_WADDR;
789 bktr->card.eepromSize = (u_char)(128 / EEPROMBLOCKSIZE);
790 goto checkTuner;
795 signCard(bktr, 1, 128, (u_char *) &probe_signature);
797 if (bootverbose) {
798 printf("%s: card signature: ", bktr_name(bktr));
799 for (j = 0; j < Bt848_MAX_SIGN; j++) {
800 printf(" %02x ", probe_signature[j]);
802 printf("\n\n");
804 for (i = 0;
805 i < (sizeof bt848_card_signature)/ sizeof (struct bt848_card_sig);
806 i++) {
808 card_found = 1;
809 probe_temp = (u_char *) &bt848_card_signature[i].signature;
811 for (j = 0; j < Bt848_MAX_SIGN; j++) {
812 if ((probe_temp[j] & 0xf) != (probe_signature[j] & 0xf)) {
813 card_found = 0;
814 break;
818 if (card_found) {
819 bktr->card = cards[card = bt848_card_signature[i].card];
820 eeprom_i2c_address = locate_eeprom_address(bktr);
821 if (eeprom_i2c_address != -1) {
822 bktr->card.eepromAddr = eeprom_i2c_address;
823 bktr->card.eepromSize = (u_char)(256 / EEPROMBLOCKSIZE);
824 } else {
825 bktr->card.eepromAddr = 0;
826 bktr->card.eepromSize = 0;
828 tuner_i2c_address = locate_tuner_address(bktr);
829 select_tuner(bktr, bt848_card_signature[i].tuner);
830 goto checkDBX;
834 /* We do not know the card type. Default to Miro */
835 bktr->card = cards[(card = CARD_MIRO)];
838 checkEEPROM:
839 /* look for a configuration eeprom */
840 eeprom_i2c_address = locate_eeprom_address(bktr);
841 if (eeprom_i2c_address != -1) {
842 bktr->card.eepromAddr = eeprom_i2c_address;
843 bktr->card.eepromSize = (u_char)(256 / EEPROMBLOCKSIZE);
844 } else {
845 bktr->card.eepromAddr = 0;
846 bktr->card.eepromSize = 0;
850 checkTuner:
852 /* look for a tuner */
853 tuner_i2c_address = locate_tuner_address(bktr);
854 if (tuner_i2c_address == -1) {
855 select_tuner(bktr, NO_TUNER);
856 goto checkDBX;
859 #if defined(BKTR_OVERRIDE_TUNER)
860 select_tuner(bktr, BKTR_OVERRIDE_TUNER);
861 goto checkDBX;
862 #endif
863 if (bktr->bt848_tuner != -1) {
864 select_tuner(bktr, bktr->bt848_tuner & 0xff);
865 goto checkDBX;
868 /* Check for i2c devices */
869 if (!any_i2c_devices) {
870 select_tuner(bktr, NO_TUNER);
871 goto checkDBX;
874 /* differentiate type of tuner */
876 switch (card) {
877 case CARD_MIRO:
878 switch (((INL(bktr, BKTR_GPIO_DATA) >> 10)-1)&7) {
879 case 0: select_tuner(bktr, TEMIC_PAL); break;
880 case 1: select_tuner(bktr, PHILIPS_PAL); break;
881 case 2: select_tuner(bktr, PHILIPS_NTSC); break;
882 case 3: select_tuner(bktr, PHILIPS_SECAM); break;
883 case 4: select_tuner(bktr, NO_TUNER); break;
884 case 5: select_tuner(bktr, PHILIPS_PALI); break;
885 case 6: select_tuner(bktr, TEMIC_NTSC); break;
886 case 7: select_tuner(bktr, TEMIC_PALI); break;
888 goto checkDBX;
889 break;
891 case CARD_HAUPPAUGE:
892 /* Hauppauge kindly supplied the following Tuner Table */
893 /* FIXME: I think the tuners the driver selects for types */
894 /* 0x08 and 0x15 may be incorrect but no one has complained. */
895 /* Old Temic tuners had their own API, but newer Temic tuners */
896 /* have the same API as Philips tuners */
898 ID Tuner Model Format We select Format
899 0x00 NONE
900 0x01 EXTERNAL
901 0x02 OTHER
902 0x03 Philips FI1216 BG
903 0x04 Philips FI1216MF BGLL' PHILIPS_SECAM
904 0x05 Philips FI1236 MN PHILIPS_NTSC
905 0x06 Philips FI1246 I PHILIPS_PALI
906 0x07 Philips FI1256 DK
907 0x08 Philips FI1216 MK2 BG PHILIPS_PALI
908 0x09 Philips FI1216MF MK2 BGLL' PHILIPS_SECAM
909 0x0a Philips FI1236 MK2 MN PHILIPS_NTSC
910 0x0b Philips FI1246 MK2 I PHILIPS_PALI
911 0x0c Philips FI1256 MK2 DK
912 0x0d Temic 4032FY5 NTSC TEMIC_NTSC
913 0x0e Temic 4002FH5 BG TEMIC_PAL
914 0x0f Temic 4062FY5 I TEMIC_PALI
915 0x10 Philips FR1216 MK2 BG
916 0x11 Philips FR1216MF MK2 BGLL' PHILIPS_FR1236_SECAM
917 0x12 Philips FR1236 MK2 MN PHILIPS_FR1236_NTSC
918 0x13 Philips FR1246 MK2 I
919 0x14 Philips FR1256 MK2 DK
920 0x15 Philips FM1216 BG PHILIPS_FR1216_PAL
921 0x16 Philips FM1216MF BGLL' PHILIPS_FR1236_SECAM
922 0x17 Philips FM1236 MN PHILIPS_FR1236_NTSC
923 0x18 Philips FM1246 I
924 0x19 Philips FM1256 DK
925 0x1a Temic 4036FY5 MN (FI1236 MK2 clone) PHILIPS_NTSC
926 0x1b Samsung TCPN9082D MN
927 0x1c Samsung TCPM9092P Pal BG/I/DK
928 0x1d Temic 4006FH5 BG PHILIPS_PALI
929 0x1e Samsung TCPN9085D MN/Radio
930 0x1f Samsung TCPB9085P Pal BG/I/DK / Radio
931 0x20 Samsung TCPL9091P Pal BG & Secam L/L'
932 0x21 Temic 4039FY5 NTSC Radio
933 0x22 Philips FQ1216ME Pal BGIDK & Secam L/L'
934 0x23 Temic 4066FY5 Pal I (FI1246 MK2 clone) PHILIPS_PALI
935 0x24 Philips TD1536 MN/ATSCDigital
936 0x25 Philips TD1536D MN/ATSCDigital DUAL INPUT
937 0x26 Philips FMR1236 M/N FM(no demod)
938 0x27 Philips FI1256MP B/G, D/K
939 0x28 Samsung TCPQ9091P BG/I/DK, L/L'
940 0x29 Temic 4006FN5 BG/I/DK
941 0x2a Temic 4009FR5 BG FM PHILIPS_FR1216_PAL
942 0x2b Temic 4046FM5 B/G, I, D/K, L/L'
943 0x2c Temic 4009FN5 B/G, I, D/K, FM (no demod)
944 0x2d Philips TD1536D_FH_44 MN/ATSCDigital DUAL INPUT
948 /* Determine the model number from the eeprom */
949 if (bktr->card.eepromAddr != 0) {
950 /* eeprom data block structure */
951 unsigned char *block_1, *block_2, *block_3;
952 int block_1_data_size, block_2_data_size, block_3_data_size;
953 int block_1_total_size, block_2_total_size, block_3_total_size;
955 unsigned int model,revision;
956 unsigned char tuner_code;
957 unsigned char no_audio_mux;
959 readEEProm(bktr, 0, 128, (u_char *) &eeprom);
961 /* LOCATE THE EEPROM DATA BLOCKS */
962 block_1 = &eeprom[0];
963 block_1_data_size = (block_1[2] << 8 | block_1[1]);
964 block_1_total_size = block_1_data_size + 3; /* Header bytes */
966 block_2 = &eeprom[block_1_total_size];
967 block_2_data_size = (block_2[2] << 8 | block_2[1]);
968 block_2_total_size = block_2_data_size + 3; /* Header bytes */
970 block_3 = &eeprom[block_1_total_size + block_2_total_size];
971 block_3_data_size = (block_3[0] &0x07);
972 block_3_total_size = block_3_data_size + 1; /* Header size */
974 model = (block_1[12] << 8 | block_1[11]);
975 revision = (block_1[15] << 16 | block_1[14] << 8 | block_1[13]);
977 tuner_code = block_1[9];
979 no_audio_mux = ((block_3[3] >> 7) &0x01);
981 if (no_audio_mux) bktr->audio_mux_present = 0;
983 if (verbose)
984 printf("%s: Hauppauge Model %d %c%c%c%c\n",
985 bktr_name(bktr),
986 model,
987 ((revision >> 18) & 0x3f) + 32,
988 ((revision >> 12) & 0x3f) + 32,
989 ((revision >> 6) & 0x3f) + 32,
990 ((revision >> 0) & 0x3f) + 32);
992 /* Determine the tuner type from the eeprom */
994 switch (tuner_code) {
996 case 0x5:
997 case 0x0a:
998 case 0x1a:
999 select_tuner(bktr, PHILIPS_NTSC);
1000 goto checkDBX;
1002 case 0x4:
1003 case 0x9:
1004 select_tuner(bktr, PHILIPS_SECAM);
1005 goto checkDBX;
1007 case 0x11:
1008 case 0x16:
1009 select_tuner(bktr, PHILIPS_FR1236_SECAM);
1010 goto checkDBX;
1012 case 0x12:
1013 case 0x17:
1014 case 0x21: /* Hauppauge WinTV-GO-FM (model 00191) */
1015 select_tuner(bktr, PHILIPS_FR1236_NTSC);
1016 goto checkDBX;
1018 case 0x6:
1019 case 0x8:
1020 case 0xb:
1021 case 0x1d:
1022 case 0x23:
1023 select_tuner(bktr, PHILIPS_PALI);
1024 goto checkDBX;
1026 case 0xd:
1027 select_tuner(bktr, TEMIC_NTSC);
1028 goto checkDBX;
1030 case 0xe:
1031 select_tuner(bktr, TEMIC_PAL);
1032 goto checkDBX;
1034 case 0xf:
1035 select_tuner(bktr, TEMIC_PALI);
1036 goto checkDBX;
1038 case 0x15:
1039 select_tuner(bktr, PHILIPS_FR1216_PAL);
1040 goto checkDBX;
1042 case 0x2a:
1043 bktr->msp_use_mono_source = 1;
1044 select_tuner(bktr, PHILIPS_FR1216_PAL);
1045 goto checkDBX;
1047 default :
1048 printf("%s: Warning - Unknown Hauppauge Tuner 0x%x\n",
1049 bktr_name(bktr), tuner_code);
1052 break;
1055 case CARD_AVER_MEDIA:
1056 /* AVerMedia kindly supplied some details of their EEPROM contents
1057 * which allow us to auto select the Tuner Type.
1058 * Only the newer AVerMedia cards actually have an EEPROM.
1060 if (bktr->card.eepromAddr != 0) {
1062 u_char tuner_make; /* Eg Philips, Temic */
1063 u_char tuner_tv_fm; /* TV or TV with FM Radio */
1064 u_char tuner_format; /* Eg NTSC, PAL, SECAM */
1065 int tuner;
1067 int tuner_0_table[] = {
1068 PHILIPS_NTSC, PHILIPS_PAL,
1069 PHILIPS_PAL, PHILIPS_PAL,
1070 PHILIPS_PAL, PHILIPS_PAL,
1071 PHILIPS_SECAM, PHILIPS_SECAM,
1072 PHILIPS_SECAM, PHILIPS_PAL};
1074 int tuner_0_fm_table[] = {
1075 PHILIPS_FR1236_NTSC, PHILIPS_FR1216_PAL,
1076 PHILIPS_FR1216_PAL, PHILIPS_FR1216_PAL,
1077 PHILIPS_FR1216_PAL, PHILIPS_FR1216_PAL,
1078 PHILIPS_FR1236_SECAM, PHILIPS_FR1236_SECAM,
1079 PHILIPS_FR1236_SECAM, PHILIPS_FR1216_PAL};
1081 int tuner_1_table[] = {
1082 TEMIC_NTSC, TEMIC_PAL, TEMIC_PAL,
1083 TEMIC_PAL, TEMIC_PAL, TEMIC_PAL,
1084 TEMIC_SECAM, TEMIC_SECAM, TEMIC_SECAM,
1085 TEMIC_PAL};
1088 /* Extract information from the EEPROM data */
1089 readEEProm(bktr, 0, 128, (u_char *) &eeprom);
1091 tuner_make = (eeprom[0x41] & 0x7);
1092 tuner_tv_fm = (eeprom[0x41] & 0x18) >> 3;
1093 tuner_format = (eeprom[0x42] & 0xf0) >> 4;
1095 /* Treat tuner make 0 (Philips) and make 2 (LG) the same */
1096 if (((tuner_make == 0) || (tuner_make == 2))
1097 && (tuner_format <= 9) && (tuner_tv_fm == 0)) {
1098 tuner = tuner_0_table[tuner_format];
1099 select_tuner(bktr, tuner);
1100 goto checkDBX;
1103 if (((tuner_make == 0) || (tuner_make == 2))
1104 && (tuner_format <= 9) && (tuner_tv_fm == 1)) {
1105 tuner = tuner_0_fm_table[tuner_format];
1106 select_tuner(bktr, tuner);
1107 goto checkDBX;
1110 if ((tuner_make == 1) && (tuner_format <= 9)) {
1111 tuner = tuner_1_table[tuner_format];
1112 select_tuner(bktr, tuner);
1113 goto checkDBX;
1116 printf("%s: Warning - Unknown AVerMedia Tuner Make %d Format %d\n",
1117 bktr_name(bktr), tuner_make, tuner_format);
1119 break;
1121 case CARD_LEADTEK:
1122 #if BKTR_SYSTEM_DEFAULT == BROOKTREE_PAL
1123 select_tuner(bktr, PHILIPS_FR1216_PAL);
1124 #else
1125 select_tuner(bktr, PHILIPS_FR1236_NTSC);
1126 #endif
1127 goto checkDBX;
1128 break;
1130 case CARD_TERRATVALUE:
1131 select_tuner(bktr, PHILIPS_PAL);
1132 goto checkDBX;
1133 break;
1135 } /* end switch(card) */
1138 /* At this point, a goto checkDBX has not occurred */
1139 /* We have not been able to select a Tuner */
1140 /* Some cards make use of the tuner address to */
1141 /* identify the make/model of tuner */
1143 /* At address 0xc0/0xc1 we often find a TEMIC NTSC */
1144 if (i2cRead(bktr, 0xc1) != ABSENT) {
1145 select_tuner(bktr, TEMIC_NTSC);
1146 goto checkDBX;
1149 /* At address 0xc6/0xc7 we often find a PHILIPS NTSC Tuner */
1150 if (i2cRead(bktr, 0xc7) != ABSENT) {
1151 select_tuner(bktr, PHILIPS_NTSC);
1152 goto checkDBX;
1155 /* Address 0xc2/0xc3 is default (or common address) for several */
1156 /* tuners and we cannot tell which is which. */
1157 /* And for all other tuner i2c addresses, select the default */
1158 select_tuner(bktr, DEFAULT_TUNER);
1161 checkDBX:
1162 #if defined(BKTR_OVERRIDE_DBX)
1163 bktr->card.dbx = BKTR_OVERRIDE_DBX;
1164 goto checkMSP;
1165 #endif
1166 /* Check for i2c devices */
1167 if (!any_i2c_devices) {
1168 goto checkMSP;
1171 /* probe for BTSC (dbx) chip */
1172 if (i2cRead(bktr, TDA9850_RADDR) != ABSENT)
1173 bktr->card.dbx = 1;
1175 checkMSP:
1176 /* If this is a Hauppauge Bt878 card, we need to enable the
1177 * MSP 34xx audio chip.
1178 * If this is a Hauppauge Bt848 card, reset the MSP device.
1179 * The MSP reset line is wired to GPIO pin 5. On Bt878 cards a pulldown
1180 * resistor holds the device in reset until we set GPIO pin 5.
1183 /* Optionally skip the MSP reset. This is handy if you initialise the
1184 * MSP audio in another operating system (eg Windows) first and then
1185 * do a soft reboot.
1188 #ifndef BKTR_NO_MSP_RESET
1189 if (card == CARD_HAUPPAUGE) {
1190 OUTL(bktr, BKTR_GPIO_OUT_EN, INL(bktr, BKTR_GPIO_OUT_EN) | (1<<5));
1191 OUTL(bktr, BKTR_GPIO_DATA, INL(bktr, BKTR_GPIO_DATA) | (1<<5)); /* write '1' */
1192 DELAY(2500); /* wait 2.5ms */
1193 OUTL(bktr, BKTR_GPIO_DATA, INL(bktr, BKTR_GPIO_DATA) & ~(1<<5)); /* write '0' */
1194 DELAY(2500); /* wait 2.5ms */
1195 OUTL(bktr, BKTR_GPIO_DATA, INL(bktr, BKTR_GPIO_DATA) | (1<<5)); /* write '1' */
1196 DELAY(2500); /* wait 2.5ms */
1198 #endif
1200 #if defined(BKTR_OVERRIDE_MSP)
1201 bktr->card.msp3400c = BKTR_OVERRIDE_MSP;
1202 goto checkMSPEnd;
1203 #endif
1205 /* Check for i2c devices */
1206 if (!any_i2c_devices) {
1207 goto checkMSPEnd;
1210 if (i2cRead(bktr, MSP3400C_RADDR) != ABSENT) {
1211 bktr->card.msp3400c = 1;
1214 checkMSPEnd:
1216 if (bktr->card.msp3400c) {
1217 bktr->msp_addr = MSP3400C_WADDR;
1218 msp_read_id(bktr);
1219 printf("%s: Detected a MSP%s at 0x%x\n", bktr_name(bktr),
1220 bktr->msp_version_string,
1221 bktr->msp_addr);
1225 /* Check for Dolby Surround Sound DPL3518A sound chip */
1226 if (i2cRead(bktr, DPL3518A_RADDR) != ABSENT) {
1227 bktr->card.dpl3518a = 1;
1230 if (bktr->card.dpl3518a) {
1231 bktr->dpl_addr = DPL3518A_WADDR;
1232 dpl_read_id(bktr);
1233 printf("%s: Detected a DPL%s at 0x%x\n", bktr_name(bktr),
1234 bktr->dpl_version_string,
1235 bktr->dpl_addr);
1238 /* Start of Check Remote */
1239 /* Check for the Hauppauge IR Remote Control */
1240 /* If there is an external unit, the internal will be ignored */
1242 bktr->remote_control = 0; /* initial value */
1244 if (any_i2c_devices) {
1245 if (i2cRead(bktr, HAUP_REMOTE_EXT_RADDR) != ABSENT)
1247 bktr->remote_control = 1;
1248 bktr->remote_control_addr = HAUP_REMOTE_EXT_RADDR;
1250 else if (i2cRead(bktr, HAUP_REMOTE_INT_RADDR) != ABSENT)
1252 bktr->remote_control = 1;
1253 bktr->remote_control_addr = HAUP_REMOTE_INT_RADDR;
1257 /* If a remote control is found, poll it 5 times to turn off the LED */
1258 if (bktr->remote_control) {
1259 int ii;
1260 for (ii=0; ii<5; ii++)
1261 i2cRead(bktr, bktr->remote_control_addr);
1263 /* End of Check Remote */
1265 #if defined(BKTR_USE_PLL)
1266 bktr->xtal_pll_mode = BT848_USE_PLL;
1267 goto checkPLLEnd;
1268 #endif
1269 /* Default is to use XTALS and not PLL mode */
1270 bktr->xtal_pll_mode = BT848_USE_XTALS;
1272 /* Enable PLL mode for OSPREY users */
1273 if (card == CARD_OSPREY)
1274 bktr->xtal_pll_mode = BT848_USE_PLL;
1276 /* Enable PLL mode for Video Highway Xtreme users */
1277 if (card == CARD_VIDEO_HIGHWAY_XTREME)
1278 bktr->xtal_pll_mode = BT848_USE_PLL;
1281 /* Most (perhaps all) Bt878 cards need to be switched to PLL mode */
1282 /* as they only fit the NTSC crystal to their cards */
1283 /* Default to enabling PLL mode for all Bt878/879 cards */
1285 if ((bktr->id==BROOKTREE_878 || bktr->id==BROOKTREE_879))
1286 bktr->xtal_pll_mode = BT848_USE_PLL;
1289 #if defined(BKTR_USE_PLL)
1290 checkPLLEnd:
1291 #endif
1294 bktr->card.tuner_pllAddr = tuner_i2c_address;
1296 if (verbose) {
1297 printf("%s: %s", bktr_name(bktr), bktr->card.name);
1298 if (bktr->card.tuner)
1299 printf(", %s tuner", bktr->card.tuner->name);
1300 if (bktr->card.dbx)
1301 printf(", dbx stereo");
1302 if (bktr->card.msp3400c)
1303 printf(", msp3400c stereo");
1304 if (bktr->card.dpl3518a)
1305 printf(", dpl3518a dolby");
1306 if (bktr->remote_control)
1307 printf(", remote control");
1308 printf(".\n");
1312 #undef ABSENT