Archive:Remap HDMI audio on Gen 1 ION - Linux

From Official Kodi Wiki
Revision as of 21:40, 5 January 2013 by >UNiversal (→‎Configure XBMC)
Jump to navigation Jump to search

Some early Nvidia ION based motherboards have their HDMI audio channels mapped incorrectly. There are two relatively simple methods to remap HDMI audio on Nvidia ION-based systems. Which one you use depends on your setup. If you require passthrough, disabling Pulseaudio (if your distribution uses it by default) is necessary to configure ALSA to remap the channels. Configuring Pulseaudio to remap the channels is another option if you don't require passthrough.

It should be noted, that whenever editing config files it's best to backup the original.

Remapping Surround Channels (ALSA)

The following steps require the removal of Pulseaudio if your distribution uses it by default.

HDMI audio output requires several steps to configure properly. My requirements were passthrough, non-passthrough and menu sounds all coming over HDMI to my receiver (fairly common). Some challenges were that the Gen 1 ION had incorrect channel mappings (e.g. Center came out of Left Rear) and menu sounds do not default to HDMI.

I first noticed the audio channels were mis-mapped while watching a movie - all the voices were coming out of the left rear channel, not center. To verify this, I ran the following command:

speaker-test -D hdmi -c 6

To correct the output, I created the following channel mapping in ~/.asoundrc or /etc/asound.conf(.asoundrc overrides the default alsa settings per user, while /etc/asound.conf is a global settings override)

For 7.1: Eden

Untested in Frodo.

pcm.hdmi-remap {
       type route
       slave.pcm hdmi
       ttable.0.0 1
       ttable.1.1 1
       ttable.2.4 1
       ttable.3.5 1
       ttable.4.2 1
       ttable.5.3 1
       ttable.6.6 1 
       ttable.7.7 1 
}
Note: There is intentionally no slave.channels line in the configuration file since it seems to corrupt the digital stream and prevented proper DTS and DD passthrough to my receiver. If you hear static when using passthrough, this might be the reason why!
To test our new configuration, we can run
speaker-test -D hdmi-remap -c 6

Hopefully the channels will now be mapped correctly.

For 5.1: Frodo

pcm.!default {
    type plug
    slave {
        pcm both
    }
}

pcm.both {
    type route
    slave {
        pcm hdmi
    }
       ttable.0.0 1
       ttable.1.1 1
       ttable.2.4 1
       ttable.3.5 1
       ttable.4.2 1
       ttable.5.3 1
}
To test our new configuration, we can run
speaker-test -D hdmi -c 6

Menu Sounds

Note: Not needed in Frodo.

To configure menu sounds, I told alsa to use the hdmi-remap device as default. I did this by adding the following section to my ~/.asoundrc file:

pcm.!default {
	type plug
	slave.pcm hdmi-remap
}

XBMC Eden Audio Configuration

Within Settings -> System -> Audio Output, I set the following values:

  • Audio Output : HDMI
  • Speaker Configuration : 7.1
  • Boost volume level on downmix : No
  • Dolby Digital (AC3) capable receiver : Yes
  • DTS capable receiver : Yes
  • Audio output device : Custom
  • Custom audio device : hdmi-remap
  • Passthrough output device : hdmi(ALSA)

XBMC Frodo Audio Configuration

Within Settings -> System -> Audio Output, I set the following values:

  • Audio Output : HDMI
  • Speaker Configuration : 5.1
  • Boost volume level on downmix : No
  • Dolby Digital (AC3) capable receiver : Yes
  • DTS capable receiver : Yes
  • Audio output device : HDA NVidia HDMI 0
  • Passthrough output device : HDA NVidia HDMI 0

After a reboot, sound should be working as expected. Feel free to update this information as needed.

Attention talk.png Linux Frodo HDMI audio channel remap discussion

Remapping Surround Channels (Pulseaudio)

Some may find that removing Pulseaudio breaks other programs and causes problems. If your setup does not require passthrough and your receiver supports multichannel PCM, you may want to configure Pulseaudio instead. These directions were adapted from here.

Configure Pulseaudio

1. Run from the command-line:

speaker-test -c6 -twav

2. Note which channels need to be remapped, I just wrote them down like so:

  SOUND                      SPEAKER
Left Front          ————-> Left Front
Center Front        ————-> Left Rear
Right Front         ————-> Right Front
Left Rear           ————-> Center Front
Subwoofer (lfe)     ————-> Right Rear
Right Rear          ————-> Subwoofer (lfe)

3. Edit "/usr/share/pulseaudio/alsa-mixer/profile-sets/extra-hdmi.conf" with your favorite text editor as root. I'm using xubuntu 12.04, so I'll be using leafpad:

sudo leafpad /usr/share/pulseaudio/alsa-mixer/profile-sets/extra-hdmi.conf

4. This file contains the Pulseaudio profiles for your HDMI audio outputs. There should be a few entries that say something about 5.1 or 7.1 audio over HDMI. Like this:

[Mapping hdmi-surround]
description = Digital Surround 5.1 (HDMI)
device-strings = hdmi:%f
paths-output = hdmi-output-0
channel-map = front-left,front-right,rear-left,rear-right,front-center,lfe
priority = 3
direction = output

Edit them to fit your needs based on the channel map you wrote down earlier. I edited all of them (except the 7.1 ones, as I only have a 5.1 setup, I would assume things would be similar for 7.1) like so:

[Mapping hdmi-surround]
description = Digital Surround 5.1 (HDMI)
device-strings = hdmi:%f
paths-output = hdmi-output-0
channel-map = front-left,front-right,front-center,lfe,rear-left,rear-right
priority = 3
direction = output

5. Restart Pulseaudio to load your new channel maps and run a speaker test:

pulseaudio -k
pulseaudio --start
speaker-test -c6 -twav

If everything is coming out of the right channel then you're all set!

Configure XBMC

Within Settings -> System -> Audio Output, set:

  • Audio Output : HDMI
  • Speaker Configuration : 5.1 (or 7.1 depeding on your setup)
  • Boost volume level on downmix : Yes
  • Dolby Digital (AC3) capable receiver : No
  • DTS capable receiver : No
  • Audio output device : defaults(Pulseaudio)
  • Passthrough output device : hdmi(ALSA) (won't be used, you can set it to whatever you'd like)

Note: Pulseaudio and XBMC do not work with passthrough as of Eden (not tested in Frodo, but likely the same). That is why we are telling XBMC the receiver can't decode AC3 and DTS. Theoretically speaking, there is no difference between decoding in software or on your receiver. Some may disagree, however the receiver tells me that it is indeed receiving 5.1 multichannel PCM. Sounds seem to be mapped correctly. Tested with XBMCubuntu 12.04, XBMC Eden, on an ASRock ION330 motherboard

Attention talk.png Linux: Remapping Pulseaudio Channels