diff options
author | Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> | 2018-01-28 23:15:27 -0500 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2018-02-12 04:52:34 -0500 |
commit | f2e6f95b4b1381fe81cdbdb70d2c50a85b770d8b (patch) | |
tree | 9d850cbe458f6d8934693d952e51c58d360af65a | |
parent | 7928b2cbe55b2a410a0f5c1f154610059c57b1b2 (diff) |
ASoC: tlv320aic31xx: replace codec to component
Now we can replace Codec to Component. Let's do it.
Note:
xxx_codec_xxx() -> xxx_component_xxx()
.idle_bias_off = 0 -> .idle_bias_on = 1
.ignore_pmdown_time = 0 -> .use_pmdown_time = 1
- -> .endianness = 1
- -> .non_legacy_dai_naming = 1
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r-- | sound/soc/codecs/tlv320aic31xx.c | 240 |
1 files changed, 116 insertions, 124 deletions
diff --git a/sound/soc/codecs/tlv320aic31xx.c b/sound/soc/codecs/tlv320aic31xx.c index 858cb8be445f..d3cd924dc300 100644 --- a/sound/soc/codecs/tlv320aic31xx.c +++ b/sound/soc/codecs/tlv320aic31xx.c | |||
@@ -153,7 +153,7 @@ struct aic31xx_disable_nb { | |||
153 | }; | 153 | }; |
154 | 154 | ||
155 | struct aic31xx_priv { | 155 | struct aic31xx_priv { |
156 | struct snd_soc_codec *codec; | 156 | struct snd_soc_component *component; |
157 | u8 i2c_regs_status; | 157 | u8 i2c_regs_status; |
158 | struct device *dev; | 158 | struct device *dev; |
159 | struct regmap *regmap; | 159 | struct regmap *regmap; |
@@ -348,8 +348,8 @@ static int aic31xx_wait_bits(struct aic31xx_priv *aic31xx, unsigned int reg, | |||
348 | static int aic31xx_dapm_power_event(struct snd_soc_dapm_widget *w, | 348 | static int aic31xx_dapm_power_event(struct snd_soc_dapm_widget *w, |
349 | struct snd_kcontrol *kcontrol, int event) | 349 | struct snd_kcontrol *kcontrol, int event) |
350 | { | 350 | { |
351 | struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); | 351 | struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); |
352 | struct aic31xx_priv *aic31xx = snd_soc_codec_get_drvdata(codec); | 352 | struct aic31xx_priv *aic31xx = snd_soc_component_get_drvdata(component); |
353 | unsigned int reg = AIC31XX_DACFLAG1; | 353 | unsigned int reg = AIC31XX_DACFLAG1; |
354 | unsigned int mask; | 354 | unsigned int mask; |
355 | 355 | ||
@@ -377,7 +377,7 @@ static int aic31xx_dapm_power_event(struct snd_soc_dapm_widget *w, | |||
377 | reg = AIC31XX_ADCFLAG; | 377 | reg = AIC31XX_ADCFLAG; |
378 | break; | 378 | break; |
379 | default: | 379 | default: |
380 | dev_err(codec->dev, "Unknown widget '%s' calling %s\n", | 380 | dev_err(component->dev, "Unknown widget '%s' calling %s\n", |
381 | w->name, __func__); | 381 | w->name, __func__); |
382 | return -EINVAL; | 382 | return -EINVAL; |
383 | } | 383 | } |
@@ -388,7 +388,7 @@ static int aic31xx_dapm_power_event(struct snd_soc_dapm_widget *w, | |||
388 | case SND_SOC_DAPM_POST_PMD: | 388 | case SND_SOC_DAPM_POST_PMD: |
389 | return aic31xx_wait_bits(aic31xx, reg, mask, 0, 5000, 100); | 389 | return aic31xx_wait_bits(aic31xx, reg, mask, 0, 5000, 100); |
390 | default: | 390 | default: |
391 | dev_dbg(codec->dev, | 391 | dev_dbg(component->dev, |
392 | "Unhandled dapm widget event %d from %s\n", | 392 | "Unhandled dapm widget event %d from %s\n", |
393 | event, w->name); | 393 | event, w->name); |
394 | } | 394 | } |
@@ -444,23 +444,23 @@ static const struct snd_kcontrol_new aic31xx_dapm_spr_switch = | |||
444 | static int mic_bias_event(struct snd_soc_dapm_widget *w, | 444 | static int mic_bias_event(struct snd_soc_dapm_widget *w, |
445 | struct snd_kcontrol *kcontrol, int event) | 445 | struct snd_kcontrol *kcontrol, int event) |
446 | { | 446 | { |
447 | struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); | 447 | struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); |
448 | struct aic31xx_priv *aic31xx = snd_soc_codec_get_drvdata(codec); | 448 | struct aic31xx_priv *aic31xx = snd_soc_component_get_drvdata(component); |
449 | 449 | ||
450 | switch (event) { | 450 | switch (event) { |
451 | case SND_SOC_DAPM_POST_PMU: | 451 | case SND_SOC_DAPM_POST_PMU: |
452 | /* change mic bias voltage to user defined */ | 452 | /* change mic bias voltage to user defined */ |
453 | snd_soc_update_bits(codec, AIC31XX_MICBIAS, | 453 | snd_soc_component_update_bits(component, AIC31XX_MICBIAS, |
454 | AIC31XX_MICBIAS_MASK, | 454 | AIC31XX_MICBIAS_MASK, |
455 | aic31xx->micbias_vg << | 455 | aic31xx->micbias_vg << |
456 | AIC31XX_MICBIAS_SHIFT); | 456 | AIC31XX_MICBIAS_SHIFT); |
457 | dev_dbg(codec->dev, "%s: turned on\n", __func__); | 457 | dev_dbg(component->dev, "%s: turned on\n", __func__); |
458 | break; | 458 | break; |
459 | case SND_SOC_DAPM_PRE_PMD: | 459 | case SND_SOC_DAPM_PRE_PMD: |
460 | /* turn mic bias off */ | 460 | /* turn mic bias off */ |
461 | snd_soc_update_bits(codec, AIC31XX_MICBIAS, | 461 | snd_soc_component_update_bits(component, AIC31XX_MICBIAS, |
462 | AIC31XX_MICBIAS_MASK, 0); | 462 | AIC31XX_MICBIAS_MASK, 0); |
463 | dev_dbg(codec->dev, "%s: turned off\n", __func__); | 463 | dev_dbg(component->dev, "%s: turned off\n", __func__); |
464 | break; | 464 | break; |
465 | } | 465 | } |
466 | return 0; | 466 | return 0; |
@@ -670,34 +670,34 @@ aic310x_audio_map[] = { | |||
670 | {"SPK", NULL, "SPK ClassD"}, | 670 | {"SPK", NULL, "SPK ClassD"}, |
671 | }; | 671 | }; |
672 | 672 | ||
673 | static int aic31xx_add_controls(struct snd_soc_codec *codec) | 673 | static int aic31xx_add_controls(struct snd_soc_component *component) |
674 | { | 674 | { |
675 | int ret = 0; | 675 | int ret = 0; |
676 | struct aic31xx_priv *aic31xx = snd_soc_codec_get_drvdata(codec); | 676 | struct aic31xx_priv *aic31xx = snd_soc_component_get_drvdata(component); |
677 | 677 | ||
678 | if (!(aic31xx->codec_type & DAC31XX_BIT)) | 678 | if (!(aic31xx->codec_type & DAC31XX_BIT)) |
679 | ret = snd_soc_add_codec_controls( | 679 | ret = snd_soc_add_component_controls( |
680 | codec, aic31xx_snd_controls, | 680 | component, aic31xx_snd_controls, |
681 | ARRAY_SIZE(aic31xx_snd_controls)); | 681 | ARRAY_SIZE(aic31xx_snd_controls)); |
682 | if (ret) | 682 | if (ret) |
683 | return ret; | 683 | return ret; |
684 | 684 | ||
685 | if (aic31xx->codec_type & AIC31XX_STEREO_CLASS_D_BIT) | 685 | if (aic31xx->codec_type & AIC31XX_STEREO_CLASS_D_BIT) |
686 | ret = snd_soc_add_codec_controls( | 686 | ret = snd_soc_add_component_controls( |
687 | codec, aic311x_snd_controls, | 687 | component, aic311x_snd_controls, |
688 | ARRAY_SIZE(aic311x_snd_controls)); | 688 | ARRAY_SIZE(aic311x_snd_controls)); |
689 | else | 689 | else |
690 | ret = snd_soc_add_codec_controls( | 690 | ret = snd_soc_add_component_controls( |
691 | codec, aic310x_snd_controls, | 691 | component, aic310x_snd_controls, |
692 | ARRAY_SIZE(aic310x_snd_controls)); | 692 | ARRAY_SIZE(aic310x_snd_controls)); |
693 | 693 | ||
694 | return ret; | 694 | return ret; |
695 | } | 695 | } |
696 | 696 | ||
697 | static int aic31xx_add_widgets(struct snd_soc_codec *codec) | 697 | static int aic31xx_add_widgets(struct snd_soc_component *component) |
698 | { | 698 | { |
699 | struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); | 699 | struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); |
700 | struct aic31xx_priv *aic31xx = snd_soc_codec_get_drvdata(codec); | 700 | struct aic31xx_priv *aic31xx = snd_soc_component_get_drvdata(component); |
701 | int ret = 0; | 701 | int ret = 0; |
702 | 702 | ||
703 | if (aic31xx->codec_type & DAC31XX_BIT) { | 703 | if (aic31xx->codec_type & DAC31XX_BIT) { |
@@ -751,10 +751,10 @@ static int aic31xx_add_widgets(struct snd_soc_codec *codec) | |||
751 | return 0; | 751 | return 0; |
752 | } | 752 | } |
753 | 753 | ||
754 | static int aic31xx_setup_pll(struct snd_soc_codec *codec, | 754 | static int aic31xx_setup_pll(struct snd_soc_component *component, |
755 | struct snd_pcm_hw_params *params) | 755 | struct snd_pcm_hw_params *params) |
756 | { | 756 | { |
757 | struct aic31xx_priv *aic31xx = snd_soc_codec_get_drvdata(codec); | 757 | struct aic31xx_priv *aic31xx = snd_soc_component_get_drvdata(component); |
758 | int bclk_score = snd_soc_params_to_frame_size(params); | 758 | int bclk_score = snd_soc_params_to_frame_size(params); |
759 | int mclk_p; | 759 | int mclk_p; |
760 | int bclk_n = 0; | 760 | int bclk_n = 0; |
@@ -762,15 +762,15 @@ static int aic31xx_setup_pll(struct snd_soc_codec *codec, | |||
762 | int i; | 762 | int i; |
763 | 763 | ||
764 | if (!aic31xx->sysclk || !aic31xx->p_div) { | 764 | if (!aic31xx->sysclk || !aic31xx->p_div) { |
765 | dev_err(codec->dev, "Master clock not supplied\n"); | 765 | dev_err(component->dev, "Master clock not supplied\n"); |
766 | return -EINVAL; | 766 | return -EINVAL; |
767 | } | 767 | } |
768 | mclk_p = aic31xx->sysclk / aic31xx->p_div; | 768 | mclk_p = aic31xx->sysclk / aic31xx->p_div; |
769 | 769 | ||
770 | /* Use PLL as CODEC_CLKIN and DAC_CLK as BDIV_CLKIN */ | 770 | /* Use PLL as CODEC_CLKIN and DAC_CLK as BDIV_CLKIN */ |
771 | snd_soc_update_bits(codec, AIC31XX_CLKMUX, | 771 | snd_soc_component_update_bits(component, AIC31XX_CLKMUX, |
772 | AIC31XX_CODEC_CLKIN_MASK, AIC31XX_CODEC_CLKIN_PLL); | 772 | AIC31XX_CODEC_CLKIN_MASK, AIC31XX_CODEC_CLKIN_PLL); |
773 | snd_soc_update_bits(codec, AIC31XX_IFACE2, | 773 | snd_soc_component_update_bits(component, AIC31XX_IFACE2, |
774 | AIC31XX_BDIVCLK_MASK, AIC31XX_DAC2BCLK); | 774 | AIC31XX_BDIVCLK_MASK, AIC31XX_DAC2BCLK); |
775 | 775 | ||
776 | for (i = 0; i < ARRAY_SIZE(aic31xx_divs); i++) { | 776 | for (i = 0; i < ARRAY_SIZE(aic31xx_divs); i++) { |
@@ -789,14 +789,14 @@ static int aic31xx_setup_pll(struct snd_soc_codec *codec, | |||
789 | } | 789 | } |
790 | 790 | ||
791 | if (match == -1) { | 791 | if (match == -1) { |
792 | dev_err(codec->dev, | 792 | dev_err(component->dev, |
793 | "%s: Sample rate (%u) and format not supported\n", | 793 | "%s: Sample rate (%u) and format not supported\n", |
794 | __func__, params_rate(params)); | 794 | __func__, params_rate(params)); |
795 | /* See bellow for details how fix this. */ | 795 | /* See bellow for details how fix this. */ |
796 | return -EINVAL; | 796 | return -EINVAL; |
797 | } | 797 | } |
798 | if (bclk_score != 0) { | 798 | if (bclk_score != 0) { |
799 | dev_warn(codec->dev, "Can not produce exact bitclock"); | 799 | dev_warn(component->dev, "Can not produce exact bitclock"); |
800 | /* This is fine if using dsp format, but if using i2s | 800 | /* This is fine if using dsp format, but if using i2s |
801 | there may be trouble. To fix the issue edit the | 801 | there may be trouble. To fix the issue edit the |
802 | aic31xx_divs table for your mclk and sample | 802 | aic31xx_divs table for your mclk and sample |
@@ -808,39 +808,39 @@ static int aic31xx_setup_pll(struct snd_soc_codec *codec, | |||
808 | i = match; | 808 | i = match; |
809 | 809 | ||
810 | /* PLL configuration */ | 810 | /* PLL configuration */ |
811 | snd_soc_update_bits(codec, AIC31XX_PLLPR, AIC31XX_PLL_MASK, | 811 | snd_soc_component_update_bits(component, AIC31XX_PLLPR, AIC31XX_PLL_MASK, |
812 | (aic31xx->p_div << 4) | 0x01); | 812 | (aic31xx->p_div << 4) | 0x01); |
813 | snd_soc_write(codec, AIC31XX_PLLJ, aic31xx_divs[i].pll_j); | 813 | snd_soc_component_write(component, AIC31XX_PLLJ, aic31xx_divs[i].pll_j); |
814 | 814 | ||
815 | snd_soc_write(codec, AIC31XX_PLLDMSB, | 815 | snd_soc_component_write(component, AIC31XX_PLLDMSB, |
816 | aic31xx_divs[i].pll_d >> 8); | 816 | aic31xx_divs[i].pll_d >> 8); |
817 | snd_soc_write(codec, AIC31XX_PLLDLSB, | 817 | snd_soc_component_write(component, AIC31XX_PLLDLSB, |
818 | aic31xx_divs[i].pll_d & 0xff); | 818 | aic31xx_divs[i].pll_d & 0xff); |
819 | 819 | ||
820 | /* DAC dividers configuration */ | 820 | /* DAC dividers configuration */ |
821 | snd_soc_update_bits(codec, AIC31XX_NDAC, AIC31XX_PLL_MASK, | 821 | snd_soc_component_update_bits(component, AIC31XX_NDAC, AIC31XX_PLL_MASK, |
822 | aic31xx_divs[i].ndac); | 822 | aic31xx_divs[i].ndac); |
823 | snd_soc_update_bits(codec, AIC31XX_MDAC, AIC31XX_PLL_MASK, | 823 | snd_soc_component_update_bits(component, AIC31XX_MDAC, AIC31XX_PLL_MASK, |
824 | aic31xx_divs[i].mdac); | 824 | aic31xx_divs[i].mdac); |
825 | 825 | ||
826 | snd_soc_write(codec, AIC31XX_DOSRMSB, aic31xx_divs[i].dosr >> 8); | 826 | snd_soc_component_write(component, AIC31XX_DOSRMSB, aic31xx_divs[i].dosr >> 8); |
827 | snd_soc_write(codec, AIC31XX_DOSRLSB, aic31xx_divs[i].dosr & 0xff); | 827 | snd_soc_component_write(component, AIC31XX_DOSRLSB, aic31xx_divs[i].dosr & 0xff); |
828 | 828 | ||
829 | /* ADC dividers configuration. Write reset value 1 if not used. */ | 829 | /* ADC dividers configuration. Write reset value 1 if not used. */ |
830 | snd_soc_update_bits(codec, AIC31XX_NADC, AIC31XX_PLL_MASK, | 830 | snd_soc_component_update_bits(component, AIC31XX_NADC, AIC31XX_PLL_MASK, |
831 | aic31xx_divs[i].nadc ? aic31xx_divs[i].nadc : 1); | 831 | aic31xx_divs[i].nadc ? aic31xx_divs[i].nadc : 1); |
832 | snd_soc_update_bits(codec, AIC31XX_MADC, AIC31XX_PLL_MASK, | 832 | snd_soc_component_update_bits(component, AIC31XX_MADC, AIC31XX_PLL_MASK, |
833 | aic31xx_divs[i].madc ? aic31xx_divs[i].madc : 1); | 833 | aic31xx_divs[i].madc ? aic31xx_divs[i].madc : 1); |
834 | 834 | ||
835 | snd_soc_write(codec, AIC31XX_AOSR, aic31xx_divs[i].aosr); | 835 | snd_soc_component_write(component, AIC31XX_AOSR, aic31xx_divs[i].aosr); |
836 | 836 | ||
837 | /* Bit clock divider configuration. */ | 837 | /* Bit clock divider configuration. */ |
838 | snd_soc_update_bits(codec, AIC31XX_BCLKN, | 838 | snd_soc_component_update_bits(component, AIC31XX_BCLKN, |
839 | AIC31XX_PLL_MASK, bclk_n); | 839 | AIC31XX_PLL_MASK, bclk_n); |
840 | 840 | ||
841 | aic31xx->rate_div_line = i; | 841 | aic31xx->rate_div_line = i; |
842 | 842 | ||
843 | dev_dbg(codec->dev, | 843 | dev_dbg(component->dev, |
844 | "pll %d.%04d/%d dosr %d n %d m %d aosr %d n %d m %d bclk_n %d\n", | 844 | "pll %d.%04d/%d dosr %d n %d m %d aosr %d n %d m %d bclk_n %d\n", |
845 | aic31xx_divs[i].pll_j, | 845 | aic31xx_divs[i].pll_j, |
846 | aic31xx_divs[i].pll_d, | 846 | aic31xx_divs[i].pll_d, |
@@ -861,10 +861,10 @@ static int aic31xx_hw_params(struct snd_pcm_substream *substream, | |||
861 | struct snd_pcm_hw_params *params, | 861 | struct snd_pcm_hw_params *params, |
862 | struct snd_soc_dai *dai) | 862 | struct snd_soc_dai *dai) |
863 | { | 863 | { |
864 | struct snd_soc_codec *codec = dai->codec; | 864 | struct snd_soc_component *component = dai->component; |
865 | u8 data = 0; | 865 | u8 data = 0; |
866 | 866 | ||
867 | dev_dbg(codec->dev, "## %s: width %d rate %d\n", | 867 | dev_dbg(component->dev, "## %s: width %d rate %d\n", |
868 | __func__, params_width(params), | 868 | __func__, params_width(params), |
869 | params_rate(params)); | 869 | params_rate(params)); |
870 | 870 | ||
@@ -884,28 +884,28 @@ static int aic31xx_hw_params(struct snd_pcm_substream *substream, | |||
884 | AIC31XX_IFACE1_DATALEN_SHIFT); | 884 | AIC31XX_IFACE1_DATALEN_SHIFT); |
885 | break; | 885 | break; |
886 | default: | 886 | default: |
887 | dev_err(codec->dev, "%s: Unsupported width %d\n", | 887 | dev_err(component->dev, "%s: Unsupported width %d\n", |
888 | __func__, params_width(params)); | 888 | __func__, params_width(params)); |
889 | return -EINVAL; | 889 | return -EINVAL; |
890 | } | 890 | } |
891 | 891 | ||
892 | snd_soc_update_bits(codec, AIC31XX_IFACE1, | 892 | snd_soc_component_update_bits(component, AIC31XX_IFACE1, |
893 | AIC31XX_IFACE1_DATALEN_MASK, | 893 | AIC31XX_IFACE1_DATALEN_MASK, |
894 | data); | 894 | data); |
895 | 895 | ||
896 | return aic31xx_setup_pll(codec, params); | 896 | return aic31xx_setup_pll(component, params); |
897 | } | 897 | } |
898 | 898 | ||
899 | static int aic31xx_dac_mute(struct snd_soc_dai *codec_dai, int mute) | 899 | static int aic31xx_dac_mute(struct snd_soc_dai *codec_dai, int mute) |
900 | { | 900 | { |
901 | struct snd_soc_codec *codec = codec_dai->codec; | 901 | struct snd_soc_component *component = codec_dai->component; |
902 | 902 | ||
903 | if (mute) { | 903 | if (mute) { |
904 | snd_soc_update_bits(codec, AIC31XX_DACMUTE, | 904 | snd_soc_component_update_bits(component, AIC31XX_DACMUTE, |
905 | AIC31XX_DACMUTE_MASK, | 905 | AIC31XX_DACMUTE_MASK, |
906 | AIC31XX_DACMUTE_MASK); | 906 | AIC31XX_DACMUTE_MASK); |
907 | } else { | 907 | } else { |
908 | snd_soc_update_bits(codec, AIC31XX_DACMUTE, | 908 | snd_soc_component_update_bits(component, AIC31XX_DACMUTE, |
909 | AIC31XX_DACMUTE_MASK, 0x0); | 909 | AIC31XX_DACMUTE_MASK, 0x0); |
910 | } | 910 | } |
911 | 911 | ||
@@ -915,12 +915,12 @@ static int aic31xx_dac_mute(struct snd_soc_dai *codec_dai, int mute) | |||
915 | static int aic31xx_set_dai_fmt(struct snd_soc_dai *codec_dai, | 915 | static int aic31xx_set_dai_fmt(struct snd_soc_dai *codec_dai, |
916 | unsigned int fmt) | 916 | unsigned int fmt) |
917 | { | 917 | { |
918 | struct snd_soc_codec *codec = codec_dai->codec; | 918 | struct snd_soc_component *component = codec_dai->component; |
919 | u8 iface_reg1 = 0; | 919 | u8 iface_reg1 = 0; |
920 | u8 iface_reg2 = 0; | 920 | u8 iface_reg2 = 0; |
921 | u8 dsp_a_val = 0; | 921 | u8 dsp_a_val = 0; |
922 | 922 | ||
923 | dev_dbg(codec->dev, "## %s: fmt = 0x%x\n", __func__, fmt); | 923 | dev_dbg(component->dev, "## %s: fmt = 0x%x\n", __func__, fmt); |
924 | 924 | ||
925 | /* set master/slave audio interface */ | 925 | /* set master/slave audio interface */ |
926 | switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { | 926 | switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { |
@@ -936,7 +936,7 @@ static int aic31xx_set_dai_fmt(struct snd_soc_dai *codec_dai, | |||
936 | case SND_SOC_DAIFMT_CBS_CFS: | 936 | case SND_SOC_DAIFMT_CBS_CFS: |
937 | break; | 937 | break; |
938 | default: | 938 | default: |
939 | dev_err(codec->dev, "Invalid DAI master/slave interface\n"); | 939 | dev_err(component->dev, "Invalid DAI master/slave interface\n"); |
940 | return -EINVAL; | 940 | return -EINVAL; |
941 | } | 941 | } |
942 | 942 | ||
@@ -948,7 +948,7 @@ static int aic31xx_set_dai_fmt(struct snd_soc_dai *codec_dai, | |||
948 | iface_reg2 |= AIC31XX_BCLKINV_MASK; | 948 | iface_reg2 |= AIC31XX_BCLKINV_MASK; |
949 | break; | 949 | break; |
950 | default: | 950 | default: |
951 | dev_err(codec->dev, "Invalid DAI clock signal polarity\n"); | 951 | dev_err(component->dev, "Invalid DAI clock signal polarity\n"); |
952 | return -EINVAL; | 952 | return -EINVAL; |
953 | } | 953 | } |
954 | 954 | ||
@@ -977,18 +977,18 @@ static int aic31xx_set_dai_fmt(struct snd_soc_dai *codec_dai, | |||
977 | AIC31XX_IFACE1_DATATYPE_SHIFT); | 977 | AIC31XX_IFACE1_DATATYPE_SHIFT); |
978 | break; | 978 | break; |
979 | default: | 979 | default: |
980 | dev_err(codec->dev, "Invalid DAI interface format\n"); | 980 | dev_err(component->dev, "Invalid DAI interface format\n"); |
981 | return -EINVAL; | 981 | return -EINVAL; |
982 | } | 982 | } |
983 | 983 | ||
984 | snd_soc_update_bits(codec, AIC31XX_IFACE1, | 984 | snd_soc_component_update_bits(component, AIC31XX_IFACE1, |
985 | AIC31XX_IFACE1_DATATYPE_MASK | | 985 | AIC31XX_IFACE1_DATATYPE_MASK | |
986 | AIC31XX_IFACE1_MASTER_MASK, | 986 | AIC31XX_IFACE1_MASTER_MASK, |
987 | iface_reg1); | 987 | iface_reg1); |
988 | snd_soc_update_bits(codec, AIC31XX_DATA_OFFSET, | 988 | snd_soc_component_update_bits(component, AIC31XX_DATA_OFFSET, |
989 | AIC31XX_DATA_OFFSET_MASK, | 989 | AIC31XX_DATA_OFFSET_MASK, |
990 | dsp_a_val); | 990 | dsp_a_val); |
991 | snd_soc_update_bits(codec, AIC31XX_IFACE2, | 991 | snd_soc_component_update_bits(component, AIC31XX_IFACE2, |
992 | AIC31XX_BCLKINV_MASK, | 992 | AIC31XX_BCLKINV_MASK, |
993 | iface_reg2); | 993 | iface_reg2); |
994 | 994 | ||
@@ -998,11 +998,11 @@ static int aic31xx_set_dai_fmt(struct snd_soc_dai *codec_dai, | |||
998 | static int aic31xx_set_dai_sysclk(struct snd_soc_dai *codec_dai, | 998 | static int aic31xx_set_dai_sysclk(struct snd_soc_dai *codec_dai, |
999 | int clk_id, unsigned int freq, int dir) | 999 | int clk_id, unsigned int freq, int dir) |
1000 | { | 1000 | { |
1001 | struct snd_soc_codec *codec = codec_dai->codec; | 1001 | struct snd_soc_component *component = codec_dai->component; |
1002 | struct aic31xx_priv *aic31xx = snd_soc_codec_get_drvdata(codec); | 1002 | struct aic31xx_priv *aic31xx = snd_soc_component_get_drvdata(component); |
1003 | int i; | 1003 | int i; |
1004 | 1004 | ||
1005 | dev_dbg(codec->dev, "## %s: clk_id = %d, freq = %d, dir = %d\n", | 1005 | dev_dbg(component->dev, "## %s: clk_id = %d, freq = %d, dir = %d\n", |
1006 | __func__, clk_id, freq, dir); | 1006 | __func__, clk_id, freq, dir); |
1007 | 1007 | ||
1008 | for (i = 1; i < 8; i++) | 1008 | for (i = 1; i < 8; i++) |
@@ -1025,7 +1025,7 @@ static int aic31xx_set_dai_sysclk(struct snd_soc_dai *codec_dai, | |||
1025 | } | 1025 | } |
1026 | 1026 | ||
1027 | /* set clock on MCLK, BCLK, or GPIO1 as PLL input */ | 1027 | /* set clock on MCLK, BCLK, or GPIO1 as PLL input */ |
1028 | snd_soc_update_bits(codec, AIC31XX_CLKMUX, AIC31XX_PLL_CLKIN_MASK, | 1028 | snd_soc_component_update_bits(component, AIC31XX_CLKMUX, AIC31XX_PLL_CLKIN_MASK, |
1029 | clk_id << AIC31XX_PLL_CLKIN_SHIFT); | 1029 | clk_id << AIC31XX_PLL_CLKIN_SHIFT); |
1030 | 1030 | ||
1031 | aic31xx->sysclk = freq; | 1031 | aic31xx->sysclk = freq; |
@@ -1071,42 +1071,42 @@ static int aic31xx_reset(struct aic31xx_priv *aic31xx) | |||
1071 | return ret; | 1071 | return ret; |
1072 | } | 1072 | } |
1073 | 1073 | ||
1074 | static void aic31xx_clk_on(struct snd_soc_codec *codec) | 1074 | static void aic31xx_clk_on(struct snd_soc_component *component) |
1075 | { | 1075 | { |
1076 | struct aic31xx_priv *aic31xx = snd_soc_codec_get_drvdata(codec); | 1076 | struct aic31xx_priv *aic31xx = snd_soc_component_get_drvdata(component); |
1077 | u8 mask = AIC31XX_PM_MASK; | 1077 | u8 mask = AIC31XX_PM_MASK; |
1078 | u8 on = AIC31XX_PM_MASK; | 1078 | u8 on = AIC31XX_PM_MASK; |
1079 | 1079 | ||
1080 | dev_dbg(codec->dev, "codec clock -> on (rate %d)\n", | 1080 | dev_dbg(component->dev, "codec clock -> on (rate %d)\n", |
1081 | aic31xx_divs[aic31xx->rate_div_line].rate); | 1081 | aic31xx_divs[aic31xx->rate_div_line].rate); |
1082 | snd_soc_update_bits(codec, AIC31XX_PLLPR, mask, on); | 1082 | snd_soc_component_update_bits(component, AIC31XX_PLLPR, mask, on); |
1083 | mdelay(10); | 1083 | mdelay(10); |
1084 | snd_soc_update_bits(codec, AIC31XX_NDAC, mask, on); | 1084 | snd_soc_component_update_bits(component, AIC31XX_NDAC, mask, on); |
1085 | snd_soc_update_bits(codec, AIC31XX_MDAC, mask, on); | 1085 | snd_soc_component_update_bits(component, AIC31XX_MDAC, mask, on); |
1086 | if (aic31xx_divs[aic31xx->rate_div_line].nadc) | 1086 | if (aic31xx_divs[aic31xx->rate_div_line].nadc) |
1087 | snd_soc_update_bits(codec, AIC31XX_NADC, mask, on); | 1087 | snd_soc_component_update_bits(component, AIC31XX_NADC, mask, on); |
1088 | if (aic31xx_divs[aic31xx->rate_div_line].madc) | 1088 | if (aic31xx_divs[aic31xx->rate_div_line].madc) |
1089 | snd_soc_update_bits(codec, AIC31XX_MADC, mask, on); | 1089 | snd_soc_component_update_bits(component, AIC31XX_MADC, mask, on); |
1090 | snd_soc_update_bits(codec, AIC31XX_BCLKN, mask, on); | 1090 | snd_soc_component_update_bits(component, AIC31XX_BCLKN, mask, on); |
1091 | } | 1091 | } |
1092 | 1092 | ||
1093 | static void aic31xx_clk_off(struct snd_soc_codec *codec) | 1093 | static void aic31xx_clk_off(struct snd_soc_component *component) |
1094 | { | 1094 | { |
1095 | u8 mask = AIC31XX_PM_MASK; | 1095 | u8 mask = AIC31XX_PM_MASK; |
1096 | u8 off = 0; | 1096 | u8 off = 0; |
1097 | 1097 | ||
1098 | dev_dbg(codec->dev, "codec clock -> off\n"); | 1098 | dev_dbg(component->dev, "codec clock -> off\n"); |
1099 | snd_soc_update_bits(codec, AIC31XX_BCLKN, mask, off); | 1099 | snd_soc_component_update_bits(component, AIC31XX_BCLKN, mask, off); |
1100 | snd_soc_update_bits(codec, AIC31XX_MADC, mask, off); | 1100 | snd_soc_component_update_bits(component, AIC31XX_MADC, mask, off); |
1101 | snd_soc_update_bits(codec, AIC31XX_NADC, mask, off); | 1101 | snd_soc_component_update_bits(component, AIC31XX_NADC, mask, off); |
1102 | snd_soc_update_bits(codec, AIC31XX_MDAC, mask, off); | 1102 | snd_soc_component_update_bits(component, AIC31XX_MDAC, mask, off); |
1103 | snd_soc_update_bits(codec, AIC31XX_NDAC, mask, off); | 1103 | snd_soc_component_update_bits(component, AIC31XX_NDAC, mask, off); |
1104 | snd_soc_update_bits(codec, AIC31XX_PLLPR, mask, off); | 1104 | snd_soc_component_update_bits(component, AIC31XX_PLLPR, mask, off); |
1105 | } | 1105 | } |
1106 | 1106 | ||
1107 | static int aic31xx_power_on(struct snd_soc_codec *codec) | 1107 | static int aic31xx_power_on(struct snd_soc_component *component) |
1108 | { | 1108 | { |
1109 | struct aic31xx_priv *aic31xx = snd_soc_codec_get_drvdata(codec); | 1109 | struct aic31xx_priv *aic31xx = snd_soc_component_get_drvdata(component); |
1110 | int ret; | 1110 | int ret; |
1111 | 1111 | ||
1112 | ret = regulator_bulk_enable(ARRAY_SIZE(aic31xx->supplies), | 1112 | ret = regulator_bulk_enable(ARRAY_SIZE(aic31xx->supplies), |
@@ -1123,7 +1123,7 @@ static int aic31xx_power_on(struct snd_soc_codec *codec) | |||
1123 | 1123 | ||
1124 | ret = regcache_sync(aic31xx->regmap); | 1124 | ret = regcache_sync(aic31xx->regmap); |
1125 | if (ret) { | 1125 | if (ret) { |
1126 | dev_err(codec->dev, | 1126 | dev_err(component->dev, |
1127 | "Failed to restore cache: %d\n", ret); | 1127 | "Failed to restore cache: %d\n", ret); |
1128 | regcache_cache_only(aic31xx->regmap, true); | 1128 | regcache_cache_only(aic31xx->regmap, true); |
1129 | regulator_bulk_disable(ARRAY_SIZE(aic31xx->supplies), | 1129 | regulator_bulk_disable(ARRAY_SIZE(aic31xx->supplies), |
@@ -1134,57 +1134,57 @@ static int aic31xx_power_on(struct snd_soc_codec *codec) | |||
1134 | return 0; | 1134 | return 0; |
1135 | } | 1135 | } |
1136 | 1136 | ||
1137 | static void aic31xx_power_off(struct snd_soc_codec *codec) | 1137 | static void aic31xx_power_off(struct snd_soc_component *component) |
1138 | { | 1138 | { |
1139 | struct aic31xx_priv *aic31xx = snd_soc_codec_get_drvdata(codec); | 1139 | struct aic31xx_priv *aic31xx = snd_soc_component_get_drvdata(component); |
1140 | 1140 | ||
1141 | regcache_cache_only(aic31xx->regmap, true); | 1141 | regcache_cache_only(aic31xx->regmap, true); |
1142 | regulator_bulk_disable(ARRAY_SIZE(aic31xx->supplies), | 1142 | regulator_bulk_disable(ARRAY_SIZE(aic31xx->supplies), |
1143 | aic31xx->supplies); | 1143 | aic31xx->supplies); |
1144 | } | 1144 | } |
1145 | 1145 | ||
1146 | static int aic31xx_set_bias_level(struct snd_soc_codec *codec, | 1146 | static int aic31xx_set_bias_level(struct snd_soc_component *component, |
1147 | enum snd_soc_bias_level level) | 1147 | enum snd_soc_bias_level level) |
1148 | { | 1148 | { |
1149 | dev_dbg(codec->dev, "## %s: %d -> %d\n", __func__, | 1149 | dev_dbg(component->dev, "## %s: %d -> %d\n", __func__, |
1150 | snd_soc_codec_get_bias_level(codec), level); | 1150 | snd_soc_component_get_bias_level(component), level); |
1151 | 1151 | ||
1152 | switch (level) { | 1152 | switch (level) { |
1153 | case SND_SOC_BIAS_ON: | 1153 | case SND_SOC_BIAS_ON: |
1154 | break; | 1154 | break; |
1155 | case SND_SOC_BIAS_PREPARE: | 1155 | case SND_SOC_BIAS_PREPARE: |
1156 | if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_STANDBY) | 1156 | if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_STANDBY) |
1157 | aic31xx_clk_on(codec); | 1157 | aic31xx_clk_on(component); |
1158 | break; | 1158 | break; |
1159 | case SND_SOC_BIAS_STANDBY: | 1159 | case SND_SOC_BIAS_STANDBY: |
1160 | switch (snd_soc_codec_get_bias_level(codec)) { | 1160 | switch (snd_soc_component_get_bias_level(component)) { |
1161 | case SND_SOC_BIAS_OFF: | 1161 | case SND_SOC_BIAS_OFF: |
1162 | aic31xx_power_on(codec); | 1162 | aic31xx_power_on(component); |
1163 | break; | 1163 | break; |
1164 | case SND_SOC_BIAS_PREPARE: | 1164 | case SND_SOC_BIAS_PREPARE: |
1165 | aic31xx_clk_off(codec); | 1165 | aic31xx_clk_off(component); |
1166 | break; | 1166 | break; |
1167 | default: | 1167 | default: |
1168 | BUG(); | 1168 | BUG(); |
1169 | } | 1169 | } |
1170 | break; | 1170 | break; |
1171 | case SND_SOC_BIAS_OFF: | 1171 | case SND_SOC_BIAS_OFF: |
1172 | if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_STANDBY) | 1172 | if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_STANDBY) |
1173 | aic31xx_power_off(codec); | 1173 | aic31xx_power_off(component); |
1174 | break; | 1174 | break; |
1175 | } | 1175 | } |
1176 | 1176 | ||
1177 | return 0; | 1177 | return 0; |
1178 | } | 1178 | } |
1179 | 1179 | ||
1180 | static int aic31xx_codec_probe(struct snd_soc_codec *codec) | 1180 | static int aic31xx_codec_probe(struct snd_soc_component *component) |
1181 | { | 1181 | { |
1182 | struct aic31xx_priv *aic31xx = snd_soc_codec_get_drvdata(codec); | 1182 | struct aic31xx_priv *aic31xx = snd_soc_component_get_drvdata(component); |
1183 | int i, ret; | 1183 | int i, ret; |
1184 | 1184 | ||
1185 | dev_dbg(aic31xx->dev, "## %s\n", __func__); | 1185 | dev_dbg(aic31xx->dev, "## %s\n", __func__); |
1186 | 1186 | ||
1187 | aic31xx->codec = codec; | 1187 | aic31xx->component = component; |
1188 | 1188 | ||
1189 | for (i = 0; i < ARRAY_SIZE(aic31xx->supplies); i++) { | 1189 | for (i = 0; i < ARRAY_SIZE(aic31xx->supplies); i++) { |
1190 | aic31xx->disable_nb[i].nb.notifier_call = | 1190 | aic31xx->disable_nb[i].nb.notifier_call = |
@@ -1193,7 +1193,7 @@ static int aic31xx_codec_probe(struct snd_soc_codec *codec) | |||
1193 | ret = regulator_register_notifier(aic31xx->supplies[i].consumer, | 1193 | ret = regulator_register_notifier(aic31xx->supplies[i].consumer, |
1194 | &aic31xx->disable_nb[i].nb); | 1194 | &aic31xx->disable_nb[i].nb); |
1195 | if (ret) { | 1195 | if (ret) { |
1196 | dev_err(codec->dev, | 1196 | dev_err(component->dev, |
1197 | "Failed to request regulator notifier: %d\n", | 1197 | "Failed to request regulator notifier: %d\n", |
1198 | ret); | 1198 | ret); |
1199 | return ret; | 1199 | return ret; |
@@ -1203,43 +1203,42 @@ static int aic31xx_codec_probe(struct snd_soc_codec *codec) | |||
1203 | regcache_cache_only(aic31xx->regmap, true); | 1203 | regcache_cache_only(aic31xx->regmap, true); |
1204 | regcache_mark_dirty(aic31xx->regmap); | 1204 | regcache_mark_dirty(aic31xx->regmap); |
1205 | 1205 | ||
1206 | ret = aic31xx_add_controls(codec); | 1206 | ret = aic31xx_add_controls(component); |
1207 | if (ret) | 1207 | if (ret) |
1208 | return ret; | 1208 | return ret; |
1209 | 1209 | ||
1210 | ret = aic31xx_add_widgets(codec); | 1210 | ret = aic31xx_add_widgets(component); |
1211 | if (ret) | 1211 | if (ret) |
1212 | return ret; | 1212 | return ret; |
1213 | 1213 | ||
1214 | return 0; | 1214 | return 0; |
1215 | } | 1215 | } |
1216 | 1216 | ||
1217 | static int aic31xx_codec_remove(struct snd_soc_codec *codec) | 1217 | static void aic31xx_codec_remove(struct snd_soc_component *component) |
1218 | { | 1218 | { |
1219 | struct aic31xx_priv *aic31xx = snd_soc_codec_get_drvdata(codec); | 1219 | struct aic31xx_priv *aic31xx = snd_soc_component_get_drvdata(component); |
1220 | int i; | 1220 | int i; |
1221 | 1221 | ||
1222 | for (i = 0; i < ARRAY_SIZE(aic31xx->supplies); i++) | 1222 | for (i = 0; i < ARRAY_SIZE(aic31xx->supplies); i++) |
1223 | regulator_unregister_notifier(aic31xx->supplies[i].consumer, | 1223 | regulator_unregister_notifier(aic31xx->supplies[i].consumer, |
1224 | &aic31xx->disable_nb[i].nb); | 1224 | &aic31xx->disable_nb[i].nb); |
1225 | |||
1226 | return 0; | ||
1227 | } | 1225 | } |
1228 | 1226 | ||
1229 | static const struct snd_soc_codec_driver soc_codec_driver_aic31xx = { | 1227 | static const struct snd_soc_component_driver soc_codec_driver_aic31xx = { |
1230 | .probe = aic31xx_codec_probe, | 1228 | .probe = aic31xx_codec_probe, |
1231 | .remove = aic31xx_codec_remove, | 1229 | .remove = aic31xx_codec_remove, |
1232 | .set_bias_level = aic31xx_set_bias_level, | 1230 | .set_bias_level = aic31xx_set_bias_level, |
1233 | .suspend_bias_off = true, | 1231 | .controls = common31xx_snd_controls, |
1234 | 1232 | .num_controls = ARRAY_SIZE(common31xx_snd_controls), | |
1235 | .component_driver = { | 1233 | .dapm_widgets = common31xx_dapm_widgets, |
1236 | .controls = common31xx_snd_controls, | 1234 | .num_dapm_widgets = ARRAY_SIZE(common31xx_dapm_widgets), |
1237 | .num_controls = ARRAY_SIZE(common31xx_snd_controls), | 1235 | .dapm_routes = common31xx_audio_map, |
1238 | .dapm_widgets = common31xx_dapm_widgets, | 1236 | .num_dapm_routes = ARRAY_SIZE(common31xx_audio_map), |
1239 | .num_dapm_widgets = ARRAY_SIZE(common31xx_dapm_widgets), | 1237 | .suspend_bias_off = 1, |
1240 | .dapm_routes = common31xx_audio_map, | 1238 | .idle_bias_on = 1, |
1241 | .num_dapm_routes = ARRAY_SIZE(common31xx_audio_map), | 1239 | .use_pmdown_time = 1, |
1242 | }, | 1240 | .endianness = 1, |
1241 | .non_legacy_dai_naming = 1, | ||
1243 | }; | 1242 | }; |
1244 | 1243 | ||
1245 | static const struct snd_soc_dai_ops aic31xx_dai_ops = { | 1244 | static const struct snd_soc_dai_ops aic31xx_dai_ops = { |
@@ -1375,23 +1374,17 @@ static int aic31xx_i2c_probe(struct i2c_client *i2c, | |||
1375 | } | 1374 | } |
1376 | 1375 | ||
1377 | if (aic31xx->codec_type & DAC31XX_BIT) | 1376 | if (aic31xx->codec_type & DAC31XX_BIT) |
1378 | return snd_soc_register_codec(&i2c->dev, | 1377 | return devm_snd_soc_register_component(&i2c->dev, |
1379 | &soc_codec_driver_aic31xx, | 1378 | &soc_codec_driver_aic31xx, |
1380 | dac31xx_dai_driver, | 1379 | dac31xx_dai_driver, |
1381 | ARRAY_SIZE(dac31xx_dai_driver)); | 1380 | ARRAY_SIZE(dac31xx_dai_driver)); |
1382 | else | 1381 | else |
1383 | return snd_soc_register_codec(&i2c->dev, | 1382 | return devm_snd_soc_register_component(&i2c->dev, |
1384 | &soc_codec_driver_aic31xx, | 1383 | &soc_codec_driver_aic31xx, |
1385 | aic31xx_dai_driver, | 1384 | aic31xx_dai_driver, |
1386 | ARRAY_SIZE(aic31xx_dai_driver)); | 1385 | ARRAY_SIZE(aic31xx_dai_driver)); |
1387 | } | 1386 | } |
1388 | 1387 | ||
1389 | static int aic31xx_i2c_remove(struct i2c_client *i2c) | ||
1390 | { | ||
1391 | snd_soc_unregister_codec(&i2c->dev); | ||
1392 | return 0; | ||
1393 | } | ||
1394 | |||
1395 | static const struct i2c_device_id aic31xx_i2c_id[] = { | 1388 | static const struct i2c_device_id aic31xx_i2c_id[] = { |
1396 | { "tlv320aic310x", AIC3100 }, | 1389 | { "tlv320aic310x", AIC3100 }, |
1397 | { "tlv320aic311x", AIC3110 }, | 1390 | { "tlv320aic311x", AIC3110 }, |
@@ -1412,7 +1405,6 @@ static struct i2c_driver aic31xx_i2c_driver = { | |||
1412 | .acpi_match_table = ACPI_PTR(aic31xx_acpi_match), | 1405 | .acpi_match_table = ACPI_PTR(aic31xx_acpi_match), |
1413 | }, | 1406 | }, |
1414 | .probe = aic31xx_i2c_probe, | 1407 | .probe = aic31xx_i2c_probe, |
1415 | .remove = aic31xx_i2c_remove, | ||
1416 | .id_table = aic31xx_i2c_id, | 1408 | .id_table = aic31xx_i2c_id, |
1417 | }; | 1409 | }; |
1418 | module_i2c_driver(aic31xx_i2c_driver); | 1410 | module_i2c_driver(aic31xx_i2c_driver); |