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