diff options
Diffstat (limited to 'sound/soc/codecs/wm8903.c')
-rw-r--r-- | sound/soc/codecs/wm8903.c | 43 |
1 files changed, 8 insertions, 35 deletions
diff --git a/sound/soc/codecs/wm8903.c b/sound/soc/codecs/wm8903.c index c038b3e04398..cc6b0ef98a34 100644 --- a/sound/soc/codecs/wm8903.c +++ b/sound/soc/codecs/wm8903.c | |||
@@ -26,6 +26,7 @@ | |||
26 | #include <linux/regmap.h> | 26 | #include <linux/regmap.h> |
27 | #include <linux/slab.h> | 27 | #include <linux/slab.h> |
28 | #include <linux/irq.h> | 28 | #include <linux/irq.h> |
29 | #include <linux/mutex.h> | ||
29 | #include <sound/core.h> | 30 | #include <sound/core.h> |
30 | #include <sound/jack.h> | 31 | #include <sound/jack.h> |
31 | #include <sound/pcm.h> | 32 | #include <sound/pcm.h> |
@@ -117,12 +118,12 @@ static const struct reg_default wm8903_reg_defaults[] = { | |||
117 | struct wm8903_priv { | 118 | struct wm8903_priv { |
118 | struct wm8903_platform_data *pdata; | 119 | struct wm8903_platform_data *pdata; |
119 | struct device *dev; | 120 | struct device *dev; |
120 | struct snd_soc_codec *codec; | ||
121 | struct regmap *regmap; | 121 | struct regmap *regmap; |
122 | 122 | ||
123 | int sysclk; | 123 | int sysclk; |
124 | int irq; | 124 | int irq; |
125 | 125 | ||
126 | struct mutex lock; | ||
126 | int fs; | 127 | int fs; |
127 | int deemph; | 128 | int deemph; |
128 | 129 | ||
@@ -457,7 +458,7 @@ static int wm8903_put_deemph(struct snd_kcontrol *kcontrol, | |||
457 | if (deemph > 1) | 458 | if (deemph > 1) |
458 | return -EINVAL; | 459 | return -EINVAL; |
459 | 460 | ||
460 | mutex_lock(&codec->mutex); | 461 | mutex_lock(&wm8903->lock); |
461 | if (wm8903->deemph != deemph) { | 462 | if (wm8903->deemph != deemph) { |
462 | wm8903->deemph = deemph; | 463 | wm8903->deemph = deemph; |
463 | 464 | ||
@@ -465,7 +466,7 @@ static int wm8903_put_deemph(struct snd_kcontrol *kcontrol, | |||
465 | 466 | ||
466 | ret = 1; | 467 | ret = 1; |
467 | } | 468 | } |
468 | mutex_unlock(&codec->mutex); | 469 | mutex_unlock(&wm8903->lock); |
469 | 470 | ||
470 | return ret; | 471 | return ret; |
471 | } | 472 | } |
@@ -1757,21 +1758,12 @@ static struct snd_soc_dai_driver wm8903_dai = { | |||
1757 | .symmetric_rates = 1, | 1758 | .symmetric_rates = 1, |
1758 | }; | 1759 | }; |
1759 | 1760 | ||
1760 | static int wm8903_suspend(struct snd_soc_codec *codec) | ||
1761 | { | ||
1762 | wm8903_set_bias_level(codec, SND_SOC_BIAS_OFF); | ||
1763 | |||
1764 | return 0; | ||
1765 | } | ||
1766 | |||
1767 | static int wm8903_resume(struct snd_soc_codec *codec) | 1761 | static int wm8903_resume(struct snd_soc_codec *codec) |
1768 | { | 1762 | { |
1769 | struct wm8903_priv *wm8903 = snd_soc_codec_get_drvdata(codec); | 1763 | struct wm8903_priv *wm8903 = snd_soc_codec_get_drvdata(codec); |
1770 | 1764 | ||
1771 | regcache_sync(wm8903->regmap); | 1765 | regcache_sync(wm8903->regmap); |
1772 | 1766 | ||
1773 | wm8903_set_bias_level(codec, SND_SOC_BIAS_STANDBY); | ||
1774 | |||
1775 | return 0; | 1767 | return 0; |
1776 | } | 1768 | } |
1777 | 1769 | ||
@@ -1889,33 +1881,12 @@ static void wm8903_free_gpio(struct wm8903_priv *wm8903) | |||
1889 | } | 1881 | } |
1890 | #endif | 1882 | #endif |
1891 | 1883 | ||
1892 | static int wm8903_probe(struct snd_soc_codec *codec) | ||
1893 | { | ||
1894 | struct wm8903_priv *wm8903 = snd_soc_codec_get_drvdata(codec); | ||
1895 | |||
1896 | wm8903->codec = codec; | ||
1897 | |||
1898 | /* power on device */ | ||
1899 | wm8903_set_bias_level(codec, SND_SOC_BIAS_STANDBY); | ||
1900 | |||
1901 | return 0; | ||
1902 | } | ||
1903 | |||
1904 | /* power down chip */ | ||
1905 | static int wm8903_remove(struct snd_soc_codec *codec) | ||
1906 | { | ||
1907 | wm8903_set_bias_level(codec, SND_SOC_BIAS_OFF); | ||
1908 | |||
1909 | return 0; | ||
1910 | } | ||
1911 | |||
1912 | static struct snd_soc_codec_driver soc_codec_dev_wm8903 = { | 1884 | static struct snd_soc_codec_driver soc_codec_dev_wm8903 = { |
1913 | .probe = wm8903_probe, | ||
1914 | .remove = wm8903_remove, | ||
1915 | .suspend = wm8903_suspend, | ||
1916 | .resume = wm8903_resume, | 1885 | .resume = wm8903_resume, |
1917 | .set_bias_level = wm8903_set_bias_level, | 1886 | .set_bias_level = wm8903_set_bias_level, |
1918 | .seq_notifier = wm8903_seq_notifier, | 1887 | .seq_notifier = wm8903_seq_notifier, |
1888 | .suspend_bias_off = true, | ||
1889 | |||
1919 | .controls = wm8903_snd_controls, | 1890 | .controls = wm8903_snd_controls, |
1920 | .num_controls = ARRAY_SIZE(wm8903_snd_controls), | 1891 | .num_controls = ARRAY_SIZE(wm8903_snd_controls), |
1921 | .dapm_widgets = wm8903_dapm_widgets, | 1892 | .dapm_widgets = wm8903_dapm_widgets, |
@@ -2023,6 +1994,8 @@ static int wm8903_i2c_probe(struct i2c_client *i2c, | |||
2023 | GFP_KERNEL); | 1994 | GFP_KERNEL); |
2024 | if (wm8903 == NULL) | 1995 | if (wm8903 == NULL) |
2025 | return -ENOMEM; | 1996 | return -ENOMEM; |
1997 | |||
1998 | mutex_init(&wm8903->lock); | ||
2026 | wm8903->dev = &i2c->dev; | 1999 | wm8903->dev = &i2c->dev; |
2027 | 2000 | ||
2028 | wm8903->regmap = devm_regmap_init_i2c(i2c, &wm8903_regmap); | 2001 | wm8903->regmap = devm_regmap_init_i2c(i2c, &wm8903_regmap); |