Changeset 82324 in vbox
- Timestamp:
- Dec 2, 2019 2:53:47 PM (5 years ago)
- Location:
- trunk/src/VBox/Devices/Audio
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/DevIchAc97.cpp
r82323 r82324 505 505 /** The device timer Hz rate. Defaults to AC97_TIMER_HZ_DEFAULT_DEFAULT. */ 506 506 uint16_t uTimerHz; 507 /** The timer for pumping data thru the attached LUN drivers - RCPtr. */ 508 PTMTIMERRC pTimerRC[AC97_MAX_STREAMS]; 509 /** The timer for pumping data thru the attached LUN drivers - R3Ptr. */ 510 PTMTIMERR3 pTimerR3[AC97_MAX_STREAMS]; 511 /** The timer for pumping data thru the attached LUN drivers - R0Ptr. */ 512 PTMTIMERR0 pTimerR0[AC97_MAX_STREAMS]; 507 uint16_t au16Padding1[3]; 508 /** The timer for pumping data thru the attached LUN drivers. */ 509 TMTIMERHANDLE ahTimers[AC97_MAX_STREAMS]; 513 510 /** List of associated LUN drivers (AC97DRIVER). */ 514 511 RTLISTANCHORR3 lstDrv; … … 581 578 #define DEVAC97_LOCK_BOTH_RETURN(a_pDevIns, a_pThis, a_SD, a_rcBusy) \ 582 579 do { \ 583 int rcLock = TMTimerLock((a_pThis)->DEVAC97_CTX_SUFF_SD(pTimer, a_SD), (a_rcBusy)); \580 int rcLock = PDMDevHlpTimerLock((a_pDevIns), RT_SAFE_SUBSCRIPT8((a_pThis)->ahTimers, (a_SD)), (a_rcBusy)); \ 584 581 if (rcLock == VINF_SUCCESS) \ 585 582 { \ … … 587 584 if (rcLock == VINF_SUCCESS) \ 588 585 break; \ 589 TMTimerUnlock((a_pThis)->DEVAC97_CTX_SUFF_SD(pTimer, a_SD)); \586 PDMDevHlpTimerUnlock((a_pDevIns), RT_SAFE_SUBSCRIPT8((a_pThis)->ahTimers, (a_SD))); \ 590 587 } \ 591 588 AssertRC(rcLock); \ … … 599 596 do { \ 600 597 PDMDevHlpCritSectLeave((a_pDevIns), &(a_pThis)->CritSect); \ 601 TMTimerUnlock((a_pThis)->DEVAC97_CTX_SUFF_SD(pTimer, a_SD)); \598 PDMDevHlpTimerUnlock((a_pDevIns), RT_SAFE_SUBSCRIPT8((a_pThis)->ahTimers, (a_SD))); \ 602 599 } while (0) 603 600 … … 655 652 # endif 656 653 #endif /* IN_RING3 */ 657 bool ichac97TimerSet(PAC97STATE pThis, PAC97STREAM pStream, uint64_t tsExpire, bool fForce);654 static bool ichac97TimerSet(PPDMDEVINS pDevIns, PAC97STATE pThis, PAC97STREAM pStream, uint64_t tsExpire, bool fForce); 658 655 659 656 static void ichac97WarmReset(PAC97STATE pThis) … … 1922 1919 * 1923 1920 * @returns Calculated ticks 1921 * @param pDevIns The device instance. 1924 1922 * @param pThis AC'97 device state. 1925 1923 * @param pStream AC'97 stream to calculate ticks for. 1926 1924 * @param cbBytes Bytes to calculate ticks for. 1927 1925 */ 1928 static uint64_t ichac97R3StreamTransferCalcNext(P AC97STATE pThis, PAC97STREAM pStream, uint32_t cbBytes)1926 static uint64_t ichac97R3StreamTransferCalcNext(PPDMDEVINS pDevIns, PAC97STATE pThis, PAC97STREAM pStream, uint32_t cbBytes) 1929 1927 { 1930 1928 if (!cbBytes) … … 1932 1930 1933 1931 const uint64_t usBytes = DrvAudioHlpBytesToMicro(cbBytes, &pStream->State.Cfg.Props); 1934 const uint64_t cTransferTicks = TMTimerFromMicro((pThis)->DEVAC97_CTX_SUFF_SD(pTimer, pStream->u8SD), usBytes);1932 const uint64_t cTransferTicks = PDMDevHlpTimerFromMicro(pDevIns, RT_SAFE_SUBSCRIPT8(pThis->ahTimers, pStream->u8SD), usBytes); 1935 1933 1936 1934 Log3Func(("[SD%RU8] Timer %uHz, cbBytes=%RU32 -> usBytes=%RU64, cTransferTicks=%RU64\n", … … 1943 1941 * Updates the next transfer based on a specific amount of bytes. 1944 1942 * 1943 * @param pDevIns The device instance. 1945 1944 * @param pThis AC'97 device state. 1946 1945 * @param pStream AC'97 stream to update. 1947 1946 * @param cbBytes Bytes to update next transfer for. 1948 1947 */ 1949 static void ichac97R3StreamTransferUpdate(P AC97STATE pThis, PAC97STREAM pStream, uint32_t cbBytes)1948 static void ichac97R3StreamTransferUpdate(PPDMDEVINS pDevIns, PAC97STATE pThis, PAC97STREAM pStream, uint32_t cbBytes) 1950 1949 { 1951 1950 if (!cbBytes) … … 1957 1956 1958 1957 /* Update the transfer ticks. */ 1959 pStream->State.cTransferTicks = ichac97R3StreamTransferCalcNext(p This, pStream, pStream->State.cbTransferChunk);1958 pStream->State.cTransferTicks = ichac97R3StreamTransferCalcNext(pDevIns, pThis, pStream, pStream->State.cbTransferChunk); 1960 1959 Assert(pStream->State.cTransferTicks); /* Paranoia. */ 1961 1960 } … … 2599 2598 AssertPtr(pStream); 2600 2599 Assert(PDMDevHlpCritSectIsOwner(pDevIns, &pThis->CritSect)); 2601 Assert( TMTimerIsLockOwner((pThis)->DEVAC97_CTX_SUFF_SD(pTimer, pStream->u8SD)));2600 Assert(PDMDevHlpTimerIsLockOwner(pDevIns, RT_SAFE_SUBSCRIPT8(pThis->ahTimers, pStream->u8SD))); 2602 2601 2603 2602 ichac97R3StreamUpdate(pThis, pStream, true /* fInTimer */); … … 2606 2605 if (pSink && AudioMixerSinkIsActive(pSink)) 2607 2606 { 2608 ichac97R3StreamTransferUpdate(pThis, pStream, pStream->Regs.picb << 1); /** @todo r=andy Assumes 16-bit samples. */ 2609 2610 ichac97TimerSet(pThis, pStream, 2611 TMTimerGet((pThis)->DEVAC97_CTX_SUFF_SD(pTimer, pStream->u8SD)) + pStream->State.cTransferTicks, 2607 ichac97R3StreamTransferUpdate(pDevIns, pThis, pStream, pStream->Regs.picb << 1); /** @todo r=andy Assumes 16-bit samples. */ 2608 2609 ichac97TimerSet(pDevIns, pThis, pStream, 2610 PDMDevHlpTimerGet(pDevIns, RT_SAFE_SUBSCRIPT8(pThis->ahTimers, pStream->u8SD)) 2611 + pStream->State.cTransferTicks, 2612 2612 false /* fForce */); 2613 2613 } … … 2622 2622 * 2623 2623 * @returns Whether the new expiration time was set or not. 2624 * @param pDevIns The device instance. 2624 2625 * @param pThis AC'97 state. 2625 2626 * @param pStream AC'97 stream to set timer for. … … 2636 2637 * Forcing a new expiration time will override the above mechanism. 2637 2638 */ 2638 bool ichac97TimerSet(PAC97STATE pThis, PAC97STREAM pStream, uint64_t tsExpire, bool fForce)2639 static bool ichac97TimerSet(PPDMDEVINS pDevIns, PAC97STATE pThis, PAC97STREAM pStream, uint64_t tsExpire, bool fForce) 2639 2640 { 2640 2641 AssertPtrReturn(pThis, false); … … 2645 2646 uint64_t tsExpireMin = tsExpire; 2646 2647 2647 AssertPtr((pThis)->DEVAC97_CTX_SUFF_SD(pTimer, pStream->u8SD)); 2648 2649 const uint64_t tsNow = TMTimerGet((pThis)->DEVAC97_CTX_SUFF_SD(pTimer, pStream->u8SD)); 2648 TMTIMERHANDLE const hTimer = RT_SAFE_SUBSCRIPT8(pThis->ahTimers, pStream->u8SD); 2649 /** @todo r=bird: This is rather silly given that all three callers just did 2650 * TimerGet + interval. */ 2651 const uint64_t tsNow = PDMDevHlpTimerGet(pDevIns, hTimer); 2650 2652 2651 2653 /* Make sure to not go backwards in time, as this will assert in TMTimerSet(). */ … … 2653 2655 tsExpireMin = tsNow; 2654 2656 2655 int rc = TMTimerSet((pThis)->DEVAC97_CTX_SUFF_SD(pTimer, pStream->u8SD), tsExpireMin);2656 AssertRC (rc);2657 2658 return RT_SUCCESS(rc);2657 int rc = PDMDevHlpTimerSet(pDevIns, hTimer, tsExpireMin); 2658 AssertRCReturn(rc, false); 2659 2660 return true; 2659 2661 } 2660 2662 … … 3146 3148 3147 3149 /* Arm the timer for this stream. */ 3148 int rc2 = ichac97TimerSet(pThis, pStream, 3149 TMTimerGet((pThis)->DEVAC97_CTX_SUFF_SD(pTimer, pStream->u8SD)) + pStream->State.cTransferTicks, 3150 /** @todo r=bird: This function returns bool, not VBox status! */ 3151 int rc2 = ichac97TimerSet(pDevIns, pThis, pStream, 3152 PDMDevHlpTimerGet(pDevIns, RT_SAFE_SUBSCRIPT8(pThis->ahTimers, 3153 pStream->u8SD)) 3154 + pStream->State.cTransferTicks, 3150 3155 false /* fForce */); 3151 3156 AssertRC(rc2); … … 3641 3646 { 3642 3647 /* Re-arm the timer for this stream. */ 3643 rc2 = ichac97TimerSet(pThis, pStream, 3644 TMTimerGet((pThis)->DEVAC97_CTX_SUFF_SD(pTimer, pStream->u8SD)) + pStream->State.cTransferTicks, 3648 /** @todo r=bird: This function returns bool, not VBox status! */ 3649 rc2 = ichac97TimerSet(pDevIns, pThis, pStream, 3650 PDMDevHlpTimerGet(pDevIns, RT_SAFE_SUBSCRIPT8(pThis->ahTimers, pStream->u8SD)) 3651 + pStream->State.cTransferTicks, 3645 3652 false /* fForce */); 3646 3653 } … … 3949 3956 PAC97STATE pThis = PDMDEVINS_2_DATA(pDevIns, PAC97STATE); 3950 3957 pThis->pDevInsRC = PDMDEVINS_2_RCPTR(pDevIns); 3951 3952 for (unsigned i = 0; i < AC97_MAX_STREAMS; i++)3953 pThis->pTimerRC[i] = TMTimerRCPtr(pThis->pTimerR3[i]);3954 3958 } 3955 3959 … … 4265 4269 ichac97R3Reset(pDevIns); 4266 4270 4267 static const char * const s_apszNames[] = 4268 { 4269 "AC97 PI", "AC97 PO", "AC97 MC" 4270 }; 4271 /* 4272 * Create the emulation timers (one per stream). 4273 * 4274 * We must the critical section for the timers as the device has a 4275 * noop section associated with it. 4276 * 4277 * Note: Use TMCLOCK_VIRTUAL_SYNC here, as the guest's AC'97 driver 4278 * relies on exact (virtual) DMA timing and uses DMA Position Buffers 4279 * instead of the LPIB registers. 4280 */ 4281 static const char * const s_apszNames[] = { "AC97 PI", "AC97 PO", "AC97 MC" }; 4271 4282 AssertCompile(RT_ELEMENTS(s_apszNames) == AC97_MAX_STREAMS); 4272 4283 AssertCompile(RT_ELEMENTS(pThis->ahTimers) == AC97_MAX_STREAMS); 4273 4284 for (unsigned i = 0; i < AC97_MAX_STREAMS; i++) 4274 4285 { 4275 /* Create the emulation timer (per stream). 4276 * 4277 * Note: Use TMCLOCK_VIRTUAL_SYNC here, as the guest's AC'97 driver 4278 * relies on exact (virtual) DMA timing and uses DMA Position Buffers 4279 * instead of the LPIB registers. 4280 */ 4281 rc = PDMDevHlpTMTimerCreate(pDevIns, TMCLOCK_VIRTUAL_SYNC, ichac97R3Timer, &pThis->aStreams[i], 4282 TMTIMER_FLAGS_NO_CRIT_SECT, s_apszNames[i], &pThis->pTimerR3[i]); 4286 rc = PDMDevHlpTimerCreate(pDevIns, TMCLOCK_VIRTUAL_SYNC, ichac97R3Timer, &pThis->aStreams[i], 4287 TMTIMER_FLAGS_NO_CRIT_SECT, s_apszNames[i], &pThis->ahTimers[i]); 4283 4288 AssertRCReturn(rc, rc); 4284 pThis->pTimerR0[i] = TMTimerR0Ptr(pThis->pTimerR3[i]); 4285 pThis->pTimerRC[i] = TMTimerRCPtr(pThis->pTimerR3[i]); 4286 4287 /* Use our own critcal section for the device timer. 4288 * That way we can control more fine-grained when to lock what. */ 4289 rc = TMR3TimerSetCritSect(pThis->pTimerR3[i], &pThis->CritSect); 4289 4290 rc = PDMDevHlpTimerSetCritSect(pDevIns, pThis->ahTimers[i], &pThis->CritSect); 4290 4291 AssertRCReturn(rc, rc); 4291 4292 } -
trunk/src/VBox/Devices/Audio/HDAStream.cpp
r82323 r82324 1110 1110 * 1111 1111 * I know, the following code is horribly slow, but seems to work for now. 1112 ** @todo Optimize channel data extraction! Use some SSE(3) / intrinsics?1113 1112 */ 1113 /** @todo Optimize channel data extraction! Use some SSE(3) / intrinsics? */ 1114 1114 for (unsigned m = 0; m < pStream->State.Mapping.cMappings; m++) 1115 1115 {
Note:
See TracChangeset
for help on using the changeset viewer.