diff options
author | Lars-Peter Clausen <lars@metafoo.de> | 2014-11-10 16:41:53 -0500 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2014-11-18 10:38:03 -0500 |
commit | 358a8bb5628420529e4f0b77068155ca8fa8973b (patch) | |
tree | 864f2cc85356c306157d6ce65d24be1914bbb21e /sound/soc/codecs/wm9712.c | |
parent | bc2632140435cc84f9817f1c362479b23dbdfebc (diff) |
ASoC: ac97: Push snd_ac97 pointer to the driver level
Now that the ASoC core no longer needs a handle to the AC'97 device that is
associated with a CODEC we can remove it from the snd_soc_codec struct and
push it into the individual driver state structs like we do for other
communication buses. Doing so creates a clean separation between the AC'97
bus support and the ASoC core.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Acked-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound/soc/codecs/wm9712.c')
-rw-r--r-- | sound/soc/codecs/wm9712.c | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/sound/soc/codecs/wm9712.c b/sound/soc/codecs/wm9712.c index 9fa794baa5f8..52a211be5b47 100644 --- a/sound/soc/codecs/wm9712.c +++ b/sound/soc/codecs/wm9712.c | |||
@@ -24,6 +24,7 @@ | |||
24 | #include "wm9712.h" | 24 | #include "wm9712.h" |
25 | 25 | ||
26 | struct wm9712_priv { | 26 | struct wm9712_priv { |
27 | struct snd_ac97 *ac97; | ||
27 | unsigned int hp_mixer[2]; | 28 | unsigned int hp_mixer[2]; |
28 | struct mutex lock; | 29 | struct mutex lock; |
29 | }; | 30 | }; |
@@ -484,12 +485,13 @@ static const struct snd_soc_dapm_route wm9712_audio_map[] = { | |||
484 | static unsigned int ac97_read(struct snd_soc_codec *codec, | 485 | static unsigned int ac97_read(struct snd_soc_codec *codec, |
485 | unsigned int reg) | 486 | unsigned int reg) |
486 | { | 487 | { |
488 | struct wm9712_priv *wm9712 = snd_soc_codec_get_drvdata(codec); | ||
487 | u16 *cache = codec->reg_cache; | 489 | u16 *cache = codec->reg_cache; |
488 | 490 | ||
489 | if (reg == AC97_RESET || reg == AC97_GPIO_STATUS || | 491 | if (reg == AC97_RESET || reg == AC97_GPIO_STATUS || |
490 | reg == AC97_VENDOR_ID1 || reg == AC97_VENDOR_ID2 || | 492 | reg == AC97_VENDOR_ID1 || reg == AC97_VENDOR_ID2 || |
491 | reg == AC97_REC_GAIN) | 493 | reg == AC97_REC_GAIN) |
492 | return soc_ac97_ops->read(codec->ac97, reg); | 494 | return soc_ac97_ops->read(wm9712->ac97, reg); |
493 | else { | 495 | else { |
494 | reg = reg >> 1; | 496 | reg = reg >> 1; |
495 | 497 | ||
@@ -503,9 +505,10 @@ static unsigned int ac97_read(struct snd_soc_codec *codec, | |||
503 | static int ac97_write(struct snd_soc_codec *codec, unsigned int reg, | 505 | static int ac97_write(struct snd_soc_codec *codec, unsigned int reg, |
504 | unsigned int val) | 506 | unsigned int val) |
505 | { | 507 | { |
508 | struct wm9712_priv *wm9712 = snd_soc_codec_get_drvdata(codec); | ||
506 | u16 *cache = codec->reg_cache; | 509 | u16 *cache = codec->reg_cache; |
507 | 510 | ||
508 | soc_ac97_ops->write(codec->ac97, reg, val); | 511 | soc_ac97_ops->write(wm9712->ac97, reg, val); |
509 | reg = reg >> 1; | 512 | reg = reg >> 1; |
510 | if (reg < (ARRAY_SIZE(wm9712_reg))) | 513 | if (reg < (ARRAY_SIZE(wm9712_reg))) |
511 | cache[reg] = val; | 514 | cache[reg] = val; |
@@ -613,15 +616,17 @@ static int wm9712_set_bias_level(struct snd_soc_codec *codec, | |||
613 | 616 | ||
614 | static int wm9712_reset(struct snd_soc_codec *codec, int try_warm) | 617 | static int wm9712_reset(struct snd_soc_codec *codec, int try_warm) |
615 | { | 618 | { |
619 | struct wm9712_priv *wm9712 = snd_soc_codec_get_drvdata(codec); | ||
620 | |||
616 | if (try_warm && soc_ac97_ops->warm_reset) { | 621 | if (try_warm && soc_ac97_ops->warm_reset) { |
617 | soc_ac97_ops->warm_reset(codec->ac97); | 622 | soc_ac97_ops->warm_reset(wm9712->ac97); |
618 | if (ac97_read(codec, 0) == wm9712_reg[0]) | 623 | if (ac97_read(codec, 0) == wm9712_reg[0]) |
619 | return 1; | 624 | return 1; |
620 | } | 625 | } |
621 | 626 | ||
622 | soc_ac97_ops->reset(codec->ac97); | 627 | soc_ac97_ops->reset(wm9712->ac97); |
623 | if (soc_ac97_ops->warm_reset) | 628 | if (soc_ac97_ops->warm_reset) |
624 | soc_ac97_ops->warm_reset(codec->ac97); | 629 | soc_ac97_ops->warm_reset(wm9712->ac97); |
625 | if (ac97_read(codec, 0) != wm9712_reg[0]) | 630 | if (ac97_read(codec, 0) != wm9712_reg[0]) |
626 | goto err; | 631 | goto err; |
627 | return 0; | 632 | return 0; |
@@ -639,6 +644,7 @@ static int wm9712_soc_suspend(struct snd_soc_codec *codec) | |||
639 | 644 | ||
640 | static int wm9712_soc_resume(struct snd_soc_codec *codec) | 645 | static int wm9712_soc_resume(struct snd_soc_codec *codec) |
641 | { | 646 | { |
647 | struct wm9712_priv *wm9712 = snd_soc_codec_get_drvdata(codec); | ||
642 | int i, ret; | 648 | int i, ret; |
643 | u16 *cache = codec->reg_cache; | 649 | u16 *cache = codec->reg_cache; |
644 | 650 | ||
@@ -654,7 +660,7 @@ static int wm9712_soc_resume(struct snd_soc_codec *codec) | |||
654 | if (i == AC97_INT_PAGING || i == AC97_POWERDOWN || | 660 | if (i == AC97_INT_PAGING || i == AC97_POWERDOWN || |
655 | (i > 0x58 && i != 0x5c)) | 661 | (i > 0x58 && i != 0x5c)) |
656 | continue; | 662 | continue; |
657 | soc_ac97_ops->write(codec->ac97, i, cache[i>>1]); | 663 | soc_ac97_ops->write(wm9712->ac97, i, cache[i>>1]); |
658 | } | 664 | } |
659 | } | 665 | } |
660 | 666 | ||
@@ -663,11 +669,13 @@ static int wm9712_soc_resume(struct snd_soc_codec *codec) | |||
663 | 669 | ||
664 | static int wm9712_soc_probe(struct snd_soc_codec *codec) | 670 | static int wm9712_soc_probe(struct snd_soc_codec *codec) |
665 | { | 671 | { |
672 | struct wm9712_priv *wm9712 = snd_soc_codec_get_drvdata(codec); | ||
666 | int ret = 0; | 673 | int ret = 0; |
667 | 674 | ||
668 | ret = snd_soc_new_ac97_codec(codec); | 675 | wm9712->ac97 = snd_soc_new_ac97_codec(codec); |
669 | if (ret < 0) { | 676 | if (IS_ERR(wm9712->ac97)) { |
670 | dev_err(codec->dev, "Failed to register AC97 codec\n"); | 677 | ret = PTR_ERR(wm9712->ac97); |
678 | dev_err(codec->dev, "Failed to register AC97 codec: %d\n", ret); | ||
671 | return ret; | 679 | return ret; |
672 | } | 680 | } |
673 | 681 | ||
@@ -683,13 +691,15 @@ static int wm9712_soc_probe(struct snd_soc_codec *codec) | |||
683 | return 0; | 691 | return 0; |
684 | 692 | ||
685 | reset_err: | 693 | reset_err: |
686 | snd_soc_free_ac97_codec(codec); | 694 | snd_soc_free_ac97_codec(wm9712->ac97); |
687 | return ret; | 695 | return ret; |
688 | } | 696 | } |
689 | 697 | ||
690 | static int wm9712_soc_remove(struct snd_soc_codec *codec) | 698 | static int wm9712_soc_remove(struct snd_soc_codec *codec) |
691 | { | 699 | { |
692 | snd_soc_free_ac97_codec(codec); | 700 | struct wm9712_priv *wm9712 = snd_soc_codec_get_drvdata(codec); |
701 | |||
702 | snd_soc_free_ac97_codec(wm9712->ac97); | ||
693 | return 0; | 703 | return 0; |
694 | } | 704 | } |
695 | 705 | ||