From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795704454; b=inl7ZtNijn5UqawK1CdE87e36WBBSFSsD1IylLQ/ZPuplMHY3qMDhbuZ7TPElGeEYT5W AaNGBMlGf5I1fmiJxo1cBG7gzrU0dSuEp+yKi4tDsHYRzRimoD9mLPjcNmW81v4wtJF/4 XYe29Rrxk0MuaoUiz4ib2gY723NLVE6QMMU3Pkpovh0ZxIWrkm+qRopqTkqLzeQeUdxaI XtOCUfBm+TRpXj2T4aWxk9DMxkTlbnhiSoggXpwkCwYkvDqTDXMryfkyvPtr/evD7Sarn LiUVmRL3xq3WUMiwmXp0xrOfy50mL7zoZXqIl6DzOdBMJMo7jCao7n/3JpyEknDGUkg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795704454; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=LDkXILZF1ngGx4j3VAA11fVYMdEgXNC6hm34H9zvjm4=; b=X1SCkBv0ebrmoOdAusxQ0ZqpWNgzaZOVQh8gVFz3nvVYOhTuoNHlPiEb4XZ4jKe6a7eS eXuROwvp25dLE0+3qEfJU9Rx32XSJjbCpmEOwwViXepMZYvMYDNvdCHsBPWFwVaC3pCCE b4MHA6Ps5XlyC0MuEm1ZhrsZMpfRCtF10rAwJTQfgnIU/C1irZo9UhUK11l0v4yI9YPBI iX5ZmIJDV3CfVbDyKYLp3R4QVJ+T2Ddn4yemSJYMDrS/XMmPF7rPN8XYKOW19PCSP26sW FWI6p1Zj/Pn3Hdx+JmkB1CmPZSuQO3MvF9HP6BDwni/1CpUO4gScF3vS931BWpYlIQg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b="CgoyM/g1"; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 70644606A31C; Thu, 26 Nov 2026 14:47:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=CgoyM/g1 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 71A571F000C4; Thu, 26 Nov 2026 14:47:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1795704454; bh=LDkXILZF1ngGx4j3VAA11fVYMdEgXNC6hm34H9zvjm4=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=CgoyM/g1Tm9LbjZrrjQdFpmeG7YtYvCj4pmDf2mOYBzSUnJoKmyh/V0btKY97j2FK Bdq59n4zfPzuK76U613jeXes224s//8N7lXRoiu+Nv3bIUz9aOniEK53i3VbbeScKX 3UxBj403D/YW0ricKSdSAaQ4T6A8/tmdMZCQ0+HM= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, LiangCheng Wang , Mark Brown , Sasha Levin Subject: [PATCH 5.10 130/265] ASoC: max98090: keep the MIC boost across mic input power-up Date: Thu, 26 Nov 2026 15:37:40 +0100 Message-ID: <20261126143614.110874186@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261126143605.076581697@linuxfoundation.org> References: <20261126143605.076581697@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.10-stable review patch. If anyone has any objections, please let me know. ------------------ From: LiangCheng Wang [ Upstream commit 58d51fa6ff1d21e79c3c340bfb3155dfa3025ca3 ] PA1EN/PA2EN select both the MIC1/MIC2 preamp enable and its gain (0 = off, 1 = 0 dB, 2 = +20 dB, 3 = +30 dB). "MICn Boost Volume" keeps the selected gain in max98090->pa1en/pa2en while the input is off, and max98090_micinput_event() writes it to the field when the "MICn Input" widget powers up. The event handler also reads the field back to keep the stored gain in sync ("Update for volatile"), but it does so on POST_PMU and POST_PMD. The widget drives PA1EN/PA2EN as a single enable bit, the low bit of the field, so at both points DAPM has just rewritten it: - POST_PMU: DAPM has set the field to 1, so the read-back stores 0 dB and the handler then restores 0 dB. - POST_PMD: DAPM has cleared the low bit, so a +30 dB (3) gain reads back as +20 dB (2). As a result every capture starts at 0 dB: a boost set while the input is powered down, e.g. restored by alsactl or an audio HAL at boot, never takes effect, and one changed during capture is lost at the next power-up. Read the field back on PRE_PMD instead, while it still holds the active gain, and only restore the stored gain on POST_PMU. Tested on i.MX95 with a MAX98090 headset mic on MIC1, running NXP's 6.18.38 vendor kernel (max98090_micinput_event() is the same as in mainline): with MIC1 Boost Volume set to 2 (+30 dB) before capture, register 0x10 reads 0x20 (0 dB) during capture without this change and 0x60 (+30 dB) with it, and a boost changed during capture is kept for the next capture. Fixes: 685e42154dcf ("ASoC: Replace max98090 Device Driver") Signed-off-by: LiangCheng Wang Link: https://patch.msgid.link/20261111-max98090-mic-boost-v1-1-20b9bd8816db@gmail.com Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- sound/soc/codecs/max98090.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/sound/soc/codecs/max98090.c b/sound/soc/codecs/max98090.c index 531cd172cb5cb..3d8227cbab031 100644 --- a/sound/soc/codecs/max98090.c +++ b/sound/soc/codecs/max98090.c @@ -742,14 +742,6 @@ static int max98090_micinput_event(struct snd_soc_dapm_widget *w, else val = (val & M98090_MIC_PA2EN_MASK) >> M98090_MIC_PA2EN_SHIFT; - if (val >= 1) { - if (w->reg == M98090_REG_MIC1_INPUT_LEVEL) { - max98090->pa1en = val - 1; /* Update for volatile */ - } else { - max98090->pa2en = val - 1; /* Update for volatile */ - } - } - switch (event) { case SND_SOC_DAPM_POST_PMU: /* If turning on, set to most recently selected volume */ @@ -758,6 +750,14 @@ static int max98090_micinput_event(struct snd_soc_dapm_widget *w, else val = max98090->pa2en + 1; break; + case SND_SOC_DAPM_PRE_PMD: + if (val >= 1) { + if (w->reg == M98090_REG_MIC1_INPUT_LEVEL) + max98090->pa1en = val - 1; + else + max98090->pa2en = val - 1; + } + return 0; case SND_SOC_DAPM_POST_PMD: /* If turning off, turn off */ val = 0; @@ -1107,11 +1107,13 @@ static const struct snd_soc_dapm_widget max98090_dapm_widgets[] = { SND_SOC_DAPM_PGA_E("MIC1 Input", M98090_REG_MIC1_INPUT_LEVEL, M98090_MIC_PA1EN_SHIFT, 0, NULL, 0, max98090_micinput_event, - SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), + SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD | + SND_SOC_DAPM_POST_PMD), SND_SOC_DAPM_PGA_E("MIC2 Input", M98090_REG_MIC2_INPUT_LEVEL, M98090_MIC_PA2EN_SHIFT, 0, NULL, 0, max98090_micinput_event, - SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), + SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD | + SND_SOC_DAPM_POST_PMD), SND_SOC_DAPM_MIXER("LINEA Mixer", SND_SOC_NOPM, 0, 0, &max98090_linea_mixer_controls[0], -- 2.53.0