Changeset 89347 in vbox for trunk/src/VBox
- Timestamp:
- May 28, 2021 11:10:11 AM (4 years ago)
- svn:sync-xref-src-repo-rev:
- 144696
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/DevSB16.cpp
r89341 r89347 412 412 } 413 413 414 unsigned cShiftChannels = pStream->Cfg.Props.cChannelsX >= 2 ? 1 : 0; 414 /** @todo r=bird: Use '(pThis->mixer_regs[0x0e] & 2) == 0 ? 1 : 2' like below? */ 415 unsigned cShiftChannels = PDMAudioPropsChannels(&pStream->Cfg.Props) >= 2 ? 1 : 0; 415 416 416 417 if (dma_len != -1) … … 455 456 pStream->dma_auto = (cmd >> 2) & 1; 456 457 457 pStream->Cfg.Props.fSigned = RT_BOOL((d0 >> 4) & 1); /** @todo Use RT_BIT? */458 pStream->Cfg.Props.cChannelsX = (d0 >> 5) & 1 ? 2 : 1;458 pStream->Cfg.Props.fSigned = RT_BOOL(d0 & RT_BIT_32(4)); 459 PDMAudioPropsSetChannels(&pStream->Cfg.Props, 1 + ((d0 >> 5) & 1)); 459 460 460 461 switch (cmd >> 4) 461 462 { 462 463 case 11: 463 pStream->Cfg.Props.cbSampleX = 2 /* 16 bit */;464 PDMAudioPropsSetSampleSize(&pStream->Cfg.Props, 2 /*16-bit*/); 464 465 break; 465 466 466 467 case 12: 467 pStream->Cfg.Props.cbSampleX = 1 /* 8 bit */;468 PDMAudioPropsSetSampleSize(&pStream->Cfg.Props, 1 /*8-bit*/); 468 469 break; 469 470 … … 486 487 487 488 pStream->cbDmaBlockSize = dma_len + 1; 488 pStream->cbDmaBlockSize <<= ((pStream->Cfg.Props.cbSampleX == 2) ? 1 : 0);489 pStream->cbDmaBlockSize <<= PDMAudioPropsSampleSize(&pStream->Cfg.Props) == 2 ? 1 : 0; 489 490 if (!pStream->dma_auto) 490 491 { … … 495 496 * wonders of SB16 yet again. 496 497 */ 497 pStream->cbDmaBlockSize <<= pStream->Cfg.Props.cChannelsX== 2 ? 1 : 0;498 pStream->cbDmaBlockSize <<= PDMAudioPropsSampleSize(&pStream->Cfg.Props) == 2 ? 1 : 0; 498 499 } 499 500 … … 823 824 { 824 825 case 0x04: 825 {826 826 pThis->csp_mode = sb16DspGetData(pThis); 827 827 pThis->csp_reg83r = 0; … … 829 829 LogFlowFunc(("CSP command 0x04: mode=%#x\n", pThis->csp_mode)); 830 830 break; 831 }832 831 833 832 case 0x05: 834 {835 833 pThis->csp_param = sb16DspGetData(pThis); 836 834 pThis->csp_value = sb16DspGetData(pThis); 837 835 LogFlowFunc(("CSP command 0x05: param=%#x value=%#x\n", pThis->csp_param, pThis->csp_value)); 838 836 break; 839 }840 837 841 838 case 0x0e: 842 {843 839 v0 = sb16DspGetData(pThis); 844 840 v1 = sb16DspGetData(pThis); … … 853 849 pThis->csp_regs[v1] = v0; 854 850 break; 855 }856 851 857 852 case 0x0f: 858 {859 853 v0 = sb16DspGetData(pThis); 860 854 LogFlowFunc(("read CSP register %#x -> %#x, mode=%#x\n", v0, pThis->csp_regs[v0], pThis->csp_mode)); … … 868 862 sb16DspSeData(pThis, pThis->csp_regs[v0]); 869 863 break; 870 }871 864 872 865 case 0x10: … … 895 888 896 889 case 0x41: /* Sets the output rate (in Hz). */ 897 {898 890 pStream->Cfg.Props.uHz = sb16DspGetHiLo(pThis); 899 891 LogFlowFunc(("set freq to %RU16Hz\n", pStream->Cfg.Props.uHz)); 900 892 break; 901 }902 893 903 894 case 0x48: 904 {905 895 pStream->cbDmaBlockSize = sb16DspGetLoHi(pThis) + 1; 906 896 LogFlowFunc(("set dma block len %d\n", pStream->cbDmaBlockSize)); 907 897 break; 908 }909 898 910 899 case 0x74: 911 RT_FALL_THROUGH();912 900 case 0x75: 913 RT_FALL_THROUGH();914 901 case 0x76: 915 RT_FALL_THROUGH();916 902 case 0x77: 917 903 /* ADPCM stuff, ignore. */ … … 919 905 920 906 case 0x80: /* Sets the IRQ. */ 921 {922 907 sb16StreamTransferScheduleNext(pThis, pStream, sb16DspGetLoHi(pThis) + 1); 923 908 break; 924 }925 909 926 910 case 0xe0: 927 {928 911 v0 = sb16DspGetData(pThis); 929 912 pThis->dsp_out_data_len = 0; … … 931 914 sb16DspSeData(pThis, ~v0); 932 915 break; 933 }934 916 935 917 case 0xe2: 936 {937 918 v0 = sb16DspGetData(pThis); 938 919 LogFlowFunc(("E2=%#x\n", v0)); 939 920 break; 940 }941 921 942 922 case 0xe4: … … 2209 2189 PDMAudioPropsInit(&pStream->Cfg.Props, 1 /* 8-bit */, false /* fSigned */, 1 /* Mono */, 11025 /* uHz */); 2210 2190 RTStrCopy(pStream->Cfg.szName, sizeof(pStream->Cfg.szName), "Output"); 2211 2212 2191 break; 2213 2192 } … … 2238 2217 { 2239 2218 LogFlowFuncEnter(); 2240 2241 PDMAudioPropsInit(&pStream->Cfg.Props, 2242 pStream->Cfg.Props.cbSampleX, 2243 pStream->Cfg.Props.fSigned, 2244 pStream->Cfg.Props.cChannelsX, 2245 pStream->Cfg.Props.uHz); 2246 2247 AssertReturn(PDMAudioPropsAreValid(&pStream->Cfg.Props), VERR_INVALID_PARAMETER); 2219 AssertLogRelReturn(PDMAudioPropsAreValid(&pStream->Cfg.Props), VERR_INTERNAL_ERROR_5); 2248 2220 2249 2221 switch (pStream->uIdx) … … 2438 2410 static int sb16Save(PCPDMDEVHLPR3 pHlp, PSSMHANDLE pSSM, PSB16STATE pThis) 2439 2411 { 2440 /* * Currently the saved state only contains the one-and-only output stream. */2412 /* The saved state only contains the one-and-only output stream. */ 2441 2413 PSB16STREAM pStream = &pThis->aStreams[SB16_IDX_OUT]; 2442 2414 … … 2449 2421 pHlp->pfnSSMPutS32(pSSM, pThis->dsp_out_data_len); 2450 2422 2451 /** Currently the saved state only contains the one-and-only output stream. */ 2452 pHlp->pfnSSMPutS32(pSSM, pStream->Cfg.Props.cChannelsX >= 2 ? 1 : 0); 2453 pHlp->pfnSSMPutS32(pSSM, pStream->Cfg.Props.fSigned ? 1 : 0); 2454 pHlp->pfnSSMPutS32(pSSM, pStream->Cfg.Props.cbSampleX * 8 /* Convert bytes to bits */); 2423 pHlp->pfnSSMPutS32(pSSM, PDMAudioPropsChannels(&pStream->Cfg.Props) >= 2 ? 1 : 0); 2424 pHlp->pfnSSMPutS32(pSSM, PDMAudioPropsIsSigned(&pStream->Cfg.Props) ? 1 : 0); 2425 pHlp->pfnSSMPutS32(pSSM, PDMAudioPropsSampleBits(&pStream->Cfg.Props)); 2455 2426 pHlp->pfnSSMPutU32(pSSM, 0); /* Legacy; was PDMAUDIOFMT, unused now. */ 2456 2427 … … 2458 2429 pHlp->pfnSSMPutS32(pSSM, pStream->cbDmaBlockSize); 2459 2430 pHlp->pfnSSMPutS32(pSSM, pStream->fifo); 2460 pHlp->pfnSSMPutS32(pSSM, pStream->Cfg.Props.uHz);2431 pHlp->pfnSSMPutS32(pSSM, PDMAudioPropsHz(&pStream->Cfg.Props)); 2461 2432 pHlp->pfnSSMPutS32(pSSM, pStream->time_const); 2462 2433 pHlp->pfnSSMPutS32(pSSM, 0); /* Legacy; was speaker control (on/off) for output stream. */ … … 2487 2458 pHlp->pfnSSMPutS32(pSSM, pStream->State.fEnabled ? 1 : 0); 2488 2459 /* The stream's bitrate. Needed for backwards (legacy) compatibility. */ 2489 pHlp->pfnSSMPutS32(pSSM, AudioHlpCalcBitrate( pThis->aStreams[SB16_IDX_OUT].Cfg.Props.cbSampleX * 8,2490 pThis->aStreams[SB16_IDX_OUT].Cfg.Props.uHz,2491 pThis->aStreams[SB16_IDX_OUT].Cfg.Props.cChannelsX));2460 pHlp->pfnSSMPutS32(pSSM, AudioHlpCalcBitrate(PDMAudioPropsSampleBits(&pThis->aStreams[SB16_IDX_OUT].Cfg.Props), 2461 PDMAudioPropsHz(&pThis->aStreams[SB16_IDX_OUT].Cfg.Props), 2462 PDMAudioPropsChannels(&pThis->aStreams[SB16_IDX_OUT].Cfg.Props))); 2492 2463 /* Block size alignment, superfluous and thus not saved anymore. Needed for backwards (legacy) compatibility. */ 2493 2464 pHlp->pfnSSMPutS32(pSSM, 0); … … 2515 2486 { 2516 2487 PCPDMDEVHLPR3 pHlp = pDevIns->pHlpR3; 2517 2518 /** Currently the saved state only contains the one-and-only output stream. */ 2519 PSB16STREAM pStream = &pThis->aStreams[SB16_IDX_OUT]; 2520 2521 int32_t s32Tmp; 2522 pHlp->pfnSSMGetS32(pSSM, &s32Tmp); 2523 pStream->HwCfgRuntime.uIrq = s32Tmp; /* IRQ. */ 2524 pHlp->pfnSSMGetS32(pSSM, &s32Tmp); 2525 pStream->HwCfgRuntime.uDmaChanLow = s32Tmp; /* Low (8-bit) DMA channel. */ 2526 pHlp->pfnSSMGetS32(pSSM, &s32Tmp); 2527 pStream->HwCfgRuntime.uDmaChanHigh = s32Tmp; /* High (16-bit) DMA channel. */ 2528 pHlp->pfnSSMGetS32(pSSM, &s32Tmp); /* Used I/O port. */ 2529 pStream->HwCfgRuntime.uPort = s32Tmp; 2530 pHlp->pfnSSMGetS32(pSSM, &s32Tmp); /* DSP version running. */ 2531 pStream->HwCfgRuntime.uVer = s32Tmp; 2488 PSB16STREAM pStream = &pThis->aStreams[SB16_IDX_OUT]; /* The saved state only contains the one-and-only output stream. */ 2489 int rc; 2490 2491 int32_t i32Tmp; 2492 pHlp->pfnSSMGetS32(pSSM, &i32Tmp); 2493 pStream->HwCfgRuntime.uIrq = i32Tmp; /* IRQ. */ 2494 pHlp->pfnSSMGetS32(pSSM, &i32Tmp); 2495 pStream->HwCfgRuntime.uDmaChanLow = i32Tmp; /* Low (8-bit) DMA channel. */ 2496 pHlp->pfnSSMGetS32(pSSM, &i32Tmp); 2497 pStream->HwCfgRuntime.uDmaChanHigh = i32Tmp; /* High (16-bit) DMA channel. */ 2498 pHlp->pfnSSMGetS32(pSSM, &i32Tmp); /* Used I/O port. */ 2499 pStream->HwCfgRuntime.uPort = i32Tmp; 2500 pHlp->pfnSSMGetS32(pSSM, &i32Tmp); /* DSP version running. */ 2501 pStream->HwCfgRuntime.uVer = i32Tmp; 2532 2502 pHlp->pfnSSMGetS32(pSSM, &pThis->dsp_in_idx); 2533 2503 pHlp->pfnSSMGetS32(pSSM, &pThis->dsp_out_data_len); 2534 pHlp->pfnSSMGetS32(pSSM, &s32Tmp); /* Output stream: Numer of channels. */ 2535 pStream->Cfg.Props.cChannelsX = (uint8_t)s32Tmp; 2536 pHlp->pfnSSMGetS32(pSSM, &s32Tmp); /* Output stream: Signed format bit. */ 2537 pStream->Cfg.Props.fSigned = s32Tmp == 0 ? false : true; 2538 pHlp->pfnSSMGetS32(pSSM, &s32Tmp); 2539 pStream->Cfg.Props.cbSampleX = s32Tmp / 8; /* Convert bits to bytes. */ 2504 2505 rc = pHlp->pfnSSMGetS32(pSSM, &i32Tmp); /* Output stream: Numer of channels. */ 2506 AssertRCReturn(rc, rc); 2507 PDMAudioPropsSetChannels(&pStream->Cfg.Props, i32Tmp); 2508 pHlp->pfnSSMGetS32(pSSM, &i32Tmp); /* Output stream: Signed format bit. */ 2509 pStream->Cfg.Props.fSigned = i32Tmp != 0; 2510 rc = pHlp->pfnSSMGetS32(pSSM, &i32Tmp); /* Output stream: Sample size in bits. */ 2511 AssertRCReturn(rc, rc); 2512 PDMAudioPropsSetSampleSize(&pStream->Cfg.Props, i32Tmp / 8); 2513 2540 2514 pHlp->pfnSSMSkip (pSSM, sizeof(int32_t)); /* Legacy; was PDMAUDIOFMT, unused now. */ 2541 2515 pHlp->pfnSSMGetS32(pSSM, &pStream->dma_auto); 2542 2516 pHlp->pfnSSMGetS32(pSSM, &pThis->aStreams[SB16_IDX_OUT].cbDmaBlockSize); 2543 2517 pHlp->pfnSSMGetS32(pSSM, &pStream->fifo); 2544 pHlp->pfnSSMGetS32(pSSM, & s32Tmp); pStream->Cfg.Props.uHz = s32Tmp;2518 pHlp->pfnSSMGetS32(pSSM, &i32Tmp); pStream->Cfg.Props.uHz = i32Tmp; 2545 2519 pHlp->pfnSSMGetS32(pSSM, &pStream->time_const); 2546 2520 pHlp->pfnSSMSkip (pSSM, sizeof(int32_t)); /* Legacy; was speaker (on / off) for output stream. */ … … 2569 2543 pHlp->pfnSSMGetS32(pSSM, &pThis->nzero); 2570 2544 pHlp->pfnSSMGetS32(pSSM, &pStream->cbDmaLeft); 2571 pHlp->pfnSSMGetS32(pSSM, & s32Tmp); /* Output stream: DMA currently running bit. */2572 const bool fStreamEnabled = s32Tmp == 0 ? false: true;2545 pHlp->pfnSSMGetS32(pSSM, &i32Tmp); /* Output stream: DMA currently running bit. */ 2546 const bool fStreamEnabled = i32Tmp != 0; 2573 2547 pHlp->pfnSSMSkip (pSSM, sizeof(int32_t)); /* Legacy; was the output stream's current bitrate (in bytes). */ 2574 2548 pHlp->pfnSSMSkip (pSSM, sizeof(int32_t)); /* Legacy; was the output stream's DMA block alignment. */ 2575 2549 2576 2550 int32_t mixer_nreg = 0; 2577 intrc = pHlp->pfnSSMGetS32(pSSM, &mixer_nreg);2551 rc = pHlp->pfnSSMGetS32(pSSM, &mixer_nreg); 2578 2552 AssertRCReturn(rc, rc); 2579 2553 pThis->mixer_nreg = (uint8_t)mixer_nreg;
Note:
See TracChangeset
for help on using the changeset viewer.