aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKuninori Morimoto <kuninori.morimoto.gx@renesas.com>2018-01-28 22:06:22 -0500
committerMark Brown <broonie@kernel.org>2018-02-12 04:41:55 -0500
commit58a6597ea0e6f310e568c0db6224b586a5bf7c7c (patch)
tree6708762746708a2e99c004e9bd9b11e011ace43f
parent7928b2cbe55b2a410a0f5c1f154610059c57b1b2 (diff)
ASoC: wm8971: 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/wm8971.c108
1 files changed, 51 insertions, 57 deletions
diff --git a/sound/soc/codecs/wm8971.c b/sound/soc/codecs/wm8971.c
index 887d31cf3945..a79f7a7ab44b 100644
--- a/sound/soc/codecs/wm8971.c
+++ b/sound/soc/codecs/wm8971.c
@@ -89,7 +89,7 @@ static const struct reg_default wm8971_reg_defaults[] = {
89 { 42, 0x0079 }, 89 { 42, 0x0079 },
90}; 90};
91 91
92#define wm8971_reset(c) snd_soc_write(c, WM8971_RESET, 0) 92#define wm8971_reset(c) snd_soc_component_write(c, WM8971_RESET, 0)
93 93
94/* WM8971 Controls */ 94/* WM8971 Controls */
95static const char *wm8971_bass[] = { "Linear Control", "Adaptive Boost" }; 95static const char *wm8971_bass[] = { "Linear Control", "Adaptive Boost" };
@@ -433,8 +433,8 @@ static int get_coeff(int mclk, int rate)
433static int wm8971_set_dai_sysclk(struct snd_soc_dai *codec_dai, 433static int wm8971_set_dai_sysclk(struct snd_soc_dai *codec_dai,
434 int clk_id, unsigned int freq, int dir) 434 int clk_id, unsigned int freq, int dir)
435{ 435{
436 struct snd_soc_codec *codec = codec_dai->codec; 436 struct snd_soc_component *component = codec_dai->component;
437 struct wm8971_priv *wm8971 = snd_soc_codec_get_drvdata(codec); 437 struct wm8971_priv *wm8971 = snd_soc_component_get_drvdata(component);
438 438
439 switch (freq) { 439 switch (freq) {
440 case 11289600: 440 case 11289600:
@@ -451,7 +451,7 @@ static int wm8971_set_dai_sysclk(struct snd_soc_dai *codec_dai,
451static int wm8971_set_dai_fmt(struct snd_soc_dai *codec_dai, 451static int wm8971_set_dai_fmt(struct snd_soc_dai *codec_dai,
452 unsigned int fmt) 452 unsigned int fmt)
453{ 453{
454 struct snd_soc_codec *codec = codec_dai->codec; 454 struct snd_soc_component *component = codec_dai->component;
455 u16 iface = 0; 455 u16 iface = 0;
456 456
457 /* set master/slave audio interface */ 457 /* set master/slave audio interface */
@@ -502,7 +502,7 @@ static int wm8971_set_dai_fmt(struct snd_soc_dai *codec_dai,
502 return -EINVAL; 502 return -EINVAL;
503 } 503 }
504 504
505 snd_soc_write(codec, WM8971_IFACE, iface); 505 snd_soc_component_write(component, WM8971_IFACE, iface);
506 return 0; 506 return 0;
507} 507}
508 508
@@ -510,10 +510,10 @@ static int wm8971_pcm_hw_params(struct snd_pcm_substream *substream,
510 struct snd_pcm_hw_params *params, 510 struct snd_pcm_hw_params *params,
511 struct snd_soc_dai *dai) 511 struct snd_soc_dai *dai)
512{ 512{
513 struct snd_soc_codec *codec = dai->codec; 513 struct snd_soc_component *component = dai->component;
514 struct wm8971_priv *wm8971 = snd_soc_codec_get_drvdata(codec); 514 struct wm8971_priv *wm8971 = snd_soc_component_get_drvdata(component);
515 u16 iface = snd_soc_read(codec, WM8971_IFACE) & 0x1f3; 515 u16 iface = snd_soc_component_read32(component, WM8971_IFACE) & 0x1f3;
516 u16 srate = snd_soc_read(codec, WM8971_SRATE) & 0x1c0; 516 u16 srate = snd_soc_component_read32(component, WM8971_SRATE) & 0x1c0;
517 int coeff = get_coeff(wm8971->sysclk, params_rate(params)); 517 int coeff = get_coeff(wm8971->sysclk, params_rate(params));
518 518
519 /* bit size */ 519 /* bit size */
@@ -532,9 +532,9 @@ static int wm8971_pcm_hw_params(struct snd_pcm_substream *substream,
532 } 532 }
533 533
534 /* set iface & srate */ 534 /* set iface & srate */
535 snd_soc_write(codec, WM8971_IFACE, iface); 535 snd_soc_component_write(component, WM8971_IFACE, iface);
536 if (coeff >= 0) 536 if (coeff >= 0)
537 snd_soc_write(codec, WM8971_SRATE, srate | 537 snd_soc_component_write(component, WM8971_SRATE, srate |
538 (coeff_div[coeff].sr << 1) | coeff_div[coeff].usb); 538 (coeff_div[coeff].sr << 1) | coeff_div[coeff].usb);
539 539
540 return 0; 540 return 0;
@@ -542,13 +542,13 @@ static int wm8971_pcm_hw_params(struct snd_pcm_substream *substream,
542 542
543static int wm8971_mute(struct snd_soc_dai *dai, int mute) 543static int wm8971_mute(struct snd_soc_dai *dai, int mute)
544{ 544{
545 struct snd_soc_codec *codec = dai->codec; 545 struct snd_soc_component *component = dai->component;
546 u16 mute_reg = snd_soc_read(codec, WM8971_ADCDAC) & 0xfff7; 546 u16 mute_reg = snd_soc_component_read32(component, WM8971_ADCDAC) & 0xfff7;
547 547
548 if (mute) 548 if (mute)
549 snd_soc_write(codec, WM8971_ADCDAC, mute_reg | 0x8); 549 snd_soc_component_write(component, WM8971_ADCDAC, mute_reg | 0x8);
550 else 550 else
551 snd_soc_write(codec, WM8971_ADCDAC, mute_reg); 551 snd_soc_component_write(component, WM8971_ADCDAC, mute_reg);
552 return 0; 552 return 0;
553} 553}
554 554
@@ -561,37 +561,37 @@ static void wm8971_charge_work(struct work_struct *work)
561 regmap_update_bits(wm8971->regmap, WM8971_PWR1, 0x0180, 0x0100); 561 regmap_update_bits(wm8971->regmap, WM8971_PWR1, 0x0180, 0x0100);
562} 562}
563 563
564static int wm8971_set_bias_level(struct snd_soc_codec *codec, 564static int wm8971_set_bias_level(struct snd_soc_component *component,
565 enum snd_soc_bias_level level) 565 enum snd_soc_bias_level level)
566{ 566{
567 struct wm8971_priv *wm8971 = snd_soc_codec_get_drvdata(codec); 567 struct wm8971_priv *wm8971 = snd_soc_component_get_drvdata(component);
568 u16 pwr_reg = snd_soc_read(codec, WM8971_PWR1) & 0xfe3e; 568 u16 pwr_reg = snd_soc_component_read32(component, WM8971_PWR1) & 0xfe3e;
569 569
570 switch (level) { 570 switch (level) {
571 case SND_SOC_BIAS_ON: 571 case SND_SOC_BIAS_ON:
572 /* set vmid to 50k and unmute dac */ 572 /* set vmid to 50k and unmute dac */
573 snd_soc_write(codec, WM8971_PWR1, pwr_reg | 0x00c1); 573 snd_soc_component_write(component, WM8971_PWR1, pwr_reg | 0x00c1);
574 break; 574 break;
575 case SND_SOC_BIAS_PREPARE: 575 case SND_SOC_BIAS_PREPARE:
576 /* Wait until fully charged */ 576 /* Wait until fully charged */
577 flush_delayed_work(&wm8971->charge_work); 577 flush_delayed_work(&wm8971->charge_work);
578 break; 578 break;
579 case SND_SOC_BIAS_STANDBY: 579 case SND_SOC_BIAS_STANDBY:
580 if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) { 580 if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) {
581 snd_soc_cache_sync(codec); 581 snd_soc_component_cache_sync(component);
582 /* charge output caps - set vmid to 5k for quick power up */ 582 /* charge output caps - set vmid to 5k for quick power up */
583 snd_soc_write(codec, WM8971_PWR1, pwr_reg | 0x01c0); 583 snd_soc_component_write(component, WM8971_PWR1, pwr_reg | 0x01c0);
584 queue_delayed_work(system_power_efficient_wq, 584 queue_delayed_work(system_power_efficient_wq,
585 &wm8971->charge_work, msecs_to_jiffies(1000)); 585 &wm8971->charge_work, msecs_to_jiffies(1000));
586 } else { 586 } else {
587 /* mute dac and set vmid to 500k, enable VREF */ 587 /* mute dac and set vmid to 500k, enable VREF */
588 snd_soc_write(codec, WM8971_PWR1, pwr_reg | 0x0140); 588 snd_soc_component_write(component, WM8971_PWR1, pwr_reg | 0x0140);
589 } 589 }
590 590
591 break; 591 break;
592 case SND_SOC_BIAS_OFF: 592 case SND_SOC_BIAS_OFF:
593 cancel_delayed_work_sync(&wm8971->charge_work); 593 cancel_delayed_work_sync(&wm8971->charge_work);
594 snd_soc_write(codec, WM8971_PWR1, 0x0001); 594 snd_soc_component_write(component, WM8971_PWR1, 0x0001);
595 break; 595 break;
596 } 596 }
597 return 0; 597 return 0;
@@ -628,40 +628,41 @@ static struct snd_soc_dai_driver wm8971_dai = {
628 .ops = &wm8971_dai_ops, 628 .ops = &wm8971_dai_ops,
629}; 629};
630 630
631static int wm8971_probe(struct snd_soc_codec *codec) 631static int wm8971_probe(struct snd_soc_component *component)
632{ 632{
633 struct wm8971_priv *wm8971 = snd_soc_codec_get_drvdata(codec); 633 struct wm8971_priv *wm8971 = snd_soc_component_get_drvdata(component);
634 634
635 INIT_DELAYED_WORK(&wm8971->charge_work, wm8971_charge_work); 635 INIT_DELAYED_WORK(&wm8971->charge_work, wm8971_charge_work);
636 636
637 wm8971_reset(codec); 637 wm8971_reset(component);
638 638
639 /* set the update bits */ 639 /* set the update bits */
640 snd_soc_update_bits(codec, WM8971_LDAC, 0x0100, 0x0100); 640 snd_soc_component_update_bits(component, WM8971_LDAC, 0x0100, 0x0100);
641 snd_soc_update_bits(codec, WM8971_RDAC, 0x0100, 0x0100); 641 snd_soc_component_update_bits(component, WM8971_RDAC, 0x0100, 0x0100);
642 snd_soc_update_bits(codec, WM8971_LOUT1V, 0x0100, 0x0100); 642 snd_soc_component_update_bits(component, WM8971_LOUT1V, 0x0100, 0x0100);
643 snd_soc_update_bits(codec, WM8971_ROUT1V, 0x0100, 0x0100); 643 snd_soc_component_update_bits(component, WM8971_ROUT1V, 0x0100, 0x0100);
644 snd_soc_update_bits(codec, WM8971_LOUT2V, 0x0100, 0x0100); 644 snd_soc_component_update_bits(component, WM8971_LOUT2V, 0x0100, 0x0100);
645 snd_soc_update_bits(codec, WM8971_ROUT2V, 0x0100, 0x0100); 645 snd_soc_component_update_bits(component, WM8971_ROUT2V, 0x0100, 0x0100);
646 snd_soc_update_bits(codec, WM8971_LINVOL, 0x0100, 0x0100); 646 snd_soc_component_update_bits(component, WM8971_LINVOL, 0x0100, 0x0100);
647 snd_soc_update_bits(codec, WM8971_RINVOL, 0x0100, 0x0100); 647 snd_soc_component_update_bits(component, WM8971_RINVOL, 0x0100, 0x0100);
648 648
649 return 0; 649 return 0;
650} 650}
651 651
652static const struct snd_soc_codec_driver soc_codec_dev_wm8971 = { 652static const struct snd_soc_component_driver soc_component_dev_wm8971 = {
653 .probe = wm8971_probe, 653 .probe = wm8971_probe,
654 .set_bias_level = wm8971_set_bias_level, 654 .set_bias_level = wm8971_set_bias_level,
655 .suspend_bias_off = true, 655 .controls = wm8971_snd_controls,
656 656 .num_controls = ARRAY_SIZE(wm8971_snd_controls),
657 .component_driver = { 657 .dapm_widgets = wm8971_dapm_widgets,
658 .controls = wm8971_snd_controls, 658 .num_dapm_widgets = ARRAY_SIZE(wm8971_dapm_widgets),
659 .num_controls = ARRAY_SIZE(wm8971_snd_controls), 659 .dapm_routes = wm8971_dapm_routes,
660 .dapm_widgets = wm8971_dapm_widgets, 660 .num_dapm_routes = ARRAY_SIZE(wm8971_dapm_routes),
661 .num_dapm_widgets = ARRAY_SIZE(wm8971_dapm_widgets), 661 .suspend_bias_off = 1,
662 .dapm_routes = wm8971_dapm_routes, 662 .idle_bias_on = 1,
663 .num_dapm_routes = ARRAY_SIZE(wm8971_dapm_routes), 663 .use_pmdown_time = 1,
664 }, 664 .endianness = 1,
665 .non_legacy_dai_naming = 1,
665}; 666};
666 667
667static const struct regmap_config wm8971_regmap = { 668static const struct regmap_config wm8971_regmap = {
@@ -691,18 +692,12 @@ static int wm8971_i2c_probe(struct i2c_client *i2c,
691 692
692 i2c_set_clientdata(i2c, wm8971); 693 i2c_set_clientdata(i2c, wm8971);
693 694
694 ret = snd_soc_register_codec(&i2c->dev, 695 ret = devm_snd_soc_register_component(&i2c->dev,
695 &soc_codec_dev_wm8971, &wm8971_dai, 1); 696 &soc_component_dev_wm8971, &wm8971_dai, 1);
696 697
697 return ret; 698 return ret;
698} 699}
699 700
700static int wm8971_i2c_remove(struct i2c_client *client)
701{
702 snd_soc_unregister_codec(&client->dev);
703 return 0;
704}
705
706static const struct i2c_device_id wm8971_i2c_id[] = { 701static const struct i2c_device_id wm8971_i2c_id[] = {
707 { "wm8971", 0 }, 702 { "wm8971", 0 },
708 { } 703 { }
@@ -714,7 +709,6 @@ static struct i2c_driver wm8971_i2c_driver = {
714 .name = "wm8971", 709 .name = "wm8971",
715 }, 710 },
716 .probe = wm8971_i2c_probe, 711 .probe = wm8971_i2c_probe,
717 .remove = wm8971_i2c_remove,
718 .id_table = wm8971_i2c_id, 712 .id_table = wm8971_i2c_id,
719}; 713};
720 714