Changeset 36691 in vbox
- Timestamp:
- Apr 18, 2011 3:03:15 AM (14 years ago)
- Location:
- trunk/src/VBox/Devices/Audio
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/DevCodec.cpp
r35515 r36691 279 279 case 1: 280 280 pNode->afg.node.name = "AFG"; 281 pNode->node.au32F00_param[8] = CODEC_MAKE_F00_08( CODEC_F00_08_BEEP_GEN, 0xd, 0xd);281 pNode->node.au32F00_param[8] = CODEC_MAKE_F00_08(1, 0xd, 0xd); 282 282 pNode->node.au32F00_param[0xC] = CODEC_MAKE_F00_0C(0x17) 283 283 | CODEC_F00_0C_CAP_BALANCED_IO … … 1333 1333 pu32Reg = &pState->pNodes[CODEC_NID(cmd)].pcbeep.u32F07_param; 1334 1334 else if ( codecIsReservedNode(pState, CODEC_NID(cmd)) 1335 && CODEC_NID(cmd) == 0x1b 1336 && pState->enmCodec == STAC9220_CODEC) 1335 && CODEC_NID(cmd) == 0x1b) 1337 1336 pu32Reg = &pState->pNodes[CODEC_NID(cmd)].reserved.u32F07_param; 1338 1337 Assert((pu32Reg)); … … 2165 2164 } 2166 2165 2167 int codecConstruct(PPDMDEVINS pDevIns, CODECState *pState, ENMCODEC enmCodec)2166 int codecConstruct(PPDMDEVINS pDevIns, CODECState *pState, PCFGMNODE pCfgHandle) 2168 2167 { 2169 2168 audsettings_t as; … … 2172 2171 pState->cVerbs = sizeof(CODECVERBS)/sizeof(CODECVERB); 2173 2172 pState->pfnLookup = codecLookup; 2174 pState->enmCodec = enmCodec; 2175 switch (enmCodec) 2176 { 2177 case STAC9220_CODEC: 2178 rc = stac9220Construct(pState); 2179 AssertRC(rc); 2180 break; 2181 case ALC885_CODEC: 2182 rc = alc885Construct(pState); 2183 AssertRC(rc); 2184 break; 2185 default: 2186 AssertMsgFailed(("Unsupported Codec")); 2187 } 2173 rc = stac9220Construct(pState); 2174 AssertRC(rc); 2188 2175 /* common root node initializers */ 2189 2176 pState->pNodes[0].node.au32F00_param[0] = CODEC_MAKE_F00_00(pState->u16VendorId, pState->u16DeviceId); … … 2191 2178 /* common AFG node initializers */ 2192 2179 pState->pNodes[1].node.au32F00_param[4] = CODEC_MAKE_F00_04(0x2, pState->cTotalNodes - 2); 2193 pState->pNodes[1].node.au32F00_param[5] = CODEC_MAKE_F00_05( CODEC_F00_05_UNSOL, CODEC_F00_05_AFG);2180 pState->pNodes[1].node.au32F00_param[5] = CODEC_MAKE_F00_05(1, CODEC_F00_05_AFG); 2194 2181 pState->pNodes[1].afg.u32F20_param = CODEC_MAKE_F20(pState->u16VendorId, pState->u8BSKU, pState->u8AssemblyId); 2195 2182 -
trunk/src/VBox/Devices/Audio/DevCodec.h
r35515 r36691 48 48 #define CODEC_VERB_CMD8(cmd) (CODEC_VERB_CMD((cmd), CODEC_VERB_8BIT_CMD, 8)) 49 49 #define CODEC_VERB_CMD16(cmd) (CODEC_VERB_CMD((cmd), CODEC_VERB_16BIT_CMD, 16)) 50 #define CODEC_VERB_PAYLOAD4(cmd) ((cmd) & CODEC_VERB_4BIT_DATA) 51 #define CODEC_VERB_PAYLOAD8(cmd) ((cmd) & CODEC_VERB_8BIT_DATA) 52 #define CODEC_VERB_PAYLOAD16(cmd) ((cmd) & CODEC_VERB_16BIT_DATA) 50 53 51 54 #define CODEC_VERB_GET_AMP_DIRECTION RT_BIT(15) … … 74 77 /* VendorID (7.3.4.1) */ 75 78 #define CODEC_MAKE_F00_00(vendorID, deviceID) (((vendorID) << 16) | (deviceID)) 79 #define CODEC_F00_00_VENDORID(f00_00) (((f00_00) >> 16) & 0xFFFF) 80 #define CODEC_F00_00_DEVICEID(f00_00) ((f00_00) & 0xFFFF) 76 81 /* RevisionID (7.3.4.2)*/ 77 82 #define CODEC_MAKE_F00_02(MajRev, MinRev, RevisionID, SteppingID) (((MajRev) << 20)|((MinRev) << 16)|((RevisionID) << 8)|(SteppingID)) 78 83 /* Subordinate node count (7.3.4.3)*/ 79 84 #define CODEC_MAKE_F00_04(startNodeNumber, totalNodeNumber) ((((startNodeNumber) & 0xFF) << 16)|((totalNodeNumber) & 0xFF)) 85 #define CODEC_F00_04_TO_START_NODE_NUMBER(f00_04) (((f00_04) >> 16) & 0xFF) 86 #define CODEC_F00_04_TO_NODE_COUNT(f00_04) ((f00_04) & 0xFF) 80 87 /* 81 88 * Function Group Type (7.3.4.4) … … 83 90 * [0x80 - 0xff] are vendor defined function groups 84 91 */ 85 #define CODEC_MAKE_F00_05(UnSol, NodeType) (( UnSol)|(NodeType))92 #define CODEC_MAKE_F00_05(UnSol, NodeType) (((UnSol) << 8)|(NodeType)) 86 93 #define CODEC_F00_05_UNSOL RT_BIT(8) 87 94 #define CODEC_F00_05_AFG (0x1) 88 95 #define CODEC_F00_05_MFG (0x2) 96 #define CODEC_F00_05_IS_UNSOL(f00_05) RT_BOOL((f00_05) & RT_BIT(8)) 97 #define CODEC_F00_05_GROUP(f00_05) ((f00_05) & 0xff) 89 98 /* Audio Function Group capabilities (7.3.4.5) */ 90 #define CODEC_MAKE_F00_08(BeepGen, InputDelay, OutputDelay) (( BeepGen)| (((InputDelay) & 0xF) << 8) | ((OutputDelay) & 0xF))91 #define CODEC_F00_08_BEEP_GEN RT_BIT(16)99 #define CODEC_MAKE_F00_08(BeepGen, InputDelay, OutputDelay) ((((BeepGen) & 0x1) << 16)| (((InputDelay) & 0xF) << 8) | ((OutputDelay) & 0xF)) 100 #define CODEC_F00_08_BEEP_GEN(f00_08) ((f00_08) & RT_BIT(16) 92 101 93 102 /* Widget Capabilities (7.3.4.6) */ … … 120 129 #define CODEC_F00_09_CAP_IN_AMP_PRESENT RT_BIT(1) 121 130 #define CODEC_F00_09_CAP_LSB RT_BIT(0) 131 132 #define CODEC_F00_09_TYPE(f00_09) (((f00_09) >> 20) & 0xF) 133 134 #define CODEC_F00_09_IS_CAP_CP(f00_09) RT_BOOL((f00_09) & RT_BIT(12)) 135 #define CODEC_F00_09_IS_CAP_L_R_SWAP(f00_09) RT_BOOL((f00_09) & RT_BIT(11)) 136 #define CODEC_F00_09_IS_CAP_POWER_CTRL(f00_09) RT_BOOL((f00_09) & RT_BIT(10)) 137 #define CODEC_F00_09_IS_CAP_DIGITAL(f00_09) RT_BOOL((f00_09) & RT_BIT(9)) 138 #define CODEC_F00_09_IS_CAP_CONNECTION_LIST(f00_09) RT_BOOL((f00_09) & RT_BIT(8)) 139 #define CODEC_F00_09_IS_CAP_UNSOL(f00_09) RT_BOOL((f00_09) & RT_BIT(7)) 140 #define CODEC_F00_09_IS_CAP_PROC_WIDGET(f00_09) RT_BOOL((f00_09) & RT_BIT(6)) 141 #define CODEC_F00_09_IS_CAP_STRIPE(f00_09) RT_BOOL((f00_09) & RT_BIT(5)) 142 #define CODEC_F00_09_IS_CAP_FMT_OVERRIDE(f00_09) RT_BOOL((f00_09) & RT_BIT(4)) 143 #define CODEC_F00_09_IS_CAP_AMP_OVERRIDE(f00_09) RT_BOOL((f00_09) & RT_BIT(3)) 144 #define CODEC_F00_09_IS_CAP_OUT_AMP_PRESENT(f00_09) RT_BOOL((f00_09) & RT_BIT(2)) 145 #define CODEC_F00_09_IS_CAP_IN_AMP_PRESENT(f00_09) RT_BOOL((f00_09) & RT_BIT(1)) 146 #define CODEC_F00_09_IS_CAP_LSB(f00_09) RT_BOOL((f00_09) & RT_BIT(0)) 122 147 123 148 /* Supported PCM size, rates (7.3.4.7) */ … … 164 189 #define CODEC_F00_0C_CAP_IMPENDANCE_SENSE RT_BIT(0) 165 190 166 /* Amplifier capabilities (7.3.4.10) */ 191 #define CODEC_F00_0C_IS_CAP_HBR(f00_0c) ((f00_0c) & RT_BIT(27)) 192 #define CODEC_F00_0C_IS_CAP_DP(f00_0c) ((f00_0c) & RT_BIT(24)) 193 #define CODEC_F00_0C_IS_CAP_EAPD(f00_0c) ((f00_0c) & RT_BIT(16)) 194 #define CODEC_F00_0C_IS_CAP_HDMI(f00_0c) ((f00_0c) & RT_BIT(7)) 195 #define CODEC_F00_0C_IS_CAP_BALANCED_IO(f00_0c) ((f00_0c) & RT_BIT(6)) 196 #define CODEC_F00_0C_IS_CAP_INPUT(f00_0c) ((f00_0c) & RT_BIT(5)) 197 #define CODEC_F00_0C_IS_CAP_OUTPUT(f00_0c) ((f00_0c) & RT_BIT(4)) 198 #define CODEC_F00_0C_IS_CAP_HP(f00_0c) ((f00_0c) & RT_BIT(3)) 199 #define CODEC_F00_0C_IS_CAP_PRESENSE_DETECT(f00_0c) ((f00_0c) & RT_BIT(2)) 200 #define CODEC_F00_0C_IS_CAP_TRIGGER_REQUIRED(f00_0c) ((f00_0c) & RT_BIT(1)) 201 #define CODEC_F00_0C_IS_CAP_IMPENDANCE_SENSE(f00_0c) ((f00_0c) & RT_BIT(0)) 202 203 /* Input Amplifier capabilities (7.3.4.10) */ 167 204 #define CODEC_MAKE_F00_0D(mute_cap, step_size, num_steps, offset) \ 168 205 ( (((mute_cap) & 0x1) << 31) \ … … 171 208 | ((offset) & 0xFF)) 172 209 210 /* Output Amplifier capabilities (7.3.4.10) */ 211 #define CODEC_MAKE_F00_12 CODEC_MAKE_F00_0D 212 173 213 /* Connection list lenght (7.3.4.11) */ 174 214 #define CODEC_MAKE_F00_0E(long_form, length) \ 175 215 ( (((long_form) & 0x1) << 7) \ 176 216 | ((length) & 0x7F)) 217 #define CODEC_F00_0E_IS_LONG(f00_0e) RT_BOOL((f00_0e) & RT_BIT(7)) 218 #define CODEC_F00_0E_COUNT(f00_0e) ((f00_0e) & 0x7F) 177 219 /* Supported Power States (7.3.4.12) */ 178 220 #define CODEC_F00_0F_EPSS RT_BIT(31) … … 185 227 #define CODEC_F00_0F_D0 RT_BIT(0) 186 228 229 /* Processing capabilities 7.3.4.13 */ 230 #define CODEC_MAKE_F00_10(num, benign) ((((num) & 0xFF) << 8) | ((benign) & 0x1)) 231 #define CODEC_F00_10_NUM(f00_10) (((f00_10) & (0xFF << 8)) >> 8) 232 #define CODEC_F00_10_BENING(f00_10) ((f00_10) & 0x1) 233 187 234 /* CP/IO Count (7.3.4.14) */ 188 235 #define CODEC_MAKE_F00_11(wake, unsol, numgpi, numgpo, numgpio) \ … … 193 240 | ((numgpio) & 0xFF)) 194 241 242 /* Processing States (7.3.3.4) */ 243 #define CODEC_F03_OFF (0) 244 #define CODEC_F03_ON RT_BIT(0) 245 #define CODEC_F03_BENING RT_BIT(1) 195 246 /* Power States (7.3.3.10) */ 196 247 #define CODEC_MAKE_F05(reset, stopok, error, act, set) \ … … 212 263 #define CODEC_F05_SET(value) (((value) & 0x7)) 213 264 265 #define CODEC_F05_GE(p0, p1) ((p0) <= (p1)) 266 #define CODEC_F05_LE(p0, p1) ((p0) >= (p1)) 267 214 268 /* Pin Widged Control (7.3.3.13) */ 215 269 #define CODEC_F07_VREF_HIZ (0) … … 222 276 #define CODEC_F07_OUT_H_ENABLE RT_BIT(7) 223 277 278 /* Unsolicited enabled (7.3.3.14) */ 279 #define CODEC_MAKE_F08(enable, tag) ((((enable) & 1) << 7) | ((tag) & 0x3F)) 280 224 281 /* Converter formats (7.3.3.8) and (3.7.1) */ 225 282 #define CODEC_MAKE_A(fNonPCM, f44_1BaseRate, mult, div, bits, chan) \ … … 260 317 | (((fELDValid) & 0x1) << 30)) 261 318 319 #define CODEC_MAKE_F0C(lrswap, eapd, btl) ((((lrswap) & 1) << 2) | (((eapd) & 1) << 1) | ((btl) & 1)) 320 #define CODEC_FOC_IS_LRSWAP(f0c) RT_BOOL((f0c) & RT_BIT(2)) 321 #define CODEC_FOC_IS_EAPD(f0c) RT_BOOL((f0c) & RT_BIT(1)) 322 #define CODEC_FOC_IS_BTL(f0c) RT_BOOL((f0c) & RT_BIT(0)) 262 323 /* HDA spec 7.3.3.31 defines layout of configuration registers/verbs (0xF1C) */ 263 324 /* Configuration's port connection */ … … 289 350 #define CODEC_F1C_LOCATION_SPECIAL_0 (0x7) 290 351 #define CODEC_F1C_LOCATION_SPECIAL_1 (0x8) 291 #define CODEC_F1C_LOCATION_SPECIAL_ 3(0x9)352 #define CODEC_F1C_LOCATION_SPECIAL_2 (0x9) 292 353 293 354 /* Configuration's devices */ … … 351 412 #define CODEC_F1C_MISC_MASK (0xF) 352 413 #define CODEC_F1C_MISC_SHIFT (8) 353 #define CODEC_F1C_MISC_JACK_DETECT RT_BIT(0)354 #define CODEC_F1C_MISC_RESERVED_0 RT_BIT(1)355 #define CODEC_F1C_MISC_RESERVED_1 RT_BIT(2)356 #define CODEC_F1C_MISC_RESERVED_2 RT_BIT(3)414 #define CODEC_F1C_MISC_JACK_DETECT (0) 415 #define CODEC_F1C_MISC_RESERVED_0 (1) 416 #define CODEC_F1C_MISC_RESERVED_1 (2) 417 #define CODEC_F1C_MISC_RESERVED_2 (3) 357 418 358 419 /* Configuration's association */ … … 382 443 383 444 445 #ifndef VBOX_WITH_HDA_CODEC_EMU 384 446 typedef struct CODECVERB 385 447 { … … 389 451 PFNCODECVERBPROCESSOR pfn; 390 452 } CODECVERB; 391 392 #ifndef VBOX_HDA_CODEC_EMU 453 #endif 454 455 #ifndef VBOX_WITH_HDA_CODEC_EMU 393 456 # define TYPE union 394 457 #else 395 458 # define TYPE struct 459 typedef struct CODECEMU CODECEMU; 460 typedef CODECEMU *PCODECEMU; 396 461 #endif 397 462 TYPE CODECNODE; … … 408 473 } ENMSOUNDSOURCE; 409 474 410 typedef enum411 {412 STAC9220_CODEC,413 ALC885_CODEC414 } ENMCODEC;415 475 416 476 typedef struct CODECState … … 421 481 uint8_t u8BSKU; 422 482 uint8_t u8AssemblyId; 483 #ifndef VBOX_WITH_HDA_CODEC_EMU 423 484 CODECVERB *pVerbs; 424 485 int cVerbs; 486 #else 487 PCODECEMU pCodecBackend; 488 #endif 425 489 PCODECNODE pNodes; 426 490 QEMUSoundCard card; … … 429 493 /** PCM out */ 430 494 SWVoiceOut *SwVoiceOut; 431 ENMCODEC enmCodec;432 495 void *pHDAState; 433 496 bool fInReset; 497 #ifndef VBOX_WITH_HDA_CODEC_EMU 434 498 const uint8_t cTotalNodes; 435 499 const uint8_t *au8Ports; … … 448 512 const uint8_t u8AdcVolsLineIn; 449 513 const uint8_t u8DacLineOut; 514 #endif 450 515 DECLR3CALLBACKMEMBER(int, pfnProcess, (struct CODECState *)); 516 DECLR3CALLBACKMEMBER(void, pfnTransfer, (struct CODECState *pState, ENMSOUNDSOURCE, int avail)); 517 /* These callbacks are set by Codec implementation */ 451 518 DECLR3CALLBACKMEMBER(int, pfnLookup, (struct CODECState *pState, uint32_t verb, PPFNCODECVERBPROCESSOR)); 452 519 DECLR3CALLBACKMEMBER(int, pfnReset, (struct CODECState *pState)); 453 DECLR3CALLBACKMEMBER(void, pfnTransfer, (struct CODECState *pState, ENMSOUNDSOURCE, int avail));454 520 DECLR3CALLBACKMEMBER(int, pfnCodecNodeReset, (struct CODECState *pState, uint8_t, PCODECNODE)); 455 456 } CODECState; 457 458 int codecConstruct(PPDMDEVINS pDevIns, CODECState *pCodecState, ENMCODEC enmCodec); 521 /* These callbacks are set by codec implementation to answer debugger requests */ 522 DECLR3CALLBACKMEMBER(void, pfnCodecDbgListNodes, (CODECState *pState, PCDBGFINFOHLP pHlp, const char *pszArgs)); 523 DECLR3CALLBACKMEMBER(void, pfnCodecDbgSelector, (CODECState *pState, PCDBGFINFOHLP pHlp, const char *pszArgs)); 524 } CODECState, *PCODECState; 525 526 int codecConstruct(PPDMDEVINS pDevIns, CODECState *pCodecState, PCFGMNODE pCfgHandle); 459 527 int codecDestruct(CODECState *pCodecState); 460 528 int codecSaveState(CODECState *pCodecState, PSSMHANDLE pSSMHandle); … … 462 530 int codecOpenVoice(CODECState *pCodecState, ENMSOUNDSOURCE enmSoundSource, audsettings_t *pAudioSettings); 463 531 532 # ifdef VBOX_WITH_HDA_CODEC_EMU 533 /* */ 534 struct CODECEMU 535 { 536 DECLR3CALLBACKMEMBER(int, pfnCodecEmuConstruct, (PCODECState pState)); 537 DECLR3CALLBACKMEMBER(int, pfnCodecEmuDestruct, (PCODECState pState)); 538 DECLR3CALLBACKMEMBER(int, pfnCodecEmuReset, (PCODECState pState, bool fInit)); 539 }; 540 # endif 464 541 #endif -
trunk/src/VBox/Devices/Audio/DevIchIntelHDA.cpp
r35515 r36691 58 58 static DECLCALLBACK(void) hdaReset (PPDMDEVINS pDevIns); 59 59 60 #define HDA_NREGS 112 60 61 /* Registers */ 61 62 #define HDA_REG_IND_NAME(x) ICH6_HDA_REG_##x … … 263 264 #define ICH6_HDA_SDCTL_NUM_MASK (0xF) 264 265 #define ICH6_HDA_SDCTL_NUM_SHIFT (20) 266 #define ICH6_HDA_SDCTL_DIR_SHIFT (19) 267 #define ICH6_HDA_SDCTL_TP_SHIFT (18) 268 #define ICH6_HDA_SDCTL_STRIPE_MASK (0x3) 269 #define ICH6_HDA_SDCTL_STRIPE_SHIFT (16) 265 270 #define ICH6_HDA_SDCTL_DEIE_SHIFT (4) 266 271 #define ICH6_HDA_SDCTL_FEIE_SHIFT (3) … … 373 378 #define ICH6_HDA_SDFMT_DIV_SHIFT (8) 374 379 #define ICH6_HDA_SDFMT_DIV_MASK (0x7) 380 #define ICH6_HDA_SDFMT_BITS_SHIFT (4) 381 #define ICH6_HDA_SDFMT_BITS_MASK (0x7) 375 382 #define SDFMT_BASE_RATE(pState, num) ((SDFMT(pState, num) & HDA_REG_FIELD_FLAG_MASK(SDFMT, BASE_RATE)) >> HDA_REG_FIELD_SHIFT(SDFMT, BASE_RATE)) 376 383 #define SDFMT_MULT(pState, num) ((SDFMT((pState), num) & HDA_REG_FIELD_MASK(SDFMT,MULT)) >> HDA_REG_FIELD_SHIFT(SDFMT, MULT)) … … 435 442 PDMIBASE IBase; 436 443 RTGCPHYS addrMMReg; 437 uint32_t au32Regs[ 113];444 uint32_t au32Regs[HDA_NREGS]; 438 445 HDABDLEDESC stInBdle; 439 446 HDABDLEDESC stOutBdle; … … 522 529 #endif 523 530 531 524 532 /* see 302349 p 6.2*/ 525 533 const static struct stIchIntelHDRegMap … … 541 549 /** Full name. */ 542 550 const char *name; 543 } s_ichIntelHDRegMap[ ] =551 } s_ichIntelHDRegMap[HDA_NREGS] = 544 552 { 545 553 /* offset size read mask write mask read callback write callback abbrev full name */ … … 1249 1257 } 1250 1258 pAudSetting->freq = u32Hz * u32HzMult / u32HzDiv; 1251 pAudSetting->nchannels = 2; 1259 1260 switch (EXTRACT_VALUE(u32SdFmt, ICH6_HDA_SDFMT_BITS_MASK, ICH6_HDA_SDFMT_BITS_SHIFT)) 1261 { 1262 case 0: 1263 Log(("hda: %s requested 8 bit\n", __FUNCTION__)); 1264 pAudSetting->fmt = AUD_FMT_S8; 1265 break; 1266 case 1: 1267 Log(("hda: %s requested 16 bit\n", __FUNCTION__)); 1268 pAudSetting->fmt = AUD_FMT_S16; 1269 break; 1270 case 2: 1271 Log(("hda: %s requested 20 bit\n", __FUNCTION__)); 1272 break; 1273 case 3: 1274 Log(("hda: %s requested 24 bit\n", __FUNCTION__)); 1275 break; 1276 case 4: 1277 Log(("hda: %s requested 32 bit\n", __FUNCTION__)); 1278 pAudSetting->fmt = AUD_FMT_S32; 1279 break; 1280 default: 1281 AssertMsgFailed(("Unsupported")); 1282 } 1283 pAudSetting->nchannels = (u32SdFmt & 0xf) + 1; 1252 1284 pAudSetting->fmt = AUD_FMT_S16; 1253 1285 pAudSetting->endianness = 0; … … 1257 1289 DECLCALLBACK(int)hdaRegWriteSDFMT(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value) 1258 1290 { 1259 #if 0 1260 /* @todo here some more investigations are required. */ 1261 audsettings_t as; 1262 /* no reason to reopen voice with same settings */ 1263 if (u32Value == HDA_REG_IND(pState, index)) 1264 return VINF_SUCCESS; 1265 hdaSdFmtToAudSettings(u32Value, &as); 1266 switch (index) 1267 { 1268 case ICH6_HDA_REG_SD0FMT: 1269 codecOpenVoice(&pState->Codec, PI_INDEX, &as); 1270 break; 1271 case ICH6_HDA_REG_SD4FMT: 1272 codecOpenVoice(&pState->Codec, PO_INDEX, &as); 1273 break; 1274 default: 1275 AssertMsgFailed(("unimplemented")); 1276 } 1291 #ifdef VBOX_WITH_HDA_CODEC_EMU 1292 /* @todo here some more investigations are required. */ 1293 int rc = 0; 1294 audsettings_t as; 1295 /* no reason to reopen voice with same settings */ 1296 if (u32Value == HDA_REG_IND(pState, index)) 1297 return VINF_SUCCESS; 1298 hdaSdFmtToAudSettings(u32Value, &as); 1299 switch (index) 1300 { 1301 case ICH6_HDA_REG_SD0FMT: 1302 rc = codecOpenVoice(&pState->Codec, PI_INDEX, &as); 1303 break; 1304 case ICH6_HDA_REG_SD4FMT: 1305 rc = codecOpenVoice(&pState->Codec, PO_INDEX, &as); 1306 break; 1307 default: 1308 Log(("HDA: attempt to change format on %d\n", index)); 1309 rc = 0; 1310 } 1311 return hdaRegWriteU16(pState, offset, index, u32Value); 1312 #else 1313 return hdaRegWriteU16(pState, offset, index, u32Value); 1277 1314 #endif 1278 return hdaRegWriteU16(pState, offset, index, u32Value);1279 1315 } 1280 1316 … … 2061 2097 } 2062 2098 2099 static inline int hdaLookUpRegisterByName(INTELHDLinkState *pState, const char *pszArgs) 2100 { 2101 int iReg = 0; 2102 for (; iReg < HDA_NREGS; ++iReg) 2103 if (!RTStrICmp(s_ichIntelHDRegMap[iReg].abbrev, pszArgs)) 2104 return iReg; 2105 return -1; 2106 } 2107 static inline void hdaDbgPrintRegister(INTELHDLinkState *pState, PCDBGFINFOHLP pHlp, int iHdaIndex) 2108 { 2109 Assert( pState 2110 && iHdaIndex >= 0 2111 && iHdaIndex < HDA_NREGS); 2112 pHlp->pfnPrintf(pHlp, "hda: %s: 0x%x\n", s_ichIntelHDRegMap[iHdaIndex].abbrev, pState->au32Regs[iHdaIndex]); 2113 } 2114 static DECLCALLBACK(void) hdaDbgInfo(PPDMDEVINS pDevIns, PCDBGFINFOHLP pHlp, const char *pszArgs) 2115 { 2116 PCIINTELHDLinkState *pThis = PDMINS_2_DATA(pDevIns, PCIINTELHDLinkState *); 2117 INTELHDLinkState *hda = &pThis->hda; 2118 int iHdaRegisterIndex = hdaLookUpRegisterByName(hda, pszArgs); 2119 if (iHdaRegisterIndex != -1) 2120 hdaDbgPrintRegister(hda, pHlp, iHdaRegisterIndex); 2121 else 2122 for(iHdaRegisterIndex = 0; (unsigned int)iHdaRegisterIndex < HDA_NREGS; ++iHdaRegisterIndex) 2123 hdaDbgPrintRegister(hda, pHlp, iHdaRegisterIndex); 2124 } 2125 2126 static inline void hdaDbgPrintStream(INTELHDLinkState *pState, PCDBGFINFOHLP pHlp, int iHdaStrmIndex) 2127 { 2128 Assert( pState 2129 && iHdaStrmIndex >= 0 2130 && iHdaStrmIndex < 7); 2131 pHlp->pfnPrintf(pHlp, "Dump of %d Hda Stream:\n", iHdaStrmIndex); 2132 pHlp->pfnPrintf(pHlp, "SD%dCTL: %R[sdctl]\n", iHdaStrmIndex, HDA_STREAM_REG2(pState, CTL, iHdaStrmIndex)); 2133 pHlp->pfnPrintf(pHlp, "SD%dCTS: %R[sdsts]\n", iHdaStrmIndex, HDA_STREAM_REG2(pState, STS, iHdaStrmIndex)); 2134 pHlp->pfnPrintf(pHlp, "SD%dFIFOS: %R[sdfifos]\n", iHdaStrmIndex, HDA_STREAM_REG2(pState, FIFOS, iHdaStrmIndex)); 2135 pHlp->pfnPrintf(pHlp, "SD%dFIFOW: %R[sdfifow]\n", iHdaStrmIndex, HDA_STREAM_REG2(pState, FIFOW, iHdaStrmIndex)); 2136 } 2137 2138 static inline int hdaLookUpStreamIndex(INTELHDLinkState *pState, const char *pszArgs) 2139 { 2140 /* todo: add args parsing */ 2141 return -1; 2142 } 2143 static DECLCALLBACK(void) hdaDbgStreamInfo(PPDMDEVINS pDevIns, PCDBGFINFOHLP pHlp, const char *pszArgs) 2144 { 2145 PCIINTELHDLinkState *pThis = PDMINS_2_DATA(pDevIns, PCIINTELHDLinkState *); 2146 INTELHDLinkState *hda = &pThis->hda; 2147 int iHdaStrmIndex = hdaLookUpStreamIndex(hda, pszArgs); 2148 if (iHdaStrmIndex != -1) 2149 hdaDbgPrintStream(hda, pHlp, iHdaStrmIndex); 2150 else 2151 for(iHdaStrmIndex = 0; iHdaStrmIndex < 7; ++iHdaStrmIndex) 2152 hdaDbgPrintStream(hda, pHlp, iHdaStrmIndex); 2153 } 2154 2155 /* Codec debugger interface */ 2156 static DECLCALLBACK(void) hdaCodecDbgNodes(PPDMDEVINS pDevIns, PCDBGFINFOHLP pHlp, const char *pszArgs) 2157 { 2158 PCIINTELHDLinkState *pThis = PDMINS_2_DATA(pDevIns, PCIINTELHDLinkState *); 2159 INTELHDLinkState *hda = &pThis->hda; 2160 if (hda->Codec.pfnCodecDbgListNodes) 2161 hda->Codec.pfnCodecDbgListNodes(&hda->Codec, pHlp, pszArgs); 2162 else 2163 pHlp->pfnPrintf(pHlp, "Codec implementation doesn't provide corresponding callback.\n"); 2164 } 2165 2166 static DECLCALLBACK(void) hdaCodecDbgSelector(PPDMDEVINS pDevIns, PCDBGFINFOHLP pHlp, const char *pszArgs) 2167 { 2168 PCIINTELHDLinkState *pThis = PDMINS_2_DATA(pDevIns, PCIINTELHDLinkState *); 2169 INTELHDLinkState *hda = &pThis->hda; 2170 if (hda->Codec.pfnCodecDbgSelector) 2171 hda->Codec.pfnCodecDbgSelector(&hda->Codec, pHlp, pszArgs); 2172 else 2173 pHlp->pfnPrintf(pHlp, "Codec implementation doesn't provide corresponding callback.\n"); 2174 } 2175 2063 2176 //#define HDA_AS_PCI_EXPRESS 2177 /* Misc routines */ 2178 static inline bool printHdaIsValid(const char *pszType, const char *pszExpectedFlag) 2179 { 2180 return (RTStrCmp(pszType, pszExpectedFlag) == 0); 2181 } 2182 static const char *printHdaYesNo(bool fFlag) 2183 { 2184 return fFlag ? "yes" : "no"; 2185 } 2186 static DECLCALLBACK(size_t) 2187 printHdaStrmCtl(PFNRTSTROUTPUT pfnOutput, void *pvArgOutput, 2188 const char *pszType, void const *pvValue, 2189 int cchWidth, int cchPrecision, unsigned fFlags, 2190 void *pvUser) 2191 { 2192 uint32_t sdCtl = (uint32_t)(uintptr_t)pvValue; 2193 size_t cb = 0; 2194 if (!printHdaIsValid(pszType, "sdctl")) 2195 return cb; 2196 cb += RTStrFormat(pfnOutput, pvArgOutput, NULL, 0, 2197 "SDCTL(raw: %#0x, strm:0x%x, dir:%s, tp:%s strip:%x, deie:%s, ioce:%s, run:%s, srst:%s)", 2198 sdCtl, 2199 ((sdCtl & HDA_REG_FIELD_MASK(SDCTL, NUM)) >> ICH6_HDA_SDCTL_NUM_SHIFT), 2200 printHdaYesNo(RT_BOOL(sdCtl & HDA_REG_FIELD_FLAG_MASK(SDCTL, DIR))), 2201 printHdaYesNo(RT_BOOL(sdCtl & HDA_REG_FIELD_FLAG_MASK(SDCTL, TP))), 2202 ((sdCtl & HDA_REG_FIELD_MASK(SDCTL, STRIPE)) >> ICH6_HDA_SDCTL_STRIPE_SHIFT), 2203 printHdaYesNo(RT_BOOL(sdCtl & HDA_REG_FIELD_FLAG_MASK(SDCTL, DEIE))), 2204 printHdaYesNo(RT_BOOL(sdCtl & HDA_REG_FIELD_FLAG_MASK(SDCTL, ICE))), 2205 printHdaYesNo(RT_BOOL(sdCtl & HDA_REG_FIELD_FLAG_MASK(SDCTL, RUN))), 2206 printHdaYesNo(RT_BOOL(sdCtl & HDA_REG_FIELD_FLAG_MASK(SDCTL, SRST)))); 2207 return cb; 2208 } 2209 2210 static DECLCALLBACK(size_t) 2211 printHdaStrmFifos(PFNRTSTROUTPUT pfnOutput, void *pvArgOutput, 2212 const char *pszType, void const *pvValue, 2213 int cchWidth, int cchPrecision, unsigned fFlags, 2214 void *pvUser) 2215 { 2216 uint32_t sdFifos = (uint32_t)(uintptr_t)pvValue; 2217 uint32_t u32Bytes = 0; 2218 size_t cb = 0; 2219 if (!printHdaIsValid(pszType, "sdfifos")) 2220 return cb; 2221 switch(sdFifos) 2222 { 2223 case HDA_SDONFIFO_16B: u32Bytes = 16; break; 2224 case HDA_SDONFIFO_32B: u32Bytes = 32; break; 2225 case HDA_SDONFIFO_64B: u32Bytes = 64; break; 2226 case HDA_SDONFIFO_128B: u32Bytes = 128; break; 2227 case HDA_SDONFIFO_192B: u32Bytes = 192; break; 2228 case HDA_SDONFIFO_256B: u32Bytes = 256; break; 2229 case HDA_SDINFIFO_120B: u32Bytes = 120; break; 2230 case HDA_SDINFIFO_160B: u32Bytes = 160; break; 2231 default:; 2232 } 2233 cb += RTStrFormat(pfnOutput, pvArgOutput, NULL, 0, 2234 "SDFIFOS(raw: %#0x, sdfifos:%d B)", 2235 sdFifos, 2236 u32Bytes); 2237 return cb; 2238 } 2239 2240 static DECLCALLBACK(size_t) 2241 printHdaStrmFifow(PFNRTSTROUTPUT pfnOutput, void *pvArgOutput, 2242 const char *pszType, void const *pvValue, 2243 int cchWidth, int cchPrecision, unsigned fFlags, 2244 void *pvUser) 2245 { 2246 uint32_t sdFifow = (uint32_t)(uintptr_t)pvValue; 2247 uint32_t u32Bytes = 0; 2248 size_t cb = 0; 2249 if (!printHdaIsValid(pszType, "sdfifow")) 2250 return cb; 2251 switch(sdFifow) 2252 { 2253 case HDA_SDFIFOW_8B: u32Bytes = 8; break; 2254 case HDA_SDFIFOW_16B: u32Bytes = 16; break; 2255 case HDA_SDFIFOW_32B: u32Bytes = 32; break; 2256 } 2257 cb += RTStrFormat(pfnOutput, pvArgOutput, NULL, 0, 2258 "SDFIFOW(raw: %#0x, sdfifow:%d B)", 2259 sdFifow, 2260 u32Bytes); 2261 return cb; 2262 } 2263 2264 static DECLCALLBACK(size_t) 2265 printHdaStrmSts(PFNRTSTROUTPUT pfnOutput, void *pvArgOutput, 2266 const char *pszType, void const *pvValue, 2267 int cchWidth, int cchPrecision, unsigned fFlags, 2268 void *pvUser) 2269 { 2270 uint32_t sdSts = (uint32_t)(uintptr_t)pvValue; 2271 size_t cb = 0; 2272 if (!printHdaIsValid(pszType, "sdsts")) 2273 return cb; 2274 cb += RTStrFormat(pfnOutput, pvArgOutput, NULL, 0, 2275 "SDSTS(raw: %#0x, fifordy:%s, dese:%s, fifoe:%s, bcis:%s)", 2276 sdSts, 2277 printHdaYesNo(RT_BOOL(sdSts & HDA_REG_FIELD_FLAG_MASK(SDSTS, FIFORDY))), 2278 printHdaYesNo(RT_BOOL(sdSts & HDA_REG_FIELD_FLAG_MASK(SDSTS, DE))), 2279 printHdaYesNo(RT_BOOL(sdSts & HDA_REG_FIELD_FLAG_MASK(SDSTS, FE))), 2280 printHdaYesNo(RT_BOOL(sdSts & HDA_REG_FIELD_FLAG_MASK(SDSTS, BCIS)))); 2281 return cb; 2282 } 2283 /** 2284 * This routine registers debugger info extensions and custom printf formatters 2285 */ 2286 static inline int hdaInitMisc(PPDMDEVINS pDevIns) 2287 { 2288 int rc; 2289 PDMDevHlpDBGFInfoRegister(pDevIns, "hda", "HDA info. (hda [register case-insensitive])", hdaDbgInfo); 2290 PDMDevHlpDBGFInfoRegister(pDevIns, "hdastrm", "HDA stream info. (hdastrm [stream number])", hdaDbgStreamInfo); 2291 PDMDevHlpDBGFInfoRegister(pDevIns, "hdcnodes", "HDA codec nodes.", hdaCodecDbgNodes); 2292 PDMDevHlpDBGFInfoRegister(pDevIns, "hdcselector", "HDA codec's selector states [node number].", hdaCodecDbgSelector); 2293 rc = RTStrFormatTypeRegister("sdctl", printHdaStrmCtl, NULL); 2294 AssertRC(rc); 2295 rc = RTStrFormatTypeRegister("sdsts", printHdaStrmSts, NULL); 2296 AssertRC(rc); 2297 rc = RTStrFormatTypeRegister("sdfifos", printHdaStrmFifos, NULL); 2298 AssertRC(rc); 2299 rc = RTStrFormatTypeRegister("sdfifow", printHdaStrmFifow, NULL); 2300 AssertRC(rc); 2301 #if 0 2302 rc = RTStrFormatTypeRegister("sdfmt", printHdaStrmFmt, NULL); 2303 AssertRC(rc); 2304 #endif 2305 return rc; 2306 } 2064 2307 2065 2308 /** … … 2218 2461 2219 2462 pThis->hda.Codec.pHDAState = (void *)&pThis->hda; 2220 rc = codecConstruct(pDevIns, &pThis->hda.Codec, /* ALC885_CODEC */ STAC9220_CODEC);2463 rc = codecConstruct(pDevIns, &pThis->hda.Codec, pCfgHandle); 2221 2464 if (RT_FAILURE(rc)) 2222 2465 AssertRCReturn(rc, rc); … … 2239 2482 WAKEEN(&pThis->hda) = 0x0; 2240 2483 STATESTS(&pThis->hda) = 0x0; 2484 hdaInitMisc(pDevIns); 2241 2485 2242 2486 return VINF_SUCCESS;
Note:
See TracChangeset
for help on using the changeset viewer.