[PATCH 3/4] ASoC: tlv320aic32x4: Add IN1 and Mixer Amp analog bypass volume controls
From: Gianfranco Mariotti
Date: Mon Nov 23 2026 - 18:41:26 EST
The TLV320AIC32x4 provides analog bypass attenuators for both the direct
IN1L/IN1R-to-HPL/HPR bypass path (Page 1, Registers 22 and 23) and the
Left/Right Mixer Amplifier (MAL/MAR) path (Page 1, Registers 24 and 25):
- AIC32X4_IN1L2HPLVOL / AIC32X4_IN1R2HPRVOL: 0.0 dB (0x00) down to
-72.3 dB (0x74) and MUTE (0x75)
- AIC32X4_MALVOL / AIC32X4_MARVOL: 0.0 dB (0x00) down to -30.1 dB (0x27)
and MUTE (0x28)
Add the register definitions, piecewise DECLARE_TLV_DB_RANGE tables
approximating the non-linear TI SLAA557 curve within 0.1 dB while
staying under alsa-lib's 256-byte MAX_TLV_RANGE_SIZE limit, and the
corresponding Bypass Playback Volume controls.
Signed-off-by: Gianfranco Mariotti <gianfranco.mariotti94@xxxxxxxxx>
---
Note: Of the two TLV320AIC3204 boards used for testing, one wires IN1
with Line-Out (LOL/LOR) and the other wires IN3 with Headphone
(HPL/HPR). Since neither board wires both IN1 and HPL/HPR on the same
codec, 'IN1 Bypass Playback Volume' was verified via alsa-lib TLV dB
conversion and live I2C register readback (Page 1, Registers 22-23)
rather than end-to-end analog audio.
sound/soc/codecs/tlv320aic32x4.c | 37 ++++++++++++++++++++++++++++++++
sound/soc/codecs/tlv320aic32x4.h | 4 ++++
2 files changed, 41 insertions(+)
diff --git a/sound/soc/codecs/tlv320aic32x4.c b/sound/soc/codecs/tlv320aic32x4.c
index 9f90e41076992..80ff52c6bbbe1 100644
--- a/sound/soc/codecs/tlv320aic32x4.c
+++ b/sound/soc/codecs/tlv320aic32x4.c
@@ -264,6 +264,39 @@ static DECLARE_TLV_DB_SCALE(tlv_adc_vol, -1200, 50, 0);
static DECLARE_TLV_DB_SCALE(tlv_tas_driver_gain, -5850, 50, 0);
static DECLARE_TLV_DB_SCALE(tlv_amp_vol, 0, 600, 1);
+/*
+ * IN1L/IN1R to HPL/HPR bypass attenuation (Page 1, Reg 22-23, inverted).
+ * Kept within alsa-lib MAX_TLV_RANGE_SIZE (256 bytes, max 10 items).
+ */
+static const DECLARE_TLV_DB_RANGE(tlv_in1_hp_vol,
+ 0, 0, TLV_DB_SCALE_ITEM(TLV_DB_GAIN_MUTE, 0, 1),
+ 1, 2, TLV_DB_SCALE_ITEM(-7230, 360, 0),
+ 3, 5, TLV_DB_SCALE_ITEM(-6612, 174, 0),
+ 6, 7, TLV_DB_SCALE_ITEM(-6020, 190, 0),
+ 8, 10, TLV_DB_SCALE_ITEM(-5667, 124, 0),
+ 11, 12, TLV_DB_SCALE_ITEM(-5370, 100, 0),
+ 13, 18, TLV_DB_SCALE_ITEM(-5240, 50, 0),
+ 19, 23, TLV_DB_SCALE_ITEM(-4921, 46, 0),
+ 24, 47, TLV_DB_SCALE_ITEM(-4670, 50, 0),
+ 48, 117, TLV_DB_SCALE_ITEM(-3450, 50, 0)
+);
+
+/*
+ * MAL/MAR Mixer Amplifier attenuation (Page 1, Reg 24-25, inverted).
+ * Kept within alsa-lib MAX_TLV_RANGE_SIZE (256 bytes, max 10 items).
+ */
+static const DECLARE_TLV_DB_RANGE(tlv_ma_vol,
+ 0, 0, TLV_DB_SCALE_ITEM(TLV_DB_GAIN_MUTE, 0, 1),
+ 1, 2, TLV_DB_SCALE_ITEM(-3010, 350, 0),
+ 3, 4, TLV_DB_SCALE_ITEM(-2410, 200, 0),
+ 5, 8, TLV_DB_SCALE_ITEM(-2050, 120, 0),
+ 9, 13, TLV_DB_SCALE_ITEM(-1602, 72, 0),
+ 14, 21, TLV_DB_SCALE_ITEM(-1251, 47, 0),
+ 22, 24, TLV_DB_SCALE_ITEM(-851, 34, 0),
+ 25, 34, TLV_DB_SCALE_ITEM(-715, 47, 0),
+ 35, 40, TLV_DB_SCALE_ITEM(-225, 45, 0)
+);
+
static const char * const lo_cm_text[] = {
"Full Chip", "1.65V",
};
@@ -291,6 +324,10 @@ static const struct snd_kcontrol_new aic32x4_snd_controls[] = {
SOC_DOUBLE_R("LO DAC Playback Switch", AIC32X4_LOLGAIN,
AIC32X4_LORGAIN, 6, 0x01, 1),
SOC_ENUM("LO Playback Common Mode Switch", lo_cm_enum),
+ SOC_DOUBLE_R_TLV("IN1 Bypass Playback Volume", AIC32X4_IN1L2HPLVOL,
+ AIC32X4_IN1R2HPRVOL, 0, 0x75, 1, tlv_in1_hp_vol),
+ SOC_DOUBLE_R_TLV("Mixer Amp Bypass Playback Volume", AIC32X4_MALVOL,
+ AIC32X4_MARVOL, 0, 0x28, 1, tlv_ma_vol),
SOC_DOUBLE_R("Mic PGA Switch", AIC32X4_LMICPGAVOL,
AIC32X4_RMICPGAVOL, 7, 0x01, 1),
diff --git a/sound/soc/codecs/tlv320aic32x4.h b/sound/soc/codecs/tlv320aic32x4.h
index d0c2e1002e99e..70ea13198002d 100644
--- a/sound/soc/codecs/tlv320aic32x4.h
+++ b/sound/soc/codecs/tlv320aic32x4.h
@@ -95,6 +95,10 @@ int aic32x4_register_clocks(struct device *dev, const char *mclk_name);
#define AIC32X4_LORGAIN AIC32X4_REG(1, 19)
#define AIC32X4_HEADSTART AIC32X4_REG(1, 20)
#define TAS2505_HPVOL AIC32X4_REG(1, 22)
+#define AIC32X4_IN1L2HPLVOL AIC32X4_REG(1, 22)
+#define AIC32X4_IN1R2HPRVOL AIC32X4_REG(1, 23)
+#define AIC32X4_MALVOL AIC32X4_REG(1, 24)
+#define AIC32X4_MARVOL AIC32X4_REG(1, 25)
#define TAS2505_SPK AIC32X4_REG(1, 45)
#define TAS2505_SPKVOL1 AIC32X4_REG(1, 46)
#define TAS2505_SPKVOL2 AIC32X4_REG(1, 48)
--
2.25.1