diff options
Diffstat (limited to 'sound/soc/codecs/wm8904.c')
-rw-r--r-- | sound/soc/codecs/wm8904.c | 59 |
1 files changed, 38 insertions, 21 deletions
diff --git a/sound/soc/codecs/wm8904.c b/sound/soc/codecs/wm8904.c index c6f0abcc5711..87f14f8675fa 100644 --- a/sound/soc/codecs/wm8904.c +++ b/sound/soc/codecs/wm8904.c | |||
@@ -613,7 +613,7 @@ static int wm8904_reset(struct snd_soc_codec *codec) | |||
613 | 613 | ||
614 | static int wm8904_configure_clocking(struct snd_soc_codec *codec) | 614 | static int wm8904_configure_clocking(struct snd_soc_codec *codec) |
615 | { | 615 | { |
616 | struct wm8904_priv *wm8904 = codec->private_data; | 616 | struct wm8904_priv *wm8904 = snd_soc_codec_get_drvdata(codec); |
617 | unsigned int clock0, clock2, rate; | 617 | unsigned int clock0, clock2, rate; |
618 | 618 | ||
619 | /* Gate the clock while we're updating to avoid misclocking */ | 619 | /* Gate the clock while we're updating to avoid misclocking */ |
@@ -669,7 +669,7 @@ static int wm8904_configure_clocking(struct snd_soc_codec *codec) | |||
669 | 669 | ||
670 | static void wm8904_set_drc(struct snd_soc_codec *codec) | 670 | static void wm8904_set_drc(struct snd_soc_codec *codec) |
671 | { | 671 | { |
672 | struct wm8904_priv *wm8904 = codec->private_data; | 672 | struct wm8904_priv *wm8904 = snd_soc_codec_get_drvdata(codec); |
673 | struct wm8904_pdata *pdata = wm8904->pdata; | 673 | struct wm8904_pdata *pdata = wm8904->pdata; |
674 | int save, i; | 674 | int save, i; |
675 | 675 | ||
@@ -689,7 +689,7 @@ static int wm8904_put_drc_enum(struct snd_kcontrol *kcontrol, | |||
689 | struct snd_ctl_elem_value *ucontrol) | 689 | struct snd_ctl_elem_value *ucontrol) |
690 | { | 690 | { |
691 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 691 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); |
692 | struct wm8904_priv *wm8904 = codec->private_data; | 692 | struct wm8904_priv *wm8904 = snd_soc_codec_get_drvdata(codec); |
693 | struct wm8904_pdata *pdata = wm8904->pdata; | 693 | struct wm8904_pdata *pdata = wm8904->pdata; |
694 | int value = ucontrol->value.integer.value[0]; | 694 | int value = ucontrol->value.integer.value[0]; |
695 | 695 | ||
@@ -707,7 +707,7 @@ static int wm8904_get_drc_enum(struct snd_kcontrol *kcontrol, | |||
707 | struct snd_ctl_elem_value *ucontrol) | 707 | struct snd_ctl_elem_value *ucontrol) |
708 | { | 708 | { |
709 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 709 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); |
710 | struct wm8904_priv *wm8904 = codec->private_data; | 710 | struct wm8904_priv *wm8904 = snd_soc_codec_get_drvdata(codec); |
711 | 711 | ||
712 | ucontrol->value.enumerated.item[0] = wm8904->drc_cfg; | 712 | ucontrol->value.enumerated.item[0] = wm8904->drc_cfg; |
713 | 713 | ||
@@ -716,7 +716,7 @@ static int wm8904_get_drc_enum(struct snd_kcontrol *kcontrol, | |||
716 | 716 | ||
717 | static void wm8904_set_retune_mobile(struct snd_soc_codec *codec) | 717 | static void wm8904_set_retune_mobile(struct snd_soc_codec *codec) |
718 | { | 718 | { |
719 | struct wm8904_priv *wm8904 = codec->private_data; | 719 | struct wm8904_priv *wm8904 = snd_soc_codec_get_drvdata(codec); |
720 | struct wm8904_pdata *pdata = wm8904->pdata; | 720 | struct wm8904_pdata *pdata = wm8904->pdata; |
721 | int best, best_val, save, i, cfg; | 721 | int best, best_val, save, i, cfg; |
722 | 722 | ||
@@ -760,7 +760,7 @@ static int wm8904_put_retune_mobile_enum(struct snd_kcontrol *kcontrol, | |||
760 | struct snd_ctl_elem_value *ucontrol) | 760 | struct snd_ctl_elem_value *ucontrol) |
761 | { | 761 | { |
762 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 762 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); |
763 | struct wm8904_priv *wm8904 = codec->private_data; | 763 | struct wm8904_priv *wm8904 = snd_soc_codec_get_drvdata(codec); |
764 | struct wm8904_pdata *pdata = wm8904->pdata; | 764 | struct wm8904_pdata *pdata = wm8904->pdata; |
765 | int value = ucontrol->value.integer.value[0]; | 765 | int value = ucontrol->value.integer.value[0]; |
766 | 766 | ||
@@ -778,7 +778,7 @@ static int wm8904_get_retune_mobile_enum(struct snd_kcontrol *kcontrol, | |||
778 | struct snd_ctl_elem_value *ucontrol) | 778 | struct snd_ctl_elem_value *ucontrol) |
779 | { | 779 | { |
780 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 780 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); |
781 | struct wm8904_priv *wm8904 = codec->private_data; | 781 | struct wm8904_priv *wm8904 = snd_soc_codec_get_drvdata(codec); |
782 | 782 | ||
783 | ucontrol->value.enumerated.item[0] = wm8904->retune_mobile_cfg; | 783 | ucontrol->value.enumerated.item[0] = wm8904->retune_mobile_cfg; |
784 | 784 | ||
@@ -789,7 +789,7 @@ static int deemph_settings[] = { 0, 32000, 44100, 48000 }; | |||
789 | 789 | ||
790 | static int wm8904_set_deemph(struct snd_soc_codec *codec) | 790 | static int wm8904_set_deemph(struct snd_soc_codec *codec) |
791 | { | 791 | { |
792 | struct wm8904_priv *wm8904 = codec->private_data; | 792 | struct wm8904_priv *wm8904 = snd_soc_codec_get_drvdata(codec); |
793 | int val, i, best; | 793 | int val, i, best; |
794 | 794 | ||
795 | /* If we're using deemphasis select the nearest available sample | 795 | /* If we're using deemphasis select the nearest available sample |
@@ -818,7 +818,7 @@ static int wm8904_get_deemph(struct snd_kcontrol *kcontrol, | |||
818 | struct snd_ctl_elem_value *ucontrol) | 818 | struct snd_ctl_elem_value *ucontrol) |
819 | { | 819 | { |
820 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 820 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); |
821 | struct wm8904_priv *wm8904 = codec->private_data; | 821 | struct wm8904_priv *wm8904 = snd_soc_codec_get_drvdata(codec); |
822 | 822 | ||
823 | return wm8904->deemph; | 823 | return wm8904->deemph; |
824 | } | 824 | } |
@@ -827,7 +827,7 @@ static int wm8904_put_deemph(struct snd_kcontrol *kcontrol, | |||
827 | struct snd_ctl_elem_value *ucontrol) | 827 | struct snd_ctl_elem_value *ucontrol) |
828 | { | 828 | { |
829 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 829 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); |
830 | struct wm8904_priv *wm8904 = codec->private_data; | 830 | struct wm8904_priv *wm8904 = snd_soc_codec_get_drvdata(codec); |
831 | int deemph = ucontrol->value.enumerated.item[0]; | 831 | int deemph = ucontrol->value.enumerated.item[0]; |
832 | 832 | ||
833 | if (deemph > 1) | 833 | if (deemph > 1) |
@@ -943,7 +943,7 @@ static int sysclk_event(struct snd_soc_dapm_widget *w, | |||
943 | struct snd_kcontrol *kcontrol, int event) | 943 | struct snd_kcontrol *kcontrol, int event) |
944 | { | 944 | { |
945 | struct snd_soc_codec *codec = w->codec; | 945 | struct snd_soc_codec *codec = w->codec; |
946 | struct wm8904_priv *wm8904 = codec->private_data; | 946 | struct wm8904_priv *wm8904 = snd_soc_codec_get_drvdata(codec); |
947 | 947 | ||
948 | switch (event) { | 948 | switch (event) { |
949 | case SND_SOC_DAPM_PRE_PMU: | 949 | case SND_SOC_DAPM_PRE_PMU: |
@@ -981,7 +981,7 @@ static int out_pga_event(struct snd_soc_dapm_widget *w, | |||
981 | struct snd_kcontrol *kcontrol, int event) | 981 | struct snd_kcontrol *kcontrol, int event) |
982 | { | 982 | { |
983 | struct snd_soc_codec *codec = w->codec; | 983 | struct snd_soc_codec *codec = w->codec; |
984 | struct wm8904_priv *wm8904 = codec->private_data; | 984 | struct wm8904_priv *wm8904 = snd_soc_codec_get_drvdata(codec); |
985 | int reg, val; | 985 | int reg, val; |
986 | int dcs_mask; | 986 | int dcs_mask; |
987 | int dcs_l, dcs_r; | 987 | int dcs_l, dcs_r; |
@@ -1429,7 +1429,7 @@ static const struct snd_soc_dapm_route wm8912_intercon[] = { | |||
1429 | 1429 | ||
1430 | static int wm8904_add_widgets(struct snd_soc_codec *codec) | 1430 | static int wm8904_add_widgets(struct snd_soc_codec *codec) |
1431 | { | 1431 | { |
1432 | struct wm8904_priv *wm8904 = codec->private_data; | 1432 | struct wm8904_priv *wm8904 = snd_soc_codec_get_drvdata(codec); |
1433 | 1433 | ||
1434 | snd_soc_dapm_new_controls(codec, wm8904_core_dapm_widgets, | 1434 | snd_soc_dapm_new_controls(codec, wm8904_core_dapm_widgets, |
1435 | ARRAY_SIZE(wm8904_core_dapm_widgets)); | 1435 | ARRAY_SIZE(wm8904_core_dapm_widgets)); |
@@ -1543,7 +1543,7 @@ static int wm8904_hw_params(struct snd_pcm_substream *substream, | |||
1543 | struct snd_soc_dai *dai) | 1543 | struct snd_soc_dai *dai) |
1544 | { | 1544 | { |
1545 | struct snd_soc_codec *codec = dai->codec; | 1545 | struct snd_soc_codec *codec = dai->codec; |
1546 | struct wm8904_priv *wm8904 = codec->private_data; | 1546 | struct wm8904_priv *wm8904 = snd_soc_codec_get_drvdata(codec); |
1547 | int ret, i, best, best_val, cur_val; | 1547 | int ret, i, best, best_val, cur_val; |
1548 | unsigned int aif1 = 0; | 1548 | unsigned int aif1 = 0; |
1549 | unsigned int aif2 = 0; | 1549 | unsigned int aif2 = 0; |
@@ -1670,7 +1670,7 @@ static int wm8904_set_sysclk(struct snd_soc_dai *dai, int clk_id, | |||
1670 | unsigned int freq, int dir) | 1670 | unsigned int freq, int dir) |
1671 | { | 1671 | { |
1672 | struct snd_soc_codec *codec = dai->codec; | 1672 | struct snd_soc_codec *codec = dai->codec; |
1673 | struct wm8904_priv *priv = codec->private_data; | 1673 | struct wm8904_priv *priv = snd_soc_codec_get_drvdata(codec); |
1674 | 1674 | ||
1675 | switch (clk_id) { | 1675 | switch (clk_id) { |
1676 | case WM8904_CLK_MCLK: | 1676 | case WM8904_CLK_MCLK: |
@@ -1786,7 +1786,7 @@ static int wm8904_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, | |||
1786 | unsigned int rx_mask, int slots, int slot_width) | 1786 | unsigned int rx_mask, int slots, int slot_width) |
1787 | { | 1787 | { |
1788 | struct snd_soc_codec *codec = dai->codec; | 1788 | struct snd_soc_codec *codec = dai->codec; |
1789 | struct wm8904_priv *wm8904 = codec->private_data; | 1789 | struct wm8904_priv *wm8904 = snd_soc_codec_get_drvdata(codec); |
1790 | int aif1 = 0; | 1790 | int aif1 = 0; |
1791 | 1791 | ||
1792 | /* Don't need to validate anything if we're turning off TDM */ | 1792 | /* Don't need to validate anything if we're turning off TDM */ |
@@ -1943,7 +1943,7 @@ static int wm8904_set_fll(struct snd_soc_dai *dai, int fll_id, int source, | |||
1943 | unsigned int Fref, unsigned int Fout) | 1943 | unsigned int Fref, unsigned int Fout) |
1944 | { | 1944 | { |
1945 | struct snd_soc_codec *codec = dai->codec; | 1945 | struct snd_soc_codec *codec = dai->codec; |
1946 | struct wm8904_priv *wm8904 = codec->private_data; | 1946 | struct wm8904_priv *wm8904 = snd_soc_codec_get_drvdata(codec); |
1947 | struct _fll_div fll_div; | 1947 | struct _fll_div fll_div; |
1948 | int ret, val; | 1948 | int ret, val; |
1949 | int clock2, fll1; | 1949 | int clock2, fll1; |
@@ -2095,7 +2095,7 @@ static int wm8904_digital_mute(struct snd_soc_dai *codec_dai, int mute) | |||
2095 | 2095 | ||
2096 | static void wm8904_sync_cache(struct snd_soc_codec *codec) | 2096 | static void wm8904_sync_cache(struct snd_soc_codec *codec) |
2097 | { | 2097 | { |
2098 | struct wm8904_priv *wm8904 = codec->private_data; | 2098 | struct wm8904_priv *wm8904 = snd_soc_codec_get_drvdata(codec); |
2099 | int i; | 2099 | int i; |
2100 | 2100 | ||
2101 | if (!codec->cache_sync) | 2101 | if (!codec->cache_sync) |
@@ -2122,7 +2122,7 @@ static void wm8904_sync_cache(struct snd_soc_codec *codec) | |||
2122 | static int wm8904_set_bias_level(struct snd_soc_codec *codec, | 2122 | static int wm8904_set_bias_level(struct snd_soc_codec *codec, |
2123 | enum snd_soc_bias_level level) | 2123 | enum snd_soc_bias_level level) |
2124 | { | 2124 | { |
2125 | struct wm8904_priv *wm8904 = codec->private_data; | 2125 | struct wm8904_priv *wm8904 = snd_soc_codec_get_drvdata(codec); |
2126 | int ret; | 2126 | int ret; |
2127 | 2127 | ||
2128 | switch (level) { | 2128 | switch (level) { |
@@ -2395,7 +2395,7 @@ static int wm8904_probe(struct platform_device *pdev) | |||
2395 | goto pcm_err; | 2395 | goto pcm_err; |
2396 | } | 2396 | } |
2397 | 2397 | ||
2398 | wm8904_handle_pdata(codec->private_data); | 2398 | wm8904_handle_pdata(snd_soc_codec_get_drvdata(codec)); |
2399 | 2399 | ||
2400 | wm8904_add_widgets(codec); | 2400 | wm8904_add_widgets(codec); |
2401 | 2401 | ||
@@ -2426,6 +2426,7 @@ EXPORT_SYMBOL_GPL(soc_codec_dev_wm8904); | |||
2426 | static int wm8904_register(struct wm8904_priv *wm8904, | 2426 | static int wm8904_register(struct wm8904_priv *wm8904, |
2427 | enum snd_soc_control_type control) | 2427 | enum snd_soc_control_type control) |
2428 | { | 2428 | { |
2429 | struct wm8904_pdata *pdata = wm8904->pdata; | ||
2429 | int ret; | 2430 | int ret; |
2430 | struct snd_soc_codec *codec = &wm8904->codec; | 2431 | struct snd_soc_codec *codec = &wm8904->codec; |
2431 | int i; | 2432 | int i; |
@@ -2439,7 +2440,7 @@ static int wm8904_register(struct wm8904_priv *wm8904, | |||
2439 | INIT_LIST_HEAD(&codec->dapm_widgets); | 2440 | INIT_LIST_HEAD(&codec->dapm_widgets); |
2440 | INIT_LIST_HEAD(&codec->dapm_paths); | 2441 | INIT_LIST_HEAD(&codec->dapm_paths); |
2441 | 2442 | ||
2442 | codec->private_data = wm8904; | 2443 | snd_soc_codec_set_drvdata(codec, wm8904); |
2443 | codec->name = "WM8904"; | 2444 | codec->name = "WM8904"; |
2444 | codec->owner = THIS_MODULE; | 2445 | codec->owner = THIS_MODULE; |
2445 | codec->bias_level = SND_SOC_BIAS_OFF; | 2446 | codec->bias_level = SND_SOC_BIAS_OFF; |
@@ -2531,6 +2532,22 @@ static int wm8904_register(struct wm8904_priv *wm8904, | |||
2531 | WM8904_LINEOUTRZC; | 2532 | WM8904_LINEOUTRZC; |
2532 | wm8904->reg_cache[WM8904_CLOCK_RATES_0] &= ~WM8904_SR_MODE; | 2533 | wm8904->reg_cache[WM8904_CLOCK_RATES_0] &= ~WM8904_SR_MODE; |
2533 | 2534 | ||
2535 | /* Apply configuration from the platform data. */ | ||
2536 | if (wm8904->pdata) { | ||
2537 | for (i = 0; i < WM8904_GPIO_REGS; i++) { | ||
2538 | if (!pdata->gpio_cfg[i]) | ||
2539 | continue; | ||
2540 | |||
2541 | wm8904->reg_cache[WM8904_GPIO_CONTROL_1 + i] | ||
2542 | = pdata->gpio_cfg[i] & 0xffff; | ||
2543 | } | ||
2544 | |||
2545 | /* Zero is the default value for these anyway */ | ||
2546 | for (i = 0; i < WM8904_MIC_REGS; i++) | ||
2547 | wm8904->reg_cache[WM8904_MIC_BIAS_CONTROL_0 + i] | ||
2548 | = pdata->mic_cfg[i]; | ||
2549 | } | ||
2550 | |||
2534 | /* Set Class W by default - this will be managed by the Class | 2551 | /* Set Class W by default - this will be managed by the Class |
2535 | * G widget at runtime where bypass paths are available. | 2552 | * G widget at runtime where bypass paths are available. |
2536 | */ | 2553 | */ |