VirtualBox

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


Ignore:
Timestamp:
Oct 28, 2015 1:32:20 PM (9 years ago)
Author:
vboxsync
Message:

AC97: Fixed AD1980 volume control, added AD1981B chip.

File:
1 edited

Legend:

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

    r58413 r58443  
    166166    AC97_6Ch_Vol_L_R_Surround_Mute = 0x38,
    167167    AC97_Vendor_Reserved           = 0x58,
     168    AC97_AD_Misc                   = 0x76,
    168169    AC97_Vendor_ID1                = 0x7c,
    169170    AC97_Vendor_ID2                = 0x7e
    170171};
    171172
     173/* Codec models. */
     174enum {
     175    Codec_STAC9700 = 0,     /* SigmaTel STAC9700 */
     176    Codec_AD1980,           /* Analog Devices AD1980 */
     177    Codec_AD1981B           /* Analog Devices AD1981B */
     178};
     179
     180/* Analog Devices miscellaneous regiter bits used in AD1980. */
     181#define AD_MISC_LOSEL       RT_BIT(5)   /* Surround (rear) goes to line out outputs. */
     182#define AD_MISC_HPSEL       RT_BIT(10)  /* PCM (front) goes to headphone outputs. */
    172183
    173184/*********************************************************************************************************************************
     
    302313    /** Size of the temporary scratch read/write buffer. */
    303314    uint32_t                cbReadWriteBuf;
     315    /** Codec model. */
     316    uint32_t                uCodecModel;
    304317} AC97STATE;
    305318/** Pointer to the AC97 device state. */
     
    501514    if (i + 2 > sizeof(pThis->mixer_data))
    502515    {
    503         LogFlowFunc(("mixer_store: index %d out of bounds %d\n", i, sizeof(pThis->mixer_data)));
     516        LogFlowFunc(("mixer_load: index %d out of bounds %d\n", i, sizeof(pThis->mixer_data)));
    504517        val = 0xffff;
    505518    }
     
    909922    ichac97MixerStore(pThis, AC97_MIC_ADC_Rate            , 0xbb80);
    910923
    911     if (PCIDevGetSubSystemVendorId(&pThis->PciDev) == 0x1028)
     924    if (pThis->uCodecModel == Codec_AD1980)
    912925    {
    913926        /* Analog Devices 1980 (AD1980) */
     927        ichac97MixerStore(pThis, AC97_Reset                   , 0x0010);    /* Headphones. */
    914928        ichac97MixerStore(pThis, AC97_Vendor_ID1              , 0x4144);
    915929        ichac97MixerStore(pThis, AC97_Vendor_ID2              , 0x5370);
     930        ichac97MixerStore(pThis, AC97_Headphone_Volume_Mute   , 0x8000);
     931    }
     932    else if (pThis->uCodecModel == Codec_AD1981B)
     933    {
     934        /* Analog Devices 1981B (AD1981B) */
     935        ichac97MixerStore(pThis, AC97_Vendor_ID1              , 0x4144);
     936        ichac97MixerStore(pThis, AC97_Vendor_ID2              , 0x5374);
    916937    }
    917938    else
     
    17121733                    break;
    17131734                case AC97_Master_Volume_Mute:
     1735                    if (pThis->uCodecModel == Codec_AD1980)
     1736                        if (ichac97MixerLoad(pThis, AC97_AD_Misc) & AD_MISC_LOSEL)
     1737                            break;  /* Register controls surround (rear), do nothing. */
    17141738                    ichac97SetVolume(pThis, index, PDMAUDIOMIXERCTL_VOLUME, u32);
     1739                    break;
     1740                case AC97_Headphone_Volume_Mute:
     1741                    if (pThis->uCodecModel == Codec_AD1980)
     1742                        if (ichac97MixerLoad(pThis, AC97_AD_Misc) & AD_MISC_HPSEL)
     1743                            /* Register controls PCM (front) outputs. */
     1744                            ichac97SetVolume(pThis, index, PDMAUDIOMIXERCTL_VOLUME, u32);
    17151745                    break;
    17161746                case AC97_PCM_Out_Volume_Mute:
     
    19141944    V_(AC97_Line_In_Volume_Mute, PDMAUDIOMIXERCTL_LINE_IN);
    19151945# undef V_
     1946    if (pThis->uCodecModel == Codec_AD1980)
     1947        if (ichac97MixerLoad(pThis, AC97_AD_Misc) & AD_MISC_HPSEL)
     1948            ichac97SetVolume(pThis, AC97_Headphone_Volume_Mute, PDMAUDIOMIXERCTL_VOLUME,
     1949                             ichac97MixerLoad(pThis, AC97_Headphone_Volume_Mute));
     1950
    19161951    ichac97ResetStreams(pThis, active);
    19171952
     
    21032138     * The AD1980 codec (with corresponding PCI subsystem vendor ID) is whitelisted
    21042139     * in the Linux kernel; Linux makes no attempt to measure the data rate and assumes
    2105      * 48 kHz rate, which is exactly what we need.
     2140     * 48 kHz rate, which is exactly what we need. Same goes for AD1981B.
    21062141     */
    21072142    bool fChipAD1980 = false;
    21082143    if (!strcmp(szCodec, "STAC9700"))
    2109         fChipAD1980 = false;
     2144        pThis->uCodecModel = Codec_STAC9700;
    21102145    else if (!strcmp(szCodec, "AD1980"))
    2111         fChipAD1980 = true;
     2146        pThis->uCodecModel = Codec_AD1980;
     2147    else if (!strcmp(szCodec, "AD1981B"))
     2148        pThis->uCodecModel = Codec_AD1981B;
    21122149    else
    21132150    {
     
    21412178    PCIDevSetInterruptPin     (&pThis->PciDev, 0x01);   /* 3d ro - INTA#. */               Assert(pThis->PciDev.config[0x3d] == 0x01);
    21422179
    2143     if (fChipAD1980)
     2180    if (pThis->uCodecModel == Codec_AD1980)
    21442181    {
    21452182        PCIDevSetSubSystemVendorId(&pThis->PciDev, 0x1028); /* 2c ro - Dell.) */
    21462183        PCIDevSetSubSystemId      (&pThis->PciDev, 0x0177); /* 2e ro. */
     2184    }
     2185    else if (pThis->uCodecModel == Codec_AD1981B)
     2186    {
     2187        PCIDevSetSubSystemVendorId(&pThis->PciDev, 0x1028); /* 2c ro - Dell.) */
     2188        PCIDevSetSubSystemId      (&pThis->PciDev, 0x01ad); /* 2e ro. */
    21472189    }
    21482190    else
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