aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci/hda
diff options
context:
space:
mode:
authorIan Minett <ian_minett@creativelabs.com>2012-09-20 23:29:20 -0400
committerTakashi Iwai <tiwai@suse.de>2012-11-28 02:47:23 -0500
commit4861af8075d91feb9df0e2f6539dad20debbeb67 (patch)
tree006c5c7f8fbdedb281210e88caee1ac0060d4ed7 /sound/pci/hda
parenta3af4807fa6766d0772396989cb6bcf93847bc53 (diff)
ALSA: hda - Update chipio functions and DSP write wait timeout
Tidy up and condense chipio_write_address|addx() functions. Improve dspio_write_wait() to use jiffies for timeout calc. Signed-off-by: Ian Minett <ian_minett@creativelabs.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/pci/hda')
-rw-r--r--sound/pci/hda/patch_ca0132.c52
1 files changed, 16 insertions, 36 deletions
diff --git a/sound/pci/hda/patch_ca0132.c b/sound/pci/hda/patch_ca0132.c
index a7b216ea9df3..7a0425ff8b7b 100644
--- a/sound/pci/hda/patch_ca0132.c
+++ b/sound/pci/hda/patch_ca0132.c
@@ -460,8 +460,12 @@ static int chipio_send(struct hda_codec *codec,
460static int chipio_write_address(struct hda_codec *codec, 460static int chipio_write_address(struct hda_codec *codec,
461 unsigned int chip_addx) 461 unsigned int chip_addx)
462{ 462{
463 struct ca0132_spec *spec = codec->spec;
463 int res; 464 int res;
464 465
466 if (spec->curr_chip_addx == chip_addx)
467 return 0;
468
465 /* send low 16 bits of the address */ 469 /* send low 16 bits of the address */
466 res = chipio_send(codec, VENDOR_CHIPIO_ADDRESS_LOW, 470 res = chipio_send(codec, VENDOR_CHIPIO_ADDRESS_LOW,
467 chip_addx & 0xffff); 471 chip_addx & 0xffff);
@@ -472,37 +476,14 @@ static int chipio_write_address(struct hda_codec *codec,
472 chip_addx >> 16); 476 chip_addx >> 16);
473 } 477 }
474 478
475 return res; 479 spec->curr_chip_addx = (res < 0) ? ~0UL : chip_addx;
476}
477
478static int chipio_write_addx(struct hda_codec *codec, u32 chip_addx)
479{
480 struct ca0132_spec *spec = codec->spec;
481 int status;
482
483 if (spec->curr_chip_addx == chip_addx)
484 return 0;
485
486 /* send low 16 bits of the address */
487 status = chipio_send(codec, VENDOR_CHIPIO_ADDRESS_LOW,
488 chip_addx & 0xffff);
489
490 if (status < 0)
491 return status;
492
493 /* send high 16 bits of the address */
494 status = chipio_send(codec, VENDOR_CHIPIO_ADDRESS_HIGH,
495 chip_addx >> 16);
496
497 spec->curr_chip_addx = (status < 0) ? ~0UL : chip_addx;
498 480
499 return status; 481 return res;
500} 482}
501 483
502/* 484/*
503 * Write data through the vendor widget -- NOT protected by the Mutex! 485 * Write data through the vendor widget -- NOT protected by the Mutex!
504 */ 486 */
505
506static int chipio_write_data(struct hda_codec *codec, unsigned int data) 487static int chipio_write_data(struct hda_codec *codec, unsigned int data)
507{ 488{
508 int res; 489 int res;
@@ -604,7 +585,7 @@ static int chipio_write_multiple(struct hda_codec *codec,
604 int status; 585 int status;
605 586
606 mutex_lock(&spec->chipio_mutex); 587 mutex_lock(&spec->chipio_mutex);
607 status = chipio_write_addx(codec, chip_addx); 588 status = chipio_write_address(codec, chip_addx);
608 if (status < 0) 589 if (status < 0)
609 goto error; 590 goto error;
610 591
@@ -742,18 +723,17 @@ static int dspio_send(struct hda_codec *codec, unsigned int reg,
742 */ 723 */
743static void dspio_write_wait(struct hda_codec *codec) 724static void dspio_write_wait(struct hda_codec *codec)
744{ 725{
745 int cur_val, prv_val; 726 int status;
746 int retry = 50; 727 unsigned long timeout = jiffies + msecs_to_jiffies(1000);
747 728
748 cur_val = 0;
749 do { 729 do {
750 prv_val = cur_val; 730 status = snd_hda_codec_read(codec, WIDGET_DSP_CTRL, 0,
751 msleep(20); 731 VENDOR_DSPIO_STATUS, 0);
752 dspio_send(codec, VENDOR_DSPIO_SCP_POST_COUNT_QUERY, 1); 732 if ((status == VENDOR_STATUS_DSPIO_OK) ||
753 dspio_send(codec, VENDOR_DSPIO_STATUS, 0); 733 (status == VENDOR_STATUS_DSPIO_SCP_RESPONSE_QUEUE_EMPTY))
754 cur_val = snd_hda_codec_read(codec, WIDGET_DSP_CTRL, 0, 734 break;
755 VENDOR_DSPIO_SCP_READ_COUNT, 0); 735 msleep(1);
756 } while (cur_val && (cur_val == prv_val) && --retry); 736 } while (time_before(jiffies, timeout));
757} 737}
758 738
759/* 739/*