Changeset 44631 in vbox
- Timestamp:
- Feb 11, 2013 12:38:33 PM (12 years ago)
- svn:sync-xref-src-repo-rev:
- 83719
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/DevIchAc97.cpp
r44630 r44631 88 88 #define GS_MIINT RT_BIT(1) /* ro */ 89 89 #define GS_GSCI RT_BIT(0) /* rwc */ 90 #define GS_RO_MASK (GS_B3S12 | \91 GS_B2S12 | \92 GS_B1S12 | \93 GS_S1CR | \94 GS_S0CR | \95 GS_MINT | \96 GS_POINT | \97 GS_PIINT | \98 GS_RSRVD | \99 GS_MOINT | \90 #define GS_RO_MASK (GS_B3S12 | \ 91 GS_B2S12 | \ 92 GS_B1S12 | \ 93 GS_S1CR | \ 94 GS_S0CR | \ 95 GS_MINT | \ 96 GS_POINT | \ 97 GS_PIINT | \ 98 GS_RSRVD | \ 99 GS_MOINT | \ 100 100 GS_MIINT) 101 101 #define GS_VALID_MASK (RT_BIT(18) - 1) … … 188 188 typedef struct AC97LinkState 189 189 { 190 /** The PCI device state. */ 191 PCIDevice PciDev; 192 193 /** Audio stuff. */ 190 194 QEMUSoundCard card; 195 191 196 /** Global Control (Bus Master Control Register) */ 192 197 uint32_t glob_cnt; … … 220 225 221 226 #define ICHAC97STATE_2_DEVINS(a_pAC97) ((a_pAC97)->pDevIns) 222 #define PCIDEV_2_ICHAC97STATE(a_pPciDev) (( PCIAC97LinkState *)(a_pPciDev))227 #define PCIDEV_2_ICHAC97STATE(a_pPciDev) ((AC97LinkState *)(a_pPciDev)) 223 228 224 229 enum … … 227 232 BUP_LAST = RT_BIT(1) 228 233 }; 229 230 typedef struct PCIAC97LinkState231 {232 PCIDevice dev;233 AC97LinkState ac97;234 } PCIAC97LinkState;235 234 236 235 #define MKREGS(prefix, start) \ … … 851 850 static DECLCALLBACK(int) ichac97IOPortNABMRead(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t *pu32, unsigned cb) 852 851 { 853 PCIAC97LinkState *d = (PCIAC97LinkState*)pvUser;854 AC97LinkState *s = &d->ac97;852 AC97LinkState *d = (AC97LinkState *)pvUser; 853 AC97LinkState *s = d; 855 854 856 855 switch (cb) … … 859 858 { 860 859 AC97BusMasterRegs *r = NULL; 861 uint32_t index = Port - d->ac97.IOPortBase[1];860 uint32_t index = Port - s->IOPortBase[1]; 862 861 *pu32 = ~0U; 863 862 … … 920 919 { 921 920 AC97BusMasterRegs *r = NULL; 922 uint32_t index = Port - d->ac97.IOPortBase[1];921 uint32_t index = Port - s->IOPortBase[1]; 923 922 *pu32 = ~0U; 924 923 … … 951 950 { 952 951 AC97BusMasterRegs *r = NULL; 953 uint32_t index = Port - d->ac97.IOPortBase[1];952 uint32_t index = Port - s->IOPortBase[1]; 954 953 *pu32 = ~0U; 955 954 … … 1012 1011 static DECLCALLBACK(int) ichac97IOPortNABMWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t u32, unsigned cb) 1013 1012 { 1014 PCIAC97LinkState *d = (PCIAC97LinkState*)pvUser;1015 AC97LinkState *s = &d->ac97;1013 AC97LinkState *d = (AC97LinkState *)pvUser; 1014 AC97LinkState *s = d; 1016 1015 1017 1016 switch (cb) … … 1020 1019 { 1021 1020 AC97BusMasterRegs *r = NULL; 1022 uint32_t index = Port - d->ac97.IOPortBase[1];1021 uint32_t index = Port - s->IOPortBase[1]; 1023 1022 switch (index) 1024 1023 { … … 1083 1082 { 1084 1083 AC97BusMasterRegs *r = NULL; 1085 uint32_t index = Port - d->ac97.IOPortBase[1];1084 uint32_t index = Port - s->IOPortBase[1]; 1086 1085 switch (index) 1087 1086 { … … 1105 1104 { 1106 1105 AC97BusMasterRegs *r = NULL; 1107 uint32_t index = Port - d->ac97.IOPortBase[1];1106 uint32_t index = Port - s->IOPortBase[1]; 1108 1107 switch (index) 1109 1108 { … … 1151 1150 static DECLCALLBACK(int) ichac97IOPortNAMRead(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t *pu32, unsigned cb) 1152 1151 { 1153 PCIAC97LinkState *d = (PCIAC97LinkState*)pvUser;1154 AC97LinkState *s = &d->ac97;1152 AC97LinkState *d = (AC97LinkState *)pvUser; 1153 AC97LinkState *s = d; 1155 1154 1156 1155 switch (cb) … … 1166 1165 case 2: 1167 1166 { 1168 uint32_t index = Port - d->ac97.IOPortBase[0];1167 uint32_t index = Port - s->IOPortBase[0]; 1169 1168 *pu32 = ~0U; 1170 1169 s->cas = 0; … … 1198 1197 static DECLCALLBACK(int) ichac97IOPortNAMWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t u32, unsigned cb) 1199 1198 { 1200 PCIAC97LinkState *d = (PCIAC97LinkState*)pvUser;1201 AC97LinkState *s = &d->ac97;1199 AC97LinkState *d = (AC97LinkState *)pvUser; 1200 AC97LinkState *s = d; 1202 1201 1203 1202 switch (cb) … … 1212 1211 case 2: 1213 1212 { 1214 uint32_t index = Port - d->ac97.IOPortBase[0];1213 uint32_t index = Port - s->IOPortBase[0]; 1215 1214 s->cas = 0; 1216 1215 switch (index) … … 1328 1327 { 1329 1328 PPDMDEVINS pDevIns = pPciDev->pDevIns; 1330 PCIAC97LinkState*pThis = PCIDEV_2_ICHAC97STATE(pPciDev);1329 AC97LinkState *pThis = PCIDEV_2_ICHAC97STATE(pPciDev); 1331 1330 RTIOPORT Port = (RTIOPORT)GCPhysAddress; 1332 1331 int rc; … … 1346 1345 return rc; 1347 1346 1348 pThis-> ac97.IOPortBase[iRegion] = Port;1347 pThis->IOPortBase[iRegion] = Port; 1349 1348 return VINF_SUCCESS; 1350 1349 } … … 1356 1355 static DECLCALLBACK(int) ichac97SaveExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM) 1357 1356 { 1358 PCIAC97LinkState *pThis = PDMINS_2_DATA(pDevIns, PCIAC97LinkState *);1359 AC97LinkState *s = &pThis->ac97;1357 AC97LinkState *pThis = PDMINS_2_DATA(pDevIns, AC97LinkState *); 1358 AC97LinkState *s = pThis; 1360 1359 1361 1360 SSMR3PutU32(pSSM, s->glob_cnt); … … 1394 1393 static DECLCALLBACK(int) ichac97LoadExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass) 1395 1394 { 1396 PCIAC97LinkState *pThis = PDMINS_2_DATA(pDevIns, PCIAC97LinkState *);1397 AC97LinkState *s = &pThis->ac97;1395 AC97LinkState *pThis = PDMINS_2_DATA(pDevIns, AC97LinkState *); 1396 AC97LinkState *s = pThis; 1398 1397 1399 1398 AssertMsgReturn (uVersion == AC97_SSM_VERSION, ("%d\n", uVersion), VERR_SSM_UNSUPPORTED_DATA_UNIT_VERSION); … … 1445 1444 static DECLCALLBACK(void *) ichac97QueryInterface(struct PDMIBASE *pInterface, const char *pszIID) 1446 1445 { 1447 PCIAC97LinkState *pThis = RT_FROM_MEMBER(pInterface, PCIAC97LinkState, ac97.IBase);1448 Assert(&pThis-> ac97.IBase == pInterface);1449 1450 PDMIBASE_RETURN_INTERFACE(pszIID, PDMIBASE, &pThis-> ac97.IBase);1446 AC97LinkState *pThis = RT_FROM_MEMBER(pInterface, AC97LinkState, IBase); 1447 Assert(&pThis->IBase == pInterface); 1448 1449 PDMIBASE_RETURN_INTERFACE(pszIID, PDMIBASE, &pThis->IBase); 1451 1450 return NULL; 1452 1451 } … … 1461 1460 static DECLCALLBACK(void) ac97Reset(PPDMDEVINS pDevIns) 1462 1461 { 1463 PCIAC97LinkState *pThis = PDMINS_2_DATA(pDevIns, PCIAC97LinkState *);1462 AC97LinkState *pThis = PDMINS_2_DATA(pDevIns, AC97LinkState *); 1464 1463 1465 1464 /* 1466 1465 * Reset the device state (will need pDrv later). 1467 1466 */ 1468 reset_bm_regs( &pThis->ac97, &pThis->ac97.bm_regs[0]);1469 reset_bm_regs( &pThis->ac97, &pThis->ac97.bm_regs[1]);1470 reset_bm_regs( &pThis->ac97, &pThis->ac97.bm_regs[2]);1467 reset_bm_regs(pThis, &pThis->bm_regs[0]); 1468 reset_bm_regs(pThis, &pThis->bm_regs[1]); 1469 reset_bm_regs(pThis, &pThis->bm_regs[2]); 1471 1470 1472 1471 /* … … 1475 1474 * the codec manually. 1476 1475 */ 1477 mixer_reset( &pThis->ac97);1476 mixer_reset(pThis); 1478 1477 } 1479 1478 … … 1484 1483 static DECLCALLBACK(int) ichac97Construct(PPDMDEVINS pDevIns, int iInstance, PCFGMNODE pCfg) 1485 1484 { 1486 PCIAC97LinkState *pThis = PDMINS_2_DATA(pDevIns, PCIAC97LinkState *); 1487 AC97LinkState *s = &pThis->ac97; 1488 int rc; 1485 AC97LinkState *pThis = PDMINS_2_DATA(pDevIns, AC97LinkState *); 1486 int rc; 1489 1487 1490 1488 Assert(iInstance == 0); … … 1501 1499 * Initialize data (most of it anyway). 1502 1500 */ 1503 s->pDevIns = pDevIns;1501 pThis->pDevIns = pDevIns; 1504 1502 /* IBase */ 1505 s->IBase.pfnQueryInterface = ichac97QueryInterface;1503 pThis->IBase.pfnQueryInterface = ichac97QueryInterface; 1506 1504 1507 1505 /* PCI Device (the assertions will be removed later) */ 1508 PCIDevSetVendorId (&pThis-> dev, 0x8086); /* 00 ro - intel. */ Assert(pThis->dev.config[0x00] == 0x86); Assert(pThis->dev.config[0x01] == 0x80);1509 PCIDevSetDeviceId (&pThis-> dev, 0x2415); /* 02 ro - 82801 / 82801aa(?). */ Assert(pThis->dev.config[0x02] == 0x15); Assert(pThis->dev.config[0x03] == 0x24);1510 PCIDevSetCommand (&pThis-> dev, 0x0000); /* 04 rw,ro - pcicmd. */ Assert(pThis->dev.config[0x04] == 0x00); Assert(pThis->dev.config[0x05] == 0x00);1511 PCIDevSetStatus (&pThis-> dev, VBOX_PCI_STATUS_DEVSEL_MEDIUM | VBOX_PCI_STATUS_FAST_BACK); /* 06 rwc?,ro? - pcists. */ Assert(pThis->dev.config[0x06] == 0x80); Assert(pThis->dev.config[0x07] == 0x02);1512 PCIDevSetRevisionId (&pThis-> dev, 0x01); /* 08 ro - rid. */ Assert(pThis->dev.config[0x08] == 0x01);1513 PCIDevSetClassProg (&pThis-> dev, 0x00); /* 09 ro - pi. */ Assert(pThis->dev.config[0x09] == 0x00);1514 PCIDevSetClassSub (&pThis-> dev, 0x01); /* 0a ro - scc; 01 == Audio. */ Assert(pThis->dev.config[0x0a] == 0x01);1515 PCIDevSetClassBase (&pThis-> dev, 0x04); /* 0b ro - bcc; 04 == multimedia. */ Assert(pThis->dev.config[0x0b] == 0x04);1516 PCIDevSetHeaderType (&pThis-> dev, 0x00); /* 0e ro - headtyp. */ Assert(pThis->dev.config[0x0e] == 0x00);1517 PCIDevSetBaseAddress (&pThis-> dev, 0, /* 10 rw - nambar - native audio mixer base. */1518 true /* fIoSpace */, false /* fPrefetchable */, false /* f64Bit */, 0x00000000); Assert(pThis-> dev.config[0x10] == 0x01); Assert(pThis->dev.config[0x11] == 0x00); Assert(pThis->dev.config[0x12] == 0x00); Assert(pThis->dev.config[0x13] == 0x00);1519 PCIDevSetBaseAddress (&pThis-> dev, 1, /* 14 rw - nabmbar - native audio bus mastering. */1520 true /* fIoSpace */, false /* fPrefetchable */, false /* f64Bit */, 0x00000000); Assert(pThis-> dev.config[0x14] == 0x01); Assert(pThis->dev.config[0x15] == 0x00); Assert(pThis->dev.config[0x16] == 0x00); Assert(pThis->dev.config[0x17] == 0x00);1521 PCIDevSetSubSystemVendorId(&pThis-> dev, 0x8086); /* 2c ro - intel.) */ Assert(pThis->dev.config[0x2c] == 0x86); Assert(pThis->dev.config[0x2d] == 0x80);1522 PCIDevSetSubSystemId (&pThis-> dev, 0x0000); /* 2e ro. */ Assert(pThis->dev.config[0x2e] == 0x00); Assert(pThis->dev.config[0x2f] == 0x00);1523 PCIDevSetInterruptLine (&pThis-> dev, 0x00); /* 3c rw. */ Assert(pThis->dev.config[0x3c] == 0x00);1524 PCIDevSetInterruptPin (&pThis-> dev, 0x01); /* 3d ro - INTA#. */ Assert(pThis->dev.config[0x3d] == 0x01);1506 PCIDevSetVendorId (&pThis->PciDev, 0x8086); /* 00 ro - intel. */ Assert(pThis->PciDev.config[0x00] == 0x86); Assert(pThis->PciDev.config[0x01] == 0x80); 1507 PCIDevSetDeviceId (&pThis->PciDev, 0x2415); /* 02 ro - 82801 / 82801aa(?). */ Assert(pThis->PciDev.config[0x02] == 0x15); Assert(pThis->PciDev.config[0x03] == 0x24); 1508 PCIDevSetCommand (&pThis->PciDev, 0x0000); /* 04 rw,ro - pcicmd. */ Assert(pThis->PciDev.config[0x04] == 0x00); Assert(pThis->PciDev.config[0x05] == 0x00); 1509 PCIDevSetStatus (&pThis->PciDev, VBOX_PCI_STATUS_DEVSEL_MEDIUM | VBOX_PCI_STATUS_FAST_BACK); /* 06 rwc?,ro? - pcists. */ Assert(pThis->PciDev.config[0x06] == 0x80); Assert(pThis->PciDev.config[0x07] == 0x02); 1510 PCIDevSetRevisionId (&pThis->PciDev, 0x01); /* 08 ro - rid. */ Assert(pThis->PciDev.config[0x08] == 0x01); 1511 PCIDevSetClassProg (&pThis->PciDev, 0x00); /* 09 ro - pi. */ Assert(pThis->PciDev.config[0x09] == 0x00); 1512 PCIDevSetClassSub (&pThis->PciDev, 0x01); /* 0a ro - scc; 01 == Audio. */ Assert(pThis->PciDev.config[0x0a] == 0x01); 1513 PCIDevSetClassBase (&pThis->PciDev, 0x04); /* 0b ro - bcc; 04 == multimedia. */ Assert(pThis->PciDev.config[0x0b] == 0x04); 1514 PCIDevSetHeaderType (&pThis->PciDev, 0x00); /* 0e ro - headtyp. */ Assert(pThis->PciDev.config[0x0e] == 0x00); 1515 PCIDevSetBaseAddress (&pThis->PciDev, 0, /* 10 rw - nambar - native audio mixer base. */ 1516 true /* fIoSpace */, false /* fPrefetchable */, false /* f64Bit */, 0x00000000); Assert(pThis->PciDev.config[0x10] == 0x01); Assert(pThis->PciDev.config[0x11] == 0x00); Assert(pThis->PciDev.config[0x12] == 0x00); Assert(pThis->PciDev.config[0x13] == 0x00); 1517 PCIDevSetBaseAddress (&pThis->PciDev, 1, /* 14 rw - nabmbar - native audio bus mastering. */ 1518 true /* fIoSpace */, false /* fPrefetchable */, false /* f64Bit */, 0x00000000); Assert(pThis->PciDev.config[0x14] == 0x01); Assert(pThis->PciDev.config[0x15] == 0x00); Assert(pThis->PciDev.config[0x16] == 0x00); Assert(pThis->PciDev.config[0x17] == 0x00); 1519 PCIDevSetSubSystemVendorId(&pThis->PciDev, 0x8086); /* 2c ro - intel.) */ Assert(pThis->PciDev.config[0x2c] == 0x86); Assert(pThis->PciDev.config[0x2d] == 0x80); 1520 PCIDevSetSubSystemId (&pThis->PciDev, 0x0000); /* 2e ro. */ Assert(pThis->PciDev.config[0x2e] == 0x00); Assert(pThis->PciDev.config[0x2f] == 0x00); 1521 PCIDevSetInterruptLine (&pThis->PciDev, 0x00); /* 3c rw. */ Assert(pThis->PciDev.config[0x3c] == 0x00); 1522 PCIDevSetInterruptPin (&pThis->PciDev, 0x01); /* 3d ro - INTA#. */ Assert(pThis->PciDev.config[0x3d] == 0x01); 1525 1523 1526 1524 /* … … 1528 1526 * saved state item. 1529 1527 */ 1530 rc = PDMDevHlpPCIRegister(pDevIns, &pThis-> dev);1528 rc = PDMDevHlpPCIRegister(pDevIns, &pThis->PciDev); 1531 1529 if (RT_FAILURE (rc)) 1532 1530 return rc; … … 1547 1545 * Attach driver. 1548 1546 */ 1549 rc = PDMDevHlpDriverAttach(pDevIns, 0, & s->IBase, &s->pDrvBase, "Audio Driver Port");1547 rc = PDMDevHlpDriverAttach(pDevIns, 0, &pThis->IBase, &pThis->pDrvBase, "Audio Driver Port"); 1550 1548 if (rc == VERR_PDM_NO_ATTACHED_DRIVER) 1551 1549 Log(("ac97: No attached driver!\n")); … … 1556 1554 } 1557 1555 1558 AUD_register_card("ICH0", & s->card);1556 AUD_register_card("ICH0", &pThis->card); 1559 1557 1560 1558 ac97Reset(pDevIns); 1561 1559 1562 if (!AUD_is_host_voice_in_ok( s->voice_pi))1560 if (!AUD_is_host_voice_in_ok(pThis->voice_pi)) 1563 1561 LogRel(("AC97: WARNING: Unable to open PCM IN!\n")); 1564 if (!AUD_is_host_voice_in_ok( s->voice_mc))1562 if (!AUD_is_host_voice_in_ok(pThis->voice_mc)) 1565 1563 LogRel(("AC97: WARNING: Unable to open PCM MC!\n")); 1566 if (!AUD_is_host_voice_out_ok( s->voice_po))1564 if (!AUD_is_host_voice_out_ok(pThis->voice_po)) 1567 1565 LogRel(("AC97: WARNING: Unable to open PCM OUT!\n")); 1568 1566 1569 if ( !AUD_is_host_voice_in_ok( s->voice_pi)1570 && !AUD_is_host_voice_out_ok( s->voice_po)1571 && !AUD_is_host_voice_in_ok( s->voice_mc))1567 if ( !AUD_is_host_voice_in_ok( pThis->voice_pi) 1568 && !AUD_is_host_voice_out_ok(pThis->voice_po) 1569 && !AUD_is_host_voice_in_ok( pThis->voice_mc)) 1572 1570 { 1573 1571 /* Was not able initialize *any* voice. Select the NULL audio driver instead */ 1574 AUD_close_in( & s->card,s->voice_pi);1575 AUD_close_out(& s->card,s->voice_po);1576 AUD_close_in( & s->card,s->voice_mc);1577 s->voice_po = NULL;1578 s->voice_pi = NULL;1579 s->voice_mc = NULL;1572 AUD_close_in( &pThis->card, pThis->voice_pi); 1573 AUD_close_out(&pThis->card, pThis->voice_po); 1574 AUD_close_in( &pThis->card, pThis->voice_mc); 1575 pThis->voice_po = NULL; 1576 pThis->voice_pi = NULL; 1577 pThis->voice_mc = NULL; 1580 1578 AUD_init_null(); 1581 1579 ac97Reset(pDevIns); … … 1585 1583 "with the consequence that no sound is audible")); 1586 1584 } 1587 else if ( !AUD_is_host_voice_in_ok( s->voice_pi)1588 || !AUD_is_host_voice_out_ok( s->voice_po)1589 || !AUD_is_host_voice_in_ok( s->voice_mc))1585 else if ( !AUD_is_host_voice_in_ok( pThis->voice_pi) 1586 || !AUD_is_host_voice_out_ok(pThis->voice_po) 1587 || !AUD_is_host_voice_in_ok( pThis->voice_mc)) 1590 1588 { 1591 1589 char szMissingVoices[128]; 1592 1590 size_t len = 0; 1593 if (!AUD_is_host_voice_in_ok( s->voice_pi))1591 if (!AUD_is_host_voice_in_ok(pThis->voice_pi)) 1594 1592 len = RTStrPrintf(szMissingVoices, sizeof(szMissingVoices), "PCM_in"); 1595 if (!AUD_is_host_voice_out_ok( s->voice_po))1593 if (!AUD_is_host_voice_out_ok(pThis->voice_po)) 1596 1594 len += RTStrPrintf(szMissingVoices + len, sizeof(szMissingVoices) - len, len ? ", PCM_out" : "PCM_out"); 1597 if (!AUD_is_host_voice_in_ok( s->voice_mc))1595 if (!AUD_is_host_voice_in_ok(pThis->voice_mc)) 1598 1596 len += RTStrPrintf(szMissingVoices + len, sizeof(szMissingVoices) - len, len ? ", PCM_mic" : "PCM_mic"); 1599 1597 … … 1630 1628 1, 1631 1629 /* cbInstance */ 1632 sizeof( PCIAC97LinkState),1630 sizeof(AC97LinkState), 1633 1631 /* pfnConstruct */ 1634 1632 ichac97Construct,
Note:
See TracChangeset
for help on using the changeset viewer.