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.c52
1 files changed, 25 insertions, 27 deletions
diff --git a/sound/soc/codecs/wm8962.c b/sound/soc/codecs/wm8962.c
index 894d0cd3aa9b..7c421cc837bd 100644
--- a/sound/soc/codecs/wm8962.c
+++ b/sound/soc/codecs/wm8962.c
@@ -52,8 +52,6 @@ static const char *wm8962_supply_names[WM8962_NUM_SUPPLIES] = {
52struct wm8962_priv { 52struct wm8962_priv {
53 struct snd_soc_codec *codec; 53 struct snd_soc_codec *codec;
54 54
55 u16 reg_cache[WM8962_MAX_REGISTER + 1];
56
57 int sysclk; 55 int sysclk;
58 int sysclk_rate; 56 int sysclk_rate;
59 57
@@ -1991,8 +1989,7 @@ static int wm8962_put_hp_sw(struct snd_kcontrol *kcontrol,
1991 struct snd_ctl_elem_value *ucontrol) 1989 struct snd_ctl_elem_value *ucontrol)
1992{ 1990{
1993 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); 1991 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
1994 struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec); 1992 u16 *reg_cache = codec->reg_cache;
1995 u16 *reg_cache = wm8962->reg_cache;
1996 int ret; 1993 int ret;
1997 1994
1998 /* Apply the update (if any) */ 1995 /* Apply the update (if any) */
@@ -2020,8 +2017,7 @@ static int wm8962_put_spk_sw(struct snd_kcontrol *kcontrol,
2020 struct snd_ctl_elem_value *ucontrol) 2017 struct snd_ctl_elem_value *ucontrol)
2021{ 2018{
2022 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); 2019 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
2023 struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec); 2020 u16 *reg_cache = codec->reg_cache;
2024 u16 *reg_cache = wm8962->reg_cache;
2025 int ret; 2021 int ret;
2026 2022
2027 /* Apply the update (if any) */ 2023 /* Apply the update (if any) */
@@ -2329,8 +2325,7 @@ static int out_pga_event(struct snd_soc_dapm_widget *w,
2329 struct snd_kcontrol *kcontrol, int event) 2325 struct snd_kcontrol *kcontrol, int event)
2330{ 2326{
2331 struct snd_soc_codec *codec = w->codec; 2327 struct snd_soc_codec *codec = w->codec;
2332 struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec); 2328 u16 *reg_cache = codec->reg_cache;
2333 u16 *reg_cache = wm8962->reg_cache;
2334 int reg; 2329 int reg;
2335 2330
2336 switch (w->shift) { 2331 switch (w->shift) {
@@ -2719,7 +2714,7 @@ static int wm8962_add_widgets(struct snd_soc_codec *codec)
2719 2714
2720static void wm8962_sync_cache(struct snd_soc_codec *codec) 2715static void wm8962_sync_cache(struct snd_soc_codec *codec)
2721{ 2716{
2722 struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec); 2717 u16 *reg_cache = codec->reg_cache;
2723 int i; 2718 int i;
2724 2719
2725 if (!codec->cache_sync) 2720 if (!codec->cache_sync)
@@ -2732,13 +2727,13 @@ static void wm8962_sync_cache(struct snd_soc_codec *codec)
2732 /* Sync back cached values if they're different from the 2727 /* Sync back cached values if they're different from the
2733 * hardware default. 2728 * hardware default.
2734 */ 2729 */
2735 for (i = 1; i < ARRAY_SIZE(wm8962->reg_cache); i++) { 2730 for (i = 1; i < codec->driver->reg_cache_size; i++) {
2736 if (i == WM8962_SOFTWARE_RESET) 2731 if (i == WM8962_SOFTWARE_RESET)
2737 continue; 2732 continue;
2738 if (wm8962->reg_cache[i] == wm8962_reg[i]) 2733 if (reg_cache[i] == wm8962_reg[i])
2739 continue; 2734 continue;
2740 2735
2741 snd_soc_write(codec, i, wm8962->reg_cache[i]); 2736 snd_soc_write(codec, i, reg_cache[i]);
2742 } 2737 }
2743 2738
2744 codec->cache_sync = 0; 2739 codec->cache_sync = 0;
@@ -3339,7 +3334,7 @@ static irqreturn_t wm8962_irq(int irq, void *data)
3339 int mask; 3334 int mask;
3340 int active; 3335 int active;
3341 3336
3342 mask = snd_soc_read(codec, WM8962_INTERRUPT_STATUS_2); 3337 mask = snd_soc_read(codec, WM8962_INTERRUPT_STATUS_2_MASK);
3343 3338
3344 active = snd_soc_read(codec, WM8962_INTERRUPT_STATUS_2); 3339 active = snd_soc_read(codec, WM8962_INTERRUPT_STATUS_2);
3345 active &= ~mask; 3340 active &= ~mask;
@@ -3406,12 +3401,11 @@ EXPORT_SYMBOL_GPL(wm8962_mic_detect);
3406#ifdef CONFIG_PM 3401#ifdef CONFIG_PM
3407static int wm8962_resume(struct snd_soc_codec *codec) 3402static int wm8962_resume(struct snd_soc_codec *codec)
3408{ 3403{
3409 struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec);
3410 u16 *reg_cache = codec->reg_cache; 3404 u16 *reg_cache = codec->reg_cache;
3411 int i; 3405 int i;
3412 3406
3413 /* Restore the registers */ 3407 /* Restore the registers */
3414 for (i = 1; i < ARRAY_SIZE(wm8962->reg_cache); i++) { 3408 for (i = 1; i < codec->driver->reg_cache_size; i++) {
3415 switch (i) { 3409 switch (i) {
3416 case WM8962_SOFTWARE_RESET: 3410 case WM8962_SOFTWARE_RESET:
3417 continue; 3411 continue;
@@ -3500,8 +3494,11 @@ static ssize_t wm8962_beep_set(struct device *dev,
3500{ 3494{
3501 struct wm8962_priv *wm8962 = dev_get_drvdata(dev); 3495 struct wm8962_priv *wm8962 = dev_get_drvdata(dev);
3502 long int time; 3496 long int time;
3497 int ret;
3503 3498
3504 strict_strtol(buf, 10, &time); 3499 ret = strict_strtol(buf, 10, &time);
3500 if (ret != 0)
3501 return ret;
3505 3502
3506 input_event(wm8962->beep, EV_SND, SND_TONE, time); 3503 input_event(wm8962->beep, EV_SND, SND_TONE, time);
3507 3504
@@ -3702,6 +3699,7 @@ static int wm8962_probe(struct snd_soc_codec *codec)
3702 struct wm8962_pdata *pdata = dev_get_platdata(codec->dev); 3699 struct wm8962_pdata *pdata = dev_get_platdata(codec->dev);
3703 struct i2c_client *i2c = container_of(codec->dev, struct i2c_client, 3700 struct i2c_client *i2c = container_of(codec->dev, struct i2c_client,
3704 dev); 3701 dev);
3702 u16 *reg_cache = codec->reg_cache;
3705 int i, trigger, irq_pol; 3703 int i, trigger, irq_pol;
3706 3704
3707 wm8962->codec = codec; 3705 wm8962->codec = codec;
@@ -3801,7 +3799,7 @@ static int wm8962_probe(struct snd_soc_codec *codec)
3801 3799
3802 /* Put the speakers into mono mode? */ 3800 /* Put the speakers into mono mode? */
3803 if (pdata->spk_mono) 3801 if (pdata->spk_mono)
3804 wm8962->reg_cache[WM8962_CLASS_D_CONTROL_2] 3802 reg_cache[WM8962_CLASS_D_CONTROL_2]
3805 |= WM8962_SPK_MONO; 3803 |= WM8962_SPK_MONO;
3806 3804
3807 /* Micbias setup, detection enable and detection 3805 /* Micbias setup, detection enable and detection
@@ -3816,16 +3814,16 @@ static int wm8962_probe(struct snd_soc_codec *codec)
3816 } 3814 }
3817 3815
3818 /* Latch volume update bits */ 3816 /* Latch volume update bits */
3819 wm8962->reg_cache[WM8962_LEFT_INPUT_VOLUME] |= WM8962_IN_VU; 3817 reg_cache[WM8962_LEFT_INPUT_VOLUME] |= WM8962_IN_VU;
3820 wm8962->reg_cache[WM8962_RIGHT_INPUT_VOLUME] |= WM8962_IN_VU; 3818 reg_cache[WM8962_RIGHT_INPUT_VOLUME] |= WM8962_IN_VU;
3821 wm8962->reg_cache[WM8962_LEFT_ADC_VOLUME] |= WM8962_ADC_VU; 3819 reg_cache[WM8962_LEFT_ADC_VOLUME] |= WM8962_ADC_VU;
3822 wm8962->reg_cache[WM8962_RIGHT_ADC_VOLUME] |= WM8962_ADC_VU; 3820 reg_cache[WM8962_RIGHT_ADC_VOLUME] |= WM8962_ADC_VU;
3823 wm8962->reg_cache[WM8962_LEFT_DAC_VOLUME] |= WM8962_DAC_VU; 3821 reg_cache[WM8962_LEFT_DAC_VOLUME] |= WM8962_DAC_VU;
3824 wm8962->reg_cache[WM8962_RIGHT_DAC_VOLUME] |= WM8962_DAC_VU; 3822 reg_cache[WM8962_RIGHT_DAC_VOLUME] |= WM8962_DAC_VU;
3825 wm8962->reg_cache[WM8962_SPKOUTL_VOLUME] |= WM8962_SPKOUT_VU; 3823 reg_cache[WM8962_SPKOUTL_VOLUME] |= WM8962_SPKOUT_VU;
3826 wm8962->reg_cache[WM8962_SPKOUTR_VOLUME] |= WM8962_SPKOUT_VU; 3824 reg_cache[WM8962_SPKOUTR_VOLUME] |= WM8962_SPKOUT_VU;
3827 wm8962->reg_cache[WM8962_HPOUTL_VOLUME] |= WM8962_HPOUT_VU; 3825 reg_cache[WM8962_HPOUTL_VOLUME] |= WM8962_HPOUT_VU;
3828 wm8962->reg_cache[WM8962_HPOUTR_VOLUME] |= WM8962_HPOUT_VU; 3826 reg_cache[WM8962_HPOUTR_VOLUME] |= WM8962_HPOUT_VU;
3829 3827
3830 wm8962_add_widgets(codec); 3828 wm8962_add_widgets(codec);
3831 3829