Skip to content
Snippets Groups Projects
Commit 6f6e2a98 authored by Oleksii Kutuzov's avatar Oleksii Kutuzov
Browse files

[DRIVER][SOUND] wm8983: Add mute control functionality

parent 3ff4b803
No related branches found
No related tags found
No related merge requests found
......@@ -16,6 +16,7 @@
#include <linux/regmap.h>
#include <linux/spi/spi.h>
#include <linux/slab.h>
#include <linux/gpio/consumer.h>
#include <sound/core.h>
#include <sound/pcm.h>
#include <sound/pcm_params.h>
......@@ -96,9 +97,11 @@ static const int vol_update_regs[] = {
};
struct wm8983_priv {
struct clk *mclk;
struct regmap *regmap;
u32 sysclk;
u32 bclk;
struct gpio_desc *mute;
};
static const struct {
......@@ -567,6 +570,10 @@ static bool wm8983_writeable(struct device *dev, unsigned int reg)
static int wm8983_dac_mute(struct snd_soc_dai *dai, int mute, int direction)
{
struct snd_soc_component *component = dai->component;
struct wm8983_priv *wm8983 = snd_soc_component_get_drvdata(component);
if (wm8983->mute)
gpiod_set_value_cansleep(wm8983->mute, mute);
return snd_soc_component_update_bits(component, WM8983_DAC_CONTROL,
WM8983_SOFTMUTE_MASK,
......@@ -833,6 +840,9 @@ static int wm8983_startup(struct snd_pcm_substream *substream,
struct snd_soc_component *component = dai->component;
struct wm8983_priv *wm8983 = snd_soc_component_get_drvdata(component);
if (wm8983->mute)
gpiod_set_value_cansleep(wm8983->mute, 1);
return 0;
}
......@@ -841,6 +851,9 @@ static void wm8983_shutdown(struct snd_pcm_substream *substream,
{
struct snd_soc_component *component = dai->component;
struct wm8983_priv *wm8983 = snd_soc_component_get_drvdata(component);
if (wm8983->mute)
gpiod_set_value_cansleep(wm8983->mute, 0);
}
static int wm8983_set_sysclk(struct snd_soc_dai *dai,
......@@ -1044,6 +1057,12 @@ static int wm8983_i2c_probe(struct i2c_client *i2c,
return ret;
}
wm8983->mute = devm_gpiod_get(&i2c->dev, "mute", GPIOD_OUT_LOW);
if (IS_ERR(wm8983->mute)) {
dev_err(&i2c->dev, "Failed to get mute line: %ld\n", PTR_ERR(wm8983->mute));
wm8983->mute = NULL;
}
i2c_set_clientdata(i2c, wm8983);
ret = devm_snd_soc_register_component(&i2c->dev,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment