Changeset 32803 in vbox for trunk/src/VBox/Devices/Audio
- Timestamp:
- Sep 29, 2010 2:11:19 AM (14 years ago)
- Location:
- trunk/src/VBox/Devices/Audio
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/DevCodec.cpp
r32626 r32803 22 22 #include <iprt/mem.h> 23 23 #include <iprt/asm.h> 24 #include <iprt/cpp/utils.h> 24 25 25 26 #include "../Builtins.h" … … 73 74 #define CODEC_SET_AMP_INDEX(cmd) (((cmd) & CODEC_VERB_SET_AMP_INDEX) >> 7) 74 75 75 76 #define STAC9220_NODE_COUNT 0x1C 77 78 #define STAC9220_IS_AFG_CMD(cmd) ( \ 79 CODEC_NID(cmd) == 0x1) 80 81 #define STAC9220_IS_PORT_CMD(cmd) ( \ 82 CODEC_NID(cmd) == 0xA \ 83 || CODEC_NID(cmd) == 0xB \ 84 || CODEC_NID(cmd) == 0xC \ 85 || CODEC_NID(cmd) == 0xD \ 86 || CODEC_NID(cmd) == 0xE \ 87 || CODEC_NID(cmd) == 0xF) 88 89 #define STAC9220_IS_DAC_CMD(cmd) ( \ 90 CODEC_NID(cmd) == 0x2 \ 91 || CODEC_NID(cmd) == 0x3 \ 92 || CODEC_NID(cmd) == 0x4 \ 93 || CODEC_NID(cmd) == 0x5) 94 95 #define STAC9220_IS_ADCVOL_CMD(cmd) ( \ 96 CODEC_NID(cmd) == 0x17 \ 97 || CODEC_NID(cmd) == 0x18) 98 99 #define STAC9220_IS_ADC_CMD(cmd) ( \ 100 CODEC_NID(cmd) == 0x6 \ 101 || CODEC_NID(cmd) == 0x7) 102 103 #define STAC9220_IS_ADCMUX_CMD(cmd) ( \ 104 CODEC_NID(cmd) == 0x12 \ 105 || CODEC_NID(cmd) == 0x13) 106 107 #define STAC9220_IS_PCBEEP_CMD(cmd) (CODEC_NID((cmd)) == 0x14) 108 #define STAC9220_IS_SPDIFOUT_CMD(cmd) (CODEC_NID((cmd)) == 0x8) 109 #define STAC9220_IS_SPDIFIN_CMD(cmd) (CODEC_NID((cmd)) == 0x9) 110 111 #define STAC9220_IS_DIGINPIN_CMD(cmd) (CODEC_NID((cmd)) == 0x11) 112 #define STAC9220_IS_DIGOUTPIN_CMD(cmd) (CODEC_NID((cmd)) == 0x10) 113 114 #define STAC9220_IS_CD_CMD(cmd) (CODEC_NID((cmd)) == 0x15) 115 116 #define STAC9220_IS_VOLKNOB_CMD(cmd) (CODEC_NID((cmd)) == 0x16) 117 118 /* STAC9220 6.2 & 6.12 */ 119 #define STAC9220_IS_RESERVED_CMD(cmd) ( \ 120 CODEC_NID((cmd)) == 0x9 \ 121 || CODEC_NID((cmd)) == 0x19 \ 122 || CODEC_NID((cmd)) == 0x1A \ 123 || CODEC_NID((cmd)) == 0x1B) 76 const static uint8_t au8Stac9220Ports[] = { 0xA, 0xB, 0xC, 0xD, 0xE, 0xF, 0}; 77 const static uint8_t au8Stac9220Dacs[] = { 0x2, 0x3, 0x4, 0x5, 0}; 78 const static uint8_t au8Stac9220Adcs[] = { 0x6, 0x7, 0}; 79 const static uint8_t au8Stac9220SpdifOuts[] = { 0x8, 0 }; 80 const static uint8_t au8Stac9220SpdifIns[] = { 0x9, 0 }; 81 const static uint8_t au8Stac9220DigOutPins[] = { 0x10, 0 }; 82 const static uint8_t au8Stac9220DigInPins[] = { 0x11, 0 }; 83 const static uint8_t au8Stac9220AdcVols[] = { 0x17, 0x18, 0}; 84 const static uint8_t au8Stac9220AdcMuxs[] = { 0x12, 0x13, 0}; 85 const static uint8_t au8Stac9220Pcbeeps[] = { 0x14, 0 }; 86 const static uint8_t au8Stac9220Cds[] = { 0x15, 0 }; 87 const static uint8_t au8Stac9220VolKnobs[] = { 0x16, 0 }; 88 const static uint8_t au8Stac9220Reserveds[] = { 0x9, 0x19, 0x1a, 0x1b, 0 }; 124 89 125 90 #define CODEC_POWER_MASK 0x3 … … 136 101 }while(0) 137 102 103 #define DECLISNODEOFTYPE(type) \ 104 static inline int codecIs##type##Node(struct CODECState *pState, uint8_t cNode) \ 105 { \ 106 Assert(pState->au8##type##s); \ 107 for(int i = 0; pState->au8##type##s[i] != 0; ++i) \ 108 if (pState->au8##type##s[i] == cNode) \ 109 return 1; \ 110 return 0; \ 111 } 112 /* codecIsPortNode */ 113 DECLISNODEOFTYPE(Port) 114 /* codecIsDacNode */ 115 DECLISNODEOFTYPE(Dac) 116 /* codecIsAdcVolNode */ 117 DECLISNODEOFTYPE(AdcVol) 118 /* codecIsAdcNode */ 119 DECLISNODEOFTYPE(Adc) 120 /* codecIsAdcMuxNode */ 121 DECLISNODEOFTYPE(AdcMux) 122 /* codecIsPcbeepNode */ 123 DECLISNODEOFTYPE(Pcbeep) 124 /* codecIsSpdifOutNode */ 125 DECLISNODEOFTYPE(SpdifOut) 126 /* codecIsSpdifInNode */ 127 DECLISNODEOFTYPE(SpdifIn) 128 /* codecIsDigInPinNode */ 129 DECLISNODEOFTYPE(DigInPin) 130 /* codecIsDigOutPinNode */ 131 DECLISNODEOFTYPE(DigOutPin) 132 /* codecIsCdNode */ 133 DECLISNODEOFTYPE(Cd) 134 /* codecIsVolKnobNode */ 135 DECLISNODEOFTYPE(VolKnob) 136 /* codecIsReservedNode */ 137 DECLISNODEOFTYPE(Reserved) 138 138 139 static int stac9220ResetNode(struct CODECState *pState, uint8_t nodenum, PCODECNODE pNode); 139 140 static int codecToAudVolume(AMPLIFIER *pAmp, audmixerctl_t mt); … … 175 176 { 176 177 Assert((CODEC_CAD(cmd) == pState->id)); 177 Assert((CODEC_NID(cmd) < STAC9220_NODE_COUNT));178 if (CODEC_NID(cmd) >= STAC9220_NODE_COUNT)178 Assert((CODEC_NID(cmd) < pState->cTotalNodes)); 179 if (CODEC_NID(cmd) >= pState->cTotalNodes) 179 180 { 180 181 Log(("HDAcodec: invalid node address %d\n", CODEC_NID(cmd))); … … 187 188 188 189 PCODECNODE pNode = &pState->pNodes[CODEC_NID(cmd)]; 189 if ( STAC9220_IS_DAC_CMD(cmd))190 if (codecIsDacNode(pState, CODEC_NID(cmd))) 190 191 *pResp = AMPLIFIER_REGISTER(pNode->dac.B_params, 191 192 CODEC_GET_AMP_DIRECTION(cmd), 192 193 CODEC_GET_AMP_SIDE(cmd), 193 194 u8Index); 194 else if ( STAC9220_IS_ADCVOL_CMD(cmd))195 else if (codecIsAdcVolNode(pState, CODEC_NID(cmd))) 195 196 *pResp = AMPLIFIER_REGISTER(pNode->adcvol.B_params, 196 197 CODEC_GET_AMP_DIRECTION(cmd), 197 198 CODEC_GET_AMP_SIDE(cmd), 198 199 u8Index); 199 else if ( STAC9220_IS_ADCMUX_CMD(cmd))200 else if (codecIsAdcMuxNode(pState, CODEC_NID(cmd))) 200 201 *pResp = AMPLIFIER_REGISTER(pNode->adcmux.B_params, 201 202 CODEC_GET_AMP_DIRECTION(cmd), 202 203 CODEC_GET_AMP_SIDE(cmd), 203 204 u8Index); 204 else if ( STAC9220_IS_PCBEEP_CMD(cmd))205 else if (codecIsPcbeepNode(pState, CODEC_NID(cmd))) 205 206 *pResp = AMPLIFIER_REGISTER(pNode->pcbeep.B_params, 206 207 CODEC_GET_AMP_DIRECTION(cmd), … … 222 223 uint8_t u8Index = 0; 223 224 Assert((CODEC_CAD(cmd) == pState->id)); 224 if (CODEC_NID(cmd) >= STAC9220_NODE_COUNT)225 if (CODEC_NID(cmd) >= pState->cTotalNodes) 225 226 { 226 227 Log(("HDAcodec: invalid node address %d\n", CODEC_NID(cmd))); … … 229 230 *pResp = 0; 230 231 PCODECNODE pNode = &pState->pNodes[CODEC_NID(cmd)]; 231 if ( STAC9220_IS_DAC_CMD(cmd))232 if (codecIsDacNode(pState, CODEC_NID(cmd))) 232 233 pAmplifier = &pNode->dac.B_params; 233 else if ( STAC9220_IS_ADCVOL_CMD(cmd))234 else if (codecIsAdcVolNode(pState, CODEC_NID(cmd))) 234 235 pAmplifier = &pNode->adcvol.B_params; 235 else if ( STAC9220_IS_ADCMUX_CMD(cmd))236 else if (codecIsAdcMuxNode(pState, CODEC_NID(cmd))) 236 237 pAmplifier = &pNode->adcmux.B_params; 237 else if ( STAC9220_IS_PCBEEP_CMD(cmd))238 else if (codecIsPcbeepNode(pState, CODEC_NID(cmd))) 238 239 pAmplifier = &pNode->pcbeep.B_params; 239 240 Assert(pAmplifier); … … 273 274 { 274 275 Assert((CODEC_CAD(cmd) == pState->id)); 275 if (CODEC_NID(cmd) >= STAC9220_NODE_COUNT)276 if (CODEC_NID(cmd) >= pState->cTotalNodes) 276 277 { 277 278 Log(("HDAcodec: invalid node address %d\n", CODEC_NID(cmd))); … … 293 294 { 294 295 Assert((CODEC_CAD(cmd) == pState->id)); 295 Assert((CODEC_NID(cmd) < STAC9220_NODE_COUNT));296 if (CODEC_NID(cmd) >= STAC9220_NODE_COUNT)297 { 298 Log(("HDAcodec: invalid node address %d\n", CODEC_NID(cmd))); 299 return VINF_SUCCESS; 300 } 301 *pResp = 0; 302 if ( STAC9220_IS_ADCMUX_CMD(cmd))296 Assert((CODEC_NID(cmd) < pState->cTotalNodes)); 297 if (CODEC_NID(cmd) >= pState->cTotalNodes) 298 { 299 Log(("HDAcodec: invalid node address %d\n", CODEC_NID(cmd))); 300 return VINF_SUCCESS; 301 } 302 *pResp = 0; 303 if (codecIsAdcMuxNode(pState, CODEC_NID(cmd))) 303 304 *pResp = pState->pNodes[CODEC_NID(cmd)].adcmux.u32F01_param; 304 else if ( STAC9220_IS_DIGOUTPIN_CMD(cmd))305 else if (codecIsDigOutPinNode(pState, CODEC_NID(cmd))) 305 306 *pResp = pState->pNodes[CODEC_NID(cmd)].digout.u32F01_param; 306 307 return VINF_SUCCESS; … … 311 312 { 312 313 uint32_t *pu32Reg = NULL; 313 Assert((CODEC_NID(cmd) < STAC9220_NODE_COUNT));314 if (CODEC_NID(cmd) >= STAC9220_NODE_COUNT)315 { 316 Log(("HDAcodec: invalid node address %d\n", CODEC_NID(cmd))); 317 return VINF_SUCCESS; 318 } 319 *pResp = 0; 320 if ( STAC9220_IS_ADCMUX_CMD(cmd))314 Assert((CODEC_NID(cmd) < pState->cTotalNodes)); 315 if (CODEC_NID(cmd) >= pState->cTotalNodes) 316 { 317 Log(("HDAcodec: invalid node address %d\n", CODEC_NID(cmd))); 318 return VINF_SUCCESS; 319 } 320 *pResp = 0; 321 if (codecIsAdcMuxNode(pState, CODEC_NID(cmd))) 321 322 pu32Reg = &pState->pNodes[CODEC_NID(cmd)].adcmux.u32F01_param; 322 else if ( STAC9220_IS_DIGOUTPIN_CMD(cmd))323 else if (codecIsDigOutPinNode(pState, CODEC_NID(cmd))) 323 324 pu32Reg = &pState->pNodes[CODEC_NID(cmd)].digout.u32F01_param; 324 325 Assert((pu32Reg)); … … 332 333 { 333 334 Assert((CODEC_CAD(cmd) == pState->id)); 334 Assert((CODEC_NID(cmd) < STAC9220_NODE_COUNT));335 if (CODEC_NID(cmd) >= STAC9220_NODE_COUNT)336 { 337 Log(("HDAcodec: invalid node address %d\n", CODEC_NID(cmd))); 338 return VINF_SUCCESS; 339 } 340 *pResp = 0; 341 if ( STAC9220_IS_PORT_CMD(cmd))335 Assert((CODEC_NID(cmd) < pState->cTotalNodes)); 336 if (CODEC_NID(cmd) >= pState->cTotalNodes) 337 { 338 Log(("HDAcodec: invalid node address %d\n", CODEC_NID(cmd))); 339 return VINF_SUCCESS; 340 } 341 *pResp = 0; 342 if (codecIsPortNode(pState, CODEC_NID(cmd))) 342 343 *pResp = pState->pNodes[CODEC_NID(cmd)].port.u32F07_param; 343 else if ( STAC9220_IS_DIGOUTPIN_CMD(cmd))344 else if (codecIsDigOutPinNode(pState, CODEC_NID(cmd))) 344 345 *pResp = pState->pNodes[CODEC_NID(cmd)].digout.u32F07_param; 345 else if ( STAC9220_IS_DIGINPIN_CMD(cmd))346 else if (codecIsDigInPinNode(pState, CODEC_NID(cmd))) 346 347 *pResp = pState->pNodes[CODEC_NID(cmd)].digin.u32F07_param; 347 else if ( STAC9220_IS_CD_CMD(cmd))348 else if (codecIsCdNode(pState, CODEC_NID(cmd))) 348 349 *pResp = pState->pNodes[CODEC_NID(cmd)].cdnode.u32F07_param; 349 else if ( STAC9220_IS_RESERVED_CMD(cmd)350 else if ( codecIsReservedNode(pState, CODEC_NID(cmd)) 350 351 && CODEC_NID(cmd) == 0x1b) 351 352 *pResp = pState->pNodes[CODEC_NID(cmd)].reserved.u32F07_param; … … 359 360 { 360 361 Assert((CODEC_CAD(cmd) == pState->id)); 361 Assert((CODEC_NID(cmd) < STAC9220_NODE_COUNT));362 if (CODEC_NID(cmd) >= STAC9220_NODE_COUNT)362 Assert((CODEC_NID(cmd) < pState->cTotalNodes)); 363 if (CODEC_NID(cmd) >= pState->cTotalNodes) 363 364 { 364 365 Log(("HDAcodec: invalid node address %d\n", CODEC_NID(cmd))); … … 367 368 *pResp = 0; 368 369 uint32_t *pu32Reg = NULL; 369 if ( STAC9220_IS_PORT_CMD(cmd))370 if (codecIsPortNode(pState, CODEC_NID(cmd))) 370 371 pu32Reg = &pState->pNodes[CODEC_NID(cmd)].port.u32F07_param; 371 else if ( STAC9220_IS_DIGINPIN_CMD(cmd))372 else if (codecIsDigInPinNode(pState, CODEC_NID(cmd))) 372 373 pu32Reg = &pState->pNodes[CODEC_NID(cmd)].digin.u32F07_param; 373 else if ( STAC9220_IS_DIGOUTPIN_CMD(cmd))374 else if (codecIsDigOutPinNode(pState, CODEC_NID(cmd))) 374 375 pu32Reg = &pState->pNodes[CODEC_NID(cmd)].digout.u32F07_param; 375 else if ( STAC9220_IS_CD_CMD(cmd))376 else if (codecIsCdNode(pState, CODEC_NID(cmd))) 376 377 pu32Reg = &pState->pNodes[CODEC_NID(cmd)].cdnode.u32F07_param; 377 else if ( STAC9220_IS_RESERVED_CMD(cmd)378 else if ( codecIsReservedNode(pState, CODEC_NID(cmd)) 378 379 && CODEC_NID(cmd) == 0x1b) 379 380 pu32Reg = &pState->pNodes[CODEC_NID(cmd)].reserved.u32F07_param; … … 388 389 { 389 390 Assert((CODEC_CAD(cmd) == pState->id)); 390 Assert((CODEC_NID(cmd) < STAC9220_NODE_COUNT));391 if (CODEC_NID(cmd) >= STAC9220_NODE_COUNT)392 { 393 Log(("HDAcodec: invalid node address %d\n", CODEC_NID(cmd))); 394 return VINF_SUCCESS; 395 } 396 *pResp = 0; 397 if ( STAC9220_IS_PORT_CMD(cmd))391 Assert((CODEC_NID(cmd) < pState->cTotalNodes)); 392 if (CODEC_NID(cmd) >= pState->cTotalNodes) 393 { 394 Log(("HDAcodec: invalid node address %d\n", CODEC_NID(cmd))); 395 return VINF_SUCCESS; 396 } 397 *pResp = 0; 398 if (codecIsPortNode(pState, CODEC_NID(cmd))) 398 399 *pResp = pState->pNodes[CODEC_NID(cmd)].port.u32F08_param; 399 else if ( STAC9220_IS_DIGINPIN_CMD(cmd))400 else if (codecIsDigInPinNode(pState, CODEC_NID(cmd))) 400 401 *pResp = pState->pNodes[CODEC_NID(cmd)].digin.u32F08_param; 401 else if ( STAC9220_IS_AFG_CMD(cmd))402 else if ((cmd) == 1 /* AFG */) 402 403 *pResp = pState->pNodes[CODEC_NID(cmd)].afg.u32F08_param; 403 else if ( STAC9220_IS_VOLKNOB_CMD(cmd))404 else if (codecIsVolKnobNode(pState, CODEC_NID(cmd))) 404 405 *pResp = pState->pNodes[CODEC_NID(cmd)].volumeKnob.u32F08_param; 405 406 else … … 412 413 { 413 414 Assert((CODEC_CAD(cmd) == pState->id)); 414 Assert((CODEC_NID(cmd) < STAC9220_NODE_COUNT));415 if (CODEC_NID(cmd) >= STAC9220_NODE_COUNT)415 Assert((CODEC_NID(cmd) < pState->cTotalNodes)); 416 if (CODEC_NID(cmd) >= pState->cTotalNodes) 416 417 { 417 418 Log(("HDAcodec: invalid node address %d\n", CODEC_NID(cmd))); … … 420 421 *pResp = 0; 421 422 uint32_t *pu32Reg = NULL; 422 if ( STAC9220_IS_PORT_CMD(cmd))423 if (codecIsPortNode(pState, CODEC_NID(cmd))) 423 424 pu32Reg = &pState->pNodes[CODEC_NID(cmd)].port.u32F08_param; 424 else if ( STAC9220_IS_DIGINPIN_CMD(cmd))425 else if (codecIsDigInPinNode(pState, CODEC_NID(cmd))) 425 426 pu32Reg = &pState->pNodes[CODEC_NID(cmd)].digin.u32F08_param; 426 else if ( STAC9220_IS_AFG_CMD(cmd))427 else if (CODEC_NID(cmd) == 1 /* AFG */) 427 428 pu32Reg = &pState->pNodes[CODEC_NID(cmd)].afg.u32F08_param; 428 else if ( STAC9220_IS_VOLKNOB_CMD(cmd))429 else if (codecIsVolKnobNode(pState, CODEC_NID(cmd))) 429 430 pu32Reg = &pState->pNodes[CODEC_NID(cmd)].volumeKnob.u32F08_param; 430 431 else … … 440 441 { 441 442 Assert((CODEC_CAD(cmd) == pState->id)); 442 Assert((CODEC_NID(cmd) < STAC9220_NODE_COUNT));443 if (CODEC_NID(cmd) >= STAC9220_NODE_COUNT)444 { 445 Log(("HDAcodec: invalid node address %d\n", CODEC_NID(cmd))); 446 return VINF_SUCCESS; 447 } 448 *pResp = 0; 449 if ( STAC9220_IS_PORT_CMD(cmd))443 Assert((CODEC_NID(cmd) < pState->cTotalNodes)); 444 if (CODEC_NID(cmd) >= pState->cTotalNodes) 445 { 446 Log(("HDAcodec: invalid node address %d\n", CODEC_NID(cmd))); 447 return VINF_SUCCESS; 448 } 449 *pResp = 0; 450 if (codecIsPortNode(pState, CODEC_NID(cmd))) 450 451 *pResp = pState->pNodes[CODEC_NID(cmd)].port.u32F09_param; 451 else if ( STAC9220_IS_DIGINPIN_CMD(cmd))452 else if (codecIsDigInPinNode(pState, CODEC_NID(cmd))) 452 453 *pResp = pState->pNodes[CODEC_NID(cmd)].digin.u32F09_param; 453 454 else … … 460 461 { 461 462 Assert((CODEC_CAD(cmd) == pState->id)); 462 Assert((CODEC_NID(cmd) < STAC9220_NODE_COUNT));463 if (CODEC_NID(cmd) >= STAC9220_NODE_COUNT)463 Assert((CODEC_NID(cmd) < pState->cTotalNodes)); 464 if (CODEC_NID(cmd) >= pState->cTotalNodes) 464 465 { 465 466 Log(("HDAcodec: invalid node address %d\n", CODEC_NID(cmd))); … … 469 470 uint32_t *pu32Reg = NULL; 470 471 //** @todo r=michaln: Copy/paste bug? This can't be F08_parm! 471 if ( STAC9220_IS_PORT_CMD(cmd))472 if (codecIsPortNode(pState, CODEC_NID(cmd))) 472 473 pu32Reg = &pState->pNodes[CODEC_NID(cmd)].port.u32F08_param; 473 else if ( STAC9220_IS_DIGINPIN_CMD(cmd))474 else if (codecIsDigInPinNode(pState, CODEC_NID(cmd))) 474 475 pu32Reg = &pState->pNodes[CODEC_NID(cmd)].digin.u32F08_param; 475 476 Assert(pu32Reg); … … 482 483 { 483 484 Assert((CODEC_CAD(cmd) == pState->id)); 484 Assert((CODEC_NID(cmd) < STAC9220_NODE_COUNT));485 if (CODEC_NID(cmd) >= STAC9220_NODE_COUNT)485 Assert((CODEC_NID(cmd) < pState->cTotalNodes)); 486 if (CODEC_NID(cmd) >= pState->cTotalNodes) 486 487 { 487 488 Log(("HDAcodec: invalid node address %d\n", CODEC_NID(cmd))); … … 500 501 { 501 502 Assert((CODEC_CAD(cmd) == pState->id)); 502 Assert((CODEC_NID(cmd) < STAC9220_NODE_COUNT));503 if (CODEC_NID(cmd) >= STAC9220_NODE_COUNT)504 { 505 Log(("HDAcodec: invalid node address %d\n", CODEC_NID(cmd))); 506 return VINF_SUCCESS; 507 } 508 *pResp = 0; 509 if ( STAC9220_IS_ADC_CMD(cmd))503 Assert((CODEC_NID(cmd) < pState->cTotalNodes)); 504 if (CODEC_NID(cmd) >= pState->cTotalNodes) 505 { 506 Log(("HDAcodec: invalid node address %d\n", CODEC_NID(cmd))); 507 return VINF_SUCCESS; 508 } 509 *pResp = 0; 510 if (codecIsAdcNode(pState, CODEC_NID(cmd))) 510 511 *pResp = pState->pNodes[CODEC_NID(cmd)].adc.u32F03_param; 511 512 return VINF_SUCCESS; … … 516 517 { 517 518 Assert((CODEC_CAD(cmd) == pState->id)); 518 Assert((CODEC_NID(cmd) < STAC9220_NODE_COUNT));519 if (CODEC_NID(cmd) >= STAC9220_NODE_COUNT)520 { 521 Log(("HDAcodec: invalid node address %d\n", CODEC_NID(cmd))); 522 return VINF_SUCCESS; 523 } 524 *pResp = 0; 525 if ( STAC9220_IS_ADC_CMD(cmd))519 Assert((CODEC_NID(cmd) < pState->cTotalNodes)); 520 if (CODEC_NID(cmd) >= pState->cTotalNodes) 521 { 522 Log(("HDAcodec: invalid node address %d\n", CODEC_NID(cmd))); 523 return VINF_SUCCESS; 524 } 525 *pResp = 0; 526 if (codecIsAdcNode(pState, CODEC_NID(cmd))) 526 527 { 527 528 codecSetRegisterU8(&pState->pNodes[CODEC_NID(cmd)].adc.u32F03_param, cmd, 0); … … 534 535 { 535 536 Assert((CODEC_CAD(cmd) == pState->id)); 536 Assert((CODEC_NID(cmd) < STAC9220_NODE_COUNT));537 if (CODEC_NID(cmd) >= STAC9220_NODE_COUNT)538 { 539 Log(("HDAcodec: invalid node address %d\n", CODEC_NID(cmd))); 540 return VINF_SUCCESS; 541 } 542 *pResp = 0; 543 if ( STAC9220_IS_SPDIFOUT_CMD(cmd))537 Assert((CODEC_NID(cmd) < pState->cTotalNodes)); 538 if (CODEC_NID(cmd) >= pState->cTotalNodes) 539 { 540 Log(("HDAcodec: invalid node address %d\n", CODEC_NID(cmd))); 541 return VINF_SUCCESS; 542 } 543 *pResp = 0; 544 if (codecIsSpdifOutNode(pState, CODEC_NID(cmd))) 544 545 *pResp = pState->pNodes[CODEC_NID(cmd)].spdifout.u32F0d_param; 545 else if ( STAC9220_IS_SPDIFIN_CMD(cmd))546 else if (codecIsSpdifInNode(pState, CODEC_NID(cmd))) 546 547 *pResp = pState->pNodes[CODEC_NID(cmd)].spdifin.u32F0d_param; 547 548 return VINF_SUCCESS; … … 551 552 { 552 553 Assert((CODEC_CAD(cmd) == pState->id)); 553 Assert((CODEC_NID(cmd) < STAC9220_NODE_COUNT));554 if (CODEC_NID(cmd) >= STAC9220_NODE_COUNT)555 { 556 Log(("HDAcodec: invalid node address %d\n", CODEC_NID(cmd))); 557 return VINF_SUCCESS; 558 } 559 *pResp = 0; 560 if ( STAC9220_IS_SPDIFOUT_CMD(cmd))554 Assert((CODEC_NID(cmd) < pState->cTotalNodes)); 555 if (CODEC_NID(cmd) >= pState->cTotalNodes) 556 { 557 Log(("HDAcodec: invalid node address %d\n", CODEC_NID(cmd))); 558 return VINF_SUCCESS; 559 } 560 *pResp = 0; 561 if (codecIsSpdifOutNode(pState, CODEC_NID(cmd))) 561 562 codecSetRegisterU8(&pState->pNodes[CODEC_NID(cmd)].spdifout.u32F0d_param, cmd, u8Offset); 562 else if ( STAC9220_IS_SPDIFIN_CMD(cmd))563 else if (codecIsSpdifInNode(pState, CODEC_NID(cmd))) 563 564 codecSetRegisterU8(&pState->pNodes[CODEC_NID(cmd)].spdifin.u32F0d_param, cmd, u8Offset); 564 565 return VINF_SUCCESS; … … 580 581 { 581 582 Assert((CODEC_CAD(cmd) == pState->id)); 582 Assert((CODEC_NID(cmd) < STAC9220_NODE_COUNT));583 if (CODEC_NID(cmd) >= STAC9220_NODE_COUNT)584 { 585 Log(("HDAcodec: invalid node address %d\n", CODEC_NID(cmd))); 586 return VINF_SUCCESS; 587 } 588 *pResp = 0; 589 if ( STAC9220_IS_AFG_CMD(cmd))583 Assert((CODEC_NID(cmd) < pState->cTotalNodes)); 584 if (CODEC_NID(cmd) >= pState->cTotalNodes) 585 { 586 Log(("HDAcodec: invalid node address %d\n", CODEC_NID(cmd))); 587 return VINF_SUCCESS; 588 } 589 *pResp = 0; 590 if (CODEC_NID(cmd) == 1 /* AFG */) 590 591 { 591 592 *pResp = pState->pNodes[CODEC_NID(cmd)].afg.u32F20_param; … … 597 598 { 598 599 Assert((CODEC_CAD(cmd) == pState->id)); 599 Assert( STAC9220_IS_AFG_CMD(cmd));600 if( STAC9220_IS_AFG_CMD(cmd))600 Assert(CODEC_NID(cmd) == 1 /* AFG */); 601 if(CODEC_NID(cmd) == 1 /* AFG */) 601 602 { 602 603 uint8_t i; 603 604 Log(("HDAcodec: enters reset\n")); 604 for (i = 0; i < STAC9220_NODE_COUNT; ++i)605 for (i = 0; i < pState->cTotalNodes; ++i) 605 606 { 606 607 stac9220ResetNode(pState, i, &pState->pNodes[i]); … … 617 618 { 618 619 Assert((CODEC_CAD(cmd) == pState->id)); 619 Assert((CODEC_NID(cmd) < STAC9220_NODE_COUNT));620 if (CODEC_NID(cmd) >= STAC9220_NODE_COUNT)621 { 622 Log(("HDAcodec: invalid node address %d\n", CODEC_NID(cmd))); 623 return VINF_SUCCESS; 624 } 625 *pResp = 0; 626 if ( STAC9220_IS_AFG_CMD(cmd))620 Assert((CODEC_NID(cmd) < pState->cTotalNodes)); 621 if (CODEC_NID(cmd) >= pState->cTotalNodes) 622 { 623 Log(("HDAcodec: invalid node address %d\n", CODEC_NID(cmd))); 624 return VINF_SUCCESS; 625 } 626 *pResp = 0; 627 if (CODEC_NID(cmd) == 1 /* AFG */) 627 628 *pResp = pState->pNodes[CODEC_NID(cmd)].afg.u32F05_param; 628 else if ( STAC9220_IS_DAC_CMD(cmd))629 else if (codecIsDacNode(pState, CODEC_NID(cmd))) 629 630 *pResp = pState->pNodes[CODEC_NID(cmd)].dac.u32F05_param; 630 else if ( STAC9220_IS_DIGINPIN_CMD(cmd))631 else if (codecIsDigInPinNode(pState, CODEC_NID(cmd))) 631 632 *pResp = pState->pNodes[CODEC_NID(cmd)].digin.u32F05_param; 632 else if ( STAC9220_IS_ADC_CMD(cmd))633 else if (codecIsAdcNode(pState, CODEC_NID(cmd))) 633 634 *pResp = pState->pNodes[CODEC_NID(cmd)].adc.u32F05_param; 634 635 return VINF_SUCCESS; … … 639 640 { 640 641 Assert((CODEC_CAD(cmd) == pState->id)); 641 Assert((CODEC_NID(cmd) < STAC9220_NODE_COUNT));642 if (CODEC_NID(cmd) >= STAC9220_NODE_COUNT)642 Assert((CODEC_NID(cmd) < pState->cTotalNodes)); 643 if (CODEC_NID(cmd) >= pState->cTotalNodes) 643 644 { 644 645 Log(("HDAcodec: invalid node address %d\n", CODEC_NID(cmd))); … … 647 648 uint32_t *pu32Reg = NULL; 648 649 *pResp = 0; 649 if ( STAC9220_IS_AFG_CMD(cmd))650 if (CODEC_NID(cmd) == 1 /* AFG */) 650 651 pu32Reg = &pState->pNodes[CODEC_NID(cmd)].afg.u32F05_param; 651 else if ( STAC9220_IS_DAC_CMD(cmd))652 else if (codecIsDacNode(pState, CODEC_NID(cmd))) 652 653 pu32Reg = &pState->pNodes[CODEC_NID(cmd)].dac.u32F05_param; 653 else if ( STAC9220_IS_DIGINPIN_CMD(cmd))654 else if (codecIsDigInPinNode(pState, CODEC_NID(cmd))) 654 655 pu32Reg = &pState->pNodes[CODEC_NID(cmd)].digin.u32F05_param; 655 else if ( STAC9220_IS_ADC_CMD(cmd))656 else if (codecIsAdcNode(pState, CODEC_NID(cmd))) 656 657 pu32Reg = &pState->pNodes[CODEC_NID(cmd)].adc.u32F05_param; 657 658 Assert((pu32Reg)); … … 659 660 return VINF_SUCCESS; 660 661 661 if (! STAC9220_IS_AFG_CMD(cmd))662 if (!CODEC_NID(cmd) == 1 /* AFG */) 662 663 { 663 664 *pu32Reg &= ~CODEC_VERB_8BIT_DATA; … … 669 670 *pu32Reg |= cmd & CODEC_VERB_4BIT_DATA; 670 671 /* Propogate next power state only if AFG is on or verb modifies AFG power state */ 671 if ( STAC9220_IS_AFG_CMD(cmd)672 if ( CODEC_NID(cmd) == 1 /* AFG */ 672 673 || !pState->pNodes[1].afg.u32F05_param) 673 674 { 674 675 *pu32Reg &= ~(CODEC_POWER_MASK << CODEC_POWER_ACT_SHIFT); 675 676 *pu32Reg |= (cmd & CODEC_VERB_4BIT_DATA) << 4; 676 if ( STAC9220_IS_AFG_CMD(cmd)677 if ( CODEC_NID(cmd) == 1 /* AFG */ 677 678 && (cmd & CODEC_POWER_MASK) == CODEC_POWER_D0) 678 679 { … … 692 693 { 693 694 Assert((CODEC_CAD(cmd) == pState->id)); 694 Assert((CODEC_NID(cmd) < STAC9220_NODE_COUNT));695 if (CODEC_NID(cmd) >= STAC9220_NODE_COUNT)696 { 697 Log(("HDAcodec: invalid node address %d\n", CODEC_NID(cmd))); 698 return VINF_SUCCESS; 699 } 700 *pResp = 0; 701 if ( STAC9220_IS_DAC_CMD(cmd))695 Assert((CODEC_NID(cmd) < pState->cTotalNodes)); 696 if (CODEC_NID(cmd) >= pState->cTotalNodes) 697 { 698 Log(("HDAcodec: invalid node address %d\n", CODEC_NID(cmd))); 699 return VINF_SUCCESS; 700 } 701 *pResp = 0; 702 if (codecIsDacNode(pState, CODEC_NID(cmd))) 702 703 *pResp = pState->pNodes[CODEC_NID(cmd)].dac.u32F06_param; 703 else if ( STAC9220_IS_ADC_CMD(cmd))704 else if (codecIsAdcNode(pState, CODEC_NID(cmd))) 704 705 *pResp = pState->pNodes[CODEC_NID(cmd)].adc.u32F06_param; 705 else if ( STAC9220_IS_SPDIFIN_CMD(cmd))706 else if (codecIsSpdifInNode(pState, CODEC_NID(cmd))) 706 707 *pResp = pState->pNodes[CODEC_NID(cmd)].spdifin.u32F06_param; 707 else if ( STAC9220_IS_SPDIFOUT_CMD(cmd))708 else if (codecIsSpdifOutNode(pState, CODEC_NID(cmd))) 708 709 *pResp = pState->pNodes[CODEC_NID(cmd)].spdifout.u32F06_param; 710 else if (CODEC_NID(cmd) == 0x1A) 711 *pResp = pState->pNodes[CODEC_NID(cmd)].reserved.u32F06_param; 709 712 return VINF_SUCCESS; 710 713 } … … 712 715 { 713 716 Assert((CODEC_CAD(cmd) == pState->id)); 714 Assert((CODEC_NID(cmd) < STAC9220_NODE_COUNT));715 if (CODEC_NID(cmd) >= STAC9220_NODE_COUNT)717 Assert((CODEC_NID(cmd) < pState->cTotalNodes)); 718 if (CODEC_NID(cmd) >= pState->cTotalNodes) 716 719 { 717 720 Log(("HDAcodec: invalid node address %d\n", CODEC_NID(cmd))); … … 721 724 uint32_t *pu32addr = NULL; 722 725 *pResp = 0; 723 if ( STAC9220_IS_DAC_CMD(cmd))726 if (codecIsDacNode(pState, CODEC_NID(cmd))) 724 727 pu32addr = &pState->pNodes[CODEC_NID(cmd)].dac.u32F06_param; 725 else if ( STAC9220_IS_ADC_CMD(cmd))728 else if (codecIsAdcNode(pState, CODEC_NID(cmd))) 726 729 pu32addr = &pState->pNodes[CODEC_NID(cmd)].adc.u32F06_param; 727 else if ( STAC9220_IS_SPDIFOUT_CMD(cmd))730 else if (codecIsSpdifOutNode(pState, CODEC_NID(cmd))) 728 731 pu32addr = &pState->pNodes[CODEC_NID(cmd)].spdifout.u32F06_param; 729 else if ( STAC9220_IS_SPDIFIN_CMD(cmd))732 else if (codecIsSpdifInNode(pState, CODEC_NID(cmd))) 730 733 pu32addr = &pState->pNodes[CODEC_NID(cmd)].spdifin.u32F06_param; 734 else if (codecIsReservedNode(pState, CODEC_NID(cmd))) 735 pu32addr = &pState->pNodes[CODEC_NID(cmd)].reserved.u32F06_param; 731 736 Assert((pu32addr)); 732 737 if (pu32addr) … … 737 742 { 738 743 Assert((CODEC_CAD(cmd) == pState->id)); 739 Assert((CODEC_NID(cmd) < STAC9220_NODE_COUNT));740 if (CODEC_NID(cmd) >= STAC9220_NODE_COUNT)741 { 742 Log(("HDAcodec: invalid node address %d\n", CODEC_NID(cmd))); 743 return VINF_SUCCESS; 744 } 745 *pResp = 0; 746 if ( STAC9220_IS_DAC_CMD(cmd))744 Assert((CODEC_NID(cmd) < pState->cTotalNodes)); 745 if (CODEC_NID(cmd) >= pState->cTotalNodes) 746 { 747 Log(("HDAcodec: invalid node address %d\n", CODEC_NID(cmd))); 748 return VINF_SUCCESS; 749 } 750 *pResp = 0; 751 if (codecIsDacNode(pState, CODEC_NID(cmd))) 747 752 *pResp = pState->pNodes[CODEC_NID(cmd)].dac.u32A_param; 748 else if ( STAC9220_IS_ADC_CMD(cmd))753 else if (codecIsAdcNode(pState, CODEC_NID(cmd))) 749 754 *pResp = pState->pNodes[CODEC_NID(cmd)].adc.u32A_param; 750 else if ( STAC9220_IS_SPDIFOUT_CMD(cmd))755 else if (codecIsSpdifOutNode(pState, CODEC_NID(cmd))) 751 756 *pResp = pState->pNodes[CODEC_NID(cmd)].spdifout.u32A_param; 752 else if ( STAC9220_IS_SPDIFIN_CMD(cmd))757 else if (codecIsSpdifInNode(pState, CODEC_NID(cmd))) 753 758 *pResp = pState->pNodes[CODEC_NID(cmd)].spdifin.u32A_param; 754 759 return VINF_SUCCESS; … … 758 763 { 759 764 Assert((CODEC_CAD(cmd) == pState->id)); 760 Assert((CODEC_NID(cmd) < STAC9220_NODE_COUNT));761 if (CODEC_NID(cmd) >= STAC9220_NODE_COUNT)762 { 763 Log(("HDAcodec: invalid node address %d\n", CODEC_NID(cmd))); 764 return VINF_SUCCESS; 765 } 766 *pResp = 0; 767 if ( STAC9220_IS_DAC_CMD(cmd))765 Assert((CODEC_NID(cmd) < pState->cTotalNodes)); 766 if (CODEC_NID(cmd) >= pState->cTotalNodes) 767 { 768 Log(("HDAcodec: invalid node address %d\n", CODEC_NID(cmd))); 769 return VINF_SUCCESS; 770 } 771 *pResp = 0; 772 if (codecIsDacNode(pState, CODEC_NID(cmd))) 768 773 codecSetRegisterU16(&pState->pNodes[CODEC_NID(cmd)].dac.u32A_param, cmd, 0); 769 else if ( STAC9220_IS_ADC_CMD(cmd))774 else if (codecIsAdcNode(pState, CODEC_NID(cmd))) 770 775 codecSetRegisterU16(&pState->pNodes[CODEC_NID(cmd)].adc.u32A_param, cmd, 0); 771 else if ( STAC9220_IS_SPDIFOUT_CMD(cmd))776 else if (codecIsSpdifOutNode(pState, CODEC_NID(cmd))) 772 777 codecSetRegisterU16(&pState->pNodes[CODEC_NID(cmd)].spdifout.u32A_param, cmd, 0); 773 else if ( STAC9220_IS_SPDIFIN_CMD(cmd))778 else if (codecIsSpdifInNode(pState, CODEC_NID(cmd))) 774 779 codecSetRegisterU16(&pState->pNodes[CODEC_NID(cmd)].spdifin.u32A_param, cmd, 0); 775 780 return VINF_SUCCESS; … … 780 785 { 781 786 Assert((CODEC_CAD(cmd) == pState->id)); 782 Assert((CODEC_NID(cmd) < STAC9220_NODE_COUNT));783 if (CODEC_NID(cmd) >= STAC9220_NODE_COUNT)784 { 785 Log(("HDAcodec: invalid node address %d\n", CODEC_NID(cmd))); 786 return VINF_SUCCESS; 787 } 788 *pResp = 0; 789 if ( STAC9220_IS_ADCVOL_CMD(cmd))787 Assert((CODEC_NID(cmd) < pState->cTotalNodes)); 788 if (CODEC_NID(cmd) >= pState->cTotalNodes) 789 { 790 Log(("HDAcodec: invalid node address %d\n", CODEC_NID(cmd))); 791 return VINF_SUCCESS; 792 } 793 *pResp = 0; 794 if (codecIsAdcVolNode(pState, CODEC_NID(cmd))) 790 795 *pResp = pState->pNodes[CODEC_NID(cmd)].adcvol.u32F0c_param; 791 else if ( STAC9220_IS_DAC_CMD(cmd))796 else if (codecIsDacNode(pState, CODEC_NID(cmd))) 792 797 *pResp = pState->pNodes[CODEC_NID(cmd)].dac.u32F0c_param; 793 else if ( STAC9220_IS_DIGINPIN_CMD(cmd))798 else if (codecIsDigInPinNode(pState, CODEC_NID(cmd))) 794 799 *pResp = pState->pNodes[CODEC_NID(cmd)].digin.u32F0c_param; 795 800 return VINF_SUCCESS; … … 800 805 { 801 806 Assert((CODEC_CAD(cmd) == pState->id)); 802 Assert((CODEC_NID(cmd) < STAC9220_NODE_COUNT));803 if (CODEC_NID(cmd) >= STAC9220_NODE_COUNT)807 Assert((CODEC_NID(cmd) < pState->cTotalNodes)); 808 if (CODEC_NID(cmd) >= pState->cTotalNodes) 804 809 { 805 810 Log(("HDAcodec: invalid node address %d\n", CODEC_NID(cmd))); … … 808 813 *pResp = 0; 809 814 uint32_t *pu32Reg = NULL; 810 if ( STAC9220_IS_ADCVOL_CMD(cmd))815 if (codecIsAdcVolNode(pState, CODEC_NID(cmd))) 811 816 pu32Reg = &pState->pNodes[CODEC_NID(cmd)].adcvol.u32F0c_param; 812 else if ( STAC9220_IS_DAC_CMD(cmd))817 else if (codecIsDacNode(pState, CODEC_NID(cmd))) 813 818 pu32Reg = &pState->pNodes[CODEC_NID(cmd)].dac.u32F0c_param; 814 else if ( STAC9220_IS_DIGINPIN_CMD(cmd))819 else if (codecIsDigInPinNode(pState, CODEC_NID(cmd))) 815 820 pu32Reg = &pState->pNodes[CODEC_NID(cmd)].digin.u32F0c_param; 816 821 *pResp = 0; … … 825 830 { 826 831 Assert((CODEC_CAD(cmd) == pState->id)); 827 Assert((CODEC_NID(cmd) < STAC9220_NODE_COUNT));828 if (CODEC_NID(cmd) >= STAC9220_NODE_COUNT)829 { 830 Log(("HDAcodec: invalid node address %d\n", CODEC_NID(cmd))); 831 return VINF_SUCCESS; 832 } 833 *pResp = 0; 834 if ( STAC9220_IS_VOLKNOB_CMD(cmd))832 Assert((CODEC_NID(cmd) < pState->cTotalNodes)); 833 if (CODEC_NID(cmd) >= pState->cTotalNodes) 834 { 835 Log(("HDAcodec: invalid node address %d\n", CODEC_NID(cmd))); 836 return VINF_SUCCESS; 837 } 838 *pResp = 0; 839 if (codecIsVolKnobNode(pState, CODEC_NID(cmd))) 835 840 *pResp = pState->pNodes[CODEC_NID(cmd)].volumeKnob.u32F0f_param; 836 841 return VINF_SUCCESS; … … 841 846 { 842 847 Assert((CODEC_CAD(cmd) == pState->id)); 843 Assert((CODEC_NID(cmd) < STAC9220_NODE_COUNT));844 if (CODEC_NID(cmd) >= STAC9220_NODE_COUNT)848 Assert((CODEC_NID(cmd) < pState->cTotalNodes)); 849 if (CODEC_NID(cmd) >= pState->cTotalNodes) 845 850 { 846 851 Log(("HDAcodec: invalid node address %d\n", CODEC_NID(cmd))); … … 849 854 uint32_t *pu32Reg = NULL; 850 855 *pResp = 0; 851 if ( STAC9220_IS_VOLKNOB_CMD(cmd))856 if (codecIsVolKnobNode(pState, CODEC_NID(cmd))) 852 857 pu32Reg = &pState->pNodes[CODEC_NID(cmd)].volumeKnob.u32F0f_param; 853 858 Assert((pu32Reg)); … … 861 866 { 862 867 Assert((CODEC_CAD(cmd) == pState->id)); 863 Assert((CODEC_NID(cmd) < STAC9220_NODE_COUNT));864 if (CODEC_NID(cmd) >= STAC9220_NODE_COUNT)865 { 866 Log(("HDAcodec: invalid node address %d\n", CODEC_NID(cmd))); 867 return VINF_SUCCESS; 868 } 869 *pResp = 0; 870 if ( STAC9220_IS_PORT_CMD(cmd))868 Assert((CODEC_NID(cmd) < pState->cTotalNodes)); 869 if (CODEC_NID(cmd) >= pState->cTotalNodes) 870 { 871 Log(("HDAcodec: invalid node address %d\n", CODEC_NID(cmd))); 872 return VINF_SUCCESS; 873 } 874 *pResp = 0; 875 if (codecIsPortNode(pState, CODEC_NID(cmd))) 871 876 *pResp = pState->pNodes[CODEC_NID(cmd)].port.u32F1c_param; 872 else if ( STAC9220_IS_DIGOUTPIN_CMD(cmd))877 else if (codecIsDigOutPinNode(pState, CODEC_NID(cmd))) 873 878 *pResp = pState->pNodes[CODEC_NID(cmd)].digout.u32F1c_param; 874 else if ( STAC9220_IS_DIGINPIN_CMD(cmd))879 else if (codecIsDigInPinNode(pState, CODEC_NID(cmd))) 875 880 *pResp = pState->pNodes[CODEC_NID(cmd)].digin.u32F1c_param; 876 else if ( STAC9220_IS_CD_CMD(cmd))881 else if (codecIsCdNode(pState, CODEC_NID(cmd))) 877 882 *pResp = pState->pNodes[CODEC_NID(cmd)].cdnode.u32F1c_param; 878 883 return VINF_SUCCESS; … … 881 886 { 882 887 Assert((CODEC_CAD(cmd) == pState->id)); 883 Assert((CODEC_NID(cmd) < STAC9220_NODE_COUNT));884 if (CODEC_NID(cmd) >= STAC9220_NODE_COUNT)888 Assert((CODEC_NID(cmd) < pState->cTotalNodes)); 889 if (CODEC_NID(cmd) >= pState->cTotalNodes) 885 890 { 886 891 Log(("HDAcodec: invalid node address %d\n", CODEC_NID(cmd))); … … 888 893 } 889 894 uint32_t *pu32Reg = NULL; 890 if ( STAC9220_IS_PORT_CMD(cmd))895 if (codecIsPortNode(pState, CODEC_NID(cmd))) 891 896 pu32Reg = &pState->pNodes[CODEC_NID(cmd)].port.u32F1c_param; 892 else if ( STAC9220_IS_DIGINPIN_CMD(cmd))897 else if (codecIsDigInPinNode(pState, CODEC_NID(cmd))) 893 898 pu32Reg = &pState->pNodes[CODEC_NID(cmd)].digin.u32F1c_param; 894 else if ( STAC9220_IS_DIGOUTPIN_CMD(cmd))899 else if (codecIsDigOutPinNode(pState, CODEC_NID(cmd))) 895 900 pu32Reg = &pState->pNodes[CODEC_NID(cmd)].digout.u32F1c_param; 896 else if ( STAC9220_IS_CD_CMD(cmd))901 else if (codecIsCdNode(pState, CODEC_NID(cmd))) 897 902 pu32Reg = &pState->pNodes[CODEC_NID(cmd)].cdnode.u32F1c_param; 898 903 else if (CODEC_NID(cmd) == 0x1B) … … 1250 1255 int rc = VINF_SUCCESS; 1251 1256 Assert(CODEC_CAD(cmd) == pState->id); 1252 if ( STAC9220_IS_RESERVED_CMD(cmd))1257 if (codecIsReservedNode(pState, CODEC_NID(cmd))) 1253 1258 { 1254 1259 LogRel(("HDAcodec: cmd %x was addressed to reseved node\n", cmd)); 1255 1260 } 1256 1261 if ( CODEC_VERBDATA(cmd) == 0 1257 || CODEC_NID(cmd) >= STAC9220_NODE_COUNT)1262 || CODEC_NID(cmd) >= pState->cTotalNodes) 1258 1263 { 1259 1264 *pfn = codecUnimplemented; … … 1311 1316 pState->cVerbs = sizeof(STAC9220VERB)/sizeof(CODECVERB); 1312 1317 pState->pfnLookup = codecLookup; 1313 pState->pNodes = (PCODECNODE)RTMemAllocZ(sizeof(CODECNODE) * STAC9220_NODE_COUNT); 1318 unconst(pState->cTotalNodes) = 0x1C; 1319 pState->pNodes = (PCODECNODE)RTMemAllocZ(sizeof(CODECNODE) * pState->cTotalNodes); 1314 1320 pState->fInReset = false; 1321 #define STAC9220WIDGET(type) pState->au8##type##s = au8Stac9220##type##s 1322 STAC9220WIDGET(Port); 1323 STAC9220WIDGET(Dac); 1324 STAC9220WIDGET(Adc); 1325 STAC9220WIDGET(AdcVol); 1326 STAC9220WIDGET(AdcMux); 1327 STAC9220WIDGET(Pcbeep); 1328 STAC9220WIDGET(SpdifIn); 1329 STAC9220WIDGET(SpdifOut); 1330 STAC9220WIDGET(DigInPin); 1331 STAC9220WIDGET(DigOutPin); 1332 STAC9220WIDGET(Cd); 1333 STAC9220WIDGET(VolKnob); 1334 STAC9220WIDGET(Reserved); 1335 #undef STAC9220WIDGET 1336 1315 1337 uint8_t i; 1316 for (i = 0; i < STAC9220_NODE_COUNT; ++i)1338 for (i = 0; i < pState->cTotalNodes; ++i) 1317 1339 { 1318 1340 stac9220ResetNode(pState, i, &pState->pNodes[i]); … … 1336 1358 codecToAudVolume(&pState->pNodes[2].dac.B_params, AUD_MIXER_VOLUME); 1337 1359 codecToAudVolume(&pState->pNodes[0x17].adcvol.B_params, AUD_MIXER_LINE_IN); 1360 1338 1361 return VINF_SUCCESS; 1339 1362 } … … 1346 1369 int stac9220SaveState(CODECState *pCodecState, PSSMHANDLE pSSMHandle) 1347 1370 { 1348 SSMR3PutMem (pSSMHandle, pCodecState->pNodes, sizeof(CODECNODE) * STAC9220_NODE_COUNT);1371 SSMR3PutMem (pSSMHandle, pCodecState->pNodes, sizeof(CODECNODE) * pCodecState->cTotalNodes); 1349 1372 return VINF_SUCCESS; 1350 1373 } 1351 1374 int stac9220LoadState(CODECState *pCodecState, PSSMHANDLE pSSMHandle) 1352 1375 { 1353 SSMR3GetMem (pSSMHandle, pCodecState->pNodes, sizeof(CODECNODE) * STAC9220_NODE_COUNT);1376 SSMR3GetMem (pSSMHandle, pCodecState->pNodes, sizeof(CODECNODE) * pCodecState->cTotalNodes); 1354 1377 codecToAudVolume(&pCodecState->pNodes[2].dac.B_params, AUD_MIXER_VOLUME); 1355 1378 codecToAudVolume(&pCodecState->pNodes[0x17].adcvol.B_params, AUD_MIXER_LINE_IN); -
trunk/src/VBox/Devices/Audio/DevCodec.h
r32626 r32803 187 187 CODECCOMMONNODE node; 188 188 uint32_t u32F07_param; 189 uint32_t u32F06_param; 189 190 uint32_t u32F1c_param; 190 191 } RESNODE, *PRESNODE; … … 233 234 void *pHDAState; 234 235 bool fInReset; 236 const uint8_t cTotalNodes; 237 const uint8_t *au8Ports; 238 const uint8_t *au8Dacs; 239 const uint8_t *au8AdcVols; 240 const uint8_t *au8Adcs; 241 const uint8_t *au8AdcMuxs; 242 const uint8_t *au8Pcbeeps; 243 const uint8_t *au8SpdifIns; 244 const uint8_t *au8SpdifOuts; 245 const uint8_t *au8DigInPins; 246 const uint8_t *au8DigOutPins; 247 const uint8_t *au8Cds; 248 const uint8_t *au8VolKnobs; 249 const uint8_t *au8Reserveds; 235 250 DECLR3CALLBACKMEMBER(int, pfnProcess, (struct CODECState *)); 236 251 DECLR3CALLBACKMEMBER(int, pfnLookup, (struct CODECState *pState, uint32_t verb, PPFNCODECVERBPROCESSOR)); 237 252 DECLR3CALLBACKMEMBER(int, pfnReset, (struct CODECState *pState)); 238 253 DECLR3CALLBACKMEMBER(void, pfnTransfer, (struct CODECState *pState, ENMSOUNDSOURCE, int avail)); 254 239 255 } CODECState; 256 240 257 241 258 int stac9220Construct(CODECState *pCodecState);
Note:
See TracChangeset
for help on using the changeset viewer.