Changeset 82374 in vbox for trunk/src/VBox/Devices/Audio
- Timestamp:
- Dec 4, 2019 11:13:54 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/DevIchAc97.cpp
r82373 r82374 214 214 * @{ 215 215 */ 216 #define AC97SOUNDSOURCE_PI_INDEX 0 /**< PCM in */ 217 #define AC97SOUNDSOURCE_PO_INDEX 1 /**< PCM out */ 218 #define AC97SOUNDSOURCE_MC_INDEX 2 /**< Mic in */ 219 #define AC97SOUNDSOURCE_MAX 3 /**< Max sound sources. */ 216 #define AC97SOUNDSOURCE_PI_INDEX 0 /**< PCM in */ 217 #define AC97SOUNDSOURCE_PO_INDEX 1 /**< PCM out */ 218 #define AC97SOUNDSOURCE_MC_INDEX 2 /**< Mic in */ 219 #define AC97SOUNDSOURCE_MAX 3 /**< Max sound sources. */ 220 /** @} */ 221 222 /** Port number (offset into NABM BAR) to stream index. */ 223 #define AC97_PORT2IDX(a_idx) ( ((a_idx) >> 4) & 3 ) 224 /** Port number (offset into NABM BAR) to stream index, but no masking. */ 225 #define AC97_PORT2IDX_UNMASKED(a_idx) ( ((a_idx) >> 4) ) 226 227 /** @name Stream offsets 228 * @{ */ 229 #define AC97_NABM_OFF_BDBAR 0x0 /**< Buffer Descriptor Base Address */ 230 #define AC97_NABM_OFF_CIV 0x4 /**< Current Index Value */ 231 #define AC97_NABM_OFF_LVI 0x5 /**< Last Valid Index */ 232 #define AC97_NABM_OFF_SR 0x6 /**< Status Register */ 233 #define AC97_NABM_OFF_PICB 0x8 /**< Position in Current Buffer */ 234 #define AC97_NABM_OFF_PIV 0xa /**< Prefetched Index Value */ 235 #define AC97_NABM_OFF_CR 0xb /**< Control Register */ 236 #define AC97_NABM_OFF_MASK 0xf /**< Mask for getting the the per-stream register. */ 220 237 /** @} */ 221 238 … … 263 280 #define AC97_CAS 0x34 264 281 /** @} */ 265 266 #define AC97_PORT2IDX(a_idx) ( ((a_idx) >> 4) & 3 )267 282 268 283 … … 2876 2891 2877 2892 /* Get the index of the NABMBAR port. */ 2878 PAC97STREAM pStream = NULL; 2879 PAC97BMREGS pRegs = NULL; 2880 if (AC97_PORT2IDX(offPort) < AC97_MAX_STREAMS) 2881 { 2882 pStream = &pThis->aStreams[AC97_PORT2IDX(offPort)]; 2883 pRegs = &pStream->Regs; 2884 } 2885 2886 VBOXSTRICTRC rc = VINF_SUCCESS; 2887 2888 switch (cb) 2889 { 2890 case 1: 2891 { 2892 switch (offPort) 2893 { 2894 case AC97_CAS: 2895 /* Codec Access Semaphore Register */ 2896 Log3Func(("CAS %d\n", pThis->cas)); 2897 *pu32 = pThis->cas; 2898 pThis->cas = 1; 2899 break; 2900 case PI_CIV: 2901 case PO_CIV: 2902 case MC_CIV: 2903 /* Current Index Value Register */ 2904 *pu32 = pRegs->civ; 2905 Log3Func(("CIV[%d] -> %#x\n", AC97_PORT2IDX(offPort), *pu32)); 2906 break; 2907 case PI_LVI: 2908 case PO_LVI: 2909 case MC_LVI: 2910 /* Last Valid Index Register */ 2911 *pu32 = pRegs->lvi; 2912 Log3Func(("LVI[%d] -> %#x\n", AC97_PORT2IDX(offPort), *pu32)); 2913 break; 2914 case PI_PIV: 2915 case PO_PIV: 2916 case MC_PIV: 2917 /* Prefetched Index Value Register */ 2918 *pu32 = pRegs->piv; 2919 Log3Func(("PIV[%d] -> %#x\n", AC97_PORT2IDX(offPort), *pu32)); 2920 break; 2921 case PI_CR: 2922 case PO_CR: 2923 case MC_CR: 2924 /* Control Register */ 2925 *pu32 = pRegs->cr; 2926 Log3Func(("CR[%d] -> %#x\n", AC97_PORT2IDX(offPort), *pu32)); 2927 break; 2928 case PI_SR: 2929 case PO_SR: 2930 case MC_SR: 2931 /* Status Register (lower part) */ 2932 *pu32 = RT_LO_U8(pRegs->sr); 2933 Log3Func(("SRb[%d] -> %#x\n", AC97_PORT2IDX(offPort), *pu32)); 2934 break; 2935 default: 2936 *pu32 = UINT32_MAX; 2937 LogFunc(("U nabm readb %#x -> %#x\n", offPort, UINT32_MAX)); 2938 break; 2939 } 2940 break; 2941 } 2942 2943 case 2: 2944 { 2945 switch (offPort) 2946 { 2947 case PI_SR: 2948 case PO_SR: 2949 case MC_SR: 2950 /* Status Register */ 2951 *pu32 = pRegs->sr; 2952 Log3Func(("SR[%d] -> %#x\n", AC97_PORT2IDX(offPort), *pu32)); 2953 break; 2954 case PI_PICB: 2955 case PO_PICB: 2956 case MC_PICB: 2957 /* Position in Current Buffer */ 2958 *pu32 = pRegs->picb; 2959 Log3Func(("PICB[%d] -> %#x\n", AC97_PORT2IDX(offPort), *pu32)); 2960 break; 2961 default: 2962 *pu32 = UINT32_MAX; 2963 LogFunc(("U nabm readw %#x -> %#x\n", offPort, UINT32_MAX)); 2964 break; 2965 } 2966 break; 2967 } 2968 2969 case 4: 2970 { 2971 switch (offPort) 2972 { 2973 case PI_BDBAR: 2974 case PO_BDBAR: 2975 case MC_BDBAR: 2976 /* Buffer Descriptor Base Address Register */ 2977 *pu32 = pRegs->bdbar; 2978 Log3Func(("BMADDR[%d] -> %#x\n", AC97_PORT2IDX(offPort), *pu32)); 2979 break; 2980 case PI_CIV: 2981 case PO_CIV: 2982 case MC_CIV: 2983 /* 32-bit access: Current Index Value Register + 2984 * Last Valid Index Register + 2985 * Status Register */ 2986 *pu32 = pRegs->civ | (pRegs->lvi << 8) | (pRegs->sr << 16); /** @todo r=andy Use RT_MAKE_U32_FROM_U8. */ 2987 Log3Func(("CIV LVI SR[%d] -> %#x, %#x, %#x\n", 2988 AC97_PORT2IDX(offPort), pRegs->civ, pRegs->lvi, pRegs->sr)); 2989 break; 2990 case PI_PICB: 2991 case PO_PICB: 2992 case MC_PICB: 2993 /* 32-bit access: Position in Current Buffer Register + 2994 * Prefetched Index Value Register + 2995 * Control Register */ 2996 *pu32 = pRegs->picb | (pRegs->piv << 16) | (pRegs->cr << 24); /** @todo r=andy Use RT_MAKE_U32_FROM_U8. */ 2997 Log3Func(("PICB PIV CR[%d] -> %#x %#x %#x %#x\n", 2998 AC97_PORT2IDX(offPort), *pu32, pRegs->picb, pRegs->piv, pRegs->cr)); 2999 break; 3000 case AC97_GLOB_CNT: 3001 /* Global Control */ 3002 *pu32 = pThis->glob_cnt; 3003 Log3Func(("glob_cnt -> %#x\n", *pu32)); 3004 break; 3005 case AC97_GLOB_STA: 3006 /* Global Status */ 3007 *pu32 = pThis->glob_sta | AC97_GS_S0CR; 3008 Log3Func(("glob_sta -> %#x\n", *pu32)); 3009 break; 3010 default: 3011 *pu32 = UINT32_MAX; 3012 LogFunc(("U nabm readl %#x -> %#x\n", offPort, UINT32_MAX)); 3013 break; 3014 } 3015 break; 3016 } 3017 3018 default: 3019 { 3020 AssertFailed(); 3021 rc = VERR_IOM_IOPORT_UNUSED; 2893 if (AC97_PORT2IDX_UNMASKED(offPort) < AC97_MAX_STREAMS) 2894 { 2895 PAC97STREAM pStream = &pThis->aStreams[AC97_PORT2IDX(offPort)]; 2896 PAC97BMREGS pRegs = &pStream->Regs; 2897 2898 switch (cb) 2899 { 2900 case 1: 2901 switch (offPort & AC97_NABM_OFF_MASK) 2902 { 2903 case AC97_NABM_OFF_CIV: 2904 /* Current Index Value Register */ 2905 *pu32 = pRegs->civ; 2906 Log3Func(("CIV[%d] -> %#x\n", AC97_PORT2IDX(offPort), *pu32)); 2907 break; 2908 case AC97_NABM_OFF_LVI: 2909 /* Last Valid Index Register */ 2910 *pu32 = pRegs->lvi; 2911 Log3Func(("LVI[%d] -> %#x\n", AC97_PORT2IDX(offPort), *pu32)); 2912 break; 2913 case AC97_NABM_OFF_PIV: 2914 /* Prefetched Index Value Register */ 2915 *pu32 = pRegs->piv; 2916 Log3Func(("PIV[%d] -> %#x\n", AC97_PORT2IDX(offPort), *pu32)); 2917 break; 2918 case AC97_NABM_OFF_CR: 2919 /* Control Register */ 2920 *pu32 = pRegs->cr; 2921 Log3Func(("CR[%d] -> %#x\n", AC97_PORT2IDX(offPort), *pu32)); 2922 break; 2923 case AC97_NABM_OFF_SR: 2924 /* Status Register (lower part) */ 2925 *pu32 = RT_LO_U8(pRegs->sr); 2926 Log3Func(("SRb[%d] -> %#x\n", AC97_PORT2IDX(offPort), *pu32)); 2927 break; 2928 default: 2929 *pu32 = UINT32_MAX; 2930 LogFunc(("U nabm readb %#x -> %#x\n", offPort, UINT32_MAX)); 2931 break; 2932 } 2933 break; 2934 2935 case 2: 2936 switch (offPort & AC97_NABM_OFF_MASK) 2937 { 2938 case AC97_NABM_OFF_SR: 2939 /* Status Register */ 2940 *pu32 = pRegs->sr; 2941 Log3Func(("SR[%d] -> %#x\n", AC97_PORT2IDX(offPort), *pu32)); 2942 break; 2943 case AC97_NABM_OFF_PICB: 2944 /* Position in Current Buffer */ 2945 *pu32 = pRegs->picb; 2946 Log3Func(("PICB[%d] -> %#x\n", AC97_PORT2IDX(offPort), *pu32)); 2947 break; 2948 default: 2949 *pu32 = UINT32_MAX; 2950 LogFunc(("U nabm readw %#x -> %#x\n", offPort, UINT32_MAX)); 2951 break; 2952 } 2953 break; 2954 2955 case 4: 2956 switch (offPort & AC97_NABM_OFF_MASK) 2957 { 2958 case AC97_NABM_OFF_BDBAR: 2959 /* Buffer Descriptor Base Address Register */ 2960 *pu32 = pRegs->bdbar; 2961 Log3Func(("BMADDR[%d] -> %#x\n", AC97_PORT2IDX(offPort), *pu32)); 2962 break; 2963 case AC97_NABM_OFF_CIV: 2964 /* 32-bit access: Current Index Value Register + 2965 * Last Valid Index Register + 2966 * Status Register */ 2967 *pu32 = pRegs->civ | (pRegs->lvi << 8) | (pRegs->sr << 16); /** @todo r=andy Use RT_MAKE_U32_FROM_U8. */ 2968 Log3Func(("CIV LVI SR[%d] -> %#x, %#x, %#x\n", 2969 AC97_PORT2IDX(offPort), pRegs->civ, pRegs->lvi, pRegs->sr)); 2970 break; 2971 case AC97_NABM_OFF_PICB: 2972 /* 32-bit access: Position in Current Buffer Register + 2973 * Prefetched Index Value Register + 2974 * Control Register */ 2975 *pu32 = pRegs->picb | (pRegs->piv << 16) | (pRegs->cr << 24); /** @todo r=andy Use RT_MAKE_U32_FROM_U8. */ 2976 Log3Func(("PICB PIV CR[%d] -> %#x %#x %#x %#x\n", 2977 AC97_PORT2IDX(offPort), *pu32, pRegs->picb, pRegs->piv, pRegs->cr)); 2978 break; 2979 default: 2980 *pu32 = UINT32_MAX; 2981 LogFunc(("U nabm readl %#x -> %#x\n", offPort, UINT32_MAX)); 2982 break; 2983 } 2984 break; 2985 2986 default: 2987 DEVAC97_UNLOCK(pDevIns, pThis); 2988 AssertFailed(); 2989 return VERR_IOM_IOPORT_UNUSED; 2990 } 2991 } 2992 else 2993 { 2994 switch (cb) 2995 { 2996 case 1: 2997 switch (offPort) 2998 { 2999 case AC97_CAS: 3000 /* Codec Access Semaphore Register */ 3001 Log3Func(("CAS %d\n", pThis->cas)); 3002 *pu32 = pThis->cas; 3003 pThis->cas = 1; 3004 break; 3005 default: 3006 *pu32 = UINT32_MAX; 3007 LogFunc(("U nabm readb %#x -> %#x\n", offPort, UINT32_MAX)); 3008 break; 3009 } 3010 break; 3011 3012 case 2: 3013 *pu32 = UINT32_MAX; 3014 LogFunc(("U nabm readw %#x -> %#x\n", offPort, UINT32_MAX)); 3015 break; 3016 3017 case 4: 3018 switch (offPort) 3019 { 3020 case AC97_GLOB_CNT: 3021 /* Global Control */ 3022 *pu32 = pThis->glob_cnt; 3023 Log3Func(("glob_cnt -> %#x\n", *pu32)); 3024 break; 3025 case AC97_GLOB_STA: 3026 /* Global Status */ 3027 *pu32 = pThis->glob_sta | AC97_GS_S0CR; 3028 Log3Func(("glob_sta -> %#x\n", *pu32)); 3029 break; 3030 default: 3031 *pu32 = UINT32_MAX; 3032 LogFunc(("U nabm readl %#x -> %#x\n", offPort, UINT32_MAX)); 3033 break; 3034 } 3035 break; 3036 3037 default: 3038 DEVAC97_UNLOCK(pDevIns, pThis); 3039 AssertFailed(); 3040 return VERR_IOM_IOPORT_UNUSED; 3022 3041 } 3023 3042 } 3024 3043 3025 3044 DEVAC97_UNLOCK(pDevIns, pThis); 3026 3027 return rc; 3045 return VINF_SUCCESS; 3028 3046 } 3029 3047 … … 3045 3063 PAC97STREAM pStream = NULL; 3046 3064 PAC97BMREGS pRegs = NULL; 3047 if (AC97_PORT2IDX (offPort) < AC97_MAX_STREAMS)3065 if (AC97_PORT2IDX_UNMASKED(offPort) < AC97_MAX_STREAMS) 3048 3066 { 3049 3067 #ifdef IN_RING3
Note:
See TracChangeset
for help on using the changeset viewer.