VirtualBox

Changeset 55430 in vbox for trunk/src/VBox/Devices


Ignore:
Timestamp:
Apr 24, 2015 3:53:15 PM (10 years ago)
Author:
vboxsync
Message:

AC97: Take 12dB volume offset used in some controls into account.

File:
1 edited

Legend:

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

    r55394 r55430  
    4949*******************************************************************************/
    5050#undef LOG_VOICES
    51 #ifndef VBOX
    52 //#define USE_MIXER
    53 #else
    54 # define USE_MIXER
    55 #endif
    5651
    5752#ifdef DEBUG
     
    835830}
    836831
    837 #ifdef USE_MIXER
    838 
    839832#ifdef VBOX_WITH_PDM_AUDIO_DRIVER
    840833static void ichac97SetVolume(PAC97STATE pThis, int index, PDMAUDIOMIXERCTL mt, uint32_t val)
     
    846839    uint8_t rvol = val & VOL_MASK;
    847840    uint8_t lvol = (val >> 8) & VOL_MASK;
     841
     842    /* For the master volume, 0 corresponds to 0dB gain. But for the other
     843     * volume controls, 0 corresponds to +12dB and 8 to 0dB. */
     844    if (mt != PDMAUDIOMIXERCTL_VOLUME)
     845    {
     846        /* NB: Currently there is no gain support, only attenuation. */
     847        lvol = lvol < 8 ? 0 : lvol - 8;
     848        rvol = rvol < 8 ? 0 : rvol - 8;
     849    }
     850
    848851    /* AC'97 has 1.5dB steps; we use 0.375dB steps. */
    849852    rvol = 255 - rvol * 4;
     
    957960}
    958961
    959 #endif /* USE_MIXER */
    960 
    961962static void ichac97MixerReset(PAC97STATE pThis)
    962963{
     
    10461047        ichac97MixerStore(pThis, AC97_Vendor_ID2              , 0x7600); /* 7608 */
    10471048    }
    1048 #ifdef USE_MIXER
    10491049    ichac97RecordSelect(pThis, 0);
    10501050# ifdef VBOX_WITH_PDM_AUDIO_DRIVER
     
    10571057    ichac97SetVolume(pThis, AC97_Line_In_Volume_Mute, AUD_MIXER_LINE_IN, 0x8808);
    10581058# endif
    1059 #else
    1060     ichac97MixerStore(pThis, AC97_Record_Select, 0);
    1061     ichac97MixerStore(pThis, AC97_Master_Volume_Mute,  0x8000);
    1062     ichac97MixerStore(pThis, AC97_PCM_Out_Volume_Mute, 0x8808);
    1063     ichac97MixerStore(pThis, AC97_Line_In_Volume_Mute, 0x8808);
    1064 #endif
    10651059
    10661060    /* Reset all streams. */
     
    19161910                    ichac97MixerStore(pThis, index, u32);
    19171911                    break;
    1918 #ifdef USE_MIXER
    19191912                case AC97_Master_Volume_Mute:
    19201913#ifdef VBOX_WITH_PDM_AUDIO_DRIVER
     
    19411934                    ichac97RecordSelect(pThis, u32);
    19421935                    break;
    1943 #else  /* !USE_MIXER */
    1944                 case AC97_Master_Volume_Mute:
    1945                 case AC97_PCM_Out_Volume_Mute:
    1946                 case AC97_Line_In_Volume_Mute:
    1947                 case AC97_Record_Select:
    1948                     ichac97MixerStore(pThis, index, u32);
    1949                     break;
    1950 #endif /* !USE_MIXER */
    19511936                case AC97_Vendor_ID1:
    19521937                case AC97_Vendor_ID2:
     
    21402125    SSMR3GetMem(pSSM, active, sizeof(active));
    21412126
    2142 #ifdef USE_MIXER
    21432127    ichac97RecordSelect(pThis, ichac97MixerLoad(pThis, AC97_Record_Select));
    21442128# define V_(a, b) ichac97SetVolume(pThis, a, b, ichac97MixerLoad(pThis, a))
     
    21532137# endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
    21542138# undef V_
    2155 #endif /* USE_MIXER */
    21562139    ichac97ResetStreams(pThis, active);
    21572140
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