[PATCH] ASoC: ab8500: Add AB8505 handsfree output gain

From: Linus Walleij

Date: Fri Nov 20 2026 - 03:42:49 EST


The AB8505 has a final gain stage in the handsfree speaker paths. On
revision 2 and later, its HFLGainCtrl and HFRGainCtrl registers reset to
0x1f, which is the no-signal setting. The existing controls only reach
the preceding DA3 and DA4 gain stage, so userspace cannot unmute the
speaker outputs.

Expose the handsfree output gain as an ALSA control. Select the combined
revision 1 register or the separate revision 2 and later registers
according to the detected chip revision.

Signed-off-by: Linus Walleij <linusw@xxxxxxxxxx>
---
sound/soc/codecs/ab8500-codec.c | 30 ++++++++++++++++++++++++++++++
sound/soc/codecs/ab8500-codec.h | 15 +++++++++++++++
2 files changed, 45 insertions(+)

diff --git a/sound/soc/codecs/ab8500-codec.c b/sound/soc/codecs/ab8500-codec.c
index 3e3ff9bfe00d..8b0cd01d2a27 100644
--- a/sound/soc/codecs/ab8500-codec.c
+++ b/sound/soc/codecs/ab8500-codec.c
@@ -955,6 +955,12 @@ static DECLARE_TLV_DB_SCALE(dax_dig_gain_tlv, -6300, 100, 1);
static DECLARE_TLV_DB_SCALE(hs_ear_dig_gain_tlv, -100, 100, 1);
/* -1dB = Mute */

+/* AB8505 v1 handsfree output gain: -3 dB to 12 dB in 1 dB steps. */
+static DECLARE_TLV_DB_SCALE(ab8505_hf_v1_gain_tlv, -300, 100, 0);
+
+/* AB8505 v2 handsfree output gain: mute, then -3 dB to 20 dB. */
+static DECLARE_TLV_DB_SCALE(ab8505_hf_v2_gain_tlv, -400, 100, 1);
+
static const DECLARE_TLV_DB_RANGE(hs_gain_tlv,
0, 3, TLV_DB_SCALE_ITEM(-3200, 400, 0),
4, 15, TLV_DB_SCALE_ITEM(-1800, 200, 0)
@@ -1519,6 +1525,18 @@ static struct snd_kcontrol_new ab8500_ctrls[] = {
AB8500_SIDFIRADR, AB8500_SIDFIRADR_FIRSIDSET, 0),
};

+static const struct snd_kcontrol_new ab8505_v1_ctrls[] = {
+ SOC_DOUBLE_TLV("HF Digital Volume", AB8505_HFGAINCTRL_V1,
+ AB8505_HFGAINCTRL_V1_HFL, AB8505_HFGAINCTRL_V1_HFR,
+ AB8505_HFGAINCTRL_V1_MAX, 1, ab8505_hf_v1_gain_tlv),
+};
+
+static const struct snd_kcontrol_new ab8505_v2_ctrls[] = {
+ SOC_DOUBLE_R_TLV("HF Digital Volume",
+ AB8505_HFLGAINCTRL_V2, AB8505_HFRGAINCTRL_V2,
+ 0, AB8505_HFGAINCTRL_V2_MAX, 1, ab8505_hf_v2_gain_tlv),
+};
+
/*
* Extended interface for codec-driver
*/
@@ -2081,6 +2099,18 @@ static int ab8500_codec_probe(struct snd_soc_component *component)
ARRAY_SIZE(ab8500_dmic_dapm_routes));
if (status)
return status;
+ } else if (is_ab8505_1p0_or_earlier(ab8500)) {
+ status = snd_soc_add_component_controls(component,
+ ab8505_v1_ctrls,
+ ARRAY_SIZE(ab8505_v1_ctrls));
+ if (status)
+ return status;
+ } else if (is_ab8505(ab8500)) {
+ status = snd_soc_add_component_controls(component,
+ ab8505_v2_ctrls,
+ ARRAY_SIZE(ab8505_v2_ctrls));
+ if (status)
+ return status;
}

status = ab8500_audio_init_audioblock(component);
diff --git a/sound/soc/codecs/ab8500-codec.h b/sound/soc/codecs/ab8500-codec.h
index 2a6f6409f1f8..9ffcb50a991d 100644
--- a/sound/soc/codecs/ab8500-codec.h
+++ b/sound/soc/codecs/ab8500-codec.h
@@ -142,6 +142,13 @@
#define AB8500_FIFOCONF6 0x6E
#define AB8500_AUDREV 0x6F

+/* AB8505 v1 audio bank registers */
+#define AB8505_HFGAINCTRL_V1 0x78
+
+/* AB8505 v2 and later audio bank registers */
+#define AB8505_HFLGAINCTRL_V2 0x80
+#define AB8505_HFRGAINCTRL_V2 0x81
+
#define AB8500_FIRST_REG AB8500_POWERUP
#define AB8500_LAST_REG AB8500_AUDREV
#define AB8500_CACHEREGNUM (AB8500_LAST_REG + 1)
@@ -150,6 +157,14 @@
#define AB8500_MASK_SLOT(slot) ((slot & 1) ? 0xF0 : 0x0F)
#define AB8500_MASK_NONE 0x00

+/* AB8505_HFGAINCTRL_V1 */
+#define AB8505_HFGAINCTRL_V1_HFL 4
+#define AB8505_HFGAINCTRL_V1_HFR 0
+#define AB8505_HFGAINCTRL_V1_MAX 0x0F
+
+/* AB8505_HFLGAINCTRL_V2, AB8505_HFRGAINCTRL_V2 */
+#define AB8505_HFGAINCTRL_V2_MAX 0x18
+
/* AB8500_POWERUP */
#define AB8500_POWERUP_POWERUP 7
#define AB8500_POWERUP_ENANA 3

---
base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4
change-id: 20261120-ux500-asoc-handsfree-gain-ab2cc2a3f6e0

Best regards,
--
Linus Walleij <linusw@xxxxxxxxxx>