Changeset 31264 in vbox for trunk/src/VBox/Devices/Audio
- Timestamp:
- Aug 2, 2010 6:22:15 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/DevCodec.cpp
r31263 r31264 123 123 int rc; 124 124 rc = codecUnimplemented(pState, cmd, pResp); 125 *pResp |= CODEC_RESPONSE_UNSOLICITED; /* ??? */125 *pResp |= CODEC_RESPONSE_UNSOLICITED; 126 126 return rc; 127 127 } … … 130 130 { 131 131 Assert((CODEC_CAD(cmd) == pState->id)); 132 Assert((CODEC_NID(cmd) < STAC9220_NODE_COUNT)); 133 if (CODEC_NID(cmd) >= STAC9220_NODE_COUNT) 134 { 135 Log(("HDAcodec: invalide node address %d\n", CODEC_NID(cmd))); 136 return VINF_SUCCESS; 137 } 138 *pResp = 0; 132 139 PCODECNODE pNode = &pState->pNodes[CODEC_NID(cmd)]; 133 140 if (STAC9220_IS_DAC_CMD(cmd)) … … 152 159 CODEC_B_INDEX(cmd)); 153 160 else{ 154 *pResp = 0;155 161 AssertMsgReturn(0, ("access to fields of %x need to be implemented\n", CODEC_NID(cmd)), VINF_SUCCESS); 156 162 } … … 161 167 { 162 168 uint32_t *pu32Bparam = NULL; 163 //** @todo r=michaln: Missing NID bounds checking! 169 Assert((CODEC_CAD(cmd) == pState->id)); 170 if (CODEC_NID(cmd) >= STAC9220_NODE_COUNT) 171 { 172 Log(("HDAcodec: invalide node address %d\n", CODEC_NID(cmd))); 173 return VINF_SUCCESS; 174 } 175 *pResp = 0; 164 176 PCODECNODE pNode = &pState->pNodes[CODEC_NID(cmd)]; 165 *pResp = 0;166 177 if (STAC9220_IS_DAC_CMD(cmd)) 167 178 pu32Bparam = &LIFIER_REGISTER(pNode->dac.B_params, … … 196 207 { 197 208 Assert((CODEC_CAD(cmd) == pState->id)); 198 //** @todo r=michaln: This is not bounds checked and may overflow the pNodes array! 209 if (CODEC_NID(cmd) >= STAC9220_NODE_COUNT) 210 { 211 Log(("HDAcodec: invalide node address %d\n", CODEC_NID(cmd))); 212 return VINF_SUCCESS; 213 } 214 Assert(((cmd & CODEC_VERB_8BIT_DATA) < 16)); 215 if ((cmd & CODEC_VERB_8BIT_DATA) >= 16) 216 { 217 Log(("HDAcodec: invalide F00 parameter %d\n", (cmd & CODEC_VERB_8BIT_DATA))); 218 return VINF_SUCCESS; 219 } 220 *pResp = 0; 199 221 *pResp = pState->pNodes[CODEC_NID(cmd)].node.au32F00_param[cmd & CODEC_VERB_8BIT_DATA]; 200 222 return VINF_SUCCESS; … … 205 227 { 206 228 Assert((CODEC_CAD(cmd) == pState->id)); 229 Assert((CODEC_NID(cmd) < STAC9220_NODE_COUNT)); 230 if (CODEC_NID(cmd) >= STAC9220_NODE_COUNT) 231 { 232 Log(("HDAcodec: invalide node address %d\n", CODEC_NID(cmd))); 233 return VINF_SUCCESS; 234 } 207 235 *pResp = 0; 208 236 if (STAC9220_IS_ADCMUX_CMD(cmd)) … … 218 246 { 219 247 uint32_t *pu32Reg = NULL; 248 Assert((CODEC_NID(cmd) < STAC9220_NODE_COUNT)); 249 if (CODEC_NID(cmd) >= STAC9220_NODE_COUNT) 250 { 251 Log(("HDAcodec: invalide node address %d\n", CODEC_NID(cmd))); 252 return VINF_SUCCESS; 253 } 220 254 *pResp = 0; 221 255 if (STAC9220_IS_ADCMUX_CMD(cmd)) … … 234 268 static int codecGetPinCtrl(struct CODECState *pState, uint32_t cmd, uint64_t *pResp) 235 269 { 270 Assert((CODEC_CAD(cmd) == pState->id)); 271 Assert((CODEC_NID(cmd) < STAC9220_NODE_COUNT)); 272 if (CODEC_NID(cmd) >= STAC9220_NODE_COUNT) 273 { 274 Log(("HDAcodec: invalide node address %d\n", CODEC_NID(cmd))); 275 return VINF_SUCCESS; 276 } 277 *pResp = 0; 236 278 if (STAC9220_IS_PORT_CMD(cmd)) 237 279 *pResp = pState->pNodes[CODEC_NID(cmd)].port.u32F07_param; … … 251 293 static int codecSetPinCtrl(struct CODECState *pState, uint32_t cmd, uint64_t *pResp) 252 294 { 295 Assert((CODEC_CAD(cmd) == pState->id)); 296 Assert((CODEC_NID(cmd) < STAC9220_NODE_COUNT)); 297 if (CODEC_NID(cmd) >= STAC9220_NODE_COUNT) 298 { 299 Log(("HDAcodec: invalide node address %d\n", CODEC_NID(cmd))); 300 return VINF_SUCCESS; 301 } 302 *pResp = 0; 253 303 uint32_t *pu32Reg = NULL; 254 *pResp = 0;255 304 if (STAC9220_IS_PORT_CMD(cmd)) 256 305 pu32Reg = &pState->pNodes[CODEC_NID(cmd)].port.u32F07_param; … … 272 321 static int codecGetUnsolicitedEnabled(struct CODECState *pState, uint32_t cmd, uint64_t *pResp) 273 322 { 323 Assert((CODEC_CAD(cmd) == pState->id)); 324 Assert((CODEC_NID(cmd) < STAC9220_NODE_COUNT)); 325 if (CODEC_NID(cmd) >= STAC9220_NODE_COUNT) 326 { 327 Log(("HDAcodec: invalide node address %d\n", CODEC_NID(cmd))); 328 return VINF_SUCCESS; 329 } 274 330 *pResp = 0; 275 331 if (STAC9220_IS_PORT_CMD(cmd)) … … 289 345 static int codecSetUnsolicitedEnabled(struct CODECState *pState, uint32_t cmd, uint64_t *pResp) 290 346 { 347 Assert((CODEC_CAD(cmd) == pState->id)); 348 Assert((CODEC_NID(cmd) < STAC9220_NODE_COUNT)); 349 if (CODEC_NID(cmd) >= STAC9220_NODE_COUNT) 350 { 351 Log(("HDAcodec: invalide node address %d\n", CODEC_NID(cmd))); 352 return VINF_SUCCESS; 353 } 291 354 *pResp = 0; 292 355 uint32_t *pu32Reg = NULL; … … 300 363 pu32Reg = &pState->pNodes[CODEC_NID(cmd)].volumeKnob.u32F08_param; 301 364 else 302 //** @todo r=michaln: This will crash in release builds! (pu32Reg will be NULL here)303 365 AssertMsgFailed(("unsupported operation %x on node: %x\n", CODEC_VERB_CMD8(cmd), CODEC_NID(cmd))); 304 366 Assert(pu32Reg); 367 if(!pu32Reg) 368 return VINF_SUCCESS; 305 369 *pu32Reg &= ~CODEC_VERB_8BIT_DATA; 306 370 *pu32Reg |= cmd & CODEC_VERB_8BIT_DATA; … … 311 375 static int codecGetPinSense(struct CODECState *pState, uint32_t cmd, uint64_t *pResp) 312 376 { 377 Assert((CODEC_CAD(cmd) == pState->id)); 378 Assert((CODEC_NID(cmd) < STAC9220_NODE_COUNT)); 379 if (CODEC_NID(cmd) >= STAC9220_NODE_COUNT) 380 { 381 Log(("HDAcodec: invalide node address %d\n", CODEC_NID(cmd))); 382 return VINF_SUCCESS; 383 } 313 384 *pResp = 0; 314 385 if (STAC9220_IS_PORT_CMD(cmd)) … … 324 395 static int codecSetPinSense(struct CODECState *pState, uint32_t cmd, uint64_t *pResp) 325 396 { 397 Assert((CODEC_CAD(cmd) == pState->id)); 398 Assert((CODEC_NID(cmd) < STAC9220_NODE_COUNT)); 399 if (CODEC_NID(cmd) >= STAC9220_NODE_COUNT) 400 { 401 Log(("HDAcodec: invalide node address %d\n", CODEC_NID(cmd))); 402 return VINF_SUCCESS; 403 } 326 404 *pResp = 0; 327 405 uint32_t *pu32Reg = NULL; … … 341 419 { 342 420 Assert((CODEC_CAD(cmd) == pState->id)); 343 //** @todo r=michaln: Again, possible pNodes array overflow 421 Assert((CODEC_NID(cmd) < STAC9220_NODE_COUNT)); 422 if (CODEC_NID(cmd) >= STAC9220_NODE_COUNT) 423 { 424 Log(("HDAcodec: invalide node address %d\n", CODEC_NID(cmd))); 425 return VINF_SUCCESS; 426 } 427 Assert((cmd & CODEC_VERB_8BIT_DATA) < 16); 428 if ((cmd & CODEC_VERB_8BIT_DATA) >= 16) 429 { 430 Log(("HDAcodec: access to invalide F02 index %d\n", (cmd & CODEC_VERB_8BIT_DATA))); 431 } 344 432 *pResp = *(uint32_t *)&pState->pNodes[CODEC_NID(cmd)].node.au8F02_param[cmd & CODEC_VERB_8BIT_DATA]; 345 433 return VINF_SUCCESS; … … 349 437 { 350 438 Assert((CODEC_CAD(cmd) == pState->id)); 439 Assert((CODEC_NID(cmd) < STAC9220_NODE_COUNT)); 440 if (CODEC_NID(cmd) >= STAC9220_NODE_COUNT) 441 { 442 Log(("HDAcodec: invalide node address %d\n", CODEC_NID(cmd))); 443 return VINF_SUCCESS; 444 } 351 445 *pResp = 0; 352 446 if (STAC9220_IS_ADC_CMD(cmd)) … … 358 452 { 359 453 Assert((CODEC_CAD(cmd) == pState->id)); 454 Assert((CODEC_NID(cmd) < STAC9220_NODE_COUNT)); 455 if (CODEC_NID(cmd) >= STAC9220_NODE_COUNT) 456 { 457 Log(("HDAcodec: invalide node address %d\n", CODEC_NID(cmd))); 458 return VINF_SUCCESS; 459 } 460 *pResp = 0; 360 461 if (STAC9220_IS_ADC_CMD(cmd)) 361 462 { … … 363 464 pState->pNodes[CODEC_NID(cmd)].adc.u32F03_param |= cmd & CODEC_VERB_8BIT_DATA; 364 465 } 365 *pResp = 0;366 466 return VINF_SUCCESS; 367 467 } … … 370 470 { 371 471 Assert((CODEC_CAD(cmd) == pState->id)); 472 Assert((CODEC_NID(cmd) < STAC9220_NODE_COUNT)); 473 if (CODEC_NID(cmd) >= STAC9220_NODE_COUNT) 474 { 475 Log(("HDAcodec: invalide node address %d\n", CODEC_NID(cmd))); 476 return VINF_SUCCESS; 477 } 372 478 *pResp = 0; 373 479 if (STAC9220_IS_SPDIFOUT_CMD(cmd)) … … 381 487 { 382 488 Assert((CODEC_CAD(cmd) == pState->id)); 489 Assert((CODEC_NID(cmd) < STAC9220_NODE_COUNT)); 490 if (CODEC_NID(cmd) >= STAC9220_NODE_COUNT) 491 { 492 Log(("HDAcodec: invalide node address %d\n", CODEC_NID(cmd))); 493 return VINF_SUCCESS; 494 } 495 *pResp = 0; 383 496 if (STAC9220_IS_SPDIFOUT_CMD(cmd)) 384 497 { … … 391 504 pState->pNodes[CODEC_NID(cmd)].spdifin.u32F0d_param |= cmd & CODEC_VERB_8BIT_DATA; 392 505 } 393 *pResp = 0;394 506 return VINF_SUCCESS; 395 507 } … … 398 510 { 399 511 Assert((CODEC_CAD(cmd) == pState->id)); 512 Assert((CODEC_NID(cmd) < STAC9220_NODE_COUNT)); 513 if (CODEC_NID(cmd) >= STAC9220_NODE_COUNT) 514 { 515 Log(("HDAcodec: invalide node address %d\n", CODEC_NID(cmd))); 516 return VINF_SUCCESS; 517 } 518 *pResp = 0; 400 519 if (STAC9220_IS_SPDIFOUT_CMD(cmd)) 401 520 { … … 408 527 pState->pNodes[CODEC_NID(cmd)].spdifin.u32F0d_param |= cmd & (CODEC_VERB_8BIT_DATA << 8); 409 528 } 410 *pResp = 0;411 529 return VINF_SUCCESS; 412 530 } … … 415 533 { 416 534 Assert((CODEC_CAD(cmd) == pState->id)); 535 Assert((CODEC_NID(cmd) < STAC9220_NODE_COUNT)); 536 if (CODEC_NID(cmd) >= STAC9220_NODE_COUNT) 537 { 538 Log(("HDAcodec: invalide node address %d\n", CODEC_NID(cmd))); 539 return VINF_SUCCESS; 540 } 541 *pResp = 0; 417 542 if (STAC9220_IS_AFG_CMD(cmd)) 418 543 { 419 544 *pResp = pState->pNodes[CODEC_NID(cmd)].afg.u32F20_param; 420 545 } 421 //** @todo r=michaln: pResp must always be filled out422 546 return VINF_SUCCESS; 423 547 } … … 446 570 { 447 571 Assert((CODEC_CAD(cmd) == pState->id)); 572 Assert((CODEC_NID(cmd) < STAC9220_NODE_COUNT)); 573 if (CODEC_NID(cmd) >= STAC9220_NODE_COUNT) 574 { 575 Log(("HDAcodec: invalide node address %d\n", CODEC_NID(cmd))); 576 return VINF_SUCCESS; 577 } 448 578 *pResp = 0; 449 579 if (STAC9220_IS_AFG_CMD(cmd)) … … 462 592 { 463 593 Assert((CODEC_CAD(cmd) == pState->id)); 594 Assert((CODEC_NID(cmd) < STAC9220_NODE_COUNT)); 595 if (CODEC_NID(cmd) >= STAC9220_NODE_COUNT) 596 { 597 Log(("HDAcodec: invalide node address %d\n", CODEC_NID(cmd))); 598 return VINF_SUCCESS; 599 } 464 600 uint32_t *pu32Reg = NULL; 465 601 *pResp = 0; … … 484 620 { 485 621 Assert((CODEC_CAD(cmd) == pState->id)); 622 Assert((CODEC_NID(cmd) < STAC9220_NODE_COUNT)); 623 if (CODEC_NID(cmd) >= STAC9220_NODE_COUNT) 624 { 625 Log(("HDAcodec: invalide node address %d\n", CODEC_NID(cmd))); 626 return VINF_SUCCESS; 627 } 628 *pResp = 0; 486 629 if (STAC9220_IS_DAC_CMD(cmd)) 487 630 *pResp = pState->pNodes[CODEC_NID(cmd)].dac.u32F06_param; 488 631 else if (STAC9220_IS_ADC_CMD(cmd)) 489 632 *pResp = pState->pNodes[CODEC_NID(cmd)].adc.u32F06_param; 490 else491 *pResp = 0; /* STAC9220 6.20 6.13-6.18: no response supposed for this verb. */492 //** @todo r=michaln: Is this intentional? I don't think we should always return 0?493 *pResp = 0;494 633 return VINF_SUCCESS; 495 634 } … … 497 636 { 498 637 Assert((CODEC_CAD(cmd) == pState->id)); 638 Assert((CODEC_NID(cmd) < STAC9220_NODE_COUNT)); 639 if (CODEC_NID(cmd) >= STAC9220_NODE_COUNT) 640 { 641 Log(("HDAcodec: invalide node address %d\n", CODEC_NID(cmd))); 642 return VINF_SUCCESS; 643 } 644 *pResp = 0; 499 645 uint32_t *pu32addr = NULL; 500 646 *pResp = 0; … … 516 662 { 517 663 Assert((CODEC_CAD(cmd) == pState->id)); 664 Assert((CODEC_NID(cmd) < STAC9220_NODE_COUNT)); 665 if (CODEC_NID(cmd) >= STAC9220_NODE_COUNT) 666 { 667 Log(("HDAcodec: invalide node address %d\n", CODEC_NID(cmd))); 668 return VINF_SUCCESS; 669 } 670 *pResp = 0; 518 671 if (STAC9220_IS_DAC_CMD(cmd)) 519 672 *pResp = pState->pNodes[CODEC_NID(cmd)].dac.u32A_param; … … 524 677 else if (STAC9220_IS_SPDIFIN_CMD(cmd)) 525 678 *pResp = pState->pNodes[CODEC_NID(cmd)].spdifin.u32A_param; 526 else527 *pResp = 0;528 679 return VINF_SUCCESS; 529 680 } … … 532 683 { 533 684 Assert((CODEC_CAD(cmd) == pState->id)); 685 Assert((CODEC_NID(cmd) < STAC9220_NODE_COUNT)); 686 if (CODEC_NID(cmd) >= STAC9220_NODE_COUNT) 687 { 688 Log(("HDAcodec: invalide node address %d\n", CODEC_NID(cmd))); 689 return VINF_SUCCESS; 690 } 691 *pResp = 0; 534 692 if (STAC9220_IS_DAC_CMD(cmd)) 535 693 { … … 552 710 pState->pNodes[CODEC_NID(cmd)].spdifin.u32A_param |= cmd & CODEC_VERB_16BIT_DATA; 553 711 } 554 *pResp = 0;555 712 return VINF_SUCCESS; 556 713 } … … 560 717 { 561 718 Assert((CODEC_CAD(cmd) == pState->id)); 719 Assert((CODEC_NID(cmd) < STAC9220_NODE_COUNT)); 720 if (CODEC_NID(cmd) >= STAC9220_NODE_COUNT) 721 { 722 Log(("HDAcodec: invalide node address %d\n", CODEC_NID(cmd))); 723 return VINF_SUCCESS; 724 } 562 725 *pResp = 0; 563 726 if (STAC9220_IS_ADCVOL_CMD(cmd)) … … 574 737 { 575 738 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: invalide node address %d\n", CODEC_NID(cmd))); 743 return VINF_SUCCESS; 744 } 745 *pResp = 0; 576 746 uint32_t *pu32Reg = NULL; 577 *pResp = 0;578 747 if (STAC9220_IS_ADCVOL_CMD(cmd)) 579 748 pu32Reg = &pState->pNodes[CODEC_NID(cmd)].adcvol.u32F0c_param; … … 596 765 { 597 766 Assert((CODEC_CAD(cmd) == pState->id)); 767 Assert((CODEC_NID(cmd) < STAC9220_NODE_COUNT)); 768 if (CODEC_NID(cmd) >= STAC9220_NODE_COUNT) 769 { 770 Log(("HDAcodec: invalide node address %d\n", CODEC_NID(cmd))); 771 return VINF_SUCCESS; 772 } 598 773 *pResp = 0; 599 774 if (STAC9220_IS_VOLKNOB_CMD(cmd)) … … 606 781 { 607 782 Assert((CODEC_CAD(cmd) == pState->id)); 783 Assert((CODEC_NID(cmd) < STAC9220_NODE_COUNT)); 784 if (CODEC_NID(cmd) >= STAC9220_NODE_COUNT) 785 { 786 Log(("HDAcodec: invalide node address %d\n", CODEC_NID(cmd))); 787 return VINF_SUCCESS; 788 } 608 789 uint32_t *pu32Reg = NULL; 609 790 *pResp = 0; 610 791 if (STAC9220_IS_VOLKNOB_CMD(cmd)) 611 792 pu32Reg = &pState->pNodes[CODEC_NID(cmd)].volumeKnob.u32F0f_param; 612 *pResp = 0;613 793 Assert((pu32Reg)); 614 794 if (pu32Reg) … … 624 804 { 625 805 Assert((CODEC_CAD(cmd) == pState->id)); 806 Assert((CODEC_NID(cmd) < STAC9220_NODE_COUNT)); 807 if (CODEC_NID(cmd) >= STAC9220_NODE_COUNT) 808 { 809 Log(("HDAcodec: invalide node address %d\n", CODEC_NID(cmd))); 810 return VINF_SUCCESS; 811 } 626 812 *pResp = 0; 627 813 if (STAC9220_IS_PORT_CMD(cmd)) … … 638 824 { 639 825 Assert((CODEC_CAD(cmd) == pState->id)); 826 Assert((CODEC_NID(cmd) < STAC9220_NODE_COUNT)); 827 if (CODEC_NID(cmd) >= STAC9220_NODE_COUNT) 828 { 829 Log(("HDAcodec: invalide node address %d\n", CODEC_NID(cmd))); 830 return VINF_SUCCESS; 831 } 640 832 uint32_t *pu32Reg = NULL; 641 833 if (STAC9220_IS_PORT_CMD(cmd))
Note:
See TracChangeset
for help on using the changeset viewer.