VirtualBox

Changeset 31075 in vbox


Ignore:
Timestamp:
Jul 24, 2010 4:08:05 AM (15 years ago)
Author:
vboxsync
Message:

Audio/HDA: some todos & clean up.

File:
1 edited

Legend:

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

    r31062 r31075  
    6565
    6666#define STAC9220_IS_AFG_CMD(cmd) (  \
    67         CODEC_NID(cmd) == 0x1        \
    68     )
     67    CODEC_NID(cmd) == 0x1)
     68
    6969#define STAC9220_IS_PORT_CMD(cmd) (  \
    70            CODEC_NID(cmd) == 0xA    \
    71         || CODEC_NID(cmd) == 0xB    \
    72         || CODEC_NID(cmd) == 0xC    \
    73         || CODEC_NID(cmd) == 0xD    \
    74         || CODEC_NID(cmd) == 0xE    \
    75         || CODEC_NID(cmd) == 0xF    \
    76     )
     70       CODEC_NID(cmd) == 0xA    \
     71    || CODEC_NID(cmd) == 0xB    \
     72    || CODEC_NID(cmd) == 0xC    \
     73    || CODEC_NID(cmd) == 0xD    \
     74    || CODEC_NID(cmd) == 0xE    \
     75    || CODEC_NID(cmd) == 0xF)
     76
    7777#define STAC9220_IS_DAC_CMD(cmd) (  \
    78            CODEC_NID(cmd) == 0x2    \
    79         || CODEC_NID(cmd) == 0x3    \
    80         || CODEC_NID(cmd) == 0x4    \
    81         || CODEC_NID(cmd) == 0x5)
     78       CODEC_NID(cmd) == 0x2    \
     79    || CODEC_NID(cmd) == 0x3    \
     80    || CODEC_NID(cmd) == 0x4    \
     81    || CODEC_NID(cmd) == 0x5)
     82
    8283#define STAC9220_IS_ADCVOL_CMD(cmd) (   \
    8384       CODEC_NID(cmd) == 0x17           \
    8485    || CODEC_NID(cmd) == 0x18)
     86
    8587#define STAC9220_IS_ADC_CMD(cmd) (     \
    8688       CODEC_NID(cmd) == 0x6           \
    8789    || CODEC_NID(cmd) == 0x7)
     90
    8891#define STAC9220_IS_ADCMUX_CMD(cmd) (   \
    8992       CODEC_NID(cmd) == 0x12           \
    9093    || CODEC_NID(cmd) == 0x13)
    9194
     95#define STAC9220_IS_SPDIFOUT_CMD(cmd) (CODEC_NID((cmd)) == 0x8)
     96
     97#define STAC9220_IS_DIGPIN_CMD(cmd) (   \
     98       CODEC_NID((cmd)) == 0x10         \
     99    || CODEC_NID((cmd)) == 0x11)
     100
     101/* STAC9220 6.2 & 6.12 */
     102#define STAC9220_IS_RESERVED_CMD(cmd) ( \
     103       CODEC_NID((cmd)) == 0x9          \
     104    || CODEC_NID((cmd)) == 0x19         \
     105    || CODEC_NID((cmd)) == 0x1A         \
     106    || CODEC_NID((cmd)) == 0x1B)
    92107
    93108static int stac9220ResetNode(struct CODECState *pState, uint8_t nodenum, PCODECNODE pNode);
     
    98113    Log(("codecUnimplemented: cmd(raw:%x: cad:%x, d:%c, nid:%x, verb:%x)\n", cmd,
    99114        CODEC_CAD(cmd), CODEC_DIRECT(cmd) ? 'N' : 'Y', CODEC_NID(cmd), CODEC_VERBDATA(cmd)));
    100     //** @todo r=michaln: The zero used as a codec ID shouldn't be hardcoded!
    101     if (CODEC_CAD(cmd) != 0)
     115    if (CODEC_CAD(cmd) != pState->id)
    102116        //** @todo r=michaln: Are we really supposed to respond to commands sent to nonexistent codecs??
    103117        //** @todo r=michaln: Where in the specs is this response format defined?
     
    118132static int codecGetAmplifier(struct CODECState *pState, uint32_t cmd, uint64_t *pResp)
    119133{
    120     Assert((CODEC_CAD(cmd) == 0));
     134    Assert((CODEC_CAD(cmd) == pState->id));
    121135    PCODECNODE pNode = &pState->pNodes[CODEC_NID(cmd)];
    122136    if (STAC9220_IS_DAC_CMD(cmd))
     
    144158static int codecGetF00(struct CODECState *pState, uint32_t cmd, uint64_t *pResp)
    145159{
    146     Assert((CODEC_CAD(cmd) == 0));
     160    Assert((CODEC_CAD(cmd) == pState->id));
    147161    *pResp = pState->pNodes[CODEC_NID(cmd)].node.au32F00_param[cmd & CODEC_VERB_8BIT_DATA];
    148162    return VINF_SUCCESS;
     
    154168        *pResp = pState->pNodes[CODEC_NID(cmd)].port.u32F07_param;
    155169    }
    156 #if 0
    157170    else
    158171        AssertMsgFailed(("Unsupported"));
    159 #endif
    160172    return VINF_SUCCESS;
    161173}
     
    175187static int codecGetF02(struct CODECState *pState, uint32_t cmd, uint64_t *pResp)
    176188{
    177     Assert((CODEC_CAD(cmd) == 0));
     189    Assert((CODEC_CAD(cmd) == pState->id));
    178190    *pResp = *(uint32_t *)&pState->pNodes[CODEC_NID(cmd)].node.au8F02_param[cmd & CODEC_VERB_8BIT_DATA];
    179191    return VINF_SUCCESS;
     
    182194static int codecGetSubId(struct CODECState *pState, uint32_t cmd, uint64_t *pResp)
    183195{
    184     Assert((CODEC_CAD(cmd) == 0));
     196    Assert((CODEC_CAD(cmd) == pState->id));
    185197    if (STAC9220_IS_AFG_CMD(cmd))
    186198    {
     
    192204static int codecReset(struct CODECState *pState, uint32_t cmd, uint64_t *pResp)
    193205{
    194     Assert((CODEC_CAD(cmd) == 0));
     206    Assert((CODEC_CAD(cmd) == pState->id));
    195207    Assert(STAC9220_IS_AFG_CMD(cmd));
    196208    if(STAC9220_IS_AFG_CMD(cmd))
     
    212224static int codecGetPowerState(struct CODECState *pState, uint32_t cmd, uint64_t *pResp)
    213225{
    214     Assert((CODEC_CAD(cmd) == 0));
     226    Assert((CODEC_CAD(cmd) == pState->id));
    215227    if (STAC9220_IS_AFG_CMD(cmd))
    216228    {
     
    220232}
    221233#endif
    222 static int stac9220Set706(struct CODECState *pState, uint32_t cmd, uint64_t *pResp)
    223 {
    224     Assert((CODEC_CAD(cmd) == 0));
     234static int codecGetStreamId(struct CODECState *pState, uint32_t cmd, uint64_t *pResp)
     235{
     236    Assert((CODEC_CAD(cmd) == pState->id));
     237    if (STAC9220_IS_DAC_CMD(cmd))
     238        *pResp = pState->pNodes[CODEC_NID(cmd)].dac.u32F06_param;
     239    else if (STAC9220_IS_ADC_CMD(cmd))
     240        *pResp = pState->pNodes[CODEC_NID(cmd)].adc.u32F06_param;
     241    else
     242        *pResp = 0; /* STAC9220 6.20 6.13-6.18: no response supposed for this verb. */
     243    *pResp = 0;
     244    return VINF_SUCCESS;
     245}
     246static int codecSetStreamId(struct CODECState *pState, uint32_t cmd, uint64_t *pResp)
     247{
     248    Assert((CODEC_CAD(cmd) == pState->id));
    225249    if (STAC9220_IS_DAC_CMD(cmd))
    226250    {
    227251        pState->pNodes[CODEC_NID(cmd)].dac.u32F06_param &= ~CODEC_VERB_8BIT_DATA;
    228252        pState->pNodes[CODEC_NID(cmd)].dac.u32F06_param |= cmd & CODEC_VERB_8BIT_DATA;
    229 #if 0
    230         if (cmd & ((0x5) << 4))
    231         {
    232             AUD_set_active_out()
    233         }
    234 #endif
    235253    }
    236254    else if (STAC9220_IS_ADC_CMD(cmd))
     
    244262    return VINF_SUCCESS;
    245263}
     264static int codecGetConverterFormat(struct CODECState *pState, uint32_t cmd, uint64_t *pResp)
     265{
     266    Assert((CODEC_CAD(cmd) == pState->id));
     267    if (STAC9220_IS_DAC_CMD(cmd))
     268        *pResp = pState->pNodes[CODEC_NID(cmd)].dac.u32A_param;
     269    else if (STAC9220_IS_ADC_CMD(cmd))
     270        *pResp = pState->pNodes[CODEC_NID(cmd)].adc.u32A_param;
     271    else if (STAC9220_IS_SPDIFOUT_CMD(cmd))
     272        *pResp = pState->pNodes[CODEC_NID(cmd)].spdifout.u32A_param;
     273    else
     274        *pResp = 0;
     275    return VINF_SUCCESS;
     276}
    246277static int codecSetConverterFormat(struct CODECState *pState, uint32_t cmd, uint64_t *pResp)
    247278{
    248     Assert((CODEC_CAD(cmd) == 0));
     279    Assert((CODEC_CAD(cmd) == pState->id));
    249280    if (STAC9220_IS_DAC_CMD(cmd))
    250281    {
     
    257288        pState->pNodes[CODEC_NID(cmd)].adc.u32A_param |= cmd & CODEC_VERB_16BIT_DATA;
    258289    }
    259     else
    260         AssertMsgFailed(("Unsupported"));
     290    else if (STAC9220_IS_SPDIFOUT_CMD(cmd))
     291    {
     292        pState->pNodes[CODEC_NID(cmd)].spdifout.u32A_param &= ~CODEC_VERB_16BIT_DATA;
     293        pState->pNodes[CODEC_NID(cmd)].spdifout.u32A_param |= cmd & CODEC_VERB_16BIT_DATA;
     294    }
    261295    *pResp = 0;
    262296    return VINF_SUCCESS;
     
    303337        dac_init:
    304338            memset(pNode->dac.B_params, 0, AMPLIFIER_SIZE);
    305             pNode->dac.u32A_param = (0x3 << 4) | RT_BIT(0);
     339            pNode->dac.u32A_param = RT_BIT(14)|(0x1 << 3)|0x2; /* 441000Hz/16bit/2ch */
    306340
    307341            AMPLIFIER_REGISTER(pNode->dac.B_params, AMPLIFIER_OUT, AMPLIFIER_LEFT, 0) = 0x7F | RT_BIT(7);
     
    320354            pNode->node.au8F02_param[0] = 0x18;
    321355        adc_init:
    322             pNode->adc.u32A_param = (0x3<<4) | 0x1;
     356            pNode->adc.u32A_param = RT_BIT(14)|(0x1 << 3)|0x2; /* 441000Hz/16bit/2ch */
    323357            pNode->adc.node.au32F00_param[0xE] = RT_BIT(0);
    324358            pNode->adc.u32F03_param = RT_BIT(0);
     
    476510/*  -----------  --------------------   -----------------------  */
    477511    {0x000F0000, CODEC_VERB_8BIT_CMD , codecGetF00},
     512    {0x000A0000, CODEC_VERB_16BIT_CMD, codecGetConverterFormat},
    478513    {0x00020000, CODEC_VERB_16BIT_CMD, codecSetConverterFormat},
    479514    {0x000B0000, CODEC_VERB_16BIT_CMD, codecGetAmplifier },
    480     {0x00070600, CODEC_VERB_8BIT_CMD , stac9220Set706    },
    481     {0x000F0700, CODEC_VERB_8BIT_CMD , stac9220SetPinCtrl},
    482     {0x00070700, CODEC_VERB_8BIT_CMD , stac9220GetPinCtrl},
     515    {0x00070600, CODEC_VERB_8BIT_CMD , codecSetStreamId    },
     516    {0x000F0600, CODEC_VERB_8BIT_CMD , codecGetStreamId    },
     517    {0x000F0700, CODEC_VERB_8BIT_CMD , stac9220GetPinCtrl},
     518    {0x00070700, CODEC_VERB_8BIT_CMD , stac9220SetPinCtrl},
    483519    {0x000F0200, CODEC_VERB_8BIT_CMD , codecGetF02       },
    484520    {0x000F2000, CODEC_VERB_8BIT_CMD , codecGetSubId     },
     
    492528{
    493529    int rc = VINF_SUCCESS;
    494     if (   CODEC_CAD(cmd) != 0
    495         || CODEC_VERBDATA(cmd) == 0)
    496     {
    497         *pfn = CODEC_CAD(cmd) != 0 ? codecUnimplemented : codecBreak;
     530    if (   CODEC_CAD(cmd) != pState->id
     531        || CODEC_VERBDATA(cmd) == 0
     532        || CODEC_NID(cmd) >= STAC9220_NODE_COUNT
     533        || STAC9220_IS_RESERVED_CMD(cmd))
     534    {
     535        *pfn = CODEC_CAD(cmd) != pState->id ? codecUnimplemented : codecBreak;
    498536        //** @todo r=michaln: There needs to be a counter to avoid log flooding (see e.g. DevRTC.cpp)
    499537        LogRel(("HDAcodec: cmd %x was ignored\n", cmd));
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