From b22cb46be7bd26b189ef2cb677d4b748a99ef285 Mon Sep 17 00:00:00 2001 From: Shunhua Lan Date: Thu, 6 Jan 2022 11:34:44 +0800 Subject: [PATCH] ASoC: hdmi-codec: pcm stop when plug out Signed-off-by: Shunhua Lan Change-Id: I1507dc6b92a0342e6b3d86472618f90dc721e779 --- sound/soc/codecs/hdmi-codec.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/sound/soc/codecs/hdmi-codec.c b/sound/soc/codecs/hdmi-codec.c index f5c1f15f83d7..f0a05fd71d84 100644 --- a/sound/soc/codecs/hdmi-codec.c +++ b/sound/soc/codecs/hdmi-codec.c @@ -278,6 +278,7 @@ struct hdmi_codec_priv { struct snd_soc_jack *jack; unsigned int jack_status; u8 iec_status[24]; + struct snd_pcm_substream *substream; }; static const struct snd_soc_dapm_widget hdmi_widgets[] = { @@ -462,6 +463,7 @@ static int hdmi_codec_startup(struct snd_pcm_substream *substream, } hcp->busy = true; + hcp->substream = substream; err: mutex_unlock(&hcp->lock); @@ -477,6 +479,7 @@ static void hdmi_codec_shutdown(struct snd_pcm_substream *substream, hcp->hcd.ops->audio_shutdown(dai->dev->parent, hcp->hcd.data); mutex_lock(&hcp->lock); + hcp->substream = NULL; hcp->busy = false; mutex_unlock(&hcp->lock); } @@ -842,6 +845,10 @@ static void plugged_cb(struct device *dev, bool plugged) hdmi_codec_jack_report(hcp, 0); memset(hcp->eld, 0, sizeof(hcp->eld)); } + mutex_lock(&hcp->lock); + if (hcp->substream && !plugged) + snd_pcm_stop(hcp->substream, SNDRV_PCM_STATE_DISCONNECTED); + mutex_unlock(&hcp->lock); } static int hdmi_codec_set_jack(struct snd_soc_component *component,