Commit 090ddad4 authored by Takashi Iwai's avatar Takashi Iwai

ALSA: hda/hdmi: Static PCM mapping again with AMD HDMI codecs

The recent code refactoring for HD-audio HDMI codec driver caused a
regression on AMD/ATI HDMI codecs; namely, PulseAudioand pipewire
don't recognize HDMI outputs any longer while the direct output via
ALSA raw access still works.

The problem turned out that, after the code refactoring, the driver
assumes only the dynamic PCM assignment, and when a PCM stream that
still isn't assigned to any pin gets opened, the driver tries to
assign any free converter to the PCM stream.  This behavior is OK for
Intel and other codecs, as they have arbitrary connections between
pins and converters.  OTOH, on AMD chips that have a 1:1 mapping
between pins and converters, this may end up with blocking the open of
the next PCM stream for the pin that is tied with the formerly taken
converter.

Also, with the code refactoring, more PCM streams are exposed than
necessary as we assume all converters can be used, while this isn't
true for AMD case.  This may change the PCM stream assignment and
confuse users as well.

This patch fixes those problems by:

- Introducing a flag spec->static_pcm_mapping, and if it's set, the
  driver applies the static mapping between pins and converters at the
  probe time
- Limiting the number of PCM streams per pins, too; this avoids the
  superfluous PCM streams

Fixes: ef6f5494 ("ALSA: hda/hdmi: Use only dynamic PCM device allocation")
Cc: <stable@vger.kernel.org>
Link: https://bugzilla.kernel.org/show_bug.cgi?id=216836Co-developed-by: default avatarJaroslav Kysela <perex@perex.cz>
Signed-off-by: default avatarJaroslav Kysela <perex@perex.cz>
Link: https://lore.kernel.org/r/20221228125714.16329-1-tiwai@suse.deSigned-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent a4517c4f
...@@ -167,6 +167,7 @@ struct hdmi_spec { ...@@ -167,6 +167,7 @@ struct hdmi_spec {
struct hdmi_ops ops; struct hdmi_ops ops;
bool dyn_pin_out; bool dyn_pin_out;
bool static_pcm_mapping;
/* hdmi interrupt trigger control flag for Nvidia codec */ /* hdmi interrupt trigger control flag for Nvidia codec */
bool hdmi_intr_trig_ctrl; bool hdmi_intr_trig_ctrl;
bool nv_dp_workaround; /* workaround DP audio infoframe for Nvidia */ bool nv_dp_workaround; /* workaround DP audio infoframe for Nvidia */
...@@ -1525,13 +1526,16 @@ static void update_eld(struct hda_codec *codec, ...@@ -1525,13 +1526,16 @@ static void update_eld(struct hda_codec *codec,
*/ */
pcm_jack = pin_idx_to_pcm_jack(codec, per_pin); pcm_jack = pin_idx_to_pcm_jack(codec, per_pin);
if (eld->eld_valid) { if (!spec->static_pcm_mapping) {
hdmi_attach_hda_pcm(spec, per_pin); if (eld->eld_valid) {
hdmi_pcm_setup_pin(spec, per_pin); hdmi_attach_hda_pcm(spec, per_pin);
} else { hdmi_pcm_setup_pin(spec, per_pin);
hdmi_pcm_reset_pin(spec, per_pin); } else {
hdmi_detach_hda_pcm(spec, per_pin); hdmi_pcm_reset_pin(spec, per_pin);
hdmi_detach_hda_pcm(spec, per_pin);
}
} }
/* if pcm_idx == -1, it means this is in monitor connection event /* if pcm_idx == -1, it means this is in monitor connection event
* we can get the correct pcm_idx now. * we can get the correct pcm_idx now.
*/ */
...@@ -2281,8 +2285,8 @@ static int generic_hdmi_build_pcms(struct hda_codec *codec) ...@@ -2281,8 +2285,8 @@ static int generic_hdmi_build_pcms(struct hda_codec *codec)
struct hdmi_spec *spec = codec->spec; struct hdmi_spec *spec = codec->spec;
int idx, pcm_num; int idx, pcm_num;
/* limit the PCM devices to the codec converters */ /* limit the PCM devices to the codec converters or available PINs */
pcm_num = spec->num_cvts; pcm_num = min(spec->num_cvts, spec->num_pins);
codec_dbg(codec, "hdmi: pcm_num set to %d\n", pcm_num); codec_dbg(codec, "hdmi: pcm_num set to %d\n", pcm_num);
for (idx = 0; idx < pcm_num; idx++) { for (idx = 0; idx < pcm_num; idx++) {
...@@ -2379,6 +2383,11 @@ static int generic_hdmi_build_controls(struct hda_codec *codec) ...@@ -2379,6 +2383,11 @@ static int generic_hdmi_build_controls(struct hda_codec *codec)
struct hdmi_spec_per_pin *per_pin = get_pin(spec, pin_idx); struct hdmi_spec_per_pin *per_pin = get_pin(spec, pin_idx);
struct hdmi_eld *pin_eld = &per_pin->sink_eld; struct hdmi_eld *pin_eld = &per_pin->sink_eld;
if (spec->static_pcm_mapping) {
hdmi_attach_hda_pcm(spec, per_pin);
hdmi_pcm_setup_pin(spec, per_pin);
}
pin_eld->eld_valid = false; pin_eld->eld_valid = false;
hdmi_present_sense(per_pin, 0); hdmi_present_sense(per_pin, 0);
} }
...@@ -4419,6 +4428,8 @@ static int patch_atihdmi(struct hda_codec *codec) ...@@ -4419,6 +4428,8 @@ static int patch_atihdmi(struct hda_codec *codec)
spec = codec->spec; spec = codec->spec;
spec->static_pcm_mapping = true;
spec->ops.pin_get_eld = atihdmi_pin_get_eld; spec->ops.pin_get_eld = atihdmi_pin_get_eld;
spec->ops.pin_setup_infoframe = atihdmi_pin_setup_infoframe; spec->ops.pin_setup_infoframe = atihdmi_pin_setup_infoframe;
spec->ops.pin_hbr_setup = atihdmi_pin_hbr_setup; spec->ops.pin_hbr_setup = atihdmi_pin_hbr_setup;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment