From a034a1f73cfa728ba80ceb7f5ab8179a963f0e43 Mon Sep 17 00:00:00 2001
From: Ondrej Jirman <megi@xff.cz>
Date: Fri, 14 Apr 2023 22:35:37 +0200
Subject: [PATCH 334/463] ASoC: codecs: rt5640: Add input mixer input volume
 controls

These are useful to attenuate strong signals from analog inputs.

Signed-off-by: Ondrej Jirman <megi@xff.cz>
---
 sound/soc/codecs/rt5640.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/sound/soc/codecs/rt5640.c b/sound/soc/codecs/rt5640.c
index de3a0b7112a3e..f66abf91aef6f 100644
--- a/sound/soc/codecs/rt5640.c
+++ b/sound/soc/codecs/rt5640.c
@@ -342,6 +342,7 @@ static const DECLARE_TLV_DB_MINMAX(dac_vol_tlv, -6562, 0);
 static const DECLARE_TLV_DB_SCALE(in_vol_tlv, -3450, 150, 0);
 static const DECLARE_TLV_DB_MINMAX(adc_vol_tlv, -1762, 3000);
 static const DECLARE_TLV_DB_SCALE(adc_bst_tlv, 0, 1200, 0);
+static const DECLARE_TLV_DB_MINMAX(rec_gain_tlv, -1800, 0);
 
 /* {0, +20, +24, +30, +35, +40, +44, +50, +52} dB */
 static const DECLARE_TLV_DB_RANGE(bst_tlv,
@@ -413,6 +414,19 @@ static const struct snd_kcontrol_new rt5640_snd_controls[] = {
 	SOC_SINGLE_TLV("IN3 Boost", RT5640_IN1_IN2,
 		RT5640_BST_SFT2, 8, 0, bst_tlv),
 
+	/* RECMIXL Gain Controls */
+	SOC_SINGLE_TLV("RECMIXL INL Gain", RT5640_REC_L1_MIXER, 10, 6, 1, rec_gain_tlv),
+	SOC_SINGLE_TLV("RECMIXL BST2 Gain", RT5640_REC_L1_MIXER, 7, 6, 1, rec_gain_tlv),
+	SOC_SINGLE_TLV("RECMIXL BST3 Gain", RT5640_REC_L1_MIXER, 1, 6, 1, rec_gain_tlv),
+	SOC_SINGLE_TLV("RECMIXL BST1 Gain", RT5640_REC_L2_MIXER, 13, 6, 1, rec_gain_tlv),
+	SOC_SINGLE_TLV("RECMIXL OUTMIXL Gain", RT5640_REC_L2_MIXER, 10, 6, 1, rec_gain_tlv),
+	
+	SOC_SINGLE_TLV("RECMIXR INR Gain", RT5640_REC_R1_MIXER, 10, 6, 1, rec_gain_tlv),
+	SOC_SINGLE_TLV("RECMIXR BST2 Gain", RT5640_REC_R1_MIXER, 7, 6, 1, rec_gain_tlv),
+	SOC_SINGLE_TLV("RECMIXR BST3 Gain", RT5640_REC_R1_MIXER, 1, 6, 1, rec_gain_tlv),
+	SOC_SINGLE_TLV("RECMIXR BST1 Gain", RT5640_REC_R2_MIXER, 13, 6, 1, rec_gain_tlv),
+	SOC_SINGLE_TLV("RECMIXR OUTMIXR Gain", RT5640_REC_R2_MIXER, 10, 6, 1, rec_gain_tlv),
+
 	/* INL/INR Volume Control */
 	SOC_DOUBLE_TLV("IN Capture Volume", RT5640_INL_INR_VOL,
 			RT5640_INL_VOL_SFT, RT5640_INR_VOL_SFT,
-- 
2.46.0

