VirtualBox

Ignore:
Timestamp:
May 12, 2016 1:12:20 PM (9 years ago)
Author:
vboxsync
Message:

Audio/HDA:

  • Lowered timer to 100Hz and start/stop it only if needed. Should improve overall performance.
  • More work on dynamic stream assignments (SDI/SDO select) by the guest -- should make more Linux guests compatible with HDA.
File:
1 edited

Legend:

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

    r60925 r60941  
    550550typedef struct CODECCOMMONNODE
    551551{
    552     /** Node id - 7 bit format */
    553     uint8_t         id;
    554     /** The node name. */
     552    /** The node's ID. */
     553    uint8_t         uID;
     554    /** The node's name. */
    555555    char const     *pszName;
     556    /** The SDn ID this node is assigned to.
     557     *  0 means not assigned, 1 is SDn0. */
     558    uint8_t         uSD;
     559    /** The SDn's channel to use.
     560     *  Only valid if a valid SDn ID is set. */
     561    uint8_t         uChannel;
    556562    /* PRM 5.3.6 */
    557563    uint32_t au32F00_param[CODECNODE_F00_PARAM_LENGTH];
     
    839845static SSMFIELD const g_aCodecNodeFields[] =
    840846{
    841     SSMFIELD_ENTRY(     CODECSAVEDSTATENODE, Core.id),
     847    SSMFIELD_ENTRY(     CODECSAVEDSTATENODE, Core.uID),
    842848    SSMFIELD_ENTRY_PAD_HC_AUTO(3, 3),
    843849    SSMFIELD_ENTRY(     CODECSAVEDSTATENODE, Core.au32F00_param),
     
    850856static SSMFIELD const g_aCodecNodeFieldsV1[] =
    851857{
    852     SSMFIELD_ENTRY(     CODECSAVEDSTATENODE, Core.id),
     858    SSMFIELD_ENTRY(     CODECSAVEDSTATENODE, Core.uID),
    853859    SSMFIELD_ENTRY_PAD_HC_AUTO(3, 7),
    854860    SSMFIELD_ENTRY_OLD_HCPTR(Core.name),
     
    890896
    891897    /* Set common parameters across all nodes. */
    892     pNode->node.id = uNID;
     898    pNode->node.uID = uNID;
     899    pNode->node.uSD = 0;
    893900
    894901    switch (uNID)
     
    20512058        && pThis->pfnCodecNodeReset)
    20522059    {
    2053         uint8_t i;
    20542060        LogFunc(("Entering reset ...\n"));
    20552061
    2056         //pThis->fInReset = true;
    2057 
    2058         for (i = 0; i < pThis->cTotalNodes; ++i)
     2062        pThis->fInReset = true;
     2063
     2064        for (uint8_t i = 0; i < pThis->cTotalNodes; ++i)
    20592065            pThis->pfnCodecNodeReset(pThis, i, &pThis->paNodes[i]);
    20602066
    2061         //pThis->fInReset = false;
     2067        pThis->fInReset = false;
    20622068
    20632069        LogFunc(("Exited reset\n"));
     
    22742280    *pResp = 0;
    22752281
     2282    bool fIsOut;
     2283
    22762284    if (hdaCodecIsDacNode(pThis, CODEC_NID(cmd)))
    22772285        *pResp = pThis->paNodes[CODEC_NID(cmd)].dac.u32F06_param;
     
    22872295        LogRel2(("HDA: Warning: Unhandled get stream ID command for NID0x%02x: 0x%x\n", CODEC_NID(cmd), cmd));
    22882296
    2289     /*LogFlowFunc(("[NID0x%02x] Stream ID is 0x%x\n",
    2290                  CODEC_NID(cmd), CODEC_F00_06_GET_STREAM_ID(*pResp)));*/
     2297    LogFlowFunc(("[NID0x%02x] Stream ID=%RU8, channel=%RU8\n",
     2298                 CODEC_NID(cmd), CODEC_F00_06_GET_STREAM_ID(cmd), CODEC_F00_06_GET_CHANNEL_ID(cmd)));
    22912299
    22922300    return VINF_SUCCESS;
     
    22982306    *pResp = 0;
    22992307
     2308    PDMAUDIODIR enmDir;
     2309
    23002310    uint32_t *pu32Addr = NULL;
    23012311    if (hdaCodecIsDacNode(pThis, CODEC_NID(cmd)))
     2312    {
    23022313        pu32Addr = &pThis->paNodes[CODEC_NID(cmd)].dac.u32F06_param;
     2314        enmDir = PDMAUDIODIR_OUT;
     2315    }
    23032316    else if (hdaCodecIsAdcNode(pThis, CODEC_NID(cmd)))
     2317    {
    23042318        pu32Addr = &pThis->paNodes[CODEC_NID(cmd)].adc.u32F06_param;
     2319        enmDir = PDMAUDIODIR_IN;
     2320    }
    23052321    else if (hdaCodecIsSpdifOutNode(pThis, CODEC_NID(cmd)))
     2322    {
    23062323        pu32Addr = &pThis->paNodes[CODEC_NID(cmd)].spdifout.u32F06_param;
     2324        enmDir = PDMAUDIODIR_OUT;
     2325    }
    23072326    else if (hdaCodecIsSpdifInNode(pThis, CODEC_NID(cmd)))
     2327    {
    23082328        pu32Addr = &pThis->paNodes[CODEC_NID(cmd)].spdifin.u32F06_param;
    2309     else if (hdaCodecIsReservedNode(pThis, CODEC_NID(cmd)))
    2310         pu32Addr = &pThis->paNodes[CODEC_NID(cmd)].reserved.u32F06_param;
     2329        enmDir = PDMAUDIODIR_IN;
     2330    }
    23112331    else
     2332    {
     2333        enmDir = PDMAUDIODIR_UNKNOWN;
    23122334        LogRel2(("HDA: Warning: Unhandled set stream ID command for NID0x%02x: 0x%x\n", CODEC_NID(cmd), cmd));
    2313 
    2314 /*    LogFlowFunc(("[NID0x%02x] Setting new stream ID to 0x%x\n",
    2315                  CODEC_NID(cmd), CODEC_F00_06_GET_STREAM_ID(cmd)));*/
     2335    }
     2336
     2337    /* Do we (re-)assign our input/output SDn (SDI/SDO) IDs? */
     2338    if (enmDir != PDMAUDIODIR_UNKNOWN)
     2339    {
     2340        uint8_t uSD      = CODEC_F00_06_GET_STREAM_ID(cmd);
     2341        uint8_t uChannel = CODEC_F00_06_GET_CHANNEL_ID(cmd);
     2342
     2343        LogFlowFunc(("[NID0x%02x] Setting to stream ID=%RU8, channel=%RU8, enmDir=%RU32\n",
     2344                     CODEC_NID(cmd), uSD, uChannel, enmDir));
     2345
     2346        pThis->paNodes[CODEC_NID(cmd)].node.uSD      = uSD;
     2347        pThis->paNodes[CODEC_NID(cmd)].node.uChannel = uChannel;
     2348
     2349        if (enmDir == PDMAUDIODIR_OUT)
     2350        {
     2351            /** @todo Check if non-interleaved streams need a different channel / SDn? */
     2352
     2353            /* Propagate to the controller. */
     2354            pThis->pfnMixerSetStream(pThis->pHDAState, PDMAUDIOMIXERCTL_FRONT,      uSD, uChannel);
     2355#ifdef VBOX_WITH_HDA_51_SURROUND
     2356            pThis->pfnMixerSetStream(pThis->pHDAState, PDMAUDIOMIXERCTL_CENTER_LFE, uSD, uChannel);
     2357            pThis->pfnMixerSetStream(pThis->pHDAState, PDMAUDIOMIXERCTL_REAR,       uSD, uChannel);
     2358#endif
     2359        }
     2360        else if (enmDir == PDMAUDIODIR_IN)
     2361        {
     2362            pThis->pfnMixerSetStream(pThis->pHDAState, PDMAUDIOMIXERCTL_LINE_IN,    uSD, uChannel);
     2363#ifdef VBOX_WITH_HDA_MIC_IN
     2364            pThis->pfnMixerSetStream(pThis->pHDAState, PDMAUDIOMIXERCTL_MIC_IN,     uSD, uChannel);
     2365#endif
     2366        }
     2367    }
    23162368
    23172369    if (pu32Addr)
     
    27562808static void codecDbgPrintNode(PCODECDBGINFO pInfo, PCODECNODE pNode, bool fRecursive)
    27572809{
    2758     codecDbgPrintf(pInfo, "Node 0x%02x (%02RU8): ", pNode->node.id, pNode->node.id);
    2759 
    2760     if (pNode->node.id == STAC9220_NID_ROOT)
     2810    codecDbgPrintf(pInfo, "Node 0x%02x (%02RU8): ", pNode->node.uID, pNode->node.uID);
     2811
     2812    if (pNode->node.uID == STAC9220_NID_ROOT)
    27612813    {
    27622814        CODECDBG_PRINT("ROOT\n");
    27632815    }
    2764     else if (pNode->node.id == STAC9220_NID_AFG)
     2816    else if (pNode->node.uID == STAC9220_NID_AFG)
    27652817    {
    27662818        CODECDBG_PRINT("AFG\n");
     
    27702822        CODECDBG_UNINDENT
    27712823    }
    2772     else if (hdaCodecIsPortNode(pInfo->pThis, pNode->node.id))
     2824    else if (hdaCodecIsPortNode(pInfo->pThis, pNode->node.uID))
    27732825    {
    27742826        CODECDBG_PRINT("PORT\n");
    27752827    }
    2776     else if (hdaCodecIsDacNode(pInfo->pThis, pNode->node.id))
     2828    else if (hdaCodecIsDacNode(pInfo->pThis, pNode->node.uID))
    27772829    {
    27782830        CODECDBG_PRINT("DAC\n");
     
    27842836        CODECDBG_UNINDENT
    27852837    }
    2786     else if (hdaCodecIsAdcVolNode(pInfo->pThis, pNode->node.id))
     2838    else if (hdaCodecIsAdcVolNode(pInfo->pThis, pNode->node.uID))
    27872839    {
    27882840        CODECDBG_PRINT("ADC VOLUME\n");
     
    27932845        CODECDBG_UNINDENT
    27942846    }
    2795     else if (hdaCodecIsAdcNode(pInfo->pThis, pNode->node.id))
     2847    else if (hdaCodecIsAdcNode(pInfo->pThis, pNode->node.uID))
    27962848    {
    27972849        CODECDBG_PRINT("ADC\n");
     
    28032855        CODECDBG_UNINDENT
    28042856    }
    2805     else if (hdaCodecIsAdcMuxNode(pInfo->pThis, pNode->node.id))
     2857    else if (hdaCodecIsAdcMuxNode(pInfo->pThis, pNode->node.uID))
    28062858    {
    28072859        CODECDBG_PRINT("ADC MUX\n");
     
    28122864        CODECDBG_UNINDENT
    28132865    }
    2814     else if (hdaCodecIsPcbeepNode(pInfo->pThis, pNode->node.id))
     2866    else if (hdaCodecIsPcbeepNode(pInfo->pThis, pNode->node.uID))
    28152867    {
    28162868        CODECDBG_PRINT("PC BEEP\n");
    28172869    }
    2818     else if (hdaCodecIsSpdifOutNode(pInfo->pThis, pNode->node.id))
     2870    else if (hdaCodecIsSpdifOutNode(pInfo->pThis, pNode->node.uID))
    28192871    {
    28202872        CODECDBG_PRINT("SPDIF OUT\n");
    28212873    }
    2822     else if (hdaCodecIsSpdifInNode(pInfo->pThis, pNode->node.id))
     2874    else if (hdaCodecIsSpdifInNode(pInfo->pThis, pNode->node.uID))
    28232875    {
    28242876        CODECDBG_PRINT("SPDIF IN\n");
    28252877    }
    2826     else if (hdaCodecIsDigInPinNode(pInfo->pThis, pNode->node.id))
     2878    else if (hdaCodecIsDigInPinNode(pInfo->pThis, pNode->node.uID))
    28272879    {
    28282880        CODECDBG_PRINT("DIGITAL IN PIN\n");
    28292881    }
    2830     else if (hdaCodecIsDigOutPinNode(pInfo->pThis, pNode->node.id))
     2882    else if (hdaCodecIsDigOutPinNode(pInfo->pThis, pNode->node.uID))
    28312883    {
    28322884        CODECDBG_PRINT("DIGITAL OUT PIN\n");
    28332885    }
    2834     else if (hdaCodecIsCdNode(pInfo->pThis, pNode->node.id))
     2886    else if (hdaCodecIsCdNode(pInfo->pThis, pNode->node.uID))
    28352887    {
    28362888        CODECDBG_PRINT("CD\n");
    28372889    }
    2838     else if (hdaCodecIsVolKnobNode(pInfo->pThis, pNode->node.id))
     2890    else if (hdaCodecIsVolKnobNode(pInfo->pThis, pNode->node.uID))
    28392891    {
    28402892        CODECDBG_PRINT("VOLUME KNOB\n");
    28412893    }
    2842     else if (hdaCodecIsReservedNode(pInfo->pThis, pNode->node.id))
     2894    else if (hdaCodecIsReservedNode(pInfo->pThis, pNode->node.uID))
    28432895    {
    28442896        CODECDBG_PRINT("RESERVED\n");
    28452897    }
    28462898    else
    2847         CODECDBG_PRINT("UNKNOWN TYPE 0x%x\n", pNode->node.id);
     2899        CODECDBG_PRINT("UNKNOWN TYPE 0x%x\n", pNode->node.uID);
    28482900
    28492901    if (fRecursive)
     
    28532905        {                                                                          \
    28542906            const uint8_t uID = RT_BYTE##_aEntry(_aNode->node.au32F02_param[0x0]); \
    2855             if (pNode->node.id == uID)                                             \
     2907            if (pNode->node.uID == uID)                                             \
    28562908                codecDbgPrintNode(pInfo, _aNode, false /* fRecursive */);          \
    28572909        }
     
    28612913        {
    28622914            const PCODECNODE pSubNode = &pInfo->pThis->paNodes[i];
    2863             if (pSubNode->node.id == pNode->node.id)
     2915            if (pSubNode->node.uID == pNode->node.uID)
    28642916                continue;
    28652917
     
    30523104    for (unsigned idxNode = 0; idxNode < pThis->cTotalNodes; ++idxNode)
    30533105    {
    3054         uint8_t idOld = pThis->paNodes[idxNode].SavedState.Core.id;
     3106        uint8_t idOld = pThis->paNodes[idxNode].SavedState.Core.uID;
    30553107        int rc = SSMR3GetStructEx(pSSM, &pThis->paNodes[idxNode].SavedState,
    30563108                                  sizeof(pThis->paNodes[idxNode].SavedState),
     
    30583110        if (RT_FAILURE(rc))
    30593111            return rc;
    3060         AssertLogRelMsgReturn(idOld == pThis->paNodes[idxNode].SavedState.Core.id,
    3061                               ("loaded %#x, expected %#x\n", pThis->paNodes[idxNode].SavedState.Core.id, idOld),
     3112        AssertLogRelMsgReturn(idOld == pThis->paNodes[idxNode].SavedState.Core.uID,
     3113                              ("loaded %#x, expected %#x\n", pThis->paNodes[idxNode].SavedState.Core.uID, idOld),
    30623114                              VERR_SSM_DATA_UNIT_FORMAT_CHANGED);
    30633115    }
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