]> Git Repo - linux.git/commitdiff
ASoC: hdmi-codec: fix channel info for compressed formats
authorMatthias Reichl <[email protected]>
Sat, 24 Jun 2023 16:52:32 +0000 (18:52 +0200)
committerTakashi Iwai <[email protected]>
Sun, 25 Jun 2023 06:42:57 +0000 (08:42 +0200)
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 <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Takashi Iwai <[email protected]>
sound/soc/codecs/hdmi-codec.c

index 6d980fbc4207780ccc966df8378f70cf554f4cd4..d21f69f0534228de38d98d923c33d4b0c3c3bd90 100644 (file)
@@ -495,31 +495,43 @@ static int hdmi_codec_fill_codec_params(struct snd_soc_dai *dai,
                                        struct hdmi_codec_params *hp)
 {
        struct hdmi_codec_priv *hcp = snd_soc_dai_get_drvdata(dai);
-       int idx;
-
-       /* Select a channel allocation that matches with ELD and pcm channels */
-       idx = 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 = HDMI_CODEC_CHMAP_IDX_UNKNOWN;
-               return idx;
+       int idx = HDMI_CODEC_CHMAP_IDX_UNKNOWN;
+       u8 ca_id = 0;
+       bool pcm_audio = !(hcp->iec_status[0] & IEC958_AES0_NONAUDIO);
+
+       if (pcm_audio) {
+               /* Select a channel allocation that matches with ELD and pcm channels */
+               idx = 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 = HDMI_CODEC_CHMAP_IDX_UNKNOWN;
+                       return idx;
+               }
+
+               ca_id = hdmi_codec_channel_alloc[idx].ca_id;
        }
 
        memset(hp, 0, sizeof(*hp));
 
        hdmi_audio_infoframe_init(&hp->cea);
-       hp->cea.channels = channels;
+
+       if (pcm_audio)
+               hp->cea.channels = channels;
+       else
+               hp->cea.channels = 0;
+
        hp->cea.coding_type = HDMI_AUDIO_CODING_TYPE_STREAM;
        hp->cea.sample_size = HDMI_AUDIO_SAMPLE_SIZE_STREAM;
        hp->cea.sample_frequency = HDMI_AUDIO_SAMPLE_FREQUENCY_STREAM;
-       hp->cea.channel_allocation = hdmi_codec_channel_alloc[idx].ca_id;
+       hp->cea.channel_allocation = ca_id;
 
        hp->sample_width = sample_width;
        hp->sample_rate = sample_rate;
        hp->channels = channels;
 
-       hcp->chmap_idx = hdmi_codec_channel_alloc[idx].ca_id;
+       hcp->chmap_idx = idx;
 
        return 0;
 }
This page took 0.057306 seconds and 4 git commands to generate.