Changeset 71756 in vbox for trunk/src/VBox/Devices
- Timestamp:
- Apr 9, 2018 9:32:41 AM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/DevIchAc97.cpp
r71753 r71756 582 582 *********************************************************************************************************************************/ 583 583 #ifdef IN_RING3 584 static int ichac97 StreamCreate(PAC97STATE pThis, PAC97STREAM pStream, uint8_t u8Strm);585 static void ichac97 StreamDestroy(PAC97STATE pThis, PAC97STREAM pStream);586 static int ichac97 StreamOpen(PAC97STATE pThis, PAC97STREAM pStream);587 static int ichac97 StreamReOpen(PAC97STATE pThis, PAC97STREAM pStream);588 static int ichac97 StreamClose(PAC97STATE pThis, PAC97STREAM pStream);589 static void ichac97 StreamReset(PAC97STATE pThis, PAC97STREAM pStream);590 static void ichac97 StreamLock(PAC97STREAM pStream);591 static void ichac97 StreamUnlock(PAC97STREAM pStream);592 static uint32_t ichac97 StreamGetUsed(PAC97STREAM pStream);593 static uint32_t ichac97 StreamGetFree(PAC97STREAM pStream);594 static int ichac97 StreamTransfer(PAC97STATE pThis, PAC97STREAM pStream, uint32_t cbToProcessMax);595 static void ichac97 StreamUpdate(PAC97STATE pThis, PAC97STREAM pStream, bool fInTimer);596 597 static DECLCALLBACK(void) ichac97R eset(PPDMDEVINS pDevIns);584 static int ichac97R3StreamCreate(PAC97STATE pThis, PAC97STREAM pStream, uint8_t u8Strm); 585 static void ichac97R3StreamDestroy(PAC97STATE pThis, PAC97STREAM pStream); 586 static int ichac97R3StreamOpen(PAC97STATE pThis, PAC97STREAM pStream); 587 static int ichac97R3StreamReOpen(PAC97STATE pThis, PAC97STREAM pStream); 588 static int ichac97R3StreamClose(PAC97STATE pThis, PAC97STREAM pStream); 589 static void ichac97R3StreamReset(PAC97STATE pThis, PAC97STREAM pStream); 590 static void ichac97R3StreamLock(PAC97STREAM pStream); 591 static void ichac97R3StreamUnlock(PAC97STREAM pStream); 592 static uint32_t ichac97R3StreamGetUsed(PAC97STREAM pStream); 593 static uint32_t ichac97R3StreamGetFree(PAC97STREAM pStream); 594 static int ichac97R3StreamTransfer(PAC97STATE pThis, PAC97STREAM pStream, uint32_t cbToProcessMax); 595 static void ichac97R3StreamUpdate(PAC97STATE pThis, PAC97STREAM pStream, bool fInTimer); 596 597 static DECLCALLBACK(void) ichac97R3Reset(PPDMDEVINS pDevIns); 598 598 # ifndef VBOX_WITH_AUDIO_AC97_CALLBACKS 599 static int ichac97 TimerStart(PAC97STATE pThis);600 static int ichac97 TimerMaybeStart(PAC97STATE pThis);601 static int ichac97 TimerStop(PAC97STATE pThis);602 static int ichac97 TimerMaybeStop(PAC97STATE pThis);603 static void ichac97 TimerMain(PAC97STATE pThis);604 static DECLCALLBACK(void) ichac97 Timer(PPDMDEVINS pDevIns, PTMTIMER pTimer, void *pvUser);599 static int ichac97R3TimerStart(PAC97STATE pThis); 600 static int ichac97R3TimerMaybeStart(PAC97STATE pThis); 601 static int ichac97R3TimerStop(PAC97STATE pThis); 602 static int ichac97R3TimerMaybeStop(PAC97STATE pThis); 603 static void ichac97R3TimerMain(PAC97STATE pThis); 604 static DECLCALLBACK(void) ichac97R3Timer(PPDMDEVINS pDevIns, PTMTIMER pTimer, void *pvUser); 605 605 # endif 606 static void ichac97 DoTransfers(PAC97STATE pThis);607 608 static int ichac97 MixerAddDrvStream(PAC97STATE pThis, PAUDMIXSINK pMixSink, PPDMAUDIOSTREAMCFG pCfg, PAC97DRIVER pDrv);609 static int ichac97 MixerAddDrvStreams(PAC97STATE pThis, PAUDMIXSINK pMixSink, PPDMAUDIOSTREAMCFG pCfg);610 static void ichac97 MixerRemoveDrvStream(PAC97STATE pThis, PAUDMIXSINK pMixSink, PDMAUDIODIR enmDir, PDMAUDIODESTSOURCE dstSrc, PAC97DRIVER pDrv);611 static void ichac97 MixerRemoveDrvStreams(PAC97STATE pThis, PAUDMIXSINK pMixSink, PDMAUDIODIR enmDir, PDMAUDIODESTSOURCE dstSrc);606 static void ichac97R3DoTransfers(PAC97STATE pThis); 607 608 static int ichac97R3MixerAddDrvStream(PAC97STATE pThis, PAUDMIXSINK pMixSink, PPDMAUDIOSTREAMCFG pCfg, PAC97DRIVER pDrv); 609 static int ichac97R3MixerAddDrvStreams(PAC97STATE pThis, PAUDMIXSINK pMixSink, PPDMAUDIOSTREAMCFG pCfg); 610 static void ichac97R3MixerRemoveDrvStream(PAC97STATE pThis, PAUDMIXSINK pMixSink, PDMAUDIODIR enmDir, PDMAUDIODESTSOURCE dstSrc, PAC97DRIVER pDrv); 611 static void ichac97R3MixerRemoveDrvStreams(PAC97STATE pThis, PAUDMIXSINK pMixSink, PDMAUDIODIR enmDir, PDMAUDIODESTSOURCE dstSrc); 612 612 613 613 # ifdef VBOX_WITH_AUDIO_AC97_ASYNC_IO 614 static DECLCALLBACK(int) ichac97 StreamAsyncIOThread(RTTHREAD hThreadSelf, void *pvUser);615 static int ichac97 StreamAsyncIOCreate(PAC97STATE pThis, PAC97STREAM pStream);616 static int ichac97 StreamAsyncIODestroy(PAC97STATE pThis, PAC97STREAM pStream);617 static int ichac97 StreamAsyncIONotify(PAC97STATE pThis, PAC97STREAM pStream);618 static void ichac97 StreamAsyncIOLock(PAC97STREAM pStream);619 static void ichac97 StreamAsyncIOUnlock(PAC97STREAM pStream);620 static void ichac97 StreamAsyncIOEnable(PAC97STREAM pStream, bool fEnable);614 static DECLCALLBACK(int) ichac97R3StreamAsyncIOThread(RTTHREAD hThreadSelf, void *pvUser); 615 static int ichac97R3StreamAsyncIOCreate(PAC97STATE pThis, PAC97STREAM pStream); 616 static int ichac97R3StreamAsyncIODestroy(PAC97STATE pThis, PAC97STREAM pStream); 617 static int ichac97R3StreamAsyncIONotify(PAC97STATE pThis, PAC97STREAM pStream); 618 static void ichac97R3StreamAsyncIOLock(PAC97STREAM pStream); 619 static void ichac97R3StreamAsyncIOUnlock(PAC97STREAM pStream); 620 static void ichac97R3StreamAsyncIOEnable(PAC97STREAM pStream, bool fEnable); 621 621 # endif 622 622 #endif /* IN_RING3 */ … … 642 642 * @param uIndex Stream index to get audio mixer sink for. 643 643 */ 644 DECLINLINE(PAUDMIXSINK) ichac97 IndexToSink(PAC97STATE pThis, uint8_t uIndex)644 DECLINLINE(PAUDMIXSINK) ichac97R3IndexToSink(PAC97STATE pThis, uint8_t uIndex) 645 645 { 646 646 AssertPtrReturn(pThis, NULL); … … 667 667 * @remark Uses CIV as BDLE index. 668 668 */ 669 static void ichac97 StreamFetchBDLE(PAC97STATE pThis, PAC97STREAM pStream)669 static void ichac97R3StreamFetchBDLE(PAC97STATE pThis, PAC97STREAM pStream) 670 670 { 671 671 PPDMDEVINS pDevIns = ICHAC97STATE_2_DEVINS(pThis); … … 676 676 PDMDevHlpPhysRead(pDevIns, pRegs->bdbar + pRegs->civ * 8, &u32[0], sizeof(u32)); 677 677 pRegs->bd_valid = 1; 678 # ifndef RT_LITTLE_ENDIAN679 # error "Please adapt the code (audio buffers are little endian)!"680 # else678 # ifndef RT_LITTLE_ENDIAN 679 # error "Please adapt the code (audio buffers are little endian)!" 680 # else 681 681 pRegs->bd.addr = RT_H2LE_U32(u32[0] & ~3); 682 682 pRegs->bd.ctl_len = RT_H2LE_U32(u32[1]); 683 # endif683 # endif 684 684 pRegs->picb = pRegs->bd.ctl_len & AC97_BD_LEN_MASK; 685 685 LogFlowFunc(("bd %2d addr=%#x ctl=%#06x len=%#x(%d bytes)\n", … … 756 756 * @param pStream Stream to return status for. 757 757 */ 758 static bool ichac97 StreamIsEnabled(PAC97STATE pThis, PAC97STREAM pStream)758 static bool ichac97R3StreamIsEnabled(PAC97STATE pThis, PAC97STREAM pStream) 759 759 { 760 760 AssertPtrReturn(pThis, false); 761 761 AssertPtrReturn(pStream, false); 762 762 763 PAUDMIXSINK pSink = ichac97 IndexToSink(pThis, pStream->u8SD);763 PAUDMIXSINK pSink = ichac97R3IndexToSink(pThis, pStream->u8SD); 764 764 bool fIsEnabled = RT_BOOL(AudioMixerSinkGetStatus(pSink) & AUDMIXSINK_STS_RUNNING); 765 765 … … 777 777 * 778 778 */ 779 static int ichac97 StreamEnable(PAC97STATE pThis, PAC97STREAM pStream, bool fEnable)779 static int ichac97R3StreamEnable(PAC97STATE pThis, PAC97STREAM pStream, bool fEnable) 780 780 { 781 781 AssertPtrReturn(pThis, VERR_INVALID_POINTER); 782 782 AssertPtrReturn(pStream, VERR_INVALID_POINTER); 783 783 784 ichac97 StreamLock(pStream);784 ichac97R3StreamLock(pStream); 785 785 786 786 int rc = VINF_SUCCESS; 787 787 788 # ifdef VBOX_WITH_AUDIO_AC97_ASYNC_IO788 # ifdef VBOX_WITH_AUDIO_AC97_ASYNC_IO 789 789 if (fEnable) 790 rc = ichac97 StreamAsyncIOCreate(pThis, pStream);790 rc = ichac97R3StreamAsyncIOCreate(pThis, pStream); 791 791 if (RT_SUCCESS(rc)) 792 792 { 793 ichac97 StreamAsyncIOLock(pStream);794 ichac97 StreamAsyncIOEnable(pStream, fEnable);795 } 796 # endif793 ichac97R3StreamAsyncIOLock(pStream); 794 ichac97R3StreamAsyncIOEnable(pStream, fEnable); 795 } 796 # endif 797 797 798 798 if (fEnable) … … 801 801 RTCircBufReset(pStream->State.pCircBuf); 802 802 803 rc = ichac97 StreamOpen(pThis, pStream);803 rc = ichac97R3StreamOpen(pThis, pStream); 804 804 } 805 805 else 806 rc = ichac97 StreamClose(pThis, pStream);806 rc = ichac97R3StreamClose(pThis, pStream); 807 807 808 808 if (RT_SUCCESS(rc)) 809 809 { 810 810 /* First, enable or disable the stream and the stream's sink, if any. */ 811 rc = AudioMixerSinkCtl(ichac97 IndexToSink(pThis, pStream->u8SD),811 rc = AudioMixerSinkCtl(ichac97R3IndexToSink(pThis, pStream->u8SD), 812 812 fEnable ? AUDMIXSINKCMD_ENABLE : AUDMIXSINKCMD_DISABLE); 813 813 } 814 814 815 # ifdef VBOX_WITH_AUDIO_AC97_ASYNC_IO816 ichac97 StreamAsyncIOUnlock(pStream);817 # endif815 # ifdef VBOX_WITH_AUDIO_AC97_ASYNC_IO 816 ichac97R3StreamAsyncIOUnlock(pStream); 817 # endif 818 818 819 819 /* Make sure to leave the lock before (eventually) starting the timer. */ 820 ichac97 StreamUnlock(pStream);821 822 # ifndef VBOX_WITH_AUDIO_AC97_CALLBACKS820 ichac97R3StreamUnlock(pStream); 821 822 # ifndef VBOX_WITH_AUDIO_AC97_CALLBACKS 823 823 /* Second, see if we need to start or stop the timer. */ 824 824 if (!fEnable) 825 ichac97 TimerMaybeStop(pThis);825 ichac97R3TimerMaybeStop(pThis); 826 826 else 827 ichac97 TimerMaybeStart(pThis);828 # endif827 ichac97R3TimerMaybeStart(pThis); 828 # endif 829 829 830 830 LogFunc(("[SD%RU8] cStreamsActive=%RU8, fEnable=%RTbool, rc=%Rrc\n", pStream->u8SD, pThis->cStreamsActive, fEnable, rc)); … … 839 839 * 840 840 */ 841 static void ichac97 StreamReset(PAC97STATE pThis, PAC97STREAM pStream)841 static void ichac97R3StreamReset(PAC97STATE pThis, PAC97STREAM pStream) 842 842 { 843 843 AssertPtrReturnVoid(pThis); 844 844 AssertPtrReturnVoid(pStream); 845 845 846 ichac97 StreamLock(pStream);846 ichac97R3StreamLock(pStream); 847 847 848 848 LogFunc(("[SD%RU8]\n", pStream->u8SD)); … … 864 864 RT_ZERO(pThis->silence); 865 865 866 ichac97 StreamUnlock(pStream);866 ichac97R3StreamUnlock(pStream); 867 867 } 868 868 … … 875 875 * @param u8Strm Stream ID to assign AC'97 stream to. 876 876 */ 877 static int ichac97 StreamCreate(PAC97STATE pThis, PAC97STREAM pStream, uint8_t u8Strm)877 static int ichac97R3StreamCreate(PAC97STATE pThis, PAC97STREAM pStream, uint8_t u8Strm) 878 878 { 879 879 RT_NOREF(pThis); … … 900 900 * @param pStream AC'97 stream to destroy. 901 901 */ 902 static void ichac97 StreamDestroy(PAC97STATE pThis, PAC97STREAM pStream)902 static void ichac97R3StreamDestroy(PAC97STATE pThis, PAC97STREAM pStream) 903 903 { 904 904 LogFlowFunc(("[SD%RU8]\n", pStream->u8SD)); … … 913 913 } 914 914 915 # ifdef VBOX_WITH_AUDIO_AC97_ASYNC_IO916 rc2 = ichac97 StreamAsyncIODestroy(pThis, pStream);915 # ifdef VBOX_WITH_AUDIO_AC97_ASYNC_IO 916 rc2 = ichac97R3StreamAsyncIODestroy(pThis, pStream); 917 917 AssertRC(rc2); 918 # else918 # else 919 919 RT_NOREF(pThis); 920 # endif920 # endif 921 921 922 922 LogFlowFuncLeave(); … … 928 928 * @param pThis AC'97 state. 929 929 */ 930 static void ichac97 StreamsDestroy(PAC97STATE pThis)930 static void ichac97R3StreamsDestroy(PAC97STATE pThis) 931 931 { 932 932 LogFlowFuncEnter(); … … 936 936 */ 937 937 938 ichac97 StreamDestroy(pThis, &pThis->StreamLineIn);939 ichac97 StreamDestroy(pThis, &pThis->StreamMicIn);940 ichac97 StreamDestroy(pThis, &pThis->StreamOut);938 ichac97R3StreamDestroy(pThis, &pThis->StreamLineIn); 939 ichac97R3StreamDestroy(pThis, &pThis->StreamMicIn); 940 ichac97R3StreamDestroy(pThis, &pThis->StreamOut); 941 941 942 942 /* … … 948 948 { 949 949 dstSrc.Source = PDMAUDIORECSOURCE_LINE; 950 ichac97 MixerRemoveDrvStreams(pThis, pThis->pSinkLineIn, PDMAUDIODIR_IN, dstSrc);950 ichac97R3MixerRemoveDrvStreams(pThis, pThis->pSinkLineIn, PDMAUDIODIR_IN, dstSrc); 951 951 952 952 AudioMixerSinkDestroy(pThis->pSinkLineIn); … … 957 957 { 958 958 dstSrc.Source = PDMAUDIORECSOURCE_MIC; 959 ichac97 MixerRemoveDrvStreams(pThis, pThis->pSinkMicIn, PDMAUDIODIR_IN, dstSrc);959 ichac97R3MixerRemoveDrvStreams(pThis, pThis->pSinkMicIn, PDMAUDIODIR_IN, dstSrc); 960 960 961 961 AudioMixerSinkDestroy(pThis->pSinkMicIn); … … 966 966 { 967 967 dstSrc.Dest = PDMAUDIOPLAYBACKDEST_FRONT; 968 ichac97 MixerRemoveDrvStreams(pThis, pThis->pSinkOut, PDMAUDIODIR_OUT, dstSrc);968 ichac97R3MixerRemoveDrvStreams(pThis, pThis->pSinkOut, PDMAUDIODIR_OUT, dstSrc); 969 969 970 970 AudioMixerSinkDestroy(pThis->pSinkOut); … … 983 983 * @param pcbWritten Number of bytes written. Optional. 984 984 */ 985 static int ichac97 StreamWrite(PAC97STATE pThis, PAC97STREAM pDstStream, PAUDMIXSINK pSrcMixSink, uint32_t cbToWrite,986 uint32_t *pcbWritten)985 static int ichac97R3StreamWrite(PAC97STATE pThis, PAC97STREAM pDstStream, PAUDMIXSINK pSrcMixSink, uint32_t cbToWrite, 986 uint32_t *pcbWritten) 987 987 { 988 988 RT_NOREF(pThis); … … 1007 1007 AssertRC(rc2); 1008 1008 1009 # ifdef VBOX_AUDIO_DEBUG_DUMP_PCM_DATA1009 # ifdef VBOX_AUDIO_DEBUG_DUMP_PCM_DATA 1010 1010 RTFILE fh; 1011 1011 RTFileOpen(&fh, VBOX_AUDIO_DEBUG_DUMP_PCM_DATA_PATH "ichac97StreamWrite.pcm", … … 1013 1013 RTFileWrite(fh, pvDst, cbRead, NULL); 1014 1014 RTFileClose(fh); 1015 # endif1015 # endif 1016 1016 } 1017 1017 … … 1034 1034 * @param pcbRead Number of bytes read. Optional. 1035 1035 */ 1036 static int ichac97 StreamRead(PAC97STATE pThis, PAC97STREAM pSrcStream, PAUDMIXSINK pDstMixSink, uint32_t cbToRead,1037 uint32_t *pcbRead)1036 static int ichac97R3StreamRead(PAC97STATE pThis, PAC97STREAM pSrcStream, PAUDMIXSINK pDstMixSink, uint32_t cbToRead, 1037 uint32_t *pcbRead) 1038 1038 { 1039 1039 RT_NOREF(pThis); … … 1061 1061 if (cbSrc) 1062 1062 { 1063 # ifdef VBOX_AUDIO_DEBUG_DUMP_PCM_DATA1063 # ifdef VBOX_AUDIO_DEBUG_DUMP_PCM_DATA 1064 1064 RTFILE fh; 1065 1065 RTFileOpen(&fh, VBOX_AUDIO_DEBUG_DUMP_PCM_DATA_PATH "ac97StreamRead.pcm", … … 1067 1067 RTFileWrite(fh, pvSrc, cbSrc, NULL); 1068 1068 RTFileClose(fh); 1069 # endif1069 # endif 1070 1070 rc = AudioMixerSinkWrite(pDstMixSink, AUDMIXOP_COPY, pvSrc, (uint32_t)cbSrc, &cbWritten); 1071 1071 if (RT_SUCCESS(rc)) … … 1096 1096 } 1097 1097 1098 # ifdef VBOX_WITH_AUDIO_AC97_ASYNC_IO1098 # ifdef VBOX_WITH_AUDIO_AC97_ASYNC_IO 1099 1099 1100 1100 /** … … 1106 1106 * @param pvUser User argument. Must be of type PAC97STREAMTHREADCTX. 1107 1107 */ 1108 static DECLCALLBACK(int) ichac97 StreamAsyncIOThread(RTTHREAD hThreadSelf, void *pvUser)1108 static DECLCALLBACK(int) ichac97R3StreamAsyncIOThread(RTTHREAD hThreadSelf, void *pvUser) 1109 1109 { 1110 1110 PAC97STREAMTHREADCTX pCtx = (PAC97STREAMTHREADCTX)pvUser; … … 1122 1122 AssertPtr(pCircBuf); 1123 1123 1124 PAUDMIXSINK pMixSink = ichac97 IndexToSink(pThis, pStream->u8SD);1124 PAUDMIXSINK pMixSink = ichac97R3IndexToSink(pThis, pStream->u8SD); 1125 1125 AssertPtr(pMixSink); 1126 1126 … … 1151 1151 } 1152 1152 1153 ichac97 StreamUpdate(pThis, pStream, false /* fInTimer */);1153 ichac97R3StreamUpdate(pThis, pStream, false /* fInTimer */); 1154 1154 1155 1155 int rc3 = RTCritSectLeave(&pAIO->CritSect); … … 1174 1174 * @param pStream AC'97 audio stream to create the async I/O thread for. 1175 1175 */ 1176 static int ichac97 StreamAsyncIOCreate(PAC97STATE pThis, PAC97STREAM pStream)1176 static int ichac97R3StreamAsyncIOCreate(PAC97STATE pThis, PAC97STREAM pStream) 1177 1177 { 1178 1178 PAC97STREAMSTATEAIO pAIO = &pStream->State.AIO; … … 1216 1216 * @param pStream AC'97 audio stream to destroy the async I/O thread for. 1217 1217 */ 1218 static int ichac97 StreamAsyncIODestroy(PAC97STATE pThis, PAC97STREAM pStream)1218 static int ichac97R3StreamAsyncIODestroy(PAC97STATE pThis, PAC97STREAM pStream) 1219 1219 { 1220 1220 PAC97STREAMSTATEAIO pAIO = &pStream->State.AIO; … … 1225 1225 ASMAtomicWriteBool(&pAIO->fShutdown, true); 1226 1226 1227 int rc = ichac97 StreamAsyncIONotify(pThis, pStream);1227 int rc = ichac97R3StreamAsyncIONotify(pThis, pStream); 1228 1228 AssertRC(rc); 1229 1229 … … 1256 1256 * @param pStream AC'97 stream to notify async I/O thread for. 1257 1257 */ 1258 static int ichac97 StreamAsyncIONotify(PAC97STATE pThis, PAC97STREAM pStream)1258 static int ichac97R3StreamAsyncIONotify(PAC97STATE pThis, PAC97STREAM pStream) 1259 1259 { 1260 1260 RT_NOREF(pThis); … … 1269 1269 * @param pStream AC'97 stream to lock async I/O thread for. 1270 1270 */ 1271 static void ichac97 StreamAsyncIOLock(PAC97STREAM pStream)1271 static void ichac97R3StreamAsyncIOLock(PAC97STREAM pStream) 1272 1272 { 1273 1273 PAC97STREAMSTATEAIO pAIO = &pStream->State.AIO; … … 1285 1285 * @param pStream AC'97 stream to unlock async I/O thread for. 1286 1286 */ 1287 static void ichac97 StreamAsyncIOUnlock(PAC97STREAM pStream)1287 static void ichac97R3StreamAsyncIOUnlock(PAC97STREAM pStream) 1288 1288 { 1289 1289 PAC97STREAMSTATEAIO pAIO = &pStream->State.AIO; … … 1304 1304 * @remarks Does not do locking. 1305 1305 */ 1306 static void ichac97 StreamAsyncIOEnable(PAC97STREAM pStream, bool fEnable)1306 static void ichac97R3StreamAsyncIOEnable(PAC97STREAM pStream, bool fEnable) 1307 1307 { 1308 1308 PAC97STREAMSTATEAIO pAIO = &pStream->State.AIO; … … 1310 1310 } 1311 1311 1312 # endif /* VBOX_WITH_AUDIO_AC97_ASYNC_IO */1312 # endif /* VBOX_WITH_AUDIO_AC97_ASYNC_IO */ 1313 1313 1314 1314 /** … … 1323 1323 * context or an asynchronous I/O stream thread (if supported). 1324 1324 */ 1325 static void ichac97 StreamUpdate(PAC97STATE pThis, PAC97STREAM pStream, bool fInTimer)1326 { 1327 PAUDMIXSINK pSink = ichac97 IndexToSink(pThis, pStream->u8SD);1325 static void ichac97R3StreamUpdate(PAC97STATE pThis, PAC97STREAM pStream, bool fInTimer) 1326 { 1327 PAUDMIXSINK pSink = ichac97R3IndexToSink(pThis, pStream->u8SD); 1328 1328 AssertPtr(pSink); 1329 1329 … … 1336 1336 { 1337 1337 /* Is the AC'97 stream ready to be written (guest output data) to? If so, by how much? */ 1338 const uint32_t cbFree = ichac97 StreamGetFree(pStream);1338 const uint32_t cbFree = ichac97R3StreamGetFree(pStream); 1339 1339 1340 1340 if ( fInTimer … … 1344 1344 1345 1345 /* Do the DMA transfer. */ 1346 rc2 = ichac97 StreamTransfer(pThis, pStream, cbFree);1346 rc2 = ichac97R3StreamTransfer(pThis, pStream, cbFree); 1347 1347 AssertRC(rc2); 1348 1348 } 1349 1349 1350 1350 /* How much (guest output) data is available at the moment for the AC'97 stream? */ 1351 uint32_t cbUsed = ichac97 StreamGetUsed(pStream);1352 1353 # ifdef VBOX_WITH_AUDIO_AC97_ASYNC_IO1351 uint32_t cbUsed = ichac97R3StreamGetUsed(pStream); 1352 1353 # ifdef VBOX_WITH_AUDIO_AC97_ASYNC_IO 1354 1354 if ( fInTimer 1355 1355 && cbUsed) 1356 1356 { 1357 rc2 = ichac97 StreamAsyncIONotify(pThis, pStream);1357 rc2 = ichac97R3StreamAsyncIONotify(pThis, pStream); 1358 1358 AssertRC(rc2); 1359 1359 } 1360 1360 else 1361 # endif1361 # endif 1362 1362 { 1363 1363 const uint32_t cbSinkWritable = AudioMixerSinkGetWritable(pSink); … … 1372 1372 /* Read (guest output) data and write it to the stream's sink. */ 1373 1373 uint32_t cbRead; 1374 rc2 = ichac97 StreamRead(pThis, pStream, pSink, cbUsed, &cbRead);1374 rc2 = ichac97R3StreamRead(pThis, pStream, pSink, cbUsed, &cbRead); 1375 1375 AssertRC(rc2); 1376 1376 … … 1388 1388 else /* Input (SDI). */ 1389 1389 { 1390 # ifdef VBOX_WITH_AUDIO_AC97_ASYNC_IO1390 # ifdef VBOX_WITH_AUDIO_AC97_ASYNC_IO 1391 1391 if (fInTimer) 1392 1392 { 1393 rc2 = ichac97 StreamAsyncIONotify(pThis, pStream);1393 rc2 = ichac97R3StreamAsyncIONotify(pThis, pStream); 1394 1394 AssertRC(rc2); 1395 1395 } 1396 1396 else 1397 # endif1397 # endif 1398 1398 { 1399 1399 rc2 = AudioMixerSinkUpdate(pSink); … … 1404 1404 1405 1405 /* How much (guest input) data is free at the moment? */ 1406 uint32_t cbFree = ichac97 StreamGetFree(pStream);1406 uint32_t cbFree = ichac97R3StreamGetFree(pStream); 1407 1407 1408 1408 Log3Func(("[SD%RU8] cbReadable=%RU32, cbFree=%RU32\n", pStream->u8SD, cbReadable, cbFree)); … … 1416 1416 { 1417 1417 /* Write (guest input) data to the stream which was read from stream's sink before. */ 1418 rc2 = ichac97 StreamWrite(pThis, pStream, pSink, cbFree, NULL /* pcbWritten */);1418 rc2 = ichac97R3StreamWrite(pThis, pStream, pSink, cbFree, NULL /* pcbWritten */); 1419 1419 AssertRC(rc2); 1420 1420 } 1421 1421 } 1422 1422 1423 # ifdef VBOX_WITH_AUDIO_AC97_ASYNC_IO1423 # ifdef VBOX_WITH_AUDIO_AC97_ASYNC_IO 1424 1424 if (fInTimer) 1425 # endif1426 { 1427 const uint32_t cbToTransfer = ichac97 StreamGetUsed(pStream);1425 # endif 1426 { 1427 const uint32_t cbToTransfer = ichac97R3StreamGetUsed(pStream); 1428 1428 if (cbToTransfer) 1429 1429 { 1430 1430 /* When running synchronously, do the DMA data transfers here. 1431 1431 * Otherwise this will be done in the stream's async I/O thread. */ 1432 rc2 = ichac97 StreamTransfer(pThis, pStream, cbToTransfer);1432 rc2 = ichac97R3StreamTransfer(pThis, pStream, cbToTransfer); 1433 1433 AssertRC(rc2); 1434 1434 } … … 1481 1481 * @param dstSrc Stream destination / source to retrieve. 1482 1482 */ 1483 static PAC97DRIVERSTREAM ichac97 MixerGetDrvStream(PAC97STATE pThis, PAC97DRIVER pDrv,1484 PDMAUDIODIR enmDir, PDMAUDIODESTSOURCE dstSrc)1483 static PAC97DRIVERSTREAM ichac97R3MixerGetDrvStream(PAC97STATE pThis, PAC97DRIVER pDrv, 1484 PDMAUDIODIR enmDir, PDMAUDIODESTSOURCE dstSrc) 1485 1485 { 1486 1486 RT_NOREF(pThis); … … 1534 1534 * @param pDrv Driver stream to add. 1535 1535 */ 1536 static int ichac97 MixerAddDrvStream(PAC97STATE pThis, PAUDMIXSINK pMixSink, PPDMAUDIOSTREAMCFG pCfg, PAC97DRIVER pDrv)1536 static int ichac97R3MixerAddDrvStream(PAC97STATE pThis, PAUDMIXSINK pMixSink, PPDMAUDIOSTREAMCFG pCfg, PAC97DRIVER pDrv) 1537 1537 { 1538 1538 AssertPtrReturn(pThis, VERR_INVALID_POINTER); … … 1554 1554 int rc; 1555 1555 1556 PAC97DRIVERSTREAM pDrvStream = ichac97 MixerGetDrvStream(pThis, pDrv, pStreamCfg->enmDir, pStreamCfg->DestSource);1556 PAC97DRIVERSTREAM pDrvStream = ichac97R3MixerGetDrvStream(pThis, pDrv, pStreamCfg->enmDir, pStreamCfg->DestSource); 1557 1557 if (pDrvStream) 1558 1558 { … … 1591 1591 * @param pCfg Stream configuration to use. 1592 1592 */ 1593 static int ichac97 MixerAddDrvStreams(PAC97STATE pThis, PAUDMIXSINK pMixSink, PPDMAUDIOSTREAMCFG pCfg)1593 static int ichac97R3MixerAddDrvStreams(PAC97STATE pThis, PAUDMIXSINK pMixSink, PPDMAUDIOSTREAMCFG pCfg) 1594 1594 { 1595 1595 AssertPtrReturn(pThis, VERR_INVALID_POINTER); … … 1607 1607 RTListForEach(&pThis->lstDrv, pDrv, AC97DRIVER, Node) 1608 1608 { 1609 int rc2 = ichac97 MixerAddDrvStream(pThis, pMixSink, pCfg, pDrv);1609 int rc2 = ichac97R3MixerAddDrvStream(pThis, pMixSink, pCfg, pDrv); 1610 1610 if (RT_FAILURE(rc2)) 1611 1611 LogFunc(("Attaching stream failed with %Rrc\n", rc2)); … … 1628 1628 * @param pDrv Driver stream to remove. 1629 1629 */ 1630 static void ichac97 MixerRemoveDrvStream(PAC97STATE pThis, PAUDMIXSINK pMixSink,1631 PDMAUDIODIR enmDir, PDMAUDIODESTSOURCE dstSrc, PAC97DRIVER pDrv)1630 static void ichac97R3MixerRemoveDrvStream(PAC97STATE pThis, PAUDMIXSINK pMixSink, 1631 PDMAUDIODIR enmDir, PDMAUDIODESTSOURCE dstSrc, PAC97DRIVER pDrv) 1632 1632 { 1633 1633 AssertPtrReturnVoid(pThis); 1634 1634 AssertPtrReturnVoid(pMixSink); 1635 1635 1636 PAC97DRIVERSTREAM pDrvStream = ichac97 MixerGetDrvStream(pThis, pDrv, enmDir, dstSrc);1636 PAC97DRIVERSTREAM pDrvStream = ichac97R3MixerGetDrvStream(pThis, pDrv, enmDir, dstSrc); 1637 1637 if (pDrvStream) 1638 1638 { … … 1655 1655 * @param dstSrc Stream destination / source to remove. 1656 1656 */ 1657 static void ichac97 MixerRemoveDrvStreams(PAC97STATE pThis, PAUDMIXSINK pMixSink,1658 PDMAUDIODIR enmDir, PDMAUDIODESTSOURCE dstSrc)1657 static void ichac97R3MixerRemoveDrvStreams(PAC97STATE pThis, PAUDMIXSINK pMixSink, 1658 PDMAUDIODIR enmDir, PDMAUDIODESTSOURCE dstSrc) 1659 1659 { 1660 1660 AssertPtrReturnVoid(pThis); … … 1663 1663 PAC97DRIVER pDrv; 1664 1664 RTListForEach(&pThis->lstDrv, pDrv, AC97DRIVER, Node) 1665 ichac97MixerRemoveDrvStream(pThis, pMixSink, enmDir, dstSrc, pDrv); 1665 { 1666 ichac97R3MixerRemoveDrvStream(pThis, pMixSink, enmDir, dstSrc, pDrv); 1667 } 1666 1668 } 1667 1669 … … 1676 1678 * @param pStream AC'97 Stream to open. 1677 1679 */ 1678 static int ichac97 StreamOpen(PAC97STATE pThis, PAC97STREAM pStream)1680 static int ichac97R3StreamOpen(PAC97STATE pThis, PAC97STREAM pStream) 1679 1681 { 1680 1682 int rc = VINF_SUCCESS; … … 1733 1735 if (RT_SUCCESS(rc)) 1734 1736 { 1735 ichac97 MixerRemoveDrvStreams(pThis, pMixSink, pCfg->enmDir, pCfg->DestSource);1737 ichac97R3MixerRemoveDrvStreams(pThis, pMixSink, pCfg->enmDir, pCfg->DestSource); 1736 1738 1737 1739 if (pCfg->Props.uHz) … … 1744 1746 pCfg->Props.cShift = PDMAUDIOPCMPROPS_MAKE_SHIFT_PARMS(pCfg->Props.cBits, pCfg->Props.cChannels); 1745 1747 1746 rc = ichac97 MixerAddDrvStreams(pThis, pMixSink, pCfg);1748 rc = ichac97R3MixerAddDrvStreams(pThis, pMixSink, pCfg); 1747 1749 } 1748 1750 } … … 1759 1761 * @param pStream AC'97 stream to close. 1760 1762 */ 1761 static int ichac97 StreamClose(PAC97STATE pThis, PAC97STREAM pStream)1763 static int ichac97R3StreamClose(PAC97STATE pThis, PAC97STREAM pStream) 1762 1764 { 1763 1765 RT_NOREF(pThis); … … 1777 1779 * @param pStream AC'97 stream to re-open. 1778 1780 */ 1779 static int ichac97 StreamReOpen(PAC97STATE pThis, PAC97STREAM pStream)1781 static int ichac97R3StreamReOpen(PAC97STATE pThis, PAC97STREAM pStream) 1780 1782 { 1781 1783 LogFlowFunc(("[SD%RU8]\n", pStream->u8SD)); 1782 1784 1783 int rc = ichac97 StreamClose(pThis, pStream);1785 int rc = ichac97R3StreamClose(pThis, pStream); 1784 1786 if (RT_SUCCESS(rc)) 1785 rc = ichac97 StreamOpen(pThis, pStream);1787 rc = ichac97R3StreamOpen(pThis, pStream); 1786 1788 1787 1789 return rc; … … 1794 1796 * @param pStream AC'97 stream to lock. 1795 1797 */ 1796 static void ichac97 StreamLock(PAC97STREAM pStream)1798 static void ichac97R3StreamLock(PAC97STREAM pStream) 1797 1799 { 1798 1800 AssertPtrReturnVoid(pStream); … … 1807 1809 * @param pStream AC'97 stream to unlock. 1808 1810 */ 1809 static void ichac97 StreamUnlock(PAC97STREAM pStream)1811 static void ichac97R3StreamUnlock(PAC97STREAM pStream) 1810 1812 { 1811 1813 AssertPtrReturnVoid(pStream); … … 1820 1822 * @param pStream AC'97 stream to retrieve size for. 1821 1823 */ 1822 static uint32_t ichac97 StreamGetUsed(PAC97STREAM pStream)1824 static uint32_t ichac97R3StreamGetUsed(PAC97STREAM pStream) 1823 1825 { 1824 1826 AssertPtrReturn(pStream, 0); … … 1836 1838 * @param pStream AC'97 stream to retrieve size for. 1837 1839 */ 1838 static uint32_t ichac97 StreamGetFree(PAC97STREAM pStream)1840 static uint32_t ichac97R3StreamGetFree(PAC97STREAM pStream) 1839 1841 { 1840 1842 AssertPtrReturn(pStream, 0); … … 1857 1859 * @param uVal Volume value to set. 1858 1860 */ 1859 static int ichac97 MixerSetVolume(PAC97STATE pThis, int index, PDMAUDIOMIXERCTL enmMixerCtl, uint32_t uVal)1861 static int ichac97R3MixerSetVolume(PAC97STATE pThis, int index, PDMAUDIOMIXERCTL enmMixerCtl, uint32_t uVal) 1860 1862 { 1861 1863 /* … … 1883 1885 if (index != AC97_Master_Volume_Mute && index != AC97_Headphone_Volume_Mute) 1884 1886 { 1885 # ifndef VBOX_WITH_AC97_GAIN_SUPPORT1887 # ifndef VBOX_WITH_AC97_GAIN_SUPPORT 1886 1888 /* NB: Currently there is no gain support, only attenuation. */ 1887 1889 uCtlAttLeft = uCtlAttLeft < 8 ? 0 : uCtlAttLeft - 8; 1888 1890 uCtlAttRight = uCtlAttRight < 8 ? 0 : uCtlAttRight - 8; 1889 # endif1891 # endif 1890 1892 } 1891 1893 Assert(uCtlAttLeft <= 255 / AC97_DB_FACTOR); … … 1954 1956 * @param uIdx AC'97 index to convert. 1955 1957 */ 1956 static PDMAUDIORECSOURCE ichac97 IdxToRecSource(uint8_t uIdx)1958 static PDMAUDIORECSOURCE ichac97R3IdxToRecSource(uint8_t uIdx) 1957 1959 { 1958 1960 switch (uIdx) … … 1978 1980 * @param enmRecSrc PDM audio recording source to convert. 1979 1981 */ 1980 static uint8_t ichac97R ecSourceToIdx(PDMAUDIORECSOURCE enmRecSrc)1982 static uint8_t ichac97R3RecSourceToIdx(PDMAUDIORECSOURCE enmRecSrc) 1981 1983 { 1982 1984 switch (enmRecSrc) … … 2026 2028 * @param val AC'97 recording source index to set. 2027 2029 */ 2028 static void ichac97 MixerRecordSelect(PAC97STATE pThis, uint32_t val)2030 static void ichac97R3MixerRecordSelect(PAC97STATE pThis, uint32_t val) 2029 2031 { 2030 2032 uint8_t rs = val & AC97_REC_MASK; 2031 2033 uint8_t ls = (val >> 8) & AC97_REC_MASK; 2032 PDMAUDIORECSOURCE ars = ichac97 IdxToRecSource(rs);2033 PDMAUDIORECSOURCE als = ichac97 IdxToRecSource(ls);2034 rs = ichac97R ecSourceToIdx(ars);2035 ls = ichac97R ecSourceToIdx(als);2034 PDMAUDIORECSOURCE ars = ichac97R3IdxToRecSource(rs); 2035 PDMAUDIORECSOURCE als = ichac97R3IdxToRecSource(ls); 2036 rs = ichac97R3RecSourceToIdx(ars); 2037 ls = ichac97R3RecSourceToIdx(als); 2036 2038 ichac97MixerSet(pThis, AC97_Record_Select, rs | (ls << 8)); 2037 2039 } … … 2043 2045 * @param pThis AC'97 state. 2044 2046 */ 2045 static int ichac97 MixerReset(PAC97STATE pThis)2047 static int ichac97R3MixerReset(PAC97STATE pThis) 2046 2048 { 2047 2049 AssertPtrReturn(pThis, VERR_INVALID_PARAMETER); … … 2094 2096 ichac97MixerSet(pThis, AC97_Vendor_ID2 , 0x7600); /* 7608 */ 2095 2097 } 2096 ichac97 MixerRecordSelect(pThis, 0);2098 ichac97R3MixerRecordSelect(pThis, 0); 2097 2099 2098 2100 /* The default value is 8000h, which corresponds to 0 dB attenuation with mute on. */ 2099 ichac97 MixerSetVolume(pThis, AC97_Master_Volume_Mute, PDMAUDIOMIXERCTL_VOLUME_MASTER, 0x8000);2101 ichac97R3MixerSetVolume(pThis, AC97_Master_Volume_Mute, PDMAUDIOMIXERCTL_VOLUME_MASTER, 0x8000); 2100 2102 2101 2103 /* The default value for stereo registers is 8808h, which corresponds to 0 dB gain with mute on.*/ 2102 ichac97 MixerSetVolume(pThis, AC97_PCM_Out_Volume_Mute, PDMAUDIOMIXERCTL_FRONT, 0x8808);2103 ichac97 MixerSetVolume(pThis, AC97_Line_In_Volume_Mute, PDMAUDIOMIXERCTL_LINE_IN, 0x8808);2104 ichac97 MixerSetVolume(pThis, AC97_Mic_Volume_Mute, PDMAUDIOMIXERCTL_MIC_IN, 0x8808);2104 ichac97R3MixerSetVolume(pThis, AC97_PCM_Out_Volume_Mute, PDMAUDIOMIXERCTL_FRONT, 0x8808); 2105 ichac97R3MixerSetVolume(pThis, AC97_Line_In_Volume_Mute, PDMAUDIOMIXERCTL_LINE_IN, 0x8808); 2106 ichac97R3MixerSetVolume(pThis, AC97_Mic_Volume_Mute, PDMAUDIOMIXERCTL_MIC_IN, 0x8808); 2105 2107 2106 2108 return VINF_SUCCESS; 2107 2109 } 2108 2110 2109 /* Unused */ 2110 #if 0 2111 static void ichac97WriteBUP(PAC97STATE pThis, uint32_t cbElapsed) 2111 # if 0 /* Unused */ 2112 static void ichac97R3WriteBUP(PAC97STATE pThis, uint32_t cbElapsed) 2112 2113 { 2113 2114 LogFlowFunc(("cbElapsed=%RU32\n", cbElapsed)); … … 2147 2148 } 2148 2149 } 2149 # endif /* Unused */2150 2151 # ifndef VBOX_WITH_AUDIO_AC97_CALLBACKS2150 # endif /* Unused */ 2151 2152 # ifndef VBOX_WITH_AUDIO_AC97_CALLBACKS 2152 2153 2153 2154 /** … … 2157 2158 * @param pThis AC'97 state. 2158 2159 */ 2159 static int ichac97 TimerStart(PAC97STATE pThis)2160 static int ichac97R3TimerStart(PAC97STATE pThis) 2160 2161 { 2161 2162 LogFlowFuncEnter(); … … 2172 2173 2173 2174 /* Start transfers. */ 2174 ichac97 TimerMain(pThis);2175 ichac97R3TimerMain(pThis); 2175 2176 } 2176 2177 … … 2186 2187 * @param pThis AC'97 state. 2187 2188 */ 2188 static int ichac97 TimerMaybeStart(PAC97STATE pThis)2189 static int ichac97R3TimerMaybeStart(PAC97STATE pThis) 2189 2190 { 2190 2191 LogFlowFuncEnter(); … … 2197 2198 /* Only start the timer at the first active stream. */ 2198 2199 if (pThis->cStreamsActive == 1) 2199 return ichac97 TimerStart(pThis);2200 return ichac97R3TimerStart(pThis); 2200 2201 2201 2202 return VINF_SUCCESS; … … 2208 2209 * @param pThis AC'97 state. 2209 2210 */ 2210 static int ichac97 TimerStop(PAC97STATE pThis)2211 static int ichac97R3TimerStop(PAC97STATE pThis) 2211 2212 { 2212 2213 LogFlowFuncEnter(); … … 2241 2242 * @param pThis AC'97 state. 2242 2243 */ 2243 static int ichac97 TimerMaybeStop(PAC97STATE pThis)2244 static int ichac97R3TimerMaybeStop(PAC97STATE pThis) 2244 2245 { 2245 2246 LogFlowFuncEnter(); … … 2253 2254 2254 2255 if (pThis->cStreamsActive == 0) 2255 return ichac97 TimerStop(pThis);2256 return ichac97R3TimerStop(pThis); 2256 2257 } 2257 2258 … … 2264 2265 * @param pThis AC'97 state. 2265 2266 */ 2266 static void ichac97 TimerMain(PAC97STATE pThis)2267 static void ichac97R3TimerMain(PAC97STATE pThis) 2267 2268 { 2268 2269 STAM_PROFILE_START(&pThis->StatTimer, a); … … 2278 2279 bool fArmTimer = false; 2279 2280 2280 ichac97 DoTransfers(pThis);2281 ichac97R3DoTransfers(pThis); 2281 2282 2282 2283 /* Do we need to arm the timer again? */ 2283 if ( AudioMixerSinkIsActive(ichac97 IndexToSink(pThis, pThis->StreamLineIn.u8SD))2284 || AudioMixerSinkIsActive(ichac97 IndexToSink(pThis, pThis->StreamMicIn.u8SD))2285 || AudioMixerSinkIsActive(ichac97 IndexToSink(pThis, pThis->StreamOut.u8SD)))2284 if ( AudioMixerSinkIsActive(ichac97R3IndexToSink(pThis, pThis->StreamLineIn.u8SD)) 2285 || AudioMixerSinkIsActive(ichac97R3IndexToSink(pThis, pThis->StreamMicIn.u8SD)) 2286 || AudioMixerSinkIsActive(ichac97R3IndexToSink(pThis, pThis->StreamOut.u8SD))) 2286 2287 { 2287 2288 fArmTimer = true; … … 2317 2318 * @param pvUser User argument as PAC97STATE. 2318 2319 */ 2319 static DECLCALLBACK(void) ichac97 Timer(PPDMDEVINS pDevIns, PTMTIMER pTimer, void *pvUser)2320 static DECLCALLBACK(void) ichac97R3Timer(PPDMDEVINS pDevIns, PTMTIMER pTimer, void *pvUser) 2320 2321 { 2321 2322 RT_NOREF(pDevIns, pTimer); … … 2325 2326 AssertPtr(pThis); 2326 2327 2327 ichac97 TimerMain(pThis);2328 } 2329 2330 # endif /* !VBOX_WITH_AUDIO_AC97_CALLBACKS */2328 ichac97R3TimerMain(pThis); 2329 } 2330 2331 # endif /* !VBOX_WITH_AUDIO_AC97_CALLBACKS */ 2331 2332 2332 2333 /** … … 2336 2337 * @param pThis AC'97 state. 2337 2338 */ 2338 static void ichac97 DoTransfers(PAC97STATE pThis)2339 static void ichac97R3DoTransfers(PAC97STATE pThis) 2339 2340 { 2340 2341 AssertPtrReturnVoid(pThis); 2341 2342 2342 ichac97 StreamUpdate(pThis, &pThis->StreamLineIn, true /* fInTimer */);2343 ichac97 StreamUpdate(pThis, &pThis->StreamMicIn, true /* fInTimer */);2344 ichac97 StreamUpdate(pThis, &pThis->StreamOut, true /* fInTimer */);2343 ichac97R3StreamUpdate(pThis, &pThis->StreamLineIn, true /* fInTimer */); 2344 ichac97R3StreamUpdate(pThis, &pThis->StreamMicIn, true /* fInTimer */); 2345 ichac97R3StreamUpdate(pThis, &pThis->StreamOut, true /* fInTimer */); 2345 2346 } 2346 2347 … … 2359 2360 * @param cbToProcessMax Maximum of data (in bytes) to process. 2360 2361 */ 2361 static int ichac97 StreamTransfer(PAC97STATE pThis, PAC97STREAM pStream, uint32_t cbToProcessMax)2362 static int ichac97R3StreamTransfer(PAC97STATE pThis, PAC97STREAM pStream, uint32_t cbToProcessMax) 2362 2363 { 2363 2364 AssertPtrReturn(pThis, VERR_INVALID_POINTER); … … 2365 2366 AssertReturn(cbToProcessMax, VERR_INVALID_PARAMETER); 2366 2367 2367 ichac97 StreamLock(pStream);2368 ichac97R3StreamLock(pStream); 2368 2369 2369 2370 PAC97BMREGS pRegs = &pStream->Regs; … … 2376 2377 { 2377 2378 case AC97SOUNDSOURCE_PO_INDEX: 2378 /*ichac97 WriteBUP(pThis, cbToProcess);*/2379 /*ichac97R3WriteBUP(pThis, cbToProcess);*/ 2379 2380 break; 2380 2381 … … 2384 2385 } 2385 2386 2386 ichac97 StreamUnlock(pStream);2387 ichac97R3StreamUnlock(pStream); 2387 2388 return VINF_SUCCESS; 2388 2389 } … … 2393 2394 Log3Func(("[SD%RU8] BCIS set\n", pStream->u8SD)); 2394 2395 2395 ichac97 StreamUnlock(pStream);2396 ichac97R3StreamUnlock(pStream); 2396 2397 return VINF_SUCCESS; 2397 2398 } … … 2412 2413 { 2413 2414 Log3Func(("Invalid buffer descriptor, fetching next one ...\n")); 2414 ichac97 StreamFetchBDLE(pThis, pStream);2415 ichac97R3StreamFetchBDLE(pThis, pStream); 2415 2416 } 2416 2417 … … 2432 2433 pRegs->piv = (pRegs->piv + 1) % AC97_MAX_BDLE; 2433 2434 2434 ichac97 StreamFetchBDLE(pThis, pStream);2435 ichac97R3StreamFetchBDLE(pThis, pStream); 2435 2436 continue; 2436 2437 } … … 2453 2454 AssertRC(rc2); 2454 2455 2455 # ifdef VBOX_AUDIO_DEBUG_DUMP_PCM_DATA2456 # ifdef VBOX_AUDIO_DEBUG_DUMP_PCM_DATA 2456 2457 RTFILE fh; 2457 2458 RTFileOpen(&fh, VBOX_AUDIO_DEBUG_DUMP_PCM_DATA_PATH "ac97DMARead.pcm", … … 2459 2460 RTFileWrite(fh, pvDst, cbDst, NULL); 2460 2461 RTFileClose(fh); 2461 # endif2462 # endif 2462 2463 } 2463 2464 … … 2483 2484 AssertRC(rc2); 2484 2485 2485 # ifdef VBOX_AUDIO_DEBUG_DUMP_PCM_DATA2486 # ifdef VBOX_AUDIO_DEBUG_DUMP_PCM_DATA 2486 2487 RTFILE fh; 2487 2488 RTFileOpen(&fh, VBOX_AUDIO_DEBUG_DUMP_PCM_DATA_PATH "ac97DMAWrite.pcm", … … 2489 2490 RTFileWrite(fh, pvSrc, cbSrc, NULL); 2490 2491 RTFileClose(fh); 2491 # endif2492 # endif 2492 2493 } 2493 2494 … … 2545 2546 pRegs->civ = pRegs->piv; 2546 2547 pRegs->piv = (pRegs->piv + 1) % AC97_MAX_BDLE; 2547 ichac97 StreamFetchBDLE(pThis, pStream);2548 ichac97R3StreamFetchBDLE(pThis, pStream); 2548 2549 } 2549 2550 … … 2560 2561 } 2561 2562 2562 ichac97 StreamUnlock(pStream);2563 ichac97R3StreamUnlock(pStream); 2563 2564 2564 2565 LogFlowFuncLeaveRC(rc); … … 2791 2792 pRegs->piv = (pRegs->piv + 1) % AC97_MAX_BDLE; 2792 2793 2793 ichac97 StreamFetchBDLE(pThis, pStream);2794 ichac97R3StreamFetchBDLE(pThis, pStream); 2794 2795 #else 2795 2796 rc = VINF_IOM_R3_IOPORT_WRITE; … … 2817 2818 Assert((pRegs->cr & AC97_CR_RPBM) == 0); 2818 2819 2819 ichac97 StreamEnable(pThis, pStream, false /* fEnable */);2820 ichac97 StreamReset(pThis, pStream);2820 ichac97R3StreamEnable(pThis, pStream, false /* fEnable */); 2821 ichac97R3StreamReset(pThis, pStream); 2821 2822 2822 2823 ichac97StreamUpdateSR(pThis, pStream, AC97_SR_DCH); /** @todo Do we need to do that? */ … … 2830 2831 Log3Func(("[SD%RU8] Disable\n", pStream->u8SD)); 2831 2832 2832 ichac97 StreamEnable(pThis, pStream, false /* fEnable */);2833 ichac97R3StreamEnable(pThis, pStream, false /* fEnable */); 2833 2834 2834 2835 pRegs->sr |= AC97_SR_DCH; … … 2844 2845 2845 2846 /* Fetch the initial BDLE descriptor. */ 2846 ichac97 StreamFetchBDLE(pThis, pStream);2847 2848 ichac97 StreamEnable(pThis, pStream, true /* fEnable */);2847 ichac97R3StreamFetchBDLE(pThis, pStream); 2848 2849 ichac97R3StreamEnable(pThis, pStream, true /* fEnable */); 2849 2850 } 2850 2851 } … … 3037 3038 case AC97_Reset: 3038 3039 #ifdef IN_RING3 3039 ichac97R eset(pThis->CTX_SUFF(pDevIns));3040 ichac97R3Reset(pThis->CTX_SUFF(pDevIns)); 3040 3041 #else 3041 3042 rc = VINF_IOM_R3_IOPORT_WRITE; … … 3054 3055 } 3055 3056 #ifdef IN_RING3 3056 ichac97 MixerSetVolume(pThis, uPortIdx, PDMAUDIOMIXERCTL_VOLUME_MASTER, u32Val);3057 ichac97R3MixerSetVolume(pThis, uPortIdx, PDMAUDIOMIXERCTL_VOLUME_MASTER, u32Val); 3057 3058 #else 3058 3059 rc = VINF_IOM_R3_IOPORT_WRITE; … … 3066 3067 /* Register controls PCM (front) outputs. */ 3067 3068 #ifdef IN_RING3 3068 ichac97 MixerSetVolume(pThis, uPortIdx, PDMAUDIOMIXERCTL_VOLUME_MASTER, u32Val);3069 ichac97R3MixerSetVolume(pThis, uPortIdx, PDMAUDIOMIXERCTL_VOLUME_MASTER, u32Val); 3069 3070 #else 3070 3071 rc = VINF_IOM_R3_IOPORT_WRITE; … … 3075 3076 case AC97_PCM_Out_Volume_Mute: 3076 3077 #ifdef IN_RING3 3077 ichac97 MixerSetVolume(pThis, uPortIdx, PDMAUDIOMIXERCTL_FRONT, u32Val);3078 ichac97R3MixerSetVolume(pThis, uPortIdx, PDMAUDIOMIXERCTL_FRONT, u32Val); 3078 3079 #else 3079 3080 rc = VINF_IOM_R3_IOPORT_WRITE; … … 3082 3083 case AC97_Line_In_Volume_Mute: 3083 3084 #ifdef IN_RING3 3084 ichac97 MixerSetVolume(pThis, uPortIdx, PDMAUDIOMIXERCTL_LINE_IN, u32Val);3085 ichac97R3MixerSetVolume(pThis, uPortIdx, PDMAUDIOMIXERCTL_LINE_IN, u32Val); 3085 3086 #else 3086 3087 rc = VINF_IOM_R3_IOPORT_WRITE; … … 3089 3090 case AC97_Record_Select: 3090 3091 #ifdef IN_RING3 3091 ichac97 MixerRecordSelect(pThis, u32Val);3092 ichac97R3MixerRecordSelect(pThis, u32Val); 3092 3093 #else 3093 3094 rc = VINF_IOM_R3_IOPORT_WRITE; … … 3098 3099 /* Newer Ubuntu guests rely on that when controlling gain and muting 3099 3100 * the recording (capturing) levels. */ 3100 ichac97 MixerSetVolume(pThis, uPortIdx, PDMAUDIOMIXERCTL_LINE_IN, u32Val);3101 ichac97R3MixerSetVolume(pThis, uPortIdx, PDMAUDIOMIXERCTL_LINE_IN, u32Val); 3101 3102 #else 3102 3103 rc = VINF_IOM_R3_IOPORT_WRITE; … … 3106 3107 #ifdef IN_RING3 3107 3108 /* Ditto; see note above. */ 3108 ichac97 MixerSetVolume(pThis, uPortIdx, PDMAUDIOMIXERCTL_MIC_IN, u32Val);3109 ichac97R3MixerSetVolume(pThis, uPortIdx, PDMAUDIOMIXERCTL_MIC_IN, u32Val); 3109 3110 #else 3110 3111 rc = VINF_IOM_R3_IOPORT_WRITE; … … 3123 3124 { 3124 3125 ichac97MixerSet(pThis, AC97_PCM_Front_DAC_Rate, 48000); 3125 ichac97 StreamReOpen(pThis, &pThis->StreamOut);3126 ichac97R3StreamReOpen(pThis, &pThis->StreamOut); 3126 3127 3127 3128 ichac97MixerSet(pThis, AC97_PCM_LR_ADC_Rate, 48000); 3128 ichac97 StreamReOpen(pThis, &pThis->StreamLineIn);3129 ichac97R3StreamReOpen(pThis, &pThis->StreamLineIn); 3129 3130 } 3130 3131 else … … 3134 3135 { 3135 3136 ichac97MixerSet(pThis, AC97_MIC_ADC_Rate, 48000); 3136 ichac97 StreamReOpen(pThis, &pThis->StreamMicIn);3137 ichac97R3StreamReOpen(pThis, &pThis->StreamMicIn); 3137 3138 } 3138 3139 else … … 3151 3152 ichac97MixerSet(pThis, uPortIdx, u32Val); 3152 3153 LogFunc(("Set front DAC rate to %RU32\n", u32Val)); 3153 ichac97 StreamReOpen(pThis, &pThis->StreamOut);3154 ichac97R3StreamReOpen(pThis, &pThis->StreamOut); 3154 3155 #else 3155 3156 rc = VINF_IOM_R3_IOPORT_WRITE; … … 3165 3166 ichac97MixerSet(pThis, uPortIdx, u32Val); 3166 3167 LogFunc(("Set MIC ADC rate to %RU32\n", u32Val)); 3167 ichac97 StreamReOpen(pThis, &pThis->StreamMicIn);3168 ichac97R3StreamReOpen(pThis, &pThis->StreamMicIn); 3168 3169 #else 3169 3170 rc = VINF_IOM_R3_IOPORT_WRITE; … … 3179 3180 ichac97MixerSet(pThis, uPortIdx, u32Val); 3180 3181 LogFunc(("Set front LR ADC rate to %RU32\n", u32Val)); 3181 ichac97 StreamReOpen(pThis, &pThis->StreamLineIn);3182 ichac97R3StreamReOpen(pThis, &pThis->StreamLineIn); 3182 3183 #else 3183 3184 rc = VINF_IOM_R3_IOPORT_WRITE; … … 3217 3218 * @callback_method_impl{FNPCIIOREGIONMAP} 3218 3219 */ 3219 static DECLCALLBACK(int) ichac97 IOPortMap(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, uint32_t iRegion,3220 RTGCPHYS GCPhysAddress, RTGCPHYS cb, PCIADDRESSSPACE enmType)3220 static DECLCALLBACK(int) ichac97R3IOPortMap(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, uint32_t iRegion, 3221 RTGCPHYS GCPhysAddress, RTGCPHYS cb, PCIADDRESSSPACE enmType) 3221 3222 { 3222 3223 RT_NOREF(cb, enmType); … … 3277 3278 * @param pStream AC'97 stream to save. 3278 3279 */ 3279 static int ichac97 SaveStream(PPDMDEVINS pDevIns, PSSMHANDLE pSSM, PAC97STREAM pStream)3280 static int ichac97R3SaveStream(PPDMDEVINS pDevIns, PSSMHANDLE pSSM, PAC97STREAM pStream) 3280 3281 { 3281 3282 RT_NOREF(pDevIns); … … 3299 3300 * @callback_method_impl{FNSSMDEVSAVEEXEC} 3300 3301 */ 3301 static DECLCALLBACK(int) ichac97 SaveExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM)3302 static DECLCALLBACK(int) ichac97R3SaveExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM) 3302 3303 { 3303 3304 PAC97STATE pThis = PDMINS_2_DATA(pDevIns, PAC97STATE); … … 3311 3312 /** @todo r=andy For the next saved state version, add unique stream identifiers and a stream count. */ 3312 3313 /* Note: The order the streams are saved here is critical, so don't touch. */ 3313 int rc2 = ichac97 SaveStream(pDevIns, pSSM, &pThis->StreamLineIn);3314 int rc2 = ichac97R3SaveStream(pDevIns, pSSM, &pThis->StreamLineIn); 3314 3315 AssertRC(rc2); 3315 rc2 = ichac97 SaveStream(pDevIns, pSSM, &pThis->StreamOut);3316 rc2 = ichac97R3SaveStream(pDevIns, pSSM, &pThis->StreamOut); 3316 3317 AssertRC(rc2); 3317 rc2 = ichac97 SaveStream(pDevIns, pSSM, &pThis->StreamMicIn);3318 rc2 = ichac97R3SaveStream(pDevIns, pSSM, &pThis->StreamMicIn); 3318 3319 AssertRC(rc2); 3319 3320 … … 3322 3323 uint8_t active[AC97SOUNDSOURCE_END_INDEX]; 3323 3324 3324 active[AC97SOUNDSOURCE_PI_INDEX] = ichac97 StreamIsEnabled(pThis, &pThis->StreamLineIn) ? 1 : 0;3325 active[AC97SOUNDSOURCE_PO_INDEX] = ichac97 StreamIsEnabled(pThis, &pThis->StreamOut) ? 1 : 0;3326 active[AC97SOUNDSOURCE_MC_INDEX] = ichac97 StreamIsEnabled(pThis, &pThis->StreamMicIn) ? 1 : 0;3325 active[AC97SOUNDSOURCE_PI_INDEX] = ichac97R3StreamIsEnabled(pThis, &pThis->StreamLineIn) ? 1 : 0; 3326 active[AC97SOUNDSOURCE_PO_INDEX] = ichac97R3StreamIsEnabled(pThis, &pThis->StreamOut) ? 1 : 0; 3327 active[AC97SOUNDSOURCE_MC_INDEX] = ichac97R3StreamIsEnabled(pThis, &pThis->StreamMicIn) ? 1 : 0; 3327 3328 3328 3329 SSMR3PutMem(pSSM, active, sizeof(active)); … … 3336 3337 * 3337 3338 * @returns IPRT status code. 3338 * @param pDevIns Device instance.3339 3339 * @param pSSM Saved state manager (SSM) handle to use. 3340 3340 * @param pStream AC'97 stream to load. 3341 3341 */ 3342 static int ichac97LoadStream(PPDMDEVINS pDevIns, PSSMHANDLE pSSM, PAC97STREAM pStream) 3343 { 3344 RT_NOREF(pDevIns); 3342 static int ichac97R3LoadStream(PSSMHANDLE pSSM, PAC97STREAM pStream) 3343 { 3345 3344 PAC97BMREGS pRegs = &pStream->Regs; 3346 3345 … … 3354 3353 SSMR3GetS32(pSSM, &pRegs->bd_valid); 3355 3354 SSMR3GetU32(pSSM, &pRegs->bd.addr); 3356 SSMR3GetU32(pSSM, &pRegs->bd.ctl_len); 3357 3358 return VINF_SUCCESS; 3355 return SSMR3GetU32(pSSM, &pRegs->bd.ctl_len); 3359 3356 } 3360 3357 … … 3362 3359 * @callback_method_impl{FNSSMDEVLOADEXEC} 3363 3360 */ 3364 static DECLCALLBACK(int) ichac97 LoadExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass)3361 static DECLCALLBACK(int) ichac97R3LoadExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass) 3365 3362 { 3366 3363 PAC97STATE pThis = PDMINS_2_DATA(pDevIns, PAC97STATE); … … 3377 3374 /** @todo r=andy For the next saved state version, add unique stream identifiers and a stream count. */ 3378 3375 /* Note: The order the streams are loaded here is critical, so don't touch. */ 3379 int rc2 = ichac97 LoadStream(pDevIns,pSSM, &pThis->StreamLineIn);3380 AssertRC (rc2);3381 rc2 = ichac97 LoadStream(pDevIns,pSSM, &pThis->StreamOut);3382 AssertRC (rc2);3383 rc2 = ichac97 LoadStream(pDevIns,pSSM, &pThis->StreamMicIn);3384 AssertRC (rc2);3376 int rc2 = ichac97R3LoadStream(pSSM, &pThis->StreamLineIn); 3377 AssertRCReturn(rc2, rc2); 3378 rc2 = ichac97R3LoadStream(pSSM, &pThis->StreamOut); 3379 AssertRCReturn(rc2, rc2); 3380 rc2 = ichac97R3LoadStream(pSSM, &pThis->StreamMicIn); 3381 AssertRCReturn(rc2, rc2); 3385 3382 3386 3383 SSMR3GetMem(pSSM, pThis->mixer_data, sizeof(pThis->mixer_data)); … … 3388 3385 /** @todo r=andy Stream IDs are hardcoded to certain streams. */ 3389 3386 uint8_t uaStrmsActive[AC97SOUNDSOURCE_END_INDEX]; 3390 SSMR3GetMem(pSSM, uaStrmsActive, sizeof(uaStrmsActive)); 3391 3392 ichac97MixerRecordSelect(pThis, ichac97MixerGet(pThis, AC97_Record_Select)); 3393 # define V_(a, b) ichac97MixerSetVolume(pThis, a, b, ichac97MixerGet(pThis, a)) 3387 rc2 = SSMR3GetMem(pSSM, uaStrmsActive, sizeof(uaStrmsActive)); 3388 AssertRCReturn(rc2, rc2); 3389 3390 ichac97R3MixerRecordSelect(pThis, ichac97MixerGet(pThis, AC97_Record_Select)); 3391 # define V_(a, b) ichac97R3MixerSetVolume(pThis, a, b, ichac97MixerGet(pThis, a)) 3394 3392 V_(AC97_Master_Volume_Mute, PDMAUDIOMIXERCTL_VOLUME_MASTER); 3395 3393 V_(AC97_PCM_Out_Volume_Mute, PDMAUDIOMIXERCTL_FRONT); … … 3399 3397 if (pThis->uCodecModel == AC97_CODEC_AD1980) 3400 3398 if (ichac97MixerGet(pThis, AC97_AD_Misc) & AC97_AD_MISC_HPSEL) 3401 ichac97 MixerSetVolume(pThis, AC97_Headphone_Volume_Mute, PDMAUDIOMIXERCTL_VOLUME_MASTER,3402 ichac97MixerGet(pThis, AC97_Headphone_Volume_Mute));3399 ichac97R3MixerSetVolume(pThis, AC97_Headphone_Volume_Mute, PDMAUDIOMIXERCTL_VOLUME_MASTER, 3400 ichac97MixerGet(pThis, AC97_Headphone_Volume_Mute)); 3403 3401 3404 3402 /** @todo r=andy Stream IDs are hardcoded to certain streams. */ 3405 rc2 = ichac97 StreamEnable(pThis, &pThis->StreamLineIn, RT_BOOL(uaStrmsActive[AC97SOUNDSOURCE_PI_INDEX]));3403 rc2 = ichac97R3StreamEnable(pThis, &pThis->StreamLineIn, RT_BOOL(uaStrmsActive[AC97SOUNDSOURCE_PI_INDEX])); 3406 3404 if (RT_SUCCESS(rc2)) 3407 rc2 = ichac97 StreamEnable(pThis, &pThis->StreamMicIn, RT_BOOL(uaStrmsActive[AC97SOUNDSOURCE_MC_INDEX]));3405 rc2 = ichac97R3StreamEnable(pThis, &pThis->StreamMicIn, RT_BOOL(uaStrmsActive[AC97SOUNDSOURCE_MC_INDEX])); 3408 3406 if (RT_SUCCESS(rc2)) 3409 rc2 = ichac97 StreamEnable(pThis, &pThis->StreamOut, RT_BOOL(uaStrmsActive[AC97SOUNDSOURCE_PO_INDEX]));3407 rc2 = ichac97R3StreamEnable(pThis, &pThis->StreamOut, RT_BOOL(uaStrmsActive[AC97SOUNDSOURCE_PO_INDEX])); 3410 3408 3411 3409 pThis->bup_flag = 0; … … 3419 3417 * @interface_method_impl{PDMIBASE,pfnQueryInterface} 3420 3418 */ 3421 static DECLCALLBACK(void *) ichac97 QueryInterface(struct PDMIBASE *pInterface, const char *pszIID)3419 static DECLCALLBACK(void *) ichac97R3QueryInterface(struct PDMIBASE *pInterface, const char *pszIID) 3422 3420 { 3423 3421 PAC97STATE pThis = RT_FROM_MEMBER(pInterface, AC97STATE, IBase); … … 3434 3432 * @param pDevIns Device instance to power off. 3435 3433 */ 3436 static DECLCALLBACK(void) ichac97 PowerOff(PPDMDEVINS pDevIns)3434 static DECLCALLBACK(void) ichac97R3PowerOff(PPDMDEVINS pDevIns) 3437 3435 { 3438 3436 PAC97STATE pThis = PDMINS_2_DATA(pDevIns, PAC97STATE); … … 3441 3439 3442 3440 /* Note: Involves mixer stream / sink destruction, so also do this here 3443 * instead of in ichac97 Destruct(). */3444 ichac97 StreamsDestroy(pThis);3441 * instead of in ichac97R3Destruct(). */ 3442 ichac97R3StreamsDestroy(pThis); 3445 3443 3446 3444 /** 3447 * Note: Destroy the mixer while powering off and *not* in ichac97 Destruct,3445 * Note: Destroy the mixer while powering off and *not* in ichac97R3Destruct, 3448 3446 * giving the mixer the chance to release any references held to 3449 3447 * PDM audio streams it maintains. … … 3463 3461 * make sense to me so we'll do it. 3464 3462 */ 3465 static DECLCALLBACK(void) ichac97R eset(PPDMDEVINS pDevIns)3463 static DECLCALLBACK(void) ichac97R3Reset(PPDMDEVINS pDevIns) 3466 3464 { 3467 3465 PAC97STATE pThis = PDMINS_2_DATA(pDevIns, PAC97STATE); … … 3474 3472 * the codec manually. 3475 3473 */ 3476 ichac97 MixerReset(pThis);3474 ichac97R3MixerReset(pThis); 3477 3475 3478 3476 /* 3479 3477 * Reset all streams. 3480 3478 */ 3481 ichac97 StreamEnable(pThis, &pThis->StreamLineIn, false /* fEnable */);3482 ichac97 StreamReset(pThis, &pThis->StreamLineIn);3483 3484 ichac97 StreamEnable(pThis, &pThis->StreamMicIn, false /* fEnable */);3485 ichac97 StreamReset(pThis, &pThis->StreamMicIn);3486 3487 ichac97 StreamEnable(pThis, &pThis->StreamOut, false /* fEnable */);3488 ichac97 StreamReset(pThis, &pThis->StreamOut);3479 ichac97R3StreamEnable(pThis, &pThis->StreamLineIn, false /* fEnable */); 3480 ichac97R3StreamReset(pThis, &pThis->StreamLineIn); 3481 3482 ichac97R3StreamEnable(pThis, &pThis->StreamMicIn, false /* fEnable */); 3483 ichac97R3StreamReset(pThis, &pThis->StreamMicIn); 3484 3485 ichac97R3StreamEnable(pThis, &pThis->StreamOut, false /* fEnable */); 3486 ichac97R3StreamReset(pThis, &pThis->StreamOut); 3489 3487 3490 3488 /* 3491 3489 * Reset mixer sinks. 3492 3490 * 3493 * Do the reset here instead of in ichac97 StreamReset();3491 * Do the reset here instead of in ichac97R3StreamReset(); 3494 3492 * the mixer sink(s) might still have data to be processed when an audio stream gets reset. 3495 3493 */ … … 3502 3500 * Stop the timer, if any. 3503 3501 */ 3504 ichac97 TimerStop(pThis);3502 ichac97R3TimerStop(pThis); 3505 3503 3506 3504 pThis->cStreamsActive = 0; … … 3522 3520 * @param ppDrv Attached driver instance on success. Optional. 3523 3521 */ 3524 static int ichac97 AttachInternal(PAC97STATE pThis, unsigned uLUN, uint32_t fFlags, PAC97DRIVER *ppDrv)3522 static int ichac97R3AttachInternal(PAC97STATE pThis, unsigned uLUN, uint32_t fFlags, PAC97DRIVER *ppDrv) 3525 3523 { 3526 3524 RT_NOREF(fFlags); … … 3594 3592 * @param fFlags Flags, combination of the PDMDEVATT_FLAGS_* \#defines. 3595 3593 */ 3596 static int ichac97 DetachInternal(PAC97STATE pThis, PAC97DRIVER pDrv, uint32_t fFlags)3594 static int ichac97R3DetachInternal(PAC97STATE pThis, PAC97DRIVER pDrv, uint32_t fFlags) 3597 3595 { 3598 3596 RT_NOREF(fFlags); … … 3619 3617 * @interface_method_impl{PDMDEVREG,pfnAttach} 3620 3618 */ 3621 static DECLCALLBACK(int) ichac97 Attach(PPDMDEVINS pDevIns, unsigned uLUN, uint32_t fFlags)3619 static DECLCALLBACK(int) ichac97R3Attach(PPDMDEVINS pDevIns, unsigned uLUN, uint32_t fFlags) 3622 3620 { 3623 3621 PAC97STATE pThis = PDMINS_2_DATA(pDevIns, PAC97STATE); … … 3628 3626 3629 3627 PAC97DRIVER pDrv; 3630 int rc2 = ichac97 AttachInternal(pThis, uLUN, fFlags, &pDrv);3628 int rc2 = ichac97R3AttachInternal(pThis, uLUN, fFlags, &pDrv); 3631 3629 if (RT_SUCCESS(rc2)) 3632 3630 { 3633 3631 if (DrvAudioHlpStreamCfgIsValid(&pThis->StreamLineIn.State.Cfg)) 3634 ichac97 MixerAddDrvStream(pThis, pThis->pSinkLineIn, &pThis->StreamLineIn.State.Cfg, pDrv);3632 ichac97R3MixerAddDrvStream(pThis, pThis->pSinkLineIn, &pThis->StreamLineIn.State.Cfg, pDrv); 3635 3633 3636 3634 if (DrvAudioHlpStreamCfgIsValid(&pThis->StreamMicIn.State.Cfg)) 3637 ichac97 MixerAddDrvStream(pThis, pThis->pSinkMicIn, &pThis->StreamMicIn.State.Cfg, pDrv);3635 ichac97R3MixerAddDrvStream(pThis, pThis->pSinkMicIn, &pThis->StreamMicIn.State.Cfg, pDrv); 3638 3636 3639 3637 if (DrvAudioHlpStreamCfgIsValid(&pThis->StreamOut.State.Cfg)) 3640 ichac97 MixerAddDrvStream(pThis, pThis->pSinkOut, &pThis->StreamOut.State.Cfg, pDrv);3638 ichac97R3MixerAddDrvStream(pThis, pThis->pSinkOut, &pThis->StreamOut.State.Cfg, pDrv); 3641 3639 } 3642 3640 … … 3649 3647 * @interface_method_impl{PDMDEVREG,pfnDetach} 3650 3648 */ 3651 static DECLCALLBACK(void) ichac97 Detach(PPDMDEVINS pDevIns, unsigned uLUN, uint32_t fFlags)3649 static DECLCALLBACK(void) ichac97R3Detach(PPDMDEVINS pDevIns, unsigned uLUN, uint32_t fFlags) 3652 3650 { 3653 3651 PAC97STATE pThis = PDMINS_2_DATA(pDevIns, PAC97STATE); … … 3662 3660 if (pDrv->uLUN == uLUN) 3663 3661 { 3664 int rc2 = ichac97 DetachInternal(pThis, pDrv, fFlags);3662 int rc2 = ichac97R3DetachInternal(pThis, pDrv, fFlags); 3665 3663 if (RT_SUCCESS(rc2)) 3666 3664 { … … 3687 3685 * @param pszDriver New driver name to attach. 3688 3686 */ 3689 static int ichac97R eattachInternal(PAC97STATE pThis, PAC97DRIVER pDrv, uint8_t uLUN, const char *pszDriver)3687 static int ichac97R3ReattachInternal(PAC97STATE pThis, PAC97DRIVER pDrv, uint8_t uLUN, const char *pszDriver) 3690 3688 { 3691 3689 AssertPtrReturn(pThis, VERR_INVALID_POINTER); … … 3696 3694 if (pDrv) 3697 3695 { 3698 rc = ichac97 DetachInternal(pThis, pDrv, 0 /* fFlags */);3696 rc = ichac97R3DetachInternal(pThis, pDrv, 0 /* fFlags */); 3699 3697 if (RT_SUCCESS(rc)) 3700 3698 rc = PDMDevHlpDriverDetach(pThis->pDevInsR3, PDMIBASE_2_PDMDRV(pDrv->pDrvBase), 0 /* fFlags */); … … 3713 3711 CFGMR3RemoveNode(CFGMR3GetChildF(pDev0, "LUN#%u/", uLUN)); 3714 3712 3715 # define RC_CHECK() if (RT_FAILURE(rc)) { AssertReleaseRC(rc); break; }3713 # define RC_CHECK() if (RT_FAILURE(rc)) { AssertReleaseRC(rc); break; } 3716 3714 3717 3715 do … … 3732 3730 3733 3731 if (RT_SUCCESS(rc)) 3734 rc = ichac97 AttachInternal(pThis, uLUN, 0 /* fFlags */, NULL /* ppDrv */);3732 rc = ichac97R3AttachInternal(pThis, uLUN, 0 /* fFlags */, NULL /* ppDrv */); 3735 3733 3736 3734 LogFunc(("pThis=%p, uLUN=%u, pszDriver=%s, rc=%Rrc\n", pThis, uLUN, pszDriver, rc)); 3737 3735 3738 # undef RC_CHECK3736 # undef RC_CHECK 3739 3737 3740 3738 return rc; … … 3744 3742 * @interface_method_impl{PDMDEVREG,pfnRelocate} 3745 3743 */ 3746 static DECLCALLBACK(void) ichac97R elocate(PPDMDEVINS pDevIns, RTGCINTPTR offDelta)3744 static DECLCALLBACK(void) ichac97R3Relocate(PPDMDEVINS pDevIns, RTGCINTPTR offDelta) 3747 3745 { 3748 3746 NOREF(offDelta); 3749 3747 PAC97STATE pThis = PDMINS_2_DATA(pDevIns, PAC97STATE); 3750 3748 pThis->pDevInsRC = PDMDEVINS_2_RCPTR(pDevIns); 3751 # ifndef VBOX_WITH_AUDIO_AC97_CALLBACKS3749 # ifndef VBOX_WITH_AUDIO_AC97_CALLBACKS 3752 3750 pThis->pTimerRC = TMTimerRCPtr(pThis->pTimerR3); 3753 # endif3751 # endif 3754 3752 } 3755 3753 … … 3757 3755 * @interface_method_impl{PDMDEVREG,pfnDestruct} 3758 3756 */ 3759 static DECLCALLBACK(int) ichac97 Destruct(PPDMDEVINS pDevIns)3757 static DECLCALLBACK(int) ichac97R3Destruct(PPDMDEVINS pDevIns) 3760 3758 { 3761 3759 PDMDEV_CHECK_VERSIONS_RETURN_QUIET(pDevIns); /* this shall come first */ … … 3780 3778 * @interface_method_impl{PDMDEVREG,pfnConstruct} 3781 3779 */ 3782 static DECLCALLBACK(int) ichac97 Construct(PPDMDEVINS pDevIns, int iInstance, PCFGMNODE pCfg)3780 static DECLCALLBACK(int) ichac97R3Construct(PPDMDEVINS pDevIns, int iInstance, PCFGMNODE pCfg) 3783 3781 { 3784 3782 PDMDEV_CHECK_VERSIONS_RETURN(pDevIns); /* this shall come first */ … … 3792 3790 pThis->pDevInsR0 = PDMDEVINS_2_R0PTR(pDevIns); 3793 3791 pThis->pDevInsRC = PDMDEVINS_2_RCPTR(pDevIns); 3794 pThis->IBase.pfnQueryInterface = ichac97 QueryInterface;3792 pThis->IBase.pfnQueryInterface = ichac97R3QueryInterface; 3795 3793 RTListInit(&pThis->lstDrv); 3796 3794 … … 3819 3817 N_("AC'97 configuration error: Querying \"Codec\" as string failed")); 3820 3818 3821 # ifndef VBOX_WITH_AUDIO_AC97_CALLBACKS3819 # ifndef VBOX_WITH_AUDIO_AC97_CALLBACKS 3822 3820 uint16_t uTimerHz; 3823 3821 rc = CFGMR3QueryU16Def(pCfg, "TimerHz", &uTimerHz, AC97_TIMER_HZ /* Default value, if not set. */); … … 3825 3823 return PDMDEV_SET_ERROR(pDevIns, rc, 3826 3824 N_("AC'97 configuration error: failed to read Hertz (Hz) rate as unsigned integer")); 3827 # endif3825 # endif 3828 3826 3829 3827 /* … … 3897 3895 return rc; 3898 3896 3899 rc = PDMDevHlpPCIIORegionRegister(pDevIns, 0, 256, PCI_ADDRESS_SPACE_IO, ichac97 IOPortMap);3897 rc = PDMDevHlpPCIIORegionRegister(pDevIns, 0, 256, PCI_ADDRESS_SPACE_IO, ichac97R3IOPortMap); 3900 3898 if (RT_FAILURE(rc)) 3901 3899 return rc; 3902 3900 3903 rc = PDMDevHlpPCIIORegionRegister(pDevIns, 1, 64, PCI_ADDRESS_SPACE_IO, ichac97 IOPortMap);3901 rc = PDMDevHlpPCIIORegionRegister(pDevIns, 1, 64, PCI_ADDRESS_SPACE_IO, ichac97R3IOPortMap); 3904 3902 if (RT_FAILURE(rc)) 3905 3903 return rc; 3906 3904 3907 rc = PDMDevHlpSSMRegister(pDevIns, AC97_SSM_VERSION, sizeof(*pThis), ichac97 SaveExec, ichac97LoadExec);3905 rc = PDMDevHlpSSMRegister(pDevIns, AC97_SSM_VERSION, sizeof(*pThis), ichac97R3SaveExec, ichac97R3LoadExec); 3908 3906 if (RT_FAILURE(rc)) 3909 3907 return rc; 3910 3908 3911 # ifdef VBOX_WITH_AUDIO_AC97_ASYNC_IO3909 # ifdef VBOX_WITH_AUDIO_AC97_ASYNC_IO 3912 3910 LogRel(("AC97: Asynchronous I/O enabled\n")); 3913 # endif3911 # endif 3914 3912 3915 3913 /* … … 3920 3918 { 3921 3919 LogFunc(("Trying to attach driver for LUN #%RU8 ...\n", uLUN)); 3922 rc = ichac97 AttachInternal(pThis, uLUN, 0 /* fFlags */, NULL /* ppDrv */);3920 rc = ichac97R3AttachInternal(pThis, uLUN, 0 /* fFlags */, NULL /* ppDrv */); 3923 3921 if (RT_FAILURE(rc)) 3924 3922 { … … 3927 3925 else if (rc == VERR_AUDIO_BACKEND_INIT_FAILED) 3928 3926 { 3929 ichac97R eattachInternal(pThis, NULL /* pDrv */, uLUN, "NullAudio");3927 ichac97R3ReattachInternal(pThis, NULL /* pDrv */, uLUN, "NullAudio"); 3930 3928 PDMDevHlpVMSetRuntimeError(pDevIns, 0 /*fFlags*/, "HostAudioNotResponding", 3931 3929 N_("Host audio backend initialization has failed. Selecting the NULL audio backend " … … 3959 3957 * Create all hardware streams. 3960 3958 */ 3961 rc = ichac97 StreamCreate(pThis, &pThis->StreamLineIn, AC97SOUNDSOURCE_PI_INDEX);3959 rc = ichac97R3StreamCreate(pThis, &pThis->StreamLineIn, AC97SOUNDSOURCE_PI_INDEX); 3962 3960 if (RT_SUCCESS(rc)) 3963 3961 { 3964 rc = ichac97 StreamCreate(pThis, &pThis->StreamMicIn, AC97SOUNDSOURCE_MC_INDEX);3962 rc = ichac97R3StreamCreate(pThis, &pThis->StreamMicIn, AC97SOUNDSOURCE_MC_INDEX); 3965 3963 if (RT_SUCCESS(rc)) 3966 rc = ichac97 StreamCreate(pThis, &pThis->StreamOut, AC97SOUNDSOURCE_PO_INDEX);3967 } 3968 3969 # ifdef VBOX_WITH_AUDIO_AC97_ONETIME_INIT3964 rc = ichac97R3StreamCreate(pThis, &pThis->StreamOut, AC97SOUNDSOURCE_PO_INDEX); 3965 } 3966 3967 # ifdef VBOX_WITH_AUDIO_AC97_ONETIME_INIT 3970 3968 PAC97DRIVER pDrv; 3971 3969 RTListForEach(&pThis->lstDrv, pDrv, AC97DRIVER, Node) … … 3991 3989 LogRel(("AC97: Falling back to NULL backend (no sound audible)\n")); 3992 3990 3993 ichac97R eset(pDevIns);3994 ichac97R eattachInternal(pThis, pDrv, pDrv->uLUN, "NullAudio");3991 ichac97R3Reset(pDevIns); 3992 ichac97R3ReattachInternal(pThis, pDrv, pDrv->uLUN, "NullAudio"); 3995 3993 3996 3994 PDMDevHlpVMSetRuntimeError(pDevIns, 0 /*fFlags*/, "HostAudioNotResponding", … … 4062 4060 } 4063 4061 } 4064 # endif /* VBOX_WITH_AUDIO_AC97_ONETIME_INIT */4062 # endif /* VBOX_WITH_AUDIO_AC97_ONETIME_INIT */ 4065 4063 } 4066 4064 4067 4065 if (RT_SUCCESS(rc)) 4068 ichac97R eset(pDevIns);4069 4070 # ifndef VBOX_WITH_AUDIO_AC97_CALLBACKS4066 ichac97R3Reset(pDevIns); 4067 4068 # ifndef VBOX_WITH_AUDIO_AC97_CALLBACKS 4071 4069 if (RT_SUCCESS(rc)) 4072 4070 { … … 4077 4075 * instead of the LPIB registers. 4078 4076 */ 4079 rc = PDMDevHlpTMTimerCreate(pDevIns, TMCLOCK_VIRTUAL_SYNC, ichac97 Timer, pThis,4077 rc = PDMDevHlpTMTimerCreate(pDevIns, TMCLOCK_VIRTUAL_SYNC, ichac97R3Timer, pThis, 4080 4078 TMTIMER_FLAGS_NO_CRIT_SECT, "AC'97 Timer", &pThis->pTimerR3); 4081 4079 AssertRCReturn(rc, rc); … … 4092 4090 LogFunc(("Timer ticks=%RU64 (%RU16 Hz)\n", pThis->cTimerTicks, uTimerHz)); 4093 4091 } 4094 # else /* !VBOX_WITH_AUDIO_AC97_CALLBACKS */4092 # else /* !VBOX_WITH_AUDIO_AC97_CALLBACKS */ 4095 4093 if (RT_SUCCESS(rc)) 4096 4094 { … … 4122 4120 } 4123 4121 } 4124 # endif /* VBOX_WITH_AUDIO_AC97_CALLBACKS */4125 4126 # ifdef VBOX_WITH_STATISTICS4122 # endif /* VBOX_WITH_AUDIO_AC97_CALLBACKS */ 4123 4124 # ifdef VBOX_WITH_STATISTICS 4127 4125 if (RT_SUCCESS(rc)) 4128 4126 { … … 4136 4134 PDMDevHlpSTAMRegister(pDevIns, &pThis->StatBytesWritten, STAMTYPE_COUNTER, "/Devices/AC97/BytesWritten", STAMUNIT_BYTES, "Bytes written to AC97 emulation."); 4137 4135 } 4138 # endif4139 4140 # ifdef VBOX_AUDIO_DEBUG_DUMP_PCM_DATA4136 # endif 4137 4138 # ifdef VBOX_AUDIO_DEBUG_DUMP_PCM_DATA 4141 4139 RTFileDelete(VBOX_AUDIO_DEBUG_DUMP_PCM_DATA_PATH "ac97DMARead.pcm"); 4142 4140 RTFileDelete(VBOX_AUDIO_DEBUG_DUMP_PCM_DATA_PATH "ac97DMAWrite.pcm"); 4143 4141 RTFileDelete(VBOX_AUDIO_DEBUG_DUMP_PCM_DATA_PATH "ac97StreamRead.pcm"); 4144 4142 RTFileDelete(VBOX_AUDIO_DEBUG_DUMP_PCM_DATA_PATH "ac97StreamWrite.pcm"); 4145 # endif4143 # endif 4146 4144 4147 4145 LogFlowFuncLeaveRC(rc); … … 4173 4171 sizeof(AC97STATE), 4174 4172 /* pfnConstruct */ 4175 ichac97 Construct,4173 ichac97R3Construct, 4176 4174 /* pfnDestruct */ 4177 ichac97 Destruct,4175 ichac97R3Destruct, 4178 4176 /* pfnRelocate */ 4179 ichac97R elocate,4177 ichac97R3Relocate, 4180 4178 /* pfnMemSetup */ 4181 4179 NULL, … … 4183 4181 NULL, 4184 4182 /* pfnReset */ 4185 ichac97R eset,4183 ichac97R3Reset, 4186 4184 /* pfnSuspend */ 4187 4185 NULL, … … 4189 4187 NULL, 4190 4188 /* pfnAttach */ 4191 ichac97 Attach,4189 ichac97R3Attach, 4192 4190 /* pfnDetach */ 4193 ichac97 Detach,4191 ichac97R3Detach, 4194 4192 /* pfnQueryInterface. */ 4195 4193 NULL, … … 4197 4195 NULL, 4198 4196 /* pfnPowerOff */ 4199 ichac97 PowerOff,4197 ichac97R3PowerOff, 4200 4198 /* pfnSoftReset */ 4201 4199 NULL,
Note:
See TracChangeset
for help on using the changeset viewer.