diff options
author | Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> | 2018-01-28 23:04:34 -0500 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2018-02-12 04:49:07 -0500 |
commit | 0b3eda289c5cf84b7b1a5245812370accece2f19 (patch) | |
tree | f4c91863c9de2a4e93af1f994df3ae8645e24941 | |
parent | 7928b2cbe55b2a410a0f5c1f154610059c57b1b2 (diff) |
ASoC: max9850: 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/max9850.c | 80 |
1 files changed, 37 insertions, 43 deletions
diff --git a/sound/soc/codecs/max9850.c b/sound/soc/codecs/max9850.c index a3dfc918c278..74d7f52c7e73 100644 --- a/sound/soc/codecs/max9850.c +++ b/sound/soc/codecs/max9850.c | |||
@@ -130,8 +130,8 @@ static int max9850_hw_params(struct snd_pcm_substream *substream, | |||
130 | struct snd_pcm_hw_params *params, | 130 | struct snd_pcm_hw_params *params, |
131 | struct snd_soc_dai *dai) | 131 | struct snd_soc_dai *dai) |
132 | { | 132 | { |
133 | struct snd_soc_codec *codec = dai->codec; | 133 | struct snd_soc_component *component = dai->component; |
134 | struct max9850_priv *max9850 = snd_soc_codec_get_drvdata(codec); | 134 | struct max9850_priv *max9850 = snd_soc_component_get_drvdata(component); |
135 | u64 lrclk_div; | 135 | u64 lrclk_div; |
136 | u8 sf, da; | 136 | u8 sf, da; |
137 | 137 | ||
@@ -139,14 +139,14 @@ static int max9850_hw_params(struct snd_pcm_substream *substream, | |||
139 | return -EINVAL; | 139 | return -EINVAL; |
140 | 140 | ||
141 | /* lrclk_div = 2^22 * rate / iclk with iclk = mclk / sf */ | 141 | /* lrclk_div = 2^22 * rate / iclk with iclk = mclk / sf */ |
142 | sf = (snd_soc_read(codec, MAX9850_CLOCK) >> 2) + 1; | 142 | sf = (snd_soc_component_read32(component, MAX9850_CLOCK) >> 2) + 1; |
143 | lrclk_div = (1 << 22); | 143 | lrclk_div = (1 << 22); |
144 | lrclk_div *= params_rate(params); | 144 | lrclk_div *= params_rate(params); |
145 | lrclk_div *= sf; | 145 | lrclk_div *= sf; |
146 | do_div(lrclk_div, max9850->sysclk); | 146 | do_div(lrclk_div, max9850->sysclk); |
147 | 147 | ||
148 | snd_soc_write(codec, MAX9850_LRCLK_MSB, (lrclk_div >> 8) & 0x7f); | 148 | snd_soc_component_write(component, MAX9850_LRCLK_MSB, (lrclk_div >> 8) & 0x7f); |
149 | snd_soc_write(codec, MAX9850_LRCLK_LSB, lrclk_div & 0xff); | 149 | snd_soc_component_write(component, MAX9850_LRCLK_LSB, lrclk_div & 0xff); |
150 | 150 | ||
151 | switch (params_width(params)) { | 151 | switch (params_width(params)) { |
152 | case 16: | 152 | case 16: |
@@ -161,7 +161,7 @@ static int max9850_hw_params(struct snd_pcm_substream *substream, | |||
161 | default: | 161 | default: |
162 | return -EINVAL; | 162 | return -EINVAL; |
163 | } | 163 | } |
164 | snd_soc_update_bits(codec, MAX9850_DIGITAL_AUDIO, 0x3, da); | 164 | snd_soc_component_update_bits(component, MAX9850_DIGITAL_AUDIO, 0x3, da); |
165 | 165 | ||
166 | return 0; | 166 | return 0; |
167 | } | 167 | } |
@@ -169,16 +169,16 @@ static int max9850_hw_params(struct snd_pcm_substream *substream, | |||
169 | static int max9850_set_dai_sysclk(struct snd_soc_dai *codec_dai, | 169 | static int max9850_set_dai_sysclk(struct snd_soc_dai *codec_dai, |
170 | int clk_id, unsigned int freq, int dir) | 170 | int clk_id, unsigned int freq, int dir) |
171 | { | 171 | { |
172 | struct snd_soc_codec *codec = codec_dai->codec; | 172 | struct snd_soc_component *component = codec_dai->component; |
173 | struct max9850_priv *max9850 = snd_soc_codec_get_drvdata(codec); | 173 | struct max9850_priv *max9850 = snd_soc_component_get_drvdata(component); |
174 | 174 | ||
175 | /* calculate mclk -> iclk divider */ | 175 | /* calculate mclk -> iclk divider */ |
176 | if (freq <= 13000000) | 176 | if (freq <= 13000000) |
177 | snd_soc_write(codec, MAX9850_CLOCK, 0x0); | 177 | snd_soc_component_write(component, MAX9850_CLOCK, 0x0); |
178 | else if (freq <= 26000000) | 178 | else if (freq <= 26000000) |
179 | snd_soc_write(codec, MAX9850_CLOCK, 0x4); | 179 | snd_soc_component_write(component, MAX9850_CLOCK, 0x4); |
180 | else if (freq <= 40000000) | 180 | else if (freq <= 40000000) |
181 | snd_soc_write(codec, MAX9850_CLOCK, 0x8); | 181 | snd_soc_component_write(component, MAX9850_CLOCK, 0x8); |
182 | else | 182 | else |
183 | return -EINVAL; | 183 | return -EINVAL; |
184 | 184 | ||
@@ -188,7 +188,7 @@ static int max9850_set_dai_sysclk(struct snd_soc_dai *codec_dai, | |||
188 | 188 | ||
189 | static int max9850_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) | 189 | static int max9850_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) |
190 | { | 190 | { |
191 | struct snd_soc_codec *codec = codec_dai->codec; | 191 | struct snd_soc_component *component = codec_dai->component; |
192 | u8 da = 0; | 192 | u8 da = 0; |
193 | 193 | ||
194 | /* set master/slave audio interface */ | 194 | /* set master/slave audio interface */ |
@@ -234,15 +234,15 @@ static int max9850_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) | |||
234 | } | 234 | } |
235 | 235 | ||
236 | /* set da */ | 236 | /* set da */ |
237 | snd_soc_write(codec, MAX9850_DIGITAL_AUDIO, da); | 237 | snd_soc_component_write(component, MAX9850_DIGITAL_AUDIO, da); |
238 | 238 | ||
239 | return 0; | 239 | return 0; |
240 | } | 240 | } |
241 | 241 | ||
242 | static int max9850_set_bias_level(struct snd_soc_codec *codec, | 242 | static int max9850_set_bias_level(struct snd_soc_component *component, |
243 | enum snd_soc_bias_level level) | 243 | enum snd_soc_bias_level level) |
244 | { | 244 | { |
245 | struct max9850_priv *max9850 = snd_soc_codec_get_drvdata(codec); | 245 | struct max9850_priv *max9850 = snd_soc_component_get_drvdata(component); |
246 | int ret; | 246 | int ret; |
247 | 247 | ||
248 | switch (level) { | 248 | switch (level) { |
@@ -251,10 +251,10 @@ static int max9850_set_bias_level(struct snd_soc_codec *codec, | |||
251 | case SND_SOC_BIAS_PREPARE: | 251 | case SND_SOC_BIAS_PREPARE: |
252 | break; | 252 | break; |
253 | case SND_SOC_BIAS_STANDBY: | 253 | case SND_SOC_BIAS_STANDBY: |
254 | if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) { | 254 | if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { |
255 | ret = regcache_sync(max9850->regmap); | 255 | ret = regcache_sync(max9850->regmap); |
256 | if (ret) { | 256 | if (ret) { |
257 | dev_err(codec->dev, | 257 | dev_err(component->dev, |
258 | "Failed to sync cache: %d\n", ret); | 258 | "Failed to sync cache: %d\n", ret); |
259 | return ret; | 259 | return ret; |
260 | } | 260 | } |
@@ -289,31 +289,32 @@ static struct snd_soc_dai_driver max9850_dai = { | |||
289 | .ops = &max9850_dai_ops, | 289 | .ops = &max9850_dai_ops, |
290 | }; | 290 | }; |
291 | 291 | ||
292 | static int max9850_probe(struct snd_soc_codec *codec) | 292 | static int max9850_probe(struct snd_soc_component *component) |
293 | { | 293 | { |
294 | /* enable zero-detect */ | 294 | /* enable zero-detect */ |
295 | snd_soc_update_bits(codec, MAX9850_GENERAL_PURPOSE, 1, 1); | 295 | snd_soc_component_update_bits(component, MAX9850_GENERAL_PURPOSE, 1, 1); |
296 | /* enable slew-rate control */ | 296 | /* enable slew-rate control */ |
297 | snd_soc_update_bits(codec, MAX9850_VOLUME, 0x40, 0x40); | 297 | snd_soc_component_update_bits(component, MAX9850_VOLUME, 0x40, 0x40); |
298 | /* set slew-rate 125ms */ | 298 | /* set slew-rate 125ms */ |
299 | snd_soc_update_bits(codec, MAX9850_CHARGE_PUMP, 0xff, 0xc0); | 299 | snd_soc_component_update_bits(component, MAX9850_CHARGE_PUMP, 0xff, 0xc0); |
300 | 300 | ||
301 | return 0; | 301 | return 0; |
302 | } | 302 | } |
303 | 303 | ||
304 | static const struct snd_soc_codec_driver soc_codec_dev_max9850 = { | 304 | static const struct snd_soc_component_driver soc_component_dev_max9850 = { |
305 | .probe = max9850_probe, | 305 | .probe = max9850_probe, |
306 | .set_bias_level = max9850_set_bias_level, | 306 | .set_bias_level = max9850_set_bias_level, |
307 | .suspend_bias_off = true, | 307 | .controls = max9850_controls, |
308 | 308 | .num_controls = ARRAY_SIZE(max9850_controls), | |
309 | .component_driver = { | 309 | .dapm_widgets = max9850_dapm_widgets, |
310 | .controls = max9850_controls, | 310 | .num_dapm_widgets = ARRAY_SIZE(max9850_dapm_widgets), |
311 | .num_controls = ARRAY_SIZE(max9850_controls), | 311 | .dapm_routes = max9850_dapm_routes, |
312 | .dapm_widgets = max9850_dapm_widgets, | 312 | .num_dapm_routes = ARRAY_SIZE(max9850_dapm_routes), |
313 | .num_dapm_widgets = ARRAY_SIZE(max9850_dapm_widgets), | 313 | .suspend_bias_off = 1, |
314 | .dapm_routes = max9850_dapm_routes, | 314 | .idle_bias_on = 1, |
315 | .num_dapm_routes = ARRAY_SIZE(max9850_dapm_routes), | 315 | .use_pmdown_time = 1, |
316 | }, | 316 | .endianness = 1, |
317 | .non_legacy_dai_naming = 1, | ||
317 | }; | 318 | }; |
318 | 319 | ||
319 | static int max9850_i2c_probe(struct i2c_client *i2c, | 320 | static int max9850_i2c_probe(struct i2c_client *i2c, |
@@ -333,17 +334,11 @@ static int max9850_i2c_probe(struct i2c_client *i2c, | |||
333 | 334 | ||
334 | i2c_set_clientdata(i2c, max9850); | 335 | i2c_set_clientdata(i2c, max9850); |
335 | 336 | ||
336 | ret = snd_soc_register_codec(&i2c->dev, | 337 | ret = devm_snd_soc_register_component(&i2c->dev, |
337 | &soc_codec_dev_max9850, &max9850_dai, 1); | 338 | &soc_component_dev_max9850, &max9850_dai, 1); |
338 | return ret; | 339 | return ret; |
339 | } | 340 | } |
340 | 341 | ||
341 | static int max9850_i2c_remove(struct i2c_client *client) | ||
342 | { | ||
343 | snd_soc_unregister_codec(&client->dev); | ||
344 | return 0; | ||
345 | } | ||
346 | |||
347 | static const struct i2c_device_id max9850_i2c_id[] = { | 342 | static const struct i2c_device_id max9850_i2c_id[] = { |
348 | { "max9850", 0 }, | 343 | { "max9850", 0 }, |
349 | { } | 344 | { } |
@@ -355,7 +350,6 @@ static struct i2c_driver max9850_i2c_driver = { | |||
355 | .name = "max9850", | 350 | .name = "max9850", |
356 | }, | 351 | }, |
357 | .probe = max9850_i2c_probe, | 352 | .probe = max9850_i2c_probe, |
358 | .remove = max9850_i2c_remove, | ||
359 | .id_table = max9850_i2c_id, | 353 | .id_table = max9850_i2c_id, |
360 | }; | 354 | }; |
361 | 355 | ||