Skip to content

Commit f022057

Browse files
Srinivas-Kandagatlabroonie
authored andcommitted
ASoC: soc-dai: add flag to mute and unmute stream during trigger
In some setups like Speaker amps which are very sensitive, ex: keeping them unmute without actual data stream for very short duration results in a static charge and results in pop and clicks. To minimize this, provide a way to mute and unmute such codecs during trigger callbacks. Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org> Tested-by: Johan Hovold <johan+linaro@kernel.org> Link: https://lore.kernel.org/r/20231027105747.32450-2-srinivas.kandagatla@linaro.org Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 168d978 commit f022057

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

include/sound/soc-dai.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,7 @@ struct snd_soc_dai_ops {
370370

371371
/* bit field */
372372
unsigned int no_capture_mute:1;
373+
unsigned int mute_unmute_on_trigger:1;
373374
};
374375

375376
struct snd_soc_cdai_ops {

sound/soc/soc-dai.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -658,6 +658,10 @@ int snd_soc_pcm_dai_trigger(struct snd_pcm_substream *substream,
658658
ret = soc_dai_trigger(dai, substream, cmd);
659659
if (ret < 0)
660660
break;
661+
662+
if (dai->driver->ops && dai->driver->ops->mute_unmute_on_trigger)
663+
snd_soc_dai_digital_mute(dai, 0, substream->stream);
664+
661665
soc_dai_mark_push(dai, substream, trigger);
662666
}
663667
break;
@@ -668,6 +672,9 @@ int snd_soc_pcm_dai_trigger(struct snd_pcm_substream *substream,
668672
if (rollback && !soc_dai_mark_match(dai, substream, trigger))
669673
continue;
670674

675+
if (dai->driver->ops && dai->driver->ops->mute_unmute_on_trigger)
676+
snd_soc_dai_digital_mute(dai, 1, substream->stream);
677+
671678
r = soc_dai_trigger(dai, substream, cmd);
672679
if (r < 0)
673680
ret = r; /* use last ret */

sound/soc/soc-pcm.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -703,8 +703,10 @@ static int soc_pcm_clean(struct snd_soc_pcm_runtime *rtd,
703703
if (snd_soc_dai_active(dai) == 0)
704704
soc_pcm_set_dai_params(dai, NULL);
705705

706-
if (snd_soc_dai_stream_active(dai, substream->stream) == 0)
707-
snd_soc_dai_digital_mute(dai, 1, substream->stream);
706+
if (snd_soc_dai_stream_active(dai, substream->stream) == 0) {
707+
if (dai->driver->ops && !dai->driver->ops->mute_unmute_on_trigger)
708+
snd_soc_dai_digital_mute(dai, 1, substream->stream);
709+
}
708710
}
709711
}
710712

@@ -898,8 +900,10 @@ static int __soc_pcm_prepare(struct snd_soc_pcm_runtime *rtd,
898900
snd_soc_dapm_stream_event(rtd, substream->stream,
899901
SND_SOC_DAPM_STREAM_START);
900902

901-
for_each_rtd_dais(rtd, i, dai)
902-
snd_soc_dai_digital_mute(dai, 0, substream->stream);
903+
for_each_rtd_dais(rtd, i, dai) {
904+
if (dai->driver->ops && !dai->driver->ops->mute_unmute_on_trigger)
905+
snd_soc_dai_digital_mute(dai, 0, substream->stream);
906+
}
903907

904908
out:
905909
return soc_pcm_ret(rtd, ret);

0 commit comments

Comments
 (0)