Changeset 44761 in vbox for trunk/src/VBox/Devices/Audio
- Timestamp:
- Feb 20, 2013 1:10:28 PM (12 years ago)
- svn:sync-xref-src-repo-rev:
- 83871
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/DevIchHda.cpp
r44760 r44761 1272 1272 bool fReset = RT_BOOL(u32Value & HDA_REG_FIELD_FLAG_MASK(SDCTL, SRST)); 1273 1273 bool fInReset = RT_BOOL(HDA_REG_IND(pThis, iReg) & HDA_REG_FIELD_FLAG_MASK(SDCTL, SRST)); 1274 int rc = VINF_SUCCESS; 1274 1275 1275 if (fInReset) 1276 1276 { 1277 /* Assert!!! Guest is resetting HDA's stream, we're expecting guest will mark stream as exit 1277 /* 1278 * Assert!!! Guest is resetting HDA's stream, we're expecting guest will mark stream as exit 1278 1279 * from reset 1279 1280 */ 1280 1281 Assert((!fReset)); 1281 1282 Log(("hda: guest initiated exit of stream reset.\n")); 1282 goto l_done;1283 1283 } 1284 1284 else if (fReset) … … 1303 1303 default: 1304 1304 Log(("hda: changing SRST bit on non-attached stream\n")); 1305 goto l_done;1305 return hdaRegWriteU24(pThis, iReg, u32Value); 1306 1306 } 1307 1307 Log(("hda: guest initiated enter to stream reset.\n")); 1308 1308 hdaInitTransferDescriptor(pThis, pBdle, u8Strm, &StreamDesc); 1309 1309 hdaStreamReset(pThis, pBdle, &StreamDesc, u8Strm); 1310 goto l_done; 1311 } 1312 1313 /* we enter here to change DMA states only */ 1314 if ( (fInRun && !fRun) 1315 || (fRun && !fInRun)) 1316 { 1317 Assert((!fReset && !fInReset)); 1318 switch (iReg) 1310 } 1311 else 1312 { 1313 /* we enter here to change DMA states only */ 1314 if ( (fInRun && !fRun) 1315 || (fRun && !fInRun)) 1319 1316 { 1320 case ICH6_HDA_REG_SD0CTL: 1321 AUD_set_active_in(pThis->Codec.SwVoiceIn, fRun); 1322 break; 1323 case ICH6_HDA_REG_SD4CTL: 1324 AUD_set_active_out(pThis->Codec.SwVoiceOut, fRun); 1325 break; 1326 default: 1327 Log(("hda: changing RUN bit on non-attached stream\n")); 1328 goto l_done; 1317 Assert((!fReset && !fInReset)); 1318 switch (iReg) 1319 { 1320 case ICH6_HDA_REG_SD0CTL: 1321 AUD_set_active_in(pThis->Codec.SwVoiceIn, fRun); 1322 break; 1323 case ICH6_HDA_REG_SD4CTL: 1324 AUD_set_active_out(pThis->Codec.SwVoiceOut, fRun); 1325 break; 1326 default: 1327 Log(("hda: changing RUN bit on non-attached stream\n")); 1328 break; 1329 } 1329 1330 } 1330 1331 } 1331 1332 1332 l_done: 1333 rc = hdaRegWriteU24(pThis, iReg, u32Value); 1334 if (RT_FAILURE(rc)) 1335 AssertRCReturn(rc, VINF_SUCCESS); 1336 return rc; 1333 return hdaRegWriteU24(pThis, iReg, u32Value); 1337 1334 } 1338 1335 … … 1840 1837 cb2Copy = hdaCalculateTransferBufferLength(pBdle, pStreamDesc, *pu32Avail, u32CblLimit); 1841 1838 if (!cb2Copy) 1842 {1843 1839 /* if we enter here we can't report "unreported bits" */ 1844 1840 *fStop = true; 1845 goto l_done;1846 }1847 1848 1849 /*1850 * read from backend input line to the last unreported position or at the begining.1851 */1852 cbBackendCopy = AUD_read(pThis->Codec.SwVoiceIn, pBdle->au8HdaBuffer, cb2Copy);1853 /*1854 * write the HDA DMA buffer1855 */1856 PDMDevHlpPhysWrite(pThis->pDevIns, pBdle->u64BdleCviAddr + pBdle->u32BdleCviPos, pBdle->au8HdaBuffer, cbBackendCopy);1857 1858 /* Don't see any reason why cb2Copy would differ from cbBackendCopy */1859 Assert((cbBackendCopy == cb2Copy && (*pu32Avail) >= cb2Copy)); /* sanity */1860 1861 if (pBdle->cbUnderFifoW + cbBackendCopy > hdaFifoWToSz(pThis, 0))1862 hdaBackendReadTransferReported(pBdle, cb2Copy, cbBackendCopy, &cbTransferred, pu32Avail);1863 1841 else 1864 1842 { 1865 hdaBackendTransferUnreported(pThis, pBdle, pStreamDesc, cbBackendCopy, pu32Avail); 1866 *fStop = true; 1867 } 1868 l_done: 1843 /* 1844 * read from backend input line to the last unreported position or at the begining. 1845 */ 1846 cbBackendCopy = AUD_read(pThis->Codec.SwVoiceIn, pBdle->au8HdaBuffer, cb2Copy); 1847 /* 1848 * write the HDA DMA buffer 1849 */ 1850 PDMDevHlpPhysWrite(pThis->pDevIns, pBdle->u64BdleCviAddr + pBdle->u32BdleCviPos, pBdle->au8HdaBuffer, cbBackendCopy); 1851 1852 /* Don't see any reason why cb2Copy would differ from cbBackendCopy */ 1853 Assert((cbBackendCopy == cb2Copy && (*pu32Avail) >= cb2Copy)); /* sanity */ 1854 1855 if (pBdle->cbUnderFifoW + cbBackendCopy > hdaFifoWToSz(pThis, 0)) 1856 hdaBackendReadTransferReported(pBdle, cb2Copy, cbBackendCopy, &cbTransferred, pu32Avail); 1857 else 1858 { 1859 hdaBackendTransferUnreported(pThis, pBdle, pStreamDesc, cbBackendCopy, pu32Avail); 1860 *fStop = true; 1861 } 1862 } 1863 1869 1864 Assert((cbTransferred <= (SDFIFOS(pThis, 0) + 1))); 1870 1865 Log(("hda:ra: CVI(pos:%d, len:%d) cbTransferred: %d\n", pBdle->u32BdleCviPos, pBdle->u32BdleCviLen, cbTransferred)); … … 1888 1883 */ 1889 1884 if (!cb2Copy) 1890 {1891 1885 *fStop = true; 1892 goto l_done; 1893 } 1894 1895 PDMDevHlpPhysRead(pThis->pDevIns, pBdle->u64BdleCviAddr + pBdle->u32BdleCviPos, pBdle->au8HdaBuffer + pBdle->cbUnderFifoW, cb2Copy); 1896 /* 1897 * Write to audio backend. we should ensure that we have enough bytes to copy to the backend. 1898 */ 1899 if (cb2Copy + pBdle->cbUnderFifoW >= hdaFifoWToSz(pThis, pStreamDesc)) 1900 { 1886 else 1887 { 1888 PDMDevHlpPhysRead(pThis->pDevIns, pBdle->u64BdleCviAddr + pBdle->u32BdleCviPos, pBdle->au8HdaBuffer + pBdle->cbUnderFifoW, cb2Copy); 1901 1889 /* 1902 * Feed the newly fetched samples, including unreported ones,to the backend.1890 * Write to audio backend. we should ensure that we have enough bytes to copy to the backend. 1903 1891 */ 1904 cbBackendCopy = AUD_write (pThis->Codec.SwVoiceOut, pBdle->au8HdaBuffer, cb2Copy + pBdle->cbUnderFifoW); 1905 hdaBackendWriteTransferReported(pBdle, cb2Copy, cbBackendCopy, &cbTransferred, pu32Avail); 1906 } 1907 else 1908 { 1909 /* Not enough bytes to be processed and reported, we'll try our luck next time around */ 1910 hdaBackendTransferUnreported(pThis, pBdle, pStreamDesc, cb2Copy, NULL); 1911 *fStop = true; 1912 } 1913 1914 l_done: 1892 if (cb2Copy + pBdle->cbUnderFifoW >= hdaFifoWToSz(pThis, pStreamDesc)) 1893 { 1894 /* 1895 * Feed the newly fetched samples, including unreported ones, to the backend. 1896 */ 1897 cbBackendCopy = AUD_write (pThis->Codec.SwVoiceOut, pBdle->au8HdaBuffer, cb2Copy + pBdle->cbUnderFifoW); 1898 hdaBackendWriteTransferReported(pBdle, cb2Copy, cbBackendCopy, &cbTransferred, pu32Avail); 1899 } 1900 else 1901 { 1902 /* Not enough bytes to be processed and reported, we'll try our luck next time around */ 1903 hdaBackendTransferUnreported(pThis, pBdle, pStreamDesc, cb2Copy, NULL); 1904 *fStop = true; 1905 } 1906 } 1907 1915 1908 Assert(cbTransferred <= SDFIFOS(pThis, 4) + 1); 1916 1909 Log(("hda:wa: CVI(pos:%d, len:%d, cbTransferred:%d)\n", pBdle->u32BdleCviPos, pBdle->u32BdleCviLen, cbTransferred));
Note:
See TracChangeset
for help on using the changeset viewer.