From ecbee1c72ab465d57215f59c22c9f503e31fe324 Mon Sep 17 00:00:00 2001 From: Xing Zheng Date: Fri, 7 Aug 2020 09:10:53 +0800 Subject: [PATCH] ASoC: wm8974: add support enable/disable micbias during capturing Signed-off-by: Xing Zheng Change-Id: I3696c0c73db6550795d192442d6bba41cea5086d --- sound/soc/codecs/wm8974.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/sound/soc/codecs/wm8974.c b/sound/soc/codecs/wm8974.c index c86231dfcf4f..c55bf9208754 100644 --- a/sound/soc/codecs/wm8974.c +++ b/sound/soc/codecs/wm8974.c @@ -613,6 +613,32 @@ static int wm8974_set_bias_level(struct snd_soc_component *component, return 0; } +static int wm8974_startup(struct snd_pcm_substream *substream, + struct snd_soc_dai *dai) +{ + struct snd_soc_component *component = dai->component; + u16 power1 = snd_soc_component_read(component, WM8974_POWER1); + + if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) { + power1 |= 0x10; + snd_soc_component_write(component, WM8974_POWER1, power1); + } + + return 0; +} + +static void wm8974_shutdown(struct snd_pcm_substream *substream, + struct snd_soc_dai *dai) +{ + struct snd_soc_component *component = dai->component; + u16 power1 = snd_soc_component_read(component, WM8974_POWER1); + + if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) { + power1 &= ~0x10; + snd_soc_component_write(component, WM8974_POWER1, power1); + } +} + #define WM8974_RATES (SNDRV_PCM_RATE_8000_48000) #define WM8974_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE |\ @@ -625,6 +651,8 @@ static const struct snd_soc_dai_ops wm8974_ops = { .set_clkdiv = wm8974_set_dai_clkdiv, .set_pll = wm8974_set_dai_pll, .set_sysclk = wm8974_set_dai_sysclk, + .startup = wm8974_startup, + .shutdown = wm8974_shutdown, .no_capture_mute = 1, };