summaryrefslogtreecommitdiffstats
path: root/sound
diff options
context:
space:
mode:
authorKuninori Morimoto <kuninori.morimoto.gx@renesas.com>2018-01-28 22:07:26 -0500
committerMark Brown <broonie@kernel.org>2018-02-12 04:42:12 -0500
commitab38ff38bc77330c009f918680501b9dc37a9b3e (patch)
tree0d0877da7dff8192b78480bebdb0a4a4649c99fa /sound
parent7928b2cbe55b2a410a0f5c1f154610059c57b1b2 (diff)
ASoC: wm8988: 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>
Diffstat (limited to 'sound')
-rw-r--r--sound/soc/codecs/wm8988.c127
1 files changed, 57 insertions, 70 deletions
diff --git a/sound/soc/codecs/wm8988.c b/sound/soc/codecs/wm8988.c
index b0d0219532f2..62200117444b 100644
--- a/sound/soc/codecs/wm8988.c
+++ b/sound/soc/codecs/wm8988.c
@@ -119,7 +119,7 @@ struct wm8988_priv {
119 const struct snd_pcm_hw_constraint_list *sysclk_constraints; 119 const struct snd_pcm_hw_constraint_list *sysclk_constraints;
120}; 120};
121 121
122#define wm8988_reset(c) snd_soc_write(c, WM8988_RESET, 0) 122#define wm8988_reset(c) snd_soc_component_write(c, WM8988_RESET, 0)
123 123
124/* 124/*
125 * WM8988 Controls 125 * WM8988 Controls
@@ -244,16 +244,16 @@ SOC_DOUBLE_R_TLV("Output 2 Playback Volume", WM8988_LOUT2V, WM8988_ROUT2V,
244static int wm8988_lrc_control(struct snd_soc_dapm_widget *w, 244static int wm8988_lrc_control(struct snd_soc_dapm_widget *w,
245 struct snd_kcontrol *kcontrol, int event) 245 struct snd_kcontrol *kcontrol, int event)
246{ 246{
247 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); 247 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
248 u16 adctl2 = snd_soc_read(codec, WM8988_ADCTL2); 248 u16 adctl2 = snd_soc_component_read32(component, WM8988_ADCTL2);
249 249
250 /* Use the DAC to gate LRC if active, otherwise use ADC */ 250 /* Use the DAC to gate LRC if active, otherwise use ADC */
251 if (snd_soc_read(codec, WM8988_PWR2) & 0x180) 251 if (snd_soc_component_read32(component, WM8988_PWR2) & 0x180)
252 adctl2 &= ~0x4; 252 adctl2 &= ~0x4;
253 else 253 else
254 adctl2 |= 0x4; 254 adctl2 |= 0x4;
255 255
256 return snd_soc_write(codec, WM8988_ADCTL2, adctl2); 256 return snd_soc_component_write(component, WM8988_ADCTL2, adctl2);
257} 257}
258 258
259static const char *wm8988_line_texts[] = { 259static const char *wm8988_line_texts[] = {
@@ -555,8 +555,8 @@ static const struct snd_pcm_hw_constraint_list constraints_12 = {
555static int wm8988_set_dai_sysclk(struct snd_soc_dai *codec_dai, 555static int wm8988_set_dai_sysclk(struct snd_soc_dai *codec_dai,
556 int clk_id, unsigned int freq, int dir) 556 int clk_id, unsigned int freq, int dir)
557{ 557{
558 struct snd_soc_codec *codec = codec_dai->codec; 558 struct snd_soc_component *component = codec_dai->component;
559 struct wm8988_priv *wm8988 = snd_soc_codec_get_drvdata(codec); 559 struct wm8988_priv *wm8988 = snd_soc_component_get_drvdata(component);
560 560
561 switch (freq) { 561 switch (freq) {
562 case 11289600: 562 case 11289600:
@@ -587,7 +587,7 @@ static int wm8988_set_dai_sysclk(struct snd_soc_dai *codec_dai,
587static int wm8988_set_dai_fmt(struct snd_soc_dai *codec_dai, 587static int wm8988_set_dai_fmt(struct snd_soc_dai *codec_dai,
588 unsigned int fmt) 588 unsigned int fmt)
589{ 589{
590 struct snd_soc_codec *codec = codec_dai->codec; 590 struct snd_soc_component *component = codec_dai->component;
591 u16 iface = 0; 591 u16 iface = 0;
592 592
593 /* set master/slave audio interface */ 593 /* set master/slave audio interface */
@@ -638,21 +638,21 @@ static int wm8988_set_dai_fmt(struct snd_soc_dai *codec_dai,
638 return -EINVAL; 638 return -EINVAL;
639 } 639 }
640 640
641 snd_soc_write(codec, WM8988_IFACE, iface); 641 snd_soc_component_write(component, WM8988_IFACE, iface);
642 return 0; 642 return 0;
643} 643}
644 644
645static int wm8988_pcm_startup(struct snd_pcm_substream *substream, 645static int wm8988_pcm_startup(struct snd_pcm_substream *substream,
646 struct snd_soc_dai *dai) 646 struct snd_soc_dai *dai)
647{ 647{
648 struct snd_soc_codec *codec = dai->codec; 648 struct snd_soc_component *component = dai->component;
649 struct wm8988_priv *wm8988 = snd_soc_codec_get_drvdata(codec); 649 struct wm8988_priv *wm8988 = snd_soc_component_get_drvdata(component);
650 650
651 /* The set of sample rates that can be supported depends on the 651 /* The set of sample rates that can be supported depends on the
652 * MCLK supplied to the CODEC - enforce this. 652 * MCLK supplied to the CODEC - enforce this.
653 */ 653 */
654 if (!wm8988->sysclk) { 654 if (!wm8988->sysclk) {
655 dev_err(codec->dev, 655 dev_err(component->dev,
656 "No MCLK configured, call set_sysclk() on init\n"); 656 "No MCLK configured, call set_sysclk() on init\n");
657 return -EINVAL; 657 return -EINVAL;
658 } 658 }
@@ -668,10 +668,10 @@ static int wm8988_pcm_hw_params(struct snd_pcm_substream *substream,
668 struct snd_pcm_hw_params *params, 668 struct snd_pcm_hw_params *params,
669 struct snd_soc_dai *dai) 669 struct snd_soc_dai *dai)
670{ 670{
671 struct snd_soc_codec *codec = dai->codec; 671 struct snd_soc_component *component = dai->component;
672 struct wm8988_priv *wm8988 = snd_soc_codec_get_drvdata(codec); 672 struct wm8988_priv *wm8988 = snd_soc_component_get_drvdata(component);
673 u16 iface = snd_soc_read(codec, WM8988_IFACE) & 0x1f3; 673 u16 iface = snd_soc_component_read32(component, WM8988_IFACE) & 0x1f3;
674 u16 srate = snd_soc_read(codec, WM8988_SRATE) & 0x180; 674 u16 srate = snd_soc_component_read32(component, WM8988_SRATE) & 0x180;
675 int coeff; 675 int coeff;
676 676
677 coeff = get_coeff(wm8988->sysclk, params_rate(params)); 677 coeff = get_coeff(wm8988->sysclk, params_rate(params));
@@ -680,7 +680,7 @@ static int wm8988_pcm_hw_params(struct snd_pcm_substream *substream,
680 srate |= 0x40; 680 srate |= 0x40;
681 } 681 }
682 if (coeff < 0) { 682 if (coeff < 0) {
683 dev_err(codec->dev, 683 dev_err(component->dev,
684 "Unable to configure sample rate %dHz with %dHz MCLK\n", 684 "Unable to configure sample rate %dHz with %dHz MCLK\n",
685 params_rate(params), wm8988->sysclk); 685 params_rate(params), wm8988->sysclk);
686 return coeff; 686 return coeff;
@@ -702,9 +702,9 @@ static int wm8988_pcm_hw_params(struct snd_pcm_substream *substream,
702 } 702 }
703 703
704 /* set iface & srate */ 704 /* set iface & srate */
705 snd_soc_write(codec, WM8988_IFACE, iface); 705 snd_soc_component_write(component, WM8988_IFACE, iface);
706 if (coeff >= 0) 706 if (coeff >= 0)
707 snd_soc_write(codec, WM8988_SRATE, srate | 707 snd_soc_component_write(component, WM8988_SRATE, srate |
708 (coeff_div[coeff].sr << 1) | coeff_div[coeff].usb); 708 (coeff_div[coeff].sr << 1) | coeff_div[coeff].usb);
709 709
710 return 0; 710 return 0;
@@ -712,21 +712,21 @@ static int wm8988_pcm_hw_params(struct snd_pcm_substream *substream,
712 712
713static int wm8988_mute(struct snd_soc_dai *dai, int mute) 713static int wm8988_mute(struct snd_soc_dai *dai, int mute)
714{ 714{
715 struct snd_soc_codec *codec = dai->codec; 715 struct snd_soc_component *component = dai->component;
716 u16 mute_reg = snd_soc_read(codec, WM8988_ADCDAC) & 0xfff7; 716 u16 mute_reg = snd_soc_component_read32(component, WM8988_ADCDAC) & 0xfff7;
717 717
718 if (mute) 718 if (mute)
719 snd_soc_write(codec, WM8988_ADCDAC, mute_reg | 0x8); 719 snd_soc_component_write(component, WM8988_ADCDAC, mute_reg | 0x8);
720 else 720 else
721 snd_soc_write(codec, WM8988_ADCDAC, mute_reg); 721 snd_soc_component_write(component, WM8988_ADCDAC, mute_reg);
722 return 0; 722 return 0;
723} 723}
724 724
725static int wm8988_set_bias_level(struct snd_soc_codec *codec, 725static int wm8988_set_bias_level(struct snd_soc_component *component,
726 enum snd_soc_bias_level level) 726 enum snd_soc_bias_level level)
727{ 727{
728 struct wm8988_priv *wm8988 = snd_soc_codec_get_drvdata(codec); 728 struct wm8988_priv *wm8988 = snd_soc_component_get_drvdata(component);
729 u16 pwr_reg = snd_soc_read(codec, WM8988_PWR1) & ~0x1c1; 729 u16 pwr_reg = snd_soc_component_read32(component, WM8988_PWR1) & ~0x1c1;
730 730
731 switch (level) { 731 switch (level) {
732 case SND_SOC_BIAS_ON: 732 case SND_SOC_BIAS_ON:
@@ -734,26 +734,26 @@ static int wm8988_set_bias_level(struct snd_soc_codec *codec,
734 734
735 case SND_SOC_BIAS_PREPARE: 735 case SND_SOC_BIAS_PREPARE:
736 /* VREF, VMID=2x50k, digital enabled */ 736 /* VREF, VMID=2x50k, digital enabled */
737 snd_soc_write(codec, WM8988_PWR1, pwr_reg | 0x00c0); 737 snd_soc_component_write(component, WM8988_PWR1, pwr_reg | 0x00c0);
738 break; 738 break;
739 739
740 case SND_SOC_BIAS_STANDBY: 740 case SND_SOC_BIAS_STANDBY:
741 if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) { 741 if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) {
742 regcache_sync(wm8988->regmap); 742 regcache_sync(wm8988->regmap);
743 743
744 /* VREF, VMID=2x5k */ 744 /* VREF, VMID=2x5k */
745 snd_soc_write(codec, WM8988_PWR1, pwr_reg | 0x1c1); 745 snd_soc_component_write(component, WM8988_PWR1, pwr_reg | 0x1c1);
746 746
747 /* Charge caps */ 747 /* Charge caps */
748 msleep(100); 748 msleep(100);
749 } 749 }
750 750
751 /* VREF, VMID=2*500k, digital stopped */ 751 /* VREF, VMID=2*500k, digital stopped */
752 snd_soc_write(codec, WM8988_PWR1, pwr_reg | 0x0141); 752 snd_soc_component_write(component, WM8988_PWR1, pwr_reg | 0x0141);
753 break; 753 break;
754 754
755 case SND_SOC_BIAS_OFF: 755 case SND_SOC_BIAS_OFF:
756 snd_soc_write(codec, WM8988_PWR1, 0x0000); 756 snd_soc_component_write(component, WM8988_PWR1, 0x0000);
757 break; 757 break;
758 } 758 }
759 return 0; 759 return 0;
@@ -792,39 +792,40 @@ static struct snd_soc_dai_driver wm8988_dai = {
792 .symmetric_rates = 1, 792 .symmetric_rates = 1,
793}; 793};
794 794
795static int wm8988_probe(struct snd_soc_codec *codec) 795static int wm8988_probe(struct snd_soc_component *component)
796{ 796{
797 int ret = 0; 797 int ret = 0;
798 798
799 ret = wm8988_reset(codec); 799 ret = wm8988_reset(component);
800 if (ret < 0) { 800 if (ret < 0) {
801 dev_err(codec->dev, "Failed to issue reset\n"); 801 dev_err(component->dev, "Failed to issue reset\n");
802 return ret; 802 return ret;
803 } 803 }
804 804
805 /* set the update bits (we always update left then right) */ 805 /* set the update bits (we always update left then right) */
806 snd_soc_update_bits(codec, WM8988_RADC, 0x0100, 0x0100); 806 snd_soc_component_update_bits(component, WM8988_RADC, 0x0100, 0x0100);
807 snd_soc_update_bits(codec, WM8988_RDAC, 0x0100, 0x0100); 807 snd_soc_component_update_bits(component, WM8988_RDAC, 0x0100, 0x0100);
808 snd_soc_update_bits(codec, WM8988_ROUT1V, 0x0100, 0x0100); 808 snd_soc_component_update_bits(component, WM8988_ROUT1V, 0x0100, 0x0100);
809 snd_soc_update_bits(codec, WM8988_ROUT2V, 0x0100, 0x0100); 809 snd_soc_component_update_bits(component, WM8988_ROUT2V, 0x0100, 0x0100);
810 snd_soc_update_bits(codec, WM8988_RINVOL, 0x0100, 0x0100); 810 snd_soc_component_update_bits(component, WM8988_RINVOL, 0x0100, 0x0100);
811 811
812 return 0; 812 return 0;
813} 813}
814 814
815static const struct snd_soc_codec_driver soc_codec_dev_wm8988 = { 815static const struct snd_soc_component_driver soc_component_dev_wm8988 = {
816 .probe = wm8988_probe, 816 .probe = wm8988_probe,
817 .set_bias_level = wm8988_set_bias_level, 817 .set_bias_level = wm8988_set_bias_level,
818 .suspend_bias_off = true, 818 .controls = wm8988_snd_controls,
819 819 .num_controls = ARRAY_SIZE(wm8988_snd_controls),
820 .component_driver = { 820 .dapm_widgets = wm8988_dapm_widgets,
821 .controls = wm8988_snd_controls, 821 .num_dapm_widgets = ARRAY_SIZE(wm8988_dapm_widgets),
822 .num_controls = ARRAY_SIZE(wm8988_snd_controls), 822 .dapm_routes = wm8988_dapm_routes,
823 .dapm_widgets = wm8988_dapm_widgets, 823 .num_dapm_routes = ARRAY_SIZE(wm8988_dapm_routes),
824 .num_dapm_widgets = ARRAY_SIZE(wm8988_dapm_widgets), 824 .suspend_bias_off = 1,
825 .dapm_routes = wm8988_dapm_routes, 825 .idle_bias_on = 1,
826 .num_dapm_routes = ARRAY_SIZE(wm8988_dapm_routes), 826 .use_pmdown_time = 1,
827 }, 827 .endianness = 1,
828 .non_legacy_dai_naming = 1,
828}; 829};
829 830
830static const struct regmap_config wm8988_regmap = { 831static const struct regmap_config wm8988_regmap = {
@@ -859,23 +860,16 @@ static int wm8988_spi_probe(struct spi_device *spi)
859 860
860 spi_set_drvdata(spi, wm8988); 861 spi_set_drvdata(spi, wm8988);
861 862
862 ret = snd_soc_register_codec(&spi->dev, 863 ret = devm_snd_soc_register_component(&spi->dev,
863 &soc_codec_dev_wm8988, &wm8988_dai, 1); 864 &soc_component_dev_wm8988, &wm8988_dai, 1);
864 return ret; 865 return ret;
865} 866}
866 867
867static int wm8988_spi_remove(struct spi_device *spi)
868{
869 snd_soc_unregister_codec(&spi->dev);
870 return 0;
871}
872
873static struct spi_driver wm8988_spi_driver = { 868static struct spi_driver wm8988_spi_driver = {
874 .driver = { 869 .driver = {
875 .name = "wm8988", 870 .name = "wm8988",
876 }, 871 },
877 .probe = wm8988_spi_probe, 872 .probe = wm8988_spi_probe,
878 .remove = wm8988_spi_remove,
879}; 873};
880#endif /* CONFIG_SPI_MASTER */ 874#endif /* CONFIG_SPI_MASTER */
881 875
@@ -900,17 +894,11 @@ static int wm8988_i2c_probe(struct i2c_client *i2c,
900 return ret; 894 return ret;
901 } 895 }
902 896
903 ret = snd_soc_register_codec(&i2c->dev, 897 ret = devm_snd_soc_register_component(&i2c->dev,
904 &soc_codec_dev_wm8988, &wm8988_dai, 1); 898 &soc_component_dev_wm8988, &wm8988_dai, 1);
905 return ret; 899 return ret;
906} 900}
907 901
908static int wm8988_i2c_remove(struct i2c_client *client)
909{
910 snd_soc_unregister_codec(&client->dev);
911 return 0;
912}
913
914static const struct i2c_device_id wm8988_i2c_id[] = { 902static const struct i2c_device_id wm8988_i2c_id[] = {
915 { "wm8988", 0 }, 903 { "wm8988", 0 },
916 { } 904 { }
@@ -922,7 +910,6 @@ static struct i2c_driver wm8988_i2c_driver = {
922 .name = "wm8988", 910 .name = "wm8988",
923 }, 911 },
924 .probe = wm8988_i2c_probe, 912 .probe = wm8988_i2c_probe,
925 .remove = wm8988_i2c_remove,
926 .id_table = wm8988_i2c_id, 913 .id_table = wm8988_i2c_id,
927}; 914};
928#endif 915#endif