diff mbox series

[08/14] Remove the mute control

Message ID 20230106091543.2440-9-kiseok.jo@irondevice.com
State New
Headers show
Series ASoC: Add a driver the Iron Device SMA1303 AMP | expand

Commit Message

Kiseok Jo Jan. 6, 2023, 9:15 a.m. UTC
Remove the mute control and add the force mute control instead.
Already used the dai mute_stream.

Signed-off-by: Kiseok Jo <kiseok.jo@irondevice.com>
---
 sound/soc/codecs/sma1303.c | 72 +++++++++++++++++++++++++-------------
 1 file changed, 47 insertions(+), 25 deletions(-)
diff mbox series

Patch

diff --git a/sound/soc/codecs/sma1303.c b/sound/soc/codecs/sma1303.c
index 1199302af01d..3a60927e20aa 100644
--- a/sound/soc/codecs/sma1303.c
+++ b/sound/soc/codecs/sma1303.c
@@ -68,6 +68,7 @@  struct sma1303_priv {
 	struct regmap *regmap;
 	struct sma1303_pll_match *pll_matches;
 	bool amp_power_status;
+	bool force_mute_status;
 	int num_of_pll_matches;
 	int retry_cnt;
 	unsigned int amp_mode;
@@ -351,14 +352,6 @@  static int bytes_ext_put(struct snd_kcontrol *kcontrol,
 	return 0;
 }
 
-static const char * const sma1303_spkmute_text[] = {
-	"Unmute", "Mute"};
-
-static const struct soc_enum sma1303_spkmute_enum =
-	SOC_ENUM_SINGLE(SMA1303_0E_MUTE_VOL_CTRL, 0,
-			ARRAY_SIZE(sma1303_spkmute_text),
-			sma1303_spkmute_text);
-
 static int postscaler_get(struct snd_kcontrol *kcontrol,
 				struct snd_ctl_elem_value *ucontrol)
 {
@@ -445,6 +438,34 @@  static const struct soc_enum sma1303_aif_out_source_enum =
 	SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(sma1303_aif_out_source_text),
 			sma1303_aif_out_source_text);
 
+static int sma1303_force_mute_get(struct snd_kcontrol *kcontrol,
+				struct snd_ctl_elem_value *ucontrol)
+{
+	struct snd_soc_component *component =
+		snd_soc_kcontrol_component(kcontrol);
+	struct sma1303_priv *sma1303 = snd_soc_component_get_drvdata(component);
+
+	ucontrol->value.integer.value[0] = (int)sma1303->force_mute_status;
+	dev_info(sma1303->dev, "%s : Force Mute %s\n", __func__,
+			sma1303->force_mute_status ? "ON" : "OFF");
+
+	return 0;
+}
+
+static int sma1303_force_mute_put(struct snd_kcontrol *kcontrol,
+				struct snd_ctl_elem_value *ucontrol)
+{
+	struct snd_soc_component *component =
+		snd_soc_kcontrol_component(kcontrol);
+	struct sma1303_priv *sma1303 = snd_soc_component_get_drvdata(component);
+
+	sma1303->force_mute_status = (bool)ucontrol->value.integer.value[0];
+	dev_info(sma1303->dev, "%s : Force Mute %s\n", __func__,
+			sma1303->force_mute_status ? "ON" : "OFF");
+
+	return 0;
+}
+
 static int sma1303_startup(struct snd_soc_component *component)
 {
 	struct sma1303_priv *sma1303 = snd_soc_component_get_drvdata(component);
@@ -484,9 +505,6 @@  static int sma1303_startup(struct snd_soc_component *component)
 					CHECK_PERIOD_TIME * HZ);
 	}
 
-	ret += sma1303_regmap_update_bits(sma1303, SMA1303_0E_MUTE_VOL_CTRL,
-			SMA1303_SPK_MUTE_MASK, SMA1303_SPK_UNMUTE);
-
 	sma1303->amp_power_status = true;
 
 	return ret;
@@ -503,9 +521,6 @@  static int sma1303_shutdown(struct snd_soc_component *component)
 		return ret;
 	}
 
-	ret += sma1303_regmap_update_bits(sma1303, SMA1303_0E_MUTE_VOL_CTRL,
-			SMA1303_SPK_MUTE_MASK, SMA1303_SPK_MUTE);
-
 	cancel_delayed_work_sync(&sma1303->check_fault_work);
 
 	msleep(55);
@@ -743,13 +758,14 @@  static const struct snd_kcontrol_new sma1303_enable_control =
 	SOC_DAPM_SINGLE_VIRT("Switch", 1);
 
 static const struct snd_kcontrol_new sma1303_snd_controls[] = {
-SOC_SINGLE_TLV("Speaker Volume", SMA1303_0A_SPK_VOL,
+	SOC_SINGLE_TLV("Speaker Volume", SMA1303_0A_SPK_VOL,
 		0, 167, 1, sma1303_spk_tlv),
-SOC_ENUM("Speaker Mute Switch", sma1303_spkmute_enum),
-SND_SOC_BYTES_EXT("Postscaler Set", 1,
+	SND_SOC_BYTES_EXT("Postscaler Set", 1,
 		postscaler_get, postscaler_put),
-SOC_ENUM_EXT("Postscaler Config", sma1303_postscaler_config_enum,
-	sma1303_postscaler_config_get, sma1303_postscaler_config_put),
+	SOC_ENUM_EXT("Postscaler Config", sma1303_postscaler_config_enum,
+		sma1303_postscaler_config_get, sma1303_postscaler_config_put),
+	SOC_SINGLE_BOOL_EXT("Force Mute", 0,
+		sma1303_force_mute_get, sma1303_force_mute_put),
 };
 
 static const struct snd_soc_dapm_widget sma1303_dapm_widgets[] = {
@@ -1084,12 +1100,17 @@  static int sma1303_dai_mute(struct snd_soc_dai *dai, int mute, int stream)
 				SMA1303_SPK_MUTE_MASK,
 				SMA1303_SPK_MUTE);
 	} else {
-		dev_info(component->dev, "%s : %s\n", __func__, "UNMUTE");
-
-		ret += sma1303_regmap_update_bits(sma1303,
-				SMA1303_0E_MUTE_VOL_CTRL,
-				SMA1303_SPK_MUTE_MASK,
-				SMA1303_SPK_UNMUTE);
+		if (!sma1303->force_mute_status) {
+			dev_info(component->dev, "%s : %s\n",
+					__func__, "UNMUTE");
+			ret += sma1303_regmap_update_bits(sma1303,
+					SMA1303_0E_MUTE_VOL_CTRL,
+					SMA1303_SPK_MUTE_MASK,
+					SMA1303_SPK_UNMUTE);
+		} else {
+			dev_info(sma1303->dev,
+					"%s : FORCE MUTE!!!\n", __func__);
+		}
 	}
 
 	return ret;
@@ -1728,6 +1749,7 @@  static int sma1303_i2c_probe(struct i2c_client *client,
 
 	sma1303->amp_mode = SMA1303_MONO;
 	sma1303->amp_power_status = false;
+	sma1303->force_mute_status = false;
 	sma1303->check_fault_status = true;
 	sma1303->pll_matches = sma1303_pll_matches;
 	sma1303->num_of_pll_matches =