Deleted Added
full compact
bktr_core.c (47439) bktr_core.c (47491)
1/* $Id: brooktree848.c,v 1.79 1999/05/22 04:34:59 bde Exp $ */
2/* BT848 Driver for Brooktree's Bt848, Bt849, Bt878 and Bt 879 based cards.
1/* $Id: brooktree848.c,v 1.80 1999/05/23 21:40:51 roger Exp $ */
2/* BT848 Driver for Brooktree's Bt848, Bt848A, Bt849A, Bt878, Bt879 based cards.
3 The Brooktree BT848 Driver driver is based upon Mark Tinguely and
4 Jim Lowe's driver for the Matrox Meteor PCI card . The
5 Philips SAA 7116 and SAA 7196 are very different chipsets than
6 the BT848. For starters, the BT848 is a one chipset solution and
7 it incorporates a RISC engine to control the DMA transfers --
8 that is it the actual dma process is control by a program which
9 resides in the hosts memory also the register definitions between
10 the Philips chipsets and the Bt848 are very different.

--- 385 unchanged lines hidden (view full) ---

3961.66 19 May 1999 Ivan Brawley <brawley@internode.com.au> added better
397 Australian channel frequencies.
398
3991.67 23 May 1999 Roger Hardiman <roger@freebsd.org>
400 Added rgb_vbi_prog() to capture VBI data and video at the
401 same time. To capture VBI data, /dev/vbi must be opened
402 before starting video capture.
403
3 The Brooktree BT848 Driver driver is based upon Mark Tinguely and
4 Jim Lowe's driver for the Matrox Meteor PCI card . The
5 Philips SAA 7116 and SAA 7196 are very different chipsets than
6 the BT848. For starters, the BT848 is a one chipset solution and
7 it incorporates a RISC engine to control the DMA transfers --
8 that is it the actual dma process is control by a program which
9 resides in the hosts memory also the register definitions between
10 the Philips chipsets and the Bt848 are very different.

--- 385 unchanged lines hidden (view full) ---

3961.66 19 May 1999 Ivan Brawley <brawley@internode.com.au> added better
397 Australian channel frequencies.
398
3991.67 23 May 1999 Roger Hardiman <roger@freebsd.org>
400 Added rgb_vbi_prog() to capture VBI data and video at the
401 same time. To capture VBI data, /dev/vbi must be opened
402 before starting video capture.
403
4041.68 25 May 1999 Roger Hardiman <roger@freebsd.org>
405 Due to differences in PCI bus implementations from various
406 motherboard chipset manufactuers, the Bt878/Bt879 has 3
407 PCI bus compatibility modes. These are
408 NORMAL PCI 2.1 for proper PCI 2.1 compatible chipsets.
409 INTEL 430 FX for the Intel 430 FX chipset.
410 SIS VIA CHIPSET for certain SiS and VIA chipsets.
411 OPTI chipset motherboards also benefit from SIS/VIA mode
412 as confirmed by Ben Laurie <ben@algroup.co.uk>
413 Older Intel and non-Intel chipsets may also benefit from
414 SIS/VIA mode.
415
416 NORMAL PCI mode is enabled by default.
417 For INTEL 430 FX mode, add this to your kenel config:
418 options "BKTR_430_FX_MODE"
419 For SIS VIA (and OPTI) mode, add this to your kernel config:
420 options "BKTR_SIS_VIA_MODE"
421
422 Using quotes in these options is not needed in FreeBSD 4.x.
423
424 Note. Newer VIA chipsets should be fully PCI 2.1 compatible
425 and should work fine in the Default mode.
426
427 Also rename 849 to 849A, the correct name for the chip.
404*/
405
406#define DDB(x) x
407#define DEB(x)
408
409#ifdef __FreeBSD__
410#include "bktr.h"
411#include "opt_bktr.h"

--- 992 unchanged lines hidden (view full) ---

