VirtualBox

Changeset 80609 in vbox for trunk/src/VBox/Devices/Audio


Ignore:
Timestamp:
Sep 5, 2019 3:50:09 PM (5 years ago)
Author:
vboxsync
Message:

Audio/AC97: More code needed for EACS VRA / VRM handling.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Audio/DevIchAc97.cpp

    r80531 r80609  
    663663static int                ichac97R3StreamCreate(PAC97STATE pThis, PAC97STREAM pStream, uint8_t u8Strm);
    664664static void               ichac97R3StreamDestroy(PAC97STATE pThis, PAC97STREAM pStream);
    665 static int                ichac97R3StreamOpen(PAC97STATE pThis, PAC97STREAM pStream);
    666 static int                ichac97R3StreamReOpen(PAC97STATE pThis, PAC97STREAM pStream);
     665static int                ichac97R3StreamOpen(PAC97STATE pThis, PAC97STREAM pStream, bool fForce);
     666static int                ichac97R3StreamReOpen(PAC97STATE pThis, PAC97STREAM pStream, bool fForce);
    667667static int                ichac97R3StreamClose(PAC97STATE pThis, PAC97STREAM pStream);
    668668static void               ichac97R3StreamReset(PAC97STATE pThis, PAC97STREAM pStream);
     
    897897            RTCircBufReset(pStream->State.pCircBuf);
    898898
    899         rc = ichac97R3StreamOpen(pThis, pStream);
     899        rc = ichac97R3StreamOpen(pThis, pStream, false /* fForce */);
    900900
    901901        if (pStream->Dbg.Runtime.fEnabled)
     
    16371637    AssertMsgReturnVoid(uMixerIdx + 2U <= sizeof(pThis->mixer_data),
    16381638                         ("Index %RU8 out of bounds (%zu)\n", uMixerIdx, sizeof(pThis->mixer_data)));
     1639
     1640    LogRel2(("AC97: Setting mixer index #%RU8 to %RU16 (%RU8 %RU8)\n",
     1641             uMixerIdx, uVal, RT_HI_U8(uVal), RT_LO_U8(uVal)));
     1642
    16391643    pThis->mixer_data[uMixerIdx + 0] = RT_LO_U8(uVal);
    16401644    pThis->mixer_data[uMixerIdx + 1] = RT_HI_U8(uVal);
     
    20122016 * @param   pThis               AC'97 device state.
    20132017 * @param   pStream             AC'97 stream to open.
    2014  */
    2015 static int ichac97R3StreamOpen(PAC97STATE pThis, PAC97STREAM pStream)
     2018 * @param   fForce              Whether to force re-opening the stream or not.
     2019 *                              Otherwise re-opening only will happen if the PCM properties have changed.
     2020 */
     2021static int ichac97R3StreamOpen(PAC97STATE pThis, PAC97STREAM pStream, bool fForce)
    20162022{
    20172023    int rc = VINF_SUCCESS;
     
    20742080        /* Only (re-)create the stream (and driver chain) if we really have to.
    20752081         * Otherwise avoid this and just reuse it, as this costs performance. */
    2076         if (!DrvAudioHlpPCMPropsAreEqual(&Cfg.Props, &pStream->State.Cfg.Props))
     2082        if (   !DrvAudioHlpPCMPropsAreEqual(&Cfg.Props, &pStream->State.Cfg.Props)
     2083            || fForce)
    20772084        {
    20782085            LogRel2(("AC97: (Re-)Opening stream '%s' (%RU32Hz, %RU8 channels, %s%RU8)\n",
     
    21502157 * @param   pThis               AC'97 device state.
    21512158 * @param   pStream             AC'97 stream to re-open.
    2152  */
    2153 static int ichac97R3StreamReOpen(PAC97STATE pThis, PAC97STREAM pStream)
     2159 * @param   fForce              Whether to force re-opening the stream or not.
     2160 *                              Otherwise re-opening only will happen if the PCM properties have changed.
     2161 */
     2162static int ichac97R3StreamReOpen(PAC97STATE pThis, PAC97STREAM pStream, bool fForce)
    21542163{
    21552164    LogFlowFunc(("[SD%RU8]\n", pStream->u8SD));
     
    21572166    int rc = ichac97R3StreamClose(pThis, pStream);
    21582167    if (RT_SUCCESS(rc))
    2159         rc = ichac97R3StreamOpen(pThis, pStream);
     2168        rc = ichac97R3StreamOpen(pThis, pStream, fForce);
    21602169
    21612170    return rc;
     
    34953504                case AC97_Extended_Audio_Ctrl_Stat:
    34963505#ifdef IN_RING3
    3497                     if (!(u32Val & AC97_EACS_VRA))
     3506                    /*
     3507                     * Handle VRA bits.
     3508                     */
     3509# ifndef VBOX_WITH_AC97_VRA
     3510                    if (u32Val & AC97_EACS_VRA)
    34983511                    {
    3499                         ichac97MixerSet(pThis, AC97_PCM_Front_DAC_Rate, 48000 /* Default = 0xBB80 */);
    3500                         ichac97R3StreamReOpen(pThis, &pThis->aStreams[AC97SOUNDSOURCE_PO_INDEX]);
    3501 
    3502                         ichac97MixerSet(pThis, AC97_PCM_LR_ADC_Rate,    48000 /* Default = 0xBB80 */);
    3503                         ichac97R3StreamReOpen(pThis, &pThis->aStreams[AC97SOUNDSOURCE_PI_INDEX]);
     3512                        u32Val &= ~AC97_EACS_VRA; /* Only clear VRA bit and keep the rest. */
     3513                        LogRel2(("AC97: Variable rate audio (VRA) is not supported, setting to 0x%x\n", u32Val));
    35043514                    }
    3505                     else
    3506                         LogRel2(("AC97: Variable rate audio (VRA) is not supported\n"));
    3507 
    3508                     if (!(u32Val & AC97_EACS_VRM))
     3515
     3516                    ichac97MixerSet(pThis, AC97_PCM_Front_DAC_Rate, 0xbb80); /* Set default (48000 Hz). */
     3517                    ichac97R3StreamReOpen(pThis, &pThis->aStreams[AC97SOUNDSOURCE_PO_INDEX], true /* fForce */);
     3518
     3519                    ichac97MixerSet(pThis, AC97_PCM_LR_ADC_Rate, 0xbb80); /* Set default (48000 Hz). */
     3520                    ichac97R3StreamReOpen(pThis, &pThis->aStreams[AC97SOUNDSOURCE_PI_INDEX], true /* fForce */);
     3521# else
     3522#  error            "Implement EACS VRA support!"
     3523# endif
     3524                    /*
     3525                     * Handle VRM bits.
     3526                     */
     3527# ifndef VBOX_WITH_AC97_VRM
     3528                    if (u32Val & AC97_EACS_VRM)
    35093529                    {
    3510                         ichac97MixerSet(pThis, AC97_MIC_ADC_Rate,       48000 /* Default = 0xBB80 */);
    3511                         ichac97R3StreamReOpen(pThis, &pThis->aStreams[AC97SOUNDSOURCE_MC_INDEX]);
     3530                        u32Val &= ~AC97_EACS_VRM; /* Only clear VRM bit and keep the rest. */
     3531                        LogRel2(("AC97: Variable rate microphone audio (VRM) is not supported, setting to 0x%x\n", u32Val));
    35123532                    }
    3513                     else
    3514                         LogRel2(("AC97: Variable rate microphone audio (VRM) is not supported\n"));
    3515 
    3516                     LogFunc(("Setting extended audio control to %#x\n", u32Val));
     3533
     3534                    ichac97MixerSet(pThis, AC97_MIC_ADC_Rate, 0xbb80); /* Set default (48000 Hz). */
     3535                    ichac97R3StreamReOpen(pThis, &pThis->aStreams[AC97SOUNDSOURCE_MC_INDEX], true /* fForce */);
     3536# else
     3537#  error            "Implement EACS VRM support!"
     3538# endif
     3539                    LogRel2(("AC97: Setting extended audio control to %#x\n", u32Val));
     3540
    35173541                    ichac97MixerSet(pThis, AC97_Extended_Audio_Ctrl_Stat, u32Val);
    3518 #else
     3542#else /* !IN_RING3 */
    35193543                    rc = VINF_IOM_R3_IOPORT_WRITE;
    35203544#endif
     
    35223546                case AC97_PCM_Front_DAC_Rate: /* Output slots 3, 4, 6. */
    35233547#ifdef IN_RING3
    3524                 if (ichac97MixerGet(pThis, AC97_Extended_Audio_Ctrl_Stat) & AC97_EACS_VRA)
     3548                    if (ichac97MixerGet(pThis, AC97_Extended_Audio_Ctrl_Stat) & AC97_EACS_VRA)
    35253549                    {
    35263550                        ichac97MixerSet(pThis, uPortIdx, u32Val);
     
    35333557                     *       set the VRA rate nevertheless. So re-open the output stream in any case to avoid
    35343558                     *       breaking playback. */
    3535                     ichac97R3StreamReOpen(pThis, &pThis->aStreams[AC97SOUNDSOURCE_PO_INDEX]);
     3559                    ichac97R3StreamReOpen(pThis, &pThis->aStreams[AC97SOUNDSOURCE_PO_INDEX], true /* fForce */);
    35363560#else
    35373561                    rc = VINF_IOM_R3_IOPORT_WRITE;
     
    35523576                     *       set the VRM rate nevertheless. So re-open the mic-in stream in any case to avoid
    35533577                     *       breaking recording.*/
    3554                     ichac97R3StreamReOpen(pThis, &pThis->aStreams[AC97SOUNDSOURCE_MC_INDEX]);
     3578                    ichac97R3StreamReOpen(pThis, &pThis->aStreams[AC97SOUNDSOURCE_MC_INDEX], true /* fForce */);
    35553579#else
    35563580                    rc = VINF_IOM_R3_IOPORT_WRITE;
     
    35703594                     *       set the VRA rate nevertheless. So re-open the line-in stream in any case to avoid
    35713595                     *       breaking recording.*/
    3572                     ichac97R3StreamReOpen(pThis, &pThis->aStreams[AC97SOUNDSOURCE_PI_INDEX]);
     3596                    ichac97R3StreamReOpen(pThis, &pThis->aStreams[AC97SOUNDSOURCE_PI_INDEX], true /* fForce */);
    35733597#else
    35743598                    rc = VINF_IOM_R3_IOPORT_WRITE;
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette