Changeset 71736 in vbox for trunk/src/VBox/Devices/Audio
- Timestamp:
- Apr 7, 2018 9:29:18 PM (7 years ago)
- Location:
- trunk/src/VBox/Devices/Audio
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/DevHDA.cpp
r71735 r71736 297 297 #ifndef VBOX_DEVICE_STRUCT_TESTCASE 298 298 #ifdef IN_RING3 299 static void hda GCTLReset(PHDASTATE pThis);299 static void hdaR3GCTLReset(PHDASTATE pThis); 300 300 #endif 301 301 … … 360 360 */ 361 361 #ifdef IN_RING3 362 static int hda AddStream(PHDASTATE pThis, PPDMAUDIOSTREAMCFG pCfg);363 static int hdaR emoveStream(PHDASTATE pThis, PPDMAUDIOSTREAMCFG pCfg);362 static int hdaR3AddStream(PHDASTATE pThis, PPDMAUDIOSTREAMCFG pCfg); 363 static int hdaR3RemoveStream(PHDASTATE pThis, PPDMAUDIOSTREAMCFG pCfg); 364 364 # ifdef HDA_USE_DMA_ACCESS_HANDLER 365 static DECLCALLBACK(VBOXSTRICTRC) hdaDMAAccessHandler(PVM pVM, PVMCPU pVCpu, RTGCPHYS GCPhys, void *pvPhys, void *pvBuf, size_t cbBuf, PGMACCESSTYPE enmAccessType, PGMACCESSORIGIN enmOrigin, void *pvUser); 365 static DECLCALLBACK(VBOXSTRICTRC) hdaR3DMAAccessHandler(PVM pVM, PVMCPU pVCpu, RTGCPHYS GCPhys, void *pvPhys, 366 void *pvBuf, size_t cbBuf, 367 PGMACCESSTYPE enmAccessType, PGMACCESSORIGIN enmOrigin, void *pvUser); 366 368 # endif 367 369 #endif /* IN_RING3 */ … … 570 572 * @param pThis The HDA device state. 571 573 */ 572 static void hdaR eschedulePendingInterrupts(PHDASTATE pThis)574 static void hdaR3ReschedulePendingInterrupts(PHDASTATE pThis) 573 575 { 574 576 bool fInterrupt = false; … … 580 582 continue; 581 583 582 if ( hda StreamPeriodIsComplete (&pStream->State.Period)583 && hda StreamPeriodNeedsInterrupt(&pStream->State.Period)584 && hda WalClkSet(pThis, hdaStreamPeriodGetAbsElapsedWalClk(&pStream->State.Period), false /* fForce */))584 if ( hdaR3StreamPeriodIsComplete (&pStream->State.Period) 585 && hdaR3StreamPeriodNeedsInterrupt(&pStream->State.Period) 586 && hdaR3WalClkSet(pThis, hdaR3StreamPeriodGetAbsElapsedWalClk(&pStream->State.Period), false /* fForce */)) 585 587 { 586 588 fInterrupt = true; … … 658 660 * @param offReg The register offset. 659 661 */ 660 static int hdaR egLookupWithin(uint32_t offReg)662 static int hdaR3RegLookupWithin(uint32_t offReg) 661 663 { 662 664 /* … … 1010 1012 HDA_REG(pThis, GCTL) &= ~HDA_GCTL_CRST; 1011 1013 1012 hda GCTLReset(pThis);1014 hdaR3GCTLReset(pThis); 1013 1015 #else 1014 1016 AssertFailedReturnStmt(DEVHDA_UNLOCK(pThis), VINF_IOM_R3_MMIO_WRITE); … … 1067 1069 * @remark Does not actually set the wall clock counter. 1068 1070 */ 1069 static uint64_t hda WalClkGetMax(PHDASTATE pThis)1071 static uint64_t hdaR3WalClkGetMax(PHDASTATE pThis) 1070 1072 { 1071 1073 const uint64_t u64WalClkCur = ASMAtomicReadU64(&pThis->u64WalClk); 1072 1074 const uint64_t u64FrontAbsWalClk = pThis->SinkFront.pStream 1073 ? hda StreamPeriodGetAbsElapsedWalClk(&pThis->SinkFront.pStream->State.Period) : 0;1075 ? hdaR3StreamPeriodGetAbsElapsedWalClk(&pThis->SinkFront.pStream->State.Period) : 0; 1074 1076 # ifdef VBOX_WITH_AUDIO_HDA_51_SURROUND 1075 1077 # error "Implement me!" 1076 1078 # endif 1077 1079 const uint64_t u64LineInAbsWalClk = pThis->SinkLineIn.pStream 1078 ? hda StreamPeriodGetAbsElapsedWalClk(&pThis->SinkLineIn.pStream->State.Period) : 0;1080 ? hdaR3StreamPeriodGetAbsElapsedWalClk(&pThis->SinkLineIn.pStream->State.Period) : 0; 1079 1081 # ifdef VBOX_WITH_HDA_MIC_IN 1080 1082 const uint64_t u64MicInAbsWalClk = pThis->SinkMicIn.pStream 1081 ? hda StreamPeriodGetAbsElapsedWalClk(&pThis->SinkMicIn.pStream->State.Period) : 0;1083 ? hdaR3StreamPeriodGetAbsElapsedWalClk(&pThis->SinkMicIn.pStream->State.Period) : 0; 1082 1084 # endif 1083 1085 … … 1107 1109 *pu32Value = RT_LO_U32(ASMAtomicReadU64(&pThis->u64WalClk)); 1108 1110 1109 Log3Func(("%RU32 (max @ %RU64)\n",*pu32Value, hda WalClkGetMax(pThis)));1111 Log3Func(("%RU32 (max @ %RU64)\n",*pu32Value, hdaR3WalClkGetMax(pThis))); 1110 1112 1111 1113 DEVHDA_UNLOCK(pThis); … … 1353 1355 LogFunc(("[SD%RU8] Reset enter\n", uSD)); 1354 1356 1355 hda StreamLock(pStream);1357 hdaR3StreamLock(pStream); 1356 1358 1357 1359 # ifdef VBOX_WITH_AUDIO_HDA_ASYNC_IO 1358 hda StreamAsyncIOLock(pStream);1359 hda StreamAsyncIOEnable(pStream, false /* fEnable */);1360 hdaR3StreamAsyncIOLock(pStream); 1361 hdaR3StreamAsyncIOEnable(pStream, false /* fEnable */); 1360 1362 # endif 1361 1363 /* Make sure to remove the run bit before doing the actual stream reset. */ 1362 1364 HDA_STREAM_REG(pThis, CTL, uSD) &= ~HDA_SDCTL_RUN; 1363 1365 1364 hda StreamReset(pThis, pStream, pStream->u8SD);1366 hdaR3StreamReset(pThis, pStream, pStream->u8SD); 1365 1367 1366 1368 # ifdef VBOX_WITH_AUDIO_HDA_ASYNC_IO 1367 hda StreamAsyncIOUnlock(pStream);1369 hdaR3StreamAsyncIOUnlock(pStream); 1368 1370 # endif 1369 hda StreamUnlock(pStream);1371 hdaR3StreamUnlock(pStream); 1370 1372 } 1371 1373 else … … 1379 1381 LogFunc(("[SD%RU8] State changed (fRun=%RTbool)\n", uSD, fRun)); 1380 1382 1381 hda StreamLock(pStream);1383 hdaR3StreamLock(pStream); 1382 1384 1383 1385 int rc2; … … 1385 1387 # ifdef VBOX_WITH_AUDIO_HDA_ASYNC_IO 1386 1388 if (fRun) 1387 rc2 = hda StreamAsyncIOCreate(pStream);1388 1389 hda StreamAsyncIOLock(pStream);1389 rc2 = hdaR3StreamAsyncIOCreate(pStream); 1390 1391 hdaR3StreamAsyncIOLock(pStream); 1390 1392 # endif 1391 1393 if (fRun) 1392 1394 { 1393 1395 # ifdef VBOX_WITH_AUDIO_HDA_ASYNC_IO 1394 hda StreamAsyncIOEnable(pStream, fRun /* fEnable */);1396 hdaR3StreamAsyncIOEnable(pStream, fRun /* fEnable */); 1395 1397 # endif 1396 1398 /* (Re-)initialize the stream with current values. */ 1397 rc2 = hda StreamInit(pStream, pStream->u8SD);1399 rc2 = hdaR3StreamInit(pStream, pStream->u8SD); 1398 1400 AssertRC(rc2); 1399 1401 1400 1402 /* Remove the old stream from the device setup. */ 1401 hdaR emoveStream(pThis, &pStream->State.Cfg);1403 hdaR3RemoveStream(pThis, &pStream->State.Cfg); 1402 1404 1403 1405 /* Add the stream to the device setup. */ 1404 rc2 = hda AddStream(pThis, &pStream->State.Cfg);1406 rc2 = hdaR3AddStream(pThis, &pStream->State.Cfg); 1405 1407 AssertRC(rc2); 1406 1408 } 1407 1409 1408 1410 /* Enable/disable the stream. */ 1409 rc2 = hda StreamEnable(pStream, fRun /* fEnable */);1411 rc2 = hdaR3StreamEnable(pStream, fRun /* fEnable */); 1410 1412 AssertRC(rc2); 1411 1413 … … 1416 1418 1417 1419 /* (Re-)init the stream's period. */ 1418 hda StreamPeriodInit(&pStream->State.Period,1419 pStream->u8SD, pStream->u16LVI, pStream->u32CBL, &pStream->State.Cfg);1420 hdaR3StreamPeriodInit(&pStream->State.Period, 1421 pStream->u8SD, pStream->u16LVI, pStream->u32CBL, &pStream->State.Cfg); 1420 1422 1421 1423 /* Begin a new period for this stream. */ 1422 rc2 = hda StreamPeriodBegin(&pStream->State.Period, hdaWalClkGetCurrent(pThis)/* Use current wall clock time */);1424 rc2 = hdaR3StreamPeriodBegin(&pStream->State.Period, hdaWalClkGetCurrent(pThis)/* Use current wall clock time */); 1423 1425 AssertRC(rc2); 1424 1426 1425 rc2 = hda TimerSet(pThis, pStream, TMTimerGet(pThis->pTimer[pStream->u8SD]) + pStream->State.cTransferTicks, false /* fForce */);1427 rc2 = hdaR3TimerSet(pThis, pStream, TMTimerGet(pThis->pTimer[pStream->u8SD]) + pStream->State.cTransferTicks, false /* fForce */); 1426 1428 AssertRC(rc2); 1427 1429 } … … 1434 1436 1435 1437 /* Make sure to (re-)schedule outstanding (delayed) interrupts. */ 1436 hdaR eschedulePendingInterrupts(pThis);1438 hdaR3ReschedulePendingInterrupts(pThis); 1437 1439 1438 1440 /* Reset the period. */ 1439 hda StreamPeriodReset(&pStream->State.Period);1441 hdaR3StreamPeriodReset(&pStream->State.Period); 1440 1442 } 1441 1443 1442 1444 # ifdef VBOX_WITH_AUDIO_HDA_ASYNC_IO 1443 hda StreamAsyncIOUnlock(pStream);1445 hdaR3StreamAsyncIOUnlock(pStream); 1444 1446 # endif 1445 1447 /* Make sure to leave the lock before (eventually) starting the timer. */ 1446 hda StreamUnlock(pStream);1448 hdaR3StreamUnlock(pStream); 1447 1449 } 1448 1450 } … … 1477 1479 } 1478 1480 1479 hda StreamLock(pStream);1481 hdaR3StreamLock(pStream); 1480 1482 1481 1483 uint32_t v = HDA_REG_IND(pThis, iReg); … … 1492 1494 PHDASTREAMPERIOD pPeriod = &pStream->State.Period; 1493 1495 1494 if (hda StreamPeriodLock(pPeriod))1495 { 1496 const bool fNeedsInterrupt = hda StreamPeriodNeedsInterrupt(pPeriod);1496 if (hdaR3StreamPeriodLock(pPeriod)) 1497 { 1498 const bool fNeedsInterrupt = hdaR3StreamPeriodNeedsInterrupt(pPeriod); 1497 1499 if (fNeedsInterrupt) 1498 hda StreamPeriodReleaseInterrupt(pPeriod);1499 1500 if (hda StreamPeriodIsComplete(pPeriod))1500 hdaR3StreamPeriodReleaseInterrupt(pPeriod); 1501 1502 if (hdaR3StreamPeriodIsComplete(pPeriod)) 1501 1503 { 1502 1504 /* Make sure to try to update the WALCLK register if a period is complete. 1503 1505 * Use the maximum WALCLK value all (active) streams agree to. */ 1504 const uint64_t uWalClkMax = hda WalClkGetMax(pThis);1506 const uint64_t uWalClkMax = hdaR3WalClkGetMax(pThis); 1505 1507 if (uWalClkMax > hdaWalClkGetCurrent(pThis)) 1506 hda WalClkSet(pThis, uWalClkMax, false /* fForce */);1507 1508 hda StreamPeriodEnd(pPeriod);1508 hdaR3WalClkSet(pThis, uWalClkMax, false /* fForce */); 1509 1510 hdaR3StreamPeriodEnd(pPeriod); 1509 1511 1510 1512 if (fRunning) 1511 hda StreamPeriodBegin(pPeriod, hdaWalClkGetCurrent(pThis) /* Use current wall clock time */);1512 } 1513 1514 hda StreamPeriodUnlock(pPeriod); /* Unlock before processing interrupt. */1513 hdaR3StreamPeriodBegin(pPeriod, hdaWalClkGetCurrent(pThis) /* Use current wall clock time */); 1514 } 1515 1516 hdaR3StreamPeriodUnlock(pPeriod); /* Unlock before processing interrupt. */ 1515 1517 } 1516 1518 … … 1569 1571 /* Re-arm the timer. */ 1570 1572 LogFunc(("Timer set SD%RU8\n", pStream->u8SD)); 1571 hda TimerSet(pThis, pStream, tsNow + cTicksToNext, false /* fForce */);1572 } 1573 } 1574 1575 hda StreamUnlock(pStream);1573 hdaR3TimerSet(pThis, pStream, tsNow + cTicksToNext, false /* fForce */); 1574 } 1575 } 1576 1577 hdaR3StreamUnlock(pStream); 1576 1578 1577 1579 DEVHDA_UNLOCK_BOTH(pThis, uSD); … … 1604 1606 /* Try registering the DMA handlers. 1605 1607 * As we can't be sure in which order LVI + BDL base are set, try registering in both routines. */ 1606 if (hda StreamRegisterDMAHandlers(pThis, pStream))1608 if (hdaR3StreamRegisterDMAHandlers(pThis, pStream)) 1607 1609 LogFunc(("[SD%RU8] DMA logging enabled\n", pStream->u8SD)); 1608 1610 } … … 1746 1748 * @param pCfg Stream configuration to use for adding a stream. 1747 1749 */ 1748 static int hda AddStreamOut(PHDASTATE pThis, PPDMAUDIOSTREAMCFG pCfg)1750 static int hdaR3AddStreamOut(PHDASTATE pThis, PPDMAUDIOSTREAMCFG pCfg) 1749 1751 { 1750 1752 AssertPtrReturn(pThis, VERR_INVALID_POINTER); … … 1883 1885 * @param pCfg Stream configuration to use for adding a stream. 1884 1886 */ 1885 static int hda AddStreamIn(PHDASTATE pThis, PPDMAUDIOSTREAMCFG pCfg)1887 static int hdaR3AddStreamIn(PHDASTATE pThis, PPDMAUDIOSTREAMCFG pCfg) 1886 1888 { 1887 1889 AssertPtrReturn(pThis, VERR_INVALID_POINTER); … … 1924 1926 * @param pCfg Stream configuration to use for adding a stream. 1925 1927 */ 1926 static int hda AddStream(PHDASTATE pThis, PPDMAUDIOSTREAMCFG pCfg)1928 static int hdaR3AddStream(PHDASTATE pThis, PPDMAUDIOSTREAMCFG pCfg) 1927 1929 { 1928 1930 AssertPtrReturn(pThis, VERR_INVALID_POINTER); … … 1936 1938 { 1937 1939 case PDMAUDIODIR_OUT: 1938 rc = hda AddStreamOut(pThis, pCfg);1940 rc = hdaR3AddStreamOut(pThis, pCfg); 1939 1941 break; 1940 1942 1941 1943 case PDMAUDIODIR_IN: 1942 rc = hda AddStreamIn(pThis, pCfg);1944 rc = hdaR3AddStreamIn(pThis, pCfg); 1943 1945 break; 1944 1946 … … 1961 1963 * @param pCfg Stream configuration to use for removing a stream. 1962 1964 */ 1963 static int hdaR emoveStream(PHDASTATE pThis, PPDMAUDIOSTREAMCFG pCfg)1965 static int hdaR3RemoveStream(PHDASTATE pThis, PPDMAUDIOSTREAMCFG pCfg) 1964 1966 { 1965 1967 AssertPtrReturn(pThis, VERR_INVALID_POINTER); … … 2076 2078 /* Try registering the DMA handlers. 2077 2079 * As we can't be sure in which order LVI + BDL base are set, try registering in both routines. */ 2078 if (hda StreamRegisterDMAHandlers(pThis, pStream))2080 if (hdaR3StreamRegisterDMAHandlers(pThis, pStream)) 2079 2081 LogFunc(("[SD%RU8] DMA logging enabled\n", pStream->u8SD)); 2080 2082 } … … 2307 2309 * @param enmMixerCtl Mixer control to get the corresponding sink for. 2308 2310 */ 2309 static PHDAMIXERSINK hda MixerControlToSink(PHDASTATE pThis, PDMAUDIOMIXERCTL enmMixerCtl)2311 static PHDAMIXERSINK hdaR3MixerControlToSink(PHDASTATE pThis, PDMAUDIOMIXERCTL enmMixerCtl) 2310 2312 { 2311 2313 PHDAMIXERSINK pSink; … … 2352 2354 * @param pDrv Driver stream to add. 2353 2355 */ 2354 static int hda MixerAddDrvStream(PHDASTATE pThis, PAUDMIXSINK pMixSink, PPDMAUDIOSTREAMCFG pCfg, PHDADRIVER pDrv)2356 static int hdaR3MixerAddDrvStream(PHDASTATE pThis, PAUDMIXSINK pMixSink, PPDMAUDIOSTREAMCFG pCfg, PHDADRIVER pDrv) 2355 2357 { 2356 2358 AssertPtrReturn(pThis, VERR_INVALID_POINTER); … … 2445 2447 * @param pCfg Audio stream configuration to use for the audio streams to add. 2446 2448 */ 2447 static int hda MixerAddDrvStreams(PHDASTATE pThis, PAUDMIXSINK pMixSink, PPDMAUDIOSTREAMCFG pCfg)2449 static int hdaR3MixerAddDrvStreams(PHDASTATE pThis, PAUDMIXSINK pMixSink, PPDMAUDIOSTREAMCFG pCfg) 2448 2450 { 2449 2451 AssertPtrReturn(pThis, VERR_INVALID_POINTER); … … 2463 2465 RTListForEach(&pThis->lstDrv, pDrv, HDADRIVER, Node) 2464 2466 { 2465 int rc2 = hda MixerAddDrvStream(pThis, pMixSink, pCfg, pDrv);2467 int rc2 = hdaR3MixerAddDrvStream(pThis, pMixSink, pCfg, pDrv); 2466 2468 if (RT_FAILURE(rc2)) 2467 2469 LogFunc(("Attaching stream failed with %Rrc\n", rc2)); … … 2487 2489 * @param pCfg Stream configuration for the new stream. 2488 2490 */ 2489 static DECLCALLBACK(int) hda MixerAddStream(PHDASTATE pThis, PDMAUDIOMIXERCTL enmMixerCtl, PPDMAUDIOSTREAMCFG pCfg)2491 static DECLCALLBACK(int) hdaR3MixerAddStream(PHDASTATE pThis, PDMAUDIOMIXERCTL enmMixerCtl, PPDMAUDIOSTREAMCFG pCfg) 2490 2492 { 2491 2493 AssertPtrReturn(pThis, VERR_INVALID_POINTER); … … 2494 2496 int rc; 2495 2497 2496 PHDAMIXERSINK pSink = hda MixerControlToSink(pThis, enmMixerCtl);2498 PHDAMIXERSINK pSink = hdaR3MixerControlToSink(pThis, enmMixerCtl); 2497 2499 if (pSink) 2498 2500 { 2499 rc = hda MixerAddDrvStreams(pThis, pSink->pMixSink, pCfg);2501 rc = hdaR3MixerAddDrvStreams(pThis, pSink->pMixSink, pCfg); 2500 2502 2501 2503 AssertPtr(pSink->pMixSink); … … 2520 2522 * @remarks Can be called as a callback by the HDA codec. 2521 2523 */ 2522 static DECLCALLBACK(int) hda MixerRemoveStream(PHDASTATE pThis, PDMAUDIOMIXERCTL enmMixerCtl)2524 static DECLCALLBACK(int) hdaR3MixerRemoveStream(PHDASTATE pThis, PDMAUDIOMIXERCTL enmMixerCtl) 2523 2525 { 2524 2526 AssertPtrReturn(pThis, VERR_INVALID_POINTER); … … 2526 2528 int rc; 2527 2529 2528 PHDAMIXERSINK pSink = hda MixerControlToSink(pThis, enmMixerCtl);2530 PHDAMIXERSINK pSink = hdaR3MixerControlToSink(pThis, enmMixerCtl); 2529 2531 if (pSink) 2530 2532 { … … 2603 2605 * @remarks Can be called as a callback by the HDA codec. 2604 2606 */ 2605 static DECLCALLBACK(int) hda MixerControl(PHDASTATE pThis, PDMAUDIOMIXERCTL enmMixerCtl, uint8_t uSD, uint8_t uChannel)2607 static DECLCALLBACK(int) hdaR3MixerControl(PHDASTATE pThis, PDMAUDIOMIXERCTL enmMixerCtl, uint8_t uSD, uint8_t uChannel) 2606 2608 { 2607 2609 LogFunc(("enmMixerCtl=%s, uSD=%RU8, uChannel=%RU8\n", DrvAudioHlpAudMixerCtlToStr(enmMixerCtl), uSD, uChannel)); … … 2630 2632 int rc = VINF_SUCCESS; 2631 2633 2632 PHDAMIXERSINK pSink = hda MixerControlToSink(pThis, enmMixerCtl);2634 PHDAMIXERSINK pSink = hdaR3MixerControlToSink(pThis, enmMixerCtl); 2633 2635 if (pSink) 2634 2636 { … … 2651 2653 pSink->pMixSink->pszName, pSink->pStream->u8SD, pSink->pStream->u8Channel)); 2652 2654 2653 hda StreamLock(pSink->pStream);2655 hdaR3StreamLock(pSink->pStream); 2654 2656 2655 2657 /* Only disable the stream if the stream descriptor # has changed. */ 2656 2658 if (pSink->pStream->u8SD != uSD) 2657 hda StreamEnable(pSink->pStream, false);2659 hdaR3StreamEnable(pSink->pStream, false); 2658 2660 2659 2661 pSink->pStream->pMixSink = NULL; 2660 2662 2661 hda StreamUnlock(pSink->pStream);2663 hdaR3StreamUnlock(pSink->pStream); 2662 2664 2663 2665 pSink->pStream = NULL; … … 2676 2678 if (pStream) 2677 2679 { 2678 hda StreamLock(pStream);2680 hdaR3StreamLock(pStream); 2679 2681 2680 2682 pSink->pStream = pStream; … … 2683 2685 pStream->pMixSink = pSink; 2684 2686 2685 hda StreamUnlock(pStream);2687 hdaR3StreamUnlock(pStream); 2686 2688 2687 2689 rc = VINF_SUCCESS; … … 2714 2716 * @remarks Can be called as a callback by the HDA codec. 2715 2717 */ 2716 static DECLCALLBACK(int) hdaMixerSetVolume(PHDASTATE pThis, 2717 PDMAUDIOMIXERCTL enmMixerCtl, PPDMAUDIOVOLUME pVol) 2718 static DECLCALLBACK(int) hdaR3MixerSetVolume(PHDASTATE pThis, PDMAUDIOMIXERCTL enmMixerCtl, PPDMAUDIOVOLUME pVol) 2718 2719 { 2719 2720 int rc; 2720 2721 2721 PHDAMIXERSINK pSink = hda MixerControlToSink(pThis, enmMixerCtl);2722 PHDAMIXERSINK pSink = hdaR3MixerControlToSink(pThis, enmMixerCtl); 2722 2723 if ( pSink 2723 2724 && pSink->pMixSink) … … 2744 2745 * @param pvUser Pointer to associated HDASTREAM. 2745 2746 */ 2746 static DECLCALLBACK(void) hda Timer(PPDMDEVINS pDevIns, PTMTIMER pTimer, void *pvUser)2747 static DECLCALLBACK(void) hdaR3Timer(PPDMDEVINS pDevIns, PTMTIMER pTimer, void *pvUser) 2747 2748 { 2748 2749 RT_NOREF(pDevIns, pTimer); … … 2755 2756 DEVHDA_LOCK_BOTH_RETURN_VOID(pStream->pHDAState, pStream->u8SD); 2756 2757 2757 hda StreamUpdate(pStream, true /* fInTimer */);2758 hdaR3StreamUpdate(pStream, true /* fInTimer */); 2758 2759 2759 2760 /* Flag indicating whether to kick the timer again for a … … 2762 2763 if (fSinkActive) 2763 2764 { 2764 const bool fTimerScheduled = hda StreamTransferIsScheduled(pStream);2765 const bool fTimerScheduled = hdaR3StreamTransferIsScheduled(pStream); 2765 2766 Log3Func(("fSinksActive=%RTbool, fTimerScheduled=%RTbool\n", fSinkActive, fTimerScheduled)); 2766 2767 if (!fTimerScheduled) 2767 hda TimerSet(pThis, pStream,2768 TMTimerGet(pThis->pTimer[pStream->u8SD])2769 + TMTimerGetFreq(pThis->pTimer[pStream->u8SD]) / pStream->pHDAState->u16TimerHz,2770 true /* fForce */);2768 hdaR3TimerSet(pThis, pStream, 2769 TMTimerGet(pThis->pTimer[pStream->u8SD]) 2770 + TMTimerGetFreq(pThis->pTimer[pStream->u8SD]) / pStream->pHDAState->u16TimerHz, 2771 true /* fForce */); 2771 2772 } 2772 2773 else … … 2792 2793 * @param pvUser User argument. 2793 2794 */ 2794 static DECLCALLBACK(VBOXSTRICTRC) hda DMAAccessHandler(PVM pVM, PVMCPU pVCpu, RTGCPHYS GCPhys, void *pvPhys,2795 void *pvBuf, size_t cbBuf,2796 PGMACCESSTYPE enmAccessType, PGMACCESSORIGIN enmOrigin, void *pvUser)2795 static DECLCALLBACK(VBOXSTRICTRC) hdaR3DMAAccessHandler(PVM pVM, PVMCPU pVCpu, RTGCPHYS GCPhys, void *pvPhys, 2796 void *pvBuf, size_t cbBuf, 2797 PGMACCESSTYPE enmAccessType, PGMACCESSORIGIN enmOrigin, void *pvUser) 2797 2798 { 2798 2799 RT_NOREF(pVM, pVCpu, pvPhys, pvBuf, enmOrigin); … … 2915 2916 * 2916 2917 */ 2917 static void hda GCTLReset(PHDASTATE pThis)2918 static void hdaR3GCTLReset(PHDASTATE pThis) 2918 2919 { 2919 2920 LogFlowFuncEnter(); … … 2975 2976 */ 2976 2977 # ifdef VBOX_WITH_AUDIO_HDA_MIC_IN 2977 hda MixerControl(pThis, PDMAUDIOMIXERCTL_MIC_IN , 1 /* SD0 */, 0 /* Channel */);2978 hdaR3MixerControl(pThis, PDMAUDIOMIXERCTL_MIC_IN , 1 /* SD0 */, 0 /* Channel */); 2978 2979 # endif 2979 hda MixerControl(pThis, PDMAUDIOMIXERCTL_LINE_IN , 1 /* SD0 */, 0 /* Channel */);2980 2981 hda MixerControl(pThis, PDMAUDIOMIXERCTL_FRONT , 5 /* SD4 */, 0 /* Channel */);2980 hdaR3MixerControl(pThis, PDMAUDIOMIXERCTL_LINE_IN , 1 /* SD0 */, 0 /* Channel */); 2981 2982 hdaR3MixerControl(pThis, PDMAUDIOMIXERCTL_FRONT , 5 /* SD4 */, 0 /* Channel */); 2982 2983 # ifdef VBOX_WITH_AUDIO_HDA_51_SURROUND 2983 hda MixerControl(pThis, PDMAUDIOMIXERCTL_CENTER_LFE, 5 /* SD4 */, 0 /* Channel */);2984 hda MixerControl(pThis, PDMAUDIOMIXERCTL_REAR , 5 /* SD4 */, 0 /* Channel */);2984 hdaR3MixerControl(pThis, PDMAUDIOMIXERCTL_CENTER_LFE, 5 /* SD4 */, 0 /* Channel */); 2985 hdaR3MixerControl(pThis, PDMAUDIOMIXERCTL_REAR , 5 /* SD4 */, 0 /* Channel */); 2985 2986 # endif 2986 2987 … … 2998 2999 for (uint8_t uSD = 0; uSD < HDA_MAX_STREAMS; ++uSD) 2999 3000 { 3000 int rc2 = hda StreamEnable(&pThis->aStreams[uSD], false /* fEnable */);3001 int rc2 = hdaR3StreamEnable(&pThis->aStreams[uSD], false /* fEnable */); 3001 3002 if (RT_SUCCESS(rc2)) 3002 3003 { 3003 3004 /* Remove the RUN bit from SDnCTL in case the stream was in a running state before. */ 3004 3005 HDA_STREAM_REG(pThis, CTL, uSD) &= ~HDA_SDCTL_RUN; 3005 hda StreamReset(pThis, &pThis->aStreams[uSD], uSD);3006 hdaR3StreamReset(pThis, &pThis->aStreams[uSD], uSD); 3006 3007 } 3007 3008 } … … 3267 3268 * shifting out input values. 3268 3269 */ 3269 if (idxRegDsc == -1 && (idxRegDsc = hdaR egLookupWithin(offReg)) != -1)3270 if (idxRegDsc == -1 && (idxRegDsc = hdaR3RegLookupWithin(offReg)) != -1) 3270 3271 { 3271 3272 uint32_t const cbBefore = offReg - g_aHdaRegMap[idxRegDsc].offset; Assert(cbBefore > 0 && cbBefore < 4); … … 3342 3343 * @callback_method_impl{FNPCIIOREGIONMAP} 3343 3344 */ 3344 static DECLCALLBACK(int) hdaPciIoRegionMap(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, uint32_t iRegion,3345 RTGCPHYS GCPhysAddress, RTGCPHYS cb, PCIADDRESSSPACE enmType)3345 static DECLCALLBACK(int) hdaR3PciIoRegionMap(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, uint32_t iRegion, 3346 RTGCPHYS GCPhysAddress, RTGCPHYS cb, PCIADDRESSSPACE enmType) 3346 3347 { 3347 3348 RT_NOREF(iRegion, enmType); 3348 PHDASTATE 3349 PHDASTATE pThis = RT_FROM_MEMBER(pPciDev, HDASTATE, PciDev); 3349 3350 3350 3351 /* … … 3381 3382 3382 3383 3383 /* Saved state callbacks. */3384 3385 static int hda SaveStream(PPDMDEVINS pDevIns, PSSMHANDLE pSSM, PHDASTREAM pStream)3384 /* Saved state workers and callbacks. */ 3385 3386 static int hdaR3SaveStream(PPDMDEVINS pDevIns, PSSMHANDLE pSSM, PHDASTREAM pStream) 3386 3387 { 3387 3388 RT_NOREF(pDevIns); … … 3430 3431 3431 3432 HDABDLE curBDLE; 3432 rc = hda BDLEFetch(pThis, &curBDLE, u64BaseDMA, pStream->State.uCurBDLE);3433 rc = hdaR3BDLEFetch(pThis, &curBDLE, u64BaseDMA, pStream->State.uCurBDLE); 3433 3434 AssertRC(rc); 3434 3435 … … 3506 3507 3507 3508 #ifdef LOG_ENABLED 3508 hda BDLEDumpAll(pThis, pStream->u64BDLBase, pStream->u16LVI + 1);3509 hdaR3BDLEDumpAll(pThis, pStream->u64BDLBase, pStream->u16LVI + 1); 3509 3510 #endif 3510 3511 … … 3515 3516 * @callback_method_impl{FNSSMDEVSAVEEXEC} 3516 3517 */ 3517 static DECLCALLBACK(int) hda SaveExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM)3518 static DECLCALLBACK(int) hdaR3SaveExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM) 3518 3519 { 3519 3520 PHDASTATE pThis = PDMINS_2_DATA(pDevIns, PHDASTATE); … … 3536 3537 for (uint8_t i = 0; i < HDA_MAX_STREAMS; i++) 3537 3538 { 3538 int rc = hda SaveStream(pDevIns, pSSM, &pThis->aStreams[i]);3539 int rc = hdaR3SaveStream(pDevIns, pSSM, &pThis->aStreams[i]); 3539 3540 AssertRCReturn(rc, rc); 3540 3541 } … … 3548 3549 * @param pThis Pointer to HDA state. 3549 3550 */ 3550 static int hda LoadExecPost(PHDASTATE pThis)3551 static int hdaR3LoadExecPost(PHDASTATE pThis) 3551 3552 { 3552 3553 int rc = VINF_SUCCESS; … … 3567 3568 #ifdef VBOX_WITH_AUDIO_HDA_ASYNC_IO 3568 3569 /* Make sure to also create the async I/O thread before actually enabling the stream. */ 3569 rc2 = hda StreamAsyncIOCreate(pStream);3570 rc2 = hdaR3StreamAsyncIOCreate(pStream); 3570 3571 AssertRC(rc2); 3571 3572 3572 3573 /* ... and enabling it. */ 3573 hda StreamAsyncIOEnable(pStream, true /* fEnable */);3574 hdaR3StreamAsyncIOEnable(pStream, true /* fEnable */); 3574 3575 #endif 3575 3576 /* Resume the stream's period. */ 3576 hda StreamPeriodResume(&pStream->State.Period);3577 hdaR3StreamPeriodResume(&pStream->State.Period); 3577 3578 3578 3579 /* (Re-)enable the stream. */ 3579 rc2 = hda StreamEnable(pStream, true /* fEnable */);3580 rc2 = hdaR3StreamEnable(pStream, true /* fEnable */); 3580 3581 AssertRC(rc2); 3581 3582 3582 3583 /* Add the stream to the device setup. */ 3583 rc2 = hda AddStream(pThis, &pStream->State.Cfg);3584 rc2 = hdaR3AddStream(pThis, &pStream->State.Cfg); 3584 3585 AssertRC(rc2); 3585 3586 3586 3587 #ifdef HDA_USE_DMA_ACCESS_HANDLER 3587 3588 /* (Re-)install the DMA handler. */ 3588 hda StreamRegisterDMAHandlers(pThis, pStream);3589 hdaR3StreamRegisterDMAHandlers(pThis, pStream); 3589 3590 #endif 3590 if (hda StreamTransferIsScheduled(pStream))3591 hda TimerSet(pThis, pStream, hdaStreamTransferGetNext(pStream), true /* fForce */);3591 if (hdaR3StreamTransferIsScheduled(pStream)) 3592 hdaR3TimerSet(pThis, pStream, hdaR3StreamTransferGetNext(pStream), true /* fForce */); 3592 3593 3593 3594 /* Also keep track of the currently active streams. */ … … 3610 3611 * @param uPass Loading stage to handle. 3611 3612 */ 3612 static int hda LoadExecLegacy(PHDASTATE pThis, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass)3613 static int hdaR3LoadExecLegacy(PHDASTATE pThis, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass) 3613 3614 { 3614 3615 RT_NOREF(uPass); … … 3727 3728 /* Output */ 3728 3729 PHDASTREAM pStream = &pThis->aStreams[4]; 3729 rc = hda StreamInit(pStream, 4 /* Stream descriptor, hardcoded */);3730 rc = hdaR3StreamInit(pStream, 4 /* Stream descriptor, hardcoded */); 3730 3731 if (RT_FAILURE(rc)) 3731 3732 break; … … 3735 3736 /* Microphone-In */ 3736 3737 pStream = &pThis->aStreams[2]; 3737 rc = hda StreamInit(pStream, 2 /* Stream descriptor, hardcoded */);3738 rc = hdaR3StreamInit(pStream, 2 /* Stream descriptor, hardcoded */); 3738 3739 if (RT_FAILURE(rc)) 3739 3740 break; … … 3743 3744 /* Line-In */ 3744 3745 pStream = &pThis->aStreams[0]; 3745 rc = hda StreamInit(pStream, 0 /* Stream descriptor, hardcoded */);3746 rc = hdaR3StreamInit(pStream, 0 /* Stream descriptor, hardcoded */); 3746 3747 if (RT_FAILURE(rc)) 3747 3748 break; … … 3780 3781 } 3781 3782 3782 rc = hda StreamInit(pStream, uStreamID);3783 rc = hdaR3StreamInit(pStream, uStreamID); 3783 3784 if (RT_FAILURE(rc)) 3784 3785 { … … 3868 3869 HDA_STREAM_REG(pThis, LPIB, uStreamID), HDA_STREAM_REG(pThis, CBL, uStreamID), HDA_STREAM_REG(pThis, LVI, uStreamID))); 3869 3870 #ifdef LOG_ENABLED 3870 hda BDLEDumpAll(pThis, pStream->u64BDLBase, pStream->u16LVI + 1);3871 hdaR3BDLEDumpAll(pThis, pStream->u64BDLBase, pStream->u16LVI + 1); 3871 3872 #endif 3872 3873 } … … 3883 3884 * @callback_method_impl{FNSSMDEVLOADEXEC} 3884 3885 */ 3885 static DECLCALLBACK(int) hda LoadExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass)3886 static DECLCALLBACK(int) hdaR3LoadExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass) 3886 3887 { 3887 3888 PHDASTATE pThis = PDMINS_2_DATA(pDevIns, PHDASTATE); … … 3889 3890 Assert(uPass == SSM_PASS_FINAL); NOREF(uPass); 3890 3891 3891 LogRel2(("hda LoadExec: uVersion=%RU32, uPass=0x%x\n", uVersion, uPass));3892 LogRel2(("hdaR3LoadExec: uVersion=%RU32, uPass=0x%x\n", uVersion, uPass)); 3892 3893 3893 3894 /* … … 3903 3904 if (uVersion < HDA_SSM_VERSION) /* Handle older saved states? */ 3904 3905 { 3905 rc = hda LoadExecLegacy(pThis, pSSM, uVersion, uPass);3906 rc = hdaR3LoadExecLegacy(pThis, pSSM, uVersion, uPass); 3906 3907 if (RT_SUCCESS(rc)) 3907 rc = hda LoadExecPost(pThis);3908 rc = hdaR3LoadExecPost(pThis); 3908 3909 3909 3910 return rc; … … 3976 3977 } 3977 3978 3978 rc = hda StreamInit(pStream, uStreamID);3979 rc = hdaR3StreamInit(pStream, uStreamID); 3979 3980 if (RT_FAILURE(rc)) 3980 3981 { … … 4005 4006 * Don't annoy other team mates (forgot this for state v7). 4006 4007 */ 4007 hda StreamPeriodInit(&pStream->State.Period,4008 pStream->u8SD, pStream->u16LVI, pStream->u32CBL, &pStream->State.Cfg);4008 hdaR3StreamPeriodInit(&pStream->State.Period, 4009 pStream->u8SD, pStream->u16LVI, pStream->u32CBL, &pStream->State.Cfg); 4009 4010 4010 4011 if ( SSMR3HandleRevision(pSSM) >= 116273 … … 4072 4073 HDA_STREAM_REG(pThis, LPIB, uStreamID), HDA_STREAM_REG(pThis, CBL, uStreamID), HDA_STREAM_REG(pThis, LVI, uStreamID))); 4073 4074 #ifdef LOG_ENABLED 4074 hda BDLEDumpAll(pThis, pStream->u64BDLBase, pStream->u16LVI + 1);4075 hdaR3BDLEDumpAll(pThis, pStream->u64BDLBase, pStream->u16LVI + 1); 4075 4076 #endif 4076 4077 /** @todo (Re-)initialize active periods? */ … … 4078 4079 } /* for cStreams */ 4079 4080 4080 rc = hda LoadExecPost(pThis);4081 rc = hdaR3LoadExecPost(pThis); 4081 4082 AssertRC(rc); 4082 4083 … … 4085 4086 } 4086 4087 4087 /* Debug and log type formatters. */4088 /* IPRT format type handlers. */ 4088 4089 4089 4090 /** 4090 4091 * @callback_method_impl{FNRTSTRFORMATTYPE} 4091 4092 */ 4092 static DECLCALLBACK(size_t) hda DbgFmtBDLE(PFNRTSTROUTPUT pfnOutput, void *pvArgOutput,4093 const char *pszType, void const *pvValue,4094 int cchWidth, int cchPrecision, unsigned fFlags,4095 void *pvUser)4093 static DECLCALLBACK(size_t) hdaR3StrFmtBDLE(PFNRTSTROUTPUT pfnOutput, void *pvArgOutput, 4094 const char *pszType, void const *pvValue, 4095 int cchWidth, int cchPrecision, unsigned fFlags, 4096 void *pvUser) 4096 4097 { 4097 4098 RT_NOREF(pszType, cchWidth, cchPrecision, fFlags, pvUser); … … 4106 4107 * @callback_method_impl{FNRTSTRFORMATTYPE} 4107 4108 */ 4108 static DECLCALLBACK(size_t) hda DbgFmtSDCTL(PFNRTSTROUTPUT pfnOutput, void *pvArgOutput,4109 const char *pszType, void const *pvValue,4110 int cchWidth, int cchPrecision, unsigned fFlags,4111 void *pvUser)4109 static DECLCALLBACK(size_t) hdaR3StrFmtSDCTL(PFNRTSTROUTPUT pfnOutput, void *pvArgOutput, 4110 const char *pszType, void const *pvValue, 4111 int cchWidth, int cchPrecision, unsigned fFlags, 4112 void *pvUser) 4112 4113 { 4113 4114 RT_NOREF(pszType, cchWidth, cchPrecision, fFlags, pvUser); … … 4129 4130 * @callback_method_impl{FNRTSTRFORMATTYPE} 4130 4131 */ 4131 static DECLCALLBACK(size_t) hdaDbgFmtSDFIFOS(PFNRTSTROUTPUT pfnOutput, void *pvArgOutput, 4132 static DECLCALLBACK(size_t) hdaR3StrFmtSDFIFOS(PFNRTSTROUTPUT pfnOutput, void *pvArgOutput, 4133 const char *pszType, void const *pvValue, 4134 int cchWidth, int cchPrecision, unsigned fFlags, 4135 void *pvUser) 4136 { 4137 RT_NOREF(pszType, cchWidth, cchPrecision, fFlags, pvUser); 4138 uint32_t uSDFIFOS = (uint32_t)(uintptr_t)pvValue; 4139 return RTStrFormat(pfnOutput, pvArgOutput, NULL, 0, "SDFIFOS(raw:%#x, sdfifos:%RU8 B)", uSDFIFOS, uSDFIFOS ? uSDFIFOS + 1 : 0); 4140 } 4141 4142 /** 4143 * @callback_method_impl{FNRTSTRFORMATTYPE} 4144 */ 4145 static DECLCALLBACK(size_t) hdaR3StrFmtSDFIFOW(PFNRTSTROUTPUT pfnOutput, void *pvArgOutput, 4146 const char *pszType, void const *pvValue, 4147 int cchWidth, int cchPrecision, unsigned fFlags, 4148 void *pvUser) 4149 { 4150 RT_NOREF(pszType, cchWidth, cchPrecision, fFlags, pvUser); 4151 uint32_t uSDFIFOW = (uint32_t)(uintptr_t)pvValue; 4152 return RTStrFormat(pfnOutput, pvArgOutput, NULL, 0, "SDFIFOW(raw: %#0x, sdfifow:%d B)", uSDFIFOW, hdaSDFIFOWToBytes(uSDFIFOW)); 4153 } 4154 4155 /** 4156 * @callback_method_impl{FNRTSTRFORMATTYPE} 4157 */ 4158 static DECLCALLBACK(size_t) hdaR3StrFmtSDSTS(PFNRTSTROUTPUT pfnOutput, void *pvArgOutput, 4132 4159 const char *pszType, void const *pvValue, 4133 4160 int cchWidth, int cchPrecision, unsigned fFlags, 4134 4161 void *pvUser) 4135 {4136 RT_NOREF(pszType, cchWidth, cchPrecision, fFlags, pvUser);4137 uint32_t uSDFIFOS = (uint32_t)(uintptr_t)pvValue;4138 return RTStrFormat(pfnOutput, pvArgOutput, NULL, 0, "SDFIFOS(raw:%#x, sdfifos:%RU8 B)", uSDFIFOS, uSDFIFOS ? uSDFIFOS + 1 : 0);4139 }4140 4141 /**4142 * @callback_method_impl{FNRTSTRFORMATTYPE}4143 */4144 static DECLCALLBACK(size_t) hdaDbgFmtSDFIFOW(PFNRTSTROUTPUT pfnOutput, void *pvArgOutput,4145 const char *pszType, void const *pvValue,4146 int cchWidth, int cchPrecision, unsigned fFlags,4147 void *pvUser)4148 {4149 RT_NOREF(pszType, cchWidth, cchPrecision, fFlags, pvUser);4150 uint32_t uSDFIFOW = (uint32_t)(uintptr_t)pvValue;4151 return RTStrFormat(pfnOutput, pvArgOutput, NULL, 0, "SDFIFOW(raw: %#0x, sdfifow:%d B)", uSDFIFOW, hdaSDFIFOWToBytes(uSDFIFOW));4152 }4153 4154 /**4155 * @callback_method_impl{FNRTSTRFORMATTYPE}4156 */4157 static DECLCALLBACK(size_t) hdaDbgFmtSDSTS(PFNRTSTROUTPUT pfnOutput, void *pvArgOutput,4158 const char *pszType, void const *pvValue,4159 int cchWidth, int cchPrecision, unsigned fFlags,4160 void *pvUser)4161 4162 { 4162 4163 RT_NOREF(pszType, cchWidth, cchPrecision, fFlags, pvUser); … … 4171 4172 } 4172 4173 4173 static int hdaDbgLookupRegByName(const char *pszArgs) 4174 /* Debug info dumpers */ 4175 4176 static int hdaR3DbgLookupRegByName(const char *pszArgs) 4174 4177 { 4175 4178 int iReg = 0; … … 4181 4184 4182 4185 4183 static void hda DbgPrintRegister(PHDASTATE pThis, PCDBGFINFOHLP pHlp, int iHdaIndex)4186 static void hdaR3DbgPrintRegister(PHDASTATE pThis, PCDBGFINFOHLP pHlp, int iHdaIndex) 4184 4187 { 4185 4188 Assert( pThis … … 4192 4195 * @callback_method_impl{FNDBGFHANDLERDEV} 4193 4196 */ 4194 static DECLCALLBACK(void) hda DbgInfo(PPDMDEVINS pDevIns, PCDBGFINFOHLP pHlp, const char *pszArgs)4197 static DECLCALLBACK(void) hdaR3DbgInfo(PPDMDEVINS pDevIns, PCDBGFINFOHLP pHlp, const char *pszArgs) 4195 4198 { 4196 4199 PHDASTATE pThis = PDMINS_2_DATA(pDevIns, PHDASTATE); 4197 int iHdaRegisterIndex = hda DbgLookupRegByName(pszArgs);4200 int iHdaRegisterIndex = hdaR3DbgLookupRegByName(pszArgs); 4198 4201 if (iHdaRegisterIndex != -1) 4199 hda DbgPrintRegister(pThis, pHlp, iHdaRegisterIndex);4202 hdaR3DbgPrintRegister(pThis, pHlp, iHdaRegisterIndex); 4200 4203 else 4201 4204 { 4202 4205 for(iHdaRegisterIndex = 0; (unsigned int)iHdaRegisterIndex < HDA_NUM_REGS; ++iHdaRegisterIndex) 4203 hda DbgPrintRegister(pThis, pHlp, iHdaRegisterIndex);4204 } 4205 } 4206 4207 static void hda DbgPrintStream(PHDASTATE pThis, PCDBGFINFOHLP pHlp, int iIdx)4206 hdaR3DbgPrintRegister(pThis, pHlp, iHdaRegisterIndex); 4207 } 4208 } 4209 4210 static void hdaR3DbgPrintStream(PHDASTATE pThis, PCDBGFINFOHLP pHlp, int iIdx) 4208 4211 { 4209 4212 Assert( pThis … … 4221 4224 } 4222 4225 4223 static void hda DbgPrintBDLE(PHDASTATE pThis, PCDBGFINFOHLP pHlp, int iIdx)4226 static void hdaR3DbgPrintBDLE(PHDASTATE pThis, PCDBGFINFOHLP pHlp, int iIdx) 4224 4227 { 4225 4228 Assert( pThis … … 4278 4281 } 4279 4282 4280 static int hda DbgLookupStrmIdx(PHDASTATE pThis, const char *pszArgs)4283 static int hdaR3DbgLookupStrmIdx(PHDASTATE pThis, const char *pszArgs) 4281 4284 { 4282 4285 RT_NOREF(pThis, pszArgs); … … 4288 4291 * @callback_method_impl{FNDBGFHANDLERDEV} 4289 4292 */ 4290 static DECLCALLBACK(void) hda DbgInfoStream(PPDMDEVINS pDevIns, PCDBGFINFOHLP pHlp, const char *pszArgs)4293 static DECLCALLBACK(void) hdaR3DbgInfoStream(PPDMDEVINS pDevIns, PCDBGFINFOHLP pHlp, const char *pszArgs) 4291 4294 { 4292 4295 PHDASTATE pThis = PDMINS_2_DATA(pDevIns, PHDASTATE); 4293 int iHdaStreamdex = hda DbgLookupStrmIdx(pThis, pszArgs);4296 int iHdaStreamdex = hdaR3DbgLookupStrmIdx(pThis, pszArgs); 4294 4297 if (iHdaStreamdex != -1) 4295 hda DbgPrintStream(pThis, pHlp, iHdaStreamdex);4298 hdaR3DbgPrintStream(pThis, pHlp, iHdaStreamdex); 4296 4299 else 4297 4300 for(iHdaStreamdex = 0; iHdaStreamdex < HDA_MAX_STREAMS; ++iHdaStreamdex) 4298 hda DbgPrintStream(pThis, pHlp, iHdaStreamdex);4301 hdaR3DbgPrintStream(pThis, pHlp, iHdaStreamdex); 4299 4302 } 4300 4303 … … 4302 4305 * @callback_method_impl{FNDBGFHANDLERDEV} 4303 4306 */ 4304 static DECLCALLBACK(void) hda DbgInfoBDLE(PPDMDEVINS pDevIns, PCDBGFINFOHLP pHlp, const char *pszArgs)4307 static DECLCALLBACK(void) hdaR3DbgInfoBDLE(PPDMDEVINS pDevIns, PCDBGFINFOHLP pHlp, const char *pszArgs) 4305 4308 { 4306 4309 PHDASTATE pThis = PDMINS_2_DATA(pDevIns, PHDASTATE); 4307 int iHdaStreamdex = hda DbgLookupStrmIdx(pThis, pszArgs);4310 int iHdaStreamdex = hdaR3DbgLookupStrmIdx(pThis, pszArgs); 4308 4311 if (iHdaStreamdex != -1) 4309 hda DbgPrintBDLE(pThis, pHlp, iHdaStreamdex);4312 hdaR3DbgPrintBDLE(pThis, pHlp, iHdaStreamdex); 4310 4313 else 4311 for (iHdaStreamdex = 0; iHdaStreamdex < HDA_MAX_STREAMS; ++iHdaStreamdex)4312 hda DbgPrintBDLE(pThis, pHlp, iHdaStreamdex);4314 for (iHdaStreamdex = 0; iHdaStreamdex < HDA_MAX_STREAMS; ++iHdaStreamdex) 4315 hdaR3DbgPrintBDLE(pThis, pHlp, iHdaStreamdex); 4313 4316 } 4314 4317 … … 4316 4319 * @callback_method_impl{FNDBGFHANDLERDEV} 4317 4320 */ 4318 static DECLCALLBACK(void) hda DbgInfoCodecNodes(PPDMDEVINS pDevIns, PCDBGFINFOHLP pHlp, const char *pszArgs)4321 static DECLCALLBACK(void) hdaR3DbgInfoCodecNodes(PPDMDEVINS pDevIns, PCDBGFINFOHLP pHlp, const char *pszArgs) 4319 4322 { 4320 4323 PHDASTATE pThis = PDMINS_2_DATA(pDevIns, PHDASTATE); … … 4329 4332 * @callback_method_impl{FNDBGFHANDLERDEV} 4330 4333 */ 4331 static DECLCALLBACK(void) hda DbgInfoCodecSelector(PPDMDEVINS pDevIns, PCDBGFINFOHLP pHlp, const char *pszArgs)4334 static DECLCALLBACK(void) hdaR3DbgInfoCodecSelector(PPDMDEVINS pDevIns, PCDBGFINFOHLP pHlp, const char *pszArgs) 4332 4335 { 4333 4336 PHDASTATE pThis = PDMINS_2_DATA(pDevIns, PHDASTATE); … … 4342 4345 * @callback_method_impl{FNDBGFHANDLERDEV} 4343 4346 */ 4344 static DECLCALLBACK(void) hda DbgInfoMixer(PPDMDEVINS pDevIns, PCDBGFINFOHLP pHlp, const char *pszArgs)4347 static DECLCALLBACK(void) hdaR3DbgInfoMixer(PPDMDEVINS pDevIns, PCDBGFINFOHLP pHlp, const char *pszArgs) 4345 4348 { 4346 4349 PHDASTATE pThis = PDMINS_2_DATA(pDevIns, PHDASTATE); … … 4358 4361 * @interface_method_impl{PDMIBASE,pfnQueryInterface} 4359 4362 */ 4360 static DECLCALLBACK(void *) hda QueryInterface(struct PDMIBASE *pInterface, const char *pszIID)4363 static DECLCALLBACK(void *) hdaR3QueryInterface(struct PDMIBASE *pInterface, const char *pszIID) 4361 4364 { 4362 4365 PHDASTATE pThis = RT_FROM_MEMBER(pInterface, HDASTATE, IBase); … … 4383 4386 * @param ppDrv Attached driver instance on success. Optional. 4384 4387 */ 4385 static int hda AttachInternal(PHDASTATE pThis, unsigned uLUN, uint32_t fFlags, PHDADRIVER *ppDrv)4388 static int hdaR3AttachInternal(PHDASTATE pThis, unsigned uLUN, uint32_t fFlags, PHDADRIVER *ppDrv) 4386 4389 { 4387 4390 RT_NOREF(fFlags); … … 4455 4458 * @param fFlags Flags, combination of the PDMDEVATT_FLAGS_* \#defines. 4456 4459 */ 4457 static int hda DetachInternal(PHDASTATE pThis, PHDADRIVER pDrv, uint32_t fFlags)4460 static int hdaR3DetachInternal(PHDASTATE pThis, PHDADRIVER pDrv, uint32_t fFlags) 4458 4461 { 4459 4462 RT_NOREF(fFlags); … … 4492 4495 * @interface_method_impl{PDMDEVREG,pfnAttach} 4493 4496 */ 4494 static DECLCALLBACK(int) hda Attach(PPDMDEVINS pDevIns, unsigned uLUN, uint32_t fFlags)4497 static DECLCALLBACK(int) hdaR3Attach(PPDMDEVINS pDevIns, unsigned uLUN, uint32_t fFlags) 4495 4498 { 4496 4499 PHDASTATE pThis = PDMINS_2_DATA(pDevIns, PHDASTATE); … … 4501 4504 4502 4505 PHDADRIVER pDrv; 4503 int rc2 = hda AttachInternal(pThis, uLUN, fFlags, &pDrv);4506 int rc2 = hdaR3AttachInternal(pThis, uLUN, fFlags, &pDrv); 4504 4507 if (RT_SUCCESS(rc2)) 4505 4508 { 4506 PHDASTREAM pStream = hda GetStreamFromSink(pThis, &pThis->SinkFront);4509 PHDASTREAM pStream = hdaR3GetStreamFromSink(pThis, &pThis->SinkFront); 4507 4510 if (DrvAudioHlpStreamCfgIsValid(&pStream->State.Cfg)) 4508 hda MixerAddDrvStream(pThis, pThis->SinkFront.pMixSink, &pStream->State.Cfg, pDrv);4511 hdaR3MixerAddDrvStream(pThis, pThis->SinkFront.pMixSink, &pStream->State.Cfg, pDrv); 4509 4512 4510 4513 #ifdef VBOX_WITH_AUDIO_HDA_51_SURROUND 4511 pStream = hda GetStreamFromSink(pThis, &pThis->SinkCenterLFE);4514 pStream = hdaR3GetStreamFromSink(pThis, &pThis->SinkCenterLFE); 4512 4515 if (DrvAudioHlpStreamCfgIsValid(&pStream->State.Cfg)) 4513 hda MixerAddDrvStream(pThis, pThis->SinkCenterLFE.pMixSink, &pStream->State.Cfg, pDrv);4514 4515 pStream = hda GetStreamFromSink(pThis, &pThis->SinkRear);4516 hdaR3MixerAddDrvStream(pThis, pThis->SinkCenterLFE.pMixSink, &pStream->State.Cfg, pDrv); 4517 4518 pStream = hdaR3GetStreamFromSink(pThis, &pThis->SinkRear); 4516 4519 if (DrvAudioHlpStreamCfgIsValid(&pStream->State.Cfg)) 4517 hda MixerAddDrvStream(pThis, pThis->SinkRear.pMixSink, &pStream->State.Cfg, pDrv);4520 hdaR3MixerAddDrvStream(pThis, pThis->SinkRear.pMixSink, &pStream->State.Cfg, pDrv); 4518 4521 #endif 4519 pStream = hda GetStreamFromSink(pThis, &pThis->SinkLineIn);4522 pStream = hdaR3GetStreamFromSink(pThis, &pThis->SinkLineIn); 4520 4523 if (DrvAudioHlpStreamCfgIsValid(&pStream->State.Cfg)) 4521 hda MixerAddDrvStream(pThis, pThis->SinkLineIn.pMixSink, &pStream->State.Cfg, pDrv);4524 hdaR3MixerAddDrvStream(pThis, pThis->SinkLineIn.pMixSink, &pStream->State.Cfg, pDrv); 4522 4525 4523 4526 #ifdef VBOX_WITH_AUDIO_HDA_MIC_IN 4524 pStream = hda GetStreamFromSink(pThis, &pThis->SinkMicIn);4527 pStream = hdaR3GetStreamFromSink(pThis, &pThis->SinkMicIn); 4525 4528 if (DrvAudioHlpStreamCfgIsValid(&pStream->State.Cfg)) 4526 hda MixerAddDrvStream(pThis, pThis->SinkMicIn.pMixSink, &pStream->State.Cfg, pDrv);4529 hdaR3MixerAddDrvStream(pThis, pThis->SinkMicIn.pMixSink, &pStream->State.Cfg, pDrv); 4527 4530 #endif 4528 4531 } … … 4536 4539 * @interface_method_impl{PDMDEVREG,pfnDetach} 4537 4540 */ 4538 static DECLCALLBACK(void) hda Detach(PPDMDEVINS pDevIns, unsigned uLUN, uint32_t fFlags)4541 static DECLCALLBACK(void) hdaR3Detach(PPDMDEVINS pDevIns, unsigned uLUN, uint32_t fFlags) 4539 4542 { 4540 4543 PHDASTATE pThis = PDMINS_2_DATA(pDevIns, PHDASTATE); … … 4549 4552 if (pDrv->uLUN == uLUN) 4550 4553 { 4551 int rc2 = hda DetachInternal(pThis, pDrv, fFlags);4554 int rc2 = hdaR3DetachInternal(pThis, pDrv, fFlags); 4552 4555 if (RT_SUCCESS(rc2)) 4553 4556 { … … 4568 4571 * @param pDevIns Device instance to power off. 4569 4572 */ 4570 static DECLCALLBACK(void) hda PowerOff(PPDMDEVINS pDevIns)4573 static DECLCALLBACK(void) hdaR3PowerOff(PPDMDEVINS pDevIns) 4571 4574 { 4572 4575 PHDASTATE pThis = PDMINS_2_DATA(pDevIns, PHDASTATE); … … 4580 4583 4581 4584 /* 4582 * Note: Destroy the mixer while powering off and *not* in hda Destruct,4585 * Note: Destroy the mixer while powering off and *not* in hdaR3Destruct, 4583 4586 * giving the mixer the chance to release any references held to 4584 4587 * PDM audio streams it maintains. … … 4608 4611 * @param pszDriver New driver name to attach. 4609 4612 */ 4610 static int hdaR eattachInternal(PHDASTATE pThis, PHDADRIVER pDrv, uint8_t uLUN, const char *pszDriver)4613 static int hdaR3ReattachInternal(PHDASTATE pThis, PHDADRIVER pDrv, uint8_t uLUN, const char *pszDriver) 4611 4614 { 4612 4615 AssertPtrReturn(pThis, VERR_INVALID_POINTER); … … 4617 4620 if (pDrv) 4618 4621 { 4619 rc = hda DetachInternal(pThis, pDrv, 0 /* fFlags */);4622 rc = hdaR3DetachInternal(pThis, pDrv, 0 /* fFlags */); 4620 4623 if (RT_SUCCESS(rc)) 4621 4624 rc = PDMDevHlpDriverDetach(pThis->pDevInsR3, PDMIBASE_2_PDMDRV(pDrv->pDrvBase), 0 /* fFlags */); … … 4653 4656 4654 4657 if (RT_SUCCESS(rc)) 4655 rc = hda AttachInternal(pThis, uLUN, 0 /* fFlags */, NULL /* ppDrv */);4658 rc = hdaR3AttachInternal(pThis, uLUN, 0 /* fFlags */, NULL /* ppDrv */); 4656 4659 4657 4660 LogFunc(("pThis=%p, uLUN=%u, pszDriver=%s, rc=%Rrc\n", pThis, uLUN, pszDriver, rc)); … … 4666 4669 * @interface_method_impl{PDMDEVREG,pfnReset} 4667 4670 */ 4668 static DECLCALLBACK(void) hdaR eset(PPDMDEVINS pDevIns)4671 static DECLCALLBACK(void) hdaR3Reset(PPDMDEVINS pDevIns) 4669 4672 { 4670 4673 PHDASTATE pThis = PDMINS_2_DATA(pDevIns, PHDASTATE); … … 4676 4679 /* 4677 4680 * 18.2.6,7 defines that values of this registers might be cleared on power on/reset 4678 * hdaR eset shouldn't affects these registers.4681 * hdaR3Reset shouldn't affects these registers. 4679 4682 */ 4680 4683 HDA_REG(pThis, WAKEEN) = 0x0; 4681 4684 4682 hda GCTLReset(pThis);4685 hdaR3GCTLReset(pThis); 4683 4686 4684 4687 /* Indicate that HDA is not in reset. The firmware is supposed to (un)reset HDA, … … 4694 4697 * @interface_method_impl{PDMDEVREG,pfnRelocate} 4695 4698 */ 4696 static DECLCALLBACK(void) hdaR elocate(PPDMDEVINS pDevIns, RTGCINTPTR offDelta)4699 static DECLCALLBACK(void) hdaR3Relocate(PPDMDEVINS pDevIns, RTGCINTPTR offDelta) 4697 4700 { 4698 4701 NOREF(offDelta); … … 4705 4708 * @interface_method_impl{PDMDEVREG,pfnDestruct} 4706 4709 */ 4707 static DECLCALLBACK(int) hda Destruct(PPDMDEVINS pDevIns)4710 static DECLCALLBACK(int) hdaR3Destruct(PPDMDEVINS pDevIns) 4708 4711 { 4709 4712 PDMDEV_CHECK_VERSIONS_RETURN_QUIET(pDevIns); … … 4735 4738 4736 4739 for (uint8_t i = 0; i < HDA_MAX_STREAMS; i++) 4737 hda StreamDestroy(&pThis->aStreams[i]);4740 hdaR3StreamDestroy(&pThis->aStreams[i]); 4738 4741 4739 4742 DEVHDA_UNLOCK(pThis); … … 4745 4748 * @interface_method_impl{PDMDEVREG,pfnConstruct} 4746 4749 */ 4747 static DECLCALLBACK(int) hda Construct(PPDMDEVINS pDevIns, int iInstance, PCFGMNODE pCfg)4750 static DECLCALLBACK(int) hdaR3Construct(PPDMDEVINS pDevIns, int iInstance, PCFGMNODE pCfg) 4748 4751 { 4749 4752 RT_NOREF(iInstance); … … 4839 4842 pThis->pDevInsRC = PDMDEVINS_2_RCPTR(pDevIns); 4840 4843 /* IBase */ 4841 pThis->IBase.pfnQueryInterface = hda QueryInterface;4844 pThis->IBase.pfnQueryInterface = hdaR3QueryInterface; 4842 4845 4843 4846 /* PCI Device */ … … 4925 4928 return rc; 4926 4929 4927 rc = PDMDevHlpPCIIORegionRegister(pDevIns, 0, 0x4000, PCI_ADDRESS_SPACE_MEM, hda PciIoRegionMap);4930 rc = PDMDevHlpPCIIORegionRegister(pDevIns, 0, 0x4000, PCI_ADDRESS_SPACE_MEM, hdaR3PciIoRegionMap); 4928 4931 if (RT_FAILURE(rc)) 4929 4932 return rc; … … 4943 4946 #endif 4944 4947 4945 rc = PDMDevHlpSSMRegister(pDevIns, HDA_SSM_VERSION, sizeof(*pThis), hda SaveExec, hdaLoadExec);4948 rc = PDMDevHlpSSMRegister(pDevIns, HDA_SSM_VERSION, sizeof(*pThis), hdaR3SaveExec, hdaR3LoadExec); 4946 4949 if (RT_FAILURE(rc)) 4947 4950 return rc; … … 4955 4958 { 4956 4959 LogFunc(("Trying to attach driver for LUN #%RU32 ...\n", uLUN)); 4957 rc = hda AttachInternal(pThis, uLUN, 0 /* fFlags */, NULL /* ppDrv */);4960 rc = hdaR3AttachInternal(pThis, uLUN, 0 /* fFlags */, NULL /* ppDrv */); 4958 4961 if (RT_FAILURE(rc)) 4959 4962 { … … 4962 4965 else if (rc == VERR_AUDIO_BACKEND_INIT_FAILED) 4963 4966 { 4964 hdaR eattachInternal(pThis, NULL /* pDrv */, uLUN, "NullAudio");4967 hdaR3ReattachInternal(pThis, NULL /* pDrv */, uLUN, "NullAudio"); 4965 4968 PDMDevHlpVMSetRuntimeError(pDevIns, 0 /*fFlags*/, "HostAudioNotResponding", 4966 4969 N_("Host audio backend initialization has failed. Selecting the NULL audio backend " … … 5042 5045 { 5043 5046 /* Set codec callbacks to this controller. */ 5044 pThis->pCodec->pfnCbMixerAddStream = hda MixerAddStream;5045 pThis->pCodec->pfnCbMixerRemoveStream = hda MixerRemoveStream;5046 pThis->pCodec->pfnCbMixerControl = hda MixerControl;5047 pThis->pCodec->pfnCbMixerSetVolume = hda MixerSetVolume;5047 pThis->pCodec->pfnCbMixerAddStream = hdaR3MixerAddStream; 5048 pThis->pCodec->pfnCbMixerRemoveStream = hdaR3MixerRemoveStream; 5049 pThis->pCodec->pfnCbMixerControl = hdaR3MixerControl; 5050 pThis->pCodec->pfnCbMixerSetVolume = hdaR3MixerSetVolume; 5048 5051 5049 5052 pThis->pCodec->pHDAState = pThis; /* Assign HDA controller state to codec. */ … … 5079 5082 RTStrPrintf2(szTimer, sizeof(szTimer), "HDA SD%RU8", i); 5080 5083 5081 rc = PDMDevHlpTMTimerCreate(pDevIns, TMCLOCK_VIRTUAL_SYNC, hda Timer, &pThis->aStreams[i],5084 rc = PDMDevHlpTMTimerCreate(pDevIns, TMCLOCK_VIRTUAL_SYNC, hdaR3Timer, &pThis->aStreams[i], 5082 5085 TMTIMER_FLAGS_NO_CRIT_SECT, szTimer, &pThis->pTimer[i]); 5083 5086 AssertRCReturn(rc, rc); … … 5088 5091 AssertRCReturn(rc, rc); 5089 5092 5090 rc = hda StreamCreate(&pThis->aStreams[i], pThis, i /* u8SD */);5093 rc = hdaR3StreamCreate(&pThis->aStreams[i], pThis, i /* u8SD */); 5091 5094 AssertRC(rc); 5092 5095 } … … 5126 5129 LogRel(("HDA: Falling back to NULL backend (no sound audible)\n")); 5127 5130 5128 hdaR eset(pDevIns);5129 hdaR eattachInternal(pThis, pDrv, pDrv->uLUN, "NullAudio");5131 hdaR3Reset(pDevIns); 5132 hdaR3ReattachInternal(pThis, pDrv, pDrv->uLUN, "NullAudio"); 5130 5133 5131 5134 PDMDevHlpVMSetRuntimeError(pDevIns, 0 /*fFlags*/, "HostAudioNotResponding", … … 5209 5212 if (RT_SUCCESS(rc)) 5210 5213 { 5211 hdaR eset(pDevIns);5214 hdaR3Reset(pDevIns); 5212 5215 5213 5216 /* 5214 5217 * Debug and string formatter types. 5215 5218 */ 5216 PDMDevHlpDBGFInfoRegister(pDevIns, "hda", "HDA info. (hda [register case-insensitive])", hda DbgInfo);5217 PDMDevHlpDBGFInfoRegister(pDevIns, "hdabdle", "HDA stream BDLE info. (hdabdle [stream number])", hda DbgInfoBDLE);5218 PDMDevHlpDBGFInfoRegister(pDevIns, "hdastream", "HDA stream info. (hdastream [stream number])", hda DbgInfoStream);5219 PDMDevHlpDBGFInfoRegister(pDevIns, "hdcnodes", "HDA codec nodes.", hda DbgInfoCodecNodes);5220 PDMDevHlpDBGFInfoRegister(pDevIns, "hdcselector", "HDA codec's selector states [node number].", hda DbgInfoCodecSelector);5221 PDMDevHlpDBGFInfoRegister(pDevIns, "hdamixer", "HDA mixer state.", hda DbgInfoMixer);5222 5223 rc = RTStrFormatTypeRegister("bdle", hda DbgFmtBDLE, NULL);5219 PDMDevHlpDBGFInfoRegister(pDevIns, "hda", "HDA info. (hda [register case-insensitive])", hdaR3DbgInfo); 5220 PDMDevHlpDBGFInfoRegister(pDevIns, "hdabdle", "HDA stream BDLE info. (hdabdle [stream number])", hdaR3DbgInfoBDLE); 5221 PDMDevHlpDBGFInfoRegister(pDevIns, "hdastream", "HDA stream info. (hdastream [stream number])", hdaR3DbgInfoStream); 5222 PDMDevHlpDBGFInfoRegister(pDevIns, "hdcnodes", "HDA codec nodes.", hdaR3DbgInfoCodecNodes); 5223 PDMDevHlpDBGFInfoRegister(pDevIns, "hdcselector", "HDA codec's selector states [node number].", hdaR3DbgInfoCodecSelector); 5224 PDMDevHlpDBGFInfoRegister(pDevIns, "hdamixer", "HDA mixer state.", hdaR3DbgInfoMixer); 5225 5226 rc = RTStrFormatTypeRegister("bdle", hdaR3StrFmtBDLE, NULL); 5224 5227 AssertRC(rc); 5225 rc = RTStrFormatTypeRegister("sdctl", hda DbgFmtSDCTL, NULL);5228 rc = RTStrFormatTypeRegister("sdctl", hdaR3StrFmtSDCTL, NULL); 5226 5229 AssertRC(rc); 5227 rc = RTStrFormatTypeRegister("sdsts", hda DbgFmtSDSTS, NULL);5230 rc = RTStrFormatTypeRegister("sdsts", hdaR3StrFmtSDSTS, NULL); 5228 5231 AssertRC(rc); 5229 rc = RTStrFormatTypeRegister("sdfifos", hda DbgFmtSDFIFOS, NULL);5232 rc = RTStrFormatTypeRegister("sdfifos", hdaR3StrFmtSDFIFOS, NULL); 5230 5233 AssertRC(rc); 5231 rc = RTStrFormatTypeRegister("sdfifow", hda DbgFmtSDFIFOW, NULL);5234 rc = RTStrFormatTypeRegister("sdfifow", hdaR3StrFmtSDFIFOW, NULL); 5232 5235 AssertRC(rc); 5233 5236 … … 5285 5288 * Register statistics. 5286 5289 */ 5287 PDMDevHlpSTAMRegister(pDevIns, &pThis->StatTimer, STAMTYPE_PROFILE, "/Devices/HDA/Timer", STAMUNIT_TICKS_PER_CALL, "Profiling hda Timer.");5290 PDMDevHlpSTAMRegister(pDevIns, &pThis->StatTimer, STAMTYPE_PROFILE, "/Devices/HDA/Timer", STAMUNIT_TICKS_PER_CALL, "Profiling hdaR3Timer."); 5288 5291 PDMDevHlpSTAMRegister(pDevIns, &pThis->StatIn, STAMTYPE_PROFILE, "/Devices/HDA/Input", STAMUNIT_TICKS_PER_CALL, "Profiling input."); 5289 5292 PDMDevHlpSTAMRegister(pDevIns, &pThis->StatOut, STAMTYPE_PROFILE, "/Devices/HDA/Output", STAMUNIT_TICKS_PER_CALL, "Profiling output."); … … 5321 5324 sizeof(HDASTATE), 5322 5325 /* pfnConstruct */ 5323 hda Construct,5326 hdaR3Construct, 5324 5327 /* pfnDestruct */ 5325 hda Destruct,5328 hdaR3Destruct, 5326 5329 /* pfnRelocate */ 5327 hdaR elocate,5330 hdaR3Relocate, 5328 5331 /* pfnMemSetup */ 5329 5332 NULL, … … 5331 5334 NULL, 5332 5335 /* pfnReset */ 5333 hdaR eset,5336 hdaR3Reset, 5334 5337 /* pfnSuspend */ 5335 5338 NULL, … … 5337 5340 NULL, 5338 5341 /* pfnAttach */ 5339 hda Attach,5342 hdaR3Attach, 5340 5343 /* pfnDetach */ 5341 hda Detach,5344 hdaR3Detach, 5342 5345 /* pfnQueryInterface. */ 5343 5346 NULL, … … 5345 5348 NULL, 5346 5349 /* pfnPowerOff */ 5347 hda PowerOff,5350 hdaR3PowerOff, 5348 5351 /* pfnSoftReset */ 5349 5352 NULL, -
trunk/src/VBox/Devices/Audio/DevHDACommon.cpp
r71735 r71736 113 113 * @param fForce Whether to force setting the wall clock value or not. 114 114 */ 115 bool hda WalClkSet(PHDASTATE pThis, uint64_t u64WalClk, bool fForce)116 { 117 const bool fFrontPassed = hda StreamPeriodHasPassedAbsWalClk (&hdaGetStreamFromSink(pThis, &pThis->SinkFront)->State.Period,115 bool hdaR3WalClkSet(PHDASTATE pThis, uint64_t u64WalClk, bool fForce) 116 { 117 const bool fFrontPassed = hdaR3StreamPeriodHasPassedAbsWalClk (&hdaR3GetStreamFromSink(pThis, &pThis->SinkFront)->State.Period, 118 118 u64WalClk); 119 const uint64_t u64FrontAbsWalClk = hda StreamPeriodGetAbsElapsedWalClk(&hdaGetStreamFromSink(pThis, &pThis->SinkFront)->State.Period);119 const uint64_t u64FrontAbsWalClk = hdaR3StreamPeriodGetAbsElapsedWalClk(&hdaR3GetStreamFromSink(pThis, &pThis->SinkFront)->State.Period); 120 120 # ifdef VBOX_WITH_AUDIO_HDA_51_SURROUND 121 121 # error "Implement me!" 122 122 # endif 123 123 124 const bool fLineInPassed = hda StreamPeriodHasPassedAbsWalClk (&hdaGetStreamFromSink(pThis, &pThis->SinkLineIn)->State.Period, u64WalClk);125 const uint64_t u64LineInAbsWalClk = hda StreamPeriodGetAbsElapsedWalClk(&hdaGetStreamFromSink(pThis, &pThis->SinkLineIn)->State.Period);124 const bool fLineInPassed = hdaR3StreamPeriodHasPassedAbsWalClk (&hdaR3GetStreamFromSink(pThis, &pThis->SinkLineIn)->State.Period, u64WalClk); 125 const uint64_t u64LineInAbsWalClk = hdaR3StreamPeriodGetAbsElapsedWalClk(&hdaR3GetStreamFromSink(pThis, &pThis->SinkLineIn)->State.Period); 126 126 # ifdef VBOX_WITH_HDA_MIC_IN 127 const bool fMicInPassed = hda StreamPeriodHasPassedAbsWalClk (&hdaGetStreamFromSink(pThis, &pThis->SinkMicIn)->State.Period, u64WalClk);128 const uint64_t u64MicInAbsWalClk = hda StreamPeriodGetAbsElapsedWalClk(&hdaGetStreamFromSink(pThis, &pThis->SinkMicIn)->State.Period);127 const bool fMicInPassed = hdaR3StreamPeriodHasPassedAbsWalClk (&hdaR3GetStreamFromSink(pThis, &pThis->SinkMicIn)->State.Period, u64WalClk); 128 const uint64_t u64MicInAbsWalClk = hdaR3StreamPeriodGetAbsElapsedWalClk(&hdaR3GetStreamFromSink(pThis, &pThis->SinkMicIn)->State.Period); 129 129 # endif 130 130 … … 196 196 * NULL if not found / handled. 197 197 */ 198 PHDAMIXERSINK hda GetDefaultSink(PHDASTATE pThis, uint8_t uSD)198 PHDAMIXERSINK hdaR3GetDefaultSink(PHDASTATE pThis, uint8_t uSD) 199 199 { 200 200 if (hdaGetDirFromSD(uSD) == PDMAUDIODIR_IN) … … 229 229 } 230 230 231 #endif /* IN_RING */231 #endif /* IN_RING3 */ 232 232 233 233 /** … … 279 279 * @return Pointer to HDA stream, or NULL if none found. 280 280 */ 281 PHDASTREAM hda GetStreamFromSink(PHDASTATE pThis, PHDAMIXERSINK pSink)281 PHDASTREAM hdaR3GetStreamFromSink(PHDASTATE pThis, PHDAMIXERSINK pSink) 282 282 { 283 283 AssertPtrReturn(pThis, NULL); … … 298 298 * @param pcbRead Returns read bytes from DMA. Optional. 299 299 */ 300 int hda DMARead(PHDASTATE pThis, PHDASTREAM pStream, void *pvBuf, uint32_t cbBuf, uint32_t *pcbRead)300 int hdaR3DMARead(PHDASTATE pThis, PHDASTREAM pStream, void *pvBuf, uint32_t cbBuf, uint32_t *pcbRead) 301 301 { 302 302 AssertPtrReturn(pThis, VERR_INVALID_POINTER); … … 383 383 * @param pcbWritten Returns written bytes on success. Optional. 384 384 */ 385 int hda DMAWrite(PHDASTATE pThis, PHDASTREAM pStream, const void *pvBuf, uint32_t cbBuf, uint32_t *pcbWritten)385 int hdaR3DMAWrite(PHDASTATE pThis, PHDASTREAM pStream, const void *pvBuf, uint32_t cbBuf, uint32_t *pcbWritten) 386 386 { 387 387 AssertPtrReturn(pThis, VERR_INVALID_POINTER); … … 477 477 } 478 478 479 #ifdef IN_RING3 480 479 481 /** 480 482 * Converts an HDA stream's SDFMT register into a given PCM properties structure. … … 484 486 * @param pProps PCM properties structure to hold converted result on success. 485 487 */ 486 int hda SDFMTToPCMProps(uint32_t u32SDFMT, PPDMAUDIOPCMPROPS pProps)488 int hdaR3SDFMTToPCMProps(uint32_t u32SDFMT, PPDMAUDIOPCMPROPS pProps) 487 489 { 488 490 AssertPtrReturn(pProps, VERR_INVALID_POINTER); 489 491 490 # define EXTRACT_VALUE(v, mask, shift) ((v & ((mask) << (shift))) >> (shift))492 # define EXTRACT_VALUE(v, mask, shift) ((v & ((mask) << (shift))) >> (shift)) 491 493 492 494 int rc = VINF_SUCCESS; … … 556 558 } 557 559 558 # undef EXTRACT_VALUE560 # undef EXTRACT_VALUE 559 561 return rc; 560 562 } 561 563 562 #ifdef IN_RING3563 564 564 # ifdef LOG_ENABLED 565 void hda BDLEDumpAll(PHDASTATE pThis, uint64_t u64BDLBase, uint16_t cBDLE)565 void hdaR3BDLEDumpAll(PHDASTATE pThis, uint64_t u64BDLBase, uint16_t cBDLE) 566 566 { 567 567 LogFlowFunc(("BDLEs @ 0x%x (%RU16):\n", u64BDLBase, cBDLE)); … … 607 607 * @param u16Entry BDLE entry to fetch. 608 608 */ 609 int hda BDLEFetch(PHDASTATE pThis, PHDABDLE pBDLE, uint64_t u64BaseDMA, uint16_t u16Entry)609 int hdaR3BDLEFetch(PHDASTATE pThis, PHDABDLE pBDLE, uint64_t u64BaseDMA, uint16_t u16Entry) 610 610 { 611 611 AssertPtrReturn(pThis, VERR_INVALID_POINTER); … … 642 642 * @param pBDLE BDLE to retrieve status for. 643 643 */ 644 bool hda BDLEIsComplete(PHDABDLE pBDLE)644 bool hdaR3BDLEIsComplete(PHDABDLE pBDLE) 645 645 { 646 646 bool fIsComplete = false; … … 664 664 * @param pBDLE BDLE to retrieve status for. 665 665 */ 666 bool hda BDLENeedsInterrupt(PHDABDLE pBDLE)666 bool hdaR3BDLENeedsInterrupt(PHDABDLE pBDLE) 667 667 { 668 668 return (pBDLE->Desc.fFlags & HDA_BDLE_FLAG_IOC); … … 687 687 * Forcing a new expiration time will override the above mechanism. 688 688 */ 689 bool hda TimerSet(PHDASTATE pThis, PHDASTREAM pStream, uint64_t tsExpire, bool fForce)689 bool hdaR3TimerSet(PHDASTATE pThis, PHDASTREAM pStream, uint64_t tsExpire, bool fForce) 690 690 { 691 691 AssertPtr(pThis); … … 696 696 if (!fForce) 697 697 { 698 if (hda StreamTransferIsScheduled(pStream))699 tsExpireMin = RT_MIN(tsExpireMin, hda StreamTransferGetNext(pStream));698 if (hdaR3StreamTransferIsScheduled(pStream)) 699 tsExpireMin = RT_MIN(tsExpireMin, hdaR3StreamTransferGetNext(pStream)); 700 700 } 701 701 -
trunk/src/VBox/Devices/Audio/DevHDACommon.h
r71735 r71736 76 76 #define HDA_NUM_GENERAL_REGS 34 77 77 /** Number of total registers in the HDA's register map. */ 78 #define HDA_NUM_REGS 78 #define HDA_NUM_REGS (HDA_NUM_GENERAL_REGS + (HDA_MAX_STREAMS * 10 /* Each stream descriptor has 10 registers */)) 79 79 /** Total number of stream tags (channels). Index 0 is reserved / invalid. */ 80 80 #define HDA_MAX_TAGS 16 … … 517 517 518 518 519 /*********************************************************************************************************************************520 * Prototypes *521 *********************************************************************************************************************************/522 519 523 520 /** The HDA controller. */ … … 580 577 * @{ 581 578 */ 582 PHDAMIXERSINK hdaGetDefaultSink(PHDASTATE pThis, uint8_t uSD); 579 #ifdef IN_RING3 580 PHDAMIXERSINK hdaR3GetDefaultSink(PHDASTATE pThis, uint8_t uSD); 581 #endif 583 582 PDMAUDIODIR hdaGetDirFromSD(uint8_t uSD); 584 583 PHDASTREAM hdaGetStreamFromSD(PHDASTATE pThis, uint8_t uSD); 585 PHDASTREAM hdaGetStreamFromSink(PHDASTATE pThis, PHDAMIXERSINK pSink); 584 #ifdef IN_RING3 585 PHDASTREAM hdaR3GetStreamFromSink(PHDASTATE pThis, PHDAMIXERSINK pSink); 586 #endif 586 587 /** @} */ 587 588 … … 601 602 uint64_t hdaWalClkGetCurrent(PHDASTATE pThis); 602 603 #ifdef IN_RING3 603 bool hda WalClkSet(PHDASTATE pThis, uint64_t u64WalClk, bool fForce);604 bool hdaR3WalClkSet(PHDASTATE pThis, uint64_t u64WalClk, bool fForce); 604 605 #endif 605 606 /** @} */ … … 608 609 * @{ 609 610 */ 610 int hdaDMARead(PHDASTATE pThis, PHDASTREAM pStream, void *pvBuf, uint32_t cbBuf, uint32_t *pcbRead); 611 int hdaDMAWrite(PHDASTATE pThis, PHDASTREAM pStream, const void *pvBuf, uint32_t cbBuf, uint32_t *pcbWritten); 611 #ifdef IN_RING3 612 int hdaR3DMARead(PHDASTATE pThis, PHDASTREAM pStream, void *pvBuf, uint32_t cbBuf, uint32_t *pcbRead); 613 int hdaR3DMAWrite(PHDASTATE pThis, PHDASTREAM pStream, const void *pvBuf, uint32_t cbBuf, uint32_t *pcbWritten); 614 #endif 612 615 /** @} */ 613 616 … … 617 620 uint32_t hdaGetINTSTS(PHDASTATE pThis); 618 621 #ifdef IN_RING3 619 int hda SDFMTToPCMProps(uint32_t u32SDFMT, PPDMAUDIOPCMPROPS pProps);622 int hdaR3SDFMTToPCMProps(uint32_t u32SDFMT, PPDMAUDIOPCMPROPS pProps); 620 623 #endif /* IN_RING3 */ 621 624 /** @} */ … … 626 629 #ifdef IN_RING3 627 630 # ifdef LOG_ENABLED 628 void hda BDLEDumpAll(PHDASTATE pThis, uint64_t u64BDLBase, uint16_t cBDLE);631 void hdaR3BDLEDumpAll(PHDASTATE pThis, uint64_t u64BDLBase, uint16_t cBDLE); 629 632 # endif 630 int hda BDLEFetch(PHDASTATE pThis, PHDABDLE pBDLE, uint64_t u64BaseDMA, uint16_t u16Entry);631 bool hda BDLEIsComplete(PHDABDLE pBDLE);632 bool hda BDLENeedsInterrupt(PHDABDLE pBDLE);633 int hdaR3BDLEFetch(PHDASTATE pThis, PHDABDLE pBDLE, uint64_t u64BaseDMA, uint16_t u16Entry); 634 bool hdaR3BDLEIsComplete(PHDABDLE pBDLE); 635 bool hdaR3BDLENeedsInterrupt(PHDABDLE pBDLE); 633 636 #endif /* IN_RING3 */ 634 637 /** @} */ … … 638 641 */ 639 642 #ifdef IN_RING3 640 bool hda TimerSet(PHDASTATE pThis, PHDASTREAM pStream, uint64_t u64Expire, bool fForce);643 bool hdaR3TimerSet(PHDASTATE pThis, PHDASTREAM pStream, uint64_t u64Expire, bool fForce); 641 644 #endif /* IN_RING3 */ 642 645 /** @} */ -
trunk/src/VBox/Devices/Audio/HDAStream.cpp
r71735 r71736 45 45 * @param u8SD Stream descriptor number to assign. 46 46 */ 47 int hda StreamCreate(PHDASTREAM pStream, PHDASTATE pThis, uint8_t u8SD)47 int hdaR3StreamCreate(PHDASTREAM pStream, PHDASTATE pThis, uint8_t u8SD) 48 48 { 49 49 RT_NOREF(pThis); … … 68 68 AssertRCReturn(rc, rc); 69 69 70 rc = hda StreamPeriodCreate(&pStream->State.Period);70 rc = hdaR3StreamPeriodCreate(&pStream->State.Period); 71 71 AssertRCReturn(rc, rc); 72 72 … … 119 119 * @param pStream HDA stream to destroy. 120 120 */ 121 void hda StreamDestroy(PHDASTREAM pStream)121 void hdaR3StreamDestroy(PHDASTREAM pStream) 122 122 { 123 123 AssertPtrReturnVoid(pStream); … … 125 125 LogFlowFunc(("[SD%RU8]: Destroying ...\n", pStream->u8SD)); 126 126 127 hda StreamMapDestroy(&pStream->State.Mapping);127 hdaR3StreamMapDestroy(&pStream->State.Mapping); 128 128 129 129 int rc2; 130 130 131 131 #ifdef VBOX_WITH_AUDIO_HDA_ASYNC_IO 132 rc2 = hda StreamAsyncIODestroy(pStream);132 rc2 = hdaR3StreamAsyncIODestroy(pStream); 133 133 AssertRC(rc2); 134 134 #endif … … 146 146 } 147 147 148 hda StreamPeriodDestroy(&pStream->State.Period);148 hdaR3StreamPeriodDestroy(&pStream->State.Period); 149 149 150 150 #ifdef DEBUG … … 175 175 * @param uSD SD (stream descriptor) number to assign the HDA stream to. 176 176 */ 177 int hda StreamInit(PHDASTREAM pStream, uint8_t uSD)177 int hdaR3StreamInit(PHDASTREAM pStream, uint8_t uSD) 178 178 { 179 179 AssertPtrReturn(pStream, VERR_INVALID_POINTER); … … 191 191 PPDMAUDIOSTREAMCFG pCfg = &pStream->State.Cfg; 192 192 193 int rc = hda SDFMTToPCMProps(HDA_STREAM_REG(pThis, FMT, uSD), &pCfg->Props);193 int rc = hdaR3SDFMTToPCMProps(HDA_STREAM_REG(pThis, FMT, uSD), &pCfg->Props); 194 194 if (RT_FAILURE(rc)) 195 195 { … … 246 246 * number of channels in a single audio stream. 247 247 */ 248 rc = hda StreamMapInit(&pStream->State.Mapping, &pCfg->Props);248 rc = hdaR3StreamMapInit(&pStream->State.Mapping, &pCfg->Props); 249 249 AssertRCReturn(rc, rc); 250 250 … … 284 284 RT_ZERO(BDLE); 285 285 286 int rc2 = hda BDLEFetch(pThis, &BDLE, pStream->u64BDLBase, 0 /* Entry */);286 int rc2 = hdaR3BDLEFetch(pThis, &BDLE, pStream->u64BDLBase, 0 /* Entry */); 287 287 AssertRC(rc2); 288 288 … … 299 299 if ( !pThis->cPosAdjustFrames 300 300 /* Position adjustmenet buffer *must* have the IOC bit set! */ 301 && hda BDLENeedsInterrupt(&BDLE))301 && hdaR3BDLENeedsInterrupt(&BDLE)) 302 302 { 303 303 /** @todo Implement / use a (dynamic) table once this gets more complicated. */ … … 387 387 388 388 /* Make sure to also update the stream's DMA counter (based on its current LPIB value). */ 389 hda StreamSetPosition(pStream, HDA_STREAM_REG(pThis, LPIB, pStream->u8SD));389 hdaR3StreamSetPosition(pStream, HDA_STREAM_REG(pThis, LPIB, pStream->u8SD)); 390 390 391 391 #ifdef LOG_ENABLED 392 hda BDLEDumpAll(pThis, pStream->u64BDLBase, pStream->u16LVI + 1);392 hdaR3BDLEDumpAll(pThis, pStream->u64BDLBase, pStream->u16LVI + 1); 393 393 #endif 394 394 } … … 407 407 * @param uSD Stream descriptor (SD) number to use for this stream. 408 408 */ 409 void hda StreamReset(PHDASTATE pThis, PHDASTREAM pStream, uint8_t uSD)409 void hdaR3StreamReset(PHDASTATE pThis, PHDASTREAM pStream, uint8_t uSD) 410 410 { 411 411 AssertPtrReturnVoid(pThis); … … 444 444 445 445 #ifdef HDA_USE_DMA_ACCESS_HANDLER 446 hda StreamUnregisterDMAHandlers(pThis, pStream);446 hdaR3StreamUnregisterDMAHandlers(pThis, pStream); 447 447 #endif 448 448 449 449 /* Assign the default mixer sink to the stream. */ 450 pStream->pMixSink = hda GetDefaultSink(pThis, uSD);450 pStream->pMixSink = hdaR3GetDefaultSink(pThis, uSD); 451 451 452 452 pStream->State.tsTransferLast = 0; … … 460 460 461 461 /* Reset stream map. */ 462 hda StreamMapReset(&pStream->State.Mapping);462 hdaR3StreamMapReset(&pStream->State.Mapping); 463 463 464 464 /* (Re-)initialize the stream with current values. */ 465 int rc2 = hda StreamInit(pStream, uSD);465 int rc2 = hdaR3StreamInit(pStream, uSD); 466 466 AssertRC(rc2); 467 467 468 468 /* Reset the stream's period. */ 469 hda StreamPeriodReset(&pStream->State.Period);469 hdaR3StreamPeriodReset(&pStream->State.Period); 470 470 471 471 #ifdef DEBUG … … 496 496 * @param fEnable Whether to enable or disble the stream. 497 497 */ 498 int hda StreamEnable(PHDASTREAM pStream, bool fEnable)498 int hdaR3StreamEnable(PHDASTREAM pStream, bool fEnable) 499 499 { 500 500 AssertPtrReturn(pStream, VERR_INVALID_POINTER); … … 545 545 } 546 546 547 uint32_t hda StreamGetPosition(PHDASTATE pThis, PHDASTREAM pStream)547 uint32_t hdaR3StreamGetPosition(PHDASTATE pThis, PHDASTREAM pStream) 548 548 { 549 549 return HDA_STREAM_REG(pThis, LPIB, pStream->u8SD); … … 557 557 * @param u32LPIB Absolute position (in bytes) to set current read / write position to. 558 558 */ 559 void hda StreamSetPosition(PHDASTREAM pStream, uint32_t u32LPIB)559 void hdaR3StreamSetPosition(PHDASTREAM pStream, uint32_t u32LPIB) 560 560 { 561 561 AssertPtrReturnVoid(pStream); … … 583 583 * @param pStream HDA stream to retrieve size for. 584 584 */ 585 uint32_t hda StreamGetUsed(PHDASTREAM pStream)585 uint32_t hdaR3StreamGetUsed(PHDASTREAM pStream) 586 586 { 587 587 AssertPtrReturn(pStream, 0); … … 599 599 * @param pStream HDA stream to retrieve size for. 600 600 */ 601 uint32_t hda StreamGetFree(PHDASTREAM pStream)601 uint32_t hdaR3StreamGetFree(PHDASTREAM pStream) 602 602 { 603 603 AssertPtrReturn(pStream, 0); … … 617 617 * @param pStream HDA stream to retrieve schedule status for. 618 618 */ 619 bool hda StreamTransferIsScheduled(PHDASTREAM pStream)619 bool hdaR3StreamTransferIsScheduled(PHDASTREAM pStream) 620 620 { 621 621 if (pStream) … … 649 649 * @param pStream HDA stream to retrieve timestamp for. 650 650 */ 651 uint64_t hda StreamTransferGetNext(PHDASTREAM pStream)651 uint64_t hdaR3StreamTransferGetNext(PHDASTREAM pStream) 652 652 { 653 653 return pStream->State.tsTransferNext; … … 664 664 * @param pcbWritten Number of bytes written. Optional. 665 665 */ 666 int hda StreamWrite(PHDASTREAM pStream, const void *pvBuf, uint32_t cbBuf, uint32_t *pcbWritten)666 int hdaR3StreamWrite(PHDASTREAM pStream, const void *pvBuf, uint32_t cbBuf, uint32_t *pcbWritten) 667 667 { 668 668 AssertPtrReturn(pStream, VERR_INVALID_POINTER); … … 731 731 * @param pcbRead Number of bytes read. Optional. 732 732 */ 733 int hda StreamRead(PHDASTREAM pStream, uint32_t cbToRead, uint32_t *pcbRead)733 int hdaR3StreamRead(PHDASTREAM pStream, uint32_t cbToRead, uint32_t *pcbRead) 734 734 { 735 735 AssertPtrReturn(pStream, VERR_INVALID_POINTER); … … 806 806 * @param cbToProcessMax How much data (in bytes) to process as maximum. 807 807 */ 808 int hda StreamTransfer(PHDASTREAM pStream, uint32_t cbToProcessMax)808 int hdaR3StreamTransfer(PHDASTREAM pStream, uint32_t cbToProcessMax) 809 809 { 810 810 AssertPtrReturn(pStream, VERR_INVALID_POINTER); 811 811 812 hda StreamLock(pStream);812 hdaR3StreamLock(pStream); 813 813 814 814 PHDASTATE pThis = pStream->pHDAState; … … 816 816 817 817 PHDASTREAMPERIOD pPeriod = &pStream->State.Period; 818 if (!hda StreamPeriodLock(pPeriod))818 if (!hdaR3StreamPeriodLock(pPeriod)) 819 819 return VERR_ACCESS_DENIED; 820 820 … … 835 835 if (!fProceed) 836 836 { 837 hda StreamPeriodUnlock(pPeriod);838 hda StreamUnlock(pStream);837 hdaR3StreamPeriodUnlock(pPeriod); 838 hdaR3StreamUnlock(pStream); 839 839 return VINF_SUCCESS; 840 840 } … … 866 866 /* Fetch first / next BDL entry. */ 867 867 PHDABDLE pBDLE = &pStream->State.BDLE; 868 if (hda BDLEIsComplete(pBDLE))869 { 870 rc = hda BDLEFetch(pThis, pBDLE, pStream->u64BDLBase, pStream->State.uCurBDLE);868 if (hdaR3BDLEIsComplete(pBDLE)) 869 { 870 rc = hdaR3BDLEFetch(pThis, pBDLE, pStream->u64BDLBase, pStream->State.uCurBDLE); 871 871 AssertRC(rc); 872 872 } … … 956 956 } 957 957 958 rc = hda DMAWrite(pThis, pStream, abChunk, cbDMAWritten, &cbDMA /* pcbWritten */);958 rc = hdaR3DMAWrite(pThis, pStream, abChunk, cbDMAWritten, &cbDMA /* pcbWritten */); 959 959 if (RT_FAILURE(rc)) 960 960 LogRel(("HDA: Writing to stream #%RU8 DMA failed with %Rrc\n", pStream->u8SD, rc)); … … 966 966 STAM_PROFILE_START(&pThis->StatOut, a); 967 967 968 rc = hda DMARead(pThis, pStream, abChunk, cbChunk, &cbDMA /* pcbRead */);968 rc = hdaR3DMARead(pThis, pStream, abChunk, cbChunk, &cbDMA /* pcbRead */); 969 969 if (RT_SUCCESS(rc)) 970 970 { … … 999 999 else 1000 1000 { 1001 /* *1001 /* 1002 1002 * The following code extracts the required audio stream (channel) data 1003 1003 * of non-interleaved *and* interleaved audio streams. … … 1010 1010 * and just discard the other channel's data. 1011 1011 * 1012 * @todo Optimize this stuff -- copying only one frame a time is expensive.1013 1012 */ 1013 /** @todo Optimize this stuff -- copying only one frame a time is expensive. */ 1014 1014 uint32_t cbDMARead = pStream->State.cbDMALeft ? pStream->State.cbFrameSize - pStream->State.cbDMALeft : 0; 1015 1015 uint32_t cbDMALeft = RT_MIN(cbDMA, (uint32_t)RTCircBufFree(pCircBuf)); … … 1070 1070 } 1071 1071 1072 /* *1072 /* 1073 1073 * Update the stream's current position. 1074 1074 * Do this as accurate and close to the actual data transfer as possible. 1075 1075 * All guetsts rely on this, depending on the mechanism they use (LPIB register or DMA counters). 1076 1076 */ 1077 uint32_t cbStreamPos = hda StreamGetPosition(pThis, pStream);1077 uint32_t cbStreamPos = hdaR3StreamGetPosition(pThis, pStream); 1078 1078 if (cbStreamPos == pStream->u32CBL) 1079 1079 cbStreamPos = 0; 1080 1080 1081 hda StreamSetPosition(pStream, cbStreamPos + cbDMA);1082 } 1083 1084 if (hda BDLEIsComplete(pBDLE))1081 hdaR3StreamSetPosition(pStream, cbStreamPos + cbDMA); 1082 } 1083 1084 if (hdaR3BDLEIsComplete(pBDLE)) 1085 1085 { 1086 1086 Log3Func(("[SD%RU8] Complete: %R[bdle]\n", pStream->u8SD, pBDLE)); 1087 1087 1088 1088 /* Does the current BDLE require an interrupt to be sent? */ 1089 if ( hda BDLENeedsInterrupt(pBDLE)1089 if ( hdaR3BDLENeedsInterrupt(pBDLE) 1090 1090 /* Are we done doing the position adjustment? 1091 1091 * It can happen that a BDLE which is handled while doing the … … 1116 1116 1117 1117 /* Fetch the next BDLE entry. */ 1118 hda BDLEFetch(pThis, pBDLE, pStream->u64BDLBase, pStream->State.uCurBDLE);1118 hdaR3BDLEFetch(pThis, pBDLE, pStream->u64BDLBase, pStream->State.uCurBDLE); 1119 1119 } 1120 1120 … … 1137 1137 if (pStream->State.cPosAdjustFramesLeft == 0) 1138 1138 { 1139 hdaStreamPeriodInc(pPeriod, RT_MIN(cbProcessed / pStream->State.cbFrameSize, hdaStreamPeriodGetRemainingFrames(pPeriod))); 1139 hdaR3StreamPeriodInc(pPeriod, RT_MIN(cbProcessed / pStream->State.cbFrameSize, 1140 hdaR3StreamPeriodGetRemainingFrames(pPeriod))); 1140 1141 1141 1142 pStream->State.cbTransferProcessed += cbProcessed; … … 1152 1153 if (fTransferComplete) 1153 1154 { 1154 /* *1155 /* 1155 1156 * Try updating the wall clock. 1156 1157 * … … 1164 1165 * sound output. Running VLC on the guest will tell! 1165 1166 */ 1166 const bool fWalClkSet = hdaWalClkSet(pThis, 1167 hdaWalClkGetCurrent(pThis) 1168 + hdaStreamPeriodFramesToWalClk(pPeriod, pStream->State.cbTransferProcessed / pStream->State.cbFrameSize), 1169 false /* fForce */); 1167 const bool fWalClkSet = hdaR3WalClkSet(pThis, 1168 hdaWalClkGetCurrent(pThis) 1169 + hdaR3StreamPeriodFramesToWalClk(pPeriod, 1170 pStream->State.cbTransferProcessed 1171 / pStream->State.cbFrameSize), 1172 false /* fForce */); 1170 1173 RT_NOREF(fWalClkSet); 1171 1174 } … … 1176 1179 Log3Func(("[SD%RU8] Scheduling interrupt\n", pStream->u8SD)); 1177 1180 1178 /* *1181 /* 1179 1182 * Set the stream's BCIS bit. 1180 1183 * … … 1211 1214 tsTransferNext = tsNow + (cbTransferNext * pStream->State.cTicksPerByte); 1212 1215 1213 /* *1216 /* 1214 1217 * If the current transfer is complete, reset our counter. 1215 1218 * … … 1230 1233 1231 1234 LogFunc(("Timer set SD%RU8\n", pStream->u8SD)); 1232 hda TimerSet(pStream->pHDAState, pStream, tsTransferNext, false /* fForce */);1235 hdaR3TimerSet(pStream->pHDAState, pStream, tsTransferNext, false /* fForce */); 1233 1236 1234 1237 TMTimerLock(pStream->pTimer, VINF_SUCCESS); … … 1246 1249 pStream->u8SD, tsNow, tsTransferNext, tsTransferNext - tsNow)); 1247 1250 1248 hda StreamPeriodUnlock(pPeriod);1249 hda StreamUnlock(pStream);1251 hdaR3StreamPeriodUnlock(pPeriod); 1252 hdaR3StreamUnlock(pStream); 1250 1253 1251 1254 return VINF_SUCCESS; … … 1262 1265 * context or an asynchronous I/O stream thread (if supported). 1263 1266 */ 1264 void hda StreamUpdate(PHDASTREAM pStream, bool fInTimer)1267 void hdaR3StreamUpdate(PHDASTREAM pStream, bool fInTimer) 1265 1268 { 1266 1269 if (!pStream) … … 1282 1285 { 1283 1286 /* Is the HDA stream ready to be written (guest output data) to? If so, by how much? */ 1284 const uint32_t cbFree = hda StreamGetFree(pStream);1287 const uint32_t cbFree = hdaR3StreamGetFree(pStream); 1285 1288 1286 1289 if ( fInTimer … … 1290 1293 1291 1294 /* Do the DMA transfer. */ 1292 rc2 = hda StreamTransfer(pStream, cbFree);1295 rc2 = hdaR3StreamTransfer(pStream, cbFree); 1293 1296 AssertRC(rc2); 1294 1297 } 1295 1298 1296 1299 /* How much (guest output) data is available at the moment for the HDA stream? */ 1297 uint32_t cbUsed = hda StreamGetUsed(pStream);1300 uint32_t cbUsed = hdaR3StreamGetUsed(pStream); 1298 1301 1299 1302 #ifdef VBOX_WITH_AUDIO_HDA_ASYNC_IO … … 1301 1304 && cbUsed) 1302 1305 { 1303 rc2 = hda StreamAsyncIONotify(pStream);1306 rc2 = hdaR3StreamAsyncIONotify(pStream); 1304 1307 AssertRC(rc2); 1305 1308 } … … 1317 1320 { 1318 1321 /* Read (guest output) data and write it to the stream's sink. */ 1319 rc2 = hda StreamRead(pStream, cbUsed, NULL /* pcbRead */);1322 rc2 = hdaR3StreamRead(pStream, cbUsed, NULL /* pcbRead */); 1320 1323 AssertRC(rc2); 1321 1324 } … … 1343 1346 1344 1347 /* How much (guest input) data is available for writing at the moment for the HDA stream? */ 1345 const uint32_t cbFree = hda StreamGetFree(pStream);1348 const uint32_t cbFree = hdaR3StreamGetFree(pStream); 1346 1349 1347 1350 Log3Func(("[SD%RU8] cbReadable=%RU32, cbFree=%RU32\n", pStream->u8SD, cbReadable, cbFree)); … … 1370 1373 /* Write (guest input) data to the stream which was read from stream's sink before. */ 1371 1374 uint32_t cbWritten; 1372 rc2 = hda StreamWrite(pStream, abFIFO, cbRead, &cbWritten);1375 rc2 = hdaR3StreamWrite(pStream, abFIFO, cbRead, &cbWritten); 1373 1376 AssertRCBreak(rc2); 1374 1377 … … 1392 1395 if (cbReadable) 1393 1396 { 1394 rc2 = hda StreamWrite(pStream, NULL /* Silence */, cbReadable, NULL /* pcbWritten */);1397 rc2 = hdaR3StreamWrite(pStream, NULL /* Silence */, cbReadable, NULL /* pcbWritten */); 1395 1398 AssertRC(rc2); 1396 1399 } … … 1409 1412 if (tsNow - s_lasti >= 10) /** @todo Fix this properly. */ 1410 1413 { 1411 rc2 = hda StreamAsyncIONotify(pStream);1414 rc2 = hdaR3StreamAsyncIONotify(pStream); 1412 1415 AssertRC(rc2); 1413 1416 … … 1415 1418 } 1416 1419 1417 const uint32_t cbToTransfer = hda StreamGetUsed(pStream);1420 const uint32_t cbToTransfer = hdaR3StreamGetUsed(pStream); 1418 1421 if (cbToTransfer) 1419 1422 { 1420 rc2 = hda StreamTransfer(pStream, cbToTransfer);1423 rc2 = hdaR3StreamTransfer(pStream, cbToTransfer); 1421 1424 AssertRC(rc2); 1422 1425 } … … 1433 1436 * @param pStream HDA stream to lock. 1434 1437 */ 1435 void hda StreamLock(PHDASTREAM pStream)1438 void hdaR3StreamLock(PHDASTREAM pStream) 1436 1439 { 1437 1440 AssertPtrReturnVoid(pStream); … … 1446 1449 * @param pStream HDA stream to unlock. 1447 1450 */ 1448 void hda StreamUnlock(PHDASTREAM pStream)1451 void hdaR3StreamUnlock(PHDASTREAM pStream) 1449 1452 { 1450 1453 AssertPtrReturnVoid(pStream); … … 1461 1464 * @param u32LPIB New LPIB (position) value to set. 1462 1465 */ 1463 uint32_t hda StreamUpdateLPIB(PHDASTREAM pStream, uint32_t u32LPIB)1466 uint32_t hdaR3StreamUpdateLPIB(PHDASTREAM pStream, uint32_t u32LPIB) 1464 1467 { 1465 1468 AssertPtrReturn(pStream, 0); … … 1497 1500 * @param pStream HDA stream to register BDLE access handlers for. 1498 1501 */ 1499 bool hda StreamRegisterDMAHandlers(PHDASTREAM pStream)1502 bool hdaR3StreamRegisterDMAHandlers(PHDASTREAM pStream) 1500 1503 { 1501 1504 /* At least LVI and the BDL base must be set. */ … … 1506 1509 } 1507 1510 1508 hda StreamUnregisterDMAHandlers(pStream);1511 hdaR3StreamUnregisterDMAHandlers(pStream); 1509 1512 1510 1513 LogFunc(("Registering ...\n")); … … 1527 1530 { 1528 1531 HDABDLE BDLE; 1529 rc = hda BDLEFetch(pThis, &BDLE, pStream->u64BDLBase, i /* Index */);1532 rc = hdaR3BDLEFetch(pThis, &BDLE, pStream->u64BDLBase, i /* Index */); 1530 1533 if (RT_FAILURE(rc)) 1531 1534 break; … … 1634 1637 * @param pStream HDA stream to unregister BDLE access handlers for. 1635 1638 */ 1636 void hda StreamUnregisterDMAHandlers(PHDASTREAM pStream)1639 void hdaR3StreamUnregisterDMAHandlers(PHDASTREAM pStream) 1637 1640 { 1638 1641 LogFunc(("\n")); … … 1670 1673 * @param pvUser User argument. Must be of type PHDASTREAMTHREADCTX. 1671 1674 */ 1672 DECLCALLBACK(int) hda StreamAsyncIOThread(RTTHREAD hThreadSelf, void *pvUser)1675 DECLCALLBACK(int) hdaR3StreamAsyncIOThread(RTTHREAD hThreadSelf, void *pvUser) 1673 1676 { 1674 1677 PHDASTREAMTHREADCTX pCtx = (PHDASTREAMTHREADCTX)pvUser; … … 1704 1707 } 1705 1708 1706 hda StreamUpdate(pStream, false /* fInTimer */);1709 hdaR3StreamUpdate(pStream, false /* fInTimer */); 1707 1710 1708 1711 int rc3 = RTCritSectLeave(&pAIO->CritSect); … … 1726 1729 * @param pStream HDA audio stream to create the async I/O thread for. 1727 1730 */ 1728 int hda StreamAsyncIOCreate(PHDASTREAM pStream)1731 int hdaR3StreamAsyncIOCreate(PHDASTREAM pStream) 1729 1732 { 1730 1733 PHDASTREAMSTATEAIO pAIO = &pStream->State.AIO; … … 1747 1750 RTStrPrintf2(szThreadName, sizeof(szThreadName), "hdaAIO%RU8", pStream->u8SD); 1748 1751 1749 rc = RTThreadCreate(&pAIO->Thread, hda StreamAsyncIOThread, &Ctx,1752 rc = RTThreadCreate(&pAIO->Thread, hdaR3StreamAsyncIOThread, &Ctx, 1750 1753 0, RTTHREADTYPE_IO, RTTHREADFLAGS_WAITABLE, szThreadName); 1751 1754 if (RT_SUCCESS(rc)) … … 1767 1770 * @param pStream HDA audio stream to destroy the async I/O thread for. 1768 1771 */ 1769 int hda StreamAsyncIODestroy(PHDASTREAM pStream)1772 int hdaR3StreamAsyncIODestroy(PHDASTREAM pStream) 1770 1773 { 1771 1774 PHDASTREAMSTATEAIO pAIO = &pStream->State.AIO; … … 1776 1779 ASMAtomicWriteBool(&pAIO->fShutdown, true); 1777 1780 1778 int rc = hda StreamAsyncIONotify(pStream);1781 int rc = hdaR3StreamAsyncIONotify(pStream); 1779 1782 AssertRC(rc); 1780 1783 … … 1806 1809 * @param pStream HDA stream to notify async I/O thread for. 1807 1810 */ 1808 int hda StreamAsyncIONotify(PHDASTREAM pStream)1811 int hdaR3StreamAsyncIONotify(PHDASTREAM pStream) 1809 1812 { 1810 1813 return RTSemEventSignal(pStream->State.AIO.Event); … … 1816 1819 * @param pStream HDA stream to lock async I/O thread for. 1817 1820 */ 1818 void hda StreamAsyncIOLock(PHDASTREAM pStream)1821 void hdaR3StreamAsyncIOLock(PHDASTREAM pStream) 1819 1822 { 1820 1823 PHDASTREAMSTATEAIO pAIO = &pStream->State.AIO; … … 1832 1835 * @param pStream HDA stream to unlock async I/O thread for. 1833 1836 */ 1834 void hda StreamAsyncIOUnlock(PHDASTREAM pStream)1837 void hdaR3StreamAsyncIOUnlock(PHDASTREAM pStream) 1835 1838 { 1836 1839 PHDASTREAMSTATEAIO pAIO = &pStream->State.AIO; … … 1851 1854 * @remarks Does not do locking. 1852 1855 */ 1853 void hda StreamAsyncIOEnable(PHDASTREAM pStream, bool fEnable)1856 void hdaR3StreamAsyncIOEnable(PHDASTREAM pStream, bool fEnable) 1854 1857 { 1855 1858 PHDASTREAMSTATEAIO pAIO = &pStream->State.AIO; -
trunk/src/VBox/Devices/Audio/HDAStream.h
r71733 r71736 243 243 * @{ 244 244 */ 245 int hda StreamCreate(PHDASTREAM pStream, PHDASTATE pThis, uint8_t u8SD);246 void hda StreamDestroy(PHDASTREAM pStream);247 int hda StreamInit(PHDASTREAM pStream, uint8_t uSD);248 void hda StreamReset(PHDASTATE pThis, PHDASTREAM pStream, uint8_t uSD);249 int hda StreamEnable(PHDASTREAM pStream, bool fEnable);250 uint32_t hda StreamGetPosition(PHDASTATE pThis, PHDASTREAM pStream);251 void hda StreamSetPosition(PHDASTREAM pStream, uint32_t u32LPIB);252 uint32_t hda StreamGetFree(PHDASTREAM pStream);253 uint32_t hda StreamGetUsed(PHDASTREAM pStream);254 bool hda StreamTransferIsScheduled(PHDASTREAM pStream);255 uint64_t hda StreamTransferGetNext(PHDASTREAM pStream);256 int hda StreamTransfer(PHDASTREAM pStream, uint32_t cbToProcessMax);257 void hda StreamLock(PHDASTREAM pStream);258 void hda StreamUnlock(PHDASTREAM pStream);259 int hda StreamRead(PHDASTREAM pStream, uint32_t cbToRead, uint32_t *pcbRead);260 int hda StreamWrite(PHDASTREAM pStream, const void *pvBuf, uint32_t cbBuf, uint32_t *pcbWritten);261 void hda StreamUpdate(PHDASTREAM pStream, bool fAsync);245 int hdaR3StreamCreate(PHDASTREAM pStream, PHDASTATE pThis, uint8_t u8SD); 246 void hdaR3StreamDestroy(PHDASTREAM pStream); 247 int hdaR3StreamInit(PHDASTREAM pStream, uint8_t uSD); 248 void hdaR3StreamReset(PHDASTATE pThis, PHDASTREAM pStream, uint8_t uSD); 249 int hdaR3StreamEnable(PHDASTREAM pStream, bool fEnable); 250 uint32_t hdaR3StreamGetPosition(PHDASTATE pThis, PHDASTREAM pStream); 251 void hdaR3StreamSetPosition(PHDASTREAM pStream, uint32_t u32LPIB); 252 uint32_t hdaR3StreamGetFree(PHDASTREAM pStream); 253 uint32_t hdaR3StreamGetUsed(PHDASTREAM pStream); 254 bool hdaR3StreamTransferIsScheduled(PHDASTREAM pStream); 255 uint64_t hdaR3StreamTransferGetNext(PHDASTREAM pStream); 256 int hdaR3StreamTransfer(PHDASTREAM pStream, uint32_t cbToProcessMax); 257 void hdaR3StreamLock(PHDASTREAM pStream); 258 void hdaR3StreamUnlock(PHDASTREAM pStream); 259 int hdaR3StreamRead(PHDASTREAM pStream, uint32_t cbToRead, uint32_t *pcbRead); 260 int hdaR3StreamWrite(PHDASTREAM pStream, const void *pvBuf, uint32_t cbBuf, uint32_t *pcbWritten); 261 void hdaR3StreamUpdate(PHDASTREAM pStream, bool fAsync); 262 262 # ifdef HDA_USE_DMA_ACCESS_HANDLER 263 bool hda StreamRegisterDMAHandlers(PHDASTREAM pStream);264 void hda StreamUnregisterDMAHandlers(PHDASTREAM pStream);263 bool hdaR3StreamRegisterDMAHandlers(PHDASTREAM pStream); 264 void hdaR3StreamUnregisterDMAHandlers(PHDASTREAM pStream); 265 265 # endif /* HDA_USE_DMA_ACCESS_HANDLER */ 266 266 /** @} */ … … 269 269 * @{ 270 270 */ 271 DECLCALLBACK(void) hda StreamTimer(PPDMDEVINS pDevIns, PTMTIMER pTimer, void *pvUser);271 DECLCALLBACK(void) hdaR3StreamTimer(PPDMDEVINS pDevIns, PTMTIMER pTimer, void *pvUser); 272 272 /** @} */ 273 273 … … 277 277 */ 278 278 # ifdef VBOX_WITH_AUDIO_HDA_ASYNC_IO 279 DECLCALLBACK(int) hda StreamAsyncIOThread(RTTHREAD hThreadSelf, void *pvUser);280 int hda StreamAsyncIOCreate(PHDASTREAM pStream);281 int hda StreamAsyncIODestroy(PHDASTREAM pStream);282 int hda StreamAsyncIONotify(PHDASTREAM pStream);283 void hda StreamAsyncIOLock(PHDASTREAM pStream);284 void hda StreamAsyncIOUnlock(PHDASTREAM pStream);285 void hda StreamAsyncIOEnable(PHDASTREAM pStream, bool fEnable);279 DECLCALLBACK(int) hdaR3StreamAsyncIOThread(RTTHREAD hThreadSelf, void *pvUser); 280 int hdaR3StreamAsyncIOCreate(PHDASTREAM pStream); 281 int hdaR3StreamAsyncIODestroy(PHDASTREAM pStream); 282 int hdaR3StreamAsyncIONotify(PHDASTREAM pStream); 283 void hdaR3StreamAsyncIOLock(PHDASTREAM pStream); 284 void hdaR3StreamAsyncIOUnlock(PHDASTREAM pStream); 285 void hdaR3StreamAsyncIOEnable(PHDASTREAM pStream, bool fEnable); 286 286 # endif /* VBOX_WITH_AUDIO_HDA_ASYNC_IO */ 287 287 /** @} */ -
trunk/src/VBox/Devices/Audio/HDAStreamChannel.cpp
r69118 r71736 35 35 * @param fFlags 36 36 */ 37 int hda StreamChannelDataInit(PPDMAUDIOSTREAMCHANNELDATA pChanData, uint32_t fFlags)37 int hdaR3StreamChannelDataInit(PPDMAUDIOSTREAMCHANNELDATA pChanData, uint32_t fFlags) 38 38 { 39 39 int rc = RTCircBufCreate(&pChanData->pCircBuf, 256); /** @todo Make this configurable? */ … … 51 51 * @param pChanData Channel data to destroy. 52 52 */ 53 void hda StreamChannelDataDestroy(PPDMAUDIOSTREAMCHANNELDATA pChanData)53 void hdaR3StreamChannelDataDestroy(PPDMAUDIOSTREAMCHANNELDATA pChanData) 54 54 { 55 55 if (!pChanData) … … 73 73 * @param cbBuf Size (in bytes) of audio data to extract. 74 74 */ 75 int hda StreamChannelExtract(PPDMAUDIOSTREAMCHANNEL pChan, const void *pvBuf, size_t cbBuf)75 int hdaR3StreamChannelExtract(PPDMAUDIOSTREAMCHANNEL pChan, const void *pvBuf, size_t cbBuf) 76 76 { 77 77 AssertPtrReturn(pChan, VERR_INVALID_POINTER); … … 130 130 * @remark Currently not used / implemented. 131 131 */ 132 int hda StreamChannelAdvance(PPDMAUDIOSTREAMCHANNEL pChan, size_t cbAdv)132 int hdaR3StreamChannelAdvance(PPDMAUDIOSTREAMCHANNEL pChan, size_t cbAdv) 133 133 { 134 134 AssertPtrReturn(pChan, VERR_INVALID_POINTER); … … 142 142 /** 143 143 * Acquires (reads) audio channel data. 144 * Must be released when done with hda StreamChannelReleaseData().144 * Must be released when done with hdaR3StreamChannelReleaseData(). 145 145 * 146 146 * @returns IPRT status code. … … 149 149 * @param pcbData Size (in bytes) of acquired data. 150 150 */ 151 int hda StreamChannelAcquireData(PPDMAUDIOSTREAMCHANNELDATA pChanData, void **ppvData, size_t *pcbData)151 int hdaR3StreamChannelAcquireData(PPDMAUDIOSTREAMCHANNELDATA pChanData, void **ppvData, size_t *pcbData) 152 152 { 153 153 AssertPtrReturn(pChanData, VERR_INVALID_POINTER); … … 162 162 163 163 /** 164 * Releases formerly acquired data by hda StreamChannelAcquireData().164 * Releases formerly acquired data by hdaR3StreamChannelAcquireData(). 165 165 * 166 166 * @returns IPRT status code. 167 167 * @param pChanData Channel data to release formerly acquired data for. 168 168 */ 169 int hda StreamChannelReleaseData(PPDMAUDIOSTREAMCHANNELDATA pChanData)169 int hdaR3StreamChannelReleaseData(PPDMAUDIOSTREAMCHANNELDATA pChanData) 170 170 { 171 171 AssertPtrReturn(pChanData, VERR_INVALID_POINTER); -
trunk/src/VBox/Devices/Audio/HDAStreamChannel.h
r67908 r71736 19 19 #define HDA_STREAMCHANNEL_H 20 20 21 int hdaStreamChannelDataInit(PPDMAUDIOSTREAMCHANNELDATA pChanData, uint32_t fFlags);22 void hda StreamChannelDataDestroy(PPDMAUDIOSTREAMCHANNELDATA pChanData);23 int hdaStreamChannelExtract(PPDMAUDIOSTREAMCHANNEL pChan, const void *pvBuf, size_t cbBuf);24 int hdaStreamChannelAdvance(PPDMAUDIOSTREAMCHANNEL pChan, size_t cbAdv);25 int hdaStreamChannelAcquireData(PPDMAUDIOSTREAMCHANNELDATA pChanData, void *ppvData, size_t *pcbData);26 int hdaStreamChannelReleaseData(PPDMAUDIOSTREAMCHANNELDATA pChanData);21 int hdaR3StreamChannelDataInit(PPDMAUDIOSTREAMCHANNELDATA pChanData, uint32_t fFlags); 22 void hdaR3StreamChannelDataDestroy(PPDMAUDIOSTREAMCHANNELDATA pChanData); 23 int hdaR3StreamChannelExtract(PPDMAUDIOSTREAMCHANNEL pChan, const void *pvBuf, size_t cbBuf); 24 int hdaR3StreamChannelAdvance(PPDMAUDIOSTREAMCHANNEL pChan, size_t cbAdv); 25 int hdaR3StreamChannelAcquireData(PPDMAUDIOSTREAMCHANNELDATA pChanData, void *ppvData, size_t *pcbData); 26 int hdaR3StreamChannelReleaseData(PPDMAUDIOSTREAMCHANNELDATA pChanData); 27 27 28 28 #endif /* !HDA_STREAMCHANNEL_H */ -
trunk/src/VBox/Devices/Audio/HDAStreamMap.cpp
r71724 r71736 42 42 * @param pProps Pointer to PCM properties to use for initialization. 43 43 */ 44 int hda StreamMapInit(PHDASTREAMMAPPING pMapping, PPDMAUDIOPCMPROPS pProps)44 int hdaR3StreamMapInit(PHDASTREAMMAPPING pMapping, PPDMAUDIOPCMPROPS pProps) 45 45 { 46 46 AssertPtrReturn(pMapping, VERR_INVALID_POINTER); … … 50 50 return VERR_INVALID_PARAMETER; 51 51 52 hda StreamMapReset(pMapping);52 hdaR3StreamMapReset(pMapping); 53 53 54 54 pMapping->paChannels = (PPDMAUDIOSTREAMCHANNEL)RTMemAlloc(sizeof(PDMAUDIOSTREAMCHANNEL) * pProps->cChannels); … … 70 70 pChan->cbOff = pChan->cbFirst; 71 71 72 int rc2 = hda StreamChannelDataInit(&pChan->Data, PDMAUDIOSTREAMCHANNELDATA_FLAG_NONE);72 int rc2 = hdaR3StreamChannelDataInit(&pChan->Data, PDMAUDIOSTREAMCHANNELDATA_FLAG_NONE); 73 73 if (RT_SUCCESS(rc)) 74 74 rc = rc2; … … 106 106 * @param pMapping Pointer to mapping to destroy. 107 107 */ 108 void hda StreamMapDestroy(PHDASTREAMMAPPING pMapping)108 void hdaR3StreamMapDestroy(PHDASTREAMMAPPING pMapping) 109 109 { 110 hda StreamMapReset(pMapping);110 hdaR3StreamMapReset(pMapping); 111 111 112 112 if (pMapping->pCircBuf) … … 123 123 * @param pMapping Pointer to mapping to reset. 124 124 */ 125 void hda StreamMapReset(PHDASTREAMMAPPING pMapping)125 void hdaR3StreamMapReset(PHDASTREAMMAPPING pMapping) 126 126 { 127 127 AssertPtrReturnVoid(pMapping); … … 132 132 { 133 133 for (uint8_t i = 0; i < pMapping->cChannels; i++) 134 hda StreamChannelDataDestroy(&pMapping->paChannels[i].Data);134 hdaR3StreamChannelDataDestroy(&pMapping->paChannels[i].Data); 135 135 136 136 AssertPtr(pMapping->paChannels); -
trunk/src/VBox/Devices/Audio/HDAStreamMap.h
r67698 r71736 38 38 */ 39 39 #ifdef IN_RING3 40 int hda StreamMapInit(PHDASTREAMMAPPING pMapping, PPDMAUDIOPCMPROPS pProps);41 void hda StreamMapDestroy(PHDASTREAMMAPPING pMapping);42 void hda StreamMapReset(PHDASTREAMMAPPING pMapping);40 int hdaR3StreamMapInit(PHDASTREAMMAPPING pMapping, PPDMAUDIOPCMPROPS pProps); 41 void hdaR3StreamMapDestroy(PHDASTREAMMAPPING pMapping); 42 void hdaR3StreamMapReset(PHDASTREAMMAPPING pMapping); 43 43 #endif /* IN_RING3 */ 44 44 /** @} */ -
trunk/src/VBox/Devices/Audio/HDAStreamPeriod.cpp
r71733 r71736 48 48 * @param pPeriod Stream period to initialize. 49 49 */ 50 int hda StreamPeriodCreate(PHDASTREAMPERIOD pPeriod)50 int hdaR3StreamPeriodCreate(PHDASTREAMPERIOD pPeriod) 51 51 { 52 52 Assert(!(pPeriod->fStatus & HDASTREAMPERIOD_FLAG_VALID)); … … 64 64 * @param pPeriod Stream period to destroy. 65 65 */ 66 void hda StreamPeriodDestroy(PHDASTREAMPERIOD pPeriod)66 void hdaR3StreamPeriodDestroy(PHDASTREAMPERIOD pPeriod) 67 67 { 68 68 if (pPeriod->fStatus & HDASTREAMPERIOD_FLAG_VALID) … … 78 78 * 79 79 * @return VBox status code. 80 * @param pPeriod Stream period to (re-)initialize. Must be created with hda StreamPeriodCreate() first.80 * @param pPeriod Stream period to (re-)initialize. Must be created with hdaR3StreamPeriodCreate() first. 81 81 * @param u8SD Stream descriptor (serial data #) number to assign this stream period to. 82 82 * @param u16LVI The HDA stream's LVI value to use for the period calculation. … … 84 84 * @param pStreamCfg Audio stream configuration to use for this period. 85 85 */ 86 int hda StreamPeriodInit(PHDASTREAMPERIOD pPeriod,87 uint8_t u8SD, uint16_t u16LVI, uint32_t u32CBL, PPDMAUDIOSTREAMCFG pStreamCfg)86 int hdaR3StreamPeriodInit(PHDASTREAMPERIOD pPeriod, 87 uint8_t u8SD, uint16_t u16LVI, uint32_t u32CBL, PPDMAUDIOSTREAMCFG pStreamCfg) 88 88 { 89 89 if ( !u16LVI … … 111 111 pPeriod->u64StartWalClk = 0; 112 112 pPeriod->u32Hz = pStreamCfg->Props.uHz; 113 pPeriod->u64DurationWalClk = hda StreamPeriodFramesToWalClk(pPeriod, framesToTransfer);113 pPeriod->u64DurationWalClk = hdaR3StreamPeriodFramesToWalClk(pPeriod, framesToTransfer); 114 114 pPeriod->u64ElapsedWalClk = 0; 115 115 pPeriod->i64DelayWalClk = 0; … … 130 130 * @param pPeriod Stream period to reset. 131 131 */ 132 void hda StreamPeriodReset(PHDASTREAMPERIOD pPeriod)132 void hdaR3StreamPeriodReset(PHDASTREAMPERIOD pPeriod) 133 133 { 134 134 Log3Func(("[SD%RU8]\n", pPeriod->u8SD)); … … 155 155 * @param u64WalClk Wall clock (WALCLK) value to set for the period's starting point. 156 156 */ 157 int hda StreamPeriodBegin(PHDASTREAMPERIOD pPeriod, uint64_t u64WalClk)157 int hdaR3StreamPeriodBegin(PHDASTREAMPERIOD pPeriod, uint64_t u64WalClk) 158 158 { 159 159 Assert(!(pPeriod->fStatus & HDASTREAMPERIOD_FLAG_ACTIVE)); /* No nested calls. */ … … 177 177 * @param pPeriod Stream period to end life span for. 178 178 */ 179 void hda StreamPeriodEnd(PHDASTREAMPERIOD pPeriod)179 void hdaR3StreamPeriodEnd(PHDASTREAMPERIOD pPeriod) 180 180 { 181 181 Log3Func(("[SD%RU8] Took %zuus\n", pPeriod->u8SD, (RTTimeNanoTS() - pPeriod->Dbg.tsStartNs) / 1000)); … … 188 188 ("%RU8 interrupts for stream #%RU8 still pending -- so ending a period might trigger audio hangs\n", 189 189 pPeriod->cIntPending, pPeriod->u8SD)); 190 Assert(hda StreamPeriodIsComplete(pPeriod));190 Assert(hdaR3StreamPeriodIsComplete(pPeriod)); 191 191 192 192 pPeriod->fStatus &= ~HDASTREAMPERIOD_FLAG_ACTIVE; … … 198 198 * @param pPeriod Stream period to pause. 199 199 */ 200 void hda StreamPeriodPause(PHDASTREAMPERIOD pPeriod)200 void hdaR3StreamPeriodPause(PHDASTREAMPERIOD pPeriod) 201 201 { 202 202 AssertMsg((pPeriod->fStatus & HDASTREAMPERIOD_FLAG_ACTIVE), ("Period %p already in inactive state\n", pPeriod)); … … 212 212 * @param pPeriod Stream period to resume. 213 213 */ 214 void hda StreamPeriodResume(PHDASTREAMPERIOD pPeriod)214 void hdaR3StreamPeriodResume(PHDASTREAMPERIOD pPeriod) 215 215 { 216 216 AssertMsg(!(pPeriod->fStatus & HDASTREAMPERIOD_FLAG_ACTIVE), ("Period %p already in active state\n", pPeriod)); … … 227 227 * @param pPeriod Stream period to lock. 228 228 */ 229 bool hda StreamPeriodLock(PHDASTREAMPERIOD pPeriod)229 bool hdaR3StreamPeriodLock(PHDASTREAMPERIOD pPeriod) 230 230 { 231 231 return RT_SUCCESS(RTCritSectEnter(&pPeriod->CritSect)); … … 237 237 * @param pPeriod Stream period to unlock. 238 238 */ 239 void hda StreamPeriodUnlock(PHDASTREAMPERIOD pPeriod)239 void hdaR3StreamPeriodUnlock(PHDASTREAMPERIOD pPeriod) 240 240 { 241 241 int rc2 = RTCritSectLeave(&pPeriod->CritSect); … … 252 252 * @remark Calculation depends on the given stream period and assumes a 24 MHz wall clock counter (WALCLK). 253 253 */ 254 uint64_t hda StreamPeriodFramesToWalClk(PHDASTREAMPERIOD pPeriod, uint32_t uFrames)254 uint64_t hdaR3StreamPeriodFramesToWalClk(PHDASTREAMPERIOD pPeriod, uint32_t uFrames) 255 255 { 256 256 /* Prevent division by zero. */ … … 268 268 * @param pPeriod Stream period to use. 269 269 */ 270 uint64_t hda StreamPeriodGetAbsElapsedWalClk(PHDASTREAMPERIOD pPeriod)270 uint64_t hdaR3StreamPeriodGetAbsElapsedWalClk(PHDASTREAMPERIOD pPeriod) 271 271 { 272 272 return pPeriod->u64StartWalClk … … 282 282 * @param pPeriod Stream period to use. 283 283 */ 284 uint64_t hda StreamPeriodGetAbsEndWalClk(PHDASTREAMPERIOD pPeriod)284 uint64_t hdaR3StreamPeriodGetAbsEndWalClk(PHDASTREAMPERIOD pPeriod) 285 285 { 286 286 return pPeriod->u64StartWalClk + pPeriod->u64DurationWalClk; … … 293 293 * @param pPeriod Stream period to return value for. 294 294 */ 295 uint32_t hda StreamPeriodGetRemainingFrames(PHDASTREAMPERIOD pPeriod)295 uint32_t hdaR3StreamPeriodGetRemainingFrames(PHDASTREAMPERIOD pPeriod) 296 296 { 297 297 Assert(pPeriod->framesToTransfer >= pPeriod->framesTransferred); … … 305 305 * @param pPeriod Stream period to get status for. 306 306 */ 307 bool hda StreamPeriodHasElapsed(PHDASTREAMPERIOD pPeriod)307 bool hdaR3StreamPeriodHasElapsed(PHDASTREAMPERIOD pPeriod) 308 308 { 309 309 return (pPeriod->u64ElapsedWalClk >= pPeriod->u64DurationWalClk); … … 318 318 * @param u64WalClk Absolute wall clock (WALCLK) time to check for. 319 319 */ 320 bool hda StreamPeriodHasPassedAbsWalClk(PHDASTREAMPERIOD pPeriod, uint64_t u64WalClk)320 bool hdaR3StreamPeriodHasPassedAbsWalClk(PHDASTREAMPERIOD pPeriod, uint64_t u64WalClk) 321 321 { 322 322 /* Period not in use? */ … … 324 324 return true; /* ... implies that it has passed. */ 325 325 326 if (hda StreamPeriodHasElapsed(pPeriod))326 if (hdaR3StreamPeriodHasElapsed(pPeriod)) 327 327 return true; /* Period already has elapsed. */ 328 328 … … 336 336 * @param pPeriod Stream period to get status for. 337 337 */ 338 bool hda StreamPeriodNeedsInterrupt(PHDASTREAMPERIOD pPeriod)338 bool hdaR3StreamPeriodNeedsInterrupt(PHDASTREAMPERIOD pPeriod) 339 339 { 340 340 return pPeriod->cIntPending > 0; … … 349 349 * keeps track of the required (pending) interrupts for a stream period. 350 350 */ 351 void hda StreamPeriodAcquireInterrupt(PHDASTREAMPERIOD pPeriod)351 void hdaR3StreamPeriodAcquireInterrupt(PHDASTREAMPERIOD pPeriod) 352 352 { 353 353 uint32_t cIntPending = pPeriod->cIntPending; … … 368 368 * @param pPeriod Stream period to release pending interrupt for. 369 369 */ 370 void hda StreamPeriodReleaseInterrupt(PHDASTREAMPERIOD pPeriod)370 void hdaR3StreamPeriodReleaseInterrupt(PHDASTREAMPERIOD pPeriod) 371 371 { 372 372 Assert(pPeriod->cIntPending); … … 383 383 * @param framesInc Audio frames to add. 384 384 */ 385 void hda StreamPeriodInc(PHDASTREAMPERIOD pPeriod, uint32_t framesInc)385 void hdaR3StreamPeriodInc(PHDASTREAMPERIOD pPeriod, uint32_t framesInc) 386 386 { 387 387 pPeriod->framesTransferred += framesInc; 388 388 Assert(pPeriod->framesTransferred <= pPeriod->framesToTransfer); 389 389 390 pPeriod->u64ElapsedWalClk = hda StreamPeriodFramesToWalClk(pPeriod, pPeriod->framesTransferred);390 pPeriod->u64ElapsedWalClk = hdaR3StreamPeriodFramesToWalClk(pPeriod, pPeriod->framesTransferred); 391 391 Assert(pPeriod->u64ElapsedWalClk <= pPeriod->u64DurationWalClk); 392 392 … … 404 404 * and 2) processed all required audio frames. 405 405 */ 406 bool hda StreamPeriodIsComplete(PHDASTREAMPERIOD pPeriod)406 bool hdaR3StreamPeriodIsComplete(PHDASTREAMPERIOD pPeriod) 407 407 { 408 408 const bool fIsComplete = /* Has the period elapsed time-wise? */ 409 hda StreamPeriodHasElapsed(pPeriod)409 hdaR3StreamPeriodHasElapsed(pPeriod) 410 410 /* All frames transferred? */ 411 411 && pPeriod->framesTransferred >= pPeriod->framesToTransfer; … … 422 422 fIsComplete ? "COMPLETE" : "NOT COMPLETE YET", 423 423 pPeriod->u64ElapsedWalClk, pPeriod->u64DurationWalClk, 424 hda StreamPeriodGetAbsElapsedWalClk(pPeriod), pPeriod->u64StartWalClk,425 hda StreamPeriodGetAbsEndWalClk(pPeriod), pPeriod->cIntPending));424 hdaR3StreamPeriodGetAbsElapsedWalClk(pPeriod), pPeriod->u64StartWalClk, 425 hdaR3StreamPeriodGetAbsEndWalClk(pPeriod), pPeriod->cIntPending)); 426 426 427 427 return fIsComplete; -
trunk/src/VBox/Devices/Audio/HDAStreamPeriod.h
r71733 r71736 84 84 85 85 #ifdef IN_RING3 86 int hda StreamPeriodCreate(PHDASTREAMPERIOD pPeriod);87 void hda StreamPeriodDestroy(PHDASTREAMPERIOD pPeriod);88 int hda StreamPeriodInit(PHDASTREAMPERIOD pPeriod, uint8_t u8SD, uint16_t u16LVI, uint32_t u32CBL, PPDMAUDIOSTREAMCFG pStreamCfg);89 void hda StreamPeriodReset(PHDASTREAMPERIOD pPeriod);90 int hda StreamPeriodBegin(PHDASTREAMPERIOD pPeriod, uint64_t u64WalClk);91 void hda StreamPeriodEnd(PHDASTREAMPERIOD pPeriod);92 void hda StreamPeriodPause(PHDASTREAMPERIOD pPeriod);93 void hda StreamPeriodResume(PHDASTREAMPERIOD pPeriod);94 bool hda StreamPeriodLock(PHDASTREAMPERIOD pPeriod);95 void hda StreamPeriodUnlock(PHDASTREAMPERIOD pPeriod);96 uint64_t hda StreamPeriodFramesToWalClk(PHDASTREAMPERIOD pPeriod, uint32_t uFrames);97 uint64_t hda StreamPeriodGetAbsEndWalClk(PHDASTREAMPERIOD pPeriod);98 uint64_t hda StreamPeriodGetAbsElapsedWalClk(PHDASTREAMPERIOD pPeriod);99 uint32_t hda StreamPeriodGetRemainingFrames(PHDASTREAMPERIOD pPeriod);100 bool hda StreamPeriodHasElapsed(PHDASTREAMPERIOD pPeriod);101 bool hda StreamPeriodHasPassedAbsWalClk(PHDASTREAMPERIOD pPeriod, uint64_t u64WalClk);102 bool hda StreamPeriodNeedsInterrupt(PHDASTREAMPERIOD pPeriod);103 void hda StreamPeriodAcquireInterrupt(PHDASTREAMPERIOD pPeriod);104 void hda StreamPeriodReleaseInterrupt(PHDASTREAMPERIOD pPeriod);105 void hda StreamPeriodInc(PHDASTREAMPERIOD pPeriod, uint32_t framesInc);106 bool hda StreamPeriodIsComplete(PHDASTREAMPERIOD pPeriod);86 int hdaR3StreamPeriodCreate(PHDASTREAMPERIOD pPeriod); 87 void hdaR3StreamPeriodDestroy(PHDASTREAMPERIOD pPeriod); 88 int hdaR3StreamPeriodInit(PHDASTREAMPERIOD pPeriod, uint8_t u8SD, uint16_t u16LVI, uint32_t u32CBL, PPDMAUDIOSTREAMCFG pStreamCfg); 89 void hdaR3StreamPeriodReset(PHDASTREAMPERIOD pPeriod); 90 int hdaR3StreamPeriodBegin(PHDASTREAMPERIOD pPeriod, uint64_t u64WalClk); 91 void hdaR3StreamPeriodEnd(PHDASTREAMPERIOD pPeriod); 92 void hdaR3StreamPeriodPause(PHDASTREAMPERIOD pPeriod); 93 void hdaR3StreamPeriodResume(PHDASTREAMPERIOD pPeriod); 94 bool hdaR3StreamPeriodLock(PHDASTREAMPERIOD pPeriod); 95 void hdaR3StreamPeriodUnlock(PHDASTREAMPERIOD pPeriod); 96 uint64_t hdaR3StreamPeriodFramesToWalClk(PHDASTREAMPERIOD pPeriod, uint32_t uFrames); 97 uint64_t hdaR3StreamPeriodGetAbsEndWalClk(PHDASTREAMPERIOD pPeriod); 98 uint64_t hdaR3StreamPeriodGetAbsElapsedWalClk(PHDASTREAMPERIOD pPeriod); 99 uint32_t hdaR3StreamPeriodGetRemainingFrames(PHDASTREAMPERIOD pPeriod); 100 bool hdaR3StreamPeriodHasElapsed(PHDASTREAMPERIOD pPeriod); 101 bool hdaR3StreamPeriodHasPassedAbsWalClk(PHDASTREAMPERIOD pPeriod, uint64_t u64WalClk); 102 bool hdaR3StreamPeriodNeedsInterrupt(PHDASTREAMPERIOD pPeriod); 103 void hdaR3StreamPeriodAcquireInterrupt(PHDASTREAMPERIOD pPeriod); 104 void hdaR3StreamPeriodReleaseInterrupt(PHDASTREAMPERIOD pPeriod); 105 void hdaR3StreamPeriodInc(PHDASTREAMPERIOD pPeriod, uint32_t framesInc); 106 bool hdaR3StreamPeriodIsComplete(PHDASTREAMPERIOD pPeriod); 107 107 #endif /* IN_RING3 */ 108 108
Note:
See TracChangeset
for help on using the changeset viewer.