1404 */
1405static const char*
1406bktr_probe( pcici_t tag, pcidi_t type )
1407{
1408 unsigned int rev = pci_conf_read( tag, PCIR_REVID) & 0x000000ff;
1409
1410 switch (type) {
1411 case BROOKTREE_848_PCI_ID:
428*/
429
430#define DDB(x) x
431#define DEB(x)
432
433#ifdef __FreeBSD__
434#include "bktr.h"
435#include "opt_bktr.h"

--- 992 unchanged lines hidden (view full) ---

1428 */
1429static const char*
1430bktr_probe( pcici_t tag, pcidi_t type )
1431{
1432 unsigned int rev = pci_conf_read( tag, PCIR_REVID) & 0x000000ff;
1433
1434 switch (type) {
1435 case BROOKTREE_848_PCI_ID:
1412 if (rev == 0x12) return("BrookTree 848a");
1436 if (rev == 0x12) return("BrookTree 848A");
1413 else return("BrookTree 848");
1414 case BROOKTREE_849_PCI_ID:
1437 else return("BrookTree 848");
1438 case BROOKTREE_849_PCI_ID:
1415 return("BrookTree 849");
1439 return("BrookTree 849A");
1416 case BROOKTREE_878_PCI_ID:
1417 return("BrookTree 878");
1418 case BROOKTREE_879_PCI_ID:
1419 return("BrookTree 879");
1420 };
1421
1422 return ((char *)0);
1423}

--- 24 unchanged lines hidden (view full) ---

1448 unit, NBKTR);
1449 printf("brooktree%d: attach: invalid unit number.\n", unit);
1450 return;
1451 }
1452
1453 bktr->tag = tag;
1454 pci_map_mem( tag, PCI_MAP_REG_START, (vm_offset_t *) &bktr->base,
1455 &bktr->phys_base );
1440 case BROOKTREE_878_PCI_ID:
1441 return("BrookTree 878");
1442 case BROOKTREE_879_PCI_ID:
1443 return("BrookTree 879");
1444 };
1445
1446 return ((char *)0);
1447}

--- 24 unchanged lines hidden (view full) ---

1472 unit, NBKTR);
1473 printf("brooktree%d: attach: invalid unit number.\n", unit);
1474 return;
1475 }
1476
1477 bktr->tag = tag;
1478 pci_map_mem( tag, PCI_MAP_REG_START, (vm_offset_t *) &bktr->base,
1479 &bktr->phys_base );
1480
1481 /* Update the Device Control Register on Bt878 and Bt879 cards */
1456 fun = pci_conf_read(tag, 0x40);
1482 fun = pci_conf_read(tag, 0x40);
1457 pci_conf_write(tag, 0x40, fun | 1);
1483 fun = fun | 1; /* Enable writes to the sub-system vendor ID */
1458
1484
1485#if defined( BKTR_430_FX_MODE )
1486 if (bootverbose) printf("Using 430 FX chipset compatibilty mode\n");
1487 fun = fun | 2; /* Enable Intel 430 FX compatibility mode */
1488#endif
1489
1490#if defined( BKTR_SIS_VIA_MODE )
1491 if (bootverbose) printf("Using SiS/VIA chipset compatibilty mode\n");
1492 fun = fun | 4; /* Enable SiS/VIA compatibility mode (usefull for
1493 OPTi chipset motherboards too */
1494#endif
1495 pci_conf_write(tag, 0x40, fun);
1496
1497
1459 /* XXX call bt848_i2c dependent attach() routine */
1460#if (NSMBUS > 0)
1461 if (bt848_i2c_attach(unit, bktr->base, &bktr->i2c_sc))
1462 printf("bktr%d: i2c_attach: can't attach\n", unit);
1463#endif
1464
1465#ifdef BROOKTREE_IRQ /* from the configuration file */
1466 old_irq = pci_conf_read(tag, PCI_INTERRUPT_REG);

--- 96 unchanged lines hidden (view full) ---

