--- src/VBox/Devices/Audio/DevIchAc97.cpp.orig 2009-12-16 09:13:05.930459951 +0800 +++ src/VBox/Devices/Audio/DevIchAc97.cpp 2009-12-16 09:18:13.404715106 +0800 @@ -490,23 +490,8 @@ static void set_volume (AC97LinkState *s, int index, audmixerctl_t mt, uint32_t val) { - int mute = (val >> MUTE_SHIFT) & 1; - uint8_t rvol = VOL_MASK - (val & VOL_MASK); - uint8_t lvol = VOL_MASK - ((val >> 8) & VOL_MASK); - rvol = 255 * rvol / VOL_MASK; - lvol = 255 * lvol / VOL_MASK; - -# ifdef SOFT_VOLUME - if (index == AC97_Master_Volume_Mute) - AUD_set_volume_out (s->voice_po, mute, lvol, rvol); - else - AUD_set_volume (mt, &mute, &lvol, &rvol); -# else - AUD_set_volume (mt, &mute, &lvol, &rvol); -# endif - - rvol = VOL_MASK - ((VOL_MASK * rvol) / 255); - lvol = VOL_MASK - ((VOL_MASK * lvol) / 255); + int mute; + uint8_t rvol, lvol; /* * From AC'97 SoundMax Codec AD1981A: "Because AC '97 defines 6-bit volume registers, to @@ -521,6 +506,24 @@ if (val & RT_BIT(13)) val |= RT_BIT(12) | RT_BIT(11) | RT_BIT(10) | RT_BIT(9) | RT_BIT(8); + /* + * 5-bit volume, behave like one. + */ + val &= ~(RT_BIT(5) | RT_BIT(13)); + + mute = (val >> MUTE_SHIFT) & 1; + rvol = (255 * (VOL_MASK - (val & VOL_MASK))) / VOL_MASK; + lvol = (255 * (VOL_MASK - ((val >> 8) & VOL_MASK))) / VOL_MASK; + +# ifdef SOFT_VOLUME + if (index == AC97_Master_Volume_Mute) + AUD_set_volume_out (s->voice_po, mute, lvol, rvol); + else + AUD_set_volume (mt, &mute, &lvol, &rvol); +# else + AUD_set_volume (mt, &mute, &lvol, &rvol); +# endif + mixer_store (s, index, val); }