Changeset d2d5329 in mainline for uspace/drv/audio/hdaudio/hdactl.c
- Timestamp:
- 2014-08-14T14:21:28Z (11 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 65b09c1
- Parents:
- 8d070710
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/audio/hdaudio/hdactl.c
r8d070710 rd2d5329 42 42 #include <stdint.h> 43 43 44 #include "codec.h" 44 45 #include "hdactl.h" 45 46 #include "regif.h" … … 49 50 ctrl_init_wait_max = 10, 50 51 codec_enum_wait_us = 512, 51 corb_wait_max = 10 52 corb_wait_max = 10, 53 rirb_wait_max = 100 52 54 }; 53 55 … … 231 233 232 234 /* Set RINTCNT - Qemu won't read from CORB if this is zero */ 233 hda_reg16_write(&hda->regs->rintcnt, 2);235 hda_reg16_write(&hda->regs->rintcnt, 128); 234 236 235 237 hda->ctl->rirb_rp = 0; … … 336 338 } 337 339 338 static void hda_rirb_read(hda_t *hda)340 static int hda_rirb_read(hda_t *hda, hda_rirb_entry_t *data, size_t count) 339 341 { 340 342 size_t wp; 341 343 hda_rirb_entry_t resp; 342 344 hda_rirb_entry_t *rirb; 345 int wcnt; 343 346 344 347 rirb = (hda_rirb_entry_t *)hda->ctl->rirb_virt; 345 348 346 wp = hda_get_rirbwp(hda); 347 ddf_msg(LVL_NOTE, "hda_rirb_read: wp=%d", wp); 348 while (hda->ctl->rirb_rp != wp) { 349 ++hda->ctl->rirb_rp; 350 resp = rirb[hda->ctl->rirb_rp]; 351 352 ddf_msg(LVL_NOTE, "RESPONSE resp=0x%x respex=0x%x", 353 resp.resp, resp.respex); 354 } 355 } 356 357 #include "spec/codec.h" 349 while (count > 0) { 350 wp = hda_get_rirbwp(hda); 351 ddf_msg(LVL_NOTE, "hda_rirb_read: wp=%d", wp); 352 while (count > 0 && hda->ctl->rirb_rp != wp) { 353 ++hda->ctl->rirb_rp; 354 resp = rirb[hda->ctl->rirb_rp]; 355 356 ddf_msg(LVL_NOTE, "RESPONSE resp=0x%x respex=0x%x", 357 resp.resp, resp.respex); 358 if ((resp.respex & BIT_V(uint32_t, respex_unsol)) == 0) { 359 /* Solicited response */ 360 *data++ = resp; 361 --count; 362 } 363 } 364 365 if (count > 0) { 366 wcnt = rirb_wait_max; 367 while (wcnt > 0 && hda_get_rirbwp(hda) == hda->ctl->rirb_rp) { 368 async_usleep(100); 369 --wcnt; 370 } 371 372 if (hda_get_rirbwp(hda) == hda->ctl->rirb_rp) 373 return ETIMEOUT; 374 } 375 } 376 377 return EOK; 378 } 379 358 380 hda_ctl_t *hda_ctl_init(hda_t *hda) 359 381 { … … 426 448 goto error; 427 449 428 uint32_t verb; 429 verb = (0 << 28) | (0 << 20) | ((hda_get_param) << 8) | (hda_sub_nc); 430 rc = hda_corb_write(hda, &verb, 1); 431 ddf_msg(LVL_NOTE, "hda_corb_write -> %d", rc); 432 rc = hda_corb_write(hda, &verb, 1); 433 ddf_msg(LVL_NOTE, "hda_corb_write -> %d", rc); 434 rc = hda_corb_write(hda, &verb, 1); 435 ddf_msg(LVL_NOTE, "hda_corb_write -> %d", rc); 436 rc = hda_corb_write(hda, &verb, 1); 437 ddf_msg(LVL_NOTE, "hda_corb_write -> %d", rc); 438 439 async_usleep(100*1000); 440 hda_rirb_read(hda); 450 hda->ctl->codec = hda_codec_init(hda, 0); 451 if (hda->ctl->codec == NULL) 452 goto error; 441 453 442 454 return ctl; … … 447 459 } 448 460 461 int hda_cmd(hda_t *hda, uint32_t verb, uint32_t *resp) 462 { 463 int rc; 464 hda_rirb_entry_t rentry; 465 466 rc = hda_corb_write(hda, &verb, 1); 467 if (rc != EOK) 468 return rc; 469 470 if (resp != NULL) { 471 rc = hda_rirb_read(hda, &rentry, 1); 472 if (rc != EOK) 473 return rc; 474 475 /* XXX Verify that response came from the correct codec */ 476 *resp = rentry.resp; 477 } 478 479 return EOK; 480 } 481 449 482 void hda_ctl_fini(hda_ctl_t *ctl) 450 483 {
Note:
See TracChangeset
for help on using the changeset viewer.