From nobody Sun Feb 8 06:21:47 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 010C9EB64DA for ; Sat, 24 Jun 2023 17:00:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233175AbjFXRAQ (ORCPT ); Sat, 24 Jun 2023 13:00:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34230 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229565AbjFXRAJ (ORCPT ); Sat, 24 Jun 2023 13:00:09 -0400 X-Greylist: delayed 458 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Sat, 24 Jun 2023 10:00:07 PDT Received: from mail.horus.com (mail.horus.com [78.46.148.228]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A62B6B8 for ; Sat, 24 Jun 2023 10:00:07 -0700 (PDT) Received: from [192.168.1.22] (193-81-115-8.adsl.highway.telekom.at [193.81.115.8]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits)) (Client did not present a certificate) by mail.horus.com (Postfix) with ESMTPSA id 5C0CE640B9; Sat, 24 Jun 2023 18:52:36 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=horus.com; s=20180324; t=1687625556; bh=WtkqfvRALn1bU+9oyk67tSfwogR+x0hk//0QW6Ye3lc=; h=From:To:Cc:Subject:Date:From; b=CyKtLNmVn7OgpUcXinRA7sKPvKmk80wk/j+yYdnysvYVXysd8qyPplADzEdgU2Qse nv91Xo/rWj5dACyq9YH/flA6/cyG9e8tbiHaIZon8SkpYBuKsMVZsIEO+EyV8Nqxdc Fu2jTJcRkZgXkmkzktgx25ELQ9r9RPWZbwTcYft8= Received: by camel3.lan (Postfix, from userid 1000) id 047F8540544; Sat, 24 Jun 2023 18:52:35 +0200 (CEST) From: Matthias Reichl To: Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai Cc: Matthias Reichl , Dom Cobley , alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org Subject: [PATCH] ASoC: hdmi-codec: fix channel info for compressed formats Date: Sat, 24 Jun 2023 18:52:32 +0200 Message-Id: <20230624165232.5751-1-hias@horus.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" According to CTA 861 the channel/speaker allocation info in the audio infoframe only applies to uncompressed (PCM) audio streams. The channel count info should indicate the number of channels in the transmitted audio, which usually won't match the number of channels used to transmit the compressed bitstream. Some devices (eg some Sony TVs) will refuse to decode compressed audio if these values are not set correctly. To fix this we can simply set the channel count to 0 (which means "refer to stream header") and set the channel/speaker allocation to 0 as well (which would mean stereo FL/FR for PCM, a safe value all sinks will support) when transmitting compressed audio. Signed-off-by: Matthias Reichl --- sound/soc/codecs/hdmi-codec.c | 36 +++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/sound/soc/codecs/hdmi-codec.c b/sound/soc/codecs/hdmi-codec.c index 6d980fbc42077..d21f69f053422 100644 --- a/sound/soc/codecs/hdmi-codec.c +++ b/sound/soc/codecs/hdmi-codec.c @@ -495,31 +495,43 @@ static int hdmi_codec_fill_codec_params(struct snd_so= c_dai *dai, struct hdmi_codec_params *hp) { struct hdmi_codec_priv *hcp =3D snd_soc_dai_get_drvdata(dai); - int idx; - - /* Select a channel allocation that matches with ELD and pcm channels */ - idx =3D hdmi_codec_get_ch_alloc_table_idx(hcp, channels); - if (idx < 0) { - dev_err(dai->dev, "Not able to map channels to speakers (%d)\n", - idx); - hcp->chmap_idx =3D HDMI_CODEC_CHMAP_IDX_UNKNOWN; - return idx; + int idx =3D HDMI_CODEC_CHMAP_IDX_UNKNOWN; + u8 ca_id =3D 0; + bool pcm_audio =3D !(hcp->iec_status[0] & IEC958_AES0_NONAUDIO); + + if (pcm_audio) { + /* Select a channel allocation that matches with ELD and pcm channels */ + idx =3D hdmi_codec_get_ch_alloc_table_idx(hcp, channels); + + if (idx < 0) { + dev_err(dai->dev, "Not able to map channels to speakers (%d)\n", + idx); + hcp->chmap_idx =3D HDMI_CODEC_CHMAP_IDX_UNKNOWN; + return idx; + } + + ca_id =3D hdmi_codec_channel_alloc[idx].ca_id; } =20 memset(hp, 0, sizeof(*hp)); =20 hdmi_audio_infoframe_init(&hp->cea); - hp->cea.channels =3D channels; + + if (pcm_audio) + hp->cea.channels =3D channels; + else + hp->cea.channels =3D 0; + hp->cea.coding_type =3D HDMI_AUDIO_CODING_TYPE_STREAM; hp->cea.sample_size =3D HDMI_AUDIO_SAMPLE_SIZE_STREAM; hp->cea.sample_frequency =3D HDMI_AUDIO_SAMPLE_FREQUENCY_STREAM; - hp->cea.channel_allocation =3D hdmi_codec_channel_alloc[idx].ca_id; + hp->cea.channel_allocation =3D ca_id; =20 hp->sample_width =3D sample_width; hp->sample_rate =3D sample_rate; hp->channels =3D channels; =20 - hcp->chmap_idx =3D hdmi_codec_channel_alloc[idx].ca_id; + hcp->chmap_idx =3D idx; =20 return 0; } --=20 2.39.2