Takashi Iwai 1c7418
From ada261b690ecd5c2f55f0c51bdf11d852a4561a6 Mon Sep 17 00:00:00 2001
Takashi Iwai 1c7418
From: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Takashi Iwai 1c7418
Date: Fri, 9 Dec 2022 12:18:20 +0200
Takashi Iwai 1c7418
Subject: [PATCH] ALSA: hda/hdmi: fix i915 silent stream programming flow
Takashi Iwai 1c7418
Git-commit: ada261b690ecd5c2f55f0c51bdf11d852a4561a6
Takashi Iwai 1c7418
Patch-mainline: v6.2-rc1
Takashi Iwai 1c7418
References: git-fixes
Takashi Iwai 1c7418
Takashi Iwai 1c7418
The i915 display codec may not successfully transition to
Takashi Iwai 1c7418
normal audio streaming mode, if the stream id is programmed
Takashi Iwai 1c7418
while codec is actively transmitting data. This can happen
Takashi Iwai 1c7418
when silent stream is enabled in KAE mode.
Takashi Iwai 1c7418
Takashi Iwai 1c7418
Fix the issue by implementing a i915 specific programming
Takashi Iwai 1c7418
flow, where the silent streaming is temporarily stopped,
Takashi Iwai 1c7418
a small delay is applied to ensure display codec becomes
Takashi Iwai 1c7418
idle, and then proceed with reprogramming the stream ID.
Takashi Iwai 1c7418
Takashi Iwai 1c7418
Fixes: 15175a4f2bbb ("ALSA: hda/hdmi: add keep-alive support for ADL-P and DG2")
Takashi Iwai 1c7418
Link: https://gitlab.freedesktop.org/drm/intel/-/issues/7353
Takashi Iwai 1c7418
Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Takashi Iwai 1c7418
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Takashi Iwai 1c7418
Tested-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Takashi Iwai 1c7418
Link: https://lore.kernel.org/r/20221209101822.3893675-2-kai.vehmanen@linux.intel.com
Takashi Iwai 1c7418
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Takashi Iwai 1c7418
Takashi Iwai 1c7418
---
Takashi Iwai 1c7418
 sound/pci/hda/patch_hdmi.c | 28 ++++++++++++++++++++++++++--
Takashi Iwai 1c7418
 1 file changed, 26 insertions(+), 2 deletions(-)
Takashi Iwai 1c7418
Takashi Iwai 1c7418
diff --git a/sound/pci/hda/patch_hdmi.c b/sound/pci/hda/patch_hdmi.c
Takashi Iwai 1c7418
index 7a40ddfd695a..48bb23745ed3 100644
Takashi Iwai 1c7418
--- a/sound/pci/hda/patch_hdmi.c
Takashi Iwai 1c7418
+++ b/sound/pci/hda/patch_hdmi.c
Takashi Iwai 1c7418
@@ -2879,9 +2879,33 @@ static int i915_hsw_setup_stream(struct hda_codec *codec, hda_nid_t cvt_nid,
Takashi Iwai 1c7418
 				 hda_nid_t pin_nid, int dev_id, u32 stream_tag,
Takashi Iwai 1c7418
 				 int format)
Takashi Iwai 1c7418
 {
Takashi Iwai 1c7418
+	struct hdmi_spec *spec = codec->spec;
Takashi Iwai 1c7418
+	int pin_idx = pin_id_to_pin_index(codec, pin_nid, dev_id);
Takashi Iwai 1c7418
+	struct hdmi_spec_per_pin *per_pin;
Takashi Iwai 1c7418
+	int res;
Takashi Iwai 1c7418
+
Takashi Iwai 1c7418
+	if (pin_idx < 0)
Takashi Iwai 1c7418
+		per_pin = NULL;
Takashi Iwai 1c7418
+	else
Takashi Iwai 1c7418
+		per_pin = get_pin(spec, pin_idx);
Takashi Iwai 1c7418
+
Takashi Iwai 1c7418
 	haswell_verify_D0(codec, cvt_nid, pin_nid);
Takashi Iwai 1c7418
-	return hdmi_setup_stream(codec, cvt_nid, pin_nid, dev_id,
Takashi Iwai 1c7418
-				 stream_tag, format);
Takashi Iwai 1c7418
+
Takashi Iwai 1c7418
+	if (spec->silent_stream_type == SILENT_STREAM_KAE && per_pin && per_pin->silent_stream) {
Takashi Iwai 1c7418
+		silent_stream_set_kae(codec, per_pin, false);
Takashi Iwai 1c7418
+		/* wait for pending transfers in codec to clear */
Takashi Iwai 1c7418
+		usleep_range(100, 200);
Takashi Iwai 1c7418
+	}
Takashi Iwai 1c7418
+
Takashi Iwai 1c7418
+	res = hdmi_setup_stream(codec, cvt_nid, pin_nid, dev_id,
Takashi Iwai 1c7418
+				stream_tag, format);
Takashi Iwai 1c7418
+
Takashi Iwai 1c7418
+	if (spec->silent_stream_type == SILENT_STREAM_KAE && per_pin && per_pin->silent_stream) {
Takashi Iwai 1c7418
+		usleep_range(100, 200);
Takashi Iwai 1c7418
+		silent_stream_set_kae(codec, per_pin, true);
Takashi Iwai 1c7418
+	}
Takashi Iwai 1c7418
+
Takashi Iwai 1c7418
+	return res;
Takashi Iwai 1c7418
 }
Takashi Iwai 1c7418
 
Takashi Iwai 1c7418
 /* pin_cvt_fixup ops override for HSW+ and VLV+ */
Takashi Iwai 1c7418
-- 
Takashi Iwai 1c7418
2.35.3
Takashi Iwai 1c7418