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