Changeset c67195c in mainline
- Timestamp:
- 2014-08-26T13:03:28Z (10 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 1e92bc3
- Parents:
- 6747b929
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/audio/hdaudio/hdactl.c
r6747b929 rc67195c 55 55 }; 56 56 57 /** Perform set-reset handshake on a 16-bit register. 58 * 59 * The bit(s) specified in the mask are written as 1, then we wait 60 * for them to read as 1. Then we write them as 0 and we wait for them 61 * to read as 0. 62 */ 63 static int hda_ctl_reg16_set_reset(uint16_t *reg, uint16_t mask) 64 { 65 uint16_t val; 66 int wcnt; 67 68 val = hda_reg16_read(reg); 69 hda_reg16_write(reg, val | mask); 70 71 wcnt = 1000; 72 while (wcnt > 0) { 73 val = hda_reg16_read(reg); 74 if ((val & mask) == mask) 75 break; 76 77 async_usleep(1000); 78 --wcnt; 79 } 80 81 if ((val & mask) != mask) 82 return ETIMEOUT; 83 84 val = hda_reg16_read(reg); 85 hda_reg16_write(reg, val & ~mask); 86 87 wcnt = 1000; 88 while (wcnt > 0) { 89 val = hda_reg16_read(reg); 90 if ((val & mask) == 0) 91 break; 92 93 async_usleep(1000); 94 --wcnt; 95 } 96 97 if ((val & mask) != 0) 98 return ETIMEOUT; 99 100 return EOK; 101 } 102 57 103 /** Select an appropriate CORB/RIRB size. 58 104 * … … 150 196 151 197 /* Reset CORB Read Pointer */ 152 hda_reg16_write(&hda->regs->corbrp, BIT_V(uint16_t, corbrp_rst)); 153 154 /* Reset CORB Write Poitner */ 198 rc = hda_ctl_reg16_set_reset(&hda->regs->corbrp, 199 BIT_V(uint16_t, corbrp_rst)); 200 if (rc != EOK) { 201 ddf_msg(LVL_NOTE, "Failed resetting CORBRP"); 202 goto error; 203 } 204 205 /* Reset CORB Write Pointer */ 155 206 hda_reg16_write(&hda->regs->corbwp, 0); 156 207 … … 356 407 int wcnt; 357 408 358 wcnt = 10*1000; 359 409 ddf_msg(LVL_NOTE, "hda_solrb_read()"); 410 wcnt = 100; 411 412 ddf_msg(LVL_NOTE, "hda_solrb_read() - lock mutex"); 360 413 fibril_mutex_lock(&hda->ctl->solrb_lock); 361 414 362 415 while (count > 0) { 416 ddf_msg(LVL_NOTE, "hda_solrb_read() - while(1)"); 363 417 while (count > 0 && hda->ctl->solrb_rp != hda->ctl->solrb_wp) { 418 ddf_msg(LVL_NOTE, "hda_solrb_read() - while(2)"); 364 419 ++hda->ctl->solrb_rp; 365 420 resp = hda->ctl->solrb[hda->ctl->solrb_rp]; 366 421 367 ddf_msg(LVL_ DEBUG2, "solrb RESPONSE resp=0x%x respex=0x%x",422 ddf_msg(LVL_NOTE, "solrb RESPONSE resp=0x%x respex=0x%x", 368 423 resp.resp, resp.respex); 369 424 if ((resp.respex & BIT_V(uint32_t, respex_unsol)) == 0) { … … 375 430 376 431 if (count > 0) { 432 ddf_msg(LVL_NOTE, "hda_solrb_read() - count > 0"); 377 433 while (wcnt > 0 && hda->ctl->solrb_wp == hda->ctl->solrb_rp) { 434 ddf_msg(LVL_NOTE, "hda_solrb_read() - while(3), wcnt=%d", wcnt); 378 435 fibril_mutex_unlock(&hda->ctl->solrb_lock); 379 async_usleep(100); 436 ddf_msg(LVL_NOTE, "hda_solrb_read() - sleep"); 437 async_usleep(10000); 438 ddf_msg(LVL_NOTE, "hda_solrb_read() - re-lock"); 380 439 fibril_mutex_lock(&hda->ctl->solrb_lock); 381 440 --wcnt; … … 384 443 if (hda->ctl->solrb_wp == hda->ctl->solrb_rp) { 385 444 ddf_msg(LVL_NOTE, "hda_solrb_read() time out"); 445 ddf_msg(LVL_NOTE, "corbwp=%d corbrp=%d", 446 hda_reg16_read(&hda->regs->corbwp), 447 hda_reg16_read(&hda->regs->corbrp)); 448 ddf_msg(LVL_NOTE, "corbctl=0x%x, corbsts=0x%x", 449 hda_reg8_read(&hda->regs->corbctl), 450 hda_reg8_read(&hda->regs->corbsts)); 451 ddf_msg(LVL_NOTE, "rirbwp=%d", 452 hda_reg16_read(&hda->regs->rirbwp)); 453 ddf_msg(LVL_NOTE, "rirbctl=0x%x, rirbsts=0x%x", 454 hda_reg8_read(&hda->regs->rirbctl), 455 hda_reg8_read(&hda->regs->rirbsts)); 386 456 fibril_mutex_unlock(&hda->ctl->solrb_lock); 387 457 return ETIMEOUT; … … 391 461 392 462 fibril_mutex_unlock(&hda->ctl->solrb_lock); 463 ddf_msg(LVL_NOTE, "hda_solrb_read() success"); 393 464 return EOK; 394 465 }
Note:
See TracChangeset
for help on using the changeset viewer.