diff options
author | Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> | 2018-01-28 23:09:48 -0500 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2018-02-12 04:50:09 -0500 |
commit | 41572b5455be5da603b671a04be267cb4bd8633b (patch) | |
tree | 195e27a7c890c29067f17f5f8c2493d247e71f5f | |
parent | 7928b2cbe55b2a410a0f5c1f154610059c57b1b2 (diff) |
ASoC: max98373: 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/max98373.c | 75 |
1 files changed, 34 insertions, 41 deletions
diff --git a/sound/soc/codecs/max98373.c b/sound/soc/codecs/max98373.c index 562e88765129..a92586106932 100644 --- a/sound/soc/codecs/max98373.c +++ b/sound/soc/codecs/max98373.c | |||
@@ -112,12 +112,12 @@ static struct reg_default max98373_reg[] = { | |||
112 | 112 | ||
113 | static int max98373_dai_set_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) | 113 | static int max98373_dai_set_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) |
114 | { | 114 | { |
115 | struct snd_soc_codec *codec = codec_dai->codec; | 115 | struct snd_soc_component *component = codec_dai->component; |
116 | struct max98373_priv *max98373 = snd_soc_codec_get_drvdata(codec); | 116 | struct max98373_priv *max98373 = snd_soc_component_get_drvdata(component); |
117 | unsigned int format = 0; | 117 | unsigned int format = 0; |
118 | unsigned int invert = 0; | 118 | unsigned int invert = 0; |
119 | 119 | ||
120 | dev_dbg(codec->dev, "%s: fmt 0x%08X\n", __func__, fmt); | 120 | dev_dbg(component->dev, "%s: fmt 0x%08X\n", __func__, fmt); |
121 | 121 | ||
122 | switch (fmt & SND_SOC_DAIFMT_INV_MASK) { | 122 | switch (fmt & SND_SOC_DAIFMT_INV_MASK) { |
123 | case SND_SOC_DAIFMT_NB_NF: | 123 | case SND_SOC_DAIFMT_NB_NF: |
@@ -126,7 +126,7 @@ static int max98373_dai_set_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) | |||
126 | invert = MAX98373_PCM_MODE_CFG_PCM_BCLKEDGE; | 126 | invert = MAX98373_PCM_MODE_CFG_PCM_BCLKEDGE; |
127 | break; | 127 | break; |
128 | default: | 128 | default: |
129 | dev_err(codec->dev, "DAI invert mode unsupported\n"); | 129 | dev_err(component->dev, "DAI invert mode unsupported\n"); |
130 | return -EINVAL; | 130 | return -EINVAL; |
131 | } | 131 | } |
132 | 132 | ||
@@ -177,10 +177,10 @@ static int max98373_get_bclk_sel(int bclk) | |||
177 | return 0; | 177 | return 0; |
178 | } | 178 | } |
179 | 179 | ||
180 | static int max98373_set_clock(struct snd_soc_codec *codec, | 180 | static int max98373_set_clock(struct snd_soc_component *component, |
181 | struct snd_pcm_hw_params *params) | 181 | struct snd_pcm_hw_params *params) |
182 | { | 182 | { |
183 | struct max98373_priv *max98373 = snd_soc_codec_get_drvdata(codec); | 183 | struct max98373_priv *max98373 = snd_soc_component_get_drvdata(component); |
184 | /* BCLK/LRCLK ratio calculation */ | 184 | /* BCLK/LRCLK ratio calculation */ |
185 | int blr_clk_ratio = params_channels(params) * max98373->ch_size; | 185 | int blr_clk_ratio = params_channels(params) * max98373->ch_size; |
186 | int value; | 186 | int value; |
@@ -189,7 +189,7 @@ static int max98373_set_clock(struct snd_soc_codec *codec, | |||
189 | /* BCLK configuration */ | 189 | /* BCLK configuration */ |
190 | value = max98373_get_bclk_sel(blr_clk_ratio); | 190 | value = max98373_get_bclk_sel(blr_clk_ratio); |
191 | if (!value) { | 191 | if (!value) { |
192 | dev_err(codec->dev, "format unsupported %d\n", | 192 | dev_err(component->dev, "format unsupported %d\n", |
193 | params_format(params)); | 193 | params_format(params)); |
194 | return -EINVAL; | 194 | return -EINVAL; |
195 | } | 195 | } |
@@ -206,8 +206,8 @@ static int max98373_dai_hw_params(struct snd_pcm_substream *substream, | |||
206 | struct snd_pcm_hw_params *params, | 206 | struct snd_pcm_hw_params *params, |
207 | struct snd_soc_dai *dai) | 207 | struct snd_soc_dai *dai) |
208 | { | 208 | { |
209 | struct snd_soc_codec *codec = dai->codec; | 209 | struct snd_soc_component *component = dai->component; |
210 | struct max98373_priv *max98373 = snd_soc_codec_get_drvdata(codec); | 210 | struct max98373_priv *max98373 = snd_soc_component_get_drvdata(component); |
211 | unsigned int sampling_rate = 0; | 211 | unsigned int sampling_rate = 0; |
212 | unsigned int chan_sz = 0; | 212 | unsigned int chan_sz = 0; |
213 | 213 | ||
@@ -223,7 +223,7 @@ static int max98373_dai_hw_params(struct snd_pcm_substream *substream, | |||
223 | chan_sz = MAX98373_PCM_MODE_CFG_CHANSZ_32; | 223 | chan_sz = MAX98373_PCM_MODE_CFG_CHANSZ_32; |
224 | break; | 224 | break; |
225 | default: | 225 | default: |
226 | dev_err(codec->dev, "format unsupported %d\n", | 226 | dev_err(component->dev, "format unsupported %d\n", |
227 | params_format(params)); | 227 | params_format(params)); |
228 | goto err; | 228 | goto err; |
229 | } | 229 | } |
@@ -234,7 +234,7 @@ static int max98373_dai_hw_params(struct snd_pcm_substream *substream, | |||
234 | MAX98373_R2024_PCM_DATA_FMT_CFG, | 234 | MAX98373_R2024_PCM_DATA_FMT_CFG, |
235 | MAX98373_PCM_MODE_CFG_CHANSZ_MASK, chan_sz); | 235 | MAX98373_PCM_MODE_CFG_CHANSZ_MASK, chan_sz); |
236 | 236 | ||
237 | dev_dbg(codec->dev, "format supported %d", | 237 | dev_dbg(component->dev, "format supported %d", |
238 | params_format(params)); | 238 | params_format(params)); |
239 | 239 | ||
240 | /* sampling rate configuration */ | 240 | /* sampling rate configuration */ |
@@ -267,7 +267,7 @@ static int max98373_dai_hw_params(struct snd_pcm_substream *substream, | |||
267 | sampling_rate = MAX98373_PCM_SR_SET1_SR_48000; | 267 | sampling_rate = MAX98373_PCM_SR_SET1_SR_48000; |
268 | break; | 268 | break; |
269 | default: | 269 | default: |
270 | dev_err(codec->dev, "rate %d not supported\n", | 270 | dev_err(component->dev, "rate %d not supported\n", |
271 | params_rate(params)); | 271 | params_rate(params)); |
272 | goto err; | 272 | goto err; |
273 | } | 273 | } |
@@ -295,7 +295,7 @@ static int max98373_dai_hw_params(struct snd_pcm_substream *substream, | |||
295 | MAX98373_PCM_SR_SET2_IVADC_SR_MASK, | 295 | MAX98373_PCM_SR_SET2_IVADC_SR_MASK, |
296 | sampling_rate); | 296 | sampling_rate); |
297 | 297 | ||
298 | return max98373_set_clock(codec, params); | 298 | return max98373_set_clock(component, params); |
299 | err: | 299 | err: |
300 | return -EINVAL; | 300 | return -EINVAL; |
301 | } | 301 | } |
@@ -304,8 +304,8 @@ static int max98373_dai_tdm_slot(struct snd_soc_dai *dai, | |||
304 | unsigned int tx_mask, unsigned int rx_mask, | 304 | unsigned int tx_mask, unsigned int rx_mask, |
305 | int slots, int slot_width) | 305 | int slots, int slot_width) |
306 | { | 306 | { |
307 | struct snd_soc_codec *codec = dai->codec; | 307 | struct snd_soc_component *component = dai->component; |
308 | struct max98373_priv *max98373 = snd_soc_codec_get_drvdata(codec); | 308 | struct max98373_priv *max98373 = snd_soc_component_get_drvdata(component); |
309 | int bsel = 0; | 309 | int bsel = 0; |
310 | unsigned int chan_sz = 0; | 310 | unsigned int chan_sz = 0; |
311 | unsigned int mask; | 311 | unsigned int mask; |
@@ -319,7 +319,7 @@ static int max98373_dai_tdm_slot(struct snd_soc_dai *dai, | |||
319 | /* BCLK configuration */ | 319 | /* BCLK configuration */ |
320 | bsel = max98373_get_bclk_sel(slots * slot_width); | 320 | bsel = max98373_get_bclk_sel(slots * slot_width); |
321 | if (bsel == 0) { | 321 | if (bsel == 0) { |
322 | dev_err(codec->dev, "BCLK %d not supported\n", | 322 | dev_err(component->dev, "BCLK %d not supported\n", |
323 | slots * slot_width); | 323 | slots * slot_width); |
324 | return -EINVAL; | 324 | return -EINVAL; |
325 | } | 325 | } |
@@ -341,7 +341,7 @@ static int max98373_dai_tdm_slot(struct snd_soc_dai *dai, | |||
341 | chan_sz = MAX98373_PCM_MODE_CFG_CHANSZ_32; | 341 | chan_sz = MAX98373_PCM_MODE_CFG_CHANSZ_32; |
342 | break; | 342 | break; |
343 | default: | 343 | default: |
344 | dev_err(codec->dev, "format unsupported %d\n", | 344 | dev_err(component->dev, "format unsupported %d\n", |
345 | slot_width); | 345 | slot_width); |
346 | return -EINVAL; | 346 | return -EINVAL; |
347 | } | 347 | } |
@@ -394,8 +394,8 @@ static const struct snd_soc_dai_ops max98373_dai_ops = { | |||
394 | static int max98373_dac_event(struct snd_soc_dapm_widget *w, | 394 | static int max98373_dac_event(struct snd_soc_dapm_widget *w, |
395 | struct snd_kcontrol *kcontrol, int event) | 395 | struct snd_kcontrol *kcontrol, int event) |
396 | { | 396 | { |
397 | struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); | 397 | struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); |
398 | struct max98373_priv *max98373 = snd_soc_codec_get_drvdata(codec); | 398 | struct max98373_priv *max98373 = snd_soc_component_get_drvdata(component); |
399 | 399 | ||
400 | switch (event) { | 400 | switch (event) { |
401 | case SND_SOC_DAPM_POST_PMU: | 401 | case SND_SOC_DAPM_POST_PMU: |
@@ -721,11 +721,9 @@ static struct snd_soc_dai_driver max98373_dai[] = { | |||
721 | } | 721 | } |
722 | }; | 722 | }; |
723 | 723 | ||
724 | static int max98373_probe(struct snd_soc_codec *codec) | 724 | static int max98373_probe(struct snd_soc_component *component) |
725 | { | 725 | { |
726 | struct max98373_priv *max98373 = snd_soc_codec_get_drvdata(codec); | 726 | struct max98373_priv *max98373 = snd_soc_component_get_drvdata(component); |
727 | |||
728 | codec->control_data = max98373->regmap; | ||
729 | 727 | ||
730 | /* Software Reset */ | 728 | /* Software Reset */ |
731 | regmap_write(max98373->regmap, | 729 | regmap_write(max98373->regmap, |
@@ -828,16 +826,18 @@ static const struct dev_pm_ops max98373_pm = { | |||
828 | SET_SYSTEM_SLEEP_PM_OPS(max98373_suspend, max98373_resume) | 826 | SET_SYSTEM_SLEEP_PM_OPS(max98373_suspend, max98373_resume) |
829 | }; | 827 | }; |
830 | 828 | ||
831 | static const struct snd_soc_codec_driver soc_codec_dev_max98373 = { | 829 | static const struct snd_soc_component_driver soc_codec_dev_max98373 = { |
832 | .probe = max98373_probe, | 830 | .probe = max98373_probe, |
833 | .component_driver = { | 831 | .controls = max98373_snd_controls, |
834 | .controls = max98373_snd_controls, | 832 | .num_controls = ARRAY_SIZE(max98373_snd_controls), |
835 | .num_controls = ARRAY_SIZE(max98373_snd_controls), | 833 | .dapm_widgets = max98373_dapm_widgets, |
836 | .dapm_widgets = max98373_dapm_widgets, | 834 | .num_dapm_widgets = ARRAY_SIZE(max98373_dapm_widgets), |
837 | .num_dapm_widgets = ARRAY_SIZE(max98373_dapm_widgets), | 835 | .dapm_routes = max98373_audio_map, |
838 | .dapm_routes = max98373_audio_map, | 836 | .num_dapm_routes = ARRAY_SIZE(max98373_audio_map), |
839 | .num_dapm_routes = ARRAY_SIZE(max98373_audio_map), | 837 | .idle_bias_on = 1, |
840 | }, | 838 | .use_pmdown_time = 1, |
839 | .endianness = 1, | ||
840 | .non_legacy_dai_naming = 1, | ||
841 | }; | 841 | }; |
842 | 842 | ||
843 | static const struct regmap_config max98373_regmap = { | 843 | static const struct regmap_config max98373_regmap = { |
@@ -920,7 +920,7 @@ static int max98373_i2c_probe(struct i2c_client *i2c, | |||
920 | max98373_slot_config(i2c, max98373); | 920 | max98373_slot_config(i2c, max98373); |
921 | 921 | ||
922 | /* codec registeration */ | 922 | /* codec registeration */ |
923 | ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_max98373, | 923 | ret = devm_snd_soc_register_component(&i2c->dev, &soc_codec_dev_max98373, |
924 | max98373_dai, ARRAY_SIZE(max98373_dai)); | 924 | max98373_dai, ARRAY_SIZE(max98373_dai)); |
925 | if (ret < 0) | 925 | if (ret < 0) |
926 | dev_err(&i2c->dev, "Failed to register codec: %d\n", ret); | 926 | dev_err(&i2c->dev, "Failed to register codec: %d\n", ret); |
@@ -928,12 +928,6 @@ static int max98373_i2c_probe(struct i2c_client *i2c, | |||
928 | return ret; | 928 | return ret; |
929 | } | 929 | } |
930 | 930 | ||
931 | static int max98373_i2c_remove(struct i2c_client *client) | ||
932 | { | ||
933 | snd_soc_unregister_codec(&client->dev); | ||
934 | return 0; | ||
935 | } | ||
936 | |||
937 | static const struct i2c_device_id max98373_i2c_id[] = { | 931 | static const struct i2c_device_id max98373_i2c_id[] = { |
938 | { "max98373", 0}, | 932 | { "max98373", 0}, |
939 | { }, | 933 | { }, |
@@ -965,7 +959,6 @@ static struct i2c_driver max98373_i2c_driver = { | |||
965 | .pm = &max98373_pm, | 959 | .pm = &max98373_pm, |
966 | }, | 960 | }, |
967 | .probe = max98373_i2c_probe, | 961 | .probe = max98373_i2c_probe, |
968 | .remove = max98373_i2c_remove, | ||
969 | .id_table = max98373_i2c_id, | 962 | .id_table = max98373_i2c_id, |
970 | }; | 963 | }; |
971 | 964 | ||