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