Changeset 34229 in vbox for trunk/src/VBox/Devices
- Timestamp:
- Nov 22, 2010 7:58:14 AM (14 years ago)
- svn:sync-xref-src-repo-rev:
- 67974
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/DevIchIntelHDA.cpp
r34228 r34229 1299 1299 } 1300 1300 1301 #ifdef LOG_ENABLED 1301 1302 static void dump_bd(INTELHDLinkState *pState, PHDABDLEDESC pBdle, uint64_t u64BaseDMA) 1302 1303 { … … 1326 1327 } 1327 1328 } 1329 #endif 1330 1328 1331 static void fetch_bd(INTELHDLinkState *pState, PHDABDLEDESC pBdle, uint64_t u64BaseDMA) 1329 1332 { … … 1334 1337 pBdle->u32BdleCviLen = *(uint32_t *)&bdle[8]; 1335 1338 pBdle->fBdleCviIoc = (*(uint32_t *)&bdle[12]) & 0x1; 1339 #ifdef LOG_ENABLED 1336 1340 dump_bd(pState, pBdle, u64BaseDMA); 1341 #endif 1342 } 1343 1344 static inline uint32_t hdaCalculateDMABufferLength(PHDABDLEDESC pBdle, uint32_t u32SoundBackendBufferBytesAvail, uint32_t u32Fifos, uint32_t u32CblLimit) 1345 { 1346 uint32_t cb2Copy; 1347 /* 1348 * Amounts of bytes depends on current position in buffer (u32BdleCviLen-u32BdleCviPos) 1349 */ 1350 Assert((pBdle->u32BdleCviLen >= pBdle->u32BdleCviPos)); /* sanity */ 1351 cb2Copy = pBdle->u32BdleCviLen - pBdle->u32BdleCviPos; 1352 /* 1353 * we may increase the counter in range of [0, FIFOS + 1] 1354 */ 1355 cb2Copy = RT_MIN(cb2Copy, u32Fifos + 1); 1356 Assert((u32SoundBackendBufferBytesAvail > 0)); 1357 1358 /* sanity check to avoid overriding sound backend buffer */ 1359 cb2Copy = RT_MIN(cb2Copy, u32SoundBackendBufferBytesAvail); 1360 cb2Copy = RT_MIN(cb2Copy, u32CblLimit); 1361 1362 if (cb2Copy <= pBdle->cbUnderFifoW) 1363 return 0; 1364 cb2Copy -= pBdle->cbUnderFifoW; /* forcely reserve amount of ureported bytes to copy */ 1365 return cb2Copy; 1337 1366 } 1338 1367 … … 1344 1373 uint32_t cbBackendCopy = 0; 1345 1374 1346 if ( !pBdle->u32BdleCviLen 1347 || (*pu32Avail < hdaFifoWToSz(pState, 0))) 1375 Log(("hda:ra: CVI(pos:%d, len:%d)\n", pBdle->u32BdleCviPos, pBdle->u32BdleCviLen)); 1376 1377 cb2Copy = hdaCalculateDMABufferLength(pBdle, *pu32Avail, SDFIFOS(pState, 0), u32CblLimit); 1378 if (!cb2Copy) 1348 1379 { 1349 1380 *fStop = true; 1350 goto done; 1351 } 1352 1353 Log(("hda:ra: CVI(pos:%d, len:%d)\n", pBdle->u32BdleCviPos, pBdle->u32BdleCviLen)); 1354 Assert((pBdle->u32BdleCviLen >= pBdle->u32BdleCviPos)); /* sanity */ 1355 cb2Copy = pBdle->u32BdleCviLen - pBdle->u32BdleCviPos; 1356 /* 1357 * we may increase the counter in range of [0, FIFOS(pState, 4) + 1] 1358 */ 1359 cb2Copy = RT_MIN(cb2Copy, SDFIFOS(pState, 0) + 1); 1360 Assert((*pu32Avail > 0)); 1361 1362 /* sanity check to avoid overriding sound backend buffer */ 1363 cb2Copy = RT_MIN(cb2Copy, *pu32Avail); 1364 cb2Copy = RT_MIN(cb2Copy, u32CblLimit); 1365 1366 if (cb2Copy <= pBdle->cbUnderFifoW) 1367 { 1368 *fStop = true; 1369 goto done; 1370 } 1371 cb2Copy -= pBdle->cbUnderFifoW; 1372 1381 return 0; 1382 } 1383 1384 1373 1385 /* 1374 1386 * read from backend input line … … 1398 1410 goto done; 1399 1411 } 1400 Log(("hda:ra: CVI(pos:%d, len:%d)\n", pBdle->u32BdleCviPos, pBdle->u32BdleCviLen));1401 1412 done: 1402 1413 Assert((cbTransfered <= (SDFIFOS(pState, 0) + 1))); 1403 Log(("hda:ra: cbTransfered: %d\n", cbTransfered));1414 Log(("hda:ra: CVI(pos:%d, len:%d) cbTransfered: %d\n", pBdle->u32BdleCviPos, pBdle->u32BdleCviLen, cbTransfered)); 1404 1415 return cbTransfered; 1405 1416 } … … 1414 1425 Log(("hda:wa: CVI(cvi:%d, pos:%d, len:%d)\n", pBdle->u32BdleCvi, pBdle->u32BdleCviPos, pBdle->u32BdleCviLen)); 1415 1426 1416 /* 1417 * Amounts of bytes depends on current position in buffer (u32BdleCviLen-u32BdleCviPos) 1418 */ 1419 if (pBdle->u32BdleCviLen) 1420 { 1421 Assert((pBdle->u32BdleCviLen >= pBdle->u32BdleCviPos)); /* sanity */ 1422 cb2Copy = pBdle->u32BdleCviLen - pBdle->u32BdleCviPos; /* align copy buffer to size of trailing space in BDLE buffer */ 1423 cb2Copy = RT_MIN(cb2Copy, SDFIFOS(pState, 4) + 1); /* we may increase the counter in range of [0, FIFOS(pState, 4) + 1] */ 1424 cb2Copy = RT_MIN(cb2Copy, *pu32Avail); /* align copying buffer size up to size of back end buffer */ 1425 cb2Copy = RT_MIN(cb2Copy, u32CblLimit); /* avoid LCBL overrun */ 1426 } 1427 if (cb2Copy <= pBdle->cbUnderFifoW) 1428 { 1429 Log(("hda:wa: amount of unreported bytes is less than room may be transfered (cbUnderFifoW:%d < %d)\n", pBdle->cbUnderFifoW, cb2Copy)); 1430 *fStop = true; 1431 goto done; 1432 } 1433 cb2Copy -= pBdle->cbUnderFifoW; /* force reserve "Unreported bits" */ 1427 cb2Copy = hdaCalculateDMABufferLength(pBdle, *pu32Avail, SDFIFOS(pState, 4), u32CblLimit); 1434 1428 1435 1429 /* … … 1439 1433 PDMDevHlpPhysRead(ICH6_HDASTATE_2_DEVINS(pState), pBdle->u64BdleCviAddr + pBdle->u32BdleCviPos, pBdle->au8HdaBuffer + pBdle->cbUnderFifoW, cb2Copy); 1440 1434 /* 1441 * Write to audio backend. 1435 * Write to audio backend. we should be sure whether we have enought bytes to copy to Audio backend. 1442 1436 */ 1443 1437 if (cb2Copy + pBdle->cbUnderFifoW >= hdaFifoWToSz(pState, 4)) … … 1466 1460 else 1467 1461 { 1462 /* Not enough bytes to be processed and reported, check luck on next enterence */ 1468 1463 Log(("hda:wa: CVI (cbUnderFifoW:%d, pos:%d, len:%d)\n", pBdle->cbUnderFifoW, pBdle->u32BdleCviPos, pBdle->u32BdleCviLen)); 1469 1464 pBdle->cbUnderFifoW += cb2Copy;
Note:
See TracChangeset
for help on using the changeset viewer.