From 0a10908da079a5c9a8283fed487848da4fd454af Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Fri, 19 Dec 2025 11:58:26 +0200 Subject: [PATCH] alsa: Disable use-chmap for HDMI PCMs on SOF cards The HDMI PCM devices should use the default ACP method on SOF cards to handle the channel mapping as it depends on the connected connected equipment and UCM cannot provide correct information. If surround 5.1 and 7.1 is enabled for SOF HDMI cards then if the use-chmap is true, the position of the speakers are all shuffled: Using the UI's speaker test this is how the channels ended up (5.1): SW button -> physical speaker -------------------------------- Front left -> Front left Front center -> Rear right Front right -> Front right Rear left -> Front center Subwoofer -> Rear left Rear right -> Subwoofer Setting the use-chmap via config makes the LPCM speaker plaement correct for SOF cards. Link: https://github.com/thesofproject/linux/issues/5627 Link: https://github.com/alsa-project/alsa-ucm-conf/pull/633 Signed-off-by: Peter Ujfalusi --- spa/plugins/alsa/alsa-pcm.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/spa/plugins/alsa/alsa-pcm.c b/spa/plugins/alsa/alsa-pcm.c index af11848a7..6ecf4a0b6 100644 --- a/spa/plugins/alsa/alsa-pcm.c +++ b/spa/plugins/alsa/alsa-pcm.c @@ -973,13 +973,6 @@ int spa_alsa_init(struct state *state, const struct spa_dict *info) if (info && (str = spa_dict_lookup(info, "device.profile.pro")) != NULL) state->is_pro = spa_atob(str); - if (info && spa_strstartswith(spa_dict_lookup(info, SPA_KEY_API_ALSA_CARD_NAME), "sof-") && - state->stream == SND_PCM_STREAM_PLAYBACK) { - state->use_period_size_min_as_headroom = true; - spa_log_info(state->log, - "ALSA SOF driver detected: default api.alsa.use-period-size-min-as-headroom=true"); - } - state->multi_rate = true; state->htimestamp = false; state->htimestamp_max_errors = MAX_HTIMESTAMP_ERROR; @@ -1045,6 +1038,19 @@ int spa_alsa_init(struct state *state, const struct spa_dict *info) state->iec958_codecs |= 1ULL << SPA_AUDIO_IEC958_CODEC_PCM; } + if (info && spa_strstartswith(spa_dict_lookup(info, SPA_KEY_API_ALSA_CARD_NAME), "sof-") && + state->stream == SND_PCM_STREAM_PLAYBACK) { + state->use_period_size_min_as_headroom = true; + spa_log_info(state->log, + "ALSA SOF driver detected: default api.alsa.use-period-size-min-as-headroom=true"); + + if (info && spa_strstartswith(spa_dict_lookup(info, "alsa.id"), "HDMI")) { + state->props.use_chmap = false; + spa_log_info(state->log, "Disable use-chmap by default for SOF %s", + spa_dict_lookup(info, "alsa.id")); + } + } + state->card = ensure_card(state->card_index, state->open_ucm, state->is_split_parent); state->log_file = fopencookie(state, "w", io_funcs);