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