aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/codecs/wm8962.c
diff options
context:
space:
mode:
authorMark Brown <broonie@opensource.wolfsonmicro.com>2010-12-28 18:42:53 -0500
committerMark Brown <broonie@opensource.wolfsonmicro.com>2010-12-28 18:42:53 -0500
commit22a756ee8951e597c76e5a60f81d40a43054489e (patch)
tree10415d740b2876dc13ac7b0f857a7717987b9ddf /sound/soc/codecs/wm8962.c
parent839d271c509b6ce5c1da8a8e89fad73a1af0ddda (diff)
parent776065e36de1d5eb9e33ff908352fef4050ab38d (diff)
Merge branch 'for-2.6.37' into for-2.6.38
Diffstat (limited to 'sound/soc/codecs/wm8962.c')
-rw-r--r--sound/soc/codecs/wm8962.c45
1 files changed, 20 insertions, 25 deletions
diff --git a/sound/soc/codecs/wm8962.c b/sound/soc/codecs/wm8962.c
index aa1192f6aa9c..b9cb1fcf8c92 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) {
@@ -2720,7 +2715,7 @@ static int wm8962_add_widgets(struct snd_soc_codec *codec)
2720 2715
2721static void wm8962_sync_cache(struct snd_soc_codec *codec) 2716static void wm8962_sync_cache(struct snd_soc_codec *codec)
2722{ 2717{
2723 struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec); 2718 u16 *reg_cache = codec->reg_cache;
2724 int i; 2719 int i;
2725 2720
2726 if (!codec->cache_sync) 2721 if (!codec->cache_sync)
@@ -2733,13 +2728,13 @@ static void wm8962_sync_cache(struct snd_soc_codec *codec)
2733 /* Sync back cached values if they're different from the 2728 /* Sync back cached values if they're different from the
2734 * hardware default. 2729 * hardware default.
2735 */ 2730 */
2736 for (i = 1; i < ARRAY_SIZE(wm8962->reg_cache); i++) { 2731 for (i = 1; i < codec->driver->reg_cache_size; i++) {
2737 if (i == WM8962_SOFTWARE_RESET) 2732 if (i == WM8962_SOFTWARE_RESET)
2738 continue; 2733 continue;
2739 if (wm8962->reg_cache[i] == wm8962_reg[i]) 2734 if (reg_cache[i] == wm8962_reg[i])
2740 continue; 2735 continue;
2741 2736
2742 snd_soc_write(codec, i, wm8962->reg_cache[i]); 2737 snd_soc_write(codec, i, reg_cache[i]);
2743 } 2738 }
2744 2739
2745 codec->cache_sync = 0; 2740 codec->cache_sync = 0;
@@ -3413,12 +3408,11 @@ EXPORT_SYMBOL_GPL(wm8962_mic_detect);
3413#ifdef CONFIG_PM 3408#ifdef CONFIG_PM
3414static int wm8962_resume(struct snd_soc_codec *codec) 3409static int wm8962_resume(struct snd_soc_codec *codec)
3415{ 3410{
3416 struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec);
3417 u16 *reg_cache = codec->reg_cache; 3411 u16 *reg_cache = codec->reg_cache;
3418 int i; 3412 int i;
3419 3413
3420 /* Restore the registers */ 3414 /* Restore the registers */
3421 for (i = 1; i < ARRAY_SIZE(wm8962->reg_cache); i++) { 3415 for (i = 1; i < codec->driver->reg_cache_size; i++) {
3422 switch (i) { 3416 switch (i) {
3423 case WM8962_SOFTWARE_RESET: 3417 case WM8962_SOFTWARE_RESET:
3424 continue; 3418 continue;
@@ -3713,6 +3707,7 @@ static int wm8962_probe(struct snd_soc_codec *codec)
3713 struct wm8962_pdata *pdata = dev_get_platdata(codec->dev); 3707 struct wm8962_pdata *pdata = dev_get_platdata(codec->dev);
3714 struct i2c_client *i2c = container_of(codec->dev, struct i2c_client, 3708 struct i2c_client *i2c = container_of(codec->dev, struct i2c_client,
3715 dev); 3709 dev);
3710 u16 *reg_cache = codec->reg_cache;
3716 int i, trigger, irq_pol; 3711 int i, trigger, irq_pol;
3717 3712
3718 wm8962->codec = codec; 3713 wm8962->codec = codec;
@@ -3812,7 +3807,7 @@ static int wm8962_probe(struct snd_soc_codec *codec)
3812 3807
3813 /* Put the speakers into mono mode? */ 3808 /* Put the speakers into mono mode? */
3814 if (pdata->spk_mono) 3809 if (pdata->spk_mono)
3815 wm8962->reg_cache[WM8962_CLASS_D_CONTROL_2] 3810 reg_cache[WM8962_CLASS_D_CONTROL_2]
3816 |= WM8962_SPK_MONO; 3811 |= WM8962_SPK_MONO;
3817 3812
3818 /* Micbias setup, detection enable and detection 3813 /* Micbias setup, detection enable and detection
@@ -3827,16 +3822,16 @@ static int wm8962_probe(struct snd_soc_codec *codec)
3827 } 3822 }
3828 3823
3829 /* Latch volume update bits */ 3824 /* Latch volume update bits */
3830 wm8962->reg_cache[WM8962_LEFT_INPUT_VOLUME] |= WM8962_IN_VU; 3825 reg_cache[WM8962_LEFT_INPUT_VOLUME] |= WM8962_IN_VU;
3831 wm8962->reg_cache[WM8962_RIGHT_INPUT_VOLUME] |= WM8962_IN_VU; 3826 reg_cache[WM8962_RIGHT_INPUT_VOLUME] |= WM8962_IN_VU;
3832 wm8962->reg_cache[WM8962_LEFT_ADC_VOLUME] |= WM8962_ADC_VU; 3827 reg_cache[WM8962_LEFT_ADC_VOLUME] |= WM8962_ADC_VU;
3833 wm8962->reg_cache[WM8962_RIGHT_ADC_VOLUME] |= WM8962_ADC_VU; 3828 reg_cache[WM8962_RIGHT_ADC_VOLUME] |= WM8962_ADC_VU;
3834 wm8962->reg_cache[WM8962_LEFT_DAC_VOLUME] |= WM8962_DAC_VU; 3829 reg_cache[WM8962_LEFT_DAC_VOLUME] |= WM8962_DAC_VU;
3835 wm8962->reg_cache[WM8962_RIGHT_DAC_VOLUME] |= WM8962_DAC_VU; 3830 reg_cache[WM8962_RIGHT_DAC_VOLUME] |= WM8962_DAC_VU;
3836 wm8962->reg_cache[WM8962_SPKOUTL_VOLUME] |= WM8962_SPKOUT_VU; 3831 reg_cache[WM8962_SPKOUTL_VOLUME] |= WM8962_SPKOUT_VU;
3837 wm8962->reg_cache[WM8962_SPKOUTR_VOLUME] |= WM8962_SPKOUT_VU; 3832 reg_cache[WM8962_SPKOUTR_VOLUME] |= WM8962_SPKOUT_VU;
3838 wm8962->reg_cache[WM8962_HPOUTL_VOLUME] |= WM8962_HPOUT_VU; 3833 reg_cache[WM8962_HPOUTL_VOLUME] |= WM8962_HPOUT_VU;
3839 wm8962->reg_cache[WM8962_HPOUTR_VOLUME] |= WM8962_HPOUT_VU; 3834 reg_cache[WM8962_HPOUTR_VOLUME] |= WM8962_HPOUT_VU;
3840 3835
3841 wm8962_add_widgets(codec); 3836 wm8962_add_widgets(codec);
3842 3837