Changeset 82306 in vbox for trunk/src/VBox/Devices/Audio
- Timestamp:
- Dec 1, 2019 12:26:09 AM (5 years ago)
- Location:
- trunk/src/VBox/Devices/Audio
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/DevHDA.cpp
r82305 r82306 379 379 #endif 380 380 /** @} */ 381 382 #ifdef IN_RING3 383 static FNSSMFIELDGETPUT hdaR3GetPutTrans_HDABDLEDESC_fFlags_6; 384 static FNSSMFIELDGETPUT hdaR3GetPutTrans_HDABDLE_Desc_fFlags_1thru4; 385 #endif 381 386 382 387 … … 494 499 }; 495 500 501 /** HDABDLEDESC field descriptors for the v6 saved states. */ 502 static SSMFIELD const g_aSSMBDLEDescFields6[] = 503 { 504 SSMFIELD_ENTRY(HDABDLEDESC, u64BufAddr), 505 SSMFIELD_ENTRY(HDABDLEDESC, u32BufSize), 506 SSMFIELD_ENTRY_CALLBACK(HDABDLEDESC, fFlags, hdaR3GetPutTrans_HDABDLEDESC_fFlags_6), 507 SSMFIELD_ENTRY_TERM() 508 }; 509 496 510 /** HDABDLESTATE field descriptors for the v6+ saved state. */ 497 511 static SSMFIELD const g_aSSMBDLEStateFields6[] = … … 540 554 SSMFIELD_ENTRY(HDASTREAMPERIOD, framesTransferred), 541 555 SSMFIELD_ENTRY(HDASTREAMPERIOD, cIntPending), 556 SSMFIELD_ENTRY_TERM() 557 }; 558 559 /** HDABDLE field descriptors for the v1 thru v4 saved states. */ 560 static SSMFIELD const g_aSSMStreamBdleFields1234[] = 561 { 562 SSMFIELD_ENTRY(HDABDLE, Desc.u64BufAddr), /* u64BdleCviAddr */ 563 SSMFIELD_ENTRY_OLD(u32BdleMaxCvi, sizeof(uint32_t)), /* u32BdleMaxCvi */ 564 SSMFIELD_ENTRY(HDABDLE, State.u32BDLIndex), /* u32BdleCvi */ 565 SSMFIELD_ENTRY(HDABDLE, Desc.u32BufSize), /* u32BdleCviLen */ 566 SSMFIELD_ENTRY(HDABDLE, State.u32BufOff), /* u32BdleCviPos */ 567 SSMFIELD_ENTRY_CALLBACK(HDABDLE, Desc.fFlags, hdaR3GetPutTrans_HDABDLE_Desc_fFlags_1thru4), /* fBdleCviIoc */ 568 SSMFIELD_ENTRY(HDABDLE, State.cbBelowFIFOW), /* cbUnderFifoW */ 569 SSMFIELD_ENTRY_OLD(au8FIFO, 256), /* au8FIFO */ 542 570 SSMFIELD_ENTRY_TERM() 543 571 }; … … 3450 3478 /* Saved state workers and callbacks. */ 3451 3479 3480 /** 3481 * @callback_method_impl{FNSSMFIELDGETPUT, 3482 * Version 6 saves the IOC flag in HDABDLEDESC::fFlags as a bool} 3483 */ 3484 static DECLCALLBACK(int) 3485 hdaR3GetPutTrans_HDABDLEDESC_fFlags_6(PSSMHANDLE pSSM, const struct SSMFIELD *pField, void *pvStruct, 3486 uint32_t fFlags, bool fGetOrPut, void *pvUser) 3487 { 3488 PPDMDEVINS pDevIns = (PPDMDEVINS)pvUser; 3489 RT_NOREF(pSSM, pField, pvStruct, fFlags); 3490 AssertReturn(fGetOrPut, VERR_INTERNAL_ERROR_4); 3491 bool fIoc; 3492 int rc = pDevIns->pHlpR3->pfnSSMGetBool(pSSM, &fIoc); 3493 if (RT_SUCCESS(rc)) 3494 { 3495 PHDABDLEDESC pDesc = (PHDABDLEDESC)pvStruct; 3496 pDesc->fFlags = fIoc ? HDA_BDLE_FLAG_IOC : 0; 3497 } 3498 return rc; 3499 } 3500 3501 3502 /** 3503 * @callback_method_impl{FNSSMFIELDGETPUT, 3504 * Versions 1 thru 4 save the IOC flag in HDASTREAMSTATE::DescfFlags as a bool} 3505 */ 3506 static DECLCALLBACK(int) 3507 hdaR3GetPutTrans_HDABDLE_Desc_fFlags_1thru4(PSSMHANDLE pSSM, const struct SSMFIELD *pField, void *pvStruct, 3508 uint32_t fFlags, bool fGetOrPut, void *pvUser) 3509 { 3510 PPDMDEVINS pDevIns = (PPDMDEVINS)pvUser; 3511 RT_NOREF(pSSM, pField, pvStruct, fFlags); 3512 AssertReturn(fGetOrPut, VERR_INTERNAL_ERROR_4); 3513 bool fIoc; 3514 int rc = pDevIns->pHlpR3->pfnSSMGetBool(pSSM, &fIoc); 3515 if (RT_SUCCESS(rc)) 3516 { 3517 PHDABDLE pState = (PHDABDLE)pvStruct; 3518 pState->Desc.fFlags = fIoc ? HDA_BDLE_FLAG_IOC : 0; 3519 } 3520 return rc; 3521 } 3522 3523 3452 3524 static int hdaR3SaveStream(PPDMDEVINS pDevIns, PSSMHANDLE pSSM, PHDASTREAM pStream) 3453 3525 { … … 3664 3736 case HDA_SSM_VERSION_5: 3665 3737 case HDA_SSM_VERSION_6: 3666 rc = pHlp->pfnSSMGetU32(pSSM, &cRegs); AssertRCReturn(rc, rc); 3738 rc = pHlp->pfnSSMGetU32(pSSM, &cRegs); 3739 AssertRCReturn(rc, rc); 3667 3740 if (cRegs != RT_ELEMENTS(pThis->au32Regs)) 3668 3741 LogRel(("HDA: SSM version cRegs is %RU32, expected %RU32\n", cRegs, RT_ELEMENTS(pThis->au32Regs))); … … 3691 3764 3692 3765 /* 3766 * Load BDLEs (Buffer Descriptor List Entries) and DMA counters. 3767 * 3693 3768 * Note: Saved states < v5 store LVI (u32BdleMaxCvi) for 3694 3769 * *every* BDLE state, whereas it only needs to be stored … … 3700 3775 * according to the spec). 3701 3776 */ 3702 #define HDA_SSM_LOAD_BDLE_STATE_PRE_V5(v, x) \3703 { \3704 pHlp->pfnSSMSkip(pSSM, sizeof(uint32_t)); /* Begin marker */ \3705 pHlp->pfnSSMGetU64(pSSM, &x.Desc.u64BufAddr); /* u64BdleCviAddr */ \3706 pHlp->pfnSSMSkip(pSSM, sizeof(uint32_t)); /* u32BdleMaxCvi */ \3707 pHlp->pfnSSMGetU32(pSSM, &x.State.u32BDLIndex); /* u32BdleCvi */ \3708 pHlp->pfnSSMGetU32(pSSM, &x.Desc.u32BufSize); /* u32BdleCviLen */ \3709 pHlp->pfnSSMGetU32(pSSM, &x.State.u32BufOff); /* u32BdleCviPos */ \3710 bool fIOC; \3711 rc = pHlp->pfnSSMGetBool(pSSM, &fIOC); /* fBdleCviIoc */ \3712 AssertRCReturn(rc, rc); \3713 x.Desc.fFlags = fIOC ? HDA_BDLE_FLAG_IOC : 0; \3714 pHlp->pfnSSMGetU32(pSSM, &x.State.cbBelowFIFOW); /* cbUnderFifoW */ \3715 pHlp->pfnSSMSkip(pSSM, sizeof(uint8_t) * 256); /* FIFO */ \3716 rc = pHlp->pfnSSMSkip(pSSM, sizeof(uint32_t)); /* End marker */ \3717 AssertRCReturn(rc, rc); \3718 }3719 3720 /*3721 * Load BDLEs (Buffer Descriptor List Entries) and DMA counters.3722 */3723 3777 switch (uVersion) 3724 3778 { … … 3738 3792 rc = hdaR3StreamInit(pStream, 4 /* Stream descriptor, hardcoded */); 3739 3793 AssertRCReturn(rc, rc); 3740 HDA_SSM_LOAD_BDLE_STATE_PRE_V5(uVersion, pStream->State.BDLE); 3794 rc = pHlp->pfnSSMGetStructEx(pSSM, &pStream->State.BDLE, sizeof(pStream->State.BDLE), 3795 0 /* fFlags */, g_aSSMStreamBdleFields1234, pDevIns); 3796 AssertRCReturn(rc, rc); 3741 3797 pStream->State.uCurBDLE = pStream->State.BDLE.State.u32BDLIndex; 3742 3798 … … 3745 3801 rc = hdaR3StreamInit(pStream, 2 /* Stream descriptor, hardcoded */); 3746 3802 AssertRCReturn(rc, rc); 3747 HDA_SSM_LOAD_BDLE_STATE_PRE_V5(uVersion, pStream->State.BDLE); 3803 rc = pHlp->pfnSSMGetStructEx(pSSM, &pStream->State.BDLE, sizeof(pStream->State.BDLE), 3804 0 /* fFlags */, g_aSSMStreamBdleFields1234, pDevIns); 3805 AssertRCReturn(rc, rc); 3748 3806 pStream->State.uCurBDLE = pStream->State.BDLE.State.u32BDLIndex; 3749 3807 … … 3752 3810 rc = hdaR3StreamInit(pStream, 0 /* Stream descriptor, hardcoded */); 3753 3811 AssertRCReturn(rc, rc); 3754 HDA_SSM_LOAD_BDLE_STATE_PRE_V5(uVersion, pStream->State.BDLE); 3812 rc = pHlp->pfnSSMGetStructEx(pSSM, &pStream->State.BDLE, sizeof(pStream->State.BDLE), 3813 0 /* fFlags */, g_aSSMStreamBdleFields1234, pDevIns); 3814 AssertRCReturn(rc, rc); 3755 3815 pStream->State.uCurBDLE = pStream->State.BDLE.State.u32BDLIndex; 3756 3816 break; 3757 3817 } 3758 3818 3759 #undef HDA_SSM_LOAD_BDLE_STATE_PRE_V5 3760 3761 default: /* Since v5 we support flexible stream and BDLE counts. */ 3819 /* 3820 * v5 & v6 - Since v5 we support flexible stream and BDLE counts. 3821 */ 3822 default: 3762 3823 { 3763 3824 /* Stream count. */ … … 3777 3838 AssertRCReturn(rc, rc); 3778 3839 3840 HDASTREAM StreamDummy; 3779 3841 PHDASTREAM pStream = hdaGetStreamFromSD(pThis, idStream); 3780 HDASTREAM StreamDummy;3781 3782 3842 if (!pStream) 3783 3843 { 3784 3844 pStream = &StreamDummy; 3785 LogRel2(("HDA: Warning: Stream ID=%RU32 not supported, skipping to load...\n", idStream));3845 LogRel2(("HDA: Warning: Stream ID=%RU32 not supported, skipping loading it ...\n", idStream)); 3786 3846 } 3787 3847 … … 3798 3858 if (uVersion == HDA_SSM_VERSION_5) 3799 3859 { 3800 /* Get the current BDLE entry and skip the rest. */ 3801 pHlp->pfnSSMSkip(pSSM, sizeof(uint32_t)); /* Begin marker */ 3802 uint16_t cBDLE; 3803 pHlp->pfnSSMGetU16(pSSM, &cBDLE); /* cBDLE */ 3804 pHlp->pfnSSMGetU16(pSSM, &pStream->State.uCurBDLE); /* uCurBDLE */ 3805 rc = pHlp->pfnSSMSkip(pSSM, sizeof(uint32_t)); /* End marker */ 3860 struct V5HDASTREAMSTATE /* HDASTREAMSTATE + HDABDLE */ 3861 { 3862 uint16_t cBLDEs; 3863 uint16_t uCurBDLE; 3864 uint32_t u32BDLEIndex; 3865 uint32_t cbBelowFIFOW; 3866 uint32_t u32BufOff; 3867 } Tmp; 3868 static SSMFIELD const g_aV5State1Fields[] = 3869 { 3870 SSMFIELD_ENTRY(V5HDASTREAMSTATE, cBLDEs), 3871 SSMFIELD_ENTRY(V5HDASTREAMSTATE, uCurBDLE), 3872 SSMFIELD_ENTRY_TERM() 3873 }; 3874 rc = pHlp->pfnSSMGetStructEx(pSSM, &Tmp, sizeof(Tmp), 0 /* fFlags */, g_aV5State1Fields, NULL); 3806 3875 AssertRCReturn(rc, rc); 3807 3808 for (uint16_t a = 0; a < cBDLE; a++) 3876 pStream->State.uCurBDLE = Tmp.uCurBDLE; 3877 3878 for (uint16_t a = 0; a < Tmp.cBLDEs; a++) 3809 3879 { 3810 pHlp->pfnSSMSkip(pSSM, sizeof(uint32_t)); /* Begin marker */ 3811 uint32_t u32BDLEIndex; 3812 rc = pHlp->pfnSSMGetU32(pSSM, &u32BDLEIndex); /* u32BDLIndex */ 3880 static SSMFIELD const g_aV5State2Fields[] = 3881 { 3882 SSMFIELD_ENTRY(V5HDASTREAMSTATE, u32BDLEIndex), 3883 SSMFIELD_ENTRY_OLD(au8FIFO, 256), 3884 SSMFIELD_ENTRY(V5HDASTREAMSTATE, cbBelowFIFOW), 3885 SSMFIELD_ENTRY_TERM() 3886 }; 3887 rc = pHlp->pfnSSMGetStructEx(pSSM, &Tmp, sizeof(Tmp), 0 /* fFlags */, g_aV5State2Fields, NULL); 3813 3888 AssertRCReturn(rc, rc); 3814 3815 /* Does the current BDLE index match the current BDLE to process? */ 3816 if (u32BDLEIndex == pStream->State.uCurBDLE) 3889 if (Tmp.u32BDLEIndex == pStream->State.uCurBDLE) 3817 3890 { 3818 pHlp->pfnSSMGetU32(pSSM, &pStream->State.BDLE.State.cbBelowFIFOW); /* cbBelowFIFOW */ 3819 pHlp->pfnSSMSkip(pSSM, sizeof(uint8_t) * 256); /* FIFO, deprecated */ 3820 pHlp->pfnSSMGetU32(pSSM, &pStream->State.BDLE.State.u32BufOff); /* u32BufOff */ 3821 rc = pHlp->pfnSSMSkip(pSSM, sizeof(uint32_t)); /* End marker */ 3822 AssertRCReturn(rc, rc); 3823 } 3824 else /* Skip not current BDLEs. */ 3825 { 3826 rc = pHlp->pfnSSMSkip(pSSM, sizeof(uint32_t) /* cbBelowFIFOW */ 3827 + sizeof(uint8_t) * 256 /* au8FIFO */ 3828 + sizeof(uint32_t) /* u32BufOff */ 3829 + sizeof(uint32_t)); /* End marker */ 3830 AssertRCReturn(rc, rc); 3891 pStream->State.BDLE.State.cbBelowFIFOW = Tmp.cbBelowFIFOW; 3892 pStream->State.BDLE.State.u32BufOff = Tmp.u32BufOff; 3831 3893 } 3832 3894 } … … 3838 3900 AssertRCReturn(rc, rc); 3839 3901 3840 /* Get HDABDLEDESC. */ 3841 /** 3842 * 3843 * @todo r=bird: This is all wrong. Appalling. There is no reason for anyone to 3844 * mess around with SSM internal magic values ever! Define a structure and(/or) 3845 * associated SSM descriptor and let SSM keep its internals to itself. 3846 * struct { uint32_t cbBuf; bool fIoc; } 3847 * 3848 */ 3849 uint32_t uMarker; 3850 rc = pHlp->pfnSSMGetU32(pSSM, &uMarker); /* Begin marker. */ 3902 rc = pHlp->pfnSSMGetStructEx(pSSM, &pStream->State.BDLE.Desc, sizeof(pStream->State.BDLE.Desc), 3903 0 /* fFlags */, g_aSSMBDLEDescFields6, pDevIns); 3851 3904 AssertRCReturn(rc, rc); 3852 AssertReturn(uMarker == UINT32_C(0x19200102) /* SSMR3STRUCT_BEGIN */, VERR_SSM_DATA_UNIT_FORMAT_CHANGED);3853 pHlp->pfnSSMGetU64(pSSM, &pStream->State.BDLE.Desc.u64BufAddr);3854 rc = pHlp->pfnSSMGetU32(pSSM, &pStream->State.BDLE.Desc.u32BufSize);3855 AssertRCReturn(rc, rc);3856 bool fFlags = false;3857 rc = pHlp->pfnSSMGetBool(pSSM, &fFlags); /* Saved states < v7 only stored the IOC as boolean flag. */3858 AssertRCReturn(rc, rc);3859 pStream->State.BDLE.Desc.fFlags = fFlags ? HDA_BDLE_FLAG_IOC : 0;3860 rc = pHlp->pfnSSMGetU32(pSSM, &uMarker); /* End marker. */3861 AssertRCReturn(rc, rc);3862 AssertReturn(uMarker == UINT32_C(0x19920406) /* SSMR3STRUCT_END */, VERR_SSM_DATA_UNIT_FORMAT_CHANGED);3863 3905 3864 3906 rc = pHlp->pfnSSMGetStructEx(pSSM, &pStream->State.BDLE.State, sizeof(HDABDLESTATE), … … 3903 3945 } 3904 3946 3905 if (uVersion < HDA_SSM_VERSION) /* Handle older saved states? */3947 if (uVersion <= HDA_SSM_VERSION_6) /* Handle older saved states? */ 3906 3948 { 3907 3949 rc = hdaR3LoadExecLegacy(pDevIns, pThis, pSSM, uVersion); -
trunk/src/VBox/Devices/Audio/HDACodec.h
r80681 r82306 132 132 int hdaCodecRemoveStream(PHDACODEC pThis, PDMAUDIOMIXERCTL enmMixerCtl); 133 133 134 /** @name Dev HDA saved state verions 135 * @todo r=bird: s/HDA_SSM_/HDA_SAVED_STATE_/g - SSM = saved state manager, duh! 136 * @{ */ 134 137 /** Added (Controller): Current wall clock value (this independent from WALCLK register value). 135 138 * Added (Controller): Current IRQ level. … … 151 154 #define HDA_SSM_VERSION_2 2 152 155 #define HDA_SSM_VERSION_1 1 156 /** @} */ 153 157 154 158 #endif /* !VBOX_INCLUDED_SRC_Audio_HDACodec_h */
Note:
See TracChangeset
for help on using the changeset viewer.