VirtualBox

Changeset 31771 in vbox for trunk/src/VBox/Devices/Audio


Ignore:
Timestamp:
Aug 19, 2010 9:15:42 AM (14 years ago)
Author:
vboxsync
Message:

Audio/HDA: introduces saved states.

Location:
trunk/src/VBox/Devices/Audio
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Audio/DevCodec.cpp

    r31760 r31771  
    12711271    return VINF_SUCCESS;
    12721272}
     1273
     1274int stac9220SaveState(CODECState *pCodecState, PSSMHANDLE pSSMHandle)
     1275{
     1276    SSMR3PutMem (pSSMHandle, pCodecState->pNodes, sizeof(CODECNODE) * STAC9220_NODE_COUNT);
     1277    return VINF_SUCCESS;
     1278}
     1279int stac9220LoadState(CODECState *pCodecState, PSSMHANDLE pSSMHandle)
     1280{
     1281    SSMR3GetMem (pSSMHandle, pCodecState->pNodes, sizeof(CODECNODE) * STAC9220_NODE_COUNT);
     1282    codecToAudVolume(&pCodecState->pNodes[2].dac.B_params, AUD_MIXER_VOLUME);
     1283    codecToAudVolume(&pCodecState->pNodes[0x17].adcvol.B_params, AUD_MIXER_PCM);
     1284    return VINF_SUCCESS;
     1285}
  • trunk/src/VBox/Devices/Audio/DevCodec.h

    r31507 r31771  
    233233int stac9220Construct(CODECState *pCodecState);
    234234int stac9220Destruct(CODECState *pCodecState);
     235int stac9220SaveState(CODECState *pCodecState, PSSMHANDLE pSSMHandle);
     236int stac9220LoadState(CODECState *pCodecState, PSSMHANDLE pSSMHandle);
    235237
    236238#endif
  • trunk/src/VBox/Devices/Audio/DevIchIntelHDA.cpp

    r31760 r31771  
    4141#endif
    4242
    43 #define INTELHD_SSM_VERSION 1
     43#define HDA_SSM_VERSION 1
    4444PDMBOTHCBDECL(int) hdaMMIORead(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS GCPhysAddr, void *pv, unsigned cb);
    4545PDMBOTHCBDECL(int) hdaMMIOWrite(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS GCPhysAddr, void *pv, unsigned cb);
     
    133133
    134134#define ICH6_HDA_REG_CORBLBASE  13 /* 0x40 */
     135#define CORBLBASE(pState) (HDA_REG((pState), CORBLBASE))
    135136#define ICH6_HDA_REG_CORBUBASE  14 /* 0x44 */
     137#define CORBUBASE(pState) (HDA_REG((pState), CORBUBASE))
    136138#define ICH6_HDA_REG_CORBWP  15 /* 48 */
    137139#define ICH6_HDA_REG_CORBRP  16 /* 4A */
     
    162164
    163165#define ICH6_HDA_REG_RIRLBASE  20 /* 0x50 */
     166#define RIRLBASE(pState) (HDA_REG((pState), RIRLBASE))
     167
    164168#define ICH6_HDA_REG_RIRUBASE  21 /* 0x54 */
     169#define RIRUBASE(pState) (HDA_REG((pState), RIRUBASE))
    165170
    166171#define ICH6_HDA_REG_RIRBWP  22 /* 0x58 */
     
    367372    uint64_t    u64RIRBBase;
    368373    uint64_t    u64DPBase;
    369     uint8_t     u8CORBRP;
    370374    /* pointer on CORB buf */
    371375    uint32_t    *pu32CorbBuf;
     
    909913{
    910914    if (u32Value & HDA_REG_FIELD_FLAG_MASK(CORBRP, RST))
    911     {
    912         pState->u8CORBRP = 0;
    913915        CORBRP(pState) = 0;
    914     }
    915916    else
    916917        return hdaRegWriteU8(pState, offset, index, u32Value);
     
    14901491}
    14911492
     1493/**
     1494 * Saves a state of the HDA device.
     1495 *
     1496 * @returns VBox status code.
     1497 * @param   pDevIns     The device instance.
     1498 * @param   pSSMHandle  The handle to save the state to.
     1499 */
     1500static DECLCALLBACK(int) hdaSaveExec (PPDMDEVINS pDevIns, PSSMHANDLE pSSMHandle)
     1501{
     1502    PCIINTELHDLinkState *pThis = PDMINS_2_DATA(pDevIns, PCIINTELHDLinkState *);
     1503    /* Save Codec nodes states */
     1504    stac9220SaveState(&pThis->hda.Codec, pSSMHandle);
     1505    /* Save MMIO registers */
     1506    SSMR3PutMem (pSSMHandle, pThis->hda.au32Regs, sizeof (pThis->hda.au32Regs));
     1507    /* Save HDA dma counters */
     1508    SSMR3PutMem (pSSMHandle, &pThis->hda.stOutBdle, sizeof (HDABDLEDESC));
     1509    SSMR3PutMem (pSSMHandle, &pThis->hda.stMicBdle, sizeof (HDABDLEDESC));
     1510    SSMR3PutMem (pSSMHandle, &pThis->hda.stInBdle, sizeof (HDABDLEDESC));
     1511    uint8_t voices = AUD_is_active_in(pThis->hda.Codec.voice_pi)? RT_BIT(0):0;
     1512    voices |= AUD_is_active_in(pThis->hda.Codec.voice_mc)? RT_BIT(1):0;
     1513    voices |= AUD_is_active_out(pThis->hda.Codec.voice_po)? RT_BIT(2):0;
     1514    SSMR3PutU8(pSSMHandle, voices);
     1515    return VINF_SUCCESS;
     1516}
     1517
     1518/**
     1519 * Loads a saved HDA device state.
     1520 *
     1521 * @returns VBox status code.
     1522 * @param   pDevIns     The device instance.
     1523 * @param   pSSMHandle  The handle to the saved state.
     1524 * @param   uVersion    The data unit version number.
     1525 * @param   uPass       The data pass.
     1526 */
     1527static DECLCALLBACK(int) hdaLoadExec (PPDMDEVINS pDevIns, PSSMHANDLE pSSMHandle,
     1528                                          uint32_t uVersion, uint32_t uPass)
     1529{
     1530    PCIINTELHDLinkState *pThis = PDMINS_2_DATA(pDevIns, PCIINTELHDLinkState *);
     1531    /* Load Codec nodes states */
     1532    stac9220LoadState(&pThis->hda.Codec, pSSMHandle);
     1533    /* Load MMIO registers */
     1534    SSMR3GetMem (pSSMHandle, pThis->hda.au32Regs, sizeof (pThis->hda.au32Regs));
     1535    /* Load HDA dma counters */
     1536    SSMR3GetMem (pSSMHandle, &pThis->hda.stOutBdle, sizeof (HDABDLEDESC));
     1537    SSMR3GetMem (pSSMHandle, &pThis->hda.stMicBdle, sizeof (HDABDLEDESC));
     1538    SSMR3GetMem (pSSMHandle, &pThis->hda.stInBdle, sizeof (HDABDLEDESC));
     1539    uint8_t voices;
     1540    SSMR3GetU8(pSSMHandle, &voices);
     1541    AUD_set_active_in(pThis->hda.Codec.voice_pi, voices & RT_BIT(0));
     1542    AUD_set_active_in(pThis->hda.Codec.voice_mc, voices & RT_BIT(1));
     1543    AUD_set_active_out(pThis->hda.Codec.voice_po, voices & RT_BIT(2));
     1544    pThis->hda.u64CORBBase = CORBLBASE(&pThis->hda);
     1545    pThis->hda.u64CORBBase |= ((uint64_t)CORBUBASE(&pThis->hda)) << 32;
     1546    pThis->hda.u64RIRBBase = RIRLBASE(&pThis->hda);
     1547    pThis->hda.u64RIRBBase |= ((uint64_t)RIRUBASE(&pThis->hda)) << 32;
     1548    pThis->hda.u64DPBase = DPLBASE(&pThis->hda);
     1549    pThis->hda.u64DPBase |= ((uint64_t)DPUBASE(&pThis->hda)) << 32;
     1550    return VINF_SUCCESS;
     1551}
    14921552
    14931553/**
     
    16461706    rc = PDMDevHlpPCIIORegionRegister (pDevIns, 0, 0x4000, PCI_ADDRESS_SPACE_MEM,
    16471707                                       hdaMap);
     1708    if (RT_FAILURE (rc))
     1709        return rc;
     1710
     1711    rc = PDMDevHlpSSMRegister (pDevIns, HDA_SSM_VERSION, sizeof(*pThis), hdaSaveExec, hdaLoadExec);
    16481712    if (RT_FAILURE (rc))
    16491713        return rc;
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette