diff options
Diffstat (limited to 'sound/soc/codecs/wm9712.c')
-rw-r--r-- | sound/soc/codecs/wm9712.c | 53 |
1 files changed, 22 insertions, 31 deletions
diff --git a/sound/soc/codecs/wm9712.c b/sound/soc/codecs/wm9712.c index 76c1e2d33e7d..9fc8edd82225 100644 --- a/sound/soc/codecs/wm9712.c +++ b/sound/soc/codecs/wm9712.c | |||
@@ -9,9 +9,6 @@ | |||
9 | * under the terms of the GNU General Public License as published by the | 9 | * under the terms of the GNU General Public License as published by the |
10 | * Free Software Foundation; either version 2 of the License, or (at your | 10 | * Free Software Foundation; either version 2 of the License, or (at your |
11 | * option) any later version. | 11 | * option) any later version. |
12 | * | ||
13 | * Revision history | ||
14 | * 4th Feb 2006 Initial version. | ||
15 | */ | 12 | */ |
16 | 13 | ||
17 | #include <linux/init.h> | 14 | #include <linux/init.h> |
@@ -25,6 +22,7 @@ | |||
25 | #include <sound/initval.h> | 22 | #include <sound/initval.h> |
26 | #include <sound/soc.h> | 23 | #include <sound/soc.h> |
27 | #include <sound/soc-dapm.h> | 24 | #include <sound/soc-dapm.h> |
25 | #include "wm9712.h" | ||
28 | 26 | ||
29 | #define WM9712_VERSION "0.4" | 27 | #define WM9712_VERSION "0.4" |
30 | 28 | ||
@@ -351,7 +349,7 @@ SND_SOC_DAPM_INPUT("MIC1"), | |||
351 | SND_SOC_DAPM_INPUT("MIC2"), | 349 | SND_SOC_DAPM_INPUT("MIC2"), |
352 | }; | 350 | }; |
353 | 351 | ||
354 | static const char *audio_map[][3] = { | 352 | static const struct snd_soc_dapm_route audio_map[] = { |
355 | /* virtual mixer - mixes left & right channels for spk and mono */ | 353 | /* virtual mixer - mixes left & right channels for spk and mono */ |
356 | {"AC97 Mixer", NULL, "Left DAC"}, | 354 | {"AC97 Mixer", NULL, "Left DAC"}, |
357 | {"AC97 Mixer", NULL, "Right DAC"}, | 355 | {"AC97 Mixer", NULL, "Right DAC"}, |
@@ -446,21 +444,14 @@ static const char *audio_map[][3] = { | |||
446 | {"Speaker PGA", NULL, "Speaker Mux"}, | 444 | {"Speaker PGA", NULL, "Speaker Mux"}, |
447 | {"LOUT2", NULL, "Speaker PGA"}, | 445 | {"LOUT2", NULL, "Speaker PGA"}, |
448 | {"ROUT2", NULL, "Speaker PGA"}, | 446 | {"ROUT2", NULL, "Speaker PGA"}, |
449 | |||
450 | {NULL, NULL, NULL}, | ||
451 | }; | 447 | }; |
452 | 448 | ||
453 | static int wm9712_add_widgets(struct snd_soc_codec *codec) | 449 | static int wm9712_add_widgets(struct snd_soc_codec *codec) |
454 | { | 450 | { |
455 | int i; | 451 | snd_soc_dapm_new_controls(codec, wm9712_dapm_widgets, |
456 | 452 | ARRAY_SIZE(wm9712_dapm_widgets)); | |
457 | for (i = 0; i < ARRAY_SIZE(wm9712_dapm_widgets); i++) | ||
458 | snd_soc_dapm_new_control(codec, &wm9712_dapm_widgets[i]); | ||
459 | 453 | ||
460 | /* set up audio path connects */ | 454 | snd_soc_dapm_add_routes(codec, audio_map, ARRAY_SIZE(audio_map)); |
461 | for (i = 0; audio_map[i][0] != NULL; i++) | ||
462 | snd_soc_dapm_connect_input(codec, audio_map[i][0], | ||
463 | audio_map[i][1], audio_map[i][2]); | ||
464 | 455 | ||
465 | snd_soc_dapm_new_widgets(codec); | 456 | snd_soc_dapm_new_widgets(codec); |
466 | return 0; | 457 | return 0; |
@@ -541,7 +532,7 @@ static int ac97_aux_prepare(struct snd_pcm_substream *substream) | |||
541 | SNDRV_PCM_RATE_22050 | SNDRV_PCM_RATE_44100 |\ | 532 | SNDRV_PCM_RATE_22050 | SNDRV_PCM_RATE_44100 |\ |
542 | SNDRV_PCM_RATE_48000) | 533 | SNDRV_PCM_RATE_48000) |
543 | 534 | ||
544 | struct snd_soc_codec_dai wm9712_dai[] = { | 535 | struct snd_soc_dai wm9712_dai[] = { |
545 | { | 536 | { |
546 | .name = "AC97 HiFi", | 537 | .name = "AC97 HiFi", |
547 | .type = SND_SOC_DAI_AC97_BUS, | 538 | .type = SND_SOC_DAI_AC97_BUS, |
@@ -574,23 +565,23 @@ struct snd_soc_codec_dai wm9712_dai[] = { | |||
574 | }; | 565 | }; |
575 | EXPORT_SYMBOL_GPL(wm9712_dai); | 566 | EXPORT_SYMBOL_GPL(wm9712_dai); |
576 | 567 | ||
577 | static int wm9712_dapm_event(struct snd_soc_codec *codec, int event) | 568 | static int wm9712_set_bias_level(struct snd_soc_codec *codec, |
569 | enum snd_soc_bias_level level) | ||
578 | { | 570 | { |
579 | switch (event) { | 571 | switch (level) { |
580 | case SNDRV_CTL_POWER_D0: /* full On */ | 572 | case SND_SOC_BIAS_ON: |
581 | case SNDRV_CTL_POWER_D1: /* partial On */ | 573 | case SND_SOC_BIAS_PREPARE: |
582 | case SNDRV_CTL_POWER_D2: /* partial On */ | ||
583 | break; | 574 | break; |
584 | case SNDRV_CTL_POWER_D3hot: /* Off, with power */ | 575 | case SND_SOC_BIAS_STANDBY: |
585 | ac97_write(codec, AC97_POWERDOWN, 0x0000); | 576 | ac97_write(codec, AC97_POWERDOWN, 0x0000); |
586 | break; | 577 | break; |
587 | case SNDRV_CTL_POWER_D3cold: /* Off, without power */ | 578 | case SND_SOC_BIAS_OFF: |
588 | /* disable everything including AC link */ | 579 | /* disable everything including AC link */ |
589 | ac97_write(codec, AC97_EXTENDED_MSTATUS, 0xffff); | 580 | ac97_write(codec, AC97_EXTENDED_MSTATUS, 0xffff); |
590 | ac97_write(codec, AC97_POWERDOWN, 0xffff); | 581 | ac97_write(codec, AC97_POWERDOWN, 0xffff); |
591 | break; | 582 | break; |
592 | } | 583 | } |
593 | codec->dapm_state = event; | 584 | codec->bias_level = level; |
594 | return 0; | 585 | return 0; |
595 | } | 586 | } |
596 | 587 | ||
@@ -598,12 +589,12 @@ static int wm9712_reset(struct snd_soc_codec *codec, int try_warm) | |||
598 | { | 589 | { |
599 | if (try_warm && soc_ac97_ops.warm_reset) { | 590 | if (try_warm && soc_ac97_ops.warm_reset) { |
600 | soc_ac97_ops.warm_reset(codec->ac97); | 591 | soc_ac97_ops.warm_reset(codec->ac97); |
601 | if (!(ac97_read(codec, 0) & 0x8000)) | 592 | if (ac97_read(codec, 0) == wm9712_reg[0]) |
602 | return 1; | 593 | return 1; |
603 | } | 594 | } |
604 | 595 | ||
605 | soc_ac97_ops.reset(codec->ac97); | 596 | soc_ac97_ops.reset(codec->ac97); |
606 | if (ac97_read(codec, 0) & 0x8000) | 597 | if (ac97_read(codec, 0) != wm9712_reg[0]) |
607 | goto err; | 598 | goto err; |
608 | return 0; | 599 | return 0; |
609 | 600 | ||
@@ -618,7 +609,7 @@ static int wm9712_soc_suspend(struct platform_device *pdev, | |||
618 | struct snd_soc_device *socdev = platform_get_drvdata(pdev); | 609 | struct snd_soc_device *socdev = platform_get_drvdata(pdev); |
619 | struct snd_soc_codec *codec = socdev->codec; | 610 | struct snd_soc_codec *codec = socdev->codec; |
620 | 611 | ||
621 | wm9712_dapm_event(codec, SNDRV_CTL_POWER_D3cold); | 612 | wm9712_set_bias_level(codec, SND_SOC_BIAS_OFF); |
622 | return 0; | 613 | return 0; |
623 | } | 614 | } |
624 | 615 | ||
@@ -635,7 +626,7 @@ static int wm9712_soc_resume(struct platform_device *pdev) | |||
635 | return ret; | 626 | return ret; |
636 | } | 627 | } |
637 | 628 | ||
638 | wm9712_dapm_event(codec, SNDRV_CTL_POWER_D3hot); | 629 | wm9712_set_bias_level(codec, SND_SOC_BIAS_STANDBY); |
639 | 630 | ||
640 | if (ret == 0) { | 631 | if (ret == 0) { |
641 | /* Sync reg_cache with the hardware after cold reset */ | 632 | /* Sync reg_cache with the hardware after cold reset */ |
@@ -647,8 +638,8 @@ static int wm9712_soc_resume(struct platform_device *pdev) | |||
647 | } | 638 | } |
648 | } | 639 | } |
649 | 640 | ||
650 | if (codec->suspend_dapm_state == SNDRV_CTL_POWER_D0) | 641 | if (codec->suspend_bias_level == SND_SOC_BIAS_ON) |
651 | wm9712_dapm_event(codec, SNDRV_CTL_POWER_D0); | 642 | wm9712_set_bias_level(codec, SND_SOC_BIAS_ON); |
652 | 643 | ||
653 | return ret; | 644 | return ret; |
654 | } | 645 | } |
@@ -682,7 +673,7 @@ static int wm9712_soc_probe(struct platform_device *pdev) | |||
682 | codec->num_dai = ARRAY_SIZE(wm9712_dai); | 673 | codec->num_dai = ARRAY_SIZE(wm9712_dai); |
683 | codec->write = ac97_write; | 674 | codec->write = ac97_write; |
684 | codec->read = ac97_read; | 675 | codec->read = ac97_read; |
685 | codec->dapm_event = wm9712_dapm_event; | 676 | codec->set_bias_level = wm9712_set_bias_level; |
686 | INIT_LIST_HEAD(&codec->dapm_widgets); | 677 | INIT_LIST_HEAD(&codec->dapm_widgets); |
687 | INIT_LIST_HEAD(&codec->dapm_paths); | 678 | INIT_LIST_HEAD(&codec->dapm_paths); |
688 | 679 | ||
@@ -706,7 +697,7 @@ static int wm9712_soc_probe(struct platform_device *pdev) | |||
706 | /* set alc mux to none */ | 697 | /* set alc mux to none */ |
707 | ac97_write(codec, AC97_VIDEO, ac97_read(codec, AC97_VIDEO) | 0x3000); | 698 | ac97_write(codec, AC97_VIDEO, ac97_read(codec, AC97_VIDEO) | 0x3000); |
708 | 699 | ||
709 | wm9712_dapm_event(codec, SNDRV_CTL_POWER_D3hot); | 700 | wm9712_set_bias_level(codec, SND_SOC_BIAS_STANDBY); |
710 | wm9712_add_controls(codec); | 701 | wm9712_add_controls(codec); |
711 | wm9712_add_widgets(codec); | 702 | wm9712_add_widgets(codec); |
712 | ret = snd_soc_register_card(socdev); | 703 | ret = snd_soc_register_card(socdev); |