VirtualBox

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


Ignore:
Timestamp:
Sep 29, 2010 2:11:19 AM (14 years ago)
Author:
vboxsync
Message:

Audio/HDA: verb handling is not depends on codec specific.

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

Legend:

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

    r32626 r32803  
    2222#include <iprt/mem.h>
    2323#include <iprt/asm.h>
     24#include <iprt/cpp/utils.h>
    2425
    2526#include "../Builtins.h"
     
    7374#define CODEC_SET_AMP_INDEX(cmd)             (((cmd) & CODEC_VERB_SET_AMP_INDEX) >> 7)
    7475
    75 
    76 #define STAC9220_NODE_COUNT 0x1C
    77 
    78 #define STAC9220_IS_AFG_CMD(cmd) (  \
    79     CODEC_NID(cmd) == 0x1)
    80 
    81 #define STAC9220_IS_PORT_CMD(cmd) (  \
    82        CODEC_NID(cmd) == 0xA    \
    83     || CODEC_NID(cmd) == 0xB    \
    84     || CODEC_NID(cmd) == 0xC    \
    85     || CODEC_NID(cmd) == 0xD    \
    86     || CODEC_NID(cmd) == 0xE    \
    87     || CODEC_NID(cmd) == 0xF)
    88 
    89 #define STAC9220_IS_DAC_CMD(cmd) (  \
    90        CODEC_NID(cmd) == 0x2    \
    91     || CODEC_NID(cmd) == 0x3    \
    92     || CODEC_NID(cmd) == 0x4    \
    93     || CODEC_NID(cmd) == 0x5)
    94 
    95 #define STAC9220_IS_ADCVOL_CMD(cmd) (   \
    96        CODEC_NID(cmd) == 0x17           \
    97     || CODEC_NID(cmd) == 0x18)
    98 
    99 #define STAC9220_IS_ADC_CMD(cmd) (     \
    100        CODEC_NID(cmd) == 0x6           \
    101     || CODEC_NID(cmd) == 0x7)
    102 
    103 #define STAC9220_IS_ADCMUX_CMD(cmd) (   \
    104        CODEC_NID(cmd) == 0x12           \
    105     || CODEC_NID(cmd) == 0x13)
    106 
    107 #define STAC9220_IS_PCBEEP_CMD(cmd) (CODEC_NID((cmd)) == 0x14)
    108 #define STAC9220_IS_SPDIFOUT_CMD(cmd) (CODEC_NID((cmd)) == 0x8)
    109 #define STAC9220_IS_SPDIFIN_CMD(cmd) (CODEC_NID((cmd)) == 0x9)
    110 
    111 #define STAC9220_IS_DIGINPIN_CMD(cmd) (CODEC_NID((cmd)) == 0x11)
    112 #define STAC9220_IS_DIGOUTPIN_CMD(cmd) (CODEC_NID((cmd)) == 0x10)
    113 
    114 #define STAC9220_IS_CD_CMD(cmd) (CODEC_NID((cmd)) == 0x15)
    115 
    116 #define STAC9220_IS_VOLKNOB_CMD(cmd) (CODEC_NID((cmd)) == 0x16)
    117 
    118 /* STAC9220 6.2 & 6.12 */
    119 #define STAC9220_IS_RESERVED_CMD(cmd) ( \
    120        CODEC_NID((cmd)) == 0x9          \
    121     || CODEC_NID((cmd)) == 0x19         \
    122     || CODEC_NID((cmd)) == 0x1A         \
    123     || CODEC_NID((cmd)) == 0x1B)
     76const static uint8_t au8Stac9220Ports[] = { 0xA, 0xB, 0xC, 0xD, 0xE, 0xF, 0};
     77const static uint8_t au8Stac9220Dacs[] = { 0x2, 0x3, 0x4, 0x5, 0};
     78const static uint8_t au8Stac9220Adcs[] = { 0x6, 0x7, 0};
     79const static uint8_t au8Stac9220SpdifOuts[] = { 0x8, 0 };
     80const static uint8_t au8Stac9220SpdifIns[] = { 0x9, 0 };
     81const static uint8_t au8Stac9220DigOutPins[] = { 0x10, 0 };
     82const static uint8_t au8Stac9220DigInPins[] = { 0x11, 0 };
     83const static uint8_t au8Stac9220AdcVols[] = { 0x17, 0x18, 0};
     84const static uint8_t au8Stac9220AdcMuxs[] = { 0x12, 0x13, 0};
     85const static uint8_t au8Stac9220Pcbeeps[] = { 0x14, 0 };
     86const static uint8_t au8Stac9220Cds[] = { 0x15, 0 };
     87const static uint8_t au8Stac9220VolKnobs[] = { 0x16, 0 };
     88const static uint8_t au8Stac9220Reserveds[] = { 0x9, 0x19, 0x1a, 0x1b, 0 };
    12489
    12590#define CODEC_POWER_MASK        0x3
     
    136101    }while(0)
    137102
     103#define DECLISNODEOFTYPE(type)                                                                  \
     104    static inline int codecIs##type##Node(struct CODECState *pState, uint8_t cNode)             \
     105    {                                                                                           \
     106        Assert(pState->au8##type##s);                                                           \
     107        for(int i = 0; pState->au8##type##s[i] != 0; ++i)                                       \
     108            if (pState->au8##type##s[i] == cNode)                                               \
     109                return 1;                                                                       \
     110        return 0;                                                                               \
     111    }
     112/* codecIsPortNode */
     113DECLISNODEOFTYPE(Port)
     114/* codecIsDacNode */
     115DECLISNODEOFTYPE(Dac)
     116/* codecIsAdcVolNode */
     117DECLISNODEOFTYPE(AdcVol)
     118/* codecIsAdcNode */
     119DECLISNODEOFTYPE(Adc)
     120/* codecIsAdcMuxNode */
     121DECLISNODEOFTYPE(AdcMux)
     122/* codecIsPcbeepNode */
     123DECLISNODEOFTYPE(Pcbeep)
     124/* codecIsSpdifOutNode */
     125DECLISNODEOFTYPE(SpdifOut)
     126/* codecIsSpdifInNode */
     127DECLISNODEOFTYPE(SpdifIn)
     128/* codecIsDigInPinNode */
     129DECLISNODEOFTYPE(DigInPin)
     130/* codecIsDigOutPinNode */
     131DECLISNODEOFTYPE(DigOutPin)
     132/* codecIsCdNode */
     133DECLISNODEOFTYPE(Cd)
     134/* codecIsVolKnobNode */
     135DECLISNODEOFTYPE(VolKnob)
     136/* codecIsReservedNode */
     137DECLISNODEOFTYPE(Reserved)
     138
    138139static int stac9220ResetNode(struct CODECState *pState, uint8_t nodenum, PCODECNODE pNode);
    139140static int codecToAudVolume(AMPLIFIER *pAmp, audmixerctl_t mt);
     
    175176{
    176177    Assert((CODEC_CAD(cmd) == pState->id));
    177     Assert((CODEC_NID(cmd) < STAC9220_NODE_COUNT));
    178     if (CODEC_NID(cmd) >= STAC9220_NODE_COUNT)
     178    Assert((CODEC_NID(cmd) < pState->cTotalNodes));
     179    if (CODEC_NID(cmd) >= pState->cTotalNodes)
    179180    {
    180181        Log(("HDAcodec: invalid node address %d\n", CODEC_NID(cmd)));
     
    187188
    188189    PCODECNODE pNode = &pState->pNodes[CODEC_NID(cmd)];
    189     if (STAC9220_IS_DAC_CMD(cmd))
     190    if (codecIsDacNode(pState, CODEC_NID(cmd)))
    190191        *pResp = AMPLIFIER_REGISTER(pNode->dac.B_params,
    191192                            CODEC_GET_AMP_DIRECTION(cmd),
    192193                            CODEC_GET_AMP_SIDE(cmd),
    193194                            u8Index);
    194     else if (STAC9220_IS_ADCVOL_CMD(cmd))
     195    else if (codecIsAdcVolNode(pState, CODEC_NID(cmd)))
    195196        *pResp = AMPLIFIER_REGISTER(pNode->adcvol.B_params,
    196197                            CODEC_GET_AMP_DIRECTION(cmd),
    197198                            CODEC_GET_AMP_SIDE(cmd),
    198199                            u8Index);
    199     else if (STAC9220_IS_ADCMUX_CMD(cmd))
     200    else if (codecIsAdcMuxNode(pState, CODEC_NID(cmd)))
    200201        *pResp = AMPLIFIER_REGISTER(pNode->adcmux.B_params,
    201202                            CODEC_GET_AMP_DIRECTION(cmd),
    202203                            CODEC_GET_AMP_SIDE(cmd),
    203204                            u8Index);
    204     else if (STAC9220_IS_PCBEEP_CMD(cmd))
     205    else if (codecIsPcbeepNode(pState, CODEC_NID(cmd)))
    205206        *pResp = AMPLIFIER_REGISTER(pNode->pcbeep.B_params,
    206207                            CODEC_GET_AMP_DIRECTION(cmd),
     
    222223    uint8_t u8Index = 0;
    223224    Assert((CODEC_CAD(cmd) == pState->id));
    224     if (CODEC_NID(cmd) >= STAC9220_NODE_COUNT)
     225    if (CODEC_NID(cmd) >= pState->cTotalNodes)
    225226    {
    226227        Log(("HDAcodec: invalid node address %d\n", CODEC_NID(cmd)));
     
    229230    *pResp = 0;
    230231    PCODECNODE pNode = &pState->pNodes[CODEC_NID(cmd)];
    231     if (STAC9220_IS_DAC_CMD(cmd))
     232    if (codecIsDacNode(pState, CODEC_NID(cmd)))
    232233        pAmplifier = &pNode->dac.B_params;
    233     else if (STAC9220_IS_ADCVOL_CMD(cmd))
     234    else if (codecIsAdcVolNode(pState, CODEC_NID(cmd)))
    234235        pAmplifier = &pNode->adcvol.B_params;
    235     else if (STAC9220_IS_ADCMUX_CMD(cmd))
     236    else if (codecIsAdcMuxNode(pState, CODEC_NID(cmd)))
    236237        pAmplifier = &pNode->adcmux.B_params;
    237     else if (STAC9220_IS_PCBEEP_CMD(cmd))
     238    else if (codecIsPcbeepNode(pState, CODEC_NID(cmd)))
    238239        pAmplifier = &pNode->pcbeep.B_params;
    239240    Assert(pAmplifier);
     
    273274{
    274275    Assert((CODEC_CAD(cmd) == pState->id));
    275     if (CODEC_NID(cmd) >= STAC9220_NODE_COUNT)
     276    if (CODEC_NID(cmd) >= pState->cTotalNodes)
    276277    {
    277278        Log(("HDAcodec: invalid node address %d\n", CODEC_NID(cmd)));
     
    293294{
    294295    Assert((CODEC_CAD(cmd) == pState->id));
    295     Assert((CODEC_NID(cmd) < STAC9220_NODE_COUNT));
    296     if (CODEC_NID(cmd) >= STAC9220_NODE_COUNT)
    297     {
    298         Log(("HDAcodec: invalid node address %d\n", CODEC_NID(cmd)));
    299         return VINF_SUCCESS;
    300     }
    301     *pResp = 0;
    302     if (STAC9220_IS_ADCMUX_CMD(cmd))
     296    Assert((CODEC_NID(cmd) < pState->cTotalNodes));
     297    if (CODEC_NID(cmd) >= pState->cTotalNodes)
     298    {
     299        Log(("HDAcodec: invalid node address %d\n", CODEC_NID(cmd)));
     300        return VINF_SUCCESS;
     301    }
     302    *pResp = 0;
     303    if (codecIsAdcMuxNode(pState, CODEC_NID(cmd)))
    303304        *pResp = pState->pNodes[CODEC_NID(cmd)].adcmux.u32F01_param;
    304     else if (STAC9220_IS_DIGOUTPIN_CMD(cmd))
     305    else if (codecIsDigOutPinNode(pState, CODEC_NID(cmd)))
    305306        *pResp = pState->pNodes[CODEC_NID(cmd)].digout.u32F01_param;
    306307    return VINF_SUCCESS;
     
    311312{
    312313    uint32_t *pu32Reg = NULL;
    313     Assert((CODEC_NID(cmd) < STAC9220_NODE_COUNT));
    314     if (CODEC_NID(cmd) >= STAC9220_NODE_COUNT)
    315     {
    316         Log(("HDAcodec: invalid node address %d\n", CODEC_NID(cmd)));
    317         return VINF_SUCCESS;
    318     }
    319     *pResp = 0;
    320     if (STAC9220_IS_ADCMUX_CMD(cmd))
     314    Assert((CODEC_NID(cmd) < pState->cTotalNodes));
     315    if (CODEC_NID(cmd) >= pState->cTotalNodes)
     316    {
     317        Log(("HDAcodec: invalid node address %d\n", CODEC_NID(cmd)));
     318        return VINF_SUCCESS;
     319    }
     320    *pResp = 0;
     321    if (codecIsAdcMuxNode(pState, CODEC_NID(cmd)))
    321322        pu32Reg = &pState->pNodes[CODEC_NID(cmd)].adcmux.u32F01_param;
    322     else if (STAC9220_IS_DIGOUTPIN_CMD(cmd))
     323    else if (codecIsDigOutPinNode(pState, CODEC_NID(cmd)))
    323324        pu32Reg = &pState->pNodes[CODEC_NID(cmd)].digout.u32F01_param;
    324325    Assert((pu32Reg));
     
    332333{
    333334    Assert((CODEC_CAD(cmd) == pState->id));
    334     Assert((CODEC_NID(cmd) < STAC9220_NODE_COUNT));
    335     if (CODEC_NID(cmd) >= STAC9220_NODE_COUNT)
    336     {
    337         Log(("HDAcodec: invalid node address %d\n", CODEC_NID(cmd)));
    338         return VINF_SUCCESS;
    339     }
    340     *pResp = 0;
    341     if (STAC9220_IS_PORT_CMD(cmd))
     335    Assert((CODEC_NID(cmd) < pState->cTotalNodes));
     336    if (CODEC_NID(cmd) >= pState->cTotalNodes)
     337    {
     338        Log(("HDAcodec: invalid node address %d\n", CODEC_NID(cmd)));
     339        return VINF_SUCCESS;
     340    }
     341    *pResp = 0;
     342    if (codecIsPortNode(pState, CODEC_NID(cmd)))
    342343        *pResp = pState->pNodes[CODEC_NID(cmd)].port.u32F07_param;
    343     else if (STAC9220_IS_DIGOUTPIN_CMD(cmd))
     344    else if (codecIsDigOutPinNode(pState, CODEC_NID(cmd)))
    344345        *pResp = pState->pNodes[CODEC_NID(cmd)].digout.u32F07_param;
    345     else if (STAC9220_IS_DIGINPIN_CMD(cmd))
     346    else if (codecIsDigInPinNode(pState, CODEC_NID(cmd)))
    346347        *pResp = pState->pNodes[CODEC_NID(cmd)].digin.u32F07_param;
    347     else if (STAC9220_IS_CD_CMD(cmd))
     348    else if (codecIsCdNode(pState, CODEC_NID(cmd)))
    348349        *pResp = pState->pNodes[CODEC_NID(cmd)].cdnode.u32F07_param;
    349     else if (   STAC9220_IS_RESERVED_CMD(cmd)
     350    else if (   codecIsReservedNode(pState, CODEC_NID(cmd))
    350351             && CODEC_NID(cmd) == 0x1b)
    351352        *pResp = pState->pNodes[CODEC_NID(cmd)].reserved.u32F07_param;
     
    359360{
    360361    Assert((CODEC_CAD(cmd) == pState->id));
    361     Assert((CODEC_NID(cmd) < STAC9220_NODE_COUNT));
    362     if (CODEC_NID(cmd) >= STAC9220_NODE_COUNT)
     362    Assert((CODEC_NID(cmd) < pState->cTotalNodes));
     363    if (CODEC_NID(cmd) >= pState->cTotalNodes)
    363364    {
    364365        Log(("HDAcodec: invalid node address %d\n", CODEC_NID(cmd)));
     
    367368    *pResp = 0;
    368369    uint32_t *pu32Reg = NULL;
    369     if (STAC9220_IS_PORT_CMD(cmd))
     370    if (codecIsPortNode(pState, CODEC_NID(cmd)))
    370371        pu32Reg = &pState->pNodes[CODEC_NID(cmd)].port.u32F07_param;
    371     else if (STAC9220_IS_DIGINPIN_CMD(cmd))
     372    else if (codecIsDigInPinNode(pState, CODEC_NID(cmd)))
    372373        pu32Reg = &pState->pNodes[CODEC_NID(cmd)].digin.u32F07_param;
    373     else if (STAC9220_IS_DIGOUTPIN_CMD(cmd))
     374    else if (codecIsDigOutPinNode(pState, CODEC_NID(cmd)))
    374375        pu32Reg = &pState->pNodes[CODEC_NID(cmd)].digout.u32F07_param;
    375     else if (STAC9220_IS_CD_CMD(cmd))
     376    else if (codecIsCdNode(pState, CODEC_NID(cmd)))
    376377        pu32Reg = &pState->pNodes[CODEC_NID(cmd)].cdnode.u32F07_param;
    377     else if (   STAC9220_IS_RESERVED_CMD(cmd)
     378    else if (   codecIsReservedNode(pState, CODEC_NID(cmd))
    378379             && CODEC_NID(cmd) == 0x1b)
    379380        pu32Reg = &pState->pNodes[CODEC_NID(cmd)].reserved.u32F07_param;
     
    388389{
    389390    Assert((CODEC_CAD(cmd) == pState->id));
    390     Assert((CODEC_NID(cmd) < STAC9220_NODE_COUNT));
    391     if (CODEC_NID(cmd) >= STAC9220_NODE_COUNT)
    392     {
    393         Log(("HDAcodec: invalid node address %d\n", CODEC_NID(cmd)));
    394         return VINF_SUCCESS;
    395     }
    396     *pResp = 0;
    397     if (STAC9220_IS_PORT_CMD(cmd))
     391    Assert((CODEC_NID(cmd) < pState->cTotalNodes));
     392    if (CODEC_NID(cmd) >= pState->cTotalNodes)
     393    {
     394        Log(("HDAcodec: invalid node address %d\n", CODEC_NID(cmd)));
     395        return VINF_SUCCESS;
     396    }
     397    *pResp = 0;
     398    if (codecIsPortNode(pState, CODEC_NID(cmd)))
    398399        *pResp = pState->pNodes[CODEC_NID(cmd)].port.u32F08_param;
    399     else if (STAC9220_IS_DIGINPIN_CMD(cmd))
     400    else if (codecIsDigInPinNode(pState, CODEC_NID(cmd)))
    400401        *pResp = pState->pNodes[CODEC_NID(cmd)].digin.u32F08_param;
    401     else if (STAC9220_IS_AFG_CMD(cmd))
     402    else if ((cmd) == 1 /* AFG */)
    402403        *pResp = pState->pNodes[CODEC_NID(cmd)].afg.u32F08_param;
    403     else if (STAC9220_IS_VOLKNOB_CMD(cmd))
     404    else if (codecIsVolKnobNode(pState, CODEC_NID(cmd)))
    404405        *pResp = pState->pNodes[CODEC_NID(cmd)].volumeKnob.u32F08_param;
    405406    else
     
    412413{
    413414    Assert((CODEC_CAD(cmd) == pState->id));
    414     Assert((CODEC_NID(cmd) < STAC9220_NODE_COUNT));
    415     if (CODEC_NID(cmd) >= STAC9220_NODE_COUNT)
     415    Assert((CODEC_NID(cmd) < pState->cTotalNodes));
     416    if (CODEC_NID(cmd) >= pState->cTotalNodes)
    416417    {
    417418        Log(("HDAcodec: invalid node address %d\n", CODEC_NID(cmd)));
     
    420421    *pResp = 0;
    421422    uint32_t *pu32Reg = NULL;
    422     if (STAC9220_IS_PORT_CMD(cmd))
     423    if (codecIsPortNode(pState, CODEC_NID(cmd)))
    423424        pu32Reg = &pState->pNodes[CODEC_NID(cmd)].port.u32F08_param;
    424     else if (STAC9220_IS_DIGINPIN_CMD(cmd))
     425    else if (codecIsDigInPinNode(pState, CODEC_NID(cmd)))
    425426        pu32Reg = &pState->pNodes[CODEC_NID(cmd)].digin.u32F08_param;
    426     else if (STAC9220_IS_AFG_CMD(cmd))
     427    else if (CODEC_NID(cmd) == 1 /* AFG */)
    427428        pu32Reg = &pState->pNodes[CODEC_NID(cmd)].afg.u32F08_param;
    428     else if (STAC9220_IS_VOLKNOB_CMD(cmd))
     429    else if (codecIsVolKnobNode(pState, CODEC_NID(cmd)))
    429430        pu32Reg = &pState->pNodes[CODEC_NID(cmd)].volumeKnob.u32F08_param;
    430431    else
     
    440441{
    441442    Assert((CODEC_CAD(cmd) == pState->id));
    442     Assert((CODEC_NID(cmd) < STAC9220_NODE_COUNT));
    443     if (CODEC_NID(cmd) >= STAC9220_NODE_COUNT)
    444     {
    445         Log(("HDAcodec: invalid node address %d\n", CODEC_NID(cmd)));
    446         return VINF_SUCCESS;
    447     }
    448     *pResp = 0;
    449     if (STAC9220_IS_PORT_CMD(cmd))
     443    Assert((CODEC_NID(cmd) < pState->cTotalNodes));
     444    if (CODEC_NID(cmd) >= pState->cTotalNodes)
     445    {
     446        Log(("HDAcodec: invalid node address %d\n", CODEC_NID(cmd)));
     447        return VINF_SUCCESS;
     448    }
     449    *pResp = 0;
     450    if (codecIsPortNode(pState, CODEC_NID(cmd)))
    450451        *pResp = pState->pNodes[CODEC_NID(cmd)].port.u32F09_param;
    451     else if (STAC9220_IS_DIGINPIN_CMD(cmd))
     452    else if (codecIsDigInPinNode(pState, CODEC_NID(cmd)))
    452453        *pResp = pState->pNodes[CODEC_NID(cmd)].digin.u32F09_param;
    453454    else
     
    460461{
    461462    Assert((CODEC_CAD(cmd) == pState->id));
    462     Assert((CODEC_NID(cmd) < STAC9220_NODE_COUNT));
    463     if (CODEC_NID(cmd) >= STAC9220_NODE_COUNT)
     463    Assert((CODEC_NID(cmd) < pState->cTotalNodes));
     464    if (CODEC_NID(cmd) >= pState->cTotalNodes)
    464465    {
    465466        Log(("HDAcodec: invalid node address %d\n", CODEC_NID(cmd)));
     
    469470    uint32_t *pu32Reg = NULL;
    470471    //** @todo r=michaln: Copy/paste bug? This can't be F08_parm!
    471     if (STAC9220_IS_PORT_CMD(cmd))
     472    if (codecIsPortNode(pState, CODEC_NID(cmd)))
    472473        pu32Reg = &pState->pNodes[CODEC_NID(cmd)].port.u32F08_param;
    473     else if (STAC9220_IS_DIGINPIN_CMD(cmd))
     474    else if (codecIsDigInPinNode(pState, CODEC_NID(cmd)))
    474475        pu32Reg = &pState->pNodes[CODEC_NID(cmd)].digin.u32F08_param;
    475476    Assert(pu32Reg);
     
    482483{
    483484    Assert((CODEC_CAD(cmd) == pState->id));
    484     Assert((CODEC_NID(cmd) < STAC9220_NODE_COUNT));
    485     if (CODEC_NID(cmd) >= STAC9220_NODE_COUNT)
     485    Assert((CODEC_NID(cmd) < pState->cTotalNodes));
     486    if (CODEC_NID(cmd) >= pState->cTotalNodes)
    486487    {
    487488        Log(("HDAcodec: invalid node address %d\n", CODEC_NID(cmd)));
     
    500501{
    501502    Assert((CODEC_CAD(cmd) == pState->id));
    502     Assert((CODEC_NID(cmd) < STAC9220_NODE_COUNT));
    503     if (CODEC_NID(cmd) >= STAC9220_NODE_COUNT)
    504     {
    505         Log(("HDAcodec: invalid node address %d\n", CODEC_NID(cmd)));
    506         return VINF_SUCCESS;
    507     }
    508     *pResp = 0;
    509     if (STAC9220_IS_ADC_CMD(cmd))
     503    Assert((CODEC_NID(cmd) < pState->cTotalNodes));
     504    if (CODEC_NID(cmd) >= pState->cTotalNodes)
     505    {
     506        Log(("HDAcodec: invalid node address %d\n", CODEC_NID(cmd)));
     507        return VINF_SUCCESS;
     508    }
     509    *pResp = 0;
     510    if (codecIsAdcNode(pState, CODEC_NID(cmd)))
    510511        *pResp = pState->pNodes[CODEC_NID(cmd)].adc.u32F03_param;
    511512    return VINF_SUCCESS;
     
    516517{
    517518    Assert((CODEC_CAD(cmd) == pState->id));
    518     Assert((CODEC_NID(cmd) < STAC9220_NODE_COUNT));
    519     if (CODEC_NID(cmd) >= STAC9220_NODE_COUNT)
    520     {
    521         Log(("HDAcodec: invalid node address %d\n", CODEC_NID(cmd)));
    522         return VINF_SUCCESS;
    523     }
    524     *pResp = 0;
    525     if (STAC9220_IS_ADC_CMD(cmd))
     519    Assert((CODEC_NID(cmd) < pState->cTotalNodes));
     520    if (CODEC_NID(cmd) >= pState->cTotalNodes)
     521    {
     522        Log(("HDAcodec: invalid node address %d\n", CODEC_NID(cmd)));
     523        return VINF_SUCCESS;
     524    }
     525    *pResp = 0;
     526    if (codecIsAdcNode(pState, CODEC_NID(cmd)))
    526527    {
    527528        codecSetRegisterU8(&pState->pNodes[CODEC_NID(cmd)].adc.u32F03_param, cmd, 0);
     
    534535{
    535536    Assert((CODEC_CAD(cmd) == pState->id));
    536     Assert((CODEC_NID(cmd) < STAC9220_NODE_COUNT));
    537     if (CODEC_NID(cmd) >= STAC9220_NODE_COUNT)
    538     {
    539         Log(("HDAcodec: invalid node address %d\n", CODEC_NID(cmd)));
    540         return VINF_SUCCESS;
    541     }
    542     *pResp = 0;
    543     if (STAC9220_IS_SPDIFOUT_CMD(cmd))
     537    Assert((CODEC_NID(cmd) < pState->cTotalNodes));
     538    if (CODEC_NID(cmd) >= pState->cTotalNodes)
     539    {
     540        Log(("HDAcodec: invalid node address %d\n", CODEC_NID(cmd)));
     541        return VINF_SUCCESS;
     542    }
     543    *pResp = 0;
     544    if (codecIsSpdifOutNode(pState, CODEC_NID(cmd)))
    544545        *pResp = pState->pNodes[CODEC_NID(cmd)].spdifout.u32F0d_param;
    545     else if (STAC9220_IS_SPDIFIN_CMD(cmd))
     546    else if (codecIsSpdifInNode(pState, CODEC_NID(cmd)))
    546547        *pResp = pState->pNodes[CODEC_NID(cmd)].spdifin.u32F0d_param;
    547548    return VINF_SUCCESS;
     
    551552{
    552553    Assert((CODEC_CAD(cmd) == pState->id));
    553     Assert((CODEC_NID(cmd) < STAC9220_NODE_COUNT));
    554     if (CODEC_NID(cmd) >= STAC9220_NODE_COUNT)
    555     {
    556         Log(("HDAcodec: invalid node address %d\n", CODEC_NID(cmd)));
    557         return VINF_SUCCESS;
    558     }
    559     *pResp = 0;
    560     if (STAC9220_IS_SPDIFOUT_CMD(cmd))
     554    Assert((CODEC_NID(cmd) < pState->cTotalNodes));
     555    if (CODEC_NID(cmd) >= pState->cTotalNodes)
     556    {
     557        Log(("HDAcodec: invalid node address %d\n", CODEC_NID(cmd)));
     558        return VINF_SUCCESS;
     559    }
     560    *pResp = 0;
     561    if (codecIsSpdifOutNode(pState, CODEC_NID(cmd)))
    561562        codecSetRegisterU8(&pState->pNodes[CODEC_NID(cmd)].spdifout.u32F0d_param, cmd, u8Offset);
    562     else if (STAC9220_IS_SPDIFIN_CMD(cmd))
     563    else if (codecIsSpdifInNode(pState, CODEC_NID(cmd)))
    563564        codecSetRegisterU8(&pState->pNodes[CODEC_NID(cmd)].spdifin.u32F0d_param, cmd, u8Offset);
    564565    return VINF_SUCCESS;
     
    580581{
    581582    Assert((CODEC_CAD(cmd) == pState->id));
    582     Assert((CODEC_NID(cmd) < STAC9220_NODE_COUNT));
    583     if (CODEC_NID(cmd) >= STAC9220_NODE_COUNT)
    584     {
    585         Log(("HDAcodec: invalid node address %d\n", CODEC_NID(cmd)));
    586         return VINF_SUCCESS;
    587     }
    588     *pResp = 0;
    589     if (STAC9220_IS_AFG_CMD(cmd))
     583    Assert((CODEC_NID(cmd) < pState->cTotalNodes));
     584    if (CODEC_NID(cmd) >= pState->cTotalNodes)
     585    {
     586        Log(("HDAcodec: invalid node address %d\n", CODEC_NID(cmd)));
     587        return VINF_SUCCESS;
     588    }
     589    *pResp = 0;
     590    if (CODEC_NID(cmd) == 1 /* AFG */)
    590591    {
    591592        *pResp = pState->pNodes[CODEC_NID(cmd)].afg.u32F20_param;
     
    597598{
    598599    Assert((CODEC_CAD(cmd) == pState->id));
    599     Assert(STAC9220_IS_AFG_CMD(cmd));
    600     if(STAC9220_IS_AFG_CMD(cmd))
     600    Assert(CODEC_NID(cmd) == 1 /* AFG */);
     601    if(CODEC_NID(cmd) == 1 /* AFG */)
    601602    {
    602603        uint8_t i;
    603604        Log(("HDAcodec: enters reset\n"));
    604         for (i = 0; i < STAC9220_NODE_COUNT; ++i)
     605        for (i = 0; i < pState->cTotalNodes; ++i)
    605606        {
    606607            stac9220ResetNode(pState, i, &pState->pNodes[i]);
     
    617618{
    618619    Assert((CODEC_CAD(cmd) == pState->id));
    619     Assert((CODEC_NID(cmd) < STAC9220_NODE_COUNT));
    620     if (CODEC_NID(cmd) >= STAC9220_NODE_COUNT)
    621     {
    622         Log(("HDAcodec: invalid node address %d\n", CODEC_NID(cmd)));
    623         return VINF_SUCCESS;
    624     }
    625     *pResp = 0;
    626     if (STAC9220_IS_AFG_CMD(cmd))
     620    Assert((CODEC_NID(cmd) < pState->cTotalNodes));
     621    if (CODEC_NID(cmd) >= pState->cTotalNodes)
     622    {
     623        Log(("HDAcodec: invalid node address %d\n", CODEC_NID(cmd)));
     624        return VINF_SUCCESS;
     625    }
     626    *pResp = 0;
     627    if (CODEC_NID(cmd) == 1 /* AFG */)
    627628        *pResp = pState->pNodes[CODEC_NID(cmd)].afg.u32F05_param;
    628     else if (STAC9220_IS_DAC_CMD(cmd))
     629    else if (codecIsDacNode(pState, CODEC_NID(cmd)))
    629630        *pResp = pState->pNodes[CODEC_NID(cmd)].dac.u32F05_param;
    630     else if (STAC9220_IS_DIGINPIN_CMD(cmd))
     631    else if (codecIsDigInPinNode(pState, CODEC_NID(cmd)))
    631632        *pResp = pState->pNodes[CODEC_NID(cmd)].digin.u32F05_param;
    632     else if (STAC9220_IS_ADC_CMD(cmd))
     633    else if (codecIsAdcNode(pState, CODEC_NID(cmd)))
    633634        *pResp = pState->pNodes[CODEC_NID(cmd)].adc.u32F05_param;
    634635    return VINF_SUCCESS;
     
    639640{
    640641    Assert((CODEC_CAD(cmd) == pState->id));
    641     Assert((CODEC_NID(cmd) < STAC9220_NODE_COUNT));
    642     if (CODEC_NID(cmd) >= STAC9220_NODE_COUNT)
     642    Assert((CODEC_NID(cmd) < pState->cTotalNodes));
     643    if (CODEC_NID(cmd) >= pState->cTotalNodes)
    643644    {
    644645        Log(("HDAcodec: invalid node address %d\n", CODEC_NID(cmd)));
     
    647648    uint32_t *pu32Reg = NULL;
    648649    *pResp = 0;
    649     if (STAC9220_IS_AFG_CMD(cmd))
     650    if (CODEC_NID(cmd) == 1 /* AFG */)
    650651        pu32Reg = &pState->pNodes[CODEC_NID(cmd)].afg.u32F05_param;
    651     else if (STAC9220_IS_DAC_CMD(cmd))
     652    else if (codecIsDacNode(pState, CODEC_NID(cmd)))
    652653        pu32Reg = &pState->pNodes[CODEC_NID(cmd)].dac.u32F05_param;
    653     else if (STAC9220_IS_DIGINPIN_CMD(cmd))
     654    else if (codecIsDigInPinNode(pState, CODEC_NID(cmd)))
    654655        pu32Reg = &pState->pNodes[CODEC_NID(cmd)].digin.u32F05_param;
    655     else if (STAC9220_IS_ADC_CMD(cmd))
     656    else if (codecIsAdcNode(pState, CODEC_NID(cmd)))
    656657        pu32Reg = &pState->pNodes[CODEC_NID(cmd)].adc.u32F05_param;
    657658    Assert((pu32Reg));
     
    659660        return VINF_SUCCESS;
    660661
    661     if (!STAC9220_IS_AFG_CMD(cmd))
     662    if (!CODEC_NID(cmd) == 1 /* AFG */)
    662663    {
    663664        *pu32Reg &= ~CODEC_VERB_8BIT_DATA;
     
    669670    *pu32Reg |= cmd & CODEC_VERB_4BIT_DATA;
    670671    /* Propogate next power state only if AFG is on or verb modifies AFG power state */
    671     if (   STAC9220_IS_AFG_CMD(cmd)
     672    if (   CODEC_NID(cmd) == 1 /* AFG */
    672673        || !pState->pNodes[1].afg.u32F05_param)
    673674    {
    674675        *pu32Reg &= ~(CODEC_POWER_MASK << CODEC_POWER_ACT_SHIFT);
    675676        *pu32Reg |= (cmd & CODEC_VERB_4BIT_DATA) << 4;
    676         if (   STAC9220_IS_AFG_CMD(cmd)
     677        if (   CODEC_NID(cmd) == 1 /* AFG */
    677678            && (cmd & CODEC_POWER_MASK) == CODEC_POWER_D0)
    678679        {
     
    692693{
    693694    Assert((CODEC_CAD(cmd) == pState->id));
    694     Assert((CODEC_NID(cmd) < STAC9220_NODE_COUNT));
    695     if (CODEC_NID(cmd) >= STAC9220_NODE_COUNT)
    696     {
    697         Log(("HDAcodec: invalid node address %d\n", CODEC_NID(cmd)));
    698         return VINF_SUCCESS;
    699     }
    700     *pResp = 0;
    701     if (STAC9220_IS_DAC_CMD(cmd))
     695    Assert((CODEC_NID(cmd) < pState->cTotalNodes));
     696    if (CODEC_NID(cmd) >= pState->cTotalNodes)
     697    {
     698        Log(("HDAcodec: invalid node address %d\n", CODEC_NID(cmd)));
     699        return VINF_SUCCESS;
     700    }
     701    *pResp = 0;
     702    if (codecIsDacNode(pState, CODEC_NID(cmd)))
    702703        *pResp = pState->pNodes[CODEC_NID(cmd)].dac.u32F06_param;
    703     else if (STAC9220_IS_ADC_CMD(cmd))
     704    else if (codecIsAdcNode(pState, CODEC_NID(cmd)))
    704705        *pResp = pState->pNodes[CODEC_NID(cmd)].adc.u32F06_param;
    705     else if (STAC9220_IS_SPDIFIN_CMD(cmd))
     706    else if (codecIsSpdifInNode(pState, CODEC_NID(cmd)))
    706707        *pResp = pState->pNodes[CODEC_NID(cmd)].spdifin.u32F06_param;
    707     else if (STAC9220_IS_SPDIFOUT_CMD(cmd))
     708    else if (codecIsSpdifOutNode(pState, CODEC_NID(cmd)))
    708709        *pResp = pState->pNodes[CODEC_NID(cmd)].spdifout.u32F06_param;
     710    else if (CODEC_NID(cmd) == 0x1A)
     711        *pResp = pState->pNodes[CODEC_NID(cmd)].reserved.u32F06_param;
    709712    return VINF_SUCCESS;
    710713}
     
    712715{
    713716    Assert((CODEC_CAD(cmd) == pState->id));
    714     Assert((CODEC_NID(cmd) < STAC9220_NODE_COUNT));
    715     if (CODEC_NID(cmd) >= STAC9220_NODE_COUNT)
     717    Assert((CODEC_NID(cmd) < pState->cTotalNodes));
     718    if (CODEC_NID(cmd) >= pState->cTotalNodes)
    716719    {
    717720        Log(("HDAcodec: invalid node address %d\n", CODEC_NID(cmd)));
     
    721724    uint32_t *pu32addr = NULL;
    722725    *pResp = 0;
    723     if (STAC9220_IS_DAC_CMD(cmd))
     726    if (codecIsDacNode(pState, CODEC_NID(cmd)))
    724727        pu32addr = &pState->pNodes[CODEC_NID(cmd)].dac.u32F06_param;
    725     else if (STAC9220_IS_ADC_CMD(cmd))
     728    else if (codecIsAdcNode(pState, CODEC_NID(cmd)))
    726729        pu32addr = &pState->pNodes[CODEC_NID(cmd)].adc.u32F06_param;
    727     else if (STAC9220_IS_SPDIFOUT_CMD(cmd))
     730    else if (codecIsSpdifOutNode(pState, CODEC_NID(cmd)))
    728731        pu32addr = &pState->pNodes[CODEC_NID(cmd)].spdifout.u32F06_param;
    729     else if (STAC9220_IS_SPDIFIN_CMD(cmd))
     732    else if (codecIsSpdifInNode(pState, CODEC_NID(cmd)))
    730733        pu32addr = &pState->pNodes[CODEC_NID(cmd)].spdifin.u32F06_param;
     734    else if (codecIsReservedNode(pState, CODEC_NID(cmd)))
     735        pu32addr = &pState->pNodes[CODEC_NID(cmd)].reserved.u32F06_param;
    731736    Assert((pu32addr));
    732737    if (pu32addr)
     
    737742{
    738743    Assert((CODEC_CAD(cmd) == pState->id));
    739     Assert((CODEC_NID(cmd) < STAC9220_NODE_COUNT));
    740     if (CODEC_NID(cmd) >= STAC9220_NODE_COUNT)
    741     {
    742         Log(("HDAcodec: invalid node address %d\n", CODEC_NID(cmd)));
    743         return VINF_SUCCESS;
    744     }
    745     *pResp = 0;
    746     if (STAC9220_IS_DAC_CMD(cmd))
     744    Assert((CODEC_NID(cmd) < pState->cTotalNodes));
     745    if (CODEC_NID(cmd) >= pState->cTotalNodes)
     746    {
     747        Log(("HDAcodec: invalid node address %d\n", CODEC_NID(cmd)));
     748        return VINF_SUCCESS;
     749    }
     750    *pResp = 0;
     751    if (codecIsDacNode(pState, CODEC_NID(cmd)))
    747752        *pResp = pState->pNodes[CODEC_NID(cmd)].dac.u32A_param;
    748     else if (STAC9220_IS_ADC_CMD(cmd))
     753    else if (codecIsAdcNode(pState, CODEC_NID(cmd)))
    749754        *pResp = pState->pNodes[CODEC_NID(cmd)].adc.u32A_param;
    750     else if (STAC9220_IS_SPDIFOUT_CMD(cmd))
     755    else if (codecIsSpdifOutNode(pState, CODEC_NID(cmd)))
    751756        *pResp = pState->pNodes[CODEC_NID(cmd)].spdifout.u32A_param;
    752     else if (STAC9220_IS_SPDIFIN_CMD(cmd))
     757    else if (codecIsSpdifInNode(pState, CODEC_NID(cmd)))
    753758        *pResp = pState->pNodes[CODEC_NID(cmd)].spdifin.u32A_param;
    754759    return VINF_SUCCESS;
     
    758763{
    759764    Assert((CODEC_CAD(cmd) == pState->id));
    760     Assert((CODEC_NID(cmd) < STAC9220_NODE_COUNT));
    761     if (CODEC_NID(cmd) >= STAC9220_NODE_COUNT)
    762     {
    763         Log(("HDAcodec: invalid node address %d\n", CODEC_NID(cmd)));
    764         return VINF_SUCCESS;
    765     }
    766     *pResp = 0;
    767     if (STAC9220_IS_DAC_CMD(cmd))
     765    Assert((CODEC_NID(cmd) < pState->cTotalNodes));
     766    if (CODEC_NID(cmd) >= pState->cTotalNodes)
     767    {
     768        Log(("HDAcodec: invalid node address %d\n", CODEC_NID(cmd)));
     769        return VINF_SUCCESS;
     770    }
     771    *pResp = 0;
     772    if (codecIsDacNode(pState, CODEC_NID(cmd)))
    768773        codecSetRegisterU16(&pState->pNodes[CODEC_NID(cmd)].dac.u32A_param, cmd, 0);
    769     else if (STAC9220_IS_ADC_CMD(cmd))
     774    else if (codecIsAdcNode(pState, CODEC_NID(cmd)))
    770775        codecSetRegisterU16(&pState->pNodes[CODEC_NID(cmd)].adc.u32A_param, cmd, 0);
    771     else if (STAC9220_IS_SPDIFOUT_CMD(cmd))
     776    else if (codecIsSpdifOutNode(pState, CODEC_NID(cmd)))
    772777        codecSetRegisterU16(&pState->pNodes[CODEC_NID(cmd)].spdifout.u32A_param, cmd, 0);
    773     else if (STAC9220_IS_SPDIFIN_CMD(cmd))
     778    else if (codecIsSpdifInNode(pState, CODEC_NID(cmd)))
    774779        codecSetRegisterU16(&pState->pNodes[CODEC_NID(cmd)].spdifin.u32A_param, cmd, 0);
    775780    return VINF_SUCCESS;
     
    780785{
    781786    Assert((CODEC_CAD(cmd) == pState->id));
    782     Assert((CODEC_NID(cmd) < STAC9220_NODE_COUNT));
    783     if (CODEC_NID(cmd) >= STAC9220_NODE_COUNT)
    784     {
    785         Log(("HDAcodec: invalid node address %d\n", CODEC_NID(cmd)));
    786         return VINF_SUCCESS;
    787     }
    788     *pResp = 0;
    789     if (STAC9220_IS_ADCVOL_CMD(cmd))
     787    Assert((CODEC_NID(cmd) < pState->cTotalNodes));
     788    if (CODEC_NID(cmd) >= pState->cTotalNodes)
     789    {
     790        Log(("HDAcodec: invalid node address %d\n", CODEC_NID(cmd)));
     791        return VINF_SUCCESS;
     792    }
     793    *pResp = 0;
     794    if (codecIsAdcVolNode(pState, CODEC_NID(cmd)))
    790795        *pResp = pState->pNodes[CODEC_NID(cmd)].adcvol.u32F0c_param;
    791     else if (STAC9220_IS_DAC_CMD(cmd))
     796    else if (codecIsDacNode(pState, CODEC_NID(cmd)))
    792797        *pResp = pState->pNodes[CODEC_NID(cmd)].dac.u32F0c_param;
    793     else if (STAC9220_IS_DIGINPIN_CMD(cmd))
     798    else if (codecIsDigInPinNode(pState, CODEC_NID(cmd)))
    794799        *pResp = pState->pNodes[CODEC_NID(cmd)].digin.u32F0c_param;
    795800    return VINF_SUCCESS;
     
    800805{
    801806    Assert((CODEC_CAD(cmd) == pState->id));
    802     Assert((CODEC_NID(cmd) < STAC9220_NODE_COUNT));
    803     if (CODEC_NID(cmd) >= STAC9220_NODE_COUNT)
     807    Assert((CODEC_NID(cmd) < pState->cTotalNodes));
     808    if (CODEC_NID(cmd) >= pState->cTotalNodes)
    804809    {
    805810        Log(("HDAcodec: invalid node address %d\n", CODEC_NID(cmd)));
     
    808813    *pResp = 0;
    809814    uint32_t *pu32Reg = NULL;
    810     if (STAC9220_IS_ADCVOL_CMD(cmd))
     815    if (codecIsAdcVolNode(pState, CODEC_NID(cmd)))
    811816        pu32Reg = &pState->pNodes[CODEC_NID(cmd)].adcvol.u32F0c_param;
    812     else if (STAC9220_IS_DAC_CMD(cmd))
     817    else if (codecIsDacNode(pState, CODEC_NID(cmd)))
    813818        pu32Reg = &pState->pNodes[CODEC_NID(cmd)].dac.u32F0c_param;
    814     else if (STAC9220_IS_DIGINPIN_CMD(cmd))
     819    else if (codecIsDigInPinNode(pState, CODEC_NID(cmd)))
    815820        pu32Reg = &pState->pNodes[CODEC_NID(cmd)].digin.u32F0c_param;
    816821    *pResp = 0;
     
    825830{
    826831    Assert((CODEC_CAD(cmd) == pState->id));
    827     Assert((CODEC_NID(cmd) < STAC9220_NODE_COUNT));
    828     if (CODEC_NID(cmd) >= STAC9220_NODE_COUNT)
    829     {
    830         Log(("HDAcodec: invalid node address %d\n", CODEC_NID(cmd)));
    831         return VINF_SUCCESS;
    832     }
    833     *pResp = 0;
    834     if (STAC9220_IS_VOLKNOB_CMD(cmd))
     832    Assert((CODEC_NID(cmd) < pState->cTotalNodes));
     833    if (CODEC_NID(cmd) >= pState->cTotalNodes)
     834    {
     835        Log(("HDAcodec: invalid node address %d\n", CODEC_NID(cmd)));
     836        return VINF_SUCCESS;
     837    }
     838    *pResp = 0;
     839    if (codecIsVolKnobNode(pState, CODEC_NID(cmd)))
    835840        *pResp = pState->pNodes[CODEC_NID(cmd)].volumeKnob.u32F0f_param;
    836841    return VINF_SUCCESS;
     
    841846{
    842847    Assert((CODEC_CAD(cmd) == pState->id));
    843     Assert((CODEC_NID(cmd) < STAC9220_NODE_COUNT));
    844     if (CODEC_NID(cmd) >= STAC9220_NODE_COUNT)
     848    Assert((CODEC_NID(cmd) < pState->cTotalNodes));
     849    if (CODEC_NID(cmd) >= pState->cTotalNodes)
    845850    {
    846851        Log(("HDAcodec: invalid node address %d\n", CODEC_NID(cmd)));
     
    849854    uint32_t *pu32Reg = NULL;
    850855    *pResp = 0;
    851     if (STAC9220_IS_VOLKNOB_CMD(cmd))
     856    if (codecIsVolKnobNode(pState, CODEC_NID(cmd)))
    852857        pu32Reg = &pState->pNodes[CODEC_NID(cmd)].volumeKnob.u32F0f_param;
    853858    Assert((pu32Reg));
     
    861866{
    862867    Assert((CODEC_CAD(cmd) == pState->id));
    863     Assert((CODEC_NID(cmd) < STAC9220_NODE_COUNT));
    864     if (CODEC_NID(cmd) >= STAC9220_NODE_COUNT)
    865     {
    866         Log(("HDAcodec: invalid node address %d\n", CODEC_NID(cmd)));
    867         return VINF_SUCCESS;
    868     }
    869     *pResp = 0;
    870     if (STAC9220_IS_PORT_CMD(cmd))
     868    Assert((CODEC_NID(cmd) < pState->cTotalNodes));
     869    if (CODEC_NID(cmd) >= pState->cTotalNodes)
     870    {
     871        Log(("HDAcodec: invalid node address %d\n", CODEC_NID(cmd)));
     872        return VINF_SUCCESS;
     873    }
     874    *pResp = 0;
     875    if (codecIsPortNode(pState, CODEC_NID(cmd)))
    871876        *pResp = pState->pNodes[CODEC_NID(cmd)].port.u32F1c_param;
    872     else if (STAC9220_IS_DIGOUTPIN_CMD(cmd))
     877    else if (codecIsDigOutPinNode(pState, CODEC_NID(cmd)))
    873878        *pResp = pState->pNodes[CODEC_NID(cmd)].digout.u32F1c_param;
    874     else if (STAC9220_IS_DIGINPIN_CMD(cmd))
     879    else if (codecIsDigInPinNode(pState, CODEC_NID(cmd)))
    875880        *pResp = pState->pNodes[CODEC_NID(cmd)].digin.u32F1c_param;
    876     else if (STAC9220_IS_CD_CMD(cmd))
     881    else if (codecIsCdNode(pState, CODEC_NID(cmd)))
    877882        *pResp = pState->pNodes[CODEC_NID(cmd)].cdnode.u32F1c_param;
    878883    return VINF_SUCCESS;
     
    881886{
    882887    Assert((CODEC_CAD(cmd) == pState->id));
    883     Assert((CODEC_NID(cmd) < STAC9220_NODE_COUNT));
    884     if (CODEC_NID(cmd) >= STAC9220_NODE_COUNT)
     888    Assert((CODEC_NID(cmd) < pState->cTotalNodes));
     889    if (CODEC_NID(cmd) >= pState->cTotalNodes)
    885890    {
    886891        Log(("HDAcodec: invalid node address %d\n", CODEC_NID(cmd)));
     
    888893    }
    889894    uint32_t *pu32Reg = NULL;
    890     if (STAC9220_IS_PORT_CMD(cmd))
     895    if (codecIsPortNode(pState, CODEC_NID(cmd)))
    891896        pu32Reg = &pState->pNodes[CODEC_NID(cmd)].port.u32F1c_param;
    892     else if (STAC9220_IS_DIGINPIN_CMD(cmd))
     897    else if (codecIsDigInPinNode(pState, CODEC_NID(cmd)))
    893898        pu32Reg = &pState->pNodes[CODEC_NID(cmd)].digin.u32F1c_param;
    894     else if (STAC9220_IS_DIGOUTPIN_CMD(cmd))
     899    else if (codecIsDigOutPinNode(pState, CODEC_NID(cmd)))
    895900        pu32Reg = &pState->pNodes[CODEC_NID(cmd)].digout.u32F1c_param;
    896     else if (STAC9220_IS_CD_CMD(cmd))
     901    else if (codecIsCdNode(pState, CODEC_NID(cmd)))
    897902        pu32Reg = &pState->pNodes[CODEC_NID(cmd)].cdnode.u32F1c_param;
    898903    else if (CODEC_NID(cmd) == 0x1B)
     
    12501255    int rc = VINF_SUCCESS;
    12511256    Assert(CODEC_CAD(cmd) == pState->id);
    1252     if (STAC9220_IS_RESERVED_CMD(cmd))
     1257    if (codecIsReservedNode(pState, CODEC_NID(cmd)))
    12531258    {
    12541259        LogRel(("HDAcodec: cmd %x was addressed to reseved node\n", cmd));
    12551260    }
    12561261    if (   CODEC_VERBDATA(cmd) == 0
    1257         || CODEC_NID(cmd) >= STAC9220_NODE_COUNT)
     1262        || CODEC_NID(cmd) >= pState->cTotalNodes)
    12581263    {
    12591264        *pfn = codecUnimplemented;
     
    13111316    pState->cVerbs = sizeof(STAC9220VERB)/sizeof(CODECVERB);
    13121317    pState->pfnLookup = codecLookup;
    1313     pState->pNodes = (PCODECNODE)RTMemAllocZ(sizeof(CODECNODE) * STAC9220_NODE_COUNT);
     1318    unconst(pState->cTotalNodes) = 0x1C;
     1319    pState->pNodes = (PCODECNODE)RTMemAllocZ(sizeof(CODECNODE) * pState->cTotalNodes);
    13141320    pState->fInReset = false;
     1321#define STAC9220WIDGET(type) pState->au8##type##s = au8Stac9220##type##s
     1322    STAC9220WIDGET(Port);
     1323    STAC9220WIDGET(Dac);
     1324    STAC9220WIDGET(Adc);
     1325    STAC9220WIDGET(AdcVol);
     1326    STAC9220WIDGET(AdcMux);
     1327    STAC9220WIDGET(Pcbeep);
     1328    STAC9220WIDGET(SpdifIn);
     1329    STAC9220WIDGET(SpdifOut);
     1330    STAC9220WIDGET(DigInPin);
     1331    STAC9220WIDGET(DigOutPin);
     1332    STAC9220WIDGET(Cd);
     1333    STAC9220WIDGET(VolKnob);
     1334    STAC9220WIDGET(Reserved);
     1335#undef STAC9220WIDGET
     1336   
    13151337    uint8_t i;
    1316     for (i = 0; i < STAC9220_NODE_COUNT; ++i)
     1338    for (i = 0; i < pState->cTotalNodes; ++i)
    13171339    {
    13181340        stac9220ResetNode(pState, i, &pState->pNodes[i]);
     
    13361358    codecToAudVolume(&pState->pNodes[2].dac.B_params, AUD_MIXER_VOLUME);
    13371359    codecToAudVolume(&pState->pNodes[0x17].adcvol.B_params, AUD_MIXER_LINE_IN);
     1360
    13381361    return VINF_SUCCESS;
    13391362}
     
    13461369int stac9220SaveState(CODECState *pCodecState, PSSMHANDLE pSSMHandle)
    13471370{
    1348     SSMR3PutMem (pSSMHandle, pCodecState->pNodes, sizeof(CODECNODE) * STAC9220_NODE_COUNT);
     1371    SSMR3PutMem (pSSMHandle, pCodecState->pNodes, sizeof(CODECNODE) * pCodecState->cTotalNodes);
    13491372    return VINF_SUCCESS;
    13501373}
    13511374int stac9220LoadState(CODECState *pCodecState, PSSMHANDLE pSSMHandle)
    13521375{
    1353     SSMR3GetMem (pSSMHandle, pCodecState->pNodes, sizeof(CODECNODE) * STAC9220_NODE_COUNT);
     1376    SSMR3GetMem (pSSMHandle, pCodecState->pNodes, sizeof(CODECNODE) * pCodecState->cTotalNodes);
    13541377    codecToAudVolume(&pCodecState->pNodes[2].dac.B_params, AUD_MIXER_VOLUME);
    13551378    codecToAudVolume(&pCodecState->pNodes[0x17].adcvol.B_params, AUD_MIXER_LINE_IN);
  • trunk/src/VBox/Devices/Audio/DevCodec.h

    r32626 r32803  
    187187    CODECCOMMONNODE node;
    188188    uint32_t    u32F07_param;
     189    uint32_t    u32F06_param;
    189190    uint32_t    u32F1c_param;
    190191} RESNODE, *PRESNODE;
     
    233234    void                    *pHDAState;
    234235    bool                    fInReset;
     236    const uint8_t           cTotalNodes;
     237    const uint8_t           *au8Ports;
     238    const uint8_t           *au8Dacs;
     239    const uint8_t           *au8AdcVols;
     240    const uint8_t           *au8Adcs;
     241    const uint8_t           *au8AdcMuxs;
     242    const uint8_t           *au8Pcbeeps;
     243    const uint8_t           *au8SpdifIns;
     244    const uint8_t           *au8SpdifOuts;
     245    const uint8_t           *au8DigInPins;
     246    const uint8_t           *au8DigOutPins;
     247    const uint8_t           *au8Cds;
     248    const uint8_t           *au8VolKnobs;
     249    const uint8_t           *au8Reserveds;
    235250    DECLR3CALLBACKMEMBER(int, pfnProcess, (struct CODECState *));
    236251    DECLR3CALLBACKMEMBER(int, pfnLookup, (struct CODECState *pState, uint32_t verb, PPFNCODECVERBPROCESSOR));
    237252    DECLR3CALLBACKMEMBER(int, pfnReset, (struct CODECState *pState));
    238253    DECLR3CALLBACKMEMBER(void, pfnTransfer, (struct CODECState *pState, ENMSOUNDSOURCE, int avail));
     254
    239255} CODECState;
     256
    240257
    241258int stac9220Construct(CODECState *pCodecState);
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