Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ASoC: wm8991: Use a supply to manage input power

Instead of using a fake register and events to manage input power use a
supply to do the job, saving code and preparing for regmap conversion of
the driver.

Signed-off-by: Mark Brown <broonie@linaro.org>
Acked-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>

+17 -45
+17 -36
sound/soc/codecs/wm8991.c
··· 374 374 /* 375 375 * _DAPM_ Controls 376 376 */ 377 - static int inmixer_event(struct snd_soc_dapm_widget *w, 378 - struct snd_kcontrol *kcontrol, int event) 379 - { 380 - u16 reg, fakepower; 381 - 382 - reg = snd_soc_read(w->codec, WM8991_POWER_MANAGEMENT_2); 383 - fakepower = snd_soc_read(w->codec, WM8991_INTDRIVBITS); 384 - 385 - if (fakepower & ((1 << WM8991_INMIXL_PWR_BIT) | 386 - (1 << WM8991_AINLMUX_PWR_BIT))) 387 - reg |= WM8991_AINL_ENA; 388 - else 389 - reg &= ~WM8991_AINL_ENA; 390 - 391 - if (fakepower & ((1 << WM8991_INMIXR_PWR_BIT) | 392 - (1 << WM8991_AINRMUX_PWR_BIT))) 393 - reg |= WM8991_AINR_ENA; 394 - else 395 - reg &= ~WM8991_AINR_ENA; 396 - 397 - snd_soc_write(w->codec, WM8991_POWER_MANAGEMENT_2, reg); 398 - return 0; 399 - } 400 - 401 377 static int outmixer_event(struct snd_soc_dapm_widget *w, 402 378 struct snd_kcontrol *kcontrol, int event) 403 379 { ··· 631 655 SND_SOC_DAPM_INPUT("RIN2"), 632 656 SND_SOC_DAPM_INPUT("Internal ADC Source"), 633 657 658 + SND_SOC_DAPM_SUPPLY("INL", WM8991_POWER_MANAGEMENT_2, 659 + WM8991_AINL_ENA_BIT, 0, NULL, 0), 660 + SND_SOC_DAPM_SUPPLY("INR", WM8991_POWER_MANAGEMENT_2, 661 + WM8991_AINR_ENA_BIT, 0, NULL, 0), 662 + 634 663 /* DACs */ 635 664 SND_SOC_DAPM_ADC("Left ADC", "Left Capture", WM8991_POWER_MANAGEMENT_2, 636 665 WM8991_ADCL_ENA_BIT, 0), ··· 657 676 ARRAY_SIZE(wm8991_dapm_rin34_pga_controls)), 658 677 659 678 /* INMIXL */ 660 - SND_SOC_DAPM_MIXER_E("INMIXL", WM8991_INTDRIVBITS, WM8991_INMIXL_PWR_BIT, 0, 679 + SND_SOC_DAPM_MIXER("INMIXL", SND_SOC_NOPM, 0, 0, 661 680 &wm8991_dapm_inmixl_controls[0], 662 - ARRAY_SIZE(wm8991_dapm_inmixl_controls), 663 - inmixer_event, SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), 681 + ARRAY_SIZE(wm8991_dapm_inmixl_controls)), 664 682 665 683 /* AINLMUX */ 666 - SND_SOC_DAPM_MUX_E("AINLMUX", WM8991_INTDRIVBITS, WM8991_AINLMUX_PWR_BIT, 0, 667 - &wm8991_dapm_ainlmux_controls, inmixer_event, 668 - SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), 684 + SND_SOC_DAPM_MUX("AINLMUX", SND_SOC_NOPM, 0, 0, 685 + &wm8991_dapm_ainlmux_controls), 669 686 670 687 /* INMIXR */ 671 - SND_SOC_DAPM_MIXER_E("INMIXR", WM8991_INTDRIVBITS, WM8991_INMIXR_PWR_BIT, 0, 688 + SND_SOC_DAPM_MIXER("INMIXR", SND_SOC_NOPM, 0, 0, 672 689 &wm8991_dapm_inmixr_controls[0], 673 - ARRAY_SIZE(wm8991_dapm_inmixr_controls), 674 - inmixer_event, SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), 690 + ARRAY_SIZE(wm8991_dapm_inmixr_controls)), 675 691 676 692 /* AINRMUX */ 677 - SND_SOC_DAPM_MUX_E("AINRMUX", WM8991_INTDRIVBITS, WM8991_AINRMUX_PWR_BIT, 0, 678 - &wm8991_dapm_ainrmux_controls, inmixer_event, 679 - SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), 693 + SND_SOC_DAPM_MUX("AINRMUX", SND_SOC_NOPM, 0, 0, 694 + &wm8991_dapm_ainrmux_controls), 680 695 681 696 /* Output Side */ 682 697 /* DACs */ ··· 774 797 {"Right ADC", NULL, "Internal ADC Source"}, 775 798 776 799 /* Input Side */ 800 + {"INMIXL", NULL, "INL"}, 801 + {"AINLMUX", NULL, "INL"}, 802 + {"INMIXR", NULL, "INR"}, 803 + {"AINRMUX", NULL, "INR"}, 777 804 /* LIN12 PGA */ 778 805 {"LIN12 PGA", "LIN1 Switch", "LIN1"}, 779 806 {"LIN12 PGA", "LIN2 Switch", "LIN2"},
-9
sound/soc/codecs/wm8991.h
··· 76 76 #define WM8991_PLL1 0x3C 77 77 #define WM8991_PLL2 0x3D 78 78 #define WM8991_PLL3 0x3E 79 - #define WM8991_INTDRIVBITS 0x3F 80 79 81 80 #define WM8991_REGISTER_COUNT 60 82 81 #define WM8991_MAX_REGISTER 0x3F ··· 805 806 * R62 (0x3E) - PLL3 806 807 */ 807 808 #define WM8991_PLLK2_MASK 0x00FF /* PLLK2 - [7:0] */ 808 - 809 - /* 810 - * R63 (0x3F) - Internal Driver Bits 811 - */ 812 - #define WM8991_INMIXL_PWR_BIT 0 813 - #define WM8991_AINLMUX_PWR_BIT 1 814 - #define WM8991_INMIXR_PWR_BIT 2 815 - #define WM8991_AINRMUX_PWR_BIT 3 816 809 817 810 #define WM8991_MCLK_DIV 0 818 811 #define WM8991_DACCLK_DIV 1