1563 rev = pci_conf_read(tag, PCIR_REVID) & 0x000000ff;
1564
1565 switch (fun) {
1566 case BROOKTREE_848_PCI_ID:
1567 if (rev == 0x12) bktr->id = BROOKTREE_848A;
1568 else bktr->id = BROOKTREE_848;
1569 break;
1570 case BROOKTREE_849_PCI_ID:
1498 /* XXX call bt848_i2c dependent attach() routine */
1499#if (NSMBUS > 0)
1500 if (bt848_i2c_attach(unit, bktr->base, &bktr->i2c_sc))
1501 printf("bktr%d: i2c_attach: can't attach\n", unit);
1502#endif
1503
1504#ifdef BROOKTREE_IRQ /* from the configuration file */
1505 old_irq = pci_conf_read(tag, PCI_INTERRUPT_REG);

--- 96 unchanged lines hidden (view full) ---

1602 rev = pci_conf_read(tag, PCIR_REVID) & 0x000000ff;
1603
1604 switch (fun) {
1605 case BROOKTREE_848_PCI_ID:
1606 if (rev == 0x12) bktr->id = BROOKTREE_848A;
1607 else bktr->id = BROOKTREE_848;
1608 break;
1609 case BROOKTREE_849_PCI_ID:
1571 bktr->id = BROOKTREE_849;
1610 bktr->id = BROOKTREE_849A;
1572 break;
1573 case BROOKTREE_878_PCI_ID:
1574 bktr->id = BROOKTREE_878;
1575 break;
1576 case BROOKTREE_879_PCI_ID:
1577 bktr->id = BROOKTREE_879;
1578 break;
1579 };

--- 1793 unchanged lines hidden (view full) ---

3373{
3374 int pixfmt;
3375 unsigned int temp;
3376 struct meteor_pixfmt *pf_pub;
3377
3378 switch (cmd) {
3379
3380 case METEORSINPUT: /* set input device */
1611 break;
1612 case BROOKTREE_878_PCI_ID:
1613 bktr->id = BROOKTREE_878;
1614 break;
1615 case BROOKTREE_879_PCI_ID:
1616 bktr->id = BROOKTREE_879;
1617 break;
1618 };

--- 1793 unchanged lines hidden (view full) ---

3412{
3413 int pixfmt;
3414 unsigned int temp;
3415 struct meteor_pixfmt *pf_pub;
3416
3417 switch (cmd) {
3418
3419 case METEORSINPUT: /* set input device */
3381 /* Bt848 has 3 MUX Inputs. Bt848a/849/878/879 has 4 MUX Inputs*/
3420 /*Bt848 has 3 MUX Inputs. Bt848A/849A/878/879 has 4 MUX Inputs*/
3382 /* On the original bt848 boards, */
3383 /* Tuner is MUX0, RCA is MUX1, S-Video is MUX2 */
3384 /* On the Hauppauge bt878 boards, */
3385 /* Tuner is MUX0, RCA is MUX3 */
3386 /* Unfortunatly Meteor driver codes DEV_RCA as DEV_0, so we */
3387 /* stick with this system in our Meteor Emulation */
3388
3389 switch(*(unsigned long *)arg & METEOR_DEV_MASK) {

--- 49 unchanged lines hidden (view full) ---

3439 bt848->iform |= BT848_IFORM_M_MUX2;
3440 bt848->e_control |= BT848_E_CONTROL_COMP;
3441 bt848->o_control |= BT848_O_CONTROL_COMP;
3442 set_audio( bktr, AUDIO_EXTERN );
3443 break;
3444
3445 case METEOR_INPUT_DEV3:
3446 if ((bktr->id == BROOKTREE_848A) ||
3421 /* On the original bt848 boards, */
3422 /* Tuner is MUX0, RCA is MUX1, S-Video is MUX2 */
3423 /* On the Hauppauge bt878 boards, */
3424 /* Tuner is MUX0, RCA is MUX3 */
3425 /* Unfortunatly Meteor driver codes DEV_RCA as DEV_0, so we */
3426 /* stick with this system in our Meteor Emulation */
3427
3428 switch(*(unsigned long *)arg & METEOR_DEV_MASK) {

--- 49 unchanged lines hidden (view full) ---

3478 bt848->iform |= BT848_IFORM_M_MUX2;
3479 bt848->e_control |= BT848_E_CONTROL_COMP;
3480 bt848->o_control |= BT848_O_CONTROL_COMP;
3481 set_audio( bktr, AUDIO_EXTERN );
3482 break;
3483
3484 case METEOR_INPUT_DEV3:
3485 if ((bktr->id == BROOKTREE_848A) ||
3447 (bktr->id == BROOKTREE_849) ||
3486 (bktr->id == BROOKTREE_849A) ||
3448 (bktr->id == BROOKTREE_878) ||
3449 (bktr->id == BROOKTREE_879) ) {
3450 bktr->flags = (bktr->flags & ~METEOR_DEV_MASK)
3451 | METEOR_DEV3;
3452 bt848->iform &= ~BT848_IFORM_MUXSEL;
3453
3454 /* work around for new Hauppauge 878 cards */
3455 if ((bktr->card.card_id == CARD_HAUPPAUGE) &&

--- 1491 unchanged lines hidden (view full) ---

4947 */
4948static int
4949i2cWrite( bktr_ptr_t bktr, int addr, int byte1, int byte2 )
4950{
4951 char cmd;
4952
4953 if (bktr->id == BROOKTREE_848 ||
4954 bktr->id == BROOKTREE_848A ||
3487 (bktr->id == BROOKTREE_878) ||
3488 (bktr->id == BROOKTREE_879) ) {
3489 bktr->flags = (bktr->flags & ~METEOR_DEV_MASK)
3490 | METEOR_DEV3;
3491 bt848->iform &= ~BT848_IFORM_MUXSEL;
3492
3493 /* work around for new Hauppauge 878 cards */
3494 if ((bktr->card.card_id == CARD_HAUPPAUGE) &&

--- 1491 unchanged lines hidden (view full) ---

4986 */
4987static int
4988i2cWrite( bktr_ptr_t bktr, int addr, int byte1, int byte2 )
4989{
4990 char cmd;
4991
4992 if (bktr->id == BROOKTREE_848 ||
4993 bktr->id == BROOKTREE_848A ||
4955 bktr->id == BROOKTREE_849)
4994 bktr->id == BROOKTREE_849A)
4956 cmd = I2C_COMMAND;
4957 else
4958 cmd = I2C_COMMAND_878;
4959
4960 if (byte2 != -1) {
4961 if (smbus_writew(bktr->i2c_sc.smbus, addr, cmd,
4962 (short)(((byte2 & 0xff) << 8) | (byte1 & 0xff))))
4963 return (-1);

--- 10 unchanged lines hidden (view full) ---

4974static int
4975i2cRead( bktr_ptr_t bktr, int addr )
4976{
4977 char result;
4978 char cmd;
4979
4980 if (bktr->id == BROOKTREE_848 ||
4981 bktr->id == BROOKTREE_848A ||
4995 cmd = I2C_COMMAND;
4996 else
4997 cmd = I2C_COMMAND_878;
4998
4999 if (byte2 != -1) {
5000 if (smbus_writew(bktr->i2c_sc.smbus, addr, cmd,
5001 (short)(((byte2 & 0xff) << 8) | (byte1 & 0xff))))
5002 return (-1);

--- 10 unchanged lines hidden (view full) ---

5013static int
5014i2cRead( bktr_ptr_t bktr, int addr )
5015{
5016 char result;
5017 char cmd;
5018
5019 if (bktr->id == BROOKTREE_848 ||
5020 bktr->id == BROOKTREE_848A ||
4982 bktr->id == BROOKTREE_849)
5021 bktr->id == BROOKTREE_849A)
4983 cmd = I2C_COMMAND;
4984 else
4985 cmd = I2C_COMMAND_878;
4986
4987 if (smbus_readb(bktr->i2c_sc.smbus, addr, cmd, &result))
4988 return (-1);
4989
4990 return ((int)((unsigned char)result));

--- 110 unchanged lines hidden (view full) ---

5101 bt848 = bktr->base;
5102
5103 /* clear status bits */
5104 bt848->int_stat = (BT848_INT_RACK | BT848_INT_I2CDONE);
5105
5106 /* build the command datum */
5107 if (bktr->id == BROOKTREE_848 ||
5108 bktr->id == BROOKTREE_848A ||
5022 cmd = I2C_COMMAND;
5023 else
5024 cmd = I2C_COMMAND_878;
5025
5026 if (smbus_readb(bktr->i2c_sc.smbus, addr, cmd, &result))
5027 return (-1);
5028
5029 return ((int)((unsigned char)result));

--- 110 unchanged lines hidden (view full) ---

5140 bt848 = bktr->base;
5141
5142 /* clear status bits */
5143 bt848->int_stat = (BT848_INT_RACK | BT848_INT_I2CDONE);
5144
5145 /* build the command datum */
5146 if (bktr->id == BROOKTREE_848 ||
5147 bktr->id == BROOKTREE_848A ||
5109 bktr->id == BROOKTREE_849) {
5148 bktr->id == BROOKTREE_849A) {
5110 data = ((addr & 0xff) << 24) | ((byte1 & 0xff) << 16) | I2C_COMMAND;
5111 } else {
5112 data = ((addr & 0xff) << 24) | ((byte1 & 0xff) << 16) | I2C_COMMAND_878;
5113 }
5114 if ( byte2 != -1 ) {
5115 data |= ((byte2 & 0xff) << 8);
5116 data |= BT848_DATA_CTL_I2CW3B;
5117 }

--- 30 unchanged lines hidden (view full) ---

5148 /* clear status bits */
5149 bt848->int_stat = (BT848_INT_RACK | BT848_INT_I2CDONE);
5150
5151 /* write the READ address */
5152 /* The Bt878 and Bt879 differed on the treatment of i2c commands */
5153
5154 if (bktr->id == BROOKTREE_848 ||
5155 bktr->id == BROOKTREE_848A ||
5149 data = ((addr & 0xff) << 24) | ((byte1 & 0xff) << 16) | I2C_COMMAND;
5150 } else {
5151 data = ((addr & 0xff) << 24) | ((byte1 & 0xff) << 16) | I2C_COMMAND_878;
5152 }
5153 if ( byte2 != -1 ) {
5154 data |= ((byte2 & 0xff) << 8);
5155 data |= BT848_DATA_CTL_I2CW3B;
5156 }

--- 30 unchanged lines hidden (view full) ---

5187 /* clear status bits */
5188 bt848->int_stat = (BT848_INT_RACK | BT848_INT_I2CDONE);
5189
5190 /* write the READ address */
5191 /* The Bt878 and Bt879 differed on the treatment of i2c commands */
5192
5193 if (bktr->id == BROOKTREE_848 ||
5194 bktr->id == BROOKTREE_848A ||
5156 bktr->id == BROOKTREE_849) {
5195 bktr->id == BROOKTREE_849A) {
5157 bt848->i2c_data_ctl = ((addr & 0xff) << 24) | I2C_COMMAND;
5158 } else {
5159 bt848->i2c_data_ctl = ((addr & 0xff) << 24) | I2C_COMMAND_878;
5160 }
5161
5162 /* wait for completion */
5163 for ( x = 0x7fffffff; x; --x ) { /* safety valve */
5164 if ( bt848->int_stat & BT848_INT_I2CDONE )

--- 402 unchanged lines hidden (view full) ---

5567 * All Hauppauge cards have a configuration eeprom which tells us the
5568 * tuner type and other features of the their cards.
5569 * Also, Bt878 based cards (certainly Hauppauge and AverMedia) should support
5570 * sub-system vendor id, identifying the make and model of the card.
5571 *
5572 * The current probe code works as follows
5573 * 1) Check if it is a BT878. If so, read the sub-system vendor id.
5574 * Select the required tuner and other onboard features.
5196 bt848->i2c_data_ctl = ((addr & 0xff) << 24) | I2C_COMMAND;
5197 } else {
5198 bt848->i2c_data_ctl = ((addr & 0xff) << 24) | I2C_COMMAND_878;
5199 }
5200
5201 /* wait for completion */
5202 for ( x = 0x7fffffff; x; --x ) { /* safety valve */
5203 if ( bt848->int_stat & BT848_INT_I2CDONE )

--- 402 unchanged lines hidden (view full) ---

5606 * All Hauppauge cards have a configuration eeprom which tells us the
5607 * tuner type and other features of the their cards.
5608 * Also, Bt878 based cards (certainly Hauppauge and AverMedia) should support
5609 * sub-system vendor id, identifying the make and model of the card.
5610 *
5611 * The current probe code works as follows
5612 * 1) Check if it is a BT878. If so, read the sub-system vendor id.
5613 * Select the required tuner and other onboard features.
5575 * 2) If it is a BT848, 848A or 849, continue on:
5614 * 2) If it is a BT848, 848A or 849A, continue on:
5576 * 3) Some cards have no I2C devices. Check if the i2c bus is empty
5577 * and if so, our detection job is nearly over.
5578 * 4) Check I2C address 0xa0. If present this will be a Hauppauge card
5579 * or an Osprey card. The Hauppauge EEPROM can determine on board tuner
5580 * type and other features.
5581 * 4) Check I2C address 0xa8. If present this is a STB card.
5582 * Still have to guess on the tuner type.
5583 * 5) Otherwise we are in the dark. Miro cards have the tuner type

--- 119 unchanged lines hidden (view full) ---

5703 printf("Warning - card vendor %4x (model %d) unknown. This may cause poor performance\n",subsystem_vendor_id,subsystem_id);
5704 }
5705 else
5706 {
5707 printf("Warning - card has no configuration EEPROM. Cannot determine card make. This may cause poor performance\n");
5708 }
5709 } /* end of bt878/bt879 card detection code */
5710
5615 * 3) Some cards have no I2C devices. Check if the i2c bus is empty
5616 * and if so, our detection job is nearly over.
5617 * 4) Check I2C address 0xa0. If present this will be a Hauppauge card
5618 * or an Osprey card. The Hauppauge EEPROM can determine on board tuner
5619 * type and other features.
5620 * 4) Check I2C address 0xa8. If present this is a STB card.
5621 * Still have to guess on the tuner type.
5622 * 5) Otherwise we are in the dark. Miro cards have the tuner type

--- 119 unchanged lines hidden (view full) ---

5742 printf("Warning - card vendor %4x (model %d) unknown. This may cause poor performance\n",subsystem_vendor_id,subsystem_id);
5743 }
5744 else
5745 {
5746 printf("Warning - card has no configuration EEPROM. Cannot determine card make. This may cause poor performance\n");
5747 }
5748 } /* end of bt878/bt879 card detection code */
5749
5711 /* If we get to this point, we must have a Bt848/848a/849 card */
5750 /* If we get to this point, we must have a Bt848/848A/849A card */
5712 /* or a Bt878 with an unknown subsystem vendor id */
5713 /* Try and determine the make of card by clever i2c probing */
5714
5715 /* Check for i2c devices. If none, move on */
5716 if (!any_i2c_devices) {
5717 bktr->card = cards[ (card = CARD_INTEL) ];
5718 goto checkTuner;
5719 }
5720
5721
5722 /* Look for Hauppauge, STB and Osprey cards by the presence */
5723 /* of an EEPROM */
5724 /* Note: Bt878 based cards also use EEPROMs so we can only do this */
5751 /* or a Bt878 with an unknown subsystem vendor id */
5752 /* Try and determine the make of card by clever i2c probing */
5753
5754 /* Check for i2c devices. If none, move on */
5755 if (!any_i2c_devices) {
5756 bktr->card = cards[ (card = CARD_INTEL) ];
5757 goto checkTuner;
5758 }
5759
5760
5761 /* Look for Hauppauge, STB and Osprey cards by the presence */
5762 /* of an EEPROM */
5763 /* Note: Bt878 based cards also use EEPROMs so we can only do this */
5725 /* test on BT848/848a and 849 based cards. */
5764 /* test on BT848/848A and 849A based cards. */
5726 if ((bktr->id==BROOKTREE_848) ||
5727 (bktr->id==BROOKTREE_848A) ||
5765 if ((bktr->id==BROOKTREE_848) ||
5766 (bktr->id==BROOKTREE_848A) ||
5728 (bktr->id==BROOKTREE_849)) {
5767 (bktr->id==BROOKTREE_849A)) {
5729
5730 /* At i2c address 0xa0, look for Hauppauge and Osprey cards */
5731 if ( (status = i2cRead( bktr, PFC8582_RADDR )) != ABSENT ) {
5732
5733 /* Read the eeprom contents */
5734 bktr->card.eepromAddr = PFC8582_WADDR;
5735 bktr->card.eepromSize = (u_char)(256 / EEPROMBLOCKSIZE);
5736 readEEProm(bktr, 0, 128, (u_char *) &probe_eeprom );

--- 1265 unchanged lines hidden ---
5768
5769 /* At i2c address 0xa0, look for Hauppauge and Osprey cards */
5770 if ( (status = i2cRead( bktr, PFC8582_RADDR )) != ABSENT ) {
5771
5772 /* Read the eeprom contents */
5773 bktr->card.eepromAddr = PFC8582_WADDR;
5774 bktr->card.eepromSize = (u_char)(256 / EEPROMBLOCKSIZE);
5775 readEEProm(bktr, 0, 128, (u_char *) &probe_eeprom );

--- 1265 unchanged lines hidden ---