Changeset 59439 in vbox
- Timestamp:
- Jan 22, 2016 2:57:11 PM (9 years ago)
- Location:
- trunk/src/VBox/Devices/Audio
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/DevIchHda.cpp
r59376 r59439 603 603 uint8_t Padding0[7]; 604 604 /** DMA base address (SDnBDPU - SDnBDPL). */ 605 uint64_t u64B aseDMA;605 uint64_t u64BDLBase; 606 606 /** Cyclic Buffer Length (SDnCBL). 607 607 * Represents the size of the ring buffer. */ … … 836 836 837 837 #ifdef IN_RING3 838 static int hdaBDLEFetch(PHDASTATE pThis, PHDABDLE pBDLE, uint64_t u64BaseDMA, uint16_t u16Entry); 839 static void hdaStreamUpdateLPIB(PHDASTATE pThis, PHDASTREAM pStrmSt, uint32_t u32LPIB); 838 static int hdaBDLEFetch(PHDASTATE pThis, PHDABDLE pBDLE, uint64_t u64BaseDMA, uint16_t u16Entry); 839 static DECLINLINE(void) hdaStreamUpdateBDLBase(PHDASTATE pThis, PHDASTREAM pStrmSt, uint64_t u64BDLBase); 840 static DECLINLINE(void) hdaStreamUpdateLPIB(PHDASTATE pThis, PHDASTREAM pStrmSt, uint32_t u32LPIB); 840 841 # ifdef LOG_ENABLED 841 static void hdaBDLEDumpAll(PHDASTATE pThis, uint64_t u64BaseDMA, uint16_t cBDLE);842 static void hdaBDLEDumpAll(PHDASTATE pThis, uint64_t u64BaseDMA, uint16_t cBDLE); 842 843 # endif 843 844 #endif … … 871 872 { offset + 0x4, 0x00004, 0xFFFFFFFF, 0x00000000, hdaRegReadLPIB, hdaRegWriteU32 , HDA_REG_IDX_STRM(name, LPIB) , #name " Link Position In Buffer" }, \ 872 873 /* Offset 0x88 (SD0) */ \ 873 { offset + 0x8, 0x00004, 0xFFFFFFFF, 0xFFFFFFFF, hdaRegReadU32, hdaRegWrite U32, HDA_REG_IDX_STRM(name, CBL) , #name " Cyclic Buffer Length" }, \874 { offset + 0x8, 0x00004, 0xFFFFFFFF, 0xFFFFFFFF, hdaRegReadU32, hdaRegWriteSDCBL , HDA_REG_IDX_STRM(name, CBL) , #name " Cyclic Buffer Length" }, \ 874 875 /* Offset 0x8C (SD0) */ \ 875 876 { offset + 0xC, 0x00002, 0x0000FFFF, 0x0000FFFF, hdaRegReadU16, hdaRegWriteSDLVI , HDA_REG_IDX_STRM(name, LVI) , #name " Last Valid Index" }, \ … … 879 880 { offset + 0x10, 0x00002, 0x000000FF, 0x00000000, hdaRegReadU16, hdaRegWriteSDFIFOS, HDA_REG_IDX_STRM(name, FIFOS), #name " FIFO Size" }, \ 880 881 /* Offset 0x92 (SD0) */ \ 881 { offset + 0x12, 0x00002, 0x00007F7F, 0x00007F7F, hdaRegReadU16, hdaRegWriteSDFMT , HDA_REG_IDX_STRM(name, FMT) , #name " Format" }, \882 { offset + 0x12, 0x00002, 0x00007F7F, 0x00007F7F, hdaRegReadU16, hdaRegWriteSDFMT , HDA_REG_IDX_STRM(name, FMT) , #name " Stream Format" }, \ 882 883 /* Reserved: 0x94 - 0x98. */ \ 883 884 /* Offset 0x98 (SD0) */ \ … … 1032 1033 Assert(u32LPIB <= pStrmSt->u32CBL); 1033 1034 1034 LogFlowFunc((" uStrm=%RU8,LPIB=%RU32 (DMA Position Buffer Enabled: %RTbool)\n",1035 LogFlowFunc(("[SD%RU8]: LPIB=%RU32 (DMA Position Buffer Enabled: %RTbool)\n", 1035 1036 pStrmSt->u8Strm, u32LPIB, pThis->fDMAPosition)); 1036 1037 … … 1046 1047 AssertRC(rc2); 1047 1048 #ifdef DEBUG 1048 hdaBDLEDumpAll(pThis, pStrmSt->u64B aseDMA, pStrmSt->State.uCurBDLE);1049 hdaBDLEDumpAll(pThis, pStrmSt->u64BDLBase, pStrmSt->State.uCurBDLE); 1049 1050 #endif 1050 1051 } … … 1138 1139 Assert(pStrmSt->State.uCurBDLE < pStrmSt->u16LVI + 1); 1139 1140 1140 int rc = hdaBDLEFetch(pThis, &pStrmSt->State.BDLE, pStrmSt->u64B aseDMA, pStrmSt->State.uCurBDLE);1141 int rc = hdaBDLEFetch(pThis, &pStrmSt->State.BDLE, pStrmSt->u64BDLBase, pStrmSt->State.uCurBDLE); 1141 1142 1142 1143 #ifdef DEBUG … … 1147 1148 } 1148 1149 #endif 1150 1151 DECLINLINE(PHDASTREAM) hdaStreamFromID(PHDASTATE pThis, uint8_t uStreamID) 1152 { 1153 PHDASTREAM pStrmSt; 1154 1155 switch (uStreamID) 1156 { 1157 case 0: /** @todo Use dynamic indices, based on stream assignment. */ 1158 { 1159 pStrmSt = &pThis->StrmStLineIn; 1160 break; 1161 } 1162 # ifdef VBOX_WITH_HDA_MIC_IN 1163 case 2: /** @todo Use dynamic indices, based on stream assignment. */ 1164 { 1165 pStrmSt = &pThis->StrmStMicIn; 1166 break; 1167 } 1168 # endif 1169 case 4: /** @todo Use dynamic indices, based on stream assignment. */ 1170 { 1171 pStrmSt = &pThis->StrmStOut; 1172 break; 1173 } 1174 1175 default: 1176 { 1177 pStrmSt = NULL; 1178 LogFunc(("Warning: Stream with ID=%RU8 not handled\n", uStreamID)); 1179 break; 1180 } 1181 } 1182 1183 return pStrmSt; 1184 } 1149 1185 1150 1186 /** … … 1478 1514 1479 1515 pStrmSt->u8Strm = u8Strm; 1480 pStrmSt->u64B aseDMA= RT_MAKE_U64(HDA_STREAM_REG(pThis, BDPL, pStrmSt->u8Strm),1516 pStrmSt->u64BDLBase = RT_MAKE_U64(HDA_STREAM_REG(pThis, BDPL, pStrmSt->u8Strm), 1481 1517 HDA_STREAM_REG(pThis, BDPU, pStrmSt->u8Strm)); 1482 1518 pStrmSt->u16LVI = HDA_STREAM_REG(pThis, LVI, pStrmSt->u8Strm); … … 1488 1524 1489 1525 LogFlowFunc(("[SD%RU8]: DMA @ 0x%x (%RU32 bytes), LVI=%RU16, FIFOS=%RU16\n", 1490 pStrmSt->u8Strm, pStrmSt->u64B aseDMA, pStrmSt->u32CBL, pStrmSt->u16LVI, pStrmSt->u16FIFOS));1526 pStrmSt->u8Strm, pStrmSt->u64BDLBase, pStrmSt->u32CBL, pStrmSt->u16LVI, pStrmSt->u16FIFOS)); 1491 1527 1492 1528 #ifdef DEBUG … … 1852 1888 static int hdaRegWriteSDCBL(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value) 1853 1889 { 1854 const uint8_t u8Strm = HDA_SD_NUM_FROM_REG(pThis, CBL, iReg); 1855 uint32_t u32LPIB = HDA_STREAM_REG(pThis, LPIB, u8Strm); 1856 1857 LogFlowFunc(("[SD%RU8]: LPIB=%RU32, CBL=%RU32\n", u8Strm, u32LPIB, u32Value)); 1858 1859 return hdaRegWriteU32(pThis, iReg, u32Value); 1890 int rc = hdaRegWriteU32(pThis, iReg, u32Value); 1891 if (RT_SUCCESS(rc)) 1892 { 1893 uint8_t u8Strm = HDA_SD_NUM_FROM_REG(pThis, CBL, iReg); 1894 1895 PHDASTREAM pStrmSt = hdaStreamFromID(pThis, u8Strm); 1896 if (pStrmSt) 1897 { 1898 pStrmSt->u32CBL = u32Value; 1899 1900 /* Reset BDLE state. */ 1901 RT_ZERO(pStrmSt->State.BDLE); 1902 pStrmSt->State.uCurBDLE = 0; 1903 } 1904 1905 LogFlowFunc(("[SD%RU8]: CBL=%RU32\n", u8Strm, u32Value)); 1906 } 1907 else 1908 AssertRCReturn(rc, VINF_SUCCESS); 1909 1910 return rc; 1860 1911 } 1861 1912 … … 1869 1920 uint8_t u8Strm = HDA_SD_NUM_FROM_REG(pThis, CTL, iReg); 1870 1921 1871 PHDASTREAM pStrmSt; 1872 switch (u8Strm) 1873 { 1874 case 0: /** @todo Use dynamic indices, based on stream assignment. */ 1875 { 1876 pStrmSt = &pThis->StrmStLineIn; 1877 break; 1878 } 1879 # ifdef VBOX_WITH_HDA_MIC_IN 1880 case 2: /** @todo Use dynamic indices, based on stream assignment. */ 1881 { 1882 pStrmSt = &pThis->StrmStMicIn; 1883 break; 1884 } 1885 # endif 1886 case 4: /** @todo Use dynamic indices, based on stream assignment. */ 1887 { 1888 pStrmSt = &pThis->StrmStOut; 1889 break; 1890 } 1891 1892 default: 1893 { 1894 LogFunc(("Warning: Changing SDCTL on non-attached stream (iReg=0x%x)\n", iReg)); 1895 return hdaRegWriteU24(pThis, iReg, u32Value); /* Write 3 bytes. */ 1896 } 1922 PHDASTREAM pStrmSt = hdaStreamFromID(pThis, u8Strm); 1923 if (!pStrmSt) 1924 { 1925 LogFunc(("Warning: Changing SDCTL on non-attached stream with ID=%RU8 (iReg=0x%x)\n", u8Strm, iReg)); 1926 return hdaRegWriteU24(pThis, iReg, u32Value); /* Write 3 bytes. */ 1897 1927 } 1898 1928 … … 1986 2016 return VINF_SUCCESS; 1987 2017 1988 int rc = hdaRegWriteU32(pThis, iReg, u32Value); 1989 if (RT_FAILURE(rc)) 2018 int rc = hdaRegWriteU16(pThis, iReg, u32Value); 2019 if (RT_SUCCESS(rc)) 2020 { 2021 uint8_t u8Strm = HDA_SD_NUM_FROM_REG(pThis, LVI, iReg); 2022 2023 PHDASTREAM pStrmSt = hdaStreamFromID(pThis, u8Strm); 2024 if (pStrmSt) 2025 { 2026 pStrmSt->u16LVI = u32Value; 2027 2028 /* Reset BDLE state. */ 2029 RT_ZERO(pStrmSt->State.BDLE); 2030 pStrmSt->State.uCurBDLE = 0; 2031 } 2032 2033 LogFlowFunc(("[SD%RU8]: CBL=%RU32\n", u8Strm, u32Value)); 2034 } 2035 else 1990 2036 AssertRCReturn(rc, VINF_SUCCESS); 2037 1991 2038 return rc; 1992 2039 } … … 2071 2118 2072 2119 #ifdef IN_RING3 2073 static int hdaSDFMTToStrmCfg(uint32_t u32S dFmt, PPDMAUDIOSTREAMCFG pCfg)2120 static int hdaSDFMTToStrmCfg(uint32_t u32SDFMT, PPDMAUDIOSTREAMCFG pCfg) 2074 2121 { 2075 2122 AssertPtrReturn(pCfg, VERR_INVALID_POINTER); … … 2079 2126 int rc = VINF_SUCCESS; 2080 2127 2081 uint32_t u32Hz = (u32S dFmt& HDA_SDFMT_BASE_RATE_SHIFT) ? 44100 : 48000;2128 uint32_t u32Hz = (u32SDFMT & HDA_SDFMT_BASE_RATE_SHIFT) ? 44100 : 48000; 2082 2129 uint32_t u32HzMult = 1; 2083 2130 uint32_t u32HzDiv = 1; 2084 2131 2085 switch (EXTRACT_VALUE(u32S dFmt, HDA_SDFMT_MULT_MASK, HDA_SDFMT_MULT_SHIFT))2132 switch (EXTRACT_VALUE(u32SDFMT, HDA_SDFMT_MULT_MASK, HDA_SDFMT_MULT_SHIFT)) 2086 2133 { 2087 2134 case 0: u32HzMult = 1; break; … … 2091 2138 default: 2092 2139 LogFunc(("Unsupported multiplier %x\n", 2093 EXTRACT_VALUE(u32S dFmt, HDA_SDFMT_MULT_MASK, HDA_SDFMT_MULT_SHIFT)));2140 EXTRACT_VALUE(u32SDFMT, HDA_SDFMT_MULT_MASK, HDA_SDFMT_MULT_SHIFT))); 2094 2141 rc = VERR_NOT_SUPPORTED; 2095 2142 break; 2096 2143 } 2097 switch (EXTRACT_VALUE(u32S dFmt, HDA_SDFMT_DIV_MASK, HDA_SDFMT_DIV_SHIFT))2144 switch (EXTRACT_VALUE(u32SDFMT, HDA_SDFMT_DIV_MASK, HDA_SDFMT_DIV_SHIFT)) 2098 2145 { 2099 2146 case 0: u32HzDiv = 1; break; … … 2107 2154 default: 2108 2155 LogFunc(("Unsupported divisor %x\n", 2109 EXTRACT_VALUE(u32S dFmt, HDA_SDFMT_DIV_MASK, HDA_SDFMT_DIV_SHIFT)));2156 EXTRACT_VALUE(u32SDFMT, HDA_SDFMT_DIV_MASK, HDA_SDFMT_DIV_SHIFT))); 2110 2157 rc = VERR_NOT_SUPPORTED; 2111 2158 break; … … 2113 2160 2114 2161 PDMAUDIOFMT enmFmt = AUD_FMT_S16; /* Default to 16-bit signed. */ 2115 switch (EXTRACT_VALUE(u32S dFmt, HDA_SDFMT_BITS_MASK, HDA_SDFMT_BITS_SHIFT))2162 switch (EXTRACT_VALUE(u32SDFMT, HDA_SDFMT_BITS_MASK, HDA_SDFMT_BITS_SHIFT)) 2116 2163 { 2117 2164 case 0: … … 2135 2182 default: 2136 2183 AssertMsgFailed(("Unsupported bits shift %x\n", 2137 EXTRACT_VALUE(u32S dFmt, HDA_SDFMT_BITS_MASK, HDA_SDFMT_BITS_SHIFT)));2184 EXTRACT_VALUE(u32SDFMT, HDA_SDFMT_BITS_MASK, HDA_SDFMT_BITS_SHIFT))); 2138 2185 rc = VERR_NOT_SUPPORTED; 2139 2186 break; … … 2143 2190 { 2144 2191 pCfg->uHz = u32Hz * u32HzMult / u32HzDiv; 2145 pCfg->cChannels = (u32S dFmt& 0xf) + 1;2192 pCfg->cChannels = (u32SDFMT & 0xf) + 1; 2146 2193 pCfg->enmFormat = enmFmt; 2147 2194 pCfg->enmEndianness = PDMAUDIOHOSTENDIANNESS; … … 2166 2213 int rc = hdaSDFMTToStrmCfg(u32Value, &strmCfg); 2167 2214 if (RT_FAILURE(rc)) 2168 return rc; 2215 return VINF_SUCCESS; /* Always return success to the MMIO handler. */ 2216 2217 uint8_t u8Strm = HDA_SD_NUM_FROM_REG(pThis, FMT, iReg); 2169 2218 2170 2219 PHDADRIVER pDrv; … … 2181 2230 break; 2182 2231 # endif 2232 case HDA_REG_SD4FMT: 2233 RTListForEach(&pThis->lstDrv, pDrv, HDADRIVER, Node) 2234 rc = hdaCodecOpenStream(pThis->pCodec, PO_INDEX, &strmCfg); 2235 break; 2183 2236 default: 2184 LogFunc(("Warning: Attempt to change format on register %RU32\n", iReg));2237 LogFunc(("Warning: Changing SDFMT on non-attached stream with ID=%RU8 (iReg=0x%x)\n", u8Strm, iReg)); 2185 2238 break; 2186 2239 } … … 2196 2249 } 2197 2250 2198 static int hdaRegWriteSDBDPL(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value) 2251 /* Note: Will be called for both, BDPL and BDPU, registers. */ 2252 static DECLINLINE(int) hdaRegWriteSDBDPX(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value, uint8_t u8Strm) 2199 2253 { 2200 2254 if (!hdaRegWriteSDIsAllowed(pThis, iReg, u32Value)) 2201 2255 return VINF_SUCCESS; 2202 2256 2203 LogFlowFunc(("[SD%RU8]: DMA BDPL -> 0x%x\n", HDA_SD_NUM_FROM_REG(pThis, CTL, iReg), u32Value));2204 2205 2257 int rc = hdaRegWriteU32(pThis, iReg, u32Value); 2206 if (RT_FAILURE(rc)) 2258 if (RT_SUCCESS(rc)) 2259 { 2260 PHDASTREAM pStrmSt = hdaStreamFromID(pThis, u8Strm); 2261 if (pStrmSt) 2262 { 2263 pStrmSt->u64BDLBase = RT_MAKE_U64(HDA_STREAM_REG(pThis, BDPL, u8Strm), 2264 HDA_STREAM_REG(pThis, BDPU, u8Strm)); 2265 /* Reset BDLE state. */ 2266 RT_ZERO(pStrmSt->State.BDLE); 2267 pStrmSt->State.uCurBDLE = 0; 2268 } 2269 } 2270 else 2207 2271 AssertRCReturn(rc, VINF_SUCCESS); 2272 2208 2273 return rc; 2209 2274 } 2210 2275 2276 static int hdaRegWriteSDBDPL(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value) 2277 { 2278 return hdaRegWriteSDBDPX(pThis, iReg, u32Value, HDA_SD_NUM_FROM_REG(pThis, BDPL, iReg)); 2279 } 2280 2211 2281 static int hdaRegWriteSDBDPU(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value) 2212 2282 { 2213 if (!hdaRegWriteSDIsAllowed(pThis, iReg, u32Value)) 2214 return VINF_SUCCESS; 2215 2216 LogFlowFunc(("[SD%RU8]: DMA BDPU -> 0x%x\n", HDA_SD_NUM_FROM_REG(pThis, CTL, iReg), u32Value)); 2217 2218 int rc = hdaRegWriteU32(pThis, iReg, u32Value); 2219 if (RT_FAILURE(rc)) 2220 AssertRCReturn(rc, VINF_SUCCESS); 2221 return rc; 2283 return hdaRegWriteSDBDPX(pThis, iReg, u32Value, HDA_SD_NUM_FROM_REG(pThis, BDPU, iReg)); 2222 2284 } 2223 2285 … … 3179 3241 /* Sanity checks. */ 3180 3242 Assert(pStrmSt->u8Strm <= 7); /** @todo Use a define for MAX_STREAMS! */ 3181 Assert(pStrmSt->u64B aseDMA);3243 Assert(pStrmSt->u64BDLBase); 3182 3244 Assert(pStrmSt->u32CBL); 3183 3245 … … 3572 3634 hdaBDLEDumpAll(pThis, u64BaseDMA, u16LVI + 1); 3573 3635 3574 Assert(u64BaseDMA == pStrm->u64B aseDMA);3636 Assert(u64BaseDMA == pStrm->u64BDLBase); 3575 3637 Assert(u16LVI == pStrm->u16LVI); 3576 3638 Assert(u32CBL == pStrm->u32CBL); … … 3804 3866 break; 3805 3867 3806 PHDASTREAM pStrm ;3868 PHDASTREAM pStrm = hdaStreamFromID(pThis, uStreamID); 3807 3869 HDASTREAM StreamDummy; 3808 3870 3809 switch (uStreamID)3871 if (!pStrm) 3810 3872 { 3811 case 0: /** @todo Implement dynamic stream IDs. */ 3812 pStrm = &pThis->StrmStLineIn; 3813 break; 3814 #ifdef VBOX_WITH_HDA_MIC_IN 3815 case 2: /** @todo Implement dynamic stream IDs. */ 3816 pStrm = &pThis->StrmStMicIn; 3817 break; 3818 #endif 3819 case 4: /** @todo Implement dynamic stream IDs. */ 3820 pStrm = &pThis->StrmStOut; 3821 break; 3822 3823 default: 3824 pStrm = &StreamDummy; 3825 3826 LogRel2(("HDA: Warning: Stream ID=%RU32 not supported, skipping to load ...\n", uStreamID)); 3827 break; 3873 pStrm = &StreamDummy; 3874 LogRel2(("HDA: Warning: Stream ID=%RU32 not supported, skipping to load ...\n", uStreamID)); 3875 break; 3828 3876 } 3829 3877 -
trunk/src/VBox/Devices/Audio/DevIchHdaCodec.h
r59275 r59439 130 130 int hdaCodecSaveState(PHDACODEC pThis, PSSMHANDLE pSSM); 131 131 int hdaCodecLoadState(PHDACODEC pThis, PSSMHANDLE pSSM, uint32_t uVersion); 132 int hdaCodecOpenStream(PHDACODEC pThis, PDMAUDIORECSOURCE enmRecSource, PDMAUDIOSTREAMCFG *pAudioSettings);132 int hdaCodecOpenStream(PHDACODEC pThis, ENMSOUNDSOURCE enmSoundSource, PPDMAUDIOSTREAMCFG pCfg); 133 133 134 134 #define HDA_SSM_VERSION 6
Note:
See TracChangeset
for help on using the changeset viewer.