diff options
Diffstat (limited to 'sound/soc/codecs/wm8731.c')
-rw-r--r-- | sound/soc/codecs/wm8731.c | 37 |
1 files changed, 10 insertions, 27 deletions
diff --git a/sound/soc/codecs/wm8731.c b/sound/soc/codecs/wm8731.c index eebb3280bfad..b9211b42f6e9 100644 --- a/sound/soc/codecs/wm8731.c +++ b/sound/soc/codecs/wm8731.c | |||
@@ -24,6 +24,7 @@ | |||
24 | #include <linux/regulator/consumer.h> | 24 | #include <linux/regulator/consumer.h> |
25 | #include <linux/spi/spi.h> | 25 | #include <linux/spi/spi.h> |
26 | #include <linux/of_device.h> | 26 | #include <linux/of_device.h> |
27 | #include <linux/mutex.h> | ||
27 | #include <sound/core.h> | 28 | #include <sound/core.h> |
28 | #include <sound/pcm.h> | 29 | #include <sound/pcm.h> |
29 | #include <sound/pcm_params.h> | 30 | #include <sound/pcm_params.h> |
@@ -50,6 +51,8 @@ struct wm8731_priv { | |||
50 | int sysclk_type; | 51 | int sysclk_type; |
51 | int playback_fs; | 52 | int playback_fs; |
52 | bool deemph; | 53 | bool deemph; |
54 | |||
55 | struct mutex lock; | ||
53 | }; | 56 | }; |
54 | 57 | ||
55 | 58 | ||
@@ -138,7 +141,7 @@ static int wm8731_put_deemph(struct snd_kcontrol *kcontrol, | |||
138 | if (deemph > 1) | 141 | if (deemph > 1) |
139 | return -EINVAL; | 142 | return -EINVAL; |
140 | 143 | ||
141 | mutex_lock(&codec->mutex); | 144 | mutex_lock(&wm8731->lock); |
142 | if (wm8731->deemph != deemph) { | 145 | if (wm8731->deemph != deemph) { |
143 | wm8731->deemph = deemph; | 146 | wm8731->deemph = deemph; |
144 | 147 | ||
@@ -146,7 +149,7 @@ static int wm8731_put_deemph(struct snd_kcontrol *kcontrol, | |||
146 | 149 | ||
147 | ret = 1; | 150 | ret = 1; |
148 | } | 151 | } |
149 | mutex_unlock(&codec->mutex); | 152 | mutex_unlock(&wm8731->lock); |
150 | 153 | ||
151 | return ret; | 154 | return ret; |
152 | } | 155 | } |
@@ -559,25 +562,6 @@ static struct snd_soc_dai_driver wm8731_dai = { | |||
559 | .symmetric_rates = 1, | 562 | .symmetric_rates = 1, |
560 | }; | 563 | }; |
561 | 564 | ||
562 | #ifdef CONFIG_PM | ||
563 | static int wm8731_suspend(struct snd_soc_codec *codec) | ||
564 | { | ||
565 | wm8731_set_bias_level(codec, SND_SOC_BIAS_OFF); | ||
566 | |||
567 | return 0; | ||
568 | } | ||
569 | |||
570 | static int wm8731_resume(struct snd_soc_codec *codec) | ||
571 | { | ||
572 | wm8731_set_bias_level(codec, SND_SOC_BIAS_STANDBY); | ||
573 | |||
574 | return 0; | ||
575 | } | ||
576 | #else | ||
577 | #define wm8731_suspend NULL | ||
578 | #define wm8731_resume NULL | ||
579 | #endif | ||
580 | |||
581 | static int wm8731_probe(struct snd_soc_codec *codec) | 565 | static int wm8731_probe(struct snd_soc_codec *codec) |
582 | { | 566 | { |
583 | struct wm8731_priv *wm8731 = snd_soc_codec_get_drvdata(codec); | 567 | struct wm8731_priv *wm8731 = snd_soc_codec_get_drvdata(codec); |
@@ -633,8 +617,6 @@ static int wm8731_remove(struct snd_soc_codec *codec) | |||
633 | { | 617 | { |
634 | struct wm8731_priv *wm8731 = snd_soc_codec_get_drvdata(codec); | 618 | struct wm8731_priv *wm8731 = snd_soc_codec_get_drvdata(codec); |
635 | 619 | ||
636 | wm8731_set_bias_level(codec, SND_SOC_BIAS_OFF); | ||
637 | |||
638 | regulator_bulk_disable(ARRAY_SIZE(wm8731->supplies), wm8731->supplies); | 620 | regulator_bulk_disable(ARRAY_SIZE(wm8731->supplies), wm8731->supplies); |
639 | 621 | ||
640 | return 0; | 622 | return 0; |
@@ -643,9 +625,9 @@ static int wm8731_remove(struct snd_soc_codec *codec) | |||
643 | static struct snd_soc_codec_driver soc_codec_dev_wm8731 = { | 625 | static struct snd_soc_codec_driver soc_codec_dev_wm8731 = { |
644 | .probe = wm8731_probe, | 626 | .probe = wm8731_probe, |
645 | .remove = wm8731_remove, | 627 | .remove = wm8731_remove, |
646 | .suspend = wm8731_suspend, | ||
647 | .resume = wm8731_resume, | ||
648 | .set_bias_level = wm8731_set_bias_level, | 628 | .set_bias_level = wm8731_set_bias_level, |
629 | .suspend_bias_off = true, | ||
630 | |||
649 | .dapm_widgets = wm8731_dapm_widgets, | 631 | .dapm_widgets = wm8731_dapm_widgets, |
650 | .num_dapm_widgets = ARRAY_SIZE(wm8731_dapm_widgets), | 632 | .num_dapm_widgets = ARRAY_SIZE(wm8731_dapm_widgets), |
651 | .dapm_routes = wm8731_intercon, | 633 | .dapm_routes = wm8731_intercon, |
@@ -680,11 +662,12 @@ static int wm8731_spi_probe(struct spi_device *spi) | |||
680 | struct wm8731_priv *wm8731; | 662 | struct wm8731_priv *wm8731; |
681 | int ret; | 663 | int ret; |
682 | 664 | ||
683 | wm8731 = devm_kzalloc(&spi->dev, sizeof(struct wm8731_priv), | 665 | wm8731 = devm_kzalloc(&spi->dev, sizeof(*wm8731), GFP_KERNEL); |
684 | GFP_KERNEL); | ||
685 | if (wm8731 == NULL) | 666 | if (wm8731 == NULL) |
686 | return -ENOMEM; | 667 | return -ENOMEM; |
687 | 668 | ||
669 | mutex_init(&wm8731->lock); | ||
670 | |||
688 | wm8731->regmap = devm_regmap_init_spi(spi, &wm8731_regmap); | 671 | wm8731->regmap = devm_regmap_init_spi(spi, &wm8731_regmap); |
689 | if (IS_ERR(wm8731->regmap)) { | 672 | if (IS_ERR(wm8731->regmap)) { |
690 | ret = PTR_ERR(wm8731->regmap); | 673 | ret = PTR_ERR(wm8731->regmap); |