ALSA: hda/hdmi: add keep-alive support for ADL-P and DG2
PATCH 1/1 ALSA: hda/hdmi: add keep-alive support for ADL-P and DG2
Implement HDA keep alive (KAE) support for Intel display codecs. When no audio stream is active, the display codec will provide a continuous clock and a valid but silent audio stream to any connected HDMI/DP receiver. Without this, upon starting a new playback stream, initial samples may be lost as many receivers require time to initialize for new clock.
This is a new feature in Intel AlderLake-P display codec implementation and replaces the Intel i915 silent-stream extension that has been used on older hardware. Main benefit of the new method is that codec no longer needs to be kept in D0 power state.
This patch depends on commit 112a87c48e83 ("drm/i915/display: program audio CDCLK-TS for keepalives").
---
Hi,
with newer Intel hardware, we can support the HDMI/DP silent-stream/keep-alive with standard HDA KAE bit. This patch only enables KAE for Intel hardware, but the patch is done in a way to allow other vendor's to opt-in and use the same KAE code. As I can't validate this for other hw, I only enable the feature for hw I have. The Intel specific implementation is put under SILENT_STREAM_I915 and it continues to be used for older hardware.
sound/pci/hda/Kconfig | 19 ++--- sound/pci/hda/patch_hdmi.c | 152 +++++++++++++++++++++++++++---------- 2 files changed, 122 insertions(+), 49 deletions(-)
sound/pci/hda/Kconfig +10 -9
@@ -285,15 +285,16 @@ config SND_HDA_INTEL_HDMI_SILENT_STREAM bool "Enable Silent Stream always for HDMI" depends on SND_HDA_INTEL help - Intel hardware has a feature called 'silent stream', that - keeps external HDMI receiver's analog circuitry powered on - avoiding 2-3 sec silence during playback start. This mechanism - relies on setting channel_id as 0xf, sending info packet and - preventing codec D3 entry (increasing platform static power - consumption when HDMI receiver is plugged-in). 2-3 sec silence - at the playback start is expected whenever there is format change. - (default is 2 channel format). - Say Y to enable Silent Stream feature. + Say Y to enable HD-Audio Keep Alive (KAE) aka Silent Stream + for HDMI on hardware that supports the feature. + + When enabled, the HDMI/DisplayPort codec will continue to provide + a continuous clock and a valid but silent data stream to + any connected external receiver. This allows to avoid gaps + at start of playback. Many receivers require multiple seconds + to start playing audio after the clock has been stopped. + This feature can impact power consumption as resources + are kept reserved both at transmitter and receiver. endif
sound/pci/hda/patch_hdmi.c +112 -40
235 lines not on this page · raw message
base-commit: fc30f8dd54d4b42ace4e0bcf356ba2f2e1d8a2c7
Signature · 1 line
2.35.1
Quoted 4 lines · Kai Vehmanen
static void silent_stream_disable(struct
hda_codec*codec,sound/pci/hda/patch_hdmi.c +0
-0@@ -1726,7 +1786,16 @@ static void silent_stream_disable(struct hda_codec *codec, {struct hdmi_spec *spec = codec->spec;
sound/pci/hda/patch_hdmi.c static void silent_stream_disable(struct hda_codec *codec, · line 1796
Quoted 10 lines
sound/pci/hda/patch_hdmi.c +8
-1struct hdmi_spec_per_cvt *per_cvt; -int cvt_idx; +int cvt_idx, err; + + err =snd_hda_power_up_pm (codec); +if (err <0 && err != -EACCES ) { +codec_err (codec, +"Failed to power up codec for silent stream disable ret=[%d]\n" , + err); +snd_hda_power_down_pm (codec);
If power up failed, do you need to power down?
Quoted 5 lines
sound/pci/hda/patch_hdmi.c +2
-0+return ; + }mutex_lock (&per_pin->lock);if (!per_pin->silent_stream)
Quoted 19 lines · On Wed, 16 Feb 2022 09:38:44 +0100, Amadeusz SX2awiX4ski wrote:
Quoted 4 lines · Kai Vehmanen
static void silent_stream_disable(struct
hda_codec*codec,sound/pci/hda/patch_hdmi.c +0
-0@@ -1726,7 +1786,16 @@ static void silent_stream_disable(struct hda_codec *codec, {struct hdmi_spec *spec = codec->spec;sound/pci/hda/patch_hdmi.c static void silent_stream_disable(struct hda_codec *codec, · line 1796
Quoted 10 lines
sound/pci/hda/patch_hdmi.c +8
-1struct hdmi_spec_per_cvt *per_cvt; -int cvt_idx; +int cvt_idx, err; + + err =snd_hda_power_up_pm (codec); +if (err <0 && err != -EACCES ) { +codec_err (codec, +"Failed to power up codec for silent stream disable ret=[%d]\n" , + err); +snd_hda_power_down_pm (codec);If power up failed, do you need to power down?
Yes, it's essentially pm_runtime_get(), and you need to put down also at an error path.
But, what I don't follow in the patch is about the part:
Quoted 3 lines
static void silent_stream_enable(struct
hda_codec*codec,
structhdmi_spec_per_pin*per_pin)
{
(snip)
sound/pci/hda/patch_hdmi.c static void silent_stream_enable(struct hda_codec *codec, · line 1781
Quoted 5 lines
unlock_out:sound/pci/hda/patch_hdmi.c +3
-0mutex_unlock (&per_pin->lock); + +if (err || !keep_power) +snd_hda_power_down_pm (codec);
So this may leave the power up. But where is the corresponding part that turns it down? The newly added snd_hda_power_up_pm() in silent_stream_disable() is paired with the one at the tail of that function, so it looks like a refcount unbalance. Kai?
thanks,
Takashi
Hi,
Quoted 3 lines · Takashi Iwai
Quoted 3 lines
static void silent_stream_enable(struct
hda_codec*codec,
structhdmi_spec_per_pin*per_pin)
{
(snip)
Quoted 10 lines
sound/pci/hda/patch_hdmi.c static void silent_stream_enable(struct hda_codec *codec, · line 1781
Quoted 5 lines
unlock_out:sound/pci/hda/patch_hdmi.c +3
-0mutex_unlock (&per_pin->lock); + +if (err || !keep_power) +snd_hda_power_down_pm (codec);So this may leave the power up. But where is the corresponding part that turns it down? The newly added
snd_hda_power_up_pm()insilent_stream_disable()is paired with the one at the tail of that function, so it looks like a refcount unbalance. Kai?
indeed it is. I'll send a V2 with this fixed.
Br, Kai