aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/codecs/wm8962.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/soc/codecs/wm8962.c')
-rw-r--r--sound/soc/codecs/wm8962.c50
1 files changed, 25 insertions, 25 deletions
diff --git a/sound/soc/codecs/wm8962.c b/sound/soc/codecs/wm8962.c
index f0c9d269184..b9cb1fcf8c9 100644
--- a/sound/soc/codecs/wm8962.c
+++ b/sound/soc/codecs/wm8962.c
@@ -32,6 +32,7 @@
32#include <sound/initval.h> 32#include <sound/initval.h>
33#include <sound/tlv.h> 33#include <sound/tlv.h>
34#include <sound/wm8962.h> 34#include <sound/wm8962.h>
35#include <trace/events/asoc.h>
35 36
36#include "wm8962.h" 37#include "wm8962.h"
37 38
@@ -51,8 +52,6 @@ static const char *wm8962_supply_names[WM8962_NUM_SUPPLIES] = {
51struct wm8962_priv { 52struct wm8962_priv {
52 struct snd_soc_codec *codec; 53 struct snd_soc_codec *codec;
53 54
54 u16 reg_cache[WM8962_MAX_REGISTER + 1];
55
56 int sysclk; 55 int sysclk;
57 int sysclk_rate; 56 int sysclk_rate;
58 57
@@ -1990,8 +1989,7 @@ static int wm8962_put_hp_sw(struct snd_kcontrol *kcontrol,
1990 struct snd_ctl_elem_value *ucontrol) 1989 struct snd_ctl_elem_value *ucontrol)
1991{ 1990{
1992 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); 1991 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
1993 struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec); 1992 u16 *reg_cache = codec->reg_cache;
1994 u16 *reg_cache = wm8962->reg_cache;
1995 int ret; 1993 int ret;
1996 1994
1997 /* Apply the update (if any) */ 1995 /* Apply the update (if any) */
@@ -2019,8 +2017,7 @@ static int wm8962_put_spk_sw(struct snd_kcontrol *kcontrol,
2019 struct snd_ctl_elem_value *ucontrol) 2017 struct snd_ctl_elem_value *ucontrol)
2020{ 2018{
2021 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); 2019 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
2022 struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec); 2020 u16 *reg_cache = codec->reg_cache;
2023 u16 *reg_cache = wm8962->reg_cache;
2024 int ret; 2021 int ret;
2025 2022
2026 /* Apply the update (if any) */ 2023 /* Apply the update (if any) */
@@ -2328,8 +2325,7 @@ static int out_pga_event(struct snd_soc_dapm_widget *w,
2328 struct snd_kcontrol *kcontrol, int event) 2325 struct snd_kcontrol *kcontrol, int event)
2329{ 2326{
2330 struct snd_soc_codec *codec = w->codec; 2327 struct snd_soc_codec *codec = w->codec;
2331 struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec); 2328 u16 *reg_cache = codec->reg_cache;
2332 u16 *reg_cache = wm8962->reg_cache;
2333 int reg; 2329 int reg;
2334 2330
2335 switch (w->shift) { 2331 switch (w->shift) {
@@ -2719,7 +2715,7 @@ static int wm8962_add_widgets(struct snd_soc_codec *codec)
2719 2715
2720static void wm8962_sync_cache(struct snd_soc_codec *codec) 2716static void wm8962_sync_cache(struct snd_soc_codec *codec)
2721{ 2717{
2722 struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec); 2718 u16 *reg_cache = codec->reg_cache;
2723 int i; 2719 int i;
2724 2720
2725 if (!codec->cache_sync) 2721 if (!codec->cache_sync)
@@ -2732,13 +2728,13 @@ static void wm8962_sync_cache(struct snd_soc_codec *codec)
2732 /* Sync back cached values if they're different from the 2728 /* Sync back cached values if they're different from the
2733 * hardware default. 2729 * hardware default.
2734 */ 2730 */
2735 for (i = 1; i < ARRAY_SIZE(wm8962->reg_cache); i++) { 2731 for (i = 1; i < codec->driver->reg_cache_size; i++) {
2736 if (i == WM8962_SOFTWARE_RESET) 2732 if (i == WM8962_SOFTWARE_RESET)
2737 continue; 2733 continue;
2738 if (wm8962->reg_cache[i] == wm8962_reg[i]) 2734 if (reg_cache[i] == wm8962_reg[i])
2739 continue; 2735 continue;
2740 2736
2741 snd_soc_write(codec, i, wm8962->reg_cache[i]); 2737 snd_soc_write(codec, i, reg_cache[i]);
2742 } 2738 }
2743 2739
2744 codec->cache_sync = 0; 2740 codec->cache_sync = 0;
@@ -3353,6 +3349,10 @@ static irqreturn_t wm8962_irq(int irq, void *data)
3353 if (active & (WM8962_MICSCD_EINT | WM8962_MICD_EINT)) { 3349 if (active & (WM8962_MICSCD_EINT | WM8962_MICD_EINT)) {
3354 dev_dbg(codec->dev, "Microphone event detected\n"); 3350 dev_dbg(codec->dev, "Microphone event detected\n");
3355 3351
3352#ifndef CONFIG_SND_SOC_WM8962_MODULE
3353 trace_snd_soc_jack_irq(dev_name(codec->dev));
3354#endif
3355
3356 pm_wakeup_event(codec->dev, 300); 3356 pm_wakeup_event(codec->dev, 300);
3357 3357
3358 schedule_delayed_work(&wm8962->mic_work, 3358 schedule_delayed_work(&wm8962->mic_work,
@@ -3408,12 +3408,11 @@ EXPORT_SYMBOL_GPL(wm8962_mic_detect);
3408#ifdef CONFIG_PM 3408#ifdef CONFIG_PM
3409static int wm8962_resume(struct snd_soc_codec *codec) 3409static int wm8962_resume(struct snd_soc_codec *codec)
3410{ 3410{
3411 struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec);
3412 u16 *reg_cache = codec->reg_cache; 3411 u16 *reg_cache = codec->reg_cache;
3413 int i; 3412 int i;
3414 3413
3415 /* Restore the registers */ 3414 /* Restore the registers */
3416 for (i = 1; i < ARRAY_SIZE(wm8962->reg_cache); i++) { 3415 for (i = 1; i < codec->driver->reg_cache_size; i++) {
3417 switch (i) { 3416 switch (i) {
3418 case WM8962_SOFTWARE_RESET: 3417 case WM8962_SOFTWARE_RESET:
3419 continue; 3418 continue;
@@ -3708,6 +3707,7 @@ static int wm8962_probe(struct snd_soc_codec *codec)
3708 struct wm8962_pdata *pdata = dev_get_platdata(codec->dev); 3707 struct wm8962_pdata *pdata = dev_get_platdata(codec->dev);
3709 struct i2c_client *i2c = container_of(codec->dev, struct i2c_client, 3708 struct i2c_client *i2c = container_of(codec->dev, struct i2c_client,
3710 dev); 3709 dev);
3710 u16 *reg_cache = codec->reg_cache;
3711 int i, trigger, irq_pol; 3711 int i, trigger, irq_pol;
3712 3712
3713 wm8962->codec = codec; 3713 wm8962->codec = codec;
@@ -3807,7 +3807,7 @@ static int wm8962_probe(struct snd_soc_codec *codec)
3807 3807
3808 /* Put the speakers into mono mode? */ 3808 /* Put the speakers into mono mode? */
3809 if (pdata->spk_mono) 3809 if (pdata->spk_mono)
3810 wm8962->reg_cache[WM8962_CLASS_D_CONTROL_2] 3810 reg_cache[WM8962_CLASS_D_CONTROL_2]
3811 |= WM8962_SPK_MONO; 3811 |= WM8962_SPK_MONO;
3812 3812
3813 /* Micbias setup, detection enable and detection 3813 /* Micbias setup, detection enable and detection
@@ -3822,16 +3822,16 @@ static int wm8962_probe(struct snd_soc_codec *codec)
3822 } 3822 }
3823 3823
3824 /* Latch volume update bits */ 3824 /* Latch volume update bits */
3825 wm8962->reg_cache[WM8962_LEFT_INPUT_VOLUME] |= WM8962_IN_VU; 3825 reg_cache[WM8962_LEFT_INPUT_VOLUME] |= WM8962_IN_VU;
3826 wm8962->reg_cache[WM8962_RIGHT_INPUT_VOLUME] |= WM8962_IN_VU; 3826 reg_cache[WM8962_RIGHT_INPUT_VOLUME] |= WM8962_IN_VU;
3827 wm8962->reg_cache[WM8962_LEFT_ADC_VOLUME] |= WM8962_ADC_VU; 3827 reg_cache[WM8962_LEFT_ADC_VOLUME] |= WM8962_ADC_VU;
3828 wm8962->reg_cache[WM8962_RIGHT_ADC_VOLUME] |= WM8962_ADC_VU; 3828 reg_cache[WM8962_RIGHT_ADC_VOLUME] |= WM8962_ADC_VU;
3829 wm8962->reg_cache[WM8962_LEFT_DAC_VOLUME] |= WM8962_DAC_VU; 3829 reg_cache[WM8962_LEFT_DAC_VOLUME] |= WM8962_DAC_VU;
3830 wm8962->reg_cache[WM8962_RIGHT_DAC_VOLUME] |= WM8962_DAC_VU; 3830 reg_cache[WM8962_RIGHT_DAC_VOLUME] |= WM8962_DAC_VU;
3831 wm8962->reg_cache[WM8962_SPKOUTL_VOLUME] |= WM8962_SPKOUT_VU; 3831 reg_cache[WM8962_SPKOUTL_VOLUME] |= WM8962_SPKOUT_VU;
3832 wm8962->reg_cache[WM8962_SPKOUTR_VOLUME] |= WM8962_SPKOUT_VU; 3832 reg_cache[WM8962_SPKOUTR_VOLUME] |= WM8962_SPKOUT_VU;
3833 wm8962->reg_cache[WM8962_HPOUTL_VOLUME] |= WM8962_HPOUT_VU; 3833 reg_cache[WM8962_HPOUTL_VOLUME] |= WM8962_HPOUT_VU;
3834 wm8962->reg_cache[WM8962_HPOUTR_VOLUME] |= WM8962_HPOUT_VU; 3834 reg_cache[WM8962_HPOUTR_VOLUME] |= WM8962_HPOUT_VU;
3835 3835
3836 wm8962_add_widgets(codec); 3836 wm8962_add_widgets(codec);
3837 3837