diff options
author | Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> | 2018-01-28 22:13:07 -0500 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2018-02-12 04:45:04 -0500 |
commit | 43c5d0f05ec55aa71680744ffcaa1aa6fd8a9bab (patch) | |
tree | 6b865e1fcd4e75b6d42a572fe793505cac2ce0c9 | |
parent | 7928b2cbe55b2a410a0f5c1f154610059c57b1b2 (diff) |
ASoC: ak4642: 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/ak4642.c | 105 |
1 files changed, 50 insertions, 55 deletions
diff --git a/sound/soc/codecs/ak4642.c b/sound/soc/codecs/ak4642.c index 29530c567bd9..9c35e91d412d 100644 --- a/sound/soc/codecs/ak4642.c +++ b/sound/soc/codecs/ak4642.c | |||
@@ -178,19 +178,19 @@ static const struct snd_kcontrol_new ak4642_lout_mixer_controls[] = { | |||
178 | static int ak4642_lout_event(struct snd_soc_dapm_widget *w, | 178 | static int ak4642_lout_event(struct snd_soc_dapm_widget *w, |
179 | struct snd_kcontrol *kcontrol, int event) | 179 | struct snd_kcontrol *kcontrol, int event) |
180 | { | 180 | { |
181 | struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); | 181 | struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); |
182 | 182 | ||
183 | switch (event) { | 183 | switch (event) { |
184 | case SND_SOC_DAPM_PRE_PMD: | 184 | case SND_SOC_DAPM_PRE_PMD: |
185 | case SND_SOC_DAPM_PRE_PMU: | 185 | case SND_SOC_DAPM_PRE_PMU: |
186 | /* Power save mode ON */ | 186 | /* Power save mode ON */ |
187 | snd_soc_update_bits(codec, SG_SL2, LOPS, LOPS); | 187 | snd_soc_component_update_bits(component, SG_SL2, LOPS, LOPS); |
188 | break; | 188 | break; |
189 | case SND_SOC_DAPM_POST_PMU: | 189 | case SND_SOC_DAPM_POST_PMU: |
190 | case SND_SOC_DAPM_POST_PMD: | 190 | case SND_SOC_DAPM_POST_PMD: |
191 | /* Power save mode OFF */ | 191 | /* Power save mode OFF */ |
192 | msleep(300); | 192 | msleep(300); |
193 | snd_soc_update_bits(codec, SG_SL2, LOPS, 0); | 193 | snd_soc_component_update_bits(component, SG_SL2, LOPS, 0); |
194 | break; | 194 | break; |
195 | } | 195 | } |
196 | 196 | ||
@@ -282,7 +282,7 @@ static int ak4642_dai_startup(struct snd_pcm_substream *substream, | |||
282 | struct snd_soc_dai *dai) | 282 | struct snd_soc_dai *dai) |
283 | { | 283 | { |
284 | int is_play = substream->stream == SNDRV_PCM_STREAM_PLAYBACK; | 284 | int is_play = substream->stream == SNDRV_PCM_STREAM_PLAYBACK; |
285 | struct snd_soc_codec *codec = dai->codec; | 285 | struct snd_soc_component *component = dai->component; |
286 | 286 | ||
287 | if (is_play) { | 287 | if (is_play) { |
288 | /* | 288 | /* |
@@ -295,8 +295,8 @@ static int ak4642_dai_startup(struct snd_pcm_substream *substream, | |||
295 | * This operation came from example code of | 295 | * This operation came from example code of |
296 | * "ASAHI KASEI AK4642" (japanese) manual p97. | 296 | * "ASAHI KASEI AK4642" (japanese) manual p97. |
297 | */ | 297 | */ |
298 | snd_soc_write(codec, L_IVC, 0x91); /* volume */ | 298 | snd_soc_component_write(component, L_IVC, 0x91); /* volume */ |
299 | snd_soc_write(codec, R_IVC, 0x91); /* volume */ | 299 | snd_soc_component_write(component, R_IVC, 0x91); /* volume */ |
300 | } else { | 300 | } else { |
301 | /* | 301 | /* |
302 | * start stereo input | 302 | * start stereo input |
@@ -311,11 +311,11 @@ static int ak4642_dai_startup(struct snd_pcm_substream *substream, | |||
311 | * This operation came from example code of | 311 | * This operation came from example code of |
312 | * "ASAHI KASEI AK4642" (japanese) manual p94. | 312 | * "ASAHI KASEI AK4642" (japanese) manual p94. |
313 | */ | 313 | */ |
314 | snd_soc_update_bits(codec, SG_SL1, PMMP | MGAIN0, PMMP | MGAIN0); | 314 | snd_soc_component_update_bits(component, SG_SL1, PMMP | MGAIN0, PMMP | MGAIN0); |
315 | snd_soc_write(codec, TIMER, ZTM(0x3) | WTM(0x3)); | 315 | snd_soc_component_write(component, TIMER, ZTM(0x3) | WTM(0x3)); |
316 | snd_soc_write(codec, ALC_CTL1, ALC | LMTH0); | 316 | snd_soc_component_write(component, ALC_CTL1, ALC | LMTH0); |
317 | snd_soc_update_bits(codec, PW_MGMT1, PMADL, PMADL); | 317 | snd_soc_component_update_bits(component, PW_MGMT1, PMADL, PMADL); |
318 | snd_soc_update_bits(codec, PW_MGMT3, PMADR, PMADR); | 318 | snd_soc_component_update_bits(component, PW_MGMT3, PMADR, PMADR); |
319 | } | 319 | } |
320 | 320 | ||
321 | return 0; | 321 | return 0; |
@@ -325,22 +325,22 @@ static void ak4642_dai_shutdown(struct snd_pcm_substream *substream, | |||
325 | struct snd_soc_dai *dai) | 325 | struct snd_soc_dai *dai) |
326 | { | 326 | { |
327 | int is_play = substream->stream == SNDRV_PCM_STREAM_PLAYBACK; | 327 | int is_play = substream->stream == SNDRV_PCM_STREAM_PLAYBACK; |
328 | struct snd_soc_codec *codec = dai->codec; | 328 | struct snd_soc_component *component = dai->component; |
329 | 329 | ||
330 | if (is_play) { | 330 | if (is_play) { |
331 | } else { | 331 | } else { |
332 | /* stop stereo input */ | 332 | /* stop stereo input */ |
333 | snd_soc_update_bits(codec, PW_MGMT1, PMADL, 0); | 333 | snd_soc_component_update_bits(component, PW_MGMT1, PMADL, 0); |
334 | snd_soc_update_bits(codec, PW_MGMT3, PMADR, 0); | 334 | snd_soc_component_update_bits(component, PW_MGMT3, PMADR, 0); |
335 | snd_soc_update_bits(codec, ALC_CTL1, ALC, 0); | 335 | snd_soc_component_update_bits(component, ALC_CTL1, ALC, 0); |
336 | } | 336 | } |
337 | } | 337 | } |
338 | 338 | ||
339 | static int ak4642_dai_set_sysclk(struct snd_soc_dai *codec_dai, | 339 | static int ak4642_dai_set_sysclk(struct snd_soc_dai *codec_dai, |
340 | int clk_id, unsigned int freq, int dir) | 340 | int clk_id, unsigned int freq, int dir) |
341 | { | 341 | { |
342 | struct snd_soc_codec *codec = codec_dai->codec; | 342 | struct snd_soc_component *component = codec_dai->component; |
343 | struct ak4642_priv *priv = snd_soc_codec_get_drvdata(codec); | 343 | struct ak4642_priv *priv = snd_soc_component_get_drvdata(component); |
344 | u8 pll; | 344 | u8 pll; |
345 | int extended_freq = 0; | 345 | int extended_freq = 0; |
346 | 346 | ||
@@ -382,14 +382,14 @@ static int ak4642_dai_set_sysclk(struct snd_soc_dai *codec_dai, | |||
382 | if (extended_freq && !priv->drvdata->extended_frequencies) | 382 | if (extended_freq && !priv->drvdata->extended_frequencies) |
383 | return -EINVAL; | 383 | return -EINVAL; |
384 | 384 | ||
385 | snd_soc_update_bits(codec, MD_CTL1, PLL_MASK, pll); | 385 | snd_soc_component_update_bits(component, MD_CTL1, PLL_MASK, pll); |
386 | 386 | ||
387 | return 0; | 387 | return 0; |
388 | } | 388 | } |
389 | 389 | ||
390 | static int ak4642_dai_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) | 390 | static int ak4642_dai_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) |
391 | { | 391 | { |
392 | struct snd_soc_codec *codec = dai->codec; | 392 | struct snd_soc_component *component = dai->component; |
393 | u8 data; | 393 | u8 data; |
394 | u8 bcko; | 394 | u8 bcko; |
395 | 395 | ||
@@ -407,8 +407,8 @@ static int ak4642_dai_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) | |||
407 | default: | 407 | default: |
408 | return -EINVAL; | 408 | return -EINVAL; |
409 | } | 409 | } |
410 | snd_soc_update_bits(codec, PW_MGMT2, MS | MCKO | PMPLL, data); | 410 | snd_soc_component_update_bits(component, PW_MGMT2, MS | MCKO | PMPLL, data); |
411 | snd_soc_update_bits(codec, MD_CTL1, BCKO_MASK, bcko); | 411 | snd_soc_component_update_bits(component, MD_CTL1, BCKO_MASK, bcko); |
412 | 412 | ||
413 | /* format type */ | 413 | /* format type */ |
414 | data = 0; | 414 | data = 0; |
@@ -425,12 +425,12 @@ static int ak4642_dai_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) | |||
425 | default: | 425 | default: |
426 | return -EINVAL; | 426 | return -EINVAL; |
427 | } | 427 | } |
428 | snd_soc_update_bits(codec, MD_CTL1, DIF_MASK, data); | 428 | snd_soc_component_update_bits(component, MD_CTL1, DIF_MASK, data); |
429 | 429 | ||
430 | return 0; | 430 | return 0; |
431 | } | 431 | } |
432 | 432 | ||
433 | static int ak4642_set_mcko(struct snd_soc_codec *codec, | 433 | static int ak4642_set_mcko(struct snd_soc_component *component, |
434 | u32 frequency) | 434 | u32 frequency) |
435 | { | 435 | { |
436 | static const u32 fs_list[] = { | 436 | static const u32 fs_list[] = { |
@@ -458,7 +458,7 @@ static int ak4642_set_mcko(struct snd_soc_codec *codec, | |||
458 | for (ps = 0; ps < ARRAY_SIZE(ps_list); ps++) { | 458 | for (ps = 0; ps < ARRAY_SIZE(ps_list); ps++) { |
459 | for (fs = 0; fs < ARRAY_SIZE(fs_list); fs++) { | 459 | for (fs = 0; fs < ARRAY_SIZE(fs_list); fs++) { |
460 | if (frequency == ps_list[ps] * fs_list[fs]) { | 460 | if (frequency == ps_list[ps] * fs_list[fs]) { |
461 | snd_soc_write(codec, MD_CTL2, | 461 | snd_soc_component_write(component, MD_CTL2, |
462 | PSs(ps) | FSs(fs)); | 462 | PSs(ps) | FSs(fs)); |
463 | return 0; | 463 | return 0; |
464 | } | 464 | } |
@@ -472,25 +472,25 @@ static int ak4642_dai_hw_params(struct snd_pcm_substream *substream, | |||
472 | struct snd_pcm_hw_params *params, | 472 | struct snd_pcm_hw_params *params, |
473 | struct snd_soc_dai *dai) | 473 | struct snd_soc_dai *dai) |
474 | { | 474 | { |
475 | struct snd_soc_codec *codec = dai->codec; | 475 | struct snd_soc_component *component = dai->component; |
476 | struct ak4642_priv *priv = snd_soc_codec_get_drvdata(codec); | 476 | struct ak4642_priv *priv = snd_soc_component_get_drvdata(component); |
477 | u32 rate = clk_get_rate(priv->mcko); | 477 | u32 rate = clk_get_rate(priv->mcko); |
478 | 478 | ||
479 | if (!rate) | 479 | if (!rate) |
480 | rate = params_rate(params) * 256; | 480 | rate = params_rate(params) * 256; |
481 | 481 | ||
482 | return ak4642_set_mcko(codec, rate); | 482 | return ak4642_set_mcko(component, rate); |
483 | } | 483 | } |
484 | 484 | ||
485 | static int ak4642_set_bias_level(struct snd_soc_codec *codec, | 485 | static int ak4642_set_bias_level(struct snd_soc_component *component, |
486 | enum snd_soc_bias_level level) | 486 | enum snd_soc_bias_level level) |
487 | { | 487 | { |
488 | switch (level) { | 488 | switch (level) { |
489 | case SND_SOC_BIAS_OFF: | 489 | case SND_SOC_BIAS_OFF: |
490 | snd_soc_write(codec, PW_MGMT1, 0x00); | 490 | snd_soc_component_write(component, PW_MGMT1, 0x00); |
491 | break; | 491 | break; |
492 | default: | 492 | default: |
493 | snd_soc_update_bits(codec, PW_MGMT1, PMVCM, PMVCM); | 493 | snd_soc_component_update_bits(component, PW_MGMT1, PMVCM, PMVCM); |
494 | break; | 494 | break; |
495 | } | 495 | } |
496 | 496 | ||
@@ -523,46 +523,48 @@ static struct snd_soc_dai_driver ak4642_dai = { | |||
523 | .symmetric_rates = 1, | 523 | .symmetric_rates = 1, |
524 | }; | 524 | }; |
525 | 525 | ||
526 | static int ak4642_suspend(struct snd_soc_codec *codec) | 526 | static int ak4642_suspend(struct snd_soc_component *component) |
527 | { | 527 | { |
528 | struct regmap *regmap = dev_get_regmap(codec->dev, NULL); | 528 | struct regmap *regmap = dev_get_regmap(component->dev, NULL); |
529 | 529 | ||
530 | regcache_cache_only(regmap, true); | 530 | regcache_cache_only(regmap, true); |
531 | regcache_mark_dirty(regmap); | 531 | regcache_mark_dirty(regmap); |
532 | return 0; | 532 | return 0; |
533 | } | 533 | } |
534 | 534 | ||
535 | static int ak4642_resume(struct snd_soc_codec *codec) | 535 | static int ak4642_resume(struct snd_soc_component *component) |
536 | { | 536 | { |
537 | struct regmap *regmap = dev_get_regmap(codec->dev, NULL); | 537 | struct regmap *regmap = dev_get_regmap(component->dev, NULL); |
538 | 538 | ||
539 | regcache_cache_only(regmap, false); | 539 | regcache_cache_only(regmap, false); |
540 | regcache_sync(regmap); | 540 | regcache_sync(regmap); |
541 | return 0; | 541 | return 0; |
542 | } | 542 | } |
543 | static int ak4642_probe(struct snd_soc_codec *codec) | 543 | static int ak4642_probe(struct snd_soc_component *component) |
544 | { | 544 | { |
545 | struct ak4642_priv *priv = snd_soc_codec_get_drvdata(codec); | 545 | struct ak4642_priv *priv = snd_soc_component_get_drvdata(component); |
546 | 546 | ||
547 | if (priv->mcko) | 547 | if (priv->mcko) |
548 | ak4642_set_mcko(codec, clk_get_rate(priv->mcko)); | 548 | ak4642_set_mcko(component, clk_get_rate(priv->mcko)); |
549 | 549 | ||
550 | return 0; | 550 | return 0; |
551 | } | 551 | } |
552 | 552 | ||
553 | static const struct snd_soc_codec_driver soc_codec_dev_ak4642 = { | 553 | static const struct snd_soc_component_driver soc_component_dev_ak4642 = { |
554 | .probe = ak4642_probe, | 554 | .probe = ak4642_probe, |
555 | .suspend = ak4642_suspend, | 555 | .suspend = ak4642_suspend, |
556 | .resume = ak4642_resume, | 556 | .resume = ak4642_resume, |
557 | .set_bias_level = ak4642_set_bias_level, | 557 | .set_bias_level = ak4642_set_bias_level, |
558 | .component_driver = { | 558 | .controls = ak4642_snd_controls, |
559 | .controls = ak4642_snd_controls, | 559 | .num_controls = ARRAY_SIZE(ak4642_snd_controls), |
560 | .num_controls = ARRAY_SIZE(ak4642_snd_controls), | 560 | .dapm_widgets = ak4642_dapm_widgets, |
561 | .dapm_widgets = ak4642_dapm_widgets, | 561 | .num_dapm_widgets = ARRAY_SIZE(ak4642_dapm_widgets), |
562 | .num_dapm_widgets = ARRAY_SIZE(ak4642_dapm_widgets), | 562 | .dapm_routes = ak4642_intercon, |
563 | .dapm_routes = ak4642_intercon, | 563 | .num_dapm_routes = ARRAY_SIZE(ak4642_intercon), |
564 | .num_dapm_routes = ARRAY_SIZE(ak4642_intercon), | 564 | .idle_bias_on = 1, |
565 | }, | 565 | .use_pmdown_time = 1, |
566 | .endianness = 1, | ||
567 | .non_legacy_dai_naming = 1, | ||
566 | }; | 568 | }; |
567 | 569 | ||
568 | static const struct regmap_config ak4642_regmap = { | 570 | static const struct regmap_config ak4642_regmap = { |
@@ -675,14 +677,8 @@ static int ak4642_i2c_probe(struct i2c_client *i2c, | |||
675 | if (IS_ERR(regmap)) | 677 | if (IS_ERR(regmap)) |
676 | return PTR_ERR(regmap); | 678 | return PTR_ERR(regmap); |
677 | 679 | ||
678 | return snd_soc_register_codec(dev, | 680 | return devm_snd_soc_register_component(dev, |
679 | &soc_codec_dev_ak4642, &ak4642_dai, 1); | 681 | &soc_component_dev_ak4642, &ak4642_dai, 1); |
680 | } | ||
681 | |||
682 | static int ak4642_i2c_remove(struct i2c_client *client) | ||
683 | { | ||
684 | snd_soc_unregister_codec(&client->dev); | ||
685 | return 0; | ||
686 | } | 682 | } |
687 | 683 | ||
688 | static const struct of_device_id ak4642_of_match[] = { | 684 | static const struct of_device_id ak4642_of_match[] = { |
@@ -707,7 +703,6 @@ static struct i2c_driver ak4642_i2c_driver = { | |||
707 | .of_match_table = ak4642_of_match, | 703 | .of_match_table = ak4642_of_match, |
708 | }, | 704 | }, |
709 | .probe = ak4642_i2c_probe, | 705 | .probe = ak4642_i2c_probe, |
710 | .remove = ak4642_i2c_remove, | ||
711 | .id_table = ak4642_i2c_id, | 706 | .id_table = ak4642_i2c_id, |
712 | }; | 707 | }; |
713 | 708 | ||