ASoC: tlv320aic32x4: Complete analog routing, Mixer Amp bypass, and volume controls
Subsystems (3)
v2 cover ASoC: tlv320aic32x4: Complete analog routing, Mixer Amp bypass, and volume controls
The TLV320AIC32x4 driver currently exposes only a subset of the codec's analog input/output routing switches and omits support for its Left and Right Mixer Amplifiers (MAL/MAR) and analog bypass volume attenuators.
This series completes the analog DAPM topology and mixer controls per the TI TLV320AIC3204/3254 (SLAA557 / SLAA408) and TLV320AIC3206/3256 (SLAA463 / SLAU306) Application Reference Guides:
1. Add the missing cross-channel DAC negative terminal switches (L_DAC to HPR, R_DAC to LOL) and output driver bridging switches (HPL to HPR on AIC32x4 only, LOR to LOL) used for mono differential headphone and line-out configurations.
2. Model the Left and Right MicPGAs and Left/Right Mixer Amplifiers (MAL/MAR, Page 1, Register 9 bits 1:0) in DAPM and wire their routing switches into the HPL, HPR, LOL, and LOR output mixers for amplified analog ADC/DAC bypass.
3. Add the non-linear analog bypass attenuation volume controls for IN1L/IN1R-to-HPL/HPR (Page 1, Registers 22-23) and MAL/MAR (Page 1, Registers 24-25) using piecewise DECLARE_TLV_DB_RANGE tables.
4. Expose the CM2_L and CM2_R common-mode resistor selections in bits 1:0 of AIC32X4_LMICPGANIN and AIC32X4_RMICPGANIN (Page 1, Registers 54 and 57).
Tested on two TI TLV320AIC3204 boards (one wiring IN1 with LOL/LOR, the other wiring IN3 with HPL/HPR) across headphone, line-out, capture, driver bridging, and MicPGA-to-MAL/MAR analog bypass configurations. Since neither board wires both IN1 and HPL/HPR on the same codec, the direct IN1-to-HP bypass volume control ('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.
Changes in v2:
- Patch 1: Restrict HPR Output Mixer 'HPL Switch' (AIC32X4_HPRROUTE bit
0) and its DAPM route to AIC32X4_TYPE_AIC32X4, as bit 0 is reserved on TLV320AIC32x6 devices (Mark Brown).
- Link to v1: https://lore.kernel.org/r/[email protected]
Gianfranco Mariotti (4):
ASoC: tlv320aic32x4: Add missing DAC and driver output mixer routes
ASoC: tlv320aic32x4: Add Left and Right Mixer Amplifier DAPM support
ASoC: tlv320aic32x4: Add IN1 and Mixer Amp analog bypass volume
controls
ASoC: tlv320aic32x4: Add CM2_L and CM2_R negative MicPGA input routing
sound/soc/codecs/tlv320aic32x4.c | 155 +++++++++++++++++++++++++++---- sound/soc/codecs/tlv320aic32x4.h | 4 + 2 files changed, 142 insertions(+), 17 deletions(-)
Signature · 1 line
2.25.1
PATCH v2 1/4 ASoC: tlv320aic32x4: Add missing DAC and driver output mixer routes
The HPR and LOL output routing selection registers (Page 1, Registers 13 and 14) support routing the opposite DAC channel's negative reconstruction filter terminal as well as bridging the HPL and LOR output amplifier stages for mono differential configurations:
- AIC32X4_HPRROUTE bit 4: Left DAC negative terminal to HPR
- AIC32X4_HPRROUTE bit 0: HPL output driver to HPR (AIC32x4 only)
- AIC32X4_LOLROUTE bit 4: Right DAC negative terminal to LOL
- AIC32X4_LOLROUTE bit 0: LOR output driver to LOL
Add the corresponding DAPM mixer controls and routes, sourcing HPL/LOR bridging from the HPL Power and LOR Power PGA widgets so the upstream driver stage is powered when bridged.
Because AIC32X4_HPRROUTE bit 0 is reserved on TLV320AIC32x6 devices (SLAA463 / SLAU306, which use ground-centered charge-pump headphone drivers rather than AVDD-powered headphone drivers), register the HPR Output Mixer widget in aic32x4_component_probe() so 'HPL Switch' and its route are only exposed on AIC32X4_TYPE_AIC32X4.
---
v2:
- Restrict 'HPL Switch' (AIC32X4_HPRROUTE bit 0) and its DAPM route to AIC32X4_TYPE_AIC32X4, since bit 0 is reserved on TLV320AIC32x6 (Mark Brown).
sound/soc/codecs/tlv320aic32x4.c | 46 +++++++++++++++++++++++++++++--- 1 file changed, 43 insertions(+), 3 deletions(-)
sound/soc/codecs/tlv320aic32x4.c +43 -3
@@ -323,12 +323,17 @@ static const struct snd_kcontrol_new hpl_output_mixer_controls[] = { };static const struct snd_kcontrol_new hpr_output_mixer_controls[] = { +SOC_DAPM_SINGLE ("L_DAC Switch" ,AIC32X4_HPRROUTE ,4 ,1 ,0 ),SOC_DAPM_SINGLE ("R_DAC Switch" ,AIC32X4_HPRROUTE ,3 ,1 ,0 ),SOC_DAPM_SINGLE ("IN1_R Switch" ,AIC32X4_HPRROUTE ,2 ,1 ,0 ), +/* HPL Switch (bit 0) is AIC32x4-only; keep last for AIC32x6 */ +SOC_DAPM_SINGLE ("HPL Switch" ,AIC32X4_HPRROUTE ,0 ,1 ,0 ), };static const struct snd_kcontrol_new lol_output_mixer_controls[] = { +SOC_DAPM_SINGLE ("R_DAC Switch" ,AIC32X4_LOLROUTE ,4 ,1 ,0 ),SOC_DAPM_SINGLE ("L_DAC Switch" ,AIC32X4_LOLROUTE ,3 ,1 ,0 ), +SOC_DAPM_SINGLE ("LOR Switch" ,AIC32X4_LOLROUTE ,0 ,1 ,0 ), };static const struct snd_kcontrol_new lor_output_mixer_controls[] = {
@@ -427,9 +432,6 @@ static const struct snd_soc_dapm_widget aic32x4_dapm_widgets[] = {SND_SOC_DAPM_PGA ("LOL Power" ,AIC32X4_OUTPWRCTL ,3 ,0 ,NULL ,0 ),SND_SOC_DAPM_DAC ("Right DAC" ,"Right Playback" ,AIC32X4_DACSETUP ,6 ,0 ), -SND_SOC_DAPM_MIXER ("HPR Output Mixer" ,SND_SOC_NOPM ,0 ,0 , - &hpr_output_mixer_controls[0 ], -ARRAY_SIZE (hpr_output_mixer_controls)),SND_SOC_DAPM_PGA ("HPR Power" ,AIC32X4_OUTPWRCTL ,4 ,0 ,NULL ,0 ), SND_SOC_DAPM_MIXER("LOR Output Mixer", SND_SOC_NOPM, 0, 0, &lor_output_mixer_controls[0],
@@ -487,6 +489,22 @@ static const struct snd_soc_dapm_widget aic32x4_dapm_widgets[] = { SND_SOC_DAPM_INPUT("CM_R"), }; +static const struct snd_soc_dapm_widget aic32x4_hpr_dapm_widgets[] = { +SND_SOC_DAPM_MIXER ("HPR Output Mixer" ,SND_SOC_NOPM ,0 ,0 , + &hpr_output_mixer_controls[0 ], +ARRAY_SIZE (hpr_output_mixer_controls)), +}; + +static const struct snd_soc_dapm_widget aic32x6_hpr_dapm_widgets[] = { +SND_SOC_DAPM_MIXER ("HPR Output Mixer" ,SND_SOC_NOPM ,0 ,0 , + &hpr_output_mixer_controls[0 ], +ARRAY_SIZE (hpr_output_mixer_controls) -1 ), +}; + +static const struct snd_soc_dapm_route aic32x4_extra_dapm_routes[] = { + {"HPR Output Mixer" ,"HPL Switch" ,"HPL Power" }, +}; +static const struct snd_soc_dapm_route aic32x4_dapm_routes[] = {/* Left Output */ {"HPL Output Mixer" ,"L_DAC Switch" ,"Left DAC" },
@@ -495,12 +513,15 @@ static const struct snd_soc_dapm_route aic32x4_dapm_routes[] = { {"HPL Power", NULL, "HPL Output Mixer"}, {"HPL", NULL, "HPL Power"}, + {"LOL Output Mixer", "R_DAC Switch", "Right DAC"}, {"LOL Output Mixer", "L_DAC Switch", "Left DAC"}, + {"LOL Output Mixer", "LOR Switch", "LOR Power"}, {"LOL Power", NULL, "LOL Output Mixer"}, {"LOL", NULL, "LOL Power"},/* Right Output */ + {"HPR Output Mixer", "L_DAC Switch", "Left DAC"}, {"HPR Output Mixer", "R_DAC Switch", "Right DAC"}, {"HPR Output Mixer", "IN1_R Switch", "IN1_R"},
@@ -961,14 +982,33 @@ static void aic32x4_setup_gpios(struct snd_soc_component *component)static int aic32x4_component_probe (struct snd_soc_component *component) { +struct snd_soc_dapm_context *dapm =snd_soc_component_to_dapm (component);struct aic32x4_priv *aic32x4 =snd_soc_component_get_drvdata (component);u32 tmp_reg; +int ret;struct clk *codec_clkin = aic32x4->clocks[AIC32X4_CLK_CODEC_CLKIN ].clk;struct clk *pll = aic32x4->clocks[AIC32X4_CLK_PLL ].clk;struct clk *bdiv = aic32x4->clocks[AIC32X4_CLK_BDIV ].clk;struct clk *mdac = aic32x4->clocks[AIC32X4_CLK_MDAC ].clk; +if (aic32x4->type ==AIC32X4_TYPE_AIC32X4 ) { + ret =snd_soc_dapm_new_controls (dapm, aic32x4_hpr_dapm_widgets, +ARRAY_SIZE (aic32x4_hpr_dapm_widgets)); +if (ret) +return ret; + + ret =snd_soc_dapm_add_routes (dapm, aic32x4_extra_dapm_routes, +ARRAY_SIZE (aic32x4_extra_dapm_routes)); +if (ret) +return ret; + }else { + ret =snd_soc_dapm_new_controls (dapm, aic32x6_hpr_dapm_widgets, +ARRAY_SIZE (aic32x6_hpr_dapm_widgets)); +if (ret) +return ret; + } +aic32x4_setup_gpios (component);clk_set_parent (codec_clkin, pll);
Signature · 1 line
2.25.1
PATCH v2 2/4 ASoC: tlv320aic32x4: Add Left and Right Mixer Amplifier DAPM support
In reply to Gianfranco MariottiThe TLV320AIC32x4 and TLV320AIC32x6 feature Left and Right Mixer Amplifiers (MAL and MAR, controlled by AIC32X4_OUTPWRCTL bits 1 and 0) that route amplified signals from the Left and Right MicPGAs directly to the headphone and line-out output mixers, bypassing the ADCs and DACs (TI SLAA557 / SLAA463 / SLAU306, Section 2.2.2):
- AIC32X4_HPLROUTE bit 1 (MAL) and bit 0 (MAR)
- AIC32X4_HPRROUTE bit 1 (MAR)
- AIC32X4_LOLROUTE bit 1 (MAL)
- AIC32X4_LORROUTE bit 1 (MAR)
Insert Left MicPGA and Right MicPGA DAPM PGA widgets between the input resistor muxes and the ADCs, feed MAL Power and MAR Power from the respective MicPGAs, and wire the MAL/MAR switches into the HPL, HPR, LOL, and LOR output mixers.
--- sound/soc/codecs/tlv320aic32x4.c | 48 ++++++++++++++++++++++---------- 1 file changed, 34 insertions(+), 14 deletions(-)
sound/soc/codecs/tlv320aic32x4.c +34 -14
@@ -320,12 +320,15 @@ static const struct snd_kcontrol_new aic32x4_snd_controls[] = {static const struct snd_kcontrol_new hpl_output_mixer_controls[] = {SOC_DAPM_SINGLE ("L_DAC Switch" ,AIC32X4_HPLROUTE ,3 ,1 ,0 ),SOC_DAPM_SINGLE ("IN1_L Switch" ,AIC32X4_HPLROUTE ,2 ,1 ,0 ), +SOC_DAPM_SINGLE ("MAL Switch" ,AIC32X4_HPLROUTE ,1 ,1 ,0 ), +SOC_DAPM_SINGLE ("MAR Switch" ,AIC32X4_HPLROUTE ,0 ,1 ,0 ), };static const struct snd_kcontrol_new hpr_output_mixer_controls[] = {SOC_DAPM_SINGLE ("L_DAC Switch" ,AIC32X4_HPRROUTE ,4 ,1 ,0 ),SOC_DAPM_SINGLE ("R_DAC Switch" ,AIC32X4_HPRROUTE ,3 ,1 ,0 ),SOC_DAPM_SINGLE ("IN1_R Switch" ,AIC32X4_HPRROUTE ,2 ,1 ,0 ), +SOC_DAPM_SINGLE ("MAR Switch" ,AIC32X4_HPRROUTE ,1 ,1 ,0 ),/* HPL Switch (bit 0) is AIC32x4-only; keep last for AIC32x6 */ SOC_DAPM_SINGLE ("HPL Switch" ,AIC32X4_HPRROUTE ,0 ,1 ,0 ), };
@@ -333,11 +336,13 @@ static const struct snd_kcontrol_new hpr_output_mixer_controls[] = {static const struct snd_kcontrol_new lol_output_mixer_controls[] = {SOC_DAPM_SINGLE ("R_DAC Switch" ,AIC32X4_LOLROUTE ,4 ,1 ,0 ),SOC_DAPM_SINGLE ("L_DAC Switch" ,AIC32X4_LOLROUTE ,3 ,1 ,0 ), +SOC_DAPM_SINGLE ("MAL Switch" ,AIC32X4_LOLROUTE ,1 ,1 ,0 ),SOC_DAPM_SINGLE ("LOR Switch" ,AIC32X4_LOLROUTE ,0 ,1 ,0 ), };static const struct snd_kcontrol_new lor_output_mixer_controls[] = {SOC_DAPM_SINGLE ("R_DAC Switch" ,AIC32X4_LORROUTE ,3 ,1 ,0 ), +SOC_DAPM_SINGLE ("MAR Switch" ,AIC32X4_LORROUTE ,1 ,1 ,0 ), };static const char *const resistor_text[] = {
@@ -425,6 +430,7 @@ static const struct snd_soc_dapm_widget aic32x4_dapm_widgets[] = { &hpl_output_mixer_controls[0], ARRAY_SIZE(hpl_output_mixer_controls)),SND_SOC_DAPM_PGA ("HPL Power" ,AIC32X4_OUTPWRCTL ,5 ,0 ,NULL ,0 ), +SND_SOC_DAPM_PGA ("MAL Power" ,AIC32X4_OUTPWRCTL ,1 ,0 ,NULL ,0 ), SND_SOC_DAPM_MIXER("LOL Output Mixer", SND_SOC_NOPM, 0, 0, &lol_output_mixer_controls[0],
@@ -433,12 +439,14 @@ static const struct snd_soc_dapm_widget aic32x4_dapm_widgets[] = {SND_SOC_DAPM_DAC ("Right DAC" ,"Right Playback" ,AIC32X4_DACSETUP ,6 ,0 ),SND_SOC_DAPM_PGA ("HPR Power" ,AIC32X4_OUTPWRCTL ,4 ,0 ,NULL ,0 ), +SND_SOC_DAPM_PGA ("MAR Power" ,AIC32X4_OUTPWRCTL ,0 ,0 ,NULL ,0 ),SND_SOC_DAPM_MIXER ("LOR Output Mixer" ,SND_SOC_NOPM ,0 ,0 , &lor_output_mixer_controls[0 ],ARRAY_SIZE (lor_output_mixer_controls)),SND_SOC_DAPM_PGA ("LOR Power" ,AIC32X4_OUTPWRCTL ,2 ,0 ,NULL ,0 ),SND_SOC_DAPM_ADC ("Right ADC" ,"Right Capture" ,AIC32X4_ADCSETUP ,6 ,0 ), +SND_SOC_DAPM_PGA ("Right MicPGA" ,SND_SOC_NOPM ,0 ,0 ,NULL ,0 ),SND_SOC_DAPM_MUX ("IN1_R to Right Mixer Positive Resistor" ,SND_SOC_NOPM ,0 ,0 , in1r_to_rmixer_controls), SND_SOC_DAPM_MUX("IN2_R to Right Mixer Positive Resistor", SND_SOC_NOPM, 0, 0,
@@ -455,6 +463,7 @@ static const struct snd_soc_dapm_widget aic32x4_dapm_widgets[] = { in3l_to_rmixer_controls),SND_SOC_DAPM_ADC ("Left ADC" ,"Left Capture" ,AIC32X4_ADCSETUP ,7 ,0 ), +SND_SOC_DAPM_PGA ("Left MicPGA" ,SND_SOC_NOPM ,0 ,0 ,NULL ,0 ),SND_SOC_DAPM_MUX ("IN1_L to Left Mixer Positive Resistor" ,SND_SOC_NOPM ,0 ,0 , in1l_to_lmixer_controls), SND_SOC_DAPM_MUX("IN2_L to Left Mixer Positive Resistor", SND_SOC_NOPM, 0, 0,
@@ -509,12 +518,15 @@ static const struct snd_soc_dapm_route aic32x4_dapm_routes[] = {/* Left Output */ {"HPL Output Mixer", "L_DAC Switch", "Left DAC"}, {"HPL Output Mixer", "IN1_L Switch", "IN1_L"}, + {"HPL Output Mixer", "MAL Switch", "MAL Power"}, + {"HPL Output Mixer", "MAR Switch", "MAR Power"}, {"HPL Power", NULL, "HPL Output Mixer"}, {"HPL", NULL, "HPL Power"}, {"LOL Output Mixer", "R_DAC Switch", "Right DAC"}, {"LOL Output Mixer", "L_DAC Switch", "Left DAC"}, + {"LOL Output Mixer", "MAL Switch", "MAL Power"}, {"LOL Output Mixer", "LOR Switch", "LOR Power"}, {"LOL Power", NULL, "LOL Output Mixer"},
@@ -524,83 +536,91 @@ static const struct snd_soc_dapm_route aic32x4_dapm_routes[] = { {"HPR Output Mixer", "L_DAC Switch", "Left DAC"}, {"HPR Output Mixer", "R_DAC Switch", "Right DAC"}, {"HPR Output Mixer", "IN1_R Switch", "IN1_R"}, + {"HPR Output Mixer", "MAR Switch", "MAR Power"}, {"HPR Power", NULL, "HPR Output Mixer"}, {"HPR", NULL, "HPR Power"}, {"LOR Output Mixer", "R_DAC Switch", "Right DAC"}, + {"LOR Output Mixer", "MAR Switch", "MAR Power"}, {"LOR Power", NULL, "LOR Output Mixer"}, {"LOR", NULL, "LOR Power"},/* Right Input */ - {"Right ADC", NULL, "IN1_R to Right Mixer Positive Resistor"}, + {"Right ADC", NULL, "Right MicPGA"}, + {"MAR Power", NULL, "Right MicPGA"}, + + {"Right MicPGA", NULL, "IN1_R to Right Mixer Positive Resistor"}, {"IN1_R to Right Mixer Positive Resistor", "10 kOhm", "IN1_R"}, {"IN1_R to Right Mixer Positive Resistor", "20 kOhm", "IN1_R"}, {"IN1_R to Right Mixer Positive Resistor", "40 kOhm", "IN1_R"}, - {"Right ADC", NULL, "IN2_R to Right Mixer Positive Resistor"}, + {"Right MicPGA", NULL, "IN2_R to Right Mixer Positive Resistor"}, {"IN2_R to Right Mixer Positive Resistor", "10 kOhm", "IN2_R"}, {"IN2_R to Right Mixer Positive Resistor", "20 kOhm", "IN2_R"}, {"IN2_R to Right Mixer Positive Resistor", "40 kOhm", "IN2_R"}, - {"Right ADC", NULL, "IN3_R to Right Mixer Positive Resistor"}, + {"Right MicPGA", NULL, "IN3_R to Right Mixer Positive Resistor"}, {"IN3_R to Right Mixer Positive Resistor", "10 kOhm", "IN3_R"}, {"IN3_R to Right Mixer Positive Resistor", "20 kOhm", "IN3_R"}, {"IN3_R to Right Mixer Positive Resistor", "40 kOhm", "IN3_R"}, - {"Right ADC", NULL, "IN2_L to Right Mixer Positive Resistor"}, + {"Right MicPGA", NULL, "IN2_L to Right Mixer Positive Resistor"}, {"IN2_L to Right Mixer Positive Resistor", "10 kOhm", "IN2_L"}, {"IN2_L to Right Mixer Positive Resistor", "20 kOhm", "IN2_L"}, {"IN2_L to Right Mixer Positive Resistor", "40 kOhm", "IN2_L"}, - {"Right ADC", NULL, "CM_R to Right Mixer Negative Resistor"}, + {"Right MicPGA", NULL, "CM_R to Right Mixer Negative Resistor"}, {"CM_R to Right Mixer Negative Resistor", "10 kOhm", "CM_R"}, {"CM_R to Right Mixer Negative Resistor", "20 kOhm", "CM_R"}, {"CM_R to Right Mixer Negative Resistor", "40 kOhm", "CM_R"}, - {"Right ADC", NULL, "IN1_L to Right Mixer Negative Resistor"}, + {"Right MicPGA", NULL, "IN1_L to Right Mixer Negative Resistor"}, {"IN1_L to Right Mixer Negative Resistor", "10 kOhm", "IN1_L"}, {"IN1_L to Right Mixer Negative Resistor", "20 kOhm", "IN1_L"}, {"IN1_L to Right Mixer Negative Resistor", "40 kOhm", "IN1_L"}, - {"Right ADC", NULL, "IN3_L to Right Mixer Negative Resistor"}, + {"Right MicPGA", NULL, "IN3_L to Right Mixer Negative Resistor"}, {"IN3_L to Right Mixer Negative Resistor", "10 kOhm", "IN3_L"}, {"IN3_L to Right Mixer Negative Resistor", "20 kOhm", "IN3_L"}, {"IN3_L to Right Mixer Negative Resistor", "40 kOhm", "IN3_L"},/* Left Input */ - {"Left ADC", NULL, "IN1_L to Left Mixer Positive Resistor"}, + {"Left ADC", NULL, "Left MicPGA"}, + {"MAL Power", NULL, "Left MicPGA"}, + + {"Left MicPGA", NULL, "IN1_L to Left Mixer Positive Resistor"}, {"IN1_L to Left Mixer Positive Resistor", "10 kOhm", "IN1_L"}, {"IN1_L to Left Mixer Positive Resistor", "20 kOhm", "IN1_L"}, {"IN1_L to Left Mixer Positive Resistor", "40 kOhm", "IN1_L"}, - {"Left ADC", NULL, "IN2_L to Left Mixer Positive Resistor"}, + {"Left MicPGA", NULL, "IN2_L to Left Mixer Positive Resistor"}, {"IN2_L to Left Mixer Positive Resistor", "10 kOhm", "IN2_L"}, {"IN2_L to Left Mixer Positive Resistor", "20 kOhm", "IN2_L"}, {"IN2_L to Left Mixer Positive Resistor", "40 kOhm", "IN2_L"}, - {"Left ADC", NULL, "IN3_L to Left Mixer Positive Resistor"}, + {"Left MicPGA", NULL, "IN3_L to Left Mixer Positive Resistor"}, {"IN3_L to Left Mixer Positive Resistor", "10 kOhm", "IN3_L"}, {"IN3_L to Left Mixer Positive Resistor", "20 kOhm", "IN3_L"}, {"IN3_L to Left Mixer Positive Resistor", "40 kOhm", "IN3_L"}, - {"Left ADC", NULL, "IN1_R to Left Mixer Positive Resistor"}, + {"Left MicPGA", NULL, "IN1_R to Left Mixer Positive Resistor"}, {"IN1_R to Left Mixer Positive Resistor", "10 kOhm", "IN1_R"}, {"IN1_R to Left Mixer Positive Resistor", "20 kOhm", "IN1_R"}, {"IN1_R to Left Mixer Positive Resistor", "40 kOhm", "IN1_R"}, - {"Left ADC", NULL, "CM_L to Left Mixer Negative Resistor"}, + {"Left MicPGA", NULL, "CM_L to Left Mixer Negative Resistor"}, {"CM_L to Left Mixer Negative Resistor", "10 kOhm", "CM_L"}, {"CM_L to Left Mixer Negative Resistor", "20 kOhm", "CM_L"}, {"CM_L to Left Mixer Negative Resistor", "40 kOhm", "CM_L"}, - {"Left ADC", NULL, "IN2_R to Left Mixer Negative Resistor"}, + {"Left MicPGA", NULL, "IN2_R to Left Mixer Negative Resistor"}, {"IN2_R to Left Mixer Negative Resistor", "10 kOhm", "IN2_R"}, {"IN2_R to Left Mixer Negative Resistor", "20 kOhm", "IN2_R"}, {"IN2_R to Left Mixer Negative Resistor", "40 kOhm", "IN2_R"}, - {"Left ADC", NULL, "IN3_R to Left Mixer Negative Resistor"}, + {"Left MicPGA", NULL, "IN3_R to Left Mixer Negative Resistor"}, {"IN3_R to Left Mixer Negative Resistor", "10 kOhm", "IN3_R"}, {"IN3_R to Left Mixer Negative Resistor", "20 kOhm", "IN3_R"}, {"IN3_R to Left Mixer Negative Resistor", "40 kOhm", "IN3_R"},
Signature · 1 line
2.25.1
PATCH v2 3/4 ASoC: tlv320aic32x4: Add IN1 and Mixer Amp analog bypass volume controls
In reply to Gianfranco MariottiThe 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.
---
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(+)
sound/soc/codecs/tlv320aic32x4.c +37 -0
@@ -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),
sound/soc/codecs/tlv320aic32x4.h +4 -0
@@ -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)
Signature · 1 line
2.25.1
PATCH v2 4/4 ASoC: tlv320aic32x4: Add CM2_L and CM2_R negative MicPGA input routing
In reply to Gianfranco MariottiBits 1:0 of AIC32X4_LMICPGANIN (Page 1, Register 54) and AIC32X4_RMICPGANIN (Page 1, Register 57) provide a second common-mode input resistor selection (CM2L / CM2R, Off / 10 kOhm / 20 kOhm / 40 kOhm) to the Left and Right MicPGA negative terminals, used to match input impedance when mixing multiple positive inputs.
Add the CM2_L and CM2_R DAPM mux widgets, enum controls, and routes sourced from CM_L and CM_R, preserving the existing CM_L and CM_R control names for ABI compatibility.
--- sound/soc/codecs/tlv320aic32x4.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)
sound/soc/codecs/tlv320aic32x4.c +24 -0
@@ -395,6 +395,7 @@ static SOC_ENUM_SINGLE_DECL(in1r_lpga_p_enum, AIC32X4_LMICPGAPIN, 0, resistor_te static SOC_ENUM_SINGLE_DECL(cml_lpga_n_enum, AIC32X4_LMICPGANIN, 6, resistor_text); static SOC_ENUM_SINGLE_DECL(in2r_lpga_n_enum, AIC32X4_LMICPGANIN, 4, resistor_text); static SOC_ENUM_SINGLE_DECL(in3r_lpga_n_enum, AIC32X4_LMICPGANIN, 2, resistor_text); +static SOC_ENUM_SINGLE_DECL(cm2l_lpga_n_enum, AIC32X4_LMICPGANIN, 0, resistor_text);static const struct snd_kcontrol_new in1l_to_lmixer_controls[] = {SOC_DAPM_ENUM ("IN1_L L+ Switch" , in1l_lpga_p_enum),
@@ -424,6 +425,10 @@ static const struct snd_kcontrol_new in3r_to_lmixer_controls[] = { SOC_DAPM_ENUM("IN3_R L- Switch", in3r_lpga_n_enum), }; +static const struct snd_kcontrol_new cm2l_to_lmixer_controls[] = { +SOC_DAPM_ENUM ("CM2_L L- Switch" , cm2l_lpga_n_enum), +}; +/* Right mixer pins */ static SOC_ENUM_SINGLE_DECL(in1r_rpga_p_enum, AIC32X4_RMICPGAPIN, 6, resistor_text); static SOC_ENUM_SINGLE_DECL(in2r_rpga_p_enum, AIC32X4_RMICPGAPIN, 4, resistor_text);
@@ -432,6 +437,7 @@ static SOC_ENUM_SINGLE_DECL(in2l_rpga_p_enum, AIC32X4_RMICPGAPIN, 0, resistor_te static SOC_ENUM_SINGLE_DECL(cmr_rpga_n_enum, AIC32X4_RMICPGANIN, 6, resistor_text); static SOC_ENUM_SINGLE_DECL(in1l_rpga_n_enum, AIC32X4_RMICPGANIN, 4, resistor_text); static SOC_ENUM_SINGLE_DECL(in3l_rpga_n_enum, AIC32X4_RMICPGANIN, 2, resistor_text); +static SOC_ENUM_SINGLE_DECL(cm2r_rpga_n_enum, AIC32X4_RMICPGANIN, 0, resistor_text);static const struct snd_kcontrol_new in1r_to_rmixer_controls[] = {SOC_DAPM_ENUM ("IN1_R R+ Switch" , in1r_rpga_p_enum),
@@ -461,6 +467,10 @@ static const struct snd_kcontrol_new in3l_to_rmixer_controls[] = { SOC_DAPM_ENUM("IN3_L R- Switch", in3l_rpga_n_enum), }; +static const struct snd_kcontrol_new cm2r_to_rmixer_controls[] = { +SOC_DAPM_ENUM ("CM2_R R- Switch" , cm2r_rpga_n_enum), +}; +static const struct snd_soc_dapm_widget aic32x4_dapm_widgets[] = {SND_SOC_DAPM_DAC ("Left DAC" ,"Left Playback" ,AIC32X4_DACSETUP ,7 ,0 ), SND_SOC_DAPM_MIXER("HPL Output Mixer", SND_SOC_NOPM, 0, 0,
@@ -498,6 +508,8 @@ static const struct snd_soc_dapm_widget aic32x4_dapm_widgets[] = { in1l_to_rmixer_controls),SND_SOC_DAPM_MUX ("IN3_L to Right Mixer Negative Resistor" ,SND_SOC_NOPM ,0 ,0 , in3l_to_rmixer_controls), +SND_SOC_DAPM_MUX ("CM2_R to Right Mixer Negative Resistor" ,SND_SOC_NOPM ,0 ,0 , + cm2r_to_rmixer_controls),SND_SOC_DAPM_ADC ("Left ADC" ,"Left Capture" ,AIC32X4_ADCSETUP ,7 ,0 ), SND_SOC_DAPM_PGA("Left MicPGA", SND_SOC_NOPM, 0, 0, NULL, 0),
@@ -515,6 +527,8 @@ static const struct snd_soc_dapm_widget aic32x4_dapm_widgets[] = { in2r_to_lmixer_controls),SND_SOC_DAPM_MUX ("IN3_R to Left Mixer Negative Resistor" ,SND_SOC_NOPM ,0 ,0 , in3r_to_lmixer_controls), +SND_SOC_DAPM_MUX ("CM2_L to Left Mixer Negative Resistor" ,SND_SOC_NOPM ,0 ,0 , + cm2l_to_lmixer_controls),SND_SOC_DAPM_SUPPLY ("Mic Bias" ,AIC32X4_MICBIAS ,6 ,0 , mic_bias_event, SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD),
@@ -623,6 +637,11 @@ static const struct snd_soc_dapm_route aic32x4_dapm_routes[] = { {"IN3_L to Right Mixer Negative Resistor", "20 kOhm", "IN3_L"}, {"IN3_L to Right Mixer Negative Resistor", "40 kOhm", "IN3_L"}, + {"Right MicPGA", NULL, "CM2_R to Right Mixer Negative Resistor"}, + {"CM2_R to Right Mixer Negative Resistor", "10 kOhm", "CM_R"}, + {"CM2_R to Right Mixer Negative Resistor", "20 kOhm", "CM_R"}, + {"CM2_R to Right Mixer Negative Resistor", "40 kOhm", "CM_R"}, +/* Left Input */ {"Left ADC", NULL, "Left MicPGA"}, {"MAL Power", NULL, "Left MicPGA"},
@@ -661,6 +680,11 @@ static const struct snd_soc_dapm_route aic32x4_dapm_routes[] = { {"IN3_R to Left Mixer Negative Resistor", "10 kOhm", "IN3_R"}, {"IN3_R to Left Mixer Negative Resistor", "20 kOhm", "IN3_R"}, {"IN3_R to Left Mixer Negative Resistor", "40 kOhm", "IN3_R"}, + + {"Left MicPGA", NULL, "CM2_L to Left Mixer Negative Resistor"}, + {"CM2_L to Left Mixer Negative Resistor", "10 kOhm", "CM_L"}, + {"CM2_L to Left Mixer Negative Resistor", "20 kOhm", "CM_L"}, + {"CM2_L to Left Mixer Negative Resistor", "40 kOhm", "CM_L"}, }; const struct regmap_range_cfg aic32x4_regmap_pages[] = {
Signature · 1 line
2.25.1
Mark Brown
maintainerQuoted 11 lines · Gianfranco Mariotti
ASoC: tlv320aic32x4: Complete analog routing, Mixer Amp bypass, and volume controls
The TLV320AIC32x4 driver currently exposes only a subset of the codec's analog input/output routing switches and omits support for its Left and Right Mixer Amplifiers (MAL/MAR) and analog bypass volume attenuators.
This series completes the analog DAPM topology and mixer controls per the TI TLV320AIC3204/3254 (SLAA557 / SLAA408) and TLV320AIC3206/3256 (SLAA463 / SLAU306) Application Reference Guides:
[...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-7.5
Thanks!
[1/4] ASoC: tlv320aic32x4: Add missing DAC and driver output mixer routes
https://git.kernel.org/broonie/sound/c/6e32ddd4201f [2/4] ASoC: tlv320aic32x4: Add Left and Right Mixer Amplifier DAPM support https://git.kernel.org/broonie/sound/c/8422bf6cbaa0 [3/4] ASoC: tlv320aic32x4: Add IN1 and Mixer Amp analog bypass volume controls https://git.kernel.org/broonie/sound/c/b04cbc99c7cd [4/4] ASoC: tlv320aic32x4: Add CM2_L and CM2_R negative MicPGA input routing https://git.kernel.org/broonie/sound/c/a355ef72a14f
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark