Skip to content

Commit 4e08713

Browse files
HiassofTtiwai
authored andcommitted
ASoC: hdmi-codec: fix channel info for compressed formats
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 <hias@horus.com> Link: https://lore.kernel.org/r/20230624165232.5751-1-hias@horus.com Signed-off-by: Takashi Iwai <tiwai@suse.de>
1 parent 04b49b9 commit 4e08713

1 file changed

Lines changed: 24 additions & 12 deletions

File tree

sound/soc/codecs/hdmi-codec.c

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -495,31 +495,43 @@ static int hdmi_codec_fill_codec_params(struct snd_soc_dai *dai,
495495
struct hdmi_codec_params *hp)
496496
{
497497
struct hdmi_codec_priv *hcp = snd_soc_dai_get_drvdata(dai);
498-
int idx;
499-
500-
/* Select a channel allocation that matches with ELD and pcm channels */
501-
idx = hdmi_codec_get_ch_alloc_table_idx(hcp, channels);
502-
if (idx < 0) {
503-
dev_err(dai->dev, "Not able to map channels to speakers (%d)\n",
504-
idx);
505-
hcp->chmap_idx = HDMI_CODEC_CHMAP_IDX_UNKNOWN;
506-
return idx;
498+
int idx = HDMI_CODEC_CHMAP_IDX_UNKNOWN;
499+
u8 ca_id = 0;
500+
bool pcm_audio = !(hcp->iec_status[0] & IEC958_AES0_NONAUDIO);
501+
502+
if (pcm_audio) {
503+
/* Select a channel allocation that matches with ELD and pcm channels */
504+
idx = hdmi_codec_get_ch_alloc_table_idx(hcp, channels);
505+
506+
if (idx < 0) {
507+
dev_err(dai->dev, "Not able to map channels to speakers (%d)\n",
508+
idx);
509+
hcp->chmap_idx = HDMI_CODEC_CHMAP_IDX_UNKNOWN;
510+
return idx;
511+
}
512+
513+
ca_id = hdmi_codec_channel_alloc[idx].ca_id;
507514
}
508515

509516
memset(hp, 0, sizeof(*hp));
510517

511518
hdmi_audio_infoframe_init(&hp->cea);
512-
hp->cea.channels = channels;
519+
520+
if (pcm_audio)
521+
hp->cea.channels = channels;
522+
else
523+
hp->cea.channels = 0;
524+
513525
hp->cea.coding_type = HDMI_AUDIO_CODING_TYPE_STREAM;
514526
hp->cea.sample_size = HDMI_AUDIO_SAMPLE_SIZE_STREAM;
515527
hp->cea.sample_frequency = HDMI_AUDIO_SAMPLE_FREQUENCY_STREAM;
516-
hp->cea.channel_allocation = hdmi_codec_channel_alloc[idx].ca_id;
528+
hp->cea.channel_allocation = ca_id;
517529

518530
hp->sample_width = sample_width;
519531
hp->sample_rate = sample_rate;
520532
hp->channels = channels;
521533

522-
hcp->chmap_idx = hdmi_codec_channel_alloc[idx].ca_id;
534+
hcp->chmap_idx = idx;
523535

524536
return 0;
525537
}

0 commit comments

Comments
 (0)