diff options
| -rw-r--r-- | sound/soc/codecs/wm8400.c | 95 |
1 files changed, 20 insertions, 75 deletions
diff --git a/sound/soc/codecs/wm8400.c b/sound/soc/codecs/wm8400.c index d2a092850283..48dc7d2fee36 100644 --- a/sound/soc/codecs/wm8400.c +++ b/sound/soc/codecs/wm8400.c | |||
| @@ -32,13 +32,6 @@ | |||
| 32 | 32 | ||
| 33 | #include "wm8400.h" | 33 | #include "wm8400.h" |
| 34 | 34 | ||
| 35 | /* Fake register for internal state */ | ||
| 36 | #define WM8400_INTDRIVBITS (WM8400_REGISTER_COUNT + 1) | ||
| 37 | #define WM8400_INMIXL_PWR 0 | ||
| 38 | #define WM8400_AINLMUX_PWR 1 | ||
| 39 | #define WM8400_INMIXR_PWR 2 | ||
| 40 | #define WM8400_AINRMUX_PWR 3 | ||
| 41 | |||
| 42 | static struct regulator_bulk_data power[] = { | 35 | static struct regulator_bulk_data power[] = { |
| 43 | { | 36 | { |
| 44 | .supply = "I2S1VDD", | 37 | .supply = "I2S1VDD", |
| @@ -74,32 +67,6 @@ struct wm8400_priv { | |||
| 74 | int fll_in, fll_out; | 67 | int fll_in, fll_out; |
| 75 | }; | 68 | }; |
| 76 | 69 | ||
| 77 | static inline unsigned int wm8400_read(struct snd_soc_codec *codec, | ||
| 78 | unsigned int reg) | ||
| 79 | { | ||
| 80 | struct wm8400_priv *wm8400 = snd_soc_codec_get_drvdata(codec); | ||
| 81 | |||
| 82 | if (reg == WM8400_INTDRIVBITS) | ||
| 83 | return wm8400->fake_register; | ||
| 84 | else | ||
| 85 | return wm8400_reg_read(wm8400->wm8400, reg); | ||
| 86 | } | ||
| 87 | |||
| 88 | /* | ||
| 89 | * write to the wm8400 register space | ||
| 90 | */ | ||
| 91 | static int wm8400_write(struct snd_soc_codec *codec, unsigned int reg, | ||
| 92 | unsigned int value) | ||
| 93 | { | ||
| 94 | struct wm8400_priv *wm8400 = snd_soc_codec_get_drvdata(codec); | ||
| 95 | |||
| 96 | if (reg == WM8400_INTDRIVBITS) { | ||
| 97 | wm8400->fake_register = value; | ||
| 98 | return 0; | ||
| 99 | } else | ||
| 100 | return wm8400_set_bits(wm8400->wm8400, reg, 0xffff, value); | ||
| 101 | } | ||
| 102 | |||
| 103 | static void wm8400_codec_reset(struct snd_soc_codec *codec) | 70 | static void wm8400_codec_reset(struct snd_soc_codec *codec) |
| 104 | { | 71 | { |
| 105 | struct wm8400_priv *wm8400 = snd_soc_codec_get_drvdata(codec); | 72 | struct wm8400_priv *wm8400 = snd_soc_codec_get_drvdata(codec); |
| @@ -352,32 +319,6 @@ SOC_SINGLE("RIN34 Mute Switch", WM8400_RIGHT_LINE_INPUT_3_4_VOLUME, | |||
| 352 | * _DAPM_ Controls | 319 | * _DAPM_ Controls |
| 353 | */ | 320 | */ |
| 354 | 321 | ||
| 355 | static int inmixer_event (struct snd_soc_dapm_widget *w, | ||
| 356 | struct snd_kcontrol *kcontrol, int event) | ||
| 357 | { | ||
| 358 | u16 reg, fakepower; | ||
| 359 | |||
| 360 | reg = snd_soc_read(w->codec, WM8400_POWER_MANAGEMENT_2); | ||
| 361 | fakepower = snd_soc_read(w->codec, WM8400_INTDRIVBITS); | ||
| 362 | |||
| 363 | if (fakepower & ((1 << WM8400_INMIXL_PWR) | | ||
| 364 | (1 << WM8400_AINLMUX_PWR))) { | ||
| 365 | reg |= WM8400_AINL_ENA; | ||
| 366 | } else { | ||
| 367 | reg &= ~WM8400_AINL_ENA; | ||
| 368 | } | ||
| 369 | |||
| 370 | if (fakepower & ((1 << WM8400_INMIXR_PWR) | | ||
| 371 | (1 << WM8400_AINRMUX_PWR))) { | ||
| 372 | reg |= WM8400_AINR_ENA; | ||
| 373 | } else { | ||
| 374 | reg &= ~WM8400_AINR_ENA; | ||
| 375 | } | ||
| 376 | snd_soc_write(w->codec, WM8400_POWER_MANAGEMENT_2, reg); | ||
| 377 | |||
| 378 | return 0; | ||
| 379 | } | ||
| 380 | |||
| 381 | static int outmixer_event (struct snd_soc_dapm_widget *w, | 322 | static int outmixer_event (struct snd_soc_dapm_widget *w, |
| 382 | struct snd_kcontrol * kcontrol, int event) | 323 | struct snd_kcontrol * kcontrol, int event) |
| 383 | { | 324 | { |
| @@ -658,27 +599,26 @@ SND_SOC_DAPM_MIXER("RIN34 PGA", WM8400_POWER_MANAGEMENT_2, | |||
| 658 | 0, &wm8400_dapm_rin34_pga_controls[0], | 599 | 0, &wm8400_dapm_rin34_pga_controls[0], |
| 659 | ARRAY_SIZE(wm8400_dapm_rin34_pga_controls)), | 600 | ARRAY_SIZE(wm8400_dapm_rin34_pga_controls)), |
| 660 | 601 | ||
| 602 | SND_SOC_DAPM_SUPPLY("INL", WM8400_POWER_MANAGEMENT_2, WM8400_AINL_ENA_SHIFT, | ||
| 603 | 0, NULL, 0), | ||
| 604 | SND_SOC_DAPM_SUPPLY("INR", WM8400_POWER_MANAGEMENT_2, WM8400_AINR_ENA_SHIFT, | ||
| 605 | 0, NULL, 0), | ||
| 606 | |||
| 661 | /* INMIXL */ | 607 | /* INMIXL */ |
| 662 | SND_SOC_DAPM_MIXER_E("INMIXL", WM8400_INTDRIVBITS, WM8400_INMIXL_PWR, 0, | 608 | SND_SOC_DAPM_MIXER("INMIXL", SND_SOC_NOPM, 0, 0, |
| 663 | &wm8400_dapm_inmixl_controls[0], | 609 | &wm8400_dapm_inmixl_controls[0], |
| 664 | ARRAY_SIZE(wm8400_dapm_inmixl_controls), | 610 | ARRAY_SIZE(wm8400_dapm_inmixl_controls)), |
| 665 | inmixer_event, SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), | ||
| 666 | 611 | ||
| 667 | /* AINLMUX */ | 612 | /* AINLMUX */ |
| 668 | SND_SOC_DAPM_MUX_E("AILNMUX", WM8400_INTDRIVBITS, WM8400_AINLMUX_PWR, 0, | 613 | SND_SOC_DAPM_MUX("AILNMUX", SND_SOC_NOPM, 0, 0, &wm8400_dapm_ainlmux_controls), |
| 669 | &wm8400_dapm_ainlmux_controls, inmixer_event, | ||
| 670 | SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), | ||
| 671 | 614 | ||
| 672 | /* INMIXR */ | 615 | /* INMIXR */ |
| 673 | SND_SOC_DAPM_MIXER_E("INMIXR", WM8400_INTDRIVBITS, WM8400_INMIXR_PWR, 0, | 616 | SND_SOC_DAPM_MIXER("INMIXR", SND_SOC_NOPM, 0, 0, |
| 674 | &wm8400_dapm_inmixr_controls[0], | 617 | &wm8400_dapm_inmixr_controls[0], |
| 675 | ARRAY_SIZE(wm8400_dapm_inmixr_controls), | 618 | ARRAY_SIZE(wm8400_dapm_inmixr_controls)), |
| 676 | inmixer_event, SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), | ||
| 677 | 619 | ||
| 678 | /* AINRMUX */ | 620 | /* AINRMUX */ |
| 679 | SND_SOC_DAPM_MUX_E("AIRNMUX", WM8400_INTDRIVBITS, WM8400_AINRMUX_PWR, 0, | 621 | SND_SOC_DAPM_MUX("AIRNMUX", SND_SOC_NOPM, 0, 0, &wm8400_dapm_ainrmux_controls), |
| 680 | &wm8400_dapm_ainrmux_controls, inmixer_event, | ||
| 681 | SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), | ||
| 682 | 622 | ||
| 683 | /* Output Side */ | 623 | /* Output Side */ |
| 684 | /* DACs */ | 624 | /* DACs */ |
| @@ -789,11 +729,13 @@ static const struct snd_soc_dapm_route wm8400_dapm_routes[] = { | |||
| 789 | {"LIN34 PGA", "LIN3 Switch", "LIN3"}, | 729 | {"LIN34 PGA", "LIN3 Switch", "LIN3"}, |
| 790 | {"LIN34 PGA", "LIN4 Switch", "LIN4/RXN"}, | 730 | {"LIN34 PGA", "LIN4 Switch", "LIN4/RXN"}, |
| 791 | /* INMIXL */ | 731 | /* INMIXL */ |
| 732 | {"INMIXL", NULL, "INL"}, | ||
| 792 | {"INMIXL", "Record Left Volume", "LOMIX"}, | 733 | {"INMIXL", "Record Left Volume", "LOMIX"}, |
| 793 | {"INMIXL", "LIN2 Volume", "LIN2"}, | 734 | {"INMIXL", "LIN2 Volume", "LIN2"}, |
| 794 | {"INMIXL", "LINPGA12 Switch", "LIN12 PGA"}, | 735 | {"INMIXL", "LINPGA12 Switch", "LIN12 PGA"}, |
| 795 | {"INMIXL", "LINPGA34 Switch", "LIN34 PGA"}, | 736 | {"INMIXL", "LINPGA34 Switch", "LIN34 PGA"}, |
| 796 | /* AILNMUX */ | 737 | /* AILNMUX */ |
| 738 | {"AILNMUX", NULL, "INL"}, | ||
| 797 | {"AILNMUX", "INMIXL Mix", "INMIXL"}, | 739 | {"AILNMUX", "INMIXL Mix", "INMIXL"}, |
| 798 | {"AILNMUX", "DIFFINL Mix", "LIN12 PGA"}, | 740 | {"AILNMUX", "DIFFINL Mix", "LIN12 PGA"}, |
| 799 | {"AILNMUX", "DIFFINL Mix", "LIN34 PGA"}, | 741 | {"AILNMUX", "DIFFINL Mix", "LIN34 PGA"}, |
| @@ -808,12 +750,14 @@ static const struct snd_soc_dapm_route wm8400_dapm_routes[] = { | |||
| 808 | /* RIN34 PGA */ | 750 | /* RIN34 PGA */ |
| 809 | {"RIN34 PGA", "RIN3 Switch", "RIN3"}, | 751 | {"RIN34 PGA", "RIN3 Switch", "RIN3"}, |
| 810 | {"RIN34 PGA", "RIN4 Switch", "RIN4/RXP"}, | 752 | {"RIN34 PGA", "RIN4 Switch", "RIN4/RXP"}, |
| 811 | /* INMIXL */ | 753 | /* INMIXR */ |
| 754 | {"INMIXR", NULL, "INR"}, | ||
| 812 | {"INMIXR", "Record Right Volume", "ROMIX"}, | 755 | {"INMIXR", "Record Right Volume", "ROMIX"}, |
| 813 | {"INMIXR", "RIN2 Volume", "RIN2"}, | 756 | {"INMIXR", "RIN2 Volume", "RIN2"}, |
| 814 | {"INMIXR", "RINPGA12 Switch", "RIN12 PGA"}, | 757 | {"INMIXR", "RINPGA12 Switch", "RIN12 PGA"}, |
| 815 | {"INMIXR", "RINPGA34 Switch", "RIN34 PGA"}, | 758 | {"INMIXR", "RINPGA34 Switch", "RIN34 PGA"}, |
| 816 | /* AIRNMUX */ | 759 | /* AIRNMUX */ |
| 760 | {"AIRNMUX", NULL, "INR"}, | ||
| 817 | {"AIRNMUX", "INMIXR Mix", "INMIXR"}, | 761 | {"AIRNMUX", "INMIXR Mix", "INMIXR"}, |
| 818 | {"AIRNMUX", "DIFFINR Mix", "RIN12 PGA"}, | 762 | {"AIRNMUX", "DIFFINR Mix", "RIN12 PGA"}, |
| 819 | {"AIRNMUX", "DIFFINR Mix", "RIN34 PGA"}, | 763 | {"AIRNMUX", "DIFFINR Mix", "RIN34 PGA"}, |
| @@ -1365,9 +1309,12 @@ static int wm8400_codec_probe(struct snd_soc_codec *codec) | |||
| 1365 | return -ENOMEM; | 1309 | return -ENOMEM; |
| 1366 | 1310 | ||
| 1367 | snd_soc_codec_set_drvdata(codec, priv); | 1311 | snd_soc_codec_set_drvdata(codec, priv); |
| 1368 | codec->control_data = priv->wm8400 = wm8400; | 1312 | priv->wm8400 = wm8400; |
| 1313 | codec->control_data = wm8400->regmap; | ||
| 1369 | priv->codec = codec; | 1314 | priv->codec = codec; |
| 1370 | 1315 | ||
| 1316 | snd_soc_codec_set_cache_io(codec, 8, 16, SND_SOC_REGMAP); | ||
| 1317 | |||
| 1371 | ret = devm_regulator_bulk_get(wm8400->dev, | 1318 | ret = devm_regulator_bulk_get(wm8400->dev, |
| 1372 | ARRAY_SIZE(power), &power[0]); | 1319 | ARRAY_SIZE(power), &power[0]); |
| 1373 | if (ret != 0) { | 1320 | if (ret != 0) { |
| @@ -1414,8 +1361,6 @@ static struct snd_soc_codec_driver soc_codec_dev_wm8400 = { | |||
| 1414 | .remove = wm8400_codec_remove, | 1361 | .remove = wm8400_codec_remove, |
| 1415 | .suspend = wm8400_suspend, | 1362 | .suspend = wm8400_suspend, |
| 1416 | .resume = wm8400_resume, | 1363 | .resume = wm8400_resume, |
| 1417 | .read = snd_soc_read, | ||
| 1418 | .write = wm8400_write, | ||
| 1419 | .set_bias_level = wm8400_set_bias_level, | 1364 | .set_bias_level = wm8400_set_bias_level, |
| 1420 | 1365 | ||
| 1421 | .controls = wm8400_snd_controls, | 1366 | .controls = wm8400_snd_controls, |
