Changeset 46272 in vbox for trunk/src/VBox/Devices/Audio
- Timestamp:
- May 26, 2013 6:02:48 PM (12 years ago)
- svn:sync-xref-src-repo-rev:
- 86011
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/DevIchHda.cpp
r45654 r46272 28 28 29 29 #include <iprt/assert.h> 30 #include <iprt/uuid.h>31 #include <iprt/string.h>32 #include <iprt/mem.h>33 30 #include <iprt/asm.h> 34 31 #include <iprt/asm-math.h> 32 #ifdef IN_RING3 33 # include <iprt/uuid.h> 34 # include <iprt/string.h> 35 # include <iprt/mem.h> 36 #endif 35 37 36 38 #include "VBoxDD.h" … … 51 53 /* HP Pavilion dv4t-1300 */ 52 54 # define HDA_PCI_VENDOR_ID 0x103c 53 # define HDA_PCI_DE ICE_ID 0x30f755 # define HDA_PCI_DEVICE_ID 0x30f7 54 56 #elif defined(VBOX_WITH_INTEL_HDA) 55 57 /* Intel HDA controller */ 56 58 # define HDA_PCI_VENDOR_ID 0x8086 57 # define HDA_PCI_DE ICE_ID 0x266859 # define HDA_PCI_DEVICE_ID 0x2668 58 60 #elif defined(VBOX_WITH_NVIDIA_HDA) 59 61 /* nVidia HDA controller */ 60 62 # define HDA_PCI_VENDOR_ID 0x10de 61 # define HDA_PCI_DE ICE_ID 0x0ac063 # define HDA_PCI_DEVICE_ID 0x0ac0 62 64 #else 63 65 # error "Please specify your HDA device vendor/device IDs" … … 453 455 { 454 456 /** The PCI device structure. */ 455 PCIDevice PciDev; 456 /** Pointer to the device instance. */ 457 PPDMDEVINSR3 pDevIns; 457 PCIDevice PciDev; 458 /** R3 Pointer to the device instance. */ 459 PPDMDEVINSR3 pDevInsR3; 460 /** R0 Pointer to the device instance. */ 461 PPDMDEVINSR0 pDevInsR0; 462 /** R0 Pointer to the device instance. */ 463 PPDMDEVINSRC pDevInsRC; 464 465 uint32_t u32Padding; 466 458 467 /** Pointer to the connector of the attached audio driver. */ 459 PPDMIAUDIOCONNECTORpDrv;468 R3PTRTYPE(PPDMIAUDIOCONNECTOR) pDrv; 460 469 /** Pointer to the attached audio driver. */ 461 PPDMIBASEpDrvBase;470 R3PTRTYPE(PPDMIBASE) pDrvBase; 462 471 /** The base interface for LUN\#0. */ 463 PDMIBASE IBase; 464 RTGCPHYS MMIOBaseAddr; 465 uint32_t au32Regs[HDA_NREGS]; 466 HDABDLEDESC StInBdle; 467 HDABDLEDESC StOutBdle; 468 HDABDLEDESC StMicBdle; 472 PDMIBASE IBase; 473 RTGCPHYS MMIOBaseAddr; 474 uint32_t au32Regs[HDA_NREGS]; 475 HDABDLEDESC StInBdle; 476 HDABDLEDESC StOutBdle; 477 HDABDLEDESC StMicBdle; 478 uint64_t u64CORBBase; 479 uint64_t u64RIRBBase; 480 uint64_t u64DPBase; 481 /** pointer to CORB buf */ 482 R3PTRTYPE(uint32_t *) pu32CorbBuf; 483 /** size in bytes of CORB buf */ 484 uint32_t cbCorbBuf; 485 uint32_t u32Padding2; 486 /** pointer on RIRB buf */ 487 R3PTRTYPE(uint64_t *) pu64RirbBuf; 488 /** size in bytes of RIRB buf */ 489 uint32_t cbRirbBuf; 490 /** indicates if HDA in reset. */ 491 bool fInReset; 469 492 /** Interrupt on completion */ 470 bool fCviIoc; 471 uint64_t u64CORBBase; 472 uint64_t u64RIRBBase; 473 uint64_t u64DPBase; 474 /** pointer to CORB buf */ 475 uint32_t *pu32CorbBuf; 476 /** size in bytes of CORB buf */ 477 uint32_t cbCorbBuf; 478 /** pointer on RIRB buf */ 479 uint64_t *pu64RirbBuf; 480 /** size in bytes of RIRB buf */ 481 uint32_t cbRirbBuf; 482 /** indicates if HDA in reset. */ 483 bool fInReset; 493 bool fCviIoc; 494 /** Flag whether the R0 part is enabled. */ 495 bool fR0Enabled; 496 /** Flag whether the RC part is enabled. */ 497 bool fRCEnabled; 484 498 /** The HDA codec state. */ 485 HDACODEC Codec; 499 R3PTRTYPE(PHDACODEC) pCodec; 500 uint64_t u64BaseTS; 486 501 /** 1.2.3.4.5.6.7. - someone please tell me what I'm counting! - .8.9.10... */ 487 uint8_t u8Counter;488 uint 64_t u64BaseTS;502 uint8_t u8Counter; 503 uint8_t au8Padding[7]; 489 504 } HDASTATE; 490 505 /** Pointer to the ICH Intel HD Audio Controller state. */ … … 492 507 493 508 #define ISD0FMT_TO_AUDIO_SELECTOR(pThis) \ 494 ( AUDIO_FORMAT_SELECTOR( &(pThis)->Codec, In, SDFMT_BASE_RATE(pThis, 0), SDFMT_MULT(pThis, 0), SDFMT_DIV(pThis, 0)) )509 ( AUDIO_FORMAT_SELECTOR((pThis)->pCodec, In, SDFMT_BASE_RATE(pThis, 0), SDFMT_MULT(pThis, 0), SDFMT_DIV(pThis, 0)) ) 495 510 #define OSD0FMT_TO_AUDIO_SELECTOR(pThis) \ 496 ( AUDIO_FORMAT_SELECTOR( &(pThis)->Codec, Out, SDFMT_BASE_RATE(pThis, 4), SDFMT_MULT(pThis, 4), SDFMT_DIV(pThis, 4)) )511 ( AUDIO_FORMAT_SELECTOR((pThis)->pCodec, Out, SDFMT_BASE_RATE(pThis, 4), SDFMT_MULT(pThis, 4), SDFMT_DIV(pThis, 4)) ) 497 512 498 513 … … 500 515 * Internal Functions * 501 516 *******************************************************************************/ 517 #ifndef VBOX_DEVICE_STRUCT_TESTCASE 502 518 static FNPDMDEVRESET hdaReset; 503 519 … … 540 556 static int hdaRegWriteU8(PHDASTATE pThis, uint32_t iReg, uint32_t pu32Value); 541 557 558 #ifdef IN_RING3 542 559 DECLINLINE(void) hdaInitTransferDescriptor(PHDASTATE pThis, PHDABDLEDESC pBdle, uint8_t u8Strm, 543 560 PHDASTREAMTRANSFERDESC pStreamDesc); … … 545 562 #ifdef LOG_ENABLED 546 563 static void dump_bd(PHDASTATE pThis, PHDABDLEDESC pBdle, uint64_t u64BaseDMA); 564 #endif 547 565 #endif 548 566 … … 727 745 }; 728 746 729 747 #ifdef IN_RING3 730 748 /** HDABDLEDESC field descriptors the v3+ saved state. */ 731 749 static SSMFIELD const g_aHdaBDLEDescFields[] = … … 756 774 SSMFIELD_ENTRY_TERM() 757 775 }; 776 #endif 758 777 759 778 /** … … 765 784 }; 766 785 767 786 #ifdef IN_RING3 768 787 DECLINLINE(void) hdaUpdatePosBuf(PHDASTATE pThis, PHDASTREAMTRANSFERDESC pStreamDesc) 769 788 { 770 789 if (pThis->u64DPBase & DPBASE_ENABLED) 771 PDMDevHlpPCIPhysWrite(pThis-> pDevIns,790 PDMDevHlpPCIPhysWrite(pThis->CTX_SUFF(pDevIns), 772 791 (pThis->u64DPBase & DPBASE_ADDR_MASK) + pStreamDesc->u8Strm * 8, 773 792 pStreamDesc->pu32Lpib, sizeof(uint32_t)); 774 793 } 794 #endif 795 775 796 DECLINLINE(uint32_t) hdaFifoWToSz(PHDASTATE pThis, PHDASTREAMTRANSFERDESC pStreamDesc) 776 797 { … … 807 828 { 808 829 Log(("hda: irq %s\n", fIrq ? "asserted" : "deasserted")); 809 PDMDevHlpPCISetIrq(pThis-> pDevIns, 0 , fIrq);830 PDMDevHlpPCISetIrq(pThis->CTX_SUFF(pDevIns), 0 , fIrq); 810 831 } 811 832 return VINF_SUCCESS; … … 919 940 } 920 941 921 942 #ifdef IN_RING3 922 943 static int hdaCmdSync(PHDASTATE pThis, bool fLocal) 923 944 { … … 926 947 { 927 948 Assert((HDA_REG_FLAG_VALUE(pThis, CORBCTL, DMA))); 928 rc = PDMDevHlpPhysRead(pThis-> pDevIns, pThis->u64CORBBase, pThis->pu32CorbBuf, pThis->cbCorbBuf);949 rc = PDMDevHlpPhysRead(pThis->CTX_SUFF(pDevIns), pThis->u64CORBBase, pThis->pu32CorbBuf, pThis->cbCorbBuf); 929 950 if (RT_FAILURE(rc)) 930 951 AssertRCReturn(rc, rc); … … 955 976 { 956 977 Assert((HDA_REG_FLAG_VALUE(pThis, RIRBCTL, DMA))); 957 rc = PDMDevHlpPCIPhysWrite(pThis-> pDevIns, pThis->u64RIRBBase, pThis->pu64RirbBuf, pThis->cbRirbBuf);978 rc = PDMDevHlpPCIPhysWrite(pThis->CTX_SUFF(pDevIns), pThis->u64RIRBBase, pThis->pu64RirbBuf, pThis->cbRirbBuf); 958 979 if (RT_FAILURE(rc)) 959 980 AssertRCReturn(rc, rc); … … 1003 1024 corbRp++; 1004 1025 cmd = pThis->pu32CorbBuf[corbRp]; 1005 rc = pThis-> Codec.pfnLookup(&pThis->Codec, cmd, &pfn);1026 rc = pThis->pCodec->pfnLookup(pThis->pCodec, cmd, &pfn); 1006 1027 if (RT_FAILURE(rc)) 1007 1028 AssertRCReturn(rc, rc); … … 1010 1031 1011 1032 if (RT_LIKELY(pfn)) 1012 rc = pfn( &pThis->Codec, cmd, &resp);1033 rc = pfn(pThis->pCodec, cmd, &resp); 1013 1034 else 1014 1035 rc = VERR_INVALID_FUNCTION; … … 1043 1064 return rc; 1044 1065 } 1066 #endif 1045 1067 1046 1068 static void hdaStreamReset(PHDASTATE pThis, PHDABDLEDESC pBdle, PHDASTREAMTRANSFERDESC pStreamDesc, uint8_t u8Strm) … … 1069 1091 } 1070 1092 1071 1072 1093 /* Register access handlers. */ 1073 1094 … … 1151 1172 else 1152 1173 { 1174 #ifdef IN_RING3 1153 1175 /* enter reset state*/ 1154 1176 if ( HDA_REG_FLAG_VALUE(pThis, CORBCTL, DMA) … … 1159 1181 HDA_REG_FLAG_VALUE(pThis, RIRBCTL, DMA) ? "on" : "off")); 1160 1182 } 1161 hdaReset(pThis-> pDevIns);1183 hdaReset(pThis->CTX_SUFF(pDevIns)); 1162 1184 GCTL(pThis) &= ~HDA_REG_FIELD_FLAG_MASK(GCTL, RST); 1163 1185 pThis->fInReset = true; 1186 #else 1187 return VINF_IOM_R3_MMIO_WRITE; 1188 #endif 1164 1189 } 1165 1190 if (u32Value & HDA_REG_FIELD_FLAG_MASK(GCTL, FSH)) … … 1209 1234 { 1210 1235 /* HDA spec (1a): 3.3.16 WALCLK counter ticks with 24Mhz bitclock rate. */ 1211 *pu32Value = (uint32_t)ASMMultU64ByU32DivByU32(PDMDevHlpTMTimeVirtGetNano(pThis-> pDevIns)1236 *pu32Value = (uint32_t)ASMMultU64ByU32DivByU32(PDMDevHlpTMTimeVirtGetNano(pThis->CTX_SUFF(pDevIns)) 1212 1237 - pThis->u64BaseTS, 24, 1000); 1213 1238 return VINF_SUCCESS; … … 1232 1257 static int hdaRegWriteCORBCTL(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value) 1233 1258 { 1259 #ifdef IN_RING3 1234 1260 int rc = hdaRegWriteU8(pThis, iReg, u32Value); 1235 1261 AssertRC(rc); … … 1238 1264 return hdaCORBCmdProcess(pThis); 1239 1265 return rc; 1266 #else 1267 return VINF_IOM_R3_MMIO_WRITE; 1268 #endif 1240 1269 } 1241 1270 … … 1249 1278 static int hdaRegWriteCORBWP(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value) 1250 1279 { 1280 #ifdef IN_RING3 1251 1281 int rc; 1252 1282 rc = hdaRegWriteU16(pThis, iReg, u32Value); … … 1259 1289 rc = hdaCORBCmdProcess(pThis); 1260 1290 return rc; 1291 #else 1292 return VINF_IOM_R3_MMIO_WRITE; 1293 #endif 1261 1294 } 1262 1295 … … 1284 1317 else if (fReset) 1285 1318 { 1319 #ifdef IN_RING3 1286 1320 /* 1287 1321 * Assert!!! ICH6 datasheet 18.2.33 says that RUN bit should be cleared before initiation of reset. … … 1308 1342 hdaInitTransferDescriptor(pThis, pBdle, u8Strm, &StreamDesc); 1309 1343 hdaStreamReset(pThis, pBdle, &StreamDesc, u8Strm); 1344 #else 1345 return VINF_IOM_R3_MMIO_WRITE; 1346 #endif 1310 1347 } 1311 1348 else 1312 1349 { 1350 #ifdef IN_RING3 1313 1351 /* we enter here to change DMA states only */ 1314 1352 if ( (fInRun && !fRun) … … 1319 1357 { 1320 1358 case ICH6_HDA_REG_SD0CTL: 1321 AUD_set_active_in(pThis-> Codec.SwVoiceIn, fRun);1359 AUD_set_active_in(pThis->pCodec->SwVoiceIn, fRun); 1322 1360 break; 1323 1361 case ICH6_HDA_REG_SD4CTL: 1324 AUD_set_active_out(pThis-> Codec.SwVoiceOut, fRun);1362 AUD_set_active_out(pThis->pCodec->SwVoiceOut, fRun); 1325 1363 break; 1326 1364 default: … … 1329 1367 } 1330 1368 } 1369 #else 1370 return VINF_IOM_R3_MMIO_WRITE; 1371 #endif 1331 1372 } 1332 1373 … … 1406 1447 } 1407 1448 1449 #ifdef IN_RING3 1408 1450 static void hdaSdFmtToAudSettings(uint32_t u32SdFmt, audsettings_t *pAudSetting) 1409 1451 { … … 1463 1505 #undef EXTRACT_VALUE 1464 1506 } 1507 #endif 1465 1508 1466 1509 static int hdaRegWriteSDFMT(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value) 1467 1510 { 1468 #ifdef VBOX_WITH_HDA_CODEC_EMU 1511 #ifdef IN_RING3 1512 # ifdef VBOX_WITH_HDA_CODEC_EMU 1469 1513 /** @todo a bit more investigation is required here. */ 1470 1514 int rc = 0; … … 1477 1521 { 1478 1522 case ICH6_HDA_REG_SD0FMT: 1479 rc = hdaCodecOpenVoice( &pThis->Codec, PI_INDEX, &as);1523 rc = hdaCodecOpenVoice(pThis->pCodec, PI_INDEX, &as); 1480 1524 break; 1481 1525 case ICH6_HDA_REG_SD4FMT: 1482 rc = hdaCodecOpenVoice( &pThis->Codec, PO_INDEX, &as);1526 rc = hdaCodecOpenVoice(pThis->pCodec, PO_INDEX, &as); 1483 1527 break; 1484 1528 default: … … 1487 1531 } 1488 1532 return hdaRegWriteU16(pThis, iReg, u32Value); 1533 # else 1534 return hdaRegWriteU16(pThis, iReg, u32Value); 1535 # endif 1489 1536 #else 1490 return hdaRegWriteU16(pThis, iReg, u32Value);1537 return VINF_IOM_R3_MMIO_WRITE; 1491 1538 #endif 1492 1539 } … … 1523 1570 { 1524 1571 int rc = VINF_SUCCESS; 1525 PFNHDACODECVERBPROCESSOR pfn = NULL;1526 uint64_t resp;1527 1572 1528 1573 /* … … 1533 1578 && !IRS_ICB(pThis)) 1534 1579 { 1580 #ifdef IN_RING3 1581 PFNHDACODECVERBPROCESSOR pfn = NULL; 1582 uint64_t resp; 1535 1583 uint32_t cmd = IC(pThis); 1536 1584 if (CORBWP(pThis) != CORBRP(pThis)) … … 1544 1592 IRS(pThis) = HDA_REG_FIELD_FLAG_MASK(IRS, ICB); /* busy */ 1545 1593 Log(("hda: IC:%x\n", cmd)); 1546 rc = pThis-> Codec.pfnLookup(&pThis->Codec, cmd, &pfn);1594 rc = pThis->pCodec->pfnLookup(pThis->pCodec, cmd, &pfn); 1547 1595 if (RT_FAILURE(rc)) 1548 1596 AssertRCReturn(rc, rc); 1549 rc = pfn( &pThis->Codec, cmd, &resp);1597 rc = pfn(pThis->pCodec, cmd, &resp); 1550 1598 if (RT_FAILURE(rc)) 1551 1599 AssertRCReturn(rc, rc); … … 1554 1602 IRS(pThis) = HDA_REG_FIELD_FLAG_MASK(IRS, IRV); /* result is ready */ 1555 1603 IRS(pThis) &= ~HDA_REG_FIELD_FLAG_MASK(IRS, ICB); /* busy is clear */ 1604 #else 1605 rc = VINF_IOM_R3_MMIO_WRITE; 1606 #endif 1556 1607 return rc; 1557 1608 } … … 1622 1673 } 1623 1674 1675 #ifdef IN_RING3 1624 1676 #ifdef LOG_ENABLED 1625 1677 static void dump_bd(PHDASTATE pThis, PHDABDLEDESC pBdle, uint64_t u64BaseDMA) … … 1636 1688 for (i = 0; i <= pBdle->u32BdleMaxCvi; ++i) 1637 1689 { 1638 PDMDevHlpPhysRead(pThis-> pDevIns, u64BaseDMA + i*16, bdle, 16);1690 PDMDevHlpPhysRead(pThis->CTX_SUFF(pDevIns), u64BaseDMA + i*16, bdle, 16); 1639 1691 addr = *(uint64_t *)bdle; 1640 1692 len = *(uint32_t *)&bdle[8]; … … 1646 1698 for (i = 0; i < 8; ++i) 1647 1699 { 1648 PDMDevHlpPhysRead(pThis-> pDevIns, (pThis->u64DPBase & DPBASE_ADDR_MASK) + i*8, &counter, sizeof(&counter));1700 PDMDevHlpPhysRead(pThis->CTX_SUFF(pDevIns), (pThis->u64DPBase & DPBASE_ADDR_MASK) + i*8, &counter, sizeof(&counter)); 1649 1701 Log(("hda: %s stream[%d] counter=%x\n", i == SDCTL_NUM(pThis, 4) || i == SDCTL_NUM(pThis, 0)? "[C]": " ", 1650 1702 i , counter)); … … 1660 1712 && pBdle 1661 1713 && pBdle->u32BdleMaxCvi)); 1662 PDMDevHlpPhysRead(pThis-> pDevIns, pStreamDesc->u64BaseDMA + pBdle->u32BdleCvi*16, bdle, 16);1714 PDMDevHlpPhysRead(pThis->CTX_SUFF(pDevIns), pStreamDesc->u64BaseDMA + pBdle->u32BdleCvi*16, bdle, 16); 1663 1715 pBdle->u64BdleCviAddr = *(uint64_t *)bdle; 1664 1716 pBdle->u32BdleCviLen = *(uint32_t *)&bdle[8]; … … 1844 1896 * read from backend input line to the last unreported position or at the begining. 1845 1897 */ 1846 cbBackendCopy = AUD_read(pThis-> Codec.SwVoiceIn, pBdle->au8HdaBuffer, cb2Copy);1898 cbBackendCopy = AUD_read(pThis->pCodec->SwVoiceIn, pBdle->au8HdaBuffer, cb2Copy); 1847 1899 /* 1848 1900 * write the HDA DMA buffer 1849 1901 */ 1850 PDMDevHlpPCIPhysWrite(pThis-> pDevIns, pBdle->u64BdleCviAddr + pBdle->u32BdleCviPos, pBdle->au8HdaBuffer, cbBackendCopy);1902 PDMDevHlpPCIPhysWrite(pThis->CTX_SUFF(pDevIns), pBdle->u64BdleCviAddr + pBdle->u32BdleCviPos, pBdle->au8HdaBuffer, cbBackendCopy); 1851 1903 1852 1904 /* Don't see any reason why cb2Copy would differ from cbBackendCopy */ … … 1886 1938 else 1887 1939 { 1888 PDMDevHlpPhysRead(pThis-> pDevIns, pBdle->u64BdleCviAddr + pBdle->u32BdleCviPos, pBdle->au8HdaBuffer + pBdle->cbUnderFifoW, cb2Copy);1940 PDMDevHlpPhysRead(pThis->CTX_SUFF(pDevIns), pBdle->u64BdleCviAddr + pBdle->u32BdleCviPos, pBdle->au8HdaBuffer + pBdle->cbUnderFifoW, cb2Copy); 1889 1941 /* 1890 1942 * Write to audio backend. we should ensure that we have enough bytes to copy to the backend. … … 1895 1947 * Feed the newly fetched samples, including unreported ones, to the backend. 1896 1948 */ 1897 cbBackendCopy = AUD_write (pThis-> Codec.SwVoiceOut, pBdle->au8HdaBuffer, cb2Copy + pBdle->cbUnderFifoW);1949 cbBackendCopy = AUD_write (pThis->pCodec->SwVoiceOut, pBdle->au8HdaBuffer, cb2Copy + pBdle->cbUnderFifoW); 1898 1950 hdaBackendWriteTransferReported(pBdle, cb2Copy, cbBackendCopy, &cbTransferred, pu32Avail); 1899 1951 } … … 2017 2069 } 2018 2070 } 2019 2071 #endif 2020 2072 2021 2073 /* MMIO callbacks */ … … 2272 2324 cbReg = 1; 2273 2325 } 2326 if (rc != VINF_SUCCESS) 2327 break; 2274 2328 if (cbReg >= cb) 2275 2329 break; … … 2351 2405 /* PCI callback. */ 2352 2406 2407 #ifdef IN_RING3 2353 2408 /** 2354 2409 * @callback_method_impl{FNPCIIOREGIONMAP} … … 2369 2424 */ 2370 2425 Assert(enmType == PCI_ADDRESS_SPACE_MEM); 2371 rc = PDMDevHlpMMIORegister(p PciDev->pDevIns, GCPhysAddress, cb, NULL /*pvUser*/,2426 rc = PDMDevHlpMMIORegister(pDevIns, GCPhysAddress, cb, NULL /*pvUser*/, 2372 2427 #ifdef NEW_READ_CODE 2373 2428 IOMMMIO_FLAGS_READ_DWORD | … … 2381 2436 return rc; 2382 2437 2438 if (pThis->fR0Enabled) 2439 { 2440 rc = PDMDevHlpMMIORegisterR0(pDevIns, GCPhysAddress, cb, NIL_RTR0PTR /*pvUser*/, 2441 "hdaMMIOWrite", "hdaMMIORead"); 2442 if (RT_FAILURE(rc)) 2443 return rc; 2444 } 2445 2446 if (pThis->fRCEnabled) 2447 { 2448 rc = PDMDevHlpMMIORegisterRC(pDevIns, GCPhysAddress, cb, NIL_RTRCPTR /*pvUser*/, 2449 "hdaMMIOWrite", "hdaMMIORead"); 2450 if (RT_FAILURE(rc)) 2451 return rc; 2452 } 2453 2383 2454 pThis->MMIOBaseAddr = GCPhysAddress; 2384 2455 return VINF_SUCCESS; … … 2395 2466 PHDASTATE pThis = PDMINS_2_DATA(pDevIns, PHDASTATE); 2396 2467 /* Save Codec nodes states */ 2397 hdaCodecSaveState( &pThis->Codec, pSSM);2468 hdaCodecSaveState(pThis->pCodec, pSSM); 2398 2469 2399 2470 /* Save MMIO registers */ … … 2422 2493 * Load Codec nodes states. 2423 2494 */ 2424 int rc = hdaCodecLoadState( &pThis->Codec, pSSM, uVersion);2495 int rc = hdaCodecLoadState(pThis->pCodec, pSSM, uVersion); 2425 2496 if (RT_FAILURE(rc)) 2426 2497 return rc; … … 2488 2559 * Update stuff after the state changes. 2489 2560 */ 2490 AUD_set_active_in(pThis-> Codec.SwVoiceIn, SDCTL(pThis, 0) & HDA_REG_FIELD_FLAG_MASK(SDCTL, RUN));2491 AUD_set_active_out(pThis-> Codec.SwVoiceOut, SDCTL(pThis, 4) & HDA_REG_FIELD_FLAG_MASK(SDCTL, RUN));2561 AUD_set_active_in(pThis->pCodec->SwVoiceIn, SDCTL(pThis, 0) & HDA_REG_FIELD_FLAG_MASK(SDCTL, RUN)); 2562 AUD_set_active_out(pThis->pCodec->SwVoiceOut, SDCTL(pThis, 4) & HDA_REG_FIELD_FLAG_MASK(SDCTL, RUN)); 2492 2563 2493 2564 pThis->u64CORBBase = RT_MAKE_U64(CORBLBASE(pThis), CORBUBASE(pThis)); … … 2664 2735 { 2665 2736 PHDASTATE pThis = PDMINS_2_DATA(pDevIns, PHDASTATE); 2666 if (pThis-> Codec.pfnCodecDbgListNodes)2667 pThis-> Codec.pfnCodecDbgListNodes(&pThis->Codec, pHlp, pszArgs);2737 if (pThis->pCodec->pfnCodecDbgListNodes) 2738 pThis->pCodec->pfnCodecDbgListNodes(pThis->pCodec, pHlp, pszArgs); 2668 2739 else 2669 2740 pHlp->pfnPrintf(pHlp, "Codec implementation doesn't provide corresponding callback.\n"); … … 2677 2748 { 2678 2749 PHDASTATE pThis = PDMINS_2_DATA(pDevIns, PHDASTATE); 2679 if (pThis-> Codec.pfnCodecDbgSelector)2680 pThis-> Codec.pfnCodecDbgSelector(&pThis->Codec, pHlp, pszArgs);2750 if (pThis->pCodec->pfnCodecDbgSelector) 2751 pThis->pCodec->pfnCodecDbgSelector(pThis->pCodec, pHlp, pszArgs); 2681 2752 else 2682 2753 pHlp->pfnPrintf(pHlp, "Codec implementation doesn't provide corresponding callback.\n"); … … 2774 2845 PHDASTATE pThis = PDMINS_2_DATA(pDevIns, PHDASTATE); 2775 2846 2776 int rc = hdaCodecDestruct(&pThis->Codec); 2777 AssertRC(rc); 2847 if (pThis->pCodec) 2848 { 2849 int rc = hdaCodecDestruct(pThis->pCodec); 2850 AssertRC(rc); 2851 2852 RTMemFree(pThis->pCodec); 2853 pThis->pCodec = NULL; 2854 } 2778 2855 2779 2856 RTMemFree(pThis->pu32CorbBuf); … … 2800 2877 * Validations. 2801 2878 */ 2802 if (!CFGMR3AreValuesValid(pCfgHandle, "\0")) 2879 if (!CFGMR3AreValuesValid(pCfgHandle, "R0Enabled\0" 2880 "RCEnabled\0")) 2803 2881 return PDMDEV_SET_ERROR(pDevIns, VERR_PDM_DEVINS_UNKNOWN_CFG_VALUES, 2804 2882 N_ ("Invalid configuration for the Intel HDA device")); 2805 2883 2806 /// @todo r=michaln: This device may need R0/RC enabling, especially if guests 2807 /// poll some register(pThis). 2884 rc = CFGMR3QueryBoolDef(pCfgHandle, "RCEnabled", &pThis->fRCEnabled, false); 2885 if (RT_FAILURE(rc)) 2886 return PDMDEV_SET_ERROR(pDevIns, rc, 2887 N_("HDA configuration error: failed to read RCEnabled as boolean")); 2888 rc = CFGMR3QueryBoolDef(pCfgHandle, "R0Enabled", &pThis->fR0Enabled, false); 2889 if (RT_FAILURE(rc)) 2890 return PDMDEV_SET_ERROR(pDevIns, rc, 2891 N_("HDA configuration error: failed to read R0Enabled as boolean")); 2808 2892 2809 2893 /* 2810 2894 * Initialize data (most of it anyway). 2811 2895 */ 2812 pThis->pDevIns = pDevIns; 2896 pThis->pDevInsR3 = pDevIns; 2897 pThis->pDevInsR0 = PDMDEVINS_2_R0PTR(pDevIns); 2898 pThis->pDevInsRC = PDMDEVINS_2_RCPTR(pDevIns); 2813 2899 /* IBase */ 2814 2900 pThis->IBase.pfnQueryInterface = hdaQueryInterface; … … 2816 2902 /* PCI Device */ 2817 2903 PCIDevSetVendorId (&pThis->PciDev, HDA_PCI_VENDOR_ID); /* nVidia */ 2818 PCIDevSetDeviceId (&pThis->PciDev, HDA_PCI_DE ICE_ID); /* HDA */2904 PCIDevSetDeviceId (&pThis->PciDev, HDA_PCI_DEVICE_ID); /* HDA */ 2819 2905 2820 2906 PCIDevSetCommand (&pThis->PciDev, 0x0000); /* 04 rw,ro - pcicmd. */ … … 2932 3018 } 2933 3019 2934 pThis->Codec.pvHDAState = pThis; 2935 rc = hdaCodecConstruct(pDevIns, &pThis->Codec, pCfgHandle); 3020 /* Construct codec state. */ 3021 pThis->pCodec = (PHDACODEC)RTMemAllocZ(sizeof(HDACODEC)); 3022 if (!pThis->pCodec) 3023 return PDMDEV_SET_ERROR(pDevIns, VERR_NO_MEMORY, N_("HDA: Out of memory allocating codec state")); 3024 3025 pThis->pCodec->pvHDAState = pThis; 3026 rc = hdaCodecConstruct(pDevIns, pThis->pCodec, pCfgHandle); 2936 3027 if (RT_FAILURE(rc)) 2937 3028 AssertRCReturn(rc, rc); … … 2939 3030 /* ICH6 datasheet defines 0 values for SVID and SID (18.1.14-15), which together with values returned for 2940 3031 verb F20 should provide device/codec recognition. */ 2941 Assert(pThis-> Codec.u16VendorId);2942 Assert(pThis-> Codec.u16DeviceId);2943 PCIDevSetSubSystemVendorId(&pThis->PciDev, pThis-> Codec.u16VendorId); /* 2c ro - intel.) */2944 PCIDevSetSubSystemId( &pThis->PciDev, pThis-> Codec.u16DeviceId); /* 2e ro. */3032 Assert(pThis->pCodec->u16VendorId); 3033 Assert(pThis->pCodec->u16DeviceId); 3034 PCIDevSetSubSystemVendorId(&pThis->PciDev, pThis->pCodec->u16VendorId); /* 2c ro - intel.) */ 3035 PCIDevSetSubSystemId( &pThis->PciDev, pThis->pCodec->u16DeviceId); /* 2e ro. */ 2945 3036 2946 3037 hdaReset(pDevIns); 2947 pThis-> Codec.id = 0;2948 pThis-> Codec.pfnTransfer = hdaTransfer;2949 pThis-> Codec.pfnReset = hdaCodecReset;3038 pThis->pCodec->id = 0; 3039 pThis->pCodec->pfnTransfer = hdaTransfer; 3040 pThis->pCodec->pfnReset = hdaCodecReset; 2950 3041 2951 3042 /* … … 3037 3128 "hda", 3038 3129 /* szRCMod */ 3039 " ",3130 "VBoxDDGC.gc", 3040 3131 /* szR0Mod */ 3041 " ",3132 "VBoxDDR0.r0", 3042 3133 /* pszDescription */ 3043 3134 "Intel HD Audio Controller", 3044 3135 /* fFlags */ 3045 PDM_DEVREG_FLAGS_DEFAULT_BITS ,3136 PDM_DEVREG_FLAGS_DEFAULT_BITS | PDM_DEVREG_FLAGS_RC | PDM_DEVREG_FLAGS_R0, 3046 3137 /* fClass */ 3047 3138 PDM_DEVREG_CLASS_AUDIO, … … 3081 3172 PDM_DEVREG_VERSION 3082 3173 }; 3174 3175 #endif /* IN_RING3 */ 3176 #endif /* !VBOX_DEVICE_STRUCT_TESTCASE */
Note:
See TracChangeset
for help on using the changeset viewer.