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

ASoC: wm8904: fix wrong outputs volume after power reactivation

Restore volume after charge pump and PGA activation to ensure
that volume settings are correctly applied when re-enabling codec
from SND_SOC_BIAS_OFF state.
CLASS_W, CHARGE_PUMP and POWER_MANAGEMENT_2 register configuration
affect how the volume register are applied and must be configured first.

Fixes: a91eb199e4dc ("ASoC: Initial WM8904 CODEC driver")
Link: https://lore.kernel.org/all/c7864c35-738c-a867-a6a6-ddf9f98df7e7@gmail.com/
Signed-off-by: Emanuele Ghidoli <emanuele.ghidoli@toradex.com>
Signed-off-by: Francesco Dolcini <francesco.dolcini@toradex.com>
Acked-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20221223080247.7258-1-francesco@dolcini.it
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Emanuele Ghidoli and committed by
Mark Brown
472a6309 810948f4

+7
+7
sound/soc/codecs/wm8904.c
··· 697 697 int dcs_mask; 698 698 int dcs_l, dcs_r; 699 699 int dcs_l_reg, dcs_r_reg; 700 + int an_out_reg; 700 701 int timeout; 701 702 int pwr_reg; 702 703 ··· 713 712 dcs_mask = WM8904_DCS_ENA_CHAN_0 | WM8904_DCS_ENA_CHAN_1; 714 713 dcs_r_reg = WM8904_DC_SERVO_8; 715 714 dcs_l_reg = WM8904_DC_SERVO_9; 715 + an_out_reg = WM8904_ANALOGUE_OUT1_LEFT; 716 716 dcs_l = 0; 717 717 dcs_r = 1; 718 718 break; ··· 722 720 dcs_mask = WM8904_DCS_ENA_CHAN_2 | WM8904_DCS_ENA_CHAN_3; 723 721 dcs_r_reg = WM8904_DC_SERVO_6; 724 722 dcs_l_reg = WM8904_DC_SERVO_7; 723 + an_out_reg = WM8904_ANALOGUE_OUT2_LEFT; 725 724 dcs_l = 2; 726 725 dcs_r = 3; 727 726 break; ··· 795 792 snd_soc_component_update_bits(component, reg, 796 793 WM8904_HPL_ENA_OUTP | WM8904_HPR_ENA_OUTP, 797 794 WM8904_HPL_ENA_OUTP | WM8904_HPR_ENA_OUTP); 795 + 796 + /* Update volume, requires PGA to be powered */ 797 + val = snd_soc_component_read(component, an_out_reg); 798 + snd_soc_component_write(component, an_out_reg, val); 798 799 break; 799 800 800 801 case SND_SOC_DAPM_POST_PMU: