Changeset 9329 in vbox for trunk/src/VBox/Devices
- Timestamp:
- Jun 2, 2008 9:44:21 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/DevIchAc97.cpp
r8155 r9329 1 /* $Id$ */ 1 2 /** @file 2 * 3 * VBox ICH AC97 Audio Controller 3 * VBox ICH AC97 Audio Controller. 4 4 */ 5 5 6 6 /* 7 * Copyright (C) 2006-200 7Sun Microsystems, Inc.7 * Copyright (C) 2006-2008 Sun Microsystems, Inc. 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 80 80 81 81 #ifndef VBOX 82 # define SOFT_VOLUME82 # define SOFT_VOLUME 83 83 #else 84 # undef SOFT_VOLUME84 # undef SOFT_VOLUME 85 85 #endif 86 86 #define SR_FIFOE RT_BIT(4) /* rwc, fifo error */ … … 228 228 229 229 #define MKREGS(prefix, start) \ 230 enum {\231 prefix ## _BDBAR = start,\232 prefix ## _CIV = start + 4,\233 prefix ## _LVI = start + 5,\234 prefix ## _SR = start + 6,\235 prefix ## _PICB = start + 8,\236 prefix ## _PIV = start + 10,\237 prefix ## _CR = start + 11\238 }230 enum { \ 231 prefix ## _BDBAR = start, \ 232 prefix ## _CIV = start + 4, \ 233 prefix ## _LVI = start + 5, \ 234 prefix ## _SR = start + 6, \ 235 prefix ## _PICB = start + 8, \ 236 prefix ## _PIV = start + 10, \ 237 prefix ## _CR = start + 11 \ 238 } 239 239 240 240 enum … … 282 282 r->bd_valid = 1; 283 283 #if !defined(RT_ARCH_X86) && !defined(RT_ARCH_AMD64) 284 # error Please adapt the code (audio buffers are little endian)!284 # error Please adapt the code (audio buffers are little endian)! 285 285 #else 286 286 r->bd.addr = (*(uint32_t *) &b[0]) & ~3; … … 417 417 s, pi_callback, &as); 418 418 #ifdef LOG_VOICES 419 LogRel (("AC97: open PI freq=%d (%s)\n", freq, s->voice_pi ? "ok" : "FAIL"));419 LogRel (("AC97: open PI freq=%d (%s)\n", freq, s->voice_pi ? "ok" : "FAIL")); 420 420 #endif 421 421 break; … … 425 425 s, po_callback, &as); 426 426 #ifdef LOG_VOICES 427 LogRel (("AC97: open PO freq=%d (%s)\n", freq, s->voice_po ? "ok" : "FAIL"));427 LogRel (("AC97: open PO freq=%d (%s)\n", freq, s->voice_po ? "ok" : "FAIL")); 428 428 #endif 429 429 break; … … 433 433 s, mc_callback, &as); 434 434 #ifdef LOG_VOICES 435 LogRel (("AC97: open MC freq=%d (%s)\n", freq, s->voice_mc ? "ok" : "FAIL"));435 LogRel (("AC97: open MC freq=%d (%s)\n", freq, s->voice_mc ? "ok" : "FAIL")); 436 436 #endif 437 437 break; … … 445 445 AUD_close_in (&s->card, s->voice_pi); 446 446 #ifdef LOG_VOICES 447 LogRel (("AC97: Closing PCM IN\n"));447 LogRel (("AC97: Closing PCM IN\n")); 448 448 #endif 449 449 s->voice_pi = NULL; … … 453 453 AUD_close_out (&s->card, s->voice_po); 454 454 #ifdef LOG_VOICES 455 LogRel (("AC97: Closing PCM OUT\n"));455 LogRel (("AC97: Closing PCM OUT\n")); 456 456 #endif 457 457 s->voice_po = NULL; … … 461 461 AUD_close_in (&s->card, s->voice_mc); 462 462 #ifdef LOG_VOICES 463 LogRel (("AC97: Closing MIC IN\n"));463 LogRel (("AC97: Closing MIC IN\n")); 464 464 #endif 465 465 s->voice_mc = NULL; … … 487 487 488 488 #ifdef USE_MIXER 489 489 490 static void set_volume (AC97LinkState *s, int index, 490 491 audmixerctl_t mt, uint32_t val) … … 496 497 lvol = 255 * lvol / VOL_MASK; 497 498 498 # ifdef SOFT_VOLUME499 # ifdef SOFT_VOLUME 499 500 if (index == AC97_Master_Volume_Mute) 500 501 AUD_set_volume_out (s->voice_po, mute, lvol, rvol); 501 502 else 502 503 AUD_set_volume (mt, &mute, &lvol, &rvol); 503 # else504 # else 504 505 AUD_set_volume (mt, &mute, &lvol, &rvol); 505 # endif506 # endif 506 507 507 508 rvol = VOL_MASK - ((VOL_MASK * rvol) / 255); 508 509 lvol = VOL_MASK - ((VOL_MASK * lvol) / 255); 509 510 510 #ifdef VBOX511 511 /* 512 512 * From AC'97 SoundMax Codec AD1981A: "Because AC '97 defines 6-bit volume registers, to … … 521 521 if (val & RT_BIT(13)) 522 522 val |= RT_BIT(12) | RT_BIT(11) | RT_BIT(10) | RT_BIT(9) | RT_BIT(8); 523 #endif524 523 525 524 mixer_store (s, index, val); … … 567 566 mixer_store (s, AC97_Record_Select, rs | (ls << 8)); 568 567 } 569 #endif 568 569 #endif /* USE_MIXER */ 570 570 571 571 static void mixer_reset (AC97LinkState *s) … … 804 804 } 805 805 806 Log (("r->picb = %d\n", r->picb));806 Log (("r->picb = %d\n", r->picb)); 807 807 808 808 if (!r->picb) … … 1275 1275 record_select (s, u32); 1276 1276 break; 1277 #else 1277 #else /* !USE_MIXER */ 1278 1278 case AC97_Master_Volume_Mute: 1279 1279 case AC97_PCM_Out_Volume_Mute: … … 1282 1282 mixer_store (s, index, u32); 1283 1283 break; 1284 #endif 1284 #endif /* !USE_MIXER */ 1285 1285 case AC97_Vendor_ID1: 1286 1286 case AC97_Vendor_ID2: … … 1497 1497 #ifdef USE_MIXER 1498 1498 record_select (s, mixer_load (s, AC97_Record_Select)); 1499 # define V_(a, b) set_volume (s, a, b, mixer_load (s, a))1499 # define V_(a, b) set_volume (s, a, b, mixer_load (s, a)) 1500 1500 V_ (AC97_Master_Volume_Mute, AUD_MIXER_VOLUME); 1501 1501 V_ (AC97_PCM_Out_Volume_Mute, AUD_MIXER_PCM); 1502 1502 V_ (AC97_Line_In_Volume_Mute, AUD_MIXER_LINE_IN); 1503 # undef V_1504 #endif 1503 # undef V_ 1504 #endif /* USE_MIXER */ 1505 1505 reset_voices (s, active); 1506 1506 … … 1520 1520 * make sense to me so we'll do it. 1521 1521 */ 1522 static DECLCALLBACK(void) ac97Reset (PPDMDEVINS pDevIns)1522 static DECLCALLBACK(void) ac97Reset (PPDMDEVINS pDevIns) 1523 1523 { 1524 1524 PCIAC97LinkState *pData = PDMINS2DATA(pDevIns, PCIAC97LinkState *); … … 1536 1536 * the codec manually. 1537 1537 */ 1538 mixer_reset (&pData->ac97);1538 mixer_reset (&pData->ac97); 1539 1539 } 1540 1540 … … 1599 1599 1600 1600 /* PCI Device */ 1601 /** @todo convert to PCI*(). */ 1601 1602 pData->dev.config[0x00] = 0x86; /* vid vendor id intel ro */ 1602 1603 pData->dev.config[0x01] = 0x80; /* intel */ … … 1643 1644 */ 1644 1645 rc = PDMDevHlpPCIRegister (pDevIns, &pData->dev); 1645 if (VBOX_FAILURE (rc))1646 if (VBOX_FAILURE (rc)) 1646 1647 return rc; 1647 1648 1648 1649 rc = PDMDevHlpPCIIORegionRegister (pDevIns, 0, 256, PCI_ADDRESS_SPACE_IO, 1649 1650 ichac97IOPortMap); 1650 if (VBOX_FAILURE (rc))1651 if (VBOX_FAILURE (rc)) 1651 1652 return rc; 1652 1653 1653 1654 rc = PDMDevHlpPCIIORegionRegister (pDevIns, 1, 64, PCI_ADDRESS_SPACE_IO, 1654 1655 ichac97IOPortMap); 1655 if (VBOX_FAILURE (rc))1656 if (VBOX_FAILURE (rc)) 1656 1657 return rc; 1657 1658 … … 1660 1661 NULL, ichac97SaveExec, NULL, 1661 1662 NULL, ichac97LoadExec, NULL); 1662 if (VBOX_FAILURE (rc))1663 if (VBOX_FAILURE (rc)) 1663 1664 return rc; 1664 1665 … … 1670 1671 if (rc == VERR_PDM_NO_ATTACHED_DRIVER) 1671 1672 Log (("ac97: No attached driver!\n")); 1672 else if (VBOX_FAILURE (rc))1673 { 1674 AssertMsgFailed (("Failed to attach AC97 LUN #0! rc=%Vrc\n", rc));1673 else if (VBOX_FAILURE (rc)) 1674 { 1675 AssertMsgFailed (("Failed to attach AC97 LUN #0! rc=%Vrc\n", rc)); 1675 1676 return rc; 1676 1677 } … … 1678 1679 AUD_register_card ("ICH0", &s->card); 1679 1680 1680 ac97Reset (pDevIns);1681 ac97Reset (pDevIns); 1681 1682 1682 1683 #ifndef RT_OS_DARWIN /* coreaudio doesn't supply these. */ 1683 1684 if (!s->voice_pi) 1684 LogRel (("AC97: WARNING: Unable to open PCM IN!\n"));1685 LogRel (("AC97: WARNING: Unable to open PCM IN!\n")); 1685 1686 if (!s->voice_mc) 1686 LogRel (("AC97: WARNING: Unable to open PCM MC!\n"));1687 LogRel (("AC97: WARNING: Unable to open PCM MC!\n")); 1687 1688 #endif 1688 1689 if (!s->voice_po) 1689 LogRel (("AC97: WARNING: Unable to open PCM OUT!\n"));1690 LogRel (("AC97: WARNING: Unable to open PCM OUT!\n")); 1690 1691 1691 1692 if (!s->voice_pi && !s->voice_po && !s->voice_mc) … … 1698 1699 s->voice_pi = NULL; 1699 1700 s->voice_mc = NULL; 1700 AUD_init_null ();1701 ac97Reset (pDevIns);1702 1703 PDMDevHlpVMSetRuntimeError (pDevIns, false, "HostAudioNotResponding",1704 N_("No audio devices could be opened. Selecting the NULL audio backend "1701 AUD_init_null (); 1702 ac97Reset (pDevIns); 1703 1704 PDMDevHlpVMSetRuntimeError (pDevIns, false, "HostAudioNotResponding", 1705 N_ ("No audio devices could be opened. Selecting the NULL audio backend " 1705 1706 "with the consequence that no sound is audible.")); 1706 1707 } … … 1710 1711 char szMissingVoices[128]; 1711 1712 size_t len = 0; 1712 bool fComma = false;1713 1713 if (!s->voice_pi) 1714 { 1715 len = RTStrPrintf(szMissingVoices, sizeof(szMissingVoices), "PCM_in"); 1716 fComma = true; 1717 } 1714 len = RTStrPrintf (szMissingVoices, sizeof(szMissingVoices), "PCM_in"); 1718 1715 if (!s->voice_po) 1719 { 1720 len = RTStrPrintf(szMissingVoices + len, sizeof(szMissingVoices)-len, "%sPCM_out", 1721 fComma ? ", " : ""); 1722 fComma = true; 1723 } 1716 len += RTStrPrintf (szMissingVoices + len, sizeof(szMissingVoices) - len, len ? ", PCM_out" : "PCM_out"); 1724 1717 if (!s->voice_mc) 1725 { 1726 len = RTStrPrintf(szMissingVoices + len, sizeof(szMissingVoices)-len, "%sPCM_mic", 1727 fComma ? ", " : ""); 1728 } 1729 1730 PDMDevHlpVMSetRuntimeError(pDevIns, false, "HostAudioNotResponding", 1731 N_("Some audio devices (%s) could not be opened. Guest applications generating audio " 1718 len += RTStrPrintf (szMissingVoices + len, sizeof(szMissingVoices) - len, len ? ", PCM_mic" : "PCM_mic"); 1719 1720 PDMDevHlpVMSetRuntimeError (pDevIns, false, "HostAudioNotResponding", 1721 N_ ("Some audio devices (%s) could not be opened. Guest applications generating audio " 1732 1722 "output or depending on audio input may hang. Make sure your host audio device " 1733 1723 "is working properly. Check the logfile for error messages of the audio "
Note:
See TracChangeset
for help on using the changeset viewer.