From: Anssi Hannula <anssi.hannula@iki.fi>
To: Takashi Iwai <tiwai@suse.de>
Cc: alsa-devel@alsa-project.org
Subject: [PATCH 2/7] ALSA: hda - hdmi: Fix incorrect default channel mapping for unusual CAs
Date: Sat, 5 Oct 2013 02:25:39 +0300 [thread overview]
Message-ID: <1380929144-24944-3-git-send-email-anssi.hannula@iki.fi> (raw)
In-Reply-To: <1380929144-24944-1-git-send-email-anssi.hannula@iki.fi>
hdmi_std_setup_channel_mapping() selects a Channel Allocation according
to the sink reported speaker mask, preferring the ALSA standard layouts.
If the channel allocation is not one of the ALSA standard layouts, the
ALSA channels are mapped directly to HDMI channels in order. However,
the function does not take into account that there a holes in the HDMI
channel map.
Additionally, the function tries to disable a slot by using
AC_VERB_SET_CHAN_SLOT with parameter ((alsa_ch << 8) | 0xf), while the
correct parameter is ((0xf << 8) | hdmi_slot), i.e. the slot should be
unassigned, not the ALSA channel.
Fix both of the issues for non-ALSA-default layouts.
Tested on Intel HDMI with a speaker mask of FL | FR | FC | RC, which
causes CA 0x06 to be selected for 4-channel audio, which causes
incorrect output (sound destined to RC goes to FC and FC goes nowhere)
without the patch.
Signed-off-by: Anssi Hannula <anssi.hannula@iki.fi>
---
sound/pci/hda/patch_hdmi.c | 20 +++++++++++++++-----
1 file changed, 15 insertions(+), 5 deletions(-)
diff --git a/sound/pci/hda/patch_hdmi.c b/sound/pci/hda/patch_hdmi.c
index 6ed34df..5244802 100644
--- a/sound/pci/hda/patch_hdmi.c
+++ b/sound/pci/hda/patch_hdmi.c
@@ -597,22 +597,32 @@ static void hdmi_std_setup_channel_mapping(struct hda_codec *codec,
bool non_pcm,
int ca)
{
+ struct cea_channel_speaker_allocation *ch_alloc;
int i;
int err;
int order;
int non_pcm_mapping[8];
order = get_channel_allocation_order(ca);
+ ch_alloc = &channel_allocations[order];
if (hdmi_channel_mapping[ca][1] == 0) {
- for (i = 0; i < channel_allocations[order].channels; i++)
- hdmi_channel_mapping[ca][i] = i | (i << 4);
- for (; i < 8; i++)
- hdmi_channel_mapping[ca][i] = 0xf | (i << 4);
+ int hdmi_slot = 0;
+ /* fill actual channel mappings in ALSA channel (i) order */
+ for (i = 0; i < ch_alloc->channels; i++) {
+ while (!ch_alloc->speakers[7 - hdmi_slot] && !WARN_ON(hdmi_slot >= 8))
+ hdmi_slot++; /* skip zero slots */
+
+ hdmi_channel_mapping[ca][i] = (i << 4) | hdmi_slot++;
+ }
+ /* fill the rest of the slots with ALSA channel 0xf */
+ for (hdmi_slot = 0; hdmi_slot < 8; hdmi_slot++)
+ if (!ch_alloc->speakers[7 - hdmi_slot])
+ hdmi_channel_mapping[ca][i++] = (0xf << 4) | hdmi_slot;
}
if (non_pcm) {
- for (i = 0; i < channel_allocations[order].channels; i++)
+ for (i = 0; i < ch_alloc->channels; i++)
non_pcm_mapping[i] = i | (i << 4);
for (; i < 8; i++)
non_pcm_mapping[i] = 0xf | (i << 4);
--
1.8.1.5
next prev parent reply other threads:[~2013-10-04 23:26 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-04 23:25 [PATCH 0/7] ALSA: hda - hdmi: Various channel mapping fixes Anssi Hannula
2013-10-04 23:25 ` [PATCH 1/7] ALSA: hda - hdmi: Fix reported channel map on common default layouts Anssi Hannula
2013-10-04 23:25 ` Anssi Hannula [this message]
2013-10-04 23:25 ` [PATCH 3/7] ALSA: hda - hdmi: Fix programmed active channel count Anssi Hannula
2013-10-04 23:25 ` [PATCH 4/7] ALSA: hda - hdmi: Fix unused slots being enabled in manual and non-PCM mappings Anssi Hannula
2013-10-04 23:25 ` [PATCH 5/7] ALSA: hda - hdmi: Fix channel maps with less common speakers Anssi Hannula
2013-10-04 23:25 ` [PATCH 6/7] ALSA: hda - hdmi: Fix available channel maps missing from TLV Anssi Hannula
2013-10-04 23:25 ` [PATCH 7/7] ALSA: hda - hdmi: Tweak debug messages to be more useful Anssi Hannula
2013-10-07 10:50 ` [PATCH 0/7] ALSA: hda - hdmi: Various channel mapping fixes Takashi Iwai
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1380929144-24944-3-git-send-email-anssi.hannula@iki.fi \
--to=anssi.hannula@iki.fi \
--cc=alsa-devel@alsa-project.org \
--cc=tiwai@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).