Changeset 71706 in vbox
- Timestamp:
- Apr 6, 2018 1:40:08 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/DevHDA.cpp
r71704 r71706 110 110 # define VBOX_WITH_HDA_AUDIO_INTERLEAVING_STREAMS_SUPPORT 111 111 #endif 112 113 /** 114 * Acquires the HDA lock. 115 */ 116 #define DEVHDA_LOCK(a_pThis) \ 117 do { \ 118 int rcLock = PDMCritSectEnter(&(a_pThis)->CritSect, VERR_IGNORED); \ 119 AssertRC(rcLock); \ 120 } while (0) 121 122 /** 123 * Acquires the HDA lock or returns. 124 */ 125 # define DEVHDA_LOCK_RETURN(a_pThis, a_rcBusy) \ 126 do { \ 127 int rcLock = PDMCritSectEnter(&(a_pThis)->CritSect, a_rcBusy); \ 128 if (rcLock != VINF_SUCCESS) \ 129 { \ 130 AssertRC(rcLock); \ 131 return rcLock; \ 132 } \ 133 } while (0) 134 135 /** 136 * Acquires the HDA lock or returns. 137 */ 138 # define DEVHDA_LOCK_RETURN_VOID(a_pThis) \ 139 do { \ 140 int rcLock = PDMCritSectEnter(&(a_pThis)->CritSect, VERR_IGNORED); \ 141 if (rcLock != VINF_SUCCESS) \ 142 { \ 143 AssertRC(rcLock); \ 144 return; \ 145 } \ 146 } while (0) 147 148 /** 149 * Releases the HDA lock. 150 */ 151 #define DEVHDA_UNLOCK(a_pThis) \ 152 do { PDMCritSectLeave(&(a_pThis)->CritSect); } while (0) 153 154 /** 155 * Acquires the TM lock and HDA lock, returns on failure. 156 */ 157 #define DEVHDA_LOCK_BOTH_RETURN_VOID(a_pThis, a_SD) \ 158 do { \ 159 int rcLock = TMTimerLock((a_pThis)->pTimer[a_SD], VERR_IGNORED); \ 160 if (rcLock != VINF_SUCCESS) \ 161 { \ 162 AssertRC(rcLock); \ 163 return; \ 164 } \ 165 rcLock = PDMCritSectEnter(&(a_pThis)->CritSect, VERR_IGNORED); \ 166 if (rcLock != VINF_SUCCESS) \ 167 { \ 168 AssertRC(rcLock); \ 169 TMTimerUnlock((a_pThis)->pTimer[a_SD]); \ 170 return; \ 171 } \ 172 } while (0) 173 174 /** 175 * Acquires the TM lock and HDA lock, returns on failure. 176 */ 177 #define DEVHDA_LOCK_BOTH_RETURN(a_pThis, a_SD, a_rcBusy) \ 178 do { \ 179 int rcLock = TMTimerLock((a_pThis)->pTimer[a_SD], (a_rcBusy)); \ 180 if (rcLock != VINF_SUCCESS) \ 181 return rcLock; \ 182 rcLock = PDMCritSectEnter(&(a_pThis)->CritSect, (a_rcBusy)); \ 183 if (rcLock != VINF_SUCCESS) \ 184 { \ 185 AssertRC(rcLock); \ 186 TMTimerUnlock((a_pThis)->pTimer[a_SD]); \ 187 return rcLock; \ 188 } \ 189 } while (0) 190 191 /** 192 * Releases the HDA lock and TM lock. 193 */ 194 #define DEVHDA_UNLOCK_BOTH(a_pThis, a_SD) \ 195 do { \ 196 PDMCritSectLeave(&(a_pThis)->CritSect); \ 197 TMTimerUnlock((a_pThis)->pTimer[a_SD]); \ 198 } while (0) 112 199 113 200 … … 451 538 }; 452 539 453 /** 454 * Acquires the HDA lock. 455 */ 456 #define DEVHDA_LOCK(a_pThis) \ 457 do { \ 458 int rcLock = PDMCritSectEnter(&(a_pThis)->CritSect, VERR_IGNORED); \ 459 AssertRC(rcLock); \ 460 } while (0) 461 462 /** 463 * Acquires the HDA lock or returns. 464 */ 465 # define DEVHDA_LOCK_RETURN(a_pThis, a_rcBusy) \ 466 do { \ 467 int rcLock = PDMCritSectEnter(&(a_pThis)->CritSect, a_rcBusy); \ 468 if (rcLock != VINF_SUCCESS) \ 469 { \ 470 AssertRC(rcLock); \ 471 return rcLock; \ 472 } \ 473 } while (0) 474 475 /** 476 * Acquires the HDA lock or returns. 477 */ 478 # define DEVHDA_LOCK_RETURN_VOID(a_pThis) \ 479 do { \ 480 int rcLock = PDMCritSectEnter(&(a_pThis)->CritSect, VERR_IGNORED); \ 481 if (rcLock != VINF_SUCCESS) \ 482 { \ 483 AssertRC(rcLock); \ 484 return; \ 485 } \ 486 } while (0) 487 488 /** 489 * Releases the HDA lock. 490 */ 491 #define DEVHDA_UNLOCK(a_pThis) \ 492 do { PDMCritSectLeave(&(a_pThis)->CritSect); } while (0) 493 494 /** 495 * Acquires the TM lock and HDA lock, returns on failure. 496 */ 497 #define DEVHDA_LOCK_BOTH_RETURN_VOID(a_pThis, a_SD) \ 498 do { \ 499 int rcLock = TMTimerLock((a_pThis)->pTimer[a_SD], VERR_IGNORED); \ 500 if (rcLock != VINF_SUCCESS) \ 501 { \ 502 AssertRC(rcLock); \ 503 return; \ 504 } \ 505 rcLock = PDMCritSectEnter(&(a_pThis)->CritSect, VERR_IGNORED); \ 506 if (rcLock != VINF_SUCCESS) \ 507 { \ 508 AssertRC(rcLock); \ 509 TMTimerUnlock((a_pThis)->pTimer[a_SD]); \ 510 return; \ 511 } \ 512 } while (0) 513 514 /** 515 * Acquires the TM lock and HDA lock, returns on failure. 516 */ 517 #define DEVHDA_LOCK_BOTH_RETURN(a_pThis, a_SD, a_rcBusy) \ 518 do { \ 519 int rcLock = TMTimerLock((a_pThis)->pTimer[a_SD], (a_rcBusy)); \ 520 if (rcLock != VINF_SUCCESS) \ 521 return rcLock; \ 522 rcLock = PDMCritSectEnter(&(a_pThis)->CritSect, (a_rcBusy)); \ 523 if (rcLock != VINF_SUCCESS) \ 524 { \ 525 AssertRC(rcLock); \ 526 TMTimerUnlock((a_pThis)->pTimer[a_SD]); \ 527 return rcLock; \ 528 } \ 529 } while (0) 530 531 /** 532 * Releases the HDA lock and TM lock. 533 */ 534 #define DEVHDA_UNLOCK_BOTH(a_pThis, a_SD) \ 535 do { \ 536 PDMCritSectLeave(&(a_pThis)->CritSect); \ 537 TMTimerUnlock((a_pThis)->pTimer[a_SD]); \ 538 } while (0) 540 539 541 540 542 #ifdef IN_RING3 543 541 544 /** 542 545 * Retrieves the number of bytes of a FIFOW register. … … 586 589 LogFunc(("fInterrupt=%RTbool\n", fInterrupt)); 587 590 588 # ifndef DEBUG591 # ifndef DEBUG 589 592 hdaProcessInterrupt(pThis); 590 # else593 # else 591 594 hdaProcessInterrupt(pThis, __FUNCTION__); 592 #endif 593 } 594 #endif 595 # endif 596 } 597 598 #endif /* IN_RING3 */ 595 599 596 600 /** … … 700 704 701 705 #ifdef IN_RING3 706 702 707 /** 703 708 * Synchronizes the CORB / RIRB buffers between internal <-> device state. … … 738 743 } 739 744 740 # ifdef DEBUG_CMD_BUFFER745 # ifdef DEBUG_CMD_BUFFER 741 746 LogFunc(("fLocal=%RTbool\n", fLocal)); 742 747 … … 762 767 } while(i != 0); 763 768 764 do { 769 do 770 { 765 771 LogFunc(("RIRB%02x: ", i)); 766 772 uint8_t j = 0; 767 do { 773 do 774 { 768 775 const char *prefix; 769 776 if ((i + j) == HDA_REG(pThis, RIRBWP)) … … 776 783 i += 8; 777 784 } while (i != 0); 778 # endif785 # endif 779 786 return rc; 780 787 } … … 782 789 /** 783 790 * Processes the next CORB buffer command in the queue. 791 * 784 792 * This will invoke the HDA codec verb dispatcher. 785 793 * … … 865 873 HDA_REG(pThis, RIRBSTS) |= HDA_RIRBSTS_RINTFL; 866 874 867 # ifndef DEBUG875 # ifndef DEBUG 868 876 rc = hdaProcessInterrupt(pThis); 869 # else877 # else 870 878 rc = hdaProcessInterrupt(pThis, __FUNCTION__); 871 # endif879 # endif 872 880 } 873 881 } … … 888 896 return rc; 889 897 } 898 890 899 #endif /* IN_RING3 */ 891 900 … … 1061 1070 * @remark Does not actually set the wall clock counter. 1062 1071 */ 1063 uint64_t hdaWalClkGetMax(PHDASTATE pThis)1072 static uint64_t hdaWalClkGetMax(PHDASTATE pThis) 1064 1073 { 1065 1074 const uint64_t u64WalClkCur = ASMAtomicReadU64(&pThis->u64WalClk); … … 2335 2344 2336 2345 #ifdef IN_RING3 2346 2337 2347 /** 2338 2348 * Retrieves a corresponding sink for a given mixer control. … … 2354 2364 pSink = &pThis->SinkFront; 2355 2365 break; 2356 # ifdef VBOX_WITH_AUDIO_HDA_51_SURROUND2366 # ifdef VBOX_WITH_AUDIO_HDA_51_SURROUND 2357 2367 case PDMAUDIOMIXERCTL_CENTER_LFE: 2358 2368 pSink = &pThis->SinkCenterLFE; … … 2361 2371 pSink = &pThis->SinkRear; 2362 2372 break; 2363 # endif2373 # endif 2364 2374 case PDMAUDIOMIXERCTL_LINE_IN: 2365 2375 pSink = &pThis->SinkLineIn; 2366 2376 break; 2367 # ifdef VBOX_WITH_AUDIO_HDA_MIC_IN2377 # ifdef VBOX_WITH_AUDIO_HDA_MIC_IN 2368 2378 case PDMAUDIOMIXERCTL_MIC_IN: 2369 2379 pSink = &pThis->SinkMicIn; 2370 2380 break; 2371 # endif2381 # endif 2372 2382 default: 2373 2383 pSink = NULL; … … 2421 2431 pDrvStream = &pDrv->LineIn; 2422 2432 break; 2423 # ifdef VBOX_WITH_AUDIO_HDA_MIC_IN2433 # ifdef VBOX_WITH_AUDIO_HDA_MIC_IN 2424 2434 case PDMAUDIORECSOURCE_MIC: 2425 2435 pDrvStream = &pDrv->MicIn; 2426 2436 break; 2427 # endif2437 # endif 2428 2438 default: 2429 2439 rc = VERR_NOT_SUPPORTED; … … 2440 2450 pDrvStream = &pDrv->Front; 2441 2451 break; 2442 # ifdef VBOX_WITH_AUDIO_HDA_51_SURROUND2452 # ifdef VBOX_WITH_AUDIO_HDA_51_SURROUND 2443 2453 case PDMAUDIOPLAYBACKDEST_CENTER_LFE: 2444 2454 pDrvStream = &pDrv->CenterLFE; … … 2447 2457 pDrvStream = &pDrv->Rear; 2448 2458 break; 2449 # endif2459 # endif 2450 2460 default: 2451 2461 rc = VERR_NOT_SUPPORTED; … … 2521 2531 2522 2532 /** 2533 * @interface_method_impl{HDACODEC,pfnCbMixerAddStream} 2534 * 2523 2535 * Adds a new audio stream to a specific mixer control. 2536 * 2524 2537 * Depending on the mixer control the stream then gets assigned to one of the internal 2525 2538 * mixer sinks, which in turn then handle the mixing of all connected streams to that sink. … … 2553 2566 2554 2567 /** 2568 * @interface_method_impl{HDACODEC,pfnCbMixerRemoveStream} 2569 * 2555 2570 * Removes a specified mixer control from the HDA's mixer. 2556 2571 * … … 2583 2598 pDrv->LineIn.pMixStrm = NULL; 2584 2599 break; 2585 # ifdef VBOX_WITH_AUDIO_HDA_MIC_IN2600 # ifdef VBOX_WITH_AUDIO_HDA_MIC_IN 2586 2601 case PDMAUDIOMIXERCTL_MIC_IN: 2587 2602 pMixStream = pDrv->MicIn.pMixStrm; 2588 2603 pDrv->MicIn.pMixStrm = NULL; 2589 2604 break; 2590 # endif2605 # endif 2591 2606 /* 2592 2607 * Output. … … 2596 2611 pDrv->Front.pMixStrm = NULL; 2597 2612 break; 2598 # ifdef VBOX_WITH_AUDIO_HDA_51_SURROUND2613 # ifdef VBOX_WITH_AUDIO_HDA_51_SURROUND 2599 2614 case PDMAUDIOMIXERCTL_CENTER_LFE: 2600 2615 pMixStream = pDrv->CenterLFE.pMixStrm; … … 2605 2620 pDrv->Rear.pMixStrm = NULL; 2606 2621 break; 2607 # endif2622 # endif 2608 2623 default: 2609 2624 AssertMsgFailed(("Mixer control %d not implemented\n", enmMixerCtl)); … … 2631 2646 2632 2647 /** 2648 * @interface_method_impl{HDACODEC,pfnCbMixerControl} 2649 * 2633 2650 * Controls an input / output converter widget, that is, which converter is connected 2634 2651 * to which stream (and channel). … … 2657 2674 uSD--; 2658 2675 2659 # ifndef VBOX_WITH_AUDIO_HDA_MIC_IN2676 # ifndef VBOX_WITH_AUDIO_HDA_MIC_IN 2660 2677 /* Only SDI0 (Line-In) is supported. */ 2661 2678 if ( hdaGetDirFromSD(uSD) == PDMAUDIODIR_IN … … 2665 2682 uSD = 0; 2666 2683 } 2667 # endif2684 # endif 2668 2685 2669 2686 int rc = VINF_SUCCESS; … … 2742 2759 2743 2760 /** 2761 * @interface_method_impl{HDACODEC,pfnCbMixerSetVolume} 2762 * 2744 2763 * Sets the volume of a specified mixer control. 2745 2764 * … … 2781 2800 * @param pvUser Pointer to associated HDASTREAM. 2782 2801 */ 2783 DECLCALLBACK(void) hdaTimer(PPDMDEVINS pDevIns, PTMTIMER pTimer, void *pvUser)2802 static DECLCALLBACK(void) hdaTimer(PPDMDEVINS pDevIns, PTMTIMER pTimer, void *pvUser) 2784 2803 { 2785 2804 RT_NOREF(pDevIns, pTimer); … … 2813 2832 } 2814 2833 2815 # ifdef HDA_USE_DMA_ACCESS_HANDLER2834 # ifdef HDA_USE_DMA_ACCESS_HANDLER 2816 2835 /** 2817 2836 * HC access handler for the FIFO. … … 2856 2875 case PGMACCESSTYPE_WRITE: 2857 2876 { 2858 # ifdef DEBUG2877 # ifdef DEBUG 2859 2878 PHDASTREAMDBGINFO pStreamDbg = &pStream->Dbg; 2860 2879 … … 2892 2911 pStream->u8SD, pStreamDbg->cWritesTotal, pStreamDbg->cbWrittenTotal, 2893 2912 ASMDivU64ByU32RetU32(pStreamDbg->cbWrittenTotal, pStreamDbg->cWritesTotal))); 2894 # endif2913 # endif 2895 2914 2896 2915 if (pThis->fDebugEnabled) … … 2903 2922 } 2904 2923 2905 # ifdef HDA_USE_DMA_ACCESS_HANDLER_WRITING2924 # ifdef HDA_USE_DMA_ACCESS_HANDLER_WRITING 2906 2925 PRTCIRCBUF pCircBuf = pStream->State.pCircBuf; 2907 2926 AssertPtr(pCircBuf); … … 2933 2952 RTCircBufReleaseWriteBlock(pCircBuf, cbChunk); 2934 2953 } 2935 # endif /* HDA_USE_DMA_ACCESS_HANDLER_WRITING */2954 # endif /* HDA_USE_DMA_ACCESS_HANDLER_WRITING */ 2936 2955 break; 2937 2956 } … … 2944 2963 return VINF_PGM_HANDLER_DO_DEFAULT; 2945 2964 } 2946 # endif /* HDA_USE_DMA_ACCESS_HANDLER */2965 # endif /* HDA_USE_DMA_ACCESS_HANDLER */ 2947 2966 2948 2967 /** … … 3011 3030 * These stream numbers can be changed by the guest dynamically lateron. 3012 3031 */ 3013 # ifdef VBOX_WITH_AUDIO_HDA_MIC_IN3032 # ifdef VBOX_WITH_AUDIO_HDA_MIC_IN 3014 3033 hdaMixerControl(pThis, PDMAUDIOMIXERCTL_MIC_IN , 1 /* SD0 */, 0 /* Channel */); 3015 # endif3034 # endif 3016 3035 hdaMixerControl(pThis, PDMAUDIOMIXERCTL_LINE_IN , 1 /* SD0 */, 0 /* Channel */); 3017 3036 3018 3037 hdaMixerControl(pThis, PDMAUDIOMIXERCTL_FRONT , 5 /* SD4 */, 0 /* Channel */); 3019 # ifdef VBOX_WITH_AUDIO_HDA_51_SURROUND3038 # ifdef VBOX_WITH_AUDIO_HDA_51_SURROUND 3020 3039 hdaMixerControl(pThis, PDMAUDIOMIXERCTL_CENTER_LFE, 5 /* SD4 */, 0 /* Channel */); 3021 3040 hdaMixerControl(pThis, PDMAUDIOMIXERCTL_REAR , 5 /* SD4 */, 0 /* Channel */); 3022 # endif3041 # endif 3023 3042 3024 3043 pThis->cbCorbBuf = HDA_CORB_SIZE * sizeof(uint32_t); … … 3058 3077 LogRel(("HDA: Reset\n")); 3059 3078 } 3060 3061 #ifdef DEBUG_andy3062 # define HDA_DEBUG_DMA3063 #endif3064 3079 3065 3080 #endif /* IN_RING3 */
Note:
See TracChangeset
for help on using the changeset viewer.