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