From 0bea87a8bc64f9a38ac21ae826037230a935d753 Mon Sep 17 00:00:00 2001 From: Libin Yang Date: Fri, 16 Nov 2018 15:39:56 +0800 Subject: [PATCH] ASoC: SOF: error handling for display audio This patch handles the operation after display audio is initialized wrong. Signed-off-by: Libin Yang --- sound/soc/sof/intel/hda-dsp.c | 6 ++++-- sound/soc/sof/intel/hda.c | 14 +++++++++++--- sound/soc/sof/sof-priv.h | 3 +++ 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/sound/soc/sof/intel/hda-dsp.c b/sound/soc/sof/intel/hda-dsp.c index 4d7028ff7a9c09..9d41fa4455007c 100644 --- a/sound/soc/sof/intel/hda-dsp.c +++ b/sound/soc/sof/intel/hda-dsp.c @@ -379,7 +379,8 @@ int hda_dsp_resume(struct snd_sof_dev *sdev) int ret; /* turn display power on */ - if (IS_ENABLED(CONFIG_SND_SOC_HDAC_HDMI)) { + if (IS_ENABLED(CONFIG_SND_SOC_HDAC_HDMI) && + sdev->display_audio) { ret = snd_hdac_display_power(bus, true); if (ret < 0) { dev_err(bus->dev, "Cannot turn on display power on i915 after resume\n"); @@ -416,7 +417,8 @@ int hda_dsp_suspend(struct snd_sof_dev *sdev, int state) } /* turn display power off */ - if (IS_ENABLED(CONFIG_SND_SOC_HDAC_HDMI)) { + if (IS_ENABLED(CONFIG_SND_SOC_HDAC_HDMI) && + sdev->display_audio) { ret = snd_hdac_display_power(bus, false); if (ret < 0) { dev_err(bus->dev, "Cannot turn OFF display power on i915 during suspend\n"); diff --git a/sound/soc/sof/intel/hda.c b/sound/soc/sof/intel/hda.c index 63d2d0a3a6e62c..e98f045de9b61b 100644 --- a/sound/soc/sof/intel/hda.c +++ b/sound/soc/sof/intel/hda.c @@ -451,15 +451,22 @@ static int hda_init_caps(struct snd_sof_dev *sdev) if (IS_ENABLED(CONFIG_SND_SOC_HDAC_HDMI)) { ret = hda_codec_i915_init(sdev); if (ret < 0) { + sdev->display_audio = 0; dev_err(&pci->dev, "no HDMI audio devices found\n"); - return ret; + } else { + sdev->display_audio = 1; } } ret = hda_dsp_ctrl_init_chip(sdev, true); if (ret < 0) { dev_err(bus->dev, "Init chip failed with ret: %d\n", ret); - if (IS_ENABLED(CONFIG_SND_SOC_HDAC_HDMI)) + /* + * If display_audio is false, we should not turn off display + * power here as it is never turned on by audio driver. + */ + if (IS_ENABLED(CONFIG_SND_SOC_HDAC_HDMI) && + sdev->display_audio) snd_hdac_display_power(bus, false); return ret; } @@ -476,7 +483,8 @@ static int hda_init_caps(struct snd_sof_dev *sdev) /* create codec instances */ hda_codec_probe_bus(sdev); - if (IS_ENABLED(CONFIG_SND_SOC_HDAC_HDMI)) { + if (IS_ENABLED(CONFIG_SND_SOC_HDAC_HDMI) && + sdev->display_audio) { ret = snd_hdac_display_power(bus, false); if (ret < 0) { dev_err(bus->dev, "Cannot turn off display power on i915\n"); diff --git a/sound/soc/sof/sof-priv.h b/sound/soc/sof/sof-priv.h index d5f386e81eef46..f97e2f7214e5ea 100644 --- a/sound/soc/sof/sof-priv.h +++ b/sound/soc/sof/sof-priv.h @@ -384,6 +384,9 @@ struct snd_sof_dev { u32 restore_kcontrols; /* restore kcontrols upon resume */ u32 first_boot; + /* display audio */ + int display_audio; /* HDMI/DP audio is used or not */ + void *private; /* core does not touch this */ };