* [PATCH] ASoC: hdmi-codec: fix channel info for compressed formats
@ 2023-06-24 16:52 Matthias Reichl
2023-06-25 8:34 ` Takashi Iwai
2023-06-29 10:33 ` Mark Brown
0 siblings, 2 replies; 5+ messages in thread
From: Matthias Reichl @ 2023-06-24 16:52 UTC (permalink / raw)
To: Liam Girdwood, Mark Brown, Jaroslav Kysela, Takashi Iwai
Cc: Matthias Reichl, Dom Cobley, alsa-devel, linux-kernel
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>
---
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_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;
}
--
2.39.2
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH] ASoC: hdmi-codec: fix channel info for compressed formats
2023-06-24 16:52 [PATCH] ASoC: hdmi-codec: fix channel info for compressed formats Matthias Reichl
@ 2023-06-25 8:34 ` Takashi Iwai
2023-06-29 10:33 ` Mark Brown
1 sibling, 0 replies; 5+ messages in thread
From: Takashi Iwai @ 2023-06-25 8:34 UTC (permalink / raw)
To: Matthias Reichl
Cc: Liam Girdwood, Mark Brown, Jaroslav Kysela, Takashi Iwai,
Dom Cobley, alsa-devel, linux-kernel
On Sat, 24 Jun 2023 18:52:32 +0200,
Matthias Reichl wrote:
>
> 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>
Thanks, applied now.
Takashi
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] ASoC: hdmi-codec: fix channel info for compressed formats
2023-06-24 16:52 [PATCH] ASoC: hdmi-codec: fix channel info for compressed formats Matthias Reichl
2023-06-25 8:34 ` Takashi Iwai
@ 2023-06-29 10:33 ` Mark Brown
2023-06-29 10:44 ` Takashi Iwai
1 sibling, 1 reply; 5+ messages in thread
From: Mark Brown @ 2023-06-29 10:33 UTC (permalink / raw)
To: Liam Girdwood, Jaroslav Kysela, Takashi Iwai, Matthias Reichl
Cc: Dom Cobley, alsa-devel, linux-kernel
On Sat, 24 Jun 2023 18:52:32 +0200, Matthias Reichl wrote:
> 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.
>
> [...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
Thanks!
[1/1] ASoC: hdmi-codec: fix channel info for compressed formats
commit: 7b5162080174ae50e8288574379d339b0fcd1760
All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying
to this mail.
Thanks,
Mark
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH] ASoC: hdmi-codec: fix channel info for compressed formats
2023-06-29 10:33 ` Mark Brown
@ 2023-06-29 10:44 ` Takashi Iwai
2023-06-29 10:53 ` Mark Brown
0 siblings, 1 reply; 5+ messages in thread
From: Takashi Iwai @ 2023-06-29 10:44 UTC (permalink / raw)
To: Mark Brown
Cc: Liam Girdwood, Jaroslav Kysela, Takashi Iwai, Matthias Reichl,
Dom Cobley, alsa-devel, linux-kernel
On Thu, 29 Jun 2023 12:33:33 +0200,
Mark Brown wrote:
>
> On Sat, 24 Jun 2023 18:52:32 +0200, Matthias Reichl wrote:
> > 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.
> >
> > [...]
>
> Applied to
>
> https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
Oh, I already applied this one together with another fix for HDMI,
and it's in the ongoing PR to Linus. I didn't notice that it was
ASoC-only. Sorry for confusion!
Takashi
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] ASoC: hdmi-codec: fix channel info for compressed formats
2023-06-29 10:44 ` Takashi Iwai
@ 2023-06-29 10:53 ` Mark Brown
0 siblings, 0 replies; 5+ messages in thread
From: Mark Brown @ 2023-06-29 10:53 UTC (permalink / raw)
To: Takashi Iwai
Cc: Liam Girdwood, Jaroslav Kysela, Takashi Iwai, Matthias Reichl,
Dom Cobley, alsa-devel, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 520 bytes --]
On Thu, Jun 29, 2023 at 12:44:31PM +0200, Takashi Iwai wrote:
> Mark Brown wrote:
> > Applied to
> > https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
> Oh, I already applied this one together with another fix for HDMI,
> and it's in the ongoing PR to Linus. I didn't notice that it was
> ASoC-only. Sorry for confusion!
No worries, two copies won't hurt anything. I think it was already
running through my CI by the time you applied it and didn't seem worth
it to restart everything.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-06-29 10:54 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-24 16:52 [PATCH] ASoC: hdmi-codec: fix channel info for compressed formats Matthias Reichl
2023-06-25 8:34 ` Takashi Iwai
2023-06-29 10:33 ` Mark Brown
2023-06-29 10:44 ` Takashi Iwai
2023-06-29 10:53 ` Mark Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox