VirtualBox

Changeset 67929 in vbox


Ignore:
Timestamp:
Jul 12, 2017 11:58:26 AM (7 years ago)
Author:
vboxsync
Message:

Audio/DevIchAc97.cpp: A bit of renaming, comments and LogRel2 logging for unimplemented stuff.

File:
1 edited

Legend:

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

    r67928 r67929  
    17331733static int ichac97MixerSetVolume(PAC97STATE pThis, int index, PDMAUDIOMIXERCTL enmMixerCtl, uint32_t uVal)
    17341734{
    1735     bool    fCntlMuted;
    1736     uint8_t lCntlAtt, rCntlAtt;
    1737 
    17381735    /*
    17391736     * From AC'97 SoundMax Codec AD1981A/AD1981B:
     
    17461743     */
    17471744    /// @todo Does this apply to anything other than the master volume control?
    1748     if (uVal & RT_BIT(5))
     1745    if (uVal & RT_BIT(5))  /* D5 bit set? */
    17491746        uVal |= RT_BIT(4) | RT_BIT(3) | RT_BIT(2) | RT_BIT(1) | RT_BIT(0);
    1750     if (uVal & RT_BIT(13))
     1747    if (uVal & RT_BIT(13)) /* D13 bit set? */
    17511748        uVal |= RT_BIT(12) | RT_BIT(11) | RT_BIT(10) | RT_BIT(9) | RT_BIT(8);
    17521749
    1753     fCntlMuted = (uVal >> AC97_BARS_VOL_MUTE_SHIFT) & 1;
    1754     lCntlAtt   = (uVal >> 8) & AC97_BARS_VOL_MASK;
    1755     rCntlAtt  = uVal & AC97_BARS_VOL_MASK;
     1750    const bool    fCtlMuted    = (uVal >> AC97_BARS_VOL_MUTE_SHIFT) & 1;
     1751          uint8_t uCtlAttLeft  = (uVal >> 8) & AC97_BARS_VOL_MASK;
     1752          uint8_t uCtlAttRight = uVal & AC97_BARS_VOL_MASK;
    17561753
    17571754    /* For the master and headphone volume, 0 corresponds to 0dB attenuation. For the other
     
    17621759#ifndef VBOX_WITH_AC97_GAIN_SUPPORT
    17631760        /* NB: Currently there is no gain support, only attenuation. */
    1764         lCntlAtt = lCntlAtt < 8 ? 0 : lCntlAtt - 8;
    1765         rCntlAtt = rCntlAtt < 8 ? 0 : rCntlAtt - 8;
     1761        uCtlAttLeft  = uCtlAttLeft  < 8 ? 0 : uCtlAttLeft - 8;
     1762        uCtlAttRight = uCtlAttRight < 8 ? 0 : uCtlAttRight - 8;
    17661763#endif
    17671764    }
    1768     Assert(lCntlAtt <= 255 / AC97_DB_FACTOR);
    1769     Assert(rCntlAtt <= 255 / AC97_DB_FACTOR);
     1765    Assert(uCtlAttLeft <= 255 / AC97_DB_FACTOR);
     1766    Assert(uCtlAttRight <= 255 / AC97_DB_FACTOR);
    17701767
    17711768    LogFunc(("index=0x%x, uVal=%RU32, enmMixerCtl=%RU32\n", index, uVal, enmMixerCtl));
    1772     LogFunc(("lAtt=%RU8, rAtt=%RU8 ", lCntlAtt, rCntlAtt));
     1769    LogFunc(("uCtlAttLeft=%RU8, uCtlAttRight=%RU8 ", uCtlAttLeft, uCtlAttRight));
    17731770
    17741771    /*
     
    17771774     * steps, each -0.375dB, where 0 corresponds to -96dB and 255 corresponds to 0dB.
    17781775     */
    1779     uint8_t lVol = PDMAUDIO_VOLUME_MAX - lCntlAtt * AC97_DB_FACTOR;
    1780     uint8_t rVol = PDMAUDIO_VOLUME_MAX - rCntlAtt * AC97_DB_FACTOR;
    1781 
    1782     Log(("-> fMuted=%RTbool, lVol=%RU8, rVol=%RU8\n", fCntlMuted, lVol, rVol));
     1776    uint8_t lVol = PDMAUDIO_VOLUME_MAX - uCtlAttLeft * AC97_DB_FACTOR;
     1777    uint8_t rVol = PDMAUDIO_VOLUME_MAX - uCtlAttRight * AC97_DB_FACTOR;
     1778
     1779    Log(("-> fMuted=%RTbool, lVol=%RU8, rVol=%RU8\n", fCtlMuted, lVol, rVol));
    17831780
    17841781    int rc = VINF_SUCCESS;
     
    17861783    if (pThis->pMixer) /* Device can be in reset state, so no mixer available. */
    17871784    {
    1788         PDMAUDIOVOLUME Vol   = { fCntlMuted, lVol, rVol };
     1785        PDMAUDIOVOLUME Vol   = { fCtlMuted, lVol, rVol };
    17891786        PAUDMIXSINK    pSink = NULL;
    17901787
     
    19701967    ichac97MixerRecordSelect(pThis, 0);
    19711968
     1969    /* The default value is 8000h, which corresponds to 0 dB attenuation with mute on. */
    19721970    ichac97MixerSetVolume(pThis, AC97_Master_Volume_Mute,  PDMAUDIOMIXERCTL_VOLUME_MASTER, 0x8000);
     1971
     1972    /* The default value for stereo registers is 8808h, which corresponds to 0 dB gain with mute on.*/
    19731973    ichac97MixerSetVolume(pThis, AC97_PCM_Out_Volume_Mute, PDMAUDIOMIXERCTL_FRONT,         0x8808);
    19741974    ichac97MixerSetVolume(pThis, AC97_Line_In_Volume_Mute, PDMAUDIOMIXERCTL_LINE_IN,       0x8808);
     
    26652665
    26662666                default:
    2667                     LogFunc(("Unimplemented: %#x <- %#x (Byte)\n", uPort, u32Val));
     2667                    LogRel2(("AC97: Warning: Unimplemented NABMWrite (%u byte) portIdx=%#x <- %#x\n", cbVal, uPortIdx, u32Val));
    26682668                    break;
    26692669            }
     
    26842684                    break;
    26852685                default:
    2686                     LogFunc(("Unimplemented: %#x <- %#x (Word)\n", uPort, u32Val));
     2686                    LogRel2(("AC97: Warning: Unimplemented NABMWrite (%u byte) portIdx=%#x <- %#x\n", cbVal, uPortIdx, u32Val));
    26872687                    break;
    26882688            }
     
    27182718                    break;
    27192719                default:
    2720                     LogFunc(("Unimplemented: %#x <- %#x (DWord)\n", uPort, u32Val));
     2720                    LogRel2(("AC97: Warning: Unimplemented NABMWrite (%u byte) portIdx=%#x <- %#x\n", cbVal, uPortIdx, u32Val));
    27212721                    break;
    27222722            }
     
    27252725
    27262726        default:
    2727             AssertMsgFailed(("Port=%#x cb=%d u32=%#x\n", uPort, cbVal, u32Val));
     2727            AssertLogRel(("AC97: Warning: Unimplemented NABMWrite (%u byte) portIdx=%#x <- %#x\n", cbVal, uPortIdx, u32Val));
    27282728            break;
    27292729    }
     
    27532753    int rc = VINF_SUCCESS;
    27542754
     2755    uint32_t index = uPort - pThis->IOPortBase[0];
     2756
    27552757    switch (cbVal)
    27562758    {
    27572759        case 1:
    27582760        {
    2759             Log3Func(("U nam readb %#x\n", uPort));
     2761            LogRel2(("AC97: Warning: Unimplemented read (%u byte) port=%#x, idx=%RU32\n", cbVal, uPort, index));
    27602762            pThis->cas = 0;
    27612763            *pu32Val = UINT32_MAX;
     
    27652767        case 2:
    27662768        {
    2767             uint32_t index = uPort - pThis->IOPortBase[0];
    27682769            *pu32Val = UINT32_MAX;
    27692770            pThis->cas = 0;
     2771
    27702772            switch (index)
    27712773            {
    27722774                default:
    27732775                    *pu32Val = ichac97MixerGet(pThis, index);
    2774                     Log3Func(("nam readw %#x -> %#x\n", uPort, *pu32Val));
    27752776                    break;
    27762777            }
     
    27802781        case 4:
    27812782        {
    2782             Log3Func(("U nam readl %#x\n", uPort));
     2783            LogRel2(("AC97: Warning: Unimplemented read (%u byte) port=%#x, idx=%RU32\n", cbVal, uPort, index));
    27832784            pThis->cas = 0;
    27842785            *pu32Val = UINT32_MAX;
     
    28142815    PAC97STATE pThis = (PAC97STATE)pvUser;
    28152816
     2817    uint32_t uPortIdx = uPort - pThis->IOPortBase[0];
     2818
    28162819    switch (cbVal)
    28172820    {
    28182821        case 1:
    28192822        {
    2820             Log3Func(("U nam writeb %#x <- %#x\n", uPort, u32Val));
     2823            LogRel2(("AC97: Warning: Unimplemented NAMWrite (%u byte) port=%#x, idx=0x%x <- %#x\n", cbVal, uPort, uPortIdx, u32Val));
    28212824            pThis->cas = 0;
    28222825            break;
     
    28252828        case 2:
    28262829        {
    2827             uint32_t index = uPort - pThis->IOPortBase[0];
    28282830            pThis->cas = 0;
    2829             switch (index)
     2831            switch (uPortIdx)
    28302832            {
    28312833                case AC97_Reset:
     
    28342836                case AC97_Powerdown_Ctrl_Stat:
    28352837                    u32Val &= ~0xf;
    2836                     u32Val |= ichac97MixerGet(pThis, index) & 0xf;
    2837                     ichac97MixerSet(pThis, index, u32Val);
     2838                    u32Val |= ichac97MixerGet(pThis, uPortIdx) & 0xf;
     2839                    ichac97MixerSet(pThis, uPortIdx, u32Val);
    28382840                    break;
    28392841                case AC97_Master_Volume_Mute:
     
    28432845                            break; /* Register controls surround (rear), do nothing. */
    28442846                    }
    2845                     ichac97MixerSetVolume(pThis, index, PDMAUDIOMIXERCTL_VOLUME_MASTER, u32Val);
     2847                    ichac97MixerSetVolume(pThis, uPortIdx, PDMAUDIOMIXERCTL_VOLUME_MASTER, u32Val);
    28462848                    break;
    28472849                case AC97_Headphone_Volume_Mute:
     
    28512853                        {
    28522854                            /* Register controls PCM (front) outputs. */
    2853                             ichac97MixerSetVolume(pThis, index, PDMAUDIOMIXERCTL_VOLUME_MASTER, u32Val);
     2855                            ichac97MixerSetVolume(pThis, uPortIdx, PDMAUDIOMIXERCTL_VOLUME_MASTER, u32Val);
    28542856                        }
    28552857                    }
    28562858                    break;
    28572859                case AC97_PCM_Out_Volume_Mute:
    2858                     ichac97MixerSetVolume(pThis, index, PDMAUDIOMIXERCTL_FRONT, u32Val);
     2860                    ichac97MixerSetVolume(pThis, uPortIdx, PDMAUDIOMIXERCTL_FRONT, u32Val);
    28592861                    break;
    28602862                case AC97_Line_In_Volume_Mute:
    2861                     ichac97MixerSetVolume(pThis, index, PDMAUDIOMIXERCTL_LINE_IN, u32Val);
     2863                    ichac97MixerSetVolume(pThis, uPortIdx, PDMAUDIOMIXERCTL_LINE_IN, u32Val);
    28622864                    break;
    28632865                case AC97_Record_Select:
     
    28672869                    /* Newer Ubuntu guests rely on that when controlling gain and muting
    28682870                     * the recording (capturing) levels. */
    2869                     ichac97MixerSetVolume(pThis, index, PDMAUDIOMIXERCTL_LINE_IN, u32Val);
     2871                    ichac97MixerSetVolume(pThis, uPortIdx, PDMAUDIOMIXERCTL_LINE_IN, u32Val);
    28702872                    break;
    28712873                case AC97_Record_Gain_Mic_Mute:
    28722874                    /* Ditto; see note above. */
    2873                     ichac97MixerSetVolume(pThis, index, PDMAUDIOMIXERCTL_MIC_IN,  u32Val);
     2875                    ichac97MixerSetVolume(pThis, uPortIdx, PDMAUDIOMIXERCTL_MIC_IN,  u32Val);
    28742876                    break;
    28752877                case AC97_Vendor_ID1:
     
    29062908                    if (ichac97MixerGet(pThis, AC97_Extended_Audio_Ctrl_Stat) & AC97_EACS_VRA)
    29072909                    {
    2908                         ichac97MixerSet(pThis, index, u32Val);
     2910                        ichac97MixerSet(pThis, uPortIdx, u32Val);
    29092911                        LogFunc(("Set front DAC rate to %RU32\n", u32Val));
    29102912                        ichac97StreamReOpen(pThis, &pThis->StreamOut);
     
    29162918                    if (ichac97MixerGet(pThis, AC97_Extended_Audio_Ctrl_Stat) & AC97_EACS_VRM)
    29172919                    {
    2918                         ichac97MixerSet(pThis, index, u32Val);
     2920                        ichac97MixerSet(pThis, uPortIdx, u32Val);
    29192921                        LogFunc(("Set MIC ADC rate to %RU32\n", u32Val));
    29202922                        ichac97StreamReOpen(pThis, &pThis->StreamMicIn);
     
    29262928                    if (ichac97MixerGet(pThis, AC97_Extended_Audio_Ctrl_Stat) & AC97_EACS_VRA)
    29272929                    {
    2928                         ichac97MixerSet(pThis, index, u32Val);
     2930                        ichac97MixerSet(pThis, uPortIdx, u32Val);
    29292931                        LogFunc(("Set front LR ADC rate to %RU32\n", u32Val));
    29302932                        ichac97StreamReOpen(pThis, &pThis->StreamLineIn);
     
    29342936                    break;
    29352937                default:
    2936                     LogFunc(("U nam writew %#x <- %#x\n", uPort, u32Val));
    2937                     ichac97MixerSet(pThis, index, u32Val);
     2938                    LogRel2(("AC97: Warning: Unimplemented NAMWrite (%u byte) port=%#x, idx=0x%x <- %#x\n", cbVal, uPort, uPortIdx, u32Val));
     2939                    ichac97MixerSet(pThis, uPortIdx, u32Val);
    29382940                    break;
    29392941            }
     
    29432945        case 4:
    29442946        {
    2945             Log3Func(("U nam writel %#x <- %#x\n", uPort, u32Val));
     2947            LogRel2(("AC97: Warning: Unimplemented NAMWrite (%u byte) port=%#x, idx=0x%x <- %#x\n", cbVal, uPort, uPortIdx, u32Val));
    29462948            pThis->cas = 0;
    29472949            break;
     
    29492951
    29502952        default:
    2951             AssertMsgFailed(("Port=%#x cb=%d u32=%#x\n", uPort, cbVal, u32Val));
     2953            AssertMsgFailed(("Unhandled NAMWrite port=%#x, cbVal=%u u32Val=%#x\n", uPort, cbVal, u32Val));
    29522954            break;
    29532955    }
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