Changeset 67929 in vbox
- Timestamp:
- Jul 12, 2017 11:58:26 AM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/DevIchAc97.cpp
r67928 r67929 1733 1733 static int ichac97MixerSetVolume(PAC97STATE pThis, int index, PDMAUDIOMIXERCTL enmMixerCtl, uint32_t uVal) 1734 1734 { 1735 bool fCntlMuted;1736 uint8_t lCntlAtt, rCntlAtt;1737 1738 1735 /* 1739 1736 * From AC'97 SoundMax Codec AD1981A/AD1981B: … … 1746 1743 */ 1747 1744 /// @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? */ 1749 1746 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? */ 1751 1748 uVal |= RT_BIT(12) | RT_BIT(11) | RT_BIT(10) | RT_BIT(9) | RT_BIT(8); 1752 1749 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; 1756 1753 1757 1754 /* For the master and headphone volume, 0 corresponds to 0dB attenuation. For the other … … 1762 1759 #ifndef VBOX_WITH_AC97_GAIN_SUPPORT 1763 1760 /* 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; 1766 1763 #endif 1767 1764 } 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); 1770 1767 1771 1768 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)); 1773 1770 1774 1771 /* … … 1777 1774 * steps, each -0.375dB, where 0 corresponds to -96dB and 255 corresponds to 0dB. 1778 1775 */ 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", fC ntlMuted, 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)); 1783 1780 1784 1781 int rc = VINF_SUCCESS; … … 1786 1783 if (pThis->pMixer) /* Device can be in reset state, so no mixer available. */ 1787 1784 { 1788 PDMAUDIOVOLUME Vol = { fC ntlMuted, lVol, rVol };1785 PDMAUDIOVOLUME Vol = { fCtlMuted, lVol, rVol }; 1789 1786 PAUDMIXSINK pSink = NULL; 1790 1787 … … 1970 1967 ichac97MixerRecordSelect(pThis, 0); 1971 1968 1969 /* The default value is 8000h, which corresponds to 0 dB attenuation with mute on. */ 1972 1970 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.*/ 1973 1973 ichac97MixerSetVolume(pThis, AC97_PCM_Out_Volume_Mute, PDMAUDIOMIXERCTL_FRONT, 0x8808); 1974 1974 ichac97MixerSetVolume(pThis, AC97_Line_In_Volume_Mute, PDMAUDIOMIXERCTL_LINE_IN, 0x8808); … … 2665 2665 2666 2666 default: 2667 Log Func(("Unimplemented: %#x <- %#x (Byte)\n", uPort, u32Val));2667 LogRel2(("AC97: Warning: Unimplemented NABMWrite (%u byte) portIdx=%#x <- %#x\n", cbVal, uPortIdx, u32Val)); 2668 2668 break; 2669 2669 } … … 2684 2684 break; 2685 2685 default: 2686 Log Func(("Unimplemented: %#x <- %#x (Word)\n", uPort, u32Val));2686 LogRel2(("AC97: Warning: Unimplemented NABMWrite (%u byte) portIdx=%#x <- %#x\n", cbVal, uPortIdx, u32Val)); 2687 2687 break; 2688 2688 } … … 2718 2718 break; 2719 2719 default: 2720 Log Func(("Unimplemented: %#x <- %#x (DWord)\n", uPort, u32Val));2720 LogRel2(("AC97: Warning: Unimplemented NABMWrite (%u byte) portIdx=%#x <- %#x\n", cbVal, uPortIdx, u32Val)); 2721 2721 break; 2722 2722 } … … 2725 2725 2726 2726 default: 2727 Assert MsgFailed(("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)); 2728 2728 break; 2729 2729 } … … 2753 2753 int rc = VINF_SUCCESS; 2754 2754 2755 uint32_t index = uPort - pThis->IOPortBase[0]; 2756 2755 2757 switch (cbVal) 2756 2758 { 2757 2759 case 1: 2758 2760 { 2759 Log 3Func(("U nam readb %#x\n", uPort));2761 LogRel2(("AC97: Warning: Unimplemented read (%u byte) port=%#x, idx=%RU32\n", cbVal, uPort, index)); 2760 2762 pThis->cas = 0; 2761 2763 *pu32Val = UINT32_MAX; … … 2765 2767 case 2: 2766 2768 { 2767 uint32_t index = uPort - pThis->IOPortBase[0];2768 2769 *pu32Val = UINT32_MAX; 2769 2770 pThis->cas = 0; 2771 2770 2772 switch (index) 2771 2773 { 2772 2774 default: 2773 2775 *pu32Val = ichac97MixerGet(pThis, index); 2774 Log3Func(("nam readw %#x -> %#x\n", uPort, *pu32Val));2775 2776 break; 2776 2777 } … … 2780 2781 case 4: 2781 2782 { 2782 Log 3Func(("U nam readl %#x\n", uPort));2783 LogRel2(("AC97: Warning: Unimplemented read (%u byte) port=%#x, idx=%RU32\n", cbVal, uPort, index)); 2783 2784 pThis->cas = 0; 2784 2785 *pu32Val = UINT32_MAX; … … 2814 2815 PAC97STATE pThis = (PAC97STATE)pvUser; 2815 2816 2817 uint32_t uPortIdx = uPort - pThis->IOPortBase[0]; 2818 2816 2819 switch (cbVal) 2817 2820 { 2818 2821 case 1: 2819 2822 { 2820 Log 3Func(("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)); 2821 2824 pThis->cas = 0; 2822 2825 break; … … 2825 2828 case 2: 2826 2829 { 2827 uint32_t index = uPort - pThis->IOPortBase[0];2828 2830 pThis->cas = 0; 2829 switch ( index)2831 switch (uPortIdx) 2830 2832 { 2831 2833 case AC97_Reset: … … 2834 2836 case AC97_Powerdown_Ctrl_Stat: 2835 2837 u32Val &= ~0xf; 2836 u32Val |= ichac97MixerGet(pThis, index) & 0xf;2837 ichac97MixerSet(pThis, index, u32Val);2838 u32Val |= ichac97MixerGet(pThis, uPortIdx) & 0xf; 2839 ichac97MixerSet(pThis, uPortIdx, u32Val); 2838 2840 break; 2839 2841 case AC97_Master_Volume_Mute: … … 2843 2845 break; /* Register controls surround (rear), do nothing. */ 2844 2846 } 2845 ichac97MixerSetVolume(pThis, index, PDMAUDIOMIXERCTL_VOLUME_MASTER, u32Val);2847 ichac97MixerSetVolume(pThis, uPortIdx, PDMAUDIOMIXERCTL_VOLUME_MASTER, u32Val); 2846 2848 break; 2847 2849 case AC97_Headphone_Volume_Mute: … … 2851 2853 { 2852 2854 /* Register controls PCM (front) outputs. */ 2853 ichac97MixerSetVolume(pThis, index, PDMAUDIOMIXERCTL_VOLUME_MASTER, u32Val);2855 ichac97MixerSetVolume(pThis, uPortIdx, PDMAUDIOMIXERCTL_VOLUME_MASTER, u32Val); 2854 2856 } 2855 2857 } 2856 2858 break; 2857 2859 case AC97_PCM_Out_Volume_Mute: 2858 ichac97MixerSetVolume(pThis, index, PDMAUDIOMIXERCTL_FRONT, u32Val);2860 ichac97MixerSetVolume(pThis, uPortIdx, PDMAUDIOMIXERCTL_FRONT, u32Val); 2859 2861 break; 2860 2862 case AC97_Line_In_Volume_Mute: 2861 ichac97MixerSetVolume(pThis, index, PDMAUDIOMIXERCTL_LINE_IN, u32Val);2863 ichac97MixerSetVolume(pThis, uPortIdx, PDMAUDIOMIXERCTL_LINE_IN, u32Val); 2862 2864 break; 2863 2865 case AC97_Record_Select: … … 2867 2869 /* Newer Ubuntu guests rely on that when controlling gain and muting 2868 2870 * the recording (capturing) levels. */ 2869 ichac97MixerSetVolume(pThis, index, PDMAUDIOMIXERCTL_LINE_IN, u32Val);2871 ichac97MixerSetVolume(pThis, uPortIdx, PDMAUDIOMIXERCTL_LINE_IN, u32Val); 2870 2872 break; 2871 2873 case AC97_Record_Gain_Mic_Mute: 2872 2874 /* Ditto; see note above. */ 2873 ichac97MixerSetVolume(pThis, index, PDMAUDIOMIXERCTL_MIC_IN, u32Val);2875 ichac97MixerSetVolume(pThis, uPortIdx, PDMAUDIOMIXERCTL_MIC_IN, u32Val); 2874 2876 break; 2875 2877 case AC97_Vendor_ID1: … … 2906 2908 if (ichac97MixerGet(pThis, AC97_Extended_Audio_Ctrl_Stat) & AC97_EACS_VRA) 2907 2909 { 2908 ichac97MixerSet(pThis, index, u32Val);2910 ichac97MixerSet(pThis, uPortIdx, u32Val); 2909 2911 LogFunc(("Set front DAC rate to %RU32\n", u32Val)); 2910 2912 ichac97StreamReOpen(pThis, &pThis->StreamOut); … … 2916 2918 if (ichac97MixerGet(pThis, AC97_Extended_Audio_Ctrl_Stat) & AC97_EACS_VRM) 2917 2919 { 2918 ichac97MixerSet(pThis, index, u32Val);2920 ichac97MixerSet(pThis, uPortIdx, u32Val); 2919 2921 LogFunc(("Set MIC ADC rate to %RU32\n", u32Val)); 2920 2922 ichac97StreamReOpen(pThis, &pThis->StreamMicIn); … … 2926 2928 if (ichac97MixerGet(pThis, AC97_Extended_Audio_Ctrl_Stat) & AC97_EACS_VRA) 2927 2929 { 2928 ichac97MixerSet(pThis, index, u32Val);2930 ichac97MixerSet(pThis, uPortIdx, u32Val); 2929 2931 LogFunc(("Set front LR ADC rate to %RU32\n", u32Val)); 2930 2932 ichac97StreamReOpen(pThis, &pThis->StreamLineIn); … … 2934 2936 break; 2935 2937 default: 2936 Log Func(("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); 2938 2940 break; 2939 2941 } … … 2943 2945 case 4: 2944 2946 { 2945 Log 3Func(("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)); 2946 2948 pThis->cas = 0; 2947 2949 break; … … 2949 2951 2950 2952 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)); 2952 2954 break; 2953 2955 }
Note:
See TracChangeset
for help on using the changeset viewer.