VirtualBox

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


Ignore:
Timestamp:
Nov 6, 2010 6:02:43 AM (14 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
67462
Message:

Audio/HDA: converter formats and pin sense more sane.

File:
1 edited

Legend:

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

    r33810 r33817  
    214214#define CODEC_F05_ACT(value)        (((value) & 0x7) >> 4)
    215215#define CODEC_F05_SET(value)        (((value) & 0x7))
     216
     217/* Converter formats (7.3.3.8) and (3.7.1) */
     218#define CODEC_MAKE_A(fNonPCM, f44_1BaseRate, mult, div, bits, chan) \
     219    (  (((fNonPCM) & 0x1) << 15)                                    \
     220     | (((f44_1BaseRate) & 0x1) << 14)                              \
     221     | (((mult) & 0x7) << 11)                                       \
     222     | (((div) & 0x7) << 8)                                         \
     223     | (((bits) & 0x7) << 4)                                        \
     224     | ((chan) & 0xF))
     225
     226#define CODEC_A_MULT_1X     (0)
     227#define CODEC_A_MULT_2X     (1)
     228#define CODEC_A_MULT_3X     (2)
     229#define CODEC_A_MULT_4X     (3)
     230
     231#define CODEC_A_DIV_1X      (0)
     232#define CODEC_A_DIV_2X      (1)
     233#define CODEC_A_DIV_3X      (2)
     234#define CODEC_A_DIV_4X      (3)
     235#define CODEC_A_DIV_5X      (4)
     236#define CODEC_A_DIV_6X      (5)
     237#define CODEC_A_DIV_7X      (6)
     238#define CODEC_A_DIV_8X      (7)
     239
     240#define CODEC_A_8_BIT       (0)
     241#define CODEC_A_16_BIT      (1)
     242#define CODEC_A_20_BIT      (2)
     243#define CODEC_A_24_BIT      (3)
     244#define CODEC_A_32_BIT      (4)
     245
     246/* Pin Sense (7.3.3.15) */
     247#define CODEC_MAKE_F09_ANALOG(fPresent, impedance)  \
     248(  (((fPresent) & 0x1) << 31)                       \
     249 | (((impedance) & 0x7FFFFFFF)))
     250#define CODEC_F09_ANALOG_NA    0x7FFFFFFF
     251#define CODEC_MAKE_F09_DIGITAL(fPresent, fELDValid) \
     252(   (((fPresent) & 0x1) << 31)                      \
     253  | (((fELDValid) & 0x1) << 30))
    216254
    217255/* HDA spec 7.3.3.31 defines layout of configuration registers/verbs (0xF1C) */
     
    426464        dac_init:
    427465            memset(pNode->dac.B_params, 0, AMPLIFIER_SIZE);
    428             pNode->dac.u32A_param = RT_BIT(14)|(0x1 << 4)|0x1; /* 441000Hz/16bit/2ch */
     466            pNode->dac.u32A_param = CODEC_MAKE_A(0, 1, CODEC_A_MULT_1X, CODEC_A_DIV_1X, CODEC_A_16_BIT, 1);//RT_BIT(14)|(0x1 << 4)|0x1; /* 441000Hz/16bit/2ch */
    429467
    430468            AMPLIFIER_REGISTER(pNode->dac.B_params, AMPLIFIER_OUT, AMPLIFIER_LEFT, 0) = 0x7F | RT_BIT(7);
     
    447485            pNode->node.au32F02_param[0] = 0x18;
    448486        adc_init:
    449             pNode->adc.u32A_param = RT_BIT(14)|(0x1 << 3)|0x1; /* 441000Hz/16bit/2ch */
     487            pNode->adc.u32A_param = CODEC_MAKE_A(0, 1, CODEC_A_MULT_1X, CODEC_A_DIV_1X, CODEC_A_16_BIT, 1);//RT_BIT(14)|(0x1 << 3)|0x1; /* 441000Hz/16bit/2ch */
    450488            pNode->adc.node.au32F00_param[0xE] = CODEC_MAKE_F00_0E(0, 1);//RT_BIT(0);
    451489            pNode->adc.u32F03_param = RT_BIT(0);
     
    460498        case 8:
    461499            pNode->spdifout.node.name = "SPDIFOut";
    462             pNode->spdifout.u32A_param = (1<<14)|(0x1<<4) | 0x1;
     500            pNode->spdifout.u32A_param = CODEC_MAKE_A(0, 1, CODEC_A_MULT_1X, CODEC_A_DIV_1X, CODEC_A_16_BIT, 1);//(1<<14)|(0x1<<4) | 0x1;
    463501            pNode->spdifout.node.au32F00_param[9] =   CODEC_MAKE_F00_09(CODEC_F00_09_TYPE_AUDIO_OUTPUT, 0x4, 0)
    464502                                                    | CODEC_F00_09_CAP_DIGITAL
     
    472510        case 9:
    473511            pNode->node.name = "Reserved_0";
    474             pNode->spdifin.u32A_param = (0x1<<4) | 0x1;
     512            pNode->spdifin.u32A_param = CODEC_MAKE_A(0, 1, CODEC_A_MULT_1X, CODEC_A_DIV_1X, CODEC_A_16_BIT, 1);//(0x1<<4) | 0x1;
    475513            pNode->spdifin.node.au32F00_param[9] =   CODEC_MAKE_F00_09(CODEC_F00_09_TYPE_AUDIO_INPUT, 0x4, 0)
    476514                                                   | CODEC_F00_09_CAP_DIGITAL
     
    561599                                                                       0x0, 0x5, 0x0);//RT_MAKE_U32_FROM_U8(0x50, 0x90, 0xA1, 0x02); /* Microphone */
    562600        port_init:
    563             pNode->port.u32F09_param = RT_BIT(31)|0x7fffffff;
     601            pNode->port.u32F09_param = CODEC_MAKE_F09_ANALOG(1, CODEC_F09_ANALOG_NA);//RT_BIT(31)|0x7fffffff;
    564602            pNode->port.u32F08_param = 0;
    565603            pNode->node.au32F00_param[9] =   CODEC_MAKE_F00_09(CODEC_F00_09_TYPE_PIN_COMPLEX, 0x0, 0)
     
    579617                                             | CODEC_F00_0C_CAP_PRESENSE_DETECT;//0x34;
    580618            pNode->port.u32F07_param = RT_BIT(5);
    581             pNode->port.u32F09_param = 0x7fffffff;
     619            pNode->port.u32F09_param = CODEC_MAKE_F09_ANALOG(0, CODEC_F09_ANALOG_NA);//0x7fffffff;
    582620            if (!pState->fInReset)
    583621                pNode->port.u32F1c_param = CODEC_MAKE_U32_DEFAULT_CONF(CODEC_DEFAULT_CONF_PORT_COMPLEX,
     
    611649                                                                       0x0, 0x1, 0x2);//RT_MAKE_U32_FROM_U8(0x12, 0x60, 0x11, 0x01);
    612650            pNode->node.au32F02_param[0] = 0x5;
    613             pNode->port.u32F09_param = 0x7fffffff;
     651            pNode->port.u32F09_param = CODEC_MAKE_F09_ANALOG(0, CODEC_F09_ANALOG_NA);//0x7fffffff;
    614652        break;
    615653        case 0x10:
     
    841879            pNode->node.au32F00_param[0x9] = 0x11;
    842880            pNode->node.au32F00_param[0xB] = CODEC_F00_0B_PCM;
    843             pNode->dac.u32A_param = (1<<14)|(0x1<<4) | 0x1;
     881            pNode->dac.u32A_param = CODEC_MAKE_A(0, 1, CODEC_A_MULT_1X, CODEC_A_DIV_1X, CODEC_A_16_BIT, 1);//(1<<14)|(0x1<<4) | 0x1;
    844882            break;
    845883        /* SPDIFs */
     
    849887            pNode->node.au32F00_param[0xB] = 0x1;
    850888            pNode->node.au32F00_param[0xA] = pState->pNodes[1].node.au32F00_param[0xA];
    851             pNode->spdifout.u32A_param = (1<<14)|(0x1<<4) | 0x1;
     889            pNode->spdifout.u32A_param = CODEC_MAKE_A(0, 1, CODEC_A_MULT_1X, CODEC_A_DIV_1X, CODEC_A_16_BIT, 1);//(1<<14)|(0x1<<4) | 0x1;
    852890            break;
    853891        case 0xA:
     
    861899            pNode->node.au32F02_param[3] = RT_MAKE_U32_FROM_U8(0x1F, 0, 0, 0);
    862900            pNode->node.au32F00_param[0xA] = pState->pNodes[1].node.au32F00_param[0xA];
    863             pNode->spdifin.u32A_param = (1<<14)|(0x1<<4) | 0x1;
     901            pNode->spdifin.u32A_param = CODEC_MAKE_A(0, 1, CODEC_A_MULT_1X, CODEC_A_DIV_1X, CODEC_A_16_BIT, 1);//(1<<14)|(0x1<<4) | 0x1;
    864902            break;
    865903        /* VENDOR DEFINE */
     
    933971            pNode->node.au32F00_param[0xE] = 0x1;
    934972            pNode->node.au32F00_param[0xA] = pState->pNodes[1].node.au32F00_param[0xA];
    935             pNode->adc.u32A_param = (1<<14)|(0x1<<4) | 0x1;
     973            pNode->adc.u32A_param = CODEC_MAKE_A(0, 1, CODEC_A_MULT_1X, CODEC_A_DIV_1X, CODEC_A_16_BIT, 1);//(1<<14)|(0x1<<4) | 0x1;
    936974            break;
    937975        /* Ports */
     
    19021940    return VINF_SUCCESS;
    19031941}
     1942
    19041943static int codecGetConverterFormat(struct CODECState *pState, uint32_t cmd, uint64_t *pResp)
    19051944{
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