diff mbox series

[7/9] ASoC: ssm2602: Add mute gpio

Message ID 168154976963.26.12831314436545841195@mailman-core.alsa-project.org
State New
Headers show
Series [1/9] ASoC: Add Chameleon v3 audio | expand

Commit Message

Paweł Anikiel April 14, 2023, 2:02 p.m. UTC
The SSM2603 has a hardware mute pin. Add an optional mute gpio to
control it.

Signed-off-by: Paweł Anikiel <pan@semihalf.com>
---
 sound/soc/codecs/ssm2602.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
diff mbox series

Patch

diff --git a/sound/soc/codecs/ssm2602.c b/sound/soc/codecs/ssm2602.c
index 35c4743e756e..dd81e62d7a3b 100644
--- a/sound/soc/codecs/ssm2602.c
+++ b/sound/soc/codecs/ssm2602.c
@@ -14,6 +14,7 @@ 
 #include <linux/delay.h>
 #include <linux/module.h>
 #include <linux/regmap.h>
+#include <linux/gpio/consumer.h>
 #include <linux/slab.h>
 
 #include <sound/pcm.h>
@@ -32,6 +33,8 @@  struct ssm2602_priv {
 
 	enum ssm2602_type type;
 	unsigned int clk_out_pwr;
+
+	struct gpio_desc *mute_gpiod;
 };
 
 /*
@@ -352,6 +355,10 @@  static int ssm2602_mute(struct snd_soc_dai *dai, int mute, int direction)
 	else
 		regmap_update_bits(ssm2602->regmap, SSM2602_APDIGI,
 				    APDIGI_ENABLE_DAC_MUTE, 0);
+
+	if (ssm2602->mute_gpiod)
+		gpiod_set_value_cansleep(ssm2602->mute_gpiod, mute);
+
 	return 0;
 }
 
@@ -680,6 +687,10 @@  int ssm2602_probe(struct device *dev, enum ssm2602_type type,
 	ssm2602->type = type;
 	ssm2602->regmap = regmap;
 
+	ssm2602->mute_gpiod = devm_gpiod_get_optional(dev, "mute", GPIOD_OUT_LOW);
+	if (IS_ERR(ssm2602->mute_gpiod))
+		return PTR_ERR(ssm2602->mute_gpiod);
+
 	return devm_snd_soc_register_component(dev, &soc_component_dev_ssm2602,
 		&ssm2602_dai, 1);
 }