Skip to content

Commit 3f38871

Browse files
HiassofTpelwell
authored andcommitted
ASoC: hdmi-codec: fix channel info for compressed formats
commit 4e08713 upstream. 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]>
1 parent e866f9f commit 3f38871

File tree

1 file changed

+24
-12
lines changed

1 file changed

+24
-12
lines changed

sound/soc/codecs/hdmi-codec.c

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -484,31 +484,43 @@ static int hdmi_codec_fill_codec_params(struct snd_soc_dai *dai,
484484
struct hdmi_codec_params *hp)
485485
{
486486
struct hdmi_codec_priv *hcp = snd_soc_dai_get_drvdata(dai);
487-
int idx;
488-
489-
/* Select a channel allocation that matches with ELD and pcm channels */
490-
idx = hdmi_codec_get_ch_alloc_table_idx(hcp, channels);
491-
if (idx < 0) {
492-
dev_err(dai->dev, "Not able to map channels to speakers (%d)\n",
493-
idx);
494-
hcp->chmap_idx = HDMI_CODEC_CHMAP_IDX_UNKNOWN;
495-
return idx;
487+
int idx = HDMI_CODEC_CHMAP_IDX_UNKNOWN;
488+
u8 ca_id = 0;
489+
bool pcm_audio = !(hcp->iec_status[0] & IEC958_AES0_NONAUDIO);
490+
491+
if (pcm_audio) {
492+
/* Select a channel allocation that matches with ELD and pcm channels */
493+
idx = hdmi_codec_get_ch_alloc_table_idx(hcp, channels);
494+
495+
if (idx < 0) {
496+
dev_err(dai->dev, "Not able to map channels to speakers (%d)\n",
497+
idx);
498+
hcp->chmap_idx = HDMI_CODEC_CHMAP_IDX_UNKNOWN;
499+
return idx;
500+
}
501+
502+
ca_id = hdmi_codec_channel_alloc[idx].ca_id;
496503
}
497504

498505
memset(hp, 0, sizeof(*hp));
499506

500507
hdmi_audio_infoframe_init(&hp->cea);
501-
hp->cea.channels = channels;
508+
509+
if (pcm_audio)
510+
hp->cea.channels = channels;
511+
else
512+
hp->cea.channels = 0;
513+
502514
hp->cea.coding_type = HDMI_AUDIO_CODING_TYPE_STREAM;
503515
hp->cea.sample_size = HDMI_AUDIO_SAMPLE_SIZE_STREAM;
504516
hp->cea.sample_frequency = HDMI_AUDIO_SAMPLE_FREQUENCY_STREAM;
505-
hp->cea.channel_allocation = hdmi_codec_channel_alloc[idx].ca_id;
517+
hp->cea.channel_allocation = ca_id;
506518

507519
hp->sample_width = sample_width;
508520
hp->sample_rate = sample_rate;
509521
hp->channels = channels;
510522

511-
hcp->chmap_idx = hdmi_codec_channel_alloc[idx].ca_id;
523+
hcp->chmap_idx = idx;
512524

513525
return 0;
514526
}

0 commit comments

Comments
 (0)