Changeset 31075 in vbox
- Timestamp:
- Jul 24, 2010 4:08:05 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/DevCodec.cpp
r31062 r31075 65 65 66 66 #define STAC9220_IS_AFG_CMD(cmd) ( \ 67 CODEC_NID(cmd) == 0x1 \68 ) 67 CODEC_NID(cmd) == 0x1) 68 69 69 #define STAC9220_IS_PORT_CMD(cmd) ( \ 70 71 72 73 74 75 || CODEC_NID(cmd) == 0xF \76 ) 70 CODEC_NID(cmd) == 0xA \ 71 || CODEC_NID(cmd) == 0xB \ 72 || CODEC_NID(cmd) == 0xC \ 73 || CODEC_NID(cmd) == 0xD \ 74 || CODEC_NID(cmd) == 0xE \ 75 || CODEC_NID(cmd) == 0xF) 76 77 77 #define STAC9220_IS_DAC_CMD(cmd) ( \ 78 CODEC_NID(cmd) == 0x2 \ 79 || CODEC_NID(cmd) == 0x3 \ 80 || CODEC_NID(cmd) == 0x4 \ 81 || CODEC_NID(cmd) == 0x5) 78 CODEC_NID(cmd) == 0x2 \ 79 || CODEC_NID(cmd) == 0x3 \ 80 || CODEC_NID(cmd) == 0x4 \ 81 || CODEC_NID(cmd) == 0x5) 82 82 83 #define STAC9220_IS_ADCVOL_CMD(cmd) ( \ 83 84 CODEC_NID(cmd) == 0x17 \ 84 85 || CODEC_NID(cmd) == 0x18) 86 85 87 #define STAC9220_IS_ADC_CMD(cmd) ( \ 86 88 CODEC_NID(cmd) == 0x6 \ 87 89 || CODEC_NID(cmd) == 0x7) 90 88 91 #define STAC9220_IS_ADCMUX_CMD(cmd) ( \ 89 92 CODEC_NID(cmd) == 0x12 \ 90 93 || CODEC_NID(cmd) == 0x13) 91 94 95 #define STAC9220_IS_SPDIFOUT_CMD(cmd) (CODEC_NID((cmd)) == 0x8) 96 97 #define STAC9220_IS_DIGPIN_CMD(cmd) ( \ 98 CODEC_NID((cmd)) == 0x10 \ 99 || CODEC_NID((cmd)) == 0x11) 100 101 /* STAC9220 6.2 & 6.12 */ 102 #define STAC9220_IS_RESERVED_CMD(cmd) ( \ 103 CODEC_NID((cmd)) == 0x9 \ 104 || CODEC_NID((cmd)) == 0x19 \ 105 || CODEC_NID((cmd)) == 0x1A \ 106 || CODEC_NID((cmd)) == 0x1B) 92 107 93 108 static int stac9220ResetNode(struct CODECState *pState, uint8_t nodenum, PCODECNODE pNode); … … 98 113 Log(("codecUnimplemented: cmd(raw:%x: cad:%x, d:%c, nid:%x, verb:%x)\n", cmd, 99 114 CODEC_CAD(cmd), CODEC_DIRECT(cmd) ? 'N' : 'Y', CODEC_NID(cmd), CODEC_VERBDATA(cmd))); 100 //** @todo r=michaln: The zero used as a codec ID shouldn't be hardcoded! 101 if (CODEC_CAD(cmd) != 0) 115 if (CODEC_CAD(cmd) != pState->id) 102 116 //** @todo r=michaln: Are we really supposed to respond to commands sent to nonexistent codecs?? 103 117 //** @todo r=michaln: Where in the specs is this response format defined? … … 118 132 static int codecGetAmplifier(struct CODECState *pState, uint32_t cmd, uint64_t *pResp) 119 133 { 120 Assert((CODEC_CAD(cmd) == 0));134 Assert((CODEC_CAD(cmd) == pState->id)); 121 135 PCODECNODE pNode = &pState->pNodes[CODEC_NID(cmd)]; 122 136 if (STAC9220_IS_DAC_CMD(cmd)) … … 144 158 static int codecGetF00(struct CODECState *pState, uint32_t cmd, uint64_t *pResp) 145 159 { 146 Assert((CODEC_CAD(cmd) == 0));160 Assert((CODEC_CAD(cmd) == pState->id)); 147 161 *pResp = pState->pNodes[CODEC_NID(cmd)].node.au32F00_param[cmd & CODEC_VERB_8BIT_DATA]; 148 162 return VINF_SUCCESS; … … 154 168 *pResp = pState->pNodes[CODEC_NID(cmd)].port.u32F07_param; 155 169 } 156 #if 0157 170 else 158 171 AssertMsgFailed(("Unsupported")); 159 #endif160 172 return VINF_SUCCESS; 161 173 } … … 175 187 static int codecGetF02(struct CODECState *pState, uint32_t cmd, uint64_t *pResp) 176 188 { 177 Assert((CODEC_CAD(cmd) == 0));189 Assert((CODEC_CAD(cmd) == pState->id)); 178 190 *pResp = *(uint32_t *)&pState->pNodes[CODEC_NID(cmd)].node.au8F02_param[cmd & CODEC_VERB_8BIT_DATA]; 179 191 return VINF_SUCCESS; … … 182 194 static int codecGetSubId(struct CODECState *pState, uint32_t cmd, uint64_t *pResp) 183 195 { 184 Assert((CODEC_CAD(cmd) == 0));196 Assert((CODEC_CAD(cmd) == pState->id)); 185 197 if (STAC9220_IS_AFG_CMD(cmd)) 186 198 { … … 192 204 static int codecReset(struct CODECState *pState, uint32_t cmd, uint64_t *pResp) 193 205 { 194 Assert((CODEC_CAD(cmd) == 0));206 Assert((CODEC_CAD(cmd) == pState->id)); 195 207 Assert(STAC9220_IS_AFG_CMD(cmd)); 196 208 if(STAC9220_IS_AFG_CMD(cmd)) … … 212 224 static int codecGetPowerState(struct CODECState *pState, uint32_t cmd, uint64_t *pResp) 213 225 { 214 Assert((CODEC_CAD(cmd) == 0));226 Assert((CODEC_CAD(cmd) == pState->id)); 215 227 if (STAC9220_IS_AFG_CMD(cmd)) 216 228 { … … 220 232 } 221 233 #endif 222 static int stac9220Set706(struct CODECState *pState, uint32_t cmd, uint64_t *pResp) 223 { 224 Assert((CODEC_CAD(cmd) == 0)); 234 static int codecGetStreamId(struct CODECState *pState, uint32_t cmd, uint64_t *pResp) 235 { 236 Assert((CODEC_CAD(cmd) == pState->id)); 237 if (STAC9220_IS_DAC_CMD(cmd)) 238 *pResp = pState->pNodes[CODEC_NID(cmd)].dac.u32F06_param; 239 else if (STAC9220_IS_ADC_CMD(cmd)) 240 *pResp = pState->pNodes[CODEC_NID(cmd)].adc.u32F06_param; 241 else 242 *pResp = 0; /* STAC9220 6.20 6.13-6.18: no response supposed for this verb. */ 243 *pResp = 0; 244 return VINF_SUCCESS; 245 } 246 static int codecSetStreamId(struct CODECState *pState, uint32_t cmd, uint64_t *pResp) 247 { 248 Assert((CODEC_CAD(cmd) == pState->id)); 225 249 if (STAC9220_IS_DAC_CMD(cmd)) 226 250 { 227 251 pState->pNodes[CODEC_NID(cmd)].dac.u32F06_param &= ~CODEC_VERB_8BIT_DATA; 228 252 pState->pNodes[CODEC_NID(cmd)].dac.u32F06_param |= cmd & CODEC_VERB_8BIT_DATA; 229 #if 0230 if (cmd & ((0x5) << 4))231 {232 AUD_set_active_out()233 }234 #endif235 253 } 236 254 else if (STAC9220_IS_ADC_CMD(cmd)) … … 244 262 return VINF_SUCCESS; 245 263 } 264 static int codecGetConverterFormat(struct CODECState *pState, uint32_t cmd, uint64_t *pResp) 265 { 266 Assert((CODEC_CAD(cmd) == pState->id)); 267 if (STAC9220_IS_DAC_CMD(cmd)) 268 *pResp = pState->pNodes[CODEC_NID(cmd)].dac.u32A_param; 269 else if (STAC9220_IS_ADC_CMD(cmd)) 270 *pResp = pState->pNodes[CODEC_NID(cmd)].adc.u32A_param; 271 else if (STAC9220_IS_SPDIFOUT_CMD(cmd)) 272 *pResp = pState->pNodes[CODEC_NID(cmd)].spdifout.u32A_param; 273 else 274 *pResp = 0; 275 return VINF_SUCCESS; 276 } 246 277 static int codecSetConverterFormat(struct CODECState *pState, uint32_t cmd, uint64_t *pResp) 247 278 { 248 Assert((CODEC_CAD(cmd) == 0));279 Assert((CODEC_CAD(cmd) == pState->id)); 249 280 if (STAC9220_IS_DAC_CMD(cmd)) 250 281 { … … 257 288 pState->pNodes[CODEC_NID(cmd)].adc.u32A_param |= cmd & CODEC_VERB_16BIT_DATA; 258 289 } 259 else 260 AssertMsgFailed(("Unsupported")); 290 else if (STAC9220_IS_SPDIFOUT_CMD(cmd)) 291 { 292 pState->pNodes[CODEC_NID(cmd)].spdifout.u32A_param &= ~CODEC_VERB_16BIT_DATA; 293 pState->pNodes[CODEC_NID(cmd)].spdifout.u32A_param |= cmd & CODEC_VERB_16BIT_DATA; 294 } 261 295 *pResp = 0; 262 296 return VINF_SUCCESS; … … 303 337 dac_init: 304 338 memset(pNode->dac.B_params, 0, AMPLIFIER_SIZE); 305 pNode->dac.u32A_param = (0x3 << 4) | RT_BIT(0);339 pNode->dac.u32A_param = RT_BIT(14)|(0x1 << 3)|0x2; /* 441000Hz/16bit/2ch */ 306 340 307 341 AMPLIFIER_REGISTER(pNode->dac.B_params, AMPLIFIER_OUT, AMPLIFIER_LEFT, 0) = 0x7F | RT_BIT(7); … … 320 354 pNode->node.au8F02_param[0] = 0x18; 321 355 adc_init: 322 pNode->adc.u32A_param = (0x3<<4) | 0x1;356 pNode->adc.u32A_param = RT_BIT(14)|(0x1 << 3)|0x2; /* 441000Hz/16bit/2ch */ 323 357 pNode->adc.node.au32F00_param[0xE] = RT_BIT(0); 324 358 pNode->adc.u32F03_param = RT_BIT(0); … … 476 510 /* ----------- -------------------- ----------------------- */ 477 511 {0x000F0000, CODEC_VERB_8BIT_CMD , codecGetF00}, 512 {0x000A0000, CODEC_VERB_16BIT_CMD, codecGetConverterFormat}, 478 513 {0x00020000, CODEC_VERB_16BIT_CMD, codecSetConverterFormat}, 479 514 {0x000B0000, CODEC_VERB_16BIT_CMD, codecGetAmplifier }, 480 {0x00070600, CODEC_VERB_8BIT_CMD , stac9220Set706 }, 481 {0x000F0700, CODEC_VERB_8BIT_CMD , stac9220SetPinCtrl}, 482 {0x00070700, CODEC_VERB_8BIT_CMD , stac9220GetPinCtrl}, 515 {0x00070600, CODEC_VERB_8BIT_CMD , codecSetStreamId }, 516 {0x000F0600, CODEC_VERB_8BIT_CMD , codecGetStreamId }, 517 {0x000F0700, CODEC_VERB_8BIT_CMD , stac9220GetPinCtrl}, 518 {0x00070700, CODEC_VERB_8BIT_CMD , stac9220SetPinCtrl}, 483 519 {0x000F0200, CODEC_VERB_8BIT_CMD , codecGetF02 }, 484 520 {0x000F2000, CODEC_VERB_8BIT_CMD , codecGetSubId }, … … 492 528 { 493 529 int rc = VINF_SUCCESS; 494 if ( CODEC_CAD(cmd) != 0 495 || CODEC_VERBDATA(cmd) == 0) 496 { 497 *pfn = CODEC_CAD(cmd) != 0 ? codecUnimplemented : codecBreak; 530 if ( CODEC_CAD(cmd) != pState->id 531 || CODEC_VERBDATA(cmd) == 0 532 || CODEC_NID(cmd) >= STAC9220_NODE_COUNT 533 || STAC9220_IS_RESERVED_CMD(cmd)) 534 { 535 *pfn = CODEC_CAD(cmd) != pState->id ? codecUnimplemented : codecBreak; 498 536 //** @todo r=michaln: There needs to be a counter to avoid log flooding (see e.g. DevRTC.cpp) 499 537 LogRel(("HDAcodec: cmd %x was ignored\n", cmd));
Note:
See TracChangeset
for help on using the changeset viewer.